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