core.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  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-2024 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 <net/genetlink.h>
  18. #include <net/cfg80211.h>
  19. #include "reg.h"
  20. #define WIPHY_IDX_INVALID -1
  21. struct cfg80211_registered_device {
  22. const struct cfg80211_ops *ops;
  23. struct list_head list;
  24. /* rfkill support */
  25. struct rfkill_ops rfkill_ops;
  26. struct work_struct rfkill_block;
  27. /* ISO / IEC 3166 alpha2 for which this device is receiving
  28. * country IEs on, this can help disregard country IEs from APs
  29. * on the same alpha2 quickly. The alpha2 may differ from
  30. * cfg80211_regdomain's alpha2 when an intersection has occurred.
  31. * If the AP is reconfigured this can also be used to tell us if
  32. * the country on the country IE changed. */
  33. char country_ie_alpha2[2];
  34. /*
  35. * the driver requests the regulatory core to set this regulatory
  36. * domain as the wiphy's. Only used for %REGULATORY_WIPHY_SELF_MANAGED
  37. * devices using the regulatory_set_wiphy_regd() API
  38. */
  39. const struct ieee80211_regdomain *requested_regd;
  40. /* If a Country IE has been received this tells us the environment
  41. * which its telling us its in. This defaults to ENVIRON_ANY */
  42. enum environment_cap env;
  43. /* wiphy index, internal only */
  44. int wiphy_idx;
  45. /* protected by RTNL */
  46. int devlist_generation, wdev_id;
  47. int opencount;
  48. wait_queue_head_t dev_wait;
  49. struct list_head beacon_registrations;
  50. spinlock_t beacon_registrations_lock;
  51. /* protected by RTNL only */
  52. int num_running_ifaces;
  53. int num_running_monitor_ifaces;
  54. u64 cookie_counter;
  55. /* BSSes/scanning */
  56. spinlock_t bss_lock;
  57. struct list_head bss_list;
  58. struct rb_root bss_tree;
  59. u32 bss_generation;
  60. u32 bss_entries;
  61. struct cfg80211_scan_request *scan_req; /* protected by RTNL */
  62. struct cfg80211_scan_request *int_scan_req;
  63. struct sk_buff *scan_msg;
  64. struct list_head sched_scan_req_list;
  65. time64_t suspend_at;
  66. struct wiphy_work scan_done_wk;
  67. struct genl_info *cur_cmd_info;
  68. struct work_struct conn_work;
  69. struct work_struct event_work;
  70. struct delayed_work dfs_update_channels_wk;
  71. struct wireless_dev *background_radar_wdev;
  72. struct cfg80211_chan_def background_radar_chandef;
  73. struct delayed_work background_cac_done_wk;
  74. struct work_struct background_cac_abort_wk;
  75. /* netlink port which started critical protocol (0 means not started) */
  76. u32 crit_proto_nlportid;
  77. struct cfg80211_coalesce *coalesce;
  78. struct work_struct destroy_work;
  79. struct wiphy_work sched_scan_stop_wk;
  80. struct work_struct sched_scan_res_wk;
  81. struct cfg80211_chan_def radar_chandef;
  82. struct work_struct propagate_radar_detect_wk;
  83. struct cfg80211_chan_def cac_done_chandef;
  84. struct work_struct propagate_cac_done_wk;
  85. struct work_struct mgmt_registrations_update_wk;
  86. /* lock for all wdev lists */
  87. spinlock_t mgmt_registrations_lock;
  88. struct work_struct wiphy_work;
  89. struct list_head wiphy_work_list;
  90. /* protects the list above */
  91. spinlock_t wiphy_work_lock;
  92. bool suspended;
  93. /* must be last because of the way we do wiphy_priv(),
  94. * and it should at least be aligned to NETDEV_ALIGN */
  95. struct wiphy wiphy __aligned(NETDEV_ALIGN);
  96. };
  97. static inline
  98. struct cfg80211_registered_device *wiphy_to_rdev(struct wiphy *wiphy)
  99. {
  100. BUG_ON(!wiphy);
  101. return container_of(wiphy, struct cfg80211_registered_device, wiphy);
  102. }
  103. static inline void
  104. cfg80211_rdev_free_wowlan(struct cfg80211_registered_device *rdev)
  105. {
  106. #ifdef CONFIG_PM
  107. int i;
  108. if (!rdev->wiphy.wowlan_config)
  109. return;
  110. for (i = 0; i < rdev->wiphy.wowlan_config->n_patterns; i++)
  111. kfree(rdev->wiphy.wowlan_config->patterns[i].mask);
  112. kfree(rdev->wiphy.wowlan_config->patterns);
  113. if (rdev->wiphy.wowlan_config->tcp &&
  114. rdev->wiphy.wowlan_config->tcp->sock)
  115. sock_release(rdev->wiphy.wowlan_config->tcp->sock);
  116. kfree(rdev->wiphy.wowlan_config->tcp);
  117. kfree(rdev->wiphy.wowlan_config->nd_config);
  118. kfree(rdev->wiphy.wowlan_config);
  119. #endif
  120. }
  121. static inline u64 cfg80211_assign_cookie(struct cfg80211_registered_device *rdev)
  122. {
  123. u64 r = ++rdev->cookie_counter;
  124. if (WARN_ON(r == 0))
  125. r = ++rdev->cookie_counter;
  126. return r;
  127. }
  128. extern struct workqueue_struct *cfg80211_wq;
  129. extern struct list_head cfg80211_rdev_list;
  130. extern int cfg80211_rdev_list_generation;
  131. /* This is constructed like this so it can be used in if/else */
  132. static inline int for_each_rdev_check_rtnl(void)
  133. {
  134. ASSERT_RTNL();
  135. return 0;
  136. }
  137. #define for_each_rdev(rdev) \
  138. if (for_each_rdev_check_rtnl()) {} else \
  139. list_for_each_entry(rdev, &cfg80211_rdev_list, list)
  140. enum bss_source_type {
  141. BSS_SOURCE_DIRECT = 0,
  142. BSS_SOURCE_MBSSID,
  143. BSS_SOURCE_STA_PROFILE,
  144. };
  145. struct cfg80211_internal_bss {
  146. struct list_head list;
  147. struct list_head hidden_list;
  148. struct rb_node rbn;
  149. u64 ts_boottime;
  150. unsigned long ts;
  151. unsigned long refcount;
  152. atomic_t hold;
  153. /* time at the start of the reception of the first octet of the
  154. * timestamp field of the last beacon/probe received for this BSS.
  155. * The time is the TSF of the BSS specified by %parent_bssid.
  156. */
  157. u64 parent_tsf;
  158. /* the BSS according to which %parent_tsf is set. This is set to
  159. * the BSS that the interface that requested the scan was connected to
  160. * when the beacon/probe was received.
  161. */
  162. u8 parent_bssid[ETH_ALEN] __aligned(2);
  163. enum bss_source_type bss_source;
  164. /* must be last because of priv member */
  165. struct cfg80211_bss pub;
  166. };
  167. static inline struct cfg80211_internal_bss *bss_from_pub(struct cfg80211_bss *pub)
  168. {
  169. return container_of(pub, struct cfg80211_internal_bss, pub);
  170. }
  171. static inline void cfg80211_hold_bss(struct cfg80211_internal_bss *bss)
  172. {
  173. atomic_inc(&bss->hold);
  174. if (bss->pub.transmitted_bss) {
  175. bss = container_of(bss->pub.transmitted_bss,
  176. struct cfg80211_internal_bss, pub);
  177. atomic_inc(&bss->hold);
  178. }
  179. }
  180. static inline void cfg80211_unhold_bss(struct cfg80211_internal_bss *bss)
  181. {
  182. int r = atomic_dec_return(&bss->hold);
  183. WARN_ON(r < 0);
  184. if (bss->pub.transmitted_bss) {
  185. bss = container_of(bss->pub.transmitted_bss,
  186. struct cfg80211_internal_bss, pub);
  187. r = atomic_dec_return(&bss->hold);
  188. WARN_ON(r < 0);
  189. }
  190. }
  191. struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx);
  192. int get_wiphy_idx(struct wiphy *wiphy);
  193. struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx);
  194. int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
  195. struct net *net);
  196. void cfg80211_init_wdev(struct wireless_dev *wdev);
  197. void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
  198. struct wireless_dev *wdev);
  199. static inline bool cfg80211_has_monitors_only(struct cfg80211_registered_device *rdev)
  200. {
  201. lockdep_assert_held(&rdev->wiphy.mtx);
  202. return rdev->num_running_ifaces == rdev->num_running_monitor_ifaces &&
  203. rdev->num_running_ifaces > 0;
  204. }
  205. enum cfg80211_event_type {
  206. EVENT_CONNECT_RESULT,
  207. EVENT_ROAMED,
  208. EVENT_DISCONNECTED,
  209. EVENT_IBSS_JOINED,
  210. EVENT_STOPPED,
  211. EVENT_PORT_AUTHORIZED,
  212. };
  213. struct cfg80211_event {
  214. struct list_head list;
  215. enum cfg80211_event_type type;
  216. union {
  217. struct cfg80211_connect_resp_params cr;
  218. struct cfg80211_roam_info rm;
  219. struct {
  220. const u8 *ie;
  221. size_t ie_len;
  222. u16 reason;
  223. bool locally_generated;
  224. } dc;
  225. struct {
  226. u8 bssid[ETH_ALEN];
  227. struct ieee80211_channel *channel;
  228. } ij;
  229. struct {
  230. u8 peer_addr[ETH_ALEN];
  231. const u8 *td_bitmap;
  232. u8 td_bitmap_len;
  233. } pa;
  234. };
  235. };
  236. struct cfg80211_cached_keys {
  237. struct key_params params[4];
  238. u8 data[4][WLAN_KEY_LEN_WEP104];
  239. int def;
  240. };
  241. struct cfg80211_beacon_registration {
  242. struct list_head list;
  243. u32 nlportid;
  244. };
  245. struct cfg80211_cqm_config {
  246. struct rcu_head rcu_head;
  247. u32 rssi_hyst;
  248. s32 last_rssi_event_value;
  249. enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
  250. bool use_range_api;
  251. int n_rssi_thresholds;
  252. s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
  253. };
  254. void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy,
  255. struct wiphy_work *work);
  256. void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev);
  257. /* free object */
  258. void cfg80211_dev_free(struct cfg80211_registered_device *rdev);
  259. int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
  260. char *newname);
  261. void ieee80211_set_bitrate_flags(struct wiphy *wiphy);
  262. void cfg80211_bss_expire(struct cfg80211_registered_device *rdev);
  263. void cfg80211_bss_age(struct cfg80211_registered_device *rdev,
  264. unsigned long age_secs);
  265. void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev,
  266. unsigned int link,
  267. struct ieee80211_channel *channel);
  268. /* IBSS */
  269. int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
  270. struct net_device *dev,
  271. struct cfg80211_ibss_params *params,
  272. struct cfg80211_cached_keys *connkeys);
  273. void cfg80211_clear_ibss(struct net_device *dev, bool nowext);
  274. int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
  275. struct net_device *dev, bool nowext);
  276. void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  277. struct ieee80211_channel *channel);
  278. int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
  279. struct wireless_dev *wdev);
  280. /* mesh */
  281. extern const struct mesh_config default_mesh_config;
  282. extern const struct mesh_setup default_mesh_setup;
  283. int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
  284. struct net_device *dev,
  285. struct mesh_setup *setup,
  286. const struct mesh_config *conf);
  287. int cfg80211_leave_mesh(struct cfg80211_registered_device *rdev,
  288. struct net_device *dev);
  289. int cfg80211_set_mesh_channel(struct cfg80211_registered_device *rdev,
  290. struct wireless_dev *wdev,
  291. struct cfg80211_chan_def *chandef);
  292. /* OCB */
  293. int cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
  294. struct net_device *dev,
  295. struct ocb_setup *setup);
  296. int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
  297. struct net_device *dev);
  298. /* AP */
  299. int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
  300. struct net_device *dev, int link,
  301. bool notify);
  302. /* MLME */
  303. int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
  304. struct net_device *dev,
  305. struct cfg80211_auth_request *req);
  306. int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
  307. struct net_device *dev,
  308. struct cfg80211_assoc_request *req,
  309. struct netlink_ext_ack *extack);
  310. int cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
  311. struct net_device *dev, const u8 *bssid,
  312. const u8 *ie, int ie_len, u16 reason,
  313. bool local_state_change);
  314. int cfg80211_mlme_disassoc(struct cfg80211_registered_device *rdev,
  315. struct net_device *dev, const u8 *ap_addr,
  316. const u8 *ie, int ie_len, u16 reason,
  317. bool local_state_change);
  318. void cfg80211_mlme_down(struct cfg80211_registered_device *rdev,
  319. struct net_device *dev);
  320. int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_pid,
  321. u16 frame_type, const u8 *match_data,
  322. int match_len, bool multicast_rx,
  323. struct netlink_ext_ack *extack);
  324. void cfg80211_mgmt_registrations_update_wk(struct work_struct *wk);
  325. void cfg80211_mlme_unregister_socket(struct wireless_dev *wdev, u32 nlpid);
  326. void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev);
  327. int cfg80211_mlme_mgmt_tx(struct cfg80211_registered_device *rdev,
  328. struct wireless_dev *wdev,
  329. struct cfg80211_mgmt_tx_params *params,
  330. u64 *cookie);
  331. void cfg80211_oper_and_ht_capa(struct ieee80211_ht_cap *ht_capa,
  332. const struct ieee80211_ht_cap *ht_capa_mask);
  333. void cfg80211_oper_and_vht_capa(struct ieee80211_vht_cap *vht_capa,
  334. const struct ieee80211_vht_cap *vht_capa_mask);
  335. /* SME events */
  336. int cfg80211_connect(struct cfg80211_registered_device *rdev,
  337. struct net_device *dev,
  338. struct cfg80211_connect_params *connect,
  339. struct cfg80211_cached_keys *connkeys,
  340. const u8 *prev_bssid);
  341. void __cfg80211_connect_result(struct net_device *dev,
  342. struct cfg80211_connect_resp_params *params,
  343. bool wextev);
  344. void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
  345. size_t ie_len, u16 reason, bool from_ap);
  346. int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
  347. struct net_device *dev, u16 reason,
  348. bool wextev);
  349. void __cfg80211_roamed(struct wireless_dev *wdev,
  350. struct cfg80211_roam_info *info);
  351. void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *peer_addr,
  352. const u8 *td_bitmap, u8 td_bitmap_len);
  353. int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
  354. struct wireless_dev *wdev);
  355. void cfg80211_autodisconnect_wk(struct work_struct *work);
  356. /* SME implementation */
  357. void cfg80211_conn_work(struct work_struct *work);
  358. void cfg80211_sme_scan_done(struct net_device *dev);
  359. bool cfg80211_sme_rx_assoc_resp(struct wireless_dev *wdev, u16 status);
  360. void cfg80211_sme_rx_auth(struct wireless_dev *wdev, const u8 *buf, size_t len);
  361. void cfg80211_sme_disassoc(struct wireless_dev *wdev);
  362. void cfg80211_sme_deauth(struct wireless_dev *wdev);
  363. void cfg80211_sme_auth_timeout(struct wireless_dev *wdev);
  364. void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev);
  365. void cfg80211_sme_abandon_assoc(struct wireless_dev *wdev);
  366. /* internal helpers */
  367. bool cfg80211_supported_cipher_suite(struct wiphy *wiphy, u32 cipher);
  368. bool cfg80211_valid_key_idx(struct cfg80211_registered_device *rdev,
  369. int key_idx, bool pairwise);
  370. int cfg80211_validate_key_settings(struct cfg80211_registered_device *rdev,
  371. struct key_params *params, int key_idx,
  372. bool pairwise, const u8 *mac_addr);
  373. void __cfg80211_scan_done(struct wiphy *wiphy, struct wiphy_work *wk);
  374. void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
  375. bool send_message);
  376. void cfg80211_add_sched_scan_req(struct cfg80211_registered_device *rdev,
  377. struct cfg80211_sched_scan_request *req);
  378. int cfg80211_sched_scan_req_possible(struct cfg80211_registered_device *rdev,
  379. bool want_multi);
  380. void cfg80211_sched_scan_results_wk(struct work_struct *work);
  381. int cfg80211_stop_sched_scan_req(struct cfg80211_registered_device *rdev,
  382. struct cfg80211_sched_scan_request *req,
  383. bool driver_initiated);
  384. int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
  385. u64 reqid, bool driver_initiated);
  386. void cfg80211_upload_connect_keys(struct wireless_dev *wdev);
  387. int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
  388. struct net_device *dev, enum nl80211_iftype ntype,
  389. struct vif_params *params);
  390. void cfg80211_process_rdev_events(struct cfg80211_registered_device *rdev);
  391. void cfg80211_process_wiphy_works(struct cfg80211_registered_device *rdev,
  392. struct wiphy_work *end);
  393. void cfg80211_process_wdev_events(struct wireless_dev *wdev);
  394. bool cfg80211_does_bw_fit_range(const struct ieee80211_freq_range *freq_range,
  395. u32 center_freq_khz, u32 bw_khz);
  396. int cfg80211_scan(struct cfg80211_registered_device *rdev);
  397. extern struct work_struct cfg80211_disconnect_work;
  398. #define NL80211_BSS_USE_FOR_ALL (NL80211_BSS_USE_FOR_NORMAL | \
  399. NL80211_BSS_USE_FOR_MLD_LINK)
  400. void cfg80211_set_dfs_state(struct wiphy *wiphy,
  401. const struct cfg80211_chan_def *chandef,
  402. enum nl80211_dfs_state dfs_state);
  403. void cfg80211_dfs_channels_update_work(struct work_struct *work);
  404. void cfg80211_sched_dfs_chan_update(struct cfg80211_registered_device *rdev);
  405. int
  406. cfg80211_start_background_radar_detection(struct cfg80211_registered_device *rdev,
  407. struct wireless_dev *wdev,
  408. struct cfg80211_chan_def *chandef);
  409. void cfg80211_stop_background_radar_detection(struct wireless_dev *wdev);
  410. void cfg80211_background_cac_done_wk(struct work_struct *work);
  411. void cfg80211_background_cac_abort_wk(struct work_struct *work);
  412. bool cfg80211_any_wiphy_oper_chan(struct wiphy *wiphy,
  413. struct ieee80211_channel *chan);
  414. bool cfg80211_beaconing_iface_active(struct wireless_dev *wdev);
  415. bool cfg80211_is_sub_chan(struct cfg80211_chan_def *chandef,
  416. struct ieee80211_channel *chan,
  417. bool primary_only);
  418. bool cfg80211_wdev_on_sub_chan(struct wireless_dev *wdev,
  419. struct ieee80211_channel *chan,
  420. bool primary_only);
  421. bool _cfg80211_chandef_usable(struct wiphy *wiphy,
  422. const struct cfg80211_chan_def *chandef,
  423. u32 prohibited_flags,
  424. u32 permitting_flags);
  425. static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
  426. {
  427. unsigned long end = jiffies;
  428. if (end >= start)
  429. return jiffies_to_msecs(end - start);
  430. return jiffies_to_msecs(end + (ULONG_MAX - start) + 1);
  431. }
  432. int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
  433. struct cfg80211_chan_def *chandef);
  434. int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
  435. const u8 *rates, unsigned int n_rates,
  436. u32 *mask);
  437. int cfg80211_validate_beacon_int(struct cfg80211_registered_device *rdev,
  438. enum nl80211_iftype iftype, u32 beacon_int);
  439. void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
  440. enum nl80211_iftype iftype, int num);
  441. void cfg80211_leave(struct cfg80211_registered_device *rdev,
  442. struct wireless_dev *wdev);
  443. void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
  444. struct wireless_dev *wdev);
  445. void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
  446. struct wireless_dev *wdev);
  447. struct cfg80211_internal_bss *
  448. cfg80211_bss_update(struct cfg80211_registered_device *rdev,
  449. struct cfg80211_internal_bss *tmp,
  450. bool signal_valid, unsigned long ts);
  451. enum ieee80211_ap_reg_power
  452. cfg80211_get_6ghz_power_type(const u8 *elems, size_t elems_len);
  453. #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
  454. #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond)
  455. #else
  456. /*
  457. * Trick to enable using it as a condition,
  458. * and also not give a warning when it's
  459. * not used that way.
  460. */
  461. #define CFG80211_DEV_WARN_ON(cond) ({bool __r = (cond); __r; })
  462. #endif
  463. void cfg80211_release_pmsr(struct wireless_dev *wdev, u32 portid);
  464. void cfg80211_pmsr_wdev_down(struct wireless_dev *wdev);
  465. void cfg80211_pmsr_free_wk(struct work_struct *work);
  466. void cfg80211_remove_link(struct wireless_dev *wdev, unsigned int link_id);
  467. void cfg80211_remove_links(struct wireless_dev *wdev);
  468. int cfg80211_remove_virtual_intf(struct cfg80211_registered_device *rdev,
  469. struct wireless_dev *wdev);
  470. void cfg80211_wdev_release_link_bsses(struct wireless_dev *wdev, u16 link_mask);
  471. /**
  472. * struct cfg80211_colocated_ap - colocated AP information
  473. *
  474. * @list: linked list to all colocated APs
  475. * @bssid: BSSID of the reported AP
  476. * @ssid: SSID of the reported AP
  477. * @ssid_len: length of the ssid
  478. * @center_freq: frequency the reported AP is on
  479. * @unsolicited_probe: the reported AP is part of an ESS, where all the APs
  480. * that operate in the same channel as the reported AP and that might be
  481. * detected by a STA receiving this frame, are transmitting unsolicited
  482. * Probe Response frames every 20 TUs
  483. * @oct_recommended: OCT is recommended to exchange MMPDUs with the reported AP
  484. * @same_ssid: the reported AP has the same SSID as the reporting AP
  485. * @multi_bss: the reported AP is part of a multiple BSSID set
  486. * @transmitted_bssid: the reported AP is the transmitting BSSID
  487. * @colocated_ess: all the APs that share the same ESS as the reported AP are
  488. * colocated and can be discovered via legacy bands.
  489. * @short_ssid_valid: short_ssid is valid and can be used
  490. * @short_ssid: the short SSID for this SSID
  491. * @psd_20: The 20MHz PSD EIRP of the primary 20MHz channel for the reported AP
  492. */
  493. struct cfg80211_colocated_ap {
  494. struct list_head list;
  495. u8 bssid[ETH_ALEN];
  496. u8 ssid[IEEE80211_MAX_SSID_LEN];
  497. size_t ssid_len;
  498. u32 short_ssid;
  499. u32 center_freq;
  500. u8 unsolicited_probe:1,
  501. oct_recommended:1,
  502. same_ssid:1,
  503. multi_bss:1,
  504. transmitted_bssid:1,
  505. colocated_ess:1,
  506. short_ssid_valid:1;
  507. s8 psd_20;
  508. };
  509. #if IS_ENABLED(CONFIG_CFG80211_KUNIT_TEST)
  510. #define EXPORT_SYMBOL_IF_CFG80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym)
  511. #define VISIBLE_IF_CFG80211_KUNIT
  512. void cfg80211_free_coloc_ap_list(struct list_head *coloc_ap_list);
  513. int cfg80211_parse_colocated_ap(const struct cfg80211_bss_ies *ies,
  514. struct list_head *list);
  515. size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen,
  516. const u8 *subie, size_t subie_len,
  517. u8 *new_ie, size_t new_ie_len);
  518. #else
  519. #define EXPORT_SYMBOL_IF_CFG80211_KUNIT(sym)
  520. #define VISIBLE_IF_CFG80211_KUNIT static
  521. #endif /* IS_ENABLED(CONFIG_CFG80211_KUNIT_TEST) */
  522. #endif /* __NET_WIRELESS_CORE_H */