xref: /wlan-driver/qcacld-3.0/core/hdd/inc/wlan_hdd_regulatory.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #if !defined __HDD_REGULATORY_H
21 #define __HDD_REGULATORY_H
22 
23 /**
24  * DOC: wlan_hdd_regulatory.h
25  *
26  * HDD Regulatory prototype implementation
27  */
28 
29 struct hdd_context;
30 
31 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) || defined(WITH_BACKPORTS)
32 #define IEEE80211_CHAN_PASSIVE_SCAN IEEE80211_CHAN_NO_IR
33 #endif
34 
35 #define CHANNEL_LIST_UPDATE_TIMEOUT 4500
36 
37 /**
38  * hdd_update_regulatory_config() - API to update regulatory config parameters
39  * @hdd_ctx: HDD context
40  *
41  * Return: 0 on success, err on failure
42  */
43 int hdd_update_regulatory_config(struct hdd_context *hdd_ctx);
44 
45 /**
46  * hdd_init_regulatory_update_event() - Initialize the regulatory update event
47  * @hdd_ctx: HDD context
48  *
49  * Return: 0 on success, err on failure
50  */
51 int hdd_init_regulatory_update_event(struct hdd_context *hdd_ctx);
52 
53 /**
54  * hdd_deinit_regulatory_update_event() - Cleanup the regulatory update event
55  * @hdd_ctx: HDD context
56  *
57  * Return: none
58  */
59 void hdd_deinit_regulatory_update_event(struct hdd_context *hdd_ctx);
60 
61 int hdd_regulatory_init(struct hdd_context *hdd_ctx, struct wiphy *wiphy);
62 
63 /**
64  * hdd_regulatory_deinit() - cleanup all components of regulatory
65  * @hdd_ctx: HDD context
66  *
67  * Return: None
68  */
69 void hdd_regulatory_deinit(struct hdd_context *hdd_ctx);
70 
71 void hdd_program_country_code(struct hdd_context *hdd_ctx);
72 void hdd_reset_global_reg_params(void);
73 
74 /**
75  * hdd_send_wiphy_regd_sync_event() - sends the regulatory sync event
76  * @hdd_ctx: HDD context
77  *
78  * Return: None
79  */
80 void hdd_send_wiphy_regd_sync_event(struct hdd_context *hdd_ctx);
81 
82 /**
83  * hdd_reg_wait_for_country_change() - Wait for country change event
84  * @hdd_ctx: the HDD context
85  *
86  * Return: None
87  */
88 void hdd_reg_wait_for_country_change(struct hdd_context *hdd_ctx);
89 
90 /**
91  * hdd_reg_set_country() - helper function for setting the regulatory country
92  * @hdd_ctx: the HDD context to set the country for
93  * @country_code: the two character country code to configure
94  *
95  * Return: zero for success, non-zero error code for failure
96  */
97 int hdd_reg_set_country(struct hdd_context *hdd_ctx, char *country_code);
98 
99 /**
100  * hdd_reg_legacy_setband_to_reg_wifi_band_bitmap() - Convert the user space
101  *	band input to a bitmap of band capabilities, with reg_wifi_band as the
102  *	bit value
103  * @qca_setband: user space/setband value band input, can be 0, 1, or 2
104  *
105  * Return: bitmap on top of reg_wifi_band of bands enabled
106  */
107 uint32_t hdd_reg_legacy_setband_to_reg_wifi_band_bitmap(uint8_t qca_setband);
108 
109 /**
110  * hdd_reg_set_band() - helper function for setting the regulatory band
111  * @dev: the network device to set the band for
112  * @band_bitmap: the band bitmap to configure
113  *
114  * Return: zero for success, non-zero error code for failure
115  */
116 int hdd_reg_set_band(struct net_device *dev, uint32_t band_bitmap);
117 
118 /**
119  * hdd_update_indoor_channel() - enable/disable indoor channel
120  * @hdd_ctx: hdd context
121  * @disable: whether to enable / disable indoor channel
122  *
123  * enable/disable indoor channel in wiphy/cds
124  *
125  * Return: void
126  */
127 void hdd_update_indoor_channel(struct  hdd_context *hdd_ctx,
128 					bool disable);
129 /**
130  * hdd_modify_indoor_channel_state_flags() - modify wiphy flags and cds state
131  * @hdd_ctx: HDD context
132  * @wiphy_chan: wiphy channel number
133  * @cds_chan: cds channel structure
134  * @chan_enum: channel enum maintain in reg db
135  * @chan_num: channel index
136  * @disable: Disable/enable the flags
137  *
138  * Modify wiphy flags and cds state if channel is indoor.
139  *
140  * Return: void
141  */
142 void hdd_modify_indoor_channel_state_flags(
143 	struct hdd_context *hdd_ctx,
144 	struct ieee80211_channel *wiphy_chan,
145 	struct regulatory_channel *cds_chan,
146 	enum channel_enum chan_enum, int chan_num, bool disable);
147 
148 /**
149  * hdd_update_regdb_offload_config() - Update regdb offload disable ini
150  * for regulatory component.
151  * @hdd_ctx: HDD context
152  *
153  * Return: None
154  */
155 void hdd_update_regdb_offload_config(struct hdd_context *hdd_ctx);
156 
157 #endif
158