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 struct mutex sctx_mutex;
57 };
58
59 struct evt_priv {
60 struct work_struct 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
110int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
111extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
112extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
113
114void rtw_stop_cmd_thread(struct adapter *adapter);
115int rtw_cmd_thread(void *context);
116
117extern void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv);
118
119extern void rtw_free_evt_priv(struct evt_priv *pevtpriv);
120extern void rtw_evt_notify_isr(struct evt_priv *pevtpriv);
121
122enum {
123 NONE_WK_CID,
124 DYNAMIC_CHK_WK_CID,
125 DM_CTRL_WK_CID,
126 PBC_POLLING_WK_CID,
127 POWER_SAVING_CTRL_WK_CID,
128 LPS_CTRL_WK_CID,
129 ANT_SELECT_WK_CID,
130 P2P_PS_WK_CID,
131 P2P_PROTO_WK_CID,
132 CHECK_HIQ_WK_CID,
133 INTEl_WIDI_WK_CID,
134 C2H_WK_CID,
135 RTP_TIMER_CFG_WK_CID,
136 RESET_SECURITYPRIV,
137 FREE_ASSOC_RESOURCES,
138 DM_IN_LPS_WK_CID,
139 DM_RA_MSK_WK_CID,
140 BEAMFORMING_WK_CID,
141 LPS_CHANGE_DTIM_CID,
142 BTINFO_WK_CID,
143 MAX_WK_CID
144};
145
146enum {
147 LPS_CTRL_SCAN = 0,
148 LPS_CTRL_JOINBSS = 1,
149 LPS_CTRL_CONNECT = 2,
150 LPS_CTRL_DISCONNECT = 3,
151 LPS_CTRL_SPECIAL_PACKET = 4,
152 LPS_CTRL_LEAVE = 5,
153 LPS_CTRL_TRAFFIC_BUSY = 6,
154};
155
156enum {
157 SWSI,
158 HWSI,
159 HWPI,
160};
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179struct joinbss_parm {
180 struct wlan_bssid_ex network;
181};
182
183
184
185
186
187
188
189
190
191struct disconnect_parm {
192 u32 deauth_timeout_ms;
193};
194
195
196
197
198
199
200
201
202struct createbss_parm {
203 struct wlan_bssid_ex network;
204};
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224struct setopmode_parm {
225 u8 mode;
226 u8 rsvd[3];
227};
228
229
230
231
232
233
234
235
236
237
238#define RTW_SSID_SCAN_AMOUNT 9
239#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
240struct sitesurvey_parm {
241 signed int scan_mode;
242 u8 ssid_num;
243 u8 ch_num;
244 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
245 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
246};
247
248
249
250
251
252
253
254
255
256struct setauth_parm {
257 u8 mode;
258 u8 _1x;
259 u8 rsvd[2];
260};
261
262
263
264
265
266
267
268
269
270
271
272
273
274struct setkey_parm {
275 u8 algorithm;
276 u8 keyid;
277 u8 grpkey;
278 u8 set_tx;
279 u8 key[16];
280};
281
282
283
284
285
286
287
288
289
290
291struct set_stakey_parm {
292 u8 addr[ETH_ALEN];
293 u8 algorithm;
294 u8 keyid;
295 u8 key[16];
296};
297
298struct set_stakey_rsp {
299 u8 addr[ETH_ALEN];
300 u8 keyid;
301 u8 rsvd;
302};
303
304
305
306
307
308
309
310
311
312
313
314struct set_assocsta_parm {
315 u8 addr[ETH_ALEN];
316};
317
318struct set_assocsta_rsp {
319 u8 cam_id;
320 u8 rsvd[3];
321};
322
323
324
325
326
327
328
329
330
331
332
333struct del_assocsta_parm {
334 u8 addr[ETH_ALEN];
335};
336
337
338
339
340
341
342
343
344
345struct setstapwrstate_parm {
346 u8 staid;
347 u8 status;
348 u8 hwaddr[6];
349};
350
351
352
353
354
355
356
357
358
359struct setbasicrate_parm {
360 u8 basicrates[NumRates];
361};
362
363
364
365
366
367
368
369
370
371struct getbasicrate_parm {
372 u32 rsvd;
373};
374
375
376
377
378
379
380
381
382
383struct setdatarate_parm {
384 u8 mac_id;
385 u8 datarates[NumRates];
386};
387
388
389
390
391
392
393
394
395
396struct getdatarate_parm {
397 u32 rsvd;
398
399};
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415struct setphyinfo_parm {
416 struct regulatory_class class_sets[NUM_REGULATORYS];
417 u8 status;
418};
419
420struct getphyinfo_parm {
421 u32 rsvd;
422};
423
424
425
426
427
428
429
430
431
432
433struct setphy_parm {
434 u8 rfchannel;
435 u8 modem;
436};
437
438
439
440
441
442
443
444
445
446struct getphy_parm {
447 u32 rsvd;
448
449};
450
451struct Tx_Beacon_param {
452 struct wlan_bssid_ex network;
453};
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510struct drvextra_cmd_parm {
511 int ec_id;
512 int type;
513 int size;
514 unsigned char *pbuf;
515};
516
517
518
519struct getcountjudge_rsp {
520 u8 count_judge[MAX_RATES_LENGTH];
521};
522
523struct addBaReq_parm {
524 unsigned int tid;
525 u8 addr[ETH_ALEN];
526};
527
528
529struct set_ch_parm {
530 u8 ch;
531 u8 bw;
532 u8 ch_offset;
533};
534
535
536struct SetChannelPlan_param {
537 u8 channel_plan;
538};
539
540
541struct SetChannelSwitch_param {
542 u8 new_ch_no;
543};
544
545
546struct TDLSoption_param {
547 u8 addr[ETH_ALEN];
548 u8 option;
549};
550
551
552struct RunInThread_param {
553 void (*func)(void *);
554 void *context;
555};
556
557
558#define GEN_CMD_CODE(cmd) cmd ## _CMD_
559
560
561
562
563
564
565
566
567
568
569
570
571
572#define H2C_RSP_OFFSET 512
573
574#define H2C_SUCCESS 0x00
575#define H2C_SUCCESS_RSP 0x01
576#define H2C_DUPLICATED 0x02
577#define H2C_DROPPED 0x03
578#define H2C_PARAMETERS_ERROR 0x04
579#define H2C_REJECTED 0x05
580#define H2C_CMD_OVERFLOW 0x06
581#define H2C_RESERVED 0x07
582
583u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num);
584extern u8 rtw_createbss_cmd(struct adapter *padapter);
585int rtw_startbss_cmd(struct adapter *padapter, int flags);
586
587struct sta_info;
588extern u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue);
589extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue);
590
591extern u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
592u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
593extern u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infrastructure networktype, bool enqueue);
594extern u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset);
595extern u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode);
596
597extern u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset, u8 *pval);
598extern u8 rtw_setfwdig_cmd(struct adapter *padapter, u8 type);
599extern u8 rtw_setfwra_cmd(struct adapter *padapter, u8 type);
600
601extern u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
602
603extern u8 rtw_reset_securitypriv_cmd(struct adapter *padapter);
604extern u8 rtw_free_assoc_resources_cmd(struct adapter *padapter);
605extern u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
606
607u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
608u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter);
609
610u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta);
611
612extern u8 rtw_ps_cmd(struct adapter *padapter);
613
614u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
615
616extern u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig);
617
618extern u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length);
619extern u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt);
620
621u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
622
623extern void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
624extern void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
625extern void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
626extern void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
627extern void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
628
629extern void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
630extern void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
631extern void rtw_getrttbl_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd);
632
633
634struct _cmd_callback {
635 u32 cmd_code;
636 void (*callback)(struct adapter *padapter, struct cmd_obj *cmd);
637};
638
639enum {
640 GEN_CMD_CODE(_Read_MACREG),
641 GEN_CMD_CODE(_Write_MACREG),
642 GEN_CMD_CODE(_Read_BBREG),
643 GEN_CMD_CODE(_Write_BBREG),
644 GEN_CMD_CODE(_Read_RFREG),
645 GEN_CMD_CODE(_Write_RFREG),
646 GEN_CMD_CODE(_Read_EEPROM),
647 GEN_CMD_CODE(_Write_EEPROM),
648 GEN_CMD_CODE(_Read_EFUSE),
649 GEN_CMD_CODE(_Write_EFUSE),
650
651 GEN_CMD_CODE(_Read_CAM),
652 GEN_CMD_CODE(_Write_CAM),
653 GEN_CMD_CODE(_setBCNITV),
654 GEN_CMD_CODE(_setMBIDCFG),
655 GEN_CMD_CODE(_JoinBss),
656 GEN_CMD_CODE(_DisConnect),
657 GEN_CMD_CODE(_CreateBss),
658 GEN_CMD_CODE(_SetOpMode),
659 GEN_CMD_CODE(_SiteSurvey),
660 GEN_CMD_CODE(_SetAuth),
661
662 GEN_CMD_CODE(_SetKey),
663 GEN_CMD_CODE(_SetStaKey),
664 GEN_CMD_CODE(_SetAssocSta),
665 GEN_CMD_CODE(_DelAssocSta),
666 GEN_CMD_CODE(_SetStaPwrState),
667 GEN_CMD_CODE(_SetBasicRate),
668 GEN_CMD_CODE(_GetBasicRate),
669 GEN_CMD_CODE(_SetDataRate),
670 GEN_CMD_CODE(_GetDataRate),
671 GEN_CMD_CODE(_SetPhyInfo),
672
673 GEN_CMD_CODE(_GetPhyInfo),
674 GEN_CMD_CODE(_SetPhy),
675 GEN_CMD_CODE(_GetPhy),
676 GEN_CMD_CODE(_readRssi),
677 GEN_CMD_CODE(_readGain),
678 GEN_CMD_CODE(_SetAtim),
679 GEN_CMD_CODE(_SetPwrMode),
680 GEN_CMD_CODE(_JoinbssRpt),
681 GEN_CMD_CODE(_SetRaTable),
682 GEN_CMD_CODE(_GetRaTable),
683
684 GEN_CMD_CODE(_GetCCXReport),
685 GEN_CMD_CODE(_GetDTMReport),
686 GEN_CMD_CODE(_GetTXRateStatistics),
687 GEN_CMD_CODE(_SetUsbSuspend),
688 GEN_CMD_CODE(_SetH2cLbk),
689 GEN_CMD_CODE(_AddBAReq),
690 GEN_CMD_CODE(_SetChannel),
691 GEN_CMD_CODE(_SetTxPower),
692 GEN_CMD_CODE(_SwitchAntenna),
693 GEN_CMD_CODE(_SetCrystalCap),
694 GEN_CMD_CODE(_SetSingleCarrierTx),
695
696 GEN_CMD_CODE(_SetSingleToneTx),
697 GEN_CMD_CODE(_SetCarrierSuppressionTx),
698 GEN_CMD_CODE(_SetContinuousTx),
699 GEN_CMD_CODE(_SwitchBandwidth),
700 GEN_CMD_CODE(_TX_Beacon),
701
702 GEN_CMD_CODE(_Set_MLME_EVT),
703 GEN_CMD_CODE(_Set_Drv_Extra),
704 GEN_CMD_CODE(_Set_H2C_MSG),
705
706 GEN_CMD_CODE(_SetChannelPlan),
707
708 GEN_CMD_CODE(_SetChannelSwitch),
709 GEN_CMD_CODE(_TDLS),
710 GEN_CMD_CODE(_ChkBMCSleepq),
711
712 GEN_CMD_CODE(_RunInThreadCMD),
713
714 MAX_H2CCMD
715};
716
717#define _GetBBReg_CMD_ _Read_BBREG_CMD_
718#define _SetBBReg_CMD_ _Write_BBREG_CMD_
719#define _GetRFReg_CMD_ _Read_RFREG_CMD_
720#define _SetRFReg_CMD_ _Write_RFREG_CMD_
721
722#endif
723