1b2e1b302SLuis R. Rodriguez #ifndef __NET_WIRELESS_REG_H 2b2e1b302SLuis R. Rodriguez #define __NET_WIRELESS_REG_H 390a53e44SJohannes Berg 490a53e44SJohannes Berg #include <net/cfg80211.h> 590a53e44SJohannes Berg 63b77d5ecSLuis R. Rodriguez /* 73b77d5ecSLuis R. Rodriguez * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> 82a537439SJohannes Berg * Copyright (C) 2019, 2023 Intel Corporation 93b77d5ecSLuis R. Rodriguez * 103b77d5ecSLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 113b77d5ecSLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 123b77d5ecSLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 133b77d5ecSLuis R. Rodriguez * 143b77d5ecSLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 153b77d5ecSLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 163b77d5ecSLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 173b77d5ecSLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 183b77d5ecSLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 193b77d5ecSLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 203b77d5ecSLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 213b77d5ecSLuis R. Rodriguez */ 22b2e1b302SLuis R. Rodriguez 23c37722bdSIlan peer enum ieee80211_regd_source { 24c37722bdSIlan peer REGD_SOURCE_INTERNAL_DB, 25c37722bdSIlan peer REGD_SOURCE_CRDA, 26e646a025SJohannes Berg REGD_SOURCE_CACHED, 27c37722bdSIlan peer }; 28c37722bdSIlan peer 29458f4f9eSJohannes Berg extern const struct ieee80211_regdomain __rcu *cfg80211_regdomain; 30f130347cSLuis R. Rodriguez 31e438768fSLuis R. Rodriguez bool reg_is_valid_request(const char *alpha2); 32a3d2eaf0SJohannes Berg bool is_world_regdom(const char *alpha2); 334c7d3982SLuis R. Rodriguez bool reg_supported_dfs_region(enum nl80211_dfs_regions dfs_region); 346c474799SLuis R. Rodriguez enum nl80211_dfs_regions reg_get_dfs_region(struct wiphy *wiphy); 35b2e1b302SLuis R. Rodriguez 3657b5ce07SLuis R. Rodriguez int regulatory_hint_user(const char *alpha2, 3757b5ce07SLuis R. Rodriguez enum nl80211_user_reg_hint_type user_reg_hint_type); 3805050753SIlan peer 3905050753SIlan peer /** 4005050753SIlan peer * regulatory_hint_indoor - hint operation in indoor env. or not 4105050753SIlan peer * @is_indoor: if true indicates that user space thinks that the 4205050753SIlan peer * device is operating in an indoor environment. 4305050753SIlan peer * @portid: the netlink port ID on which the hint was given. 4405050753SIlan peer */ 45dbda949bSJohannes Berg void regulatory_hint_indoor(bool is_indoor, u32 portid); 4605050753SIlan peer 4705050753SIlan peer /** 4805050753SIlan peer * regulatory_netlink_notify - notify on released netlink socket 4905050753SIlan peer * @portid: the netlink socket port ID 5005050753SIlan peer */ 5105050753SIlan peer void regulatory_netlink_notify(u32 portid); 52fe33eb39SLuis R. Rodriguez 5357b5ce07SLuis R. Rodriguez void wiphy_regulatory_register(struct wiphy *wiphy); 54bfead080SLuis R. Rodriguez void wiphy_regulatory_deregister(struct wiphy *wiphy); 553f2355cbSLuis R. Rodriguez 562fcc9f73SUwe Kleine-König int __init regulatory_init(void); 57b2e1b302SLuis R. Rodriguez void regulatory_exit(void); 58b2e1b302SLuis R. Rodriguez 59c37722bdSIlan peer int set_regdom(const struct ieee80211_regdomain *rd, 60c37722bdSIlan peer enum ieee80211_regd_source regd_src); 61c37722bdSIlan peer 6297524820SJanusz Dziedzic unsigned int reg_get_max_bandwidth(const struct ieee80211_regdomain *rd, 6397524820SJanusz Dziedzic const struct ieee80211_reg_rule *rule); 64b2e1b302SLuis R. Rodriguez 6557b5ce07SLuis R. Rodriguez bool reg_last_request_cell_base(void); 66eac03e38SSven Neumann 67cf03268eSJohannes Berg /** 68e38f8a7aSLuis R. Rodriguez * regulatory_hint_found_beacon - hints a beacon was found on a channel 69e38f8a7aSLuis R. Rodriguez * @wiphy: the wireless device where the beacon was found on 70e38f8a7aSLuis R. Rodriguez * @beacon_chan: the channel on which the beacon was found on 71e38f8a7aSLuis R. Rodriguez * @gfp: context flags 72e38f8a7aSLuis R. Rodriguez * 73e38f8a7aSLuis R. Rodriguez * This informs the wireless core that a beacon from an AP was found on 74e38f8a7aSLuis R. Rodriguez * the channel provided. This allows the wireless core to make educated 75e38f8a7aSLuis R. Rodriguez * guesses on regulatory to help with world roaming. This is only used for 76e38f8a7aSLuis R. Rodriguez * world roaming -- when we do not know our current location. This is 77e38f8a7aSLuis R. Rodriguez * only useful on channels 12, 13 and 14 on the 2 GHz band as channels 78e38f8a7aSLuis R. Rodriguez * 1-11 are already enabled by the world regulatory domain; and on 79e38f8a7aSLuis R. Rodriguez * non-radar 5 GHz channels. 80e38f8a7aSLuis R. Rodriguez * 81e38f8a7aSLuis R. Rodriguez * Drivers do not need to call this, cfg80211 will do it for after a scan 8237184244SLuis R. Rodriguez * on a newly found BSS. If you cannot make use of this feature you can 8337184244SLuis R. Rodriguez * set the wiphy->disable_beacon_hints to true. 84e38f8a7aSLuis R. Rodriguez */ 85dbda949bSJohannes Berg void regulatory_hint_found_beacon(struct wiphy *wiphy, 86e38f8a7aSLuis R. Rodriguez struct ieee80211_channel *beacon_chan, 87e38f8a7aSLuis R. Rodriguez gfp_t gfp); 88e38f8a7aSLuis R. Rodriguez 898b19e6caSLuis R. Rodriguez /** 90789fd033SLuis R. Rodriguez * regulatory_hint_country_ie - hints a country IE as a regulatory domain 918b19e6caSLuis R. Rodriguez * @wiphy: the wireless device giving the hint (used only for reporting 928b19e6caSLuis R. Rodriguez * conflicts) 9384920e3eSLuis R. Rodriguez * @band: the band on which the country IE was received on. This determines 9484920e3eSLuis R. Rodriguez * the band we'll process the country IE channel triplets for. 958b19e6caSLuis R. Rodriguez * @country_ie: pointer to the country IE 968b19e6caSLuis R. Rodriguez * @country_ie_len: length of the country IE 978b19e6caSLuis R. Rodriguez * 988b19e6caSLuis R. Rodriguez * We will intersect the rd with the what CRDA tells us should apply 998b19e6caSLuis R. Rodriguez * for the alpha2 this country IE belongs to, this prevents APs from 1008b19e6caSLuis R. Rodriguez * sending us incorrect or outdated information against a country. 10184920e3eSLuis R. Rodriguez * 10284920e3eSLuis R. Rodriguez * The AP is expected to provide Country IE channel triplets for the 10384920e3eSLuis R. Rodriguez * band it is on. It is technically possible for APs to send channel 10484920e3eSLuis R. Rodriguez * country IE triplets even for channels outside of the band they are 10584920e3eSLuis R. Rodriguez * in but for that they would have to use the regulatory extension 10684920e3eSLuis R. Rodriguez * in combination with a triplet but this behaviour is currently 10784920e3eSLuis R. Rodriguez * not observed. For this reason if a triplet is seen with channel 10884920e3eSLuis R. Rodriguez * information for a band the BSS is not present in it will be ignored. 1098b19e6caSLuis R. Rodriguez */ 110789fd033SLuis R. Rodriguez void regulatory_hint_country_ie(struct wiphy *wiphy, 11157fbcce3SJohannes Berg enum nl80211_band band, 1129caf0364SJohannes Berg const u8 *country_ie, 1138b19e6caSLuis R. Rodriguez u8 country_ie_len); 1148b19e6caSLuis R. Rodriguez 11509d989d1SLuis R. Rodriguez /** 116e1b18549SGeert Uytterhoeven * regulatory_hint_disconnect - informs all devices have been disconnected 11709d989d1SLuis R. Rodriguez * 11809d989d1SLuis R. Rodriguez * Regulotory rules can be enhanced further upon scanning and upon 11909d989d1SLuis R. Rodriguez * connection to an AP. These rules become stale if we disconnect 12009d989d1SLuis R. Rodriguez * and go to another country, whether or not we suspend and resume. 12109d989d1SLuis R. Rodriguez * If we suspend, go to another country and resume we'll automatically 12209d989d1SLuis R. Rodriguez * get disconnected shortly after resuming and things will be reset as well. 12309d989d1SLuis R. Rodriguez * This routine is a helper to restore regulatory settings to how they were 12409d989d1SLuis R. Rodriguez * prior to our first connect attempt. This includes ignoring country IE and 12509d989d1SLuis R. Rodriguez * beacon regulatory hints. The ieee80211_regdom module parameter will always 12609d989d1SLuis R. Rodriguez * be respected but if a user had set the regulatory domain that will take 12709d989d1SLuis R. Rodriguez * precedence. 12809d989d1SLuis R. Rodriguez * 12909d989d1SLuis R. Rodriguez * Must be called from process context. 13009d989d1SLuis R. Rodriguez */ 13109d989d1SLuis R. Rodriguez void regulatory_hint_disconnect(void); 13209d989d1SLuis R. Rodriguez 133174e0cd2SIlan Peer /** 134174e0cd2SIlan Peer * cfg80211_get_unii - get the U-NII band for the frequency 135174e0cd2SIlan Peer * @freq: the frequency for which we want to get the UNII band. 1362a537439SJohannes Berg * 137174e0cd2SIlan Peer * Get a value specifying the U-NII band frequency belongs to. 138174e0cd2SIlan Peer * U-NII bands are defined by the FCC in C.F.R 47 part 15. 139174e0cd2SIlan Peer * 140*2bf78f0fSJohannes Berg * Return: -EINVAL if freq is invalid, 0 for UNII-1, 1 for UNII-2A, 141174e0cd2SIlan Peer * 2 for UNII-2B, 3 for UNII-2C and 4 for UNII-3. 142174e0cd2SIlan Peer */ 143174e0cd2SIlan Peer int cfg80211_get_unii(int freq); 144174e0cd2SIlan Peer 145c8866e55SIlan Peer /** 146c8866e55SIlan Peer * regulatory_indoor_allowed - is indoor operation allowed 147*2bf78f0fSJohannes Berg * Return: %true if indoor operation is allowed, %false otherwise 148c8866e55SIlan Peer */ 149c8866e55SIlan Peer bool regulatory_indoor_allowed(void); 150c8866e55SIlan Peer 151b35a51c7SVasanthakumar Thiagarajan /* 152b35a51c7SVasanthakumar Thiagarajan * Grace period to timeout pre-CAC results on the dfs channels. This timeout 153b35a51c7SVasanthakumar Thiagarajan * value is used for Non-ETSI domain. 154b35a51c7SVasanthakumar Thiagarajan * TODO: May be make this timeout available through regdb? 155b35a51c7SVasanthakumar Thiagarajan */ 156b35a51c7SVasanthakumar Thiagarajan #define REG_PRE_CAC_EXPIRY_GRACE_MS 2000 157b35a51c7SVasanthakumar Thiagarajan 158b35a51c7SVasanthakumar Thiagarajan /** 15989766727SVasanthakumar Thiagarajan * regulatory_propagate_dfs_state - Propagate DFS channel state to other wiphys 1602a537439SJohannes Berg * @wiphy: wiphy on which radar is detected and the event will be propagated 16189766727SVasanthakumar Thiagarajan * to other available wiphys having the same DFS domain 1622a537439SJohannes Berg * @chandef: Channel definition of radar detected channel 1632a537439SJohannes Berg * @dfs_state: DFS channel state to be set 1642a537439SJohannes Berg * @event: Type of radar event which triggered this DFS state change 16589766727SVasanthakumar Thiagarajan * 16689766727SVasanthakumar Thiagarajan * This function should be called with rtnl lock held. 16789766727SVasanthakumar Thiagarajan */ 16889766727SVasanthakumar Thiagarajan void regulatory_propagate_dfs_state(struct wiphy *wiphy, 16989766727SVasanthakumar Thiagarajan struct cfg80211_chan_def *chandef, 17089766727SVasanthakumar Thiagarajan enum nl80211_dfs_state dfs_state, 17189766727SVasanthakumar Thiagarajan enum nl80211_radar_event event); 17289766727SVasanthakumar Thiagarajan 17389766727SVasanthakumar Thiagarajan /** 17489766727SVasanthakumar Thiagarajan * reg_dfs_domain_same - Checks if both wiphy have same DFS domain configured 1752a537439SJohannes Berg * @wiphy1: wiphy it's dfs_region to be checked against that of wiphy2 1762a537439SJohannes Berg * @wiphy2: wiphy it's dfs_region to be checked against that of wiphy1 177*2bf78f0fSJohannes Berg * Return: %true if both wiphys have the same DFS domain, %false otherwise 17889766727SVasanthakumar Thiagarajan */ 17989766727SVasanthakumar Thiagarajan bool reg_dfs_domain_same(struct wiphy *wiphy1, struct wiphy *wiphy2); 1801ea4ff3eSJohannes Berg 1811ea4ff3eSJohannes Berg /** 1821ea4ff3eSJohannes Berg * reg_reload_regdb - reload the regulatory.db firmware file 183*2bf78f0fSJohannes Berg * Return: 0 for success, an error code otherwise 1841ea4ff3eSJohannes Berg */ 1851ea4ff3eSJohannes Berg int reg_reload_regdb(void); 1861ea4ff3eSJohannes Berg 1879be61558SAndrei Otcheretianski /** 1889be61558SAndrei Otcheretianski * reg_check_channels - schedule regulatory enforcement 1899be61558SAndrei Otcheretianski */ 1909be61558SAndrei Otcheretianski void reg_check_channels(void); 1919be61558SAndrei Otcheretianski 19290a53e44SJohannes Berg extern const u8 shipped_regdb_certs[]; 19390a53e44SJohannes Berg extern unsigned int shipped_regdb_certs_len; 19490a53e44SJohannes Berg extern const u8 extra_regdb_certs[]; 19590a53e44SJohannes Berg extern unsigned int extra_regdb_certs_len; 19690a53e44SJohannes Berg 197b2e1b302SLuis R. Rodriguez #endif /* __NET_WIRELESS_REG_H */ 198