blob: 08ca59217cb716bbf908e02c2a0b2d12a8c2f5e8 [file] [log] [blame]
Larry Finger475b922e2013-08-21 22:34:08 -05001/******************************************************************************
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 *
Larry Finger475b922e2013-08-21 22:34:08 -050014 ******************************************************************************/
15#ifndef __RTW_CMD_H_
16#define __RTW_CMD_H_
17
18#include <wlan_bssdef.h>
19#include <rtw_rf.h>
20#include <rtw_led.h>
21
Larry Finger475b922e2013-08-21 22:34:08 -050022#include <osdep_service.h>
23#include <ieee80211.h> /* <ieee80211/ieee80211.h> */
24
Larry Finger475b922e2013-08-21 22:34:08 -050025#define MAX_CMDSZ 1024
26#define MAX_RSPSZ 512
Larry Finger475b922e2013-08-21 22:34:08 -050027
28#define CMDBUFF_ALIGN_SZ 512
29
30struct cmd_obj {
31 struct adapter *padapter;
32 u16 cmdcode;
33 u8 res;
34 u8 *parmbuf;
35 u32 cmdsz;
36 u8 *rsp;
37 u32 rspsz;
38 struct list_head list;
39};
40
41struct cmd_priv {
42 struct semaphore cmd_queue_sema;
43 struct semaphore terminate_cmdthread_sema;
44 struct __queue cmd_queue;
Larry Finger475b922e2013-08-21 22:34:08 -050045 u8 cmdthd_running;
46 struct adapter *padapter;
47};
48
Larry Finger475b922e2013-08-21 22:34:08 -050049#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \
50do {\
navin patidaraa3f5cc2014-06-22 13:49:34 +053051 INIT_LIST_HEAD(&pcmd->list);\
Larry Finger475b922e2013-08-21 22:34:08 -050052 pcmd->cmdcode = code;\
53 pcmd->parmbuf = (u8 *)(pparm);\
54 pcmd->cmdsz = sizeof(*pparm);\
55 pcmd->rsp = NULL;\
56 pcmd->rspsz = 0;\
57} while (0)
58
Larry Finger475b922e2013-08-21 22:34:08 -050059u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj);
navin patidar4680f152014-07-10 09:11:59 +053060struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue);
Larry Finger475b922e2013-08-21 22:34:08 -050061void rtw_free_cmd_obj(struct cmd_obj *pcmd);
62
63int rtw_cmd_thread(void *context);
64
navin patidarb6d42302014-07-10 09:11:57 +053065int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv);
Larry Finger475b922e2013-08-21 22:34:08 -050066
Larry Finger475b922e2013-08-21 22:34:08 -050067enum rtw_drvextra_cmd_id {
68 NONE_WK_CID,
69 DYNAMIC_CHK_WK_CID,
70 DM_CTRL_WK_CID,
71 PBC_POLLING_WK_CID,
72 POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */
73 LPS_CTRL_WK_CID,
74 ANT_SELECT_WK_CID,
75 P2P_PS_WK_CID,
76 P2P_PROTO_WK_CID,
77 CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */
78 INTEl_WIDI_WK_CID,
79 C2H_WK_CID,
80 RTP_TIMER_CFG_WK_CID,
81 MAX_WK_CID
82};
83
84enum LPS_CTRL_TYPE {
85 LPS_CTRL_SCAN = 0,
86 LPS_CTRL_JOINBSS = 1,
87 LPS_CTRL_CONNECT = 2,
88 LPS_CTRL_DISCONNECT = 3,
89 LPS_CTRL_SPECIAL_PACKET = 4,
90 LPS_CTRL_LEAVE = 5,
91};
92
93enum RFINTFS {
94 SWSI,
95 HWSI,
96 HWPI,
97};
98
99/*
Larry Finger475b922e2013-08-21 22:34:08 -0500100Caller Mode: Infra, Ad-HoC(C)
101
102Notes: To disconnect the current associated BSS
103
104Command Mode
105
106*/
107struct disconnect_parm {
108 u32 deauth_timeout_ms;
109};
110
Larry Finger475b922e2013-08-21 22:34:08 -0500111struct setopmode_parm {
112 u8 mode;
113 u8 rsvd[3];
114};
115
116/*
117Caller Mode: AP, Ad-HoC, Infra
118
119Notes: To ask RTL8711 performing site-survey
120
121Command-Event Mode
122
123*/
124
125#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */
126#define RTW_CHANNEL_SCAN_AMOUNT (14+37)
127struct sitesurvey_parm {
128 int scan_mode; /* active: 1, passive: 0 */
129 u8 ssid_num;
130 u8 ch_num;
131 struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT];
132 struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT];
133};
134
135/*
136Caller Mode: Any
137
138Notes: To set the auth type of RTL8711. open/shared/802.1x
139
140Command Mode
141
142*/
143struct setauth_parm {
144 u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */
145 u8 _1x; /* 0: PSK, 1: TLS */
146 u8 rsvd[2];
147};
148
149/*
150Caller Mode: Infra
151
152a. algorithm: wep40, wep104, tkip & aes
153b. keytype: grp key/unicast key
154c. key contents
155
156when shared key ==> keyid is the camid
157when 802.1x ==> keyid [0:1] ==> grp key
158when 802.1x ==> keyid > 2 ==> unicast key
159
160*/
161struct setkey_parm {
162 u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */
163 u8 keyid;
164 u8 grpkey; /* 1: this is the grpkey for 802.1x.
165 * 0: this is the unicast key for 802.1x */
166 u8 set_tx; /* 1: main tx key for wep. 0: other key. */
167 u8 key[16]; /* this could be 40 or 104 */
168};
169
170/*
171When in AP or Ad-Hoc mode, this is used to
172allocate an sw/hw entry for a newly associated sta.
173
174Command
175
176when shared key ==> algorithm/keyid
177
178*/
179struct set_stakey_parm {
180 u8 addr[ETH_ALEN];
181 u8 algorithm;
182 u8 id;/* currently for erasing cam entry if
183 * algorithm == _NO_PRIVACY_ */
184 u8 key[16];
185};
186
187struct set_stakey_rsp {
188 u8 addr[ETH_ALEN];
189 u8 keyid;
190 u8 rsvd;
191};
192
193/*
194Caller Ad-Hoc/AP
195
196Command -Rsp(AID == CAMID) mode
197
198This is to force fw to add an sta_data entry per driver's request.
199
200FW will write an cam entry associated with it.
201
202*/
203struct set_assocsta_parm {
204 u8 addr[ETH_ALEN];
205};
206
207struct set_assocsta_rsp {
208 u8 cam_id;
209 u8 rsvd[3];
210};
211
212/*
213 Caller Ad-Hoc/AP
214
215 Command mode
216
217 This is to force fw to del an sta_data entry per driver's request
218
219 FW will invalidate the cam entry associated with it.
220
221*/
222struct del_assocsta_parm {
223 u8 addr[ETH_ALEN];
224};
225
226/*
227Caller Mode: AP/Ad-HoC(M)
228
229Notes: To notify fw that given staid has changed its power state
230
231Command Mode
232
233*/
234struct setstapwrstate_parm {
235 u8 staid;
236 u8 status;
237 u8 hwaddr[6];
238};
239
240/*
Larry Finger475b922e2013-08-21 22:34:08 -0500241 Notes: This command is used for H2C/C2H loopback testing
242
243 mac[0] == 0
244 ==> CMD mode, return H2C_SUCCESS.
245 The following condition must be ture under CMD mode
246 mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0;
247 s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7;
248 s2 == (b1 << 8 | b0);
249
250 mac[0] == 1
251 ==> CMD_RSP mode, return H2C_SUCCESS_RSP
252
253 The rsp layout shall be:
254 rsp: parm:
255 mac[0] = mac[5];
256 mac[1] = mac[4];
257 mac[2] = mac[3];
258 mac[3] = mac[2];
259 mac[4] = mac[1];
260 mac[5] = mac[0];
261 s0 = s1;
262 s1 = swap16(s0);
263 w0 = swap32(w1);
264 b0 = b1
265 s2 = s0 + s1
266 b1 = b0
267 w1 = w0
268
269 mac[0] == 2
270 ==> CMD_EVENT mode, return H2C_SUCCESS
271 The event layout shall be:
272 event: parm:
273 mac[0] = mac[5];
274 mac[1] = mac[4];
275 mac[2] = event's seq no, starting from 1 to parm's marc[3]
276 mac[3] = mac[2];
277 mac[4] = mac[1];
278 mac[5] = mac[0];
279 s0 = swap16(s0) - event.mac[2];
280 s1 = s1 + event.mac[2];
281 w0 = swap32(w0);
282 b0 = b1
283 s2 = s0 + event.mac[2]
284 b1 = b0
285 w1 = swap32(w1) - event.mac[2];
286
287 parm->mac[3] is the total event counts that host requested.
288 event will be the same with the cmd's param.
289*/
290
291/* CMD param Format for driver extra cmd handler */
292struct drvextra_cmd_parm {
293 int ec_id; /* extra cmd id */
294 int type_size; /* Can use this field as the type id or command size */
295 unsigned char *pbuf;
296};
297
Larry Finger475b922e2013-08-21 22:34:08 -0500298struct addBaReq_parm {
299 unsigned int tid;
300 u8 addr[ETH_ALEN];
301};
302
303/*H2C Handler index: 46 */
304struct set_ch_parm {
305 u8 ch;
306 u8 bw;
307 u8 ch_offset;
308};
309
310/*H2C Handler index: 59 */
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100311struct SetChannelPlan_param {
Larry Finger475b922e2013-08-21 22:34:08 -0500312 u8 channel_plan;
313};
314
Larry Finger475b922e2013-08-21 22:34:08 -0500315#define GEN_CMD_CODE(cmd) cmd ## _CMD_
316
317/*
318
319Result:
3200x00: success
Masanari Iidaf7bba922013-09-27 00:11:43 +09003210x01: success, and check Response.
Larry Finger475b922e2013-08-21 22:34:08 -05003220x02: cmd ignored due to duplicated sequcne number
3230x03: cmd dropped due to invalid cmd code
3240x04: reserved.
325
326*/
327
Larry Finger475b922e2013-08-21 22:34:08 -0500328#define H2C_SUCCESS 0x00
329#define H2C_SUCCESS_RSP 0x01
Larry Finger475b922e2013-08-21 22:34:08 -0500330#define H2C_DROPPED 0x03
331#define H2C_PARAMETERS_ERROR 0x04
332#define H2C_REJECTED 0x05
Larry Finger475b922e2013-08-21 22:34:08 -0500333
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100334u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid,
Larry Finger475b922e2013-08-21 22:34:08 -0500335 int ssid_num, struct rtw_ieee80211_channel *ch,
336 int ch_num);
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100337u8 rtw_createbss_cmd(struct adapter *padapter);
Larry Finger475b922e2013-08-21 22:34:08 -0500338u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key);
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100339u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry,
340 u8 enqueue);
341u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork);
342u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms,
343 bool enqueue);
344u8 rtw_setopmode_cmd(struct adapter *padapter,
345 enum ndis_802_11_network_infra networktype);
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100346u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr);
Larry Finger475b922e2013-08-21 22:34:08 -0500347
348u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter);
349
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100350u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue);
351u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime);
Larry Finger475b922e2013-08-21 22:34:08 -0500352
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100353u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue);
354u8 rtw_ps_cmd(struct adapter *padapter);
Larry Finger475b922e2013-08-21 22:34:08 -0500355
356#ifdef CONFIG_88EU_AP_MODE
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100357u8 rtw_chk_hi_queue_cmd(struct adapter *padapter);
Larry Finger475b922e2013-08-21 22:34:08 -0500358#endif
359
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100360u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue);
Larry Finger475b922e2013-08-21 22:34:08 -0500361u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf);
362
363void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
364void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
365void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd);
366void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd);
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100367void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
Larry Finger475b922e2013-08-21 22:34:08 -0500368
369void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
370void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm);
371void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd);
372
373struct _cmd_callback {
374 u32 cmd_code;
375 void (*callback)(struct adapter *padapter, struct cmd_obj *cmd);
376};
377
378enum rtw_h2c_cmd {
navin patidar7c8b4f42014-07-10 09:12:07 +0530379 GEN_CMD_CODE(_JoinBss),
380 GEN_CMD_CODE(_DisConnect),
Larry Finger475b922e2013-08-21 22:34:08 -0500381 GEN_CMD_CODE(_CreateBss),
382 GEN_CMD_CODE(_SetOpMode),
navin patidar7c8b4f42014-07-10 09:12:07 +0530383 GEN_CMD_CODE(_SiteSurvey),
Larry Finger475b922e2013-08-21 22:34:08 -0500384 GEN_CMD_CODE(_SetAuth),
navin patidar7c8b4f42014-07-10 09:12:07 +0530385 GEN_CMD_CODE(_SetKey),
Larry Finger475b922e2013-08-21 22:34:08 -0500386 GEN_CMD_CODE(_SetStaKey),
387 GEN_CMD_CODE(_SetAssocSta),
navin patidar7c8b4f42014-07-10 09:12:07 +0530388 GEN_CMD_CODE(_AddBAReq),
389 GEN_CMD_CODE(_SetChannel),
390 GEN_CMD_CODE(_TX_Beacon),
391 GEN_CMD_CODE(_Set_MLME_EVT),
392 GEN_CMD_CODE(_Set_Drv_Extra),
navin patidar7c8b4f42014-07-10 09:12:07 +0530393 GEN_CMD_CODE(_SetChannelPlan),
Larry Finger475b922e2013-08-21 22:34:08 -0500394
395 MAX_H2CCMD
396};
397
Larry Finger475b922e2013-08-21 22:34:08 -0500398#ifdef _RTW_CMD_C_
Matthias Wirthf8d8f6f2013-12-16 18:51:48 +0100399static struct _cmd_callback rtw_cmd_callback[] = {
navin patidar7c8b4f42014-07-10 09:12:07 +0530400 {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback},
401 {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback},
Larry Finger475b922e2013-08-21 22:34:08 -0500402 {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback},
403 {GEN_CMD_CODE(_SetOpMode), NULL},
navin patidar7c8b4f42014-07-10 09:12:07 +0530404 {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback},
Larry Finger475b922e2013-08-21 22:34:08 -0500405 {GEN_CMD_CODE(_SetAuth), NULL},
navin patidar7c8b4f42014-07-10 09:12:07 +0530406 {GEN_CMD_CODE(_SetKey), NULL},
Larry Finger475b922e2013-08-21 22:34:08 -0500407 {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback},
408 {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback},
navin patidar7c8b4f42014-07-10 09:12:07 +0530409 {GEN_CMD_CODE(_AddBAReq), NULL},
410 {GEN_CMD_CODE(_SetChannel), NULL},
411 {GEN_CMD_CODE(_TX_Beacon), NULL},
412 {GEN_CMD_CODE(_Set_MLME_EVT), NULL},
413 {GEN_CMD_CODE(_Set_Drv_Extra), NULL},
navin patidar7c8b4f42014-07-10 09:12:07 +0530414 {GEN_CMD_CODE(_SetChannelPlan), NULL},
Larry Finger475b922e2013-08-21 22:34:08 -0500415};
416#endif
417
418#endif /* _CMD_H_ */