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