OSDN Git Service

7f296b65902a64f67a184612cf3faf76be39f108
[android-x86/external-modules-rtl8723au.git] / include / rtw_cmd.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __RTW_CMD_H_
21 #define __RTW_CMD_H_
22
23 #include <drv_conf.h>
24 #include <wlan_bssdef.h>
25 #include <rtw_rf.h>
26 #include <rtw_led.h>
27
28 #define C2H_MEM_SZ (16*1024)
29
30 #ifndef CONFIG_RTL8711FW
31
32         #include <osdep_service.h>
33         #include <ieee80211.h> // <ieee80211/ieee80211.h>
34
35
36         #define FREE_CMDOBJ_SZ  128
37
38         #define MAX_CMDSZ       1024
39         #define MAX_RSPSZ       512
40         #define MAX_EVTSZ       1024
41
42         #define CMDBUFF_ALIGN_SZ 512
43
44         struct cmd_obj {
45                 _adapter *padapter;
46                 u16     cmdcode;
47                 u8      res;
48                 u8      *parmbuf;
49                 u32     cmdsz;
50                 u8      *rsp;
51                 u32     rspsz;
52                 //struct semaphore              cmd_sem;
53                 struct list_head        list;
54         };
55
56         struct cmd_priv {
57                 struct semaphore        cmd_queue_sema;
58                 //struct semaphore      cmd_done_sema;
59                 struct semaphore        terminate_cmdthread_sema;
60                 _queue  cmd_queue;
61                 u8      cmd_seq;
62                 u8      *cmd_buf;       //shall be non-paged, and 4 bytes aligned
63                 u8      *cmd_allocated_buf;
64                 u8      *rsp_buf;       //shall be non-paged, and 4 bytes aligned
65                 u8      *rsp_allocated_buf;
66                 u32     cmd_issued_cnt;
67                 u32     cmd_done_cnt;
68                 u32     rsp_cnt;
69                 u8 cmdthd_running;
70                 _adapter *padapter;
71         };
72
73 #ifdef CONFIG_EVENT_THREAD_MODE
74         struct evt_obj {
75                 u16     evtcode;
76                 u8      res;
77                 u8      *parmbuf;
78                 u32     evtsz;
79                 struct list_head        list;
80         };
81 #endif
82
83         struct  evt_priv {
84 #ifdef CONFIG_EVENT_THREAD_MODE
85                 struct semaphore        evt_notify;
86                 struct semaphore        terminate_evtthread_sema;
87                 _queue  evt_queue;
88 #endif
89
90 #define CONFIG_C2H_WK
91 #ifdef CONFIG_C2H_WK
92                 struct work_struct c2h_wk;
93                 bool c2h_wk_alive;
94                 struct rtw_cbuf *c2h_queue;
95                 #define C2H_QUEUE_MAX_LEN 10
96 #endif
97
98 #ifdef CONFIG_H2CLBK
99                 struct semaphore        lbkevt_done;
100                 u8      lbkevt_limit;
101                 u8      lbkevt_num;
102                 u8      *cmdevt_parm;
103 #endif
104                 atomic_t event_seq;
105                 u8      *evt_buf;       //shall be non-paged, and 4 bytes aligned
106                 u8      *evt_allocated_buf;
107                 u32     evt_done_cnt;
108         };
109
110 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
111 do {\
112         INIT_LIST_HEAD(&pcmd->list);\
113         pcmd->cmdcode = code;\
114         pcmd->parmbuf = (u8 *)(pparm);\
115         pcmd->cmdsz = sizeof (*pparm);\
116         pcmd->rsp = NULL;\
117         pcmd->rspsz = 0;\
118 } while(0)
119
120 struct c2h_evt_hdr {
121         u8 id:4;
122         u8 plen:4;
123         u8 seq;
124         u8 payload[0];
125 };
126
127 #define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
128
129 extern u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
130 extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
131 extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
132
133 #ifdef CONFIG_EVENT_THREAD_MODE
134 extern u32 rtw_enqueue_evt(struct evt_priv *pevtpriv, struct evt_obj *obj);
135 extern struct evt_obj *rtw_dequeue_evt(_queue *queue);
136 extern void rtw_free_evt_obj(struct evt_obj *pcmd);
137 #endif
138
139 thread_return rtw_cmd_thread(thread_context context);
140
141 extern u32 rtw_init_cmd_priv (struct cmd_priv *pcmdpriv);
142 extern void rtw_free_cmd_priv (struct cmd_priv *pcmdpriv);
143
144 extern u32 rtw_init_evt_priv (struct evt_priv *pevtpriv);
145 extern void rtw_free_evt_priv (struct evt_priv *pevtpriv);
146 extern void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv);
147 extern void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
148 #ifdef CONFIG_P2P
149 u8 p2p_protocol_wk_cmd(_adapter*padapter, int intCmdType );
150 #endif //CONFIG_P2P
151
152 #else
153         #include <ieee80211.h>
154 #endif  /* CONFIG_RTL8711FW */
155
156 enum rtw_drvextra_cmd_id
157 {
158         NONE_WK_CID,
159         DYNAMIC_CHK_WK_CID,
160         DM_CTRL_WK_CID,
161         PBC_POLLING_WK_CID,
162         POWER_SAVING_CTRL_WK_CID,//IPS,AUTOSuspend
163         LPS_CTRL_WK_CID,
164         ANT_SELECT_WK_CID,
165         P2P_PS_WK_CID,
166         P2P_PROTO_WK_CID,
167         CHECK_HIQ_WK_CID,//for softap mode, check hi queue if empty
168         C2H_WK_CID,
169         RTP_TIMER_CFG_WK_CID,
170         MAX_WK_CID
171 };
172
173 enum LPS_CTRL_TYPE
174 {
175         LPS_CTRL_SCAN=0,
176         LPS_CTRL_JOINBSS=1,
177         LPS_CTRL_CONNECT=2,
178         LPS_CTRL_DISCONNECT=3,
179         LPS_CTRL_SPECIAL_PACKET=4,
180         LPS_CTRL_LEAVE=5,
181 };
182
183 enum RFINTFS {
184         SWSI,
185         HWSI,
186         HWPI,
187 };
188
189 /*
190 Caller Mode: Infra, Ad-HoC(C)
191
192 Notes: To enter USB suspend mode
193
194 Command Mode
195
196 */
197 struct usb_suspend_parm {
198         u32 action;// 1: sleep, 0:resume
199 };
200
201 /*
202 Caller Mode: Infra, Ad-HoC
203
204 Notes: To join a known BSS.
205
206 Command-Event Mode
207
208 */
209
210 /*
211 Caller Mode: Infra, Ad-Hoc
212
213 Notes: To join the specified bss
214
215 Command Event Mode
216
217 */
218 struct joinbss_parm {
219         WLAN_BSSID_EX network;
220 };
221
222 /*
223 Caller Mode: Infra, Ad-HoC(C)
224
225 Notes: To disconnect the current associated BSS
226
227 Command Mode
228
229 */
230 struct disconnect_parm {
231         u32 deauth_timeout_ms;
232 };
233
234 /*
235 Caller Mode: AP, Ad-HoC(M)
236
237 Notes: To create a BSS
238
239 Command Mode
240 */
241 struct createbss_parm {
242         WLAN_BSSID_EX network;
243 };
244
245 /*
246 Caller Mode: AP, Ad-HoC, Infra
247
248 Notes: To set the NIC mode of RTL8711
249
250 Command Mode
251
252 The definition of mode:
253
254 #define IW_MODE_AUTO    0       // Let the driver decides which AP to join
255 #define IW_MODE_ADHOC   1       // Single cell network (Ad-Hoc Clients)
256 #define IW_MODE_INFRA   2       // Multi cell network, roaming, ..
257 #define IW_MODE_MASTER  3       // Synchronisation master or Access Point
258 #define IW_MODE_REPEAT  4       // Wireless Repeater (forwarder)
259 #define IW_MODE_SECOND  5       // Secondary master/repeater (backup)
260 #define IW_MODE_MONITOR 6       // Passive monitor (listen only)
261
262 */
263 struct  setopmode_parm {
264         u8      mode;
265         u8      rsvd[3];
266 };
267
268 /*
269 Caller Mode: AP, Ad-HoC, Infra
270
271 Notes: To ask RTL8711 performing site-survey
272
273 Command-Event Mode
274
275 */
276
277 #define RTW_SSID_SCAN_AMOUNT 9 // for WEXT_CSCAN_AMOUNT 9
278 #define RTW_CHANNEL_SCAN_AMOUNT (14+37)
279 struct sitesurvey_parm {
280         int scan_mode;  //active: 1, passive: 0
281         /* int bsslimit;        // 1 ~ 48 */
282         u8 ssid_num;
283         u8 ch_num;
284         NDIS_802_11_SSID ssid[RTW_SSID_SCAN_AMOUNT];
285         struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
286 };
287
288 /*
289 Caller Mode: Any
290
291 Notes: To set the auth type of RTL8711. open/shared/802.1x
292
293 Command Mode
294
295 */
296 struct setauth_parm {
297         u8 mode;  //0: legacy open, 1: legacy shared 2: 802.1x
298         u8 _1x;   //0: PSK, 1: TLS
299         u8 rsvd[2];
300 };
301
302 /*
303 Caller Mode: Infra
304
305 a. algorithm: wep40, wep104, tkip & aes
306 b. keytype: grp key/unicast key
307 c. key contents
308
309 when shared key ==> keyid is the camid
310 when 802.1x ==> keyid [0:1] ==> grp key
311 when 802.1x ==> keyid > 2 ==> unicast key
312
313 */
314 struct setkey_parm {
315         u8      algorithm;      // encryption algorithm, could be none, wep40, TKIP, CCMP, wep104
316         u8      keyid;
317         u8      grpkey;         // 1: this is the grpkey for 802.1x. 0: this is the unicast key for 802.1x
318         u8      set_tx;         // 1: main tx key for wep. 0: other key.
319         u8      key[16];        // this could be 40 or 104
320 };
321
322 /*
323 When in AP or Ad-Hoc mode, this is used to
324 allocate an sw/hw entry for a newly associated sta.
325
326 Command
327
328 when shared key ==> algorithm/keyid
329
330 */
331 struct set_stakey_parm {
332         u8      addr[ETH_ALEN];
333         u8      algorithm;
334         u8      id;// currently for erasing cam entry if algorithm == _NO_PRIVACY_
335         u8      key[16];
336 };
337
338 struct set_stakey_rsp {
339         u8      addr[ETH_ALEN];
340         u8      keyid;
341         u8      rsvd;
342 };
343
344 /*
345 Caller Ad-Hoc/AP
346
347 Command -Rsp(AID == CAMID) mode
348
349 This is to force fw to add an sta_data entry per driver's request.
350
351 FW will write an cam entry associated with it.
352
353 */
354 struct set_assocsta_parm {
355         u8      addr[ETH_ALEN];
356 };
357
358 struct set_assocsta_rsp {
359         u8      cam_id;
360         u8      rsvd[3];
361 };
362
363 /*
364         Caller Ad-Hoc/AP
365
366         Command mode
367
368         This is to force fw to del an sta_data entry per driver's request
369
370         FW will invalidate the cam entry associated with it.
371
372 */
373 struct del_assocsta_parm {
374         u8      addr[ETH_ALEN];
375 };
376
377 /*
378 Caller Mode: AP/Ad-HoC(M)
379
380 Notes: To notify fw that given staid has changed its power state
381
382 Command Mode
383
384 */
385 struct setstapwrstate_parm {
386         u8      staid;
387         u8      status;
388         u8      hwaddr[6];
389 };
390
391 /*
392 Caller Mode: Any
393
394 Notes: To setup the basic rate of RTL8711
395
396 Command Mode
397
398 */
399 struct  setbasicrate_parm {
400         u8      basicrates[NumRates];
401 };
402
403 /*
404 Caller Mode: Any
405
406 Notes: To read the current basic rate
407
408 Command-Rsp Mode
409
410 */
411 struct getbasicrate_parm {
412         u32 rsvd;
413 };
414
415 struct getbasicrate_rsp {
416         u8 basicrates[NumRates];
417 };
418
419 /*
420 Caller Mode: Any
421
422 Notes: To setup the data rate of RTL8711
423
424 Command Mode
425
426 */
427 struct setdatarate_parm {
428 #ifdef MP_FIRMWARE_OFFLOAD
429         u32     curr_rateidx;
430 #else
431         u8      mac_id;
432         u8      datarates[NumRates];
433 #endif
434 };
435
436 /*
437 Caller Mode: Any
438
439 Notes: To read the current data rate
440
441 Command-Rsp Mode
442
443 */
444 struct getdatarate_parm {
445         u32 rsvd;
446 };
447
448 struct getdatarate_rsp {
449         u8 datarates[NumRates];
450 };
451
452
453 /*
454 Caller Mode: Any
455 AP: AP can use the info for the contents of beacon frame
456 Infra: STA can use the info when sitesurveying
457 Ad-HoC(M): Like AP
458 Ad-HoC(C): Like STA
459
460
461 Notes: To set the phy capability of the NIC
462
463 Command Mode
464
465 */
466
467 struct  setphyinfo_parm {
468         struct regulatory_class class_sets[NUM_REGULATORYS];
469         u8      status;
470 };
471
472 struct  getphyinfo_parm {
473         u32 rsvd;
474 };
475
476 struct  getphyinfo_rsp {
477         struct regulatory_class class_sets[NUM_REGULATORYS];
478         u8      status;
479 };
480
481 /*
482 Caller Mode: Any
483
484 Notes: To set the channel/modem/band
485 This command will be used when channel/modem/band is changed.
486
487 Command Mode
488
489 */
490 struct  setphy_parm {
491         u8      rfchannel;
492         u8      modem;
493 };
494
495 /*
496 Caller Mode: Any
497
498 Notes: To get the current setting of channel/modem/band
499
500 Command-Rsp Mode
501
502 */
503 struct  getphy_parm {
504         u32 rsvd;
505 };
506
507 struct  getphy_rsp {
508         u8      rfchannel;
509         u8      modem;
510 };
511
512 struct readBB_parm {
513         u8      offset;
514 };
515
516 struct readBB_rsp {
517         u8      value;
518 };
519
520 struct readTSSI_parm {
521         u8      offset;
522 };
523
524 struct readTSSI_rsp {
525         u8      value;
526 };
527
528 struct writeBB_parm {
529         u8      offset;
530         u8      value;
531 };
532
533 struct readRF_parm {
534         u8      offset;
535 };
536
537 struct readRF_rsp {
538         u32     value;
539 };
540
541 struct writeRF_parm {
542         u32     offset;
543         u32     value;
544 };
545
546 struct getrfintfs_parm {
547         u8      rfintfs;
548 };
549
550 struct Tx_Beacon_param
551 {
552         WLAN_BSSID_EX network;
553 };
554
555 #ifdef CONFIG_H2CLBK
556
557 struct seth2clbk_parm {
558         u8 mac[6];
559         u16     s0;
560         u16     s1;
561         u32     w0;
562         u8      b0;
563         u16  s2;
564         u8      b1;
565         u32     w1;
566 };
567
568 struct geth2clbk_parm {
569         u32 rsv;
570 };
571
572 struct geth2clbk_rsp {
573         u8      mac[6];
574         u16     s0;
575         u16     s1;
576         u32     w0;
577         u8      b0;
578         u16     s2;
579         u8      b1;
580         u32     w1;
581 };
582
583 #endif  /* CONFIG_H2CLBK */
584
585 // CMD param Formart for driver extra cmd handler
586 struct drvextra_cmd_parm {
587         int ec_id; //extra cmd id
588         int type_size; // Can use this field as the type id or command size
589         unsigned char *pbuf;
590 };
591
592 /*------------------- Below are used for RF/BB tunning ---------------------*/
593
594 struct  setantenna_parm {
595         u8      tx_antset;
596         u8      rx_antset;
597         u8      tx_antenna;
598         u8      rx_antenna;
599 };
600
601 struct  enrateadaptive_parm {
602         u32     en;
603 };
604
605 struct settxagctbl_parm {
606         u32     txagc[MAX_RATES_LENGTH];
607 };
608
609 struct gettxagctbl_parm {
610         u32 rsvd;
611 };
612
613 struct gettxagctbl_rsp {
614         u32     txagc[MAX_RATES_LENGTH];
615 };
616
617 struct setagcctrl_parm {
618         u32     agcctrl;                // 0: pure hw, 1: fw
619 };
620
621 struct setssup_parm     {
622         u32     ss_ForceUp[MAX_RATES_LENGTH];
623 };
624
625 struct getssup_parm     {
626         u32 rsvd;
627 };
628
629 struct getssup_rsp      {
630         u8      ss_ForceUp[MAX_RATES_LENGTH];
631 };
632
633 struct setssdlevel_parm {
634         u8      ss_DLevel[MAX_RATES_LENGTH];
635 };
636
637 struct getssdlevel_parm {
638         u32 rsvd;
639 };
640
641 struct getssdlevel_rsp  {
642         u8      ss_DLevel[MAX_RATES_LENGTH];
643 };
644
645 struct setssulevel_parm {
646         u8      ss_ULevel[MAX_RATES_LENGTH];
647 };
648
649 struct getssulevel_parm {
650         u32 rsvd;
651 };
652
653 struct getssulevel_rsp  {
654         u8      ss_ULevel[MAX_RATES_LENGTH];
655 };
656
657 struct  setcountjudge_parm {
658         u8      count_judge[MAX_RATES_LENGTH];
659 };
660
661 struct  getcountjudge_parm {
662         u32 rsvd;
663 };
664
665 struct  getcountjudge_rsp {
666         u8      count_judge[MAX_RATES_LENGTH];
667 };
668
669 struct setratable_parm {
670         u8 ss_ForceUp[NumRates];
671         u8 ss_ULevel[NumRates];
672         u8 ss_DLevel[NumRates];
673         u8 count_judge[NumRates];
674 };
675
676 struct getratable_parm {
677                 uint rsvd;
678 };
679
680 struct getratable_rsp {
681         u8 ss_ForceUp[NumRates];
682         u8 ss_ULevel[NumRates];
683         u8 ss_DLevel[NumRates];
684         u8 count_judge[NumRates];
685 };
686
687 //to get TX,RX retry count
688 struct gettxretrycnt_parm{
689         unsigned int rsvd;
690 };
691 struct gettxretrycnt_rsp{
692         unsigned long tx_retrycnt;
693 };
694
695 struct getrxretrycnt_parm{
696         unsigned int rsvd;
697 };
698 struct getrxretrycnt_rsp{
699         unsigned long rx_retrycnt;
700 };
701
702 //to get BCNOK,BCNERR count
703 struct getbcnokcnt_parm{
704         unsigned int rsvd;
705 };
706 struct getbcnokcnt_rsp{
707         unsigned long  bcnokcnt;
708 };
709
710 struct getbcnerrcnt_parm{
711         unsigned int rsvd;
712 };
713 struct getbcnerrcnt_rsp{
714         unsigned long bcnerrcnt;
715 };
716
717 // to get current TX power level
718 struct getcurtxpwrlevel_parm{
719         unsigned int rsvd;
720 };
721
722 struct getcurtxpwrlevel_rsp{
723         unsigned short tx_power;
724 };
725
726 struct setprobereqextraie_parm {
727         unsigned char e_id;
728         unsigned char ie_len;
729         unsigned char ie[0];
730 };
731
732 struct setassocreqextraie_parm {
733         unsigned char e_id;
734         unsigned char ie_len;
735         unsigned char ie[0];
736 };
737
738 struct setproberspextraie_parm {
739         unsigned char e_id;
740         unsigned char ie_len;
741         unsigned char ie[0];
742 };
743
744 struct setassocrspextraie_parm {
745         unsigned char e_id;
746         unsigned char ie_len;
747         unsigned char ie[0];
748 };
749
750 struct addBaReq_parm {
751         unsigned int tid;
752         u8      addr[ETH_ALEN];
753 };
754
755 /*H2C Handler index: 46 */
756 struct set_ch_parm {
757         u8 ch;
758         u8 bw;
759         u8 ch_offset;
760 };
761
762 #ifdef MP_FIRMWARE_OFFLOAD
763 /*H2C Handler index: 47 */
764 struct SetTxPower_parm {
765         u8 TxPower;
766 };
767
768 /*H2C Handler index: 48 */
769 struct SwitchAntenna_parm {
770         u16 antenna_tx;
771         u16 antenna_rx;
772         u8 cck_txrx;
773 };
774
775 /*H2C Handler index: 49 */
776 struct SetCrystalCap_parm {
777         u32 curr_crystalcap;
778 };
779
780 /*H2C Handler index: 50 */
781 struct SetSingleCarrierTx_parm {
782         u8 bStart;
783 };
784
785 /*H2C Handler index: 51 */
786 struct SetSingleToneTx_parm {
787         u8 bStart;
788         u8 curr_rfpath;
789 };
790
791 /*H2C Handler index: 52 */
792 struct SetCarrierSuppressionTx_parm {
793         u8 bStart;
794         u32 curr_rateidx;
795 };
796
797 /*H2C Handler index: 53 */
798 struct SetContinuousTx_parm {
799         u8 bStart;
800         u8 CCK_flag; /*1:CCK 2:OFDM*/
801         u32 curr_rateidx;
802 };
803
804 /*H2C Handler index: 54 */
805 struct SwitchBandwidth_parm {
806         u8 curr_bandwidth;
807 };
808
809 #endif  /* MP_FIRMWARE_OFFLOAD */
810
811 /*H2C Handler index: 59 */
812 struct SetChannelPlan_param {
813         u8 channel_plan;
814 };
815
816 /*H2C Handler index: 60 */
817 struct LedBlink_param {
818         PLED_871x        pLed;
819 };
820
821 /*H2C Handler index: 61 */
822 struct SetChannelSwitch_param {
823         u8 new_ch_no;
824 };
825
826 /*H2C Handler index: 62 */
827 struct TDLSoption_param {
828         u8 addr[ETH_ALEN];
829         u8 option;
830 };
831
832 #define GEN_CMD_CODE(cmd)       cmd ## _CMD_
833
834
835 /*
836
837 Result:
838 0x00: success
839 0x01: sucess, and check Response.
840 0x02: cmd ignored due to duplicated sequcne number
841 0x03: cmd dropped due to invalid cmd code
842 0x04: reserved.
843
844 */
845
846 #define H2C_RSP_OFFSET                  512
847
848 #define H2C_SUCCESS                     0x00
849 #define H2C_SUCCESS_RSP                 0x01
850 #define H2C_DUPLICATED                  0x02
851 #define H2C_DROPPED                     0x03
852 #define H2C_PARAMETERS_ERROR            0x04
853 #define H2C_REJECTED                    0x05
854 #define H2C_CMD_OVERFLOW                0x06
855 #define H2C_RESERVED                    0x07
856
857 u8 rtw_setassocsta_cmd(_adapter  *padapter, u8 *mac_addr);
858 u8 rtw_setstandby_cmd(_adapter *padapter, uint action);
859 u8 rtw_sitesurvey_cmd(_adapter  *padapter, NDIS_802_11_SSID *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num);
860 u8 rtw_createbss_cmd(_adapter  *padapter);
861 u8 rtw_createbss_cmd_ex(_adapter  *padapter, unsigned char *pbss, unsigned int sz);
862 u8 rtw_setphy_cmd(_adapter  *padapter, u8 modem, u8 ch);
863 u8 rtw_setstakey_cmd(_adapter  *padapter, u8 *psta, u8 unicast_key);
864 u8 rtw_clearstakey_cmd(_adapter *padapter, u8 *psta, u8 entry, u8 enqueue);
865 u8 rtw_joinbss_cmd(_adapter  *padapter, struct wlan_network* pnetwork);
866 u8 rtw_disassoc_cmd(_adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
867 u8 rtw_setopmode_cmd(_adapter  *padapter, NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
868 u8 rtw_setdatarate_cmd(_adapter  *padapter, u8 *rateset);
869 u8 rtw_setbasicrate_cmd(_adapter  *padapter, u8 *rateset);
870 u8 rtw_setbbreg_cmd(_adapter * padapter, u8 offset, u8 val);
871 u8 rtw_setrfreg_cmd(_adapter * padapter, u8 offset, u32 val);
872 u8 rtw_getbbreg_cmd(_adapter * padapter, u8 offset, u8 * pval);
873 u8 rtw_getrfreg_cmd(_adapter * padapter, u8 offset, u8 * pval);
874 u8 rtw_setrfintfs_cmd(_adapter  *padapter, u8 mode);
875 u8 rtw_setrttbl_cmd(_adapter  *padapter, struct setratable_parm *prate_table);
876 u8 rtw_getrttbl_cmd(_adapter  *padapter, struct getratable_rsp *pval);
877
878 u8 rtw_gettssi_cmd(_adapter  *padapter, u8 offset,u8 *pval);
879 u8 rtw_setfwdig_cmd(_adapter*padapter, u8 type);
880 u8 rtw_setfwra_cmd(_adapter*padapter, u8 type);
881
882 u8 rtw_addbareq_cmd(_adapter*padapter, u8 tid, u8 *addr);
883
884 u8 rtw_dynamic_chk_wk_cmd(_adapter *adapter);
885
886 u8 rtw_lps_ctrl_wk_cmd(_adapter*padapter, u8 lps_ctrl_type, u8 enqueue);
887 #if (RATE_ADAPTIVE_SUPPORT==1)
888 u8 rtw_rpt_timer_cfg_cmd(_adapter*padapter, u16 minRptTime);
889 #endif
890
891 #ifdef CONFIG_ANTENNA_DIVERSITY
892 u8 rtw_antenna_select_cmd(_adapter*padapter, u8 antenna,u8 enqueue);
893 #endif
894
895 extern u8 rtw_ps_cmd(_adapter*padapter);
896
897 #ifdef CONFIG_AP_MODE
898 u8 rtw_chk_hi_queue_cmd(_adapter*padapter);
899 #endif
900
901 u8 rtw_set_ch_cmd(_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue);
902 u8 rtw_set_chplan_cmd(_adapter*padapter, u8 chplan, u8 enqueue);
903 u8 rtw_led_blink_cmd(_adapter*padapter, PLED_871x pLed);
904 u8 rtw_set_csa_cmd(_adapter*padapter, u8 new_ch_no);
905 u8 rtw_tdls_cmd(_adapter*padapter, u8 *addr, u8 option);
906
907 u8 rtw_c2h_wk_cmd(PADAPTER padapter, u8 *c2h_evt);
908
909 u8 rtw_drvextra_cmd_hdl(_adapter *padapter, unsigned char *pbuf);
910
911 void rtw_survey_cmd_callback(_adapter  *padapter, struct cmd_obj *pcmd);
912 void rtw_disassoc_cmd_callback(_adapter  *padapter, struct cmd_obj *pcmd);
913 void rtw_joinbss_cmd_callback(_adapter  *padapter, struct cmd_obj *pcmd);
914 void rtw_createbss_cmd_callback(_adapter  *padapter, struct cmd_obj *pcmd);
915 void rtw_getbbrfreg_cmdrsp_callback(_adapter  *padapter, struct cmd_obj *pcmd);
916 void rtw_readtssi_cmdrsp_callback(_adapter*     padapter,  struct cmd_obj *pcmd);
917
918 void rtw_setstaKey_cmdrsp_callback(_adapter  *padapter,  struct cmd_obj *pcmd);
919 void rtw_setassocsta_cmdrsp_callback(_adapter  *padapter,  struct cmd_obj *pcmd);
920 void rtw_getrttbl_cmdrsp_callback(_adapter  *padapter,  struct cmd_obj *pcmd);
921
922 struct _cmd_callback {
923         u32     cmd_code;
924         void (*callback)(_adapter  *padapter, struct cmd_obj *cmd);
925 };
926
927 enum rtw_h2c_cmd {
928         GEN_CMD_CODE(_Read_MACREG) ,    /*0*/
929         GEN_CMD_CODE(_Write_MACREG) ,
930         GEN_CMD_CODE(_Read_BBREG) ,
931         GEN_CMD_CODE(_Write_BBREG) ,
932         GEN_CMD_CODE(_Read_RFREG) ,
933         GEN_CMD_CODE(_Write_RFREG) , /*5*/
934         GEN_CMD_CODE(_Read_EEPROM) ,
935         GEN_CMD_CODE(_Write_EEPROM) ,
936         GEN_CMD_CODE(_Read_EFUSE) ,
937         GEN_CMD_CODE(_Write_EFUSE) ,
938
939         GEN_CMD_CODE(_Read_CAM) ,       /*10*/
940         GEN_CMD_CODE(_Write_CAM) ,
941         GEN_CMD_CODE(_setBCNITV),
942         GEN_CMD_CODE(_setMBIDCFG),
943         GEN_CMD_CODE(_JoinBss),   /*14*/
944         GEN_CMD_CODE(_DisConnect) , /*15*/
945         GEN_CMD_CODE(_CreateBss) ,
946         GEN_CMD_CODE(_SetOpMode) ,
947         GEN_CMD_CODE(_SiteSurvey),  /*18*/
948         GEN_CMD_CODE(_SetAuth) ,
949
950         GEN_CMD_CODE(_SetKey) , /*20*/
951         GEN_CMD_CODE(_SetStaKey) ,
952         GEN_CMD_CODE(_SetAssocSta) ,
953         GEN_CMD_CODE(_DelAssocSta) ,
954         GEN_CMD_CODE(_SetStaPwrState) ,
955         GEN_CMD_CODE(_SetBasicRate) , /*25*/
956         GEN_CMD_CODE(_GetBasicRate) ,
957         GEN_CMD_CODE(_SetDataRate) ,
958         GEN_CMD_CODE(_GetDataRate) ,
959         GEN_CMD_CODE(_SetPhyInfo) ,
960
961         GEN_CMD_CODE(_GetPhyInfo) ,     /*30*/
962         GEN_CMD_CODE(_SetPhy) ,
963         GEN_CMD_CODE(_GetPhy) ,
964         GEN_CMD_CODE(_readRssi) ,
965         GEN_CMD_CODE(_readGain) ,
966         GEN_CMD_CODE(_SetAtim) , /*35*/
967         GEN_CMD_CODE(_SetPwrMode) ,
968         GEN_CMD_CODE(_JoinbssRpt),
969         GEN_CMD_CODE(_SetRaTable) ,
970         GEN_CMD_CODE(_GetRaTable) ,
971
972         GEN_CMD_CODE(_GetCCXReport), /*40*/
973         GEN_CMD_CODE(_GetDTMReport),
974         GEN_CMD_CODE(_GetTXRateStatistics),
975         GEN_CMD_CODE(_SetUsbSuspend),
976         GEN_CMD_CODE(_SetH2cLbk),
977         GEN_CMD_CODE(_AddBAReq) , /*45*/
978         GEN_CMD_CODE(_SetChannel), /*46*/
979         GEN_CMD_CODE(_SetTxPower),
980         GEN_CMD_CODE(_SwitchAntenna),
981         GEN_CMD_CODE(_SetCrystalCap),
982         GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
983
984         GEN_CMD_CODE(_SetSingleToneTx),/*51*/
985         GEN_CMD_CODE(_SetCarrierSuppressionTx),
986         GEN_CMD_CODE(_SetContinuousTx),
987         GEN_CMD_CODE(_SwitchBandwidth), /*54*/
988         GEN_CMD_CODE(_TX_Beacon), /*55*/
989
990         GEN_CMD_CODE(_Set_MLME_EVT), /*56*/
991         GEN_CMD_CODE(_Set_Drv_Extra), /*57*/
992         GEN_CMD_CODE(_Set_H2C_MSG), /*58*/
993
994         GEN_CMD_CODE(_SetChannelPlan), /*59*/
995         GEN_CMD_CODE(_LedBlink), /*60*/
996
997         GEN_CMD_CODE(_SetChannelSwitch), /*61*/
998         GEN_CMD_CODE(_TDLS), /*62*/
999
1000         MAX_H2CCMD
1001 };
1002
1003 #define _GetBBReg_CMD_          _Read_BBREG_CMD_
1004 #define _SetBBReg_CMD_          _Write_BBREG_CMD_
1005 #define _GetRFReg_CMD_          _Read_RFREG_CMD_
1006 #define _SetRFReg_CMD_          _Write_RFREG_CMD_
1007
1008 #ifdef _RTW_CMD_C_
1009 struct _cmd_callback    rtw_cmd_callback[] = {
1010         {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/
1011         {GEN_CMD_CODE(_Write_MACREG), NULL},
1012         {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback},
1013         {GEN_CMD_CODE(_Write_BBREG), NULL},
1014         {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback},
1015         {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/
1016         {GEN_CMD_CODE(_Read_EEPROM), NULL},
1017         {GEN_CMD_CODE(_Write_EEPROM), NULL},
1018         {GEN_CMD_CODE(_Read_EFUSE), NULL},
1019         {GEN_CMD_CODE(_Write_EFUSE), NULL},
1020
1021         {GEN_CMD_CODE(_Read_CAM),       NULL},  /*10*/
1022         {GEN_CMD_CODE(_Write_CAM),       NULL},
1023         {GEN_CMD_CODE(_setBCNITV), NULL},
1024         {GEN_CMD_CODE(_setMBIDCFG), NULL},
1025         {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback},  /*14*/
1026         {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, /*15*/
1027         {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback},
1028         {GEN_CMD_CODE(_SetOpMode), NULL},
1029         {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, /*18*/
1030         {GEN_CMD_CODE(_SetAuth), NULL},
1031
1032         {GEN_CMD_CODE(_SetKey), NULL},  /*20*/
1033         {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback},
1034         {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback},
1035         {GEN_CMD_CODE(_DelAssocSta), NULL},
1036         {GEN_CMD_CODE(_SetStaPwrState), NULL},
1037         {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/
1038         {GEN_CMD_CODE(_GetBasicRate), NULL},
1039         {GEN_CMD_CODE(_SetDataRate), NULL},
1040         {GEN_CMD_CODE(_GetDataRate), NULL},
1041         {GEN_CMD_CODE(_SetPhyInfo), NULL},
1042
1043         {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/
1044         {GEN_CMD_CODE(_SetPhy), NULL},
1045         {GEN_CMD_CODE(_GetPhy), NULL},
1046         {GEN_CMD_CODE(_readRssi), NULL},
1047         {GEN_CMD_CODE(_readGain), NULL},
1048         {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/
1049         {GEN_CMD_CODE(_SetPwrMode), NULL},
1050         {GEN_CMD_CODE(_JoinbssRpt), NULL},
1051         {GEN_CMD_CODE(_SetRaTable), NULL},
1052         {GEN_CMD_CODE(_GetRaTable) , NULL},
1053
1054         {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/
1055         {GEN_CMD_CODE(_GetDTMReport),   NULL},
1056         {GEN_CMD_CODE(_GetTXRateStatistics), NULL},
1057         {GEN_CMD_CODE(_SetUsbSuspend), NULL},
1058         {GEN_CMD_CODE(_SetH2cLbk), NULL},
1059         {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/
1060         {GEN_CMD_CODE(_SetChannel), NULL},              /*46*/
1061         {GEN_CMD_CODE(_SetTxPower), NULL},
1062         {GEN_CMD_CODE(_SwitchAntenna), NULL},
1063         {GEN_CMD_CODE(_SetCrystalCap), NULL},
1064         {GEN_CMD_CODE(_SetSingleCarrierTx), NULL},      /*50*/
1065
1066         {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/
1067         {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL},
1068         {GEN_CMD_CODE(_SetContinuousTx), NULL},
1069         {GEN_CMD_CODE(_SwitchBandwidth), NULL},         /*54*/
1070         {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/
1071
1072         {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/
1073         {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/
1074         {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/
1075         {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/
1076         {GEN_CMD_CODE(_LedBlink), NULL},/*60*/
1077
1078         {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/
1079         {GEN_CMD_CODE(_TDLS), NULL},/*62*/
1080 };
1081 #else
1082 extern struct _cmd_callback     rtw_cmd_callback[];
1083 #endif
1084
1085 #endif // _CMD_H_