Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: CFG80211 |
| 3 | * |
| 4 | * Copyright (C) 2011, 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 | |
| 20 | #include "cfg80211.h" |
| 21 | #include "main.h" |
| 22 | |
Avinash Patil | cd8440d | 2012-05-08 18:30:16 -0700 | [diff] [blame] | 23 | static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = { |
| 24 | { |
| 25 | .max = 1, .types = BIT(NL80211_IFTYPE_STATION), |
| 26 | }, |
| 27 | { |
| 28 | .max = 1, .types = BIT(NL80211_IFTYPE_AP), |
| 29 | }, |
| 30 | }; |
| 31 | |
| 32 | static const struct ieee80211_iface_combination mwifiex_iface_comb_ap_sta = { |
| 33 | .limits = mwifiex_ap_sta_limits, |
| 34 | .num_different_channels = 1, |
| 35 | .n_limits = ARRAY_SIZE(mwifiex_ap_sta_limits), |
| 36 | .max_interfaces = MWIFIEX_MAX_BSS_NUM, |
| 37 | .beacon_int_infra_match = true, |
| 38 | }; |
| 39 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 40 | /* |
| 41 | * This function maps the nl802.11 channel type into driver channel type. |
| 42 | * |
| 43 | * The mapping is as follows - |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 44 | * NL80211_CHAN_NO_HT -> IEEE80211_HT_PARAM_CHA_SEC_NONE |
| 45 | * NL80211_CHAN_HT20 -> IEEE80211_HT_PARAM_CHA_SEC_NONE |
| 46 | * NL80211_CHAN_HT40PLUS -> IEEE80211_HT_PARAM_CHA_SEC_ABOVE |
| 47 | * NL80211_CHAN_HT40MINUS -> IEEE80211_HT_PARAM_CHA_SEC_BELOW |
| 48 | * Others -> IEEE80211_HT_PARAM_CHA_SEC_NONE |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 49 | */ |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 50 | static u8 |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 51 | mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 52 | { |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 53 | switch (chan_type) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 54 | case NL80211_CHAN_NO_HT: |
| 55 | case NL80211_CHAN_HT20: |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 56 | return IEEE80211_HT_PARAM_CHA_SEC_NONE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 57 | case NL80211_CHAN_HT40PLUS: |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 58 | return IEEE80211_HT_PARAM_CHA_SEC_ABOVE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 59 | case NL80211_CHAN_HT40MINUS: |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 60 | return IEEE80211_HT_PARAM_CHA_SEC_BELOW; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 61 | default: |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 62 | return IEEE80211_HT_PARAM_CHA_SEC_NONE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 63 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 67 | * This function checks whether WEP is set. |
| 68 | */ |
| 69 | static int |
| 70 | mwifiex_is_alg_wep(u32 cipher) |
| 71 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 72 | switch (cipher) { |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 73 | case WLAN_CIPHER_SUITE_WEP40: |
| 74 | case WLAN_CIPHER_SUITE_WEP104: |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 75 | return 1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 76 | default: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 77 | break; |
| 78 | } |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 79 | |
| 80 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 84 | * This function retrieves the private structure from kernel wiphy structure. |
| 85 | */ |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 86 | static void *mwifiex_cfg80211_get_adapter(struct wiphy *wiphy) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 87 | { |
| 88 | return (void *) (*(unsigned long *) wiphy_priv(wiphy)); |
| 89 | } |
| 90 | |
| 91 | /* |
| 92 | * CFG802.11 operation handler to delete a network key. |
| 93 | */ |
| 94 | static int |
| 95 | mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, |
| 96 | u8 key_index, bool pairwise, const u8 *mac_addr) |
| 97 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 98 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 99 | const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 100 | const u8 *peer_mac = pairwise ? mac_addr : bc_mac; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 101 | |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 102 | if (mwifiex_set_encode(priv, NULL, 0, key_index, peer_mac, 1)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 103 | wiphy_err(wiphy, "deleting the crypto keys\n"); |
| 104 | return -EFAULT; |
| 105 | } |
| 106 | |
| 107 | wiphy_dbg(wiphy, "info: crypto keys deleted\n"); |
| 108 | return 0; |
| 109 | } |
| 110 | |
| 111 | /* |
| 112 | * CFG802.11 operation handler to set Tx power. |
| 113 | */ |
| 114 | static int |
| 115 | mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy, |
| 116 | enum nl80211_tx_power_setting type, |
Luis R. Rodriguez | 742c29f | 2011-11-28 16:38:50 -0500 | [diff] [blame] | 117 | int mbm) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 118 | { |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 119 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
| 120 | struct mwifiex_private *priv; |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 121 | struct mwifiex_power_cfg power_cfg; |
Luis R. Rodriguez | 742c29f | 2011-11-28 16:38:50 -0500 | [diff] [blame] | 122 | int dbm = MBM_TO_DBM(mbm); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 123 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 124 | if (type == NL80211_TX_POWER_FIXED) { |
| 125 | power_cfg.is_power_auto = 0; |
| 126 | power_cfg.power_level = dbm; |
| 127 | } else { |
| 128 | power_cfg.is_power_auto = 1; |
| 129 | } |
| 130 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 131 | priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); |
| 132 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 133 | return mwifiex_set_tx_power(priv, &power_cfg); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /* |
| 137 | * CFG802.11 operation handler to set Power Save option. |
| 138 | * |
| 139 | * The timeout value, if provided, is currently ignored. |
| 140 | */ |
| 141 | static int |
| 142 | mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 143 | struct net_device *dev, |
| 144 | bool enabled, int timeout) |
| 145 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 146 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 147 | u32 ps_mode; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 148 | |
| 149 | if (timeout) |
| 150 | wiphy_dbg(wiphy, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 151 | "info: ignore timeout value for IEEE Power Save\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 152 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 153 | ps_mode = enabled; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 154 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 155 | return mwifiex_drv_set_power(priv, &ps_mode); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* |
| 159 | * CFG802.11 operation handler to set the default network key. |
| 160 | */ |
| 161 | static int |
| 162 | mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev, |
| 163 | u8 key_index, bool unicast, |
| 164 | bool multicast) |
| 165 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 166 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 167 | |
Amitkumar Karwar | 2d3d0a8 | 2011-04-01 18:36:46 -0700 | [diff] [blame] | 168 | /* Return if WEP key not configured */ |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 169 | if (!priv->sec_info.wep_enabled) |
Amitkumar Karwar | 2d3d0a8 | 2011-04-01 18:36:46 -0700 | [diff] [blame] | 170 | return 0; |
| 171 | |
Avinash Patil | 9689353 | 2012-06-15 12:21:55 -0700 | [diff] [blame] | 172 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { |
| 173 | priv->wep_key_curr_index = key_index; |
| 174 | } else if (mwifiex_set_encode(priv, NULL, 0, key_index, NULL, 0)) { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 175 | wiphy_err(wiphy, "set default Tx key index\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 176 | return -EFAULT; |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 177 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | /* |
| 183 | * CFG802.11 operation handler to add a network key. |
| 184 | */ |
| 185 | static int |
| 186 | mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, |
| 187 | u8 key_index, bool pairwise, const u8 *mac_addr, |
| 188 | struct key_params *params) |
| 189 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 190 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev); |
Avinash Patil | 9689353 | 2012-06-15 12:21:55 -0700 | [diff] [blame] | 191 | struct mwifiex_wep_key *wep_key; |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 192 | const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
| 193 | const u8 *peer_mac = pairwise ? mac_addr : bc_mac; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 194 | |
Avinash Patil | 9689353 | 2012-06-15 12:21:55 -0700 | [diff] [blame] | 195 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP && |
| 196 | (params->cipher == WLAN_CIPHER_SUITE_WEP40 || |
| 197 | params->cipher == WLAN_CIPHER_SUITE_WEP104)) { |
| 198 | if (params->key && params->key_len) { |
| 199 | wep_key = &priv->wep_key[key_index]; |
| 200 | memset(wep_key, 0, sizeof(struct mwifiex_wep_key)); |
| 201 | memcpy(wep_key->key_material, params->key, |
| 202 | params->key_len); |
| 203 | wep_key->key_index = key_index; |
| 204 | wep_key->key_length = params->key_len; |
| 205 | priv->sec_info.wep_enabled = 1; |
| 206 | } |
| 207 | return 0; |
| 208 | } |
| 209 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 210 | if (mwifiex_set_encode(priv, params->key, params->key_len, |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 211 | key_index, peer_mac, 0)) { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 212 | wiphy_err(wiphy, "crypto keys added\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 213 | return -EFAULT; |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 214 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | * This function sends domain information to the firmware. |
| 221 | * |
| 222 | * The following information are passed to the firmware - |
| 223 | * - Country codes |
| 224 | * - Sub bands (first channel, number of channels, maximum Tx power) |
| 225 | */ |
| 226 | static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) |
| 227 | { |
| 228 | u8 no_of_triplet = 0; |
| 229 | struct ieee80211_country_ie_triplet *t; |
| 230 | u8 no_of_parsed_chan = 0; |
| 231 | u8 first_chan = 0, next_chan = 0, max_pwr = 0; |
| 232 | u8 i, flag = 0; |
| 233 | enum ieee80211_band band; |
| 234 | struct ieee80211_supported_band *sband; |
| 235 | struct ieee80211_channel *ch; |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 236 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
| 237 | struct mwifiex_private *priv; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 238 | struct mwifiex_802_11d_domain_reg *domain_info = &adapter->domain_reg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 239 | |
| 240 | /* Set country code */ |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 241 | domain_info->country_code[0] = adapter->country_code[0]; |
| 242 | domain_info->country_code[1] = adapter->country_code[1]; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 243 | domain_info->country_code[2] = ' '; |
| 244 | |
| 245 | band = mwifiex_band_to_radio_type(adapter->config_bands); |
| 246 | if (!wiphy->bands[band]) { |
| 247 | wiphy_err(wiphy, "11D: setting domain info in FW\n"); |
| 248 | return -1; |
| 249 | } |
| 250 | |
| 251 | sband = wiphy->bands[band]; |
| 252 | |
| 253 | for (i = 0; i < sband->n_channels ; i++) { |
| 254 | ch = &sband->channels[i]; |
| 255 | if (ch->flags & IEEE80211_CHAN_DISABLED) |
| 256 | continue; |
| 257 | |
| 258 | if (!flag) { |
| 259 | flag = 1; |
| 260 | first_chan = (u32) ch->hw_value; |
| 261 | next_chan = first_chan; |
Amitkumar Karwar | 34202e2 | 2012-06-27 19:57:59 -0700 | [diff] [blame] | 262 | max_pwr = ch->max_reg_power; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 263 | no_of_parsed_chan = 1; |
| 264 | continue; |
| 265 | } |
| 266 | |
| 267 | if (ch->hw_value == next_chan + 1 && |
Amitkumar Karwar | 34202e2 | 2012-06-27 19:57:59 -0700 | [diff] [blame] | 268 | ch->max_reg_power == max_pwr) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 269 | next_chan++; |
| 270 | no_of_parsed_chan++; |
| 271 | } else { |
| 272 | t = &domain_info->triplet[no_of_triplet]; |
| 273 | t->chans.first_channel = first_chan; |
| 274 | t->chans.num_channels = no_of_parsed_chan; |
| 275 | t->chans.max_power = max_pwr; |
| 276 | no_of_triplet++; |
| 277 | first_chan = (u32) ch->hw_value; |
| 278 | next_chan = first_chan; |
Amitkumar Karwar | 34202e2 | 2012-06-27 19:57:59 -0700 | [diff] [blame] | 279 | max_pwr = ch->max_reg_power; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 280 | no_of_parsed_chan = 1; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | if (flag) { |
| 285 | t = &domain_info->triplet[no_of_triplet]; |
| 286 | t->chans.first_channel = first_chan; |
| 287 | t->chans.num_channels = no_of_parsed_chan; |
| 288 | t->chans.max_power = max_pwr; |
| 289 | no_of_triplet++; |
| 290 | } |
| 291 | |
| 292 | domain_info->no_of_triplet = no_of_triplet; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 293 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 294 | priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); |
| 295 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 296 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 297 | HostCmd_ACT_GEN_SET, 0, NULL)) { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 298 | wiphy_err(wiphy, "11D: setting domain info in FW\n"); |
| 299 | return -1; |
| 300 | } |
| 301 | |
| 302 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* |
| 306 | * CFG802.11 regulatory domain callback function. |
| 307 | * |
| 308 | * This function is called when the regulatory domain is changed due to the |
| 309 | * following reasons - |
| 310 | * - Set by driver |
| 311 | * - Set by system core |
| 312 | * - Set by user |
| 313 | * - Set bt Country IE |
| 314 | */ |
| 315 | static int mwifiex_reg_notifier(struct wiphy *wiphy, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 316 | struct regulatory_request *request) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 317 | { |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 318 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 319 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 320 | wiphy_dbg(wiphy, "info: cfg80211 regulatory domain callback for %c%c\n", |
| 321 | request->alpha2[0], request->alpha2[1]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 322 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 323 | memcpy(adapter->country_code, request->alpha2, sizeof(request->alpha2)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 324 | |
| 325 | switch (request->initiator) { |
| 326 | case NL80211_REGDOM_SET_BY_DRIVER: |
| 327 | case NL80211_REGDOM_SET_BY_CORE: |
| 328 | case NL80211_REGDOM_SET_BY_USER: |
| 329 | break; |
| 330 | /* Todo: apply driver specific changes in channel flags based |
| 331 | on the request initiator if necessary. */ |
| 332 | case NL80211_REGDOM_SET_BY_COUNTRY_IE: |
| 333 | break; |
| 334 | } |
| 335 | mwifiex_send_domain_info_cmd_fw(wiphy); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 341 | * This function sets the fragmentation threshold. |
| 342 | * |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 343 | * The fragmentation threshold value must lie between MWIFIEX_FRAG_MIN_VALUE |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 344 | * and MWIFIEX_FRAG_MAX_VALUE. |
| 345 | */ |
| 346 | static int |
| 347 | mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr) |
| 348 | { |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 349 | if (frag_thr < MWIFIEX_FRAG_MIN_VALUE || |
| 350 | frag_thr > MWIFIEX_FRAG_MAX_VALUE) |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 351 | frag_thr = MWIFIEX_FRAG_MAX_VALUE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 352 | |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 353 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, |
| 354 | HostCmd_ACT_GEN_SET, FRAG_THRESH_I, |
| 355 | &frag_thr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | /* |
| 359 | * This function sets the RTS threshold. |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 360 | |
| 361 | * The rts value must lie between MWIFIEX_RTS_MIN_VALUE |
| 362 | * and MWIFIEX_RTS_MAX_VALUE. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 363 | */ |
| 364 | static int |
| 365 | mwifiex_set_rts(struct mwifiex_private *priv, u32 rts_thr) |
| 366 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 367 | if (rts_thr < MWIFIEX_RTS_MIN_VALUE || rts_thr > MWIFIEX_RTS_MAX_VALUE) |
| 368 | rts_thr = MWIFIEX_RTS_MAX_VALUE; |
| 369 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 370 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 371 | HostCmd_ACT_GEN_SET, RTS_THRESH_I, |
| 372 | &rts_thr); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | /* |
| 376 | * CFG802.11 operation handler to set wiphy parameters. |
| 377 | * |
| 378 | * This function can be used to set the RTS threshold and the |
| 379 | * Fragmentation threshold of the driver. |
| 380 | */ |
| 381 | static int |
| 382 | mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 383 | { |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 384 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 385 | struct mwifiex_private *priv; |
| 386 | struct mwifiex_uap_bss_param *bss_cfg; |
| 387 | int ret, bss_started, i; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 388 | |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 389 | for (i = 0; i < adapter->priv_num; i++) { |
| 390 | priv = adapter->priv[i]; |
| 391 | |
| 392 | switch (priv->bss_role) { |
| 393 | case MWIFIEX_BSS_ROLE_UAP: |
| 394 | bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), |
| 395 | GFP_KERNEL); |
| 396 | if (!bss_cfg) |
| 397 | return -ENOMEM; |
| 398 | |
| 399 | mwifiex_set_sys_config_invalid_data(bss_cfg); |
| 400 | |
| 401 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) |
| 402 | bss_cfg->rts_threshold = wiphy->rts_threshold; |
| 403 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) |
| 404 | bss_cfg->frag_threshold = wiphy->frag_threshold; |
| 405 | if (changed & WIPHY_PARAM_RETRY_LONG) |
| 406 | bss_cfg->retry_limit = wiphy->retry_long; |
| 407 | |
| 408 | bss_started = priv->bss_started; |
| 409 | |
| 410 | ret = mwifiex_send_cmd_sync(priv, |
| 411 | HostCmd_CMD_UAP_BSS_STOP, |
| 412 | HostCmd_ACT_GEN_SET, 0, |
| 413 | NULL); |
| 414 | if (ret) { |
| 415 | wiphy_err(wiphy, "Failed to stop the BSS\n"); |
| 416 | kfree(bss_cfg); |
| 417 | return ret; |
| 418 | } |
| 419 | |
| 420 | ret = mwifiex_send_cmd_async(priv, |
| 421 | HostCmd_CMD_UAP_SYS_CONFIG, |
| 422 | HostCmd_ACT_GEN_SET, |
Avinash Patil | e76268d | 2012-05-08 18:30:27 -0700 | [diff] [blame] | 423 | UAP_BSS_PARAMS_I, bss_cfg); |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 424 | |
| 425 | kfree(bss_cfg); |
| 426 | |
| 427 | if (ret) { |
| 428 | wiphy_err(wiphy, "Failed to set bss config\n"); |
| 429 | return ret; |
| 430 | } |
| 431 | |
| 432 | if (!bss_started) |
| 433 | break; |
| 434 | |
| 435 | ret = mwifiex_send_cmd_async(priv, |
| 436 | HostCmd_CMD_UAP_BSS_START, |
| 437 | HostCmd_ACT_GEN_SET, 0, |
| 438 | NULL); |
| 439 | if (ret) { |
| 440 | wiphy_err(wiphy, "Failed to start BSS\n"); |
| 441 | return ret; |
| 442 | } |
| 443 | |
| 444 | break; |
| 445 | case MWIFIEX_BSS_ROLE_STA: |
| 446 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 447 | ret = mwifiex_set_rts(priv, |
| 448 | wiphy->rts_threshold); |
| 449 | if (ret) |
| 450 | return ret; |
| 451 | } |
| 452 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 453 | ret = mwifiex_set_frag(priv, |
| 454 | wiphy->frag_threshold); |
| 455 | if (ret) |
| 456 | return ret; |
| 457 | } |
| 458 | break; |
| 459 | } |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 460 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 461 | |
Avinash Patil | 9b930ea | 2012-05-08 18:30:23 -0700 | [diff] [blame] | 462 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /* |
| 466 | * CFG802.11 operation handler to change interface type. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 467 | */ |
| 468 | static int |
| 469 | mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy, |
| 470 | struct net_device *dev, |
| 471 | enum nl80211_iftype type, u32 *flags, |
| 472 | struct vif_params *params) |
| 473 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 474 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 475 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 476 | |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 477 | switch (dev->ieee80211_ptr->iftype) { |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 478 | case NL80211_IFTYPE_ADHOC: |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 479 | switch (type) { |
| 480 | case NL80211_IFTYPE_STATION: |
| 481 | break; |
| 482 | case NL80211_IFTYPE_UNSPECIFIED: |
| 483 | wiphy_warn(wiphy, "%s: kept type as IBSS\n", dev->name); |
| 484 | case NL80211_IFTYPE_ADHOC: /* This shouldn't happen */ |
| 485 | return 0; |
| 486 | case NL80211_IFTYPE_AP: |
| 487 | default: |
| 488 | wiphy_err(wiphy, "%s: changing to %d not supported\n", |
| 489 | dev->name, type); |
| 490 | return -EOPNOTSUPP; |
| 491 | } |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 492 | break; |
| 493 | case NL80211_IFTYPE_STATION: |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 494 | switch (type) { |
| 495 | case NL80211_IFTYPE_ADHOC: |
| 496 | break; |
| 497 | case NL80211_IFTYPE_UNSPECIFIED: |
| 498 | wiphy_warn(wiphy, "%s: kept type as STA\n", dev->name); |
| 499 | case NL80211_IFTYPE_STATION: /* This shouldn't happen */ |
| 500 | return 0; |
| 501 | case NL80211_IFTYPE_AP: |
| 502 | default: |
| 503 | wiphy_err(wiphy, "%s: changing to %d not supported\n", |
| 504 | dev->name, type); |
| 505 | return -EOPNOTSUPP; |
| 506 | } |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 507 | break; |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 508 | case NL80211_IFTYPE_AP: |
| 509 | switch (type) { |
| 510 | case NL80211_IFTYPE_UNSPECIFIED: |
| 511 | wiphy_warn(wiphy, "%s: kept type as AP\n", dev->name); |
| 512 | case NL80211_IFTYPE_AP: /* This shouldn't happen */ |
| 513 | return 0; |
| 514 | case NL80211_IFTYPE_ADHOC: |
| 515 | case NL80211_IFTYPE_STATION: |
| 516 | default: |
| 517 | wiphy_err(wiphy, "%s: changing to %d not supported\n", |
| 518 | dev->name, type); |
| 519 | return -EOPNOTSUPP; |
| 520 | } |
| 521 | break; |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 522 | default: |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 523 | wiphy_err(wiphy, "%s: unknown iftype: %d\n", |
| 524 | dev->name, dev->ieee80211_ptr->iftype); |
| 525 | return -EOPNOTSUPP; |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 526 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 527 | |
Avinash Patil | 4f02341 | 2012-05-08 18:30:22 -0700 | [diff] [blame] | 528 | dev->ieee80211_ptr->iftype = type; |
| 529 | priv->bss_mode = type; |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 530 | mwifiex_deauthenticate(priv, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 531 | |
Marc Yang | f986b6d | 2011-03-28 17:55:42 -0700 | [diff] [blame] | 532 | priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM; |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 533 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 534 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_SET_BSS_MODE, |
| 535 | HostCmd_ACT_GEN_SET, 0, NULL); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 536 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 537 | return ret; |
| 538 | } |
| 539 | |
| 540 | /* |
| 541 | * This function dumps the station information on a buffer. |
| 542 | * |
| 543 | * The following information are shown - |
| 544 | * - Total bytes transmitted |
| 545 | * - Total bytes received |
| 546 | * - Total packets transmitted |
| 547 | * - Total packets received |
| 548 | * - Signal quality level |
| 549 | * - Transmission rate |
| 550 | */ |
| 551 | static int |
| 552 | mwifiex_dump_station_info(struct mwifiex_private *priv, |
| 553 | struct station_info *sinfo) |
| 554 | { |
Amitkumar Karwar | 006606c | 2012-07-13 20:09:31 -0700 | [diff] [blame] | 555 | u32 rate; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 556 | |
| 557 | sinfo->filled = STATION_INFO_RX_BYTES | STATION_INFO_TX_BYTES | |
Amitkumar Karwar | 7013d3e | 2012-03-15 20:51:50 -0700 | [diff] [blame] | 558 | STATION_INFO_RX_PACKETS | STATION_INFO_TX_PACKETS | |
| 559 | STATION_INFO_TX_BITRATE | |
| 560 | STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 561 | |
| 562 | /* Get signal information from the firmware */ |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame] | 563 | if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_RSSI_INFO, |
| 564 | HostCmd_ACT_GEN_GET, 0, NULL)) { |
| 565 | dev_err(priv->adapter->dev, "failed to get signal information\n"); |
| 566 | return -EFAULT; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | if (mwifiex_drv_get_data_rate(priv, &rate)) { |
| 570 | dev_err(priv->adapter->dev, "getting data rate\n"); |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame] | 571 | return -EFAULT; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 572 | } |
| 573 | |
Amitkumar Karwar | caf60a6 | 2012-02-02 20:48:58 -0800 | [diff] [blame] | 574 | /* Get DTIM period information from firmware */ |
| 575 | mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB, |
| 576 | HostCmd_ACT_GEN_GET, DTIM_PERIOD_I, |
| 577 | &priv->dtim_period); |
| 578 | |
Amitkumar Karwar | 4ec6f9c | 2011-09-26 20:37:25 -0700 | [diff] [blame] | 579 | /* |
| 580 | * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid |
Amitkumar Karwar | fe02012 | 2012-07-11 18:12:57 -0700 | [diff] [blame] | 581 | * MCS index values for us are 0 to 15. |
Amitkumar Karwar | 4ec6f9c | 2011-09-26 20:37:25 -0700 | [diff] [blame] | 582 | */ |
Amitkumar Karwar | fe02012 | 2012-07-11 18:12:57 -0700 | [diff] [blame] | 583 | if ((priv->tx_htinfo & BIT(0)) && (priv->tx_rate < 16)) { |
Amitkumar Karwar | 4ec6f9c | 2011-09-26 20:37:25 -0700 | [diff] [blame] | 584 | sinfo->txrate.mcs = priv->tx_rate; |
| 585 | sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS; |
| 586 | /* 40MHz rate */ |
| 587 | if (priv->tx_htinfo & BIT(1)) |
| 588 | sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
| 589 | /* SGI enabled */ |
| 590 | if (priv->tx_htinfo & BIT(2)) |
| 591 | sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; |
| 592 | } |
| 593 | |
Amitkumar Karwar | 7013d3e | 2012-03-15 20:51:50 -0700 | [diff] [blame] | 594 | sinfo->signal_avg = priv->bcn_rssi_avg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 595 | sinfo->rx_bytes = priv->stats.rx_bytes; |
| 596 | sinfo->tx_bytes = priv->stats.tx_bytes; |
| 597 | sinfo->rx_packets = priv->stats.rx_packets; |
| 598 | sinfo->tx_packets = priv->stats.tx_packets; |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame] | 599 | sinfo->signal = priv->bcn_rssi_avg; |
Amitkumar Karwar | 4ec6f9c | 2011-09-26 20:37:25 -0700 | [diff] [blame] | 600 | /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */ |
Amitkumar Karwar | 006606c | 2012-07-13 20:09:31 -0700 | [diff] [blame] | 601 | sinfo->txrate.legacy = rate * 5; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 602 | |
Amitkumar Karwar | c4f3b97 | 2012-01-24 20:50:25 -0800 | [diff] [blame] | 603 | if (priv->bss_mode == NL80211_IFTYPE_STATION) { |
| 604 | sinfo->filled |= STATION_INFO_BSS_PARAM; |
| 605 | sinfo->bss_param.flags = 0; |
| 606 | if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap & |
| 607 | WLAN_CAPABILITY_SHORT_PREAMBLE) |
| 608 | sinfo->bss_param.flags |= |
| 609 | BSS_PARAM_FLAGS_SHORT_PREAMBLE; |
| 610 | if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap & |
| 611 | WLAN_CAPABILITY_SHORT_SLOT_TIME) |
| 612 | sinfo->bss_param.flags |= |
| 613 | BSS_PARAM_FLAGS_SHORT_SLOT_TIME; |
Amitkumar Karwar | caf60a6 | 2012-02-02 20:48:58 -0800 | [diff] [blame] | 614 | sinfo->bss_param.dtim_period = priv->dtim_period; |
Amitkumar Karwar | c4f3b97 | 2012-01-24 20:50:25 -0800 | [diff] [blame] | 615 | sinfo->bss_param.beacon_interval = |
| 616 | priv->curr_bss_params.bss_descriptor.beacon_period; |
| 617 | } |
| 618 | |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame] | 619 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /* |
| 623 | * CFG802.11 operation handler to get station information. |
| 624 | * |
| 625 | * This function only works in connected mode, and dumps the |
| 626 | * requested station information, if available. |
| 627 | */ |
| 628 | static int |
| 629 | mwifiex_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, |
| 630 | u8 *mac, struct station_info *sinfo) |
| 631 | { |
| 632 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 633 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 634 | if (!priv->media_connected) |
| 635 | return -ENOENT; |
| 636 | if (memcmp(mac, priv->cfg_bssid, ETH_ALEN)) |
| 637 | return -ENOENT; |
| 638 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 639 | return mwifiex_dump_station_info(priv, sinfo); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 640 | } |
| 641 | |
Amitkumar Karwar | f85aae6 | 2012-03-15 20:51:48 -0700 | [diff] [blame] | 642 | /* |
| 643 | * CFG802.11 operation handler to dump station information. |
| 644 | */ |
| 645 | static int |
| 646 | mwifiex_cfg80211_dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 647 | int idx, u8 *mac, struct station_info *sinfo) |
| 648 | { |
| 649 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 650 | |
| 651 | if (!priv->media_connected || idx) |
| 652 | return -ENOENT; |
| 653 | |
| 654 | memcpy(mac, priv->cfg_bssid, ETH_ALEN); |
| 655 | |
| 656 | return mwifiex_dump_station_info(priv, sinfo); |
| 657 | } |
| 658 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 659 | /* Supported rates to be advertised to the cfg80211 */ |
| 660 | |
| 661 | static struct ieee80211_rate mwifiex_rates[] = { |
| 662 | {.bitrate = 10, .hw_value = 2, }, |
| 663 | {.bitrate = 20, .hw_value = 4, }, |
| 664 | {.bitrate = 55, .hw_value = 11, }, |
| 665 | {.bitrate = 110, .hw_value = 22, }, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 666 | {.bitrate = 60, .hw_value = 12, }, |
| 667 | {.bitrate = 90, .hw_value = 18, }, |
| 668 | {.bitrate = 120, .hw_value = 24, }, |
| 669 | {.bitrate = 180, .hw_value = 36, }, |
| 670 | {.bitrate = 240, .hw_value = 48, }, |
| 671 | {.bitrate = 360, .hw_value = 72, }, |
| 672 | {.bitrate = 480, .hw_value = 96, }, |
| 673 | {.bitrate = 540, .hw_value = 108, }, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 674 | }; |
| 675 | |
| 676 | /* Channel definitions to be advertised to cfg80211 */ |
| 677 | |
| 678 | static struct ieee80211_channel mwifiex_channels_2ghz[] = { |
| 679 | {.center_freq = 2412, .hw_value = 1, }, |
| 680 | {.center_freq = 2417, .hw_value = 2, }, |
| 681 | {.center_freq = 2422, .hw_value = 3, }, |
| 682 | {.center_freq = 2427, .hw_value = 4, }, |
| 683 | {.center_freq = 2432, .hw_value = 5, }, |
| 684 | {.center_freq = 2437, .hw_value = 6, }, |
| 685 | {.center_freq = 2442, .hw_value = 7, }, |
| 686 | {.center_freq = 2447, .hw_value = 8, }, |
| 687 | {.center_freq = 2452, .hw_value = 9, }, |
| 688 | {.center_freq = 2457, .hw_value = 10, }, |
| 689 | {.center_freq = 2462, .hw_value = 11, }, |
| 690 | {.center_freq = 2467, .hw_value = 12, }, |
| 691 | {.center_freq = 2472, .hw_value = 13, }, |
| 692 | {.center_freq = 2484, .hw_value = 14, }, |
| 693 | }; |
| 694 | |
| 695 | static struct ieee80211_supported_band mwifiex_band_2ghz = { |
| 696 | .channels = mwifiex_channels_2ghz, |
| 697 | .n_channels = ARRAY_SIZE(mwifiex_channels_2ghz), |
| 698 | .bitrates = mwifiex_rates, |
Amitkumar Karwar | 8763848 | 2012-03-07 19:36:07 -0800 | [diff] [blame] | 699 | .n_bitrates = ARRAY_SIZE(mwifiex_rates), |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 700 | }; |
| 701 | |
| 702 | static struct ieee80211_channel mwifiex_channels_5ghz[] = { |
| 703 | {.center_freq = 5040, .hw_value = 8, }, |
| 704 | {.center_freq = 5060, .hw_value = 12, }, |
| 705 | {.center_freq = 5080, .hw_value = 16, }, |
| 706 | {.center_freq = 5170, .hw_value = 34, }, |
| 707 | {.center_freq = 5190, .hw_value = 38, }, |
| 708 | {.center_freq = 5210, .hw_value = 42, }, |
| 709 | {.center_freq = 5230, .hw_value = 46, }, |
| 710 | {.center_freq = 5180, .hw_value = 36, }, |
| 711 | {.center_freq = 5200, .hw_value = 40, }, |
| 712 | {.center_freq = 5220, .hw_value = 44, }, |
| 713 | {.center_freq = 5240, .hw_value = 48, }, |
| 714 | {.center_freq = 5260, .hw_value = 52, }, |
| 715 | {.center_freq = 5280, .hw_value = 56, }, |
| 716 | {.center_freq = 5300, .hw_value = 60, }, |
| 717 | {.center_freq = 5320, .hw_value = 64, }, |
| 718 | {.center_freq = 5500, .hw_value = 100, }, |
| 719 | {.center_freq = 5520, .hw_value = 104, }, |
| 720 | {.center_freq = 5540, .hw_value = 108, }, |
| 721 | {.center_freq = 5560, .hw_value = 112, }, |
| 722 | {.center_freq = 5580, .hw_value = 116, }, |
| 723 | {.center_freq = 5600, .hw_value = 120, }, |
| 724 | {.center_freq = 5620, .hw_value = 124, }, |
| 725 | {.center_freq = 5640, .hw_value = 128, }, |
| 726 | {.center_freq = 5660, .hw_value = 132, }, |
| 727 | {.center_freq = 5680, .hw_value = 136, }, |
| 728 | {.center_freq = 5700, .hw_value = 140, }, |
| 729 | {.center_freq = 5745, .hw_value = 149, }, |
| 730 | {.center_freq = 5765, .hw_value = 153, }, |
| 731 | {.center_freq = 5785, .hw_value = 157, }, |
| 732 | {.center_freq = 5805, .hw_value = 161, }, |
| 733 | {.center_freq = 5825, .hw_value = 165, }, |
| 734 | }; |
| 735 | |
| 736 | static struct ieee80211_supported_band mwifiex_band_5ghz = { |
| 737 | .channels = mwifiex_channels_5ghz, |
| 738 | .n_channels = ARRAY_SIZE(mwifiex_channels_5ghz), |
Avinash Patil | eb416ad | 2012-02-27 22:04:11 -0800 | [diff] [blame] | 739 | .bitrates = mwifiex_rates + 4, |
| 740 | .n_bitrates = ARRAY_SIZE(mwifiex_rates) - 4, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 741 | }; |
| 742 | |
| 743 | |
| 744 | /* Supported crypto cipher suits to be advertised to cfg80211 */ |
| 745 | |
| 746 | static const u32 mwifiex_cipher_suites[] = { |
| 747 | WLAN_CIPHER_SUITE_WEP40, |
| 748 | WLAN_CIPHER_SUITE_WEP104, |
| 749 | WLAN_CIPHER_SUITE_TKIP, |
| 750 | WLAN_CIPHER_SUITE_CCMP, |
| 751 | }; |
| 752 | |
| 753 | /* |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 754 | * CFG802.11 operation handler for setting bit rates. |
| 755 | * |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 756 | * Function configures data rates to firmware using bitrate mask |
| 757 | * provided by cfg80211. |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 758 | */ |
| 759 | static int mwifiex_cfg80211_set_bitrate_mask(struct wiphy *wiphy, |
| 760 | struct net_device *dev, |
| 761 | const u8 *peer, |
| 762 | const struct cfg80211_bitrate_mask *mask) |
| 763 | { |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 764 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 765 | u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; |
| 766 | enum ieee80211_band band; |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 767 | |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 768 | if (!priv->media_connected) { |
| 769 | dev_err(priv->adapter->dev, |
| 770 | "Can not set Tx data rate in disconnected state\n"); |
| 771 | return -EINVAL; |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 772 | } |
| 773 | |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 774 | band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 775 | |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 776 | memset(bitmap_rates, 0, sizeof(bitmap_rates)); |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 777 | |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 778 | /* Fill HR/DSSS rates. */ |
| 779 | if (band == IEEE80211_BAND_2GHZ) |
| 780 | bitmap_rates[0] = mask->control[band].legacy & 0x000f; |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 781 | |
Amitkumar Karwar | 433c399 | 2012-07-13 20:09:33 -0700 | [diff] [blame] | 782 | /* Fill OFDM rates */ |
| 783 | if (band == IEEE80211_BAND_2GHZ) |
| 784 | bitmap_rates[1] = (mask->control[band].legacy & 0x0ff0) >> 4; |
| 785 | else |
| 786 | bitmap_rates[1] = mask->control[band].legacy; |
| 787 | |
| 788 | /* Fill MCS rates */ |
| 789 | bitmap_rates[2] = mask->control[band].mcs[0]; |
| 790 | if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) |
| 791 | bitmap_rates[2] |= mask->control[band].mcs[1] << 8; |
| 792 | |
| 793 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG, |
| 794 | HostCmd_ACT_GEN_SET, 0, bitmap_rates); |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 795 | } |
| 796 | |
| 797 | /* |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 798 | * CFG802.11 operation handler for connection quality monitoring. |
| 799 | * |
| 800 | * This function subscribes/unsubscribes HIGH_RSSI and LOW_RSSI |
| 801 | * events to FW. |
| 802 | */ |
| 803 | static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy *wiphy, |
| 804 | struct net_device *dev, |
| 805 | s32 rssi_thold, u32 rssi_hyst) |
| 806 | { |
| 807 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 808 | struct mwifiex_ds_misc_subsc_evt subsc_evt; |
| 809 | |
| 810 | priv->cqm_rssi_thold = rssi_thold; |
| 811 | priv->cqm_rssi_hyst = rssi_hyst; |
| 812 | |
| 813 | memset(&subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt)); |
| 814 | subsc_evt.events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH; |
| 815 | |
| 816 | /* Subscribe/unsubscribe low and high rssi events */ |
| 817 | if (rssi_thold && rssi_hyst) { |
| 818 | subsc_evt.action = HostCmd_ACT_BITWISE_SET; |
| 819 | subsc_evt.bcn_l_rssi_cfg.abs_value = abs(rssi_thold); |
| 820 | subsc_evt.bcn_h_rssi_cfg.abs_value = abs(rssi_thold); |
| 821 | subsc_evt.bcn_l_rssi_cfg.evt_freq = 1; |
| 822 | subsc_evt.bcn_h_rssi_cfg.evt_freq = 1; |
| 823 | return mwifiex_send_cmd_sync(priv, |
| 824 | HostCmd_CMD_802_11_SUBSCRIBE_EVENT, |
| 825 | 0, 0, &subsc_evt); |
| 826 | } else { |
| 827 | subsc_evt.action = HostCmd_ACT_BITWISE_CLR; |
| 828 | return mwifiex_send_cmd_sync(priv, |
| 829 | HostCmd_CMD_802_11_SUBSCRIBE_EVENT, |
| 830 | 0, 0, &subsc_evt); |
| 831 | } |
| 832 | |
| 833 | return 0; |
| 834 | } |
| 835 | |
Avinash Patil | 5370c83 | 2012-06-28 20:30:28 -0700 | [diff] [blame] | 836 | /* cfg80211 operation handler for change_beacon. |
| 837 | * Function retrieves and sets modified management IEs to FW. |
| 838 | */ |
| 839 | static int mwifiex_cfg80211_change_beacon(struct wiphy *wiphy, |
| 840 | struct net_device *dev, |
| 841 | struct cfg80211_beacon_data *data) |
| 842 | { |
| 843 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 844 | |
| 845 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
| 846 | wiphy_err(wiphy, "%s: bss_type mismatched\n", __func__); |
| 847 | return -EINVAL; |
| 848 | } |
| 849 | |
| 850 | if (!priv->bss_started) { |
| 851 | wiphy_err(wiphy, "%s: bss not started\n", __func__); |
| 852 | return -EINVAL; |
| 853 | } |
| 854 | |
| 855 | if (mwifiex_set_mgmt_ies(priv, data)) { |
| 856 | wiphy_err(wiphy, "%s: setting mgmt ies failed\n", __func__); |
| 857 | return -EFAULT; |
| 858 | } |
| 859 | |
| 860 | return 0; |
| 861 | } |
| 862 | |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 863 | static int |
| 864 | mwifiex_cfg80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant) |
| 865 | { |
| 866 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
| 867 | struct mwifiex_private *priv = mwifiex_get_priv(adapter, |
| 868 | MWIFIEX_BSS_ROLE_ANY); |
| 869 | struct mwifiex_ds_ant_cfg ant_cfg; |
| 870 | |
| 871 | if (!tx_ant || !rx_ant) |
| 872 | return -EOPNOTSUPP; |
| 873 | |
| 874 | if (adapter->hw_dev_mcs_support != HT_STREAM_2X2) { |
| 875 | /* Not a MIMO chip. User should provide specific antenna number |
| 876 | * for Tx/Rx path or enable all antennas for diversity |
| 877 | */ |
| 878 | if (tx_ant != rx_ant) |
| 879 | return -EOPNOTSUPP; |
| 880 | |
| 881 | if ((tx_ant & (tx_ant - 1)) && |
| 882 | (tx_ant != BIT(adapter->number_of_antenna) - 1)) |
| 883 | return -EOPNOTSUPP; |
| 884 | |
| 885 | if ((tx_ant == BIT(adapter->number_of_antenna) - 1) && |
| 886 | (priv->adapter->number_of_antenna > 1)) { |
| 887 | tx_ant = RF_ANTENNA_AUTO; |
| 888 | rx_ant = RF_ANTENNA_AUTO; |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | ant_cfg.tx_ant = tx_ant; |
| 893 | ant_cfg.rx_ant = rx_ant; |
| 894 | |
| 895 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_RF_ANTENNA, |
| 896 | HostCmd_ACT_GEN_SET, 0, &ant_cfg); |
| 897 | } |
| 898 | |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 899 | /* cfg80211 operation handler for stop ap. |
| 900 | * Function stops BSS running at uAP interface. |
| 901 | */ |
| 902 | static int mwifiex_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev) |
| 903 | { |
| 904 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 905 | |
Avinash Patil | 40bbc21 | 2012-05-08 18:30:30 -0700 | [diff] [blame] | 906 | if (mwifiex_del_mgmt_ies(priv)) |
| 907 | wiphy_err(wiphy, "Failed to delete mgmt IEs!\n"); |
| 908 | |
Avinash Patil | c825891 | 2012-08-03 18:06:05 -0700 | [diff] [blame^] | 909 | priv->ap_11n_enabled = 0; |
| 910 | |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 911 | if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP, |
| 912 | HostCmd_ACT_GEN_SET, 0, NULL)) { |
| 913 | wiphy_err(wiphy, "Failed to stop the BSS\n"); |
| 914 | return -1; |
| 915 | } |
| 916 | |
| 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | /* cfg80211 operation handler for start_ap. |
| 921 | * Function sets beacon period, DTIM period, SSID and security into |
| 922 | * AP config structure. |
| 923 | * AP is configured with these settings and BSS is started. |
| 924 | */ |
| 925 | static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy, |
| 926 | struct net_device *dev, |
| 927 | struct cfg80211_ap_settings *params) |
| 928 | { |
| 929 | struct mwifiex_uap_bss_param *bss_cfg; |
| 930 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 931 | u8 config_bands = 0; |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 932 | |
Avinash Patil | f752dcd | 2012-05-08 18:30:26 -0700 | [diff] [blame] | 933 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) |
| 934 | return -1; |
Avinash Patil | adb6ed0 | 2012-06-28 20:30:25 -0700 | [diff] [blame] | 935 | if (mwifiex_set_mgmt_ies(priv, ¶ms->beacon)) |
Avinash Patil | f31acab | 2012-05-08 18:30:29 -0700 | [diff] [blame] | 936 | return -1; |
Avinash Patil | f752dcd | 2012-05-08 18:30:26 -0700 | [diff] [blame] | 937 | |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 938 | bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), GFP_KERNEL); |
| 939 | if (!bss_cfg) |
| 940 | return -ENOMEM; |
| 941 | |
| 942 | mwifiex_set_sys_config_invalid_data(bss_cfg); |
| 943 | |
| 944 | if (params->beacon_interval) |
| 945 | bss_cfg->beacon_period = params->beacon_interval; |
| 946 | if (params->dtim_period) |
| 947 | bss_cfg->dtim_period = params->dtim_period; |
| 948 | |
| 949 | if (params->ssid && params->ssid_len) { |
| 950 | memcpy(bss_cfg->ssid.ssid, params->ssid, params->ssid_len); |
| 951 | bss_cfg->ssid.ssid_len = params->ssid_len; |
| 952 | } |
| 953 | |
Avinash Patil | 7a1c993 | 2012-05-29 15:39:05 -0700 | [diff] [blame] | 954 | switch (params->hidden_ssid) { |
| 955 | case NL80211_HIDDEN_SSID_NOT_IN_USE: |
| 956 | bss_cfg->bcast_ssid_ctl = 1; |
| 957 | break; |
| 958 | case NL80211_HIDDEN_SSID_ZERO_LEN: |
| 959 | bss_cfg->bcast_ssid_ctl = 0; |
| 960 | break; |
| 961 | case NL80211_HIDDEN_SSID_ZERO_CONTENTS: |
| 962 | /* firmware doesn't support this type of hidden SSID */ |
| 963 | default: |
Bing Zhao | b319046 | 2012-07-03 15:53:13 -0700 | [diff] [blame] | 964 | kfree(bss_cfg); |
Avinash Patil | 7a1c993 | 2012-05-29 15:39:05 -0700 | [diff] [blame] | 965 | return -EINVAL; |
| 966 | } |
| 967 | |
Avinash Patil | 0abd79e | 2012-06-15 12:21:51 -0700 | [diff] [blame] | 968 | bss_cfg->channel = |
| 969 | (u8)ieee80211_frequency_to_channel(params->channel->center_freq); |
| 970 | bss_cfg->band_cfg = BAND_CONFIG_MANUAL; |
| 971 | |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 972 | /* Set appropriate bands */ |
| 973 | if (params->channel->band == IEEE80211_BAND_2GHZ) { |
| 974 | if (params->channel_type == NL80211_CHAN_NO_HT) |
| 975 | config_bands = BAND_B | BAND_G; |
| 976 | else |
| 977 | config_bands = BAND_B | BAND_G | BAND_GN; |
| 978 | } else { |
| 979 | if (params->channel_type == NL80211_CHAN_NO_HT) |
| 980 | config_bands = BAND_A; |
| 981 | else |
| 982 | config_bands = BAND_AN | BAND_A; |
Avinash Patil | 0abd79e | 2012-06-15 12:21:51 -0700 | [diff] [blame] | 983 | } |
| 984 | |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 985 | if (!((config_bands | priv->adapter->fw_bands) & |
| 986 | ~priv->adapter->fw_bands)) |
| 987 | priv->adapter->config_bands = config_bands; |
| 988 | |
| 989 | mwifiex_send_domain_info_cmd_fw(wiphy); |
| 990 | |
Avinash Patil | f752dcd | 2012-05-08 18:30:26 -0700 | [diff] [blame] | 991 | if (mwifiex_set_secure_params(priv, bss_cfg, params)) { |
| 992 | kfree(bss_cfg); |
| 993 | wiphy_err(wiphy, "Failed to parse secuirty parameters!\n"); |
| 994 | return -1; |
| 995 | } |
| 996 | |
Avinash Patil | 2228125 | 2012-06-15 12:21:53 -0700 | [diff] [blame] | 997 | mwifiex_set_ht_params(priv, bss_cfg, params); |
| 998 | |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 999 | if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP, |
| 1000 | HostCmd_ACT_GEN_SET, 0, NULL)) { |
| 1001 | wiphy_err(wiphy, "Failed to stop the BSS\n"); |
| 1002 | kfree(bss_cfg); |
| 1003 | return -1; |
| 1004 | } |
| 1005 | |
| 1006 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG, |
Avinash Patil | e76268d | 2012-05-08 18:30:27 -0700 | [diff] [blame] | 1007 | HostCmd_ACT_GEN_SET, |
| 1008 | UAP_BSS_PARAMS_I, bss_cfg)) { |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 1009 | wiphy_err(wiphy, "Failed to set the SSID\n"); |
| 1010 | kfree(bss_cfg); |
| 1011 | return -1; |
| 1012 | } |
| 1013 | |
| 1014 | kfree(bss_cfg); |
| 1015 | |
| 1016 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_BSS_START, |
| 1017 | HostCmd_ACT_GEN_SET, 0, NULL)) { |
| 1018 | wiphy_err(wiphy, "Failed to start the BSS\n"); |
| 1019 | return -1; |
| 1020 | } |
| 1021 | |
Avinash Patil | 9689353 | 2012-06-15 12:21:55 -0700 | [diff] [blame] | 1022 | if (priv->sec_info.wep_enabled) |
| 1023 | priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE; |
| 1024 | else |
| 1025 | priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; |
| 1026 | |
| 1027 | if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL, |
| 1028 | HostCmd_ACT_GEN_SET, 0, |
| 1029 | &priv->curr_pkt_filter)) |
| 1030 | return -1; |
| 1031 | |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 1032 | return 0; |
| 1033 | } |
| 1034 | |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1035 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1036 | * CFG802.11 operation handler for disconnection request. |
| 1037 | * |
| 1038 | * This function does not work when there is already a disconnection |
| 1039 | * procedure going on. |
| 1040 | */ |
| 1041 | static int |
| 1042 | mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, |
| 1043 | u16 reason_code) |
| 1044 | { |
| 1045 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 1046 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1047 | if (mwifiex_deauthenticate(priv, NULL)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1048 | return -EFAULT; |
| 1049 | |
| 1050 | wiphy_dbg(wiphy, "info: successfully disconnected from %pM:" |
| 1051 | " reason code %d\n", priv->cfg_bssid, reason_code); |
| 1052 | |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1053 | memset(priv->cfg_bssid, 0, ETH_ALEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1054 | |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
| 1058 | /* |
| 1059 | * This function informs the CFG802.11 subsystem of a new IBSS. |
| 1060 | * |
| 1061 | * The following information are sent to the CFG802.11 subsystem |
| 1062 | * to register the new IBSS. If we do not register the new IBSS, |
| 1063 | * a kernel panic will result. |
| 1064 | * - SSID |
| 1065 | * - SSID length |
| 1066 | * - BSSID |
| 1067 | * - Channel |
| 1068 | */ |
| 1069 | static int mwifiex_cfg80211_inform_ibss_bss(struct mwifiex_private *priv) |
| 1070 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1071 | struct ieee80211_channel *chan; |
| 1072 | struct mwifiex_bss_info bss_info; |
Amitkumar Karwar | aa95a48 | 2011-11-07 21:41:12 -0800 | [diff] [blame] | 1073 | struct cfg80211_bss *bss; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1074 | int ie_len; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1075 | u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)]; |
Amitkumar Karwar | 4ed5d52 | 2011-09-21 21:43:24 -0700 | [diff] [blame] | 1076 | enum ieee80211_band band; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1077 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1078 | if (mwifiex_get_bss_info(priv, &bss_info)) |
| 1079 | return -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1080 | |
| 1081 | ie_buf[0] = WLAN_EID_SSID; |
| 1082 | ie_buf[1] = bss_info.ssid.ssid_len; |
| 1083 | |
| 1084 | memcpy(&ie_buf[sizeof(struct ieee_types_header)], |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1085 | &bss_info.ssid.ssid, bss_info.ssid.ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1086 | ie_len = ie_buf[1] + sizeof(struct ieee_types_header); |
| 1087 | |
Amitkumar Karwar | 4ed5d52 | 2011-09-21 21:43:24 -0700 | [diff] [blame] | 1088 | band = mwifiex_band_to_radio_type(priv->curr_bss_params.band); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1089 | chan = __ieee80211_get_channel(priv->wdev->wiphy, |
| 1090 | ieee80211_channel_to_frequency(bss_info.bss_chan, |
Amitkumar Karwar | 4ed5d52 | 2011-09-21 21:43:24 -0700 | [diff] [blame] | 1091 | band)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1092 | |
Amitkumar Karwar | aa95a48 | 2011-11-07 21:41:12 -0800 | [diff] [blame] | 1093 | bss = cfg80211_inform_bss(priv->wdev->wiphy, chan, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1094 | bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, |
| 1095 | 0, ie_buf, ie_len, 0, GFP_KERNEL); |
Amitkumar Karwar | aa95a48 | 2011-11-07 21:41:12 -0800 | [diff] [blame] | 1096 | cfg80211_put_bss(bss); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1097 | memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); |
| 1098 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1099 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1103 | * This function connects with a BSS. |
| 1104 | * |
| 1105 | * This function handles both Infra and Ad-Hoc modes. It also performs |
| 1106 | * validity checking on the provided parameters, disconnects from the |
| 1107 | * current BSS (if any), sets up the association/scan parameters, |
| 1108 | * including security settings, and performs specific SSID scan before |
| 1109 | * trying to connect. |
| 1110 | * |
| 1111 | * For Infra mode, the function returns failure if the specified SSID |
| 1112 | * is not found in scan table. However, for Ad-Hoc mode, it can create |
| 1113 | * the IBSS if it does not exist. On successful completion in either case, |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1114 | * the function notifies the CFG802.11 subsystem of the new BSS connection. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1115 | */ |
| 1116 | static int |
| 1117 | mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, |
| 1118 | u8 *bssid, int mode, struct ieee80211_channel *channel, |
| 1119 | struct cfg80211_connect_params *sme, bool privacy) |
| 1120 | { |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 1121 | struct cfg80211_ssid req_ssid; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1122 | int ret, auth_type = 0; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1123 | struct cfg80211_bss *bss = NULL; |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 1124 | u8 is_scanning_required = 0, config_bands = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1125 | |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 1126 | memset(&req_ssid, 0, sizeof(struct cfg80211_ssid)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1127 | |
| 1128 | req_ssid.ssid_len = ssid_len; |
| 1129 | if (ssid_len > IEEE80211_MAX_SSID_LEN) { |
| 1130 | dev_err(priv->adapter->dev, "invalid SSID - aborting\n"); |
| 1131 | return -EINVAL; |
| 1132 | } |
| 1133 | |
| 1134 | memcpy(req_ssid.ssid, ssid, ssid_len); |
| 1135 | if (!req_ssid.ssid_len || req_ssid.ssid[0] < 0x20) { |
| 1136 | dev_err(priv->adapter->dev, "invalid SSID - aborting\n"); |
| 1137 | return -EINVAL; |
| 1138 | } |
| 1139 | |
| 1140 | /* disconnect before try to associate */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1141 | mwifiex_deauthenticate(priv, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1142 | |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 1143 | if (channel) { |
| 1144 | if (mode == NL80211_IFTYPE_STATION) { |
| 1145 | if (channel->band == IEEE80211_BAND_2GHZ) |
| 1146 | config_bands = BAND_B | BAND_G | BAND_GN; |
| 1147 | else |
| 1148 | config_bands = BAND_A | BAND_AN; |
| 1149 | |
| 1150 | if (!((config_bands | priv->adapter->fw_bands) & |
| 1151 | ~priv->adapter->fw_bands)) |
| 1152 | priv->adapter->config_bands = config_bands; |
| 1153 | } |
| 1154 | mwifiex_send_domain_info_cmd_fw(priv->wdev->wiphy); |
| 1155 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1156 | |
Amitkumar Karwar | 6670f15 | 2012-02-09 18:32:22 -0800 | [diff] [blame] | 1157 | /* As this is new association, clear locally stored |
| 1158 | * keys and security related flags */ |
| 1159 | priv->sec_info.wpa_enabled = false; |
| 1160 | priv->sec_info.wpa2_enabled = false; |
| 1161 | priv->wep_key_curr_index = 0; |
Amitkumar Karwar | 00f157b | 2012-02-24 21:35:35 -0800 | [diff] [blame] | 1162 | priv->sec_info.encryption_mode = 0; |
Amitkumar Karwar | a0f6d6c | 2012-02-24 21:36:05 -0800 | [diff] [blame] | 1163 | priv->sec_info.is_authtype_auto = 0; |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 1164 | ret = mwifiex_set_encode(priv, NULL, 0, 0, NULL, 1); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1165 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1166 | if (mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1167 | /* "privacy" is set only for ad-hoc mode */ |
| 1168 | if (privacy) { |
| 1169 | /* |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 1170 | * Keep WLAN_CIPHER_SUITE_WEP104 for now so that |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1171 | * the firmware can find a matching network from the |
| 1172 | * scan. The cfg80211 does not give us the encryption |
| 1173 | * mode at this stage so just setting it to WEP here. |
| 1174 | */ |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 1175 | priv->sec_info.encryption_mode = |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 1176 | WLAN_CIPHER_SUITE_WEP104; |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 1177 | priv->sec_info.authentication_mode = |
Marc Yang | f986b6d | 2011-03-28 17:55:42 -0700 | [diff] [blame] | 1178 | NL80211_AUTHTYPE_OPEN_SYSTEM; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | goto done; |
| 1182 | } |
| 1183 | |
| 1184 | /* Now handle infra mode. "sme" is valid for infra mode only */ |
Amitkumar Karwar | a0f6d6c | 2012-02-24 21:36:05 -0800 | [diff] [blame] | 1185 | if (sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) { |
Marc Yang | f986b6d | 2011-03-28 17:55:42 -0700 | [diff] [blame] | 1186 | auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; |
Amitkumar Karwar | a0f6d6c | 2012-02-24 21:36:05 -0800 | [diff] [blame] | 1187 | priv->sec_info.is_authtype_auto = 1; |
| 1188 | } else { |
| 1189 | auth_type = sme->auth_type; |
| 1190 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1191 | |
| 1192 | if (sme->crypto.n_ciphers_pairwise) { |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 1193 | priv->sec_info.encryption_mode = |
| 1194 | sme->crypto.ciphers_pairwise[0]; |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 1195 | priv->sec_info.authentication_mode = auth_type; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1196 | } |
| 1197 | |
| 1198 | if (sme->crypto.cipher_group) { |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 1199 | priv->sec_info.encryption_mode = sme->crypto.cipher_group; |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 1200 | priv->sec_info.authentication_mode = auth_type; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1201 | } |
| 1202 | if (sme->ie) |
| 1203 | ret = mwifiex_set_gen_ie(priv, sme->ie, sme->ie_len); |
| 1204 | |
| 1205 | if (sme->key) { |
Amitkumar Karwar | e6faada | 2011-07-07 17:33:19 -0700 | [diff] [blame] | 1206 | if (mwifiex_is_alg_wep(priv->sec_info.encryption_mode)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1207 | dev_dbg(priv->adapter->dev, |
| 1208 | "info: setting wep encryption" |
| 1209 | " with key len %d\n", sme->key_len); |
Amitkumar Karwar | 6670f15 | 2012-02-09 18:32:22 -0800 | [diff] [blame] | 1210 | priv->wep_key_curr_index = sme->key_idx; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1211 | ret = mwifiex_set_encode(priv, sme->key, sme->key_len, |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 1212 | sme->key_idx, NULL, 0); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1213 | } |
| 1214 | } |
| 1215 | done: |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1216 | /* |
| 1217 | * Scan entries are valid for some time (15 sec). So we can save one |
| 1218 | * active scan time if we just try cfg80211_get_bss first. If it fails |
| 1219 | * then request scan and cfg80211_get_bss() again for final output. |
| 1220 | */ |
| 1221 | while (1) { |
| 1222 | if (is_scanning_required) { |
| 1223 | /* Do specific SSID scanning */ |
| 1224 | if (mwifiex_request_scan(priv, &req_ssid)) { |
| 1225 | dev_err(priv->adapter->dev, "scan error\n"); |
| 1226 | return -EFAULT; |
| 1227 | } |
| 1228 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1229 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1230 | /* Find the BSS we want using available scan results */ |
| 1231 | if (mode == NL80211_IFTYPE_ADHOC) |
| 1232 | bss = cfg80211_get_bss(priv->wdev->wiphy, channel, |
| 1233 | bssid, ssid, ssid_len, |
| 1234 | WLAN_CAPABILITY_IBSS, |
| 1235 | WLAN_CAPABILITY_IBSS); |
| 1236 | else |
| 1237 | bss = cfg80211_get_bss(priv->wdev->wiphy, channel, |
| 1238 | bssid, ssid, ssid_len, |
| 1239 | WLAN_CAPABILITY_ESS, |
| 1240 | WLAN_CAPABILITY_ESS); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1241 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1242 | if (!bss) { |
| 1243 | if (is_scanning_required) { |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1244 | dev_warn(priv->adapter->dev, |
| 1245 | "assoc: requested bss not found in scan results\n"); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1246 | break; |
| 1247 | } |
| 1248 | is_scanning_required = 1; |
| 1249 | } else { |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1250 | dev_dbg(priv->adapter->dev, |
| 1251 | "info: trying to associate to '%s' bssid %pM\n", |
| 1252 | (char *) req_ssid.ssid, bss->bssid); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1253 | memcpy(&priv->cfg_bssid, bss->bssid, ETH_ALEN); |
| 1254 | break; |
| 1255 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 1258 | if (mwifiex_bss_start(priv, bss, &req_ssid)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1259 | return -EFAULT; |
| 1260 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1261 | if (mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1262 | /* Inform the BSS information to kernel, otherwise |
| 1263 | * kernel will give a panic after successful assoc */ |
| 1264 | if (mwifiex_cfg80211_inform_ibss_bss(priv)) |
| 1265 | return -EFAULT; |
| 1266 | } |
| 1267 | |
| 1268 | return ret; |
| 1269 | } |
| 1270 | |
| 1271 | /* |
| 1272 | * CFG802.11 operation handler for association request. |
| 1273 | * |
| 1274 | * This function does not work when the current mode is set to Ad-Hoc, or |
| 1275 | * when there is already an association procedure going on. The given BSS |
| 1276 | * information is used to associate. |
| 1277 | */ |
| 1278 | static int |
| 1279 | mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, |
| 1280 | struct cfg80211_connect_params *sme) |
| 1281 | { |
| 1282 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
| 1283 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1284 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1285 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1286 | wiphy_err(wiphy, "received infra assoc request " |
| 1287 | "when station is in ibss mode\n"); |
| 1288 | goto done; |
| 1289 | } |
| 1290 | |
Avinash Patil | e568634 | 2012-05-08 18:30:25 -0700 | [diff] [blame] | 1291 | if (priv->bss_mode == NL80211_IFTYPE_AP) { |
| 1292 | wiphy_err(wiphy, "skip association request for AP interface\n"); |
| 1293 | goto done; |
| 1294 | } |
| 1295 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1296 | wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n", |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1297 | (char *) sme->ssid, sme->bssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1298 | |
| 1299 | ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid, |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1300 | priv->bss_mode, sme->channel, sme, 0); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1301 | done: |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1302 | if (!ret) { |
| 1303 | cfg80211_connect_result(priv->netdev, priv->cfg_bssid, NULL, 0, |
| 1304 | NULL, 0, WLAN_STATUS_SUCCESS, |
| 1305 | GFP_KERNEL); |
| 1306 | dev_dbg(priv->adapter->dev, |
| 1307 | "info: associated to bssid %pM successfully\n", |
| 1308 | priv->cfg_bssid); |
| 1309 | } else { |
| 1310 | dev_dbg(priv->adapter->dev, |
| 1311 | "info: association to bssid %pM failed\n", |
| 1312 | priv->cfg_bssid); |
| 1313 | memset(priv->cfg_bssid, 0, ETH_ALEN); |
| 1314 | } |
| 1315 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1316 | return ret; |
| 1317 | } |
| 1318 | |
| 1319 | /* |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 1320 | * This function sets following parameters for ibss network. |
| 1321 | * - channel |
| 1322 | * - start band |
| 1323 | * - 11n flag |
| 1324 | * - secondary channel offset |
| 1325 | */ |
| 1326 | static int mwifiex_set_ibss_params(struct mwifiex_private *priv, |
| 1327 | struct cfg80211_ibss_params *params) |
| 1328 | { |
| 1329 | struct wiphy *wiphy = priv->wdev->wiphy; |
| 1330 | struct mwifiex_adapter *adapter = priv->adapter; |
| 1331 | int index = 0, i; |
| 1332 | u8 config_bands = 0; |
| 1333 | |
| 1334 | if (params->channel->band == IEEE80211_BAND_2GHZ) { |
| 1335 | if (!params->basic_rates) { |
| 1336 | config_bands = BAND_B | BAND_G; |
| 1337 | } else { |
| 1338 | for (i = 0; i < mwifiex_band_2ghz.n_bitrates; i++) { |
| 1339 | /* |
| 1340 | * Rates below 6 Mbps in the table are CCK |
| 1341 | * rates; 802.11b and from 6 they are OFDM; |
| 1342 | * 802.11G |
| 1343 | */ |
| 1344 | if (mwifiex_rates[i].bitrate == 60) { |
| 1345 | index = 1 << i; |
| 1346 | break; |
| 1347 | } |
| 1348 | } |
| 1349 | |
| 1350 | if (params->basic_rates < index) { |
| 1351 | config_bands = BAND_B; |
| 1352 | } else { |
| 1353 | config_bands = BAND_G; |
| 1354 | if (params->basic_rates % index) |
| 1355 | config_bands |= BAND_B; |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | if (params->channel_type != NL80211_CHAN_NO_HT) |
| 1360 | config_bands |= BAND_GN; |
| 1361 | } else { |
| 1362 | if (params->channel_type == NL80211_CHAN_NO_HT) |
| 1363 | config_bands = BAND_A; |
| 1364 | else |
| 1365 | config_bands = BAND_AN | BAND_A; |
| 1366 | } |
| 1367 | |
| 1368 | if (!((config_bands | adapter->fw_bands) & ~adapter->fw_bands)) { |
| 1369 | adapter->config_bands = config_bands; |
| 1370 | adapter->adhoc_start_band = config_bands; |
| 1371 | |
| 1372 | if ((config_bands & BAND_GN) || (config_bands & BAND_AN)) |
| 1373 | adapter->adhoc_11n_enabled = true; |
| 1374 | else |
| 1375 | adapter->adhoc_11n_enabled = false; |
| 1376 | } |
| 1377 | |
| 1378 | adapter->sec_chan_offset = |
| 1379 | mwifiex_chan_type_to_sec_chan_offset(params->channel_type); |
| 1380 | priv->adhoc_channel = |
| 1381 | ieee80211_frequency_to_channel(params->channel->center_freq); |
| 1382 | |
| 1383 | wiphy_dbg(wiphy, "info: set ibss band %d, chan %d, chan offset %d\n", |
| 1384 | config_bands, priv->adhoc_channel, adapter->sec_chan_offset); |
| 1385 | |
| 1386 | return 0; |
| 1387 | } |
| 1388 | |
| 1389 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1390 | * CFG802.11 operation handler to join an IBSS. |
| 1391 | * |
| 1392 | * This function does not work in any mode other than Ad-Hoc, or if |
| 1393 | * a join operation is already in progress. |
| 1394 | */ |
| 1395 | static int |
| 1396 | mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, |
| 1397 | struct cfg80211_ibss_params *params) |
| 1398 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 1399 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1400 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1401 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1402 | if (priv->bss_mode != NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1403 | wiphy_err(wiphy, "request to join ibss received " |
| 1404 | "when station is not in ibss mode\n"); |
| 1405 | goto done; |
| 1406 | } |
| 1407 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1408 | wiphy_dbg(wiphy, "info: trying to join to %s and bssid %pM\n", |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1409 | (char *) params->ssid, params->bssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1410 | |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 1411 | mwifiex_set_ibss_params(priv, params); |
| 1412 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1413 | ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1414 | params->bssid, priv->bss_mode, |
| 1415 | params->channel, NULL, params->privacy); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1416 | done: |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1417 | if (!ret) { |
| 1418 | cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL); |
| 1419 | dev_dbg(priv->adapter->dev, |
| 1420 | "info: joined/created adhoc network with bssid" |
| 1421 | " %pM successfully\n", priv->cfg_bssid); |
| 1422 | } else { |
| 1423 | dev_dbg(priv->adapter->dev, |
| 1424 | "info: failed creating/joining adhoc network\n"); |
| 1425 | } |
| 1426 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1427 | return ret; |
| 1428 | } |
| 1429 | |
| 1430 | /* |
| 1431 | * CFG802.11 operation handler to leave an IBSS. |
| 1432 | * |
| 1433 | * This function does not work if a leave operation is |
| 1434 | * already in progress. |
| 1435 | */ |
| 1436 | static int |
| 1437 | mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) |
| 1438 | { |
Yogesh Ashok Powar | f540f9f | 2012-01-11 20:06:12 -0800 | [diff] [blame] | 1439 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1440 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1441 | wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1442 | priv->cfg_bssid); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1443 | if (mwifiex_deauthenticate(priv, NULL)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1444 | return -EFAULT; |
| 1445 | |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1446 | memset(priv->cfg_bssid, 0, ETH_ALEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1447 | |
| 1448 | return 0; |
| 1449 | } |
| 1450 | |
| 1451 | /* |
| 1452 | * CFG802.11 operation handler for scan request. |
| 1453 | * |
| 1454 | * This function issues a scan request to the firmware based upon |
| 1455 | * the user specified scan configuration. On successfull completion, |
| 1456 | * it also informs the results. |
| 1457 | */ |
| 1458 | static int |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 1459 | mwifiex_cfg80211_scan(struct wiphy *wiphy, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1460 | struct cfg80211_scan_request *request) |
| 1461 | { |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 1462 | struct net_device *dev = request->wdev->netdev; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1463 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1464 | int i; |
| 1465 | struct ieee80211_channel *chan; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1466 | |
| 1467 | wiphy_dbg(wiphy, "info: received scan request on %s\n", dev->name); |
| 1468 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1469 | priv->scan_request = request; |
| 1470 | |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1471 | priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1472 | GFP_KERNEL); |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1473 | if (!priv->user_scan_cfg) { |
| 1474 | dev_err(priv->adapter->dev, "failed to alloc scan_req\n"); |
| 1475 | return -ENOMEM; |
| 1476 | } |
Amitkumar Karwar | be0b281 | 2012-02-27 22:04:15 -0800 | [diff] [blame] | 1477 | |
| 1478 | priv->user_scan_cfg->num_ssids = request->n_ssids; |
| 1479 | priv->user_scan_cfg->ssid_list = request->ssids; |
| 1480 | |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 1481 | if (request->ie && request->ie_len) { |
| 1482 | for (i = 0; i < MWIFIEX_MAX_VSIE_NUM; i++) { |
| 1483 | if (priv->vs_ie[i].mask != MWIFIEX_VSIE_MASK_CLEAR) |
| 1484 | continue; |
| 1485 | priv->vs_ie[i].mask = MWIFIEX_VSIE_MASK_SCAN; |
| 1486 | memcpy(&priv->vs_ie[i].ie, request->ie, |
| 1487 | request->ie_len); |
| 1488 | break; |
| 1489 | } |
| 1490 | } |
| 1491 | |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1492 | for (i = 0; i < request->n_channels; i++) { |
| 1493 | chan = request->channels[i]; |
| 1494 | priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value; |
| 1495 | priv->user_scan_cfg->chan_list[i].radio_type = chan->band; |
| 1496 | |
| 1497 | if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) |
| 1498 | priv->user_scan_cfg->chan_list[i].scan_type = |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1499 | MWIFIEX_SCAN_TYPE_PASSIVE; |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1500 | else |
| 1501 | priv->user_scan_cfg->chan_list[i].scan_type = |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1502 | MWIFIEX_SCAN_TYPE_ACTIVE; |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1503 | |
| 1504 | priv->user_scan_cfg->chan_list[i].scan_time = 0; |
| 1505 | } |
Amitkumar Karwar | 1a1fb97 | 2012-06-27 19:57:56 -0700 | [diff] [blame] | 1506 | if (mwifiex_scan_networks(priv, priv->user_scan_cfg)) |
Amitkumar Karwar | 38c9d66 | 2011-12-13 20:43:17 -0800 | [diff] [blame] | 1507 | return -EFAULT; |
| 1508 | |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 1509 | if (request->ie && request->ie_len) { |
| 1510 | for (i = 0; i < MWIFIEX_MAX_VSIE_NUM; i++) { |
| 1511 | if (priv->vs_ie[i].mask == MWIFIEX_VSIE_MASK_SCAN) { |
| 1512 | priv->vs_ie[i].mask = MWIFIEX_VSIE_MASK_CLEAR; |
| 1513 | memset(&priv->vs_ie[i].ie, 0, |
| 1514 | MWIFIEX_MAX_VSIE_LEN); |
| 1515 | } |
| 1516 | } |
| 1517 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | /* |
| 1522 | * This function sets up the CFG802.11 specific HT capability fields |
| 1523 | * with default values. |
| 1524 | * |
| 1525 | * The following default values are set - |
| 1526 | * - HT Supported = True |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 1527 | * - Maximum AMPDU length factor = IEEE80211_HT_MAX_AMPDU_64K |
| 1528 | * - Minimum AMPDU spacing = IEEE80211_HT_MPDU_DENSITY_NONE |
| 1529 | * - HT Capabilities supported by firmware |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1530 | * - MCS information, Rx mask = 0xff |
| 1531 | * - MCD information, Tx parameters = IEEE80211_HT_MCS_TX_DEFINED (0x01) |
| 1532 | */ |
| 1533 | static void |
| 1534 | mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info, |
| 1535 | struct mwifiex_private *priv) |
| 1536 | { |
| 1537 | int rx_mcs_supp; |
| 1538 | struct ieee80211_mcs_info mcs_set; |
| 1539 | u8 *mcs = (u8 *)&mcs_set; |
| 1540 | struct mwifiex_adapter *adapter = priv->adapter; |
| 1541 | |
| 1542 | ht_info->ht_supported = true; |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 1543 | ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; |
| 1544 | ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1545 | |
| 1546 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1547 | |
Amitkumar Karwar | a46b7b5 | 2011-04-27 19:13:12 -0700 | [diff] [blame] | 1548 | /* Fill HT capability information */ |
| 1549 | if (ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap)) |
| 1550 | ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 1551 | else |
| 1552 | ht_info->cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 1553 | |
| 1554 | if (ISSUPP_SHORTGI20(adapter->hw_dot_11n_dev_cap)) |
| 1555 | ht_info->cap |= IEEE80211_HT_CAP_SGI_20; |
| 1556 | else |
| 1557 | ht_info->cap &= ~IEEE80211_HT_CAP_SGI_20; |
| 1558 | |
| 1559 | if (ISSUPP_SHORTGI40(adapter->hw_dot_11n_dev_cap)) |
| 1560 | ht_info->cap |= IEEE80211_HT_CAP_SGI_40; |
| 1561 | else |
| 1562 | ht_info->cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 1563 | |
| 1564 | if (ISSUPP_RXSTBC(adapter->hw_dot_11n_dev_cap)) |
| 1565 | ht_info->cap |= 1 << IEEE80211_HT_CAP_RX_STBC_SHIFT; |
| 1566 | else |
| 1567 | ht_info->cap &= ~(3 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 1568 | |
| 1569 | if (ISSUPP_TXSTBC(adapter->hw_dot_11n_dev_cap)) |
| 1570 | ht_info->cap |= IEEE80211_HT_CAP_TX_STBC; |
| 1571 | else |
| 1572 | ht_info->cap &= ~IEEE80211_HT_CAP_TX_STBC; |
| 1573 | |
| 1574 | ht_info->cap &= ~IEEE80211_HT_CAP_MAX_AMSDU; |
| 1575 | ht_info->cap |= IEEE80211_HT_CAP_SM_PS; |
| 1576 | |
| 1577 | rx_mcs_supp = GET_RXMCSSUPP(adapter->hw_dev_mcs_support); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1578 | /* Set MCS for 1x1 */ |
| 1579 | memset(mcs, 0xff, rx_mcs_supp); |
| 1580 | /* Clear all the other values */ |
| 1581 | memset(&mcs[rx_mcs_supp], 0, |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1582 | sizeof(struct ieee80211_mcs_info) - rx_mcs_supp); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1583 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
Yogesh Ashok Powar | aea0701 | 2012-03-13 19:22:35 -0700 | [diff] [blame] | 1584 | ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1585 | /* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */ |
| 1586 | SETHT_MCS32(mcs_set.rx_mask); |
| 1587 | |
| 1588 | memcpy((u8 *) &ht_info->mcs, mcs, sizeof(struct ieee80211_mcs_info)); |
| 1589 | |
| 1590 | ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; |
| 1591 | } |
| 1592 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1593 | /* |
| 1594 | * create a new virtual interface with the given name |
| 1595 | */ |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1596 | struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy, |
| 1597 | char *name, |
| 1598 | enum nl80211_iftype type, |
| 1599 | u32 *flags, |
| 1600 | struct vif_params *params) |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1601 | { |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 1602 | struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy); |
| 1603 | struct mwifiex_private *priv; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1604 | struct net_device *dev; |
| 1605 | void *mdev_priv; |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1606 | struct wireless_dev *wdev; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1607 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1608 | if (!adapter) |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1609 | return ERR_PTR(-EFAULT); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1610 | |
| 1611 | switch (type) { |
| 1612 | case NL80211_IFTYPE_UNSPECIFIED: |
| 1613 | case NL80211_IFTYPE_STATION: |
| 1614 | case NL80211_IFTYPE_ADHOC: |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1615 | priv = adapter->priv[MWIFIEX_BSS_TYPE_STA]; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1616 | if (priv->bss_mode) { |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1617 | wiphy_err(wiphy, |
| 1618 | "cannot create multiple sta/adhoc ifaces\n"); |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1619 | return ERR_PTR(-EINVAL); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1622 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 1623 | if (!wdev) |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1624 | return ERR_PTR(-ENOMEM); |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1625 | |
| 1626 | wdev->wiphy = wiphy; |
| 1627 | priv->wdev = wdev; |
| 1628 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 1629 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1630 | if (type == NL80211_IFTYPE_UNSPECIFIED) |
| 1631 | priv->bss_mode = NL80211_IFTYPE_STATION; |
| 1632 | else |
| 1633 | priv->bss_mode = type; |
| 1634 | |
| 1635 | priv->bss_type = MWIFIEX_BSS_TYPE_STA; |
| 1636 | priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II; |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1637 | priv->bss_priority = MWIFIEX_BSS_ROLE_STA; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1638 | priv->bss_role = MWIFIEX_BSS_ROLE_STA; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1639 | priv->bss_num = 0; |
| 1640 | |
| 1641 | break; |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1642 | case NL80211_IFTYPE_AP: |
| 1643 | priv = adapter->priv[MWIFIEX_BSS_TYPE_UAP]; |
| 1644 | |
| 1645 | if (priv->bss_mode) { |
| 1646 | wiphy_err(wiphy, "Can't create multiple AP interfaces"); |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1647 | return ERR_PTR(-EINVAL); |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1648 | } |
| 1649 | |
| 1650 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 1651 | if (!wdev) |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1652 | return ERR_PTR(-ENOMEM); |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1653 | |
| 1654 | priv->wdev = wdev; |
| 1655 | wdev->wiphy = wiphy; |
| 1656 | wdev->iftype = NL80211_IFTYPE_AP; |
| 1657 | |
| 1658 | priv->bss_type = MWIFIEX_BSS_TYPE_UAP; |
| 1659 | priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II; |
| 1660 | priv->bss_priority = MWIFIEX_BSS_ROLE_UAP; |
| 1661 | priv->bss_role = MWIFIEX_BSS_ROLE_UAP; |
| 1662 | priv->bss_started = 0; |
| 1663 | priv->bss_num = 0; |
| 1664 | priv->bss_mode = type; |
| 1665 | |
| 1666 | break; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1667 | default: |
| 1668 | wiphy_err(wiphy, "type not supported\n"); |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1669 | return ERR_PTR(-EINVAL); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | dev = alloc_netdev_mq(sizeof(struct mwifiex_private *), name, |
| 1673 | ether_setup, 1); |
| 1674 | if (!dev) { |
| 1675 | wiphy_err(wiphy, "no memory available for netdevice\n"); |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1676 | priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED; |
| 1677 | return ERR_PTR(-ENOMEM); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1678 | } |
| 1679 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1680 | mwifiex_init_priv_params(priv, dev); |
| 1681 | priv->netdev = dev; |
| 1682 | |
| 1683 | mwifiex_setup_ht_caps(&wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap, priv); |
| 1684 | |
| 1685 | if (adapter->config_bands & BAND_A) |
| 1686 | mwifiex_setup_ht_caps( |
| 1687 | &wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap, priv); |
| 1688 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1689 | dev_net_set(dev, wiphy_net(wiphy)); |
| 1690 | dev->ieee80211_ptr = priv->wdev; |
| 1691 | dev->ieee80211_ptr->iftype = priv->bss_mode; |
| 1692 | memcpy(dev->dev_addr, wiphy->perm_addr, ETH_ALEN); |
| 1693 | memcpy(dev->perm_addr, wiphy->perm_addr, ETH_ALEN); |
| 1694 | SET_NETDEV_DEV(dev, wiphy_dev(wiphy)); |
| 1695 | |
| 1696 | dev->flags |= IFF_BROADCAST | IFF_MULTICAST; |
| 1697 | dev->watchdog_timeo = MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT; |
| 1698 | dev->hard_header_len += MWIFIEX_MIN_DATA_HEADER_LEN; |
| 1699 | |
| 1700 | mdev_priv = netdev_priv(dev); |
| 1701 | *((unsigned long *) mdev_priv) = (unsigned long) priv; |
| 1702 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1703 | SET_NETDEV_DEV(dev, adapter->dev); |
| 1704 | |
| 1705 | /* Register network device */ |
| 1706 | if (register_netdevice(dev)) { |
| 1707 | wiphy_err(wiphy, "cannot register virtual network device\n"); |
Bing Zhao | 858faa5 | 2012-06-15 15:49:54 -0700 | [diff] [blame] | 1708 | free_netdev(dev); |
| 1709 | priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED; |
| 1710 | return ERR_PTR(-EFAULT); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1711 | } |
| 1712 | |
| 1713 | sema_init(&priv->async_sem, 1); |
| 1714 | priv->scan_pending_on_block = false; |
| 1715 | |
| 1716 | dev_dbg(adapter->dev, "info: %s: Marvell 802.11 Adapter\n", dev->name); |
| 1717 | |
| 1718 | #ifdef CONFIG_DEBUG_FS |
| 1719 | mwifiex_dev_debugfs_init(priv); |
| 1720 | #endif |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1721 | return wdev; |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1722 | } |
| 1723 | EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf); |
| 1724 | |
| 1725 | /* |
| 1726 | * del_virtual_intf: remove the virtual interface determined by dev |
| 1727 | */ |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1728 | int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1729 | { |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1730 | struct mwifiex_private *priv = mwifiex_netdev_get_priv(wdev->netdev); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1731 | |
| 1732 | #ifdef CONFIG_DEBUG_FS |
| 1733 | mwifiex_dev_debugfs_remove(priv); |
| 1734 | #endif |
| 1735 | |
| 1736 | if (!netif_queue_stopped(priv->netdev)) |
| 1737 | netif_stop_queue(priv->netdev); |
| 1738 | |
| 1739 | if (netif_carrier_ok(priv->netdev)) |
| 1740 | netif_carrier_off(priv->netdev); |
| 1741 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1742 | if (wdev->netdev->reg_state == NETREG_REGISTERED) |
| 1743 | unregister_netdevice(wdev->netdev); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1744 | |
Johannes Berg | 84efbb8 | 2012-06-16 00:00:26 +0200 | [diff] [blame] | 1745 | if (wdev->netdev->reg_state == NETREG_UNREGISTERED) |
| 1746 | free_netdev(wdev->netdev); |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1747 | |
| 1748 | /* Clear the priv in adapter */ |
| 1749 | priv->netdev = NULL; |
| 1750 | |
| 1751 | priv->media_connected = false; |
| 1752 | |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1753 | priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED; |
| 1754 | |
| 1755 | return 0; |
| 1756 | } |
| 1757 | EXPORT_SYMBOL_GPL(mwifiex_del_virtual_intf); |
| 1758 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1759 | /* station cfg80211 operations */ |
| 1760 | static struct cfg80211_ops mwifiex_cfg80211_ops = { |
Yogesh Ashok Powar | 93a1df4 | 2011-09-26 20:37:26 -0700 | [diff] [blame] | 1761 | .add_virtual_intf = mwifiex_add_virtual_intf, |
| 1762 | .del_virtual_intf = mwifiex_del_virtual_intf, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1763 | .change_virtual_intf = mwifiex_cfg80211_change_virtual_intf, |
| 1764 | .scan = mwifiex_cfg80211_scan, |
| 1765 | .connect = mwifiex_cfg80211_connect, |
| 1766 | .disconnect = mwifiex_cfg80211_disconnect, |
| 1767 | .get_station = mwifiex_cfg80211_get_station, |
Amitkumar Karwar | f85aae6 | 2012-03-15 20:51:48 -0700 | [diff] [blame] | 1768 | .dump_station = mwifiex_cfg80211_dump_station, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1769 | .set_wiphy_params = mwifiex_cfg80211_set_wiphy_params, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1770 | .join_ibss = mwifiex_cfg80211_join_ibss, |
| 1771 | .leave_ibss = mwifiex_cfg80211_leave_ibss, |
| 1772 | .add_key = mwifiex_cfg80211_add_key, |
| 1773 | .del_key = mwifiex_cfg80211_del_key, |
| 1774 | .set_default_key = mwifiex_cfg80211_set_default_key, |
| 1775 | .set_power_mgmt = mwifiex_cfg80211_set_power_mgmt, |
| 1776 | .set_tx_power = mwifiex_cfg80211_set_tx_power, |
Yogesh Ashok Powar | 5d82c53 | 2011-07-11 20:04:44 -0700 | [diff] [blame] | 1777 | .set_bitrate_mask = mwifiex_cfg80211_set_bitrate_mask, |
Avinash Patil | 12190c5 | 2012-05-08 18:30:24 -0700 | [diff] [blame] | 1778 | .start_ap = mwifiex_cfg80211_start_ap, |
| 1779 | .stop_ap = mwifiex_cfg80211_stop_ap, |
Avinash Patil | 5370c83 | 2012-06-28 20:30:28 -0700 | [diff] [blame] | 1780 | .change_beacon = mwifiex_cfg80211_change_beacon, |
Amitkumar Karwar | fa444bf | 2012-03-15 20:51:51 -0700 | [diff] [blame] | 1781 | .set_cqm_rssi_config = mwifiex_cfg80211_set_cqm_rssi_config, |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 1782 | .set_antenna = mwifiex_cfg80211_set_antenna, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1783 | }; |
| 1784 | |
| 1785 | /* |
| 1786 | * This function registers the device with CFG802.11 subsystem. |
| 1787 | * |
| 1788 | * The function creates the wireless device/wiphy, populates it with |
| 1789 | * default parameters and handler function pointers, and finally |
| 1790 | * registers the device. |
| 1791 | */ |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1792 | |
| 1793 | int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1794 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1795 | int ret; |
| 1796 | void *wdev_priv; |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1797 | struct wiphy *wiphy; |
| 1798 | struct mwifiex_private *priv = adapter->priv[MWIFIEX_BSS_TYPE_STA]; |
Amitkumar Karwar | 9e04a7c | 2012-04-09 20:06:54 -0700 | [diff] [blame] | 1799 | u8 *country_code; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1800 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1801 | /* create a new wiphy for use with cfg80211 */ |
| 1802 | wiphy = wiphy_new(&mwifiex_cfg80211_ops, |
| 1803 | sizeof(struct mwifiex_adapter *)); |
| 1804 | if (!wiphy) { |
| 1805 | dev_err(adapter->dev, "%s: creating new wiphy\n", __func__); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1806 | return -ENOMEM; |
| 1807 | } |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1808 | wiphy->max_scan_ssids = MWIFIEX_MAX_SSID_LIST_LENGTH; |
| 1809 | wiphy->max_scan_ie_len = MWIFIEX_MAX_VSIE_LEN; |
| 1810 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
| 1811 | BIT(NL80211_IFTYPE_ADHOC) | |
| 1812 | BIT(NL80211_IFTYPE_AP); |
Amitkumar Karwar | adc8959 | 2011-04-27 19:13:11 -0700 | [diff] [blame] | 1813 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1814 | wiphy->bands[IEEE80211_BAND_2GHZ] = &mwifiex_band_2ghz; |
| 1815 | if (adapter->config_bands & BAND_A) |
| 1816 | wiphy->bands[IEEE80211_BAND_5GHZ] = &mwifiex_band_5ghz; |
| 1817 | else |
| 1818 | wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1819 | |
Avinash Patil | cd8440d | 2012-05-08 18:30:16 -0700 | [diff] [blame] | 1820 | wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta; |
| 1821 | wiphy->n_iface_combinations = 1; |
| 1822 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1823 | /* Initialize cipher suits */ |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1824 | wiphy->cipher_suites = mwifiex_cipher_suites; |
| 1825 | wiphy->n_cipher_suites = ARRAY_SIZE(mwifiex_cipher_suites); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1826 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1827 | memcpy(wiphy->perm_addr, priv->curr_addr, ETH_ALEN); |
| 1828 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
Avinash Patil | 2dd2bd6 | 2012-06-28 20:30:29 -0700 | [diff] [blame] | 1829 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | |
| 1830 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; |
| 1831 | |
| 1832 | wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | |
| 1833 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1834 | |
Amitkumar Karwar | 8a279d5 | 2012-07-02 19:32:33 -0700 | [diff] [blame] | 1835 | wiphy->available_antennas_tx = BIT(adapter->number_of_antenna) - 1; |
| 1836 | wiphy->available_antennas_rx = BIT(adapter->number_of_antenna) - 1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1837 | |
Amitkumar Karwar | 05910f4 | 2012-07-13 20:09:32 -0700 | [diff] [blame] | 1838 | wiphy->features = NL80211_FEATURE_HT_IBSS; |
| 1839 | |
Amitkumar Karwar | b5abcf0 | 2012-04-16 21:36:52 -0700 | [diff] [blame] | 1840 | /* Reserve space for mwifiex specific private data for BSS */ |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1841 | wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv); |
Amitkumar Karwar | 5116f3c | 2011-09-21 21:43:23 -0700 | [diff] [blame] | 1842 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1843 | wiphy->reg_notifier = mwifiex_reg_notifier; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1844 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 1845 | /* Set struct mwifiex_adapter pointer in wiphy_priv */ |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1846 | wdev_priv = wiphy_priv(wiphy); |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 1847 | *(unsigned long *)wdev_priv = (unsigned long)adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1848 | |
Joe Perches | 2c20889 | 2012-06-04 12:44:17 +0000 | [diff] [blame] | 1849 | set_wiphy_dev(wiphy, priv->adapter->dev); |
Yogesh Ashok Powar | a7b2116 | 2011-06-13 09:49:27 +0530 | [diff] [blame] | 1850 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1851 | ret = wiphy_register(wiphy); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1852 | if (ret < 0) { |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1853 | dev_err(adapter->dev, |
| 1854 | "%s: wiphy_register failed: %d\n", __func__, ret); |
| 1855 | wiphy_free(wiphy); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1856 | return ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1857 | } |
Amitkumar Karwar | 9e04a7c | 2012-04-09 20:06:54 -0700 | [diff] [blame] | 1858 | country_code = mwifiex_11d_code_2_region(priv->adapter->region_code); |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1859 | if (country_code && regulatory_hint(wiphy, country_code)) |
| 1860 | dev_err(adapter->dev, "regulatory_hint() failed\n"); |
Amitkumar Karwar | 9e04a7c | 2012-04-09 20:06:54 -0700 | [diff] [blame] | 1861 | |
Avinash Patil | d6bffe8 | 2012-05-08 18:30:15 -0700 | [diff] [blame] | 1862 | adapter->wiphy = wiphy; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1863 | return ret; |
| 1864 | } |