blob: 833c66f53480097f79fc03b82ca4cd0c6e644f98 [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 {
35 FSM_CARD_NOT_READY,
36 FSM_BOOT_PARAMS_SENT,
37 FSM_EEPROM_READ_MAC_ADDR,
38 FSM_RESET_MAC_SENT,
39 FSM_RADIO_CAPS_SENT,
40 FSM_BB_RF_PROG_SENT,
41 FSM_MAC_INIT_DONE
42};
Fariya Fatimadad0d042014-03-16 03:47:02 +053043
44extern u32 rsi_zone_enabled;
Joe Perches5fe1b762014-03-18 17:59:47 -070045extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
Fariya Fatimadad0d042014-03-16 03:47:02 +053046
47#define RSI_MAX_VIFS 1
48#define NUM_EDCA_QUEUES 4
49#define IEEE80211_ADDR_LEN 6
50#define FRAME_DESC_SZ 16
51#define MIN_802_11_HDR_LEN 24
52
53#define DATA_QUEUE_WATER_MARK 400
54#define MIN_DATA_QUEUE_WATER_MARK 300
55#define MULTICAST_WATER_MARK 200
56#define MAC_80211_HDR_FRAME_CONTROL 0
57#define WME_NUM_AC 4
58#define NUM_SOFT_QUEUES 5
59#define MAX_HW_QUEUES 8
60#define INVALID_QUEUE 0xff
61#define MAX_CONTINUOUS_VO_PKTS 8
62#define MAX_CONTINUOUS_VI_PKTS 4
63
64/* Queue information */
65#define RSI_WIFI_MGMT_Q 0x4
66#define RSI_WIFI_DATA_Q 0x5
67#define IEEE80211_MGMT_FRAME 0x00
68#define IEEE80211_CTL_FRAME 0x04
69
70#define IEEE80211_QOS_TID 0x0f
71#define IEEE80211_NONQOS_TID 16
72
73#define MAX_DEBUGFS_ENTRIES 4
74
75#define TID_TO_WME_AC(_tid) ( \
76 ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
77 ((_tid) < 3) ? BK_Q : \
78 ((_tid) < 6) ? VI_Q : \
79 VO_Q)
80
81#define WME_AC(_q) ( \
82 ((_q) == BK_Q) ? IEEE80211_AC_BK : \
83 ((_q) == BE_Q) ? IEEE80211_AC_BE : \
84 ((_q) == VI_Q) ? IEEE80211_AC_VI : \
85 IEEE80211_AC_VO)
86
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +053087#define RSI_DEV_9113 1
88
Fariya Fatimadad0d042014-03-16 03:47:02 +053089struct version_info {
90 u16 major;
91 u16 minor;
92 u16 release_num;
93 u16 patch_num;
94} __packed;
95
96struct skb_info {
97 s8 rssi;
98 u32 flags;
99 u16 channel;
100 s8 tid;
101 s8 sta_id;
102};
103
104enum edca_queue {
105 BK_Q,
106 BE_Q,
107 VI_Q,
108 VO_Q,
109 MGMT_SOFT_Q
110};
111
112struct security_info {
113 bool security_enable;
114 u32 ptk_cipher;
115 u32 gtk_cipher;
116};
117
118struct wmm_qinfo {
119 s32 weight;
120 s32 wme_params;
121 s32 pkt_contended;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530122 s32 txop;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530123};
124
125struct transmit_q_stats {
126 u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 1];
127 u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 1];
128};
129
130struct vif_priv {
131 bool is_ht;
132 bool sgi;
133 u16 seq_start;
134};
135
136struct rsi_event {
137 atomic_t event_condition;
138 wait_queue_head_t event_queue;
139};
140
141struct rsi_thread {
142 void (*thread_function)(void *);
143 struct completion completion;
144 struct task_struct *task;
145 struct rsi_event event;
146 atomic_t thread_done;
147};
148
Jahnavi Meher686a2542014-06-16 19:46:48 +0530149struct cqm_info {
150 s8 last_cqm_event_rssi;
151 int rssi_thold;
152 u32 rssi_hyst;
153};
154
Fariya Fatimadad0d042014-03-16 03:47:02 +0530155struct rsi_hw;
156
157struct rsi_common {
158 struct rsi_hw *priv;
159 struct vif_priv vif_info[RSI_MAX_VIFS];
160
161 bool mgmt_q_block;
162 struct version_info driver_ver;
163 struct version_info fw_ver;
164
165 struct rsi_thread tx_thread;
166 struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 1];
167 /* Mutex declaration */
168 struct mutex mutex;
169 /* Mutex used between tx/rx threads */
170 struct mutex tx_rxlock;
171 u8 endpoint;
172
173 /* Channel/band related */
174 u8 band;
175 u8 channel_width;
176
177 u16 rts_threshold;
178 u16 bitrate_mask[2];
179 u32 fixedrate_mask[2];
180
181 u8 rf_reset;
182 struct transmit_q_stats tx_stats;
183 struct security_info secinfo;
184 struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
185 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
186 u8 mac_addr[IEEE80211_ADDR_LEN];
187
188 /* state related */
189 u32 fsm_state;
190 bool init_done;
191 u8 bb_rf_prog_count;
192 bool iface_down;
193
194 /* Generic */
195 u8 channel;
196 u8 *rx_data_pkt;
197 u8 mac_id;
198 u8 radio_id;
199 u16 rate_pwr[20];
200 u16 min_rate;
201
202 /* WMM algo related */
203 u8 selected_qnum;
204 u32 pkt_cnt;
205 u8 min_weight;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530206
Jahnavi Meher686a2542014-06-16 19:46:48 +0530207 /* bgscan related */
208 struct cqm_info cqm_info;
209
Jahnavi Meher360accb2014-06-16 19:45:03 +0530210 bool hw_data_qs_blocked;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530211 u8 coex_mode;
Prameela Rani Garnepudi8b36de82016-11-18 16:08:04 +0530212
213 int tx_power;
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530214 u8 ant_in_use;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530215};
216
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530217enum host_intf {
218 RSI_HOST_INTF_SDIO = 0,
219 RSI_HOST_INTF_USB
220};
221
Fariya Fatimadad0d042014-03-16 03:47:02 +0530222struct rsi_hw {
223 struct rsi_common *priv;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530224 u8 device_model;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530225 struct ieee80211_hw *hw;
226 struct ieee80211_vif *vifs[RSI_MAX_VIFS];
227 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
Johannes Berg57fbcce2016-04-12 15:56:15 +0200228 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
Fariya Fatimadad0d042014-03-16 03:47:02 +0530229
230 struct device *device;
231 u8 sc_nvifs;
232
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530233 enum host_intf rsi_host_intf;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530234 u16 block_size;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530235#ifdef CONFIG_RSI_DEBUGFS
236 struct rsi_debugfs *dfsentry;
237 u8 num_debugfs_entries;
238#endif
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530239 char *fw_file_name;
240 struct timer_list bl_cmd_timer;
241 bool blcmd_timer_expired;
242 u32 flash_capacity;
Prameela Rani Garnepudi61d10842016-11-18 16:08:43 +0530243 u8 dfs_region;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530244 void *rsi_dev;
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530245 struct rsi_host_intf_ops *host_intf_ops;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530246 int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
247 int (*rx_urb_submit)(struct rsi_hw *adapter);
248 int (*determine_event_timeout)(struct rsi_hw *adapter);
249};
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530250
251struct rsi_host_intf_ops {
252 int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
253 int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530254 int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530255 int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
256 u8 *data, u16 count);
257 int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
258 u8 *data, u16 count);
Prameela Rani Garnepudib97e9b92017-05-16 15:31:15 +0530259 int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
260 u32 *read_buf, u16 size);
261 int (*master_reg_write)(struct rsi_hw *adapter,
262 unsigned long addr, unsigned long data,
263 u16 size);
264 int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
265 u32 instructions_size, u16 block_size,
266 u8 *fw);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530267};
Fariya Fatimadad0d042014-03-16 03:47:02 +0530268#endif