Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of version 2 of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | ******************************************************************************/ |
| 15 | #define _RTW_CMD_C_ |
| 16 | |
| 17 | #include <osdep_service.h> |
| 18 | #include <drv_types.h> |
| 19 | #include <recv_osdep.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 20 | #include <mlme_osdep.h> |
Larry Finger | 88cdc94 | 2014-04-09 23:21:18 +0200 | [diff] [blame] | 21 | #include <rtl8723a_cmd.h> |
Jes Sorensen | 9680817 | 2014-05-21 09:37:25 +0200 | [diff] [blame] | 22 | #include <rtw_sreset.h> |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 23 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 24 | static struct cmd_hdl wlancmds[] = { |
| 25 | GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ |
| 26 | GEN_DRV_CMD_HANDLER(0, NULL) |
| 27 | GEN_DRV_CMD_HANDLER(0, NULL) |
| 28 | GEN_DRV_CMD_HANDLER(0, NULL) |
| 29 | GEN_DRV_CMD_HANDLER(0, NULL) |
| 30 | GEN_DRV_CMD_HANDLER(0, NULL) |
| 31 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 32 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 33 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 34 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 35 | GEN_MLME_EXT_HANDLER(0, NULL) /*10*/ |
| 36 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 37 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 38 | GEN_MLME_EXT_HANDLER(0, NULL) |
anuvazhayil | ed09b44 | 2014-10-29 03:43:26 +0530 | [diff] [blame] | 39 | GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), join_cmd_hdl23a) /*14*/ |
| 40 | GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl23a) |
| 41 | GEN_MLME_EXT_HANDLER(sizeof(struct wlan_bssid_ex), createbss_hdl23a) |
| 42 | GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl23a) |
| 43 | GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl23a) /*18*/ |
| 44 | GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl23a) |
| 45 | GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl23a) /*20*/ |
| 46 | GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl23a) |
| 47 | GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL) |
| 48 | GEN_MLME_EXT_HANDLER(sizeof(struct del_assocsta_parm), NULL) |
| 49 | GEN_MLME_EXT_HANDLER(sizeof(struct setstapwrstate_parm), NULL) |
| 50 | GEN_MLME_EXT_HANDLER(sizeof(struct setbasicrate_parm), NULL) |
| 51 | GEN_MLME_EXT_HANDLER(sizeof(struct getbasicrate_parm), NULL) |
| 52 | GEN_MLME_EXT_HANDLER(sizeof(struct setdatarate_parm), NULL) |
| 53 | GEN_MLME_EXT_HANDLER(sizeof(struct getdatarate_parm), NULL) |
| 54 | GEN_MLME_EXT_HANDLER(sizeof(struct setphyinfo_parm), NULL) |
| 55 | GEN_MLME_EXT_HANDLER(sizeof(struct getphyinfo_parm), NULL) /*30*/ |
| 56 | GEN_MLME_EXT_HANDLER(sizeof(struct setphy_parm), NULL) |
| 57 | GEN_MLME_EXT_HANDLER(sizeof(struct getphy_parm), NULL) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 58 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 59 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 60 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 61 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 62 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 63 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 64 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 65 | GEN_MLME_EXT_HANDLER(0, NULL) /*40*/ |
| 66 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 67 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 68 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 69 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 70 | GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl23a) |
| 71 | GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl23a) /* 46 */ |
| 72 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 73 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 74 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 75 | GEN_MLME_EXT_HANDLER(0, NULL) /*50*/ |
| 76 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 77 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 78 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 79 | GEN_MLME_EXT_HANDLER(0, NULL) |
| 80 | GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param), tx_beacon_hdl23a) /*55*/ |
| 81 | |
| 82 | GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl23a) /*56*/ |
| 83 | GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl23a) /*57*/ |
| 84 | |
| 85 | GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl23a) /*58*/ |
| 86 | GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), set_chplan_hdl23a) /*59*/ |
| 87 | GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), led_blink_hdl23a) /*60*/ |
| 88 | |
| 89 | GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), set_csa_hdl23a) /*61*/ |
| 90 | GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), tdls_hdl23a) /*62*/ |
| 91 | }; |
| 92 | |
| 93 | struct _cmd_callback rtw_cmd_callback[] = { |
| 94 | {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ |
| 95 | {GEN_CMD_CODE(_Write_MACREG), NULL}, |
| 96 | {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback23a}, |
| 97 | {GEN_CMD_CODE(_Write_BBREG), NULL}, |
| 98 | {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback23a}, |
| 99 | {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ |
| 100 | {GEN_CMD_CODE(_Read_EEPROM), NULL}, |
| 101 | {GEN_CMD_CODE(_Write_EEPROM), NULL}, |
| 102 | {GEN_CMD_CODE(_Read_EFUSE), NULL}, |
| 103 | {GEN_CMD_CODE(_Write_EFUSE), NULL}, |
| 104 | |
| 105 | {GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/ |
| 106 | {GEN_CMD_CODE(_Write_CAM), NULL}, |
| 107 | {GEN_CMD_CODE(_setBCNITV), NULL}, |
| 108 | {GEN_CMD_CODE(_setMBIDCFG), NULL}, |
| 109 | {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd23a_callback}, /*14*/ |
| 110 | {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd23a_callback}, /*15*/ |
| 111 | {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd23a_callback}, |
| 112 | {GEN_CMD_CODE(_SetOpMode), NULL}, |
| 113 | {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback23a}, /*18*/ |
| 114 | {GEN_CMD_CODE(_SetAuth), NULL}, |
| 115 | |
| 116 | {GEN_CMD_CODE(_SetKey), NULL}, /*20*/ |
| 117 | {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback23a}, |
| 118 | {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback23a}, |
| 119 | {GEN_CMD_CODE(_DelAssocSta), NULL}, |
| 120 | {GEN_CMD_CODE(_SetStaPwrState), NULL}, |
| 121 | {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/ |
| 122 | {GEN_CMD_CODE(_GetBasicRate), NULL}, |
| 123 | {GEN_CMD_CODE(_SetDataRate), NULL}, |
| 124 | {GEN_CMD_CODE(_GetDataRate), NULL}, |
| 125 | {GEN_CMD_CODE(_SetPhyInfo), NULL}, |
| 126 | |
| 127 | {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/ |
| 128 | {GEN_CMD_CODE(_SetPhy), NULL}, |
| 129 | {GEN_CMD_CODE(_GetPhy), NULL}, |
| 130 | {GEN_CMD_CODE(_readRssi), NULL}, |
| 131 | {GEN_CMD_CODE(_readGain), NULL}, |
| 132 | {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/ |
| 133 | {GEN_CMD_CODE(_SetPwrMode), NULL}, |
| 134 | {GEN_CMD_CODE(_JoinbssRpt), NULL}, |
| 135 | {GEN_CMD_CODE(_SetRaTable), NULL}, |
| 136 | {GEN_CMD_CODE(_GetRaTable), NULL}, |
| 137 | |
| 138 | {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/ |
| 139 | {GEN_CMD_CODE(_GetDTMReport), NULL}, |
| 140 | {GEN_CMD_CODE(_GetTXRateStatistics), NULL}, |
| 141 | {GEN_CMD_CODE(_SetUsbSuspend), NULL}, |
| 142 | {GEN_CMD_CODE(_SetH2cLbk), NULL}, |
| 143 | {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/ |
| 144 | {GEN_CMD_CODE(_SetChannel), NULL}, /*46*/ |
| 145 | {GEN_CMD_CODE(_SetTxPower), NULL}, |
| 146 | {GEN_CMD_CODE(_SwitchAntenna), NULL}, |
| 147 | {GEN_CMD_CODE(_SetCrystalCap), NULL}, |
| 148 | {GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/ |
| 149 | |
| 150 | {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/ |
| 151 | {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL}, |
| 152 | {GEN_CMD_CODE(_SetContinuousTx), NULL}, |
| 153 | {GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/ |
| 154 | {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/ |
| 155 | |
| 156 | {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/ |
| 157 | {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/ |
| 158 | {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/ |
| 159 | {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/ |
| 160 | {GEN_CMD_CODE(_LedBlink), NULL},/*60*/ |
| 161 | |
| 162 | {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/ |
| 163 | {GEN_CMD_CODE(_TDLS), NULL},/*62*/ |
| 164 | }; |
| 165 | |
| 166 | /* |
| 167 | Caller and the rtw_cmd_thread23a can protect cmd_q by spin_lock. |
| 168 | No irqsave is necessary. |
| 169 | */ |
| 170 | |
| 171 | int rtw_init_cmd_priv23a(struct cmd_priv *pcmdpriv) |
| 172 | { |
| 173 | int res = _SUCCESS; |
| 174 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 175 | pcmdpriv->cmd_issued_cnt = 0; |
| 176 | pcmdpriv->cmd_done_cnt = 0; |
| 177 | pcmdpriv->rsp_cnt = 0; |
| 178 | |
Jes Sorensen | 8df06a3 | 2014-05-09 15:03:13 +0200 | [diff] [blame] | 179 | pcmdpriv->wq = alloc_workqueue("rtl8723au_cmd", 0, 1); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 180 | if (!pcmdpriv->wq) |
| 181 | res = _FAIL; |
| 182 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 183 | return res; |
| 184 | } |
| 185 | |
| 186 | /* forward definition */ |
| 187 | |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 188 | static void rtw_irq_work(struct work_struct *work); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 189 | |
Jes Sorensen | ab033fdb | 2014-04-26 18:55:01 +0200 | [diff] [blame] | 190 | u32 rtw_init_evt_priv23a(struct evt_priv *pevtpriv) |
| 191 | { |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 192 | pevtpriv->wq = alloc_workqueue("rtl8723au_evt", 0, 1); |
| 193 | |
| 194 | INIT_WORK(&pevtpriv->irq_wk, rtw_irq_work); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 195 | |
Jes Sorensen | ab033fdb | 2014-04-26 18:55:01 +0200 | [diff] [blame] | 196 | return _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | void rtw_free_evt_priv23a(struct evt_priv *pevtpriv) |
| 200 | { |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 201 | cancel_work_sync(&pevtpriv->irq_wk); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 202 | } |
| 203 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 204 | static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) |
| 205 | { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 206 | /* set to true to allow enqueuing cmd when hw_init_completed is false */ |
| 207 | u8 bAllow = false; |
| 208 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 209 | if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) |
| 210 | bAllow = true; |
| 211 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 212 | if (pcmdpriv->padapter->hw_init_completed == false && bAllow == false) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 213 | return _FAIL; |
| 214 | return _SUCCESS; |
| 215 | } |
| 216 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 217 | static void rtw_cmd_work(struct work_struct *work); |
| 218 | |
| 219 | int rtw_enqueue_cmd23a(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 220 | { |
| 221 | int res = _FAIL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 222 | |
| 223 | if (!cmd_obj) |
| 224 | goto exit; |
| 225 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 226 | cmd_obj->padapter = pcmdpriv->padapter; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 227 | |
| 228 | res = rtw_cmd_filter(pcmdpriv, cmd_obj); |
| 229 | if (res == _FAIL) { |
| 230 | rtw_free_cmd_obj23a(cmd_obj); |
| 231 | goto exit; |
| 232 | } |
| 233 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 234 | INIT_WORK(&cmd_obj->work, rtw_cmd_work); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 235 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 236 | res = queue_work(pcmdpriv->wq, &cmd_obj->work); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 237 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 238 | if (!res) { |
Alison Schofield | 0d07fc1 | 2015-10-20 23:06:45 -0700 | [diff] [blame] | 239 | netdev_err(pcmdpriv->padapter->pnetdev, |
| 240 | "%s: Call to queue_work() failed\n", __func__); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 241 | res = _FAIL; |
| 242 | } else |
| 243 | res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 244 | exit: |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 245 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 246 | return res; |
| 247 | } |
| 248 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 249 | void rtw_free_cmd_obj23a(struct cmd_obj *pcmd) |
| 250 | { |
| 251 | |
| 252 | if (pcmd->cmdcode != _JoinBss_CMD_ && |
| 253 | pcmd->cmdcode != _CreateBss_CMD_) { |
| 254 | /* free parmbuf in cmd_obj */ |
| 255 | kfree(pcmd->parmbuf); |
| 256 | } |
| 257 | |
| 258 | if (pcmd->rsp) { |
| 259 | if (pcmd->rspsz != 0) { |
| 260 | /* free rsp in cmd_obj */ |
| 261 | kfree(pcmd->rsp); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | kfree(pcmd); |
| 266 | } |
| 267 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 268 | static void rtw_cmd_work(struct work_struct *work) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 269 | { |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 270 | int (*cmd_hdl)(struct rtw_adapter *padapter, const u8 *pbuf); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 271 | void (*pcmd_callback)(struct rtw_adapter *dev, struct cmd_obj *pcmd); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 272 | struct cmd_priv *pcmdpriv; |
| 273 | struct cmd_obj *pcmd = container_of(work, struct cmd_obj, work); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 274 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 275 | pcmdpriv = &pcmd->padapter->cmdpriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 276 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 277 | if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { |
| 278 | pcmd->res = H2C_DROPPED; |
| 279 | goto post_process; |
| 280 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 281 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 282 | pcmdpriv->cmd_issued_cnt++; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 283 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 284 | pcmd->cmdsz = ALIGN(pcmd->cmdsz, 4); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 285 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 286 | if (pcmd->cmdcode < (sizeof(wlancmds)/sizeof(struct cmd_hdl))) { |
| 287 | cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; |
| 288 | |
| 289 | if (cmd_hdl) |
Jes Sorensen | c347dc6 | 2014-05-09 15:03:10 +0200 | [diff] [blame] | 290 | pcmd->res = cmd_hdl(pcmd->padapter, pcmd->parmbuf); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 291 | else |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 292 | pcmd->res = H2C_DROPPED; |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 293 | } else |
| 294 | pcmd->res = H2C_PARAMETERS_ERROR; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 295 | |
| 296 | post_process: |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 297 | /* call callback function for post-processed */ |
Janani Ravichandran | 993c0a0 | 2016-02-11 18:50:40 -0500 | [diff] [blame] | 298 | if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 299 | pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; |
| 300 | if (!pcmd_callback) { |
| 301 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 302 | "mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", |
| 303 | pcmd_callback, pcmd->cmdcode); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 304 | rtw_free_cmd_obj23a(pcmd); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 305 | } else { |
Masanari Iida | 808bcb4 | 2014-07-22 23:42:53 +0900 | [diff] [blame] | 306 | /* need consider that free cmd_obj in |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 307 | rtw_cmd_callback */ |
| 308 | pcmd_callback(pcmd->padapter, pcmd); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 309 | } |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 310 | } else { |
| 311 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 312 | "%s: cmdcode = 0x%x callback not defined!\n", |
| 313 | __func__, pcmd->cmdcode); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 314 | rtw_free_cmd_obj23a(pcmd); |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 315 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 316 | } |
| 317 | |
Jes Sorensen | d97e2d2 | 2014-04-26 18:54:57 +0200 | [diff] [blame] | 318 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 319 | int rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, |
| 320 | struct cfg80211_ssid *ssid, int ssid_num, |
| 321 | struct rtw_ieee80211_channel *ch, int ch_num) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 322 | { |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 323 | int res = _FAIL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 324 | struct cmd_obj *ph2c; |
| 325 | struct sitesurvey_parm *psurveyPara; |
| 326 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 327 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 328 | |
Jes Sorensen | f2f9703 | 2014-05-25 22:43:04 +0200 | [diff] [blame] | 329 | if (check_fwstate(pmlmepriv, _FW_LINKED)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 330 | rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1); |
| 331 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 332 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 333 | if (!ph2c) |
| 334 | return _FAIL; |
| 335 | |
| 336 | psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); |
| 337 | if (!psurveyPara) { |
| 338 | kfree(ph2c); |
| 339 | return _FAIL; |
| 340 | } |
| 341 | |
Jes Sorensen | 528e5c1 | 2014-04-26 18:55:51 +0200 | [diff] [blame] | 342 | rtw_free_network_queue23a(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 343 | |
| 344 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 345 | "%s: flush network queue\n", __func__); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 346 | |
| 347 | init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, |
| 348 | GEN_CMD_CODE(_SiteSurvey)); |
| 349 | |
| 350 | /* psurveyPara->bsslimit = 48; */ |
| 351 | psurveyPara->scan_mode = pmlmepriv->scan_mode; |
| 352 | |
| 353 | /* prepare ssid list */ |
| 354 | if (ssid) { |
| 355 | int i; |
Yeliz Taneroglu | fbc6d79 | 2014-10-09 01:22:10 +0300 | [diff] [blame] | 356 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 357 | for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { |
| 358 | if (ssid[i].ssid_len) { |
| 359 | memcpy(&psurveyPara->ssid[i], &ssid[i], |
| 360 | sizeof(struct cfg80211_ssid)); |
| 361 | psurveyPara->ssid_num++; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /* prepare channel list */ |
| 367 | if (ch) { |
| 368 | int i; |
Yeliz Taneroglu | fbc6d79 | 2014-10-09 01:22:10 +0300 | [diff] [blame] | 369 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 370 | for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { |
| 371 | if (ch[i].hw_value && |
| 372 | !(ch[i].flags & IEEE80211_CHAN_DISABLED)) { |
| 373 | memcpy(&psurveyPara->ch[i], &ch[i], |
| 374 | sizeof(struct rtw_ieee80211_channel)); |
| 375 | psurveyPara->ch_num++; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); |
| 381 | |
| 382 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 383 | |
| 384 | if (res == _SUCCESS) { |
| 385 | mod_timer(&pmlmepriv->scan_to_timer, jiffies + |
| 386 | msecs_to_jiffies(SCANNING_TIMEOUT)); |
| 387 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 388 | pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ |
| 389 | } else |
| 390 | _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); |
| 391 | |
| 392 | return res; |
| 393 | } |
| 394 | |
| 395 | void rtw_getbbrfreg_cmdrsp_callback23a(struct rtw_adapter *padapter, |
| 396 | struct cmd_obj *pcmd) |
| 397 | { |
| 398 | kfree(pcmd->parmbuf); |
| 399 | kfree(pcmd); |
| 400 | } |
| 401 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 402 | int rtw_createbss_cmd23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 403 | { |
| 404 | struct cmd_obj *pcmd; |
| 405 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 406 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 407 | struct wlan_bssid_ex *pdev_network; |
| 408 | u8 res = _SUCCESS; |
| 409 | |
| 410 | pdev_network = &padapter->registrypriv.dev_network; |
| 411 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 412 | if (pmlmepriv->assoc_ssid.ssid_len == 0) { |
| 413 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 414 | "createbss for Any SSid:%s\n", |
| 415 | pmlmepriv->assoc_ssid.ssid); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 416 | } else { |
| 417 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 418 | "createbss for SSid:%s\n", |
| 419 | pmlmepriv->assoc_ssid.ssid); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 423 | if (!pcmd) { |
| 424 | res = _FAIL; |
| 425 | goto exit; |
| 426 | } |
| 427 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 428 | pcmd->cmdcode = _CreateBss_CMD_; |
| 429 | pcmd->parmbuf = (unsigned char *)pdev_network; |
Jes Sorensen | aab2645 | 2014-04-26 18:55:08 +0200 | [diff] [blame] | 430 | pcmd->cmdsz = get_wlan_bssid_ex_sz(pdev_network); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 431 | pcmd->rsp = NULL; |
| 432 | pcmd->rspsz = 0; |
| 433 | |
| 434 | pdev_network->Length = pcmd->cmdsz; |
| 435 | |
| 436 | res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); |
| 437 | |
| 438 | exit: |
| 439 | |
| 440 | return res; |
| 441 | } |
| 442 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 443 | int rtw_joinbss_cmd23a(struct rtw_adapter *padapter, |
| 444 | struct wlan_network *pnetwork) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 445 | { |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 446 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 447 | struct wlan_bssid_ex *psecnetwork; |
| 448 | struct cmd_obj *pcmd; |
| 449 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 450 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 451 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
| 452 | struct registry_priv *pregistrypriv = &padapter->registrypriv; |
| 453 | struct ht_priv *phtpriv = &pmlmepriv->htpriv; |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 454 | enum nl80211_iftype ifmode; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 455 | struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; |
| 456 | struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; |
| 457 | |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 458 | ifmode = pnetwork->network.ifmode; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 459 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 460 | if (pmlmepriv->assoc_ssid.ssid_len == 0) { |
| 461 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 462 | "+Join cmd: Any SSid\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 463 | } else { |
| 464 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 465 | "+Join cmd: SSid =[%s]\n", |
| 466 | pmlmepriv->assoc_ssid.ssid); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 470 | if (!pcmd) { |
| 471 | res = _FAIL; |
| 472 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 473 | "rtw_joinbss_cmd23a: memory allocate for cmd_obj fail!!!\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 474 | goto exit; |
| 475 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 476 | |
| 477 | /* for hidden ap to set fw_state here */ |
| 478 | if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 479 | switch (ifmode) { |
| 480 | case NL80211_IFTYPE_ADHOC: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 481 | set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); |
| 482 | break; |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 483 | case NL80211_IFTYPE_P2P_CLIENT: |
| 484 | case NL80211_IFTYPE_STATION: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 485 | set_fwstate(pmlmepriv, WIFI_STATION_STATE); |
| 486 | break; |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 487 | default: |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 488 | break; |
| 489 | } |
| 490 | } |
| 491 | |
Jes Sorensen | ea4190b | 2014-04-26 18:55:07 +0200 | [diff] [blame] | 492 | psecnetwork = &psecuritypriv->sec_bss; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 493 | if (!psecnetwork) { |
Fabian Frederick | 352f145 | 2014-07-01 10:11:23 +0200 | [diff] [blame] | 494 | kfree(pcmd); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 495 | res = _FAIL; |
| 496 | |
| 497 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 498 | "rtw_joinbss_cmd23a :psecnetwork == NULL!!!\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 499 | |
| 500 | goto exit; |
| 501 | } |
| 502 | |
Jes Sorensen | ea4190b | 2014-04-26 18:55:07 +0200 | [diff] [blame] | 503 | memset(psecnetwork, 0, sizeof(struct wlan_bssid_ex)); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 504 | |
| 505 | memcpy(psecnetwork, &pnetwork->network, |
| 506 | get_wlan_bssid_ex_sz(&pnetwork->network)); |
| 507 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 508 | psecnetwork->IELength = 0; |
| 509 | /* Added by Albert 2009/02/18 */ |
| 510 | /* If the the driver wants to use the bssid to create the |
| 511 | * connection. If not, we have to copy the connecting AP's |
| 512 | * MAC address to it so that the driver just has the bssid |
| 513 | * information for PMKIDList searching. */ |
| 514 | |
| 515 | if (pmlmepriv->assoc_by_bssid == false) |
| 516 | ether_addr_copy(&pmlmepriv->assoc_bssid[0], |
| 517 | &pnetwork->network.MacAddress[0]); |
| 518 | |
| 519 | psecnetwork->IELength = |
| 520 | rtw_restruct_sec_ie23a(padapter, &pnetwork->network.IEs[0], |
| 521 | &psecnetwork->IEs[0], |
| 522 | pnetwork->network.IELength); |
| 523 | |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 524 | pmlmepriv->qos_option = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 525 | |
| 526 | if (pregistrypriv->wmm_enable) { |
| 527 | u32 tmp_len; |
| 528 | |
| 529 | tmp_len = rtw_restruct_wmm_ie23a(padapter, |
| 530 | &pnetwork->network.IEs[0], |
| 531 | &psecnetwork->IEs[0], |
| 532 | pnetwork->network.IELength, |
| 533 | psecnetwork->IELength); |
| 534 | |
| 535 | if (psecnetwork->IELength != tmp_len) { |
| 536 | psecnetwork->IELength = tmp_len; |
| 537 | /* There is WMM IE in this corresp. beacon */ |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 538 | pmlmepriv->qos_option = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 539 | } else { |
| 540 | /* There is no WMM IE in this corresp. beacon */ |
Jes Sorensen | bd8ad4a | 2014-05-09 15:03:21 +0200 | [diff] [blame] | 541 | pmlmepriv->qos_option = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 542 | } |
| 543 | } |
| 544 | |
| 545 | phtpriv->ht_option = false; |
| 546 | if (pregistrypriv->ht_enable) { |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 547 | u32 algo = padapter->securitypriv.dot11PrivacyAlgrthm; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 548 | /* Added by Albert 2010/06/23 */ |
| 549 | /* For the WEP mode, we will use the bg mode to do |
| 550 | the connection to avoid some IOT issue. */ |
| 551 | /* Especially for Realtek 8192u SoftAP. */ |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 552 | if (algo != WLAN_CIPHER_SUITE_WEP40 && |
| 553 | algo != WLAN_CIPHER_SUITE_WEP104 && |
| 554 | algo != WLAN_CIPHER_SUITE_TKIP) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 555 | /* rtw_restructure_ht_ie23a */ |
| 556 | rtw_restructure_ht_ie23a(padapter, |
| 557 | &pnetwork->network.IEs[0], |
| 558 | &psecnetwork->IEs[0], |
| 559 | pnetwork->network.IELength, |
| 560 | &psecnetwork->IELength); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | pmlmeinfo->assoc_AP_vendor = |
| 565 | check_assoc_AP23a(pnetwork->network.IEs, |
| 566 | pnetwork->network.IELength); |
| 567 | |
| 568 | if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA) |
| 569 | padapter->pwrctrlpriv.smart_ps = 0; |
| 570 | else |
| 571 | padapter->pwrctrlpriv.smart_ps = |
| 572 | padapter->registrypriv.smart_ps; |
| 573 | |
| 574 | DBG_8723A("%s: smart_ps =%d\n", __func__, |
| 575 | padapter->pwrctrlpriv.smart_ps); |
| 576 | |
| 577 | /* get cmdsz before endian conversion */ |
| 578 | pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork); |
| 579 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 580 | pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */ |
| 581 | pcmd->parmbuf = (unsigned char *)psecnetwork; |
| 582 | pcmd->rsp = NULL; |
| 583 | pcmd->rspsz = 0; |
| 584 | |
| 585 | res = rtw_enqueue_cmd23a(pcmdpriv, pcmd); |
| 586 | exit: |
| 587 | |
| 588 | return res; |
| 589 | } |
| 590 | |
anuvazhayil | a58af1e | 2014-10-30 00:03:48 +0530 | [diff] [blame] | 591 | int rtw_disassoc_cmd23a(struct rtw_adapter *padapter, u32 deauth_timeout_ms, |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 592 | bool enqueue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 593 | { |
| 594 | struct cmd_obj *cmdobj = NULL; |
| 595 | struct disconnect_parm *param = NULL; |
| 596 | struct cmd_priv *cmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 597 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 598 | |
| 599 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 600 | "+rtw_disassoc_cmd23a\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 601 | |
| 602 | /* prepare cmd parameter */ |
| 603 | param = kzalloc(sizeof(*param), GFP_ATOMIC); |
| 604 | if (param == NULL) { |
| 605 | res = _FAIL; |
| 606 | goto exit; |
| 607 | } |
| 608 | param->deauth_timeout_ms = deauth_timeout_ms; |
| 609 | |
| 610 | if (enqueue) { |
| 611 | /* need enqueue, prepare cmd_obj and enqueue */ |
| 612 | cmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 613 | if (!cmdobj) { |
| 614 | res = _FAIL; |
| 615 | kfree(param); |
| 616 | goto exit; |
| 617 | } |
| 618 | init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); |
| 619 | res = rtw_enqueue_cmd23a(cmdpriv, cmdobj); |
| 620 | } else { |
| 621 | /* no need to enqueue, do the cmd hdl directly and |
| 622 | free cmd parameter */ |
Alison Schofield | c12e8db | 2015-10-20 23:08:27 -0700 | [diff] [blame] | 623 | if (disconnect_hdl23a(padapter, (u8 *)param) != H2C_SUCCESS) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 624 | res = _FAIL; |
| 625 | kfree(param); |
| 626 | } |
| 627 | |
| 628 | exit: |
| 629 | return res; |
| 630 | } |
| 631 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 632 | int rtw_setopmode_cmd23a(struct rtw_adapter *padapter, |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 633 | enum nl80211_iftype ifmode) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 634 | { |
| 635 | struct cmd_obj *ph2c; |
| 636 | struct setopmode_parm *psetop; |
| 637 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 638 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 639 | |
| 640 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); |
| 641 | if (!ph2c) { |
| 642 | res = false; |
| 643 | goto exit; |
| 644 | } |
| 645 | psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL); |
| 646 | |
| 647 | if (!psetop) { |
| 648 | kfree(ph2c); |
| 649 | res = false; |
| 650 | goto exit; |
| 651 | } |
| 652 | |
| 653 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); |
Jes Sorensen | efc7144 | 2014-05-21 09:37:26 +0200 | [diff] [blame] | 654 | psetop->mode = ifmode; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 655 | |
| 656 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 657 | exit: |
| 658 | return res; |
| 659 | } |
| 660 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 661 | int rtw_setstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 unicast_key) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 662 | { |
| 663 | struct cmd_obj *ph2c; |
| 664 | struct set_stakey_parm *psetstakey_para; |
| 665 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 666 | struct set_stakey_rsp *psetstakey_rsp = NULL; |
| 667 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 668 | struct security_priv *psecuritypriv = &padapter->securitypriv; |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 669 | struct sta_info *sta = (struct sta_info *)psta; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 670 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 671 | |
| 672 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); |
| 673 | if (!ph2c) { |
| 674 | res = _FAIL; |
| 675 | goto exit; |
| 676 | } |
| 677 | |
| 678 | psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); |
| 679 | if (!psetstakey_para) { |
| 680 | kfree(ph2c); |
| 681 | res = _FAIL; |
| 682 | goto exit; |
| 683 | } |
| 684 | |
| 685 | psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL); |
| 686 | if (!psetstakey_rsp) { |
| 687 | kfree(ph2c); |
| 688 | kfree(psetstakey_para); |
| 689 | res = _FAIL; |
| 690 | goto exit; |
| 691 | } |
| 692 | |
| 693 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); |
| 694 | ph2c->rsp = (u8 *) psetstakey_rsp; |
| 695 | ph2c->rspsz = sizeof(struct set_stakey_rsp); |
| 696 | |
| 697 | ether_addr_copy(psetstakey_para->addr, sta->hwaddr); |
| 698 | |
| 699 | if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { |
| 700 | psetstakey_para->algorithm = |
| 701 | (unsigned char)psecuritypriv->dot11PrivacyAlgrthm; |
| 702 | } else { |
| 703 | GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, |
| 704 | false); |
| 705 | } |
| 706 | |
| 707 | if (unicast_key == true) { |
| 708 | memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 709 | } else { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 710 | int idx = psecuritypriv->dot118021XGrpKeyid; |
Yeliz Taneroglu | fbc6d79 | 2014-10-09 01:22:10 +0300 | [diff] [blame] | 711 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 712 | memcpy(&psetstakey_para->key, |
| 713 | &psecuritypriv->dot118021XGrpKey[idx].skey, 16); |
Greg Donald | a82b4b0 | 2014-09-08 20:50:23 -0500 | [diff] [blame] | 714 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 715 | |
Masanari Iida | 808bcb4 | 2014-07-22 23:42:53 +0900 | [diff] [blame] | 716 | /* jeff: set this because at least sw key is ready */ |
Jes Sorensen | 9216c51 | 2014-05-21 09:37:29 +0200 | [diff] [blame] | 717 | padapter->securitypriv.busetkipkey = 1; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 718 | |
| 719 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 720 | |
| 721 | exit: |
| 722 | |
| 723 | return res; |
| 724 | } |
| 725 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 726 | int rtw_clearstakey_cmd23a(struct rtw_adapter *padapter, u8 *psta, u8 entry, |
| 727 | u8 enqueue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 728 | { |
| 729 | struct cmd_obj *ph2c; |
| 730 | struct set_stakey_parm *psetstakey_para; |
| 731 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 732 | struct set_stakey_rsp *psetstakey_rsp = NULL; |
| 733 | struct sta_info *sta = (struct sta_info *)psta; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 734 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 735 | |
| 736 | if (!enqueue) { |
| 737 | clear_cam_entry23a(padapter, entry); |
| 738 | } else { |
| 739 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); |
| 740 | if (!ph2c) { |
| 741 | res = _FAIL; |
| 742 | goto exit; |
| 743 | } |
| 744 | |
| 745 | psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), |
| 746 | GFP_KERNEL); |
| 747 | if (!psetstakey_para) { |
| 748 | kfree(ph2c); |
| 749 | res = _FAIL; |
| 750 | goto exit; |
| 751 | } |
| 752 | |
| 753 | psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), |
| 754 | GFP_KERNEL); |
| 755 | if (!psetstakey_rsp) { |
| 756 | kfree(ph2c); |
| 757 | kfree(psetstakey_para); |
| 758 | res = _FAIL; |
| 759 | goto exit; |
| 760 | } |
| 761 | |
| 762 | init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, |
| 763 | _SetStaKey_CMD_); |
| 764 | ph2c->rsp = (u8 *) psetstakey_rsp; |
| 765 | ph2c->rspsz = sizeof(struct set_stakey_rsp); |
| 766 | |
| 767 | ether_addr_copy(psetstakey_para->addr, sta->hwaddr); |
| 768 | |
Jes Sorensen | 9e3d6df | 2014-05-21 09:37:34 +0200 | [diff] [blame] | 769 | psetstakey_para->algorithm = 0; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 770 | |
| 771 | psetstakey_para->id = entry; |
| 772 | |
| 773 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 774 | } |
| 775 | exit: |
| 776 | return res; |
| 777 | } |
| 778 | |
anuvazhayil | a58af1e | 2014-10-30 00:03:48 +0530 | [diff] [blame] | 779 | int rtw_addbareq_cmd23a(struct rtw_adapter *padapter, u8 tid, u8 *addr) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 780 | { |
| 781 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
| 782 | struct cmd_obj *ph2c; |
| 783 | struct addBaReq_parm *paddbareq_parm; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 784 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 785 | |
Jes Sorensen | d7f2c23 | 2014-05-09 15:04:17 +0200 | [diff] [blame] | 786 | if (tid >= MAXTID) { |
| 787 | res = _FAIL; |
| 788 | goto exit; |
| 789 | } |
| 790 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 791 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 792 | if (!ph2c) { |
| 793 | res = _FAIL; |
| 794 | goto exit; |
| 795 | } |
| 796 | |
| 797 | paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); |
| 798 | if (!paddbareq_parm) { |
| 799 | kfree(ph2c); |
| 800 | res = _FAIL; |
| 801 | goto exit; |
| 802 | } |
| 803 | |
| 804 | paddbareq_parm->tid = tid; |
| 805 | ether_addr_copy(paddbareq_parm->addr, addr); |
| 806 | |
| 807 | init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, |
| 808 | GEN_CMD_CODE(_AddBAReq)); |
| 809 | |
| 810 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 811 | exit: |
| 812 | return res; |
| 813 | } |
| 814 | |
anuvazhayil | a58af1e | 2014-10-30 00:03:48 +0530 | [diff] [blame] | 815 | int rtw_dynamic_chk_wk_cmd23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 816 | { |
| 817 | struct cmd_obj *ph2c; |
| 818 | struct drvextra_cmd_parm *pdrvextra_cmd_parm; |
| 819 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 820 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 821 | |
| 822 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 823 | if (!ph2c) { |
| 824 | res = _FAIL; |
| 825 | goto exit; |
| 826 | } |
| 827 | |
| 828 | pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); |
| 829 | if (!pdrvextra_cmd_parm) { |
| 830 | kfree(ph2c); |
| 831 | res = _FAIL; |
| 832 | goto exit; |
| 833 | } |
| 834 | |
| 835 | pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID; |
| 836 | pdrvextra_cmd_parm->type_size = 0; |
| 837 | pdrvextra_cmd_parm->pbuf = (u8 *)padapter; |
| 838 | |
| 839 | init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, |
| 840 | GEN_CMD_CODE(_Set_Drv_Extra)); |
| 841 | |
| 842 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 843 | exit: |
| 844 | |
| 845 | return res; |
| 846 | } |
| 847 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 848 | static void traffic_status_watchdog(struct rtw_adapter *padapter) |
| 849 | { |
| 850 | u8 bEnterPS; |
| 851 | u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false; |
| 852 | u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false; |
| 853 | u8 bHigherBusyTxTraffic = false; |
| 854 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Larry Finger | c17416e | 2014-03-28 21:37:42 -0500 | [diff] [blame] | 855 | int BusyThreshold = 100; |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 856 | struct rt_link_detect *ldi = &pmlmepriv->LinkDetectInfo; |
| 857 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 858 | /* */ |
| 859 | /* Determine if our traffic is busy now */ |
| 860 | /* */ |
| 861 | if (check_fwstate(pmlmepriv, _FW_LINKED)) { |
Jes Sorensen | 09d8879 | 2014-05-25 22:43:32 +0200 | [diff] [blame] | 862 | if (rtl8723a_BT_coexist(padapter)) |
| 863 | BusyThreshold = 50; |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 864 | else if (ldi->bBusyTraffic) |
Jes Sorensen | 09d8879 | 2014-05-25 22:43:32 +0200 | [diff] [blame] | 865 | BusyThreshold = 75; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 866 | /* if we raise bBusyTraffic in last watchdog, using |
| 867 | lower threshold. */ |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 868 | if (ldi->NumRxOkInPeriod > BusyThreshold || |
| 869 | ldi->NumTxOkInPeriod > BusyThreshold) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 870 | bBusyTraffic = true; |
| 871 | |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 872 | if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 873 | bRxBusyTraffic = true; |
| 874 | else |
| 875 | bTxBusyTraffic = true; |
| 876 | } |
| 877 | |
| 878 | /* Higher Tx/Rx data. */ |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 879 | if (ldi->NumRxOkInPeriod > 4000 || |
| 880 | ldi->NumTxOkInPeriod > 4000) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 881 | bHigherBusyTraffic = true; |
| 882 | |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 883 | if (ldi->NumRxOkInPeriod > ldi->NumTxOkInPeriod) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 884 | bHigherBusyRxTraffic = true; |
| 885 | else |
| 886 | bHigherBusyTxTraffic = true; |
| 887 | } |
| 888 | |
Jes Sorensen | ef95e27 | 2014-05-25 22:43:26 +0200 | [diff] [blame] | 889 | if (!rtl8723a_BT_coexist(padapter) || |
| 890 | !rtl8723a_BT_using_antenna_1(padapter)) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 891 | /* check traffic for powersaving. */ |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 892 | if (((ldi->NumRxUnicastOkInPeriod + |
| 893 | ldi->NumTxOkInPeriod) > 8) || |
| 894 | ldi->NumRxUnicastOkInPeriod > 2) |
Jes Sorensen | ef95e27 | 2014-05-25 22:43:26 +0200 | [diff] [blame] | 895 | bEnterPS = false; |
| 896 | else |
| 897 | bEnterPS = true; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 898 | |
Jes Sorensen | ef95e27 | 2014-05-25 22:43:26 +0200 | [diff] [blame] | 899 | /* LeisurePS only work in infra mode. */ |
| 900 | if (bEnterPS) |
| 901 | LPS_Enter23a(padapter); |
| 902 | else |
| 903 | LPS_Leave23a(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 904 | } |
| 905 | } else |
| 906 | LPS_Leave23a(padapter); |
| 907 | |
Sanjeev Sharma | 6b1b4ca | 2014-11-11 15:28:14 +0530 | [diff] [blame] | 908 | ldi->NumRxOkInPeriod = 0; |
| 909 | ldi->NumTxOkInPeriod = 0; |
| 910 | ldi->NumRxUnicastOkInPeriod = 0; |
| 911 | ldi->bBusyTraffic = bBusyTraffic; |
| 912 | ldi->bTxBusyTraffic = bTxBusyTraffic; |
| 913 | ldi->bRxBusyTraffic = bRxBusyTraffic; |
| 914 | ldi->bHigherBusyTraffic = bHigherBusyTraffic; |
| 915 | ldi->bHigherBusyRxTraffic = bHigherBusyRxTraffic; |
| 916 | ldi->bHigherBusyTxTraffic = bHigherBusyTxTraffic; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 917 | } |
| 918 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 919 | static void dynamic_chk_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 920 | { |
| 921 | struct mlme_priv *pmlmepriv; |
| 922 | |
| 923 | padapter = (struct rtw_adapter *)pbuf; |
| 924 | pmlmepriv = &padapter->mlmepriv; |
| 925 | |
| 926 | #ifdef CONFIG_8723AU_AP_MODE |
Jes Sorensen | f2f9703 | 2014-05-25 22:43:04 +0200 | [diff] [blame] | 927 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 928 | expire_timeout_chk23a(padapter); |
| 929 | #endif |
| 930 | |
Jes Sorensen | b7c19c2 | 2014-05-16 10:04:00 +0200 | [diff] [blame] | 931 | rtl8723a_sreset_xmit_status_check(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 932 | |
| 933 | linked_status_chk23a(padapter); |
| 934 | traffic_status_watchdog(padapter); |
| 935 | |
Jes Sorensen | 8289d35 | 2014-05-16 10:03:59 +0200 | [diff] [blame] | 936 | rtl8723a_HalDmWatchDog(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 937 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 938 | /* */ |
| 939 | /* BT-Coexist */ |
| 940 | /* */ |
Jes Sorensen | febf308 | 2014-05-25 22:43:27 +0200 | [diff] [blame] | 941 | rtl8723a_BT_do_coexist(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 942 | } |
| 943 | |
Larry Finger | c0b99be | 2014-04-26 18:55:17 +0200 | [diff] [blame] | 944 | static void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 945 | { |
| 946 | struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; |
| 947 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 948 | u8 mstatus; |
| 949 | |
Jes Sorensen | f2f9703 | 2014-05-25 22:43:04 +0200 | [diff] [blame] | 950 | if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || |
| 951 | check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 952 | return; |
| 953 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 954 | switch (lps_ctrl_type) { |
Tina Ruchandani | 3e3f878 | 2014-10-23 20:17:48 -0700 | [diff] [blame] | 955 | case LPS_CTRL_SCAN: |
| 956 | rtl8723a_BT_wifiscan_notify(padapter, true); |
| 957 | if (!rtl8723a_BT_using_antenna_1(padapter)) { |
| 958 | if (check_fwstate(pmlmepriv, _FW_LINKED)) |
| 959 | LPS_Leave23a(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 960 | } |
Tina Ruchandani | 3e3f878 | 2014-10-23 20:17:48 -0700 | [diff] [blame] | 961 | break; |
| 962 | case LPS_CTRL_JOINBSS: |
| 963 | LPS_Leave23a(padapter); |
| 964 | break; |
| 965 | case LPS_CTRL_CONNECT: |
| 966 | mstatus = 1;/* connect */ |
| 967 | /* Reset LPS Setting */ |
| 968 | padapter->pwrctrlpriv.LpsIdleCount = 0; |
| 969 | rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); |
| 970 | rtl8723a_BT_mediastatus_notify(padapter, mstatus); |
| 971 | break; |
| 972 | case LPS_CTRL_DISCONNECT: |
| 973 | mstatus = 0;/* disconnect */ |
| 974 | rtl8723a_BT_mediastatus_notify(padapter, mstatus); |
| 975 | if (!rtl8723a_BT_using_antenna_1(padapter)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 976 | LPS_Leave23a(padapter); |
Tina Ruchandani | 3e3f878 | 2014-10-23 20:17:48 -0700 | [diff] [blame] | 977 | rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); |
| 978 | break; |
| 979 | case LPS_CTRL_SPECIAL_PACKET: |
| 980 | pwrpriv->DelayLPSLastTimeStamp = jiffies; |
| 981 | rtl8723a_BT_specialpacket_notify(padapter); |
| 982 | if (!rtl8723a_BT_using_antenna_1(padapter)) |
| 983 | LPS_Leave23a(padapter); |
| 984 | break; |
| 985 | case LPS_CTRL_LEAVE: |
| 986 | rtl8723a_BT_lps_leave(padapter); |
| 987 | if (!rtl8723a_BT_using_antenna_1(padapter)) |
| 988 | LPS_Leave23a(padapter); |
| 989 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 990 | |
Tina Ruchandani | 3e3f878 | 2014-10-23 20:17:48 -0700 | [diff] [blame] | 991 | default: |
| 992 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 993 | } |
| 994 | } |
| 995 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 996 | int rtw_lps_ctrl_wk_cmd23a(struct rtw_adapter *padapter, |
| 997 | u8 lps_ctrl_type, u8 enqueue) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 998 | { |
| 999 | struct cmd_obj *ph2c; |
| 1000 | struct drvextra_cmd_parm *pdrvextra_cmd_parm; |
| 1001 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1002 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1003 | |
| 1004 | if (enqueue) { |
| 1005 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 1006 | if (!ph2c) { |
| 1007 | res = _FAIL; |
| 1008 | goto exit; |
| 1009 | } |
| 1010 | |
| 1011 | pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), |
| 1012 | GFP_ATOMIC); |
| 1013 | if (!pdrvextra_cmd_parm) { |
| 1014 | kfree(ph2c); |
| 1015 | res = _FAIL; |
| 1016 | goto exit; |
| 1017 | } |
| 1018 | |
| 1019 | pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID; |
| 1020 | pdrvextra_cmd_parm->type_size = lps_ctrl_type; |
| 1021 | pdrvextra_cmd_parm->pbuf = NULL; |
| 1022 | |
| 1023 | init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, |
| 1024 | GEN_CMD_CODE(_Set_Drv_Extra)); |
| 1025 | |
| 1026 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 1027 | } else |
| 1028 | lps_ctrl_wk_hdl(padapter, lps_ctrl_type); |
| 1029 | exit: |
| 1030 | |
| 1031 | return res; |
| 1032 | } |
| 1033 | |
anuvazhayil | a58af1e | 2014-10-30 00:03:48 +0530 | [diff] [blame] | 1034 | int rtw_ps_cmd23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1035 | { |
| 1036 | struct cmd_obj *ppscmd; |
| 1037 | struct drvextra_cmd_parm *pdrvextra_cmd_parm; |
| 1038 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1039 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1040 | |
| 1041 | ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 1042 | if (!ppscmd) { |
| 1043 | res = _FAIL; |
| 1044 | goto exit; |
| 1045 | } |
| 1046 | |
| 1047 | pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), |
| 1048 | GFP_ATOMIC); |
| 1049 | if (!pdrvextra_cmd_parm) { |
| 1050 | kfree(ppscmd); |
| 1051 | res = _FAIL; |
| 1052 | goto exit; |
| 1053 | } |
| 1054 | |
| 1055 | pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; |
| 1056 | pdrvextra_cmd_parm->pbuf = NULL; |
| 1057 | init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, |
| 1058 | GEN_CMD_CODE(_Set_Drv_Extra)); |
| 1059 | |
| 1060 | res = rtw_enqueue_cmd23a(pcmdpriv, ppscmd); |
| 1061 | exit: |
| 1062 | |
| 1063 | return res; |
| 1064 | } |
| 1065 | |
| 1066 | #ifdef CONFIG_8723AU_AP_MODE |
| 1067 | |
| 1068 | static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) |
| 1069 | { |
| 1070 | int cnt = 0; |
| 1071 | struct sta_info *psta_bmc; |
| 1072 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1073 | |
| 1074 | psta_bmc = rtw_get_bcmc_stainfo23a(padapter); |
| 1075 | if (!psta_bmc) |
| 1076 | return; |
| 1077 | |
| 1078 | if (psta_bmc->sleepq_len == 0) { |
Jes Sorensen | 8d3fd61 | 2014-04-09 23:20:55 +0200 | [diff] [blame] | 1079 | bool val; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1080 | |
Jes Sorensen | 8d3fd61 | 2014-04-09 23:20:55 +0200 | [diff] [blame] | 1081 | val = rtl8723a_chk_hi_queue_empty(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1082 | |
Roberta Dobrescu | 08551cb | 2014-10-26 23:30:05 +0200 | [diff] [blame] | 1083 | while (!val) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1084 | msleep(100); |
| 1085 | |
| 1086 | cnt++; |
| 1087 | |
Sanjeev Sharma | af13ccf | 2014-11-11 13:24:43 +0530 | [diff] [blame] | 1088 | if (cnt > 10) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1089 | break; |
| 1090 | |
Jes Sorensen | 8d3fd61 | 2014-04-09 23:20:55 +0200 | [diff] [blame] | 1091 | val = rtl8723a_chk_hi_queue_empty(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1092 | } |
| 1093 | |
| 1094 | if (cnt <= 10) { |
| 1095 | pstapriv->tim_bitmap &= ~BIT(0); |
| 1096 | pstapriv->sta_dz_bitmap &= ~BIT(0); |
| 1097 | |
Jes Sorensen | 3021bc4 | 2014-04-15 19:43:33 +0200 | [diff] [blame] | 1098 | update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1099 | } else /* re check again */ |
| 1100 | rtw_chk_hi_queue_cmd23a(padapter); |
| 1101 | } |
| 1102 | } |
| 1103 | |
anuvazhayil | a58af1e | 2014-10-30 00:03:48 +0530 | [diff] [blame] | 1104 | int rtw_chk_hi_queue_cmd23a(struct rtw_adapter *padapter) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1105 | { |
| 1106 | struct cmd_obj *ph2c; |
| 1107 | struct drvextra_cmd_parm *pdrvextra_cmd_parm; |
| 1108 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1109 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1110 | |
| 1111 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 1112 | if (!ph2c) { |
| 1113 | res = _FAIL; |
| 1114 | goto exit; |
| 1115 | } |
| 1116 | |
| 1117 | pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), |
| 1118 | GFP_ATOMIC); |
| 1119 | if (!pdrvextra_cmd_parm) { |
| 1120 | kfree(ph2c); |
| 1121 | res = _FAIL; |
| 1122 | goto exit; |
| 1123 | } |
| 1124 | |
| 1125 | pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID; |
| 1126 | pdrvextra_cmd_parm->type_size = 0; |
| 1127 | pdrvextra_cmd_parm->pbuf = NULL; |
| 1128 | |
| 1129 | init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, |
| 1130 | GEN_CMD_CODE(_Set_Drv_Extra)); |
| 1131 | |
| 1132 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 1133 | exit: |
| 1134 | |
| 1135 | return res; |
| 1136 | } |
| 1137 | #endif |
| 1138 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1139 | int rtw_c2h_wk_cmd23a(struct rtw_adapter *padapter, u8 *c2h_evt) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1140 | { |
| 1141 | struct cmd_obj *ph2c; |
| 1142 | struct drvextra_cmd_parm *pdrvextra_cmd_parm; |
| 1143 | struct cmd_priv *pcmdpriv = &padapter->cmdpriv; |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1144 | int res = _SUCCESS; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1145 | |
| 1146 | ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); |
| 1147 | if (!ph2c) { |
| 1148 | res = _FAIL; |
| 1149 | goto exit; |
| 1150 | } |
| 1151 | |
| 1152 | pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), |
| 1153 | GFP_ATOMIC); |
| 1154 | if (!pdrvextra_cmd_parm) { |
| 1155 | kfree(ph2c); |
| 1156 | res = _FAIL; |
| 1157 | goto exit; |
| 1158 | } |
| 1159 | |
| 1160 | pdrvextra_cmd_parm->ec_id = C2H_WK_CID; |
| 1161 | pdrvextra_cmd_parm->type_size = c2h_evt?16:0; |
| 1162 | pdrvextra_cmd_parm->pbuf = c2h_evt; |
| 1163 | |
| 1164 | init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, |
| 1165 | GEN_CMD_CODE(_Set_Drv_Extra)); |
| 1166 | |
| 1167 | res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); |
| 1168 | |
| 1169 | exit: |
| 1170 | |
| 1171 | return res; |
| 1172 | } |
| 1173 | |
Jes Sorensen | 849befa | 2014-05-09 15:04:10 +0200 | [diff] [blame] | 1174 | static int c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1175 | { |
Jes Sorensen | ab281e3 | 2014-05-09 15:04:09 +0200 | [diff] [blame] | 1176 | int ret = _FAIL; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1177 | u8 buf[16]; |
| 1178 | |
| 1179 | if (!c2h_evt) { |
| 1180 | /* No c2h event in cmd_obj, read c2h event before handling*/ |
| 1181 | if (c2h_evt_read23a(adapter, buf) == _SUCCESS) { |
| 1182 | c2h_evt = (struct c2h_evt_hdr *)buf; |
| 1183 | |
Jes Sorensen | 00cf86c | 2014-05-09 15:04:12 +0200 | [diff] [blame] | 1184 | ret = c2h_handler_8723a(adapter, c2h_evt); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1185 | } |
Jes Sorensen | 849befa | 2014-05-09 15:04:10 +0200 | [diff] [blame] | 1186 | } else |
Jes Sorensen | 00cf86c | 2014-05-09 15:04:12 +0200 | [diff] [blame] | 1187 | ret = c2h_handler_8723a(adapter, c2h_evt); |
Jes Sorensen | 849befa | 2014-05-09 15:04:10 +0200 | [diff] [blame] | 1188 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1189 | return ret; |
| 1190 | } |
| 1191 | |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1192 | static void rtw_irq_work(struct work_struct *work) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1193 | { |
| 1194 | struct evt_priv *evtpriv; |
| 1195 | struct rtw_adapter *adapter; |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1196 | |
| 1197 | evtpriv = container_of(work, struct evt_priv, irq_wk); |
| 1198 | adapter = container_of(evtpriv, struct rtw_adapter, evtpriv); |
| 1199 | |
| 1200 | c2h_evt_clear23a(adapter); |
| 1201 | } |
| 1202 | |
| 1203 | void rtw_evt_work(struct work_struct *work) |
| 1204 | { |
| 1205 | struct evt_work *ework; |
| 1206 | struct rtw_adapter *adapter; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1207 | |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1208 | ework = container_of(work, struct evt_work, work); |
| 1209 | adapter = ework->adapter; |
| 1210 | |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1211 | c2h_evt_clear23a(adapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1212 | |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1213 | if (!c2h_evt_exist(&ework->u.c2h_evt)) { |
| 1214 | kfree(ework); |
| 1215 | return; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1216 | } |
| 1217 | |
Jes Sorensen | 227ca8c | 2014-05-09 15:04:11 +0200 | [diff] [blame] | 1218 | if (c2h_id_filter_ccx_8723a(ework->u.c2h_evt.id) == true) { |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1219 | /* Handle CCX report here */ |
Jes Sorensen | 00cf86c | 2014-05-09 15:04:12 +0200 | [diff] [blame] | 1220 | c2h_handler_8723a(adapter, &ework->u.c2h_evt); |
Jes Sorensen | 980cf72 | 2014-05-09 15:03:14 +0200 | [diff] [blame] | 1221 | kfree(ework); |
| 1222 | } else { |
| 1223 | /* |
| 1224 | * Enqueue into cmd_thread for others. |
| 1225 | * ework will be turned into a c2h_evt and freed once it |
| 1226 | * has been consumed. |
| 1227 | */ |
| 1228 | rtw_c2h_wk_cmd23a(adapter, (u8 *)&ework->u.c2h_evt); |
| 1229 | } |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1230 | } |
| 1231 | |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1232 | int rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, const u8 *pbuf) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1233 | { |
Jes Sorensen | 0348dc74 | 2014-04-26 18:55:06 +0200 | [diff] [blame] | 1234 | const struct drvextra_cmd_parm *pdrvextra_cmd; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1235 | |
| 1236 | if (!pbuf) |
| 1237 | return H2C_PARAMETERS_ERROR; |
| 1238 | |
| 1239 | pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; |
| 1240 | |
Tina Ruchandani | f237216 | 2014-10-23 20:16:51 -0700 | [diff] [blame] | 1241 | switch (pdrvextra_cmd->ec_id) { |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1242 | case DYNAMIC_CHK_WK_CID: |
| 1243 | dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, |
| 1244 | pdrvextra_cmd->type_size); |
| 1245 | break; |
| 1246 | case POWER_SAVING_CTRL_WK_CID: |
Jes Sorensen | 462eb49 | 2014-07-01 10:11:15 +0200 | [diff] [blame] | 1247 | rtw_ps_processor23a(padapter); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1248 | break; |
| 1249 | case LPS_CTRL_WK_CID: |
| 1250 | lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); |
| 1251 | break; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1252 | #ifdef CONFIG_8723AU_AP_MODE |
| 1253 | case CHECK_HIQ_WK_CID: |
| 1254 | rtw_chk_hi_queue_hdl(padapter); |
| 1255 | break; |
| 1256 | #endif /* CONFIG_8723AU_AP_MODE */ |
| 1257 | case C2H_WK_CID: |
| 1258 | c2h_evt_hdl(padapter, |
Jes Sorensen | 849befa | 2014-05-09 15:04:10 +0200 | [diff] [blame] | 1259 | (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1260 | break; |
| 1261 | |
| 1262 | default: |
| 1263 | break; |
| 1264 | } |
| 1265 | |
| 1266 | if (pdrvextra_cmd->pbuf && (pdrvextra_cmd->type_size > 0)) { |
| 1267 | kfree(pdrvextra_cmd->pbuf); |
Jes Sorensen | 0348dc74 | 2014-04-26 18:55:06 +0200 | [diff] [blame] | 1268 | /* |
| 1269 | * No need to set pdrvextra_cmd->pbuf = NULL as we were |
| 1270 | * operating on a copy of the original pcmd->parmbuf |
| 1271 | * created in rtw_cmd_work(). |
| 1272 | */ |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | return H2C_SUCCESS; |
| 1276 | } |
| 1277 | |
| 1278 | void rtw_survey_cmd_callback23a(struct rtw_adapter *padapter, |
Jes Sorensen | 1ec8911 | 2014-05-16 10:04:28 +0200 | [diff] [blame] | 1279 | struct cmd_obj *pcmd) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1280 | { |
| 1281 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1282 | |
| 1283 | if (pcmd->res == H2C_DROPPED) { |
| 1284 | /* TODO: cancel timer and do timeout handler directly... */ |
| 1285 | /* need to make timeout handlerOS independent */ |
| 1286 | mod_timer(&pmlmepriv->scan_to_timer, |
| 1287 | jiffies + msecs_to_jiffies(1)); |
| 1288 | } else if (pcmd->res != H2C_SUCCESS) { |
| 1289 | mod_timer(&pmlmepriv->scan_to_timer, |
| 1290 | jiffies + msecs_to_jiffies(1)); |
| 1291 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1292 | "********Error: MgntActrtw_set_802_11_bssid23a_LIST_SCAN Fail ************\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1293 | } |
| 1294 | |
| 1295 | /* free cmd */ |
| 1296 | rtw_free_cmd_obj23a(pcmd); |
| 1297 | } |
| 1298 | |
| 1299 | void rtw_disassoc_cmd23a_callback(struct rtw_adapter *padapter, |
| 1300 | struct cmd_obj *pcmd) |
| 1301 | { |
| 1302 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1303 | |
| 1304 | if (pcmd->res != H2C_SUCCESS) { |
| 1305 | spin_lock_bh(&pmlmepriv->lock); |
| 1306 | set_fwstate(pmlmepriv, _FW_LINKED); |
| 1307 | spin_unlock_bh(&pmlmepriv->lock); |
| 1308 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1309 | "***Error: disconnect_cmd_callback Fail ***\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1310 | return; |
| 1311 | } |
| 1312 | |
| 1313 | /* free cmd */ |
| 1314 | rtw_free_cmd_obj23a(pcmd); |
| 1315 | } |
| 1316 | |
| 1317 | void rtw_joinbss_cmd23a_callback(struct rtw_adapter *padapter, |
| 1318 | struct cmd_obj *pcmd) |
| 1319 | { |
| 1320 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1321 | |
| 1322 | if (pcmd->res == H2C_DROPPED) { |
| 1323 | /* TODO: cancel timer and do timeout handler directly... */ |
| 1324 | /* need to make timeout handlerOS independent */ |
| 1325 | mod_timer(&pmlmepriv->assoc_timer, |
| 1326 | jiffies + msecs_to_jiffies(1)); |
| 1327 | } else if (pcmd->res != H2C_SUCCESS) { |
| 1328 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1329 | "********Error:rtw_select_and_join_from_scanned_queue Wait Sema Fail ************\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1330 | mod_timer(&pmlmepriv->assoc_timer, |
| 1331 | jiffies + msecs_to_jiffies(1)); |
| 1332 | } |
| 1333 | |
| 1334 | rtw_free_cmd_obj23a(pcmd); |
| 1335 | } |
| 1336 | |
| 1337 | void rtw_createbss_cmd23a_callback(struct rtw_adapter *padapter, |
| 1338 | struct cmd_obj *pcmd) |
| 1339 | { |
| 1340 | struct sta_info *psta; |
| 1341 | struct wlan_network *pwlan; |
| 1342 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
| 1343 | struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; |
| 1344 | struct wlan_network *tgt_network = &pmlmepriv->cur_network; |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1345 | struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1346 | |
| 1347 | if (pcmd->res != H2C_SUCCESS) { |
| 1348 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1349 | "********Error: rtw_createbss_cmd23a_callback Fail ************\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1350 | mod_timer(&pmlmepriv->assoc_timer, |
| 1351 | jiffies + msecs_to_jiffies(1)); |
| 1352 | } |
| 1353 | |
| 1354 | del_timer_sync(&pmlmepriv->assoc_timer); |
| 1355 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1356 | if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { |
| 1357 | psta = rtw_get_stainfo23a(&padapter->stapriv, |
| 1358 | pnetwork->MacAddress); |
| 1359 | if (!psta) { |
| 1360 | psta = rtw_alloc_stainfo23a(&padapter->stapriv, |
Jes Sorensen | 6e8bc71 | 2014-05-09 15:03:49 +0200 | [diff] [blame] | 1361 | pnetwork->MacAddress, |
| 1362 | GFP_KERNEL); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1363 | if (!psta) { |
| 1364 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1365 | "Can't alloc sta_info when createbss_cmd_callback\n"); |
Yeliz Taneroglu | 25d5546 | 2015-02-27 12:58:09 +0200 | [diff] [blame] | 1366 | goto createbss_cmd_fail; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1367 | } |
| 1368 | } |
| 1369 | |
Jes Sorensen | 5290cd6 | 2014-05-09 15:03:45 +0200 | [diff] [blame] | 1370 | spin_lock_bh(&pmlmepriv->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1371 | rtw_indicate_connect23a(padapter); |
Jes Sorensen | 5290cd6 | 2014-05-09 15:03:45 +0200 | [diff] [blame] | 1372 | spin_unlock_bh(&pmlmepriv->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1373 | } else { |
Jes Sorensen | ec838b0 | 2014-05-09 15:03:46 +0200 | [diff] [blame] | 1374 | pwlan = rtw_alloc_network(pmlmepriv, GFP_KERNEL); |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1375 | spin_lock_bh(&scanned_queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1376 | if (!pwlan) { |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1377 | pwlan = rtw_get_oldest_wlan_network23a(scanned_queue); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1378 | if (!pwlan) { |
| 1379 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1380 | "Error: can't get pwlan in rtw23a_joinbss_event_cb\n"); |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1381 | spin_unlock_bh(&scanned_queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1382 | goto createbss_cmd_fail; |
| 1383 | } |
| 1384 | pwlan->last_scanned = jiffies; |
| 1385 | } else { |
| 1386 | list_add_tail(&pwlan->list, |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1387 | &scanned_queue->queue); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1388 | } |
| 1389 | |
| 1390 | pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); |
| 1391 | memcpy(&pwlan->network, pnetwork, pnetwork->Length); |
| 1392 | /* pwlan->fixed = true; */ |
| 1393 | |
| 1394 | /* list_add_tail(&pwlan->list, |
| 1395 | &pmlmepriv->scanned_queue.queue); */ |
| 1396 | |
| 1397 | /* copy pdev_network information to |
| 1398 | pmlmepriv->cur_network */ |
| 1399 | memcpy(&tgt_network->network, pnetwork, |
| 1400 | get_wlan_bssid_ex_sz(pnetwork)); |
| 1401 | |
| 1402 | /* reset DSConfig */ |
| 1403 | |
Jes Sorensen | 5290cd6 | 2014-05-09 15:03:45 +0200 | [diff] [blame] | 1404 | clr_fwstate(pmlmepriv, _FW_UNDER_LINKING); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1405 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1406 | /* we will set _FW_LINKED when there is one more sat to |
| 1407 | join us (rtw_stassoc_event_callback23a) */ |
Alison Schofield | 164e265 | 2015-10-20 23:09:37 -0700 | [diff] [blame] | 1408 | spin_unlock_bh(&scanned_queue->lock); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1409 | } |
| 1410 | |
| 1411 | createbss_cmd_fail: |
| 1412 | |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1413 | rtw_free_cmd_obj23a(pcmd); |
| 1414 | } |
| 1415 | |
| 1416 | void rtw_setstaKey_cmdrsp_callback23a(struct rtw_adapter *padapter, |
| 1417 | struct cmd_obj *pcmd) |
| 1418 | { |
| 1419 | struct sta_priv *pstapriv; |
| 1420 | struct set_stakey_rsp *psetstakey_rsp; |
| 1421 | struct sta_info *psta; |
| 1422 | |
| 1423 | pstapriv = &padapter->stapriv; |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1424 | psetstakey_rsp = (struct set_stakey_rsp *) (pcmd->rsp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1425 | psta = rtw_get_stainfo23a(pstapriv, psetstakey_rsp->addr); |
| 1426 | |
| 1427 | if (!psta) { |
| 1428 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1429 | "ERROR: rtw_setstaKey_cmdrsp_callback23a => can't get sta_info\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1430 | goto exit; |
| 1431 | } |
| 1432 | |
| 1433 | exit: |
| 1434 | |
| 1435 | rtw_free_cmd_obj23a(pcmd); |
| 1436 | } |
| 1437 | |
| 1438 | void rtw_setassocsta_cmdrsp_callback23a(struct rtw_adapter *padapter, |
| 1439 | struct cmd_obj *pcmd) |
| 1440 | { |
| 1441 | struct sta_priv *pstapriv = &padapter->stapriv; |
| 1442 | struct mlme_priv *pmlmepriv = &padapter->mlmepriv; |
Greg Donald | 4e66cf0 | 2014-08-22 10:57:49 -0500 | [diff] [blame] | 1443 | struct set_assocsta_parm *passocsta_parm; |
| 1444 | struct set_assocsta_rsp *passocsta_rsp; |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1445 | struct sta_info *psta; |
| 1446 | |
| 1447 | passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); |
Greg Donald | 7e6646d | 2014-09-06 19:42:03 -0500 | [diff] [blame] | 1448 | passocsta_rsp = (struct set_assocsta_rsp *) (pcmd->rsp); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1449 | psta = rtw_get_stainfo23a(pstapriv, passocsta_parm->addr); |
| 1450 | |
| 1451 | if (psta == NULL) { |
| 1452 | RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, |
Joe Perches | 90403aa | 2015-03-24 16:06:44 -0700 | [diff] [blame] | 1453 | "ERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n"); |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1454 | goto exit; |
| 1455 | } |
| 1456 | |
| 1457 | psta->aid = psta->mac_id = passocsta_rsp->cam_id; |
| 1458 | |
| 1459 | spin_lock_bh(&pmlmepriv->lock); |
| 1460 | |
Jes Sorensen | f2f9703 | 2014-05-25 22:43:04 +0200 | [diff] [blame] | 1461 | if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && |
| 1462 | check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) |
Larry Finger | 5e93f35 | 2014-03-28 21:37:38 -0500 | [diff] [blame] | 1463 | _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); |
| 1464 | |
| 1465 | set_fwstate(pmlmepriv, _FW_LINKED); |
| 1466 | spin_unlock_bh(&pmlmepriv->lock); |
| 1467 | |
| 1468 | exit: |
| 1469 | rtw_free_cmd_obj23a(pcmd); |
| 1470 | } |