blob: 95320f2b25eb064d962ccc0d038e7ed12723e42e [file] [log] [blame]
Solomon Peachya910e4a2013-05-24 20:04:38 -04001/*
2 * Common private data for ST-Ericsson CW1200 drivers
3 *
4 * Copyright (c) 2010, ST-Ericsson
5 * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
6 *
7 * Based on the mac80211 Prism54 code, which is
8 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
9 *
10 * Based on the islsm (softmac prism54) driver, which is:
11 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18#ifndef CW1200_H
19#define CW1200_H
20
21#include <linux/wait.h>
Solomon Peachya910e4a2013-05-24 20:04:38 -040022#include <linux/mutex.h>
23#include <linux/workqueue.h>
24#include <net/mac80211.h>
25
26#include "queue.h"
27#include "wsm.h"
28#include "scan.h"
29#include "txrx.h"
30#include "pm.h"
31
32/* Forward declarations */
Solomon Peachy911373c2013-06-01 08:08:42 -040033struct hwbus_ops;
Solomon Peachya910e4a2013-05-24 20:04:38 -040034struct task_struct;
35struct cw1200_debug_priv;
36struct firmware;
37
38#ifdef CONFIG_CW1200_ETF
39extern int etf_mode;
40extern char *etf_firmware;
41#endif
42
43#define CW1200_MAX_CTRL_FRAME_LEN (0x1000)
44
45#define CW1200_MAX_STA_IN_AP_MODE (5)
46#define CW1200_LINK_ID_AFTER_DTIM (CW1200_MAX_STA_IN_AP_MODE + 1)
47#define CW1200_LINK_ID_UAPSD (CW1200_MAX_STA_IN_AP_MODE + 2)
48#define CW1200_LINK_ID_MAX (CW1200_MAX_STA_IN_AP_MODE + 3)
49#define CW1200_MAX_REQUEUE_ATTEMPTS (5)
50
51#define CW1200_MAX_TID (8)
52
53#define CW1200_BLOCK_ACK_CNT (30)
54#define CW1200_BLOCK_ACK_THLD (800)
55#define CW1200_BLOCK_ACK_HIST (3)
56#define CW1200_BLOCK_ACK_INTERVAL (1 * HZ / CW1200_BLOCK_ACK_HIST)
57
58#define CW1200_JOIN_TIMEOUT (1 * HZ)
59#define CW1200_AUTH_TIMEOUT (5 * HZ)
60
61struct cw1200_ht_info {
62 struct ieee80211_sta_ht_cap ht_cap;
63 enum nl80211_channel_type channel_type;
64 u16 operation_mode;
65};
66
67/* Please keep order */
68enum cw1200_join_status {
69 CW1200_JOIN_STATUS_PASSIVE = 0,
70 CW1200_JOIN_STATUS_MONITOR,
71 CW1200_JOIN_STATUS_JOINING,
72 CW1200_JOIN_STATUS_PRE_STA,
73 CW1200_JOIN_STATUS_STA,
74 CW1200_JOIN_STATUS_IBSS,
75 CW1200_JOIN_STATUS_AP,
76};
77
78enum cw1200_link_status {
79 CW1200_LINK_OFF,
80 CW1200_LINK_RESERVE,
81 CW1200_LINK_SOFT,
82 CW1200_LINK_HARD,
83 CW1200_LINK_RESET,
84 CW1200_LINK_RESET_REMAP,
85};
86
87extern int cw1200_power_mode;
88extern const char * const cw1200_fw_types[];
89
90struct cw1200_link_entry {
91 unsigned long timestamp;
92 enum cw1200_link_status status;
93 enum cw1200_link_status prev_status;
94 u8 mac[ETH_ALEN];
95 u8 buffered[CW1200_MAX_TID];
96 struct sk_buff_head rx_queue;
97};
98
99struct cw1200_common {
100 /* interfaces to the rest of the stack */
101 struct ieee80211_hw *hw;
102 struct ieee80211_vif *vif;
103 struct device *pdev;
104
105 /* Statistics */
106 struct ieee80211_low_level_stats stats;
107
108 /* Our macaddr */
109 u8 mac_addr[ETH_ALEN];
110
111 /* Hardware interface */
Solomon Peachy911373c2013-06-01 08:08:42 -0400112 const struct hwbus_ops *hwbus_ops;
113 struct hwbus_priv *hwbus_priv;
Solomon Peachya910e4a2013-05-24 20:04:38 -0400114
115 /* Hardware information */
116 enum {
117 HIF_9000_SILICON_VERSATILE = 0,
118 HIF_8601_VERSATILE,
119 HIF_8601_SILICON,
120 } hw_type;
121 enum {
122 CW1200_HW_REV_CUT10 = 10,
123 CW1200_HW_REV_CUT11 = 11,
124 CW1200_HW_REV_CUT20 = 20,
125 CW1200_HW_REV_CUT22 = 22,
126 CW1X60_HW_REV = 40,
127 } hw_revision;
128 int hw_refclk;
129 bool hw_have_5ghz;
130 const struct firmware *sdd;
131 char *sdd_path;
132
133 struct cw1200_debug_priv *debug;
134
135 struct workqueue_struct *workqueue;
136 struct mutex conf_mutex;
137
138 struct cw1200_queue tx_queue[4];
139 struct cw1200_queue_stats tx_queue_stats;
140 int tx_burst_idx;
141
142 /* firmware/hardware info */
143 unsigned int tx_hdr_len;
144
145 /* Radio data */
146 int output_power;
147
148 /* BBP/MAC state */
149 struct ieee80211_rate *rates;
150 struct ieee80211_rate *mcs_rates;
151 struct ieee80211_channel *channel;
152 struct wsm_edca_params edca;
153 struct wsm_tx_queue_params tx_queue_params;
154 struct wsm_mib_association_mode association_mode;
155 struct wsm_set_bss_params bss_params;
156 struct cw1200_ht_info ht_info;
157 struct wsm_set_pm powersave_mode;
158 struct wsm_set_pm firmware_ps_mode;
159 int cqm_rssi_thold;
160 unsigned cqm_rssi_hyst;
161 bool cqm_use_rssi;
162 int cqm_beacon_loss_count;
163 int channel_switch_in_progress;
164 wait_queue_head_t channel_switch_done;
165 u8 long_frame_max_tx_count;
166 u8 short_frame_max_tx_count;
167 int mode;
168 bool enable_beacon;
169 int beacon_int;
170 bool listening;
171 struct wsm_rx_filter rx_filter;
172 struct wsm_mib_multicast_filter multicast_filter;
173 bool has_multicast_subscription;
174 bool disable_beacon_filter;
175 struct work_struct update_filtering_work;
176 struct work_struct set_beacon_wakeup_period_work;
177
178 u8 ba_rx_tid_mask;
179 u8 ba_tx_tid_mask;
180
181 struct cw1200_pm_state pm_state;
182
183 struct wsm_p2p_ps_modeinfo p2p_ps_modeinfo;
184 struct wsm_uapsd_info uapsd_info;
185 bool setbssparams_done;
186 bool bt_present;
187 u8 conf_listen_interval;
188 u32 listen_interval;
189 u32 erp_info;
190 u32 rts_threshold;
191
192 /* BH */
193 atomic_t bh_rx;
194 atomic_t bh_tx;
195 atomic_t bh_term;
196 atomic_t bh_suspend;
197
198 struct workqueue_struct *bh_workqueue;
199 struct work_struct bh_work;
200
201 int bh_error;
202 wait_queue_head_t bh_wq;
203 wait_queue_head_t bh_evt_wq;
204 u8 buf_id_tx;
205 u8 buf_id_rx;
206 u8 wsm_rx_seq;
207 u8 wsm_tx_seq;
208 int hw_bufs_used;
209 bool powersave_enabled;
210 bool device_can_sleep;
211
212 /* Scan status */
213 struct cw1200_scan scan;
214 /* Keep cw1200 awake (WUP = 1) 1 second after each scan to avoid
215 * FW issue with sleeping/waking up. */
216 atomic_t recent_scan;
217 struct delayed_work clear_recent_scan_work;
218
219 /* WSM */
220 struct wsm_startup_ind wsm_caps;
221 struct mutex wsm_cmd_mux;
222 struct wsm_buf wsm_cmd_buf;
223 struct wsm_cmd wsm_cmd;
224 wait_queue_head_t wsm_cmd_wq;
225 wait_queue_head_t wsm_startup_done;
226 int firmware_ready;
227 atomic_t tx_lock;
228
229 /* WSM debug */
230 int wsm_enable_wsm_dumps;
231
232 /* WSM Join */
233 enum cw1200_join_status join_status;
234 u32 pending_frame_id;
235 bool join_pending;
236 struct delayed_work join_timeout;
237 struct work_struct unjoin_work;
238 struct work_struct join_complete_work;
239 int join_complete_status;
240 int join_dtim_period;
241 bool delayed_unjoin;
242
243 /* TX/RX and security */
244 s8 wep_default_key_id;
245 struct work_struct wep_key_work;
246 u32 key_map;
247 struct wsm_add_key keys[WSM_KEY_MAX_INDEX + 1];
248
249 /* AP powersave */
250 u32 link_id_map;
251 struct cw1200_link_entry link_id_db[CW1200_MAX_STA_IN_AP_MODE];
252 struct work_struct link_id_work;
253 struct delayed_work link_id_gc_work;
254 u32 sta_asleep_mask;
255 u32 pspoll_mask;
256 bool aid0_bit_set;
257 spinlock_t ps_state_lock; /* Protect power save state */
258 bool buffered_multicasts;
259 bool tx_multicast;
260 struct work_struct set_tim_work;
261 struct work_struct set_cts_work;
262 struct work_struct multicast_start_work;
263 struct work_struct multicast_stop_work;
264 struct timer_list mcast_timeout;
265
266 /* WSM events and CQM implementation */
267 spinlock_t event_queue_lock; /* Protect event queue */
268 struct list_head event_queue;
269 struct work_struct event_handler;
270
271 struct delayed_work bss_loss_work;
272 spinlock_t bss_loss_lock; /* Protect BSS loss state */
273 int bss_loss_state;
274 int bss_loss_confirm_id;
275 int delayed_link_loss;
276 struct work_struct bss_params_work;
277
278 /* TX rate policy cache */
279 struct tx_policy_cache tx_policy_cache;
280 struct work_struct tx_policy_upload_work;
281
282 /* legacy PS mode switch in suspend */
283 int ps_mode_switch_in_progress;
284 wait_queue_head_t ps_mode_switch_done;
285
286 /* Workaround for WFD testcase 6.1.10*/
287 struct work_struct linkid_reset_work;
288 u8 action_frame_sa[ETH_ALEN];
289 u8 action_linkid;
290
291#ifdef CONFIG_CW1200_ETF
292 struct sk_buff_head etf_q;
293#endif
294};
295
296struct cw1200_sta_priv {
297 int link_id;
298};
299
300/* interfaces for the drivers */
Solomon Peachy911373c2013-06-01 08:08:42 -0400301int cw1200_core_probe(const struct hwbus_ops *hwbus_ops,
302 struct hwbus_priv *hwbus,
Solomon Peachya910e4a2013-05-24 20:04:38 -0400303 struct device *pdev,
304 struct cw1200_common **pself,
305 int ref_clk, const u8 *macaddr,
306 const char *sdd_path, bool have_5ghz);
307void cw1200_core_release(struct cw1200_common *self);
308
309#define FWLOAD_BLOCK_SIZE (1024)
310
311static inline int cw1200_is_ht(const struct cw1200_ht_info *ht_info)
312{
313 return ht_info->channel_type != NL80211_CHAN_NO_HT;
314}
315
316static inline int cw1200_ht_greenfield(const struct cw1200_ht_info *ht_info)
317{
318 return cw1200_is_ht(ht_info) &&
319 (ht_info->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) &&
320 !(ht_info->operation_mode &
321 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
322}
323
324static inline int cw1200_ht_ampdu_density(const struct cw1200_ht_info *ht_info)
325{
326 if (!cw1200_is_ht(ht_info))
327 return 0;
328 return ht_info->ht_cap.ampdu_density;
329}
330
331#endif /* CW1200_H */