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  ******************************************************************************/
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 		/* _sema		cmd_sem; */
39 		struct list_head	list;
40 	};
41 
42 	/* cmd flags */
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 		/* _sema	cmd_done_sema; */
51 		_sema	terminate_cmdthread_sema;
52 		struct __queue	cmd_queue;
53 		u8 cmd_seq;
54 		u8 *cmd_buf;	/* shall be non-paged, and 4 bytes aligned */
55 		u8 *cmd_allocated_buf;
56 		u8 *rsp_buf;	/* shall be non-paged, and 4 bytes aligned */
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 		/* u8 cmdthd_running; */
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;	/* shall be non-paged, and 4 bytes aligned */
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) \
83 do {\
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) \
93 do {\
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 
102 struct c2h_evt_hdr {
103 	u8 id:4;
104 	u8 plen:4;
105 	u8 seq;
106 	u8 payload[0];
107 };
108 
109 struct 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 
119 struct P2P_PS_Offload_t {
120 	u8 Offload_En:1;
121 	u8 role:1; /*  1: Owner, 0: Client */
122 	u8 CTWindow_En:1;
123 	u8 NoA0_En:1;
124 	u8 NoA1_En:1;
125 	u8 AllStaSleep:1; /*  Only valid in Owner */
126 	u8 discovery:1;
127 	u8 rsvd:1;
128 };
129 
130 struct P2P_PS_CTWPeriod_t {
131 	u8 CTWPeriod;	/* TU */
132 };
133 
134 extern u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
135 extern struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv);
136 extern void rtw_free_cmd_obj(struct cmd_obj *pcmd);
137 
138 void rtw_stop_cmd_thread(struct adapter *adapter);
139 int rtw_cmd_thread(void *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_evt_notify_isr(struct evt_priv *pevtpriv);
147 
148 enum 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,/* IPS, AUTOSuspend */
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,/* for softap mode, check hi queue if empty */
160 	INTEl_WIDI_WK_CID,
161 	C2H_WK_CID,
162 	RTP_TIMER_CFG_WK_CID,
163 	RESET_SECURITYPRIV, /*  add for CONFIG_IEEE80211W, none 11w also can use */
164 	FREE_ASSOC_RESOURCES, /*  add for CONFIG_IEEE80211W, none 11w also can use */
165 	DM_IN_LPS_WK_CID,
166 	DM_RA_MSK_WK_CID, /* add for STA update RAMask when bandwith change. */
167 	BEAMFORMING_WK_CID,
168 	LPS_CHANGE_DTIM_CID,
169 	BTINFO_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 	LPS_CTRL_TRAFFIC_BUSY = 6,
182 };
183 
184 enum RFINTFS {
185 	SWSI,
186 	HWSI,
187 	HWPI,
188 };
189 
190 /*
191 Caller Mode: Infra, Ad-HoC(C)
192 
193 Notes: To enter USB suspend mode
194 
195 Command Mode
196 
197 */
198 struct usb_suspend_parm {
199 	u32 action;/*  1: sleep, 0:resume */
200 };
201 
202 /*
203 Caller Mode: Infra, Ad-HoC
204 
205 Notes: To join a known BSS.
206 
207 Command-Event Mode
208 
209 */
210 
211 /*
212 Caller Mode: Infra, Ad-Hoc
213 
214 Notes: To join the specified bss
215 
216 Command Event Mode
217 
218 */
219 struct joinbss_parm {
220 	struct wlan_bssid_ex network;
221 };
222 
223 /*
224 Caller Mode: Infra, Ad-HoC(C)
225 
226 Notes: To disconnect the current associated BSS
227 
228 Command Mode
229 
230 */
231 struct disconnect_parm {
232 	u32 deauth_timeout_ms;
233 };
234 
235 /*
236 Caller Mode: AP, Ad-HoC(M)
237 
238 Notes: To create a BSS
239 
240 Command Mode
241 */
242 struct createbss_parm {
243 	struct wlan_bssid_ex network;
244 };
245 
246 /*
247 Caller Mode: AP, Ad-HoC, Infra
248 
249 Notes: To set the NIC mode of RTL8711
250 
251 Command Mode
252 
253 The definition of mode:
254 
255 #define IW_MODE_AUTO	0	 Let the driver decides which AP to join
256 #define IW_MODE_ADHOC	1	 Single cell network (Ad-Hoc Clients)
257 #define IW_MODE_INFRA	2	 Multi cell network, roaming, ..
258 #define IW_MODE_MASTER	3	 Synchronisation master or Access Point
259 #define IW_MODE_REPEAT	4	 Wireless Repeater (forwarder)
260 #define IW_MODE_SECOND	5	 Secondary master/repeater (backup)
261 #define IW_MODE_MONITOR	6	 Passive monitor (listen only)
262 
263 */
264 struct	setopmode_parm {
265 	u8 mode;
266 	u8 rsvd[3];
267 };
268 
269 /*
270 Caller Mode: AP, Ad-HoC, Infra
271 
272 Notes: To ask RTL8711 performing site-survey
273 
274 Command-Event Mode
275 
276 */
277 
278 #define RTW_SSID_SCAN_AMOUNT 9 /*  for WEXT_CSCAN_AMOUNT 9 */
279 #define RTW_CHANNEL_SCAN_AMOUNT (14+37)
280 struct sitesurvey_parm {
281 	sint scan_mode;	/* active: 1, passive: 0 */
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 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 keyid;
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 	u8 mac_id;
429 	u8 datarates[NumRates];
430 };
431 
432 /*
433 Caller Mode: Any
434 
435 Notes: To read the current data rate
436 
437 Command-Rsp Mode
438 
439 */
440 struct getdatarate_parm {
441 	u32 rsvd;
442 
443 };
444 struct getdatarate_rsp {
445 	u8 datarates[NumRates];
446 };
447 
448 
449 /*
450 Caller Mode: Any
451 AP: AP can use the info for the contents of beacon frame
452 Infra: STA can use the info when sitesurveying
453 Ad-HoC(M): Like AP
454 Ad-HoC(C): Like STA
455 
456 
457 Notes: To set the phy capability of the NIC
458 
459 Command Mode
460 
461 */
462 
463 struct	setphyinfo_parm {
464 	struct regulatory_class class_sets[NUM_REGULATORYS];
465 	u8 status;
466 };
467 
468 struct	getphyinfo_parm {
469 	u32 rsvd;
470 };
471 
472 struct	getphyinfo_rsp {
473 	struct regulatory_class class_sets[NUM_REGULATORYS];
474 	u8 status;
475 };
476 
477 /*
478 Caller Mode: Any
479 
480 Notes: To set the channel/modem/band
481 This command will be used when channel/modem/band is changed.
482 
483 Command Mode
484 
485 */
486 struct	setphy_parm {
487 	u8 rfchannel;
488 	u8 modem;
489 };
490 
491 /*
492 Caller Mode: Any
493 
494 Notes: To get the current setting of channel/modem/band
495 
496 Command-Rsp Mode
497 
498 */
499 struct	getphy_parm {
500 	u32 rsvd;
501 
502 };
503 struct	getphy_rsp {
504 	u8 rfchannel;
505 	u8 modem;
506 };
507 
508 struct readBB_parm {
509 	u8 offset;
510 };
511 struct readBB_rsp {
512 	u8 value;
513 };
514 
515 struct readTSSI_parm {
516 	u8 offset;
517 };
518 struct readTSSI_rsp {
519 	u8 value;
520 };
521 
522 struct writeBB_parm {
523 	u8 offset;
524 	u8 value;
525 };
526 
527 struct readRF_parm {
528 	u8 offset;
529 };
530 struct readRF_rsp {
531 	u32 value;
532 };
533 
534 struct writeRF_parm {
535 	u32 offset;
536 	u32 value;
537 };
538 
539 struct getrfintfs_parm {
540 	u8 rfintfs;
541 };
542 
543 
544 struct Tx_Beacon_param
545 {
546 	struct wlan_bssid_ex network;
547 };
548 
549 /*
550 	Notes: This command is used for H2C/C2H loopback testing
551 
552 	mac[0] == 0
553 	==> CMD mode, return H2C_SUCCESS.
554 	The following condition must be ture under CMD mode
555 		mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
556 		s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
557 		s2 == (b1 << 8 | b0);
558 
559 	mac[0] == 1
560 	==> CMD_RSP mode, return H2C_SUCCESS_RSP
561 
562 	The rsp layout shall be:
563 	rsp:			parm:
564 		mac[0]  =   mac[5];
565 		mac[1]  =   mac[4];
566 		mac[2]  =   mac[3];
567 		mac[3]  =   mac[2];
568 		mac[4]  =   mac[1];
569 		mac[5]  =   mac[0];
570 		s0		=   s1;
571 		s1		=   swap16(s0);
572 		w0		=	swap32(w1);
573 		b0		=	b1
574 		s2		=	s0 + s1
575 		b1		=	b0
576 		w1		=	w0
577 
578 	mac[0] ==	2
579 	==> CMD_EVENT mode, return	H2C_SUCCESS
580 	The event layout shall be:
581 	event:			parm:
582 		mac[0]  =   mac[5];
583 		mac[1]  =   mac[4];
584 		mac[2]  =   event's sequence number, starting from 1 to parm's marc[3]
585 		mac[3]  =   mac[2];
586 		mac[4]  =   mac[1];
587 		mac[5]  =   mac[0];
588 		s0		=   swap16(s0) - event.mac[2];
589 		s1		=   s1 + event.mac[2];
590 		w0		=	swap32(w0);
591 		b0		=	b1
592 		s2		=	s0 + event.mac[2]
593 		b1		=	b0
594 		w1		=	swap32(w1) - event.mac[2];
595 
596 		parm->mac[3] is the total event counts that host requested.
597 
598 
599 	event will be the same with the cmd's param.
600 
601 */
602 
603 /*  CMD param Formart for driver extra cmd handler */
604 struct drvextra_cmd_parm {
605 	int ec_id; /* extra cmd id */
606 	int type; /*  Can use this field as the type id or command size */
607 	int size; /* buffer size */
608 	unsigned char *pbuf;
609 };
610 
611 /*------------------- Below are used for RF/BB tunning ---------------------*/
612 
613 struct	setantenna_parm {
614 	u8 tx_antset;
615 	u8 rx_antset;
616 	u8 tx_antenna;
617 	u8 rx_antenna;
618 };
619 
620 struct	enrateadaptive_parm {
621 	u32 en;
622 };
623 
624 struct settxagctbl_parm {
625 	u32 txagc[MAX_RATES_LENGTH];
626 };
627 
628 struct gettxagctbl_parm {
629 	u32 rsvd;
630 };
631 struct gettxagctbl_rsp {
632 	u32 txagc[MAX_RATES_LENGTH];
633 };
634 
635 struct setagcctrl_parm {
636 	u32 agcctrl;		/*  0: pure hw, 1: fw */
637 };
638 
639 
640 struct setssup_parm	{
641 	u32 ss_ForceUp[MAX_RATES_LENGTH];
642 };
643 
644 struct getssup_parm	{
645 	u32 rsvd;
646 };
647 struct getssup_rsp	{
648 	u8 ss_ForceUp[MAX_RATES_LENGTH];
649 };
650 
651 
652 struct setssdlevel_parm	{
653 	u8 ss_DLevel[MAX_RATES_LENGTH];
654 };
655 
656 struct getssdlevel_parm	{
657 	u32 rsvd;
658 };
659 struct getssdlevel_rsp	{
660 	u8 ss_DLevel[MAX_RATES_LENGTH];
661 };
662 
663 struct setssulevel_parm	{
664 	u8 ss_ULevel[MAX_RATES_LENGTH];
665 };
666 
667 struct getssulevel_parm	{
668 	u32 rsvd;
669 };
670 struct getssulevel_rsp	{
671 	u8 ss_ULevel[MAX_RATES_LENGTH];
672 };
673 
674 
675 struct	setcountjudge_parm {
676 	u8 count_judge[MAX_RATES_LENGTH];
677 };
678 
679 struct	getcountjudge_parm {
680 	u32 rsvd;
681 };
682 struct	getcountjudge_rsp {
683 	u8 count_judge[MAX_RATES_LENGTH];
684 };
685 
686 
687 struct setratable_parm {
688 	u8 ss_ForceUp[NumRates];
689 	u8 ss_ULevel[NumRates];
690 	u8 ss_DLevel[NumRates];
691 	u8 count_judge[NumRates];
692 };
693 
694 struct getratable_parm {
695                 uint rsvd;
696 };
697 struct 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 /* to get TX, RX retry count */
706 struct gettxretrycnt_parm{
707 	unsigned int rsvd;
708 };
709 struct gettxretrycnt_rsp{
710 	unsigned long tx_retrycnt;
711 };
712 
713 struct getrxretrycnt_parm{
714 	unsigned int rsvd;
715 };
716 struct getrxretrycnt_rsp{
717 	unsigned long rx_retrycnt;
718 };
719 
720 /* to get BCNOK, BCNERR count */
721 struct getbcnokcnt_parm{
722 	unsigned int rsvd;
723 };
724 struct getbcnokcnt_rsp{
725 	unsigned long  bcnokcnt;
726 };
727 
728 struct getbcnerrcnt_parm{
729 	unsigned int rsvd;
730 };
731 struct getbcnerrcnt_rsp{
732 	unsigned long bcnerrcnt;
733 };
734 
735 /*  to get current TX power level */
736 struct getcurtxpwrlevel_parm{
737 	unsigned int rsvd;
738 };
739 struct getcurtxpwrlevel_rsp{
740 	unsigned short tx_power;
741 };
742 
743 struct setprobereqextraie_parm {
744 	unsigned char e_id;
745 	unsigned char ie_len;
746 	unsigned char ie[0];
747 };
748 
749 struct setassocreqextraie_parm {
750 	unsigned char e_id;
751 	unsigned char ie_len;
752 	unsigned char ie[0];
753 };
754 
755 struct setproberspextraie_parm {
756 	unsigned char e_id;
757 	unsigned char ie_len;
758 	unsigned char ie[0];
759 };
760 
761 struct setassocrspextraie_parm {
762 	unsigned char e_id;
763 	unsigned char ie_len;
764 	unsigned char ie[0];
765 };
766 
767 
768 struct addBaReq_parm
769 {
770 	unsigned int tid;
771 	u8 addr[ETH_ALEN];
772 };
773 
774 /*H2C Handler index: 46 */
775 struct set_ch_parm {
776 	u8 ch;
777 	u8 bw;
778 	u8 ch_offset;
779 };
780 
781 /*H2C Handler index: 59 */
782 struct SetChannelPlan_param
783 {
784 	u8 channel_plan;
785 };
786 
787 /*H2C Handler index: 60 */
788 struct LedBlink_param
789 {
790 	void *pLed;
791 };
792 
793 /*H2C Handler index: 61 */
794 struct SetChannelSwitch_param
795 {
796 	u8 new_ch_no;
797 };
798 
799 /*H2C Handler index: 62 */
800 struct TDLSoption_param
801 {
802 	u8 addr[ETH_ALEN];
803 	u8 option;
804 };
805 
806 /*H2C Handler index: 64 */
807 struct 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 Result:
820 0x00: success
821 0x01: sucess, and check Response.
822 0x02: cmd ignored due to duplicated sequcne number
823 0x03: cmd dropped due to invalid cmd code
824 0x04: reserved.
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 
839 u8 rtw_sitesurvey_cmd(struct adapter  *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, struct rtw_ieee80211_channel *ch, int ch_num);
840 extern u8 rtw_createbss_cmd(struct adapter  *padapter);
841 u8 rtw_startbss_cmd(struct adapter  *padapter, int flags);
842 
843 struct sta_info;
844 extern u8 rtw_setstakey_cmd(struct adapter  *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue);
845 extern u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue);
846 
847 extern u8 rtw_joinbss_cmd(struct adapter  *padapter, struct wlan_network* pnetwork);
848 u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue);
849 extern u8 rtw_setopmode_cmd(struct adapter  *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue);
850 extern u8 rtw_setdatarate_cmd(struct adapter  *padapter, u8 *rateset);
851 extern u8 rtw_setrfintfs_cmd(struct adapter  *padapter, u8 mode);
852 
853 extern u8 rtw_gettssi_cmd(struct adapter  *padapter, u8 offset, u8 *pval);
854 extern u8 rtw_setfwdig_cmd(struct adapter *padapter, u8 type);
855 extern u8 rtw_setfwra_cmd(struct adapter *padapter, u8 type);
856 
857 extern u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
858 /*  add for CONFIG_IEEE80211W, none 11w also can use */
859 extern u8 rtw_reset_securitypriv_cmd(struct adapter *padapter);
860 extern u8 rtw_free_assoc_resources_cmd(struct adapter *padapter);
861 extern u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
862 
863 u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
864 u8 rtw_dm_in_lps_wk_cmd(struct adapter *padapter);
865 
866 u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta);
867 
868 extern u8 rtw_ps_cmd(struct adapter *padapter);
869 
870 u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
871 
872 extern u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig);
873 
874 extern u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length);
875 extern u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt);
876 
877 u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
878 
879 extern void rtw_survey_cmd_callback(struct adapter  *padapter, struct cmd_obj *pcmd);
880 extern void rtw_disassoc_cmd_callback(struct adapter  *padapter, struct cmd_obj *pcmd);
881 extern void rtw_joinbss_cmd_callback(struct adapter  *padapter, struct cmd_obj *pcmd);
882 extern void rtw_createbss_cmd_callback(struct adapter  *padapter, struct cmd_obj *pcmd);
883 extern void rtw_getbbrfreg_cmdrsp_callback(struct adapter  *padapter, struct cmd_obj *pcmd);
884 
885 extern void rtw_setstaKey_cmdrsp_callback(struct adapter  *padapter,  struct cmd_obj *pcmd);
886 extern void rtw_setassocsta_cmdrsp_callback(struct adapter  *padapter,  struct cmd_obj *pcmd);
887 extern void rtw_getrttbl_cmdrsp_callback(struct adapter  *padapter,  struct cmd_obj *pcmd);
888 
889 
890 struct _cmd_callback {
891 	u32 cmd_code;
892 	void (*callback)(struct adapter  *padapter, struct cmd_obj *cmd);
893 };
894 
895 enum rtw_h2c_cmd
896 {
897 	GEN_CMD_CODE(_Read_MACREG) ,	/*0*/
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) , /*5*/
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) ,	/*10*/
909 	GEN_CMD_CODE(_Write_CAM) ,
910 	GEN_CMD_CODE(_setBCNITV),
911 	GEN_CMD_CODE(_setMBIDCFG),
912 	GEN_CMD_CODE(_JoinBss),   /*14*/
913 	GEN_CMD_CODE(_DisConnect) , /*15*/
914 	GEN_CMD_CODE(_CreateBss) ,
915 	GEN_CMD_CODE(_SetOpMode) ,
916 	GEN_CMD_CODE(_SiteSurvey),  /*18*/
917 	GEN_CMD_CODE(_SetAuth) ,
918 
919 	GEN_CMD_CODE(_SetKey) ,	/*20*/
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) , /*25*/
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) ,	/*30*/
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) , /*35*/
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), /*40*/
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) , /*45*/
947 	GEN_CMD_CODE(_SetChannel), /*46*/
948 	GEN_CMD_CODE(_SetTxPower),
949 	GEN_CMD_CODE(_SwitchAntenna),
950 	GEN_CMD_CODE(_SetCrystalCap),
951 	GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/
952 
953 	GEN_CMD_CODE(_SetSingleToneTx),/*51*/
954 	GEN_CMD_CODE(_SetCarrierSuppressionTx),
955 	GEN_CMD_CODE(_SetContinuousTx),
956 	GEN_CMD_CODE(_SwitchBandwidth), /*54*/
957 	GEN_CMD_CODE(_TX_Beacon), /*55*/
958 
959 	GEN_CMD_CODE(_Set_MLME_EVT), /*56*/
960 	GEN_CMD_CODE(_Set_Drv_Extra), /*57*/
961 	GEN_CMD_CODE(_Set_H2C_MSG), /*58*/
962 
963 	GEN_CMD_CODE(_SetChannelPlan), /*59*/
964 	GEN_CMD_CODE(_LedBlink), /*60*/
965 
966 	GEN_CMD_CODE(_SetChannelSwitch), /*61*/
967 	GEN_CMD_CODE(_TDLS), /*62*/
968 	GEN_CMD_CODE(_ChkBMCSleepq), /*63*/
969 
970 	GEN_CMD_CODE(_RunInThreadCMD), /*64*/
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 /*  _CMD_H_ */
981