]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[mirror_ubuntu-jammy-kernel.git] / drivers / net / wireless / broadcom / brcm80211 / brcmfmac / cfg80211.h
CommitLineData
daeccac2 1// SPDX-License-Identifier: ISC
5b435de0
AS
2/*
3 * Copyright (c) 2010 Broadcom Corporation
5b435de0
AS
4 */
5
bfe81975
HM
6#ifndef BRCMFMAC_CFG80211_H
7#define BRCMFMAC_CFG80211_H
5b435de0 8
83cf17aa
FL
9/* for brcmu_d11inf */
10#include <brcmu_d11.h>
11
bda9d014 12#include "core.h"
29477269
RM
13#include "fwil_types.h"
14#include "p2p.h"
15
94ed6ffb
AVS
16#define BRCMF_SCAN_IE_LEN_MAX 2048
17
f0799895 18#define WL_NUM_SCAN_MAX 10
5b435de0
AS
19#define WL_TLV_INFO_MAX 1024
20#define WL_BSS_INFO_MAX 2048
f0799895
HM
21#define WL_ASSOC_INFO_MAX 512 /* assoc related fil max buf */
22#define WL_EXTRA_BUF_MAX 2048
5b435de0
AS
23#define WL_ROAM_TRIGGER_LEVEL -75
24#define WL_ROAM_DELTA 20
5b435de0 25
d5367334
HM
26/* Keep BRCMF_ESCAN_BUF_SIZE below 64K (65536). Allocing over 64K can be
27 * problematic on some systems and should be avoided.
28 */
29#define BRCMF_ESCAN_BUF_SIZE 65000
30#define BRCMF_ESCAN_TIMER_INTERVAL_MS 10000 /* E-Scan timeout */
e756af5b
HM
31
32#define WL_ESCAN_ACTION_START 1
33#define WL_ESCAN_ACTION_CONTINUE 2
34#define WL_ESCAN_ACTION_ABORT 3
35
f09d0c02 36#define WL_AUTH_SHARED_KEY 1 /* d11 shared authentication */
1a873342 37#define IE_MAX_LEN 512
f09d0c02 38
9f440b7b
AS
39/* IE TLV processing */
40#define TLV_LEN_OFF 1 /* length offset */
41#define TLV_HDR_LEN 2 /* header length */
42#define TLV_BODY_OFF 2 /* body offset */
43#define TLV_OUI_LEN 3 /* oui id length */
44
45/* 802.11 Mgmt Packet flags */
46#define BRCMF_VNDR_IE_BEACON_FLAG 0x1
47#define BRCMF_VNDR_IE_PRBRSP_FLAG 0x2
48#define BRCMF_VNDR_IE_ASSOCRSP_FLAG 0x4
49#define BRCMF_VNDR_IE_AUTHRSP_FLAG 0x8
50#define BRCMF_VNDR_IE_PRBREQ_FLAG 0x10
51#define BRCMF_VNDR_IE_ASSOCREQ_FLAG 0x20
52/* vendor IE in IW advertisement protocol ID field */
53#define BRCMF_VNDR_IE_IWAPID_FLAG 0x40
54/* allow custom IE id */
55#define BRCMF_VNDR_IE_CUSTOM_FLAG 0x100
56
57/* P2P Action Frames flags (spec ordered) */
58#define BRCMF_VNDR_IE_GONREQ_FLAG 0x001000
59#define BRCMF_VNDR_IE_GONRSP_FLAG 0x002000
60#define BRCMF_VNDR_IE_GONCFM_FLAG 0x004000
61#define BRCMF_VNDR_IE_INVREQ_FLAG 0x008000
62#define BRCMF_VNDR_IE_INVRSP_FLAG 0x010000
63#define BRCMF_VNDR_IE_DISREQ_FLAG 0x020000
64#define BRCMF_VNDR_IE_DISRSP_FLAG 0x040000
65#define BRCMF_VNDR_IE_PRDREQ_FLAG 0x080000
66#define BRCMF_VNDR_IE_PRDRSP_FLAG 0x100000
67
68#define BRCMF_VNDR_IE_P2PAF_SHIFT 12
69
240d61a9 70#define BRCMF_MAX_DEFAULT_KEYS 6
118eb304 71
1119e23e
HM
72/* beacon loss timeout defaults */
73#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON 2
74#define BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_OFF 4
9f440b7b 75
63ce3d5d
AS
76#define BRCMF_VIF_EVENT_TIMEOUT msecs_to_jiffies(1500)
77
c1179033 78/**
1687eee2 79 * enum brcmf_scan_status - scan engine status
c1179033
AS
80 *
81 * @BRCMF_SCAN_STATUS_BUSY: scanning in progress on dongle.
82 * @BRCMF_SCAN_STATUS_ABORT: scan being aborted on dongle.
1687eee2 83 * @BRCMF_SCAN_STATUS_SUPPRESS: scanning is suppressed in driver.
c1179033
AS
84 */
85enum brcmf_scan_status {
86 BRCMF_SCAN_STATUS_BUSY,
87 BRCMF_SCAN_STATUS_ABORT,
1687eee2 88 BRCMF_SCAN_STATUS_SUPPRESS,
5b435de0
AS
89};
90
5b435de0
AS
91/* dongle configuration */
92struct brcmf_cfg80211_conf {
5b435de0
AS
93 u32 frag_threshold;
94 u32 rts_threshold;
95 u32 retry_short;
96 u32 retry_long;
5b435de0
AS
97};
98
5b435de0
AS
99/* security information with currently associated ap */
100struct brcmf_cfg80211_security {
101 u32 wpa_versions;
102 u32 auth_type;
103 u32 cipher_pairwise;
104 u32 cipher_group;
5b435de0
AS
105};
106
b8a64f0e
AS
107enum brcmf_profile_fwsup {
108 BRCMF_PROFILE_FWSUP_NONE,
2526ff21 109 BRCMF_PROFILE_FWSUP_PSK,
3b1e0a7b
CHH
110 BRCMF_PROFILE_FWSUP_1X,
111 BRCMF_PROFILE_FWSUP_SAE
b8a64f0e
AS
112};
113
3bc0a96c
AS
114/**
115 * struct brcmf_cfg80211_profile - profile information.
116 *
3bc0a96c
AS
117 * @bssid: bssid of joined/joining ibss.
118 * @sec: security information.
118eb304 119 * @key: key information
3bc0a96c 120 */
5b435de0 121struct brcmf_cfg80211_profile {
5b435de0 122 u8 bssid[ETH_ALEN];
5b435de0 123 struct brcmf_cfg80211_security sec;
118eb304 124 struct brcmf_wsec_key key[BRCMF_MAX_DEFAULT_KEYS];
b8a64f0e 125 enum brcmf_profile_fwsup use_fwsup;
be898fed 126 bool is_ft;
5b435de0
AS
127};
128
c1179033
AS
129/**
130 * enum brcmf_vif_status - bit indices for vif status.
131 *
132 * @BRCMF_VIF_STATUS_READY: ready for operation.
133 * @BRCMF_VIF_STATUS_CONNECTING: connect/join in progress.
b8a64f0e 134 * @BRCMF_VIF_STATUS_CONNECTED: connected/joined successfully.
5f4f9f11 135 * @BRCMF_VIF_STATUS_DISCONNECTING: disconnect/disable in progress.
c1179033 136 * @BRCMF_VIF_STATUS_AP_CREATED: AP operation started.
b8a64f0e
AS
137 * @BRCMF_VIF_STATUS_EAP_SUCCUSS: EAPOL handshake successful.
138 * @BRCMF_VIF_STATUS_ASSOC_SUCCESS: successful SET_SSID received.
c1179033
AS
139 */
140enum brcmf_vif_status {
141 BRCMF_VIF_STATUS_READY,
142 BRCMF_VIF_STATUS_CONNECTING,
143 BRCMF_VIF_STATUS_CONNECTED,
5f4f9f11 144 BRCMF_VIF_STATUS_DISCONNECTING,
b8a64f0e
AS
145 BRCMF_VIF_STATUS_AP_CREATED,
146 BRCMF_VIF_STATUS_EAP_SUCCESS,
147 BRCMF_VIF_STATUS_ASSOC_SUCCESS,
c1179033
AS
148};
149
8ff5dc92
AS
150/**
151 * struct vif_saved_ie - holds saved IEs for a virtual interface.
152 *
9f440b7b 153 * @probe_req_ie: IE info for probe request.
8ff5dc92
AS
154 * @probe_res_ie: IE info for probe response.
155 * @beacon_ie: IE info for beacon frame.
9f440b7b 156 * @probe_req_ie_len: IE info length for probe request.
8ff5dc92
AS
157 * @probe_res_ie_len: IE info length for probe response.
158 * @beacon_ie_len: IE info length for beacon frame.
159 */
160struct vif_saved_ie {
dae3a273 161 u8 probe_req_ie[IE_MAX_LEN];
8ff5dc92
AS
162 u8 probe_res_ie[IE_MAX_LEN];
163 u8 beacon_ie[IE_MAX_LEN];
89286dc9 164 u8 assoc_req_ie[IE_MAX_LEN];
9f440b7b 165 u32 probe_req_ie_len;
8ff5dc92
AS
166 u32 probe_res_ie_len;
167 u32 beacon_ie_len;
89286dc9 168 u32 assoc_req_ie_len;
8ff5dc92
AS
169};
170
3eacf866
AS
171/**
172 * struct brcmf_cfg80211_vif - virtual interface specific information.
173 *
174 * @ifp: lower layer interface pointer
175 * @wdev: wireless device.
6ac4f4ed 176 * @profile: profile information.
c1179033 177 * @sme_state: SME state using enum brcmf_vif_status bits.
3eacf866 178 * @list: linked list.
0de8aace 179 * @mgmt_rx_reg: registered rx mgmt frame types.
a44aa400 180 * @mbss: Multiple BSS type, set if not first AP (not relevant for P2P).
3eacf866
AS
181 */
182struct brcmf_cfg80211_vif {
183 struct brcmf_if *ifp;
184 struct wireless_dev wdev;
6ac4f4ed 185 struct brcmf_cfg80211_profile profile;
c1179033 186 unsigned long sme_state;
8ff5dc92 187 struct vif_saved_ie saved_ie;
3eacf866 188 struct list_head list;
0de8aace 189 u16 mgmt_rx_reg;
a44aa400 190 bool mbss;
98027769 191 int is_11d;
3eacf866
AS
192};
193
5b435de0
AS
194/* association inform */
195struct brcmf_cfg80211_connect_info {
196 u8 *req_ie;
197 s32 req_ie_len;
198 u8 *resp_ie;
199 s32 resp_ie_len;
200};
201
202/* assoc ie length */
c4e382d2
AS
203struct brcmf_cfg80211_assoc_ielen_le {
204 __le32 req_len;
205 __le32 resp_len;
5b435de0
AS
206};
207
e756af5b
HM
208/* dongle escan state */
209enum wl_escan_state {
210 WL_ESCAN_STATE_IDLE,
211 WL_ESCAN_STATE_SCANNING
212};
213
214struct escan_info {
215 u32 escan_state;
d5367334 216 u8 *escan_buf;
e756af5b 217 struct wiphy *wiphy;
a0f472ac
AS
218 struct brcmf_if *ifp;
219 s32 (*run)(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
c4958106 220 struct cfg80211_scan_request *request);
e756af5b
HM
221};
222
d3c0b633
AS
223/**
224 * struct brcmf_cfg80211_vif_event - virtual interface event information.
225 *
226 * @vif_wq: waitqueue awaiting interface event from firmware.
227 * @vif_event_lock: protects other members in this structure.
228 * @vif_complete: completion for net attach.
229 * @action: either add, change, or delete.
230 * @vif: virtual interface object related to the event.
231 */
232struct brcmf_cfg80211_vif_event {
233 wait_queue_head_t vif_wq;
b64abcb7 234 spinlock_t vif_event_lock;
d3c0b633
AS
235 u8 action;
236 struct brcmf_cfg80211_vif *vif;
237};
238
3021ad9a
HM
239/**
240 * struct brcmf_cfg80211_wowl - wowl related information.
241 *
242 * @active: set on suspend, cleared on resume.
243 * @pre_pmmode: firmware PM mode at entering suspend.
244 * @nd: net dectect data.
245 * @nd_info: helper struct to pass to cfg80211.
246 * @nd_data_wait: wait queue to sync net detect data.
247 * @nd_data_completed: completion for net detect data.
248 * @nd_enabled: net detect enabled.
249 */
250struct brcmf_cfg80211_wowl {
251 bool active;
252 u32 pre_pmmode;
253 struct cfg80211_wowlan_nd_match *nd;
254 struct cfg80211_wowlan_nd_info *nd_info;
255 wait_queue_head_t nd_data_wait;
256 bool nd_data_completed;
257 bool nd_enabled;
258};
259
02030eb6 260/**
27a68fe3 261 * struct brcmf_cfg80211_info - dongle private data of cfg80211 interface
02030eb6 262 *
3eacf866 263 * @wiphy: wiphy object for cfg80211 interface.
5c22fb85 264 * @ops: pointer to copy of ops as registered with wiphy object.
02030eb6 265 * @conf: dongle configuration.
9f440b7b 266 * @p2p: peer-to-peer specific information.
61730d4d 267 * @btcoex: Bluetooth coexistence information.
02030eb6 268 * @scan_request: cfg80211 scan request object.
02030eb6
AS
269 * @usr_sync: mainly for dongle up/down synchronization.
270 * @bss_list: bss_list holding scanned ap information.
02030eb6 271 * @bss_info: bss information for cfg80211 layer.
02030eb6
AS
272 * @conn_info: association info.
273 * @pmk_list: wpa2 pmk list.
c1179033 274 * @scan_status: scan activity on the dongle.
02030eb6
AS
275 * @pub: common driver information.
276 * @channel: current channel.
efc2c1fa 277 * @int_escan_map: bucket map for which internal e-scan is done.
02030eb6 278 * @ibss_starter: indicates this sta is ibss starter.
02030eb6
AS
279 * @pwr_save: indicate whether dongle to support power save mode.
280 * @dongle_up: indicate whether dongle up or not.
281 * @roam_on: on/off switch for dongle self-roaming.
282 * @scan_tried: indicates if first scan attempted.
283 * @dcmd_buf: dcmd buffer.
284 * @extra_buf: mainly to grab assoc information.
285 * @debugfsdir: debugfs folder for this device.
02030eb6
AS
286 * @escan_info: escan information.
287 * @escan_timeout: Timer for catch scan timeout.
288 * @escan_timeout_work: scan timeout worker.
3eacf866
AS
289 * @vif_list: linked list of vif instances.
290 * @vif_cnt: number of vif instances.
d3c0b633 291 * @vif_event: vif event signalling.
3021ad9a 292 * @wowl: wowl related information.
efc2c1fa 293 * @pno: information of pno module.
02030eb6 294 */
27a68fe3 295struct brcmf_cfg80211_info {
3eacf866 296 struct wiphy *wiphy;
02030eb6 297 struct brcmf_cfg80211_conf *conf;
9f440b7b 298 struct brcmf_p2p_info p2p;
61730d4d 299 struct brcmf_btcoex_info *btcoex;
02030eb6 300 struct cfg80211_scan_request *scan_request;
02030eb6 301 struct mutex usr_sync;
02030eb6 302 struct wl_cfg80211_bss_info *bss_info;
02030eb6 303 struct brcmf_cfg80211_connect_info conn_info;
6c404f34 304 struct brcmf_pmk_list_le pmk_list;
c1179033 305 unsigned long scan_status;
ee928381 306 struct brcmf_pub *pub;
02030eb6 307 u32 channel;
efc2c1fa 308 u32 int_escan_map;
02030eb6 309 bool ibss_starter;
02030eb6
AS
310 bool pwr_save;
311 bool dongle_up;
02030eb6
AS
312 bool scan_tried;
313 u8 *dcmd_buf;
314 u8 *extra_buf;
5b435de0 315 struct dentry *debugfsdir;
02030eb6
AS
316 struct escan_info escan_info;
317 struct timer_list escan_timeout;
318 struct work_struct escan_timeout_work;
3eacf866 319 struct list_head vif_list;
d3c0b633 320 struct brcmf_cfg80211_vif_event vif_event;
5f4f9f11 321 struct completion vif_disabled;
83cf17aa 322 struct brcmu_d11inf d11inf;
bf2a7e04 323 struct brcmf_assoclist_le assoclist;
3021ad9a 324 struct brcmf_cfg80211_wowl wowl;
efc2c1fa 325 struct brcmf_pno_info *pno;
5b435de0
AS
326};
327
9f440b7b
AS
328/**
329 * struct brcmf_tlv - tag_ID/length/value_buffer tuple.
330 *
331 * @id: tag identifier.
332 * @len: number of bytes in value buffer.
333 * @data: value buffer.
334 */
335struct brcmf_tlv {
336 u8 id;
337 u8 len;
338 u8 data[1];
339};
340
3eacf866 341static inline struct wiphy *cfg_to_wiphy(struct brcmf_cfg80211_info *cfg)
5b435de0 342{
3eacf866 343 return cfg->wiphy;
5b435de0
AS
344}
345
27a68fe3 346static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
5b435de0 347{
856d5a01
AVS
348 struct brcmf_pub *drvr = wiphy_priv(w);
349 return drvr->config;
5b435de0
AS
350}
351
27a68fe3 352static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
5b435de0 353{
856d5a01
AVS
354 return wiphy_to_cfg(wd->wiphy);
355}
356
357static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)
358{
359 return container_of(wdev, struct brcmf_cfg80211_vif, wdev);
5b435de0
AS
360}
361
3eacf866
AS
362static inline
363struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
5b435de0 364{
856d5a01 365 return brcmf_get_ifp(cfg->pub, 0)->ndev;
5b435de0
AS
366}
367
27a68fe3 368static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
5b435de0
AS
369{
370 return wdev_to_cfg(ndev->ieee80211_ptr);
371}
372
6ac4f4ed
AS
373static inline struct brcmf_cfg80211_profile *ndev_to_prof(struct net_device *nd)
374{
375 struct brcmf_if *ifp = netdev_priv(nd);
376 return &ifp->vif->profile;
377}
378
1332e26e
AS
379static inline struct brcmf_cfg80211_vif *ndev_to_vif(struct net_device *ndev)
380{
381 struct brcmf_if *ifp = netdev_priv(ndev);
382 return ifp->vif;
383}
384
5b435de0 385static inline struct
27a68fe3 386brcmf_cfg80211_connect_info *cfg_to_conn(struct brcmf_cfg80211_info *cfg)
5b435de0
AS
387{
388 return &cfg->conn_info;
389}
390
d9cb2596 391struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
856d5a01 392 struct cfg80211_ops *ops,
ae7c03f6 393 bool p2pdev_forced);
27a68fe3 394void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
bdf5ff51
AS
395s32 brcmf_cfg80211_up(struct net_device *ndev);
396s32 brcmf_cfg80211_down(struct net_device *ndev);
8c892df4 397struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);
a7965fbb 398enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
5b435de0 399
9f440b7b 400struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
26072330 401 enum nl80211_iftype type);
427dec5f 402void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
9f440b7b
AS
403
404s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
405 const u8 *vndr_ie_buf, u32 vndr_ie_len);
5f4f9f11 406s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif);
83cf17aa
FL
407u16 channel_to_chanspec(struct brcmu_d11inf *d11inf,
408 struct ieee80211_channel *ch);
bfe81975
HM
409bool brcmf_get_vif_state_any(struct brcmf_cfg80211_info *cfg,
410 unsigned long state);
d3c0b633
AS
411void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg,
412 struct brcmf_cfg80211_vif *vif);
413bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);
a9eb0c4b
AS
414int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
415 u8 action, ulong timeout);
7a5c1f64 416s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
a0f472ac
AS
417 struct brcmf_if *ifp, bool aborted,
418 bool fw_abort);
f96aa07e 419void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);
18e2f61d 420void brcmf_abort_scanning(struct brcmf_cfg80211_info *cfg);
9df4d542 421void brcmf_cfg80211_free_netdev(struct net_device *ndev);
9f440b7b 422
bfe81975 423#endif /* BRCMFMAC_CFG80211_H */