Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: 802.11h |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2013-2014, Marvell International Ltd. |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 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 | |
| 20 | #include "main.h" |
| 21 | #include "fw.h" |
| 22 | |
| 23 | |
| 24 | /* This function appends 11h info to a buffer while joining an |
| 25 | * infrastructure BSS |
| 26 | */ |
| 27 | static void |
| 28 | mwifiex_11h_process_infra_join(struct mwifiex_private *priv, u8 **buffer, |
| 29 | struct mwifiex_bssdescriptor *bss_desc) |
| 30 | { |
| 31 | struct mwifiex_ie_types_header *ie_header; |
| 32 | struct mwifiex_ie_types_pwr_capability *cap; |
| 33 | struct mwifiex_ie_types_local_pwr_constraint *constraint; |
| 34 | struct ieee80211_supported_band *sband; |
| 35 | u8 radio_type; |
| 36 | int i; |
| 37 | |
| 38 | if (!buffer || !(*buffer)) |
| 39 | return; |
| 40 | |
| 41 | radio_type = mwifiex_band_to_radio_type((u8) bss_desc->bss_band); |
| 42 | sband = priv->wdev->wiphy->bands[radio_type]; |
| 43 | |
| 44 | cap = (struct mwifiex_ie_types_pwr_capability *)*buffer; |
| 45 | cap->header.type = cpu_to_le16(WLAN_EID_PWR_CAPABILITY); |
| 46 | cap->header.len = cpu_to_le16(2); |
| 47 | cap->min_pwr = 0; |
| 48 | cap->max_pwr = 0; |
| 49 | *buffer += sizeof(*cap); |
| 50 | |
| 51 | constraint = (struct mwifiex_ie_types_local_pwr_constraint *)*buffer; |
| 52 | constraint->header.type = cpu_to_le16(WLAN_EID_PWR_CONSTRAINT); |
| 53 | constraint->header.len = cpu_to_le16(2); |
| 54 | constraint->chan = bss_desc->channel; |
| 55 | constraint->constraint = bss_desc->local_constraint; |
| 56 | *buffer += sizeof(*constraint); |
| 57 | |
| 58 | ie_header = (struct mwifiex_ie_types_header *)*buffer; |
| 59 | ie_header->type = cpu_to_le16(TLV_TYPE_PASSTHROUGH); |
| 60 | ie_header->len = cpu_to_le16(2 * sband->n_channels + 2); |
| 61 | *buffer += sizeof(*ie_header); |
| 62 | *(*buffer)++ = WLAN_EID_SUPPORTED_CHANNELS; |
| 63 | *(*buffer)++ = 2 * sband->n_channels; |
| 64 | for (i = 0; i < sband->n_channels; i++) { |
| 65 | *(*buffer)++ = ieee80211_frequency_to_channel( |
| 66 | sband->channels[i].center_freq); |
| 67 | *(*buffer)++ = 1; /* one channel in the subband */ |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /* Enable or disable the 11h extensions in the firmware */ |
| 72 | static int mwifiex_11h_activate(struct mwifiex_private *priv, bool flag) |
| 73 | { |
| 74 | u32 enable = flag; |
| 75 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 76 | return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB, |
| 77 | HostCmd_ACT_GEN_SET, DOT11H_I, &enable, true); |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /* This functions processes TLV buffer for a pending BSS Join command. |
| 81 | * |
| 82 | * Activate 11h functionality in the firmware if the spectrum management |
| 83 | * capability bit is found in the network we are joining. Also, necessary |
| 84 | * TLVs are set based on requested network's 11h capability. |
| 85 | */ |
| 86 | void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer, |
| 87 | struct mwifiex_bssdescriptor *bss_desc) |
| 88 | { |
| 89 | if (bss_desc->sensed_11h) { |
| 90 | /* Activate 11h functions in firmware, turns on capability |
| 91 | * bit |
| 92 | */ |
| 93 | mwifiex_11h_activate(priv, true); |
| 94 | bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_SPECTRUM_MGMT; |
| 95 | mwifiex_11h_process_infra_join(priv, buffer, bss_desc); |
| 96 | } else { |
| 97 | /* Deactivate 11h functions in the firmware */ |
| 98 | mwifiex_11h_activate(priv, false); |
| 99 | bss_desc->cap_info_bitmap &= ~WLAN_CAPABILITY_SPECTRUM_MGMT; |
| 100 | } |
| 101 | } |