1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Common private data for ST-Ericsson CW1200 drivers
5 * Copyright (c) 2010, ST-Ericsson
6 * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
8 * Based on the mac80211 Prism54 code, which is
9 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
11 * Based on the islsm (softmac prism54) driver, which is:
12 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
18 #include <linux/wait.h>
19 #include <linux/mutex.h>
20 #include <linux/workqueue.h>
21 #include <net/mac80211.h>
29 /* Forward declarations */
32 struct cw1200_debug_priv
;
35 #define CW1200_MAX_CTRL_FRAME_LEN (0x1000)
37 #define CW1200_MAX_STA_IN_AP_MODE (5)
38 #define CW1200_LINK_ID_AFTER_DTIM (CW1200_MAX_STA_IN_AP_MODE + 1)
39 #define CW1200_LINK_ID_UAPSD (CW1200_MAX_STA_IN_AP_MODE + 2)
40 #define CW1200_LINK_ID_MAX (CW1200_MAX_STA_IN_AP_MODE + 3)
41 #define CW1200_MAX_REQUEUE_ATTEMPTS (5)
43 #define CW1200_MAX_TID (8)
45 #define CW1200_BLOCK_ACK_CNT (30)
46 #define CW1200_BLOCK_ACK_THLD (800)
47 #define CW1200_BLOCK_ACK_HIST (3)
48 #define CW1200_BLOCK_ACK_INTERVAL (1 * HZ / CW1200_BLOCK_ACK_HIST)
50 #define CW1200_JOIN_TIMEOUT (1 * HZ)
51 #define CW1200_AUTH_TIMEOUT (5 * HZ)
53 struct cw1200_ht_info
{
54 struct ieee80211_sta_ht_cap ht_cap
;
55 enum nl80211_channel_type channel_type
;
59 /* Please keep order */
60 enum cw1200_join_status
{
61 CW1200_JOIN_STATUS_PASSIVE
= 0,
62 CW1200_JOIN_STATUS_MONITOR
,
63 CW1200_JOIN_STATUS_JOINING
,
64 CW1200_JOIN_STATUS_PRE_STA
,
65 CW1200_JOIN_STATUS_STA
,
66 CW1200_JOIN_STATUS_IBSS
,
67 CW1200_JOIN_STATUS_AP
,
70 enum cw1200_link_status
{
76 CW1200_LINK_RESET_REMAP
,
79 extern int cw1200_power_mode
;
80 extern const char * const cw1200_fw_types
[];
82 struct cw1200_link_entry
{
83 unsigned long timestamp
;
84 enum cw1200_link_status status
;
85 enum cw1200_link_status prev_status
;
87 u8 buffered
[CW1200_MAX_TID
];
88 struct sk_buff_head rx_queue
;
91 struct cw1200_common
{
92 /* interfaces to the rest of the stack */
93 struct ieee80211_hw
*hw
;
94 struct ieee80211_vif
*vif
;
98 struct ieee80211_low_level_stats stats
;
101 u8 mac_addr
[ETH_ALEN
];
103 /* Hardware interface */
104 const struct hwbus_ops
*hwbus_ops
;
105 struct hwbus_priv
*hwbus_priv
;
107 /* Hardware information */
109 HIF_9000_SILICON_VERSATILE
= 0,
114 CW1200_HW_REV_CUT10
= 10,
115 CW1200_HW_REV_CUT11
= 11,
116 CW1200_HW_REV_CUT20
= 20,
117 CW1200_HW_REV_CUT22
= 22,
122 const struct firmware
*sdd
;
125 struct cw1200_debug_priv
*debug
;
127 struct workqueue_struct
*workqueue
;
128 struct mutex conf_mutex
;
130 struct cw1200_queue tx_queue
[4];
131 struct cw1200_queue_stats tx_queue_stats
;
134 /* firmware/hardware info */
135 unsigned int tx_hdr_len
;
141 struct ieee80211_rate
*rates
;
142 struct ieee80211_rate
*mcs_rates
;
143 struct ieee80211_channel
*channel
;
144 struct wsm_edca_params edca
;
145 struct wsm_tx_queue_params tx_queue_params
;
146 struct wsm_mib_association_mode association_mode
;
147 struct wsm_set_bss_params bss_params
;
148 struct cw1200_ht_info ht_info
;
149 struct wsm_set_pm powersave_mode
;
150 struct wsm_set_pm firmware_ps_mode
;
152 unsigned cqm_rssi_hyst
;
154 int cqm_beacon_loss_count
;
155 int channel_switch_in_progress
;
156 wait_queue_head_t channel_switch_done
;
157 u8 long_frame_max_tx_count
;
158 u8 short_frame_max_tx_count
;
163 struct wsm_rx_filter rx_filter
;
164 struct wsm_mib_multicast_filter multicast_filter
;
165 bool has_multicast_subscription
;
166 bool disable_beacon_filter
;
167 struct work_struct update_filtering_work
;
168 struct work_struct set_beacon_wakeup_period_work
;
173 struct cw1200_pm_state pm_state
;
175 struct wsm_p2p_ps_modeinfo p2p_ps_modeinfo
;
176 struct wsm_uapsd_info uapsd_info
;
177 bool setbssparams_done
;
179 u8 conf_listen_interval
;
190 struct workqueue_struct
*bh_workqueue
;
191 struct work_struct bh_work
;
194 wait_queue_head_t bh_wq
;
195 wait_queue_head_t bh_evt_wq
;
201 bool powersave_enabled
;
202 bool device_can_sleep
;
205 struct cw1200_scan scan
;
206 /* Keep cw1200 awake (WUP = 1) 1 second after each scan to avoid
207 * FW issue with sleeping/waking up.
209 atomic_t recent_scan
;
210 struct delayed_work clear_recent_scan_work
;
213 struct wsm_startup_ind wsm_caps
;
214 struct mutex wsm_cmd_mux
;
215 struct wsm_buf wsm_cmd_buf
;
216 struct wsm_cmd wsm_cmd
;
217 wait_queue_head_t wsm_cmd_wq
;
218 wait_queue_head_t wsm_startup_done
;
223 int wsm_enable_wsm_dumps
;
226 enum cw1200_join_status join_status
;
227 u32 pending_frame_id
;
229 struct delayed_work join_timeout
;
230 struct work_struct unjoin_work
;
231 struct work_struct join_complete_work
;
232 int join_complete_status
;
233 int join_dtim_period
;
236 /* TX/RX and security */
237 s8 wep_default_key_id
;
238 struct work_struct wep_key_work
;
240 struct wsm_add_key keys
[WSM_KEY_MAX_INDEX
+ 1];
244 struct cw1200_link_entry link_id_db
[CW1200_MAX_STA_IN_AP_MODE
];
245 struct work_struct link_id_work
;
246 struct delayed_work link_id_gc_work
;
250 spinlock_t ps_state_lock
; /* Protect power save state */
251 bool buffered_multicasts
;
253 struct work_struct set_tim_work
;
254 struct work_struct set_cts_work
;
255 struct work_struct multicast_start_work
;
256 struct work_struct multicast_stop_work
;
257 struct timer_list mcast_timeout
;
259 /* WSM events and CQM implementation */
260 spinlock_t event_queue_lock
; /* Protect event queue */
261 struct list_head event_queue
;
262 struct work_struct event_handler
;
264 struct delayed_work bss_loss_work
;
265 spinlock_t bss_loss_lock
; /* Protect BSS loss state */
267 u32 bss_loss_confirm_id
;
268 int delayed_link_loss
;
269 struct work_struct bss_params_work
;
271 /* TX rate policy cache */
272 struct tx_policy_cache tx_policy_cache
;
273 struct work_struct tx_policy_upload_work
;
275 /* legacy PS mode switch in suspend */
276 int ps_mode_switch_in_progress
;
277 wait_queue_head_t ps_mode_switch_done
;
279 /* Workaround for WFD testcase 6.1.10*/
280 struct work_struct linkid_reset_work
;
281 u8 action_frame_sa
[ETH_ALEN
];
285 struct cw1200_sta_priv
{
289 /* interfaces for the drivers */
290 int cw1200_core_probe(const struct hwbus_ops
*hwbus_ops
,
291 struct hwbus_priv
*hwbus
,
293 struct cw1200_common
**pself
,
294 int ref_clk
, const u8
*macaddr
,
295 const char *sdd_path
, bool have_5ghz
);
296 void cw1200_core_release(struct cw1200_common
*self
);
298 #define FWLOAD_BLOCK_SIZE (1024)
300 static inline int cw1200_is_ht(const struct cw1200_ht_info
*ht_info
)
302 return ht_info
->channel_type
!= NL80211_CHAN_NO_HT
;
305 static inline int cw1200_ht_greenfield(const struct cw1200_ht_info
*ht_info
)
307 return cw1200_is_ht(ht_info
) &&
308 (ht_info
->ht_cap
.cap
& IEEE80211_HT_CAP_GRN_FLD
) &&
309 !(ht_info
->operation_mode
&
310 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT
);
313 static inline int cw1200_ht_ampdu_density(const struct cw1200_ht_info
*ht_info
)
315 if (!cw1200_is_ht(ht_info
))
317 return ht_info
->ht_cap
.ampdu_density
;
320 #endif /* CW1200_H */