1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Common private data for Silicon Labs WFx chips.
5 * Copyright (c) 2017-2019, 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>
23 #include "secure_link.h"
27 #include "hif_api_general.h"
29 #define USEC_PER_TXOP 32 // see struct ieee80211_tx_queue_params
30 #define USEC_PER_TU 1024
35 struct wfx_platform_data pdata
;
37 struct ieee80211_hw
*hw
;
38 struct ieee80211_vif
*vif
[2];
39 struct mac_address addresses
[2];
40 const struct hwbus_ops
*hwbus_ops
;
44 struct completion firmware_ready
;
45 struct hif_ind_startup hw_caps
;
49 struct mutex conf_mutex
;
51 struct wfx_hif_cmd hif_cmd
;
52 struct wfx_queue tx_queue
[4];
53 struct wfx_queue_stats tx_queue_stats
;
59 struct hif_req_add_key keys
[MAX_KEY_ENTRIES
];
61 struct hif_rx_stats rx_stats
;
62 struct mutex rx_stats_lock
;
67 struct ieee80211_vif
*vif
;
68 struct ieee80211_channel
*channel
;
73 u32 bss_loss_confirm_id
;
74 struct mutex bss_loss_lock
;
75 struct delayed_work bss_loss_work
;
79 bool after_dtim_tx_allowed
;
80 struct wfx_grp_addr_table mcast_filter
;
82 s8 wep_default_key_id
;
83 struct sk_buff
*wep_pending_skb
;
84 struct work_struct wep_key_work
;
86 struct tx_policy_cache tx_policy_cache
;
87 struct work_struct tx_policy_upload_work
;
90 spinlock_t ps_state_lock
;
91 struct work_struct update_tim_work
;
96 bool disable_beacon_filter
;
97 struct work_struct update_filtering_work
;
99 unsigned long uapsd_mask
;
100 struct ieee80211_tx_queue_params edca_params
[IEEE80211_NUM_ACS
];
101 struct hif_req_set_bss_params bss_params
;
102 struct work_struct bss_params_work
;
104 int join_complete_status
;
105 struct work_struct unjoin_work
;
107 /* avoid some operations in parallel with scan */
108 struct mutex scan_lock
;
109 struct work_struct scan_work
;
110 struct completion scan_complete
;
112 struct ieee80211_scan_request
*scan_req
;
114 struct completion set_pm_mode_complete
;
116 struct list_head event_queue
;
117 spinlock_t event_queue_lock
;
118 struct work_struct event_handler_work
;
121 static inline struct wfx_vif
*wdev_to_wvif(struct wfx_dev
*wdev
, int vif_id
)
123 if (vif_id
>= ARRAY_SIZE(wdev
->vif
)) {
124 dev_dbg(wdev
->dev
, "requesting non-existent vif: %d\n", vif_id
);
127 vif_id
= array_index_nospec(vif_id
, ARRAY_SIZE(wdev
->vif
));
128 if (!wdev
->vif
[vif_id
]) {
129 dev_dbg(wdev
->dev
, "requesting non-allocated vif: %d\n",
133 return (struct wfx_vif
*) wdev
->vif
[vif_id
]->drv_priv
;
136 static inline struct wfx_vif
*wvif_iterate(struct wfx_dev
*wdev
,
145 for (i
= 0; i
< ARRAY_SIZE(wdev
->vif
); i
++) {
146 tmp
= wdev_to_wvif(wdev
, i
);
155 static inline int wvif_count(struct wfx_dev
*wdev
)
159 struct wfx_vif
*wvif
;
161 for (i
= 0; i
< ARRAY_SIZE(wdev
->vif
); i
++) {
162 wvif
= wdev_to_wvif(wdev
, i
);
169 static inline void memreverse(u8
*src
, u8 length
)
172 u8
*hi
= src
+ length
- 1;
182 static inline int memzcmp(void *src
, unsigned int size
)
190 return memcmp(buf
, buf
+ 1, size
- 1);