xref: /wlan-driver/qcacld-3.0/core/cds/src/cds_regdomain.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2011,2013-2020 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /*
21*5113495bSYour Name  * Notifications and licenses are retained for attribution purposes only.
22*5113495bSYour Name  */
23*5113495bSYour Name /*
24*5113495bSYour Name  * Copyright (c) 2002-2006 Sam Leffler, Errno Consulting
25*5113495bSYour Name  * Copyright (c) 2005-2006 Atheros Communications, Inc.
26*5113495bSYour Name  * Copyright (c) 2010, Atheros Communications Inc.
27*5113495bSYour Name  *
28*5113495bSYour Name  * Redistribution and use in source and binary forms are permitted
29*5113495bSYour Name  * provided that the following conditions are met:
30*5113495bSYour Name  * 1. The materials contained herein are unmodified and are used
31*5113495bSYour Name  *    unmodified.
32*5113495bSYour Name  * 2. Redistributions of source code must retain the above copyright
33*5113495bSYour Name  *    notice, this list of conditions and the following NO
34*5113495bSYour Name  *    ''WARRANTY'' disclaimer below (''Disclaimer''), without
35*5113495bSYour Name  *    modification.
36*5113495bSYour Name  * 3. Redistributions in binary form must reproduce at minimum a
37*5113495bSYour Name  *    disclaimer similar to the Disclaimer below and any redistribution
38*5113495bSYour Name  *    must be conditioned upon including a substantially similar
39*5113495bSYour Name  *    Disclaimer requirement for further binary redistribution.
40*5113495bSYour Name  * 4. Neither the names of the above-listed copyright holders nor the
41*5113495bSYour Name  *    names of any contributors may be used to endorse or promote
42*5113495bSYour Name  *    product derived from this software without specific prior written
43*5113495bSYour Name  *    permission.
44*5113495bSYour Name  *
45*5113495bSYour Name  * NO WARRANTY
46*5113495bSYour Name  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
47*5113495bSYour Name  * ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
48*5113495bSYour Name  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
49*5113495bSYour Name  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50*5113495bSYour Name  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
51*5113495bSYour Name  * FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
52*5113495bSYour Name  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
53*5113495bSYour Name  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54*5113495bSYour Name  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55*5113495bSYour Name  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
56*5113495bSYour Name  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57*5113495bSYour Name  * SUCH DAMAGES.
58*5113495bSYour Name  */
59*5113495bSYour Name 
60*5113495bSYour Name #include "qdf_types.h"
61*5113495bSYour Name #include "wma.h"
62*5113495bSYour Name #include "cds_regdomain.h"
63*5113495bSYour Name 
64*5113495bSYour Name 
65*5113495bSYour Name static const struct reg_dmn_pair g_reg_dmn_pairs[] = {
66*5113495bSYour Name 	{NO_ENUMRD, FCC8, FCCA, CTRY_DEFAULT},
67*5113495bSYour Name 	{NULL1_WORLD, NULL1, WORLD, CTRY_DEFAULT},
68*5113495bSYour Name 	{FCC1_FCCA, FCC1, FCCA, CTRY_DEFAULT},
69*5113495bSYour Name 	{FCC1_WORLD, FCC1, WORLD, CTRY_DEFAULT},
70*5113495bSYour Name 	{FCC2_WORLD, FCC2, WORLD, CTRY_DEFAULT},
71*5113495bSYour Name 	{FCC2_ETSIC, FCC2, ETSIC, CTRY_DEFAULT},
72*5113495bSYour Name 	{FCC2_FCCA, FCC2, FCCA, CTRY_DEFAULT},
73*5113495bSYour Name 	{FCC3_FCCA, FCC3, FCCA, CTRY_DEFAULT},
74*5113495bSYour Name 	{FCC3_WORLD, FCC3, WORLD, CTRY_DEFAULT},
75*5113495bSYour Name 	{FCC3_ETSIC, FCC3, ETSIC, CTRY_DEFAULT},
76*5113495bSYour Name 	{FCC4_FCCA, FCC4, FCCA, CTRY_DEFAULT},
77*5113495bSYour Name 	{FCC5_FCCA, FCC5, FCCA, CTRY_DEFAULT},
78*5113495bSYour Name 	{FCC6_FCCA, FCC6, FCCA, CTRY_DEFAULT},
79*5113495bSYour Name 	{FCC7_FCCA, FCC7, FCCA, CTRY_DEFAULT},
80*5113495bSYour Name 	{FCC8_FCCA, FCC8, FCCA, CTRY_DEFAULT},
81*5113495bSYour Name 	{FCC6_WORLD, FCC6, WORLD, CTRY_DEFAULT},
82*5113495bSYour Name 	{FCC9_FCCA, FCC9, FCCA, CTRY_DEFAULT},
83*5113495bSYour Name 	{FCC10_FCCA, FCC10, FCCA, CTRY_DEFAULT},
84*5113495bSYour Name 	{FCC11_WORLD, FCC11, WORLD, CTRY_DEFAULT},
85*5113495bSYour Name 	{FCC13_WORLD, FCC13, WORLD, CTRY_DEFAULT},
86*5113495bSYour Name 	{FCC14_FCCB, FCC14, FCCB, CTRY_DEFAULT},
87*5113495bSYour Name 	{ETSI1_WORLD, ETSI1, WORLD, CTRY_DEFAULT},
88*5113495bSYour Name 	{ETSI3_WORLD, ETSI3, WORLD, CTRY_DEFAULT},
89*5113495bSYour Name 	{ETSI4_WORLD, ETSI4, WORLD, CTRY_DEFAULT},
90*5113495bSYour Name 	{ETSI7_WORLD, ETSI4, WORLD, CTRY_DEFAULT},
91*5113495bSYour Name 	{ETSI8_WORLD, ETSI8, WORLD, CTRY_DEFAULT},
92*5113495bSYour Name 	{ETSI9_WORLD, ETSI9, WORLD, CTRY_DEFAULT},
93*5113495bSYour Name 	{APL4_WORLD, APL4, WORLD, CTRY_DEFAULT},
94*5113495bSYour Name 	{APL2_WORLD, APL2, WORLD, CTRY_DEFAULT},
95*5113495bSYour Name 	{APL2_FCCA, APL2, FCCA, CTRY_DEFAULT},
96*5113495bSYour Name 	{APL2_ETSIC, APL2, ETSIC, CTRY_DEFAULT},
97*5113495bSYour Name 	{APL1_WORLD, APL1, WORLD, CTRY_DEFAULT},
98*5113495bSYour Name 	{APL1_ETSIC, APL1, ETSIC, CTRY_DEFAULT},
99*5113495bSYour Name 	{APL6_WORLD, APL6, WORLD, CTRY_DEFAULT},
100*5113495bSYour Name 	{APL7_FCCA, APL7, FCCA, CTRY_DEFAULT},
101*5113495bSYour Name 	{APL8_WORLD, APL8, WORLD, CTRY_DEFAULT},
102*5113495bSYour Name 	{APL9_WORLD, APL9, WORLD, CTRY_DEFAULT},
103*5113495bSYour Name 	{APL10_WORLD, APL10, WORLD, CTRY_DEFAULT},
104*5113495bSYour Name 	{APL12_WORLD, APL12, WORLD, CTRY_DEFAULT},
105*5113495bSYour Name 	{APL13_WORLD, APL13, WORLD, CTRY_DEFAULT},
106*5113495bSYour Name 	{APL14_WORLD, APL14, WORLD, CTRY_DEFAULT},
107*5113495bSYour Name 	{APL15_WORLD, APL15, WORLD, CTRY_DEFAULT},
108*5113495bSYour Name 	{APL16_WORLD, APL16, WORLD, CTRY_DEFAULT},
109*5113495bSYour Name 	{APL17_ETSID, APL17, WORLD, CTRY_DEFAULT},
110*5113495bSYour Name 	{APL20_WORLD, APL20, WORLD, CTRY_DEFAULT},
111*5113495bSYour Name 	{APL23_WORLD, APL23, WORLD, CTRY_DEFAULT},
112*5113495bSYour Name 	{WOR0_WORLD, WOR0_WORLD, WOR0_WORLD, CTRY_DEFAULT},
113*5113495bSYour Name 	{WOR1_WORLD, WOR1_WORLD, WOR1_WORLD, CTRY_DEFAULT},
114*5113495bSYour Name 	{WOR2_WORLD, WOR2_WORLD, WOR2_WORLD, CTRY_DEFAULT},
115*5113495bSYour Name 	{WOR3_WORLD, WOR3_WORLD, WOR3_WORLD, CTRY_DEFAULT},
116*5113495bSYour Name 	{WOR4_FCCA, WOR4_FCCA, WOR4_FCCA, CTRY_DEFAULT},
117*5113495bSYour Name 	{WOR5_ETSIC, WOR5_ETSIC, WOR5_ETSIC, CTRY_DEFAULT},
118*5113495bSYour Name 	{WOR01_WORLD, WOR01_WORLD, WOR01_WORLD, CTRY_DEFAULT},
119*5113495bSYour Name 	{WOR02_WORLD, WOR02_WORLD, WOR02_WORLD, CTRY_DEFAULT},
120*5113495bSYour Name 	{EU1_WORLD, EU1_WORLD, EU1_WORLD, CTRY_DEFAULT},
121*5113495bSYour Name 	{WOR9_WORLD, WOR9_WORLD, WOR9_WORLD, CTRY_DEFAULT},
122*5113495bSYour Name 	{WORA_WORLD, WORA_WORLD, WORA_WORLD, CTRY_DEFAULT},
123*5113495bSYour Name 	{WORB_WORLD, WORB_WORLD, WORB_WORLD, CTRY_DEFAULT},
124*5113495bSYour Name 	{WORC_WORLD, WORC_WORLD, WORC_WORLD, CTRY_DEFAULT},
125*5113495bSYour Name 	{MKK5_MKKC, MKK5, MKKC, CTRY_JAPAN15},
126*5113495bSYour Name 	{MKK5_MKKA2, MKK5, MKKA, CTRY_DEFAULT},
127*5113495bSYour Name };
128*5113495bSYour Name 
129*5113495bSYour Name static const struct country_code_to_reg_dmn g_all_countries[] = {
130*5113495bSYour Name 	{CTRY_AFGHANISTAN, ETSI1_WORLD, "AF", "AFGHANISTAN"},
131*5113495bSYour Name 	{CTRY_ALBANIA, ETSI1_WORLD, "AL", "ALBANIA"},
132*5113495bSYour Name 	{CTRY_ALGERIA, APL13_WORLD, "DZ", "ALGERIA"},
133*5113495bSYour Name 	{CTRY_AMERICAN_SAMOA, FCC3_FCCA, "AS", "AMERICAN SAMOA"},
134*5113495bSYour Name 	{CTRY_ANGUILLA, ETSI1_WORLD, "AI", "ANGUILLA"},
135*5113495bSYour Name 	{CTRY_ARGENTINA, APL17_ETSID, "AR", "ARGENTINA"},
136*5113495bSYour Name 	{CTRY_ARMENIA, ETSI4_WORLD, "AM", "ARMENIA"},
137*5113495bSYour Name 	{CTRY_ARUBA, ETSI1_WORLD, "AW", "ARUBA"},
138*5113495bSYour Name 	{CTRY_AUSTRALIA, FCC6_WORLD, "AU", "AUSTRALIA"},
139*5113495bSYour Name 	{CTRY_AUSTRIA, ETSI1_WORLD, "AT", "AUSTRIA"},
140*5113495bSYour Name 	{CTRY_AZERBAIJAN, ETSI4_WORLD, "AZ", "AZERBAIJAN"},
141*5113495bSYour Name 	{CTRY_BAHAMAS, FCC3_WORLD, "BS", "BAHAMAS"},
142*5113495bSYour Name 	{CTRY_BAHRAIN, APL15_WORLD, "BH", "BAHRAIN"},
143*5113495bSYour Name 	{CTRY_BANGLADESH, APL1_WORLD, "BD", "BANGLADESH"},
144*5113495bSYour Name 	{CTRY_BARBADOS, FCC2_WORLD, "BB", "BARBADOS"},
145*5113495bSYour Name 	{CTRY_BELARUS, ETSI1_WORLD, "BY", "BELARUS"},
146*5113495bSYour Name 	{CTRY_BELGIUM, ETSI1_WORLD, "BE", "BELGIUM"},
147*5113495bSYour Name 	{CTRY_BELIZE, ETSI8_WORLD, "BZ", "BELIZE"},
148*5113495bSYour Name 	{CTRY_BERMUDA, FCC3_FCCA, "BM", "BERMUDA"},
149*5113495bSYour Name 	{CTRY_BHUTAN, ETSI1_WORLD, "BT", "BHUTAN"},
150*5113495bSYour Name 	{CTRY_BOLIVIA, APL8_WORLD, "BO", "BOLIVIA"},
151*5113495bSYour Name 	{CTRY_BOSNIA_HERZ, ETSI1_WORLD, "BA", "BOSNIA AND HERZEGOVINA"},
152*5113495bSYour Name 	{CTRY_BRAZIL, FCC3_ETSIC, "BR", "BRAZIL"},
153*5113495bSYour Name 	{CTRY_BRUNEI_DARUSSALAM, APL6_WORLD, "BN", "BRUNEI DARUSSALAM"},
154*5113495bSYour Name 	{CTRY_BULGARIA, ETSI1_WORLD, "BG", "BULGARIA"},
155*5113495bSYour Name 	{CTRY_BURKINA_FASO, FCC3_WORLD, "BF", "BURKINA-FASO"},
156*5113495bSYour Name 	{CTRY_CAMBODIA, ETSI1_WORLD, "KH", "CAMBODIA"},
157*5113495bSYour Name 	{CTRY_CANADA, FCC3_FCCA, "CA", "CANADA"},
158*5113495bSYour Name 	{CTRY_CAYMAN_ISLANDS, FCC3_WORLD, "KY", "CAYMAN ISLANDS"},
159*5113495bSYour Name 	{CTRY_CENTRAL_AFRICA_REPUBLIC, FCC3_WORLD, "CF", "AFRICA REPUBLIC"},
160*5113495bSYour Name 	{CTRY_CHAD, ETSI1_WORLD, "TD", "CHAD"},
161*5113495bSYour Name 	{CTRY_CHILE, APL23_WORLD, "CL", "CHILE"},
162*5113495bSYour Name 	{CTRY_CHINA, APL14_WORLD, "CN", "CHINA"},
163*5113495bSYour Name 	{CTRY_CHRISTMAS_ISLAND, FCC3_WORLD, "CX", "CHRISTMAS ISLAND"},
164*5113495bSYour Name 	{CTRY_COLOMBIA, FCC3_WORLD, "CO", "COLOMBIA"},
165*5113495bSYour Name 	{CTRY_COSTA_RICA, FCC3_WORLD, "CR", "COSTA RICA"},
166*5113495bSYour Name 	{CTRY_COTE_DIVOIRE, FCC3_WORLD, "CI", "COTE DIVOIRE"},
167*5113495bSYour Name 	{CTRY_CROATIA, ETSI1_WORLD, "HR", "CROATIA"},
168*5113495bSYour Name 	{CTRY_CYPRUS, ETSI1_WORLD, "CY", "CYPRUS"},
169*5113495bSYour Name 	{CTRY_CZECH, ETSI1_WORLD, "CZ", "CZECH REPUBLIC"},
170*5113495bSYour Name 	{CTRY_DENMARK, ETSI1_WORLD, "DK", "DENMARK"},
171*5113495bSYour Name 	{CTRY_DOMINICA, FCC2_FCCA, "DM", "DOMINICA"},
172*5113495bSYour Name 	{CTRY_DOMINICAN_REPUBLIC, FCC2_FCCA, "DO", "DOMINICAN REPUBLIC"},
173*5113495bSYour Name 	{CTRY_ECUADOR, FCC3_WORLD, "EC", "ECUADOR"},
174*5113495bSYour Name 	{CTRY_EGYPT, ETSI3_WORLD, "EG", "EGYPT"},
175*5113495bSYour Name 	{CTRY_EL_SALVADOR, FCC2_WORLD, "SV", "EL SALVADOR"},
176*5113495bSYour Name 	{CTRY_ESTONIA, ETSI1_WORLD, "EE", "ESTONIA"},
177*5113495bSYour Name 	{CTRY_ETHIOPIA, ETSI1_WORLD, "ET", "ETHIOPIA"},
178*5113495bSYour Name 	{CTRY_FINLAND, ETSI1_WORLD, "FI", "FINLAND"},
179*5113495bSYour Name 	{CTRY_FRANCE, ETSI1_WORLD, "FR", "FRANCE"},
180*5113495bSYour Name 	{CTRY_FRENCH_GUIANA, ETSI1_WORLD, "GF", "FRENCH GUIANA"},
181*5113495bSYour Name 	{CTRY_FRENCH_POLYNESIA, ETSI1_WORLD, "PF", "FRENCH POLYNESIA"},
182*5113495bSYour Name 	{CTRY_GEORGIA, ETSI4_WORLD, "GE", "GEORGIA"},
183*5113495bSYour Name 	{CTRY_GERMANY, ETSI1_WORLD, "DE", "GERMANY"},
184*5113495bSYour Name 	{CTRY_GHANA, FCC3_WORLD, "GH", "GHANA"},
185*5113495bSYour Name 	{CTRY_GIBRALTAR, ETSI1_WORLD, "GI", "GIBRALTAR"},
186*5113495bSYour Name 	{CTRY_GREECE, ETSI1_WORLD, "GR", "GREECE"},
187*5113495bSYour Name 	{CTRY_GREENLAND, ETSI1_WORLD, "GL", "GREENLAND"},
188*5113495bSYour Name 	{CTRY_GRENADA, FCC3_FCCA, "GD", "GRENADA"},
189*5113495bSYour Name 	{CTRY_GUADELOUPE, ETSI1_WORLD, "GP", "GUADELOUPE"},
190*5113495bSYour Name 	{CTRY_GUAM, FCC3_FCCA, "GU", "GUAM"},
191*5113495bSYour Name 	{CTRY_GUATEMALA, ETSI1_WORLD, "GT", "GUATEMALA"},
192*5113495bSYour Name 	{CTRY_GUYANA, APL1_ETSIC, "GY", "GUYANA"},
193*5113495bSYour Name 	{CTRY_HAITI, FCC3_FCCA, "HT", "HAITI"},
194*5113495bSYour Name 	{CTRY_HONDURAS, FCC13_WORLD, "HN", "HONDURAS"},
195*5113495bSYour Name 	{CTRY_HONG_KONG, FCC3_WORLD, "HK", "HONG KONG"},
196*5113495bSYour Name 	{CTRY_HUNGARY, ETSI1_WORLD, "HU", "HUNGARY"},
197*5113495bSYour Name 	{CTRY_ICELAND, ETSI1_WORLD, "IS", "ICELAND"},
198*5113495bSYour Name 	{CTRY_INDIA, APL15_WORLD, "IN", "INDIA"},
199*5113495bSYour Name 	{CTRY_INDONESIA, APL2_ETSIC, "ID", "INDONESIA"},
200*5113495bSYour Name 	{CTRY_IRAQ, ETSI1_WORLD, "IQ", "IRAQ"},
201*5113495bSYour Name 	{CTRY_IRELAND, ETSI1_WORLD, "IE", "IRELAND"},
202*5113495bSYour Name 	{CTRY_ISRAEL, ETSI3_WORLD, "IL", "ISRAEL"},
203*5113495bSYour Name 	{CTRY_ITALY, ETSI1_WORLD, "IT", "ITALY"},
204*5113495bSYour Name 	{CTRY_JAMAICA, FCC13_WORLD, "JM", "JAMAICA"},
205*5113495bSYour Name 	{CTRY_JORDAN, APL4_WORLD, "JO", "JORDAN"},
206*5113495bSYour Name 	{CTRY_KAZAKHSTAN, NULL1_WORLD, "KZ", "KAZAKHSTAN"},
207*5113495bSYour Name 	{CTRY_KENYA, APL12_WORLD, "KE", "KENYA"},
208*5113495bSYour Name 	{CTRY_KOREA_ROC, APL9_WORLD, "KR", "KOREA REPUBLIC"},
209*5113495bSYour Name 	{CTRY_KUWAIT, ETSI3_WORLD, "KW", "KUWAIT"},
210*5113495bSYour Name 	{CTRY_LATVIA, ETSI1_WORLD, "LV", "LATVIA"},
211*5113495bSYour Name 	{CTRY_LEBANON, FCC3_WORLD, "LB", "LEBANON"},
212*5113495bSYour Name 	{CTRY_LESOTHO, ETSI1_WORLD, "LS", "LESOTHO"},
213*5113495bSYour Name 	{CTRY_LIECHTENSTEIN, ETSI1_WORLD, "LI", "LIECHTENSTEIN"},
214*5113495bSYour Name 	{CTRY_LITHUANIA, ETSI1_WORLD, "LT", "LITHUANIA"},
215*5113495bSYour Name 	{CTRY_LUXEMBOURG, ETSI1_WORLD, "LU", "LUXEMBOURG"},
216*5113495bSYour Name 	{CTRY_MACAU, FCC3_WORLD, "MO", "MACAU SAR"},
217*5113495bSYour Name 	{CTRY_MACEDONIA, ETSI1_WORLD, "MK", "MACEDONIA, FYRO"},
218*5113495bSYour Name 	{CTRY_MALAWI, ETSI1_WORLD, "MW", "MALAWI"},
219*5113495bSYour Name 	{CTRY_MALAYSIA, FCC11_WORLD, "MY", "MALAYSIA"},
220*5113495bSYour Name 	{CTRY_MALDIVES, APL6_WORLD, "MV", "MALDIVES"},
221*5113495bSYour Name 	{CTRY_MALTA, ETSI1_WORLD, "MT", "MALTA"},
222*5113495bSYour Name 	{CTRY_MARSHALL_ISLANDS, FCC3_FCCA, "MH", "MARSHALL ISLANDS"},
223*5113495bSYour Name 	{CTRY_MARTINIQUE, ETSI1_WORLD, "MQ", "MARTINIQUE"},
224*5113495bSYour Name 	{CTRY_MAURITANIA, ETSI1_WORLD, "MR", "MAURITANA"},
225*5113495bSYour Name 	{CTRY_MAURITIUS, FCC3_WORLD, "MU", "MAURITIUS"},
226*5113495bSYour Name 	{CTRY_MAYOTTE, ETSI1_WORLD, "YT", "MAYOTTE"},
227*5113495bSYour Name 	{CTRY_MEXICO, FCC3_ETSIC, "MX", "MEXICO"},
228*5113495bSYour Name 	{CTRY_MICRONESIA, FCC3_FCCA, "FM", "MICRONESIA"},
229*5113495bSYour Name 	{CTRY_MOLDOVA, ETSI1_WORLD, "MD", "MOLDOVA"},
230*5113495bSYour Name 	{CTRY_MONACO, ETSI1_WORLD, "MC", "MONACO"},
231*5113495bSYour Name 	{CTRY_MONGOLIA, FCC3_WORLD, "MN", "MONGOLIA"},
232*5113495bSYour Name 	{CTRY_MONTENEGRO, ETSI1_WORLD, "ME", "MONTENEGRO"},
233*5113495bSYour Name 	{CTRY_MOROCCO, ETSI3_WORLD, "MA", "MOROCCO"},
234*5113495bSYour Name 	{CTRY_NAMIBIA, APL20_WORLD, "NA", "NAMIBIA"},
235*5113495bSYour Name 	{CTRY_NEPAL, APL23_WORLD, "NP", "NEPAL"},
236*5113495bSYour Name 	{CTRY_NETHERLANDS, ETSI1_WORLD, "NL", "NETHERLANDS"},
237*5113495bSYour Name 	{CTRY_NETHERLANDS_ANTILLES, ETSI1_WORLD, "AN", "NETHERLANDS ANTILLES"},
238*5113495bSYour Name 	{CTRY_NEW_ZEALAND, FCC3_ETSIC, "NZ", "NEW ZEALAND"},
239*5113495bSYour Name 	{CTRY_NIGERIA, APL8_WORLD, "NG", "NIGERIA"},
240*5113495bSYour Name 	{CTRY_NORTHERN_MARIANA_ISLANDS, FCC3_FCCA, "MP", "MARIANA ISLANDS"},
241*5113495bSYour Name 	{CTRY_NICARAGUA, FCC3_FCCA, "NI", "NICARAGUA"},
242*5113495bSYour Name 	{CTRY_NORWAY, ETSI1_WORLD, "NO", "NORWAY"},
243*5113495bSYour Name 	{CTRY_OMAN, ETSI1_WORLD, "OM", "OMAN"},
244*5113495bSYour Name 	{CTRY_PAKISTAN, APL1_ETSIC, "PK", "PAKISTAN"},
245*5113495bSYour Name 	{CTRY_PALAU, FCC3_FCCA, "PW", "PALAU"},
246*5113495bSYour Name 	{CTRY_PANAMA, FCC14_FCCB, "PA", "PANAMA"},
247*5113495bSYour Name 	{CTRY_PAPUA_NEW_GUINEA, FCC3_WORLD, "PG", "PAPUA NEW GUINEA"},
248*5113495bSYour Name 	{CTRY_PARAGUAY, FCC3_WORLD, "PY", "PARAGUAY"},
249*5113495bSYour Name 	{CTRY_PERU, FCC3_WORLD, "PE", "PERU"},
250*5113495bSYour Name 	{CTRY_PHILIPPINES, FCC3_WORLD, "PH", "PHILIPPINES"},
251*5113495bSYour Name 	{CTRY_POLAND, ETSI1_WORLD, "PL", "POLAND"},
252*5113495bSYour Name 	{CTRY_PORTUGAL, ETSI1_WORLD, "PT", "PORTUGAL"},
253*5113495bSYour Name 	{CTRY_PUERTO_RICO, FCC3_FCCA, "PR", "PUERTO RICO"},
254*5113495bSYour Name 	{CTRY_QATAR, APL1_WORLD, "QA", "QATAR"},
255*5113495bSYour Name 	{CTRY_REUNION, ETSI1_WORLD, "RE", "REUNION"},
256*5113495bSYour Name 	{CTRY_ROMANIA, ETSI1_WORLD, "RO", "ROMANIA"},
257*5113495bSYour Name 	{CTRY_RUSSIA, ETSI8_WORLD, "RU", "RUSSIA"},
258*5113495bSYour Name 	{CTRY_RWANDA, FCC3_WORLD, "RW", "RWANDA"},
259*5113495bSYour Name 	{CTRY_SAINT_BARTHELEMY, ETSI1_WORLD, "BL", "SAINT BARTHELEMY"},
260*5113495bSYour Name 	{CTRY_SAINT_KITTS_AND_NEVIS, APL10_WORLD, "KN", "SAINT KITTS"},
261*5113495bSYour Name 	{CTRY_SAINT_LUCIA, APL10_WORLD, "LC", "SAINT LUCIA"},
262*5113495bSYour Name 	{CTRY_SAINT_MARTIN, ETSI1_WORLD, "MF", "SAINT MARTIN"},
263*5113495bSYour Name 	{CTRY_SAINT_PIERRE_AND_MIQUELON, ETSI1_WORLD, "PM", "SAINT PIERRE"},
264*5113495bSYour Name 	{CTRY_SAINT_VINCENT_AND_THE_GRENADIENS, ETSI1_WORLD, "VC", "VINCENT"},
265*5113495bSYour Name 	{CTRY_SAMOA, ETSI1_WORLD, "WS", "SAMOA"},
266*5113495bSYour Name 	{CTRY_SAUDI_ARABIA, ETSI1_WORLD, "SA", "SAUDI ARABIA"},
267*5113495bSYour Name 	{CTRY_SENEGAL, FCC13_WORLD, "SN", "SENEGAL"},
268*5113495bSYour Name 	{CTRY_SERBIA, ETSI1_WORLD, "RS", "REPUBLIC OF SERBIA"},
269*5113495bSYour Name 	{CTRY_SINGAPORE, FCC3_WORLD, "SG", "SINGAPORE"},
270*5113495bSYour Name 	{CTRY_SLOVAKIA, ETSI1_WORLD, "SK", "SLOVAKIA"},
271*5113495bSYour Name 	{CTRY_SLOVENIA, ETSI1_WORLD, "SI", "SLOVENIA"},
272*5113495bSYour Name 	{CTRY_SOUTH_AFRICA, FCC3_WORLD, "ZA", "SOUTH AFRICA"},
273*5113495bSYour Name 	{CTRY_SPAIN, ETSI1_WORLD, "ES", "SPAIN"},
274*5113495bSYour Name 	{CTRY_SURINAME, ETSI1_WORLD, "SR", "SURINAME"},
275*5113495bSYour Name 	{CTRY_SRI_LANKA, FCC3_WORLD, "LK", "SRI LANKA"},
276*5113495bSYour Name 	{CTRY_SWEDEN, ETSI1_WORLD, "SE", "SWEDEN"},
277*5113495bSYour Name 	{CTRY_SWITZERLAND, ETSI1_WORLD, "CH", "SWITZERLAND"},
278*5113495bSYour Name 	{CTRY_TAIWAN, FCC3_FCCA, "TW", "TAIWAN"},
279*5113495bSYour Name 	{CTRY_TANZANIA, APL1_WORLD, "TZ", "TANZANIA"},
280*5113495bSYour Name 	{CTRY_THAILAND, FCC3_WORLD, "TH", "THAILAND"},
281*5113495bSYour Name 	{CTRY_TOGO, ETSI1_WORLD, "TG", "TOGO"},
282*5113495bSYour Name 	{CTRY_TRINIDAD_Y_TOBAGO, FCC3_WORLD, "TT", "TRINIDAD AND TOBAGO"},
283*5113495bSYour Name 	{CTRY_TUNISIA, ETSI3_WORLD, "TN", "TUNISIA"},
284*5113495bSYour Name 	{CTRY_TURKEY, ETSI1_WORLD, "TR", "TURKEY"},
285*5113495bSYour Name 	{CTRY_TURKS_AND_CAICOS, FCC3_WORLD, "TC" "TURKS AND CAICOS"},
286*5113495bSYour Name 	{CTRY_UGANDA, FCC3_WORLD, "UG", "UGANDA"},
287*5113495bSYour Name 	{CTRY_UKRAINE, ETSI9_WORLD, "UA", "UKRAINE"},
288*5113495bSYour Name 	{CTRY_UAE, FCC3_WORLD, "AE", "UNITED ARAB EMIRATES"},
289*5113495bSYour Name 	{CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB", "UNITED KINGDOM"},
290*5113495bSYour Name 	{CTRY_UNITED_STATES, FCC8_FCCA, "US", "UNITED STATES"},
291*5113495bSYour Name 	{CTRY_URUGUAY, FCC2_WORLD, "UY", "URUGUAY"},
292*5113495bSYour Name 	{CTRY_UZBEKISTAN, ETSI3_WORLD, "UZ", "UZBEKISTAN"},
293*5113495bSYour Name 	{CTRY_VANUATU, FCC3_WORLD, "VU", "VANUATU"},
294*5113495bSYour Name 	{CTRY_VENEZUELA, FCC2_ETSIC, "VE", "VENEZUELA"},
295*5113495bSYour Name 	{CTRY_VIET_NAM, FCC3_WORLD, "VN", "VIETNAM"},
296*5113495bSYour Name 	{CTRY_VIRGIN_ISLANDS, FCC3_FCCA, "VI", "VIRGIN ISLANDS"},
297*5113495bSYour Name 	{CTRY_WALLIS_AND_FUTUNA, ETSI1_WORLD, "WF" "WALLIS"},
298*5113495bSYour Name 	{CTRY_YEMEN, NULL1_WORLD, "YE", "YEMEN"},
299*5113495bSYour Name 	{CTRY_ZIMBABWE, ETSI1_WORLD, "ZW", "ZIMBABWE"},
300*5113495bSYour Name 	{CTRY_JAPAN15, MKK5_MKKC, "JP", "JAPAN"},
301*5113495bSYour Name 	{CTRY_XA, MKK5_MKKA2, "XA", "JAPAN PASSIVE"}
302*5113495bSYour Name };
303*5113495bSYour Name 
304*5113495bSYour Name static const struct reg_dmn g_reg_dmns[] = {
305*5113495bSYour Name 	{FCC1, CTL_FCC},
306*5113495bSYour Name 	{FCC2, CTL_FCC},
307*5113495bSYour Name 	{FCC3, CTL_FCC},
308*5113495bSYour Name 	{FCC4, CTL_FCC},
309*5113495bSYour Name 	{FCC5, CTL_FCC},
310*5113495bSYour Name 	{FCC6, CTL_FCC},
311*5113495bSYour Name 	{FCC7, CTL_FCC},
312*5113495bSYour Name 	{FCC8, CTL_FCC},
313*5113495bSYour Name 	{FCC9, CTL_FCC},
314*5113495bSYour Name 	{FCC10, CTL_FCC},
315*5113495bSYour Name 	{FCC11, CTL_FCC},
316*5113495bSYour Name 	{FCC13, CTL_FCC},
317*5113495bSYour Name 	{FCC14, CTL_FCC},
318*5113495bSYour Name 	{ETSI1, CTL_ETSI},
319*5113495bSYour Name 	{ETSI2, CTL_ETSI},
320*5113495bSYour Name 	{ETSI3, CTL_ETSI},
321*5113495bSYour Name 	{ETSI4, CTL_ETSI},
322*5113495bSYour Name 	{ETSI5, CTL_ETSI},
323*5113495bSYour Name 	{ETSI6, CTL_ETSI},
324*5113495bSYour Name 	{ETSI8, CTL_ETSI},
325*5113495bSYour Name 	{ETSI9, CTL_ETSI},
326*5113495bSYour Name 	{ETSI10, CTL_ETSI},
327*5113495bSYour Name 	{ETSI11, CTL_ETSI},
328*5113495bSYour Name 	{APL1, CTL_ETSI},
329*5113495bSYour Name 	{APL2, CTL_ETSI},
330*5113495bSYour Name 	{APL3, CTL_ETSI},
331*5113495bSYour Name 	{APL4, CTL_ETSI},
332*5113495bSYour Name 	{APL5, CTL_ETSI},
333*5113495bSYour Name 	{APL6, CTL_ETSI},
334*5113495bSYour Name 	{APL7, CTL_ETSI},
335*5113495bSYour Name 	{APL8, CTL_ETSI},
336*5113495bSYour Name 	{APL9, CTL_ETSI},
337*5113495bSYour Name 	{APL10, CTL_ETSI},
338*5113495bSYour Name 	{APL11, CTL_ETSI},
339*5113495bSYour Name 	{APL12, CTL_ETSI},
340*5113495bSYour Name 	{APL13, CTL_ETSI},
341*5113495bSYour Name 	{APL14, CTL_FCC},
342*5113495bSYour Name 	{APL15, CTL_FCC},
343*5113495bSYour Name 	{APL16, CTL_FCC},
344*5113495bSYour Name 	{APL17, CTL_FCC},
345*5113495bSYour Name 	{APL20, CTL_ETSI},
346*5113495bSYour Name 	{APL23, CTL_ETSI},
347*5113495bSYour Name 	{NULL1, CTL_NONE},
348*5113495bSYour Name 	{MKK3, CTL_MKK},
349*5113495bSYour Name 	{MKK5, CTL_MKK},
350*5113495bSYour Name 	{MKK11, CTL_MKK},
351*5113495bSYour Name 	{WORLD, CTL_ETSI},
352*5113495bSYour Name 	{FCCA, CTL_FCC},
353*5113495bSYour Name 	{MKKA, CTL_MKK},
354*5113495bSYour Name 	{MKKC, CTL_MKK},
355*5113495bSYour Name 	{ETSIC, CTL_ETSI},
356*5113495bSYour Name 	{WOR0_WORLD, CTL_NONE},
357*5113495bSYour Name 	{WOR1_WORLD, CTL_NONE},
358*5113495bSYour Name 	{WOR2_WORLD, CTL_NONE},
359*5113495bSYour Name 	{WOR3_WORLD, CTL_NONE},
360*5113495bSYour Name 	{WOR4_FCCA, CTL_NONE},
361*5113495bSYour Name 	{WOR5_ETSIC, CTL_NONE},
362*5113495bSYour Name 	{WOR01_WORLD, CTL_NONE},
363*5113495bSYour Name 	{WOR02_WORLD, CTL_NONE},
364*5113495bSYour Name 	{EU1_WORLD, CTL_NONE},
365*5113495bSYour Name 	{WOR9_WORLD, CTL_NONE},
366*5113495bSYour Name 	{WORA_WORLD, CTL_NONE},
367*5113495bSYour Name 	{WORB_WORLD, CTL_NONE},
368*5113495bSYour Name 	{WORC_WORLD, CTL_NONE},
369*5113495bSYour Name };
370*5113495bSYour Name 
371*5113495bSYour Name 
372*5113495bSYour Name struct reg_dmn_tables g_reg_dmn_tbl = {
373*5113495bSYour Name 	g_reg_dmn_pairs,
374*5113495bSYour Name 	g_all_countries,
375*5113495bSYour Name 	g_reg_dmns,
376*5113495bSYour Name 	QDF_ARRAY_SIZE(g_reg_dmn_pairs),
377*5113495bSYour Name 	QDF_ARRAY_SIZE(g_all_countries),
378*5113495bSYour Name 	QDF_ARRAY_SIZE(g_reg_dmns),
379*5113495bSYour Name };
380*5113495bSYour Name 
381*5113495bSYour Name /*
382*5113495bSYour Name  *  ETSI is updating EN 301 893, which specifies 5 GHz channel access
383*5113495bSYour Name  *  in Europe
384*5113495bSYour Name  */
385*5113495bSYour Name static const char etsi_europe_country[][2] = {
386*5113495bSYour Name 	{'A', 'T'},
387*5113495bSYour Name 	{'B', 'E'},
388*5113495bSYour Name 	{'B', 'G'},
389*5113495bSYour Name 	{'C', 'Z'},
390*5113495bSYour Name 	{'D', 'K'},
391*5113495bSYour Name 	{'E', 'E'},
392*5113495bSYour Name 	{'F', 'R'},
393*5113495bSYour Name 
394*5113495bSYour Name 	{'D', 'E'},
395*5113495bSYour Name 	{'I', 'S'},
396*5113495bSYour Name 	{'I', 'E'},
397*5113495bSYour Name 	{'I', 'T'},
398*5113495bSYour Name 	{'E', 'L'},
399*5113495bSYour Name 	{'E', 'S'},
400*5113495bSYour Name 	{'C', 'Y'},
401*5113495bSYour Name 
402*5113495bSYour Name 	{'L', 'V'},
403*5113495bSYour Name 	{'L', 'I'},
404*5113495bSYour Name 	{'L', 'T'},
405*5113495bSYour Name 	{'L', 'U'},
406*5113495bSYour Name 	{'H', 'U'},
407*5113495bSYour Name 	{'M', 'T'},
408*5113495bSYour Name 	{'N', 'L'},
409*5113495bSYour Name 
410*5113495bSYour Name 	{'N', 'O'},
411*5113495bSYour Name 	{'P', 'L'},
412*5113495bSYour Name 	{'P', 'T'},
413*5113495bSYour Name 	{'R', 'O'},
414*5113495bSYour Name 	{'S', 'I'},
415*5113495bSYour Name 	{'S', 'K'},
416*5113495bSYour Name 	{'T', 'R'},
417*5113495bSYour Name 
418*5113495bSYour Name 	{'F', 'I'},
419*5113495bSYour Name 	{'S', 'E'},
420*5113495bSYour Name 	{'C', 'H'},
421*5113495bSYour Name 	{'U', 'K'},
422*5113495bSYour Name 	{'H', 'R'},
423*5113495bSYour Name };
424*5113495bSYour Name 
cds_is_etsi_europe_country(uint8_t * country)425*5113495bSYour Name bool cds_is_etsi_europe_country(uint8_t *country)
426*5113495bSYour Name {
427*5113495bSYour Name 	int32_t i;
428*5113495bSYour Name 
429*5113495bSYour Name 	for (i = 0; i < QDF_ARRAY_SIZE(etsi_europe_country); i++) {
430*5113495bSYour Name 		if (country[0] == etsi_europe_country[i][0] &&
431*5113495bSYour Name 		    country[1] == etsi_europe_country[i][1])
432*5113495bSYour Name 			return true;
433*5113495bSYour Name 	}
434*5113495bSYour Name 
435*5113495bSYour Name 	return false;
436*5113495bSYour Name }
437*5113495bSYour Name 
438*5113495bSYour Name /**
439*5113495bSYour Name  * get_bdf_reg_dmn() - get regulatory domain from BDF
440*5113495bSYour Name  * @reg_dmn: BDF regulatory domain
441*5113495bSYour Name  *
442*5113495bSYour Name  * Return: regulatory domain
443*5113495bSYour Name  */
get_bdf_reg_dmn(uint16_t reg_dmn)444*5113495bSYour Name static uint16_t get_bdf_reg_dmn(uint16_t reg_dmn)
445*5113495bSYour Name {
446*5113495bSYour Name 	return reg_dmn & ~WORLD_ROAMING_FLAG;
447*5113495bSYour Name }
448*5113495bSYour Name 
449*5113495bSYour Name /**
450*5113495bSYour Name  * is_reg_dmn_valid() - is regulatory domain valid
451*5113495bSYour Name  * @reg_dmn: regulatory domain
452*5113495bSYour Name  *
453*5113495bSYour Name  * Return: true or false
454*5113495bSYour Name  */
is_reg_dmn_valid(uint16_t reg_dmn)455*5113495bSYour Name static bool is_reg_dmn_valid(uint16_t reg_dmn)
456*5113495bSYour Name {
457*5113495bSYour Name 	int32_t i;
458*5113495bSYour Name 
459*5113495bSYour Name 	if (reg_dmn & CTRY_FLAG) {
460*5113495bSYour Name 		uint16_t cc = reg_dmn & ~CTRY_FLAG;
461*5113495bSYour Name 
462*5113495bSYour Name 		for (i = 0; i < g_reg_dmn_tbl.all_countries_cnt; i++)
463*5113495bSYour Name 			if (g_reg_dmn_tbl.all_countries[i].country_code == cc)
464*5113495bSYour Name 				return true;
465*5113495bSYour Name 	} else {
466*5113495bSYour Name 		for (i = 0; i < g_reg_dmn_tbl.reg_dmn_pairs_cnt; i++)
467*5113495bSYour Name 			if (g_reg_dmn_tbl.reg_dmn_pairs[i].reg_dmn_pair
468*5113495bSYour Name 			    == reg_dmn)
469*5113495bSYour Name 				return true;
470*5113495bSYour Name 	}
471*5113495bSYour Name 
472*5113495bSYour Name 	cds_err("invalid regulatory domain/country code 0x%x", reg_dmn);
473*5113495bSYour Name 
474*5113495bSYour Name 	return false;
475*5113495bSYour Name }
476*5113495bSYour Name 
477*5113495bSYour Name /**
478*5113495bSYour Name  * find_country() - find country data
479*5113495bSYour Name  * @country_code: country code
480*5113495bSYour Name  *
481*5113495bSYour Name  * Return: country code data pointer
482*5113495bSYour Name  */
find_country(uint16_t country_code)483*5113495bSYour Name static const struct country_code_to_reg_dmn *find_country(uint16_t country_code)
484*5113495bSYour Name {
485*5113495bSYour Name 	int32_t i;
486*5113495bSYour Name 
487*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.all_countries_cnt; i++) {
488*5113495bSYour Name 		if (g_reg_dmn_tbl.all_countries[i].country_code == country_code)
489*5113495bSYour Name 			return &g_reg_dmn_tbl.all_countries[i];
490*5113495bSYour Name 	}
491*5113495bSYour Name 
492*5113495bSYour Name 	return NULL;
493*5113495bSYour Name }
494*5113495bSYour Name 
495*5113495bSYour Name /**
496*5113495bSYour Name  * cds_get_country_from_alpha2() - get country from alpha2
497*5113495bSYour Name  * @alpha2: country code alpha2
498*5113495bSYour Name  *
499*5113495bSYour Name  * Return: country code
500*5113495bSYour Name  */
cds_get_country_from_alpha2(uint8_t * alpha2)501*5113495bSYour Name int32_t cds_get_country_from_alpha2(uint8_t *alpha2)
502*5113495bSYour Name {
503*5113495bSYour Name 	int32_t i;
504*5113495bSYour Name 
505*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.all_countries_cnt; i++) {
506*5113495bSYour Name 		if (g_reg_dmn_tbl.all_countries[i].alpha2[0] == alpha2[0] &&
507*5113495bSYour Name 		    g_reg_dmn_tbl.all_countries[i].alpha2[1] == alpha2[1])
508*5113495bSYour Name 			return g_reg_dmn_tbl.all_countries[i].country_code;
509*5113495bSYour Name 	}
510*5113495bSYour Name 
511*5113495bSYour Name 	return CTRY_DEFAULT;
512*5113495bSYour Name }
513*5113495bSYour Name 
514*5113495bSYour Name /**
515*5113495bSYour Name  * reg_dmn_get_default_country() - get default country for regulatory domain
516*5113495bSYour Name  * @reg_dmn: regulatory domain
517*5113495bSYour Name  *
518*5113495bSYour Name  * Return: default country
519*5113495bSYour Name  */
reg_dmn_get_default_country(uint16_t reg_dmn)520*5113495bSYour Name static uint16_t reg_dmn_get_default_country(uint16_t reg_dmn)
521*5113495bSYour Name {
522*5113495bSYour Name 	int32_t i;
523*5113495bSYour Name 	const struct country_code_to_reg_dmn *country = NULL;
524*5113495bSYour Name 	uint16_t cc = reg_dmn & ~CTRY_FLAG;
525*5113495bSYour Name 
526*5113495bSYour Name 	if (reg_dmn & CTRY_FLAG) {
527*5113495bSYour Name 		country = find_country(cc);
528*5113495bSYour Name 		if (country)
529*5113495bSYour Name 			return cc;
530*5113495bSYour Name 	}
531*5113495bSYour Name 
532*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.reg_dmn_pairs_cnt; i++) {
533*5113495bSYour Name 		if (g_reg_dmn_tbl.reg_dmn_pairs[i].reg_dmn_pair == reg_dmn) {
534*5113495bSYour Name 			if (g_reg_dmn_tbl.reg_dmn_pairs[i].single_cc != 0)
535*5113495bSYour Name 				return g_reg_dmn_tbl.reg_dmn_pairs[i].single_cc;
536*5113495bSYour Name 			else
537*5113495bSYour Name 				i = g_reg_dmn_tbl.reg_dmn_pairs_cnt;
538*5113495bSYour Name 		}
539*5113495bSYour Name 	}
540*5113495bSYour Name 
541*5113495bSYour Name 	return CTRY_DEFAULT;
542*5113495bSYour Name }
543*5113495bSYour Name 
544*5113495bSYour Name /**
545*5113495bSYour Name  * get_reg_dmn_pair() - get regulatory domain pair pointer
546*5113495bSYour Name  * @reg_dmn: regulatory domain
547*5113495bSYour Name  *
548*5113495bSYour Name  * Return: pointer to regulatory domain pair data
549*5113495bSYour Name  */
get_reg_dmn_pair(uint16_t reg_dmn)550*5113495bSYour Name static const struct reg_dmn_pair *get_reg_dmn_pair(uint16_t reg_dmn)
551*5113495bSYour Name {
552*5113495bSYour Name 	int32_t i;
553*5113495bSYour Name 
554*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.reg_dmn_pairs_cnt; i++) {
555*5113495bSYour Name 		if (g_reg_dmn_tbl.reg_dmn_pairs[i].reg_dmn_pair == reg_dmn)
556*5113495bSYour Name 			return &g_reg_dmn_tbl.reg_dmn_pairs[i];
557*5113495bSYour Name 	}
558*5113495bSYour Name 
559*5113495bSYour Name 	return NULL;
560*5113495bSYour Name }
561*5113495bSYour Name 
562*5113495bSYour Name /**
563*5113495bSYour Name  * get_reg_dmn() - get regulatory domain pointer
564*5113495bSYour Name  * @reg_dmn: regulatory domain
565*5113495bSYour Name  *
566*5113495bSYour Name  * Return: pointer to regulatory domain data
567*5113495bSYour Name  */
get_reg_dmn(uint16_t reg_dmn)568*5113495bSYour Name static const struct reg_dmn *get_reg_dmn(uint16_t reg_dmn)
569*5113495bSYour Name {
570*5113495bSYour Name 	int32_t i;
571*5113495bSYour Name 
572*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.reg_dmns_cnt; i++) {
573*5113495bSYour Name 		if (g_reg_dmn_tbl.reg_dmns[i].reg_dmn == reg_dmn)
574*5113495bSYour Name 			return &g_reg_dmn_tbl.reg_dmns[i];
575*5113495bSYour Name 	}
576*5113495bSYour Name 
577*5113495bSYour Name 	return NULL;
578*5113495bSYour Name }
579*5113495bSYour Name 
580*5113495bSYour Name /**
581*5113495bSYour Name  * get_country_from_rd() - get country from regulatory domain
582*5113495bSYour Name  * @reg_dmn: regulatory domain
583*5113495bSYour Name  *
584*5113495bSYour Name  * Return: country code enum
585*5113495bSYour Name  */
get_country_from_rd(uint16_t reg_dmn)586*5113495bSYour Name static const struct country_code_to_reg_dmn *get_country_from_rd(
587*5113495bSYour Name 	uint16_t reg_dmn)
588*5113495bSYour Name {
589*5113495bSYour Name 	int32_t i;
590*5113495bSYour Name 
591*5113495bSYour Name 	for (i = 0; i < g_reg_dmn_tbl.all_countries_cnt; i++) {
592*5113495bSYour Name 		if (g_reg_dmn_tbl.all_countries[i].reg_dmn_pair == reg_dmn)
593*5113495bSYour Name 			return &g_reg_dmn_tbl.all_countries[i];
594*5113495bSYour Name 	}
595*5113495bSYour Name 
596*5113495bSYour Name 	return NULL;
597*5113495bSYour Name }
598*5113495bSYour Name 
599*5113495bSYour Name /**
600*5113495bSYour Name  * reg_dmn_sanitize() - sanitize regulatory domain
601*5113495bSYour Name  * @reg: regulatory data structure
602*5113495bSYour Name  *
603*5113495bSYour Name  * Return: none
604*5113495bSYour Name  */
reg_dmn_sanitize(struct regulatory * reg)605*5113495bSYour Name static void reg_dmn_sanitize(struct regulatory *reg)
606*5113495bSYour Name {
607*5113495bSYour Name 	if (reg->reg_domain != CTRY_FLAG)
608*5113495bSYour Name 		return;
609*5113495bSYour Name 
610*5113495bSYour Name 	reg->reg_domain = WOR0_WORLD;
611*5113495bSYour Name }
612*5113495bSYour Name 
613*5113495bSYour Name /**
614*5113495bSYour Name  * cds_fill_some_regulatory_info() - fill regulatory information
615*5113495bSYour Name  * @reg: regulatory data structure
616*5113495bSYour Name  *
617*5113495bSYour Name  * Return: error code
618*5113495bSYour Name  */
cds_fill_some_regulatory_info(struct regulatory * reg)619*5113495bSYour Name int32_t cds_fill_some_regulatory_info(struct regulatory *reg)
620*5113495bSYour Name {
621*5113495bSYour Name 	uint16_t country_code;
622*5113495bSYour Name 	uint16_t reg_dmn, rd;
623*5113495bSYour Name 	const struct country_code_to_reg_dmn *country = NULL;
624*5113495bSYour Name 
625*5113495bSYour Name 	reg_dmn_sanitize(reg);
626*5113495bSYour Name 	rd = reg->reg_domain;
627*5113495bSYour Name 
628*5113495bSYour Name 	if (!is_reg_dmn_valid(rd))
629*5113495bSYour Name 		return -EINVAL;
630*5113495bSYour Name 
631*5113495bSYour Name 	reg_dmn = get_bdf_reg_dmn(rd);
632*5113495bSYour Name 
633*5113495bSYour Name 	country_code = reg_dmn_get_default_country(reg_dmn);
634*5113495bSYour Name 	if (country_code == CTRY_DEFAULT && reg_dmn == CTRY_DEFAULT)
635*5113495bSYour Name 		country_code = CTRY_UNITED_STATES;
636*5113495bSYour Name 
637*5113495bSYour Name 	if (country_code != CTRY_DEFAULT) {
638*5113495bSYour Name 		country = find_country(country_code);
639*5113495bSYour Name 		if (!country) {
640*5113495bSYour Name 			cds_err("not a valid country code");
641*5113495bSYour Name 			return -EINVAL;
642*5113495bSYour Name 		}
643*5113495bSYour Name 
644*5113495bSYour Name 		reg_dmn = country->reg_dmn_pair;
645*5113495bSYour Name 	}
646*5113495bSYour Name 
647*5113495bSYour Name 	reg->regpair = get_reg_dmn_pair(reg_dmn);
648*5113495bSYour Name 	if (!reg->regpair) {
649*5113495bSYour Name 		cds_err("no regpair is found, can not proceed");
650*5113495bSYour Name 		return -EINVAL;
651*5113495bSYour Name 	}
652*5113495bSYour Name 
653*5113495bSYour Name 	reg->country_code = country_code;
654*5113495bSYour Name 
655*5113495bSYour Name 	if (!country)
656*5113495bSYour Name 		country = get_country_from_rd(reg_dmn);
657*5113495bSYour Name 
658*5113495bSYour Name 	if (country) {
659*5113495bSYour Name 		reg->alpha2[0] = country->alpha2[0];
660*5113495bSYour Name 		reg->alpha2[1] = country->alpha2[1];
661*5113495bSYour Name 	} else {
662*5113495bSYour Name 		reg->alpha2[0] = '0';
663*5113495bSYour Name 		reg->alpha2[1] = '0';
664*5113495bSYour Name 	}
665*5113495bSYour Name 
666*5113495bSYour Name 	return 0;
667*5113495bSYour Name }
668*5113495bSYour Name 
669*5113495bSYour Name /**
670*5113495bSYour Name  * cds_fill_and_send_ctl_to_fw() - fill and send ctl to firmware
671*5113495bSYour Name  * @reg: the regulatory handle
672*5113495bSYour Name  *
673*5113495bSYour Name  * Return: none
674*5113495bSYour Name  */
cds_fill_and_send_ctl_to_fw(struct regulatory * reg)675*5113495bSYour Name void cds_fill_and_send_ctl_to_fw(struct regulatory *reg)
676*5113495bSYour Name {
677*5113495bSYour Name 	const struct reg_dmn *reg_dmn_2g = NULL;
678*5113495bSYour Name 	const struct reg_dmn *reg_dmn_5g = NULL;
679*5113495bSYour Name 	uint8_t ctl_2g, ctl_5g;
680*5113495bSYour Name 	const struct reg_dmn_pair *regpair;
681*5113495bSYour Name 	tp_wma_handle wma = cds_get_context(QDF_MODULE_ID_WMA);
682*5113495bSYour Name 
683*5113495bSYour Name 	if (!wma)
684*5113495bSYour Name 		return;
685*5113495bSYour Name 
686*5113495bSYour Name 	if (!reg->regpair) {
687*5113495bSYour Name 		cds_err(FL("no regpair is found, can not proceed"));
688*5113495bSYour Name 		return;
689*5113495bSYour Name 	}
690*5113495bSYour Name 	regpair = reg->regpair;
691*5113495bSYour Name 	reg_dmn_2g = get_reg_dmn(regpair->reg_dmn_2ghz);
692*5113495bSYour Name 	if (!reg_dmn_2g) {
693*5113495bSYour Name 		cds_err("failed to get regdmn 2G");
694*5113495bSYour Name 		return;
695*5113495bSYour Name 	}
696*5113495bSYour Name 
697*5113495bSYour Name 	reg_dmn_5g = get_reg_dmn(regpair->reg_dmn_5ghz);
698*5113495bSYour Name 	if (!reg_dmn_5g) {
699*5113495bSYour Name 		cds_err("failed to get regdmn 5G");
700*5113495bSYour Name 		return;
701*5113495bSYour Name 	}
702*5113495bSYour Name 
703*5113495bSYour Name 	ctl_2g = reg_dmn_2g->conformance_test_limit;
704*5113495bSYour Name 	ctl_5g = reg_dmn_5g->conformance_test_limit;
705*5113495bSYour Name 
706*5113495bSYour Name 
707*5113495bSYour Name 	reg->ctl_5g = ctl_5g;
708*5113495bSYour Name 	reg->ctl_2g = ctl_2g;
709*5113495bSYour Name 
710*5113495bSYour Name 	wma_send_regdomain_info_to_fw(reg->reg_domain, regpair->reg_dmn_2ghz,
711*5113495bSYour Name 				      regpair->reg_dmn_5ghz, ctl_2g, ctl_5g);
712*5113495bSYour Name }
713