xref: /wlan-driver/qcacld-3.0/core/cds/inc/cds_regdomain.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011, 2014-2018, 2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 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 /*
21  * Notifications and licenses are retained for attribution purposes only.
22  */
23 /*
24  * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
25  * Copyright (c) 2005-2006 Atheros Communications, Inc.
26  * Copyright (c) 2010, Atheros Communications Inc.
27  *
28  * Redistribution and use in source and binary forms are permitted
29  * provided that the following conditions are met:
30  * 1. The materials contained herein are unmodified and are used
31  *    unmodified.
32  * 2. Redistributions of source code must retain the above copyright
33  *    notice, this list of conditions and the following NO
34  *    ''WARRANTY'' disclaimer below (''Disclaimer''), without
35  *    modification.
36  * 3. Redistributions in binary form must reproduce at minimum a
37  *    disclaimer similar to the Disclaimer below and any redistribution
38  *    must be conditioned upon including a substantially similar
39  *    Disclaimer requirement for further binary redistribution.
40  * 4. Neither the names of the above-listed copyright holders nor the
41  *    names of any contributors may be used to endorse or promote
42  *    product derived from this software without specific prior written
43  *    permission.
44  *
45  * NO WARRANTY
46  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47  * ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
49  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
51  * FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57  * SUCH DAMAGES.
58  *
59  * This module contains the regulatory domain private structure definitions .
60  *
61  */
62 
63 #ifndef __CDS_REGDOMAIN_H
64 #define __CDS_REGDOMAIN_H
65 
66 #include <wlan_cmn.h>
67 #include <reg_services_public_struct.h>
68 #include "reg_db.h"
69 
70 #define MIN_TX_PWR_CAP    8
71 #define MAX_TX_PWR_CAP    24
72 
73 #define CTRY_DEFAULT          0
74 #define CTRY_FLAG             0x8000
75 #define WORLD_ROAMING_FLAG    0x4000
76 #define WORLD_ROAMING_MASK    0x00F0
77 #define WORLD_ROAMING_PREFIX  0x0060
78 /**
79  * struct reg_dmn_pair: regulatory domain pair
80  * @reg_dmn_pair: reg domain pair
81  * @reg_dmn_5ghz: 5G reg domain
82  * @reg_dmn_2ghz: 2G reg domain
83  * @single_cc: country with this reg domain
84  */
85 struct reg_dmn_pair {
86 	uint16_t reg_dmn_pair;
87 	uint16_t reg_dmn_5ghz;
88 	uint16_t reg_dmn_2ghz;
89 	uint16_t single_cc;
90 };
91 
92 /**
93  * struct country_code_to_reg_dmn: country code to reg domain mapping
94  * @country_code: country code
95  * @reg_dmn_pair: regulatory domain pair
96  * @alpha2: country alpha2
97  * @name: country name
98  */
99 struct country_code_to_reg_dmn {
100 	uint16_t country_code;
101 	uint16_t reg_dmn_pair;
102 	const char *alpha2;
103 	const char *name;
104 };
105 
106 /**
107  * struct reg_dmn: regulatory domain structure
108  * @reg_dmn: regulatory domain
109  * @conformance_test_limit:  CTL limit
110  */
111 struct reg_dmn {
112 	uint16_t reg_dmn;
113 	uint8_t conformance_test_limit;
114 };
115 
116 /**
117  * struct reg_dmn_tables: reg domain table
118  * @reg_dmn_pairs: list of reg domain pairs
119  * @all_countries: list of countries
120  * @reg_dmns: list of reg domains
121  * @reg_dmn_pairs_cnt: count of reg domain pairs
122  * @all_countries_cnt: count of countries
123  * @reg_dmns_cnt: count of reg domains
124  */
125 struct reg_dmn_tables {
126 	const struct reg_dmn_pair *reg_dmn_pairs;
127 	const struct country_code_to_reg_dmn *all_countries;
128 	const struct reg_dmn *reg_dmns;
129 	uint16_t reg_dmn_pairs_cnt;
130 	uint16_t all_countries_cnt;
131 	uint16_t reg_dmns_cnt;
132 };
133 
134 int32_t cds_fill_some_regulatory_info(struct regulatory *reg);
135 int32_t cds_get_country_from_alpha2(uint8_t *alpha2);
136 void cds_fill_and_send_ctl_to_fw(struct regulatory *reg);
137 /**
138  * cds_is_etsi_europe_country - check ETSI Europe country or not
139  * @country: country string with two Characters
140  *
141  * Return: true if country in ETSI Europe country list
142  */
143 bool cds_is_etsi_europe_country(uint8_t *country);
144 #endif /* __CDS_REGDOMAIN_H */
145