1 #ifndef __RTL871X_CMD_H_
2 #define __RTL871X_CMD_H_
4 #include "wlan_bssdef.h"
5 #include "rtl871x_rf.h"
6 #define C2H_MEM_SZ (16*1024)
8 #include "osdep_service.h"
11 #define FREE_CMDOBJ_SZ 128
14 #define MAX_EVTSZ 1024
15 #define CMDBUFF_ALIGN_SZ 512
24 struct list_head list;
28 struct semaphore cmd_queue_sema;
29 struct semaphore terminate_cmdthread_sema;
30 struct __queue cmd_queue;
32 u8 *cmd_buf; /*shall be non-paged, and 4 bytes aligned*/
33 u8 *cmd_allocated_buf;
34 u8 *rsp_buf; /*shall be non-paged, and 4 bytes aligned*/
35 u8 *rsp_allocated_buf;
39 struct _adapter *padapter;
47 struct list_head list;
51 struct __queue evt_queue;
53 u8 *evt_buf; /*shall be non-paged, and 4 bytes aligned*/
54 u8 *evt_allocated_buf;
56 struct tasklet_struct event_tasklet;
59 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
61 _init_listhead(&pcmd->list);\
62 pcmd->cmdcode = code;\
63 pcmd->parmbuf = (u8 *)(pparm);\
64 pcmd->cmdsz = sizeof(*pparm);\
69 u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
70 u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
71 struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue);
72 void r8712_free_cmd_obj(struct cmd_obj *pcmd);
73 int r8712_cmd_thread(void *context);
74 u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv);
75 void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv);
76 u32 r8712_init_evt_priv(struct evt_priv *pevtpriv);
77 void r8712_free_evt_priv(struct evt_priv *pevtpriv);
79 enum rtl871x_drvint_cid {
92 * Caller Mode: Infra, Ad-HoC(C)
93 * Notes: To enter USB suspend mode
96 struct usb_suspend_parm {
97 u32 action; /* 1: sleep, 0:resume */
101 * Caller Mode: Infra, Ad-Hoc
102 * Notes: To join the specified bss
105 struct joinbss_parm {
106 struct ndis_wlan_bssid_ex network;
110 * Caller Mode: Infra, Ad-HoC(C)
111 * Notes: To disconnect the current associated BSS
114 struct disconnect_parm {
119 * Caller Mode: AP, Ad-HoC(M)
120 * Notes: To create a BSS
123 struct createbss_parm {
124 struct ndis_wlan_bssid_ex network;
128 * Caller Mode: AP, Ad-HoC, Infra
129 * Notes: To set the NIC mode of RTL8711
131 * The definition of mode:
133 * #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
134 * #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
135 * #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
136 * #define IW_MODE_MASTER 3 // Synchronisation master or AP
137 * #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
138 * #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
139 * #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
141 struct setopmode_parm {
147 * Caller Mode: AP, Ad-HoC, Infra
148 * Notes: To ask RTL8711 performing site-survey
151 struct sitesurvey_parm {
152 sint passive_mode; /*active: 1, passive: 0 */
153 sint bsslimit; /* 1 ~ 48 */
155 u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
160 * Notes: To set the auth type of RTL8711. open/shared/802.1x
163 struct setauth_parm {
164 u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
165 u8 _1x; /*0: PSK, 1: TLS*/
171 * a. algorithm: wep40, wep104, tkip & aes
172 * b. keytype: grp key/unicast key
175 * when shared key ==> keyid is the camid
176 * when 802.1x ==> keyid [0:1] ==> grp key
177 * when 802.1x ==> keyid > 2 ==> unicast key
180 u8 algorithm; /* encryption algorithm, could be none, wep40,
181 * TKIP, CCMP, wep104 */
183 u8 grpkey; /* 1: this is the grpkey for 802.1x.
184 * 0: this is the unicast key for 802.1x */
185 u8 key[16]; /* this could be 40 or 104 */
189 * When in AP or Ad-Hoc mode, this is used to
190 * allocate an sw/hw entry for a newly associated sta.
192 * when shared key ==> algorithm/keyid
194 struct set_stakey_parm {
200 struct set_stakey_rsp {
206 struct SetMacAddr_param {
207 u8 MacAddr[ETH_ALEN];
213 Command -Rsp(AID == CAMID) mode
215 This is to force fw to add an sta_data entry per driver's request.
217 FW will write an cam entry associated with it.
220 struct set_assocsta_parm {
224 struct set_assocsta_rsp {
234 This is to force fw to del an sta_data entry per driver's request
236 FW will invalidate the cam entry associated with it.
239 struct del_assocsta_parm {
244 Caller Mode: AP/Ad-HoC(M)
246 Notes: To notify fw that given staid has changed its power state
251 struct setstapwrstate_parm {
260 Notes: To setup the basic rate of RTL8711
265 struct setbasicrate_parm {
266 u8 basicrates[NumRates];
272 Notes: To read the current basic rate
277 struct getbasicrate_parm {
281 struct getbasicrate_rsp {
282 u8 basicrates[NumRates];
288 Notes: To setup the data rate of RTL8711
293 struct setdatarate_parm {
295 u8 datarates[NumRates];
301 Notes: To read the current data rate
306 struct getdatarate_parm {
310 struct getdatarate_rsp {
311 u8 datarates[NumRates];
317 AP: AP can use the info for the contents of beacon frame
318 Infra: STA can use the info when sitesurveying
323 Notes: To set the phy capability of the NIC
332 Notes: To set the channel/modem/band
333 This command will be used when channel/modem/band is changed.
341 Notes: To get the current setting of channel/modem/band
358 struct readTSSI_parm {
361 struct readTSSI_rsp {
365 struct writeBB_parm {
377 struct writeRF_parm {
382 struct setrfintfs_parm {
386 struct getrfintfs_parm {
391 Notes: This command is used for H2C/C2H loopback testing
394 ==> CMD mode, return H2C_SUCCESS.
395 The following condition must be ture under CMD mode
396 mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
397 s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
398 s2 == (b1 << 8 | b0);
401 ==> CMD_RSP mode, return H2C_SUCCESS_RSP
403 The rsp layout shall be:
420 ==> CMD_EVENT mode, return H2C_SUCCESS
421 The event layout shall be:
425 mac[2] = event's sequence number, starting from 1 to parm's marc[3]
429 s0 = swap16(s0) - event.mac[2];
430 s1 = s1 + event.mac[2];
433 s2 = s0 + event.mac[2]
435 w1 = swap32(w1) - event.mac[2];
437 parm->mac[3] is the total event counts that host requested.
440 event will be the same with the cmd's param.
444 /* CMD param Formart for DRV INTERNAL CMD HDL*/
445 struct drvint_cmd_parm {
446 int i_cid; /*internal cmd id*/
451 /*------------------- Below are used for RF/BB tunning ---------------------*/
453 struct setantenna_parm {
460 struct enrateadaptive_parm {
464 struct settxagctbl_parm {
465 u32 txagc[MAX_RATES_LENGTH];
468 struct gettxagctbl_parm {
471 struct gettxagctbl_rsp {
472 u32 txagc[MAX_RATES_LENGTH];
475 struct setagcctrl_parm {
476 u32 agcctrl; /* 0: pure hw, 1: fw */
479 struct setssup_parm {
480 u32 ss_ForceUp[MAX_RATES_LENGTH];
483 struct getssup_parm {
487 u8 ss_ForceUp[MAX_RATES_LENGTH];
490 struct setssdlevel_parm {
491 u8 ss_DLevel[MAX_RATES_LENGTH];
494 struct getssdlevel_parm {
497 struct getssdlevel_rsp {
498 u8 ss_DLevel[MAX_RATES_LENGTH];
501 struct setssulevel_parm {
502 u8 ss_ULevel[MAX_RATES_LENGTH];
505 struct getssulevel_parm {
508 struct getssulevel_rsp {
509 u8 ss_ULevel[MAX_RATES_LENGTH];
512 struct setcountjudge_parm {
513 u8 count_judge[MAX_RATES_LENGTH];
516 struct getcountjudge_parm {
520 struct getcountjudge_rsp {
521 u8 count_judge[MAX_RATES_LENGTH];
524 struct setpwrmode_parm {
526 u8 flag_low_traffic_en;
528 u8 flag_rf_low_snr_en;
529 u8 flag_dps_en; /* 1: dps, 0: 32k */
531 u8 bcn_pass_cnt; /* fw report one beacon information to
532 * driver when it receives bcn_pass_cnt
534 u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
536 u8 app_itv; /* only for VOIP mode. */
539 u8 bcn_pass_time; /* unit: 100ms */
542 struct setatim_parm {
543 u8 op; /*0: add, 1:del*/
544 u8 txid; /* id of dest station.*/
547 struct setratable_parm {
548 u8 ss_ForceUp[NumRates];
549 u8 ss_ULevel[NumRates];
550 u8 ss_DLevel[NumRates];
551 u8 count_judge[NumRates];
554 struct getratable_parm {
557 struct getratable_rsp {
558 u8 ss_ForceUp[NumRates];
559 u8 ss_ULevel[NumRates];
560 u8 ss_DLevel[NumRates];
561 u8 count_judge[NumRates];
564 /*to get TX,RX retry count*/
565 struct gettxretrycnt_parm{
569 struct gettxretrycnt_rsp{
570 unsigned long tx_retrycnt;
573 struct getrxretrycnt_parm{
577 struct getrxretrycnt_rsp{
578 unsigned long rx_retrycnt;
581 /*to get BCNOK,BCNERR count*/
582 struct getbcnokcnt_parm{
586 struct getbcnokcnt_rsp{
587 unsigned long bcnokcnt;
590 struct getbcnerrcnt_parm{
593 struct getbcnerrcnt_rsp{
594 unsigned long bcnerrcnt;
597 /* to get current TX power level*/
598 struct getcurtxpwrlevel_parm{
602 struct getcurtxpwrlevel_rsp{
603 unsigned short tx_power;
606 /*dynamic on/off DIG*/
608 unsigned char dig_on; /* 1:on , 0:off */
611 /*dynamic on/off RA*/
613 unsigned char ra_on; /* 1:on , 0:off */
616 struct setprobereqextraie_parm {
618 unsigned char ie_len;
622 struct setassocreqextraie_parm {
624 unsigned char ie_len;
628 struct setproberspextraie_parm {
630 unsigned char ie_len;
634 struct setassocrspextraie_parm {
636 unsigned char ie_len;
640 struct addBaReq_parm {
644 /*H2C Handler index: 46 */
645 struct SetChannel_parm {
649 /*H2C Handler index: 56 */
654 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
659 * 0x01: sucess, and check Response.
660 * 0x02: cmd ignored due to duplicated sequcne number
661 * 0x03: cmd dropped due to invalid cmd code
665 #define H2C_RSP_OFFSET 512
666 #define H2C_SUCCESS 0x00
667 #define H2C_SUCCESS_RSP 0x01
668 #define H2C_DUPLICATED 0x02
669 #define H2C_DROPPED 0x03
670 #define H2C_PARAMETERS_ERROR 0x04
671 #define H2C_REJECTED 0x05
672 #define H2C_CMD_OVERFLOW 0x06
673 #define H2C_RESERVED 0x07
675 u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr);
676 u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr);
677 u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
678 struct ndis_802_11_ssid *pssid);
679 u8 r8712_createbss_cmd(struct _adapter *padapter);
680 u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
681 u8 r8712_joinbss_cmd(struct _adapter *padapter,
682 struct wlan_network *pnetwork);
683 u8 r8712_disassoc_cmd(struct _adapter *padapter);
684 u8 r8712_setopmode_cmd(struct _adapter *padapter,
685 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
686 u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
687 u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset);
688 u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 * pval);
689 u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode);
690 u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val);
691 u8 r8712_setrttbl_cmd(struct _adapter *padapter,
692 struct setratable_parm *prate_table);
693 u8 r8712_setptm_cmd(struct _adapter *padapter, u8 type);
694 u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid);
695 u8 r8712_wdg_wk_cmd(struct _adapter *padapter);
696 void r8712_survey_cmd_callback(struct _adapter *padapter,
697 struct cmd_obj *pcmd);
698 void r8712_disassoc_cmd_callback(struct _adapter *padapter,
699 struct cmd_obj *pcmd);
700 void r8712_joinbss_cmd_callback(struct _adapter *padapter,
701 struct cmd_obj *pcmd);
702 void r8712_createbss_cmd_callback(struct _adapter *padapter,
703 struct cmd_obj *pcmd);
704 void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
705 struct cmd_obj *pcmd);
706 void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
707 struct cmd_obj *pcmd);
708 void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
709 struct cmd_obj *pcmd);
711 struct _cmd_callback {
713 void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
716 #include "rtl8712_cmd.h"