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