Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: association and ad-hoc start/join |
| 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 "decl.h" |
| 21 | #include "ioctl.h" |
| 22 | #include "util.h" |
| 23 | #include "fw.h" |
| 24 | #include "main.h" |
| 25 | #include "wmm.h" |
| 26 | #include "11n.h" |
| 27 | |
| 28 | #define CAPINFO_MASK (~(BIT(15) | BIT(14) | BIT(12) | BIT(11) | BIT(9))) |
| 29 | |
| 30 | /* |
| 31 | * Append a generic IE as a pass through TLV to a TLV buffer. |
| 32 | * |
| 33 | * This function is called from the network join command preparation routine. |
| 34 | * |
| 35 | * If the IE buffer has been setup by the application, this routine appends |
| 36 | * the buffer as a pass through TLV type to the request. |
| 37 | */ |
| 38 | static int |
| 39 | mwifiex_cmd_append_generic_ie(struct mwifiex_private *priv, u8 **buffer) |
| 40 | { |
| 41 | int ret_len = 0; |
| 42 | struct mwifiex_ie_types_header ie_header; |
| 43 | |
| 44 | /* Null Checks */ |
| 45 | if (!buffer) |
| 46 | return 0; |
| 47 | if (!(*buffer)) |
| 48 | return 0; |
| 49 | |
| 50 | /* |
| 51 | * If there is a generic ie buffer setup, append it to the return |
| 52 | * parameter buffer pointer. |
| 53 | */ |
| 54 | if (priv->gen_ie_buf_len) { |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 55 | dev_dbg(priv->adapter->dev, |
| 56 | "info: %s: append generic ie len %d to %p\n", |
| 57 | __func__, priv->gen_ie_buf_len, *buffer); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 58 | |
| 59 | /* Wrap the generic IE buffer with a pass through TLV type */ |
| 60 | ie_header.type = cpu_to_le16(TLV_TYPE_PASSTHROUGH); |
| 61 | ie_header.len = cpu_to_le16(priv->gen_ie_buf_len); |
| 62 | memcpy(*buffer, &ie_header, sizeof(ie_header)); |
| 63 | |
| 64 | /* Increment the return size and the return buffer pointer |
| 65 | param */ |
| 66 | *buffer += sizeof(ie_header); |
| 67 | ret_len += sizeof(ie_header); |
| 68 | |
| 69 | /* Copy the generic IE buffer to the output buffer, advance |
| 70 | pointer */ |
| 71 | memcpy(*buffer, priv->gen_ie_buf, priv->gen_ie_buf_len); |
| 72 | |
| 73 | /* Increment the return size and the return buffer pointer |
| 74 | param */ |
| 75 | *buffer += priv->gen_ie_buf_len; |
| 76 | ret_len += priv->gen_ie_buf_len; |
| 77 | |
| 78 | /* Reset the generic IE buffer */ |
| 79 | priv->gen_ie_buf_len = 0; |
| 80 | } |
| 81 | |
| 82 | /* return the length appended to the buffer */ |
| 83 | return ret_len; |
| 84 | } |
| 85 | |
| 86 | /* |
| 87 | * Append TSF tracking info from the scan table for the target AP. |
| 88 | * |
| 89 | * This function is called from the network join command preparation routine. |
| 90 | * |
| 91 | * The TSF table TSF sent to the firmware contains two TSF values: |
| 92 | * - The TSF of the target AP from its previous beacon/probe response |
| 93 | * - The TSF timestamp of our local MAC at the time we observed the |
| 94 | * beacon/probe response. |
| 95 | * |
| 96 | * The firmware uses the timestamp values to set an initial TSF value |
| 97 | * in the MAC for the new association after a reassociation attempt. |
| 98 | */ |
| 99 | static int |
| 100 | mwifiex_cmd_append_tsf_tlv(struct mwifiex_private *priv, u8 **buffer, |
| 101 | struct mwifiex_bssdescriptor *bss_desc) |
| 102 | { |
| 103 | struct mwifiex_ie_types_tsf_timestamp tsf_tlv; |
Bing Zhao | 1a5b306 | 2011-05-02 11:00:45 -0700 | [diff] [blame] | 104 | __le64 tsf_val; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 105 | |
| 106 | /* Null Checks */ |
| 107 | if (buffer == NULL) |
| 108 | return 0; |
| 109 | if (*buffer == NULL) |
| 110 | return 0; |
| 111 | |
| 112 | memset(&tsf_tlv, 0x00, sizeof(struct mwifiex_ie_types_tsf_timestamp)); |
| 113 | |
| 114 | tsf_tlv.header.type = cpu_to_le16(TLV_TYPE_TSFTIMESTAMP); |
| 115 | tsf_tlv.header.len = cpu_to_le16(2 * sizeof(tsf_val)); |
| 116 | |
| 117 | memcpy(*buffer, &tsf_tlv, sizeof(tsf_tlv.header)); |
| 118 | *buffer += sizeof(tsf_tlv.header); |
| 119 | |
Bing Zhao | 1a5b306 | 2011-05-02 11:00:45 -0700 | [diff] [blame] | 120 | /* TSF at the time when beacon/probe_response was received */ |
| 121 | tsf_val = cpu_to_le64(bss_desc->network_tsf); |
| 122 | memcpy(*buffer, &tsf_val, sizeof(tsf_val)); |
| 123 | *buffer += sizeof(tsf_val); |
| 124 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 125 | memcpy(&tsf_val, bss_desc->time_stamp, sizeof(tsf_val)); |
| 126 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 127 | dev_dbg(priv->adapter->dev, |
| 128 | "info: %s: TSF offset calc: %016llx - %016llx\n", |
| 129 | __func__, tsf_val, bss_desc->network_tsf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 130 | |
| 131 | memcpy(*buffer, &tsf_val, sizeof(tsf_val)); |
| 132 | *buffer += sizeof(tsf_val); |
| 133 | |
| 134 | return sizeof(tsf_tlv.header) + (2 * sizeof(tsf_val)); |
| 135 | } |
| 136 | |
| 137 | /* |
| 138 | * This function finds out the common rates between rate1 and rate2. |
| 139 | * |
| 140 | * It will fill common rates in rate1 as output if found. |
| 141 | * |
| 142 | * NOTE: Setting the MSB of the basic rates needs to be taken |
| 143 | * care of, either before or after calling this function. |
| 144 | */ |
| 145 | static int mwifiex_get_common_rates(struct mwifiex_private *priv, u8 *rate1, |
| 146 | u32 rate1_size, u8 *rate2, u32 rate2_size) |
| 147 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 148 | int ret; |
| 149 | u8 *ptr = rate1, *tmp; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 150 | u32 i, j; |
| 151 | |
Yogesh Ashok Powar | 5982b47 | 2011-08-29 13:21:10 -0700 | [diff] [blame] | 152 | tmp = kmemdup(rate1, rate1_size, GFP_KERNEL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 153 | if (!tmp) { |
| 154 | dev_err(priv->adapter->dev, "failed to alloc tmp buf\n"); |
| 155 | return -ENOMEM; |
| 156 | } |
| 157 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 158 | memset(rate1, 0, rate1_size); |
| 159 | |
| 160 | for (i = 0; rate2[i] && i < rate2_size; i++) { |
| 161 | for (j = 0; tmp[j] && j < rate1_size; j++) { |
| 162 | /* Check common rate, excluding the bit for |
| 163 | basic rate */ |
| 164 | if ((rate2[i] & 0x7F) == (tmp[j] & 0x7F)) { |
| 165 | *rate1++ = tmp[j]; |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | dev_dbg(priv->adapter->dev, "info: Tx data rate set to %#x\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 172 | priv->data_rate); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 173 | |
| 174 | if (!priv->is_data_rate_auto) { |
| 175 | while (*ptr) { |
| 176 | if ((*ptr & 0x7f) == priv->data_rate) { |
| 177 | ret = 0; |
| 178 | goto done; |
| 179 | } |
| 180 | ptr++; |
| 181 | } |
| 182 | dev_err(priv->adapter->dev, "previously set fixed data rate %#x" |
| 183 | " is not compatible with the network\n", |
| 184 | priv->data_rate); |
| 185 | |
| 186 | ret = -1; |
| 187 | goto done; |
| 188 | } |
| 189 | |
| 190 | ret = 0; |
| 191 | done: |
| 192 | kfree(tmp); |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * This function creates the intersection of the rates supported by a |
| 198 | * target BSS and our adapter settings for use in an assoc/join command. |
| 199 | */ |
| 200 | static int |
| 201 | mwifiex_setup_rates_from_bssdesc(struct mwifiex_private *priv, |
| 202 | struct mwifiex_bssdescriptor *bss_desc, |
| 203 | u8 *out_rates, u32 *out_rates_size) |
| 204 | { |
| 205 | u8 card_rates[MWIFIEX_SUPPORTED_RATES]; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 206 | u32 card_rates_size; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 207 | |
| 208 | /* Copy AP supported rates */ |
| 209 | memcpy(out_rates, bss_desc->supported_rates, MWIFIEX_SUPPORTED_RATES); |
| 210 | /* Get the STA supported rates */ |
| 211 | card_rates_size = mwifiex_get_active_data_rates(priv, card_rates); |
| 212 | /* Get the common rates between AP and STA supported rates */ |
| 213 | if (mwifiex_get_common_rates(priv, out_rates, MWIFIEX_SUPPORTED_RATES, |
| 214 | card_rates, card_rates_size)) { |
| 215 | *out_rates_size = 0; |
| 216 | dev_err(priv->adapter->dev, "%s: cannot get common rates\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 217 | __func__); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 218 | return -1; |
| 219 | } |
| 220 | |
| 221 | *out_rates_size = |
| 222 | min_t(size_t, strlen(out_rates), MWIFIEX_SUPPORTED_RATES); |
| 223 | |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 228 | * This function appends a WAPI IE. |
| 229 | * |
| 230 | * This function is called from the network join command preparation routine. |
| 231 | * |
| 232 | * If the IE buffer has been setup by the application, this routine appends |
| 233 | * the buffer as a WAPI TLV type to the request. |
| 234 | */ |
| 235 | static int |
| 236 | mwifiex_cmd_append_wapi_ie(struct mwifiex_private *priv, u8 **buffer) |
| 237 | { |
| 238 | int retLen = 0; |
| 239 | struct mwifiex_ie_types_header ie_header; |
| 240 | |
| 241 | /* Null Checks */ |
| 242 | if (buffer == NULL) |
| 243 | return 0; |
| 244 | if (*buffer == NULL) |
| 245 | return 0; |
| 246 | |
| 247 | /* |
| 248 | * If there is a wapi ie buffer setup, append it to the return |
| 249 | * parameter buffer pointer. |
| 250 | */ |
| 251 | if (priv->wapi_ie_len) { |
| 252 | dev_dbg(priv->adapter->dev, "cmd: append wapi ie %d to %p\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 253 | priv->wapi_ie_len, *buffer); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 254 | |
| 255 | /* Wrap the generic IE buffer with a pass through TLV type */ |
| 256 | ie_header.type = cpu_to_le16(TLV_TYPE_WAPI_IE); |
| 257 | ie_header.len = cpu_to_le16(priv->wapi_ie_len); |
| 258 | memcpy(*buffer, &ie_header, sizeof(ie_header)); |
| 259 | |
| 260 | /* Increment the return size and the return buffer pointer |
| 261 | param */ |
| 262 | *buffer += sizeof(ie_header); |
| 263 | retLen += sizeof(ie_header); |
| 264 | |
| 265 | /* Copy the wapi IE buffer to the output buffer, advance |
| 266 | pointer */ |
| 267 | memcpy(*buffer, priv->wapi_ie, priv->wapi_ie_len); |
| 268 | |
| 269 | /* Increment the return size and the return buffer pointer |
| 270 | param */ |
| 271 | *buffer += priv->wapi_ie_len; |
| 272 | retLen += priv->wapi_ie_len; |
| 273 | |
| 274 | } |
| 275 | /* return the length appended to the buffer */ |
| 276 | return retLen; |
| 277 | } |
| 278 | |
| 279 | /* |
| 280 | * This function appends rsn ie tlv for wpa/wpa2 security modes. |
| 281 | * It is called from the network join command preparation routine. |
| 282 | */ |
| 283 | static int mwifiex_append_rsn_ie_wpa_wpa2(struct mwifiex_private *priv, |
| 284 | u8 **buffer) |
| 285 | { |
| 286 | struct mwifiex_ie_types_rsn_param_set *rsn_ie_tlv; |
| 287 | int rsn_ie_len; |
| 288 | |
| 289 | if (!buffer || !(*buffer)) |
| 290 | return 0; |
| 291 | |
| 292 | rsn_ie_tlv = (struct mwifiex_ie_types_rsn_param_set *) (*buffer); |
| 293 | rsn_ie_tlv->header.type = cpu_to_le16((u16) priv->wpa_ie[0]); |
| 294 | rsn_ie_tlv->header.type = cpu_to_le16( |
| 295 | le16_to_cpu(rsn_ie_tlv->header.type) & 0x00FF); |
| 296 | rsn_ie_tlv->header.len = cpu_to_le16((u16) priv->wpa_ie[1]); |
| 297 | rsn_ie_tlv->header.len = cpu_to_le16(le16_to_cpu(rsn_ie_tlv->header.len) |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 298 | & 0x00FF); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 299 | if (le16_to_cpu(rsn_ie_tlv->header.len) <= (sizeof(priv->wpa_ie) - 2)) |
| 300 | memcpy(rsn_ie_tlv->rsn_ie, &priv->wpa_ie[2], |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 301 | le16_to_cpu(rsn_ie_tlv->header.len)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 302 | else |
| 303 | return -1; |
| 304 | |
| 305 | rsn_ie_len = sizeof(rsn_ie_tlv->header) + |
| 306 | le16_to_cpu(rsn_ie_tlv->header.len); |
| 307 | *buffer += rsn_ie_len; |
| 308 | |
| 309 | return rsn_ie_len; |
| 310 | } |
| 311 | |
| 312 | /* |
| 313 | * This function prepares command for association. |
| 314 | * |
| 315 | * This sets the following parameters - |
| 316 | * - Peer MAC address |
| 317 | * - Listen interval |
| 318 | * - Beacon interval |
| 319 | * - Capability information |
| 320 | * |
| 321 | * ...and the following TLVs, as required - |
| 322 | * - SSID TLV |
| 323 | * - PHY TLV |
| 324 | * - SS TLV |
| 325 | * - Rates TLV |
| 326 | * - Authentication TLV |
| 327 | * - Channel TLV |
| 328 | * - WPA/WPA2 IE |
| 329 | * - 11n TLV |
| 330 | * - Vendor specific TLV |
| 331 | * - WMM TLV |
| 332 | * - WAPI IE |
| 333 | * - Generic IE |
| 334 | * - TSF TLV |
| 335 | * |
| 336 | * Preparation also includes - |
| 337 | * - Setting command ID and proper size |
| 338 | * - Ensuring correct endian-ness |
| 339 | */ |
| 340 | int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, |
| 341 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 342 | struct mwifiex_bssdescriptor *bss_desc) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 343 | { |
| 344 | struct host_cmd_ds_802_11_associate *assoc = &cmd->params.associate; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 345 | struct mwifiex_ie_types_ssid_param_set *ssid_tlv; |
| 346 | struct mwifiex_ie_types_phy_param_set *phy_tlv; |
| 347 | struct mwifiex_ie_types_ss_param_set *ss_tlv; |
| 348 | struct mwifiex_ie_types_rates_param_set *rates_tlv; |
| 349 | struct mwifiex_ie_types_auth_type *auth_tlv; |
| 350 | struct mwifiex_ie_types_chan_list_param_set *chan_tlv; |
| 351 | u8 rates[MWIFIEX_SUPPORTED_RATES]; |
| 352 | u32 rates_size; |
| 353 | u16 tmp_cap; |
| 354 | u8 *pos; |
| 355 | int rsn_ie_len = 0; |
| 356 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 357 | pos = (u8 *) assoc; |
| 358 | |
| 359 | mwifiex_cfg_tx_buf(priv, bss_desc); |
| 360 | |
| 361 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_ASSOCIATE); |
| 362 | |
| 363 | /* Save so we know which BSS Desc to use in the response handler */ |
| 364 | priv->attempted_bss_desc = bss_desc; |
| 365 | |
| 366 | memcpy(assoc->peer_sta_addr, |
| 367 | bss_desc->mac_address, sizeof(assoc->peer_sta_addr)); |
| 368 | pos += sizeof(assoc->peer_sta_addr); |
| 369 | |
| 370 | /* Set the listen interval */ |
| 371 | assoc->listen_interval = cpu_to_le16(priv->listen_interval); |
| 372 | /* Set the beacon period */ |
| 373 | assoc->beacon_period = cpu_to_le16(bss_desc->beacon_period); |
| 374 | |
| 375 | pos += sizeof(assoc->cap_info_bitmap); |
| 376 | pos += sizeof(assoc->listen_interval); |
| 377 | pos += sizeof(assoc->beacon_period); |
| 378 | pos += sizeof(assoc->dtim_period); |
| 379 | |
| 380 | ssid_tlv = (struct mwifiex_ie_types_ssid_param_set *) pos; |
| 381 | ssid_tlv->header.type = cpu_to_le16(WLAN_EID_SSID); |
| 382 | ssid_tlv->header.len = cpu_to_le16((u16) bss_desc->ssid.ssid_len); |
| 383 | memcpy(ssid_tlv->ssid, bss_desc->ssid.ssid, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 384 | le16_to_cpu(ssid_tlv->header.len)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 385 | pos += sizeof(ssid_tlv->header) + le16_to_cpu(ssid_tlv->header.len); |
| 386 | |
| 387 | phy_tlv = (struct mwifiex_ie_types_phy_param_set *) pos; |
| 388 | phy_tlv->header.type = cpu_to_le16(WLAN_EID_DS_PARAMS); |
| 389 | phy_tlv->header.len = cpu_to_le16(sizeof(phy_tlv->fh_ds.ds_param_set)); |
| 390 | memcpy(&phy_tlv->fh_ds.ds_param_set, |
| 391 | &bss_desc->phy_param_set.ds_param_set.current_chan, |
| 392 | sizeof(phy_tlv->fh_ds.ds_param_set)); |
| 393 | pos += sizeof(phy_tlv->header) + le16_to_cpu(phy_tlv->header.len); |
| 394 | |
| 395 | ss_tlv = (struct mwifiex_ie_types_ss_param_set *) pos; |
| 396 | ss_tlv->header.type = cpu_to_le16(WLAN_EID_CF_PARAMS); |
| 397 | ss_tlv->header.len = cpu_to_le16(sizeof(ss_tlv->cf_ibss.cf_param_set)); |
| 398 | pos += sizeof(ss_tlv->header) + le16_to_cpu(ss_tlv->header.len); |
| 399 | |
| 400 | /* Get the common rates supported between the driver and the BSS Desc */ |
| 401 | if (mwifiex_setup_rates_from_bssdesc |
| 402 | (priv, bss_desc, rates, &rates_size)) |
| 403 | return -1; |
| 404 | |
| 405 | /* Save the data rates into Current BSS state structure */ |
| 406 | priv->curr_bss_params.num_of_rates = rates_size; |
| 407 | memcpy(&priv->curr_bss_params.data_rates, rates, rates_size); |
| 408 | |
| 409 | /* Setup the Rates TLV in the association command */ |
| 410 | rates_tlv = (struct mwifiex_ie_types_rates_param_set *) pos; |
| 411 | rates_tlv->header.type = cpu_to_le16(WLAN_EID_SUPP_RATES); |
| 412 | rates_tlv->header.len = cpu_to_le16((u16) rates_size); |
| 413 | memcpy(rates_tlv->rates, rates, rates_size); |
| 414 | pos += sizeof(rates_tlv->header) + rates_size; |
| 415 | dev_dbg(priv->adapter->dev, "info: ASSOC_CMD: rates size = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 416 | rates_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 417 | |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 418 | /* Add the Authentication type to be used for Auth frames */ |
| 419 | auth_tlv = (struct mwifiex_ie_types_auth_type *) pos; |
| 420 | auth_tlv->header.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE); |
| 421 | auth_tlv->header.len = cpu_to_le16(sizeof(auth_tlv->auth_type)); |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 422 | if (priv->sec_info.wep_enabled) |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 423 | auth_tlv->auth_type = cpu_to_le16( |
| 424 | (u16) priv->sec_info.authentication_mode); |
| 425 | else |
Marc Yang | f986b6d | 2011-03-28 17:55:42 -0700 | [diff] [blame] | 426 | auth_tlv->auth_type = cpu_to_le16(NL80211_AUTHTYPE_OPEN_SYSTEM); |
Marc Yang | 203afec | 2011-03-24 20:49:39 -0700 | [diff] [blame] | 427 | |
| 428 | pos += sizeof(auth_tlv->header) + le16_to_cpu(auth_tlv->header.len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 429 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 430 | if (IS_SUPPORT_MULTI_BANDS(priv->adapter) && |
| 431 | !(ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && |
| 432 | (!bss_desc->disable_11n) && |
| 433 | (priv->adapter->config_bands & BAND_GN || |
| 434 | priv->adapter->config_bands & BAND_AN) && |
| 435 | (bss_desc->bcn_ht_cap) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 436 | ) |
| 437 | ) { |
| 438 | /* Append a channel TLV for the channel the attempted AP was |
| 439 | found on */ |
| 440 | chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos; |
| 441 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
| 442 | chan_tlv->header.len = |
| 443 | cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set)); |
| 444 | |
| 445 | memset(chan_tlv->chan_scan_param, 0x00, |
| 446 | sizeof(struct mwifiex_chan_scan_param_set)); |
| 447 | chan_tlv->chan_scan_param[0].chan_number = |
| 448 | (bss_desc->phy_param_set.ds_param_set.current_chan); |
| 449 | dev_dbg(priv->adapter->dev, "info: Assoc: TLV Chan = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 450 | chan_tlv->chan_scan_param[0].chan_number); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 451 | |
| 452 | chan_tlv->chan_scan_param[0].radio_type = |
| 453 | mwifiex_band_to_radio_type((u8) bss_desc->bss_band); |
| 454 | |
| 455 | dev_dbg(priv->adapter->dev, "info: Assoc: TLV Band = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 456 | chan_tlv->chan_scan_param[0].radio_type); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 457 | pos += sizeof(chan_tlv->header) + |
| 458 | sizeof(struct mwifiex_chan_scan_param_set); |
| 459 | } |
| 460 | |
| 461 | if (!priv->wps.session_enable) { |
| 462 | if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled) |
| 463 | rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos); |
| 464 | |
| 465 | if (rsn_ie_len == -1) |
| 466 | return -1; |
| 467 | } |
| 468 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 469 | if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info) && |
| 470 | (!bss_desc->disable_11n) && |
| 471 | (priv->adapter->config_bands & BAND_GN || |
| 472 | priv->adapter->config_bands & BAND_AN)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 473 | mwifiex_cmd_append_11n_tlv(priv, bss_desc, &pos); |
| 474 | |
| 475 | /* Append vendor specific IE TLV */ |
| 476 | mwifiex_cmd_append_vsie_tlv(priv, MWIFIEX_VSIE_MASK_ASSOC, &pos); |
| 477 | |
| 478 | mwifiex_wmm_process_association_req(priv, &pos, &bss_desc->wmm_ie, |
| 479 | bss_desc->bcn_ht_cap); |
| 480 | if (priv->sec_info.wapi_enabled && priv->wapi_ie_len) |
| 481 | mwifiex_cmd_append_wapi_ie(priv, &pos); |
| 482 | |
| 483 | |
| 484 | mwifiex_cmd_append_generic_ie(priv, &pos); |
| 485 | |
| 486 | mwifiex_cmd_append_tsf_tlv(priv, &pos, bss_desc); |
| 487 | |
| 488 | cmd->size = cpu_to_le16((u16) (pos - (u8 *) assoc) + S_DS_GEN); |
| 489 | |
| 490 | /* Set the Capability info at last */ |
| 491 | tmp_cap = bss_desc->cap_info_bitmap; |
| 492 | |
| 493 | if (priv->adapter->config_bands == BAND_B) |
Bing Zhao | b93f85f | 2011-03-25 19:47:01 -0700 | [diff] [blame] | 494 | tmp_cap &= ~WLAN_CAPABILITY_SHORT_SLOT_TIME; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 495 | |
| 496 | tmp_cap &= CAPINFO_MASK; |
| 497 | dev_dbg(priv->adapter->dev, "info: ASSOC_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 498 | tmp_cap, CAPINFO_MASK); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 499 | assoc->cap_info_bitmap = cpu_to_le16(tmp_cap); |
| 500 | |
| 501 | return 0; |
| 502 | } |
| 503 | |
| 504 | /* |
| 505 | * Association firmware command response handler |
| 506 | * |
| 507 | * The response buffer for the association command has the following |
| 508 | * memory layout. |
| 509 | * |
| 510 | * For cases where an association response was not received (indicated |
| 511 | * by the CapInfo and AId field): |
| 512 | * |
| 513 | * .------------------------------------------------------------. |
| 514 | * | Header(4 * sizeof(t_u16)): Standard command response hdr | |
| 515 | * .------------------------------------------------------------. |
| 516 | * | cap_info/Error Return(t_u16): | |
| 517 | * | 0xFFFF(-1): Internal error | |
| 518 | * | 0xFFFE(-2): Authentication unhandled message | |
| 519 | * | 0xFFFD(-3): Authentication refused | |
| 520 | * | 0xFFFC(-4): Timeout waiting for AP response | |
| 521 | * .------------------------------------------------------------. |
| 522 | * | status_code(t_u16): | |
| 523 | * | If cap_info is -1: | |
| 524 | * | An internal firmware failure prevented the | |
| 525 | * | command from being processed. The status_code | |
| 526 | * | will be set to 1. | |
| 527 | * | | |
| 528 | * | If cap_info is -2: | |
| 529 | * | An authentication frame was received but was | |
| 530 | * | not handled by the firmware. IEEE Status | |
| 531 | * | code for the failure is returned. | |
| 532 | * | | |
| 533 | * | If cap_info is -3: | |
| 534 | * | An authentication frame was received and the | |
| 535 | * | status_code is the IEEE Status reported in the | |
| 536 | * | response. | |
| 537 | * | | |
| 538 | * | If cap_info is -4: | |
| 539 | * | (1) Association response timeout | |
| 540 | * | (2) Authentication response timeout | |
| 541 | * .------------------------------------------------------------. |
| 542 | * | a_id(t_u16): 0xFFFF | |
| 543 | * .------------------------------------------------------------. |
| 544 | * |
| 545 | * |
| 546 | * For cases where an association response was received, the IEEE |
| 547 | * standard association response frame is returned: |
| 548 | * |
| 549 | * .------------------------------------------------------------. |
| 550 | * | Header(4 * sizeof(t_u16)): Standard command response hdr | |
| 551 | * .------------------------------------------------------------. |
| 552 | * | cap_info(t_u16): IEEE Capability | |
| 553 | * .------------------------------------------------------------. |
| 554 | * | status_code(t_u16): IEEE Status Code | |
| 555 | * .------------------------------------------------------------. |
| 556 | * | a_id(t_u16): IEEE Association ID | |
| 557 | * .------------------------------------------------------------. |
| 558 | * | IEEE IEs(variable): Any received IEs comprising the | |
| 559 | * | remaining portion of a received | |
| 560 | * | association response frame. | |
| 561 | * .------------------------------------------------------------. |
| 562 | * |
| 563 | * For simplistic handling, the status_code field can be used to determine |
| 564 | * an association success (0) or failure (non-zero). |
| 565 | */ |
| 566 | int mwifiex_ret_802_11_associate(struct mwifiex_private *priv, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 567 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 568 | { |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 569 | struct mwifiex_adapter *adapter = priv->adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 570 | int ret = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 571 | struct ieee_types_assoc_rsp *assoc_rsp; |
| 572 | struct mwifiex_bssdescriptor *bss_desc; |
| 573 | u8 enable_data = true; |
| 574 | |
| 575 | assoc_rsp = (struct ieee_types_assoc_rsp *) &resp->params; |
| 576 | |
| 577 | priv->assoc_rsp_size = min(le16_to_cpu(resp->size) - S_DS_GEN, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 578 | sizeof(priv->assoc_rsp_buf)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 579 | |
| 580 | memcpy(priv->assoc_rsp_buf, &resp->params, priv->assoc_rsp_size); |
| 581 | |
| 582 | if (le16_to_cpu(assoc_rsp->status_code)) { |
| 583 | priv->adapter->dbg.num_cmd_assoc_failure++; |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 584 | dev_err(priv->adapter->dev, |
| 585 | "ASSOC_RESP: failed, status code=%d err=%#x a_id=%#x\n", |
| 586 | le16_to_cpu(assoc_rsp->status_code), |
| 587 | le16_to_cpu(assoc_rsp->cap_info_bitmap), |
| 588 | le16_to_cpu(assoc_rsp->a_id)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 589 | |
Amitkumar Karwar | a0f6d6c | 2012-02-24 21:36:05 -0800 | [diff] [blame] | 590 | ret = le16_to_cpu(assoc_rsp->status_code); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 591 | goto done; |
| 592 | } |
| 593 | |
| 594 | /* Send a Media Connected event, according to the Spec */ |
| 595 | priv->media_connected = true; |
| 596 | |
| 597 | priv->adapter->ps_state = PS_STATE_AWAKE; |
| 598 | priv->adapter->pps_uapsd_mode = false; |
| 599 | priv->adapter->tx_lock_flag = false; |
| 600 | |
| 601 | /* Set the attempted BSSID Index to current */ |
| 602 | bss_desc = priv->attempted_bss_desc; |
| 603 | |
| 604 | dev_dbg(priv->adapter->dev, "info: ASSOC_RESP: %s\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 605 | bss_desc->ssid.ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 606 | |
| 607 | /* Make a copy of current BSSID descriptor */ |
| 608 | memcpy(&priv->curr_bss_params.bss_descriptor, |
| 609 | bss_desc, sizeof(struct mwifiex_bssdescriptor)); |
| 610 | |
| 611 | /* Update curr_bss_params */ |
| 612 | priv->curr_bss_params.bss_descriptor.channel |
| 613 | = bss_desc->phy_param_set.ds_param_set.current_chan; |
| 614 | |
| 615 | priv->curr_bss_params.band = (u8) bss_desc->bss_band; |
| 616 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 617 | if (bss_desc->wmm_ie.vend_hdr.element_id == WLAN_EID_VENDOR_SPECIFIC) |
| 618 | priv->curr_bss_params.wmm_enabled = true; |
| 619 | else |
| 620 | priv->curr_bss_params.wmm_enabled = false; |
| 621 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 622 | if ((priv->wmm_required || bss_desc->bcn_ht_cap) && |
| 623 | priv->curr_bss_params.wmm_enabled) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 624 | priv->wmm_enabled = true; |
| 625 | else |
| 626 | priv->wmm_enabled = false; |
| 627 | |
| 628 | priv->curr_bss_params.wmm_uapsd_enabled = false; |
| 629 | |
| 630 | if (priv->wmm_enabled) |
| 631 | priv->curr_bss_params.wmm_uapsd_enabled |
| 632 | = ((bss_desc->wmm_ie.qos_info_bitmap & |
| 633 | IEEE80211_WMM_IE_AP_QOSINFO_UAPSD) ? 1 : 0); |
| 634 | |
| 635 | dev_dbg(priv->adapter->dev, "info: ASSOC_RESP: curr_pkt_filter is %#x\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 636 | priv->curr_pkt_filter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 637 | if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled) |
| 638 | priv->wpa_is_gtk_set = false; |
| 639 | |
| 640 | if (priv->wmm_enabled) { |
| 641 | /* Don't re-enable carrier until we get the WMM_GET_STATUS |
| 642 | event */ |
| 643 | enable_data = false; |
| 644 | } else { |
| 645 | /* Since WMM is not enabled, setup the queues with the |
| 646 | defaults */ |
| 647 | mwifiex_wmm_setup_queue_priorities(priv, NULL); |
| 648 | mwifiex_wmm_setup_ac_downgrade(priv); |
| 649 | } |
| 650 | |
| 651 | if (enable_data) |
| 652 | dev_dbg(priv->adapter->dev, |
| 653 | "info: post association, re-enabling data flow\n"); |
| 654 | |
| 655 | /* Reset SNR/NF/RSSI values */ |
| 656 | priv->data_rssi_last = 0; |
| 657 | priv->data_nf_last = 0; |
| 658 | priv->data_rssi_avg = 0; |
| 659 | priv->data_nf_avg = 0; |
| 660 | priv->bcn_rssi_last = 0; |
| 661 | priv->bcn_nf_last = 0; |
| 662 | priv->bcn_rssi_avg = 0; |
| 663 | priv->bcn_nf_avg = 0; |
| 664 | priv->rxpd_rate = 0; |
| 665 | priv->rxpd_htinfo = 0; |
| 666 | |
| 667 | mwifiex_save_curr_bcn(priv); |
| 668 | |
| 669 | priv->adapter->dbg.num_cmd_assoc_success++; |
| 670 | |
| 671 | dev_dbg(priv->adapter->dev, "info: ASSOC_RESP: associated\n"); |
| 672 | |
| 673 | /* Add the ra_list here for infra mode as there will be only 1 ra |
| 674 | always */ |
| 675 | mwifiex_ralist_add(priv, |
| 676 | priv->curr_bss_params.bss_descriptor.mac_address); |
| 677 | |
| 678 | if (!netif_carrier_ok(priv->netdev)) |
| 679 | netif_carrier_on(priv->netdev); |
| 680 | if (netif_queue_stopped(priv->netdev)) |
| 681 | netif_wake_queue(priv->netdev); |
| 682 | |
| 683 | if (priv->sec_info.wpa_enabled || priv->sec_info.wpa2_enabled) |
| 684 | priv->scan_block = true; |
| 685 | |
| 686 | done: |
| 687 | /* Need to indicate IOCTL complete */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 688 | if (adapter->curr_cmd->wait_q_enabled) { |
| 689 | if (ret) |
| 690 | adapter->cmd_wait_q.status = -1; |
| 691 | else |
| 692 | adapter->cmd_wait_q.status = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | return ret; |
| 696 | } |
| 697 | |
| 698 | /* |
| 699 | * This function prepares command for ad-hoc start. |
| 700 | * |
| 701 | * Driver will fill up SSID, BSS mode, IBSS parameters, physical |
| 702 | * parameters, probe delay, and capability information. Firmware |
| 703 | * will fill up beacon period, basic rates and operational rates. |
| 704 | * |
| 705 | * In addition, the following TLVs are added - |
| 706 | * - Channel TLV |
| 707 | * - Vendor specific IE |
| 708 | * - WPA/WPA2 IE |
| 709 | * - HT Capabilities IE |
| 710 | * - HT Information IE |
| 711 | * |
| 712 | * Preparation also includes - |
| 713 | * - Setting command ID and proper size |
| 714 | * - Ensuring correct endian-ness |
| 715 | */ |
| 716 | int |
| 717 | mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 718 | struct host_cmd_ds_command *cmd, |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 719 | struct cfg80211_ssid *req_ssid) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 720 | { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 721 | int rsn_ie_len = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 722 | struct mwifiex_adapter *adapter = priv->adapter; |
| 723 | struct host_cmd_ds_802_11_ad_hoc_start *adhoc_start = |
| 724 | &cmd->params.adhoc_start; |
| 725 | struct mwifiex_bssdescriptor *bss_desc; |
| 726 | u32 cmd_append_size = 0; |
| 727 | u32 i; |
| 728 | u16 tmp_cap; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 729 | struct mwifiex_ie_types_chan_list_param_set *chan_tlv; |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 730 | u8 radio_type; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 731 | |
| 732 | struct mwifiex_ie_types_htcap *ht_cap; |
| 733 | struct mwifiex_ie_types_htinfo *ht_info; |
| 734 | u8 *pos = (u8 *) adhoc_start + |
| 735 | sizeof(struct host_cmd_ds_802_11_ad_hoc_start); |
| 736 | |
| 737 | if (!adapter) |
| 738 | return -1; |
| 739 | |
| 740 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_START); |
| 741 | |
| 742 | bss_desc = &priv->curr_bss_params.bss_descriptor; |
| 743 | priv->attempted_bss_desc = bss_desc; |
| 744 | |
| 745 | /* |
| 746 | * Fill in the parameters for 2 data structures: |
| 747 | * 1. struct host_cmd_ds_802_11_ad_hoc_start command |
| 748 | * 2. bss_desc |
| 749 | * Driver will fill up SSID, bss_mode,IBSS param, Physical Param, |
| 750 | * probe delay, and Cap info. |
| 751 | * Firmware will fill up beacon period, Basic rates |
| 752 | * and operational rates. |
| 753 | */ |
| 754 | |
| 755 | memset(adhoc_start->ssid, 0, IEEE80211_MAX_SSID_LEN); |
| 756 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 757 | memcpy(adhoc_start->ssid, req_ssid->ssid, req_ssid->ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 758 | |
| 759 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: SSID = %s\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 760 | adhoc_start->ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 761 | |
| 762 | memset(bss_desc->ssid.ssid, 0, IEEE80211_MAX_SSID_LEN); |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 763 | memcpy(bss_desc->ssid.ssid, req_ssid->ssid, req_ssid->ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 764 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 765 | bss_desc->ssid.ssid_len = req_ssid->ssid_len; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 766 | |
| 767 | /* Set the BSS mode */ |
| 768 | adhoc_start->bss_mode = HostCmd_BSS_MODE_IBSS; |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 769 | bss_desc->bss_mode = NL80211_IFTYPE_ADHOC; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 770 | adhoc_start->beacon_period = cpu_to_le16(priv->beacon_period); |
| 771 | bss_desc->beacon_period = priv->beacon_period; |
| 772 | |
| 773 | /* Set Physical param set */ |
| 774 | /* Parameter IE Id */ |
| 775 | #define DS_PARA_IE_ID 3 |
| 776 | /* Parameter IE length */ |
| 777 | #define DS_PARA_IE_LEN 1 |
| 778 | |
| 779 | adhoc_start->phy_param_set.ds_param_set.element_id = DS_PARA_IE_ID; |
| 780 | adhoc_start->phy_param_set.ds_param_set.len = DS_PARA_IE_LEN; |
| 781 | |
Yogesh Ashok Powar | 6685d10 | 2012-03-12 19:35:10 -0700 | [diff] [blame] | 782 | if (!mwifiex_get_cfp(priv, adapter->adhoc_start_band, |
| 783 | (u16) priv->adhoc_channel, 0)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 784 | struct mwifiex_chan_freq_power *cfp; |
Yogesh Ashok Powar | 6685d10 | 2012-03-12 19:35:10 -0700 | [diff] [blame] | 785 | cfp = mwifiex_get_cfp(priv, adapter->adhoc_start_band, |
| 786 | FIRST_VALID_CHANNEL, 0); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 787 | if (cfp) |
| 788 | priv->adhoc_channel = (u8) cfp->channel; |
| 789 | } |
| 790 | |
| 791 | if (!priv->adhoc_channel) { |
| 792 | dev_err(adapter->dev, "ADHOC_S_CMD: adhoc_channel cannot be 0\n"); |
| 793 | return -1; |
| 794 | } |
| 795 | |
| 796 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: creating ADHOC on channel %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 797 | priv->adhoc_channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 798 | |
| 799 | priv->curr_bss_params.bss_descriptor.channel = priv->adhoc_channel; |
| 800 | priv->curr_bss_params.band = adapter->adhoc_start_band; |
| 801 | |
| 802 | bss_desc->channel = priv->adhoc_channel; |
| 803 | adhoc_start->phy_param_set.ds_param_set.current_chan = |
| 804 | priv->adhoc_channel; |
| 805 | |
| 806 | memcpy(&bss_desc->phy_param_set, &adhoc_start->phy_param_set, |
| 807 | sizeof(union ieee_types_phy_param_set)); |
| 808 | |
| 809 | /* Set IBSS param set */ |
| 810 | /* IBSS parameter IE Id */ |
| 811 | #define IBSS_PARA_IE_ID 6 |
| 812 | /* IBSS parameter IE length */ |
| 813 | #define IBSS_PARA_IE_LEN 2 |
| 814 | |
| 815 | adhoc_start->ss_param_set.ibss_param_set.element_id = IBSS_PARA_IE_ID; |
| 816 | adhoc_start->ss_param_set.ibss_param_set.len = IBSS_PARA_IE_LEN; |
| 817 | adhoc_start->ss_param_set.ibss_param_set.atim_window |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 818 | = cpu_to_le16(priv->atim_window); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 819 | memcpy(&bss_desc->ss_param_set, &adhoc_start->ss_param_set, |
| 820 | sizeof(union ieee_types_ss_param_set)); |
| 821 | |
| 822 | /* Set Capability info */ |
| 823 | bss_desc->cap_info_bitmap |= WLAN_CAPABILITY_IBSS; |
| 824 | tmp_cap = le16_to_cpu(adhoc_start->cap_info_bitmap); |
| 825 | tmp_cap &= ~WLAN_CAPABILITY_ESS; |
| 826 | tmp_cap |= WLAN_CAPABILITY_IBSS; |
| 827 | |
| 828 | /* Set up privacy in bss_desc */ |
Yogesh Ashok Powar | 2be50b8 | 2011-04-01 18:36:47 -0700 | [diff] [blame] | 829 | if (priv->sec_info.encryption_mode) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 830 | /* Ad-Hoc capability privacy on */ |
| 831 | dev_dbg(adapter->dev, |
| 832 | "info: ADHOC_S_CMD: wep_status set privacy to WEP\n"); |
| 833 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP; |
| 834 | tmp_cap |= WLAN_CAPABILITY_PRIVACY; |
| 835 | } else { |
| 836 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: wep_status NOT set," |
| 837 | " setting privacy to ACCEPT ALL\n"); |
| 838 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; |
| 839 | } |
| 840 | |
Yogesh Ashok Powar | 63af633 | 2011-11-07 21:41:09 -0800 | [diff] [blame] | 841 | memset(adhoc_start->data_rate, 0, sizeof(adhoc_start->data_rate)); |
| 842 | mwifiex_get_active_data_rates(priv, adhoc_start->data_rate); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 843 | if ((adapter->adhoc_start_band & BAND_G) && |
| 844 | (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 845 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 846 | HostCmd_ACT_GEN_SET, 0, |
| 847 | &priv->curr_pkt_filter)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 848 | dev_err(adapter->dev, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 849 | "ADHOC_S_CMD: G Protection config failed\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 850 | return -1; |
| 851 | } |
| 852 | } |
| 853 | /* Find the last non zero */ |
Yogesh Ashok Powar | 63af633 | 2011-11-07 21:41:09 -0800 | [diff] [blame] | 854 | for (i = 0; i < sizeof(adhoc_start->data_rate); i++) |
| 855 | if (!adhoc_start->data_rate[i]) |
| 856 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 857 | |
| 858 | priv->curr_bss_params.num_of_rates = i; |
| 859 | |
| 860 | /* Copy the ad-hoc creating rates into Current BSS rate structure */ |
| 861 | memcpy(&priv->curr_bss_params.data_rates, |
Yogesh Ashok Powar | 63af633 | 2011-11-07 21:41:09 -0800 | [diff] [blame] | 862 | &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 863 | |
| 864 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 865 | adhoc_start->data_rate[0], adhoc_start->data_rate[1], |
| 866 | adhoc_start->data_rate[2], adhoc_start->data_rate[3]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 867 | |
| 868 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); |
| 869 | |
| 870 | if (IS_SUPPORT_MULTI_BANDS(adapter)) { |
| 871 | /* Append a channel TLV */ |
| 872 | chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos; |
| 873 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
| 874 | chan_tlv->header.len = |
| 875 | cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set)); |
| 876 | |
| 877 | memset(chan_tlv->chan_scan_param, 0x00, |
| 878 | sizeof(struct mwifiex_chan_scan_param_set)); |
| 879 | chan_tlv->chan_scan_param[0].chan_number = |
| 880 | (u8) priv->curr_bss_params.bss_descriptor.channel; |
| 881 | |
| 882 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: TLV Chan = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 883 | chan_tlv->chan_scan_param[0].chan_number); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 884 | |
| 885 | chan_tlv->chan_scan_param[0].radio_type |
| 886 | = mwifiex_band_to_radio_type(priv->curr_bss_params.band); |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 887 | if (adapter->adhoc_start_band & BAND_GN || |
| 888 | adapter->adhoc_start_band & BAND_AN) { |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 889 | if (adapter->sec_chan_offset == |
| 890 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 891 | chan_tlv->chan_scan_param[0].radio_type |= |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 892 | (IEEE80211_HT_PARAM_CHA_SEC_ABOVE << 4); |
| 893 | else if (adapter->sec_chan_offset == |
| 894 | IEEE80211_HT_PARAM_CHA_SEC_ABOVE) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 895 | chan_tlv->chan_scan_param[0].radio_type |= |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 896 | (IEEE80211_HT_PARAM_CHA_SEC_BELOW << 4); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 897 | } |
| 898 | dev_dbg(adapter->dev, "info: ADHOC_S_CMD: TLV Band = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 899 | chan_tlv->chan_scan_param[0].radio_type); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 900 | pos += sizeof(chan_tlv->header) + |
| 901 | sizeof(struct mwifiex_chan_scan_param_set); |
| 902 | cmd_append_size += |
| 903 | sizeof(chan_tlv->header) + |
| 904 | sizeof(struct mwifiex_chan_scan_param_set); |
| 905 | } |
| 906 | |
| 907 | /* Append vendor specific IE TLV */ |
| 908 | cmd_append_size += mwifiex_cmd_append_vsie_tlv(priv, |
| 909 | MWIFIEX_VSIE_MASK_ADHOC, &pos); |
| 910 | |
| 911 | if (priv->sec_info.wpa_enabled) { |
| 912 | rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos); |
| 913 | if (rsn_ie_len == -1) |
| 914 | return -1; |
| 915 | cmd_append_size += rsn_ie_len; |
| 916 | } |
| 917 | |
| 918 | if (adapter->adhoc_11n_enabled) { |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 919 | /* Fill HT CAPABILITY */ |
| 920 | ht_cap = (struct mwifiex_ie_types_htcap *) pos; |
| 921 | memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); |
| 922 | ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); |
| 923 | ht_cap->header.len = |
| 924 | cpu_to_le16(sizeof(struct ieee80211_ht_cap)); |
| 925 | radio_type = mwifiex_band_to_radio_type( |
| 926 | priv->adapter->config_bands); |
| 927 | mwifiex_fill_cap_info(priv, radio_type, ht_cap); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 928 | |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 929 | pos += sizeof(struct mwifiex_ie_types_htcap); |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 930 | cmd_append_size += sizeof(struct mwifiex_ie_types_htcap); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 931 | |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 932 | /* Fill HT INFORMATION */ |
| 933 | ht_info = (struct mwifiex_ie_types_htinfo *) pos; |
| 934 | memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo)); |
| 935 | ht_info->header.type = cpu_to_le16(WLAN_EID_HT_INFORMATION); |
| 936 | ht_info->header.len = |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 937 | cpu_to_le16(sizeof(struct ieee80211_ht_info)); |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 938 | |
| 939 | ht_info->ht_info.control_chan = |
| 940 | (u8) priv->curr_bss_params.bss_descriptor.channel; |
Amitkumar Karwar | 21c3ba3 | 2011-12-20 23:47:21 -0800 | [diff] [blame] | 941 | if (adapter->sec_chan_offset) { |
| 942 | ht_info->ht_info.ht_param = adapter->sec_chan_offset; |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 943 | ht_info->ht_info.ht_param |= |
Marc Yang | 6d2bd91 | 2011-03-25 19:47:02 -0700 | [diff] [blame] | 944 | IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 945 | } |
Yogesh Ashok Powar | eedf15d | 2011-11-07 21:41:07 -0800 | [diff] [blame] | 946 | ht_info->ht_info.operation_mode = |
| 947 | cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); |
| 948 | ht_info->ht_info.basic_set[0] = 0xff; |
| 949 | pos += sizeof(struct mwifiex_ie_types_htinfo); |
| 950 | cmd_append_size += |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 951 | sizeof(struct mwifiex_ie_types_htinfo); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 952 | } |
| 953 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 954 | cmd->size = |
| 955 | cpu_to_le16((u16)(sizeof(struct host_cmd_ds_802_11_ad_hoc_start) |
| 956 | + S_DS_GEN + cmd_append_size)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 957 | |
| 958 | if (adapter->adhoc_start_band == BAND_B) |
Bing Zhao | b93f85f | 2011-03-25 19:47:01 -0700 | [diff] [blame] | 959 | tmp_cap &= ~WLAN_CAPABILITY_SHORT_SLOT_TIME; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 960 | else |
Bing Zhao | b93f85f | 2011-03-25 19:47:01 -0700 | [diff] [blame] | 961 | tmp_cap |= WLAN_CAPABILITY_SHORT_SLOT_TIME; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 962 | |
| 963 | adhoc_start->cap_info_bitmap = cpu_to_le16(tmp_cap); |
| 964 | |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | /* |
| 969 | * This function prepares command for ad-hoc join. |
| 970 | * |
| 971 | * Most of the parameters are set up by copying from the target BSS descriptor |
| 972 | * from the scan response. |
| 973 | * |
| 974 | * In addition, the following TLVs are added - |
| 975 | * - Channel TLV |
| 976 | * - Vendor specific IE |
| 977 | * - WPA/WPA2 IE |
| 978 | * - 11n IE |
| 979 | * |
| 980 | * Preparation also includes - |
| 981 | * - Setting command ID and proper size |
| 982 | * - Ensuring correct endian-ness |
| 983 | */ |
| 984 | int |
| 985 | mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 986 | struct host_cmd_ds_command *cmd, |
| 987 | struct mwifiex_bssdescriptor *bss_desc) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 988 | { |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 989 | int rsn_ie_len = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 990 | struct host_cmd_ds_802_11_ad_hoc_join *adhoc_join = |
| 991 | &cmd->params.adhoc_join; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 992 | struct mwifiex_ie_types_chan_list_param_set *chan_tlv; |
| 993 | u32 cmd_append_size = 0; |
| 994 | u16 tmp_cap; |
| 995 | u32 i, rates_size = 0; |
| 996 | u16 curr_pkt_filter; |
| 997 | u8 *pos = |
| 998 | (u8 *) adhoc_join + |
| 999 | sizeof(struct host_cmd_ds_802_11_ad_hoc_join); |
| 1000 | |
| 1001 | /* Use G protection */ |
| 1002 | #define USE_G_PROTECTION 0x02 |
| 1003 | if (bss_desc->erp_flags & USE_G_PROTECTION) { |
| 1004 | curr_pkt_filter = |
| 1005 | priv-> |
| 1006 | curr_pkt_filter | HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON; |
| 1007 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1008 | if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1009 | HostCmd_ACT_GEN_SET, 0, |
| 1010 | &curr_pkt_filter)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1011 | dev_err(priv->adapter->dev, |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1012 | "ADHOC_J_CMD: G Protection config failed\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1013 | return -1; |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | priv->attempted_bss_desc = bss_desc; |
| 1018 | |
| 1019 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_JOIN); |
| 1020 | |
| 1021 | adhoc_join->bss_descriptor.bss_mode = HostCmd_BSS_MODE_IBSS; |
| 1022 | |
| 1023 | adhoc_join->bss_descriptor.beacon_period |
| 1024 | = cpu_to_le16(bss_desc->beacon_period); |
| 1025 | |
| 1026 | memcpy(&adhoc_join->bss_descriptor.bssid, |
| 1027 | &bss_desc->mac_address, ETH_ALEN); |
| 1028 | |
| 1029 | memcpy(&adhoc_join->bss_descriptor.ssid, |
| 1030 | &bss_desc->ssid.ssid, bss_desc->ssid.ssid_len); |
| 1031 | |
| 1032 | memcpy(&adhoc_join->bss_descriptor.phy_param_set, |
| 1033 | &bss_desc->phy_param_set, |
| 1034 | sizeof(union ieee_types_phy_param_set)); |
| 1035 | |
| 1036 | memcpy(&adhoc_join->bss_descriptor.ss_param_set, |
| 1037 | &bss_desc->ss_param_set, sizeof(union ieee_types_ss_param_set)); |
| 1038 | |
| 1039 | tmp_cap = bss_desc->cap_info_bitmap; |
| 1040 | |
| 1041 | tmp_cap &= CAPINFO_MASK; |
| 1042 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1043 | dev_dbg(priv->adapter->dev, |
| 1044 | "info: ADHOC_J_CMD: tmp_cap=%4X CAPINFO_MASK=%4lX\n", |
| 1045 | tmp_cap, CAPINFO_MASK); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1046 | |
| 1047 | /* Information on BSSID descriptor passed to FW */ |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1048 | dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: BSSID=%pM, SSID='%s'\n", |
| 1049 | adhoc_join->bss_descriptor.bssid, |
| 1050 | adhoc_join->bss_descriptor.ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1051 | |
| 1052 | for (i = 0; bss_desc->supported_rates[i] && |
| 1053 | i < MWIFIEX_SUPPORTED_RATES; |
| 1054 | i++) |
| 1055 | ; |
| 1056 | rates_size = i; |
| 1057 | |
| 1058 | /* Copy Data Rates from the Rates recorded in scan response */ |
| 1059 | memset(adhoc_join->bss_descriptor.data_rates, 0, |
| 1060 | sizeof(adhoc_join->bss_descriptor.data_rates)); |
| 1061 | memcpy(adhoc_join->bss_descriptor.data_rates, |
| 1062 | bss_desc->supported_rates, rates_size); |
| 1063 | |
| 1064 | /* Copy the adhoc join rates into Current BSS state structure */ |
| 1065 | priv->curr_bss_params.num_of_rates = rates_size; |
| 1066 | memcpy(&priv->curr_bss_params.data_rates, bss_desc->supported_rates, |
| 1067 | rates_size); |
| 1068 | |
| 1069 | /* Copy the channel information */ |
| 1070 | priv->curr_bss_params.bss_descriptor.channel = bss_desc->channel; |
| 1071 | priv->curr_bss_params.band = (u8) bss_desc->bss_band; |
| 1072 | |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 1073 | if (priv->sec_info.wep_enabled || priv->sec_info.wpa_enabled) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1074 | tmp_cap |= WLAN_CAPABILITY_PRIVACY; |
| 1075 | |
| 1076 | if (IS_SUPPORT_MULTI_BANDS(priv->adapter)) { |
| 1077 | /* Append a channel TLV */ |
| 1078 | chan_tlv = (struct mwifiex_ie_types_chan_list_param_set *) pos; |
| 1079 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
| 1080 | chan_tlv->header.len = |
| 1081 | cpu_to_le16(sizeof(struct mwifiex_chan_scan_param_set)); |
| 1082 | |
| 1083 | memset(chan_tlv->chan_scan_param, 0x00, |
| 1084 | sizeof(struct mwifiex_chan_scan_param_set)); |
| 1085 | chan_tlv->chan_scan_param[0].chan_number = |
| 1086 | (bss_desc->phy_param_set.ds_param_set.current_chan); |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1087 | dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Chan=%d\n", |
| 1088 | chan_tlv->chan_scan_param[0].chan_number); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1089 | |
| 1090 | chan_tlv->chan_scan_param[0].radio_type = |
| 1091 | mwifiex_band_to_radio_type((u8) bss_desc->bss_band); |
| 1092 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1093 | dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: TLV Band=%d\n", |
| 1094 | chan_tlv->chan_scan_param[0].radio_type); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1095 | pos += sizeof(chan_tlv->header) + |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1096 | sizeof(struct mwifiex_chan_scan_param_set); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1097 | cmd_append_size += sizeof(chan_tlv->header) + |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1098 | sizeof(struct mwifiex_chan_scan_param_set); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | if (priv->sec_info.wpa_enabled) |
| 1102 | rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2(priv, &pos); |
| 1103 | if (rsn_ie_len == -1) |
| 1104 | return -1; |
| 1105 | cmd_append_size += rsn_ie_len; |
| 1106 | |
| 1107 | if (ISSUPP_11NENABLED(priv->adapter->fw_cap_info)) |
| 1108 | cmd_append_size += mwifiex_cmd_append_11n_tlv(priv, |
| 1109 | bss_desc, &pos); |
| 1110 | |
| 1111 | /* Append vendor specific IE TLV */ |
| 1112 | cmd_append_size += mwifiex_cmd_append_vsie_tlv(priv, |
| 1113 | MWIFIEX_VSIE_MASK_ADHOC, &pos); |
| 1114 | |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1115 | cmd->size = cpu_to_le16 |
| 1116 | ((u16) (sizeof(struct host_cmd_ds_802_11_ad_hoc_join) |
| 1117 | + S_DS_GEN + cmd_append_size)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1118 | |
| 1119 | adhoc_join->bss_descriptor.cap_info_bitmap = cpu_to_le16(tmp_cap); |
| 1120 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1121 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
| 1124 | /* |
| 1125 | * This function handles the command response of ad-hoc start and |
| 1126 | * ad-hoc join. |
| 1127 | * |
| 1128 | * The function generates a device-connected event to notify |
| 1129 | * the applications, in case of successful ad-hoc start/join, and |
| 1130 | * saves the beacon buffer. |
| 1131 | */ |
| 1132 | int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1133 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1134 | { |
| 1135 | int ret = 0; |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1136 | struct mwifiex_adapter *adapter = priv->adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1137 | struct host_cmd_ds_802_11_ad_hoc_result *adhoc_result; |
| 1138 | struct mwifiex_bssdescriptor *bss_desc; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1139 | |
| 1140 | adhoc_result = &resp->params.adhoc_result; |
| 1141 | |
| 1142 | bss_desc = priv->attempted_bss_desc; |
| 1143 | |
| 1144 | /* Join result code 0 --> SUCCESS */ |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1145 | if (le16_to_cpu(resp->result)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1146 | dev_err(priv->adapter->dev, "ADHOC_RESP: failed\n"); |
| 1147 | if (priv->media_connected) |
| 1148 | mwifiex_reset_connect_state(priv); |
| 1149 | |
| 1150 | memset(&priv->curr_bss_params.bss_descriptor, |
| 1151 | 0x00, sizeof(struct mwifiex_bssdescriptor)); |
| 1152 | |
| 1153 | ret = -1; |
| 1154 | goto done; |
| 1155 | } |
| 1156 | |
| 1157 | /* Send a Media Connected event, according to the Spec */ |
| 1158 | priv->media_connected = true; |
| 1159 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1160 | if (le16_to_cpu(resp->command) == HostCmd_CMD_802_11_AD_HOC_START) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1161 | dev_dbg(priv->adapter->dev, "info: ADHOC_S_RESP %s\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1162 | bss_desc->ssid.ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1163 | |
| 1164 | /* Update the created network descriptor with the new BSSID */ |
| 1165 | memcpy(bss_desc->mac_address, |
| 1166 | adhoc_result->bssid, ETH_ALEN); |
| 1167 | |
| 1168 | priv->adhoc_state = ADHOC_STARTED; |
| 1169 | } else { |
| 1170 | /* |
| 1171 | * Now the join cmd should be successful. |
| 1172 | * If BSSID has changed use SSID to compare instead of BSSID |
| 1173 | */ |
| 1174 | dev_dbg(priv->adapter->dev, "info: ADHOC_J_RESP %s\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1175 | bss_desc->ssid.ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1176 | |
| 1177 | /* |
| 1178 | * Make a copy of current BSSID descriptor, only needed for |
| 1179 | * join since the current descriptor is already being used |
| 1180 | * for adhoc start |
| 1181 | */ |
| 1182 | memcpy(&priv->curr_bss_params.bss_descriptor, |
| 1183 | bss_desc, sizeof(struct mwifiex_bssdescriptor)); |
| 1184 | |
| 1185 | priv->adhoc_state = ADHOC_JOINED; |
| 1186 | } |
| 1187 | |
| 1188 | dev_dbg(priv->adapter->dev, "info: ADHOC_RESP: channel = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1189 | priv->adhoc_channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1190 | dev_dbg(priv->adapter->dev, "info: ADHOC_RESP: BSSID = %pM\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1191 | priv->curr_bss_params.bss_descriptor.mac_address); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1192 | |
| 1193 | if (!netif_carrier_ok(priv->netdev)) |
| 1194 | netif_carrier_on(priv->netdev); |
| 1195 | if (netif_queue_stopped(priv->netdev)) |
| 1196 | netif_wake_queue(priv->netdev); |
| 1197 | |
| 1198 | mwifiex_save_curr_bcn(priv); |
| 1199 | |
| 1200 | done: |
| 1201 | /* Need to indicate IOCTL complete */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1202 | if (adapter->curr_cmd->wait_q_enabled) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1203 | if (ret) |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1204 | adapter->cmd_wait_q.status = -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1205 | else |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1206 | adapter->cmd_wait_q.status = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1207 | |
| 1208 | } |
| 1209 | |
| 1210 | return ret; |
| 1211 | } |
| 1212 | |
| 1213 | /* |
| 1214 | * This function associates to a specific BSS discovered in a scan. |
| 1215 | * |
| 1216 | * It clears any past association response stored for application |
| 1217 | * retrieval and calls the command preparation routine to send the |
| 1218 | * command to firmware. |
| 1219 | */ |
| 1220 | int mwifiex_associate(struct mwifiex_private *priv, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1221 | struct mwifiex_bssdescriptor *bss_desc) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1222 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1223 | u8 current_bssid[ETH_ALEN]; |
| 1224 | |
| 1225 | /* Return error if the adapter or table entry is not marked as infra */ |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1226 | if ((priv->bss_mode != NL80211_IFTYPE_STATION) || |
| 1227 | (bss_desc->bss_mode != NL80211_IFTYPE_STATION)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1228 | return -1; |
| 1229 | |
| 1230 | memcpy(¤t_bssid, |
| 1231 | &priv->curr_bss_params.bss_descriptor.mac_address, |
| 1232 | sizeof(current_bssid)); |
| 1233 | |
| 1234 | /* Clear any past association response stored for application |
| 1235 | retrieval */ |
| 1236 | priv->assoc_rsp_size = 0; |
| 1237 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1238 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_ASSOCIATE, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1239 | HostCmd_ACT_GEN_SET, 0, bss_desc); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | /* |
| 1243 | * This function starts an ad-hoc network. |
| 1244 | * |
| 1245 | * It calls the command preparation routine to send the command to firmware. |
| 1246 | */ |
| 1247 | int |
| 1248 | mwifiex_adhoc_start(struct mwifiex_private *priv, |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 1249 | struct cfg80211_ssid *adhoc_ssid) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1250 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1251 | dev_dbg(priv->adapter->dev, "info: Adhoc Channel = %d\n", |
| 1252 | priv->adhoc_channel); |
| 1253 | dev_dbg(priv->adapter->dev, "info: curr_bss_params.channel = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1254 | priv->curr_bss_params.bss_descriptor.channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1255 | dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1256 | priv->curr_bss_params.band); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1257 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1258 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_START, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1259 | HostCmd_ACT_GEN_SET, 0, adhoc_ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 | * This function joins an ad-hoc network found in a previous scan. |
| 1264 | * |
| 1265 | * It calls the command preparation routine to send the command to firmware, |
| 1266 | * if already not connected to the requested SSID. |
| 1267 | */ |
| 1268 | int mwifiex_adhoc_join(struct mwifiex_private *priv, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1269 | struct mwifiex_bssdescriptor *bss_desc) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1270 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1271 | dev_dbg(priv->adapter->dev, "info: adhoc join: curr_bss ssid =%s\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1272 | priv->curr_bss_params.bss_descriptor.ssid.ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1273 | dev_dbg(priv->adapter->dev, "info: adhoc join: curr_bss ssid_len =%u\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1274 | priv->curr_bss_params.bss_descriptor.ssid.ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1275 | dev_dbg(priv->adapter->dev, "info: adhoc join: ssid =%s\n", |
| 1276 | bss_desc->ssid.ssid); |
| 1277 | dev_dbg(priv->adapter->dev, "info: adhoc join: ssid_len =%u\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1278 | bss_desc->ssid.ssid_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1279 | |
| 1280 | /* Check if the requested SSID is already joined */ |
| 1281 | if (priv->curr_bss_params.bss_descriptor.ssid.ssid_len && |
| 1282 | !mwifiex_ssid_cmp(&bss_desc->ssid, |
| 1283 | &priv->curr_bss_params.bss_descriptor.ssid) && |
| 1284 | (priv->curr_bss_params.bss_descriptor.bss_mode == |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1285 | NL80211_IFTYPE_ADHOC)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1286 | dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: new ad-hoc SSID" |
| 1287 | " is the same as current; not attempting to re-join\n"); |
| 1288 | return -1; |
| 1289 | } |
| 1290 | |
| 1291 | dev_dbg(priv->adapter->dev, "info: curr_bss_params.channel = %d\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1292 | priv->curr_bss_params.bss_descriptor.channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1293 | dev_dbg(priv->adapter->dev, "info: curr_bss_params.band = %c\n", |
Yogesh Ashok Powar | 931f158 | 2012-03-13 19:22:36 -0700 | [diff] [blame] | 1294 | priv->curr_bss_params.band); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1295 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1296 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_AD_HOC_JOIN, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1297 | HostCmd_ACT_GEN_SET, 0, bss_desc); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
| 1300 | /* |
| 1301 | * This function deauthenticates/disconnects from infra network by sending |
| 1302 | * deauthentication request. |
| 1303 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1304 | static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1305 | { |
| 1306 | u8 mac_address[ETH_ALEN]; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1307 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1308 | u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; |
| 1309 | |
| 1310 | if (mac) { |
| 1311 | if (!memcmp(mac, zero_mac, sizeof(zero_mac))) |
| 1312 | memcpy((u8 *) &mac_address, |
| 1313 | (u8 *) &priv->curr_bss_params.bss_descriptor. |
| 1314 | mac_address, ETH_ALEN); |
| 1315 | else |
| 1316 | memcpy((u8 *) &mac_address, (u8 *) mac, ETH_ALEN); |
| 1317 | } else { |
| 1318 | memcpy((u8 *) &mac_address, (u8 *) &priv->curr_bss_params. |
| 1319 | bss_descriptor.mac_address, ETH_ALEN); |
| 1320 | } |
| 1321 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1322 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_DEAUTHENTICATE, |
| 1323 | HostCmd_ACT_GEN_SET, 0, &mac_address); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1324 | |
| 1325 | return ret; |
| 1326 | } |
| 1327 | |
| 1328 | /* |
| 1329 | * This function deauthenticates/disconnects from a BSS. |
| 1330 | * |
| 1331 | * In case of infra made, it sends deauthentication request, and |
| 1332 | * in case of ad-hoc mode, a stop network request is sent to the firmware. |
| 1333 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1334 | int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1335 | { |
| 1336 | int ret = 0; |
| 1337 | |
| 1338 | if (priv->media_connected) { |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1339 | if (priv->bss_mode == NL80211_IFTYPE_STATION) { |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1340 | ret = mwifiex_deauthenticate_infra(priv, mac); |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1341 | } else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1342 | ret = mwifiex_send_cmd_sync(priv, |
| 1343 | HostCmd_CMD_802_11_AD_HOC_STOP, |
| 1344 | HostCmd_ACT_GEN_SET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1345 | } |
| 1346 | } |
| 1347 | |
| 1348 | return ret; |
| 1349 | } |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1350 | EXPORT_SYMBOL_GPL(mwifiex_deauthenticate); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1351 | |
| 1352 | /* |
| 1353 | * This function converts band to radio type used in channel TLV. |
| 1354 | */ |
| 1355 | u8 |
| 1356 | mwifiex_band_to_radio_type(u8 band) |
| 1357 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1358 | switch (band) { |
| 1359 | case BAND_A: |
| 1360 | case BAND_AN: |
| 1361 | case BAND_A | BAND_AN: |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1362 | return HostCmd_SCAN_RADIO_TYPE_A; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1363 | case BAND_B: |
| 1364 | case BAND_G: |
| 1365 | case BAND_B | BAND_G: |
| 1366 | default: |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1367 | return HostCmd_SCAN_RADIO_TYPE_BG; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1368 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1369 | } |