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;
71 #define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
73 INIT_LIST_HEAD(&pcmd->list);\
74 pcmd->cmdcode = code;\
75 pcmd->parmbuf = (u8 *)(pparm);\
76 pcmd->cmdsz = sizeof(*pparm);\
81 void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
82 void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
83 struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue);
84 void r8712_free_cmd_obj(struct cmd_obj *pcmd);
85 int r8712_cmd_thread(void *context);
86 int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv);
87 void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv);
88 int r8712_init_evt_priv(struct evt_priv *pevtpriv);
89 void r8712_free_evt_priv(struct evt_priv *pevtpriv);
91 enum rtl871x_drvint_cid {
104 * Caller Mode: Infra, Ad-HoC(C)
105 * Notes: To enter USB suspend mode
108 struct usb_suspend_parm {
109 u32 action; /* 1: sleep, 0:resume */
113 * Caller Mode: Infra, Ad-HoC(C)
114 * Notes: To disconnect the current associated BSS
117 struct disconnect_parm {
122 * Caller Mode: AP, Ad-HoC, Infra
123 * Notes: To set the NIC mode of RTL8711
125 * The definition of mode:
127 * #define IW_MODE_AUTO 0 // Let the driver decides which AP to join
128 * #define IW_MODE_ADHOC 1 // Single cell network (Ad-Hoc Clients)
129 * #define IW_MODE_INFRA 2 // Multi cell network, roaming, ..
130 * #define IW_MODE_MASTER 3 // Synchronisation master or AP
131 * #define IW_MODE_REPEAT 4 // Wireless Repeater (forwarder)
132 * #define IW_MODE_SECOND 5 // Secondary master/repeater (backup)
133 * #define IW_MODE_MONITOR 6 // Passive monitor (listen only)
135 struct setopmode_parm {
141 * Caller Mode: AP, Ad-HoC, Infra
142 * Notes: To ask RTL8711 performing site-survey
145 struct sitesurvey_parm {
146 __le32 passive_mode; /*active: 1, passive: 0 */
147 __le32 bsslimit; /* 1 ~ 48 */
149 u8 ss_ssid[IW_ESSID_MAX_SIZE + 1];
154 * Notes: To set the auth type of RTL8711. open/shared/802.1x
157 struct setauth_parm {
158 u8 mode; /*0: legacy open, 1: legacy shared 2: 802.1x*/
159 u8 _1x; /*0: PSK, 1: TLS*/
165 * a. algorithm: wep40, wep104, tkip & aes
166 * b. keytype: grp key/unicast key
169 * when shared key ==> keyid is the camid
170 * when 802.1x ==> keyid [0:1] ==> grp key
171 * when 802.1x ==> keyid > 2 ==> unicast key
174 u8 algorithm; /* encryption algorithm, could be none, wep40,
178 u8 grpkey; /* 1: this is the grpkey for 802.1x.
179 * 0: this is the unicast key for 802.1x
181 u8 key[16]; /* this could be 40 or 104 */
185 * When in AP or Ad-Hoc mode, this is used to
186 * allocate an sw/hw entry for a newly associated sta.
188 * when shared key ==> algorithm/keyid
190 struct set_stakey_parm {
196 struct set_stakey_rsp {
202 struct SetMacAddr_param {
203 u8 MacAddr[ETH_ALEN];
209 * Command -Rsp(AID == CAMID) mode
211 * This is to force fw to add an sta_data entry per driver's request.
213 * FW will write an cam entry associated with it.
216 struct set_assocsta_parm {
220 struct set_assocsta_rsp {
230 * This is to force fw to del an sta_data entry per driver's request
232 * FW will invalidate the cam entry associated with it.
235 struct del_assocsta_parm {
240 * Caller Mode: AP/Ad-HoC(M)
242 * Notes: To notify fw that given staid has changed its power state
247 struct setstapwrstate_parm {
256 * Notes: To setup the basic rate of RTL8711
261 struct setbasicrate_parm {
262 u8 basicrates[NumRates];
268 * Notes: To read the current basic rate
273 struct getbasicrate_parm {
277 struct getbasicrate_rsp {
278 u8 basicrates[NumRates];
284 * Notes: To setup the data rate of RTL8711
289 struct setdatarate_parm {
291 u8 datarates[NumRates];
294 enum _RT_CHANNEL_DOMAIN {
295 RT_CHANNEL_DOMAIN_FCC = 0,
296 RT_CHANNEL_DOMAIN_IC = 1,
297 RT_CHANNEL_DOMAIN_ETSI = 2,
298 RT_CHANNEL_DOMAIN_SPAIN = 3,
299 RT_CHANNEL_DOMAIN_FRANCE = 4,
300 RT_CHANNEL_DOMAIN_MKK = 5,
301 RT_CHANNEL_DOMAIN_MKK1 = 6,
302 RT_CHANNEL_DOMAIN_ISRAEL = 7,
303 RT_CHANNEL_DOMAIN_TELEC = 8,
305 /* Be compatible with old channel plan. No good! */
306 RT_CHANNEL_DOMAIN_MIC = 9,
307 RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 10,
308 RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 11,
309 RT_CHANNEL_DOMAIN_TELEC_NETGEAR = 12,
311 RT_CHANNEL_DOMAIN_NCC = 13,
312 RT_CHANNEL_DOMAIN_5G = 14,
313 RT_CHANNEL_DOMAIN_5G_40M = 15,
314 /*===== Add new channel plan above this line===============*/
315 RT_CHANNEL_DOMAIN_MAX,
318 struct SetChannelPlan_param {
319 enum _RT_CHANNEL_DOMAIN ChannelPlan;
325 * Notes: To read the current data rate
330 struct getdatarate_parm {
335 struct getdatarate_rsp {
336 u8 datarates[NumRates];
341 * AP: AP can use the info for the contents of beacon frame
342 * Infra: STA can use the info when sitesurveying
344 * Ad-HoC(C): Like STA
347 * Notes: To set the phy capability of the NIC
356 * Notes: To set the channel/modem/band
357 * This command will be used when channel/modem/band is changed.
365 * Notes: To get the current setting of channel/modem/band
383 struct readTSSI_parm {
387 struct readTSSI_rsp {
391 struct writeBB_parm {
396 struct writePTM_parm {
408 struct writeRF_parm {
413 struct setrfintfs_parm {
417 struct getrfintfs_parm {
422 * Notes: This command is used for H2C/C2H loopback testing
425 * ==> CMD mode, return H2C_SUCCESS.
426 * The following condition must be true under CMD mode
427 * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
428 * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
429 * s2 == (b1 << 8 | b0);
432 * ==> CMD_RSP mode, return H2C_SUCCESS_RSP
434 * The rsp layout shall be:
451 * ==> CMD_EVENT mode, return H2C_SUCCESS
452 * The event layout shall be:
456 * mac[2] = event's sequence number, starting from 1 to parm's marc[3]
460 * s0 = swap16(s0) - event.mac[2];
461 * s1 = s1 + event.mac[2];
464 * s2 = s0 + event.mac[2]
466 * w1 = swap32(w1) - event.mac[2];
468 * parm->mac[3] is the total event counts that host requested.
471 * event will be the same with the cmd's param.
475 /* CMD param Formart for DRV INTERNAL CMD HDL*/
476 struct drvint_cmd_parm {
477 int i_cid; /*internal cmd id*/
482 /*------------------- Below are used for RF/BB tuning ---------------------*/
484 struct setantenna_parm {
491 struct enrateadaptive_parm {
495 struct settxagctbl_parm {
496 u32 txagc[MAX_RATES_LENGTH];
499 struct gettxagctbl_parm {
503 struct gettxagctbl_rsp {
504 u32 txagc[MAX_RATES_LENGTH];
507 struct setagcctrl_parm {
508 u32 agcctrl; /* 0: pure hw, 1: fw */
511 struct setssup_parm {
512 u32 ss_ForceUp[MAX_RATES_LENGTH];
515 struct getssup_parm {
520 u8 ss_ForceUp[MAX_RATES_LENGTH];
523 struct setssdlevel_parm {
524 u8 ss_DLevel[MAX_RATES_LENGTH];
527 struct getssdlevel_parm {
531 struct getssdlevel_rsp {
532 u8 ss_DLevel[MAX_RATES_LENGTH];
535 struct setssulevel_parm {
536 u8 ss_ULevel[MAX_RATES_LENGTH];
539 struct getssulevel_parm {
543 struct getssulevel_rsp {
544 u8 ss_ULevel[MAX_RATES_LENGTH];
547 struct setcountjudge_parm {
548 u8 count_judge[MAX_RATES_LENGTH];
551 struct getcountjudge_parm {
555 struct getcountjudge_rsp {
556 u8 count_judge[MAX_RATES_LENGTH];
559 struct setpwrmode_parm {
561 u8 flag_low_traffic_en;
563 u8 flag_rf_low_snr_en;
564 u8 flag_dps_en; /* 1: dps, 0: 32k */
566 u8 bcn_pass_cnt; /* fw report one beacon information to
567 * driver when it receives bcn_pass_cnt
570 u8 bcn_to; /* beacon TO (ms). ¡§=0¡¨ no limit.*/
572 u8 app_itv; /* only for VOIP mode. */
575 u8 bcn_pass_time; /* unit: 100ms */
578 struct setatim_parm {
579 u8 op; /*0: add, 1:del*/
580 u8 txid; /* id of dest station.*/
583 struct setratable_parm {
584 u8 ss_ForceUp[NumRates];
585 u8 ss_ULevel[NumRates];
586 u8 ss_DLevel[NumRates];
587 u8 count_judge[NumRates];
590 struct getratable_parm {
594 struct getratable_rsp {
595 u8 ss_ForceUp[NumRates];
596 u8 ss_ULevel[NumRates];
597 u8 ss_DLevel[NumRates];
598 u8 count_judge[NumRates];
601 /*to get TX,RX retry count*/
602 struct gettxretrycnt_parm {
606 struct gettxretrycnt_rsp {
607 unsigned long tx_retrycnt;
610 struct getrxretrycnt_parm {
614 struct getrxretrycnt_rsp {
615 unsigned long rx_retrycnt;
618 /*to get BCNOK,BCNERR count*/
619 struct getbcnokcnt_parm {
623 struct getbcnokcnt_rsp {
624 unsigned long bcnokcnt;
627 struct getbcnerrcnt_parm {
631 struct getbcnerrcnt_rsp {
632 unsigned long bcnerrcnt;
635 /* to get current TX power level*/
636 struct getcurtxpwrlevel_parm {
640 struct getcurtxpwrlevel_rsp {
641 unsigned short tx_power;
644 /*dynamic on/off DIG*/
646 unsigned char dig_on; /* 1:on , 0:off */
649 /*dynamic on/off RA*/
651 unsigned char ra_on; /* 1:on , 0:off */
654 struct setprobereqextraie_parm {
656 unsigned char ie_len;
660 struct setassocreqextraie_parm {
662 unsigned char ie_len;
666 struct setproberspextraie_parm {
668 unsigned char ie_len;
672 struct setassocrspextraie_parm {
674 unsigned char ie_len;
678 struct addBaReq_parm {
682 /*H2C Handler index: 46 */
683 struct SetChannel_parm {
687 /*H2C Handler index: 61 */
688 struct DisconnectCtrlEx_param {
689 /* MAXTIME = (2 * FirstStageTO) + (TryPktCnt * TryPktInterval) */
690 unsigned char EnableDrvCtrl;
691 unsigned char TryPktCnt;
692 unsigned char TryPktInterval; /* Unit: ms */
694 unsigned int FirstStageTO; /* Unit: ms */
697 #define GEN_CMD_CODE(cmd) cmd ## _CMD_
702 * 0x01: success, and check Response.
703 * 0x02: cmd ignored due to duplicated sequence number
704 * 0x03: cmd dropped due to invalid cmd code
708 #define H2C_RSP_OFFSET 512
709 #define H2C_SUCCESS 0x00
710 #define H2C_SUCCESS_RSP 0x01
711 #define H2C_DUPLICATED 0x02
712 #define H2C_DROPPED 0x03
713 #define H2C_PARAMETERS_ERROR 0x04
714 #define H2C_REJECTED 0x05
715 #define H2C_CMD_OVERFLOW 0x06
716 #define H2C_RESERVED 0x07
718 void r8712_setMacAddr_cmd(struct _adapter *padapter, const u8 *mac_addr);
719 u8 r8712_sitesurvey_cmd(struct _adapter *padapter,
720 struct ndis_802_11_ssid *pssid);
721 int r8712_createbss_cmd(struct _adapter *padapter);
722 void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key);
723 int r8712_joinbss_cmd(struct _adapter *padapter,
724 struct wlan_network *pnetwork);
725 void r8712_disassoc_cmd(struct _adapter *padapter);
726 void r8712_setopmode_cmd(struct _adapter *padapter,
727 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype);
728 int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset);
729 void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan);
730 int r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval);
731 int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val);
732 void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid);
733 void r8712_wdg_wk_cmd(struct _adapter *padapter);
734 void r8712_survey_cmd_callback(struct _adapter *padapter,
735 struct cmd_obj *pcmd);
736 void r8712_disassoc_cmd_callback(struct _adapter *padapter,
737 struct cmd_obj *pcmd);
738 void r8712_joinbss_cmd_callback(struct _adapter *padapter,
739 struct cmd_obj *pcmd);
740 void r8712_createbss_cmd_callback(struct _adapter *padapter,
741 struct cmd_obj *pcmd);
742 void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter,
743 struct cmd_obj *pcmd);
744 void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter,
745 struct cmd_obj *pcmd);
746 void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter,
747 struct cmd_obj *pcmd);
748 void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter,
749 struct cmd_obj *pcmd);
750 void r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl,
751 u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO);
753 struct _cmd_callback {
755 void (*callback)(struct _adapter *padapter, struct cmd_obj *cmd);
758 #include "rtl8712_cmd.h"