2 * Copyright (c) 2014 Redpine Signals Inc.
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.
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.
17 #ifndef __RSI_MAIN_H__
18 #define __RSI_MAIN_H__
20 #include <linux/string.h>
21 #include <linux/skbuff.h>
22 #include <net/mac80211.h>
23 #include <net/rsi_91x.h>
26 struct ieee80211_sta
*sta
;
28 u16 seq_start
[IEEE80211_NUM_TIDS
];
29 bool start_tx_aggr
[IEEE80211_NUM_TIDS
];
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 */
49 FSM_COMMON_DEV_PARAMS_SENT
,
51 FSM_EEPROM_READ_MAC_ADDR
,
52 FSM_EEPROM_READ_RF_TYPE
,
61 extern u32 rsi_zone_enabled
;
62 extern __printf(2, 3) void rsi_dbg(u32 zone
, const char *fmt
, ...);
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
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
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
84 /* Hardware queue info */
85 #define BROADCAST_HW_Q 9
87 #define BEACON_HW_Q 11
89 #define IEEE80211_MGMT_FRAME 0x00
90 #define IEEE80211_CTL_FRAME 0x04
92 #define RSI_MAX_ASSOC_STAS 32
93 #define IEEE80211_QOS_TID 0x0f
94 #define IEEE80211_NONQOS_TID 16
96 #define MAX_DEBUGFS_ENTRIES 4
98 #define TID_TO_WME_AC(_tid) ( \
99 ((_tid) == 0 || (_tid) == 3) ? BE_Q : \
100 ((_tid) < 3) ? BK_Q : \
101 ((_tid) < 6) ? VI_Q : \
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 : \
111 #define RSI_WOW_ENABLED BIT(0)
112 #define RSI_WOW_NO_CONNECTION BIT(1)
114 #define RSI_MAX_RX_PKTS 64
121 struct version_info
{
139 u8 internal_hdr_size
;
140 struct ieee80211_vif
*vif
;
153 struct security_info
{
154 bool security_enable
;
166 struct transmit_q_stats
{
167 u32 total_tx_pkt_send
[NUM_EDCA_QUEUES
+ 2];
168 u32 total_tx_pkt_freed
[NUM_EDCA_QUEUES
+ 2];
171 #define MAX_BGSCAN_CHANNELS_DUAL_BAND 38
172 #define MAX_BGSCAN_PROBE_REQ_LEN 0x64
173 #define RSI_DEF_BGSCAN_THRLD 0x0
174 #define RSI_DEF_ROAM_THRLD 0xa
175 #define RSI_BGSCAN_PERIODICITY 0x1e
176 #define RSI_ACTIVE_SCAN_TIME 0x14
177 #define RSI_PASSIVE_SCAN_TIME 0x46
178 #define RSI_CHANNEL_SCAN_TIME 20
179 struct rsi_bgscan_params
{
180 u16 bgscan_threshold
;
182 u16 bgscan_periodicity
;
183 u8 num_bgscan_channels
;
185 u16 active_scan_duration
;
186 u16 passive_scan_duration
;
197 atomic_t event_condition
;
198 wait_queue_head_t event_queue
;
202 void (*thread_function
)(void *);
203 struct completion completion
;
204 struct task_struct
*task
;
205 struct rsi_event event
;
206 atomic_t thread_done
;
210 s8 last_cqm_event_rssi
;
215 enum rsi_dfs_regions
{
222 struct rsi_9116_features
{
235 struct vif_priv vif_info
[RSI_MAX_VIFS
];
239 struct version_info lmac_ver
;
241 struct rsi_thread tx_thread
;
242 struct sk_buff_head tx_queue
[NUM_EDCA_QUEUES
+ 2];
243 struct completion wlan_init_completion
;
244 /* Mutex declaration */
246 /* Mutex used for tx thread */
247 struct mutex tx_lock
;
248 /* Mutex used for rx thread */
249 struct mutex rx_lock
;
252 /* Channel/band related */
259 u32 fixedrate_mask
[2];
262 struct transmit_q_stats tx_stats
;
263 struct security_info secinfo
;
264 struct wmm_qinfo tx_qinfo
[NUM_EDCA_QUEUES
];
265 struct ieee80211_tx_queue_params edca_params
[NUM_EDCA_QUEUES
];
266 u8 mac_addr
[IEEE80211_ADDR_LEN
];
282 /* WMM algo related */
288 struct cqm_info cqm_info
;
290 bool hw_data_qs_blocked
;
294 u8 lp_ps_handshake_mode
;
295 u8 ulp_ps_handshake_mode
;
298 u8 wlan_rf_power_mode
;
302 /* Mutex used for writing packet to bus */
303 struct mutex tx_bus_mutex
;
304 bool hibernate_resume
;
310 /* AP mode parameters */
313 struct rsi_sta stations
[RSI_MAX_ASSOC_STAS
+ 1];
316 struct ieee80211_key_conf
*key
;
318 /* Wi-Fi direct mode related */
320 struct timer_list roc_timer
;
321 struct ieee80211_vif
*roc_vif
;
326 struct cfg80211_scan_request
*hwscan
;
327 struct rsi_bgscan_params bgscan
;
328 struct rsi_9116_features w9116_features
;
333 struct eepromrw_info
{
347 struct rsi_common
*priv
;
348 enum rsi_dev_model device_model
;
349 struct ieee80211_hw
*hw
;
350 struct ieee80211_vif
*vifs
[RSI_MAX_VIFS
];
351 struct ieee80211_tx_queue_params edca_params
[NUM_EDCA_QUEUES
];
352 struct ieee80211_supported_band sbands
[NUM_NL80211_BANDS
];
354 struct device
*device
;
357 enum rsi_host_intf rsi_host_intf
;
359 enum ps_state ps_state
;
360 struct rsi_ps_info ps_info
;
361 spinlock_t ps_lock
; /*To protect power save config*/
362 u32 usb_buffer_status_reg
;
363 #ifdef CONFIG_RSI_DEBUGFS
364 struct rsi_debugfs
*dfsentry
;
365 u8 num_debugfs_entries
;
368 struct timer_list bl_cmd_timer
;
369 bool blcmd_timer_expired
;
371 struct eepromrw_info eeprom
;
372 u32 interrupt_status
;
376 struct rsi_host_intf_ops
*host_intf_ops
;
377 int (*check_hw_queue_status
)(struct rsi_hw
*adapter
, u8 q_num
);
378 int (*determine_event_timeout
)(struct rsi_hw
*adapter
);
381 void rsi_print_version(struct rsi_common
*common
);
383 struct rsi_host_intf_ops
{
384 int (*read_pkt
)(struct rsi_hw
*adapter
, u8
*pkt
, u32 len
);
385 int (*write_pkt
)(struct rsi_hw
*adapter
, u8
*pkt
, u32 len
);
386 int (*master_access_msword
)(struct rsi_hw
*adapter
, u16 ms_word
);
387 int (*read_reg_multiple
)(struct rsi_hw
*adapter
, u32 addr
,
388 u8
*data
, u16 count
);
389 int (*write_reg_multiple
)(struct rsi_hw
*adapter
, u32 addr
,
390 u8
*data
, u16 count
);
391 int (*master_reg_read
)(struct rsi_hw
*adapter
, u32 addr
,
392 u32
*read_buf
, u16 size
);
393 int (*master_reg_write
)(struct rsi_hw
*adapter
,
394 unsigned long addr
, unsigned long data
,
396 int (*load_data_master_write
)(struct rsi_hw
*adapter
, u32 addr
,
397 u32 instructions_size
, u16 block_size
,
399 int (*reinit_device
)(struct rsi_hw
*adapter
);
400 int (*ta_reset
)(struct rsi_hw
*adapter
);
403 enum rsi_host_intf
rsi_get_host_intf(void *priv
);
404 void rsi_set_bt_context(void *priv
, void *bt_context
);