1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
6 * Modifications for inclusion into the Linux staging tree are
7 * Copyright(c) 2010 Larry Finger. All rights reserved.
13 ******************************************************************************/
14 #ifndef __RTL871X_CMD_H_
15 #define __RTL871X_CMD_H_
17 #include "wlan_bssdef.h"
18 #include "rtl871x_rf.h"
19 #define C2H_MEM_SZ (16*1024)
21 #include "osdep_service.h"
22 #include "ieee80211.h"
24 #define FREE_CMDOBJ_SZ 128
27 #define MAX_EVTSZ 1024
28 #define CMDBUFF_ALIGN_SZ 512
37 struct list_head list;
41 struct completion cmd_queue_comp;
42 struct completion terminate_cmdthread_comp;
43 struct __queue cmd_queue;
45 u8 *cmd_buf; /*shall be non-paged, and 4 bytes aligned*/
46 u8 *cmd_allocated_buf;
47 u8 *rsp_buf; /*shall be non-paged, and 4 bytes aligned*/
48 u8 *rsp_allocated_buf;
52 struct _adapter *padapter;
60 struct list_head list;
64 struct __queue evt_queue;
66 u8 *evt_buf; /*shall be non-paged, and 4 bytes aligned*/
67 u8 *evt_allocated_buf;
69 struct tasklet_struct event_tasklet;
72 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
74 INIT_LIST_HEAD(&pcmd->list);\
75 pcmd->cmdcode = code;\
76 pcmd->parmbuf = (u8 *)(pparm);\
77 pcmd->cmdsz = sizeof(*pparm);\
82 void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
83 void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
84 struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue);
85 void r8712_free_cmd_obj(struct cmd_obj *pcmd);
86 int r8712_cmd_thread(void *context);
87 int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv);
88 void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv);
89 int r8712_init_evt_priv(struct evt_priv *pevtpriv);
90 void r8712_free_evt_priv(struct evt_priv *pevtpriv);
92 enum rtl871x_drvint_cid {
105 * Caller Mode: Infra, Ad-HoC(C)
106 * Notes: To enter USB suspend mode
109 struct usb_suspend_parm {
110 u32 action; /* 1: sleep, 0:resume */
114 * Caller Mode: Infra, Ad-HoC(C)
115 * Notes: To disconnect the current associated BSS
118 struct disconnect_parm {
123 * Caller Mode: AP, Ad-HoC, Infra
124 * Notes: To set the NIC mode of RTL8711
126 * The definition of mode:
128 * #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
129 * #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
130 * #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
131 * #define IW_MODE_MASTER 3 // Synchronisation master or AP
132 * #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
133 * #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
134 * #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
136 struct setopmode_parm {
142 * Caller Mode: AP, Ad-HoC, Infra
143 * Notes: To ask RTL8711 performing site-survey
146 struct sitesurvey_parm {
147 __le32 passive_mode; /*active: 1, passive: 0 */
148 __le32 bsslimit; /* 1 ~ 48 */
150 u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
155 * Notes: To set the auth type of RTL8711. open/shared/802.1x
158 struct setauth_parm {
159 u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
160 u8 _1x; /*0: PSK, 1: TLS*/
166 * a. algorithm: wep40, wep104, tkip & aes
167 * b. keytype: grp key/unicast key
170 * when shared key ==> keyid is the camid
171 * when 802.1x ==> keyid [0:1] ==> grp key
172 * when 802.1x ==> keyid > 2 ==> unicast key
175 u8 algorithm; /* encryption algorithm, could be none, wep40,
179 u8 grpkey; /* 1: this is the grpkey for 802.1x.
180 * 0: this is the unicast key for 802.1x
182 u8 key[16]; /* this could be 40 or 104 */
186 * When in AP or Ad-Hoc mode, this is used to
187 * allocate an sw/hw entry for a newly associated sta.
189 * when shared key ==> algorithm/keyid
191 struct set_stakey_parm {
197 struct set_stakey_rsp {
203 struct SetMacAddr_param {
204 u8 MacAddr[ETH_ALEN];
210 * Command -Rsp(AID == CAMID) mode
212 * This is to force fw to add an sta_data entry per driver's request.
214 * FW will write an cam entry associated with it.
217 struct set_assocsta_parm {
221 struct set_assocsta_rsp {
231 * This is to force fw to del an sta_data entry per driver's request
233 * FW will invalidate the cam entry associated with it.
236 struct del_assocsta_parm {
241 * Caller Mode: AP/Ad-HoC(M)
243 * Notes: To notify fw that given staid has changed its power state
248 struct setstapwrstate_parm {
257 * Notes: To setup the basic rate of RTL8711
262 struct setbasicrate_parm {
263 u8 basicrates[NumRates];
269 * Notes: To read the current basic rate
274 struct getbasicrate_parm {
278 struct getbasicrate_rsp {
279 u8 basicrates[NumRates];
285 * Notes: To setup the data rate of RTL8711
290 struct setdatarate_parm {
292 u8 datarates[NumRates];
295 enum _RT_CHANNEL_DOMAIN {
296 RT_CHANNEL_DOMAIN_FCC = 0,
297 RT_CHANNEL_DOMAIN_IC = 1,
298 RT_CHANNEL_DOMAIN_ETSI = 2,
299 RT_CHANNEL_DOMAIN_SPAIN = 3,
300 RT_CHANNEL_DOMAIN_FRANCE = 4,
301 RT_CHANNEL_DOMAIN_MKK = 5,
302 RT_CHANNEL_DOMAIN_MKK1 = 6,
303 RT_CHANNEL_DOMAIN_ISRAEL = 7,
304 RT_CHANNEL_DOMAIN_TELEC = 8,
306 /* Be compatible with old channel plan. No good! */
307 RT_CHANNEL_DOMAIN_MIC = 9,
308 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 10,
309 RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 11,
310 RT_CHANNEL_DOMAIN_TELEC_NETGEAR = 12,
312 RT_CHANNEL_DOMAIN_NCC = 13,
313 RT_CHANNEL_DOMAIN_5G = 14,
314 RT_CHANNEL_DOMAIN_5G_40M = 15,
315 /*===== Add new channel plan above this line===============*/
316 RT_CHANNEL_DOMAIN_MAX,
320 struct SetChannelPlan_param {
321 enum _RT_CHANNEL_DOMAIN ChannelPlan;
327 * Notes: To read the current data rate
332 struct getdatarate_parm {
336 struct getdatarate_rsp {
337 u8 datarates[NumRates];
343 * AP: AP can use the info for the contents of beacon frame
344 * Infra: STA can use the info when sitesurveying
346 * Ad-HoC(C): Like STA
349 * Notes: To set the phy capability of the NIC
358 * Notes: To set the channel/modem/band
359 * This command will be used when channel/modem/band is changed.
367 * Notes: To get the current setting of channel/modem/band
384 struct readTSSI_parm {
387 struct readTSSI_rsp {
391 struct writeBB_parm {
396 struct writePTM_parm {
407 struct writeRF_parm {
412 struct setrfintfs_parm {
416 struct getrfintfs_parm {
421 * Notes: This command is used for H2C/C2H loopback testing
424 * ==> CMD mode, return H2C_SUCCESS.
425 * The following condition must be true under CMD mode
426 * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
427 * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
428 * s2 == (b1 << 8 | b0);
431 * ==> CMD_RSP mode, return H2C_SUCCESS_RSP
433 * The rsp layout shall be:
450 * ==> CMD_EVENT mode, return H2C_SUCCESS
451 * The event layout shall be:
455 * mac[2] = event's sequence number, starting from 1 to parm's marc[3]
459 * s0 = swap16(s0) - event.mac[2];
460 * s1 = s1 + event.mac[2];
463 * s2 = s0 + event.mac[2]
465 * w1 = swap32(w1) - event.mac[2];
467 * parm->mac[3] is the total event counts that host requested.
470 * event will be the same with the cmd's param.
474 /* CMD param Formart for DRV INTERNAL CMD HDL*/
475 struct drvint_cmd_parm {
476 int i_cid; /*internal cmd id*/
481 /*------------------- Below are used for RF/BB tuning ---------------------*/
483 struct setantenna_parm {
490 struct enrateadaptive_parm {
494 struct settxagctbl_parm {
495 u32 txagc[MAX_RATES_LENGTH];
498 struct gettxagctbl_parm {
501 struct gettxagctbl_rsp {
502 u32 txagc[MAX_RATES_LENGTH];
505 struct setagcctrl_parm {
506 u32 agcctrl; /* 0: pure hw, 1: fw */
509 struct setssup_parm {
510 u32 ss_ForceUp[MAX_RATES_LENGTH];
513 struct getssup_parm {
517 u8 ss_ForceUp[MAX_RATES_LENGTH];
520 struct setssdlevel_parm {
521 u8 ss_DLevel[MAX_RATES_LENGTH];
524 struct getssdlevel_parm {
527 struct getssdlevel_rsp {
528 u8 ss_DLevel[MAX_RATES_LENGTH];
531 struct setssulevel_parm {
532 u8 ss_ULevel[MAX_RATES_LENGTH];
535 struct getssulevel_parm {
538 struct getssulevel_rsp {
539 u8 ss_ULevel[MAX_RATES_LENGTH];
542 struct setcountjudge_parm {
543 u8 count_judge[MAX_RATES_LENGTH];
546 struct getcountjudge_parm {
550 struct getcountjudge_rsp {
551 u8 count_judge[MAX_RATES_LENGTH];
554 struct setpwrmode_parm {
556 u8 flag_low_traffic_en;
558 u8 flag_rf_low_snr_en;
559 u8 flag_dps_en; /* 1: dps, 0: 32k */
561 u8 bcn_pass_cnt; /* fw report one beacon information to
562 * driver when it receives bcn_pass_cnt
565 u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
567 u8 app_itv; /* only for VOIP mode. */
570 u8 bcn_pass_time; /* unit: 100ms */
573 struct setatim_parm {
574 u8 op; /*0: add, 1:del*/
575 u8 txid; /* id of dest station.*/
578 struct setratable_parm {
579 u8 ss_ForceUp[NumRates];
580 u8 ss_ULevel[NumRates];
581 u8 ss_DLevel[NumRates];
582 u8 count_judge[NumRates];
585 struct getratable_parm {
588 struct getratable_rsp {
589 u8 ss_ForceUp[NumRates];
590 u8 ss_ULevel[NumRates];
591 u8 ss_DLevel[NumRates];
592 u8 count_judge[NumRates];
595 /*to get TX,RX retry count*/
596 struct gettxretrycnt_parm {
600 struct gettxretrycnt_rsp {
601 unsigned long tx_retrycnt;
604 struct getrxretrycnt_parm {
608 struct getrxretrycnt_rsp {
609 unsigned long rx_retrycnt;
612 /*to get BCNOK,BCNERR count*/
613 struct getbcnokcnt_parm {
617 struct getbcnokcnt_rsp {
618 unsigned long bcnokcnt;
621 struct getbcnerrcnt_parm {
624 struct getbcnerrcnt_rsp {
625 unsigned long bcnerrcnt;
628 /* to get current TX power level*/
629 struct getcurtxpwrlevel_parm {
633 struct getcurtxpwrlevel_rsp {
634 unsigned short tx_power;
637 /*dynamic on/off DIG*/
639 unsigned char dig_on; /* 1:on , 0:off */
642 /*dynamic on/off RA*/
644 unsigned char ra_on; /* 1:on , 0:off */
647 struct setprobereqextraie_parm {
649 unsigned char ie_len;
653 struct setassocreqextraie_parm {
655 unsigned char ie_len;
659 struct setproberspextraie_parm {
661 unsigned char ie_len;
665 struct setassocrspextraie_parm {
667 unsigned char ie_len;
671 struct addBaReq_parm {
675 /*H2C Handler index: 46 */
676 struct SetChannel_parm {
680 /*H2C Handler index: 61 */
681 struct DisconnectCtrlEx_param {
682 /* MAXTIME = (2 * FirstStageTO) + (TryPktCnt * TryPktInterval) */
683 unsigned char EnableDrvCtrl;
684 unsigned char TryPktCnt;
685 unsigned char TryPktInterval; /* Unit: ms */
687 unsigned int FirstStageTO; /* Unit: ms */
690 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
695 * 0x01: success, and check Response.
696 * 0x02: cmd ignored due to duplicated sequence number
697 * 0x03: cmd dropped due to invalid cmd code
701 #define H2C_RSP_OFFSET 512
702 #define H2C_SUCCESS 0x00
703 #define H2C_SUCCESS_RSP 0x01
704 #define H2C_DUPLICATED 0x02
705 #define H2C_DROPPED 0x03
706 #define H2C_PARAMETERS_ERROR 0x04
707 #define H2C_REJECTED 0x05
708 #define H2C_CMD_OVERFLOW 0x06
709 #define H2C_RESERVED 0x07
711 void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr);
712 u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
713 struct ndis_802_11_ssid *pssid);
714 int r8712_createbss_cmd(struct _adapter *padapter);
715 void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
716 int r8712_joinbss_cmd(struct _adapter *padapter,
717 struct wlan_network *pnetwork);
718 void r8712_disassoc_cmd(struct _adapter *padapter);
719 void r8712_setopmode_cmd(struct _adapter *padapter,
720 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
721 int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
722 void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan);
723 int r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval);
724 int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val);
725 void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid);
726 void r8712_wdg_wk_cmd(struct _adapter *padapter);
727 void r8712_survey_cmd_callback(struct _adapter *padapter,
728 struct cmd_obj *pcmd);
729 void r8712_disassoc_cmd_callback(struct _adapter *padapter,
730 struct cmd_obj *pcmd);
731 void r8712_joinbss_cmd_callback(struct _adapter *padapter,
732 struct cmd_obj *pcmd);
733 void r8712_createbss_cmd_callback(struct _adapter *padapter,
734 struct cmd_obj *pcmd);
735 void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
736 struct cmd_obj *pcmd);
737 void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter,
738 struct cmd_obj *pcmd);
739 void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
740 struct cmd_obj *pcmd);
741 void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
742 struct cmd_obj *pcmd);
743 void r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl,
744 u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO);
746 struct _cmd_callback {
748 void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
751 #include "rtl8712_cmd.h"