11h.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Marvell Wireless LAN device driver: 802.11h
  3. *
  4. * Copyright (C) 2013, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #include "main.h"
  20. #include "fw.h"
  21. /* This function appends 11h info to a buffer while joining an
  22. * infrastructure BSS
  23. */
  24. static void
  25. mwifiex_11h_process_infra_join(struct mwifiex_private *priv, u8 **buffer,
  26. struct mwifiex_bssdescriptor *bss_desc)
  27. {
  28. struct mwifiex_ie_types_header *ie_header;
  29. struct mwifiex_ie_types_pwr_capability *cap;
  30. struct mwifiex_ie_types_local_pwr_constraint *constraint;
  31. struct ieee80211_supported_band *sband;
  32. u8 radio_type;
  33. int i;
  34. if (!buffer || !(*buffer))
  35. return;
  36. radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band);
  37. sband = priv->wdev->wiphy->bands[radio_type];
  38. cap = (struct mwifiex_ie_types_pwr_capability *)*buffer;
  39. cap->header.type = cpu_to_le16(WLAN_EID_PWR_CAPABILITY);
  40. cap->header.len = cpu_to_le16(2);
  41. cap->min_pwr = 0;
  42. cap->max_pwr = 0;
  43. *buffer += sizeof(*cap);
  44. constraint = (struct mwifiex_ie_types_local_pwr_constraint *)*buffer;
  45. constraint->header.type = cpu_to_le16(WLAN_EID_PWR_CONSTRAINT);
  46. constraint->header.len = cpu_to_le16(2);
  47. constraint->chan = bss_desc->channel;
  48. constraint->constraint = bss_desc->local_constraint;
  49. *buffer += sizeof(*constraint);
  50. ie_header = (struct mwifiex_ie_types_header *)*buffer;
  51. ie_header->type = cpu_to_le16(TLV_TYPE_PASSTHROUGH);
  52. ie_header->len = cpu_to_le16(2 * sband->n_channels + 2);
  53. *buffer += sizeof(*ie_header);
  54. *(*buffer)++ = WLAN_EID_SUPPORTED_CHANNELS;
  55. *(*buffer)++ = 2 * sband->n_channels;
  56. for (i = 0; i < sband->n_channels; i++) {
  57. *(*buffer)++ = ieee80211_frequency_to_channel(
  58. sband->channels[i].center_freq);
  59. *(*buffer)++ = 1; /* one channel in the subband */
  60. }
  61. }
  62. /* Enable or disable the 11h extensions in the firmware */
  63. static int mwifiex_11h_activate(struct mwifiex_private *priv, bool flag)
  64. {
  65. u32 enable = flag;
  66. return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
  67. HostCmd_ACT_GEN_SET, DOT11H_I, &enable);
  68. }
  69. /* This functions processes TLV buffer for a pending BSS Join command.
  70. *
  71. * Activate 11h functionality in the firmware if the spectrum management
  72. * capability bit is found in the network we are joining. Also, necessary
  73. * TLVs are set based on requested network's 11h capability.
  74. */
  75. void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
  76. struct mwifiex_bssdescriptor *bss_desc)
  77. {
  78. if (bss_desc->sensed_11h) {
  79. /* Activate 11h functions in firmware, turns on capability
  80. * bit
  81. */
  82. mwifiex_11h_activate(priv, true);
  83. bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_SPECTRUM_MGMT;
  84. mwifiex_11h_process_infra_join(priv, buffer, bss_desc);
  85. } else {
  86. /* Deactivate 11h functions in the firmware */
  87. mwifiex_11h_activate(priv, false);
  88. bss_desc->cap_info_bitmap &= ~WLAN_CAPABILITY_SPECTRUM_MGMT;
  89. }
  90. }