blob: 74ae0ac113ee570a5385864593c531d0138a6cbb [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 */
66#define RSI_WIFI_MGMT_Q 0x4
67#define RSI_WIFI_DATA_Q 0x5
68#define IEEE80211_MGMT_FRAME 0x00
69#define IEEE80211_CTL_FRAME 0x04
70
71#define IEEE80211_QOS_TID 0x0f
72#define IEEE80211_NONQOS_TID 16
73
74#define MAX_DEBUGFS_ENTRIES 4
75
76#define TID_TO_WME_AC(_tid) ( \
77 ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
78 ((_tid) < 3) ? BK_Q : \
79 ((_tid) < 6) ? VI_Q : \
80 VO_Q)
81
82#define WME_AC(_q) ( \
83 ((_q) == BK_Q) ? IEEE80211_AC_BK : \
84 ((_q) == BE_Q) ? IEEE80211_AC_BE : \
85 ((_q) == VI_Q) ? IEEE80211_AC_VI : \
86 IEEE80211_AC_VO)
87
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +053088#define RSI_DEV_9113 1
89
Fariya Fatimadad0d042014-03-16 03:47:02 +053090struct version_info {
91 u16 major;
92 u16 minor;
93 u16 release_num;
94 u16 patch_num;
95} __packed;
96
97struct skb_info {
98 s8 rssi;
99 u32 flags;
100 u16 channel;
101 s8 tid;
102 s8 sta_id;
103};
104
105enum edca_queue {
106 BK_Q,
107 BE_Q,
108 VI_Q,
109 VO_Q,
110 MGMT_SOFT_Q
111};
112
113struct security_info {
114 bool security_enable;
115 u32 ptk_cipher;
116 u32 gtk_cipher;
117};
118
119struct wmm_qinfo {
120 s32 weight;
121 s32 wme_params;
122 s32 pkt_contended;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530123 s32 txop;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530124};
125
126struct transmit_q_stats {
127 u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 1];
128 u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 1];
129};
130
131struct vif_priv {
132 bool is_ht;
133 bool sgi;
134 u16 seq_start;
135};
136
137struct rsi_event {
138 atomic_t event_condition;
139 wait_queue_head_t event_queue;
140};
141
142struct rsi_thread {
143 void (*thread_function)(void *);
144 struct completion completion;
145 struct task_struct *task;
146 struct rsi_event event;
147 atomic_t thread_done;
148};
149
Jahnavi Meher686a2542014-06-16 19:46:48 +0530150struct cqm_info {
151 s8 last_cqm_event_rssi;
152 int rssi_thold;
153 u32 rssi_hyst;
154};
155
Fariya Fatimadad0d042014-03-16 03:47:02 +0530156struct rsi_hw;
157
158struct rsi_common {
159 struct rsi_hw *priv;
160 struct vif_priv vif_info[RSI_MAX_VIFS];
161
162 bool mgmt_q_block;
163 struct version_info driver_ver;
164 struct version_info fw_ver;
165
166 struct rsi_thread tx_thread;
167 struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 1];
168 /* Mutex declaration */
169 struct mutex mutex;
170 /* Mutex used between tx/rx threads */
171 struct mutex tx_rxlock;
172 u8 endpoint;
173
174 /* Channel/band related */
175 u8 band;
176 u8 channel_width;
177
178 u16 rts_threshold;
179 u16 bitrate_mask[2];
180 u32 fixedrate_mask[2];
181
182 u8 rf_reset;
183 struct transmit_q_stats tx_stats;
184 struct security_info secinfo;
185 struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
186 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
187 u8 mac_addr[IEEE80211_ADDR_LEN];
188
189 /* state related */
190 u32 fsm_state;
191 bool init_done;
192 u8 bb_rf_prog_count;
193 bool iface_down;
194
195 /* Generic */
196 u8 channel;
197 u8 *rx_data_pkt;
198 u8 mac_id;
199 u8 radio_id;
200 u16 rate_pwr[20];
201 u16 min_rate;
202
203 /* WMM algo related */
204 u8 selected_qnum;
205 u32 pkt_cnt;
206 u8 min_weight;
Jahnavi Meher360accb2014-06-16 19:45:03 +0530207
Jahnavi Meher686a2542014-06-16 19:46:48 +0530208 /* bgscan related */
209 struct cqm_info cqm_info;
210
Jahnavi Meher360accb2014-06-16 19:45:03 +0530211 bool hw_data_qs_blocked;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530212 u8 coex_mode;
Prameela Rani Garnepudi8b36de82016-11-18 16:08:04 +0530213
214 int tx_power;
Prameela Rani Garnepudi4edbcd12016-11-18 16:08:22 +0530215 u8 ant_in_use;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530216};
217
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530218enum host_intf {
219 RSI_HOST_INTF_SDIO = 0,
220 RSI_HOST_INTF_USB
221};
222
Fariya Fatimadad0d042014-03-16 03:47:02 +0530223struct rsi_hw {
224 struct rsi_common *priv;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530225 u8 device_model;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530226 struct ieee80211_hw *hw;
227 struct ieee80211_vif *vifs[RSI_MAX_VIFS];
228 struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
Johannes Berg57fbcce2016-04-12 15:56:15 +0200229 struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
Fariya Fatimadad0d042014-03-16 03:47:02 +0530230
231 struct device *device;
232 u8 sc_nvifs;
233
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530234 enum host_intf rsi_host_intf;
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530235 u16 block_size;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530236#ifdef CONFIG_RSI_DEBUGFS
237 struct rsi_debugfs *dfsentry;
238 u8 num_debugfs_entries;
239#endif
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530240 char *fw_file_name;
241 struct timer_list bl_cmd_timer;
242 bool blcmd_timer_expired;
243 u32 flash_capacity;
Prameela Rani Garnepudi61d10842016-11-18 16:08:43 +0530244 u8 dfs_region;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530245 void *rsi_dev;
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530246 struct rsi_host_intf_ops *host_intf_ops;
Fariya Fatimadad0d042014-03-16 03:47:02 +0530247 int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
248 int (*rx_urb_submit)(struct rsi_hw *adapter);
249 int (*determine_event_timeout)(struct rsi_hw *adapter);
250};
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530251
252struct rsi_host_intf_ops {
253 int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
254 int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
Prameela Rani Garnepudib78e91b2017-05-16 15:31:16 +0530255 int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530256 int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
257 u8 *data, u16 count);
258 int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
259 u8 *data, u16 count);
Prameela Rani Garnepudib97e9b92017-05-16 15:31:15 +0530260 int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
261 u32 *read_buf, u16 size);
262 int (*master_reg_write)(struct rsi_hw *adapter,
263 unsigned long addr, unsigned long data,
264 u16 size);
265 int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
266 u32 instructions_size, u16 block_size,
267 u8 *fw);
Prameela Rani Garnepudia2ce9522017-05-16 15:31:14 +0530268};
Fariya Fatimadad0d042014-03-16 03:47:02 +0530269#endif