1
2
3
4
5
6
7#ifndef __RTW_CMD_H_
8#define __RTW_CMD_H_
9
10#include <linux/completion.h>
11
12#define C2H_MEM_SZ (16*1024)
13
14 #define FREE_CMDOBJ_SZ 128
15
16 #define MAX_CMDSZ 1024
17 #define MAX_RSPSZ 512
18 #define MAX_EVTSZ 1024
19
20 #define CMDBUFF_ALIGN_SZ 512
21
22 struct cmd_obj {
23 struct adapter *padapter;
24 u16 cmdcode;
25 u8 res;
26 u8 *parmbuf;
27 u32 cmdsz;
28 u8 *rsp;
29 u32 rspsz;
30 struct submit_ctx *sctx;
31 struct list_head list;
32 };
33
34
35 enum {
36 RTW_CMDF_DIRECTLY = BIT0,
37 RTW_CMDF_WAIT_ACK = BIT1,
38 };
39
40 struct cmd_priv {
41 struct completion cmd_queue_comp;
42 struct completion terminate_cmdthread_comp;
43 struct __queue cmd_queue;
44 u8 cmd_seq;
45 u8 *cmd_buf;
46 u8 *cmd_allocated_buf;
47 u8 *rsp_buf;
48 u8 *rsp_allocated_buf;
49 u32 cmd_issued_cnt;
50 u32 cmd_done_cnt;
51 u32 rsp_cnt;
52 atomic_t cmdthd_running;
53
54 u8 stop_req;
55 struct adapter *padapter;
56 _mutex sctx_mutex;
57 };
58
59 struct evt_priv {
60 _workitem c2h_wk;
61 bool c2h_wk_alive;
62 struct rtw_cbuf *c2h_queue;
63 #define C2H_QUEUE_MAX_LEN 10
64
65 atomic_t event_seq;
66 u8 *evt_buf;
67 u8 *evt_allocated_buf;
68 u32 evt_done_cnt;
69 u8 *c2h_mem;
70 u8 *allocated_c2h_mem;
71 };
72
73#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
74do {\
75 INIT_LIST_HEAD(&pcmd->list);\
76 pcmd->cmdcode = code;\
77 pcmd->parmbuf = (u8 *)(pparm);\
78 pcmd->cmdsz = sizeof (*pparm);\
79 pcmd->rsp = NULL;\
80 pcmd->rspsz = 0;\
81} while (0)
82
83#define init_h2fwcmd_w_parm_no_parm_rsp(pcmd, code) \
84do {\
85 INIT_LIST_HEAD(&pcmd->list);\
86 pcmd->cmdcode = code;\
87 pcmd->parmbuf = NULL;\
88 pcmd->cmdsz = 0;\
89 pcmd->rsp = NULL;\
90 pcmd->rspsz = 0;\
91} while (0)
92
93struct c2h_evt_hdr {
94 u8 id:4;
95 u8 plen:4;
96 u8 seq;
97 u8 payload[0];
98};
99
100struct c2h_evt_hdr_88xx {
101 u8 id;
102 u8 seq;
103 u8 payload[12];
104 u8 plen;
105 u8 trigger;
106};
107
108#define c2h_evt_valid(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen)
109
110struct P2P_PS_Offload_t {
111 u8 Offload_En:1;
112 u8 role:1;
113 u8 CTWindow_En:1;
114 u8 NoA0_En:1;
115 u8 NoA1_En:1;
116 u8 AllStaSleep:1;
117 u8 discovery:1;
118 u8 rsvd:1;
119};
120
121struct P2P_PS_CTWPeriod_t {
122 u8 CTWPeriod;
123};
124
125int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
126extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
127extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
128
129void rtw_stop_cmd_thread(struct adapter *adapter);
130int rtw_cmd_thread(void *context);
131
132extern void rtw_free_cmd_priv (struct cmd_priv *pcmdpriv);
133
134extern void rtw_free_evt_priv (struct evt_priv *pevtpriv);
135extern void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
136
137enum rtw_drvextra_cmd_id
138{
139 NONE_WK_CID,
140 DYNAMIC_CHK_WK_CID,
141 DM_CTRL_WK_CID,
142 PBC_POLLING_WK_CID,
143 POWER_SAVING_CTRL_WK_CID,
144 LPS_CTRL_WK_CID,
145 ANT_SELECT_WK_CID,
146 P2P_PS_WK_CID,
147 P2P_PROTO_WK_CID,
148 CHECK_HIQ_WK_CID,
149 INTEl_WIDI_WK_CID,
150 C2H_WK_CID,
151 RTP_TIMER_CFG_WK_CID,
152 RESET_SECURITYPRIV,
153 FREE_ASSOC_RESOURCES,
154 DM_IN_LPS_WK_CID,
155 DM_RA_MSK_WK_CID,
156 BEAMFORMING_WK_CID,
157 LPS_CHANGE_DTIM_CID,
158 BTINFO_WK_CID,
159 MAX_WK_CID
160};
161
162enum LPS_CTRL_TYPE
163{
164 LPS_CTRL_SCAN = 0,
165 LPS_CTRL_JOINBSS = 1,
166 LPS_CTRL_CONNECT =2,
167 LPS_CTRL_DISCONNECT =3,
168 LPS_CTRL_SPECIAL_PACKET =4,
169 LPS_CTRL_LEAVE =5,
170 LPS_CTRL_TRAFFIC_BUSY = 6,
171};
172
173enum RFINTFS {
174 SWSI,
175 HWSI,
176 HWPI,
177};
178
179
180
181
182
183
184
185
186
187struct usb_suspend_parm {
188 u32 action;
189};
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208struct joinbss_parm {
209 struct wlan_bssid_ex network;
210};
211
212
213
214
215
216
217
218
219
220struct disconnect_parm {
221 u32 deauth_timeout_ms;
222};
223
224
225
226
227
228
229
230
231struct createbss_parm {
232 struct wlan_bssid_ex network;
233};
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253struct setopmode_parm {
254 u8 mode;
255 u8 rsvd[3];
256};
257
258
259
260
261
262
263
264
265
266
267#define RTW_SSID_SCAN_AMOUNT 9
268#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
269struct sitesurvey_parm {
270 sint scan_mode;
271 u8 ssid_num;
272 u8 ch_num;
273 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
274 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
275};
276
277
278
279
280
281
282
283
284
285struct setauth_parm {
286 u8 mode;
287 u8 _1x;
288 u8 rsvd[2];
289};
290
291
292
293
294
295
296
297
298
299
300
301
302
303struct setkey_parm {
304 u8 algorithm;
305 u8 keyid;
306 u8 grpkey;
307 u8 set_tx;
308 u8 key[16];
309};
310
311
312
313
314
315
316
317
318
319
320struct set_stakey_parm {
321 u8 addr[ETH_ALEN];
322 u8 algorithm;
323 u8 keyid;
324 u8 key[16];
325};
326
327struct set_stakey_rsp {
328 u8 addr[ETH_ALEN];
329 u8 keyid;
330 u8 rsvd;
331};
332
333
334
335
336
337
338
339
340
341
342
343struct set_assocsta_parm {
344 u8 addr[ETH_ALEN];
345};
346
347struct set_assocsta_rsp {
348 u8 cam_id;
349 u8 rsvd[3];
350};
351
352
353
354
355
356
357
358
359
360
361
362struct del_assocsta_parm {
363 u8 addr[ETH_ALEN];
364};
365
366
367
368
369
370
371
372
373
374struct setstapwrstate_parm {
375 u8 staid;
376 u8 status;
377 u8 hwaddr[6];
378};
379
380
381
382
383
384
385
386
387
388struct setbasicrate_parm {
389 u8 basicrates[NumRates];
390};
391
392
393
394
395
396
397
398
399
400struct getbasicrate_parm {
401 u32 rsvd;
402};
403
404struct getbasicrate_rsp {
405 u8 basicrates[NumRates];
406};
407
408
409
410
411
412
413
414
415
416struct setdatarate_parm {
417 u8 mac_id;
418 u8 datarates[NumRates];
419};
420
421
422
423
424
425
426
427
428
429struct getdatarate_parm {
430 u32 rsvd;
431
432};
433struct getdatarate_rsp {
434 u8 datarates[NumRates];
435};
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452struct setphyinfo_parm {
453 struct regulatory_class class_sets[NUM_REGULATORYS];
454 u8 status;
455};
456
457struct getphyinfo_parm {
458 u32 rsvd;
459};
460
461struct getphyinfo_rsp {
462 struct regulatory_class class_sets[NUM_REGULATORYS];
463 u8 status;
464};
465
466
467
468
469
470
471
472
473
474
475struct setphy_parm {
476 u8 rfchannel;
477 u8 modem;
478};
479
480
481
482
483
484
485
486
487
488struct getphy_parm {
489 u32 rsvd;
490
491};
492struct getphy_rsp {
493 u8 rfchannel;
494 u8 modem;
495};
496
497struct readBB_parm {
498 u8 offset;
499};
500struct readBB_rsp {
501 u8 value;
502};
503
504struct readTSSI_parm {
505 u8 offset;
506};
507struct readTSSI_rsp {
508 u8 value;
509};
510
511struct writeBB_parm {
512 u8 offset;
513 u8 value;
514};
515
516struct readRF_parm {
517 u8 offset;
518};
519struct readRF_rsp {
520 u32 value;
521};
522
523struct writeRF_parm {
524 u32 offset;
525 u32 value;
526};
527
528struct getrfintfs_parm {
529 u8 rfintfs;
530};
531
532
533struct Tx_Beacon_param
534{
535 struct wlan_bssid_ex network;
536};
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593struct drvextra_cmd_parm {
594 int ec_id;
595 int type;
596 int size;
597 unsigned char *pbuf;
598};
599
600
601
602struct setantenna_parm {
603 u8 tx_antset;
604 u8 rx_antset;
605 u8 tx_antenna;
606 u8 rx_antenna;
607};
608
609struct enrateadaptive_parm {
610 u32 en;
611};
612
613struct settxagctbl_parm {
614 u32 txagc[MAX_RATES_LENGTH];
615};
616
617struct gettxagctbl_parm {
618 u32 rsvd;
619};
620struct gettxagctbl_rsp {
621 u32 txagc[MAX_RATES_LENGTH];
622};
623
624struct setagcctrl_parm {
625 u32 agcctrl;
626};
627
628
629struct setssup_parm {
630 u32 ss_ForceUp[MAX_RATES_LENGTH];
631};
632
633struct getssup_parm {
634 u32 rsvd;
635};
636struct getssup_rsp {
637 u8 ss_ForceUp[MAX_RATES_LENGTH];
638};
639
640
641struct setssdlevel_parm {
642 u8 ss_DLevel[MAX_RATES_LENGTH];
643};
644
645struct getssdlevel_parm {
646 u32 rsvd;
647};
648struct getssdlevel_rsp {
649 u8 ss_DLevel[MAX_RATES_LENGTH];
650};
651
652struct setssulevel_parm {
653 u8 ss_ULevel[MAX_RATES_LENGTH];
654};
655
656struct getssulevel_parm {
657 u32 rsvd;
658};
659struct getssulevel_rsp {
660 u8 ss_ULevel[MAX_RATES_LENGTH];
661};
662
663
664struct setcountjudge_parm {
665 u8 count_judge[MAX_RATES_LENGTH];
666};
667
668struct getcountjudge_parm {
669 u32 rsvd;
670};
671struct getcountjudge_rsp {
672 u8 count_judge[MAX_RATES_LENGTH];
673};
674
675
676struct setratable_parm {
677 u8 ss_ForceUp[NumRates];
678 u8 ss_ULevel[NumRates];
679 u8 ss_DLevel[NumRates];
680 u8 count_judge[NumRates];
681};
682
683struct getratable_parm {
684 uint rsvd;
685};
686struct getratable_rsp {
687 u8 ss_ForceUp[NumRates];
688 u8 ss_ULevel[NumRates];
689 u8 ss_DLevel[NumRates];
690 u8 count_judge[NumRates];
691};
692
693
694
695struct gettxretrycnt_parm{
696 unsigned int rsvd;
697};
698struct gettxretrycnt_rsp{
699 unsigned long tx_retrycnt;
700};
701
702struct getrxretrycnt_parm{
703 unsigned int rsvd;
704};
705struct getrxretrycnt_rsp{
706 unsigned long rx_retrycnt;
707};
708
709
710struct getbcnokcnt_parm{
711 unsigned int rsvd;
712};
713struct getbcnokcnt_rsp{
714 unsigned long bcnokcnt;
715};
716
717struct getbcnerrcnt_parm{
718 unsigned int rsvd;
719};
720struct getbcnerrcnt_rsp{
721 unsigned long bcnerrcnt;
722};
723
724
725struct getcurtxpwrlevel_parm{
726 unsigned int rsvd;
727};
728struct getcurtxpwrlevel_rsp{
729 unsigned short tx_power;
730};
731
732struct setprobereqextraie_parm {
733 unsigned char e_id;
734 unsigned char ie_len;
735 unsigned char ie[0];
736};
737
738struct setassocreqextraie_parm {
739 unsigned char e_id;
740 unsigned char ie_len;
741 unsigned char ie[0];
742};
743
744struct setproberspextraie_parm {
745 unsigned char e_id;
746 unsigned char ie_len;
747 unsigned char ie[0];
748};
749
750struct setassocrspextraie_parm {
751 unsigned char e_id;
752 unsigned char ie_len;
753 unsigned char ie[0];
754};
755
756
757struct addBaReq_parm
758{
759 unsigned int tid;
760 u8 addr[ETH_ALEN];
761};
762
763
764struct set_ch_parm {
765 u8 ch;
766 u8 bw;
767 u8 ch_offset;
768};
769
770
771struct SetChannelPlan_param
772{
773 u8 channel_plan;
774};
775
776
777struct LedBlink_param
778{
779 void *pLed;
780};
781
782
783struct SetChannelSwitch_param
784{
785 u8 new_ch_no;
786};
787
788
789struct TDLSoption_param
790{
791 u8 addr[ETH_ALEN];
792 u8 option;
793};
794
795
796struct RunInThread_param
797{
798 void (*func)(void*);
799 void *context;
800};
801
802
803#define GEN_CMD_CODE(cmd) cmd ## _CMD_
804
805
806
807
808
809
810
811
812
813
814
815
816
817#define H2C_RSP_OFFSET 512
818
819#define H2C_SUCCESS 0x00
820#define H2C_SUCCESS_RSP 0x01
821#define H2C_DUPLICATED 0x02
822#define H2C_DROPPED 0x03
823#define H2C_PARAMETERS_ERROR 0x04
824#define H2C_REJECTED 0x05
825#define H2C_CMD_OVERFLOW 0x06
826#define H2C_RESERVED 0x07
827
828u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num);
829extern u8 rtw_createbss_cmd(struct adapter *padapter);
830int rtw_startbss_cmd(struct adapter *padapter, int flags);
831
832struct sta_info;
833extern u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue);
834extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue);
835
836extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork);
837u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
838extern u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue);
839extern u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
840extern u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode);
841
842extern u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval);
843extern u8 rtw_setfwdig_cmd(struct adapter *padapter, u8 type);
844extern u8 rtw_setfwra_cmd(struct adapter *padapter, u8 type);
845
846extern u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
847
848extern u8 rtw_reset_securitypriv_cmd(struct adapter *padapter);
849extern u8 rtw_free_assoc_resources_cmd(struct adapter *padapter);
850extern u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
851
852u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
853u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter);
854
855u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta);
856
857extern u8 rtw_ps_cmd(struct adapter *padapter);
858
859u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
860
861extern u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig);
862
863extern u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length);
864extern u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt);
865
866u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
867
868extern void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
869extern void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
870extern void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
871extern void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
872extern void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
873
874extern void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
875extern void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
876extern void rtw_getrttbl_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
877
878
879struct _cmd_callback {
880 u32 cmd_code;
881 void (*callback)(struct adapter *padapter, struct cmd_obj *cmd);
882};
883
884enum rtw_h2c_cmd
885{
886 GEN_CMD_CODE(_Read_MACREG) ,
887 GEN_CMD_CODE(_Write_MACREG) ,
888 GEN_CMD_CODE(_Read_BBREG) ,
889 GEN_CMD_CODE(_Write_BBREG) ,
890 GEN_CMD_CODE(_Read_RFREG) ,
891 GEN_CMD_CODE(_Write_RFREG) ,
892 GEN_CMD_CODE(_Read_EEPROM) ,
893 GEN_CMD_CODE(_Write_EEPROM) ,
894 GEN_CMD_CODE(_Read_EFUSE) ,
895 GEN_CMD_CODE(_Write_EFUSE) ,
896
897 GEN_CMD_CODE(_Read_CAM) ,
898 GEN_CMD_CODE(_Write_CAM) ,
899 GEN_CMD_CODE(_setBCNITV),
900 GEN_CMD_CODE(_setMBIDCFG),
901 GEN_CMD_CODE(_JoinBss),
902 GEN_CMD_CODE(_DisConnect) ,
903 GEN_CMD_CODE(_CreateBss) ,
904 GEN_CMD_CODE(_SetOpMode) ,
905 GEN_CMD_CODE(_SiteSurvey),
906 GEN_CMD_CODE(_SetAuth) ,
907
908 GEN_CMD_CODE(_SetKey) ,
909 GEN_CMD_CODE(_SetStaKey) ,
910 GEN_CMD_CODE(_SetAssocSta) ,
911 GEN_CMD_CODE(_DelAssocSta) ,
912 GEN_CMD_CODE(_SetStaPwrState) ,
913 GEN_CMD_CODE(_SetBasicRate) ,
914 GEN_CMD_CODE(_GetBasicRate) ,
915 GEN_CMD_CODE(_SetDataRate) ,
916 GEN_CMD_CODE(_GetDataRate) ,
917 GEN_CMD_CODE(_SetPhyInfo) ,
918
919 GEN_CMD_CODE(_GetPhyInfo) ,
920 GEN_CMD_CODE(_SetPhy) ,
921 GEN_CMD_CODE(_GetPhy) ,
922 GEN_CMD_CODE(_readRssi) ,
923 GEN_CMD_CODE(_readGain) ,
924 GEN_CMD_CODE(_SetAtim) ,
925 GEN_CMD_CODE(_SetPwrMode) ,
926 GEN_CMD_CODE(_JoinbssRpt),
927 GEN_CMD_CODE(_SetRaTable) ,
928 GEN_CMD_CODE(_GetRaTable) ,
929
930 GEN_CMD_CODE(_GetCCXReport),
931 GEN_CMD_CODE(_GetDTMReport),
932 GEN_CMD_CODE(_GetTXRateStatistics),
933 GEN_CMD_CODE(_SetUsbSuspend),
934 GEN_CMD_CODE(_SetH2cLbk),
935 GEN_CMD_CODE(_AddBAReq) ,
936 GEN_CMD_CODE(_SetChannel),
937 GEN_CMD_CODE(_SetTxPower),
938 GEN_CMD_CODE(_SwitchAntenna),
939 GEN_CMD_CODE(_SetCrystalCap),
940 GEN_CMD_CODE(_SetSingleCarrierTx),
941
942 GEN_CMD_CODE(_SetSingleToneTx),
943 GEN_CMD_CODE(_SetCarrierSuppressionTx),
944 GEN_CMD_CODE(_SetContinuousTx),
945 GEN_CMD_CODE(_SwitchBandwidth),
946 GEN_CMD_CODE(_TX_Beacon),
947
948 GEN_CMD_CODE(_Set_MLME_EVT),
949 GEN_CMD_CODE(_Set_Drv_Extra),
950 GEN_CMD_CODE(_Set_H2C_MSG),
951
952 GEN_CMD_CODE(_SetChannelPlan),
953 GEN_CMD_CODE(_LedBlink),
954
955 GEN_CMD_CODE(_SetChannelSwitch),
956 GEN_CMD_CODE(_TDLS),
957 GEN_CMD_CODE(_ChkBMCSleepq),
958
959 GEN_CMD_CODE(_RunInThreadCMD),
960
961 MAX_H2CCMD
962};
963
964#define _GetBBReg_CMD_ _Read_BBREG_CMD_
965#define _SetBBReg_CMD_ _Write_BBREG_CMD_
966#define _GetRFReg_CMD_ _Read_RFREG_CMD_
967#define _SetRFReg_CMD_ _Write_RFREG_CMD_
968
969#endif
970