1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
18 #include <wlan_bssdef.h>
22 #include <osdep_service.h>
23 #include <ieee80211.h> /* <ieee80211/ieee80211.h> */
25 #define MAX_CMDSZ 1024
28 #define CMDBUFF_ALIGN_SZ 512
31 struct adapter
*padapter
;
38 struct list_head list
;
42 struct semaphore cmd_queue_sema
;
43 struct semaphore terminate_cmdthread_sema
;
44 struct __queue cmd_queue
;
46 struct adapter
*padapter
;
49 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
51 INIT_LIST_HEAD(&pcmd->list);\
52 pcmd->cmdcode = code;\
53 pcmd->parmbuf = (u8 *)(pparm);\
54 pcmd->cmdsz = sizeof(*pparm);\
59 u32
rtw_enqueue_cmd(struct cmd_priv
*pcmdpriv
, struct cmd_obj
*obj
);
60 struct cmd_obj
*rtw_dequeue_cmd(struct __queue
*queue
);
61 void rtw_free_cmd_obj(struct cmd_obj
*pcmd
);
63 int rtw_cmd_thread(void *context
);
65 int rtw_init_cmd_priv(struct cmd_priv
*pcmdpriv
);
67 enum rtw_drvextra_cmd_id
{
72 POWER_SAVING_CTRL_WK_CID
,/* IPS,AUTOSuspend */
77 CHECK_HIQ_WK_CID
,/* for softap mode, check hi queue if empty */
88 LPS_CTRL_DISCONNECT
= 3,
89 LPS_CTRL_SPECIAL_PACKET
= 4,
100 Caller Mode: Infra, Ad-HoC(C)
102 Notes: To disconnect the current associated BSS
107 struct disconnect_parm
{
108 u32 deauth_timeout_ms
;
111 struct setopmode_parm
{
117 Caller Mode: AP, Ad-HoC, Infra
119 Notes: To ask RTL8711 performing site-survey
125 #define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */
126 #define RTW_CHANNEL_SCAN_AMOUNT (14+37)
127 struct sitesurvey_parm
{
128 int scan_mode
; /* active: 1, passive: 0 */
131 struct ndis_802_11_ssid ssid
[RTW_SSID_SCAN_AMOUNT
];
132 struct rtw_ieee80211_channel ch
[RTW_CHANNEL_SCAN_AMOUNT
];
138 Notes: To set the auth type of RTL8711. open/shared/802.1x
143 struct setauth_parm
{
144 u8 mode
; /* 0: legacy open, 1: legacy shared 2: 802.1x */
145 u8 _1x
; /* 0: PSK, 1: TLS */
152 a. algorithm: wep40, wep104, tkip & aes
153 b. keytype: grp key/unicast key
156 when shared key ==> keyid is the camid
157 when 802.1x ==> keyid [0:1] ==> grp key
158 when 802.1x ==> keyid > 2 ==> unicast key
162 u8 algorithm
; /* could be none, wep40, TKIP, CCMP, wep104 */
164 u8 grpkey
; /* 1: this is the grpkey for 802.1x.
165 * 0: this is the unicast key for 802.1x */
166 u8 set_tx
; /* 1: main tx key for wep. 0: other key. */
167 u8 key
[16]; /* this could be 40 or 104 */
171 When in AP or Ad-Hoc mode, this is used to
172 allocate an sw/hw entry for a newly associated sta.
176 when shared key ==> algorithm/keyid
179 struct set_stakey_parm
{
182 u8 id
;/* currently for erasing cam entry if
183 * algorithm == _NO_PRIVACY_ */
187 struct set_stakey_rsp
{
196 Command -Rsp(AID == CAMID) mode
198 This is to force fw to add an sta_data entry per driver's request.
200 FW will write an cam entry associated with it.
203 struct set_assocsta_parm
{
207 struct set_assocsta_rsp
{
217 This is to force fw to del an sta_data entry per driver's request
219 FW will invalidate the cam entry associated with it.
222 struct del_assocsta_parm
{
227 Caller Mode: AP/Ad-HoC(M)
229 Notes: To notify fw that given staid has changed its power state
234 struct setstapwrstate_parm
{
241 Notes: This command is used for H2C/C2H loopback testing
244 ==> CMD mode, return H2C_SUCCESS.
245 The following condition must be ture under CMD mode
246 mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
247 s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
248 s2 == (b1 << 8 | b0);
251 ==> CMD_RSP mode, return H2C_SUCCESS_RSP
253 The rsp layout shall be:
270 ==> CMD_EVENT mode, return H2C_SUCCESS
271 The event layout shall be:
275 mac[2] = event's seq no, starting from 1 to parm's marc[3]
279 s0 = swap16(s0) - event.mac[2];
280 s1 = s1 + event.mac[2];
283 s2 = s0 + event.mac[2]
285 w1 = swap32(w1) - event.mac[2];
287 parm->mac[3] is the total event counts that host requested.
288 event will be the same with the cmd's param.
291 /* CMD param Format for driver extra cmd handler */
292 struct drvextra_cmd_parm
{
293 int ec_id
; /* extra cmd id */
294 int type_size
; /* Can use this field as the type id or command size */
298 struct addBaReq_parm
{
303 /*H2C Handler index: 46 */
310 /*H2C Handler index: 59 */
311 struct SetChannelPlan_param
{
315 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
321 0x01: success, and check Response.
322 0x02: cmd ignored due to duplicated sequcne number
323 0x03: cmd dropped due to invalid cmd code
328 #define H2C_SUCCESS 0x00
329 #define H2C_SUCCESS_RSP 0x01
330 #define H2C_DROPPED 0x03
331 #define H2C_PARAMETERS_ERROR 0x04
332 #define H2C_REJECTED 0x05
334 u8
rtw_sitesurvey_cmd(struct adapter
*padapter
, struct ndis_802_11_ssid
*ssid
,
335 int ssid_num
, struct rtw_ieee80211_channel
*ch
,
337 u8
rtw_createbss_cmd(struct adapter
*padapter
);
338 u8
rtw_setstakey_cmd(struct adapter
*padapter
, u8
*psta
, u8 unicast_key
);
339 u8
rtw_clearstakey_cmd(struct adapter
*padapter
, u8
*psta
, u8 entry
,
341 u8
rtw_joinbss_cmd(struct adapter
*padapter
, struct wlan_network
*pnetwork
);
342 u8
rtw_disassoc_cmd(struct adapter
*padapter
, u32 deauth_timeout_ms
,
344 u8
rtw_setopmode_cmd(struct adapter
*padapter
,
345 enum ndis_802_11_network_infra networktype
);
346 u8
rtw_addbareq_cmd(struct adapter
*padapter
, u8 tid
, u8
*addr
);
348 u8
rtw_dynamic_chk_wk_cmd(struct adapter
*adapter
);
350 u8
rtw_lps_ctrl_wk_cmd(struct adapter
*padapter
, u8 lps_ctrl_type
, u8 enqueue
);
351 u8
rtw_rpt_timer_cfg_cmd(struct adapter
*padapter
, u16 minRptTime
);
353 u8
rtw_antenna_select_cmd(struct adapter
*padapter
, u8 antenna
, u8 enqueue
);
354 u8
rtw_ps_cmd(struct adapter
*padapter
);
356 #ifdef CONFIG_88EU_AP_MODE
357 u8
rtw_chk_hi_queue_cmd(struct adapter
*padapter
);
360 u8
rtw_set_chplan_cmd(struct adapter
*padapter
, u8 chplan
, u8 enqueue
);
361 u8
rtw_drvextra_cmd_hdl(struct adapter
*padapter
, unsigned char *pbuf
);
363 void rtw_survey_cmd_callback(struct adapter
*padapter
, struct cmd_obj
*pcmd
);
364 void rtw_disassoc_cmd_callback(struct adapter
*padapter
, struct cmd_obj
*pcmd
);
365 void rtw_joinbss_cmd_callback(struct adapter
*padapter
, struct cmd_obj
*pcmd
);
366 void rtw_createbss_cmd_callback(struct adapter
*adapt
, struct cmd_obj
*pcmd
);
367 void rtw_readtssi_cmdrsp_callback(struct adapter
*adapt
, struct cmd_obj
*cmd
);
369 void rtw_setstaKey_cmdrsp_callback(struct adapter
*adapt
, struct cmd_obj
*cmd
);
370 void rtw_setassocsta_cmdrsp_callback(struct adapter
*adapt
, struct cmd_obj
*cm
);
371 void rtw_getrttbl_cmdrsp_callback(struct adapter
*adapt
, struct cmd_obj
*cmd
);
373 struct _cmd_callback
{
375 void (*callback
)(struct adapter
*padapter
, struct cmd_obj
*cmd
);
379 GEN_CMD_CODE(_JoinBss
),
380 GEN_CMD_CODE(_DisConnect
),
381 GEN_CMD_CODE(_CreateBss
),
382 GEN_CMD_CODE(_SetOpMode
),
383 GEN_CMD_CODE(_SiteSurvey
),
384 GEN_CMD_CODE(_SetAuth
),
385 GEN_CMD_CODE(_SetKey
),
386 GEN_CMD_CODE(_SetStaKey
),
387 GEN_CMD_CODE(_SetAssocSta
),
388 GEN_CMD_CODE(_AddBAReq
),
389 GEN_CMD_CODE(_SetChannel
),
390 GEN_CMD_CODE(_TX_Beacon
),
391 GEN_CMD_CODE(_Set_MLME_EVT
),
392 GEN_CMD_CODE(_Set_Drv_Extra
),
393 GEN_CMD_CODE(_SetChannelPlan
),
399 static struct _cmd_callback rtw_cmd_callback
[] = {
400 {GEN_CMD_CODE(_JoinBss
), &rtw_joinbss_cmd_callback
},
401 {GEN_CMD_CODE(_DisConnect
), &rtw_disassoc_cmd_callback
},
402 {GEN_CMD_CODE(_CreateBss
), &rtw_createbss_cmd_callback
},
403 {GEN_CMD_CODE(_SetOpMode
), NULL
},
404 {GEN_CMD_CODE(_SiteSurvey
), &rtw_survey_cmd_callback
},
405 {GEN_CMD_CODE(_SetAuth
), NULL
},
406 {GEN_CMD_CODE(_SetKey
), NULL
},
407 {GEN_CMD_CODE(_SetStaKey
), &rtw_setstaKey_cmdrsp_callback
},
408 {GEN_CMD_CODE(_SetAssocSta
), &rtw_setassocsta_cmdrsp_callback
},
409 {GEN_CMD_CODE(_AddBAReq
), NULL
},
410 {GEN_CMD_CODE(_SetChannel
), NULL
},
411 {GEN_CMD_CODE(_TX_Beacon
), NULL
},
412 {GEN_CMD_CODE(_Set_MLME_EVT
), NULL
},
413 {GEN_CMD_CODE(_Set_Drv_Extra
), NULL
},
414 {GEN_CMD_CODE(_SetChannelPlan
), NULL
},