Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
[linux-btrfs-devel.git] / drivers / staging / rtl8712 / rtl871x_cmd.h
blobdcf256d44d1ccd972cc9e1b3ffdcdbb792bbf9ac
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"
9 #include "ieee80211.h"
11 #define FREE_CMDOBJ_SZ 128
12 #define MAX_CMDSZ 512
13 #define MAX_RSPSZ 512
14 #define MAX_EVTSZ 1024
15 #define CMDBUFF_ALIGN_SZ 512
17 struct cmd_obj {
18 u16 cmdcode;
19 u8 res;
20 u8 *parmbuf;
21 u32 cmdsz;
22 u8 *rsp;
23 u32 rspsz;
24 struct list_head list;
27 struct cmd_priv {
28 struct semaphore cmd_queue_sema;
29 struct semaphore terminate_cmdthread_sema;
30 struct __queue cmd_queue;
31 u8 cmd_seq;
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;
36 u32 cmd_issued_cnt;
37 u32 cmd_done_cnt;
38 u32 rsp_cnt;
39 struct _adapter *padapter;
42 struct evt_obj {
43 u16 evtcode;
44 u8 res;
45 u8 *parmbuf;
46 u32 evtsz;
47 struct list_head list;
50 struct evt_priv {
51 struct __queue evt_queue;
52 u8 event_seq;
53 u8 *evt_buf; /*shall be non-paged, and 4 bytes aligned*/
54 u8 *evt_allocated_buf;
55 u32 evt_done_cnt;
56 struct tasklet_struct event_tasklet;
59 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
60 do {\
61 _init_listhead(&pcmd->list);\
62 pcmd->cmdcode = code;\
63 pcmd->parmbuf = (u8 *)(pparm);\
64 pcmd->cmdsz = sizeof(*pparm);\
65 pcmd->rsp = NULL;\
66 pcmd->rspsz = 0;\
67 } while (0)
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 {
80 NONE_WK_CID,
81 WDG_WK_CID,
82 MAX_WK_CID
85 enum RFINTFS {
86 SWSI,
87 HWSI,
88 HWPI,
92 * Caller Mode: Infra, Ad-HoC(C)
93 * Notes: To enter USB suspend mode
94 * Command 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
103 * Command Event Mode
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
112 * Command Mode
114 struct disconnect_parm {
115 u32 rsvd;
119 * Caller Mode: AP, Ad-HoC(M)
120 * Notes: To create a BSS
121 * Command Mode
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
130 * Command Mode
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 {
142 u8 mode;
143 u8 rsvd[3];
147 * Caller Mode: AP, Ad-HoC, Infra
148 * Notes: To ask RTL8711 performing site-survey
149 * Command-Event Mode
151 struct sitesurvey_parm {
152 sint passive_mode; /*active: 1, passive: 0 */
153 sint bsslimit; /* 1 ~ 48 */
154 sint ss_ssidlen;
155 u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
159 * Caller Mode: Any
160 * Notes: To set the auth type of RTL8711. open/shared/802.1x
161 * Command Mode
163 struct setauth_parm {
164 u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
165 u8 _1x; /*0: PSK, 1: TLS*/
166 u8 rsvd[2];
170 * Caller Mode: Infra
171 * a. algorithm: wep40, wep104, tkip & aes
172 * b. keytype: grp key/unicast key
173 * c. key contents
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
179 struct setkey_parm {
180 u8 algorithm; /* encryption algorithm, could be none, wep40,
181 * TKIP, CCMP, wep104 */
182 u8 keyid;
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.
191 * Command
192 * when shared key ==> algorithm/keyid
194 struct set_stakey_parm {
195 u8 addr[ETH_ALEN];
196 u8 algorithm;
197 u8 key[16];
200 struct set_stakey_rsp {
201 u8 addr[ETH_ALEN];
202 u8 keyid;
203 u8 rsvd;
206 struct SetMacAddr_param {
207 u8 MacAddr[ETH_ALEN];
211 Caller Ad-Hoc/AP
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 {
221 u8 addr[ETH_ALEN];
224 struct set_assocsta_rsp {
225 u8 cam_id;
226 u8 rsvd[3];
230 Caller Ad-Hoc/AP
232 Command mode
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 {
240 u8 addr[ETH_ALEN];
244 Caller Mode: AP/Ad-HoC(M)
246 Notes: To notify fw that given staid has changed its power state
248 Command Mode
251 struct setstapwrstate_parm {
252 u8 staid;
253 u8 status;
254 u8 hwaddr[6];
258 Caller Mode: Any
260 Notes: To setup the basic rate of RTL8711
262 Command Mode
265 struct setbasicrate_parm {
266 u8 basicrates[NumRates];
270 Caller Mode: Any
272 Notes: To read the current basic rate
274 Command-Rsp Mode
277 struct getbasicrate_parm {
278 u32 rsvd;
281 struct getbasicrate_rsp {
282 u8 basicrates[NumRates];
286 Caller Mode: Any
288 Notes: To setup the data rate of RTL8711
290 Command Mode
293 struct setdatarate_parm {
294 u8 mac_id;
295 u8 datarates[NumRates];
299 Caller Mode: Any
301 Notes: To read the current data rate
303 Command-Rsp Mode
306 struct getdatarate_parm {
307 u32 rsvd;
310 struct getdatarate_rsp {
311 u8 datarates[NumRates];
316 Caller Mode: Any
317 AP: AP can use the info for the contents of beacon frame
318 Infra: STA can use the info when sitesurveying
319 Ad-HoC(M): Like AP
320 Ad-HoC(C): Like STA
323 Notes: To set the phy capability of the NIC
325 Command Mode
330 Caller Mode: Any
332 Notes: To set the channel/modem/band
333 This command will be used when channel/modem/band is changed.
335 Command Mode
339 Caller Mode: Any
341 Notes: To get the current setting of channel/modem/band
343 Command-Rsp Mode
346 struct getphy_rsp {
347 u8 rfchannel;
348 u8 modem;
351 struct readBB_parm {
352 u8 offset;
354 struct readBB_rsp {
355 u8 value;
358 struct readTSSI_parm {
359 u8 offset;
361 struct readTSSI_rsp {
362 u8 value;
365 struct writeBB_parm {
366 u8 offset;
367 u8 value;
370 struct readRF_parm {
371 u8 offset;
373 struct readRF_rsp {
374 u32 value;
377 struct writeRF_parm {
378 u32 offset;
379 u32 value;
382 struct setrfintfs_parm {
383 u8 rfintfs;
386 struct getrfintfs_parm {
387 u8 rfintfs;
391 Notes: This command is used for H2C/C2H loopback testing
393 mac[0] == 0
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);
400 mac[0] == 1
401 ==> CMD_RSP mode, return H2C_SUCCESS_RSP
403 The rsp layout shall be:
404 rsp: parm:
405 mac[0] = mac[5];
406 mac[1] = mac[4];
407 mac[2] = mac[3];
408 mac[3] = mac[2];
409 mac[4] = mac[1];
410 mac[5] = mac[0];
411 s0 = s1;
412 s1 = swap16(s0);
413 w0 = swap32(w1);
414 b0 = b1
415 s2 = s0 + s1
416 b1 = b0
417 w1 = w0
419 mac[0] == 2
420 ==> CMD_EVENT mode, return H2C_SUCCESS
421 The event layout shall be:
422 event: parm:
423 mac[0] = mac[5];
424 mac[1] = mac[4];
425 mac[2] = event's sequence number, starting from 1 to parm's marc[3]
426 mac[3] = mac[2];
427 mac[4] = mac[1];
428 mac[5] = mac[0];
429 s0 = swap16(s0) - event.mac[2];
430 s1 = s1 + event.mac[2];
431 w0 = swap32(w0);
432 b0 = b1
433 s2 = s0 + event.mac[2]
434 b1 = b0
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*/
447 int sz; /* buf sz*/
448 unsigned char *pbuf;
451 /*------------------- Below are used for RF/BB tunning ---------------------*/
453 struct setantenna_parm {
454 u8 tx_antset;
455 u8 rx_antset;
456 u8 tx_antenna;
457 u8 rx_antenna;
460 struct enrateadaptive_parm {
461 u32 en;
464 struct settxagctbl_parm {
465 u32 txagc[MAX_RATES_LENGTH];
468 struct gettxagctbl_parm {
469 u32 rsvd;
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 {
484 u32 rsvd;
486 struct getssup_rsp {
487 u8 ss_ForceUp[MAX_RATES_LENGTH];
490 struct setssdlevel_parm {
491 u8 ss_DLevel[MAX_RATES_LENGTH];
494 struct getssdlevel_parm {
495 u32 rsvd;
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 {
506 u32 rsvd;
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 {
517 u32 rsvd;
520 struct getcountjudge_rsp {
521 u8 count_judge[MAX_RATES_LENGTH];
524 struct setpwrmode_parm {
525 u8 mode;
526 u8 flag_low_traffic_en;
527 u8 flag_lpnav_en;
528 u8 flag_rf_low_snr_en;
529 u8 flag_dps_en; /* 1: dps, 0: 32k */
530 u8 bcn_rx_en;
531 u8 bcn_pass_cnt; /* fw report one beacon information to
532 * driver when it receives bcn_pass_cnt
533 * beacons. */
534 u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
535 u16 bcn_itv;
536 u8 app_itv; /* only for VOIP mode. */
537 u8 awake_bcn_itv;
538 u8 smart_ps;
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 {
555 uint rsvd;
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 {
566 unsigned int rsvd;
569 struct gettxretrycnt_rsp {
570 unsigned long tx_retrycnt;
573 struct getrxretrycnt_parm {
574 unsigned int rsvd;
577 struct getrxretrycnt_rsp {
578 unsigned long rx_retrycnt;
581 /*to get BCNOK,BCNERR count*/
582 struct getbcnokcnt_parm {
583 unsigned int rsvd;
586 struct getbcnokcnt_rsp {
587 unsigned long bcnokcnt;
590 struct getbcnerrcnt_parm {
591 unsigned int rsvd;
593 struct getbcnerrcnt_rsp {
594 unsigned long bcnerrcnt;
597 /* to get current TX power level*/
598 struct getcurtxpwrlevel_parm {
599 unsigned int rsvd;
602 struct getcurtxpwrlevel_rsp {
603 unsigned short tx_power;
606 /*dynamic on/off DIG*/
607 struct setdig_parm {
608 unsigned char dig_on; /* 1:on , 0:off */
611 /*dynamic on/off RA*/
612 struct setra_parm {
613 unsigned char ra_on; /* 1:on , 0:off */
616 struct setprobereqextraie_parm {
617 unsigned char e_id;
618 unsigned char ie_len;
619 unsigned char ie[0];
622 struct setassocreqextraie_parm {
623 unsigned char e_id;
624 unsigned char ie_len;
625 unsigned char ie[0];
628 struct setproberspextraie_parm {
629 unsigned char e_id;
630 unsigned char ie_len;
631 unsigned char ie[0];
634 struct setassocrspextraie_parm {
635 unsigned char e_id;
636 unsigned char ie_len;
637 unsigned char ie[0];
640 struct addBaReq_parm {
641 unsigned int tid;
644 /*H2C Handler index: 46 */
645 struct SetChannel_parm {
646 u32 curr_ch;
649 /*H2C Handler index: 56 */
650 struct PT_param {
651 u8 PT_En;
654 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
657 * Result:
658 * 0x00: success
659 * 0x01: success, and check Response.
660 * 0x02: cmd ignored due to duplicated sequcne number
661 * 0x03: cmd dropped due to invalid cmd code
662 * 0x04: reserved.
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 {
712 u32 cmd_code;
713 void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
716 #include "rtl8712_cmd.h"
718 #endif /* _CMD_H_ */