rtw_chplan.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2018 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. *****************************************************************************/
  15. #define _RTW_CHPLAN_C_
  16. #include <drv_types.h>
  17. #define RTW_DOMAIN_MAP_VER "35e"
  18. #define RTW_COUNTRY_MAP_VER "20"
  19. #ifdef LEGACY_CHANNEL_PLAN_REF
  20. /********************************************************
  21. ChannelPlan definitions
  22. *********************************************************/
  23. static RT_CHANNEL_PLAN legacy_channel_plan[] = {
  24. /* 0x00, RTW_CHPLAN_FCC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165}, 32},
  25. /* 0x01, RTW_CHPLAN_IC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 31},
  26. /* 0x02, RTW_CHPLAN_ETSI */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32},
  27. /* 0x03, RTW_CHPLAN_SPAIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  28. /* 0x04, RTW_CHPLAN_FRANCE */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  29. /* 0x05, RTW_CHPLAN_MKK */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  30. /* 0x06, RTW_CHPLAN_MKK1 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  31. /* 0x07, RTW_CHPLAN_ISRAEL */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21},
  32. /* 0x08, RTW_CHPLAN_TELEC */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},
  33. /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14},
  34. /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
  35. /* 0x0B, RTW_CHPLAN_TAIWAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165}, 26},
  36. /* 0x0C, RTW_CHPLAN_CHINA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 149, 153, 157, 161, 165}, 18},
  37. /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24},
  38. /* 0x0E, RTW_CHPLAN_KOREA */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165}, 31},
  39. /* 0x0F, RTW_CHPLAN_TURKEY */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19},
  40. /* 0x10, RTW_CHPLAN_JAPAN */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140}, 32},
  41. /* 0x11, RTW_CHPLAN_FCC_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 149, 153, 157, 161, 165}, 20},
  42. /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48}, 17},
  43. /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165}, 37},
  44. /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */ {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 56, 60, 64, 149, 153, 157, 161, 165}, 19},
  45. };
  46. #endif
  47. enum rtw_rd_2g {
  48. RTW_RD_2G_NULL = 0,
  49. RTW_RD_2G_WORLD = 1, /* Worldwird 13 */
  50. RTW_RD_2G_ETSI1 = 2, /* Europe */
  51. RTW_RD_2G_FCC1 = 3, /* US */
  52. RTW_RD_2G_MKK1 = 4, /* Japan */
  53. RTW_RD_2G_ETSI2 = 5, /* France */
  54. RTW_RD_2G_GLOBAL = 6, /* Global domain */
  55. RTW_RD_2G_MKK2 = 7, /* Japan */
  56. RTW_RD_2G_FCC2 = 8, /* US */
  57. RTW_RD_2G_IC1 = 9, /* Canada */
  58. RTW_RD_2G_WORLD1 = 10, /* Worldwide 11 */
  59. RTW_RD_2G_KCC1 = 11, /* Korea */
  60. RTW_RD_2G_MAX,
  61. };
  62. enum rtw_rd_5g {
  63. RTW_RD_5G_NULL = 0, /* */
  64. RTW_RD_5G_ETSI1 = 1, /* Europe */
  65. RTW_RD_5G_ETSI2 = 2, /* Australia, New Zealand */
  66. RTW_RD_5G_ETSI3 = 3, /* Russia */
  67. RTW_RD_5G_FCC1 = 4, /* US */
  68. RTW_RD_5G_FCC2 = 5, /* FCC w/o DFS Channels */
  69. RTW_RD_5G_FCC3 = 6, /* Bolivia, Chile, El Salvador, Venezuela */
  70. RTW_RD_5G_FCC4 = 7, /* Venezuela */
  71. RTW_RD_5G_FCC5 = 8, /* China */
  72. RTW_RD_5G_FCC6 = 9, /* */
  73. RTW_RD_5G_FCC7 = 10, /* US(w/o Weather radar) */
  74. RTW_RD_5G_IC1 = 11, /* Canada(w/o Weather radar) */
  75. RTW_RD_5G_KCC1 = 12, /* Korea */
  76. RTW_RD_5G_MKK1 = 13, /* Japan */
  77. RTW_RD_5G_MKK2 = 14, /* Japan (W52, W53) */
  78. RTW_RD_5G_MKK3 = 15, /* Japan (W56) */
  79. RTW_RD_5G_NCC1 = 16, /* Taiwan, (w/o Weather radar) */
  80. RTW_RD_5G_NCC2 = 17, /* Taiwan, Band2, Band4 */
  81. RTW_RD_5G_NCC3 = 18, /* Taiwan w/o DFS, Band4 only */
  82. RTW_RD_5G_ETSI4 = 19, /* Europe w/o DFS, Band1 only */
  83. RTW_RD_5G_ETSI5 = 20, /* Australia, New Zealand(w/o Weather radar) */
  84. RTW_RD_5G_FCC8 = 21, /* Latin America */
  85. RTW_RD_5G_ETSI6 = 22, /* Israel, Bahrain, Egypt, India, China, Malaysia */
  86. RTW_RD_5G_ETSI7 = 23, /* China */
  87. RTW_RD_5G_ETSI8 = 24, /* Jordan */
  88. RTW_RD_5G_ETSI9 = 25, /* Lebanon */
  89. RTW_RD_5G_ETSI10 = 26, /* Qatar */
  90. RTW_RD_5G_ETSI11 = 27, /* Russia */
  91. RTW_RD_5G_NCC4 = 28, /* Taiwan, (w/o Weather radar) */
  92. RTW_RD_5G_ETSI12 = 29, /* Indonesia */
  93. RTW_RD_5G_FCC9 = 30, /* (w/o Weather radar) */
  94. RTW_RD_5G_ETSI13 = 31, /* (w/o Weather radar) */
  95. RTW_RD_5G_FCC10 = 32, /* Argentina(w/o Weather radar) */
  96. RTW_RD_5G_MKK4 = 33, /* Japan (W52) */
  97. RTW_RD_5G_ETSI14 = 34, /* Russia */
  98. RTW_RD_5G_FCC11 = 35, /* US(include CH144) */
  99. RTW_RD_5G_ETSI15 = 36, /* Malaysia */
  100. RTW_RD_5G_MKK5 = 37, /* Japan */
  101. RTW_RD_5G_ETSI16 = 38, /* Europe */
  102. RTW_RD_5G_ETSI17 = 39, /* Europe */
  103. RTW_RD_5G_FCC12 = 40, /* FCC */
  104. RTW_RD_5G_FCC13 = 41, /* FCC */
  105. RTW_RD_5G_FCC14 = 42, /* FCC w/o Weather radar(w/o 5600~5650MHz) */
  106. RTW_RD_5G_FCC15 = 43, /* FCC w/o Band3 */
  107. RTW_RD_5G_FCC16 = 44, /* FCC w/o Band3 */
  108. RTW_RD_5G_ETSI18 = 45, /* ETSI w/o DFS Band2&3 */
  109. RTW_RD_5G_ETSI19 = 46, /* Europe */
  110. RTW_RD_5G_FCC17 = 47, /* FCC w/o Weather radar(w/o 5600~5650MHz) */
  111. RTW_RD_5G_ETSI20 = 48, /* Europe */
  112. RTW_RD_5G_IC2 = 49, /* Canada(w/o Weather radar), include ch144 */
  113. RTW_RD_5G_ETSI21 = 50, /* Australia, New Zealand(w/o Weather radar) */
  114. RTW_RD_5G_FCC18 = 51, /* */
  115. RTW_RD_5G_WORLD = 52, /* Worldwide */
  116. RTW_RD_5G_CHILE1 = 53, /* Chile */
  117. RTW_RD_5G_ACMA1 = 54, /* Australia, New Zealand (w/o Weather radar) (w/o Ch120~Ch128) */
  118. RTW_RD_5G_WORLD1 = 55, /* 5G Worldwide Band1&2 */
  119. RTW_RD_5G_CHILE2 = 56, /* Chile (Band2,Band3) */
  120. RTW_RD_5G_KCC2 = 57, /* Korea (New standard) */
  121. /* === Below are driver defined for legacy channel plan compatible, DON'T assign index ==== */
  122. RTW_RD_5G_OLD_FCC1,
  123. RTW_RD_5G_OLD_NCC1,
  124. RTW_RD_5G_OLD_KCC1,
  125. RTW_RD_5G_MAX,
  126. };
  127. struct ch_list_t {
  128. u8 *len_ch;
  129. };
  130. #define CH_LIST_ENT(_len, arg...) \
  131. {.len_ch = (u8[_len + 1]) {_len, ##arg}, }
  132. #define CH_LIST_LEN(_ch_list) (_ch_list.len_ch[0])
  133. #define CH_LIST_CH(_ch_list, _i) (_ch_list.len_ch[_i + 1])
  134. struct chplan_ent_t {
  135. u8 rd_2g;
  136. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  137. u8 rd_5g;
  138. #endif
  139. u8 regd; /* value of REGULATION_TXPWR_LMT */
  140. };
  141. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  142. #define CHPLAN_ENT(i2g, i5g, regd) {i2g, i5g, regd}
  143. #else
  144. #define CHPLAN_ENT(i2g, i5g, regd) {i2g, regd}
  145. #endif
  146. static struct ch_list_t RTW_ChannelPlan2G[] = {
  147. /* 0, RTW_RD_2G_NULL */ CH_LIST_ENT(0),
  148. /* 1, RTW_RD_2G_WORLD */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  149. /* 2, RTW_RD_2G_ETSI1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  150. /* 3, RTW_RD_2G_FCC1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
  151. /* 4, RTW_RD_2G_MKK1 */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
  152. /* 5, RTW_RD_2G_ETSI2 */ CH_LIST_ENT(4, 10, 11, 12, 13),
  153. /* 6, RTW_RD_2G_GLOBAL */ CH_LIST_ENT(14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
  154. /* 7, RTW_RD_2G_MKK2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  155. /* 8, RTW_RD_2G_FCC2 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  156. /* 9, RTW_RD_2G_IC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  157. /* 10, RTW_RD_2G_WORLD1 */ CH_LIST_ENT(11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11),
  158. /* 11, RTW_RD_2G_KCC1 */ CH_LIST_ENT(13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13),
  159. };
  160. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  161. static struct ch_list_t RTW_ChannelPlan5G[] = {
  162. /* 0, RTW_RD_5G_NULL */ CH_LIST_ENT(0),
  163. /* 1, RTW_RD_5G_ETSI1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140),
  164. /* 2, RTW_RD_5G_ETSI2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  165. /* 3, RTW_RD_5G_ETSI3 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 149, 153, 157, 161, 165),
  166. /* 4, RTW_RD_5G_FCC1 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  167. /* 5, RTW_RD_5G_FCC2 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165),
  168. /* 6, RTW_RD_5G_FCC3 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165),
  169. /* 7, RTW_RD_5G_FCC4 */ CH_LIST_ENT(12, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161),
  170. /* 8, RTW_RD_5G_FCC5 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165),
  171. /* 9, RTW_RD_5G_FCC6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64),
  172. /* 10, RTW_RD_5G_FCC7 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  173. /* 11, RTW_RD_5G_IC1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  174. /* 12, RTW_RD_5G_KCC1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161),
  175. /* 13, RTW_RD_5G_MKK1 */ CH_LIST_ENT(19, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140),
  176. /* 14, RTW_RD_5G_MKK2 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64),
  177. /* 15, RTW_RD_5G_MKK3 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140),
  178. /* 16, RTW_RD_5G_NCC1 */ CH_LIST_ENT(16, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  179. /* 17, RTW_RD_5G_NCC2 */ CH_LIST_ENT(8, 56, 60, 64, 149, 153, 157, 161, 165),
  180. /* 18, RTW_RD_5G_NCC3 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165),
  181. /* 19, RTW_RD_5G_ETSI4 */ CH_LIST_ENT(4, 36, 40, 44, 48),
  182. /* 20, RTW_RD_5G_ETSI5 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  183. /* 21, RTW_RD_5G_FCC8 */ CH_LIST_ENT(4, 149, 153, 157, 161),
  184. /* 22, RTW_RD_5G_ETSI6 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64),
  185. /* 23, RTW_RD_5G_ETSI7 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165),
  186. /* 24, RTW_RD_5G_ETSI8 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165),
  187. /* 25, RTW_RD_5G_ETSI9 */ CH_LIST_ENT(11, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140),
  188. /* 26, RTW_RD_5G_ETSI10 */ CH_LIST_ENT(5, 149, 153, 157, 161, 165),
  189. /* 27, RTW_RD_5G_ETSI11 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140, 149, 153, 157, 161, 165),
  190. /* 28, RTW_RD_5G_NCC4 */ CH_LIST_ENT(17, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  191. /* 29, RTW_RD_5G_ETSI12 */ CH_LIST_ENT(4, 149, 153, 157, 161),
  192. /* 30, RTW_RD_5G_FCC9 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  193. /* 31, RTW_RD_5G_ETSI13 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140),
  194. /* 32, RTW_RD_5G_FCC10 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161),
  195. /* 33, RTW_RD_5G_MKK4 */ CH_LIST_ENT(4, 36, 40, 44, 48),
  196. /* 34, RTW_RD_5G_ETSI14 */ CH_LIST_ENT(11, 36, 40, 44, 48, 52, 56, 60, 64, 132, 136, 140),
  197. /* 35, RTW_RD_5G_FCC11 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165),
  198. /* 36, RTW_RD_5G_ETSI15 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 149, 153, 157, 161, 165),
  199. /* 37, RTW_RD_5G_MKK5 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  200. /* 38, RTW_RD_5G_ETSI16 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  201. /* 39, RTW_RD_5G_ETSI17 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  202. /* 40, RTW_RD_5G_FCC12*/ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  203. /* 41, RTW_RD_5G_FCC13 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  204. /* 42, RTW_RD_5G_FCC14 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  205. /* 43, RTW_RD_5G_FCC15 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165),
  206. /* 44, RTW_RD_5G_FCC16 */ CH_LIST_ENT(13, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165),
  207. /* 45, RTW_RD_5G_ETSI18 */ CH_LIST_ENT(9, 36, 40, 44, 48, 149, 153, 157, 161, 165),
  208. /* 46, RTW_RD_5G_ETSI19 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  209. /* 47, RTW_RD_5G_FCC17 */ CH_LIST_ENT(16, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140),
  210. /* 48, RTW_RD_5G_ETSI20 */ CH_LIST_ENT(9, 52, 56, 60, 64, 149, 153, 157, 161, 165),
  211. /* 49, RTW_RD_5G_IC2 */ CH_LIST_ENT(22, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165),
  212. /* 50, RTW_RD_5G_ETSI21 */ CH_LIST_ENT(13, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  213. /* 51, RTW_RD_5G_FCC18 */ CH_LIST_ENT(8, 100, 104, 108, 112, 116, 132, 136, 140),
  214. /* 52, RTW_RD_5G_WORLD */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165),
  215. /* 53, RTW_RD_5G_CHILE1 */ CH_LIST_ENT(25, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 149, 153, 157, 161, 165),
  216. /* 54, RTW_RD_5G_ACMA1 */ CH_LIST_ENT(21, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 132, 136, 140, 149, 153, 157, 161, 165),
  217. /* 55, RTW_RD_5G_WORLD1 */ CH_LIST_ENT(8, 36, 40, 44, 48, 52, 56, 60, 64),
  218. /* 56, RTW_RD_5G_CHILE2 */ CH_LIST_ENT(16, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144),
  219. /* 57, RTW_RD_5G_KCC2 */ CH_LIST_ENT(24, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 149, 153, 157, 161, 165),
  220. /* === Below are driver defined for legacy channel plan compatible, NO static index assigned ==== */
  221. /* RTW_RD_5G_OLD_FCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165),
  222. /* RTW_RD_5G_OLD_NCC1 */ CH_LIST_ENT(15, 56, 60, 64, 100, 104, 108, 112, 116, 136, 140, 149, 153, 157, 161, 165),
  223. /* RTW_RD_5G_OLD_KCC1 */ CH_LIST_ENT(20, 36, 40, 44, 48, 52, 56, 60, 64, 100, 104, 108, 112, 116, 120, 124, 149, 153, 157, 161, 165),
  224. };
  225. #endif /* CONFIG_IEEE80211_BAND_5GHZ */
  226. static struct chplan_ent_t RTW_ChannelPlanMap[RTW_CHPLAN_MAX] = {
  227. /* ===== 0x00 ~ 0x1F, legacy channel plan ===== */
  228. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_KCC1, TXPWR_LMT_FCC), /* 0x00, RTW_CHPLAN_FCC */
  229. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_FCC1, TXPWR_LMT_FCC), /* 0x01, RTW_CHPLAN_IC */
  230. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x02, RTW_CHPLAN_ETSI */
  231. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x03, RTW_CHPLAN_SPAIN */
  232. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x04, RTW_CHPLAN_FRANCE */
  233. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x05, RTW_CHPLAN_MKK */
  234. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x06, RTW_CHPLAN_MKK1 */
  235. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x07, RTW_CHPLAN_ISRAEL */
  236. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC6, TXPWR_LMT_MKK), /* 0x08, RTW_CHPLAN_TELEC */
  237. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x09, RTW_CHPLAN_GLOBAL_DOAMIN */
  238. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x0A, RTW_CHPLAN_WORLD_WIDE_13 */
  239. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_NCC1, TXPWR_LMT_FCC), /* 0x0B, RTW_CHPLAN_TAIWAN */
  240. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x0C, RTW_CHPLAN_CHINA */
  241. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC3, TXPWR_LMT_WW), /* 0x0D, RTW_CHPLAN_SINGAPORE_INDIA_MEXICO */ /* ETSI:Singapore, India. FCC:Mexico => WW */
  242. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_OLD_KCC1, TXPWR_LMT_ETSI), /* 0x0E, RTW_CHPLAN_KOREA */
  243. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC6, TXPWR_LMT_ETSI), /* 0x0F, RTW_CHPLAN_TURKEY */
  244. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_MKK), /* 0x10, RTW_CHPLAN_JAPAN */
  245. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x11, RTW_CHPLAN_FCC_NO_DFS */
  246. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x12, RTW_CHPLAN_JAPAN_NO_DFS */
  247. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x13, RTW_CHPLAN_WORLD_WIDE_5G */
  248. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x14, RTW_CHPLAN_TAIWAN_NO_DFS */
  249. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_ETSI), /* 0x15, RTW_CHPLAN_ETSI_NO_DFS */
  250. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NCC1, TXPWR_LMT_ETSI), /* 0x16, RTW_CHPLAN_KOREA_NO_DFS */
  251. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_FCC7, TXPWR_LMT_MKK), /* 0x17, RTW_CHPLAN_JAPAN_NO_DFS */
  252. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC5, TXPWR_LMT_ETSI), /* 0x18, RTW_CHPLAN_PAKISTAN_NO_DFS */
  253. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x19, RTW_CHPLAN_TAIWAN2_NO_DFS */
  254. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1A, */
  255. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1B, */
  256. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1C, */
  257. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1D, */
  258. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x1E, */
  259. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_FCC1, TXPWR_LMT_WW), /* 0x1F, RTW_CHPLAN_WORLD_WIDE_ONLY_5G */
  260. /* ===== 0x20 ~ 0x7F, new channel plan ===== */
  261. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x20, RTW_CHPLAN_WORLD_NULL */
  262. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x21, RTW_CHPLAN_ETSI1_NULL */
  263. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x22, RTW_CHPLAN_FCC1_NULL */
  264. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x23, RTW_CHPLAN_MKK1_NULL */
  265. CHPLAN_ENT(RTW_RD_2G_ETSI2, RTW_RD_5G_NULL, TXPWR_LMT_ETSI), /* 0x24, RTW_CHPLAN_ETSI2_NULL */
  266. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x25, RTW_CHPLAN_FCC1_FCC1 */
  267. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x26, RTW_CHPLAN_WORLD_ETSI1 */
  268. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x27, RTW_CHPLAN_MKK1_MKK1 */
  269. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_KCC1, TXPWR_LMT_KCC), /* 0x28, RTW_CHPLAN_WORLD_KCC1 */
  270. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x29, RTW_CHPLAN_WORLD_FCC2 */
  271. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_NULL, TXPWR_LMT_FCC), /* 0x2A, RTW_CHPLAN_FCC2_NULL */
  272. CHPLAN_ENT(RTW_RD_2G_IC1, RTW_RD_5G_IC2, TXPWR_LMT_IC), /* 0x2B, RTW_CHPLAN_IC1_IC2 */
  273. CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_NULL, TXPWR_LMT_MKK), /* 0x2C, RTW_CHPLAN_MKK2_NULL */
  274. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE1, TXPWR_LMT_CHILE), /* 0x2D, RTW_CHPLAN_WORLD_CHILE1 */
  275. CHPLAN_ENT(RTW_RD_2G_WORLD1, RTW_RD_5G_WORLD1, TXPWR_LMT_WW), /* 0x2E, RTW_CHPLAN_WORLD1_WORLD1 */
  276. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_CHILE2, TXPWR_LMT_CHILE), /* 0x2F, RTW_CHPLAN_WORLD_CHILE2 */
  277. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC3, TXPWR_LMT_FCC), /* 0x30, RTW_CHPLAN_WORLD_FCC3 */
  278. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC4, TXPWR_LMT_FCC), /* 0x31, RTW_CHPLAN_WORLD_FCC4 */
  279. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x32, RTW_CHPLAN_WORLD_FCC5 */
  280. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC6, TXPWR_LMT_FCC), /* 0x33, RTW_CHPLAN_WORLD_FCC6 */
  281. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x34, RTW_CHPLAN_FCC1_FCC7 */
  282. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI2, TXPWR_LMT_ETSI), /* 0x35, RTW_CHPLAN_WORLD_ETSI2 */
  283. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI3, TXPWR_LMT_ETSI), /* 0x36, RTW_CHPLAN_WORLD_ETSI3 */
  284. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK2, TXPWR_LMT_MKK), /* 0x37, RTW_CHPLAN_MKK1_MKK2 */
  285. CHPLAN_ENT(RTW_RD_2G_MKK1, RTW_RD_5G_MKK3, TXPWR_LMT_MKK), /* 0x38, RTW_CHPLAN_MKK1_MKK3 */
  286. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC1, TXPWR_LMT_FCC), /* 0x39, RTW_CHPLAN_FCC1_NCC1 */
  287. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI1, TXPWR_LMT_ETSI), /* 0x3A, RTW_CHPLAN_ETSI1_ETSI1 */
  288. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x3B, RTW_CHPLAN_ETSI1_ACMA1 */
  289. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x3C, RTW_CHPLAN_ETSI1_ETSI6 */
  290. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x3D, RTW_CHPLAN_ETSI1_ETSI12 */
  291. CHPLAN_ENT(RTW_RD_2G_KCC1, RTW_RD_5G_KCC2, TXPWR_LMT_KCC), /* 0x3E, RTW_CHPLAN_KCC1_KCC2 */
  292. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x3F, */
  293. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC2, TXPWR_LMT_FCC), /* 0x40, RTW_CHPLAN_FCC1_NCC2 */
  294. CHPLAN_ENT(RTW_RD_2G_GLOBAL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x41, RTW_CHPLAN_GLOBAL_NULL */
  295. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI4, TXPWR_LMT_ETSI), /* 0x42, RTW_CHPLAN_ETSI1_ETSI4 */
  296. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC2, TXPWR_LMT_FCC), /* 0x43, RTW_CHPLAN_FCC1_FCC2 */
  297. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC3, TXPWR_LMT_FCC), /* 0x44, RTW_CHPLAN_FCC1_NCC3 */
  298. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ACMA1, TXPWR_LMT_ACMA), /* 0x45, RTW_CHPLAN_WORLD_ACMA1 */
  299. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC8, TXPWR_LMT_FCC), /* 0x46, RTW_CHPLAN_FCC1_FCC8 */
  300. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI6, TXPWR_LMT_ETSI), /* 0x47, RTW_CHPLAN_WORLD_ETSI6 */
  301. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI7, TXPWR_LMT_ETSI), /* 0x48, RTW_CHPLAN_WORLD_ETSI7 */
  302. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x49, RTW_CHPLAN_WORLD_ETSI8 */
  303. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4A, */
  304. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4B, */
  305. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4C, */
  306. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4D, */
  307. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4E, */
  308. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x4F, */
  309. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI9, TXPWR_LMT_ETSI), /* 0x50, RTW_CHPLAN_WORLD_ETSI9 */
  310. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI10, TXPWR_LMT_ETSI), /* 0x51, RTW_CHPLAN_WORLD_ETSI10 */
  311. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI11, TXPWR_LMT_ETSI), /* 0x52, RTW_CHPLAN_WORLD_ETSI11 */
  312. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_NCC4, TXPWR_LMT_FCC), /* 0x53, RTW_CHPLAN_FCC1_NCC4 */
  313. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI12, TXPWR_LMT_ETSI), /* 0x54, RTW_CHPLAN_WORLD_ETSI12 */
  314. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC9, TXPWR_LMT_FCC), /* 0x55, RTW_CHPLAN_FCC1_FCC9 */
  315. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI13, TXPWR_LMT_ETSI), /* 0x56, RTW_CHPLAN_WORLD_ETSI13 */
  316. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC10, TXPWR_LMT_FCC), /* 0x57, RTW_CHPLAN_FCC1_FCC10 */
  317. CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK4, TXPWR_LMT_MKK), /* 0x58, RTW_CHPLAN_MKK2_MKK4 */
  318. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI14, TXPWR_LMT_ETSI), /* 0x59, RTW_CHPLAN_WORLD_ETSI14 */
  319. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5A, */
  320. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5B, */
  321. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5C, */
  322. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5D, */
  323. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5E, */
  324. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_NULL, TXPWR_LMT_WW), /* 0x5F, */
  325. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC5, TXPWR_LMT_FCC), /* 0x60, RTW_CHPLAN_FCC1_FCC5 */
  326. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x61, RTW_CHPLAN_FCC2_FCC7 */
  327. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC1, TXPWR_LMT_FCC), /* 0x62, RTW_CHPLAN_FCC2_FCC1 */
  328. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI15, TXPWR_LMT_ETSI), /* 0x63, RTW_CHPLAN_WORLD_ETSI15 */
  329. CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK5, TXPWR_LMT_MKK), /* 0x64, RTW_CHPLAN_MKK2_MKK5 */
  330. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI16, TXPWR_LMT_ETSI), /* 0x65, RTW_CHPLAN_ETSI1_ETSI16 */
  331. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x66, RTW_CHPLAN_FCC1_FCC14 */
  332. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x67, RTW_CHPLAN_FCC1_FCC12 */
  333. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC14, TXPWR_LMT_FCC), /* 0x68, RTW_CHPLAN_FCC2_FCC14 */
  334. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x69, RTW_CHPLAN_FCC2_FCC12 */
  335. CHPLAN_ENT(RTW_RD_2G_ETSI1, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x6A, RTW_CHPLAN_ETSI1_ETSI17 */
  336. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC16, TXPWR_LMT_FCC), /* 0x6B, RTW_CHPLAN_WORLD_FCC16 */
  337. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC13, TXPWR_LMT_FCC), /* 0x6C, RTW_CHPLAN_WORLD_FCC13 */
  338. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC15, TXPWR_LMT_FCC), /* 0x6D, RTW_CHPLAN_FCC2_FCC15 */
  339. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC12, TXPWR_LMT_FCC), /* 0x6E, RTW_CHPLAN_WORLD_FCC12 */
  340. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI8, TXPWR_LMT_ETSI), /* 0x6F, RTW_CHPLAN_NULL_ETSI8 */
  341. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI18, TXPWR_LMT_ETSI), /* 0x70, RTW_CHPLAN_NULL_ETSI18 */
  342. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI17, TXPWR_LMT_ETSI), /* 0x71, RTW_CHPLAN_NULL_ETSI17 */
  343. CHPLAN_ENT(RTW_RD_2G_NULL, RTW_RD_5G_ETSI19, TXPWR_LMT_ETSI), /* 0x72, RTW_CHPLAN_NULL_ETSI19 */
  344. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC7, TXPWR_LMT_FCC), /* 0x73, RTW_CHPLAN_WORLD_FCC7 */
  345. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC17, TXPWR_LMT_FCC), /* 0x74, RTW_CHPLAN_FCC2_FCC17 */
  346. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI20, TXPWR_LMT_ETSI), /* 0x75, RTW_CHPLAN_WORLD_ETSI20 */
  347. CHPLAN_ENT(RTW_RD_2G_FCC2, RTW_RD_5G_FCC11, TXPWR_LMT_FCC), /* 0x76, RTW_CHPLAN_FCC2_FCC11 */
  348. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_ETSI21, TXPWR_LMT_ETSI), /* 0x77, RTW_CHPLAN_WORLD_ETSI21 */
  349. CHPLAN_ENT(RTW_RD_2G_FCC1, RTW_RD_5G_FCC18, TXPWR_LMT_FCC), /* 0x78, RTW_CHPLAN_FCC1_FCC18 */
  350. CHPLAN_ENT(RTW_RD_2G_MKK2, RTW_RD_5G_MKK1, TXPWR_LMT_MKK), /* 0x79, RTW_CHPLAN_MKK2_MKK1 */
  351. };
  352. static struct chplan_ent_t RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE =
  353. CHPLAN_ENT(RTW_RD_2G_WORLD, RTW_RD_5G_FCC1, TXPWR_LMT_FCC); /* 0x7F, Realtek Define */
  354. u8 rtw_chplan_get_default_regd(u8 id)
  355. {
  356. u8 regd;
  357. if (id == RTW_CHPLAN_REALTEK_DEFINE)
  358. regd = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.regd;
  359. else
  360. regd = RTW_ChannelPlanMap[id].regd;
  361. return regd;
  362. }
  363. bool rtw_chplan_is_empty(u8 id)
  364. {
  365. struct chplan_ent_t *chplan_map;
  366. if (id == RTW_CHPLAN_REALTEK_DEFINE)
  367. chplan_map = &RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE;
  368. else
  369. chplan_map = &RTW_ChannelPlanMap[id];
  370. if (chplan_map->rd_2g == RTW_RD_2G_NULL
  371. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  372. && chplan_map->rd_5g == RTW_RD_5G_NULL
  373. #endif
  374. )
  375. return _TRUE;
  376. return _FALSE;
  377. }
  378. bool rtw_regsty_is_excl_chs(struct registry_priv *regsty, u8 ch)
  379. {
  380. int i;
  381. for (i = 0; i < MAX_CHANNEL_NUM; i++) {
  382. if (regsty->excl_chs[i] == 0)
  383. break;
  384. if (regsty->excl_chs[i] == ch)
  385. return _TRUE;
  386. }
  387. return _FALSE;
  388. }
  389. inline static u8 rtw_rd_5g_band1_passive(u8 rtw_rd_5g)
  390. {
  391. u8 passive = 0;
  392. switch (rtw_rd_5g) {
  393. case RTW_RD_5G_FCC13:
  394. case RTW_RD_5G_FCC16:
  395. case RTW_RD_5G_ETSI18:
  396. case RTW_RD_5G_ETSI19:
  397. case RTW_RD_5G_WORLD:
  398. case RTW_RD_5G_WORLD1:
  399. passive = 1;
  400. };
  401. return passive;
  402. }
  403. inline static u8 rtw_rd_5g_band4_passive(u8 rtw_rd_5g)
  404. {
  405. u8 passive = 0;
  406. switch (rtw_rd_5g) {
  407. case RTW_RD_5G_MKK5:
  408. case RTW_RD_5G_ETSI16:
  409. case RTW_RD_5G_ETSI18:
  410. case RTW_RD_5G_ETSI19:
  411. case RTW_RD_5G_WORLD:
  412. passive = 1;
  413. };
  414. return passive;
  415. }
  416. u8 init_channel_set(_adapter *padapter, u8 ChannelPlan, RT_CHANNEL_INFO *channel_set)
  417. {
  418. struct registry_priv *regsty = adapter_to_regsty(padapter);
  419. u8 index, chanset_size = 0;
  420. u8 b5GBand = _FALSE, b2_4GBand = _FALSE;
  421. u8 rd_2g = 0, rd_5g = 0;
  422. #ifdef CONFIG_DFS_MASTER
  423. int i;
  424. #endif
  425. if (!rtw_is_channel_plan_valid(ChannelPlan)) {
  426. RTW_ERR("ChannelPlan ID 0x%02X error !!!!!\n", ChannelPlan);
  427. return chanset_size;
  428. }
  429. _rtw_memset(channel_set, 0, sizeof(RT_CHANNEL_INFO) * MAX_CHANNEL_NUM);
  430. if (IsSupported24G(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_2G))
  431. b2_4GBand = _TRUE;
  432. if (is_supported_5g(regsty->wireless_mode) && hal_chk_band_cap(padapter, BAND_CAP_5G))
  433. b5GBand = _TRUE;
  434. if (b2_4GBand == _FALSE && b5GBand == _FALSE) {
  435. RTW_WARN("HW band_cap has no intersection with SW wireless_mode setting\n");
  436. return chanset_size;
  437. }
  438. if (b2_4GBand) {
  439. if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE)
  440. rd_2g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_2g;
  441. else
  442. rd_2g = RTW_ChannelPlanMap[ChannelPlan].rd_2g;
  443. for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan2G[rd_2g]); index++) {
  444. if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index)) == _TRUE)
  445. continue;
  446. if (chanset_size >= MAX_CHANNEL_NUM) {
  447. RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
  448. break;
  449. }
  450. channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan2G[rd_2g], index);
  451. if (ChannelPlan == RTW_CHPLAN_GLOBAL_DOAMIN
  452. || rd_2g == RTW_RD_2G_GLOBAL
  453. ) {
  454. /* Channel 1~11 is active, and 12~14 is passive */
  455. if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11)
  456. channel_set[chanset_size].ScanType = SCAN_ACTIVE;
  457. else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14))
  458. channel_set[chanset_size].ScanType = SCAN_PASSIVE;
  459. } else if (ChannelPlan == RTW_CHPLAN_WORLD_WIDE_13
  460. || ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G
  461. || rd_2g == RTW_RD_2G_WORLD
  462. ) {
  463. /* channel 12~13, passive scan */
  464. if (channel_set[chanset_size].ChannelNum <= 11)
  465. channel_set[chanset_size].ScanType = SCAN_ACTIVE;
  466. else
  467. channel_set[chanset_size].ScanType = SCAN_PASSIVE;
  468. } else
  469. channel_set[chanset_size].ScanType = SCAN_ACTIVE;
  470. chanset_size++;
  471. }
  472. }
  473. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  474. if (b5GBand) {
  475. if (ChannelPlan == RTW_CHPLAN_REALTEK_DEFINE)
  476. rd_5g = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.rd_5g;
  477. else
  478. rd_5g = RTW_ChannelPlanMap[ChannelPlan].rd_5g;
  479. for (index = 0; index < CH_LIST_LEN(RTW_ChannelPlan5G[rd_5g]); index++) {
  480. if (rtw_regsty_is_excl_chs(regsty, CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)) == _TRUE)
  481. continue;
  482. #ifndef CONFIG_DFS
  483. if (rtw_is_dfs_ch(CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index)))
  484. continue;
  485. #endif
  486. if (chanset_size >= MAX_CHANNEL_NUM) {
  487. RTW_WARN("chset size can't exceed MAX_CHANNEL_NUM(%u)\n", MAX_CHANNEL_NUM);
  488. break;
  489. }
  490. channel_set[chanset_size].ChannelNum = CH_LIST_CH(RTW_ChannelPlan5G[rd_5g], index);
  491. if ((ChannelPlan == RTW_CHPLAN_WORLD_WIDE_5G) /* all channels passive */
  492. || (rtw_is_5g_band1(channel_set[chanset_size].ChannelNum)
  493. && rtw_rd_5g_band1_passive(rd_5g)) /* band1 passive */
  494. || (rtw_is_5g_band4(channel_set[chanset_size].ChannelNum)
  495. && rtw_rd_5g_band4_passive(rd_5g)) /* band4 passive */
  496. || (rtw_is_dfs_ch(channel_set[chanset_size].ChannelNum)) /* DFS channel(band2, 3) passive */
  497. )
  498. channel_set[chanset_size].ScanType = SCAN_PASSIVE;
  499. else
  500. channel_set[chanset_size].ScanType = SCAN_ACTIVE;
  501. chanset_size++;
  502. }
  503. }
  504. #ifdef CONFIG_DFS_MASTER
  505. for (i = 0; i < chanset_size; i++)
  506. channel_set[i].non_ocp_end_time = rtw_get_current_time();
  507. #endif
  508. #endif /* CONFIG_IEEE80211_BAND_5GHZ */
  509. if (chanset_size)
  510. RTW_INFO(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, ch num:%d\n"
  511. , FUNC_ADPT_ARG(padapter), ChannelPlan, chanset_size);
  512. else
  513. RTW_WARN(FUNC_ADPT_FMT" ChannelPlan ID:0x%02x, final chset has no channel\n"
  514. , FUNC_ADPT_ARG(padapter), ChannelPlan);
  515. return chanset_size;
  516. }
  517. #ifdef CONFIG_80211AC_VHT
  518. #define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val) , .en_11ac = (_val)
  519. #else
  520. #define COUNTRY_CHPLAN_ASSIGN_EN_11AC(_val)
  521. #endif
  522. #if RTW_DEF_MODULE_REGULATORY_CERT
  523. #define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val) , .def_module_flags = (_val)
  524. #else
  525. #define COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_val)
  526. #endif
  527. /* has def_module_flags specified, used by common map and HAL dfference map */
  528. #define COUNTRY_CHPLAN_ENT(_alpha2, _chplan, _en_11ac, _def_module_flags) \
  529. {.alpha2 = (_alpha2), .chplan = (_chplan) \
  530. COUNTRY_CHPLAN_ASSIGN_EN_11AC(_en_11ac) \
  531. COUNTRY_CHPLAN_ASSIGN_DEF_MODULE_FLAGS(_def_module_flags) \
  532. }
  533. #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
  534. #include "../platform/custom_country_chplan.h"
  535. #elif RTW_DEF_MODULE_REGULATORY_CERT
  536. /* leave def_module_flags empty, def_module_flags check is done on country_chplan_map */
  537. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AE_HMC_M2) /* 2013 certify */
  538. static const struct country_chplan RTL8821AE_HMC_M2_country_chplan_exc_map[] = {
  539. COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
  540. COUNTRY_CHPLAN_ENT("CL", 0x30, 1, 0), /* Chile */
  541. COUNTRY_CHPLAN_ENT("CN", 0x51, 1, 0), /* China */
  542. COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
  543. COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
  544. COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
  545. COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
  546. COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
  547. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  548. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  549. COUNTRY_CHPLAN_ENT("MY", 0x47, 1, 0), /* Malaysia */
  550. COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
  551. COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
  552. COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
  553. COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
  554. COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
  555. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  556. COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
  557. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  558. };
  559. #endif
  560. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821AU) /* 2014 certify */
  561. static const struct country_chplan RTL8821AU_country_chplan_exc_map[] = {
  562. COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
  563. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  564. COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */
  565. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  566. COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
  567. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  568. };
  569. #endif
  570. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AENF_NGFF) /* 2014 certify */
  571. static const struct country_chplan RTL8812AENF_NGFF_country_chplan_exc_map[] = {
  572. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  573. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  574. };
  575. #endif
  576. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8812AEBT_HMC) /* 2013 certify */
  577. static const struct country_chplan RTL8812AEBT_HMC_country_chplan_exc_map[] = {
  578. COUNTRY_CHPLAN_ENT("CA", 0x34, 1, 0), /* Canada */
  579. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  580. COUNTRY_CHPLAN_ENT("RU", 0x59, 0, 0), /* Russia(fac/gost), Kaliningrad */
  581. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  582. COUNTRY_CHPLAN_ENT("UA", 0x36, 0, 0), /* Ukraine */
  583. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  584. };
  585. #endif
  586. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8188EE_HMC_M2) /* 2012 certify */
  587. static const struct country_chplan RTL8188EE_HMC_M2_country_chplan_exc_map[] = {
  588. COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
  589. COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */
  590. COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
  591. COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
  592. COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
  593. COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
  594. COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
  595. COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
  596. COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */
  597. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  598. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  599. COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
  600. COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
  601. COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
  602. COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
  603. COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
  604. COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */
  605. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  606. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  607. COUNTRY_CHPLAN_ENT("VC", 0x34, 1, 0), /* Saint Vincent and the Grenadines */
  608. };
  609. #endif
  610. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BE_HMC_M2) /* 2013 certify */
  611. static const struct country_chplan RTL8723BE_HMC_M2_country_chplan_exc_map[] = {
  612. COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
  613. COUNTRY_CHPLAN_ENT("BS", 0x34, 1, 0), /* Bahamas */
  614. COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
  615. COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
  616. COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
  617. COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
  618. COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
  619. COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
  620. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  621. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  622. COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
  623. COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
  624. COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
  625. COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
  626. COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
  627. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  628. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  629. };
  630. #endif
  631. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723BS_NGFF1216) /* 2014 certify */
  632. static const struct country_chplan RTL8723BS_NGFF1216_country_chplan_exc_map[] = {
  633. COUNTRY_CHPLAN_ENT("BB", 0x34, 1, 0), /* Barbados */
  634. COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
  635. COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
  636. COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
  637. COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
  638. COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
  639. COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
  640. COUNTRY_CHPLAN_ENT("HT", 0x34, 1, 0), /* Haiti */
  641. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  642. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  643. COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
  644. COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
  645. COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
  646. COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
  647. COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
  648. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  649. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  650. };
  651. #endif
  652. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8192EEBT_HMC_M2) /* 2013 certify */
  653. static const struct country_chplan RTL8192EEBT_HMC_M2_country_chplan_exc_map[] = {
  654. COUNTRY_CHPLAN_ENT("AW", 0x34, 1, 0), /* Aruba */
  655. COUNTRY_CHPLAN_ENT("CA", 0x20, 1, 0), /* Canada */
  656. COUNTRY_CHPLAN_ENT("CO", 0x34, 1, 0), /* Colombia */
  657. COUNTRY_CHPLAN_ENT("CR", 0x34, 1, 0), /* Costa Rica */
  658. COUNTRY_CHPLAN_ENT("DO", 0x34, 1, 0), /* Dominican Republic */
  659. COUNTRY_CHPLAN_ENT("EC", 0x34, 1, 0), /* Ecuador */
  660. COUNTRY_CHPLAN_ENT("GT", 0x34, 1, 0), /* Guatemala */
  661. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  662. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  663. COUNTRY_CHPLAN_ENT("NI", 0x34, 1, 0), /* Nicaragua */
  664. COUNTRY_CHPLAN_ENT("PA", 0x34, 1, 0), /* Panama */
  665. COUNTRY_CHPLAN_ENT("PE", 0x34, 1, 0), /* Peru */
  666. COUNTRY_CHPLAN_ENT("PR", 0x34, 1, 0), /* Puerto Rico */
  667. COUNTRY_CHPLAN_ENT("PY", 0x34, 1, 0), /* Paraguay */
  668. COUNTRY_CHPLAN_ENT("SC", 0x34, 1, 0), /* Seychelles */
  669. COUNTRY_CHPLAN_ENT("ST", 0x34, 1, 0), /* Sao Tome and Principe */
  670. COUNTRY_CHPLAN_ENT("TW", 0x39, 1, 0), /* Taiwan */
  671. COUNTRY_CHPLAN_ENT("US", 0x34, 1, 0), /* United States of America (USA) */
  672. };
  673. #endif
  674. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8723DE_NGFF1630) /* 2016 certify */
  675. static const struct country_chplan RTL8723DE_NGFF1630_country_chplan_exc_map[] = {
  676. COUNTRY_CHPLAN_ENT("CA", 0x2A, 1, 0), /* Canada */
  677. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  678. COUNTRY_CHPLAN_ENT("MX", 0x34, 1, 0), /* Mexico */
  679. };
  680. #endif
  681. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8822BE) /* 2016 certify */
  682. static const struct country_chplan RTL8822BE_country_chplan_exc_map[] = {
  683. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  684. };
  685. #endif
  686. #if (RTW_DEF_MODULE_REGULATORY_CERT & RTW_MODULE_RTL8821CE) /* 2016 certify */
  687. static const struct country_chplan RTL8821CE_country_chplan_exc_map[] = {
  688. COUNTRY_CHPLAN_ENT("KR", 0x28, 1, 0), /* South Korea */
  689. };
  690. #endif
  691. /**
  692. * rtw_def_module_get_chplan_from_country -
  693. * @country_code: string of country code
  694. * @return:
  695. * Return NULL for case referring to common map
  696. */
  697. static const struct country_chplan *rtw_def_module_get_chplan_from_country(const char *country_code)
  698. {
  699. const struct country_chplan *ent = NULL;
  700. const struct country_chplan *hal_map = NULL;
  701. u16 hal_map_sz = 0;
  702. int i;
  703. /* TODO: runtime selection for multi driver */
  704. #if (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AE_HMC_M2)
  705. hal_map = RTL8821AE_HMC_M2_country_chplan_exc_map;
  706. hal_map_sz = sizeof(RTL8821AE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
  707. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821AU)
  708. hal_map = RTL8821AU_country_chplan_exc_map;
  709. hal_map_sz = sizeof(RTL8821AU_country_chplan_exc_map) / sizeof(struct country_chplan);
  710. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AENF_NGFF)
  711. hal_map = RTL8812AENF_NGFF_country_chplan_exc_map;
  712. hal_map_sz = sizeof(RTL8812AENF_NGFF_country_chplan_exc_map) / sizeof(struct country_chplan);
  713. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8812AEBT_HMC)
  714. hal_map = RTL8812AEBT_HMC_country_chplan_exc_map;
  715. hal_map_sz = sizeof(RTL8812AEBT_HMC_country_chplan_exc_map) / sizeof(struct country_chplan);
  716. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8188EE_HMC_M2)
  717. hal_map = RTL8188EE_HMC_M2_country_chplan_exc_map;
  718. hal_map_sz = sizeof(RTL8188EE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
  719. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BE_HMC_M2)
  720. hal_map = RTL8723BE_HMC_M2_country_chplan_exc_map;
  721. hal_map_sz = sizeof(RTL8723BE_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
  722. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723BS_NGFF1216)
  723. hal_map = RTL8723BS_NGFF1216_country_chplan_exc_map;
  724. hal_map_sz = sizeof(RTL8723BS_NGFF1216_country_chplan_exc_map) / sizeof(struct country_chplan);
  725. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8192EEBT_HMC_M2)
  726. hal_map = RTL8192EEBT_HMC_M2_country_chplan_exc_map;
  727. hal_map_sz = sizeof(RTL8192EEBT_HMC_M2_country_chplan_exc_map) / sizeof(struct country_chplan);
  728. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8723DE_NGFF1630)
  729. hal_map = RTL8723DE_NGFF1630_country_chplan_exc_map;
  730. hal_map_sz = sizeof(RTL8723DE_NGFF1630_country_chplan_exc_map) / sizeof(struct country_chplan);
  731. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8822BE)
  732. hal_map = RTL8822BE_country_chplan_exc_map;
  733. hal_map_sz = sizeof(RTL8822BE_country_chplan_exc_map) / sizeof(struct country_chplan);
  734. #elif (RTW_DEF_MODULE_REGULATORY_CERT == RTW_MODULE_RTL8821CE)
  735. hal_map = RTL8821CE_country_chplan_exc_map;
  736. hal_map_sz = sizeof(RTL8821CE_country_chplan_exc_map) / sizeof(struct country_chplan);
  737. #endif
  738. if (hal_map == NULL || hal_map_sz == 0)
  739. goto exit;
  740. for (i = 0; i < hal_map_sz; i++) {
  741. if (strncmp(country_code, hal_map[i].alpha2, 2) == 0) {
  742. ent = &hal_map[i];
  743. break;
  744. }
  745. }
  746. exit:
  747. return ent;
  748. }
  749. #endif /* CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP or RTW_DEF_MODULE_REGULATORY_CERT */
  750. static const struct country_chplan country_chplan_map[] = {
  751. COUNTRY_CHPLAN_ENT("AD", 0x26, 1, 0x000), /* Andorra */
  752. COUNTRY_CHPLAN_ENT("AE", 0x26, 1, 0x7FB), /* United Arab Emirates */
  753. COUNTRY_CHPLAN_ENT("AF", 0x42, 1, 0x000), /* Afghanistan */
  754. COUNTRY_CHPLAN_ENT("AG", 0x26, 1, 0x000), /* Antigua & Barbuda */
  755. COUNTRY_CHPLAN_ENT("AI", 0x26, 1, 0x000), /* Anguilla(UK) */
  756. COUNTRY_CHPLAN_ENT("AL", 0x26, 1, 0x7F1), /* Albania */
  757. COUNTRY_CHPLAN_ENT("AM", 0x26, 1, 0x6B0), /* Armenia */
  758. COUNTRY_CHPLAN_ENT("AN", 0x26, 1, 0x7F1), /* Netherlands Antilles */
  759. COUNTRY_CHPLAN_ENT("AO", 0x47, 1, 0x6E0), /* Angola */
  760. COUNTRY_CHPLAN_ENT("AQ", 0x26, 1, 0x000), /* Antarctica */
  761. COUNTRY_CHPLAN_ENT("AR", 0x61, 1, 0x7F3), /* Argentina */
  762. COUNTRY_CHPLAN_ENT("AS", 0x76, 1, 0x000), /* American Samoa */
  763. COUNTRY_CHPLAN_ENT("AT", 0x26, 1, 0x7FB), /* Austria */
  764. COUNTRY_CHPLAN_ENT("AU", 0x45, 1, 0x7FB), /* Australia */
  765. COUNTRY_CHPLAN_ENT("AW", 0x76, 1, 0x0B0), /* Aruba */
  766. COUNTRY_CHPLAN_ENT("AZ", 0x26, 1, 0x7F1), /* Azerbaijan */
  767. COUNTRY_CHPLAN_ENT("BA", 0x26, 1, 0x7F1), /* Bosnia & Herzegovina */
  768. COUNTRY_CHPLAN_ENT("BB", 0x76, 1, 0x650), /* Barbados */
  769. COUNTRY_CHPLAN_ENT("BD", 0x26, 1, 0x7F1), /* Bangladesh */
  770. COUNTRY_CHPLAN_ENT("BE", 0x26, 1, 0x7FB), /* Belgium */
  771. COUNTRY_CHPLAN_ENT("BF", 0x26, 1, 0x6B0), /* Burkina Faso */
  772. COUNTRY_CHPLAN_ENT("BG", 0x26, 1, 0x7F1), /* Bulgaria */
  773. COUNTRY_CHPLAN_ENT("BH", 0x47, 1, 0x7F1), /* Bahrain */
  774. COUNTRY_CHPLAN_ENT("BI", 0x26, 1, 0x6B0), /* Burundi */
  775. COUNTRY_CHPLAN_ENT("BJ", 0x26, 1, 0x6B0), /* Benin */
  776. COUNTRY_CHPLAN_ENT("BN", 0x47, 1, 0x610), /* Brunei */
  777. COUNTRY_CHPLAN_ENT("BO", 0x73, 1, 0x7F1), /* Bolivia */
  778. COUNTRY_CHPLAN_ENT("BR", 0x62, 1, 0x7F1), /* Brazil */
  779. COUNTRY_CHPLAN_ENT("BS", 0x76, 1, 0x620), /* Bahamas */
  780. COUNTRY_CHPLAN_ENT("BW", 0x26, 1, 0x6F1), /* Botswana */
  781. COUNTRY_CHPLAN_ENT("BY", 0x26, 1, 0x7F1), /* Belarus */
  782. COUNTRY_CHPLAN_ENT("BZ", 0x76, 1, 0x000), /* Belize */
  783. COUNTRY_CHPLAN_ENT("CA", 0x2B, 1, 0x7FB), /* Canada */
  784. COUNTRY_CHPLAN_ENT("CC", 0x26, 1, 0x000), /* Cocos (Keeling) Islands (Australia) */
  785. COUNTRY_CHPLAN_ENT("CD", 0x26, 1, 0x6B0), /* Congo, Republic of the */
  786. COUNTRY_CHPLAN_ENT("CF", 0x26, 1, 0x6B0), /* Central African Republic */
  787. COUNTRY_CHPLAN_ENT("CG", 0x26, 1, 0x6B0), /* Congo, Democratic Republic of the. Zaire */
  788. COUNTRY_CHPLAN_ENT("CH", 0x26, 1, 0x7FB), /* Switzerland */
  789. COUNTRY_CHPLAN_ENT("CI", 0x26, 1, 0x7F1), /* Cote d'Ivoire */
  790. COUNTRY_CHPLAN_ENT("CK", 0x26, 1, 0x000), /* Cook Islands */
  791. COUNTRY_CHPLAN_ENT("CL", 0x2D, 1, 0x7F1), /* Chile */
  792. COUNTRY_CHPLAN_ENT("CM", 0x26, 1, 0x6B0), /* Cameroon */
  793. COUNTRY_CHPLAN_ENT("CN", 0x48, 1, 0x7FB), /* China */
  794. COUNTRY_CHPLAN_ENT("CO", 0x76, 1, 0x7F1), /* Colombia */
  795. COUNTRY_CHPLAN_ENT("CR", 0x76, 1, 0x7F1), /* Costa Rica */
  796. COUNTRY_CHPLAN_ENT("CV", 0x26, 1, 0x6B0), /* Cape Verde */
  797. COUNTRY_CHPLAN_ENT("CX", 0x45, 1, 0x000), /* Christmas Island (Australia) */
  798. COUNTRY_CHPLAN_ENT("CY", 0x26, 1, 0x7FB), /* Cyprus */
  799. COUNTRY_CHPLAN_ENT("CZ", 0x26, 1, 0x7FB), /* Czech Republic */
  800. COUNTRY_CHPLAN_ENT("DE", 0x26, 1, 0x7FB), /* Germany */
  801. COUNTRY_CHPLAN_ENT("DJ", 0x26, 1, 0x680), /* Djibouti */
  802. COUNTRY_CHPLAN_ENT("DK", 0x26, 1, 0x7FB), /* Denmark */
  803. COUNTRY_CHPLAN_ENT("DM", 0x76, 1, 0x000), /* Dominica */
  804. COUNTRY_CHPLAN_ENT("DO", 0x76, 1, 0x7F1), /* Dominican Republic */
  805. COUNTRY_CHPLAN_ENT("DZ", 0x26, 1, 0x7F1), /* Algeria */
  806. COUNTRY_CHPLAN_ENT("EC", 0x76, 1, 0x7F1), /* Ecuador */
  807. COUNTRY_CHPLAN_ENT("EE", 0x26, 1, 0x7FB), /* Estonia */
  808. COUNTRY_CHPLAN_ENT("EG", 0x47, 1, 0x7F1), /* Egypt */
  809. COUNTRY_CHPLAN_ENT("EH", 0x47, 1, 0x680), /* Western Sahara */
  810. COUNTRY_CHPLAN_ENT("ER", 0x26, 1, 0x000), /* Eritrea */
  811. COUNTRY_CHPLAN_ENT("ES", 0x26, 1, 0x7FB), /* Spain, Canary Islands, Ceuta, Melilla */
  812. COUNTRY_CHPLAN_ENT("ET", 0x26, 1, 0x4B0), /* Ethiopia */
  813. COUNTRY_CHPLAN_ENT("FI", 0x26, 1, 0x7FB), /* Finland */
  814. COUNTRY_CHPLAN_ENT("FJ", 0x76, 1, 0x600), /* Fiji */
  815. COUNTRY_CHPLAN_ENT("FK", 0x26, 1, 0x000), /* Falkland Islands (Islas Malvinas) (UK) */
  816. COUNTRY_CHPLAN_ENT("FM", 0x76, 1, 0x000), /* Micronesia, Federated States of (USA) */
  817. COUNTRY_CHPLAN_ENT("FO", 0x26, 1, 0x000), /* Faroe Islands (Denmark) */
  818. COUNTRY_CHPLAN_ENT("FR", 0x26, 1, 0x7FB), /* France */
  819. COUNTRY_CHPLAN_ENT("GA", 0x26, 1, 0x6B0), /* Gabon */
  820. COUNTRY_CHPLAN_ENT("GB", 0x26, 1, 0x7FB), /* Great Britain (United Kingdom; England) */
  821. COUNTRY_CHPLAN_ENT("GD", 0x34, 1, 0x0B0), /* Grenada */
  822. COUNTRY_CHPLAN_ENT("GE", 0x26, 1, 0x600), /* Georgia */
  823. COUNTRY_CHPLAN_ENT("GF", 0x26, 1, 0x080), /* French Guiana */
  824. COUNTRY_CHPLAN_ENT("GG", 0x26, 1, 0x000), /* Guernsey (UK) */
  825. COUNTRY_CHPLAN_ENT("GH", 0x26, 1, 0x7F1), /* Ghana */
  826. COUNTRY_CHPLAN_ENT("GI", 0x26, 1, 0x600), /* Gibraltar (UK) */
  827. COUNTRY_CHPLAN_ENT("GL", 0x26, 1, 0x600), /* Greenland (Denmark) */
  828. COUNTRY_CHPLAN_ENT("GM", 0x26, 1, 0x6B0), /* Gambia */
  829. COUNTRY_CHPLAN_ENT("GN", 0x26, 1, 0x610), /* Guinea */
  830. COUNTRY_CHPLAN_ENT("GP", 0x26, 1, 0x600), /* Guadeloupe (France) */
  831. COUNTRY_CHPLAN_ENT("GQ", 0x26, 1, 0x6B0), /* Equatorial Guinea */
  832. COUNTRY_CHPLAN_ENT("GR", 0x26, 1, 0x7FB), /* Greece */
  833. COUNTRY_CHPLAN_ENT("GS", 0x26, 1, 0x000), /* South Georgia and the Sandwich Islands (UK) */
  834. COUNTRY_CHPLAN_ENT("GT", 0x61, 1, 0x7F1), /* Guatemala */
  835. COUNTRY_CHPLAN_ENT("GU", 0x76, 1, 0x600), /* Guam (USA) */
  836. COUNTRY_CHPLAN_ENT("GW", 0x26, 1, 0x6B0), /* Guinea-Bissau */
  837. COUNTRY_CHPLAN_ENT("GY", 0x44, 1, 0x000), /* Guyana */
  838. COUNTRY_CHPLAN_ENT("HK", 0x26, 1, 0x7FB), /* Hong Kong */
  839. COUNTRY_CHPLAN_ENT("HM", 0x45, 1, 0x000), /* Heard and McDonald Islands (Australia) */
  840. COUNTRY_CHPLAN_ENT("HN", 0x32, 1, 0x7F1), /* Honduras */
  841. COUNTRY_CHPLAN_ENT("HR", 0x26, 1, 0x7F9), /* Croatia */
  842. COUNTRY_CHPLAN_ENT("HT", 0x76, 1, 0x650), /* Haiti */
  843. COUNTRY_CHPLAN_ENT("HU", 0x26, 1, 0x7FB), /* Hungary */
  844. COUNTRY_CHPLAN_ENT("ID", 0x3D, 0, 0x7F3), /* Indonesia */
  845. COUNTRY_CHPLAN_ENT("IE", 0x26, 1, 0x7FB), /* Ireland */
  846. COUNTRY_CHPLAN_ENT("IL", 0x47, 1, 0x7F1), /* Israel */
  847. COUNTRY_CHPLAN_ENT("IM", 0x26, 1, 0x000), /* Isle of Man (UK) */
  848. COUNTRY_CHPLAN_ENT("IN", 0x48, 1, 0x7F1), /* India */
  849. COUNTRY_CHPLAN_ENT("IQ", 0x26, 1, 0x000), /* Iraq */
  850. COUNTRY_CHPLAN_ENT("IR", 0x26, 0, 0x000), /* Iran */
  851. COUNTRY_CHPLAN_ENT("IS", 0x26, 1, 0x7FB), /* Iceland */
  852. COUNTRY_CHPLAN_ENT("IT", 0x26, 1, 0x7FB), /* Italy */
  853. COUNTRY_CHPLAN_ENT("JE", 0x26, 1, 0x000), /* Jersey (UK) */
  854. COUNTRY_CHPLAN_ENT("JM", 0x51, 1, 0x7F1), /* Jamaica */
  855. COUNTRY_CHPLAN_ENT("JO", 0x49, 1, 0x7FB), /* Jordan */
  856. COUNTRY_CHPLAN_ENT("JP", 0x27, 1, 0x7FF), /* Japan- Telec */
  857. COUNTRY_CHPLAN_ENT("KE", 0x47, 1, 0x7F9), /* Kenya */
  858. COUNTRY_CHPLAN_ENT("KG", 0x26, 1, 0x7F1), /* Kyrgyzstan */
  859. COUNTRY_CHPLAN_ENT("KH", 0x26, 1, 0x7F1), /* Cambodia */
  860. COUNTRY_CHPLAN_ENT("KI", 0x26, 1, 0x000), /* Kiribati */
  861. COUNTRY_CHPLAN_ENT("KN", 0x76, 1, 0x000), /* Saint Kitts and Nevis */
  862. COUNTRY_CHPLAN_ENT("KR", 0x3E, 1, 0x7FB), /* South Korea */
  863. COUNTRY_CHPLAN_ENT("KW", 0x47, 1, 0x7FB), /* Kuwait */
  864. COUNTRY_CHPLAN_ENT("KY", 0x76, 1, 0x000), /* Cayman Islands (UK) */
  865. COUNTRY_CHPLAN_ENT("KZ", 0x26, 1, 0x700), /* Kazakhstan */
  866. COUNTRY_CHPLAN_ENT("LA", 0x26, 1, 0x000), /* Laos */
  867. COUNTRY_CHPLAN_ENT("LB", 0x26, 1, 0x7F1), /* Lebanon */
  868. COUNTRY_CHPLAN_ENT("LC", 0x76, 1, 0x000), /* Saint Lucia */
  869. COUNTRY_CHPLAN_ENT("LI", 0x26, 1, 0x7FB), /* Liechtenstein */
  870. COUNTRY_CHPLAN_ENT("LK", 0x26, 1, 0x7F1), /* Sri Lanka */
  871. COUNTRY_CHPLAN_ENT("LR", 0x26, 1, 0x6B0), /* Liberia */
  872. COUNTRY_CHPLAN_ENT("LS", 0x26, 1, 0x7F1), /* Lesotho */
  873. COUNTRY_CHPLAN_ENT("LT", 0x26, 1, 0x7FB), /* Lithuania */
  874. COUNTRY_CHPLAN_ENT("LU", 0x26, 1, 0x7FB), /* Luxembourg */
  875. COUNTRY_CHPLAN_ENT("LV", 0x26, 1, 0x7FB), /* Latvia */
  876. COUNTRY_CHPLAN_ENT("LY", 0x26, 1, 0x000), /* Libya */
  877. COUNTRY_CHPLAN_ENT("MA", 0x47, 1, 0x7F1), /* Morocco */
  878. COUNTRY_CHPLAN_ENT("MC", 0x26, 1, 0x7FB), /* Monaco */
  879. COUNTRY_CHPLAN_ENT("MD", 0x26, 1, 0x7F1), /* Moldova */
  880. COUNTRY_CHPLAN_ENT("ME", 0x26, 1, 0x7F1), /* Montenegro */
  881. COUNTRY_CHPLAN_ENT("MF", 0x76, 1, 0x000), /* Saint Martin */
  882. COUNTRY_CHPLAN_ENT("MG", 0x26, 1, 0x620), /* Madagascar */
  883. COUNTRY_CHPLAN_ENT("MH", 0x76, 1, 0x000), /* Marshall Islands (USA) */
  884. COUNTRY_CHPLAN_ENT("MK", 0x26, 1, 0x7F1), /* Republic of Macedonia (FYROM) */
  885. COUNTRY_CHPLAN_ENT("ML", 0x26, 1, 0x6B0), /* Mali */
  886. COUNTRY_CHPLAN_ENT("MM", 0x26, 1, 0x000), /* Burma (Myanmar) */
  887. COUNTRY_CHPLAN_ENT("MN", 0x26, 1, 0x000), /* Mongolia */
  888. COUNTRY_CHPLAN_ENT("MO", 0x26, 1, 0x600), /* Macau */
  889. COUNTRY_CHPLAN_ENT("MP", 0x76, 1, 0x000), /* Northern Mariana Islands (USA) */
  890. COUNTRY_CHPLAN_ENT("MQ", 0x26, 1, 0x640), /* Martinique (France) */
  891. COUNTRY_CHPLAN_ENT("MR", 0x26, 1, 0x6A0), /* Mauritania */
  892. COUNTRY_CHPLAN_ENT("MS", 0x26, 1, 0x000), /* Montserrat (UK) */
  893. COUNTRY_CHPLAN_ENT("MT", 0x26, 1, 0x7FB), /* Malta */
  894. COUNTRY_CHPLAN_ENT("MU", 0x26, 1, 0x6B0), /* Mauritius */
  895. COUNTRY_CHPLAN_ENT("MV", 0x47, 1, 0x000), /* Maldives */
  896. COUNTRY_CHPLAN_ENT("MW", 0x26, 1, 0x6B0), /* Malawi */
  897. COUNTRY_CHPLAN_ENT("MX", 0x61, 1, 0x7F1), /* Mexico */
  898. COUNTRY_CHPLAN_ENT("MY", 0x63, 1, 0x7F1), /* Malaysia */
  899. COUNTRY_CHPLAN_ENT("MZ", 0x26, 1, 0x7F1), /* Mozambique */
  900. COUNTRY_CHPLAN_ENT("NA", 0x26, 1, 0x700), /* Namibia */
  901. COUNTRY_CHPLAN_ENT("NC", 0x26, 1, 0x000), /* New Caledonia */
  902. COUNTRY_CHPLAN_ENT("NE", 0x26, 1, 0x6B0), /* Niger */
  903. COUNTRY_CHPLAN_ENT("NF", 0x45, 1, 0x000), /* Norfolk Island (Australia) */
  904. COUNTRY_CHPLAN_ENT("NG", 0x75, 1, 0x7F9), /* Nigeria */
  905. COUNTRY_CHPLAN_ENT("NI", 0x76, 1, 0x7F1), /* Nicaragua */
  906. COUNTRY_CHPLAN_ENT("NL", 0x26, 1, 0x7FB), /* Netherlands */
  907. COUNTRY_CHPLAN_ENT("NO", 0x26, 1, 0x7FB), /* Norway */
  908. COUNTRY_CHPLAN_ENT("NP", 0x47, 1, 0x6F0), /* Nepal */
  909. COUNTRY_CHPLAN_ENT("NR", 0x26, 1, 0x000), /* Nauru */
  910. COUNTRY_CHPLAN_ENT("NU", 0x45, 1, 0x000), /* Niue */
  911. COUNTRY_CHPLAN_ENT("NZ", 0x45, 1, 0x7FB), /* New Zealand */
  912. COUNTRY_CHPLAN_ENT("OM", 0x26, 1, 0x7F9), /* Oman */
  913. COUNTRY_CHPLAN_ENT("PA", 0x76, 1, 0x7F1), /* Panama */
  914. COUNTRY_CHPLAN_ENT("PE", 0x76, 1, 0x7F1), /* Peru */
  915. COUNTRY_CHPLAN_ENT("PF", 0x26, 1, 0x000), /* French Polynesia (France) */
  916. COUNTRY_CHPLAN_ENT("PG", 0x26, 1, 0x7F1), /* Papua New Guinea */
  917. COUNTRY_CHPLAN_ENT("PH", 0x26, 1, 0x7F1), /* Philippines */
  918. COUNTRY_CHPLAN_ENT("PK", 0x51, 1, 0x7F1), /* Pakistan */
  919. COUNTRY_CHPLAN_ENT("PL", 0x26, 1, 0x7FB), /* Poland */
  920. COUNTRY_CHPLAN_ENT("PM", 0x26, 1, 0x000), /* Saint Pierre and Miquelon (France) */
  921. COUNTRY_CHPLAN_ENT("PR", 0x76, 1, 0x7F1), /* Puerto Rico */
  922. COUNTRY_CHPLAN_ENT("PT", 0x26, 1, 0x7FB), /* Portugal */
  923. COUNTRY_CHPLAN_ENT("PW", 0x76, 1, 0x000), /* Palau */
  924. COUNTRY_CHPLAN_ENT("PY", 0x76, 1, 0x7F1), /* Paraguay */
  925. COUNTRY_CHPLAN_ENT("QA", 0x51, 1, 0x7F9), /* Qatar */
  926. COUNTRY_CHPLAN_ENT("RE", 0x26, 1, 0x000), /* Reunion (France) */
  927. COUNTRY_CHPLAN_ENT("RO", 0x26, 1, 0x7F1), /* Romania */
  928. COUNTRY_CHPLAN_ENT("RS", 0x26, 1, 0x7F1), /* Serbia, Kosovo */
  929. COUNTRY_CHPLAN_ENT("RU", 0x59, 1, 0x7FB), /* Russia(fac/gost), Kaliningrad */
  930. COUNTRY_CHPLAN_ENT("RW", 0x26, 1, 0x0B0), /* Rwanda */
  931. COUNTRY_CHPLAN_ENT("SA", 0x26, 1, 0x7FB), /* Saudi Arabia */
  932. COUNTRY_CHPLAN_ENT("SB", 0x26, 1, 0x000), /* Solomon Islands */
  933. COUNTRY_CHPLAN_ENT("SC", 0x76, 1, 0x690), /* Seychelles */
  934. COUNTRY_CHPLAN_ENT("SE", 0x26, 1, 0x7FB), /* Sweden */
  935. COUNTRY_CHPLAN_ENT("SG", 0x35, 1, 0x7FB), /* Singapore */
  936. COUNTRY_CHPLAN_ENT("SH", 0x26, 1, 0x000), /* Saint Helena (UK) */
  937. COUNTRY_CHPLAN_ENT("SI", 0x26, 1, 0x7FB), /* Slovenia */
  938. COUNTRY_CHPLAN_ENT("SJ", 0x26, 1, 0x000), /* Svalbard (Norway) */
  939. COUNTRY_CHPLAN_ENT("SK", 0x26, 1, 0x7FB), /* Slovakia */
  940. COUNTRY_CHPLAN_ENT("SL", 0x26, 1, 0x6B0), /* Sierra Leone */
  941. COUNTRY_CHPLAN_ENT("SM", 0x26, 1, 0x000), /* San Marino */
  942. COUNTRY_CHPLAN_ENT("SN", 0x26, 1, 0x7F1), /* Senegal */
  943. COUNTRY_CHPLAN_ENT("SO", 0x26, 1, 0x000), /* Somalia */
  944. COUNTRY_CHPLAN_ENT("SR", 0x74, 1, 0x000), /* Suriname */
  945. COUNTRY_CHPLAN_ENT("ST", 0x76, 1, 0x680), /* Sao Tome and Principe */
  946. COUNTRY_CHPLAN_ENT("SV", 0x30, 1, 0x7F1), /* El Salvador */
  947. COUNTRY_CHPLAN_ENT("SX", 0x76, 1, 0x000), /* Sint Marteen */
  948. COUNTRY_CHPLAN_ENT("SZ", 0x26, 1, 0x020), /* Swaziland */
  949. COUNTRY_CHPLAN_ENT("TC", 0x26, 1, 0x000), /* Turks and Caicos Islands (UK) */
  950. COUNTRY_CHPLAN_ENT("TD", 0x26, 1, 0x6B0), /* Chad */
  951. COUNTRY_CHPLAN_ENT("TF", 0x26, 1, 0x680), /* French Southern and Antarctic Lands (FR Southern Territories) */
  952. COUNTRY_CHPLAN_ENT("TG", 0x26, 1, 0x6B0), /* Togo */
  953. COUNTRY_CHPLAN_ENT("TH", 0x26, 1, 0x7F1), /* Thailand */
  954. COUNTRY_CHPLAN_ENT("TJ", 0x26, 1, 0x640), /* Tajikistan */
  955. COUNTRY_CHPLAN_ENT("TK", 0x45, 1, 0x000), /* Tokelau */
  956. COUNTRY_CHPLAN_ENT("TM", 0x26, 1, 0x000), /* Turkmenistan */
  957. COUNTRY_CHPLAN_ENT("TN", 0x47, 1, 0x7F1), /* Tunisia */
  958. COUNTRY_CHPLAN_ENT("TO", 0x26, 1, 0x000), /* Tonga */
  959. COUNTRY_CHPLAN_ENT("TR", 0x26, 1, 0x7F1), /* Turkey, Northern Cyprus */
  960. COUNTRY_CHPLAN_ENT("TT", 0x42, 1, 0x3F1), /* Trinidad & Tobago */
  961. COUNTRY_CHPLAN_ENT("TW", 0x76, 1, 0x7FF), /* Taiwan */
  962. COUNTRY_CHPLAN_ENT("TZ", 0x26, 1, 0x6F0), /* Tanzania */
  963. COUNTRY_CHPLAN_ENT("UA", 0x36, 1, 0x7FB), /* Ukraine */
  964. COUNTRY_CHPLAN_ENT("UG", 0x26, 1, 0x6F1), /* Uganda */
  965. COUNTRY_CHPLAN_ENT("US", 0x76, 1, 0x7FF), /* United States of America (USA) */
  966. COUNTRY_CHPLAN_ENT("UY", 0x30, 1, 0x7F1), /* Uruguay */
  967. COUNTRY_CHPLAN_ENT("UZ", 0x47, 1, 0x6F0), /* Uzbekistan */
  968. COUNTRY_CHPLAN_ENT("VA", 0x26, 1, 0x000), /* Holy See (Vatican City) */
  969. COUNTRY_CHPLAN_ENT("VC", 0x76, 1, 0x010), /* Saint Vincent and the Grenadines */
  970. COUNTRY_CHPLAN_ENT("VE", 0x30, 1, 0x7F1), /* Venezuela */
  971. COUNTRY_CHPLAN_ENT("VI", 0x76, 1, 0x000), /* United States Virgin Islands (USA) */
  972. COUNTRY_CHPLAN_ENT("VN", 0x26, 1, 0x7F1), /* Vietnam */
  973. COUNTRY_CHPLAN_ENT("VU", 0x26, 1, 0x000), /* Vanuatu */
  974. COUNTRY_CHPLAN_ENT("WF", 0x26, 1, 0x000), /* Wallis and Futuna (France) */
  975. COUNTRY_CHPLAN_ENT("WS", 0x76, 1, 0x000), /* Samoa */
  976. COUNTRY_CHPLAN_ENT("YE", 0x26, 1, 0x040), /* Yemen */
  977. COUNTRY_CHPLAN_ENT("YT", 0x26, 1, 0x680), /* Mayotte (France) */
  978. COUNTRY_CHPLAN_ENT("ZA", 0x26, 1, 0x7F1), /* South Africa */
  979. COUNTRY_CHPLAN_ENT("ZM", 0x26, 1, 0x6B0), /* Zambia */
  980. COUNTRY_CHPLAN_ENT("ZW", 0x26, 1, 0x7F1), /* Zimbabwe */
  981. };
  982. /*
  983. * rtw_get_chplan_from_country -
  984. * @country_code: string of country code
  985. *
  986. * Return pointer of struct country_chplan entry or NULL when unsupported country_code is given
  987. */
  988. const struct country_chplan *rtw_get_chplan_from_country(const char *country_code)
  989. {
  990. #if RTW_DEF_MODULE_REGULATORY_CERT
  991. const struct country_chplan *exc_ent = NULL;
  992. #endif
  993. const struct country_chplan *ent = NULL;
  994. const struct country_chplan *map = NULL;
  995. u16 map_sz = 0;
  996. char code[2];
  997. int i;
  998. code[0] = alpha_to_upper(country_code[0]);
  999. code[1] = alpha_to_upper(country_code[1]);
  1000. #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
  1001. map = CUSTOMIZED_country_chplan_map;
  1002. map_sz = sizeof(CUSTOMIZED_country_chplan_map) / sizeof(struct country_chplan);
  1003. #else
  1004. #if RTW_DEF_MODULE_REGULATORY_CERT
  1005. exc_ent = rtw_def_module_get_chplan_from_country(code);
  1006. #endif
  1007. map = country_chplan_map;
  1008. map_sz = sizeof(country_chplan_map) / sizeof(struct country_chplan);
  1009. #endif
  1010. for (i = 0; i < map_sz; i++) {
  1011. if (strncmp(code, map[i].alpha2, 2) == 0) {
  1012. ent = &map[i];
  1013. break;
  1014. }
  1015. }
  1016. #if RTW_DEF_MODULE_REGULATORY_CERT
  1017. if (!ent || !(COUNTRY_CHPLAN_DEF_MODULE_FALGS(ent) & RTW_DEF_MODULE_REGULATORY_CERT))
  1018. exc_ent = ent = NULL;
  1019. if (exc_ent)
  1020. ent = exc_ent;
  1021. #endif
  1022. return ent;
  1023. }
  1024. void dump_country_chplan(void *sel, const struct country_chplan *ent)
  1025. {
  1026. RTW_PRINT_SEL(sel, "\"%c%c\", 0x%02X%s\n"
  1027. , ent->alpha2[0], ent->alpha2[1], ent->chplan
  1028. , COUNTRY_CHPLAN_EN_11AC(ent) ? " ac" : ""
  1029. );
  1030. }
  1031. void dump_country_chplan_map(void *sel)
  1032. {
  1033. const struct country_chplan *ent;
  1034. u8 code[2];
  1035. #if RTW_DEF_MODULE_REGULATORY_CERT
  1036. RTW_PRINT_SEL(sel, "RTW_DEF_MODULE_REGULATORY_CERT:0x%x\n", RTW_DEF_MODULE_REGULATORY_CERT);
  1037. #endif
  1038. #ifdef CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP
  1039. RTW_PRINT_SEL(sel, "CONFIG_CUSTOMIZED_COUNTRY_CHPLAN_MAP\n");
  1040. #endif
  1041. for (code[0] = 'A'; code[0] <= 'Z'; code[0]++) {
  1042. for (code[1] = 'A'; code[1] <= 'Z'; code[1]++) {
  1043. ent = rtw_get_chplan_from_country(code);
  1044. if (!ent)
  1045. continue;
  1046. dump_country_chplan(sel, ent);
  1047. }
  1048. }
  1049. }
  1050. void dump_chplan_id_list(void *sel)
  1051. {
  1052. u8 first = 1;
  1053. int i;
  1054. for (i = 0; i < RTW_CHPLAN_MAX; i++) {
  1055. if (!rtw_is_channel_plan_valid(i))
  1056. continue;
  1057. if (first) {
  1058. RTW_PRINT_SEL(sel, "0x%02X ", i);
  1059. first = 0;
  1060. } else
  1061. _RTW_PRINT_SEL(sel, "0x%02X ", i);
  1062. }
  1063. _RTW_PRINT_SEL(sel, "0x7F\n");
  1064. }
  1065. void dump_chplan_test(void *sel)
  1066. {
  1067. int i, j;
  1068. /* check invalid channel */
  1069. for (i = 0; i < RTW_RD_2G_MAX; i++) {
  1070. for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan2G[i]); j++) {
  1071. if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan2G[i], j)) == 0)
  1072. RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan2G[i], j), i, j);
  1073. }
  1074. }
  1075. #ifdef CONFIG_IEEE80211_BAND_5GHZ
  1076. for (i = 0; i < RTW_RD_5G_MAX; i++) {
  1077. for (j = 0; j < CH_LIST_LEN(RTW_ChannelPlan5G[i]); j++) {
  1078. if (rtw_ch2freq(CH_LIST_CH(RTW_ChannelPlan5G[i], j)) == 0)
  1079. RTW_PRINT_SEL(sel, "invalid ch:%u at (%d,%d)\n", CH_LIST_CH(RTW_ChannelPlan5G[i], j), i, j);
  1080. }
  1081. }
  1082. #endif
  1083. }
  1084. void dump_chplan_ver(void *sel)
  1085. {
  1086. RTW_PRINT_SEL(sel, "%s-%s\n", RTW_DOMAIN_MAP_VER, RTW_COUNTRY_MAP_VER);
  1087. }