xref: /linux/net/wireless/core.h (revision 9a8407984ab43a70174e5474946ab6c19dc2e0ba)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Wireless configuration interface internals.
4  *
5  * Copyright 2006-2010	Johannes Berg <johannes@sipsolutions.net>
6  * Copyright (C) 2018-2026 Intel Corporation
7  */
8 #ifndef __NET_WIRELESS_CORE_H
9 #define __NET_WIRELESS_CORE_H
10 #include <linux/list.h>
11 #include <linux/netdevice.h>
12 #include <linux/rbtree.h>
13 #include <linux/debugfs.h>
14 #include <linux/rfkill.h>
15 #include <linux/workqueue.h>
16 #include <linux/rtnetlink.h>
17 #include <linux/wait_bit.h>
18 #include <net/genetlink.h>
19 #include <net/cfg80211.h>
20 #include "reg.h"
21 
22 
23 /* protects the wiphy list, wiphy netns changes and regulatory state */
24 extern struct mutex cfg80211_mutex;
25 
26 #define WIPHY_IDX_INVALID	-1
27 
28 struct cfg80211_scan_request_int {
29 	struct cfg80211_scan_info info;
30 	bool notified;
31 	/*
32 	 * set while the request is handed to the driver, i.e. between
33 	 * rdev_scan() and cfg80211_scan_done()
34 	 */
35 	bool driver_owns;
36 	/*
37 	 * set when cfg80211 is done with the request but the driver still
38 	 * owns it, so that cfg80211_scan_done() knows to just free it
39 	 */
40 	bool stale;
41 	/* must be last - variable members */
42 	struct cfg80211_scan_request req;
43 };
44 
45 struct cfg80211_registered_device {
46 	const struct cfg80211_ops *ops;
47 	struct list_head list;
48 
49 	/* rfkill support */
50 	struct rfkill_ops rfkill_ops;
51 	struct work_struct rfkill_block;
52 
53 	/* ISO / IEC 3166 alpha2 for which this device is receiving
54 	 * country IEs on, this can help disregard country IEs from APs
55 	 * on the same alpha2 quickly. The alpha2 may differ from
56 	 * cfg80211_regdomain's alpha2 when an intersection has occurred.
57 	 * If the AP is reconfigured this can also be used to tell us if
58 	 * the country on the country IE changed. */
59 	char country_ie_alpha2[2];
60 
61 	/*
62 	 * the driver requests the regulatory core to set this regulatory
63 	 * domain as the wiphy's. Only used for %REGULATORY_WIPHY_SELF_MANAGED
64 	 * devices using the regulatory_set_wiphy_regd() API
65 	 */
66 	const struct ieee80211_regdomain *requested_regd;
67 
68 	/* If a Country IE has been received this tells us the environment
69 	 * which its telling us its in. This defaults to ENVIRON_ANY */
70 	enum environment_cap env;
71 
72 	/* wiphy index, internal only */
73 	int wiphy_idx;
74 
75 	/* protected by RTNL */
76 	int devlist_generation, wdev_id;
77 	int opencount;
78 	wait_queue_head_t dev_wait;
79 
80 	struct list_head beacon_registrations;
81 	spinlock_t beacon_registrations_lock;
82 
83 	/* protected by RTNL only */
84 	int num_running_ifaces;
85 	int num_running_monitor_ifaces;
86 
87 	/* atomic for unlocked users */
88 	atomic64_t cookie_counter;
89 
90 	/* BSSes/scanning */
91 	spinlock_t bss_lock;
92 	struct list_head bss_list;
93 	struct rb_root bss_tree;
94 	u32 bss_generation;
95 	u32 bss_entries;
96 	struct cfg80211_scan_request_int *scan_req; /* protected by RTNL */
97 	struct cfg80211_scan_request_int *int_scan_req;
98 	struct sk_buff *scan_msg;
99 	struct list_head sched_scan_req_list;
100 	time64_t suspend_at;
101 	struct wiphy_work scan_done_wk;
102 
103 	struct genl_info *cur_cmd_info;
104 
105 	struct work_struct conn_work;
106 	struct work_struct event_work;
107 
108 	struct delayed_work dfs_update_channels_wk;
109 
110 	struct wireless_dev *background_radar_wdev;
111 	struct cfg80211_chan_def background_radar_chandef;
112 	struct delayed_work background_cac_done_wk;
113 	struct work_struct background_cac_abort_wk;
114 
115 	/* netlink port which started critical protocol (0 means not started) */
116 	u32 crit_proto_nlportid;
117 
118 	struct cfg80211_coalesce *coalesce;
119 
120 	struct work_struct destroy_work;
121 	struct wiphy_work sched_scan_stop_wk;
122 	struct work_struct sched_scan_res_wk;
123 	struct wiphy_work reg_check_chans_wk;
124 	struct work_struct reg_leave_nan_wk;
125 
126 	struct cfg80211_chan_def radar_chandef;
127 	struct work_struct propagate_radar_detect_wk;
128 
129 	struct cfg80211_chan_def cac_done_chandef;
130 	struct work_struct propagate_cac_done_wk;
131 
132 	struct work_struct mgmt_registrations_update_wk;
133 	/* lock for all wdev lists */
134 	spinlock_t mgmt_registrations_lock;
135 
136 	struct work_struct wiphy_work;
137 	struct list_head wiphy_work_list;
138 	/* protects the list above */
139 	spinlock_t wiphy_work_lock;
140 	bool suspended;
141 
142 	/* must be last because of the way we do wiphy_priv(),
143 	 * and it should at least be aligned to NETDEV_ALIGN */
144 	struct wiphy wiphy __aligned(NETDEV_ALIGN);
145 };
146 
147 static inline
148 struct cfg80211_registered_device *wiphy_to_rdev(struct wiphy *wiphy)
149 {
150 	BUG_ON(!wiphy);
151 	return container_of(wiphy, struct cfg80211_registered_device, wiphy);
152 }
153 
154 static inline void
155 cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev)
156 {
157 #ifdef CONFIG_PM
158 	int i;
159 
160 	if (!rdev->wiphy.wowlan_config)
161 		return;
162 	for (i = 0; i < rdev->wiphy.wowlan_config->n_patterns; i++)
163 		kfree(rdev->wiphy.wowlan_config->patterns[i].mask);
164 	kfree(rdev->wiphy.wowlan_config->patterns);
165 	if (rdev->wiphy.wowlan_config->tcp &&
166 	    rdev->wiphy.wowlan_config->tcp->sock)
167 		sock_release(rdev->wiphy.wowlan_config->tcp->sock);
168 	kfree(rdev->wiphy.wowlan_config->tcp);
169 	kfree(rdev->wiphy.wowlan_config->nd_config);
170 	kfree(rdev->wiphy.wowlan_config);
171 #endif
172 }
173 
174 static inline u64 cfg80211_assign_cookie(struct cfg80211_registered_device *rdev)
175 {
176 	u64 r = atomic64_inc_return(&rdev->cookie_counter);
177 
178 	if (WARN_ON(r == 0))
179 		r = atomic64_inc_return(&rdev->cookie_counter);
180 
181 	return r;
182 }
183 
184 extern struct workqueue_struct *cfg80211_wq;
185 extern struct list_head cfg80211_rdev_list;
186 extern int cfg80211_rdev_list_generation;
187 
188 #define for_each_rdev(rdev)						\
189 	list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list,	\
190 				lockdep_rtnl_is_held() ||		\
191 				lockdep_is_held(&cfg80211_mutex))
192 
193 enum bss_source_type {
194 	BSS_SOURCE_DIRECT = 0,
195 	BSS_SOURCE_MBSSID,
196 	BSS_SOURCE_STA_PROFILE,
197 };
198 
199 struct cfg80211_internal_bss {
200 	struct list_head list;
201 	struct list_head hidden_list;
202 	struct rb_node rbn;
203 	unsigned long ts;
204 	unsigned long refcount;
205 	atomic_t hold;
206 
207 	/* time at the start of the reception of the first octet of the
208 	 * timestamp field of the last beacon/probe received for this BSS.
209 	 * The time is the TSF of the BSS specified by %parent_bssid.
210 	 */
211 	u64 parent_tsf;
212 
213 	/* the BSS according to which %parent_tsf is set. This is set to
214 	 * the BSS that the interface that requested the scan was connected to
215 	 * when the beacon/probe was received.
216 	 */
217 	u8 parent_bssid[ETH_ALEN] __aligned(2);
218 
219 	enum bss_source_type bss_source;
220 
221 	/* must be last because of priv member */
222 	struct cfg80211_bss pub;
223 };
224 
225 static inline struct cfg80211_internal_bss *bss_from_pub(struct cfg80211_bss *pub)
226 {
227 	return container_of(pub, struct cfg80211_internal_bss, pub);
228 }
229 
230 static inline void cfg80211_hold_bss(struct cfg80211_internal_bss *bss)
231 {
232 	atomic_inc(&bss->hold);
233 	if (bss->pub.transmitted_bss) {
234 		bss = container_of(bss->pub.transmitted_bss,
235 				   struct cfg80211_internal_bss, pub);
236 		atomic_inc(&bss->hold);
237 	}
238 }
239 
240 static inline void cfg80211_unhold_bss(struct cfg80211_internal_bss *bss)
241 {
242 	int r = atomic_dec_return(&bss->hold);
243 	WARN_ON(r < 0);
244 	if (bss->pub.transmitted_bss) {
245 		bss = container_of(bss->pub.transmitted_bss,
246 				   struct cfg80211_internal_bss, pub);
247 		r = atomic_dec_return(&bss->hold);
248 		WARN_ON(r < 0);
249 	}
250 }
251 
252 
253 struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx);
254 int get_wiphy_idx(struct wiphy *wiphy);
255 
256 struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx);
257 
258 int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
259 			  struct net *net);
260 
261 void cfg80211_init_wdev(struct wireless_dev *wdev);
262 void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
263 			    struct wireless_dev *wdev);
264 
265 static inline void wdev_hold(struct wireless_dev *wdev)
266 {
267 	if (wdev->netdev) {
268 		dev_hold(wdev->netdev);
269 		return;
270 	}
271 
272 	/* also not RTNL, but can't check that */
273 	lockdep_assert_not_held(&wdev->wiphy->mtx);
274 	refcount_inc(&wdev->refcnt);
275 }
276 
277 static inline void wdev_put(struct wireless_dev *wdev)
278 {
279 	if (wdev->netdev)
280 		dev_put(wdev->netdev);
281 	else if (refcount_dec_and_test(&wdev->refcnt))
282 		wake_up_var(&wdev->refcnt);
283 }
284 
285 static inline bool cfg80211_has_monitors_only(struct cfg80211_registered_device *rdev)
286 {
287 	lockdep_assert_held(&rdev->wiphy.mtx);
288 
289 	return rdev->num_running_ifaces == rdev->num_running_monitor_ifaces &&
290 	       rdev->num_running_ifaces > 0;
291 }
292 
293 enum cfg80211_event_type {
294 	EVENT_CONNECT_RESULT,
295 	EVENT_ROAMED,
296 	EVENT_DISCONNECTED,
297 	EVENT_IBSS_JOINED,
298 	EVENT_STOPPED,
299 	EVENT_PORT_AUTHORIZED,
300 };
301 
302 struct cfg80211_event {
303 	struct list_head list;
304 	enum cfg80211_event_type type;
305 
306 	union {
307 		struct cfg80211_connect_resp_params cr;
308 		struct cfg80211_roam_info rm;
309 		struct {
310 			const u8 *ie;
311 			size_t ie_len;
312 			u16 reason;
313 			bool locally_generated;
314 		} dc;
315 		struct {
316 			struct cfg80211_bss *bss;
317 		} ij;
318 		struct {
319 			u8 peer_addr[ETH_ALEN];
320 			const u8 *td_bitmap;
321 			u8 td_bitmap_len;
322 		} pa;
323 	};
324 	int link_id;
325 };
326 
327 struct cfg80211_cached_keys {
328 	struct key_params params[4];
329 	u8 data[4][WLAN_KEY_LEN_WEP104];
330 	int def;
331 };
332 
333 struct cfg80211_beacon_registration {
334 	struct list_head list;
335 	u32 nlportid;
336 };
337 
338 struct cfg80211_cqm_config {
339 	struct rcu_head rcu_head;
340 	u32 rssi_hyst;
341 	s32 last_rssi_event_value;
342 	enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
343 	bool use_range_api;
344 	int n_rssi_thresholds;
345 	s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
346 };
347 
348 void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy,
349 				   struct wiphy_work *work);
350 
351 void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev);
352 
353 void cfg80211_close_dependents(struct cfg80211_registered_device *rdev,
354 			       struct wireless_dev *wdev);
355 
356 /* free object */
357 void cfg80211_dev_free(struct cfg80211_registered_device *rdev);
358 
359 int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
360 			char *newname);
361 
362 void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
363 
364 void cfg80211_bss_expire(struct cfg80211_registered_device *rdev);
365 void cfg80211_bss_age(struct cfg80211_registered_device *rdev,
366                       unsigned long age_secs);
367 void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,
368 				     unsigned int link,
369 				     struct ieee80211_channel *channel);
370 
371 /* IBSS */
372 int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
373 			 struct net_device *dev,
374 			 struct cfg80211_ibss_params *params,
375 			 struct cfg80211_cached_keys *connkeys);
376 void cfg80211_clear_ibss(struct net_device *dev, bool nowext);
377 int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
378 			struct net_device *dev, bool nowext);
379 void __cfg80211_ibss_joined(struct net_device *dev, struct cfg80211_bss *bss);
380 int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
381 			    struct wireless_dev *wdev);
382 
383 /* mesh */
384 extern const struct mesh_config default_mesh_config;
385 extern const struct mesh_setup default_mesh_setup;
386 int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
387 			 struct net_device *dev,
388 			 struct mesh_setup *setup,
389 			 const struct mesh_config *conf);
390 int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
391 			struct net_device *dev);
392 int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
393 			      struct wireless_dev *wdev,
394 			      struct cfg80211_chan_def *chandef);
395 
396 /* OCB */
397 int cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
398 		      struct net_device *dev,
399 		      struct ocb_setup *setup);
400 int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
401 		       struct net_device *dev);
402 
403 /* AP */
404 int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
405 		     struct net_device *dev, int link,
406 		     bool notify);
407 
408 /* MLME */
409 int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
410 		       struct net_device *dev,
411 		       struct cfg80211_auth_request *req);
412 int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
413 			struct net_device *dev,
414 			struct cfg80211_assoc_request *req,
415 			struct netlink_ext_ack *extack);
416 int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
417 			 struct net_device *dev, const u8 *bssid,
418 			 const u8 *ie, int ie_len, u16 reason,
419 			 bool local_state_change);
420 int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
421 			   struct net_device *dev, const u8 *ap_addr,
422 			   const u8 *ie, int ie_len, u16 reason,
423 			   bool local_state_change);
424 void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
425 			struct net_device *dev);
426 int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid,
427 				u16 frame_type, const u8 *match_data,
428 				int match_len, bool multicast_rx,
429 				struct netlink_ext_ack *extack);
430 void cfg80211_mgmt_registrations_update_wk(struct work_struct *wk);
431 void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid);
432 void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev);
433 int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
434 			  struct wireless_dev *wdev,
435 			  struct cfg80211_mgmt_tx_params *params,
436 			  u64 cookie);
437 int cfg80211_mlme_mgmt_tx_unlocked(struct cfg80211_registered_device *rdev,
438 				   struct wireless_dev *wdev,
439 				   struct cfg80211_mgmt_tx_params *params,
440 				   u64 cookie);
441 void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
442 			       const struct ieee80211_ht_cap *ht_capa_mask);
443 void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
444 				const struct ieee80211_vht_cap *vht_capa_mask);
445 
446 /* SME events */
447 int cfg80211_connect(struct cfg80211_registered_device *rdev,
448 		     struct net_device *dev,
449 		     struct cfg80211_connect_params *connect,
450 		     struct cfg80211_cached_keys *connkeys,
451 		     const u8 *prev_bssid);
452 void __cfg80211_connect_result(struct net_device *dev,
453 			       struct cfg80211_connect_resp_params *params,
454 			       bool wextev);
455 void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
456 			     size_t ie_len, u16 reason, bool from_ap);
457 int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
458 			struct net_device *dev, u16 reason,
459 			bool wextev);
460 void __cfg80211_roamed(struct wireless_dev *wdev,
461 		       struct cfg80211_roam_info *info);
462 void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *peer_addr,
463 				const u8 *td_bitmap, u8 td_bitmap_len);
464 int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
465 			      struct wireless_dev *wdev);
466 void cfg80211_autodisconnect_wk(struct wiphy *wiphy, struct wiphy_work *work);
467 
468 /* SME implementation */
469 void cfg80211_conn_work(struct work_struct *work);
470 void cfg80211_sme_scan_done(struct net_device *dev);
471 bool cfg80211_sme_rx_assoc_resp(struct wireless_dev *wdev, u16 status);
472 void cfg80211_sme_rx_auth(struct wireless_dev *wdev, const u8 *buf, size_t len);
473 void cfg80211_sme_disassoc(struct wireless_dev *wdev);
474 void cfg80211_sme_deauth(struct wireless_dev *wdev);
475 void cfg80211_sme_auth_timeout(struct wireless_dev *wdev);
476 void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev);
477 void cfg80211_sme_abandon_assoc(struct wireless_dev *wdev);
478 
479 /* internal helpers */
480 bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher);
481 bool cfg80211_cigtk_supported(struct wireless_dev *wdev,
482 			      struct genl_info *info);
483 bool cfg80211_valid_key_idx(struct wireless_dev *wdev,
484 			    int key_idx, enum nl80211_key_type type,
485 			    const u8 *mac_addr);
486 int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
487 				   struct wireless_dev *wdev,
488 				   struct key_params *params, int key_idx,
489 				   enum nl80211_key_type type,
490 				   const u8 *mac_addr);
491 void __cfg80211_scan_done(struct wiphy *wiphy, struct wiphy_work *wk);
492 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
493 			   bool send_message);
494 void cfg80211_add_sched_scan_req(struct cfg80211_registered_device *rdev,
495 				 struct cfg80211_sched_scan_request *req);
496 int cfg80211_sched_scan_req_possible(struct cfg80211_registered_device *rdev,
497 				     bool want_multi);
498 void cfg80211_sched_scan_results_wk(struct work_struct *work);
499 int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
500 				 struct cfg80211_sched_scan_request *req,
501 				 bool driver_initiated);
502 int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
503 			       u64 reqid, bool driver_initiated);
504 void cfg80211_upload_connect_keys(struct wireless_dev *wdev);
505 int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
506 			  struct net_device *dev, enum nl80211_iftype ntype,
507 			  struct vif_params *params);
508 void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
509 void cfg80211_process_wiphy_works(struct cfg80211_registered_device *rdev,
510 				  struct wiphy_work *end);
511 void cfg80211_process_wdev_events(struct wireless_dev *wdev);
512 
513 bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
514 				u32 center_freq_khz, u32 bw_khz);
515 
516 int cfg80211_scan(struct cfg80211_registered_device *rdev);
517 
518 extern struct work_struct cfg80211_disconnect_work;
519 
520 #define NL80211_BSS_USE_FOR_ALL	(NL80211_BSS_USE_FOR_NORMAL | \
521 				 NL80211_BSS_USE_FOR_MLD_LINK)
522 
523 void cfg80211_set_dfs_state(struct wiphy *wiphy,
524 			    const struct cfg80211_chan_def *chandef,
525 			    enum nl80211_dfs_state dfs_state);
526 
527 void cfg80211_set_cac_state(struct wiphy *wiphy,
528 			    const struct cfg80211_chan_def *chandef,
529 			    bool cac_ongoing);
530 
531 void cfg80211_dfs_channels_update_work(struct work_struct *work);
532 
533 void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev);
534 
535 int
536 cfg80211_start_background_radar_detection(struct cfg80211_registered_device *rdev,
537 					  struct wireless_dev *wdev,
538 					  struct cfg80211_chan_def *chandef);
539 
540 void cfg80211_stop_radar_detection(struct wireless_dev *wdev);
541 void cfg80211_stop_background_radar_detection(struct wireless_dev *wdev);
542 
543 void cfg80211_background_cac_done_wk(struct work_struct *work);
544 
545 void cfg80211_background_cac_abort_wk(struct work_struct *work);
546 
547 bool cfg80211_any_wiphy_oper_chan(struct wiphy *wiphy,
548 				  struct ieee80211_channel *chan);
549 
550 bool cfg80211_beaconing_iface_active(struct wireless_dev *wdev);
551 
552 bool cfg80211_is_sub_chan(struct cfg80211_chan_def *chandef,
553 			  struct ieee80211_channel *chan,
554 			  bool primary_only);
555 bool cfg80211_wdev_on_sub_chan(struct wireless_dev *wdev,
556 			       struct ieee80211_channel *chan,
557 			       bool primary_only);
558 bool _cfg80211_chandef_usable(struct wiphy *wiphy,
559 			      const struct cfg80211_chan_def *chandef,
560 			      u32 prohibited_flags,
561 			      u32 permitting_flags);
562 
563 static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
564 {
565 	unsigned long end = jiffies;
566 
567 	if (end >= start)
568 		return jiffies_to_msecs(end - start);
569 
570 	return jiffies_to_msecs(end + (ULONG_MAX - start) + 1);
571 }
572 
573 int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
574 				 struct net_device *dev,
575 				 struct cfg80211_chan_def *chandef);
576 
577 int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
578 			   const u8 *rates, unsigned int n_rates,
579 			   u32 *mask);
580 
581 int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
582 				 enum nl80211_iftype iftype, u32 beacon_int);
583 
584 void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
585 			       enum nl80211_iftype iftype, int num);
586 
587 void cfg80211_leave_locked(struct cfg80211_registered_device *rdev,
588 			   struct wireless_dev *wdev, int link_id);
589 
590 void cfg80211_leave(struct cfg80211_registered_device *rdev,
591 		    struct wireless_dev *wdev,
592 		    int link_id);
593 
594 void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
595 			      struct wireless_dev *wdev);
596 
597 void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
598 		       struct wireless_dev *wdev);
599 void cfg80211_stop_pd(struct cfg80211_registered_device *rdev,
600 		      struct wireless_dev *wdev);
601 
602 int cfg80211_nan_set_local_schedule(struct cfg80211_registered_device *rdev,
603 				    struct wireless_dev *wdev,
604 				    struct cfg80211_nan_local_sched *sched);
605 
606 int cfg80211_nan_set_non_evac_channels(struct cfg80211_registered_device *rdev,
607 				       struct wireless_dev *wdev,
608 				       struct cfg80211_nan_non_evac_channels *channels);
609 
610 struct cfg80211_internal_bss *
611 cfg80211_bss_update(struct cfg80211_registered_device *rdev,
612 		    struct cfg80211_internal_bss *tmp,
613 		    bool signal_valid, unsigned long ts);
614 
615 enum ieee80211_ap_reg_power
616 cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len,
617 			     u32 client_flags);
618 
619 #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
620 #define CFG80211_DEV_WARN_ON(cond)	WARN_ON(cond)
621 #else
622 /*
623  * Trick to enable using it as a condition,
624  * and also not give a warning when it's
625  * not used that way.
626  */
627 #define CFG80211_DEV_WARN_ON(cond)	({bool __r = (cond); __r; })
628 #endif
629 
630 void cfg80211_release_pmsr(struct wireless_dev *wdev, u32 portid);
631 void cfg80211_pmsr_wdev_down(struct wireless_dev *wdev);
632 void cfg80211_pmsr_free_wk(struct wiphy *wiphy, struct wiphy_work *work);
633 
634 void cfg80211_remove_link(struct wireless_dev *wdev, unsigned int link_id);
635 void cfg80211_remove_links(struct wireless_dev *wdev);
636 int cfg80211_remove_virtual_intf(struct cfg80211_registered_device *rdev,
637 				 struct wireless_dev *wdev);
638 void cfg80211_wdev_release_link_bsses(struct wireless_dev *wdev, u16 link_mask);
639 
640 int cfg80211_assoc_ml_reconf(struct cfg80211_registered_device *rdev,
641 			     struct net_device *dev,
642 			     struct cfg80211_ml_reconf_req *req);
643 
644 /**
645  * struct cfg80211_colocated_ap - colocated AP information
646  *
647  * @list: linked list to all colocated APs
648  * @bssid: BSSID of the reported AP
649  * @ssid: SSID of the reported AP
650  * @ssid_len: length of the ssid
651  * @center_freq: frequency the reported AP is on
652  * @unsolicited_probe: the reported AP is part of an ESS, where all the APs
653  *	that operate in the same channel as the reported AP and that might be
654  *	detected by a STA receiving this frame, are transmitting unsolicited
655  *	Probe Response frames every 20 TUs
656  * @oct_recommended: OCT is recommended to exchange MMPDUs with the reported AP
657  * @same_ssid: the reported AP has the same SSID as the reporting AP
658  * @multi_bss: the reported AP is part of a multiple BSSID set
659  * @transmitted_bssid: the reported AP is the transmitting BSSID
660  * @colocated_ess: all the APs that share the same ESS as the reported AP are
661  *	colocated and can be discovered via legacy bands.
662  * @short_ssid_valid: short_ssid is valid and can be used
663  * @short_ssid: the short SSID for this SSID
664  * @psd_20: The 20MHz PSD EIRP of the primary 20MHz channel for the reported AP
665  */
666 struct cfg80211_colocated_ap {
667 	struct list_head list;
668 	u8 bssid[ETH_ALEN];
669 	u8 ssid[IEEE80211_MAX_SSID_LEN];
670 	size_t ssid_len;
671 	u32 short_ssid;
672 	u32 center_freq;
673 	u8 unsolicited_probe:1,
674 	   oct_recommended:1,
675 	   same_ssid:1,
676 	   multi_bss:1,
677 	   transmitted_bssid:1,
678 	   colocated_ess:1,
679 	   short_ssid_valid:1;
680 	s8 psd_20;
681 };
682 
683 #if IS_ENABLED(CONFIG_CFG80211_KUNIT_TEST)
684 #define EXPORT_SYMBOL_IF_CFG80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym)
685 #define VISIBLE_IF_CFG80211_KUNIT
686 void cfg80211_free_coloc_ap_list(struct list_head *coloc_ap_list);
687 
688 int cfg80211_parse_colocated_ap(const struct cfg80211_bss_ies *ies,
689 				struct list_head *list);
690 
691 size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen,
692 			   const u8 *subie, size_t subie_len,
693 			   u8 *new_ie, size_t new_ie_len);
694 #else
695 #define EXPORT_SYMBOL_IF_CFG80211_KUNIT(sym)
696 #define VISIBLE_IF_CFG80211_KUNIT static
697 #endif /* IS_ENABLED(CONFIG_CFG80211_KUNIT_TEST) */
698 
699 #endif /* __NET_WIRELESS_CORE_H */
700