Larry Finger | 2865d42 | 2010-08-20 10:15:30 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * rtl871x_cmd.c |
| 3 | * |
| 4 | * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. |
| 5 | * Linux device driver for RTL8192SU |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of version 2 of the GNU General Public License as |
| 9 | * published by the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | * more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program; if not, write to the Free Software Foundation, Inc., |
| 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 19 | * |
| 20 | * Modifications for inclusion into the Linux staging tree are |
| 21 | * Copyright(c) 2010 Larry Finger. All rights reserved. |
| 22 | * |
| 23 | * Contact information: |
| 24 | * WLAN FAE <wlanfae@realtek.com> |
| 25 | * Larry Finger <Larry.Finger@lwfinger.net> |
| 26 | * |
| 27 | ******************************************************************************/ |
| 28 | |
| 29 | #define _RTL871X_CMD_C_ |
| 30 | |
Ali Bahar | 359140a | 2011-09-04 03:14:11 +0800 | [diff] [blame] | 31 | #include <linux/compiler.h> |
| 32 | #include <linux/kernel.h> |
| 33 | #include <linux/errno.h> |
| 34 | #include <linux/init.h> |
| 35 | #include <linux/slab.h> |
| 36 | #include <linux/module.h> |
| 37 | #include <linux/kref.h> |
| 38 | #include <linux/netdevice.h> |
| 39 | #include <linux/skbuff.h> |
| 40 | #include <linux/usb.h> |
| 41 | #include <linux/usb/ch9.h> |
| 42 | #include <linux/circ_buf.h> |
| 43 | #include <linux/uaccess.h> |
| 44 | #include <asm/byteorder.h> |
| 45 | #include <linux/atomic.h> |
| 46 | #include <linux/semaphore.h> |
| 47 | #include <linux/rtnetlink.h> |
| 48 | |
Larry Finger | 2865d42 | 2010-08-20 10:15:30 -0500 | [diff] [blame] | 49 | #include "osdep_service.h" |
| 50 | #include "drv_types.h" |
| 51 | #include "recv_osdep.h" |
| 52 | #include "mlme_osdep.h" |
| 53 | #include "rtl871x_byteorder.h" |
| 54 | |
| 55 | /* |
| 56 | Caller and the r8712_cmd_thread can protect cmd_q by spin_lock. |
| 57 | No irqsave is necessary. |
| 58 | */ |
| 59 | |
| 60 | static sint _init_cmd_priv(struct cmd_priv *pcmdpriv) |
| 61 | { |
| 62 | sema_init(&(pcmdpriv->cmd_queue_sema), 0); |
| 63 | sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0); |
| 64 | |
| 65 | _init_queue(&(pcmdpriv->cmd_queue)); |
| 66 | |
| 67 | /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ |
| 68 | pcmdpriv->cmd_seq = 1; |
| 69 | pcmdpriv->cmd_allocated_buf = _malloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ); |
| 70 | if (pcmdpriv->cmd_allocated_buf == NULL) |
| 71 | return _FAIL; |
| 72 | pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - |
| 73 | ((addr_t)(pcmdpriv->cmd_allocated_buf) & |
| 74 | (CMDBUFF_ALIGN_SZ-1)); |
| 75 | pcmdpriv->rsp_allocated_buf = _malloc(MAX_RSPSZ + 4); |
| 76 | if (pcmdpriv->rsp_allocated_buf == NULL) |
| 77 | return _FAIL; |
| 78 | pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - |
| 79 | ((addr_t)(pcmdpriv->rsp_allocated_buf) & 3); |
| 80 | pcmdpriv->cmd_issued_cnt = 0; |
| 81 | pcmdpriv->cmd_done_cnt = 0; |
| 82 | pcmdpriv->rsp_cnt = 0; |
| 83 | return _SUCCESS; |
| 84 | } |
| 85 | |
| 86 | static sint _init_evt_priv(struct evt_priv *pevtpriv) |
| 87 | { |
| 88 | /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ |
| 89 | pevtpriv->event_seq = 0; |
| 90 | pevtpriv->evt_allocated_buf = _malloc(MAX_EVTSZ + 4); |
| 91 | |
| 92 | if (pevtpriv->evt_allocated_buf == NULL) |
| 93 | return _FAIL; |
| 94 | pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 - |
| 95 | ((addr_t)(pevtpriv->evt_allocated_buf) & 3); |
| 96 | pevtpriv->evt_done_cnt = 0; |
| 97 | return _SUCCESS; |
| 98 | } |
| 99 | |
| 100 | static void _free_evt_priv(struct evt_priv *pevtpriv) |
| 101 | { |
| 102 | kfree(pevtpriv->evt_allocated_buf); |
| 103 | } |
| 104 | |
| 105 | static void _free_cmd_priv(struct cmd_priv *pcmdpriv) |
| 106 | { |
| 107 | if (pcmdpriv) { |
| 108 | kfree(pcmdpriv->cmd_allocated_buf); |
| 109 | kfree(pcmdpriv->rsp_allocated_buf); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | Calling Context: |
| 115 | |
| 116 | _enqueue_cmd can only be called between kernel thread, |
| 117 | since only spin_lock is used. |
| 118 | |
| 119 | ISR/Call-Back functions can't call this sub-function. |
| 120 | |
| 121 | */ |
| 122 | |
| 123 | static sint _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) |
| 124 | { |
| 125 | unsigned long irqL; |
| 126 | |
| 127 | if (obj == NULL) |
| 128 | return _SUCCESS; |
| 129 | spin_lock_irqsave(&queue->lock, irqL); |
| 130 | list_insert_tail(&obj->list, &queue->queue); |
| 131 | spin_unlock_irqrestore(&queue->lock, irqL); |
| 132 | return _SUCCESS; |
| 133 | } |
| 134 | |
| 135 | static struct cmd_obj *_dequeue_cmd(struct __queue *queue) |
| 136 | { |
| 137 | unsigned long irqL; |
| 138 | struct cmd_obj *obj; |
| 139 | |
| 140 | spin_lock_irqsave(&(queue->lock), irqL); |
| 141 | if (is_list_empty(&(queue->queue))) |
| 142 | obj = NULL; |
| 143 | else { |
| 144 | obj = LIST_CONTAINOR(get_next(&(queue->queue)), |
| 145 | struct cmd_obj, list); |
| 146 | list_delete(&obj->list); |
| 147 | } |
| 148 | spin_unlock_irqrestore(&(queue->lock), irqL); |
| 149 | return obj; |
| 150 | } |
| 151 | |
| 152 | u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) |
| 153 | { |
| 154 | return _init_cmd_priv(pcmdpriv); |
| 155 | } |
| 156 | |
| 157 | u32 r8712_init_evt_priv(struct evt_priv *pevtpriv) |
| 158 | { |
| 159 | return _init_evt_priv(pevtpriv); |
| 160 | } |
| 161 | |
| 162 | void r8712_free_evt_priv(struct evt_priv *pevtpriv) |
| 163 | { |
| 164 | _free_evt_priv(pevtpriv); |
| 165 | } |
| 166 | |
| 167 | void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv) |
| 168 | { |
| 169 | _free_cmd_priv(pcmdpriv); |
| 170 | } |
| 171 | |
| 172 | u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) |
| 173 | { |
| 174 | int res; |
| 175 | |
| 176 | if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true) |
| 177 | return _FAIL; |
| 178 | res = _enqueue_cmd(&pcmdpriv->cmd_queue, obj); |
| 179 | up(&pcmdpriv->cmd_queue_sema); |
| 180 | return res; |
| 181 | } |
| 182 | |
| 183 | u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) |
| 184 | { |
| 185 | unsigned long irqL; |
| 186 | struct __queue *queue; |
| 187 | |
| 188 | if (obj == NULL) |
| 189 | return _SUCCESS; |
| 190 | if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag == true) |
| 191 | return _FAIL; |
| 192 | queue = &pcmdpriv->cmd_queue; |
| 193 | spin_lock_irqsave(&queue->lock, irqL); |
| 194 | list_insert_tail(&obj->list, &queue->queue); |
| 195 | spin_unlock_irqrestore(&queue->lock, irqL); |
| 196 | up(&pcmdpriv->cmd_queue_sema); |
| 197 | return _SUCCESS; |
| 198 | } |
| 199 | |
| 200 | struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue) |
| 201 | { |
| 202 | return _dequeue_cmd(queue); |
| 203 | } |
| 204 | |
| 205 | void r8712_free_cmd_obj(struct cmd_obj *pcmd) |
| 206 | { |
| 207 | if ((pcmd->cmdcode != _JoinBss_CMD_) && |
| 208 | (pcmd->cmdcode != _CreateBss_CMD_)) |
| 209 | kfree((unsigned char *)pcmd->parmbuf); |
| 210 | if (pcmd->rsp != NULL) { |
| 211 | if (pcmd->rspsz != 0) |
| 212 | kfree((unsigned char *)pcmd->rsp); |
| 213 | } |
| 214 | kfree((unsigned char *)pcmd); |
| 215 | } |
| 216 | |
| 217 | /* |
| 218 | r8712_sitesurvey_cmd(~) |
| 219 | ### NOTE:#### (!!!!) |
| 220 | MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, |
| 221 | YOU SHOULD HAVE LOCKED pmlmepriv->lock |
| 222 | */ |
| 223 | u8 r8712_sitesurvey_cmd(struct _adapter *padapter, |
| 224 | struct ndis_802_11_ssid *pssid) |
| 225 | { |
| 226 | struct cmd_obj *ph2c; |
| 227 | struct sitesurvey_parm *psurveyPara; |
| 228 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 229 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 230 | |
| 231 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 232 | if (ph2c == NULL) |
| 233 | return _FAIL; |
| 234 | psurveyPara = (struct sitesurvey_parm *)_malloc( |
| 235 | sizeof(struct sitesurvey_parm)); |
| 236 | if (psurveyPara == NULL) { |
| 237 | kfree((unsigned char *) ph2c); |
| 238 | return _FAIL; |
| 239 | } |
| 240 | init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, |
| 241 | GEN_CMD_CODE(_SiteSurvey)); |
| 242 | psurveyPara->bsslimit = cpu_to_le32(48); |
| 243 | psurveyPara->passive_mode = cpu_to_le32(1); |
| 244 | psurveyPara->ss_ssidlen = 0; |
| 245 | memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1); |
| 246 | if ((pssid != NULL) && (pssid->SsidLength)) { |
| 247 | memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength); |
| 248 | psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength); |
| 249 | } |
| 250 | set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); |
| 251 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 252 | _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); |
| 253 | padapter->ledpriv.LedControlHandler(padapter, LED_CTL_SITE_SURVEY); |
| 254 | return _SUCCESS; |
| 255 | } |
| 256 | |
| 257 | u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) |
| 258 | { |
| 259 | struct cmd_obj *ph2c; |
| 260 | struct setdatarate_parm *pbsetdataratepara; |
| 261 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 262 | |
| 263 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 264 | if (ph2c == NULL) |
| 265 | return _FAIL; |
| 266 | pbsetdataratepara = (struct setdatarate_parm *)_malloc( |
| 267 | sizeof(struct setdatarate_parm)); |
| 268 | if (pbsetdataratepara == NULL) { |
| 269 | kfree((u8 *) ph2c); |
| 270 | return _FAIL; |
| 271 | } |
| 272 | init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, |
| 273 | GEN_CMD_CODE(_SetDataRate)); |
| 274 | pbsetdataratepara->mac_id = 5; |
| 275 | memcpy(pbsetdataratepara->datarates, rateset, NumRates); |
| 276 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 277 | return _SUCCESS; |
| 278 | } |
| 279 | |
| 280 | u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) |
| 281 | { |
| 282 | struct cmd_obj *ph2c; |
| 283 | struct setbasicrate_parm *pssetbasicratepara; |
| 284 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 285 | |
| 286 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 287 | if (ph2c == NULL) |
| 288 | return _FAIL; |
| 289 | pssetbasicratepara = (struct setbasicrate_parm *)_malloc( |
| 290 | sizeof(struct setbasicrate_parm)); |
| 291 | if (pssetbasicratepara == NULL) { |
| 292 | kfree((u8 *) ph2c); |
| 293 | return _FAIL; |
| 294 | } |
| 295 | init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, |
| 296 | _SetBasicRate_CMD_); |
| 297 | memcpy(pssetbasicratepara->basicrates, rateset, NumRates); |
| 298 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 299 | return _SUCCESS; |
| 300 | } |
| 301 | |
| 302 | /* power tracking mechanism setting */ |
| 303 | u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type) |
| 304 | { |
| 305 | struct cmd_obj *ph2c; |
| 306 | struct PT_param *pptparm; |
| 307 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 308 | |
| 309 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 310 | if (ph2c == NULL) |
| 311 | return _FAIL; |
| 312 | pptparm = (struct PT_param *)_malloc(sizeof(struct PT_param)); |
| 313 | if (pptparm == NULL) { |
| 314 | kfree((u8 *) ph2c); |
| 315 | return _FAIL; |
| 316 | } |
| 317 | init_h2fwcmd_w_parm_no_rsp(ph2c, pptparm, |
| 318 | GEN_CMD_CODE(_SetPowerTracking)); |
| 319 | pptparm->PT_En = type; |
| 320 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 321 | return _SUCCESS; |
| 322 | } |
| 323 | |
| 324 | u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) |
| 325 | { |
| 326 | struct cmd_obj *ph2c; |
| 327 | struct writeRF_parm *pwriterfparm; |
| 328 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 329 | |
| 330 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 331 | if (ph2c == NULL) |
| 332 | return _FAIL; |
| 333 | pwriterfparm = (struct writeRF_parm *)_malloc( |
| 334 | sizeof(struct writeRF_parm)); |
| 335 | if (pwriterfparm == NULL) { |
| 336 | kfree((u8 *) ph2c); |
| 337 | return _FAIL; |
| 338 | } |
| 339 | init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); |
| 340 | pwriterfparm->offset = offset; |
| 341 | pwriterfparm->value = val; |
| 342 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 343 | return _SUCCESS; |
| 344 | } |
| 345 | |
| 346 | u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) |
| 347 | { |
| 348 | struct cmd_obj *ph2c; |
| 349 | struct readRF_parm *prdrfparm; |
| 350 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 351 | |
| 352 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 353 | if (ph2c == NULL) |
| 354 | return _FAIL; |
| 355 | prdrfparm = (struct readRF_parm *)_malloc(sizeof(struct readRF_parm)); |
| 356 | if (prdrfparm == NULL) { |
| 357 | kfree((u8 *) ph2c); |
| 358 | return _FAIL; |
| 359 | } |
| 360 | _init_listhead(&ph2c->list); |
| 361 | ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg); |
| 362 | ph2c->parmbuf = (unsigned char *)prdrfparm; |
| 363 | ph2c->cmdsz = sizeof(struct readRF_parm); |
| 364 | ph2c->rsp = pval; |
| 365 | ph2c->rspsz = sizeof(struct readRF_rsp); |
| 366 | prdrfparm->offset = offset; |
| 367 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 368 | return _SUCCESS; |
| 369 | } |
| 370 | |
| 371 | void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter, |
| 372 | struct cmd_obj *pcmd) |
| 373 | { |
Ali Bahar | f15abb8 | 2011-09-04 03:14:19 +0800 | [diff] [blame^] | 374 | kfree(pcmd->parmbuf); |
| 375 | kfree(pcmd); |
| 376 | padapter->mppriv.workparam.bcompleted = true; |
| 377 | } |
| 378 | |
| 379 | void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter, |
| 380 | struct cmd_obj *pcmd) |
| 381 | { |
| 382 | kfree(pcmd->parmbuf); |
| 383 | kfree(pcmd); |
| 384 | |
Larry Finger | 2865d42 | 2010-08-20 10:15:30 -0500 | [diff] [blame] | 385 | padapter->mppriv.workparam.bcompleted = true; |
| 386 | } |
| 387 | |
| 388 | u8 r8712_createbss_cmd(struct _adapter *padapter) |
| 389 | { |
| 390 | struct cmd_obj *pcmd; |
| 391 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 392 | struct wlan_bssid_ex *pdev_network = |
| 393 | &padapter->registrypriv.dev_network; |
| 394 | |
| 395 | padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); |
| 396 | pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 397 | if (pcmd == NULL) |
| 398 | return _FAIL; |
| 399 | _init_listhead(&pcmd->list); |
| 400 | pcmd->cmdcode = _CreateBss_CMD_; |
| 401 | pcmd->parmbuf = (unsigned char *)pdev_network; |
| 402 | pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(( |
| 403 | struct ndis_wlan_bssid_ex *) |
| 404 | pdev_network); |
| 405 | pcmd->rsp = NULL; |
| 406 | pcmd->rspsz = 0; |
| 407 | /* notes: translate IELength & Length after assign to cmdsz; */ |
| 408 | pdev_network->Length = cpu_to_le32(pcmd->cmdsz); |
| 409 | pdev_network->IELength = cpu_to_le32(pdev_network->IELength); |
| 410 | pdev_network->Ssid.SsidLength = cpu_to_le32( |
| 411 | pdev_network->Ssid.SsidLength); |
| 412 | r8712_enqueue_cmd(pcmdpriv, pcmd); |
| 413 | return _SUCCESS; |
| 414 | } |
| 415 | |
| 416 | u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) |
| 417 | { |
| 418 | u8 *auth; |
| 419 | uint t_len = 0; |
| 420 | struct ndis_wlan_bssid_ex *psecnetwork; |
| 421 | struct cmd_obj *pcmd; |
| 422 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 423 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 424 | struct qos_priv *pqospriv = &pmlmepriv->qospriv; |
| 425 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 426 | struct registry_priv *pregistrypriv = &padapter->registrypriv; |
| 427 | enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork-> |
| 428 | network.InfrastructureMode; |
| 429 | |
| 430 | padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); |
| 431 | pcmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 432 | if (pcmd == NULL) |
| 433 | return _FAIL; |
| 434 | t_len = sizeof(u32) + 6 * sizeof(unsigned char) + 2 + |
| 435 | sizeof(struct ndis_802_11_ssid) + sizeof(u32) + |
| 436 | sizeof(s32) + |
| 437 | sizeof(enum NDIS_802_11_NETWORK_TYPE) + |
| 438 | sizeof(struct NDIS_802_11_CONFIGURATION) + |
| 439 | sizeof(enum NDIS_802_11_NETWORK_INFRASTRUCTURE) + |
| 440 | sizeof(NDIS_802_11_RATES_EX) + |
| 441 | sizeof(u32) + MAX_IE_SZ; |
| 442 | |
| 443 | /* for hidden ap to set fw_state here */ |
| 444 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) != |
| 445 | true) { |
| 446 | switch (ndis_network_mode) { |
| 447 | case Ndis802_11IBSS: |
| 448 | pmlmepriv->fw_state |= WIFI_ADHOC_STATE; |
| 449 | break; |
| 450 | case Ndis802_11Infrastructure: |
| 451 | pmlmepriv->fw_state |= WIFI_STATION_STATE; |
| 452 | break; |
| 453 | case Ndis802_11APMode: |
| 454 | case Ndis802_11AutoUnknown: |
| 455 | case Ndis802_11InfrastructureMax: |
| 456 | break; |
| 457 | } |
| 458 | } |
| 459 | psecnetwork = (struct ndis_wlan_bssid_ex *)&psecuritypriv->sec_bss; |
| 460 | if (psecnetwork == NULL) { |
Alexander Beregalov | 4008386 | 2011-03-26 20:18:14 +0300 | [diff] [blame] | 461 | kfree(pcmd); |
Larry Finger | 2865d42 | 2010-08-20 10:15:30 -0500 | [diff] [blame] | 462 | return _FAIL; |
| 463 | } |
| 464 | memset(psecnetwork, 0, t_len); |
| 465 | memcpy(psecnetwork, &pnetwork->network, t_len); |
| 466 | auth = &psecuritypriv->authenticator_ie[0]; |
| 467 | psecuritypriv->authenticator_ie[0] = (unsigned char) |
| 468 | psecnetwork->IELength; |
| 469 | if ((psecnetwork->IELength-12) < (256 - 1)) |
| 470 | memcpy(&psecuritypriv->authenticator_ie[1], |
| 471 | &psecnetwork->IEs[12], psecnetwork->IELength-12); |
| 472 | else |
| 473 | memcpy(&psecuritypriv->authenticator_ie[1], |
| 474 | &psecnetwork->IEs[12], (256-1)); |
| 475 | psecnetwork->IELength = 0; |
| 476 | /* If the the driver wants to use the bssid to create the connection. |
| 477 | * If not, we copy the connecting AP's MAC address to it so that |
| 478 | * the driver just has the bssid information for PMKIDList searching. |
| 479 | */ |
| 480 | if (pmlmepriv->assoc_by_bssid == false) |
| 481 | memcpy(&pmlmepriv->assoc_bssid[0], |
| 482 | &pnetwork->network.MacAddress[0], ETH_ALEN); |
| 483 | psecnetwork->IELength = r8712_restruct_sec_ie(padapter, |
| 484 | &pnetwork->network.IEs[0], |
| 485 | &psecnetwork->IEs[0], |
| 486 | pnetwork->network.IELength); |
| 487 | pqospriv->qos_option = 0; |
| 488 | if (pregistrypriv->wmm_enable) { |
| 489 | u32 tmp_len; |
| 490 | |
| 491 | tmp_len = r8712_restruct_wmm_ie(padapter, |
| 492 | &pnetwork->network.IEs[0], |
| 493 | &psecnetwork->IEs[0], |
| 494 | pnetwork->network.IELength, |
| 495 | psecnetwork->IELength); |
| 496 | if (psecnetwork->IELength != tmp_len) { |
| 497 | psecnetwork->IELength = tmp_len; |
| 498 | pqospriv->qos_option = 1; /* WMM IE in beacon */ |
| 499 | } else |
| 500 | pqospriv->qos_option = 0; /* no WMM IE in beacon */ |
| 501 | } |
| 502 | if (pregistrypriv->ht_enable) { |
Larry Finger | 1c9bb32 | 2010-08-30 22:32:34 -0500 | [diff] [blame] | 503 | /* For WEP mode, we will use the bg mode to do the connection |
| 504 | * to avoid some IOT issues, especially for Realtek 8192u |
| 505 | * SoftAP. |
| 506 | */ |
Javier M. Mellid | 2657c30 | 2011-04-02 03:02:12 +0200 | [diff] [blame] | 507 | if ((padapter->securitypriv.PrivacyAlgrthm != _WEP40_) && |
| 508 | (padapter->securitypriv.PrivacyAlgrthm != _WEP104_)) { |
Larry Finger | 1c9bb32 | 2010-08-30 22:32:34 -0500 | [diff] [blame] | 509 | /* restructure_ht_ie */ |
| 510 | r8712_restructure_ht_ie(padapter, |
| 511 | &pnetwork->network.IEs[0], |
| 512 | &psecnetwork->IEs[0], |
| 513 | pnetwork->network.IELength, |
| 514 | &psecnetwork->IELength); |
| 515 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) |
| 516 | r8712_add_ht_addt_info(padapter, |
| 517 | &pnetwork->network.IEs[0], |
| 518 | &psecnetwork->IEs[0], |
| 519 | pnetwork->network.IELength, |
| 520 | &psecnetwork->IELength); |
| 521 | } |
Larry Finger | 2865d42 | 2010-08-20 10:15:30 -0500 | [diff] [blame] | 522 | } |
| 523 | psecuritypriv->supplicant_ie[0] = (u8)psecnetwork->IELength; |
| 524 | if (psecnetwork->IELength < 255) |
| 525 | memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0], |
| 526 | psecnetwork->IELength); |
| 527 | else |
| 528 | memcpy(&psecuritypriv->supplicant_ie[1], &psecnetwork->IEs[0], |
| 529 | 255); |
| 530 | /* get cmdsz before endian conversion */ |
| 531 | pcmd->cmdsz = r8712_get_ndis_wlan_bssid_ex_sz(psecnetwork); |
| 532 | #ifdef __BIG_ENDIAN |
| 533 | /* wlan_network endian conversion */ |
| 534 | psecnetwork->Length = cpu_to_le32(psecnetwork->Length); |
| 535 | psecnetwork->Ssid.SsidLength = cpu_to_le32( |
| 536 | psecnetwork->Ssid.SsidLength); |
| 537 | psecnetwork->Privacy = cpu_to_le32(psecnetwork->Privacy); |
| 538 | psecnetwork->Rssi = cpu_to_le32(psecnetwork->Rssi); |
| 539 | psecnetwork->NetworkTypeInUse = cpu_to_le32( |
| 540 | psecnetwork->NetworkTypeInUse); |
| 541 | psecnetwork->Configuration.ATIMWindow = cpu_to_le32( |
| 542 | psecnetwork->Configuration.ATIMWindow); |
| 543 | psecnetwork->Configuration.BeaconPeriod = cpu_to_le32( |
| 544 | psecnetwork->Configuration.BeaconPeriod); |
| 545 | psecnetwork->Configuration.DSConfig = cpu_to_le32( |
| 546 | psecnetwork->Configuration.DSConfig); |
| 547 | psecnetwork->Configuration.FHConfig.DwellTime = cpu_to_le32( |
| 548 | psecnetwork->Configuration.FHConfig.DwellTime); |
| 549 | psecnetwork->Configuration.FHConfig.HopPattern = cpu_to_le32( |
| 550 | psecnetwork->Configuration.FHConfig.HopPattern); |
| 551 | psecnetwork->Configuration.FHConfig.HopSet = cpu_to_le32( |
| 552 | psecnetwork->Configuration.FHConfig.HopSet); |
| 553 | psecnetwork->Configuration.FHConfig.Length = cpu_to_le32( |
| 554 | psecnetwork->Configuration.FHConfig.Length); |
| 555 | psecnetwork->Configuration.Length = cpu_to_le32( |
| 556 | psecnetwork->Configuration.Length); |
| 557 | psecnetwork->InfrastructureMode = cpu_to_le32( |
| 558 | psecnetwork->InfrastructureMode); |
| 559 | psecnetwork->IELength = cpu_to_le32(psecnetwork->IELength); |
| 560 | #endif |
| 561 | _init_listhead(&pcmd->list); |
| 562 | pcmd->cmdcode = _JoinBss_CMD_; |
| 563 | pcmd->parmbuf = (unsigned char *)psecnetwork; |
| 564 | pcmd->rsp = NULL; |
| 565 | pcmd->rspsz = 0; |
| 566 | r8712_enqueue_cmd(pcmdpriv, pcmd); |
| 567 | return _SUCCESS; |
| 568 | } |
| 569 | |
| 570 | u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ |
| 571 | { |
| 572 | struct cmd_obj *pdisconnect_cmd; |
| 573 | struct disconnect_parm *pdisconnect; |
| 574 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 575 | |
| 576 | pdisconnect_cmd = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 577 | if (pdisconnect_cmd == NULL) |
| 578 | return _FAIL; |
| 579 | pdisconnect = (struct disconnect_parm *)_malloc( |
| 580 | sizeof(struct disconnect_parm)); |
| 581 | if (pdisconnect == NULL) { |
| 582 | kfree((u8 *)pdisconnect_cmd); |
| 583 | return _FAIL; |
| 584 | } |
| 585 | init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect, |
| 586 | _DisConnect_CMD_); |
| 587 | r8712_enqueue_cmd(pcmdpriv, pdisconnect_cmd); |
| 588 | return _SUCCESS; |
| 589 | } |
| 590 | |
| 591 | u8 r8712_setopmode_cmd(struct _adapter *padapter, |
| 592 | enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype) |
| 593 | { |
| 594 | struct cmd_obj *ph2c; |
| 595 | struct setopmode_parm *psetop; |
| 596 | |
| 597 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 598 | |
| 599 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 600 | if (ph2c == NULL) |
| 601 | return _FAIL; |
| 602 | psetop = (struct setopmode_parm *)_malloc( |
| 603 | sizeof(struct setopmode_parm)); |
| 604 | if (psetop == NULL) { |
| 605 | kfree((u8 *) ph2c); |
| 606 | return _FAIL; |
| 607 | } |
| 608 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); |
| 609 | psetop->mode = (u8)networktype; |
| 610 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 611 | return _SUCCESS; |
| 612 | } |
| 613 | |
| 614 | u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) |
| 615 | { |
| 616 | struct cmd_obj *ph2c; |
| 617 | struct set_stakey_parm *psetstakey_para; |
| 618 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 619 | struct set_stakey_rsp *psetstakey_rsp = NULL; |
| 620 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 621 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 622 | struct sta_info *sta = (struct sta_info *)psta; |
| 623 | |
| 624 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 625 | if (ph2c == NULL) |
| 626 | return _FAIL; |
| 627 | psetstakey_para = (struct set_stakey_parm *)_malloc( |
| 628 | sizeof(struct set_stakey_parm)); |
| 629 | if (psetstakey_para == NULL) { |
| 630 | kfree((u8 *) ph2c); |
| 631 | return _FAIL; |
| 632 | } |
| 633 | psetstakey_rsp = (struct set_stakey_rsp *)_malloc( |
| 634 | sizeof(struct set_stakey_rsp)); |
| 635 | if (psetstakey_rsp == NULL) { |
| 636 | kfree((u8 *) ph2c); |
| 637 | kfree((u8 *) psetstakey_para); |
| 638 | return _FAIL; |
| 639 | } |
| 640 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); |
| 641 | ph2c->rsp = (u8 *) psetstakey_rsp; |
| 642 | ph2c->rspsz = sizeof(struct set_stakey_rsp); |
| 643 | memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); |
| 644 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) |
| 645 | psetstakey_para->algorithm = (unsigned char) |
| 646 | psecuritypriv->PrivacyAlgrthm; |
| 647 | else |
| 648 | GET_ENCRY_ALGO(psecuritypriv, sta, |
| 649 | psetstakey_para->algorithm, false); |
| 650 | if (unicast_key == true) |
| 651 | memcpy(&psetstakey_para->key, &sta->x_UncstKey, 16); |
| 652 | else |
| 653 | memcpy(&psetstakey_para->key, |
| 654 | &psecuritypriv->XGrpKey[ |
| 655 | psecuritypriv->XGrpKeyid - 1]. skey, 16); |
| 656 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 657 | return _SUCCESS; |
| 658 | } |
| 659 | |
| 660 | u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode) |
| 661 | { |
| 662 | struct cmd_obj *ph2c; |
| 663 | struct setrfintfs_parm *psetrfintfsparm; |
| 664 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 665 | |
| 666 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 667 | if (ph2c == NULL) |
| 668 | return _FAIL; |
| 669 | psetrfintfsparm = (struct setrfintfs_parm *)_malloc( |
| 670 | sizeof(struct setrfintfs_parm)); |
| 671 | if (psetrfintfsparm == NULL) { |
| 672 | kfree((unsigned char *) ph2c); |
| 673 | return _FAIL; |
| 674 | } |
| 675 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm, |
| 676 | GEN_CMD_CODE(_SetRFIntFs)); |
| 677 | psetrfintfsparm->rfintfs = mode; |
| 678 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 679 | return _SUCCESS; |
| 680 | } |
| 681 | |
| 682 | u8 r8712_setrttbl_cmd(struct _adapter *padapter, |
| 683 | struct setratable_parm *prate_table) |
| 684 | { |
| 685 | struct cmd_obj *ph2c; |
| 686 | struct setratable_parm *psetrttblparm; |
| 687 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 688 | |
| 689 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 690 | if (ph2c == NULL) |
| 691 | return _FAIL; |
| 692 | psetrttblparm = (struct setratable_parm *)_malloc( |
| 693 | sizeof(struct setratable_parm)); |
| 694 | if (psetrttblparm == NULL) { |
| 695 | kfree((unsigned char *)ph2c); |
| 696 | return _FAIL; |
| 697 | } |
| 698 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, |
| 699 | GEN_CMD_CODE(_SetRaTable)); |
| 700 | memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm)); |
| 701 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 702 | return _SUCCESS; |
| 703 | } |
| 704 | |
| 705 | u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) |
| 706 | { |
| 707 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 708 | struct cmd_obj *ph2c; |
| 709 | struct SetMacAddr_param *psetMacAddr_para; |
| 710 | |
| 711 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 712 | if (ph2c == NULL) |
| 713 | return _FAIL; |
| 714 | psetMacAddr_para = (struct SetMacAddr_param *)_malloc( |
| 715 | sizeof(struct SetMacAddr_param)); |
| 716 | if (psetMacAddr_para == NULL) { |
| 717 | kfree((u8 *) ph2c); |
| 718 | return _FAIL; |
| 719 | } |
| 720 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para, |
| 721 | _SetMacAddress_CMD_); |
| 722 | memcpy(psetMacAddr_para->MacAddr, mac_addr, ETH_ALEN); |
| 723 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 724 | return _SUCCESS; |
| 725 | } |
| 726 | |
| 727 | u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) |
| 728 | { |
| 729 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 730 | struct cmd_obj *ph2c; |
| 731 | struct set_assocsta_parm *psetassocsta_para; |
| 732 | struct set_stakey_rsp *psetassocsta_rsp = NULL; |
| 733 | |
| 734 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 735 | if (ph2c == NULL) |
| 736 | return _FAIL; |
| 737 | psetassocsta_para = (struct set_assocsta_parm *) |
| 738 | _malloc(sizeof(struct set_assocsta_parm)); |
| 739 | if (psetassocsta_para == NULL) { |
| 740 | kfree((u8 *) ph2c); |
| 741 | return _FAIL; |
| 742 | } |
| 743 | psetassocsta_rsp = (struct set_stakey_rsp *)_malloc( |
| 744 | sizeof(struct set_assocsta_rsp)); |
| 745 | if (psetassocsta_rsp == NULL) { |
| 746 | kfree((u8 *)ph2c); |
| 747 | kfree((u8 *)psetassocsta_para); |
| 748 | return _FAIL; |
| 749 | } |
| 750 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); |
| 751 | ph2c->rsp = (u8 *) psetassocsta_rsp; |
| 752 | ph2c->rspsz = sizeof(struct set_assocsta_rsp); |
| 753 | memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN); |
| 754 | r8712_enqueue_cmd(pcmdpriv, ph2c); |
| 755 | return _SUCCESS; |
| 756 | } |
| 757 | |
| 758 | u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) |
| 759 | { |
| 760 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 761 | struct cmd_obj *ph2c; |
| 762 | struct addBaReq_parm *paddbareq_parm; |
| 763 | |
| 764 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 765 | if (ph2c == NULL) |
| 766 | return _FAIL; |
| 767 | paddbareq_parm = (struct addBaReq_parm *)_malloc( |
| 768 | sizeof(struct addBaReq_parm)); |
| 769 | if (paddbareq_parm == NULL) { |
| 770 | kfree((unsigned char *)ph2c); |
| 771 | return _FAIL; |
| 772 | } |
| 773 | paddbareq_parm->tid = tid; |
| 774 | init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, |
| 775 | GEN_CMD_CODE(_AddBAReq)); |
| 776 | r8712_enqueue_cmd_ex(pcmdpriv, ph2c); |
| 777 | return _SUCCESS; |
| 778 | } |
| 779 | |
| 780 | u8 r8712_wdg_wk_cmd(struct _adapter *padapter) |
| 781 | { |
| 782 | struct cmd_obj *ph2c; |
| 783 | struct drvint_cmd_parm *pdrvintcmd_param; |
| 784 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 785 | |
| 786 | ph2c = (struct cmd_obj *)_malloc(sizeof(struct cmd_obj)); |
| 787 | if (ph2c == NULL) |
| 788 | return _FAIL; |
| 789 | pdrvintcmd_param = (struct drvint_cmd_parm *)_malloc( |
| 790 | sizeof(struct drvint_cmd_parm)); |
| 791 | if (pdrvintcmd_param == NULL) { |
| 792 | kfree((unsigned char *)ph2c); |
| 793 | return _FAIL; |
| 794 | } |
| 795 | pdrvintcmd_param->i_cid = WDG_WK_CID; |
| 796 | pdrvintcmd_param->sz = 0; |
| 797 | pdrvintcmd_param->pbuf = NULL; |
| 798 | init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvintcmd_param, _DRV_INT_CMD_); |
| 799 | r8712_enqueue_cmd_ex(pcmdpriv, ph2c); |
| 800 | return _SUCCESS; |
| 801 | } |
| 802 | |
| 803 | void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd) |
| 804 | { |
| 805 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 806 | |
| 807 | if (pcmd->res != H2C_SUCCESS) |
| 808 | clr_fwstate(pmlmepriv, _FW_UNDER_SURVEY); |
| 809 | r8712_free_cmd_obj(pcmd); |
| 810 | } |
| 811 | |
| 812 | void r8712_disassoc_cmd_callback(struct _adapter *padapter, |
| 813 | struct cmd_obj *pcmd) |
| 814 | { |
| 815 | unsigned long irqL; |
| 816 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 817 | |
| 818 | if (pcmd->res != H2C_SUCCESS) { |
| 819 | spin_lock_irqsave(&pmlmepriv->lock, irqL); |
| 820 | set_fwstate(pmlmepriv, _FW_LINKED); |
| 821 | spin_unlock_irqrestore(&pmlmepriv->lock, irqL); |
| 822 | return; |
| 823 | } |
| 824 | r8712_free_cmd_obj(pcmd); |
| 825 | } |
| 826 | |
| 827 | void r8712_joinbss_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd) |
| 828 | { |
| 829 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 830 | |
| 831 | if ((pcmd->res != H2C_SUCCESS)) |
| 832 | _set_timer(&pmlmepriv->assoc_timer, 1); |
| 833 | r8712_free_cmd_obj(pcmd); |
| 834 | } |
| 835 | |
| 836 | void r8712_createbss_cmd_callback(struct _adapter *padapter, |
| 837 | struct cmd_obj *pcmd) |
| 838 | { |
| 839 | unsigned long irqL; |
| 840 | u8 timer_cancelled; |
| 841 | struct sta_info *psta = NULL; |
| 842 | struct wlan_network *pwlan = NULL; |
| 843 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 844 | struct ndis_wlan_bssid_ex *pnetwork = (struct ndis_wlan_bssid_ex *) |
| 845 | pcmd->parmbuf; |
| 846 | struct wlan_network *tgt_network = &(pmlmepriv->cur_network); |
| 847 | |
| 848 | if ((pcmd->res != H2C_SUCCESS)) |
| 849 | _set_timer(&pmlmepriv->assoc_timer, 1); |
| 850 | _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); |
| 851 | #ifdef __BIG_ENDIAN |
| 852 | /* endian_convert */ |
| 853 | pnetwork->Length = le32_to_cpu(pnetwork->Length); |
| 854 | pnetwork->Ssid.SsidLength = le32_to_cpu(pnetwork->Ssid.SsidLength); |
| 855 | pnetwork->Privacy = le32_to_cpu(pnetwork->Privacy); |
| 856 | pnetwork->Rssi = le32_to_cpu(pnetwork->Rssi); |
| 857 | pnetwork->NetworkTypeInUse = le32_to_cpu(pnetwork->NetworkTypeInUse); |
| 858 | pnetwork->Configuration.ATIMWindow = le32_to_cpu(pnetwork-> |
| 859 | Configuration.ATIMWindow); |
| 860 | pnetwork->Configuration.DSConfig = le32_to_cpu(pnetwork-> |
| 861 | Configuration.DSConfig); |
| 862 | pnetwork->Configuration.FHConfig.DwellTime = le32_to_cpu(pnetwork-> |
| 863 | Configuration.FHConfig.DwellTime); |
| 864 | pnetwork->Configuration.FHConfig.HopPattern = le32_to_cpu(pnetwork-> |
| 865 | Configuration.FHConfig.HopPattern); |
| 866 | pnetwork->Configuration.FHConfig.HopSet = le32_to_cpu(pnetwork-> |
| 867 | Configuration.FHConfig.HopSet); |
| 868 | pnetwork->Configuration.FHConfig.Length = le32_to_cpu(pnetwork-> |
| 869 | Configuration.FHConfig.Length); |
| 870 | pnetwork->Configuration.Length = le32_to_cpu(pnetwork-> |
| 871 | Configuration.Length); |
| 872 | pnetwork->InfrastructureMode = le32_to_cpu(pnetwork-> |
| 873 | InfrastructureMode); |
| 874 | pnetwork->IELength = le32_to_cpu(pnetwork->IELength); |
| 875 | #endif |
| 876 | spin_lock_irqsave(&pmlmepriv->lock, irqL); |
| 877 | if ((pmlmepriv->fw_state) & WIFI_AP_STATE) { |
| 878 | psta = r8712_get_stainfo(&padapter->stapriv, |
| 879 | pnetwork->MacAddress); |
| 880 | if (!psta) { |
| 881 | psta = r8712_alloc_stainfo(&padapter->stapriv, |
| 882 | pnetwork->MacAddress); |
| 883 | if (psta == NULL) |
| 884 | goto createbss_cmd_fail ; |
| 885 | } |
| 886 | r8712_indicate_connect(padapter); |
| 887 | } else { |
| 888 | pwlan = _r8712_alloc_network(pmlmepriv); |
| 889 | if (pwlan == NULL) { |
| 890 | pwlan = r8712_get_oldest_wlan_network( |
| 891 | &pmlmepriv->scanned_queue); |
| 892 | if (pwlan == NULL) |
| 893 | goto createbss_cmd_fail; |
| 894 | pwlan->last_scanned = jiffies; |
| 895 | } else |
| 896 | list_insert_tail(&(pwlan->list), |
| 897 | &pmlmepriv->scanned_queue.queue); |
| 898 | pnetwork->Length = r8712_get_ndis_wlan_bssid_ex_sz(pnetwork); |
| 899 | memcpy(&(pwlan->network), pnetwork, pnetwork->Length); |
| 900 | pwlan->fixed = true; |
| 901 | memcpy(&tgt_network->network, pnetwork, |
| 902 | (r8712_get_ndis_wlan_bssid_ex_sz(pnetwork))); |
| 903 | if (pmlmepriv->fw_state & _FW_UNDER_LINKING) |
| 904 | pmlmepriv->fw_state ^= _FW_UNDER_LINKING; |
| 905 | /* we will set _FW_LINKED when there is one more sat to |
| 906 | * join us (stassoc_event_callback) */ |
| 907 | } |
| 908 | createbss_cmd_fail: |
| 909 | spin_unlock_irqrestore(&pmlmepriv->lock, irqL); |
| 910 | r8712_free_cmd_obj(pcmd); |
| 911 | } |
| 912 | |
| 913 | void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter, |
| 914 | struct cmd_obj *pcmd) |
| 915 | { |
| 916 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 917 | struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *) |
| 918 | (pcmd->rsp); |
| 919 | struct sta_info *psta = r8712_get_stainfo(pstapriv, |
| 920 | psetstakey_rsp->addr); |
| 921 | |
| 922 | if (psta == NULL) |
| 923 | goto exit; |
| 924 | psta->aid = psta->mac_id = psetstakey_rsp->keyid; /*CAM_ID(CAM_ENTRY)*/ |
| 925 | exit: |
| 926 | r8712_free_cmd_obj(pcmd); |
| 927 | } |
| 928 | |
| 929 | void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter, |
| 930 | struct cmd_obj *pcmd) |
| 931 | { |
| 932 | unsigned long irqL; |
| 933 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 934 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 935 | struct set_assocsta_parm *passocsta_parm = |
| 936 | (struct set_assocsta_parm *)(pcmd->parmbuf); |
| 937 | struct set_assocsta_rsp *passocsta_rsp = |
| 938 | (struct set_assocsta_rsp *) (pcmd->rsp); |
| 939 | struct sta_info *psta = r8712_get_stainfo(pstapriv, |
| 940 | passocsta_parm->addr); |
| 941 | |
| 942 | if (psta == NULL) |
| 943 | return; |
| 944 | psta->aid = psta->mac_id = passocsta_rsp->cam_id; |
| 945 | spin_lock_irqsave(&pmlmepriv->lock, irqL); |
| 946 | if ((check_fwstate(pmlmepriv, WIFI_MP_STATE)) && |
| 947 | (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) |
| 948 | pmlmepriv->fw_state ^= _FW_UNDER_LINKING; |
| 949 | set_fwstate(pmlmepriv, _FW_LINKED); |
| 950 | spin_unlock_irqrestore(&pmlmepriv->lock, irqL); |
| 951 | r8712_free_cmd_obj(pcmd); |
| 952 | } |