1 /******************************************************************************
3 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 * Modifications for inclusion into the Linux staging tree are
19 * Copyright(c) 2010 Larry Finger. All rights reserved.
21 * Contact information:
22 * WLAN FAE <wlanfae@realtek.com>
23 * Larry Finger <Larry.Finger@lwfinger.net>
25 ******************************************************************************/
26 #ifndef __RTL871X_CMD_H_
27 #define __RTL871X_CMD_H_
29 #include "wlan_bssdef.h"
30 #include "rtl871x_rf.h"
31 #define C2H_MEM_SZ (16*1024)
33 #include "osdep_service.h"
34 #include "ieee80211.h"
36 #define FREE_CMDOBJ_SZ 128
39 #define MAX_EVTSZ 1024
40 #define CMDBUFF_ALIGN_SZ 512
49 struct list_head list
;
53 struct semaphore cmd_queue_sema
;
54 struct semaphore terminate_cmdthread_sema
;
55 struct __queue cmd_queue
;
57 u8
*cmd_buf
; /*shall be non-paged, and 4 bytes aligned*/
58 u8
*cmd_allocated_buf
;
59 u8
*rsp_buf
; /*shall be non-paged, and 4 bytes aligned*/
60 u8
*rsp_allocated_buf
;
64 struct _adapter
*padapter
;
72 struct list_head list
;
76 struct __queue evt_queue
;
78 u8
*evt_buf
; /*shall be non-paged, and 4 bytes aligned*/
79 u8
*evt_allocated_buf
;
81 struct tasklet_struct event_tasklet
;
84 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
86 INIT_LIST_HEAD(&pcmd->list);\
87 pcmd->cmdcode = code;\
88 pcmd->parmbuf = (u8 *)(pparm);\
89 pcmd->cmdsz = sizeof(*pparm);\
94 u32
r8712_enqueue_cmd(struct cmd_priv
*pcmdpriv
, struct cmd_obj
*obj
);
95 u32
r8712_enqueue_cmd_ex(struct cmd_priv
*pcmdpriv
, struct cmd_obj
*obj
);
96 struct cmd_obj
*r8712_dequeue_cmd(struct __queue
*queue
);
97 void r8712_free_cmd_obj(struct cmd_obj
*pcmd
);
98 int r8712_cmd_thread(void *context
);
99 u32
r8712_init_cmd_priv(struct cmd_priv
*pcmdpriv
);
100 void r8712_free_cmd_priv(struct cmd_priv
*pcmdpriv
);
101 u32
r8712_init_evt_priv(struct evt_priv
*pevtpriv
);
102 void r8712_free_evt_priv(struct evt_priv
*pevtpriv
);
104 enum rtl871x_drvint_cid
{
117 * Caller Mode: Infra, Ad-HoC(C)
118 * Notes: To enter USB suspend mode
121 struct usb_suspend_parm
{
122 u32 action
; /* 1: sleep, 0:resume */
126 * Caller Mode: Infra, Ad-HoC(C)
127 * Notes: To disconnect the current associated BSS
130 struct disconnect_parm
{
135 * Caller Mode: AP, Ad-HoC, Infra
136 * Notes: To set the NIC mode of RTL8711
138 * The definition of mode:
140 * #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
141 * #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
142 * #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
143 * #define IW_MODE_MASTER 3 // Synchronisation master or AP
144 * #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
145 * #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
146 * #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
148 struct setopmode_parm
{
154 * Caller Mode: AP, Ad-HoC, Infra
155 * Notes: To ask RTL8711 performing site-survey
158 struct sitesurvey_parm
{
159 sint passive_mode
; /*active: 1, passive: 0 */
160 sint bsslimit
; /* 1 ~ 48 */
162 u8 ss_ssid
[IW_ESSID_MAX_SIZE
+ 1];
167 * Notes: To set the auth type of RTL8711. open/shared/802.1x
170 struct setauth_parm
{
171 u8 mode
; /*0: legacy open, 1: legacy shared 2: 802.1x*/
172 u8 _1x
; /*0: PSK, 1: TLS*/
178 * a. algorithm: wep40, wep104, tkip & aes
179 * b. keytype: grp key/unicast key
182 * when shared key ==> keyid is the camid
183 * when 802.1x ==> keyid [0:1] ==> grp key
184 * when 802.1x ==> keyid > 2 ==> unicast key
187 u8 algorithm
; /* encryption algorithm, could be none, wep40,
188 * TKIP, CCMP, wep104 */
190 u8 grpkey
; /* 1: this is the grpkey for 802.1x.
191 * 0: this is the unicast key for 802.1x */
192 u8 key
[16]; /* this could be 40 or 104 */
196 * When in AP or Ad-Hoc mode, this is used to
197 * allocate an sw/hw entry for a newly associated sta.
199 * when shared key ==> algorithm/keyid
201 struct set_stakey_parm
{
207 struct set_stakey_rsp
{
213 struct SetMacAddr_param
{
214 u8 MacAddr
[ETH_ALEN
];
220 Command -Rsp(AID == CAMID) mode
222 This is to force fw to add an sta_data entry per driver's request.
224 FW will write an cam entry associated with it.
227 struct set_assocsta_parm
{
231 struct set_assocsta_rsp
{
241 This is to force fw to del an sta_data entry per driver's request
243 FW will invalidate the cam entry associated with it.
246 struct del_assocsta_parm
{
251 Caller Mode: AP/Ad-HoC(M)
253 Notes: To notify fw that given staid has changed its power state
258 struct setstapwrstate_parm
{
267 Notes: To setup the basic rate of RTL8711
272 struct setbasicrate_parm
{
273 u8 basicrates
[NumRates
];
279 Notes: To read the current basic rate
284 struct getbasicrate_parm
{
288 struct getbasicrate_rsp
{
289 u8 basicrates
[NumRates
];
295 Notes: To setup the data rate of RTL8711
300 struct setdatarate_parm
{
302 u8 datarates
[NumRates
];
305 enum _RT_CHANNEL_DOMAIN
{
306 RT_CHANNEL_DOMAIN_FCC
= 0,
307 RT_CHANNEL_DOMAIN_IC
= 1,
308 RT_CHANNEL_DOMAIN_ETSI
= 2,
309 RT_CHANNEL_DOMAIN_SPAIN
= 3,
310 RT_CHANNEL_DOMAIN_FRANCE
= 4,
311 RT_CHANNEL_DOMAIN_MKK
= 5,
312 RT_CHANNEL_DOMAIN_MKK1
= 6,
313 RT_CHANNEL_DOMAIN_ISRAEL
= 7,
314 RT_CHANNEL_DOMAIN_TELEC
= 8,
316 /* Be compatible with old channel plan. No good! */
317 RT_CHANNEL_DOMAIN_MIC
= 9,
318 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN
= 10,
319 RT_CHANNEL_DOMAIN_WORLD_WIDE_13
= 11,
320 RT_CHANNEL_DOMAIN_TELEC_NETGEAR
= 12,
322 RT_CHANNEL_DOMAIN_NCC
= 13,
323 RT_CHANNEL_DOMAIN_5G
= 14,
324 RT_CHANNEL_DOMAIN_5G_40M
= 15,
325 /*===== Add new channel plan above this line===============*/
326 RT_CHANNEL_DOMAIN_MAX
,
330 struct SetChannelPlan_param
{
331 enum _RT_CHANNEL_DOMAIN ChannelPlan
;
337 Notes: To read the current data rate
342 struct getdatarate_parm
{
346 struct getdatarate_rsp
{
347 u8 datarates
[NumRates
];
353 AP: AP can use the info for the contents of beacon frame
354 Infra: STA can use the info when sitesurveying
359 Notes: To set the phy capability of the NIC
368 Notes: To set the channel/modem/band
369 This command will be used when channel/modem/band is changed.
377 Notes: To get the current setting of channel/modem/band
394 struct readTSSI_parm
{
397 struct readTSSI_rsp
{
401 struct writeBB_parm
{
406 struct writePTM_parm
{
417 struct writeRF_parm
{
422 struct setrfintfs_parm
{
426 struct getrfintfs_parm
{
431 Notes: This command is used for H2C/C2H loopback testing
434 ==> CMD mode, return H2C_SUCCESS.
435 The following condition must be ture under CMD mode
436 mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
437 s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
438 s2 == (b1 << 8 | b0);
441 ==> CMD_RSP mode, return H2C_SUCCESS_RSP
443 The rsp layout shall be:
460 ==> CMD_EVENT mode, return H2C_SUCCESS
461 The event layout shall be:
465 mac[2] = event's sequence number, starting from 1 to parm's marc[3]
469 s0 = swap16(s0) - event.mac[2];
470 s1 = s1 + event.mac[2];
473 s2 = s0 + event.mac[2]
475 w1 = swap32(w1) - event.mac[2];
477 parm->mac[3] is the total event counts that host requested.
480 event will be the same with the cmd's param.
484 /* CMD param Formart for DRV INTERNAL CMD HDL*/
485 struct drvint_cmd_parm
{
486 int i_cid
; /*internal cmd id*/
491 /*------------------- Below are used for RF/BB tunning ---------------------*/
493 struct setantenna_parm
{
500 struct enrateadaptive_parm
{
504 struct settxagctbl_parm
{
505 u32 txagc
[MAX_RATES_LENGTH
];
508 struct gettxagctbl_parm
{
511 struct gettxagctbl_rsp
{
512 u32 txagc
[MAX_RATES_LENGTH
];
515 struct setagcctrl_parm
{
516 u32 agcctrl
; /* 0: pure hw, 1: fw */
519 struct setssup_parm
{
520 u32 ss_ForceUp
[MAX_RATES_LENGTH
];
523 struct getssup_parm
{
527 u8 ss_ForceUp
[MAX_RATES_LENGTH
];
530 struct setssdlevel_parm
{
531 u8 ss_DLevel
[MAX_RATES_LENGTH
];
534 struct getssdlevel_parm
{
537 struct getssdlevel_rsp
{
538 u8 ss_DLevel
[MAX_RATES_LENGTH
];
541 struct setssulevel_parm
{
542 u8 ss_ULevel
[MAX_RATES_LENGTH
];
545 struct getssulevel_parm
{
548 struct getssulevel_rsp
{
549 u8 ss_ULevel
[MAX_RATES_LENGTH
];
552 struct setcountjudge_parm
{
553 u8 count_judge
[MAX_RATES_LENGTH
];
556 struct getcountjudge_parm
{
560 struct getcountjudge_rsp
{
561 u8 count_judge
[MAX_RATES_LENGTH
];
564 struct setpwrmode_parm
{
566 u8 flag_low_traffic_en
;
568 u8 flag_rf_low_snr_en
;
569 u8 flag_dps_en
; /* 1: dps, 0: 32k */
571 u8 bcn_pass_cnt
; /* fw report one beacon information to
572 * driver when it receives bcn_pass_cnt
574 u8 bcn_to
; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
576 u8 app_itv
; /* only for VOIP mode. */
579 u8 bcn_pass_time
; /* unit: 100ms */
582 struct setatim_parm
{
583 u8 op
; /*0: add, 1:del*/
584 u8 txid
; /* id of dest station.*/
587 struct setratable_parm
{
588 u8 ss_ForceUp
[NumRates
];
589 u8 ss_ULevel
[NumRates
];
590 u8 ss_DLevel
[NumRates
];
591 u8 count_judge
[NumRates
];
594 struct getratable_parm
{
597 struct getratable_rsp
{
598 u8 ss_ForceUp
[NumRates
];
599 u8 ss_ULevel
[NumRates
];
600 u8 ss_DLevel
[NumRates
];
601 u8 count_judge
[NumRates
];
604 /*to get TX,RX retry count*/
605 struct gettxretrycnt_parm
{
609 struct gettxretrycnt_rsp
{
610 unsigned long tx_retrycnt
;
613 struct getrxretrycnt_parm
{
617 struct getrxretrycnt_rsp
{
618 unsigned long rx_retrycnt
;
621 /*to get BCNOK,BCNERR count*/
622 struct getbcnokcnt_parm
{
626 struct getbcnokcnt_rsp
{
627 unsigned long bcnokcnt
;
630 struct getbcnerrcnt_parm
{
633 struct getbcnerrcnt_rsp
{
634 unsigned long bcnerrcnt
;
637 /* to get current TX power level*/
638 struct getcurtxpwrlevel_parm
{
642 struct getcurtxpwrlevel_rsp
{
643 unsigned short tx_power
;
646 /*dynamic on/off DIG*/
648 unsigned char dig_on
; /* 1:on , 0:off */
651 /*dynamic on/off RA*/
653 unsigned char ra_on
; /* 1:on , 0:off */
656 struct setprobereqextraie_parm
{
658 unsigned char ie_len
;
662 struct setassocreqextraie_parm
{
664 unsigned char ie_len
;
668 struct setproberspextraie_parm
{
670 unsigned char ie_len
;
674 struct setassocrspextraie_parm
{
676 unsigned char ie_len
;
680 struct addBaReq_parm
{
684 /*H2C Handler index: 46 */
685 struct SetChannel_parm
{
689 /*H2C Handler index: 61 */
690 struct DisconnectCtrlEx_param
{
691 /* MAXTIME = (2 * FirstStageTO) + (TryPktCnt * TryPktInterval) */
692 unsigned char EnableDrvCtrl
;
693 unsigned char TryPktCnt
;
694 unsigned char TryPktInterval
; /* Unit: ms */
696 unsigned int FirstStageTO
; /* Unit: ms */
699 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
704 * 0x01: success, and check Response.
705 * 0x02: cmd ignored due to duplicated sequence number
706 * 0x03: cmd dropped due to invalid cmd code
710 #define H2C_RSP_OFFSET 512
711 #define H2C_SUCCESS 0x00
712 #define H2C_SUCCESS_RSP 0x01
713 #define H2C_DUPLICATED 0x02
714 #define H2C_DROPPED 0x03
715 #define H2C_PARAMETERS_ERROR 0x04
716 #define H2C_REJECTED 0x05
717 #define H2C_CMD_OVERFLOW 0x06
718 #define H2C_RESERVED 0x07
720 u8
r8712_setMacAddr_cmd(struct _adapter
*padapter
, u8
*mac_addr
);
721 u8
r8712_setassocsta_cmd(struct _adapter
*padapter
, u8
*mac_addr
);
722 u8
r8712_sitesurvey_cmd(struct _adapter
*padapter
,
723 struct ndis_802_11_ssid
*pssid
);
724 u8
r8712_createbss_cmd(struct _adapter
*padapter
);
725 u8
r8712_setstakey_cmd(struct _adapter
*padapter
, u8
*psta
, u8 unicast_key
);
726 u8
r8712_joinbss_cmd(struct _adapter
*padapter
,
727 struct wlan_network
*pnetwork
);
728 u8
r8712_disassoc_cmd(struct _adapter
*padapter
);
729 u8
r8712_setopmode_cmd(struct _adapter
*padapter
,
730 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype
);
731 u8
r8712_setdatarate_cmd(struct _adapter
*padapter
, u8
*rateset
);
732 u8
r8712_set_chplan_cmd(struct _adapter
*padapter
, int chplan
);
733 u8
r8712_setbasicrate_cmd(struct _adapter
*padapter
, u8
*rateset
);
734 u8
r8712_getrfreg_cmd(struct _adapter
*padapter
, u8 offset
, u8
*pval
);
735 u8
r8712_setrfintfs_cmd(struct _adapter
*padapter
, u8 mode
);
736 u8
r8712_setrfreg_cmd(struct _adapter
*padapter
, u8 offset
, u32 val
);
737 u8
r8712_setrttbl_cmd(struct _adapter
*padapter
,
738 struct setratable_parm
*prate_table
);
739 u8
r8712_gettssi_cmd(struct _adapter
*padapter
, u8 offset
, u8
*pval
);
740 u8
r8712_setptm_cmd(struct _adapter
*padapter
, u8 type
);
741 u8
r8712_setfwdig_cmd(struct _adapter
*padapter
, u8 type
);
742 u8
r8712_setfwra_cmd(struct _adapter
*padapter
, u8 type
);
743 u8
r8712_addbareq_cmd(struct _adapter
*padapter
, u8 tid
);
744 u8
r8712_wdg_wk_cmd(struct _adapter
*padapter
);
745 void r8712_survey_cmd_callback(struct _adapter
*padapter
,
746 struct cmd_obj
*pcmd
);
747 void r8712_disassoc_cmd_callback(struct _adapter
*padapter
,
748 struct cmd_obj
*pcmd
);
749 void r8712_joinbss_cmd_callback(struct _adapter
*padapter
,
750 struct cmd_obj
*pcmd
);
751 void r8712_createbss_cmd_callback(struct _adapter
*padapter
,
752 struct cmd_obj
*pcmd
);
753 void r8712_getbbrfreg_cmdrsp_callback(struct _adapter
*padapter
,
754 struct cmd_obj
*pcmd
);
755 void r8712_readtssi_cmdrsp_callback(struct _adapter
*padapter
,
756 struct cmd_obj
*pcmd
);
757 void r8712_setstaKey_cmdrsp_callback(struct _adapter
*padapter
,
758 struct cmd_obj
*pcmd
);
759 void r8712_setassocsta_cmdrsp_callback(struct _adapter
*padapter
,
760 struct cmd_obj
*pcmd
);
761 u8
r8712_disconnectCtrlEx_cmd(struct _adapter
*adapter
, u32 enableDrvCtrl
,
762 u32 tryPktCnt
, u32 tryPktInterval
, u32 firstStageTO
);
764 struct _cmd_callback
{
766 void (*callback
)(struct _adapter
*padapter
, struct cmd_obj
*cmd
);
769 #include "rtl8712_cmd.h"