]> Git Repo - linux.git/blob - drivers/net/wireless/rsi/rsi_main.h
Merge tag 'perf-urgent-for-mingo-4.18-20180625' of git://git.kernel.org/pub/scm/linux...
[linux.git] / drivers / net / wireless / rsi / rsi_main.h
1 /**
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 #include <net/rsi_91x.h>
24
25 struct rsi_sta {
26         struct ieee80211_sta *sta;
27         s16 sta_id;
28         u16 seq_start[IEEE80211_NUM_TIDS];
29         bool start_tx_aggr[IEEE80211_NUM_TIDS];
30 };
31
32 struct rsi_hw;
33
34 #include "rsi_ps.h"
35
36 #define ERR_ZONE                        BIT(0)  /* For Error Msgs             */
37 #define INFO_ZONE                       BIT(1)  /* For General Status Msgs    */
38 #define INIT_ZONE                       BIT(2)  /* For Driver Init Seq Msgs   */
39 #define MGMT_TX_ZONE                    BIT(3)  /* For TX Mgmt Path Msgs      */
40 #define MGMT_RX_ZONE                    BIT(4)  /* For RX Mgmt Path Msgs      */
41 #define DATA_TX_ZONE                    BIT(5)  /* For TX Data Path Msgs      */
42 #define DATA_RX_ZONE                    BIT(6)  /* For RX Data Path Msgs      */
43 #define FSM_ZONE                        BIT(7)  /* For State Machine Msgs     */
44 #define ISR_ZONE                        BIT(8)  /* For Interrupt Msgs         */
45
46 enum RSI_FSM_STATES {
47         FSM_FW_NOT_LOADED,
48         FSM_CARD_NOT_READY,
49         FSM_COMMON_DEV_PARAMS_SENT,
50         FSM_BOOT_PARAMS_SENT,
51         FSM_EEPROM_READ_MAC_ADDR,
52         FSM_EEPROM_READ_RF_TYPE,
53         FSM_RESET_MAC_SENT,
54         FSM_RADIO_CAPS_SENT,
55         FSM_BB_RF_PROG_SENT,
56         FSM_MAC_INIT_DONE,
57
58         NUM_FSM_STATES
59 };
60
61 extern u32 rsi_zone_enabled;
62 extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
63
64 #define RSI_MAX_VIFS                    3
65 #define NUM_EDCA_QUEUES                 4
66 #define IEEE80211_ADDR_LEN              6
67 #define FRAME_DESC_SZ                   16
68 #define MIN_802_11_HDR_LEN              24
69 #define RSI_DEF_KEEPALIVE               90
70 #define RSI_WOW_KEEPALIVE                5
71 #define RSI_BCN_MISS_THRESHOLD           24
72
73 #define DATA_QUEUE_WATER_MARK           400
74 #define MIN_DATA_QUEUE_WATER_MARK       300
75 #define MULTICAST_WATER_MARK            200
76 #define MAC_80211_HDR_FRAME_CONTROL     0
77 #define WME_NUM_AC                      4
78 #define NUM_SOFT_QUEUES                 6
79 #define MAX_HW_QUEUES                   12
80 #define INVALID_QUEUE                   0xff
81 #define MAX_CONTINUOUS_VO_PKTS          8
82 #define MAX_CONTINUOUS_VI_PKTS          4
83
84 /* Hardware queue info */
85 #define BROADCAST_HW_Q                  9
86 #define MGMT_HW_Q                       10
87 #define BEACON_HW_Q                     11
88
89 #define IEEE80211_MGMT_FRAME            0x00
90 #define IEEE80211_CTL_FRAME             0x04
91
92 #define RSI_MAX_ASSOC_STAS              32
93 #define IEEE80211_QOS_TID               0x0f
94 #define IEEE80211_NONQOS_TID            16
95
96 #define MAX_DEBUGFS_ENTRIES             4
97
98 #define TID_TO_WME_AC(_tid) (      \
99         ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
100         ((_tid) < 3) ? BK_Q : \
101         ((_tid) < 6) ? VI_Q : \
102         VO_Q)
103
104 #define WME_AC(_q) (    \
105         ((_q) == BK_Q) ? IEEE80211_AC_BK : \
106         ((_q) == BE_Q) ? IEEE80211_AC_BE : \
107         ((_q) == VI_Q) ? IEEE80211_AC_VI : \
108         IEEE80211_AC_VO)
109
110 /* WoWLAN flags */
111 #define RSI_WOW_ENABLED                 BIT(0)
112 #define RSI_WOW_NO_CONNECTION           BIT(1)
113
114 #define RSI_DEV_9113            1
115 #define RSI_MAX_RX_PKTS         64
116
117 struct version_info {
118         u16 major;
119         u16 minor;
120         u8 release_num;
121         u8 patch_num;
122         union {
123                 struct {
124                         u8 fw_ver[8];
125                 } info;
126         } ver;
127 } __packed;
128
129 struct skb_info {
130         s8 rssi;
131         u32 flags;
132         u16 channel;
133         s8 tid;
134         s8 sta_id;
135         u8 internal_hdr_size;
136         struct ieee80211_vif *vif;
137         u8 vap_id;
138 };
139
140 enum edca_queue {
141         BK_Q,
142         BE_Q,
143         VI_Q,
144         VO_Q,
145         MGMT_SOFT_Q,
146         MGMT_BEACON_Q
147 };
148
149 struct security_info {
150         bool security_enable;
151         u32 ptk_cipher;
152         u32 gtk_cipher;
153 };
154
155 struct wmm_qinfo {
156         s32 weight;
157         s32 wme_params;
158         s32 pkt_contended;
159         s32 txop;
160 };
161
162 struct transmit_q_stats {
163         u32 total_tx_pkt_send[NUM_EDCA_QUEUES + 2];
164         u32 total_tx_pkt_freed[NUM_EDCA_QUEUES + 2];
165 };
166
167 struct vif_priv {
168         bool is_ht;
169         bool sgi;
170         u16 seq_start;
171         int vap_id;
172 };
173
174 struct rsi_event {
175         atomic_t event_condition;
176         wait_queue_head_t event_queue;
177 };
178
179 struct rsi_thread {
180         void (*thread_function)(void *);
181         struct completion completion;
182         struct task_struct *task;
183         struct rsi_event event;
184         atomic_t thread_done;
185 };
186
187 struct cqm_info {
188         s8 last_cqm_event_rssi;
189         int rssi_thold;
190         u32 rssi_hyst;
191 };
192
193 enum rsi_dfs_regions {
194         RSI_REGION_FCC = 0,
195         RSI_REGION_ETSI,
196         RSI_REGION_TELEC,
197         RSI_REGION_WORLD
198 };
199
200 struct rsi_common {
201         struct rsi_hw *priv;
202         struct vif_priv vif_info[RSI_MAX_VIFS];
203
204         void *coex_cb;
205         bool mgmt_q_block;
206         struct version_info lmac_ver;
207
208         struct rsi_thread tx_thread;
209         struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
210         struct completion wlan_init_completion;
211         /* Mutex declaration */
212         struct mutex mutex;
213         /* Mutex used for tx thread */
214         struct mutex tx_lock;
215         /* Mutex used for rx thread */
216         struct mutex rx_lock;
217         u8 endpoint;
218
219         /* Channel/band related */
220         u8 band;
221         u8 num_supp_bands;
222         u8 channel_width;
223
224         u16 rts_threshold;
225         u16 bitrate_mask[2];
226         u32 fixedrate_mask[2];
227
228         u8 rf_reset;
229         struct transmit_q_stats tx_stats;
230         struct security_info secinfo;
231         struct wmm_qinfo tx_qinfo[NUM_EDCA_QUEUES];
232         struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
233         u8 mac_addr[IEEE80211_ADDR_LEN];
234
235         /* state related */
236         u32 fsm_state;
237         bool init_done;
238         u8 bb_rf_prog_count;
239         bool iface_down;
240
241         /* Generic */
242         u8 channel;
243         u8 *rx_data_pkt;
244         u8 mac_id;
245         u8 radio_id;
246         u16 rate_pwr[20];
247         u16 min_rate;
248
249         /* WMM algo related */
250         u8 selected_qnum;
251         u32 pkt_cnt;
252         u8 min_weight;
253
254         /* bgscan related */
255         struct cqm_info cqm_info;
256
257         bool hw_data_qs_blocked;
258         u8 driver_mode;
259         u8 coex_mode;
260         u16 oper_mode;
261         u8 lp_ps_handshake_mode;
262         u8 ulp_ps_handshake_mode;
263         u8 uapsd_bitmap;
264         u8 rf_power_val;
265         u8 wlan_rf_power_mode;
266         u8 obm_ant_sel_val;
267         int tx_power;
268         u8 ant_in_use;
269         /* Mutex used for writing packet to bus */
270         struct mutex tx_bus_mutex;
271         bool hibernate_resume;
272         bool reinit_hw;
273         u8 wow_flags;
274         u16 beacon_interval;
275         u8 dtim_cnt;
276
277         /* AP mode parameters */
278         u8 beacon_enabled;
279         u16 beacon_cnt;
280         struct rsi_sta stations[RSI_MAX_ASSOC_STAS + 1];
281         int num_stations;
282         int max_stations;
283         struct ieee80211_key_conf *key;
284
285         /* Wi-Fi direct mode related */
286         bool p2p_enabled;
287         struct timer_list roc_timer;
288         struct ieee80211_vif *roc_vif;
289
290         bool eapol4_confirm;
291         void *bt_adapter;
292 };
293
294 struct eepromrw_info {
295         u32 offset;
296         u32 length;
297         u8  write;
298         u16 eeprom_erase;
299         u8 data[480];
300 };
301
302 struct eeprom_read {
303         u16 length;
304         u16 off_set;
305 };
306
307 struct rsi_hw {
308         struct rsi_common *priv;
309         u8 device_model;
310         struct ieee80211_hw *hw;
311         struct ieee80211_vif *vifs[RSI_MAX_VIFS];
312         struct ieee80211_tx_queue_params edca_params[NUM_EDCA_QUEUES];
313         struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
314
315         struct device *device;
316         u8 sc_nvifs;
317
318         enum rsi_host_intf rsi_host_intf;
319         u16 block_size;
320         enum ps_state ps_state;
321         struct rsi_ps_info ps_info;
322         spinlock_t ps_lock; /*To protect power save config*/
323         u32 usb_buffer_status_reg;
324 #ifdef CONFIG_RSI_DEBUGFS
325         struct rsi_debugfs *dfsentry;
326         u8 num_debugfs_entries;
327 #endif
328         char *fw_file_name;
329         struct timer_list bl_cmd_timer;
330         bool blcmd_timer_expired;
331         u32 flash_capacity;
332         struct eepromrw_info eeprom;
333         u32 interrupt_status;
334         u8 dfs_region;
335         char country[2];
336         void *rsi_dev;
337         struct rsi_host_intf_ops *host_intf_ops;
338         int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
339         int (*determine_event_timeout)(struct rsi_hw *adapter);
340 };
341
342 void rsi_print_version(struct rsi_common *common);
343
344 struct rsi_host_intf_ops {
345         int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
346         int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
347         int (*master_access_msword)(struct rsi_hw *adapter, u16 ms_word);
348         int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
349                                  u8 *data, u16 count);
350         int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
351                                   u8 *data, u16 count);
352         int (*master_reg_read)(struct rsi_hw *adapter, u32 addr,
353                                u32 *read_buf, u16 size);
354         int (*master_reg_write)(struct rsi_hw *adapter,
355                                 unsigned long addr, unsigned long data,
356                                 u16 size);
357         int (*load_data_master_write)(struct rsi_hw *adapter, u32 addr,
358                                       u32 instructions_size, u16 block_size,
359                                       u8 *fw);
360         int (*reinit_device)(struct rsi_hw *adapter);
361 };
362
363 enum rsi_host_intf rsi_get_host_intf(void *priv);
364 void rsi_set_bt_context(void *priv, void *bt_context);
365
366 #endif
This page took 0.055173 seconds and 4 git commands to generate.