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