1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
6 ******************************************************************************/
10 #include <wlan_bssdef.h>
14 #include <osdep_service.h>
15 #include <ieee80211.h> /* <ieee80211/ieee80211.h> */
17 #define MAX_CMDSZ 1024
20 #define CMDBUFF_ALIGN_SZ 512
23 struct adapter *padapter;
30 struct list_head list;
34 struct completion cmd_queue_comp;
35 struct completion terminate_cmdthread_comp;
36 struct __queue cmd_queue;
38 struct adapter *padapter;
41 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
43 INIT_LIST_HEAD(&pcmd->list);\
44 pcmd->cmdcode = code;\
45 pcmd->parmbuf = (u8 *)(pparm);\
46 pcmd->cmdsz = sizeof(*pparm);\
51 u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
52 struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue);
53 void rtw_free_cmd_obj(struct cmd_obj *pcmd);
55 int rtw_cmd_thread(void *context);
57 int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv);
59 enum rtw_drvextra_cmd_id {
64 POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */
69 CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */
80 LPS_CTRL_DISCONNECT = 3,
81 LPS_CTRL_SPECIAL_PACKET = 4,
92 * Caller Mode: Infra, Ad-HoC(C)
94 * Notes: To disconnect the current associated BSS
99 struct disconnect_parm {
100 u32 deauth_timeout_ms;
103 struct setopmode_parm {
109 * Caller Mode: AP, Ad-HoC, Infra
111 * Notes: To ask RTL8711 performing site-survey
117 #define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */
118 #define RTW_CHANNEL_SCAN_AMOUNT (14+37)
119 struct sitesurvey_parm {
120 int scan_mode; /* active: 1, passive: 0 */
123 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
124 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
130 * Notes: To set the auth type of RTL8711. open/shared/802.1x
135 struct setauth_parm {
136 u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */
137 u8 _1x; /* 0: PSK, 1: TLS */
144 * a. algorithm: wep40, wep104, tkip & aes
145 * b. keytype: grp key/unicast key
148 * when shared key ==> keyid is the camid
149 * when 802.1x ==> keyid [0:1] ==> grp key
150 * when 802.1x ==> keyid > 2 ==> unicast key
154 u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */
156 u8 grpkey; /* 1: this is the grpkey for 802.1x.
157 * 0: this is the unicast key for 802.1x
159 u8 set_tx; /* 1: main tx key for wep. 0: other key. */
160 u8 key[16]; /* this could be 40 or 104 */
164 * When in AP or Ad-Hoc mode, this is used to
165 * allocate an sw/hw entry for a newly associated sta.
169 * when shared key ==> algorithm/keyid
172 struct set_stakey_parm {
175 u8 id;/* currently for erasing cam entry if
176 * algorithm == _NO_PRIVACY_
181 struct set_stakey_rsp {
190 * Command -Rsp(AID == CAMID) mode
192 * This is to force fw to add an sta_data entry per driver's request.
194 * FW will write an cam entry associated with it.
197 struct set_assocsta_parm {
201 struct set_assocsta_rsp {
207 * Notes: This command is used for H2C/C2H loopback testing
210 * ==> CMD mode, return H2C_SUCCESS.
211 * The following condition must be true under CMD mode
212 * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
213 * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
214 * s2 == (b1 << 8 | b0);
217 * ==> CMD_RSP mode, return H2C_SUCCESS_RSP
219 * The rsp layout shall be:
236 * ==> CMD_EVENT mode, return H2C_SUCCESS
237 * The event layout shall be:
241 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
242 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
243 * mac[2] = event's seq no, starting from 1 to parm's marc[3]
247 * s0 = swap16(s0) - event.mac[2];
248 * s1 = s1 + event.mac[2];
251 * s2 = s0 + event.mac[2]
253 * w1 = swap32(w1) - event.mac[2];
255 * parm->mac[3] is the total event counts that host requested.
256 * event will be the same with the cmd's param.
259 /* CMD param Format for driver extra cmd handler */
260 struct drvextra_cmd_parm {
261 int ec_id; /* extra cmd id */
262 int type_size; /* Can use this field as the type id or command size */
266 struct addBaReq_parm {
271 /*H2C Handler index: 46 */
278 /*H2C Handler index: 59 */
279 struct SetChannelPlan_param {
287 * 0x01: success, and check Response.
288 * 0x02: cmd ignored due to duplicated sequcne number
289 * 0x03: cmd dropped due to invalid cmd code
294 #define H2C_SUCCESS 0x00
295 #define H2C_SUCCESS_RSP 0x01
296 #define H2C_DROPPED 0x03
297 #define H2C_PARAMETERS_ERROR 0x04
298 #define H2C_REJECTED 0x05
300 u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
301 int ssid_num, struct rtw_ieee80211_channel *ch,
303 u8 rtw_createbss_cmd(struct adapter *padapter);
304 u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key);
305 u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry,
307 u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
308 u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms,
310 u8 rtw_setopmode_cmd(struct adapter *padapter,
311 enum ndis_802_11_network_infra networktype);
312 u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
314 u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
316 u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
317 u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime);
319 u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue);
320 u8 rtw_ps_cmd(struct adapter *padapter);
322 #ifdef CONFIG_88EU_AP_MODE
323 u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
326 u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue);
327 u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
329 void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
330 void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
331 void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
332 void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd);
333 void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
335 void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
336 void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm);
337 void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
339 struct _cmd_callback {
341 void (*callback)(struct adapter *padapter, struct cmd_obj *cmd);
359 _SetChannelPlan_CMD_,
365 static struct _cmd_callback rtw_cmd_callback[] = {
366 {_JoinBss_CMD_, &rtw_joinbss_cmd_callback},
367 {_DisConnect_CMD_, &rtw_disassoc_cmd_callback},
368 {_CreateBss_CMD_, &rtw_createbss_cmd_callback},
369 {_SetOpMode_CMD_, NULL},
370 {_SiteSurvey_CMD_, &rtw_survey_cmd_callback},
371 {_SetAuth_CMD_, NULL},
372 {_SetKey_CMD_, NULL},
373 {_SetStaKey_CMD_, &rtw_setstaKey_cmdrsp_callback},
374 {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback},
375 {_AddBAReq_CMD_, NULL},
376 {_SetChannel_CMD_, NULL},
377 {_TX_Beacon_CMD_, NULL},
378 {_Set_MLME_EVT_CMD_, NULL},
379 {_Set_Drv_Extra_CMD_, NULL},
380 {_SetChannelPlan_CMD_, NULL},