rlm_domain.c 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846
  1. /*
  2. ** Id: //Department/DaVinci/BRANCHES/MT6620_WIFI_DRIVER_V2_3/mgmt/rlm_domain.c#1
  3. */
  4. /*! \file "rlm_domain.c"
  5. \brief
  6. */
  7. /*
  8. ** Log: rlm_domain.c
  9. *
  10. * 11 10 2011 cm.chang
  11. * NULL
  12. * Modify debug message for XLOG
  13. *
  14. * 09 29 2011 cm.chang
  15. * NULL
  16. * Change the function prototype of rlmDomainGetChnlList()
  17. *
  18. * 09 23 2011 cm.chang
  19. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  20. * Let channel number to zero if band is illegal
  21. *
  22. * 09 22 2011 cm.chang
  23. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  24. * Exclude channel list with illegal band
  25. *
  26. * 09 15 2011 cm.chang
  27. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  28. * Use defined country group to have a change to add new group
  29. *
  30. * 09 08 2011 cm.chang
  31. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  32. * Use new fields ucChannelListMap and ucChannelListIndex in NVRAM
  33. *
  34. * 08 31 2011 cm.chang
  35. * [WCXRP00000969] [MT6620 Wi-Fi][Driver][FW] Channel list for 5G band based on country code
  36. * .
  37. *
  38. * 06 01 2011 cm.chang
  39. * [WCXRP00000756] [MT6620 Wi-Fi][Driver] 1. AIS follow channel of BOW 2. Provide legal channel function
  40. * Provide legal channel function based on domain
  41. *
  42. * 03 19 2011 yuche.tsai
  43. * [WCXRP00000584] [Volunteer Patch][MT6620][Driver] Add beacon timeout support for WiFi Direct.
  44. * Add beacon timeout support for WiFi Direct Network.
  45. *
  46. * 03 02 2011 terry.wu
  47. * [WCXRP00000505] [MT6620 Wi-Fi][Driver/FW] WiFi Direct Integration
  48. * Export rlmDomainGetDomainInfo for p2p driver.
  49. *
  50. * 01 12 2011 cm.chang
  51. * [WCXRP00000354] [MT6620 Wi-Fi][Driver][FW] Follow NVRAM bandwidth setting
  52. * User-defined bandwidth is for 2.4G and 5G individually
  53. *
  54. * 12 07 2010 cm.chang
  55. * [WCXRP00000238] MT6620 Wi-Fi][Driver][FW] Support regulation domain setting from NVRAM and supplicant
  56. * 1. Country code is from NVRAM or supplicant
  57. * 2. Change band definition in CMD/EVENT.
  58. *
  59. * 07 08 2010 cp.wu
  60. *
  61. * [WPD00003833] [MT6620 and MT5931] Driver migration - move to new repository.
  62. *
  63. * 07 08 2010 cm.chang
  64. * [WPD00003841][LITE Driver] Migrate RLM/CNM to host driver
  65. * Check draft RLM code for HT cap
  66. *
  67. * 03 25 2010 cm.chang
  68. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  69. * Filter out not supported RF freq when reporting available chnl list
  70. *
  71. * 01 22 2010 cm.chang
  72. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  73. * Support protection and bandwidth switch
  74. *
  75. * 01 13 2010 cm.chang
  76. * [BORA00000018]Integrate WIFI part into BORA for the 1st time
  77. * Provide query function about full channel list.
  78. *
  79. * Dec 1 2009 mtk01104
  80. * [BORA00000018] Integrate WIFI part into BORA for the 1st time
  81. *
  82. *
  83. **
  84. */
  85. /*******************************************************************************
  86. * C O M P I L E R F L A G S
  87. ********************************************************************************
  88. */
  89. /*******************************************************************************
  90. * E X T E R N A L R E F E R E N C E S
  91. ********************************************************************************
  92. */
  93. #include "precomp.h"
  94. /*******************************************************************************
  95. * C O N S T A N T S
  96. ********************************************************************************
  97. */
  98. /*******************************************************************************
  99. * D A T A T Y P E S
  100. ********************************************************************************
  101. */
  102. /*******************************************************************************
  103. * P U B L I C D A T A
  104. ********************************************************************************
  105. */
  106. /* The following country or domain shall be set from host driver.
  107. * And host driver should pass specified DOMAIN_INFO_ENTRY to MT6620 as
  108. * the channel list of being a STA to do scanning/searching AP or being an
  109. * AP to choose an adequate channel if auto-channel is set.
  110. */
  111. /* Define mapping tables between country code and its channel set
  112. */
  113. static const UINT_16 g_u2CountryGroup0[] = {
  114. COUNTRY_CODE_AO, COUNTRY_CODE_BZ, COUNTRY_CODE_BJ, COUNTRY_CODE_BT,
  115. COUNTRY_CODE_BO, COUNTRY_CODE_BI, COUNTRY_CODE_CM, COUNTRY_CODE_CF,
  116. COUNTRY_CODE_TD, COUNTRY_CODE_KM, COUNTRY_CODE_CD, COUNTRY_CODE_CG,
  117. COUNTRY_CODE_CI, COUNTRY_CODE_DJ, COUNTRY_CODE_GQ, COUNTRY_CODE_ER,
  118. COUNTRY_CODE_FJ, COUNTRY_CODE_GA, COUNTRY_CODE_GM, COUNTRY_CODE_GN,
  119. COUNTRY_CODE_GW, COUNTRY_CODE_RKS, COUNTRY_CODE_KG, COUNTRY_CODE_LY,
  120. COUNTRY_CODE_MG, COUNTRY_CODE_ML, COUNTRY_CODE_NR, COUNTRY_CODE_NC,
  121. COUNTRY_CODE_ST, COUNTRY_CODE_SC, COUNTRY_CODE_SL, COUNTRY_CODE_SB,
  122. COUNTRY_CODE_SO, COUNTRY_CODE_SR, COUNTRY_CODE_SZ, COUNTRY_CODE_TJ,
  123. COUNTRY_CODE_TG, COUNTRY_CODE_TO, COUNTRY_CODE_TM, COUNTRY_CODE_TV,
  124. COUNTRY_CODE_VU, COUNTRY_CODE_IL, COUNTRY_CODE_YE
  125. };
  126. static const UINT_16 g_u2CountryGroup1[] = {
  127. COUNTRY_CODE_AS, COUNTRY_CODE_AI, COUNTRY_CODE_BM, COUNTRY_CODE_CA,
  128. COUNTRY_CODE_KY, COUNTRY_CODE_GU, COUNTRY_CODE_FM, COUNTRY_CODE_PR,
  129. COUNTRY_CODE_US, COUNTRY_CODE_VI,
  130. };
  131. static const UINT_16 g_u2CountryGroup2[] = {
  132. COUNTRY_CODE_AR, COUNTRY_CODE_AU, COUNTRY_CODE_AZ, COUNTRY_CODE_BW,
  133. COUNTRY_CODE_KH, COUNTRY_CODE_CX, COUNTRY_CODE_CO, COUNTRY_CODE_CR,
  134. #if (CFG_CN_SUPPORT_CLASS121 == 1)
  135. COUNTRY_CODE_CN,
  136. #endif
  137. COUNTRY_CODE_EC, COUNTRY_CODE_GD, COUNTRY_CODE_GT, COUNTRY_CODE_HK,
  138. COUNTRY_CODE_KI, COUNTRY_CODE_LB, COUNTRY_CODE_LR, COUNTRY_CODE_MN,
  139. COUNTRY_CODE_AN, COUNTRY_CODE_NZ, COUNTRY_CODE_NI, COUNTRY_CODE_PW,
  140. COUNTRY_CODE_PY, COUNTRY_CODE_PE, COUNTRY_CODE_PH, COUNTRY_CODE_WS,
  141. COUNTRY_CODE_SG, COUNTRY_CODE_LK, COUNTRY_CODE_TH, COUNTRY_CODE_TT,
  142. COUNTRY_CODE_UY, COUNTRY_CODE_VN
  143. };
  144. static const UINT_16 g_u2CountryGroup3[] = {
  145. COUNTRY_CODE_AW, COUNTRY_CODE_LA, COUNTRY_CODE_SA, COUNTRY_CODE_AE,
  146. COUNTRY_CODE_UG
  147. };
  148. static const UINT_16 g_u2CountryGroup4[] = { COUNTRY_CODE_MM };
  149. static const UINT_16 g_u2CountryGroup5[] = {
  150. COUNTRY_CODE_AL, COUNTRY_CODE_DZ, COUNTRY_CODE_AD, COUNTRY_CODE_AT,
  151. COUNTRY_CODE_BY, COUNTRY_CODE_BE, COUNTRY_CODE_BA, COUNTRY_CODE_VG,
  152. COUNTRY_CODE_BG, COUNTRY_CODE_CV, COUNTRY_CODE_HR, COUNTRY_CODE_CY,
  153. COUNTRY_CODE_CZ, COUNTRY_CODE_DK, COUNTRY_CODE_EE, COUNTRY_CODE_ET,
  154. COUNTRY_CODE_FI, COUNTRY_CODE_FR, COUNTRY_CODE_GF, COUNTRY_CODE_PF,
  155. COUNTRY_CODE_TF, COUNTRY_CODE_GE, COUNTRY_CODE_DE, COUNTRY_CODE_GH,
  156. COUNTRY_CODE_GR, COUNTRY_CODE_GP, COUNTRY_CODE_HU, COUNTRY_CODE_IS,
  157. COUNTRY_CODE_IQ, COUNTRY_CODE_IE, COUNTRY_CODE_IT, COUNTRY_CODE_KE,
  158. COUNTRY_CODE_LV, COUNTRY_CODE_LS, COUNTRY_CODE_LI, COUNTRY_CODE_LT,
  159. COUNTRY_CODE_LU, COUNTRY_CODE_MK, COUNTRY_CODE_MT, COUNTRY_CODE_MQ,
  160. COUNTRY_CODE_MR, COUNTRY_CODE_MU, COUNTRY_CODE_YT, COUNTRY_CODE_MD,
  161. COUNTRY_CODE_MC, COUNTRY_CODE_ME, COUNTRY_CODE_MS, COUNTRY_CODE_NL,
  162. COUNTRY_CODE_NO, COUNTRY_CODE_OM, COUNTRY_CODE_PL, COUNTRY_CODE_PT,
  163. COUNTRY_CODE_RE, COUNTRY_CODE_RO, COUNTRY_CODE_MF, COUNTRY_CODE_SM,
  164. COUNTRY_CODE_SN, COUNTRY_CODE_RS, COUNTRY_CODE_SK, COUNTRY_CODE_SI,
  165. COUNTRY_CODE_ZA, COUNTRY_CODE_ES, COUNTRY_CODE_SE, COUNTRY_CODE_CH,
  166. COUNTRY_CODE_TR, COUNTRY_CODE_TC, COUNTRY_CODE_GB, COUNTRY_CODE_VA,
  167. COUNTRY_CODE_FR
  168. };
  169. static const UINT_16 g_u2CountryGroup6[] = { COUNTRY_CODE_JP };
  170. static const UINT_16 g_u2CountryGroup7[] = {
  171. COUNTRY_CODE_AM, COUNTRY_CODE_IL, COUNTRY_CODE_KW, COUNTRY_CODE_MA,
  172. COUNTRY_CODE_NE, COUNTRY_CODE_TN, COUNTRY_CODE_MA
  173. };
  174. static const UINT_16 g_u2CountryGroup8[] = { COUNTRY_CODE_NP };
  175. static const UINT_16 g_u2CountryGroup9[] = { COUNTRY_CODE_AF };
  176. static const UINT_16 g_u2CountryGroup10[] = {
  177. COUNTRY_CODE_AG, COUNTRY_CODE_BS, COUNTRY_CODE_BH, COUNTRY_CODE_BB,
  178. COUNTRY_CODE_BN, COUNTRY_CODE_CL, COUNTRY_CODE_EG,
  179. #if (CFG_CN_SUPPORT_CLASS121 == 0)
  180. COUNTRY_CODE_CN,
  181. #endif
  182. COUNTRY_CODE_SV, COUNTRY_CODE_IN, COUNTRY_CODE_MY, COUNTRY_CODE_MV,
  183. COUNTRY_CODE_PA, COUNTRY_CODE_VE, COUNTRY_CODE_ZM,
  184. };
  185. static const UINT_16 g_u2CountryGroup11[] = { COUNTRY_CODE_JO, COUNTRY_CODE_PG };
  186. static const UINT_16 g_u2CountryGroup12[] = {
  187. COUNTRY_CODE_BF, COUNTRY_CODE_GY, COUNTRY_CODE_HT, COUNTRY_CODE_HN,
  188. COUNTRY_CODE_JM, COUNTRY_CODE_MO, COUNTRY_CODE_MW, COUNTRY_CODE_PK,
  189. COUNTRY_CODE_QA, COUNTRY_CODE_RW, COUNTRY_CODE_KN, COUNTRY_CODE_TZ,
  190. };
  191. static const UINT_16 g_u2CountryGroup13[] = { COUNTRY_CODE_ID };
  192. static const UINT_16 g_u2CountryGroup14[] = { COUNTRY_CODE_KR };
  193. static const UINT_16 g_u2CountryGroup15[] = { COUNTRY_CODE_NG };
  194. static const UINT_16 g_u2CountryGroup16[] = {
  195. COUNTRY_CODE_BD, COUNTRY_CODE_BR, COUNTRY_CODE_DM, COUNTRY_CODE_DO,
  196. COUNTRY_CODE_FK, COUNTRY_CODE_KZ, COUNTRY_CODE_MX, COUNTRY_CODE_MZ,
  197. COUNTRY_CODE_NA, COUNTRY_CODE_RU, COUNTRY_CODE_LC, COUNTRY_CODE_VC,
  198. COUNTRY_CODE_UA, COUNTRY_CODE_UZ, COUNTRY_CODE_ZW
  199. };
  200. static const UINT_16 g_u2CountryGroup17[] = { COUNTRY_CODE_MP };
  201. static const UINT_16 g_u2CountryGroup18[] = { COUNTRY_CODE_TW };
  202. static const UINT_16 g_u2CountryGroup19[] = {
  203. COUNTRY_CODE_CK, COUNTRY_CODE_CU, COUNTRY_CODE_TL, COUNTRY_CODE_FO,
  204. COUNTRY_CODE_GI, COUNTRY_CODE_GB, COUNTRY_CODE_IR, COUNTRY_CODE_IM,
  205. COUNTRY_CODE_JE, COUNTRY_CODE_KP, COUNTRY_CODE_MH, COUNTRY_CODE_NU,
  206. COUNTRY_CODE_NF, COUNTRY_CODE_PS, COUNTRY_CODE_PN, COUNTRY_CODE_PM,
  207. COUNTRY_CODE_SS, COUNTRY_CODE_SD, COUNTRY_CODE_SY
  208. };
  209. static const UINT_16 g_u2CountryGroup20[] = {
  210. COUNTRY_CODE_EU, COUNTRY_CODE_FF
  211. /* When country code is not found and no matched NVRAM setting, this domain info will be used.
  212. * So mark all country codes to reduce search time. 20110908
  213. */
  214. };
  215. static const UINT_16 g_u2CountryGroup21[] = {
  216. COUNTRY_CODE_UDF
  217. };
  218. #define REG_DOMAIN_DEF_IDX 20 /* EU (Europe Union) */
  219. DOMAIN_INFO_ENTRY arSupportedRegDomains[] = {
  220. {
  221. (PUINT_16) g_u2CountryGroup0, sizeof(g_u2CountryGroup0) / 2,
  222. {
  223. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  224. , /* CH_SET_2G4_1_13 */
  225. {115, BAND_NULL, 0, 0, 0, FALSE}
  226. , /* CH_SET_UNII_LOW_NA */
  227. {118, BAND_NULL, 0, 0, 0, FALSE}
  228. , /* CH_SET_UNII_MID_NA */
  229. {121, BAND_NULL, 0, 0, 0, FALSE}
  230. , /* CH_SET_UNII_WW_NA */
  231. {125, BAND_NULL, 0, 0, 0, FALSE}
  232. , /* CH_SET_UNII_UPPER_NA */
  233. {0, BAND_NULL, 0, 0, 0, FALSE}
  234. }
  235. }
  236. ,
  237. {
  238. (PUINT_16) g_u2CountryGroup1, sizeof(g_u2CountryGroup1) / 2,
  239. {
  240. {81, BAND_2G4, CHNL_SPAN_5, 1, 11, FALSE}
  241. , /* CH_SET_2G4_1_11 */
  242. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  243. , /* CH_SET_UNII_LOW_36_48 */
  244. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  245. , /* CH_SET_UNII_MID_52_64 */
  246. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  247. , /* CH_SET_UNII_WW_100_144 */
  248. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  249. , /* CH_SET_UNII_UPPER_149_165 */
  250. {0, BAND_NULL, 0, 0, 0, FALSE}
  251. }
  252. }
  253. ,
  254. {
  255. (PUINT_16) g_u2CountryGroup2, sizeof(g_u2CountryGroup2) / 2,
  256. {
  257. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  258. , /* CH_SET_2G4_1_13 */
  259. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  260. , /* CH_SET_UNII_LOW_36_48 */
  261. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  262. , /* CH_SET_UNII_MID_52_64 */
  263. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  264. , /* CH_SET_UNII_WW_100_144 */
  265. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  266. , /* CH_SET_UNII_UPPER_149_165 */
  267. {0, BAND_NULL, 0, 0, 0, FALSE}
  268. }
  269. }
  270. ,
  271. {
  272. (PUINT_16) g_u2CountryGroup3, sizeof(g_u2CountryGroup3) / 2,
  273. {
  274. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  275. , /* CH_SET_2G4_1_13 */
  276. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  277. , /* CH_SET_UNII_LOW_36_48 */
  278. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  279. , /* CH_SET_UNII_MID_52_64 */
  280. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  281. , /* CH_SET_UNII_WW_100_144 */
  282. {125, BAND_5G, CHNL_SPAN_20, 149, 4, FALSE}
  283. , /* CH_SET_UNII_UPPER_149_161 */
  284. {0, BAND_NULL, 0, 0, 0, FALSE}
  285. }
  286. }
  287. ,
  288. {
  289. (PUINT_16) g_u2CountryGroup4, sizeof(g_u2CountryGroup4) / 2,
  290. {
  291. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  292. , /* CH_SET_2G4_1_13 */
  293. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  294. , /* CH_SET_UNII_LOW_36_48 */
  295. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  296. , /* CH_SET_UNII_MID_52_64 */
  297. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  298. , /* CH_SET_UNII_WW_100_144 */
  299. {125, BAND_NULL, 0, 0, 0, FALSE}
  300. , /* CH_SET_UNII_UPPER_NA */
  301. {0, BAND_NULL, 0, 0, 0, FALSE}
  302. }
  303. }
  304. ,
  305. {
  306. (PUINT_16) g_u2CountryGroup5, sizeof(g_u2CountryGroup5) / 2,
  307. {
  308. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  309. , /* CH_SET_2G4_1_13 */
  310. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  311. , /* CH_SET_UNII_LOW_36_48 */
  312. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  313. , /* CH_SET_UNII_MID_52_64 */
  314. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  315. , /* CH_SET_UNII_WW_100_140 */
  316. {125, BAND_NULL, 0, 0, 0, FALSE}
  317. , /* CH_SET_UNII_UPPER_NA */
  318. {0, BAND_NULL, 0, 0, 0, FALSE}
  319. }
  320. }
  321. ,
  322. {
  323. (PUINT_16) g_u2CountryGroup6, sizeof(g_u2CountryGroup6) / 2,
  324. {
  325. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  326. , /* CH_SET_2G4_1_13 */
  327. {82, BAND_2G4, CHNL_SPAN_5, 14, 1, FALSE}
  328. , /* CH_SET_2G4_14_14 */
  329. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  330. , /* CH_SET_UNII_LOW_36_48 */
  331. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  332. , /* CH_SET_UNII_MID_52_64 */
  333. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  334. , /* CH_SET_UNII_WW_100_140 */
  335. {125, BAND_NULL, 0, 0, 0, FALSE}
  336. , /* CH_SET_UNII_UPPER_NA */
  337. }
  338. }
  339. ,
  340. {
  341. (PUINT_16) g_u2CountryGroup7, sizeof(g_u2CountryGroup7) / 2,
  342. {
  343. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  344. , /* CH_SET_2G4_1_13 */
  345. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  346. , /* CH_SET_UNII_LOW_36_48 */
  347. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  348. , /* CH_SET_UNII_MID_52_64 */
  349. {121, BAND_NULL, 0, 0, 0, FALSE}
  350. , /* CH_SET_UNII_WW_NA */
  351. {125, BAND_NULL, 0, 0, 0, FALSE}
  352. , /* CH_SET_UNII_UPPER_NA */
  353. {0, BAND_NULL, 0, 0, 0, FALSE}
  354. }
  355. }
  356. ,
  357. {
  358. (PUINT_16) g_u2CountryGroup8, sizeof(g_u2CountryGroup8) / 2,
  359. {
  360. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  361. , /* CH_SET_2G4_1_13 */
  362. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  363. , /* CH_SET_UNII_LOW_36_48 */
  364. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  365. , /* CH_SET_UNII_MID_52_64 */
  366. {121, BAND_NULL, 0, 0, 0, FALSE}
  367. , /* CH_SET_UNII_WW_NA */
  368. {125, BAND_5G, CHNL_SPAN_20, 149, 4, FALSE}
  369. , /* CH_SET_UNII_UPPER_149_161 */
  370. {0, BAND_NULL, 0, 0, 0, FALSE}
  371. }
  372. }
  373. ,
  374. {
  375. (PUINT_16) g_u2CountryGroup9, sizeof(g_u2CountryGroup9) / 2,
  376. {
  377. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  378. , /* CH_SET_2G4_1_13 */
  379. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  380. , /* CH_SET_UNII_LOW_36_48 */
  381. {118, BAND_NULL, 0, 0, 0, FALSE}
  382. , /* CH_SET_UNII_MID_NA */
  383. {121, BAND_NULL, 0, 0, 0, FALSE}
  384. , /* CH_SET_UNII_WW_NA */
  385. {125, BAND_NULL, 0, 0, 0, FALSE}
  386. , /* CH_SET_UNII_UPPER_NA */
  387. {0, BAND_NULL, 0, 0, 0, FALSE}
  388. }
  389. }
  390. ,
  391. {
  392. (PUINT_16) g_u2CountryGroup10, sizeof(g_u2CountryGroup10) / 2,
  393. {
  394. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  395. , /* CH_SET_2G4_1_13 */
  396. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  397. , /* CH_SET_UNII_LOW_36_48 */
  398. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  399. , /* CH_SET_UNII_MID_52_64 */
  400. {121, BAND_NULL, 0, 0, 0, FALSE}
  401. , /* CH_SET_UNII_WW_NA */
  402. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  403. , /* CH_SET_UNII_UPPER_149_165 */
  404. {0, BAND_NULL, 0, 0, 0, FALSE}
  405. }
  406. }
  407. ,
  408. {
  409. (PUINT_16) g_u2CountryGroup11, sizeof(g_u2CountryGroup11) / 2,
  410. {
  411. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  412. , /* CH_SET_2G4_1_13 */
  413. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  414. , /* CH_SET_UNII_LOW_36_48 */
  415. {118, BAND_NULL, 0, 0, 0, FALSE}
  416. , /* CH_SET_UNII_MID_NA */
  417. {121, BAND_NULL, 0, 0, 0, FALSE}
  418. , /* CH_SET_UNII_WW_NA */
  419. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  420. , /* CH_SET_UNII_UPPER_149_165 */
  421. {0, BAND_NULL, 0, 0, 0, FALSE}
  422. }
  423. }
  424. ,
  425. {
  426. (PUINT_16) g_u2CountryGroup12, sizeof(g_u2CountryGroup12) / 2,
  427. {
  428. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  429. , /* CH_SET_2G4_1_13 */
  430. {115, BAND_NULL, 0, 0, 0, FALSE}
  431. , /* CH_SET_UNII_LOW_NA */
  432. {118, BAND_NULL, 0, 0, 0, FALSE}
  433. , /* CH_SET_UNII_MID_NA */
  434. {121, BAND_NULL, 0, 0, 0, FALSE}
  435. , /* CH_SET_UNII_WW_NA */
  436. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  437. , /* CH_SET_UNII_UPPER_149_165 */
  438. {0, BAND_NULL, 0, 0, 0, FALSE}
  439. }
  440. }
  441. ,
  442. {
  443. (PUINT_16) g_u2CountryGroup13, sizeof(g_u2CountryGroup13) / 2,
  444. {
  445. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  446. , /* CH_SET_2G4_1_13 */
  447. {115, BAND_NULL, 0, 0, 0, FALSE}
  448. , /* CH_SET_UNII_LOW_NA */
  449. {118, BAND_NULL, 0, 0, 0, FALSE}
  450. , /* CH_SET_UNII_MID_NA */
  451. {121, BAND_NULL, 0, 0, 0, FALSE}
  452. , /* CH_SET_UNII_WW_NA */
  453. {125, BAND_5G, CHNL_SPAN_20, 149, 4, FALSE}
  454. , /* CH_SET_UNII_UPPER_149_161 */
  455. {0, BAND_NULL, 0, 0, 0, FALSE}
  456. }
  457. }
  458. ,
  459. {
  460. (PUINT_16) g_u2CountryGroup14, sizeof(g_u2CountryGroup14) / 2,
  461. {
  462. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  463. , /* CH_SET_2G4_1_13 */
  464. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  465. , /* CH_SET_UNII_LOW_36_48 */
  466. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  467. , /* CH_SET_UNII_MID_52_64 */
  468. {121, BAND_5G, CHNL_SPAN_20, 100, 8, FALSE}
  469. , /* CH_SET_UNII_WW_100_128 */
  470. {125, BAND_5G, CHNL_SPAN_20, 149, 4, FALSE}
  471. , /* CH_SET_UNII_UPPER_149_161 */
  472. {0, BAND_NULL, 0, 0, 0, FALSE}
  473. }
  474. }
  475. ,
  476. {
  477. (PUINT_16) g_u2CountryGroup15, sizeof(g_u2CountryGroup15) / 2,
  478. {
  479. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  480. , /* CH_SET_2G4_1_13 */
  481. {115, BAND_NULL, 0, 0, 0, FALSE}
  482. , /* CH_SET_UNII_LOW_36_48 */
  483. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  484. , /* CH_SET_UNII_MID_52_64 */
  485. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  486. , /* CH_SET_UNII_WW_100_140 */
  487. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  488. , /* CH_SET_UNII_UPPER_149_165 */
  489. {0, BAND_NULL, 0, 0, 0, FALSE}
  490. }
  491. }
  492. ,
  493. {
  494. (PUINT_16) g_u2CountryGroup16, sizeof(g_u2CountryGroup16) / 2,
  495. {
  496. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  497. , /* CH_SET_2G4_1_13 */
  498. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  499. , /* CH_SET_UNII_LOW_36_48 */
  500. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  501. , /* CH_SET_UNII_MID_52_64 */
  502. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  503. , /* CH_SET_UNII_WW_100_140 */
  504. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  505. , /* CH_SET_UNII_UPPER_149_165 */
  506. {0, BAND_NULL, 0, 0, 0, FALSE}
  507. }
  508. }
  509. ,
  510. {
  511. (PUINT_16) g_u2CountryGroup17, sizeof(g_u2CountryGroup17) / 2,
  512. {
  513. {81, BAND_2G4, CHNL_SPAN_5, 1, 11, FALSE}
  514. , /* CH_SET_2G4_1_11 */
  515. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  516. , /* CH_SET_UNII_LOW_36_48 */
  517. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  518. , /* CH_SET_UNII_MID_52_64 */
  519. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  520. , /* CH_SET_UNII_WW_100_140 */
  521. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  522. , /* CH_SET_UNII_UPPER_149_165 */
  523. {0, BAND_NULL, 0, 0, 0, FALSE}
  524. }
  525. }
  526. ,
  527. {
  528. (PUINT_16) g_u2CountryGroup18, sizeof(g_u2CountryGroup18) / 2,
  529. {
  530. {81, BAND_2G4, CHNL_SPAN_5, 1, 11, FALSE}
  531. , /* CH_SET_2G4_1_11 */
  532. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  533. , /* CH_SET_UNII_LOW_36_48 */
  534. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  535. , /* CH_SET_UNII_MID_52_64 */
  536. {121, BAND_5G, CHNL_SPAN_20, 100, 11, FALSE}
  537. , /* CH_SET_UNII_WW_100_140 */
  538. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  539. , /* CH_SET_UNII_UPPER_149_165 */
  540. {0, BAND_NULL, 0, 0, 0, FALSE}
  541. }
  542. }
  543. ,
  544. {
  545. (PUINT_16) g_u2CountryGroup19, sizeof(g_u2CountryGroup19) / 2,
  546. {
  547. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  548. , /* CH_SET_2G4_1_13 */
  549. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  550. , /* CH_SET_UNII_LOW_36_48 */
  551. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  552. , /* CH_SET_UNII_MID_52_64 */
  553. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  554. , /* CH_SET_UNII_WW_100_144 */
  555. {125, BAND_5G, CHNL_SPAN_20, 149, 5, FALSE}
  556. , /* CH_SET_UNII_UPPER_149_165 */
  557. {0, BAND_NULL, 0, 0, 0, FALSE}
  558. }
  559. }
  560. ,
  561. {
  562. /* Note: REG_DOMAIN_DEF_IDX group is Europe union */
  563. (PUINT_16) g_u2CountryGroup20, sizeof(g_u2CountryGroup20) / 2,
  564. {
  565. {81, BAND_2G4, CHNL_SPAN_5, 1, 13, FALSE}
  566. , /* CH_SET_2G4_1_13 */
  567. {115, BAND_5G, CHNL_SPAN_20, 36, 4, FALSE}
  568. , /* CH_SET_UNII_LOW_36_48 */
  569. {118, BAND_5G, CHNL_SPAN_20, 52, 4, FALSE}
  570. , /* CH_SET_UNII_MID_52_64 */
  571. {121, BAND_5G, CHNL_SPAN_20, 100, 12, FALSE}
  572. , /* CH_SET_UNII_WW_100_144 */
  573. {125, BAND_5G, CHNL_SPAN_20, 149, 7, FALSE}
  574. , /* CH_SET_UNII_UPPER_149_173 */
  575. {0, BAND_NULL, 0, 0, 0, FALSE}
  576. }
  577. }
  578. ,
  579. {
  580. /* Note: for customer configured their own scanning list and passive scan list */
  581. (PUINT_16) g_u2CountryGroup21, sizeof(g_u2CountryGroup21) / 2,
  582. {
  583. {81, BAND_2G4, CHNL_SPAN_5, 1, 12, FALSE}
  584. , /* CH_SET_2G4_1_13 */
  585. {115, BAND_5G, CHNL_SPAN_20, 36, 0, FALSE}
  586. ,
  587. {118, BAND_5G, CHNL_SPAN_20, 52, 0, FALSE}
  588. ,
  589. {121, BAND_5G, CHNL_SPAN_20, 100, 0, FALSE}
  590. ,
  591. {125, BAND_5G, CHNL_SPAN_20, 149, 0, FALSE}
  592. ,
  593. {0, BAND_NULL, 0, 0, 0, FALSE}
  594. }
  595. }
  596. };
  597. #define REG_DOMAIN_PASSIVE_DEF_IDX 0
  598. #define REG_DOMAIN_PASSIVE_UDF_IDX 1
  599. static UINT_16 g_u2CountryGroup0_Passive[] = {
  600. COUNTRY_CODE_UDF
  601. };
  602. DOMAIN_INFO_ENTRY arSupportedRegDomains_Passive[] = {
  603. {
  604. /* default passive scan channel table is empty */
  605. COUNTRY_CODE_NULL, 0,
  606. {
  607. {81, BAND_2G4, CHNL_SPAN_5, 11, 0, 0}, /* CH_SET_2G4_1_14 */
  608. {82, BAND_2G4, CHNL_SPAN_5, 5, 0, 0},
  609. {115, BAND_5G, CHNL_SPAN_20, 36, 0, 0}, /* CH_SET_UNII_LOW_36_48 */
  610. {118, BAND_5G, CHNL_SPAN_20, 52, 0, 0}, /* CH_SET_UNII_MID_52_64 */
  611. {121, BAND_5G, CHNL_SPAN_20, 100, 0, 0}, /* CH_SET_UNII_WW_100_140 */
  612. {125, BAND_5G, CHNL_SPAN_20, 149, 0, 0}, /* CH_SET_UNII_UPPER_149_173 */
  613. }
  614. },
  615. {
  616. /* User Defined passive scan channel table */
  617. g_u2CountryGroup0_Passive, 0,
  618. {
  619. {81, BAND_2G4, CHNL_SPAN_5, 12, 1, 0}, /* CH_SET_2G4_1_14 */
  620. {82, BAND_2G4, CHNL_SPAN_5, 5, 0, 0},
  621. {115, BAND_5G, CHNL_SPAN_20, 36, 0, 0}, /* CH_SET_UNII_LOW_36_48 */
  622. {118, BAND_5G, CHNL_SPAN_20, 52, 0, 0}, /* CH_SET_UNII_MID_52_64 */
  623. {121, BAND_5G, CHNL_SPAN_20, 100, 0, 0}, /* CH_SET_UNII_WW_100_140 */
  624. {125, BAND_5G, CHNL_SPAN_20, 149, 0, 0}, /* CH_SET_UNII_UPPER_149_173 */
  625. }
  626. }
  627. };
  628. #if 0
  629. COUNTRY_CH_SET_T arCountryChSets[] = {
  630. /* idx=0: US, Bahamas, Barbados, Bolivia(Voluntary), Dominica (the Commonwealth of Dominica),
  631. The Dominican Republic, Haiti */
  632. {CH_SET_2G4_1_11, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  633. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_165},
  634. /* idx=1: Brazil, Ecuador, Hong Kong, Mexico, Peru */
  635. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  636. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_165},
  637. /* idx=2: JP1, Colombia(Voluntary), Paraguay */
  638. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  639. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_NA},
  640. /* idx=3: JP2 */
  641. {CH_SET_2G4_1_14, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  642. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_NA},
  643. /* idx=4: CN, Uruguay, Morocco */
  644. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_NA, CH_SET_UNII_MID_NA,
  645. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_149_165},
  646. /* idx=5: Argentina */
  647. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_NA, CH_SET_UNII_MID_52_64,
  648. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_149_165},
  649. /* idx=6: Australia, New Zealand */
  650. {CH_SET_2G4_1_11, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  651. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_161},
  652. /* idx=7: Russia */
  653. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  654. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_161},
  655. /* idx=8: Indonesia */
  656. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_NA, CH_SET_UNII_MID_NA,
  657. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_149_161},
  658. /* idx=9: Canada */
  659. {CH_SET_2G4_1_11, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  660. CH_SET_UNII_WW_100_116_132_140, CH_SET_UNII_UPPER_149_165},
  661. /* idx=10: Chile, India, Saudi Arabia, Singapore */
  662. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  663. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_149_165},
  664. /* idx=11: Israel, Ukraine */
  665. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  666. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_NA},
  667. /* idx=12: Jordan, Kuwait */
  668. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_NA,
  669. CH_SET_UNII_WW_NA, CH_SET_UNII_UPPER_NA},
  670. /* idx=13: South Korea */
  671. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  672. CH_SET_UNII_WW_100_128, CH_SET_UNII_UPPER_149_165},
  673. /* idx=14: Taiwan */
  674. {CH_SET_2G4_1_11, CH_SET_UNII_LOW_NA, CH_SET_UNII_MID_52_64,
  675. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_165},
  676. /* idx=15: EU all countries */
  677. {CH_SET_2G4_1_13, CH_SET_UNII_LOW_36_48, CH_SET_UNII_MID_52_64,
  678. CH_SET_UNII_WW_100_140, CH_SET_UNII_UPPER_149_173}
  679. };
  680. #endif
  681. #include "rlm_txpwr_init.h"
  682. #if CFG_SUPPORT_PWR_LIMIT_COUNTRY
  683. SUBBAND_CHANNEL_T g_rRlmSubBand[] = {
  684. {BAND_2G4_LOWER_BOUND, BAND_2G4_UPPER_BOUND, 1, 0}
  685. , /* 2.4G */
  686. {UNII1_LOWER_BOUND, UNII1_UPPER_BOUND, 2, 0}
  687. , /* ch36,38,40,..,48 */
  688. {UNII2A_LOWER_BOUND, UNII2A_UPPER_BOUND, 2, 0}
  689. , /* ch52,54,56,..,64 */
  690. {UNII2C_LOWER_BOUND, UNII2C_UPPER_BOUND, 2, 0}
  691. , /* ch100,102,104,...,144 */
  692. {UNII3_LOWER_BOUND, UNII3_UPPER_BOUND, 2, 0} /* ch149,151,153,....,173 */
  693. };
  694. #endif
  695. /*******************************************************************************
  696. * P R I V A T E D A T A
  697. ********************************************************************************
  698. */
  699. /*******************************************************************************
  700. * M A C R O S
  701. ********************************************************************************
  702. */
  703. /*******************************************************************************
  704. * F U N C T I O N D E C L A R A T I O N S
  705. ********************************************************************************
  706. */
  707. /*******************************************************************************
  708. * F U N C T I O N S
  709. ********************************************************************************
  710. */
  711. UINT32 rlmDomainSupOperatingClassIeFill(UINT_8 *pBuf)
  712. {
  713. /*
  714. The Country element should only be included for Status Code 0 (Successful).
  715. */
  716. UINT32 u4IeLen;
  717. UINT8 aucClass[12] = { 0x01, 0x02, 0x03, 0x05, 0x16, 0x17, 0x19, 0x1b,
  718. 0x1c, 0x1e, 0x20, 0x21
  719. };
  720. /*
  721. The Supported Operating Classes element is used by a STA to advertise the
  722. operating classes that it is capable of operating with in this country.
  723. The Country element (see 8.4.2.10) allows a STA to configure its PHY and MAC
  724. for operation when the operating triplet of Operating Extension Identifier,
  725. Operating Class, and Coverage Class fields is present.
  726. */
  727. SUP_OPERATING_CLASS_IE(pBuf)->ucId = ELEM_ID_SUP_OPERATING_CLASS;
  728. SUP_OPERATING_CLASS_IE(pBuf)->ucLength = 1 + sizeof(aucClass);
  729. SUP_OPERATING_CLASS_IE(pBuf)->ucCur = 0x0c; /* 0x51 */
  730. kalMemCopy(SUP_OPERATING_CLASS_IE(pBuf)->ucSup, aucClass, sizeof(aucClass));
  731. u4IeLen = (SUP_OPERATING_CLASS_IE(pBuf)->ucLength + 2);
  732. pBuf += u4IeLen;
  733. COUNTRY_IE(pBuf)->ucId = ELEM_ID_COUNTRY_INFO;
  734. COUNTRY_IE(pBuf)->ucLength = 6;
  735. COUNTRY_IE(pBuf)->aucCountryStr[0] = 0x55;
  736. COUNTRY_IE(pBuf)->aucCountryStr[1] = 0x53;
  737. COUNTRY_IE(pBuf)->aucCountryStr[2] = 0x20;
  738. COUNTRY_IE(pBuf)->arCountryStr[0].ucFirstChnlNum = 1;
  739. COUNTRY_IE(pBuf)->arCountryStr[0].ucNumOfChnl = 11;
  740. COUNTRY_IE(pBuf)->arCountryStr[0].cMaxTxPwrLv = 0x1e;
  741. u4IeLen += (COUNTRY_IE(pBuf)->ucLength + 2);
  742. return u4IeLen;
  743. }
  744. /*----------------------------------------------------------------------------*/
  745. /*!
  746. * \brief
  747. *
  748. * \param[in/out]
  749. *
  750. * \return none
  751. */
  752. /*----------------------------------------------------------------------------*/
  753. P_DOMAIN_INFO_ENTRY rlmDomainGetDomainInfo(P_ADAPTER_T prAdapter)
  754. {
  755. #define REG_DOMAIN_GROUP_NUM \
  756. (sizeof(arSupportedRegDomains) / sizeof(DOMAIN_INFO_ENTRY))
  757. UINT_16 i, j;
  758. P_DOMAIN_INFO_ENTRY prDomainInfo;
  759. P_REG_INFO_T prRegInfo;
  760. UINT_16 u2TargetCountryCode;
  761. ASSERT(prAdapter);
  762. prRegInfo = &prAdapter->prGlueInfo->rRegInfo;
  763. DBGLOG(RLM, TRACE, "Domain: map=%d, idx=%d, code=0x%04x\n",
  764. prRegInfo->eRegChannelListMap, prRegInfo->ucRegChannelListIndex,
  765. prAdapter->rWifiVar.rConnSettings.u2CountryCode);
  766. /* only 1 is set among idx/customized/countryCode in NVRAM */
  767. /* searched by idx */
  768. if (prRegInfo->eRegChannelListMap == REG_CH_MAP_TBL_IDX &&
  769. prRegInfo->ucRegChannelListIndex < REG_DOMAIN_GROUP_NUM) {
  770. prDomainInfo = &arSupportedRegDomains[prRegInfo->ucRegChannelListIndex];
  771. goto L_set_domain_info;
  772. } /* searched by customized */
  773. else if (prRegInfo->eRegChannelListMap == REG_CH_MAP_CUSTOMIZED) {
  774. prDomainInfo = &prRegInfo->rDomainInfo;
  775. goto L_set_domain_info;
  776. }
  777. /* searched by countryCode */
  778. u2TargetCountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
  779. for (i = 0; i < REG_DOMAIN_GROUP_NUM; i++) {
  780. prDomainInfo = &arSupportedRegDomains[i];
  781. if ((prDomainInfo->u4CountryNum && prDomainInfo->pu2CountryGroup) ||
  782. prDomainInfo->u4CountryNum == 0) {
  783. for (j = 0; j < prDomainInfo->u4CountryNum; j++) {
  784. if (prDomainInfo->pu2CountryGroup[j] == u2TargetCountryCode)
  785. break;
  786. }
  787. if (j < prDomainInfo->u4CountryNum)
  788. break; /* Found */
  789. }
  790. }
  791. DATA_STRUCT_INSPECTING_ASSERT(REG_DOMAIN_DEF_IDX < REG_DOMAIN_GROUP_NUM);
  792. /* If no matched countryCode */
  793. if (i >= REG_DOMAIN_GROUP_NUM) {
  794. if (prAdapter->prDomainInfo) /* use previous NVRAM setting */
  795. return prAdapter->prDomainInfo;
  796. /* if never set before, use EU */
  797. prDomainInfo = &arSupportedRegDomains[REG_DOMAIN_DEF_IDX];
  798. }
  799. L_set_domain_info:
  800. prAdapter->prDomainInfo = prDomainInfo;
  801. return prDomainInfo;
  802. }
  803. /*----------------------------------------------------------------------------*/
  804. /*!
  805. * \brief
  806. *
  807. * \param[in/out] The input variable pointed by pucNumOfChannel is the max
  808. * arrary size. The return value indciates meaning list size.
  809. *
  810. * \return none
  811. */
  812. /*----------------------------------------------------------------------------*/
  813. VOID
  814. rlmDomainGetChnlList(P_ADAPTER_T prAdapter,
  815. ENUM_BAND_T eSpecificBand,
  816. UINT_8 ucMaxChannelNum, PUINT_8 pucNumOfChannel, P_RF_CHANNEL_INFO_T paucChannelList)
  817. {
  818. UINT_8 i, j, ucNum;
  819. P_DOMAIN_SUBBAND_INFO prSubband;
  820. P_DOMAIN_INFO_ENTRY prDomainInfo;
  821. ASSERT(prAdapter);
  822. ASSERT(paucChannelList);
  823. ASSERT(pucNumOfChannel);
  824. /* If no matched country code, use previous NVRAM setting or EU */
  825. prDomainInfo = rlmDomainGetDomainInfo(prAdapter);
  826. ASSERT(prDomainInfo);
  827. ucNum = 0;
  828. for (i = 0; i < MAX_SUBBAND_NUM; i++) {
  829. prSubband = &prDomainInfo->rSubBand[i];
  830. if (prSubband->ucBand == BAND_NULL || prSubband->ucBand >= BAND_NUM ||
  831. (prSubband->ucBand == BAND_5G && !prAdapter->fgEnable5GBand))
  832. continue;
  833. if (eSpecificBand == BAND_NULL || prSubband->ucBand == eSpecificBand) {
  834. for (j = 0; j < prSubband->ucNumChannels; j++) {
  835. if (ucNum >= ucMaxChannelNum)
  836. break;
  837. paucChannelList[ucNum].eBand = prSubband->ucBand;
  838. paucChannelList[ucNum].ucChannelNum =
  839. prSubband->ucFirstChannelNum + j * prSubband->ucChannelSpan;
  840. ucNum++;
  841. }
  842. }
  843. }
  844. *pucNumOfChannel = ucNum;
  845. }
  846. /*----------------------------------------------------------------------------*/
  847. /*!
  848. * @brief
  849. *
  850. * @param[in]
  851. *
  852. * @return (none)
  853. */
  854. /*----------------------------------------------------------------------------*/
  855. VOID rlmDomainSendCmd(P_ADAPTER_T prAdapter, BOOLEAN fgIsOid)
  856. {
  857. P_DOMAIN_INFO_ENTRY prDomainInfo;
  858. P_CMD_SET_DOMAIN_INFO_T prCmd;
  859. WLAN_STATUS rStatus;
  860. P_DOMAIN_SUBBAND_INFO prSubBand;
  861. UINT_8 i;
  862. prDomainInfo = rlmDomainGetDomainInfo(prAdapter);
  863. ASSERT(prDomainInfo);
  864. prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T));
  865. ASSERT(prCmd);
  866. /* To do: exception handle */
  867. if (!prCmd) {
  868. DBGLOG(RLM, ERROR, "Domain: no buf to send cmd\n");
  869. return;
  870. }
  871. kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T));
  872. /* previous country code == FF : ignore country code, current country code == FE : resume */
  873. if (prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup == COUNTRY_CODE_FF) {
  874. if (prAdapter->rWifiVar.rConnSettings.u2CountryCode != COUNTRY_CODE_FE) {
  875. DBGLOG(RLM, INFO,
  876. "Domain: skip country code cmd (0x%x)\n",
  877. prAdapter->rWifiVar.rConnSettings.u2CountryCode);
  878. cnmMemFree(prAdapter, prCmd);
  879. return;
  880. }
  881. DBGLOG(RLM, INFO,
  882. "Domain: disable skip country code cmd (0x%x)\n",
  883. prAdapter->rWifiVar.rConnSettings.u2CountryCode);
  884. }
  885. prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
  886. DBGLOG(RLM, LOUD, "Domain: country code backup %x\n", prAdapter->rWifiVar.rConnSettings.u2CountryCodeBakup);
  887. prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
  888. prCmd->u2IsSetPassiveScan = 0;
  889. prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode;
  890. prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode;
  891. prCmd->aucReserved[0] = 0;
  892. prCmd->aucReserved[1] = 0;
  893. for (i = 0; i < 6; i++) {
  894. prSubBand = &prDomainInfo->rSubBand[i];
  895. prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass;
  896. prCmd->rSubBand[i].ucBand = prSubBand->ucBand;
  897. if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) {
  898. prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan;
  899. prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum;
  900. prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels;
  901. }
  902. }
  903. /* Update domain info to chip */
  904. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  905. CMD_ID_SET_DOMAIN_INFO, /* ucCID */
  906. TRUE, /* fgSetQuery */
  907. FALSE, /* fgNeedResp */
  908. fgIsOid, /* fgIsOid */
  909. NULL, /* pfCmdDoneHandler */
  910. NULL, /* pfCmdTimeoutHandler */
  911. sizeof(CMD_SET_DOMAIN_INFO_T), /* u4SetQueryInfoLen */
  912. (PUINT_8) prCmd, /* pucInfoBuffer */
  913. NULL, /* pvSetQueryBuffer */
  914. 0 /* u4SetQueryBufferLen */
  915. );
  916. ASSERT(rStatus == WLAN_STATUS_PENDING);
  917. cnmMemFree(prAdapter, prCmd);
  918. #if CFG_SUPPORT_PWR_LIMIT_COUNTRY
  919. rlmDomainSendPwrLimitCmd(prAdapter);
  920. #endif
  921. rlmDomainPassiveScanSendCmd(prAdapter, fgIsOid);
  922. }
  923. VOID rlmDomainPassiveScanSendCmd(P_ADAPTER_T prAdapter, BOOLEAN fgIsOid)
  924. {
  925. P_DOMAIN_INFO_ENTRY prDomainInfo;
  926. P_CMD_SET_DOMAIN_INFO_T prCmd;
  927. WLAN_STATUS rStatus;
  928. P_DOMAIN_SUBBAND_INFO prSubBand;
  929. UINT_8 i;
  930. prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, sizeof(CMD_SET_DOMAIN_INFO_T));
  931. ASSERT(prCmd);
  932. /* To do: exception handle */
  933. if (!prCmd) {
  934. DBGLOG(RLM, ERROR, "Domain: no buf to send cmd\n");
  935. return;
  936. }
  937. kalMemZero(prCmd, sizeof(CMD_SET_DOMAIN_INFO_T));
  938. prCmd->u2CountryCode = prAdapter->rWifiVar.rConnSettings.u2CountryCode;
  939. prCmd->u2IsSetPassiveScan = 1;
  940. prCmd->uc2G4Bandwidth = prAdapter->rWifiVar.rConnSettings.uc2G4BandwidthMode;
  941. prCmd->uc5GBandwidth = prAdapter->rWifiVar.rConnSettings.uc5GBandwidthMode;
  942. prCmd->aucReserved[0] = 0;
  943. prCmd->aucReserved[1] = 0;
  944. DBGLOG(RLM, TRACE,
  945. "rlmDomainPassiveScanSendCmd(), CountryCode = %x\n", prAdapter->rWifiVar.rConnSettings.u2CountryCode);
  946. if (prAdapter->rWifiVar.rConnSettings.u2CountryCode == COUNTRY_CODE_UDF)
  947. prDomainInfo = &arSupportedRegDomains_Passive[REG_DOMAIN_PASSIVE_UDF_IDX];
  948. else
  949. prDomainInfo = &arSupportedRegDomains_Passive[REG_DOMAIN_PASSIVE_DEF_IDX];
  950. for (i = 0; i < 6; i++) {
  951. prSubBand = &prDomainInfo->rSubBand[i];
  952. prCmd->rSubBand[i].ucRegClass = prSubBand->ucRegClass;
  953. prCmd->rSubBand[i].ucBand = prSubBand->ucBand;
  954. if (prSubBand->ucBand != BAND_NULL && prSubBand->ucBand < BAND_NUM) {
  955. prCmd->rSubBand[i].ucChannelSpan = prSubBand->ucChannelSpan;
  956. prCmd->rSubBand[i].ucFirstChannelNum = prSubBand->ucFirstChannelNum;
  957. prCmd->rSubBand[i].ucNumChannels = prSubBand->ucNumChannels;
  958. }
  959. }
  960. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  961. CMD_ID_SET_DOMAIN_INFO, /* ucCID */
  962. TRUE, /* fgSetQuery */
  963. FALSE, /* fgNeedResp */
  964. fgIsOid, /* fgIsOid */
  965. NULL, /* pfCmdDoneHandler */
  966. NULL, /* pfCmdTimeoutHandler */
  967. sizeof(CMD_SET_DOMAIN_INFO_T), /* u4SetQueryInfoLen */
  968. (PUINT_8) prCmd, /* pucInfoBuffer */
  969. NULL, /* pvSetQueryBuffer */
  970. 0 /* u4SetQueryBufferLen */
  971. );
  972. ASSERT(rStatus == WLAN_STATUS_PENDING);
  973. cnmMemFree(prAdapter, prCmd);
  974. }
  975. /*----------------------------------------------------------------------------*/
  976. /*!
  977. * \brief
  978. *
  979. * \param[in/out]
  980. *
  981. * \return TRUE Legal channel
  982. * FALSE Illegal channel for current regulatory domain
  983. */
  984. /*----------------------------------------------------------------------------*/
  985. BOOLEAN rlmDomainIsLegalChannel(P_ADAPTER_T prAdapter, ENUM_BAND_T eBand, UINT_8 ucChannel)
  986. {
  987. UINT_8 i, j;
  988. P_DOMAIN_SUBBAND_INFO prSubband;
  989. P_DOMAIN_INFO_ENTRY prDomainInfo;
  990. prDomainInfo = rlmDomainGetDomainInfo(prAdapter);
  991. ASSERT(prDomainInfo);
  992. for (i = 0; i < MAX_SUBBAND_NUM; i++) {
  993. prSubband = &prDomainInfo->rSubBand[i];
  994. if (prSubband->ucBand == BAND_5G && !prAdapter->fgEnable5GBand)
  995. continue;
  996. if (prSubband->ucBand == eBand) {
  997. for (j = 0; j < prSubband->ucNumChannels; j++) {
  998. if ((prSubband->ucFirstChannelNum + j * prSubband->ucChannelSpan)
  999. == ucChannel) {
  1000. return TRUE;
  1001. }
  1002. }
  1003. }
  1004. }
  1005. return FALSE;
  1006. }
  1007. /*----------------------------------------------------------------------------*/
  1008. /*!
  1009. * @brief
  1010. *
  1011. * @param[in]
  1012. *
  1013. * @return (fgValid) : 0 -> inValid, 1 -> Valid
  1014. */
  1015. /*----------------------------------------------------------------------------*/
  1016. BOOLEAN rlmDomainCheckChannelEntryValid(P_ADAPTER_T prAdapter, UINT_8 ucCentralCh)
  1017. {
  1018. BOOLEAN fgValid = FALSE;
  1019. UINT_8 ucTemp = 0;
  1020. UINT_8 i;
  1021. /*Check Power limit table channel efficient or not */
  1022. for (i = POWER_LIMIT_2G4; i < POWER_LIMIT_SUBAND_NUM; i++) {
  1023. if ((ucCentralCh >= g_rRlmSubBand[i].ucStartCh) && (ucCentralCh <= g_rRlmSubBand[i].ucEndCh))
  1024. ucTemp = (ucCentralCh - g_rRlmSubBand[i].ucStartCh) % g_rRlmSubBand[i].ucInterval;
  1025. }
  1026. #if 0
  1027. /*2.4G, ex 1, 2, 3 */
  1028. if (ucCentralCh >= BAND_2G4_LOWER_BOUND && ucCentralCh <= BAND_2G4_UPPER_BOUND)
  1029. ucTemp = 0;
  1030. /*FCC- Spec : Band UNII-1, ex 36, 38, 40.... */
  1031. else if (ucCentralCh >= UNII1_LOWER_BOUND && ucCentralCh <= UNII1_UPPER_BOUND)
  1032. ucTemp = (ucCentralCh - UNII1_LOWER_BOUND) % 2;
  1033. /*FCC- Spec : Band UNII-2A, ex 52, 54, 56.... */
  1034. else if (ucCentralCh >= UNII2A_LOWER_BOUND && ucCentralCh <= UNII2A_UPPER_BOUND)
  1035. ucTemp = (ucCentralCh - UNII2A_LOWER_BOUND) % 2;
  1036. /*FCC- Spec : Band UNII-2C, ex 100, 102, 104.... */
  1037. else if (ucCentralCh >= UNII2C_LOWER_BOUND && ucCentralCh <= UNII2C_UPPER_BOUND)
  1038. ucTemp = (ucCentralCh - UNII2C_LOWER_BOUND) % 2;
  1039. /*FCC- Spec : Band UNII-3, ex 149, 151, 153... */
  1040. else if (ucCentralCh >= UNII3_LOWER_BOUND && ucCentralCh <= UNII3_UPPER_BOUND)
  1041. ucTemp = (ucCentralCh - UNII3_LOWER_BOUND) % 2;
  1042. #endif
  1043. if (ucTemp == 0)
  1044. fgValid = TRUE;
  1045. return fgValid;
  1046. }
  1047. /*----------------------------------------------------------------------------*/
  1048. /*!
  1049. * \brief
  1050. *
  1051. * \param[in]
  1052. *
  1053. * \return
  1054. */
  1055. /*----------------------------------------------------------------------------*/
  1056. UINT_8 rlmDomainGetCenterChannel(ENUM_BAND_T eBand, UINT_8 ucPriChannel, ENUM_CHNL_EXT_T eExtend)
  1057. {
  1058. UINT_8 ucCenterChannel;
  1059. if (eExtend == CHNL_EXT_SCA)
  1060. ucCenterChannel = ucPriChannel + 2;
  1061. else if (eExtend == CHNL_EXT_SCB)
  1062. ucCenterChannel = ucPriChannel - 2;
  1063. else
  1064. ucCenterChannel = ucPriChannel;
  1065. return ucCenterChannel;
  1066. }
  1067. /*----------------------------------------------------------------------------*/
  1068. /*!
  1069. * \brief
  1070. *
  1071. * \param[in]
  1072. *
  1073. * \return
  1074. */
  1075. /*----------------------------------------------------------------------------*/
  1076. BOOLEAN
  1077. rlmDomainIsValidRfSetting(P_ADAPTER_T prAdapter,
  1078. ENUM_BAND_T eBand,
  1079. UINT_8 ucPriChannel,
  1080. ENUM_CHNL_EXT_T eExtend,
  1081. ENUM_CHANNEL_WIDTH_T eChannelWidth, UINT_8 ucChannelS1, UINT_8 ucChannelS2)
  1082. {
  1083. UINT_8 ucCenterChannel;
  1084. BOOLEAN fgValidChannel = TRUE;
  1085. BOOLEAN fgValidBW = TRUE;
  1086. BOOLEAN fgValidRfSetting = TRUE;
  1087. UINT_32 u4PrimaryOffset;
  1088. /*DBG msg for Channel InValid */
  1089. if (eChannelWidth == CW_20_40MHZ) {
  1090. ucCenterChannel = rlmDomainGetCenterChannel(eBand, ucPriChannel, eExtend);
  1091. /* Check Central Channel Valid or Not */
  1092. fgValidChannel = rlmDomainCheckChannelEntryValid(prAdapter, ucCenterChannel);
  1093. if (fgValidChannel == FALSE)
  1094. DBGLOG(RLM, WARN, "Rf: CentralCh=%d\n", ucCenterChannel);
  1095. } else if (eChannelWidth == CW_80MHZ) {
  1096. ucCenterChannel = ucChannelS1;
  1097. /* Check Central Channel Valid or Not */
  1098. fgValidChannel = rlmDomainCheckChannelEntryValid(prAdapter, ucCenterChannel);
  1099. if (fgValidChannel == FALSE)
  1100. DBGLOG(RLM, WARN, "Rf: CentralCh=%d\n", ucCenterChannel);
  1101. } else if (eChannelWidth == CW_160MHZ) {
  1102. ucCenterChannel = ucChannelS2;
  1103. /* Check Central Channel Valid or Not */
  1104. /*TODo */
  1105. }
  1106. /* Check BW Setting Correct or Not */
  1107. if (eBand == BAND_2G4) {
  1108. if (eChannelWidth != CW_20_40MHZ) {
  1109. fgValidBW = FALSE;
  1110. DBGLOG(RLM, WARN, "Rf: B=%d, W=%d\n", eBand, eChannelWidth);
  1111. }
  1112. } else {
  1113. if (eChannelWidth == CW_80MHZ) {
  1114. u4PrimaryOffset = CAL_CH_OFFSET_80M(ucPriChannel, ucCenterChannel);
  1115. if (u4PrimaryOffset > 4) {
  1116. fgValidBW = FALSE;
  1117. DBGLOG(RLM, WARN, "Rf: PriOffSet=%d, W=%d\n", u4PrimaryOffset, eChannelWidth);
  1118. }
  1119. } else if (eChannelWidth == CW_160MHZ) {
  1120. u4PrimaryOffset = CAL_CH_OFFSET_160M(ucPriChannel, ucCenterChannel);
  1121. if (u4PrimaryOffset > 8) {
  1122. fgValidBW = FALSE;
  1123. DBGLOG(RLM, WARN, "Rf: PriOffSet=%d, W=%d\n", u4PrimaryOffset, eChannelWidth);
  1124. }
  1125. }
  1126. }
  1127. if ((fgValidBW == FALSE) || (fgValidChannel == FALSE))
  1128. fgValidRfSetting = FALSE;
  1129. return fgValidRfSetting;
  1130. }
  1131. #if CFG_SUPPORT_PWR_LIMIT_COUNTRY
  1132. /*----------------------------------------------------------------------------*/
  1133. /*!
  1134. * @brief
  1135. *
  1136. * @param[in]
  1137. *
  1138. * @return (fgValid) : 0 -> inValid, 1 -> Valid
  1139. */
  1140. /*----------------------------------------------------------------------------*/
  1141. BOOLEAN
  1142. rlmDomainCheckPowerLimitValid(P_ADAPTER_T prAdapter,
  1143. COUNTRY_POWER_LIMIT_TABLE_CONFIGURATION rPowerLimitTableConfiguration,
  1144. UINT_8 ucPwrLimitNum)
  1145. {
  1146. UINT_8 i;
  1147. BOOLEAN fgValid = TRUE;
  1148. PINT_8 prPwrLimit;
  1149. prPwrLimit = &rPowerLimitTableConfiguration.aucPwrLimit[0];
  1150. for (i = 0; i < ucPwrLimitNum; i++, prPwrLimit++) {
  1151. if (*prPwrLimit > MAX_TX_POWER || *prPwrLimit < MIN_TX_POWER) {
  1152. fgValid = FALSE;
  1153. break; /*Find out Wrong Power limit */
  1154. }
  1155. }
  1156. return fgValid;
  1157. }
  1158. /*----------------------------------------------------------------------------*/
  1159. /*!
  1160. * @brief
  1161. *
  1162. * @param[in]
  1163. *
  1164. * @return (none)
  1165. */
  1166. /*----------------------------------------------------------------------------*/
  1167. VOID rlmDomainCheckCountryPowerLimitTable(P_ADAPTER_T prAdapter)
  1168. {
  1169. UINT_8 i, j;
  1170. UINT_16 u2CountryCodeTable, u2CountryCodeCheck;
  1171. BOOLEAN fgChannelValid = FALSE;
  1172. BOOLEAN fgPowerLimitValid = FALSE;
  1173. BOOLEAN fgEntryRepetetion = FALSE;
  1174. BOOLEAN fgTableValid = TRUE;
  1175. /*Configuration Table Check */
  1176. for (i = 0; i < sizeof(g_rRlmPowerLimitConfiguration) / sizeof(COUNTRY_POWER_LIMIT_TABLE_CONFIGURATION); i++) {
  1177. /*Table Country Code */
  1178. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitConfiguration[i].aucCountryCode[0], &u2CountryCodeTable);
  1179. /*Repetition Entry Check */
  1180. for (j = i + 1;
  1181. j < sizeof(g_rRlmPowerLimitConfiguration) / sizeof(COUNTRY_POWER_LIMIT_TABLE_CONFIGURATION);
  1182. j++) {
  1183. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitConfiguration[j].aucCountryCode[0], &u2CountryCodeCheck);
  1184. if (((g_rRlmPowerLimitConfiguration[i].ucCentralCh) ==
  1185. g_rRlmPowerLimitConfiguration[j].ucCentralCh)
  1186. && (u2CountryCodeTable == u2CountryCodeCheck)) {
  1187. fgEntryRepetetion = TRUE;
  1188. DBGLOG(RLM, LOUD, "Domain: Configuration Repetition CC=%c%c, Ch=%d\n",
  1189. g_rRlmPowerLimitConfiguration[i].aucCountryCode[0],
  1190. g_rRlmPowerLimitConfiguration[i].aucCountryCode[1],
  1191. g_rRlmPowerLimitConfiguration[i].ucCentralCh);
  1192. }
  1193. }
  1194. /*Channel Number Check */
  1195. fgChannelValid =
  1196. rlmDomainCheckChannelEntryValid(prAdapter, g_rRlmPowerLimitConfiguration[i].ucCentralCh);
  1197. /*Power Limit Check */
  1198. fgPowerLimitValid =
  1199. rlmDomainCheckPowerLimitValid(prAdapter, g_rRlmPowerLimitConfiguration[i], PWR_LIMIT_NUM);
  1200. if (fgChannelValid == FALSE || fgPowerLimitValid == FALSE) {
  1201. fgTableValid = FALSE;
  1202. DBGLOG(RLM, LOUD, "Domain: CC=%c%c, Ch=%d, Limit: %d,%d,%d,%d,%d\n",
  1203. g_rRlmPowerLimitConfiguration[i].aucCountryCode[0],
  1204. g_rRlmPowerLimitConfiguration[i].aucCountryCode[1],
  1205. g_rRlmPowerLimitConfiguration[i].ucCentralCh,
  1206. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_CCK],
  1207. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_20M],
  1208. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_40M],
  1209. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_80M],
  1210. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_160M]);
  1211. }
  1212. if (u2CountryCodeTable == COUNTRY_CODE_NULL) {
  1213. DBGLOG(RLM, LOUD, "Domain: Full search down\n");
  1214. break; /*End of country table entry */
  1215. }
  1216. }
  1217. if (fgEntryRepetetion == FALSE)
  1218. DBGLOG(RLM, TRACE, "Domain: Configuration Table no Repetiton.\n");
  1219. /*Configuration Table no error */
  1220. if (fgTableValid == TRUE)
  1221. prAdapter->fgIsPowerLimitTableValid = TRUE;
  1222. else
  1223. prAdapter->fgIsPowerLimitTableValid = FALSE;
  1224. /*Default Table Check */
  1225. fgEntryRepetetion = FALSE;
  1226. for (i = 0; i < sizeof(g_rRlmPowerLimitDefault) / sizeof(COUNTRY_POWER_LIMIT_TABLE_DEFAULT); i++) {
  1227. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitDefault[i].aucCountryCode[0], &u2CountryCodeTable);
  1228. for (j = i + 1; j < sizeof(g_rRlmPowerLimitDefault) / sizeof(COUNTRY_POWER_LIMIT_TABLE_DEFAULT); j++) {
  1229. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitDefault[j].aucCountryCode[0], &u2CountryCodeCheck);
  1230. if (u2CountryCodeTable == u2CountryCodeCheck) {
  1231. fgEntryRepetetion = TRUE;
  1232. DBGLOG(RLM, LOUD,
  1233. "Domain: Default Repetition CC=%c%c\n",
  1234. g_rRlmPowerLimitDefault[j].aucCountryCode[0],
  1235. g_rRlmPowerLimitDefault[j].aucCountryCode[1]);
  1236. }
  1237. }
  1238. }
  1239. if (fgEntryRepetetion == FALSE)
  1240. DBGLOG(RLM, TRACE, "Domain: Default Table no Repetiton.\n");
  1241. }
  1242. /*----------------------------------------------------------------------------*/
  1243. /*!
  1244. * @brief
  1245. *
  1246. * @param[in]
  1247. *
  1248. * @return (u2TableIndex) : if 0xFFFF -> No Table Match
  1249. */
  1250. /*----------------------------------------------------------------------------*/
  1251. UINT_16 rlmDomainPwrLimitDefaultTableDecision(P_ADAPTER_T prAdapter, UINT_16 u2CountryCode)
  1252. {
  1253. UINT_16 i;
  1254. UINT_16 u2CountryCodeTable = COUNTRY_CODE_NULL;
  1255. UINT_16 u2TableIndex = POWER_LIMIT_TABLE_NULL; /* No Table Match */
  1256. /*Default Table Index */
  1257. for (i = 0; i < sizeof(g_rRlmPowerLimitDefault) / sizeof(COUNTRY_POWER_LIMIT_TABLE_DEFAULT); i++) {
  1258. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitDefault[i].aucCountryCode[0], &u2CountryCodeTable);
  1259. if (u2CountryCodeTable == u2CountryCode) {
  1260. u2TableIndex = i;
  1261. break; /*match country code */
  1262. } else if (u2CountryCodeTable == COUNTRY_CODE_NULL) {
  1263. u2TableIndex = i;
  1264. break; /*find last one country- Default */
  1265. }
  1266. }
  1267. DBGLOG(RLM, TRACE, "Domain: Default Table Index = %d\n", u2TableIndex);
  1268. return u2TableIndex;
  1269. }
  1270. /*----------------------------------------------------------------------------*/
  1271. /*!
  1272. * @brief
  1273. *
  1274. * @param[in]
  1275. *
  1276. * @return (none)
  1277. */
  1278. /*----------------------------------------------------------------------------*/
  1279. VOID rlmDomainBuildCmdByDefaultTable(P_CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T prCmd, UINT_16 u2DefaultTableIndex)
  1280. {
  1281. UINT_8 i, k;
  1282. P_COUNTRY_POWER_LIMIT_TABLE_DEFAULT prPwrLimitSubBand;
  1283. P_CMD_CHANNEL_POWER_LIMIT prCmdPwrLimit;
  1284. prCmdPwrLimit = &prCmd->rChannelPowerLimit[0];
  1285. prPwrLimitSubBand = &g_rRlmPowerLimitDefault[u2DefaultTableIndex];
  1286. /*Build power limit cmd by default table information */
  1287. for (i = POWER_LIMIT_2G4; i < POWER_LIMIT_SUBAND_NUM; i++) {
  1288. if (prPwrLimitSubBand->aucPwrLimitSubBand[i] < MAX_TX_POWER) {
  1289. for (k = g_rRlmSubBand[i].ucStartCh; k <= g_rRlmSubBand[i].ucEndCh;
  1290. k += g_rRlmSubBand[i].ucInterval) {
  1291. if ((prPwrLimitSubBand->ucPwrUnit & BIT(i)) == 0) {
  1292. prCmdPwrLimit->ucCentralCh = k;
  1293. prCmdPwrLimit->cPwrLimitCCK =
  1294. prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1295. prCmdPwrLimit->cPwrLimit20 =
  1296. prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1297. prCmdPwrLimit->cPwrLimit40 =
  1298. prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1299. prCmdPwrLimit->cPwrLimit80 =
  1300. prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1301. prCmdPwrLimit->cPwrLimit160 =
  1302. prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1303. prCmdPwrLimit++;
  1304. prCmd->ucNum++;
  1305. } else {
  1306. /* ex: 40MHz power limit(mW\MHz) = 20MHz power limit(mW\MHz) * 2
  1307. * ---> 40MHz power limit(dBm) = 20MHz power limit(dBm) + 6; */
  1308. prCmdPwrLimit->ucCentralCh = k;
  1309. prCmdPwrLimit->cPwrLimitCCK = prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1310. prCmdPwrLimit->cPwrLimit20 = prPwrLimitSubBand->aucPwrLimitSubBand[i];
  1311. prCmdPwrLimit->cPwrLimit40 = prPwrLimitSubBand->aucPwrLimitSubBand[i] + 6;
  1312. if (prCmdPwrLimit->cPwrLimit40 > MAX_TX_POWER)
  1313. prCmdPwrLimit->cPwrLimit40 = MAX_TX_POWER;
  1314. prCmdPwrLimit->cPwrLimit80 = prPwrLimitSubBand->aucPwrLimitSubBand[i] + 12;
  1315. if (prCmdPwrLimit->cPwrLimit80 > MAX_TX_POWER)
  1316. prCmdPwrLimit->cPwrLimit80 = MAX_TX_POWER;
  1317. prCmdPwrLimit->cPwrLimit160 = prPwrLimitSubBand->aucPwrLimitSubBand[i] + 18;
  1318. if (prCmdPwrLimit->cPwrLimit160 > MAX_TX_POWER)
  1319. prCmdPwrLimit->cPwrLimit160 = MAX_TX_POWER;
  1320. prCmdPwrLimit++;
  1321. prCmd->ucNum++;
  1322. }
  1323. }
  1324. }
  1325. }
  1326. #if 0
  1327. if (prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_2G4] < MAX_TX_POWER) {
  1328. for (i = BAND_2G4_LOWER_BOUND; i <= BAND_2G4_UPPER_BOUND; i++) {
  1329. prCmdPwrLimit->ucCentralCh = i;
  1330. kalMemSet(&prCmdPwrLimit->cPwrLimitCCK, prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_2G4],
  1331. PWR_LIMIT_NUM);
  1332. prCmdPwrLimit++;
  1333. prCmd->ucNum++;
  1334. }
  1335. }
  1336. if (prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII1] < MAX_TX_POWER) {
  1337. if (prCmd->u2CountryCode != COUNTRY_CODE_KR) {
  1338. for (i = UNII1_LOWER_BOUND; i <= UNII1_UPPER_BOUND; i += 2) {
  1339. prCmdPwrLimit->ucCentralCh = i;
  1340. kalMemSet(&prCmdPwrLimit->cPwrLimitCCK,
  1341. prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII1], PWR_LIMIT_NUM);
  1342. prCmdPwrLimit++;
  1343. prCmd->ucNum++;
  1344. }
  1345. } else {
  1346. for (i = UNII1_LOWER_BOUND; i <= UNII1_UPPER_BOUND; i += 2) {
  1347. /* ex: 40MHz power limit(mW\MHz) = 20MHz power limit(mW\MHz) * 2
  1348. * ---> 40MHz power limit(dBm) = 20MHz power limit(dBm) + 6; */
  1349. prCmdPwrLimit->ucCentralCh = i;
  1350. prCmdPwrLimit->cPwrLimitCCK =
  1351. g_rRlmPowerLimitDefault[u2DefaultTableIndex].cPwrLimitUnii1;
  1352. prCmdPwrLimit->cPwrLimit20 =
  1353. g_rRlmPowerLimitDefault[u2DefaultTableIndex].cPwrLimitUnii1;
  1354. prCmdPwrLimit->cPwrLimit40 =
  1355. g_rRlmPowerLimitDefault[u2DefaultTableIndex].cPwrLimitUnii1 + 6;
  1356. prCmdPwrLimit->cPwrLimit80 =
  1357. g_rRlmPowerLimitDefault[u2DefaultTableIndex].cPwrLimitUnii1 + 12;
  1358. prCmdPwrLimit->cPwrLimit160 =
  1359. g_rRlmPowerLimitDefault[u2DefaultTableIndex].cPwrLimitUnii1 + 18;
  1360. prCmdPwrLimit++;
  1361. prCmd->ucNum++;
  1362. }
  1363. }
  1364. }
  1365. if (prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII2A] < MAX_TX_POWER) {
  1366. for (i = UNII2A_LOWER_BOUND; i <= UNII2A_UPPER_BOUND; i += 2) {
  1367. prCmdPwrLimit->ucCentralCh = i;
  1368. kalMemSet(&prCmdPwrLimit->cPwrLimitCCK,
  1369. prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII2A], PWR_LIMIT_NUM);
  1370. prCmdPwrLimit++;
  1371. prCmd->ucNum++;
  1372. }
  1373. }
  1374. if (prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII2C] < MAX_TX_POWER) {
  1375. for (i = UNII2C_LOWER_BOUND; i <= UNII2C_UPPER_BOUND; i += 2) {
  1376. prCmdPwrLimit->ucCentralCh = i;
  1377. kalMemSet(&prCmdPwrLimit->cPwrLimitCCK,
  1378. prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII2C], PWR_LIMIT_NUM);
  1379. prCmdPwrLimit++;
  1380. prCmd->ucNum++;
  1381. }
  1382. }
  1383. if (prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII3] < MAX_TX_POWER) {
  1384. for (i = UNII3_LOWER_BOUND; i <= UNII3_UPPER_BOUND; i += 2) {
  1385. prCmdPwrLimit->ucCentralCh = i;
  1386. kalMemSet(&prCmdPwrLimit->cPwrLimitCCK,
  1387. prPwrLimitSubBand->aucPwrLimitSubBand[POWER_LIMIT_UNII3], PWR_LIMIT_NUM);
  1388. prCmdPwrLimit++;
  1389. prCmd->ucNum++;
  1390. }
  1391. }
  1392. #endif
  1393. }
  1394. /*----------------------------------------------------------------------------*/
  1395. /*!
  1396. * @brief
  1397. *
  1398. * @param[in]
  1399. *
  1400. * @return (none)
  1401. */
  1402. /*----------------------------------------------------------------------------*/
  1403. VOID rlmDomainBuildCmdByConfigTable(P_ADAPTER_T prAdapter, P_CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T prCmd)
  1404. {
  1405. UINT_8 i, k;
  1406. UINT_16 u2CountryCodeTable = COUNTRY_CODE_NULL;
  1407. P_CMD_CHANNEL_POWER_LIMIT prCmdPwrLimit;
  1408. BOOLEAN fgChannelValid;
  1409. /*Build power limit cmd by configuration table information */
  1410. for (i = 0; i < sizeof(g_rRlmPowerLimitConfiguration) / sizeof(COUNTRY_POWER_LIMIT_TABLE_CONFIGURATION); i++) {
  1411. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitConfiguration[i].aucCountryCode[0], &u2CountryCodeTable);
  1412. fgChannelValid =
  1413. rlmDomainCheckChannelEntryValid(prAdapter, g_rRlmPowerLimitConfiguration[i].ucCentralCh);
  1414. if (u2CountryCodeTable == COUNTRY_CODE_NULL) {
  1415. DBGLOG(RLM, TRACE, "Domain: full search configuration table done.\n");
  1416. break; /*end of configuration table */
  1417. } else if ((u2CountryCodeTable == prCmd->u2CountryCode) && (fgChannelValid == TRUE)) {
  1418. prCmdPwrLimit = &prCmd->rChannelPowerLimit[0];
  1419. if (prCmd->ucNum != 0) {
  1420. for (k = 0; k < prCmd->ucNum; k++) {
  1421. if (prCmdPwrLimit->ucCentralCh ==
  1422. g_rRlmPowerLimitConfiguration[i].ucCentralCh) {
  1423. /*Cmd setting (Default table information) and
  1424. Configuration table has repetition channel entry,
  1425. ex : Default table (ex: 2.4G, limit = 20dBm) --> ch1~14 limit =20dBm,
  1426. Configuration table (ex: ch1, limit = 22dBm) --> ch 1 = 22 dBm
  1427. Cmd final setting --> ch1 = 22dBm, ch12~14 = 20dBm
  1428. */
  1429. prCmdPwrLimit->cPwrLimitCCK =
  1430. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_CCK];
  1431. prCmdPwrLimit->cPwrLimit20 =
  1432. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_20M];
  1433. prCmdPwrLimit->cPwrLimit40 =
  1434. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_40M];
  1435. prCmdPwrLimit->cPwrLimit80 =
  1436. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_80M];
  1437. prCmdPwrLimit->cPwrLimit160 =
  1438. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_160M];
  1439. DBGLOG(RLM, LOUD,
  1440. "Domain: CC=%c%c,ConfigCh=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n",
  1441. ((prCmd->u2CountryCode & 0xff00) >> 8),
  1442. (prCmd->u2CountryCode & 0x00ff), prCmdPwrLimit->ucCentralCh,
  1443. prCmdPwrLimit->cPwrLimitCCK, prCmdPwrLimit->cPwrLimit20,
  1444. prCmdPwrLimit->cPwrLimit40, prCmdPwrLimit->cPwrLimit80,
  1445. prCmdPwrLimit->cPwrLimit160, prCmdPwrLimit->ucFlag);
  1446. break;
  1447. }
  1448. prCmdPwrLimit++;
  1449. }
  1450. if (k == prCmd->ucNum) {
  1451. /*Full search cmd (Default table setting) no match channey,
  1452. ex : Default table (ex: 2.4G, limit = 20dBm) --> ch1~14 limit =20dBm,
  1453. Configuration table (ex: ch36, limit = 22dBm) --> ch 36 = 22 dBm
  1454. Cmd final setting --> ch1~14 = 20dBm, ch36= 22dBm
  1455. */
  1456. prCmdPwrLimit->cPwrLimitCCK =
  1457. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_CCK];
  1458. prCmdPwrLimit->cPwrLimit20 =
  1459. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_20M];
  1460. prCmdPwrLimit->cPwrLimit40 =
  1461. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_40M];
  1462. prCmdPwrLimit->cPwrLimit80 =
  1463. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_80M];
  1464. prCmdPwrLimit->cPwrLimit160 =
  1465. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_160M];
  1466. prCmd->ucNum++;
  1467. DBGLOG(RLM, LOUD,
  1468. "Domain: Full CC=%c%c,ConfigCh=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n",
  1469. ((prCmd->u2CountryCode & 0xff00) >> 8), (prCmd->u2CountryCode & 0x00ff),
  1470. prCmdPwrLimit->ucCentralCh, prCmdPwrLimit->cPwrLimitCCK,
  1471. prCmdPwrLimit->cPwrLimit20, prCmdPwrLimit->cPwrLimit40,
  1472. prCmdPwrLimit->cPwrLimit80, prCmdPwrLimit->cPwrLimit160,
  1473. prCmdPwrLimit->ucFlag);
  1474. }
  1475. } else {
  1476. /*Default table power limit value are 63--> cmd table no channel entry
  1477. ex : Default table (ex: 2.4G, limit = 63Bm) --> no channel entry in cmd,
  1478. Configuration table (ex: ch36, limit = 22dBm) --> ch 36 = 22 dBm
  1479. Cmd final setting --> ch36= 22dBm
  1480. */
  1481. prCmdPwrLimit->ucCentralCh = g_rRlmPowerLimitConfiguration[i].ucCentralCh;
  1482. prCmdPwrLimit->cPwrLimitCCK =
  1483. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_CCK];
  1484. prCmdPwrLimit->cPwrLimit20 =
  1485. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_20M];
  1486. prCmdPwrLimit->cPwrLimit40 =
  1487. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_40M];
  1488. prCmdPwrLimit->cPwrLimit80 =
  1489. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_80M];
  1490. prCmdPwrLimit->cPwrLimit160 =
  1491. g_rRlmPowerLimitConfiguration[i].aucPwrLimit[PWR_LIMIT_160M];
  1492. prCmd->ucNum++;
  1493. DBGLOG(RLM, LOUD, "Domain: Default table power limit value are 63.\n");
  1494. DBGLOG(RLM, LOUD, "Domain: CC=%c%c,ConfigCh=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n",
  1495. ((prCmd->u2CountryCode & 0xff00) >> 8),
  1496. (prCmd->u2CountryCode & 0x00ff), prCmdPwrLimit->ucCentralCh,
  1497. prCmdPwrLimit->cPwrLimitCCK, prCmdPwrLimit->cPwrLimit20,
  1498. prCmdPwrLimit->cPwrLimit40, prCmdPwrLimit->cPwrLimit80,
  1499. prCmdPwrLimit->cPwrLimit160, prCmdPwrLimit->ucFlag);
  1500. }
  1501. }
  1502. }
  1503. }
  1504. /*----------------------------------------------------------------------------*/
  1505. /*!
  1506. * @brief
  1507. *
  1508. * @param[in]
  1509. *
  1510. * @return (none)
  1511. */
  1512. /*----------------------------------------------------------------------------*/
  1513. VOID rlmDomainSendPwrLimitCmd(P_ADAPTER_T prAdapter)
  1514. {
  1515. P_CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T prCmd;
  1516. WLAN_STATUS rStatus;
  1517. UINT_8 i;
  1518. UINT_16 u2DefaultTableIndex;
  1519. UINT_32 u4SetCmdTableMaxSize;
  1520. UINT_32 u4SetQueryInfoLen;
  1521. P_CMD_CHANNEL_POWER_LIMIT prCmdPwrLimit; /* for print usage */
  1522. u4SetCmdTableMaxSize =
  1523. sizeof(CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T) +
  1524. MAX_CMD_SUPPORT_CHANNEL_NUM * sizeof(CMD_CHANNEL_POWER_LIMIT);
  1525. prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, u4SetCmdTableMaxSize);
  1526. if (!prCmd) {
  1527. DBGLOG(RLM, ERROR, "Domain: no buf to send cmd\n");
  1528. return;
  1529. }
  1530. kalMemZero(prCmd, u4SetCmdTableMaxSize);
  1531. u2DefaultTableIndex =
  1532. rlmDomainPwrLimitDefaultTableDecision(prAdapter, prAdapter->rWifiVar.rConnSettings.u2CountryCode);
  1533. if (u2DefaultTableIndex != POWER_LIMIT_TABLE_NULL) {
  1534. WLAN_GET_FIELD_BE16(&g_rRlmPowerLimitDefault[u2DefaultTableIndex].aucCountryCode[0],
  1535. &prCmd->u2CountryCode);
  1536. prCmd->ucNum = 0;
  1537. if (prCmd->u2CountryCode != COUNTRY_CODE_NULL) {
  1538. /*Command - default table information */
  1539. rlmDomainBuildCmdByDefaultTable(prCmd, u2DefaultTableIndex);
  1540. /*Command - configuration table information */
  1541. rlmDomainBuildCmdByConfigTable(prAdapter, prCmd);
  1542. }
  1543. }
  1544. #if 0
  1545. u4SetCmdTableMaxSize =
  1546. sizeof(CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T) +
  1547. MAX_CMD_SUPPORT_CHANNEL_NUM * sizeof(CMD_CHANNEL_POWER_LIMIT);
  1548. prCmd = cnmMemAlloc(prAdapter, RAM_TYPE_BUF, u4SetCmdTableMaxSize);
  1549. ASSERT(prCmd);
  1550. /* To do: exception handle */
  1551. if (!prCmd) {
  1552. DBGLOG(RLM, ERROR, "Domain: no buf to send cmd\n");
  1553. return;
  1554. }
  1555. kalMemZero(prCmd, u4SetCmdTableMaxSize); /* TODO memzero */
  1556. if (u2TableIndex != POWER_LIMIT_TABLE_NULL && u2TableIndex < MAX_DEFAULT_TABLE_COUNTRY_NUM) {
  1557. prCmd->u2CountryCode = (((UINT_16) g_rRlmCountryPowerLimitTable[u2TableIndex].aucCountryCode[0]) << 8) |
  1558. (((UINT_16) g_rRlmCountryPowerLimitTable[u2TableIndex].aucCountryCode[1]) & BITS(0, 7));
  1559. prChPwrLimit = &g_rRlmCountryPowerLimitTable[u2TableIndex].rChannelPowerLimit[0];
  1560. prCmdPwrLimit = &prCmd->rChannelPowerLimit[0];
  1561. prCmd->ucNum = 0;
  1562. for (i = 0; i < MAX_CMD_SUPPORT_CHANNEL_NUM; i++) {
  1563. if (prChPwrLimit->ucCentralCh != ENDCH) {
  1564. /*Check Power limit table channel efficient or not */
  1565. fgChannelValid = rlmDomainCheckChannelEntryValid(prAdapter, prChPwrLimit->ucCentralCh);
  1566. /*Cmd set up */
  1567. if (fgChannelValid) {
  1568. kalMemCopy(prCmdPwrLimit, prChPwrLimit, sizeof(CMD_CHANNEL_POWER_LIMIT));
  1569. DBGLOG(RLM, INFO,
  1570. "Domain: ValidCh=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n",
  1571. prCmdPwrLimit->ucCentralCh, prCmdPwrLimit->cPwrLimitCCK,
  1572. prCmdPwrLimit->cPwrLimit20, prCmdPwrLimit->cPwrLimit40,
  1573. prCmdPwrLimit->cPwrLimit80, prCmdPwrLimit->cPwrLimit160,
  1574. prCmdPwrLimit->ucFlag);
  1575. prCmd->ucNum++;
  1576. prCmdPwrLimit++;
  1577. } else {
  1578. DBGLOG(RLM, INFO,
  1579. "Domain: Non-Ch=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n",
  1580. prChPwrLimit->ucCentralCh, prChPwrLimit->cPwrLimitCCK,
  1581. prChPwrLimit->cPwrLimit20, prChPwrLimit->cPwrLimit40,
  1582. prChPwrLimit->cPwrLimit80, prChPwrLimit->cPwrLimit160,
  1583. prChPwrLimit->ucFlag);
  1584. }
  1585. prChPwrLimit++;
  1586. } else {
  1587. /*End of the chanel entry */
  1588. break;
  1589. }
  1590. };
  1591. }
  1592. #endif
  1593. if (prCmd->u2CountryCode != 0) {
  1594. DBGLOG(RLM, INFO,
  1595. "Domain: ValidCC =%c%c, ChNum=%d\n", ((prCmd->u2CountryCode & 0xff00) >> 8),
  1596. (prCmd->u2CountryCode & 0x00ff), prCmd->ucNum);
  1597. } else {
  1598. DBGLOG(RLM, INFO, "Domain: ValidCC =0x%04x, ucNum=%d\n", prCmd->u2CountryCode, prCmd->ucNum);
  1599. }
  1600. prCmdPwrLimit = &prCmd->rChannelPowerLimit[0];
  1601. for (i = 0; i < prCmd->ucNum; i++) {
  1602. DBGLOG(RLM, TRACE, "Domain: Ch=%d,Limit=%d,%d,%d,%d,%d,Fg=%d\n", prCmdPwrLimit->ucCentralCh,
  1603. prCmdPwrLimit->cPwrLimitCCK, prCmdPwrLimit->cPwrLimit20, prCmdPwrLimit->cPwrLimit40,
  1604. prCmdPwrLimit->cPwrLimit80, prCmdPwrLimit->cPwrLimit160, prCmdPwrLimit->ucFlag);
  1605. prCmdPwrLimit++;
  1606. }
  1607. u4SetQueryInfoLen =
  1608. (sizeof(CMD_SET_COUNTRY_CHANNEL_POWER_LIMIT_T) + (prCmd->ucNum) * sizeof(CMD_CHANNEL_POWER_LIMIT));
  1609. /* Update domain info to chip */
  1610. if (prCmd->ucNum <= MAX_CMD_SUPPORT_CHANNEL_NUM) {
  1611. rStatus = wlanSendSetQueryCmd(prAdapter, /* prAdapter */
  1612. CMD_ID_SET_COUNTRY_POWER_LIMIT, /* ucCID */
  1613. TRUE, /* fgSetQuery */
  1614. FALSE, /* fgNeedResp */
  1615. FALSE, /* fgIsOid */
  1616. NULL, /* pfCmdDoneHandler */
  1617. NULL, /* pfCmdTimeoutHandler */
  1618. u4SetQueryInfoLen, /* u4SetQueryInfoLen */
  1619. (PUINT_8) prCmd, /* pucInfoBuffer */
  1620. NULL, /* pvSetQueryBuffer */
  1621. 0 /* u4SetQueryBufferLen */
  1622. );
  1623. } else
  1624. DBGLOG(RLM, ERROR, "Domain: illegal power limit table");
  1625. /* ASSERT(rStatus == WLAN_STATUS_PENDING); */
  1626. cnmMemFree(prAdapter, prCmd);
  1627. }
  1628. #endif