1 /* SPDX-License-Identifier: GPL-2.0-only */
5 * Copyright (c) 2017-2020, Silicon Laboratories, Inc.
6 * Copyright (c) 2010, ST-Ericsson
7 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
8 * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
13 #include <linux/completion.h>
14 #include <linux/workqueue.h>
15 #include <linux/mutex.h>
16 #include <linux/nospec.h>
17 #include <net/mac80211.h>
25 #define USEC_PER_TXOP 32 /* see struct ieee80211_tx_queue_params */
26 #define USEC_PER_TU 1024
31 struct wfx_platform_data pdata
;
33 struct ieee80211_hw
*hw
;
34 struct ieee80211_vif
*vif
[2];
35 struct mac_address addresses
[2];
36 const struct wfx_hwbus_ops
*hwbus_ops
;
40 struct completion firmware_ready
;
41 struct wfx_hif_ind_startup hw_caps
;
43 struct delayed_work cooling_timeout_work
;
46 struct mutex scan_lock
;
47 struct mutex conf_mutex
;
49 struct wfx_hif_cmd hif_cmd
;
50 struct sk_buff_head tx_pending
;
51 wait_queue_head_t tx_dequeue
;
57 struct wfx_hif_rx_stats rx_stats
;
58 struct mutex rx_stats_lock
;
59 struct wfx_hif_tx_power_loop_info tx_power_loop_info
;
60 struct mutex tx_power_loop_info_lock
;
61 struct workqueue_struct
*bh_wq
;
66 struct ieee80211_channel
*channel
;
71 bool after_dtim_tx_allowed
;
72 bool join_in_progress
;
73 struct completion set_pm_mode_complete
;
75 struct delayed_work beacon_loss_work
;
77 struct wfx_queue tx_queue
[4];
78 struct wfx_tx_policy_cache tx_policy_cache
;
79 struct work_struct tx_policy_upload_work
;
81 struct work_struct update_tim_work
;
83 unsigned long uapsd_mask
;
85 struct work_struct scan_work
;
86 struct completion scan_complete
;
87 int scan_nb_chan_done
;
89 struct ieee80211_scan_request
*scan_req
;
91 struct ieee80211_channel
*remain_on_channel_chan
;
92 int remain_on_channel_duration
;
93 struct work_struct remain_on_channel_work
;
96 static inline struct ieee80211_vif
*wvif_to_vif(struct wfx_vif
*wvif
)
98 return container_of((void *)wvif
, struct ieee80211_vif
, drv_priv
);
101 static inline struct wfx_vif
*wdev_to_wvif(struct wfx_dev
*wdev
, int vif_id
)
103 if (vif_id
>= ARRAY_SIZE(wdev
->vif
)) {
104 dev_dbg(wdev
->dev
, "requesting non-existent vif: %d\n", vif_id
);
107 vif_id
= array_index_nospec(vif_id
, ARRAY_SIZE(wdev
->vif
));
108 if (!wdev
->vif
[vif_id
])
110 return (struct wfx_vif
*)wdev
->vif
[vif_id
]->drv_priv
;
113 static inline struct wfx_vif
*wvif_iterate(struct wfx_dev
*wdev
, struct wfx_vif
*cur
)
121 for (i
= 0; i
< ARRAY_SIZE(wdev
->vif
); i
++) {
122 tmp
= wdev_to_wvif(wdev
, i
);
131 static inline int wvif_count(struct wfx_dev
*wdev
)
135 struct wfx_vif
*wvif
;
137 for (i
= 0; i
< ARRAY_SIZE(wdev
->vif
); i
++) {
138 wvif
= wdev_to_wvif(wdev
, i
);
145 static inline void memreverse(u8
*src
, u8 length
)
148 u8
*hi
= src
+ length
- 1;
158 static inline int memzcmp(void *src
, unsigned int size
)
166 return memcmp(buf
, buf
+ 1, size
- 1);