blob: f12e5d94bec2fb996760d996e3e621dc6ae8a0af [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_MAIN_H__
18#define __RSI_MAIN_H__
19
20#include <linux/string.h>
21#include <linux/skbuff.h>
22#include <net/mac80211.h>
23
24#define ERR_ZONE BIT(0) /* For Error Msgs */
25#define INFO_ZONE BIT(1) /* For General Status Msgs */
26#define INIT_ZONE BIT(2) /* For Driver Init Seq Msgs */
27#define MGMT_TX_ZONE BIT(3) /* For TX Mgmt Path Msgs */
28#define MGMT_RX_ZONE BIT(4) /* For RX Mgmt Path Msgs */
29#define DATA_TX_ZONE BIT(5) /* For TX Data Path Msgs */
30#define DATA_RX_ZONE BIT(6) /* For RX Data Path Msgs */
31#define FSM_ZONE BIT(7) /* For State Machine Msgs */
32#define ISR_ZONE BIT(8) /* For Interrupt Msgs */
33
Amitkumar Karwar4833c952017-06-16 20:05:37 +053034enum RSI_FSM_STATES {
Prameela Rani Garnepudi015e3672017-06-16 20:05:38 +053035 FSM_FW_NOT_LOADED,
Amitkumar Karwar4833c952017-06-16 20:05:37 +053036 FSM_CARD_NOT_READY,
37 FSM_BOOT_PARAMS_SENT,
38 FSM_EEPROM_READ_MAC_ADDR,
39 FSM_RESET_MAC_SENT,
40 FSM_RADIO_CAPS_SENT,
41 FSM_BB_RF_PROG_SENT,
42 FSM_MAC_INIT_DONE
43};
Fariya Fatimadad0d042014-03-16 03:47:02 +053044
45extern u32 rsi_zone_enabled;
Joe Perches5fe1b762014-03-18 17:59:47 -070046extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
Fariya Fatimadad0d042014-03-16 03:47:02 +053047
48#define RSI_MAX_VIFS 1
49#define NUM_EDCA_QUEUES 4
50#define IEEE80211_ADDR_LEN 6
51#define FRAME_DESC_SZ 16
52#define MIN_802_11_HDR_LEN 24
53
54#define DATA_QUEUE_WATER_MARK 400
55#define MIN_DATA_QUEUE_WATER_MARK 300
56#define MULTICAST_WATER_MARK 200
57#define MAC_80211_HDR_FRAME_CONTROL 0
58#define WME_NUM_AC 4
59#define NUM_SOFT_QUEUES 5
60#define MAX_HW_QUEUES 8
61#define INVALID_QUEUE 0xff
62#define MAX_CONTINUOUS_VO_PKTS 8
63#define MAX_CONTINUOUS_VI_PKTS 4
64
65/* Queue information */
Prameela Rani Garnepudi61f2a6f2017-06-16 20:05:39 +053066#define RSI_COEX_Q 0x0
Fariya Fatimadad0d042014-03-16 03:47:02 +053067#define RSI_WIFI_MGMT_Q 0x4
68#define RSI_WIFI_DATA_Q 0x5
69#define IEEE80211_MGMT_FRAME 0x00
70#define IEEE80211_CTL_FRAME 0x04
71
72#define IEEE80211_QOS_TID 0x0f
73#define IEEE80211_NONQOS_TID 16
74
75#define MAX_DEBUGFS_ENTRIES 4
76
77#define TID_TO_WME_AC(_tid) ( \
78 ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
79 ((_tid) < 3) ? BK_Q : \
80 ((_tid) < 6) ? VI_Q : \
81 VO_Q)
82
83#define WME_AC(_q) ( \
84 ((_q) == BK_Q) ? IEEE80211_AC_BK : \
85 ((_q) == BE_Q) ? IEEE80211_AC_BE : \
86 ((_q) == VI_Q) ? IEEE80211_AC_VI : \
87 IEEE80211_AC_VO)
88
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +053089#define RSI_DEV_9113 1
90
Fariya Fatimadad0d042014-03-16 03:47:02 +053091struct version_info {
92 u16 major;
93 u16 minor;
94 u16 release_num;
95 u16 patch_num;
96} __packed;
97
98struct skb_info {
99 s8 rssi;
100 u32 flags;
101 u16 channel;
102 s8 tid;
103 s8 sta_id;
104};
105
106enum edca_queue {
107 BK_Q,
108 BE_Q,
109 VI_Q,
110 VO_Q,
111 MGMT_SOFT_Q
112};
113
114struct security_info {
115 bool security_enable;
116 u32 ptk_cipher;
117 u32 gtk_cipher;
118};
119
120struct wmm_qinfo {
121 s32 weight;
122 s32 wme_params;
123 s32 pkt_contended;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530124 s32 txop;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530125};
126
127struct transmit_q_stats {
128 u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 1];
129 u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 1];
130};
131
132struct vif_priv {
133 bool is_ht;
134 bool sgi;
135 u16 seq_start;
136};
137
138struct rsi_event {
139 atomic_t event_condition;
140 wait_queue_head_t event_queue;
141};
142
143struct rsi_thread {
144 void (*thread_function)(void *);
145 struct completion completion;
146 struct task_struct *task;
147 struct rsi_event event;
148 atomic_t thread_done;
149};
150
Jahnavi Meher686a2542014-06-16 19:46:48 +0530151struct cqm_info {
152 s8 last_cqm_event_rssi;
153 int rssi_thold;
154 u32 rssi_hyst;
155};
156
Fariya Fatimadad0d042014-03-16 03:47:02 +0530157struct rsi_hw;
158
159struct rsi_common {
160 struct rsi_hw *priv;
161 struct vif_priv vif_info[RSI_MAX_VIFS];
162
163 bool mgmt_q_block;
164 struct version_info driver_ver;
165 struct version_info fw_ver;
166
167 struct rsi_thread tx_thread;
168 struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 1];
169 /* Mutex declaration */
170 struct mutex mutex;
171 /* Mutex used between tx/rx threads */
172 struct mutex tx_rxlock;
173 u8 endpoint;
174
175 /* Channel/band related */
176 u8 band;
177 u8 channel_width;
178
179 u16 rts_threshold;
180 u16 bitrate_mask[2];
181 u32 fixedrate_mask[2];
182
183 u8 rf_reset;
184 struct transmit_q_stats tx_stats;
185 struct security_info secinfo;
186 struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
187 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
188 u8 mac_addr[IEEE80211_ADDR_LEN];
189
190 /* state related */
191 u32 fsm_state;
192 bool init_done;
193 u8 bb_rf_prog_count;
194 bool iface_down;
195
196 /* Generic */
197 u8 channel;
198 u8 *rx_data_pkt;
199 u8 mac_id;
200 u8 radio_id;
201 u16 rate_pwr[20];
202 u16 min_rate;
203
204 /* WMM algo related */
205 u8 selected_qnum;
206 u32 pkt_cnt;
207 u8 min_weight;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530208
Jahnavi Meher686a2542014-06-16 19:46:48 +0530209 /* bgscan related */
210 struct cqm_info cqm_info;
211
Jahnavi Meher360accb2014-06-16 19:45:03 +0530212 bool hw_data_qs_blocked;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530213 u8 coex_mode;
Prameela Rani Garnepudi8b36de82016-11-18 16:08:04 +0530214
215 int tx_power;
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530216 u8 ant_in_use;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530217};
218
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530219enum host_intf {
220 RSI_HOST_INTF_SDIO = 0,
221 RSI_HOST_INTF_USB
222};
223
Fariya Fatimadad0d042014-03-16 03:47:02 +0530224struct rsi_hw {
225 struct rsi_common *priv;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530226 u8 device_model;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530227 struct ieee80211_hw *hw;
228 struct ieee80211_vif *vifs[RSI_MAX_VIFS];
229 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
Johannes Berg57fbcce2016-04-12 15:56:15 +0200230 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
Fariya Fatimadad0d042014-03-16 03:47:02 +0530231
232 struct device *device;
233 u8 sc_nvifs;
234
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530235 enum host_intf rsi_host_intf;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530236 u16 block_size;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530237#ifdef CONFIG_RSI_DEBUGFS
238 struct rsi_debugfs *dfsentry;
239 u8 num_debugfs_entries;
240#endif
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530241 char *fw_file_name;
242 struct timer_list bl_cmd_timer;
243 bool blcmd_timer_expired;
244 u32 flash_capacity;
Prameela Rani Garnepudi61d10842016-11-18 16:08:43 +0530245 u8 dfs_region;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530246 void *rsi_dev;
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530247 struct rsi_host_intf_ops *host_intf_ops;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530248 int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
249 int (*rx_urb_submit)(struct rsi_hw *adapter);
250 int (*determine_event_timeout)(struct rsi_hw *adapter);
251};
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530252
253struct rsi_host_intf_ops {
254 int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
255 int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530256 int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530257 int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
258 u8 *data, u16 count);
259 int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
260 u8 *data, u16 count);
Prameela Rani Garnepudib97e9b92017-05-16 15:31:15 +0530261 int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
262 u32 *read_buf, u16 size);
263 int (*master_reg_write)(struct rsi_hw *adapter,
264 unsigned long addr, unsigned long data,
265 u16 size);
266 int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
267 u32 instructions_size, u16 block_size,
268 u8 *fw);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530269};
Fariya Fatimadad0d042014-03-16 03:47:02 +0530270#endif