blob: ea83faa15c7ec27e4f11ec7d22ad73c0cf487d99 [file] [log] [blame]
Fariya Fatimadad0d042014-03-16 03:47:02 +05301/**
2 * Copyright (c) 2014 Redpine Signals Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef __RSI_MGMT_H__
18#define __RSI_MGMT_H__
19
20#include <linux/sort.h>
21#include "rsi_boot_params.h"
22#include "rsi_main.h"
23
24#define MAX_MGMT_PKT_SIZE 512
Amol Hanwateabbe87d2018-07-16 19:09:35 +053025#define RSI_NEEDED_HEADROOM 84
Fariya Fatimadad0d042014-03-16 03:47:02 +053026#define RSI_RCV_BUFFER_LEN 2000
27
28#define RSI_11B_MODE 0
29#define RSI_11G_MODE BIT(7)
30#define RETRY_COUNT 8
31#define RETRY_LONG 4
32#define RETRY_SHORT 7
33#define WMM_SHORT_SLOT_TIME 9
34#define SIFS_DURATION 16
35
Prameela Rani Garnepudi4fd6c472018-03-29 19:44:52 +053036#define EAPOL4_PACKET_LEN 0x85
Fariya Fatimadad0d042014-03-16 03:47:02 +053037#define KEY_TYPE_CLEAR 0
38#define RSI_PAIRWISE_KEY 1
39#define RSI_GROUP_KEY 2
40
41/* EPPROM_READ_ADDRESS */
42#define WLAN_MAC_EEPROM_ADDR 40
43#define WLAN_MAC_MAGIC_WORD_LEN 0x01
44#define WLAN_HOST_MODE_LEN 0x04
45#define WLAN_FW_VERSION_LEN 0x08
46#define MAGIC_WORD 0x5A
Prameela Rani Garnepudi09cfb412017-07-06 20:07:05 +053047#define WLAN_EEPROM_RFTYPE_ADDR 424
Fariya Fatimadad0d042014-03-16 03:47:02 +053048
Karun Eagalapatif3ac4e72017-10-27 16:55:55 +053049/*WOWLAN RESUME WAKEUP TYPES*/
50#define RSI_UNICAST_MAGIC_PKT BIT(0)
51#define RSI_BROADCAST_MAGICPKT BIT(1)
52#define RSI_EAPOL_PKT BIT(2)
53#define RSI_DISCONNECT_PKT BIT(3)
54#define RSI_HW_BMISS_PKT BIT(4)
55#define RSI_INSERT_SEQ_IN_FW BIT(2)
56
57#define WOW_MAX_FILTERS_PER_LIST 16
58#define WOW_PATTERN_SIZE 256
59
Fariya Fatimadad0d042014-03-16 03:47:02 +053060/* Receive Frame Types */
Prameela Rani Garnepudi2108df32018-02-27 19:56:14 +053061#define RSI_RX_DESC_MSG_TYPE_OFFSET 2
Fariya Fatimadad0d042014-03-16 03:47:02 +053062#define TA_CONFIRM_TYPE 0x01
63#define RX_DOT11_MGMT 0x02
64#define TX_STATUS_IND 0x04
Prameela Rani Garnepudid26a9552017-08-16 18:43:11 +053065#define BEACON_EVENT_IND 0x08
Prameela Rani Garnepudi4fd6c472018-03-29 19:44:52 +053066#define EAPOL4_CONFIRM 1
Fariya Fatimadad0d042014-03-16 03:47:02 +053067#define PROBEREQ_CONFIRM 2
68#define CARD_READY_IND 0x00
Prameela Rani Garnepudi2108df32018-02-27 19:56:14 +053069#define SLEEP_NOTIFY_IND 0x06
Prameela Rani Garnepudi4fd6c472018-03-29 19:44:52 +053070#define RSI_TX_STATUS_TYPE 15
71#define RSI_TX_STATUS 12
Fariya Fatimadad0d042014-03-16 03:47:02 +053072
73#define RSI_DELETE_PEER 0x0
74#define RSI_ADD_PEER 0x1
75#define START_AMPDU_AGGR 0x1
76#define STOP_AMPDU_AGGR 0x0
77#define INTERNAL_MGMT_PKT 0x99
78
79#define PUT_BBP_RESET 0
80#define BBP_REG_WRITE 0
81#define RF_RESET_ENABLE BIT(3)
82#define RATE_INFO_ENABLE BIT(0)
Prameela Rani Garnepudi19844c02017-08-16 18:43:14 +053083#define MORE_DATA_PRESENT BIT(1)
Fariya Fatimadad0d042014-03-16 03:47:02 +053084#define RSI_BROADCAST_PKT BIT(9)
Prameela Rani Garnepudi6507de62017-07-06 20:07:16 +053085#define RSI_DESC_REQUIRE_CFM_TO_HOST BIT(2)
Pavani Muthyala0eb42582017-07-06 20:07:18 +053086#define RSI_ADD_DELTA_TSF_VAP_ID BIT(3)
87#define RSI_FETCH_RETRY_CNT_FRM_HST BIT(4)
Pavani Muthyalaaf193092017-07-06 20:07:17 +053088#define RSI_QOS_ENABLE BIT(12)
Pavani Muthyala0eb42582017-07-06 20:07:18 +053089#define RSI_REKEY_PURPOSE BIT(13)
Pavani Muthyalaaf193092017-07-06 20:07:17 +053090#define RSI_ENCRYPT_PKT BIT(15)
Karun Eagalapatice868932017-08-03 19:58:59 +053091#define RSI_SET_PS_ENABLE BIT(12)
Fariya Fatimadad0d042014-03-16 03:47:02 +053092
Prameela Rani Garnepudi6abdf2c2017-07-10 18:10:34 +053093#define RSI_CMDDESC_40MHZ BIT(4)
94#define RSI_CMDDESC_UPPER_20_ENABLE BIT(5)
95#define RSI_CMDDESC_LOWER_20_ENABLE BIT(6)
96#define RSI_CMDDESC_FULL_40_ENABLE (BIT(5) | BIT(6))
Fariya Fatimadad0d042014-03-16 03:47:02 +053097#define UPPER_20_ENABLE (0x2 << 12)
98#define LOWER_20_ENABLE (0x4 << 12)
99#define FULL40M_ENABLE 0x6
100
101#define RSI_LMAC_CLOCK_80MHZ 0x1
102#define RSI_ENABLE_40MHZ (0x1 << 3)
Jahnavi Meher2bfa6962014-06-16 19:43:54 +0530103#define ENABLE_SHORTGI_RATE BIT(9)
Fariya Fatimadad0d042014-03-16 03:47:02 +0530104
105#define RX_BA_INDICATION 1
106#define RSI_TBL_SZ 40
107#define MAX_RETRIES 8
Jahnavi Meher48d11dc2014-04-29 01:03:53 +0530108#define RSI_IFTYPE_STATION 0
Fariya Fatimadad0d042014-03-16 03:47:02 +0530109
110#define STD_RATE_MCS7 0x07
111#define STD_RATE_MCS6 0x06
112#define STD_RATE_MCS5 0x05
113#define STD_RATE_MCS4 0x04
114#define STD_RATE_MCS3 0x03
115#define STD_RATE_MCS2 0x02
116#define STD_RATE_MCS1 0x01
117#define STD_RATE_MCS0 0x00
118#define STD_RATE_54 0x6c
119#define STD_RATE_48 0x60
120#define STD_RATE_36 0x48
121#define STD_RATE_24 0x30
122#define STD_RATE_18 0x24
123#define STD_RATE_12 0x18
124#define STD_RATE_11 0x16
125#define STD_RATE_09 0x12
126#define STD_RATE_06 0x0C
127#define STD_RATE_5_5 0x0B
128#define STD_RATE_02 0x04
129#define STD_RATE_01 0x02
130
131#define RSI_RF_TYPE 1
132#define RSI_RATE_00 0x00
133#define RSI_RATE_1 0x0
134#define RSI_RATE_2 0x2
135#define RSI_RATE_5_5 0x4
136#define RSI_RATE_11 0x6
137#define RSI_RATE_6 0x8b
138#define RSI_RATE_9 0x8f
139#define RSI_RATE_12 0x8a
140#define RSI_RATE_18 0x8e
141#define RSI_RATE_24 0x89
142#define RSI_RATE_36 0x8d
143#define RSI_RATE_48 0x88
144#define RSI_RATE_54 0x8c
145#define RSI_RATE_MCS0 0x100
146#define RSI_RATE_MCS1 0x101
147#define RSI_RATE_MCS2 0x102
148#define RSI_RATE_MCS3 0x103
149#define RSI_RATE_MCS4 0x104
150#define RSI_RATE_MCS5 0x105
151#define RSI_RATE_MCS6 0x106
152#define RSI_RATE_MCS7 0x107
153#define RSI_RATE_MCS7_SG 0x307
Pavani Muthyalaaf193092017-07-06 20:07:17 +0530154#define RSI_RATE_AUTO 0xffff
Fariya Fatimadad0d042014-03-16 03:47:02 +0530155
156#define BW_20MHZ 0
157#define BW_40MHZ 1
158
Jahnavi Meherf870a342014-06-16 19:41:22 +0530159#define EP_2GHZ_20MHZ 0
160#define EP_2GHZ_40MHZ 1
161#define EP_5GHZ_20MHZ 2
162#define EP_5GHZ_40MHZ 3
163
Jahnavi Meher4550faa2014-06-16 19:41:41 +0530164#define SIFS_TX_11N_VALUE 580
165#define SIFS_TX_11B_VALUE 346
166#define SHORT_SLOT_VALUE 360
167#define LONG_SLOT_VALUE 640
168#define OFDM_ACK_TOUT_VALUE 2720
169#define CCK_ACK_TOUT_VALUE 9440
170#define LONG_PREAMBLE 0x0000
171#define SHORT_PREAMBLE 0x0001
172
Fariya Fatimadad0d042014-03-16 03:47:02 +0530173#define RSI_SUPP_FILTERS (FIF_ALLMULTI | FIF_PROBE_REQ |\
174 FIF_BCN_PRBRESP_PROMISC)
Prameela Rani Garnepudie6d64282016-11-18 16:07:09 +0530175
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530176#define ANTENNA_SEL_INT 0x02 /* RF_OUT_2 / Integerated */
177#define ANTENNA_SEL_UFL 0x03 /* RF_OUT_1 / U.FL */
Pavani Muthyala588349a2017-08-03 19:58:58 +0530178#define ANTENNA_MASK_VALUE 0x00ff
179#define ANTENNA_SEL_TYPE 1
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530180
Prameela Rani Garnepudie6d64282016-11-18 16:07:09 +0530181/* Rx filter word definitions */
182#define PROMISCOUS_MODE BIT(0)
183#define ALLOW_DATA_ASSOC_PEER BIT(1)
184#define ALLOW_MGMT_ASSOC_PEER BIT(2)
185#define ALLOW_CTRL_ASSOC_PEER BIT(3)
186#define DISALLOW_BEACONS BIT(4)
187#define ALLOW_CONN_PEER_MGMT_WHILE_BUF_FULL BIT(5)
188#define DISALLOW_BROADCAST_DATA BIT(6)
189
Prameela Rani Garnepudi59e006d2017-07-10 18:10:36 +0530190#define RSI_MPDU_DENSITY 0x8
Prameela Rani Garnepudif04854f2017-07-10 18:10:39 +0530191#define RSI_CHAN_RADAR BIT(7)
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530192#define RSI_BEACON_INTERVAL 200
193#define RSI_DTIM_COUNT 2
Prameela Rani Garnepudi59e006d2017-07-10 18:10:36 +0530194
Karun Eagalapatice868932017-08-03 19:58:59 +0530195#define RSI_PS_DISABLE_IND BIT(15)
196#define RSI_PS_ENABLE 1
197#define RSI_PS_DISABLE 0
198#define RSI_DEEP_SLEEP 1
199#define RSI_CONNECTED_SLEEP 2
200#define RSI_SLEEP_REQUEST 1
201#define RSI_WAKEUP_REQUEST 2
202
Karun Eagalapatidb079712017-08-03 19:59:00 +0530203#define RSI_IEEE80211_UAPSD_QUEUES \
204 (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO | \
205 IEEE80211_WMM_IE_STA_QOSINFO_AC_VI | \
206 IEEE80211_WMM_IE_STA_QOSINFO_AC_BE | \
207 IEEE80211_WMM_IE_STA_QOSINFO_AC_BK)
208
Arnd Bergmanna39644b2017-10-05 14:05:24 +0200209#define RSI_DESC_VAP_ID_MASK 0xC000u
Prameela Rani Garnepudi4671c2092017-08-30 15:08:24 +0530210#define RSI_DESC_VAP_ID_OFST 14
Prameela Rani Garnepudid26a9552017-08-16 18:43:11 +0530211#define RSI_DATA_DESC_MAC_BBP_INFO BIT(0)
212#define RSI_DATA_DESC_NO_ACK_IND BIT(9)
213#define RSI_DATA_DESC_QOS_EN BIT(12)
214#define RSI_DATA_DESC_NORMAL_FRAME 0x00
215#define RSI_DATA_DESC_DTIM_BEACON_GATED_FRAME BIT(10)
216#define RSI_DATA_DESC_BEACON_FRAME BIT(11)
217#define RSI_DATA_DESC_DTIM_BEACON (BIT(10) | BIT(11))
218#define RSI_DATA_DESC_INSERT_TSF BIT(15)
219#define RSI_DATA_DESC_INSERT_SEQ_NO BIT(2)
220
Karun Eagalapatif3ac4e72017-10-27 16:55:55 +0530221#ifdef CONFIG_PM
222#define RSI_WOW_ANY BIT(1)
223#define RSI_WOW_GTK_REKEY BIT(3)
224#define RSI_WOW_MAGIC_PKT BIT(4)
225#define RSI_WOW_DISCONNECT BIT(5)
226#endif
227
Amitkumar Karwara55e50f2018-04-10 20:34:14 +0530228#define RSI_MAX_TX_AGGR_FRMS 8
229#define RSI_MAX_RX_AGGR_FRMS 8
230
Prameela Rani Garnepudi7fdcb8e2018-12-27 14:56:18 +0530231#define RSI_MAX_SCAN_SSIDS 16
232#define RSI_MAX_SCAN_IE_LEN 256
233
Fariya Fatimadad0d042014-03-16 03:47:02 +0530234enum opmode {
Prameela Rani Garnepudib8bd3a42017-08-30 15:08:22 +0530235 RSI_OPMODE_UNSUPPORTED = -1,
236 RSI_OPMODE_AP = 0,
237 RSI_OPMODE_STA,
238 RSI_OPMODE_P2P_GO,
239 RSI_OPMODE_P2P_CLIENT
Fariya Fatimadad0d042014-03-16 03:47:02 +0530240};
241
Prameela Rani Garnepudi77364aa2016-10-13 16:56:45 +0530242enum vap_status {
243 VAP_ADD = 1,
244 VAP_DELETE = 2,
245 VAP_UPDATE = 3
246};
247
Prameela Rani Garnepudi35286082017-08-16 18:43:12 +0530248enum peer_type {
249 PEER_TYPE_AP,
250 PEER_TYPE_STA,
251};
Fariya Fatimadad0d042014-03-16 03:47:02 +0530252extern struct ieee80211_rate rsi_rates[12];
253extern const u16 rsi_mcsrates[8];
254
255enum sta_notify_events {
256 STA_CONNECTED = 0,
257 STA_DISCONNECTED,
258 STA_TX_ADDBA_DONE,
259 STA_TX_DELBA,
260 STA_RX_ADDBA_DONE,
261 STA_RX_DELBA
262};
263
264/* Send Frames Types */
265enum cmd_frame_type {
266 TX_DOT11_MGMT,
267 RESET_MAC_REQ,
268 RADIO_CAPABILITIES,
269 BB_PROG_VALUES_REQUEST,
270 RF_PROG_VALUES_REQUEST,
271 WAKEUP_SLEEP_REQUEST,
272 SCAN_REQUEST,
273 TSF_UPDATE,
274 PEER_NOTIFY,
Jahnavi Meher686a2542014-06-16 19:46:48 +0530275 BLOCK_HW_QUEUE,
Fariya Fatimadad0d042014-03-16 03:47:02 +0530276 SET_KEY_REQ,
277 AUTO_RATE_IND,
278 BOOTUP_PARAMS_REQUEST,
279 VAP_CAPABILITIES,
Prameela Rani Garnepudi09cfb412017-07-06 20:07:05 +0530280 EEPROM_READ,
Fariya Fatimadad0d042014-03-16 03:47:02 +0530281 EEPROM_WRITE,
282 GPIO_PIN_CONFIG ,
283 SET_RX_FILTER,
284 AMPDU_IND,
285 STATS_REQUEST_FRAME,
286 BB_BUF_PROG_VALUES_REQ,
287 BBP_PROG_IN_TA,
288 BG_SCAN_PARAMS,
289 BG_SCAN_PROBE_REQ,
290 CW_MODE_REQ,
Prameela Rani Garnepudi8b36de82016-11-18 16:08:04 +0530291 PER_CMD_PKT,
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530292 ANT_SEL_FRAME = 0x20,
Karun Eagalapati80a88ec2017-08-03 19:59:04 +0530293 VAP_DYNAMIC_UPDATE = 0x27,
Prameela Rani Garnepudi99203222017-06-16 20:12:05 +0530294 COMMON_DEV_CONFIG = 0x28,
Karun Eagalapatif3ac4e72017-10-27 16:55:55 +0530295 RADIO_PARAMS_UPDATE = 0x29,
296 WOWLAN_CONFIG_PARAMS = 0x2B,
297 WOWLAN_WAKEUP_REASON = 0xc5
Fariya Fatimadad0d042014-03-16 03:47:02 +0530298};
299
300struct rsi_mac_frame {
301 __le16 desc_word[8];
302} __packed;
303
Prameela Rani Garnepudi6c8ab762017-07-10 18:10:32 +0530304#define PWR_SAVE_WAKEUP_IND BIT(0)
305#define TCP_CHECK_SUM_OFFLOAD BIT(1)
306#define CONFIRM_REQUIRED_TO_HOST BIT(2)
307#define ADD_DELTA_TSF BIT(3)
308#define FETCH_RETRY_CNT_FROM_HOST_DESC BIT(4)
309#define EOSP_INDICATION BIT(5)
310#define REQUIRE_TSF_SYNC_CONFIRM BIT(6)
311#define ENCAP_MGMT_PKT BIT(7)
Prameela Rani Garnepudi9a629fa2017-07-10 18:10:33 +0530312#define DESC_IMMEDIATE_WAKEUP BIT(15)
Prameela Rani Garnepudi6c8ab762017-07-10 18:10:32 +0530313
Prameela Rani Garnepudi5dc36382018-03-29 19:44:49 +0530314struct rsi_xtended_desc {
315 u8 confirm_frame_type;
316 u8 retry_cnt;
317 u16 reserved;
318};
319
Prameela Rani Garnepudi6c8ab762017-07-10 18:10:32 +0530320struct rsi_cmd_desc_dword0 {
321 __le16 len_qno;
322 u8 frame_type;
323 u8 misc_flags;
324};
325
326struct rsi_cmd_desc_dword1 {
327 u8 xtend_desc_size;
328 u8 reserved1;
329 __le16 reserved2;
330};
331
332struct rsi_cmd_desc_dword2 {
333 __le32 pkt_info; /* Packet specific data */
334};
335
336struct rsi_cmd_desc_dword3 {
337 __le16 token;
338 u8 qid_tid;
339 u8 sta_id;
340};
341
342struct rsi_cmd_desc {
343 struct rsi_cmd_desc_dword0 desc_dword0;
344 struct rsi_cmd_desc_dword1 desc_dword1;
345 struct rsi_cmd_desc_dword2 desc_dword2;
346 struct rsi_cmd_desc_dword3 desc_dword3;
347};
348
Fariya Fatimadad0d042014-03-16 03:47:02 +0530349struct rsi_boot_params {
350 __le16 desc_word[8];
351 struct bootup_params bootup_params;
352} __packed;
353
354struct rsi_peer_notify {
Prameela Rani Garnepudi59e006d2017-07-10 18:10:36 +0530355 struct rsi_cmd_desc desc;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530356 u8 mac_addr[6];
357 __le16 command;
358 __le16 mpdu_density;
359 __le16 reserved;
360 __le32 sta_flags;
361} __packed;
362
Prameela Rani Garnepudi3a9828c2017-07-10 18:10:37 +0530363/* Aggregation params flags */
364#define RSI_AGGR_PARAMS_TID_MASK 0xf
365#define RSI_AGGR_PARAMS_START BIT(4)
366#define RSI_AGGR_PARAMS_RX_AGGR BIT(5)
367struct rsi_aggr_params {
368 struct rsi_cmd_desc_dword0 desc_dword0;
369 struct rsi_cmd_desc_dword0 desc_dword1;
370 __le16 seq_start;
371 __le16 baw_size;
372 __le16 token;
373 u8 aggr_params;
374 u8 peer_id;
375} __packed;
376
Prameela Rani Garnepudi5c7ca1b2017-07-10 18:10:38 +0530377struct rsi_bb_rf_prog {
378 struct rsi_cmd_desc_dword0 desc_dword0;
379 __le16 reserved1;
380 u8 rf_power_mode;
381 u8 reserved2;
382 u8 endpoint;
383 u8 reserved3;
384 __le16 reserved4;
385 __le16 reserved5;
386 __le16 flags;
387} __packed;
388
Prameela Rani Garnepudif04854f2017-07-10 18:10:39 +0530389struct rsi_chan_config {
390 struct rsi_cmd_desc_dword0 desc_dword0;
391 struct rsi_cmd_desc_dword1 desc_dword1;
392 u8 channel_number;
393 u8 antenna_gain_offset_2g;
394 u8 antenna_gain_offset_5g;
395 u8 channel_width;
396 __le16 tx_power;
397 u8 region_rftype;
398 u8 flags;
399} __packed;
400
Fariya Fatimadad0d042014-03-16 03:47:02 +0530401struct rsi_vap_caps {
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530402 struct rsi_cmd_desc_dword0 desc_dword0;
403 u8 reserved1;
404 u8 status;
405 __le16 reserved2;
406 u8 vif_type;
407 u8 channel_bw;
408 __le16 antenna_info;
Prameela Rani Garnepudib8bd3a42017-08-30 15:08:22 +0530409 __le16 token;
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530410 u8 radioid_macid;
411 u8 vap_id;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530412 u8 mac_addr[6];
413 __le16 keep_alive_period;
414 u8 bssid[6];
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530415 __le16 reserved4;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530416 __le32 flags;
417 __le16 frag_threshold;
418 __le16 rts_threshold;
419 __le32 default_mgmt_rate;
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530420 __le16 default_ctrl_rate;
421 __le16 ctrl_rate_flags;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530422 __le32 default_data_rate;
423 __le16 beacon_interval;
424 __le16 dtim_period;
Prameela Rani Garnepudide1d1812017-07-10 18:10:40 +0530425 __le16 beacon_miss_threshold;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530426} __packed;
427
Pavani Muthyala588349a2017-08-03 19:58:58 +0530428struct rsi_ant_sel_frame {
429 struct rsi_cmd_desc_dword0 desc_dword0;
430 u8 reserved;
431 u8 sub_frame_type;
432 __le16 ant_value;
433 __le32 reserved1;
434 __le32 reserved2;
435} __packed;
436
Karun Eagalapati80a88ec2017-08-03 19:59:04 +0530437struct rsi_dynamic_s {
438 struct rsi_cmd_desc_dword0 desc_dword0;
439 struct rsi_cmd_desc_dword1 desc_dword1;
440 struct rsi_cmd_desc_dword2 desc_dword2;
441 struct rsi_cmd_desc_dword3 desc_dword3;
442 struct framebody {
443 __le16 data_rate;
444 __le16 mgmt_rate;
445 __le16 keep_alive_period;
446 } frame_body;
447} __packed;
448
Prameela Rani Garnepudia84faab2017-07-10 18:10:41 +0530449/* Key descriptor flags */
450#define RSI_KEY_TYPE_BROADCAST BIT(1)
451#define RSI_WEP_KEY BIT(2)
452#define RSI_WEP_KEY_104 BIT(3)
453#define RSI_CIPHER_WPA BIT(4)
454#define RSI_CIPHER_TKIP BIT(5)
Prameela Rani Garnepudi38ef6232017-08-16 18:43:18 +0530455#define RSI_KEY_MODE_AP BIT(7)
Prameela Rani Garnepudia84faab2017-07-10 18:10:41 +0530456#define RSI_PROTECT_DATA_FRAMES BIT(13)
457#define RSI_KEY_ID_MASK 0xC0
458#define RSI_KEY_ID_OFFSET 14
Fariya Fatimadad0d042014-03-16 03:47:02 +0530459struct rsi_set_key {
Prameela Rani Garnepudia84faab2017-07-10 18:10:41 +0530460 struct rsi_cmd_desc_dword0 desc_dword0;
461 struct rsi_cmd_desc_dword1 desc_dword1;
462 __le16 key_desc;
463 __le32 bpn;
464 u8 sta_id;
465 u8 vap_id;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530466 u8 key[4][32];
467 u8 tx_mic_key[8];
468 u8 rx_mic_key[8];
469} __packed;
470
471struct rsi_auto_rate {
Prameela Rani Garnepudi6572f052017-08-16 18:43:15 +0530472 struct rsi_cmd_desc desc;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530473 __le16 failure_limit;
474 __le16 initial_boundary;
475 __le16 max_threshold_limt;
476 __le16 num_supported_rates;
477 __le16 aarf_rssi;
478 __le16 moderate_rate_inx;
479 __le16 collision_tolerance;
480 __le16 supported_rates[40];
481} __packed;
482
Prameela Rani Garnepudi79e590d2017-07-10 18:10:45 +0530483#define QUIET_INFO_VALID BIT(0)
484#define QUIET_ENABLE BIT(1)
485struct rsi_block_unblock_data {
486 struct rsi_cmd_desc_dword0 desc_dword0;
487 u8 xtend_desc_size;
488 u8 host_quiet_info;
489 __le16 reserved;
490 __le16 block_q_bitmap;
491 __le16 unblock_q_bitmap;
492 __le16 token;
493 __le16 flush_q_bitmap;
494} __packed;
495
Fariya Fatimadad0d042014-03-16 03:47:02 +0530496struct qos_params {
497 __le16 cont_win_min_q;
498 __le16 cont_win_max_q;
499 __le16 aifsn_val_q;
500 __le16 txop_q;
501} __packed;
502
503struct rsi_radio_caps {
Prameela Rani Garnepudi6abdf2c2017-07-10 18:10:34 +0530504 struct rsi_cmd_desc_dword0 desc_dword0;
505 struct rsi_cmd_desc_dword0 desc_dword1;
506 u8 channel_num;
507 u8 rf_model;
508 __le16 ppe_ack_rate;
509 __le16 mode_11j;
510 u8 radio_cfg_info;
511 u8 radio_info;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530512 struct qos_params qos_params[MAX_HW_QUEUES];
513 u8 num_11n_rates;
514 u8 num_11ac_rates;
515 __le16 gcpd_per_rate[20];
Jahnavi Meher4550faa2014-06-16 19:41:41 +0530516 __le16 sifs_tx_11n;
517 __le16 sifs_tx_11b;
518 __le16 slot_rx_11n;
519 __le16 ofdm_ack_tout;
520 __le16 cck_ack_tout;
521 __le16 preamble_type;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530522} __packed;
523
Prameela Rani Garnepudi99203222017-06-16 20:12:05 +0530524/* ULP GPIO flags */
525#define RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP BIT(0)
526#define RSI_GPIO_SLEEP_IND_FROM_DEVICE BIT(1)
527#define RSI_GPIO_2_ULP BIT(2)
528#define RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP BIT(3)
529
530/* SOC GPIO flags */
531#define RSI_GPIO_0_PSPI_CSN_0 BIT(0)
532#define RSI_GPIO_1_PSPI_CSN_1 BIT(1)
533#define RSI_GPIO_2_HOST_WAKEUP_INTR BIT(2)
534#define RSI_GPIO_3_PSPI_DATA_0 BIT(3)
535#define RSI_GPIO_4_PSPI_DATA_1 BIT(4)
536#define RSI_GPIO_5_PSPI_DATA_2 BIT(5)
537#define RSI_GPIO_6_PSPI_DATA_3 BIT(6)
538#define RSI_GPIO_7_I2C_SCL BIT(7)
539#define RSI_GPIO_8_I2C_SDA BIT(8)
540#define RSI_GPIO_9_UART1_RX BIT(9)
541#define RSI_GPIO_10_UART1_TX BIT(10)
542#define RSI_GPIO_11_UART1_RTS_I2S_CLK BIT(11)
543#define RSI_GPIO_12_UART1_CTS_I2S_WS BIT(12)
544#define RSI_GPIO_13_DBG_UART_RX_I2S_DIN BIT(13)
545#define RSI_GPIO_14_DBG_UART_RX_I2S_DOUT BIT(14)
546#define RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS BIT(15)
547#define RSI_GPIO_16_LED_0 BIT(16)
548#define RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL BIT(17)
549#define RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL BIT(18)
550#define RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF BIT(19)
551#define RSI_GPIO_20_RF_RESET BIT(20)
552#define RSI_GPIO_21_SLEEP_IND_FROM_DEVICE BIT(21)
553
554#define RSI_UNUSED_SOC_GPIO_BITMAP (RSI_GPIO_9_UART1_RX | \
555 RSI_GPIO_10_UART1_TX | \
556 RSI_GPIO_11_UART1_RTS_I2S_CLK | \
557 RSI_GPIO_12_UART1_CTS_I2S_WS | \
558 RSI_GPIO_13_DBG_UART_RX_I2S_DIN | \
559 RSI_GPIO_14_DBG_UART_RX_I2S_DOUT | \
560 RSI_GPIO_15_LP_WAKEUP_BOOT_BYPASS | \
561 RSI_GPIO_17_BTCOEX_WLAN_ACT_EXT_ANT_SEL | \
562 RSI_GPIO_18_BTCOEX_BT_PRIO_EXT_ANT_SEL | \
563 RSI_GPIO_19_BTCOEX_BT_ACT_EXT_ON_OFF | \
564 RSI_GPIO_21_SLEEP_IND_FROM_DEVICE)
565
566#define RSI_UNUSED_ULP_GPIO_BITMAP (RSI_GPIO_MOTION_SENSOR_ULP_WAKEUP | \
567 RSI_GPIO_SLEEP_IND_FROM_DEVICE | \
568 RSI_GPIO_2_ULP | \
569 RSI_GPIO_PUSH_BUTTON_ULP_WAKEUP);
570struct rsi_config_vals {
571 __le16 len_qno;
572 u8 pkt_type;
573 u8 misc_flags;
574 __le16 reserved1[6];
575 u8 lp_ps_handshake;
576 u8 ulp_ps_handshake;
577 u8 sleep_config_params; /* 0 for no handshake,
578 * 1 for GPIO based handshake,
579 * 2 packet handshake
580 */
581 u8 unused_ulp_gpio;
582 __le32 unused_soc_gpio_bitmap;
583 u8 ext_pa_or_bt_coex_en;
584 u8 opermode;
585 u8 wlan_rf_pwr_mode;
586 u8 bt_rf_pwr_mode;
587 u8 zigbee_rf_pwr_mode;
588 u8 driver_mode;
589 u8 region_code;
590 u8 antenna_sel_val;
591 u8 reserved2[16];
592} __packed;
593
Prameela Rani Garnepudi09cfb412017-07-06 20:07:05 +0530594/* Packet info flags */
595#define RSI_EEPROM_HDR_SIZE_OFFSET 8
596#define RSI_EEPROM_HDR_SIZE_MASK 0x300
597#define RSI_EEPROM_LEN_OFFSET 20
598#define RSI_EEPROM_LEN_MASK 0xFFF00000
599
600struct rsi_eeprom_read_frame {
601 __le16 len_qno;
602 u8 pkt_type;
603 u8 misc_flags;
604 __le32 pkt_info;
605 __le32 eeprom_offset;
606 __le16 delay_ms;
607 __le16 reserved3;
608} __packed;
609
Karun Eagalapatice868932017-08-03 19:58:59 +0530610struct rsi_request_ps {
611 struct rsi_cmd_desc desc;
612 struct ps_sleep_params ps_sleep;
613 u8 ps_mimic_support;
614 u8 ps_uapsd_acs;
615 u8 ps_uapsd_wakeup_period;
616 u8 reserved;
617 __le32 ps_listen_interval;
618 __le32 ps_dtim_interval_duration;
619 __le16 ps_num_dtim_intervals;
620} __packed;
621
Karun Eagalapatif3ac4e72017-10-27 16:55:55 +0530622struct rsi_wowlan_req {
623 struct rsi_cmd_desc desc;
624 u8 sourceid[ETH_ALEN];
625 u16 wow_flags;
626 u16 host_sleep_status;
627} __packed;
628
Prameela Rani Garnepudi7fdcb8e2018-12-27 14:56:18 +0530629#define RSI_START_BGSCAN 1
630#define RSI_STOP_BGSCAN 0
631#define HOST_BG_SCAN_TRIG BIT(4)
632struct rsi_bgscan_config {
633 struct rsi_cmd_desc_dword0 desc_dword0;
634 __le64 reserved;
635 __le32 reserved1;
636 __le16 bgscan_threshold;
637 __le16 roam_threshold;
638 __le16 bgscan_periodicity;
639 u8 num_bgscan_channels;
640 u8 two_probe;
641 __le16 active_scan_duration;
642 __le16 passive_scan_duration;
643 __le16 channels2scan[MAX_BGSCAN_CHANNELS_DUAL_BAND];
644} __packed;
645
646struct rsi_bgscan_probe {
647 struct rsi_cmd_desc_dword0 desc_dword0;
648 __le64 reserved;
649 __le32 reserved1;
650 __le16 mgmt_rate;
651 __le16 flags;
652 __le16 def_chan;
653 __le16 channel_scan_time;
654 __le16 probe_req_length;
655} __packed;
656
Fariya Fatimadad0d042014-03-16 03:47:02 +0530657static inline u32 rsi_get_queueno(u8 *addr, u16 offset)
658{
659 return (le16_to_cpu(*(__le16 *)&addr[offset]) & 0x7000) >> 12;
660}
661
662static inline u32 rsi_get_length(u8 *addr, u16 offset)
663{
664 return (le16_to_cpu(*(__le16 *)&addr[offset])) & 0x0fff;
665}
666
667static inline u8 rsi_get_extended_desc(u8 *addr, u16 offset)
668{
669 return le16_to_cpu(*((__le16 *)&addr[offset + 4])) & 0x00ff;
670}
671
672static inline u8 rsi_get_rssi(u8 *addr)
673{
674 return *(u8 *)(addr + FRAME_DESC_SZ);
675}
676
677static inline u8 rsi_get_channel(u8 *addr)
678{
679 return *(char *)(addr + 15);
680}
681
Prameela Rani Garnepudi99203222017-06-16 20:12:05 +0530682static inline void rsi_set_len_qno(__le16 *addr, u16 len, u8 qno)
683{
684 *addr = cpu_to_le16(len | ((qno & 7) << 12));
685}
686
Prameela Rani Garnepudi2108df32018-02-27 19:56:14 +0530687int rsi_handle_card_ready(struct rsi_common *common, u8 *msg);
Fariya Fatimadad0d042014-03-16 03:47:02 +0530688int rsi_mgmt_pkt_recv(struct rsi_common *common, u8 *msg);
Prameela Rani Garnepudi77364aa2016-10-13 16:56:45 +0530689int rsi_set_vap_capabilities(struct rsi_common *common, enum opmode mode,
Prameela Rani Garnepudi03c34c02017-08-16 18:43:09 +0530690 u8 *mac_addr, u8 vap_id, u8 vap_status);
Fariya Fatimadad0d042014-03-16 03:47:02 +0530691int rsi_send_aggregation_params_frame(struct rsi_common *common, u16 tid,
Prameela Rani Garnepudi32be57a2017-08-16 18:43:17 +0530692 u16 ssn, u8 buf_size, u8 event,
693 u8 sta_id);
Fariya Fatimadad0d042014-03-16 03:47:02 +0530694int rsi_hal_load_key(struct rsi_common *common, u8 *data, u16 key_len,
Prameela Rani Garnepudieac4eed2017-08-30 15:08:25 +0530695 u8 key_type, u8 key_id, u32 cipher, s16 sta_id,
696 struct ieee80211_vif *vif);
Prameela Rani Garnepudi61d10842016-11-18 16:08:43 +0530697int rsi_set_channel(struct rsi_common *common,
698 struct ieee80211_channel *channel);
Karun Eagalapati80a88ec2017-08-03 19:59:04 +0530699int rsi_send_vap_dynamic_update(struct rsi_common *common);
Jahnavi Meher686a2542014-06-16 19:46:48 +0530700int rsi_send_block_unblock_frame(struct rsi_common *common, bool event);
Prameela Rani Garnepudi4fd6c472018-03-29 19:44:52 +0530701int rsi_hal_send_sta_notify_frame(struct rsi_common *common, enum opmode opmode,
702 u8 notify_event, const unsigned char *bssid,
703 u8 qos_enable, u16 aid, u16 sta_id,
704 struct ieee80211_vif *vif);
Prameela Rani Garnepudi35286082017-08-16 18:43:12 +0530705void rsi_inform_bss_status(struct rsi_common *common, enum opmode opmode,
706 u8 status, const u8 *addr, u8 qos_enable, u16 aid,
Prameela Rani Garnepudi4671c2092017-08-30 15:08:24 +0530707 struct ieee80211_sta *sta, u16 sta_id,
Prameela Rani Garnepudi4fd6c472018-03-29 19:44:52 +0530708 u16 assoc_cap, struct ieee80211_vif *vif);
Fariya Fatimadad0d042014-03-16 03:47:02 +0530709void rsi_indicate_pkt_to_os(struct rsi_common *common, struct sk_buff *skb);
710int rsi_mac80211_attach(struct rsi_common *common);
711void rsi_indicate_tx_status(struct rsi_hw *common, struct sk_buff *skb,
712 int status);
713bool rsi_is_cipher_wep(struct rsi_common *common);
714void rsi_core_qos_processor(struct rsi_common *common);
715void rsi_core_xmit(struct rsi_common *common, struct sk_buff *skb);
716int rsi_send_mgmt_pkt(struct rsi_common *common, struct sk_buff *skb);
717int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb);
Prameela Rani Garnepudidf771912017-08-30 15:08:23 +0530718int rsi_band_check(struct rsi_common *common, struct ieee80211_channel *chan);
Prameela Rani Garnepudie6d64282016-11-18 16:07:09 +0530719int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word);
Prameela Rani Garnepudi8b36de82016-11-18 16:08:04 +0530720int rsi_send_radio_params_update(struct rsi_common *common);
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530721int rsi_set_antenna(struct rsi_common *common, u8 antenna);
Amitkumar Karware6b3b2e2017-11-01 17:42:45 +0530722#ifdef CONFIG_PM
Karun Eagalapatif3ac4e72017-10-27 16:55:55 +0530723int rsi_send_wowlan_request(struct rsi_common *common, u16 flags,
724 u16 sleep_status);
Amitkumar Karware6b3b2e2017-11-01 17:42:45 +0530725#endif
Prameela Rani Garnepudiefe877a2017-08-30 15:08:26 +0530726int rsi_send_ps_request(struct rsi_hw *adapter, bool enable,
727 struct ieee80211_vif *vif);
Prameela Rani Garnepudi7fdcb8e2018-12-27 14:56:18 +0530728void init_bgscan_params(struct rsi_common *common);
729int rsi_send_bgscan_params(struct rsi_common *common, int enable);
730int rsi_send_bgscan_probe_req(struct rsi_common *common,
731 struct ieee80211_vif *vif);
Fariya Fatimadad0d042014-03-16 03:47:02 +0530732#endif