phydm_hwconfig.c 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
  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. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. *
  19. ******************************************************************************/
  20. /* ************************************************************
  21. * include files
  22. * ************************************************************ */
  23. #include "mp_precomp.h"
  24. #include "phydm_precomp.h"
  25. #define READ_AND_CONFIG_MP(ic, txt) (odm_read_and_config_mp_##ic##txt(p_dm_odm))
  26. #define READ_AND_CONFIG_TC(ic, txt) (odm_read_and_config_tc_##ic##txt(p_dm_odm))
  27. #if (PHYDM_TESTCHIP_SUPPORT == 1)
  28. #define READ_AND_CONFIG(ic, txt) do {\
  29. if (p_dm_odm->is_mp_chip)\
  30. READ_AND_CONFIG_MP(ic, txt);\
  31. else\
  32. READ_AND_CONFIG_TC(ic, txt);\
  33. } while (0)
  34. #else
  35. #define READ_AND_CONFIG READ_AND_CONFIG_MP
  36. #endif
  37. #define READ_FIRMWARE_MP(ic, txt) (odm_read_firmware_mp_##ic##txt(p_dm_odm, p_firmware, p_size))
  38. #define READ_FIRMWARE_TC(ic, txt) (odm_read_firmware_tc_##ic##txt(p_dm_odm, p_firmware, p_size))
  39. #if (PHYDM_TESTCHIP_SUPPORT == 1)
  40. #define READ_FIRMWARE(ic, txt) do {\
  41. if (p_dm_odm->is_mp_chip)\
  42. READ_FIRMWARE_MP(ic, txt);\
  43. else\
  44. READ_FIRMWARE_TC(ic, txt);\
  45. } while (0)
  46. #else
  47. #define READ_FIRMWARE READ_FIRMWARE_MP
  48. #endif
  49. #define GET_VERSION_MP(ic, txt) (odm_get_version_mp_##ic##txt())
  50. #define GET_VERSION_TC(ic, txt) (odm_get_version_tc_##ic##txt())
  51. #if (PHYDM_TESTCHIP_SUPPORT == 1)
  52. #define GET_VERSION(ic, txt) (p_dm_odm->is_mp_chip ? GET_VERSION_MP(ic, txt) : GET_VERSION_TC(ic, txt))
  53. #else
  54. #define GET_VERSION(ic, txt) GET_VERSION_MP(ic, txt)
  55. #endif
  56. u8
  57. odm_query_rx_pwr_percentage(
  58. s8 ant_power
  59. )
  60. {
  61. if ((ant_power <= -100) || (ant_power >= 20))
  62. return 0;
  63. else if (ant_power >= 0)
  64. return 100;
  65. else
  66. return 100 + ant_power;
  67. }
  68. /*
  69. * 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer.
  70. * IF other SW team do not support the feature, remove this section.??
  71. * */
  72. s32
  73. odm_signal_scale_mapping_92c_series_patch_rt_cid_819x_lenovo(
  74. struct PHY_DM_STRUCT *p_dm_odm,
  75. s32 curr_sig
  76. )
  77. {
  78. s32 ret_sig = 0;
  79. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  80. /* if(p_dm_odm->support_interface == ODM_ITRF_PCIE) */
  81. {
  82. /* step 1. Scale mapping. */
  83. /* 20100611 Joseph: Re-tunning RSSI presentation for Lenovo. */
  84. /* 20100426 Joseph: Modify Signal strength mapping. */
  85. /* This modification makes the RSSI indication similar to Intel solution. */
  86. /* 20100414 Joseph: Tunning RSSI for Lenovo according to RTL8191SE. */
  87. if (curr_sig >= 54 && curr_sig <= 100)
  88. ret_sig = 100;
  89. else if (curr_sig >= 42 && curr_sig <= 53)
  90. ret_sig = 95;
  91. else if (curr_sig >= 36 && curr_sig <= 41)
  92. ret_sig = 74 + ((curr_sig - 36) * 20) / 6;
  93. else if (curr_sig >= 33 && curr_sig <= 35)
  94. ret_sig = 65 + ((curr_sig - 33) * 8) / 2;
  95. else if (curr_sig >= 18 && curr_sig <= 32)
  96. ret_sig = 62 + ((curr_sig - 18) * 2) / 15;
  97. else if (curr_sig >= 15 && curr_sig <= 17)
  98. ret_sig = 33 + ((curr_sig - 15) * 28) / 2;
  99. else if (curr_sig >= 10 && curr_sig <= 14)
  100. ret_sig = 39;
  101. else if (curr_sig >= 8 && curr_sig <= 9)
  102. ret_sig = 33;
  103. else if (curr_sig <= 8)
  104. ret_sig = 19;
  105. }
  106. #endif /* ENDIF (DM_ODM_SUPPORT_TYPE == ODM_WIN) */
  107. return ret_sig;
  108. }
  109. s32
  110. odm_signal_scale_mapping_92c_series_patch_rt_cid_819x_netcore(
  111. struct PHY_DM_STRUCT *p_dm_odm,
  112. s32 curr_sig
  113. )
  114. {
  115. s32 ret_sig = 0;
  116. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  117. /* if(p_dm_odm->support_interface == ODM_ITRF_USB) */
  118. {
  119. /* Netcore request this modification because 2009.04.13 SU driver use it. */
  120. if (curr_sig >= 31 && curr_sig <= 100)
  121. ret_sig = 100;
  122. else if (curr_sig >= 21 && curr_sig <= 30)
  123. ret_sig = 90 + ((curr_sig - 20) / 1);
  124. else if (curr_sig >= 11 && curr_sig <= 20)
  125. ret_sig = 80 + ((curr_sig - 10) / 1);
  126. else if (curr_sig >= 7 && curr_sig <= 10)
  127. ret_sig = 69 + (curr_sig - 7);
  128. else if (curr_sig == 6)
  129. ret_sig = 54;
  130. else if (curr_sig == 5)
  131. ret_sig = 45;
  132. else if (curr_sig == 4)
  133. ret_sig = 36;
  134. else if (curr_sig == 3)
  135. ret_sig = 27;
  136. else if (curr_sig == 2)
  137. ret_sig = 18;
  138. else if (curr_sig == 1)
  139. ret_sig = 9;
  140. else
  141. ret_sig = curr_sig;
  142. }
  143. #endif /* ENDIF (DM_ODM_SUPPORT_TYPE == ODM_WIN) */
  144. return ret_sig;
  145. }
  146. s32
  147. odm_signal_scale_mapping_92c_series(
  148. struct PHY_DM_STRUCT *p_dm_odm,
  149. s32 curr_sig
  150. )
  151. {
  152. s32 ret_sig = 0;
  153. #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
  154. if (p_dm_odm->support_interface == ODM_ITRF_PCIE) {
  155. /* step 1. Scale mapping. */
  156. if (curr_sig >= 61 && curr_sig <= 100)
  157. ret_sig = 90 + ((curr_sig - 60) / 4);
  158. else if (curr_sig >= 41 && curr_sig <= 60)
  159. ret_sig = 78 + ((curr_sig - 40) / 2);
  160. else if (curr_sig >= 31 && curr_sig <= 40)
  161. ret_sig = 66 + (curr_sig - 30);
  162. else if (curr_sig >= 21 && curr_sig <= 30)
  163. ret_sig = 54 + (curr_sig - 20);
  164. else if (curr_sig >= 5 && curr_sig <= 20)
  165. ret_sig = 42 + (((curr_sig - 5) * 2) / 3);
  166. else if (curr_sig == 4)
  167. ret_sig = 36;
  168. else if (curr_sig == 3)
  169. ret_sig = 27;
  170. else if (curr_sig == 2)
  171. ret_sig = 18;
  172. else if (curr_sig == 1)
  173. ret_sig = 9;
  174. else
  175. ret_sig = curr_sig;
  176. }
  177. #endif
  178. #if ((DEV_BUS_TYPE == RT_USB_INTERFACE) || (DEV_BUS_TYPE == RT_SDIO_INTERFACE))
  179. if ((p_dm_odm->support_interface == ODM_ITRF_USB) || (p_dm_odm->support_interface == ODM_ITRF_SDIO)) {
  180. if (curr_sig >= 51 && curr_sig <= 100)
  181. ret_sig = 100;
  182. else if (curr_sig >= 41 && curr_sig <= 50)
  183. ret_sig = 80 + ((curr_sig - 40) * 2);
  184. else if (curr_sig >= 31 && curr_sig <= 40)
  185. ret_sig = 66 + (curr_sig - 30);
  186. else if (curr_sig >= 21 && curr_sig <= 30)
  187. ret_sig = 54 + (curr_sig - 20);
  188. else if (curr_sig >= 10 && curr_sig <= 20)
  189. ret_sig = 42 + (((curr_sig - 10) * 2) / 3);
  190. else if (curr_sig >= 5 && curr_sig <= 9)
  191. ret_sig = 22 + (((curr_sig - 5) * 3) / 2);
  192. else if (curr_sig >= 1 && curr_sig <= 4)
  193. ret_sig = 6 + (((curr_sig - 1) * 3) / 2);
  194. else
  195. ret_sig = curr_sig;
  196. }
  197. #endif
  198. return ret_sig;
  199. }
  200. s32
  201. odm_signal_scale_mapping(
  202. struct PHY_DM_STRUCT *p_dm_odm,
  203. s32 curr_sig
  204. )
  205. {
  206. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  207. if ((p_dm_odm->support_platform == ODM_WIN) &&
  208. (p_dm_odm->support_interface != ODM_ITRF_PCIE) && /* USB & SDIO */
  209. (p_dm_odm->patch_id == 10)) /* p_mgnt_info->customer_id == RT_CID_819x_Netcore */
  210. return odm_signal_scale_mapping_92c_series_patch_rt_cid_819x_netcore(p_dm_odm, curr_sig);
  211. else if ((p_dm_odm->support_platform == ODM_WIN) &&
  212. (p_dm_odm->support_interface == ODM_ITRF_PCIE) &&
  213. (p_dm_odm->patch_id == 19)) /* p_mgnt_info->customer_id == RT_CID_819X_LENOVO) */
  214. return odm_signal_scale_mapping_92c_series_patch_rt_cid_819x_lenovo(p_dm_odm, curr_sig);
  215. else
  216. #endif
  217. {
  218. #ifdef CONFIG_SIGNAL_SCALE_MAPPING
  219. return odm_signal_scale_mapping_92c_series(p_dm_odm, curr_sig);
  220. #else
  221. return curr_sig;
  222. #endif
  223. }
  224. }
  225. static u8 odm_sq_process_patch_rt_cid_819x_lenovo(
  226. struct PHY_DM_STRUCT *p_dm_odm,
  227. u8 is_cck_rate,
  228. u8 PWDB_ALL,
  229. u8 path,
  230. u8 RSSI
  231. )
  232. {
  233. u8 SQ = 0;
  234. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  235. if (is_cck_rate) {
  236. if (IS_HARDWARE_TYPE_8192E(p_dm_odm->adapter)) {
  237. /* */
  238. /* <Roger_Notes> Expected signal strength and bars indication at Lenovo lab. 2013.04.11 */
  239. /* 802.11n, 802.11b, 802.11g only at channel 6 */
  240. /* */
  241. /* Attenuation (dB) OS Signal Bars RSSI by Xirrus (dBm) */
  242. /* 50 5 -49 */
  243. /* 55 5 -49 */
  244. /* 60 5 -50 */
  245. /* 65 5 -51 */
  246. /* 70 5 -52 */
  247. /* 75 5 -54 */
  248. /* 80 5 -55 */
  249. /* 85 4 -60 */
  250. /* 90 3 -63 */
  251. /* 95 3 -65 */
  252. /* 100 2 -67 */
  253. /* 102 2 -67 */
  254. /* 104 1 -70 */
  255. /* */
  256. if (PWDB_ALL >= 50)
  257. SQ = 100;
  258. else if (PWDB_ALL >= 35 && PWDB_ALL < 50)
  259. SQ = 80;
  260. else if (PWDB_ALL >= 31 && PWDB_ALL < 35)
  261. SQ = 60;
  262. else if (PWDB_ALL >= 22 && PWDB_ALL < 31)
  263. SQ = 40;
  264. else if (PWDB_ALL >= 18 && PWDB_ALL < 22)
  265. SQ = 20;
  266. else
  267. SQ = 10;
  268. } else {
  269. if (PWDB_ALL >= 50)
  270. SQ = 100;
  271. else if (PWDB_ALL >= 35 && PWDB_ALL < 50)
  272. SQ = 80;
  273. else if (PWDB_ALL >= 22 && PWDB_ALL < 35)
  274. SQ = 60;
  275. else if (PWDB_ALL >= 18 && PWDB_ALL < 22)
  276. SQ = 40;
  277. else
  278. SQ = 10;
  279. }
  280. } else {
  281. /* OFDM rate */
  282. if (IS_HARDWARE_TYPE_8192E(p_dm_odm->adapter)) {
  283. if (RSSI >= 45)
  284. SQ = 100;
  285. else if (RSSI >= 22 && RSSI < 45)
  286. SQ = 80;
  287. else if (RSSI >= 18 && RSSI < 22)
  288. SQ = 40;
  289. else
  290. SQ = 20;
  291. } else {
  292. if (RSSI >= 45)
  293. SQ = 100;
  294. else if (RSSI >= 22 && RSSI < 45)
  295. SQ = 80;
  296. else if (RSSI >= 18 && RSSI < 22)
  297. SQ = 40;
  298. else
  299. SQ = 20;
  300. }
  301. }
  302. RT_TRACE(COMP_DBG, DBG_TRACE, ("is_cck_rate(%#d), PWDB_ALL(%#d), RSSI(%#d), SQ(%#d)\n", is_cck_rate, PWDB_ALL, RSSI, SQ));
  303. #endif
  304. return SQ;
  305. }
  306. static u8 odm_sq_process_patch_rt_cid_819x_acer(
  307. struct PHY_DM_STRUCT *p_dm_odm,
  308. u8 is_cck_rate,
  309. u8 PWDB_ALL,
  310. u8 path,
  311. u8 RSSI
  312. )
  313. {
  314. u8 SQ = 0;
  315. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  316. if (is_cck_rate) {
  317. RT_TRACE(COMP_DBG, DBG_WARNING, ("odm_SQ_process_patch_RT_Acer\n"));
  318. #if OS_WIN_FROM_WIN8(OS_VERSION)
  319. if (PWDB_ALL >= 50)
  320. SQ = 100;
  321. else if (PWDB_ALL >= 35 && PWDB_ALL < 50)
  322. SQ = 80;
  323. else if (PWDB_ALL >= 30 && PWDB_ALL < 35)
  324. SQ = 60;
  325. else if (PWDB_ALL >= 25 && PWDB_ALL < 30)
  326. SQ = 40;
  327. else if (PWDB_ALL >= 20 && PWDB_ALL < 25)
  328. SQ = 20;
  329. else
  330. SQ = 10;
  331. #else
  332. if (PWDB_ALL >= 50)
  333. SQ = 100;
  334. else if (PWDB_ALL >= 35 && PWDB_ALL < 50)
  335. SQ = 80;
  336. else if (PWDB_ALL >= 30 && PWDB_ALL < 35)
  337. SQ = 60;
  338. else if (PWDB_ALL >= 25 && PWDB_ALL < 30)
  339. SQ = 40;
  340. else if (PWDB_ALL >= 20 && PWDB_ALL < 25)
  341. SQ = 20;
  342. else
  343. SQ = 10;
  344. if (PWDB_ALL == 0) /* Abnormal case, do not indicate the value above 20 on Win7 */
  345. SQ = 20;
  346. #endif
  347. } else {
  348. /* OFDM rate */
  349. if (IS_HARDWARE_TYPE_8192E(p_dm_odm->adapter)) {
  350. if (RSSI >= 45)
  351. SQ = 100;
  352. else if (RSSI >= 22 && RSSI < 45)
  353. SQ = 80;
  354. else if (RSSI >= 18 && RSSI < 22)
  355. SQ = 40;
  356. else
  357. SQ = 20;
  358. } else {
  359. if (RSSI >= 35)
  360. SQ = 100;
  361. else if (RSSI >= 30 && RSSI < 35)
  362. SQ = 80;
  363. else if (RSSI >= 25 && RSSI < 30)
  364. SQ = 40;
  365. else
  366. SQ = 20;
  367. }
  368. }
  369. RT_TRACE(COMP_DBG, DBG_LOUD, ("is_cck_rate(%#d), PWDB_ALL(%#d), RSSI(%#d), SQ(%#d)\n", is_cck_rate, PWDB_ALL, RSSI, SQ));
  370. #endif
  371. return SQ;
  372. }
  373. static u8
  374. odm_evm_db_to_percentage(
  375. s8 value
  376. )
  377. {
  378. /* */
  379. /* -33dB~0dB to 0%~99% */
  380. /* */
  381. s8 ret_val;
  382. ret_val = value;
  383. ret_val /= 2;
  384. /*dbg_print("value=%d\n", value);*/
  385. /*ODM_RT_DISP(FRX, RX_PHY_SQ, ("EVMdbToPercentage92C value=%d / %x\n", ret_val, ret_val));*/
  386. #ifdef ODM_EVM_ENHANCE_ANTDIV
  387. if (ret_val >= 0)
  388. ret_val = 0;
  389. if (ret_val <= -40)
  390. ret_val = -40;
  391. ret_val = 0 - ret_val;
  392. ret_val *= 3;
  393. #else
  394. if (ret_val >= 0)
  395. ret_val = 0;
  396. if (ret_val <= -33)
  397. ret_val = -33;
  398. ret_val = 0 - ret_val;
  399. ret_val *= 3;
  400. if (ret_val == 99)
  401. ret_val = 100;
  402. #endif
  403. return (u8)ret_val;
  404. }
  405. static u8
  406. odm_evm_dbm_jaguar_series(
  407. s8 value
  408. )
  409. {
  410. s8 ret_val = value;
  411. /* -33dB~0dB to 33dB ~ 0dB */
  412. if (ret_val == -128)
  413. ret_val = 127;
  414. else if (ret_val < 0)
  415. ret_val = 0 - ret_val;
  416. ret_val = ret_val >> 1;
  417. return (u8)ret_val;
  418. }
  419. static s16
  420. odm_cfo(
  421. s8 value
  422. )
  423. {
  424. s16 ret_val;
  425. if (value < 0) {
  426. ret_val = 0 - value;
  427. ret_val = (ret_val << 1) + (ret_val >> 1) ; /* *2.5~=312.5/2^7 */
  428. ret_val = ret_val | BIT(12); /* set bit12 as 1 for negative cfo */
  429. } else {
  430. ret_val = value;
  431. ret_val = (ret_val << 1) + (ret_val >> 1) ; /* *2.5~=312.5/2^7 */
  432. }
  433. return ret_val;
  434. }
  435. u8
  436. phydm_rate_to_num_ss(
  437. struct PHY_DM_STRUCT *p_dm_odm,
  438. u8 data_rate
  439. )
  440. {
  441. u8 num_ss = 1;
  442. if (data_rate <= ODM_RATE54M)
  443. num_ss = 1;
  444. else if (data_rate <= ODM_RATEMCS31)
  445. num_ss = ((data_rate - ODM_RATEMCS0) >> 3) + 1;
  446. else if (data_rate <= ODM_RATEVHTSS1MCS9)
  447. num_ss = 1;
  448. else if (data_rate <= ODM_RATEVHTSS2MCS9)
  449. num_ss = 2;
  450. else if (data_rate <= ODM_RATEVHTSS3MCS9)
  451. num_ss = 3;
  452. else if (data_rate <= ODM_RATEVHTSS4MCS9)
  453. num_ss = 4;
  454. return num_ss;
  455. }
  456. #if (ODM_IC_11N_SERIES_SUPPORT == 1)
  457. #if (RTL8703B_SUPPORT == 1)
  458. s8
  459. odm_CCKRSSI_8703B(
  460. u16 LNA_idx,
  461. u8 VGA_idx
  462. )
  463. {
  464. s8 rx_pwr_all = 0x00;
  465. switch (LNA_idx) {
  466. case 0xf:
  467. rx_pwr_all = -48 - (2 * VGA_idx);
  468. break;
  469. case 0xb:
  470. rx_pwr_all = -42 - (2 * VGA_idx); /*TBD*/
  471. break;
  472. case 0xa:
  473. rx_pwr_all = -36 - (2 * VGA_idx);
  474. break;
  475. case 8:
  476. rx_pwr_all = -32 - (2 * VGA_idx);
  477. break;
  478. case 7:
  479. rx_pwr_all = -19 - (2 * VGA_idx);
  480. break;
  481. case 4:
  482. rx_pwr_all = -6 - (2 * VGA_idx);
  483. break;
  484. case 0:
  485. rx_pwr_all = -2 - (2 * VGA_idx);
  486. break;
  487. default:
  488. /*rx_pwr_all = -53+(2*(31-VGA_idx));*/
  489. /*dbg_print("wrong LNA index\n");*/
  490. break;
  491. }
  492. return rx_pwr_all;
  493. }
  494. #endif
  495. #if (RTL8195A_SUPPORT == 1)
  496. s8
  497. odm_CCKRSSI_8195A(
  498. struct PHY_DM_STRUCT *p_dm_odm,
  499. u16 LNA_idx,
  500. u8 VGA_idx
  501. )
  502. {
  503. s8 rx_pwr_all = 0;
  504. s8 lna_gain = 0;
  505. s8 lna_gain_table_0[8] = {0, -8, -15, -22, -29, -36, -45, -54};
  506. s8 lna_gain_table_1[8] = {0, -8, -15, -22, -29, -36, -45, -54};/*use 8195A to calibrate this table. 2016.06.24, Dino*/
  507. if (p_dm_odm->cck_agc_report_type == 0)
  508. lna_gain = lna_gain_table_0[LNA_idx];
  509. else
  510. lna_gain = lna_gain_table_1[LNA_idx];
  511. rx_pwr_all = lna_gain - (2 * VGA_idx);
  512. return rx_pwr_all;
  513. }
  514. #endif
  515. #if (RTL8192E_SUPPORT == 1)
  516. s8
  517. odm_CCKRSSI_8192E(
  518. struct PHY_DM_STRUCT *p_dm_odm,
  519. u16 LNA_idx,
  520. u8 VGA_idx
  521. )
  522. {
  523. s8 rx_pwr_all = 0;
  524. s8 lna_gain = 0;
  525. s8 lna_gain_table_0[8] = {15, 9, -10, -21, -23, -27, -43, -44};
  526. s8 lna_gain_table_1[8] = {24, 18, 13, -4, -11, -18, -31, -36};/*use 8192EU to calibrate this table. 2015.12.15, Dino*/
  527. if (p_dm_odm->cck_agc_report_type == 0)
  528. lna_gain = lna_gain_table_0[LNA_idx];
  529. else
  530. lna_gain = lna_gain_table_1[LNA_idx];
  531. rx_pwr_all = lna_gain - (2 * VGA_idx);
  532. return rx_pwr_all;
  533. }
  534. #endif
  535. #if (RTL8188E_SUPPORT == 1)
  536. s8
  537. odm_CCKRSSI_8188E(
  538. struct PHY_DM_STRUCT *p_dm_odm,
  539. u16 LNA_idx,
  540. u8 VGA_idx
  541. )
  542. {
  543. s8 rx_pwr_all = 0;
  544. s8 lna_gain = 0;
  545. s8 lna_gain_table_0[8] = {17, -1, -13, -29, -32, -35, -38, -41};/*only use lna0/1/2/3/7*/
  546. s8 lna_gain_table_1[8] = {29, 20, 12, 3, -6, -15, -24, -33}; /*only use lna3 /7*/
  547. if (p_dm_odm->cut_version >= ODM_CUT_I) /*SMIC*/
  548. lna_gain = lna_gain_table_0[LNA_idx];
  549. else /*TSMC*/
  550. lna_gain = lna_gain_table_1[LNA_idx];
  551. rx_pwr_all = lna_gain - (2 * VGA_idx);
  552. return rx_pwr_all;
  553. }
  554. #endif
  555. void
  556. odm_rx_phy_status92c_series_parsing(
  557. struct PHY_DM_STRUCT *p_dm_odm,
  558. struct _odm_phy_status_info_ *p_phy_info,
  559. u8 *p_phy_status,
  560. struct _odm_per_pkt_info_ *p_pktinfo
  561. )
  562. {
  563. struct _sw_antenna_switch_ *p_dm_swat_table = &p_dm_odm->dm_swat_table;
  564. u8 i, max_spatial_stream;
  565. s8 rx_pwr[4], rx_pwr_all = 0;
  566. u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT;
  567. u8 RSSI, total_rssi = 0;
  568. boolean is_cck_rate = false;
  569. u8 rf_rx_num = 0;
  570. u8 cck_highpwr = 0;
  571. u8 LNA_idx = 0;
  572. u8 VGA_idx = 0;
  573. u8 cck_agc_rpt;
  574. u8 num_ss;
  575. struct _phy_status_rpt_8192cd *p_phy_sta_rpt = (struct _phy_status_rpt_8192cd *)p_phy_status;
  576. is_cck_rate = (p_pktinfo->data_rate <= ODM_RATE11M) ? true : false;
  577. if (p_pktinfo->is_to_self)
  578. p_dm_odm->curr_station_id = p_pktinfo->station_id;
  579. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1;
  580. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1;
  581. if (is_cck_rate) {
  582. p_dm_odm->phy_dbg_info.num_qry_phy_status_cck++;
  583. cck_agc_rpt = p_phy_sta_rpt->cck_agc_rpt_ofdm_cfosho_a ;
  584. if (p_dm_odm->support_ic_type & (ODM_RTL8703B)) {
  585. #if (RTL8703B_SUPPORT == 1)
  586. if (p_dm_odm->cck_agc_report_type == 1) { /*4 bit LNA*/
  587. u8 cck_agc_rpt_b = (p_phy_sta_rpt->cck_rpt_b_ofdm_cfosho_b & BIT(7)) ? 1 : 0;
  588. LNA_idx = (cck_agc_rpt_b << 3) | ((cck_agc_rpt & 0xE0) >> 5);
  589. VGA_idx = (cck_agc_rpt & 0x1F);
  590. rx_pwr_all = odm_CCKRSSI_8703B(LNA_idx, VGA_idx);
  591. }
  592. #endif
  593. } else { /*3 bit LNA*/
  594. LNA_idx = ((cck_agc_rpt & 0xE0) >> 5);
  595. VGA_idx = (cck_agc_rpt & 0x1F);
  596. if (p_dm_odm->support_ic_type & (ODM_RTL8188E)) {
  597. #if (RTL8188E_SUPPORT == 1)
  598. rx_pwr_all = odm_CCKRSSI_8188E(p_dm_odm, LNA_idx, VGA_idx);
  599. /**/
  600. #endif
  601. }
  602. #if (RTL8192E_SUPPORT == 1)
  603. else if (p_dm_odm->support_ic_type & (ODM_RTL8192E)) {
  604. rx_pwr_all = odm_CCKRSSI_8192E(p_dm_odm, LNA_idx, VGA_idx);
  605. /**/
  606. }
  607. #endif
  608. #if (RTL8723B_SUPPORT == 1)
  609. else if (p_dm_odm->support_ic_type & (ODM_RTL8723B)) {
  610. rx_pwr_all = odm_CCKRSSI_8723B(LNA_idx, VGA_idx);
  611. /**/
  612. }
  613. #endif
  614. #if (RTL8188F_SUPPORT == 1)
  615. else if (p_dm_odm->support_ic_type & (ODM_RTL8188F)) {
  616. rx_pwr_all = odm_CCKRSSI_8188F(LNA_idx, VGA_idx);
  617. /**/
  618. }
  619. #endif
  620. #if (RTL8195A_SUPPORT == 1)
  621. else if (p_dm_odm->support_ic_type & (ODM_RTL8195A)) {
  622. rx_pwr_all = odm_CCKRSSI_8195A(LNA_idx, VGA_idx);
  623. /**/
  624. }
  625. #endif
  626. }
  627. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("ext_lna_gain (( %d )), LNA_idx: (( 0x%x )), VGA_idx: (( 0x%x )), rx_pwr_all: (( %d ))\n",
  628. p_dm_odm->ext_lna_gain, LNA_idx, VGA_idx, rx_pwr_all));
  629. if (p_dm_odm->board_type & ODM_BOARD_EXT_LNA)
  630. rx_pwr_all -= p_dm_odm->ext_lna_gain;
  631. PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  632. if (p_pktinfo->is_to_self) {
  633. p_dm_odm->cck_lna_idx = LNA_idx;
  634. p_dm_odm->cck_vga_idx = VGA_idx;
  635. }
  636. p_phy_info->rx_pwdb_all = PWDB_ALL;
  637. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  638. p_phy_info->bt_rx_rssi_percentage = PWDB_ALL;
  639. p_phy_info->recv_signal_power = rx_pwr_all;
  640. #endif
  641. /* */
  642. /* (3) Get Signal Quality (EVM) */
  643. /* */
  644. /* if(p_pktinfo->is_packet_match_bssid) */
  645. {
  646. u8 SQ, SQ_rpt;
  647. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  648. if ((p_dm_odm->support_platform == ODM_WIN) &&
  649. (p_dm_odm->patch_id == RT_CID_819X_LENOVO))
  650. SQ = odm_sq_process_patch_rt_cid_819x_lenovo(p_dm_odm, is_cck_rate, PWDB_ALL, 0, 0);
  651. else if ((p_dm_odm->support_platform == ODM_WIN) &&
  652. (p_dm_odm->patch_id == RT_CID_819X_ACER))
  653. SQ = odm_sq_process_patch_rt_cid_819x_acer(p_dm_odm, is_cck_rate, PWDB_ALL, 0, 0);
  654. else
  655. #endif
  656. if (p_phy_info->rx_pwdb_all > 40 && !p_dm_odm->is_in_hct_test)
  657. SQ = 100;
  658. else {
  659. SQ_rpt = p_phy_sta_rpt->cck_sig_qual_ofdm_pwdb_all;
  660. if (SQ_rpt > 64)
  661. SQ = 0;
  662. else if (SQ_rpt < 20)
  663. SQ = 100;
  664. else
  665. SQ = ((64 - SQ_rpt) * 100) / 44;
  666. }
  667. /* dbg_print("cck SQ = %d\n", SQ); */
  668. p_phy_info->signal_quality = SQ;
  669. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = SQ;
  670. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1;
  671. }
  672. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) {
  673. if (i == 0)
  674. p_phy_info->rx_mimo_signal_strength[0] = PWDB_ALL;
  675. else
  676. p_phy_info->rx_mimo_signal_strength[1] = 0;
  677. }
  678. } else { /* 2 is OFDM rate */
  679. p_dm_odm->phy_dbg_info.num_qry_phy_status_ofdm++;
  680. /* */
  681. /* (1)Get RSSI for HT rate */
  682. /* */
  683. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) {
  684. /* 2008/01/30 MH we will judge RF RX path now. */
  685. if (p_dm_odm->rf_path_rx_enable & BIT(i))
  686. rf_rx_num++;
  687. /* else */
  688. /* continue; */
  689. rx_pwr[i] = ((p_phy_sta_rpt->path_agc[i].gain & 0x3F) * 2) - 110;
  690. if (p_pktinfo->is_to_self) {
  691. p_dm_odm->ofdm_agc_idx[i] = (p_phy_sta_rpt->path_agc[i].gain & 0x3F);
  692. /**/
  693. }
  694. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  695. p_phy_info->rx_pwr[i] = rx_pwr[i];
  696. #endif
  697. /* Translate DBM to percentage. */
  698. RSSI = odm_query_rx_pwr_percentage(rx_pwr[i]);
  699. total_rssi += RSSI;
  700. /* RT_DISP(FRX, RX_PHY_SS, ("RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI)); */
  701. p_phy_info->rx_mimo_signal_strength[i] = (u8) RSSI;
  702. #if (DM_ODM_SUPPORT_TYPE & (/*ODM_WIN|*/ODM_CE|ODM_AP))
  703. /* Get Rx snr value in DB */
  704. p_phy_info->rx_snr[i] = p_dm_odm->phy_dbg_info.rx_snr_db[i] = (s32)(p_phy_sta_rpt->path_rxsnr[i] / 2);
  705. #endif
  706. /* Record Signal Strength for next packet */
  707. /* if(p_pktinfo->is_packet_match_bssid) */
  708. {
  709. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  710. if ((p_dm_odm->support_platform == ODM_WIN) &&
  711. (p_dm_odm->patch_id == RT_CID_819X_LENOVO)) {
  712. if (i == ODM_RF_PATH_A)
  713. p_phy_info->signal_quality = odm_sq_process_patch_rt_cid_819x_lenovo(p_dm_odm, is_cck_rate, PWDB_ALL, i, RSSI);
  714. } else if ((p_dm_odm->support_platform == ODM_WIN) &&
  715. (p_dm_odm->patch_id == RT_CID_819X_ACER))
  716. p_phy_info->signal_quality = odm_sq_process_patch_rt_cid_819x_acer(p_dm_odm, is_cck_rate, PWDB_ALL, 0, RSSI);
  717. #endif
  718. }
  719. }
  720. /* */
  721. /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */
  722. /* */
  723. rx_pwr_all = (((p_phy_sta_rpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110;
  724. PWDB_ALL_BT = PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  725. p_phy_info->rx_pwdb_all = PWDB_ALL;
  726. /* ODM_RT_TRACE(p_dm_odm,ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("ODM OFDM RSSI=%d\n",p_phy_info->rx_pwdb_all)); */
  727. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  728. p_phy_info->bt_rx_rssi_percentage = PWDB_ALL_BT;
  729. p_phy_info->rx_power = rx_pwr_all;
  730. p_phy_info->recv_signal_power = rx_pwr_all;
  731. #endif
  732. if ((p_dm_odm->support_platform == ODM_WIN) && (p_dm_odm->patch_id == 19)) {
  733. /* do nothing */
  734. } else if ((p_dm_odm->support_platform == ODM_WIN) && (p_dm_odm->patch_id == 25)) {
  735. /* do nothing */
  736. } else { /* p_mgnt_info->customer_id != RT_CID_819X_LENOVO */
  737. /* */
  738. /* (3)EVM of HT rate */
  739. /* */
  740. if (p_pktinfo->data_rate >= ODM_RATEMCS8 && p_pktinfo->data_rate <= ODM_RATEMCS15)
  741. max_spatial_stream = 2; /* both spatial stream make sense */
  742. else
  743. max_spatial_stream = 1; /* only spatial stream 1 makes sense */
  744. for (i = 0; i < max_spatial_stream; i++) {
  745. /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */
  746. /* fill most significant bit to "zero" when doing shifting operation which may change a negative */
  747. /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */
  748. EVM = odm_evm_db_to_percentage((p_phy_sta_rpt->stream_rxevm[i])); /* dbm */
  749. /* GET_RX_STATUS_DESC_RX_MCS(p_desc), p_drv_info->rxevm[i], "%", EVM)); */
  750. /* if(p_pktinfo->is_packet_match_bssid) */
  751. {
  752. if (i == ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */
  753. p_phy_info->signal_quality = (u8)(EVM & 0xff);
  754. p_phy_info->rx_mimo_signal_quality[i] = (u8)(EVM & 0xff);
  755. }
  756. }
  757. }
  758. num_ss = phydm_rate_to_num_ss(p_dm_odm, p_pktinfo->data_rate);
  759. odm_parsing_cfo(p_dm_odm, p_pktinfo, p_phy_sta_rpt->path_cfotail, num_ss);
  760. }
  761. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  762. /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */
  763. /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */
  764. if (is_cck_rate) {
  765. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  766. /* 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/ */
  767. p_phy_info->signal_strength = SignalScaleProc(p_dm_odm->adapter, PWDB_ALL, true, true);
  768. #else
  769. p_phy_info->signal_strength = (u8)(odm_signal_scale_mapping(p_dm_odm, PWDB_ALL));/*PWDB_ALL;*/
  770. #endif /*#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)*/
  771. } else {
  772. if (rf_rx_num != 0) {
  773. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  774. /* 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/ */
  775. p_phy_info->signal_strength = SignalScaleProc(p_dm_odm->adapter, (total_rssi /= rf_rx_num), true, false);
  776. #else
  777. p_phy_info->signal_strength = (u8)(odm_signal_scale_mapping(p_dm_odm, total_rssi /= rf_rx_num));
  778. #endif
  779. }
  780. }
  781. #endif /*#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE))*/
  782. /* dbg_print("is_cck_rate = %d, p_phy_info->rx_pwdb_all = %d, p_phy_sta_rpt->cck_agc_rpt_ofdm_cfosho_a = 0x%x\n", */
  783. /* is_cck_rate, p_phy_info->rx_pwdb_all, p_phy_sta_rpt->cck_agc_rpt_ofdm_cfosho_a); */
  784. /* For 92C/92D HW (Hybrid) Antenna Diversity */
  785. #if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY))
  786. /* For 88E HW Antenna Diversity */
  787. p_dm_odm->dm_fat_table.antsel_rx_keep_0 = p_phy_sta_rpt->ant_sel;
  788. p_dm_odm->dm_fat_table.antsel_rx_keep_1 = p_phy_sta_rpt->ant_sel_b;
  789. p_dm_odm->dm_fat_table.antsel_rx_keep_2 = p_phy_sta_rpt->antsel_rx_keep_2;
  790. #endif
  791. }
  792. #endif
  793. #if ODM_IC_11AC_SERIES_SUPPORT
  794. void
  795. odm_rx_phy_bw_jaguar_series_parsing(
  796. struct _odm_phy_status_info_ *p_phy_info,
  797. struct _odm_per_pkt_info_ *p_pktinfo,
  798. struct _phy_status_rpt_8812 *p_phy_sta_rpt
  799. )
  800. {
  801. if (p_pktinfo->data_rate <= ODM_RATE54M) {
  802. switch (p_phy_sta_rpt->r_RFMOD) {
  803. case 1:
  804. if (p_phy_sta_rpt->sub_chnl == 0)
  805. p_phy_info->band_width = 1;
  806. else
  807. p_phy_info->band_width = 0;
  808. break;
  809. case 2:
  810. if (p_phy_sta_rpt->sub_chnl == 0)
  811. p_phy_info->band_width = 2;
  812. else if (p_phy_sta_rpt->sub_chnl == 9 || p_phy_sta_rpt->sub_chnl == 10)
  813. p_phy_info->band_width = 1;
  814. else
  815. p_phy_info->band_width = 0;
  816. break;
  817. default:
  818. case 0:
  819. p_phy_info->band_width = 0;
  820. break;
  821. }
  822. }
  823. }
  824. void
  825. odm_rx_phy_status_jaguar_series_parsing(
  826. struct PHY_DM_STRUCT *p_dm_odm,
  827. struct _odm_phy_status_info_ *p_phy_info,
  828. u8 *p_phy_status,
  829. struct _odm_per_pkt_info_ *p_pktinfo
  830. )
  831. {
  832. u8 i, max_spatial_stream;
  833. s8 rx_pwr[4], rx_pwr_all = 0;
  834. u8 EVM, evm_dbm, PWDB_ALL = 0, PWDB_ALL_BT;
  835. u8 RSSI, avg_rssi = 0, best_rssi = 0, second_rssi = 0;
  836. u8 is_cck_rate = 0;
  837. u8 rf_rx_num = 0;
  838. u8 cck_highpwr = 0;
  839. u8 LNA_idx, VGA_idx;
  840. struct _phy_status_rpt_8812 *p_phy_sta_rpt = (struct _phy_status_rpt_8812 *)p_phy_status;
  841. struct _FAST_ANTENNA_TRAINNING_ *p_dm_fat_table = &p_dm_odm->dm_fat_table;
  842. u8 num_ss;
  843. odm_rx_phy_bw_jaguar_series_parsing(p_phy_info, p_pktinfo, p_phy_sta_rpt);
  844. if (p_pktinfo->data_rate <= ODM_RATE11M)
  845. is_cck_rate = true;
  846. else
  847. is_cck_rate = false;
  848. if (p_pktinfo->is_to_self)
  849. p_dm_odm->curr_station_id = p_pktinfo->station_id;
  850. else
  851. p_dm_odm->curr_station_id = 0xff;
  852. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1;
  853. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1;
  854. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_C] = -1;
  855. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_D] = -1;
  856. if (is_cck_rate) {
  857. u8 cck_agc_rpt;
  858. p_dm_odm->phy_dbg_info.num_qry_phy_status_cck++;
  859. /*(1)Hardware does not provide RSSI for CCK*/
  860. /*(2)PWDB, Average PWDB calculated by hardware (for rate adaptive)*/
  861. /*if(p_hal_data->e_rf_power_state == e_rf_on)*/
  862. cck_highpwr = p_dm_odm->is_cck_high_power;
  863. /*else*/
  864. /*cck_highpwr = false;*/
  865. cck_agc_rpt = p_phy_sta_rpt->cfosho[0] ;
  866. LNA_idx = ((cck_agc_rpt & 0xE0) >> 5);
  867. VGA_idx = (cck_agc_rpt & 0x1F);
  868. if (p_dm_odm->support_ic_type == ODM_RTL8812) {
  869. switch (LNA_idx) {
  870. case 7:
  871. if (VGA_idx <= 27)
  872. rx_pwr_all = -100 + 2 * (27 - VGA_idx); /*VGA_idx = 27~2*/
  873. else
  874. rx_pwr_all = -100;
  875. break;
  876. case 6:
  877. rx_pwr_all = -48 + 2 * (2 - VGA_idx); /*VGA_idx = 2~0*/
  878. break;
  879. case 5:
  880. rx_pwr_all = -42 + 2 * (7 - VGA_idx); /*VGA_idx = 7~5*/
  881. break;
  882. case 4:
  883. rx_pwr_all = -36 + 2 * (7 - VGA_idx); /*VGA_idx = 7~4*/
  884. break;
  885. case 3:
  886. /*rx_pwr_all = -28 + 2*(7-VGA_idx); VGA_idx = 7~0*/
  887. rx_pwr_all = -24 + 2 * (7 - VGA_idx); /*VGA_idx = 7~0*/
  888. break;
  889. case 2:
  890. if (cck_highpwr)
  891. rx_pwr_all = -12 + 2 * (5 - VGA_idx); /*VGA_idx = 5~0*/
  892. else
  893. rx_pwr_all = -6 + 2 * (5 - VGA_idx);
  894. break;
  895. case 1:
  896. rx_pwr_all = 8 - 2 * VGA_idx;
  897. break;
  898. case 0:
  899. rx_pwr_all = 14 - 2 * VGA_idx;
  900. break;
  901. default:
  902. /*dbg_print("CCK Exception default\n");*/
  903. break;
  904. }
  905. rx_pwr_all += 6;
  906. PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  907. if (cck_highpwr == false) {
  908. if (PWDB_ALL >= 80)
  909. PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80;
  910. else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20))
  911. PWDB_ALL += 3;
  912. if (PWDB_ALL > 100)
  913. PWDB_ALL = 100;
  914. }
  915. } else if (p_dm_odm->support_ic_type & (ODM_RTL8821 | ODM_RTL8881A)) {
  916. s8 pout = -6;
  917. switch (LNA_idx) {
  918. case 5:
  919. rx_pwr_all = pout - 32 - (2 * VGA_idx);
  920. break;
  921. case 4:
  922. rx_pwr_all = pout - 24 - (2 * VGA_idx);
  923. break;
  924. case 2:
  925. rx_pwr_all = pout - 11 - (2 * VGA_idx);
  926. break;
  927. case 1:
  928. rx_pwr_all = pout + 5 - (2 * VGA_idx);
  929. break;
  930. case 0:
  931. rx_pwr_all = pout + 21 - (2 * VGA_idx);
  932. break;
  933. }
  934. PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  935. } else if (p_dm_odm->support_ic_type == ODM_RTL8814A || p_dm_odm->support_ic_type == ODM_RTL8822B) {
  936. s8 pout = -6;
  937. switch (LNA_idx) {
  938. /*CCK only use LNA: 2, 3, 5, 7*/
  939. case 7:
  940. rx_pwr_all = pout - 32 - (2 * VGA_idx);
  941. break;
  942. case 5:
  943. rx_pwr_all = pout - 22 - (2 * VGA_idx);
  944. break;
  945. case 3:
  946. rx_pwr_all = pout - 2 - (2 * VGA_idx);
  947. break;
  948. case 2:
  949. rx_pwr_all = pout + 5 - (2 * VGA_idx);
  950. break;
  951. /*case 6:*/
  952. /*rx_pwr_all = pout -26 - (2*VGA_idx);*/
  953. /*break;*/
  954. /*case 4:*/
  955. /*rx_pwr_all = pout - 8 - (2*VGA_idx);*/
  956. /*break;*/
  957. /*case 1:*/
  958. /*rx_pwr_all = pout + 21 - (2*VGA_idx);*/
  959. /*break;*/
  960. /*case 0:*/
  961. /*rx_pwr_all = pout + 10 - (2*VGA_idx);*/
  962. /* break; */
  963. default:
  964. /* dbg_print("CCK Exception default\n"); */
  965. break;
  966. }
  967. PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  968. }
  969. p_dm_odm->cck_lna_idx = LNA_idx;
  970. p_dm_odm->cck_vga_idx = VGA_idx;
  971. p_phy_info->rx_pwdb_all = PWDB_ALL;
  972. /* if(p_pktinfo->station_id == 0) */
  973. /* { */
  974. /* dbg_print("CCK: LNA_idx = %d, VGA_idx = %d, p_phy_info->rx_pwdb_all = %d\n", */
  975. /* LNA_idx, VGA_idx, p_phy_info->rx_pwdb_all); */
  976. /* } */
  977. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  978. p_phy_info->bt_rx_rssi_percentage = PWDB_ALL;
  979. p_phy_info->recv_signal_power = rx_pwr_all;
  980. #endif
  981. /*(3) Get Signal Quality (EVM)*/
  982. /*if (p_pktinfo->is_packet_match_bssid)*/
  983. {
  984. u8 SQ, SQ_rpt;
  985. if ((p_dm_odm->support_platform == ODM_WIN) &&
  986. (p_dm_odm->patch_id == RT_CID_819X_LENOVO))
  987. SQ = odm_sq_process_patch_rt_cid_819x_lenovo(p_dm_odm, is_cck_rate, PWDB_ALL, 0, 0);
  988. else if (p_phy_info->rx_pwdb_all > 40 && !p_dm_odm->is_in_hct_test)
  989. SQ = 100;
  990. else {
  991. SQ_rpt = p_phy_sta_rpt->pwdb_all;
  992. if (SQ_rpt > 64)
  993. SQ = 0;
  994. else if (SQ_rpt < 20)
  995. SQ = 100;
  996. else
  997. SQ = ((64 - SQ_rpt) * 100) / 44;
  998. }
  999. /* dbg_print("cck SQ = %d\n", SQ); */
  1000. p_phy_info->signal_quality = SQ;
  1001. p_phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = SQ;
  1002. }
  1003. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX_JAGUAR; i++) {
  1004. if (i == 0)
  1005. p_phy_info->rx_mimo_signal_strength[0] = PWDB_ALL;
  1006. else
  1007. p_phy_info->rx_mimo_signal_strength[i] = 0;
  1008. }
  1009. } else {
  1010. /*is OFDM rate*/
  1011. p_dm_fat_table->hw_antsw_occur = p_phy_sta_rpt->hw_antsw_occur;
  1012. p_dm_odm->phy_dbg_info.num_qry_phy_status_ofdm++;
  1013. /*(1)Get RSSI for OFDM rate*/
  1014. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX_JAGUAR; i++) {
  1015. /*2008/01/30 MH we will judge RF RX path now.*/
  1016. /* dbg_print("p_dm_odm->rf_path_rx_enable = %x\n", p_dm_odm->rf_path_rx_enable); */
  1017. if (p_dm_odm->rf_path_rx_enable & BIT(i))
  1018. rf_rx_num++;
  1019. /* else */
  1020. /* continue; */
  1021. /*2012.05.25 LukeLee: Testchip AGC report is wrong, it should be restored back to old formula in MP chip*/
  1022. /* if((p_dm_odm->support_ic_type & (ODM_RTL8812|ODM_RTL8821)) && (!p_dm_odm->is_mp_chip)) */
  1023. if (i < ODM_RF_PATH_C)
  1024. rx_pwr[i] = (p_phy_sta_rpt->gain_trsw[i] & 0x7F) - 110;
  1025. else
  1026. rx_pwr[i] = (p_phy_sta_rpt->gain_trsw_cd[i - 2] & 0x7F) - 110;
  1027. /* else */
  1028. /*rx_pwr[i] = ((p_phy_sta_rpt->gain_trsw[i]& 0x3F)*2) - 110; OLD FORMULA*/
  1029. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  1030. p_phy_info->rx_pwr[i] = rx_pwr[i];
  1031. #endif
  1032. /* Translate DBM to percentage. */
  1033. RSSI = odm_query_rx_pwr_percentage(rx_pwr[i]);
  1034. /*total_rssi += RSSI;*/
  1035. /*Get the best two RSSI*/
  1036. if (RSSI > best_rssi && RSSI > second_rssi) {
  1037. second_rssi = best_rssi;
  1038. best_rssi = RSSI;
  1039. } else if (RSSI > second_rssi && RSSI <= best_rssi)
  1040. second_rssi = RSSI;
  1041. /*RT_DISP(FRX, RX_PHY_SS, ("RF-%d RXPWR=%x RSSI=%d\n", i, rx_pwr[i], RSSI));*/
  1042. p_phy_info->rx_mimo_signal_strength[i] = (u8) RSSI;
  1043. /*Get Rx snr value in DB*/
  1044. if (i < ODM_RF_PATH_C)
  1045. p_phy_info->rx_snr[i] = p_dm_odm->phy_dbg_info.rx_snr_db[i] = p_phy_sta_rpt->rxsnr[i] / 2;
  1046. else if (p_dm_odm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B))
  1047. p_phy_info->rx_snr[i] = p_dm_odm->phy_dbg_info.rx_snr_db[i] = p_phy_sta_rpt->csi_current[i - 2] / 2;
  1048. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  1049. /*(2) CFO_short & CFO_tail*/
  1050. if (i < ODM_RF_PATH_C) {
  1051. p_phy_info->cfo_short[i] = odm_cfo((p_phy_sta_rpt->cfosho[i]));
  1052. p_phy_info->cfo_tail[i] = odm_cfo((p_phy_sta_rpt->cfotail[i]));
  1053. }
  1054. #endif
  1055. /* Record Signal Strength for next packet */
  1056. if (p_pktinfo->is_packet_match_bssid) {
  1057. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1058. if ((p_dm_odm->support_platform == ODM_WIN) &&
  1059. (p_dm_odm->patch_id == RT_CID_819X_LENOVO)) {
  1060. if (i == ODM_RF_PATH_A)
  1061. p_phy_info->signal_quality = odm_sq_process_patch_rt_cid_819x_lenovo(p_dm_odm, is_cck_rate, PWDB_ALL, i, RSSI);
  1062. }
  1063. #endif
  1064. }
  1065. }
  1066. /*(3)PWDB, Average PWDB calculated by hardware (for rate adaptive)*/
  1067. /*2012.05.25 LukeLee: Testchip AGC report is wrong, it should be restored back to old formula in MP chip*/
  1068. if ((p_dm_odm->support_ic_type & (ODM_RTL8812 | ODM_RTL8821 | ODM_RTL8881A)) && (!p_dm_odm->is_mp_chip))
  1069. rx_pwr_all = (p_phy_sta_rpt->pwdb_all & 0x7f) - 110;
  1070. else
  1071. rx_pwr_all = (((p_phy_sta_rpt->pwdb_all) >> 1) & 0x7f) - 110; /*OLD FORMULA*/
  1072. PWDB_ALL_BT = PWDB_ALL = odm_query_rx_pwr_percentage(rx_pwr_all);
  1073. p_phy_info->rx_pwdb_all = PWDB_ALL;
  1074. /*ODM_RT_TRACE(p_dm_odm,ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("ODM OFDM RSSI=%d\n",p_phy_info->rx_pwdb_all));*/
  1075. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  1076. p_phy_info->bt_rx_rssi_percentage = PWDB_ALL_BT;
  1077. p_phy_info->rx_power = rx_pwr_all;
  1078. p_phy_info->recv_signal_power = rx_pwr_all;
  1079. #endif
  1080. if ((p_dm_odm->support_platform == ODM_WIN) && (p_dm_odm->patch_id == 19)) {
  1081. /*do nothing*/
  1082. } else {
  1083. /*p_mgnt_info->customer_id != RT_CID_819X_LENOVO*/
  1084. /*(4)EVM of OFDM rate*/
  1085. if ((p_pktinfo->data_rate >= ODM_RATEMCS8) &&
  1086. (p_pktinfo->data_rate <= ODM_RATEMCS15))
  1087. max_spatial_stream = 2;
  1088. else if ((p_pktinfo->data_rate >= ODM_RATEVHTSS2MCS0) &&
  1089. (p_pktinfo->data_rate <= ODM_RATEVHTSS2MCS9))
  1090. max_spatial_stream = 2;
  1091. else if ((p_pktinfo->data_rate >= ODM_RATEMCS16) &&
  1092. (p_pktinfo->data_rate <= ODM_RATEMCS23))
  1093. max_spatial_stream = 3;
  1094. else if ((p_pktinfo->data_rate >= ODM_RATEVHTSS3MCS0) &&
  1095. (p_pktinfo->data_rate <= ODM_RATEVHTSS3MCS9))
  1096. max_spatial_stream = 3;
  1097. else
  1098. max_spatial_stream = 1;
  1099. /*if (p_pktinfo->is_packet_match_bssid) */
  1100. {
  1101. /*dbg_print("p_pktinfo->data_rate = %d\n", p_pktinfo->data_rate);*/
  1102. for (i = 0; i < max_spatial_stream; i++) {
  1103. /*Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment*/
  1104. /*fill most significant bit to "zero" when doing shifting operation which may change a negative*/
  1105. /*value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.*/
  1106. if (p_pktinfo->data_rate >= ODM_RATE6M && p_pktinfo->data_rate <= ODM_RATE54M) {
  1107. if (i == ODM_RF_PATH_A) {
  1108. EVM = odm_evm_db_to_percentage((p_phy_sta_rpt->sigevm)); /*dbm*/
  1109. EVM += 20;
  1110. if (EVM > 100)
  1111. EVM = 100;
  1112. }
  1113. } else {
  1114. if (i < ODM_RF_PATH_C) {
  1115. if (p_phy_sta_rpt->rxevm[i] == -128)
  1116. p_phy_sta_rpt->rxevm[i] = -25;
  1117. EVM = odm_evm_db_to_percentage((p_phy_sta_rpt->rxevm[i])); /*dbm*/
  1118. } else {
  1119. if (p_phy_sta_rpt->rxevm_cd[i - 2] == -128)
  1120. p_phy_sta_rpt->rxevm_cd[i - 2] = -25;
  1121. EVM = odm_evm_db_to_percentage((p_phy_sta_rpt->rxevm_cd[i - 2])); /*dbm*/
  1122. }
  1123. }
  1124. if (i < ODM_RF_PATH_C)
  1125. evm_dbm = odm_evm_dbm_jaguar_series(p_phy_sta_rpt->rxevm[i]);
  1126. else
  1127. evm_dbm = odm_evm_dbm_jaguar_series(p_phy_sta_rpt->rxevm_cd[i - 2]);
  1128. /*RT_DISP(FRX, RX_PHY_SQ, ("RXRATE=%x RXEVM=%x EVM=%s%d\n",*/
  1129. /*p_pktinfo->data_rate, p_phy_sta_rpt->rxevm[i], "%", EVM));*/
  1130. {
  1131. if (i == ODM_RF_PATH_A) {
  1132. /*Fill value in RFD, Get the first spatial stream only*/
  1133. p_phy_info->signal_quality = EVM;
  1134. }
  1135. p_phy_info->rx_mimo_signal_quality[i] = EVM;
  1136. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  1137. p_phy_info->rx_mimo_evm_dbm[i] = evm_dbm;
  1138. #endif
  1139. }
  1140. }
  1141. }
  1142. }
  1143. num_ss = phydm_rate_to_num_ss(p_dm_odm, p_pktinfo->data_rate);
  1144. odm_parsing_cfo(p_dm_odm, p_pktinfo, p_phy_sta_rpt->cfotail, num_ss);
  1145. }
  1146. /* dbg_print("is_cck_rate= %d, p_phy_info->signal_strength=%d % PWDB_AL=%d rf_rx_num=%d\n", is_cck_rate, p_phy_info->signal_strength, PWDB_ALL, rf_rx_num); */
  1147. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  1148. /*UI BSS List signal strength(in percentage), make it good looking, from 0~100.*/
  1149. /*It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().*/
  1150. if (is_cck_rate) {
  1151. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1152. /*2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/*/
  1153. p_phy_info->signal_strength = SignalScaleProc(p_dm_odm->adapter, PWDB_ALL, false, true);
  1154. #else
  1155. p_phy_info->signal_strength = (u8)(odm_signal_scale_mapping(p_dm_odm, PWDB_ALL));/*PWDB_ALL;*/
  1156. #endif
  1157. } else {
  1158. if (rf_rx_num != 0) {
  1159. /* 2015/01 Sean, use the best two RSSI only, suggested by Ynlin and ChenYu.*/
  1160. if (rf_rx_num == 1)
  1161. avg_rssi = best_rssi;
  1162. else
  1163. avg_rssi = (best_rssi + second_rssi) / 2;
  1164. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1165. /* 2012/01/12 MH Use customeris signal strength from HalComRxdDesc.c/*/
  1166. p_phy_info->signal_strength = SignalScaleProc(p_dm_odm->adapter, avg_rssi, false, false);
  1167. #else
  1168. p_phy_info->signal_strength = (u8)(odm_signal_scale_mapping(p_dm_odm, avg_rssi));
  1169. #endif
  1170. }
  1171. }
  1172. #endif
  1173. p_dm_odm->rx_pwdb_ave = p_dm_odm->rx_pwdb_ave + p_phy_info->rx_pwdb_all;
  1174. p_dm_odm->dm_fat_table.antsel_rx_keep_0 = p_phy_sta_rpt->antidx_anta;
  1175. p_dm_odm->dm_fat_table.antsel_rx_keep_1 = p_phy_sta_rpt->antidx_antb;
  1176. p_dm_odm->dm_fat_table.antsel_rx_keep_2 = p_phy_sta_rpt->antidx_antc;
  1177. p_dm_odm->dm_fat_table.antsel_rx_keep_3 = p_phy_sta_rpt->antidx_antd;
  1178. /*ODM_RT_TRACE(p_dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("StaID[%d]: antidx_anta = ((%d)), MatchBSSID = ((%d))\n", p_pktinfo->station_id, p_phy_sta_rpt->antidx_anta, p_pktinfo->is_packet_match_bssid));*/
  1179. /* dbg_print("p_phy_sta_rpt->antidx_anta = %d, p_phy_sta_rpt->antidx_antb = %d\n",*/
  1180. /* p_phy_sta_rpt->antidx_anta, p_phy_sta_rpt->antidx_antb);*/
  1181. /* dbg_print("----------------------------\n");*/
  1182. /* dbg_print("p_pktinfo->station_id=%d, p_pktinfo->data_rate=0x%x\n",p_pktinfo->station_id, p_pktinfo->data_rate);*/
  1183. /* dbg_print("p_phy_sta_rpt->r_RFMOD = %d\n", p_phy_sta_rpt->r_RFMOD);*/
  1184. /* dbg_print("p_phy_sta_rpt->gain_trsw[0]=0x%x, p_phy_sta_rpt->gain_trsw[1]=0x%x\n",*/
  1185. /* p_phy_sta_rpt->gain_trsw[0],p_phy_sta_rpt->gain_trsw[1]);*/
  1186. /* dbg_print("p_phy_sta_rpt->gain_trsw[2]=0x%x, p_phy_sta_rpt->gain_trsw[3]=0x%x\n",*/
  1187. /* p_phy_sta_rpt->gain_trsw_cd[0],p_phy_sta_rpt->gain_trsw_cd[1]);*/
  1188. /* dbg_print("p_phy_sta_rpt->pwdb_all = 0x%x, p_phy_info->rx_pwdb_all = %d\n", p_phy_sta_rpt->pwdb_all, p_phy_info->rx_pwdb_all);*/
  1189. /* dbg_print("p_phy_sta_rpt->cfotail[i] = 0x%x, p_phy_sta_rpt->CFO_tail[i] = 0x%x\n", p_phy_sta_rpt->cfotail[0], p_phy_sta_rpt->cfotail[1]);*/
  1190. /* dbg_print("p_phy_sta_rpt->rxevm[0] = %d, p_phy_sta_rpt->rxevm[1] = %d\n", p_phy_sta_rpt->rxevm[0], p_phy_sta_rpt->rxevm[1]);*/
  1191. /* dbg_print("p_phy_sta_rpt->rxevm[2] = %d, p_phy_sta_rpt->rxevm[3] = %d\n", p_phy_sta_rpt->rxevm_cd[0], p_phy_sta_rpt->rxevm_cd[1]);*/
  1192. /* dbg_print("p_phy_info->rx_mimo_signal_strength[0]=%d, p_phy_info->rx_mimo_signal_strength[1]=%d, rx_pwdb_all=%d\n",*/
  1193. /* p_phy_info->rx_mimo_signal_strength[0], p_phy_info->rx_mimo_signal_strength[1], p_phy_info->rx_pwdb_all);*/
  1194. /* dbg_print("p_phy_info->rx_mimo_signal_strength[2]=%d, p_phy_info->rx_mimo_signal_strength[3]=%d\n",*/
  1195. /* p_phy_info->rx_mimo_signal_strength[2], p_phy_info->rx_mimo_signal_strength[3]);*/
  1196. /* dbg_print("ppPhyInfo->rx_mimo_signal_quality[0]=%d, p_phy_info->rx_mimo_signal_quality[1]=%d\n",*/
  1197. /* p_phy_info->rx_mimo_signal_quality[0], p_phy_info->rx_mimo_signal_quality[1]);*/
  1198. /* dbg_print("ppPhyInfo->rx_mimo_signal_quality[2]=%d, p_phy_info->rx_mimo_signal_quality[3]=%d\n",*/
  1199. /* p_phy_info->rx_mimo_signal_quality[2], p_phy_info->rx_mimo_signal_quality[3]);*/
  1200. }
  1201. #endif
  1202. void
  1203. phydm_reset_rssi_for_dm(
  1204. struct PHY_DM_STRUCT *p_dm_odm,
  1205. u8 station_id
  1206. )
  1207. {
  1208. struct sta_info *p_entry;
  1209. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1210. struct _ADAPTER *adapter = p_dm_odm->adapter;
  1211. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  1212. #endif
  1213. p_entry = p_dm_odm->p_odm_sta_info[station_id];
  1214. if (!IS_STA_VALID(p_entry)) {
  1215. /**/
  1216. return;
  1217. }
  1218. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("Reset RSSI for macid = (( %d ))\n", station_id));
  1219. p_entry->rssi_stat.undecorated_smoothed_cck = -1;
  1220. p_entry->rssi_stat.undecorated_smoothed_ofdm = -1;
  1221. p_entry->rssi_stat.undecorated_smoothed_pwdb = -1;
  1222. p_entry->rssi_stat.ofdm_pkt = 0;
  1223. p_entry->rssi_stat.cck_pkt = 0;
  1224. p_entry->rssi_stat.cck_sum_power = 0;
  1225. p_entry->rssi_stat.is_send_rssi = RA_RSSI_STATE_INIT;
  1226. p_entry->rssi_stat.packet_map = 0;
  1227. p_entry->rssi_stat.valid_bit = 0;
  1228. /*in WIN Driver: sta_ID==0->p_entry==NULL -> default port HAL_Data*/
  1229. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1230. p_entry->bUsed = 0;
  1231. if (station_id == 0) {
  1232. p_hal_data->UndecoratedSmoothedPWDB = -1;
  1233. /**/
  1234. }
  1235. #endif
  1236. }
  1237. void
  1238. odm_init_rssi_for_dm(
  1239. struct PHY_DM_STRUCT *p_dm_odm
  1240. )
  1241. {
  1242. }
  1243. void
  1244. odm_process_rssi_for_dm(
  1245. struct PHY_DM_STRUCT *p_dm_odm,
  1246. struct _odm_phy_status_info_ *p_phy_info,
  1247. struct _odm_per_pkt_info_ *p_pktinfo
  1248. )
  1249. {
  1250. s32 undecorated_smoothed_pwdb, undecorated_smoothed_cck, undecorated_smoothed_ofdm, rssi_ave, cck_pkt;
  1251. u8 i, is_cck_rate = 0;
  1252. u8 RSSI_max, RSSI_min;
  1253. u32 weighting = 0;
  1254. u8 send_rssi_2_fw = 0;
  1255. struct sta_info *p_entry;
  1256. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1257. struct _FAST_ANTENNA_TRAINNING_ *p_dm_fat_table = &p_dm_odm->dm_fat_table;
  1258. struct _ADAPTER *adapter = p_dm_odm->adapter;
  1259. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  1260. #endif
  1261. if (p_pktinfo->station_id >= ODM_ASSOCIATE_ENTRY_NUM)
  1262. return;
  1263. #ifdef CONFIG_S0S1_SW_ANTENNA_DIVERSITY
  1264. odm_s0s1_sw_ant_div_by_ctrl_frame_process_rssi(p_dm_odm, p_phy_info, p_pktinfo);
  1265. #endif
  1266. /* */
  1267. /* 2012/05/30 MH/Luke.Lee Add some description */
  1268. /* In windows driver: AP/IBSS mode STA */
  1269. /* */
  1270. /* if (p_dm_odm->support_platform == ODM_WIN) */
  1271. /* { */
  1272. /* p_entry = p_dm_odm->p_odm_sta_info[p_dm_odm->pAidMap[p_pktinfo->station_id-1]]; */
  1273. /* } */
  1274. /* else */
  1275. p_entry = p_dm_odm->p_odm_sta_info[p_pktinfo->station_id];
  1276. if (!IS_STA_VALID(p_entry)) {
  1277. return;
  1278. /**/
  1279. }
  1280. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1281. if ((p_dm_odm->support_ability & ODM_BB_ANT_DIV) &&
  1282. (p_dm_fat_table->enable_ctrl_frame_antdiv)
  1283. ) {
  1284. if (p_pktinfo->is_packet_match_bssid)
  1285. p_dm_odm->data_frame_num++;
  1286. if ((p_dm_fat_table->use_ctrl_frame_antdiv)) {
  1287. if (!p_pktinfo->is_to_self)/*data frame + CTRL frame*/
  1288. return;
  1289. } else {
  1290. if ((!p_pktinfo->is_packet_match_bssid))/*data frame only*/
  1291. return;
  1292. }
  1293. } else
  1294. #endif
  1295. {
  1296. if ((!p_pktinfo->is_packet_match_bssid))/*data frame only*/
  1297. return;
  1298. }
  1299. if (p_pktinfo->is_packet_beacon)
  1300. p_dm_odm->phy_dbg_info.num_qry_beacon_pkt++;
  1301. is_cck_rate = (p_pktinfo->data_rate <= ODM_RATE11M) ? true : false;
  1302. p_dm_odm->rx_rate = p_pktinfo->data_rate;
  1303. /* --------------Statistic for antenna/path diversity------------------ */
  1304. if (p_dm_odm->support_ability & ODM_BB_ANT_DIV) {
  1305. #if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY))
  1306. odm_process_rssi_for_ant_div(p_dm_odm, p_phy_info, p_pktinfo);
  1307. #endif
  1308. }
  1309. #if (defined(CONFIG_PATH_DIVERSITY))
  1310. else if (p_dm_odm->support_ability & ODM_BB_PATH_DIV)
  1311. phydm_process_rssi_for_path_div(p_dm_odm, p_phy_info, p_pktinfo);
  1312. #endif
  1313. /* -----------------Smart Antenna Debug Message------------------ */
  1314. undecorated_smoothed_cck = p_entry->rssi_stat.undecorated_smoothed_cck;
  1315. undecorated_smoothed_ofdm = p_entry->rssi_stat.undecorated_smoothed_ofdm;
  1316. undecorated_smoothed_pwdb = p_entry->rssi_stat.undecorated_smoothed_pwdb;
  1317. if (p_pktinfo->is_packet_to_self || p_pktinfo->is_packet_beacon) {
  1318. if (!is_cck_rate) { /* ofdm rate */
  1319. #if (RTL8814A_SUPPORT == 1) || (RTL8822B_SUPPORT == 1)
  1320. if (p_dm_odm->support_ic_type & (ODM_RTL8814A | ODM_RTL8822B)) {
  1321. u8 RX_count = 0;
  1322. u32 RSSI_linear = 0;
  1323. if (p_dm_odm->rx_ant_status & ODM_RF_A) {
  1324. p_dm_odm->RSSI_A = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1325. RX_count++;
  1326. RSSI_linear += odm_convert_to_linear(p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A]);
  1327. } else
  1328. p_dm_odm->RSSI_A = 0;
  1329. if (p_dm_odm->rx_ant_status & ODM_RF_B) {
  1330. p_dm_odm->RSSI_B = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B];
  1331. RX_count++;
  1332. RSSI_linear += odm_convert_to_linear(p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B]);
  1333. } else
  1334. p_dm_odm->RSSI_B = 0;
  1335. if (p_dm_odm->rx_ant_status & ODM_RF_C) {
  1336. p_dm_odm->RSSI_C = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_C];
  1337. RX_count++;
  1338. RSSI_linear += odm_convert_to_linear(p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_C]);
  1339. } else
  1340. p_dm_odm->RSSI_C = 0;
  1341. if (p_dm_odm->rx_ant_status & ODM_RF_D) {
  1342. p_dm_odm->RSSI_D = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_D];
  1343. RX_count++;
  1344. RSSI_linear += odm_convert_to_linear(p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_D]);
  1345. } else
  1346. p_dm_odm->RSSI_D = 0;
  1347. /* Calculate average RSSI */
  1348. switch (RX_count) {
  1349. case 2:
  1350. RSSI_linear = (RSSI_linear >> 1);
  1351. break;
  1352. case 3:
  1353. RSSI_linear = ((RSSI_linear) + (RSSI_linear << 1) + (RSSI_linear << 3)) >> 5; /* RSSI_linear/3 ~ RSSI_linear*11/32 */
  1354. break;
  1355. case 4:
  1356. RSSI_linear = (RSSI_linear >> 2);
  1357. break;
  1358. }
  1359. rssi_ave = odm_convert_to_db(RSSI_linear);
  1360. } else
  1361. #endif
  1362. {
  1363. if (p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B] == 0) {
  1364. rssi_ave = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1365. p_dm_odm->RSSI_A = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1366. p_dm_odm->RSSI_B = 0;
  1367. } else {
  1368. /*dbg_print("p_rfd->status.rx_mimo_signal_strength[0] = %d, p_rfd->status.rx_mimo_signal_strength[1] = %d\n",*/
  1369. /*p_rfd->status.rx_mimo_signal_strength[0], p_rfd->status.rx_mimo_signal_strength[1]);*/
  1370. p_dm_odm->RSSI_A = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1371. p_dm_odm->RSSI_B = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B];
  1372. if (p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A] > p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B]) {
  1373. RSSI_max = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1374. RSSI_min = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B];
  1375. } else {
  1376. RSSI_max = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B];
  1377. RSSI_min = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  1378. }
  1379. if ((RSSI_max - RSSI_min) < 3)
  1380. rssi_ave = RSSI_max;
  1381. else if ((RSSI_max - RSSI_min) < 6)
  1382. rssi_ave = RSSI_max - 1;
  1383. else if ((RSSI_max - RSSI_min) < 10)
  1384. rssi_ave = RSSI_max - 2;
  1385. else
  1386. rssi_ave = RSSI_max - 3;
  1387. }
  1388. }
  1389. /* 1 Process OFDM RSSI */
  1390. if (undecorated_smoothed_ofdm <= 0) { /* initialize */
  1391. undecorated_smoothed_ofdm = p_phy_info->rx_pwdb_all;
  1392. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("OFDM_INIT: (( %d ))\n", undecorated_smoothed_ofdm));
  1393. } else {
  1394. if (p_phy_info->rx_pwdb_all > (u32)undecorated_smoothed_ofdm) {
  1395. undecorated_smoothed_ofdm =
  1396. (((undecorated_smoothed_ofdm)*(RX_SMOOTH_FACTOR - 1)) +
  1397. (rssi_ave)) / (RX_SMOOTH_FACTOR);
  1398. undecorated_smoothed_ofdm = undecorated_smoothed_ofdm + 1;
  1399. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("OFDM_1: (( %d ))\n", undecorated_smoothed_ofdm));
  1400. } else {
  1401. undecorated_smoothed_ofdm =
  1402. (((undecorated_smoothed_ofdm)*(RX_SMOOTH_FACTOR - 1)) +
  1403. (rssi_ave)) / (RX_SMOOTH_FACTOR);
  1404. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("OFDM_2: (( %d ))\n", undecorated_smoothed_ofdm));
  1405. }
  1406. }
  1407. if (p_entry->rssi_stat.ofdm_pkt != 64) {
  1408. i = 63;
  1409. p_entry->rssi_stat.ofdm_pkt -= (u8)(((p_entry->rssi_stat.packet_map >> i) & BIT(0)) - 1);
  1410. }
  1411. p_entry->rssi_stat.packet_map = (p_entry->rssi_stat.packet_map << 1) | BIT(0);
  1412. } else {
  1413. rssi_ave = p_phy_info->rx_pwdb_all;
  1414. p_dm_odm->RSSI_A = (u8) p_phy_info->rx_pwdb_all;
  1415. p_dm_odm->RSSI_B = 0xFF;
  1416. p_dm_odm->RSSI_C = 0xFF;
  1417. p_dm_odm->RSSI_D = 0xFF;
  1418. if (p_entry->rssi_stat.cck_pkt <= 63)
  1419. p_entry->rssi_stat.cck_pkt++;
  1420. /* 1 Process CCK RSSI */
  1421. if (undecorated_smoothed_cck <= 0) { /* initialize */
  1422. undecorated_smoothed_cck = p_phy_info->rx_pwdb_all;
  1423. p_entry->rssi_stat.cck_sum_power = (u16)p_phy_info->rx_pwdb_all ; /*reset*/
  1424. p_entry->rssi_stat.cck_pkt = 1; /*reset*/
  1425. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("CCK_INIT: (( %d ))\n", undecorated_smoothed_cck));
  1426. } else if (p_entry->rssi_stat.cck_pkt <= CCK_RSSI_INIT_COUNT) {
  1427. p_entry->rssi_stat.cck_sum_power = p_entry->rssi_stat.cck_sum_power + (u16)p_phy_info->rx_pwdb_all;
  1428. undecorated_smoothed_cck = p_entry->rssi_stat.cck_sum_power / p_entry->rssi_stat.cck_pkt;
  1429. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("CCK_0: (( %d )), SumPow = (( %d )), cck_pkt = (( %d ))\n",
  1430. undecorated_smoothed_cck, p_entry->rssi_stat.cck_sum_power, p_entry->rssi_stat.cck_pkt));
  1431. } else {
  1432. if (p_phy_info->rx_pwdb_all > (u32)undecorated_smoothed_cck) {
  1433. undecorated_smoothed_cck =
  1434. (((undecorated_smoothed_cck)*(RX_SMOOTH_FACTOR - 1)) +
  1435. (p_phy_info->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
  1436. undecorated_smoothed_cck = undecorated_smoothed_cck + 1;
  1437. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("CCK_1: (( %d ))\n", undecorated_smoothed_cck));
  1438. } else {
  1439. undecorated_smoothed_cck =
  1440. (((undecorated_smoothed_cck)*(RX_SMOOTH_FACTOR - 1)) +
  1441. (p_phy_info->rx_pwdb_all)) / (RX_SMOOTH_FACTOR);
  1442. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("CCK_2: (( %d ))\n", undecorated_smoothed_cck));
  1443. }
  1444. }
  1445. i = 63;
  1446. p_entry->rssi_stat.ofdm_pkt -= (u8)((p_entry->rssi_stat.packet_map >> i) & BIT(0));
  1447. p_entry->rssi_stat.packet_map = p_entry->rssi_stat.packet_map << 1;
  1448. }
  1449. /* if(p_entry) */
  1450. {
  1451. /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */
  1452. if (p_entry->rssi_stat.ofdm_pkt == 64) { /* speed up when all packets are OFDM*/
  1453. undecorated_smoothed_pwdb = undecorated_smoothed_ofdm;
  1454. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("PWDB_0[%d] = (( %d ))\n", p_pktinfo->station_id, undecorated_smoothed_cck));
  1455. } else {
  1456. if (p_entry->rssi_stat.valid_bit < 64)
  1457. p_entry->rssi_stat.valid_bit++;
  1458. if (p_entry->rssi_stat.valid_bit == 64) {
  1459. weighting = ((p_entry->rssi_stat.ofdm_pkt) > 4) ? 64 : (p_entry->rssi_stat.ofdm_pkt << 4);
  1460. undecorated_smoothed_pwdb = (weighting * undecorated_smoothed_ofdm + (64 - weighting) * undecorated_smoothed_cck) >> 6;
  1461. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("PWDB_1[%d] = (( %d )), W = (( %d ))\n", p_pktinfo->station_id, undecorated_smoothed_cck, weighting));
  1462. } else {
  1463. if (p_entry->rssi_stat.valid_bit != 0)
  1464. undecorated_smoothed_pwdb = (p_entry->rssi_stat.ofdm_pkt * undecorated_smoothed_ofdm + (p_entry->rssi_stat.valid_bit - p_entry->rssi_stat.ofdm_pkt) * undecorated_smoothed_cck) / p_entry->rssi_stat.valid_bit;
  1465. else
  1466. undecorated_smoothed_pwdb = 0;
  1467. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("PWDB_2[%d] = (( %d )), ofdm_pkt = (( %d )), Valid_Bit = (( %d ))\n", p_pktinfo->station_id, undecorated_smoothed_cck, p_entry->rssi_stat.ofdm_pkt, p_entry->rssi_stat.valid_bit));
  1468. }
  1469. }
  1470. if ((p_entry->rssi_stat.ofdm_pkt >= 1 || p_entry->rssi_stat.cck_pkt >= 5) && (p_entry->rssi_stat.is_send_rssi == RA_RSSI_STATE_INIT)) {
  1471. send_rssi_2_fw = 1;
  1472. p_entry->rssi_stat.is_send_rssi = RA_RSSI_STATE_SEND;
  1473. }
  1474. p_entry->rssi_stat.undecorated_smoothed_cck = undecorated_smoothed_cck;
  1475. p_entry->rssi_stat.undecorated_smoothed_ofdm = undecorated_smoothed_ofdm;
  1476. p_entry->rssi_stat.undecorated_smoothed_pwdb = undecorated_smoothed_pwdb;
  1477. if (send_rssi_2_fw) { /* Trigger init rate by RSSI */
  1478. if (p_entry->rssi_stat.ofdm_pkt != 0)
  1479. p_entry->rssi_stat.undecorated_smoothed_pwdb = undecorated_smoothed_ofdm;
  1480. ODM_RT_TRACE(p_dm_odm, ODM_COMP_RSSI_MONITOR, ODM_DBG_LOUD, ("[Send to FW] PWDB = (( %d )), ofdm_pkt = (( %d )), cck_pkt = (( %d ))\n",
  1481. undecorated_smoothed_pwdb, p_entry->rssi_stat.ofdm_pkt, p_entry->rssi_stat.cck_pkt));
  1482. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  1483. phydm_ra_rssi_rpt_wk(p_dm_odm);
  1484. #endif
  1485. }
  1486. /*in WIN Driver: sta_ID==0->p_entry==NULL -> default port HAL_Data*/
  1487. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1488. if (p_pktinfo->station_id == 0) {
  1489. /**/
  1490. p_hal_data->UndecoratedSmoothedPWDB = undecorated_smoothed_pwdb;
  1491. }
  1492. #endif
  1493. /* dbg_print("ofdm_pkt=%d, weighting=%d\n", ofdm_pkt, weighting); */
  1494. /* dbg_print("undecorated_smoothed_ofdm=%d, undecorated_smoothed_pwdb=%d, undecorated_smoothed_cck=%d\n", */
  1495. /* undecorated_smoothed_ofdm, undecorated_smoothed_pwdb, undecorated_smoothed_cck); */
  1496. }
  1497. }
  1498. }
  1499. #if (ODM_IC_11N_SERIES_SUPPORT == 1)
  1500. /*
  1501. * Endianness before calling this API
  1502. * */
  1503. void
  1504. odm_phy_status_query_92c_series(
  1505. struct PHY_DM_STRUCT *p_dm_odm,
  1506. struct _odm_phy_status_info_ *p_phy_info,
  1507. u8 *p_phy_status,
  1508. struct _odm_per_pkt_info_ *p_pktinfo
  1509. )
  1510. {
  1511. odm_rx_phy_status92c_series_parsing(p_dm_odm, p_phy_info, p_phy_status, p_pktinfo);
  1512. odm_process_rssi_for_dm(p_dm_odm, p_phy_info, p_pktinfo);
  1513. }
  1514. #endif
  1515. /*
  1516. * Endianness before calling this API
  1517. * */
  1518. #if ODM_IC_11AC_SERIES_SUPPORT
  1519. void
  1520. odm_phy_status_query_jaguar_series(
  1521. struct PHY_DM_STRUCT *p_dm_odm,
  1522. struct _odm_phy_status_info_ *p_phy_info,
  1523. u8 *p_phy_status,
  1524. struct _odm_per_pkt_info_ *p_pktinfo
  1525. )
  1526. {
  1527. odm_rx_phy_status_jaguar_series_parsing(p_dm_odm, p_phy_info, p_phy_status, p_pktinfo);
  1528. odm_process_rssi_for_dm(p_dm_odm, p_phy_info, p_pktinfo);
  1529. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1530. /*phydm_sbd_check(p_dm_odm);*/
  1531. #endif
  1532. }
  1533. #endif
  1534. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  1535. void
  1536. phydm_normal_driver_rx_sniffer(
  1537. struct PHY_DM_STRUCT *p_dm_odm,
  1538. u8 *p_desc,
  1539. PRT_RFD_STATUS p_rt_rfd_status,
  1540. u8 *p_drv_info,
  1541. u8 phy_status
  1542. )
  1543. {
  1544. #if (defined(CONFIG_PHYDM_RX_SNIFFER_PARSING))
  1545. u32 *p_msg;
  1546. u16 seq_num;
  1547. struct _FAST_ANTENNA_TRAINNING_ *p_dm_fat_table = &p_dm_odm->dm_fat_table;
  1548. if (p_rt_rfd_status->packet_report_type != NORMAL_RX)
  1549. return;
  1550. if (!p_dm_odm->is_linked) {
  1551. if (p_rt_rfd_status->is_hw_error)
  1552. return;
  1553. }
  1554. if (!(p_dm_fat_table->fat_state == FAT_TRAINING_STATE))
  1555. return;
  1556. if (phy_status == true) {
  1557. if ((p_dm_odm->rx_pkt_type == type_block_ack) || (p_dm_odm->rx_pkt_type == type_rts) || (p_dm_odm->rx_pkt_type == type_cts))
  1558. seq_num = 0;
  1559. else
  1560. seq_num = p_rt_rfd_status->seq_num;
  1561. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, ("%04d , %01s, rate=0x%02x, L=%04d , %s , %s",
  1562. seq_num,
  1563. /*p_rt_rfd_status->mac_id,*/
  1564. ((p_rt_rfd_status->is_crc) ? "C" : (p_rt_rfd_status->is_ampdu) ? "A" : "_"),
  1565. p_rt_rfd_status->data_rate,
  1566. p_rt_rfd_status->length,
  1567. ((p_rt_rfd_status->band_width == 0) ? "20M" : ((p_rt_rfd_status->band_width == 1) ? "40M" : "80M")),
  1568. ((p_rt_rfd_status->is_ldpc) ? "LDP" : "BCC")
  1569. ));
  1570. if (p_dm_odm->rx_pkt_type == type_asoc_req) {
  1571. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "AS_REQ"));
  1572. /**/
  1573. } else if (p_dm_odm->rx_pkt_type == type_asoc_rsp) {
  1574. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "AS_RSP"));
  1575. /**/
  1576. } else if (p_dm_odm->rx_pkt_type == type_probe_req) {
  1577. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "PR_REQ"));
  1578. /**/
  1579. } else if (p_dm_odm->rx_pkt_type == type_probe_rsp) {
  1580. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "PR_RSP"));
  1581. /**/
  1582. } else if (p_dm_odm->rx_pkt_type == type_deauth) {
  1583. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "DEAUTH"));
  1584. /**/
  1585. } else if (p_dm_odm->rx_pkt_type == type_beacon) {
  1586. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "BEACON"));
  1587. /**/
  1588. } else if (p_dm_odm->rx_pkt_type == type_block_ack_req) {
  1589. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "BA_REQ"));
  1590. /**/
  1591. } else if (p_dm_odm->rx_pkt_type == type_rts) {
  1592. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "__RTS_"));
  1593. /**/
  1594. } else if (p_dm_odm->rx_pkt_type == type_cts) {
  1595. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "__CTS_"));
  1596. /**/
  1597. } else if (p_dm_odm->rx_pkt_type == type_ack) {
  1598. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "__ACK_"));
  1599. /**/
  1600. } else if (p_dm_odm->rx_pkt_type == type_block_ack) {
  1601. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "__BA__"));
  1602. /**/
  1603. } else if (p_dm_odm->rx_pkt_type == type_data) {
  1604. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "_DATA_"));
  1605. /**/
  1606. } else if (p_dm_odm->rx_pkt_type == type_data_ack) {
  1607. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "Data_Ack"));
  1608. /**/
  1609. } else if (p_dm_odm->rx_pkt_type == type_qos_data) {
  1610. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [%s]", "QoS_Data"));
  1611. /**/
  1612. } else {
  1613. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [0x%x]", p_dm_odm->rx_pkt_type));
  1614. /**/
  1615. }
  1616. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , [RSSI=%d,%d,%d,%d ]",
  1617. p_dm_odm->RSSI_A,
  1618. p_dm_odm->RSSI_B,
  1619. p_dm_odm->RSSI_C,
  1620. p_dm_odm->RSSI_D
  1621. ));
  1622. p_msg = (u32 *)p_drv_info;
  1623. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, (" , P-STS[28:0]=%08x-%08x-%08x-%08x-%08x-%08x-%08x\n",
  1624. p_msg[6], p_msg[5], p_msg[4], p_msg[3], p_msg[2], p_msg[1], p_msg[1]));
  1625. } else {
  1626. ODM_RT_TRACE_F(p_dm_odm, ODM_COMP_SNIFFER, ODM_DBG_LOUD, ("%04d , %01s, rate=0x%02x, L=%04d , %s , %s\n",
  1627. p_rt_rfd_status->seq_num,
  1628. /*p_rt_rfd_status->mac_id,*/
  1629. ((p_rt_rfd_status->is_crc) ? "C" : (p_rt_rfd_status->is_ampdu) ? "A" : "_"),
  1630. p_rt_rfd_status->data_rate,
  1631. p_rt_rfd_status->length,
  1632. ((p_rt_rfd_status->band_width == 0) ? "20M" : ((p_rt_rfd_status->band_width == 1) ? "40M" : "80M")),
  1633. ((p_rt_rfd_status->is_ldpc) ? "LDP" : "BCC")
  1634. ));
  1635. }
  1636. #endif
  1637. }
  1638. #endif
  1639. void
  1640. odm_phy_status_query(
  1641. struct PHY_DM_STRUCT *p_dm_odm,
  1642. struct _odm_phy_status_info_ *p_phy_info,
  1643. u8 *p_phy_status,
  1644. struct _odm_per_pkt_info_ *p_pktinfo
  1645. )
  1646. {
  1647. #if (ODM_PHY_STATUS_NEW_TYPE_SUPPORT == 1)
  1648. if (p_dm_odm->support_ic_type & ODM_IC_PHY_STATUE_NEW_TYPE) {
  1649. phydm_rx_phy_status_new_type(p_dm_odm, p_phy_status, p_pktinfo, p_phy_info);
  1650. return;
  1651. }
  1652. #endif
  1653. #if ODM_IC_11AC_SERIES_SUPPORT
  1654. if (p_dm_odm->support_ic_type & ODM_IC_11AC_SERIES)
  1655. odm_phy_status_query_jaguar_series(p_dm_odm, p_phy_info, p_phy_status, p_pktinfo);
  1656. #endif
  1657. #if ODM_IC_11N_SERIES_SUPPORT
  1658. if (p_dm_odm->support_ic_type & ODM_IC_11N_SERIES)
  1659. odm_phy_status_query_92c_series(p_dm_odm, p_phy_info, p_phy_status, p_pktinfo);
  1660. #endif
  1661. }
  1662. /* For future use. */
  1663. void
  1664. odm_mac_status_query(
  1665. struct PHY_DM_STRUCT *p_dm_odm,
  1666. u8 *p_mac_status,
  1667. u8 mac_id,
  1668. boolean is_packet_match_bssid,
  1669. boolean is_packet_to_self,
  1670. boolean is_packet_beacon
  1671. )
  1672. {
  1673. /* 2011/10/19 Driver team will handle in the future. */
  1674. }
  1675. /*
  1676. * If you want to add a new IC, Please follow below template and generate a new one.
  1677. *
  1678. * */
  1679. enum hal_status
  1680. odm_config_rf_with_header_file(
  1681. struct PHY_DM_STRUCT *p_dm_odm,
  1682. enum odm_rf_config_type config_type,
  1683. enum odm_rf_radio_path_e e_rf_path
  1684. )
  1685. {
  1686. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  1687. struct _ADAPTER *adapter = p_dm_odm->adapter;
  1688. PMGNT_INFO p_mgnt_info = &(adapter->MgntInfo);
  1689. #endif
  1690. enum hal_status ret = HAL_STATUS_SUCCESS;
  1691. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1692. ("===>odm_config_rf_with_header_file (%s)\n", (p_dm_odm->is_mp_chip) ? "MPChip" : "TestChip"));
  1693. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1694. ("p_dm_odm->support_platform: 0x%X, p_dm_odm->support_interface: 0x%X, p_dm_odm->board_type: 0x%X\n",
  1695. p_dm_odm->support_platform, p_dm_odm->support_interface, p_dm_odm->board_type));
  1696. /* 1 AP doesn't use PHYDM power tracking table in these ICs */
  1697. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  1698. #if (RTL8812A_SUPPORT == 1)
  1699. if (p_dm_odm->support_ic_type == ODM_RTL8812) {
  1700. if (config_type == CONFIG_RF_RADIO) {
  1701. if (e_rf_path == ODM_RF_PATH_A)
  1702. READ_AND_CONFIG_MP(8812a, _radioa);
  1703. else if (e_rf_path == ODM_RF_PATH_B)
  1704. READ_AND_CONFIG_MP(8812a, _radiob);
  1705. } else if (config_type == CONFIG_RF_TXPWR_LMT) {
  1706. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) && (DEV_BUS_TYPE == RT_PCI_INTERFACE)
  1707. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  1708. if ((p_hal_data->EEPROMSVID == 0x17AA && p_hal_data->EEPROMSMID == 0xA811) ||
  1709. (p_hal_data->EEPROMSVID == 0x10EC && p_hal_data->EEPROMSMID == 0xA812) ||
  1710. (p_hal_data->EEPROMSVID == 0x10EC && p_hal_data->EEPROMSMID == 0x8812))
  1711. READ_AND_CONFIG_MP(8812a, _txpwr_lmt_hm812a03);
  1712. else
  1713. #endif
  1714. READ_AND_CONFIG_MP(8812a, _txpwr_lmt);
  1715. }
  1716. }
  1717. #endif
  1718. #if (RTL8821A_SUPPORT == 1)
  1719. if (p_dm_odm->support_ic_type == ODM_RTL8821) {
  1720. if (config_type == CONFIG_RF_RADIO) {
  1721. if (e_rf_path == ODM_RF_PATH_A)
  1722. READ_AND_CONFIG_MP(8821a, _radioa);
  1723. } else if (config_type == CONFIG_RF_TXPWR_LMT) {
  1724. if (p_dm_odm->support_interface == ODM_ITRF_USB) {
  1725. if (p_dm_odm->ext_pa_5g || p_dm_odm->ext_lna_5g)
  1726. READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8811a_u_fem);
  1727. else
  1728. READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8811a_u_ipa);
  1729. } else {
  1730. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  1731. if (p_mgnt_info->CustomerID == RT_CID_8821AE_ASUS_MB)
  1732. READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a_sar_8mm);
  1733. else if (p_mgnt_info->CustomerID == RT_CID_ASUS_NB)
  1734. READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a_sar_5mm);
  1735. else
  1736. #endif
  1737. READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a);
  1738. }
  1739. }
  1740. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("<===8821_ODM_ConfigRFWithHeaderFile\n"));
  1741. }
  1742. #endif
  1743. #if (RTL8192E_SUPPORT == 1)
  1744. if (p_dm_odm->support_ic_type == ODM_RTL8192E) {
  1745. if (config_type == CONFIG_RF_RADIO) {
  1746. if (e_rf_path == ODM_RF_PATH_A)
  1747. READ_AND_CONFIG_MP(8192e, _radioa);
  1748. else if (e_rf_path == ODM_RF_PATH_B)
  1749. READ_AND_CONFIG_MP(8192e, _radiob);
  1750. } else if (config_type == CONFIG_RF_TXPWR_LMT) {
  1751. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) && (DEV_BUS_TYPE == RT_PCI_INTERFACE) /*Refine by Vincent Lan for 5mm SAR pwr limit*/
  1752. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  1753. if ((p_hal_data->EEPROMSVID == 0x11AD && p_hal_data->EEPROMSMID == 0x8192) ||
  1754. (p_hal_data->EEPROMSVID == 0x11AD && p_hal_data->EEPROMSMID == 0x8193))
  1755. READ_AND_CONFIG_MP(8192e, _txpwr_lmt_8192e_sar_5mm);
  1756. else
  1757. #endif
  1758. READ_AND_CONFIG_MP(8192e, _txpwr_lmt);
  1759. }
  1760. }
  1761. #endif
  1762. #if (RTL8723D_SUPPORT == 1)
  1763. if (p_dm_odm->support_ic_type == ODM_RTL8723D) {
  1764. if (config_type == CONFIG_RF_RADIO) {
  1765. if (e_rf_path == ODM_RF_PATH_A)
  1766. READ_AND_CONFIG_MP(8723d, _radioa);
  1767. } else if (config_type == CONFIG_RF_TXPWR_LMT)
  1768. READ_AND_CONFIG_MP(8723d, _txpwr_lmt);
  1769. }
  1770. #endif
  1771. /* JJ ADD 20161014 */
  1772. #if (RTL8710B_SUPPORT == 1)
  1773. if (p_dm_odm->support_ic_type == ODM_RTL8710B) {
  1774. if (config_type == CONFIG_RF_RADIO) {
  1775. if (e_rf_path == ODM_RF_PATH_A)
  1776. READ_AND_CONFIG_MP(8710b, _radioa);
  1777. } else if (config_type == CONFIG_RF_TXPWR_LMT)
  1778. READ_AND_CONFIG_MP(8710b, _txpwr_lmt);
  1779. }
  1780. #endif
  1781. #endif/* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  1782. /* 1 All platforms support */
  1783. #if (RTL8188E_SUPPORT == 1)
  1784. if (p_dm_odm->support_ic_type == ODM_RTL8188E) {
  1785. if (config_type == CONFIG_RF_RADIO) {
  1786. if (e_rf_path == ODM_RF_PATH_A)
  1787. READ_AND_CONFIG_MP(8188e, _radioa);
  1788. } else if (config_type == CONFIG_RF_TXPWR_LMT)
  1789. READ_AND_CONFIG_MP(8188e, _txpwr_lmt);
  1790. }
  1791. #endif
  1792. #if (RTL8723B_SUPPORT == 1)
  1793. if (p_dm_odm->support_ic_type == ODM_RTL8723B) {
  1794. if (config_type == CONFIG_RF_RADIO)
  1795. READ_AND_CONFIG_MP(8723b, _radioa);
  1796. else if (config_type == CONFIG_RF_TXPWR_LMT)
  1797. READ_AND_CONFIG_MP(8723b, _txpwr_lmt);
  1798. }
  1799. #endif
  1800. #if (RTL8814A_SUPPORT == 1)
  1801. if (p_dm_odm->support_ic_type == ODM_RTL8814A) {
  1802. if (config_type == CONFIG_RF_RADIO) {
  1803. if (e_rf_path == ODM_RF_PATH_A)
  1804. READ_AND_CONFIG_MP(8814a, _radioa);
  1805. else if (e_rf_path == ODM_RF_PATH_B)
  1806. READ_AND_CONFIG_MP(8814a, _radiob);
  1807. else if (e_rf_path == ODM_RF_PATH_C)
  1808. READ_AND_CONFIG_MP(8814a, _radioc);
  1809. else if (e_rf_path == ODM_RF_PATH_D)
  1810. READ_AND_CONFIG_MP(8814a, _radiod);
  1811. } else if (config_type == CONFIG_RF_TXPWR_LMT) {
  1812. if (p_dm_odm->rfe_type == 0)
  1813. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type0);
  1814. else if (p_dm_odm->rfe_type == 1)
  1815. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type1);
  1816. else if (p_dm_odm->rfe_type == 2)
  1817. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type2);
  1818. else if (p_dm_odm->rfe_type == 3)
  1819. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type3);
  1820. else if (p_dm_odm->rfe_type == 5)
  1821. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type5);
  1822. else if (p_dm_odm->rfe_type == 7)
  1823. READ_AND_CONFIG_MP(8814a,_txpwr_lmt_type7);
  1824. else
  1825. READ_AND_CONFIG_MP(8814a,_txpwr_lmt);
  1826. }
  1827. }
  1828. #endif
  1829. #if (RTL8703B_SUPPORT == 1)
  1830. if (p_dm_odm->support_ic_type == ODM_RTL8703B) {
  1831. if (config_type == CONFIG_RF_RADIO) {
  1832. if (e_rf_path == ODM_RF_PATH_A)
  1833. READ_AND_CONFIG_MP(8703b, _radioa);
  1834. }
  1835. }
  1836. #endif
  1837. #if (RTL8188F_SUPPORT == 1)
  1838. if (p_dm_odm->support_ic_type == ODM_RTL8188F) {
  1839. if (config_type == CONFIG_RF_RADIO) {
  1840. if (e_rf_path == ODM_RF_PATH_A)
  1841. READ_AND_CONFIG_MP(8188f, _radioa);
  1842. } else if (config_type == CONFIG_RF_TXPWR_LMT)
  1843. READ_AND_CONFIG_MP(8188f, _txpwr_lmt);
  1844. }
  1845. #endif
  1846. #if (RTL8822B_SUPPORT == 1)
  1847. if (p_dm_odm->support_ic_type == ODM_RTL8822B) {
  1848. if (config_type == CONFIG_RF_RADIO) {
  1849. if (e_rf_path == ODM_RF_PATH_A)
  1850. READ_AND_CONFIG_MP(8822b, _radioa);
  1851. else if (e_rf_path == ODM_RF_PATH_B)
  1852. READ_AND_CONFIG_MP(8822b, _radiob);
  1853. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  1854. if(p_dm_odm->halmac_ability & ODM_PHY_PARAM_OFFLOAD)
  1855. {
  1856. RT_STATUS status = RT_STATUS_SUCCESS;
  1857. status = HAL_MAC_Config_PHY_WriteNByte(&GET_HAL_MAC_INFO(p_dm_odm->adapter),HALMAC_PARAMETER_CMD_END,0,0,FALSE,0,TRUE,0,0);
  1858. if(status != RT_STATUS_SUCCESS)
  1859. ret = HAL_STATUS_FAILURE;
  1860. RT_TRACE(COMP_INIT, DBG_LOUD, ("RF param. offload status = %x\n",status));
  1861. }
  1862. #endif
  1863. } else if (config_type == CONFIG_RF_TXPWR_LMT) {
  1864. if (p_dm_odm->rfe_type == 5)
  1865. READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type5);
  1866. else
  1867. READ_AND_CONFIG_MP(8822b, _txpwr_lmt);
  1868. }
  1869. }
  1870. #endif
  1871. #if (RTL8197F_SUPPORT == 1)
  1872. if (p_dm_odm->support_ic_type == ODM_RTL8197F) {
  1873. if (config_type == CONFIG_RF_RADIO) {
  1874. if (e_rf_path == ODM_RF_PATH_A)
  1875. READ_AND_CONFIG_MP(8197f, _radioa);
  1876. else if (e_rf_path == ODM_RF_PATH_B)
  1877. READ_AND_CONFIG_MP(8197f, _radiob);
  1878. }
  1879. }
  1880. #endif
  1881. #if (RTL8821C_SUPPORT == 1)
  1882. if (p_dm_odm->support_ic_type == ODM_RTL8821C) {
  1883. if (config_type == CONFIG_RF_RADIO) {
  1884. if (e_rf_path == ODM_RF_PATH_A)
  1885. READ_AND_CONFIG(8821c, _radioa);
  1886. } else if (config_type == CONFIG_RF_TXPWR_LMT)
  1887. READ_AND_CONFIG(8821c, _txpwr_lmt);
  1888. }
  1889. #endif
  1890. return ret;
  1891. }
  1892. enum hal_status
  1893. odm_config_rf_with_tx_pwr_track_header_file(
  1894. struct PHY_DM_STRUCT *p_dm_odm
  1895. )
  1896. {
  1897. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1898. ("===>odm_config_rf_with_tx_pwr_track_header_file (%s)\n", (p_dm_odm->is_mp_chip) ? "MPChip" : "TestChip"));
  1899. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  1900. ("p_dm_odm->support_platform: 0x%X, p_dm_odm->support_interface: 0x%X, p_dm_odm->board_type: 0x%X\n",
  1901. p_dm_odm->support_platform, p_dm_odm->support_interface, p_dm_odm->board_type));
  1902. /* 1 AP doesn't use PHYDM power tracking table in these ICs */
  1903. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  1904. #if RTL8821A_SUPPORT
  1905. if (p_dm_odm->support_ic_type == ODM_RTL8821) {
  1906. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1907. READ_AND_CONFIG_MP(8821a, _txpowertrack_pcie);
  1908. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1909. READ_AND_CONFIG_MP(8821a, _txpowertrack_usb);
  1910. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1911. READ_AND_CONFIG_MP(8821a, _txpowertrack_sdio);
  1912. }
  1913. #endif
  1914. #if RTL8812A_SUPPORT
  1915. if (p_dm_odm->support_ic_type == ODM_RTL8812) {
  1916. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1917. READ_AND_CONFIG_MP(8812a, _txpowertrack_pcie);
  1918. else if (p_dm_odm->support_interface == ODM_ITRF_USB) {
  1919. if (p_dm_odm->rfe_type == 3 && p_dm_odm->is_mp_chip)
  1920. READ_AND_CONFIG_MP(8812a, _txpowertrack_rfe3);
  1921. else
  1922. READ_AND_CONFIG_MP(8812a, _txpowertrack_usb);
  1923. }
  1924. }
  1925. #endif
  1926. #if RTL8192E_SUPPORT
  1927. if (p_dm_odm->support_ic_type == ODM_RTL8192E) {
  1928. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1929. READ_AND_CONFIG_MP(8192e, _txpowertrack_pcie);
  1930. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1931. READ_AND_CONFIG_MP(8192e, _txpowertrack_usb);
  1932. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1933. READ_AND_CONFIG_MP(8192e, _txpowertrack_sdio);
  1934. }
  1935. #endif
  1936. #if RTL8723D_SUPPORT
  1937. if (p_dm_odm->support_ic_type == ODM_RTL8723D) {
  1938. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1939. READ_AND_CONFIG_MP(8723d, _txpowertrack_pcie);
  1940. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1941. READ_AND_CONFIG_MP(8723d, _txpowertrack_usb);
  1942. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1943. READ_AND_CONFIG_MP(8723d, _txpowertrack_sdio);
  1944. READ_AND_CONFIG_MP(8723d, _txxtaltrack);
  1945. }
  1946. #endif
  1947. /* JJ ADD 20161014 */
  1948. #if RTL8710B_SUPPORT
  1949. if (p_dm_odm->support_ic_type == ODM_RTL8710B) {
  1950. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1951. READ_AND_CONFIG_MP(8710b, _txpowertrack_pcie);
  1952. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1953. READ_AND_CONFIG_MP(8710b, _txpowertrack_usb);
  1954. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1955. READ_AND_CONFIG_MP(8710b, _txpowertrack_sdio);
  1956. READ_AND_CONFIG_MP(8710b, _txxtaltrack);
  1957. }
  1958. #endif
  1959. #if RTL8188E_SUPPORT
  1960. if (p_dm_odm->support_ic_type == ODM_RTL8188E) {
  1961. if (odm_get_mac_reg(p_dm_odm, 0xF0, 0xF000) >= 8) { /*if 0xF0[15:12] >= 8, SMIC*/
  1962. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1963. READ_AND_CONFIG_MP(8188e, _txpowertrack_pcie_icut);
  1964. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1965. READ_AND_CONFIG_MP(8188e, _txpowertrack_usb_icut);
  1966. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1967. READ_AND_CONFIG_MP(8188e, _txpowertrack_sdio_icut);
  1968. } else { /*else 0xF0[15:12] < 8, TSMC*/
  1969. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1970. READ_AND_CONFIG_MP(8188e, _txpowertrack_pcie);
  1971. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1972. READ_AND_CONFIG_MP(8188e, _txpowertrack_usb);
  1973. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1974. READ_AND_CONFIG_MP(8188e, _txpowertrack_sdio);
  1975. }
  1976. }
  1977. #endif
  1978. #endif/* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  1979. /* 1 All platforms support */
  1980. #if RTL8723B_SUPPORT
  1981. if (p_dm_odm->support_ic_type == ODM_RTL8723B) {
  1982. if (p_dm_odm->support_interface == ODM_ITRF_PCIE)
  1983. READ_AND_CONFIG_MP(8723b, _txpowertrack_pcie);
  1984. else if (p_dm_odm->support_interface == ODM_ITRF_USB)
  1985. READ_AND_CONFIG_MP(8723b, _txpowertrack_usb);
  1986. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  1987. READ_AND_CONFIG_MP(8723b, _txpowertrack_sdio);
  1988. }
  1989. #endif
  1990. #if RTL8814A_SUPPORT
  1991. if (p_dm_odm->support_ic_type == ODM_RTL8814A) {
  1992. if (p_dm_odm->rfe_type == 0)
  1993. READ_AND_CONFIG_MP(8814a, _txpowertrack_type0);
  1994. else if (p_dm_odm->rfe_type == 2)
  1995. READ_AND_CONFIG_MP(8814a, _txpowertrack_type2);
  1996. else if (p_dm_odm->rfe_type == 5)
  1997. READ_AND_CONFIG_MP(8814a, _txpowertrack_type5);
  1998. else
  1999. READ_AND_CONFIG_MP(8814a, _txpowertrack);
  2000. READ_AND_CONFIG_MP(8814a, _txpowertssi);
  2001. }
  2002. #endif
  2003. #if RTL8703B_SUPPORT
  2004. if (p_dm_odm->support_ic_type == ODM_RTL8703B) {
  2005. if (p_dm_odm->support_interface == ODM_ITRF_USB)
  2006. READ_AND_CONFIG_MP(8703b, _txpowertrack_usb);
  2007. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  2008. READ_AND_CONFIG_MP(8703b, _txpowertrack_sdio);
  2009. READ_AND_CONFIG_MP(8703b, _txxtaltrack);
  2010. }
  2011. #endif
  2012. #if RTL8188F_SUPPORT
  2013. if (p_dm_odm->support_ic_type == ODM_RTL8188F) {
  2014. if (p_dm_odm->support_interface == ODM_ITRF_USB)
  2015. READ_AND_CONFIG_MP(8188f, _txpowertrack_usb);
  2016. else if (p_dm_odm->support_interface == ODM_ITRF_SDIO)
  2017. READ_AND_CONFIG_MP(8188f, _txpowertrack_sdio);
  2018. }
  2019. #endif
  2020. #if RTL8822B_SUPPORT
  2021. if (p_dm_odm->support_ic_type == ODM_RTL8822B) {
  2022. if (p_dm_odm->rfe_type == 0)
  2023. READ_AND_CONFIG_MP(8822b, _txpowertrack_type0);
  2024. else if (p_dm_odm->rfe_type == 1)
  2025. READ_AND_CONFIG_MP(8822b, _txpowertrack_type1);
  2026. else if (p_dm_odm->rfe_type == 2)
  2027. READ_AND_CONFIG_MP(8822b, _txpowertrack_type2);
  2028. else if ((p_dm_odm->rfe_type == 3) || (p_dm_odm->rfe_type == 5))
  2029. READ_AND_CONFIG_MP(8822b, _txpowertrack_type3_type5);
  2030. else if (p_dm_odm->rfe_type == 4)
  2031. READ_AND_CONFIG_MP(8822b, _txpowertrack_type4);
  2032. else if (p_dm_odm->rfe_type == 6)
  2033. READ_AND_CONFIG_MP(8822b, _txpowertrack_type6);
  2034. else if (p_dm_odm->rfe_type == 7)
  2035. READ_AND_CONFIG_MP(8822b, _txpowertrack_type7);
  2036. else if (p_dm_odm->rfe_type == 8)
  2037. READ_AND_CONFIG_MP(8822b, _txpowertrack_type8);
  2038. else if (p_dm_odm->rfe_type == 9)
  2039. READ_AND_CONFIG_MP(8822b, _txpowertrack_type9);
  2040. else if (p_dm_odm->rfe_type == 10)
  2041. READ_AND_CONFIG_MP(8822b, _txpowertrack_type10);
  2042. else if (p_dm_odm->rfe_type == 11)
  2043. READ_AND_CONFIG_MP(8822b, _txpowertrack_type11);
  2044. else if (p_dm_odm->rfe_type == 12)
  2045. READ_AND_CONFIG_MP(8822b, _txpowertrack_type12);
  2046. else if (p_dm_odm->rfe_type == 13)
  2047. READ_AND_CONFIG_MP(8822b, _txpowertrack_type13);
  2048. else
  2049. READ_AND_CONFIG_MP(8822b, _txpowertrack);
  2050. }
  2051. #endif
  2052. #if RTL8197F_SUPPORT
  2053. if (p_dm_odm->support_ic_type == ODM_RTL8197F) {
  2054. if (p_dm_odm->rfe_type == 0)
  2055. READ_AND_CONFIG_MP(8197f, _txpowertrack_type0);
  2056. else if (p_dm_odm->rfe_type == 1)
  2057. READ_AND_CONFIG_MP(8197f, _txpowertrack_type1);
  2058. else
  2059. READ_AND_CONFIG_MP(8197f, _txpowertrack);
  2060. }
  2061. #endif
  2062. #if RTL8821C_SUPPORT
  2063. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  2064. READ_AND_CONFIG(8821c, _txpowertrack);
  2065. #endif
  2066. return HAL_STATUS_SUCCESS;
  2067. }
  2068. enum hal_status
  2069. odm_config_bb_with_header_file(
  2070. struct PHY_DM_STRUCT *p_dm_odm,
  2071. enum odm_bb_config_type config_type
  2072. )
  2073. {
  2074. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2075. struct _ADAPTER *adapter = p_dm_odm->adapter;
  2076. PMGNT_INFO p_mgnt_info = &(adapter->MgntInfo);
  2077. #endif
  2078. enum hal_status ret = HAL_STATUS_SUCCESS;
  2079. /* 1 AP doesn't use PHYDM initialization in these ICs */
  2080. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  2081. #if (RTL8812A_SUPPORT == 1)
  2082. if (p_dm_odm->support_ic_type == ODM_RTL8812) {
  2083. if (config_type == CONFIG_BB_PHY_REG)
  2084. READ_AND_CONFIG_MP(8812a, _phy_reg);
  2085. else if (config_type == CONFIG_BB_AGC_TAB)
  2086. READ_AND_CONFIG_MP(8812a, _agc_tab);
  2087. else if (config_type == CONFIG_BB_PHY_REG_PG) {
  2088. if (p_dm_odm->rfe_type == 3 && p_dm_odm->is_mp_chip)
  2089. READ_AND_CONFIG_MP(8812a, _phy_reg_pg_asus);
  2090. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2091. else if (p_mgnt_info->CustomerID == RT_CID_WNC_NEC && p_dm_odm->is_mp_chip)
  2092. READ_AND_CONFIG_MP(8812a, _phy_reg_pg_nec);
  2093. #if RT_PLATFORM == PLATFORM_MACOSX
  2094. /*{1827}{1024} for BUFFALO power by rate table. Isaiah 2013-11-29*/
  2095. else if (p_mgnt_info->CustomerID == RT_CID_DNI_BUFFALO)
  2096. READ_AND_CONFIG_MP(8812a, _phy_reg_pg_dni);
  2097. /* TP-Link T4UH, Isaiah 2015-03-16*/
  2098. else if (p_mgnt_info->CustomerID == RT_CID_TPLINK_HPWR) {
  2099. dbg_print("RT_CID_TPLINK_HPWR:: _PHY_REG_PG_TPLINK\n");
  2100. READ_AND_CONFIG_MP(8812a, _phy_reg_pg_tplink);
  2101. }
  2102. #endif
  2103. #endif
  2104. else
  2105. READ_AND_CONFIG_MP(8812a, _phy_reg_pg);
  2106. } else if (config_type == CONFIG_BB_PHY_REG_MP)
  2107. READ_AND_CONFIG_MP(8812a, _phy_reg_mp);
  2108. else if (config_type == CONFIG_BB_AGC_TAB_DIFF) {
  2109. if ((36 <= *p_dm_odm->p_channel) && (*p_dm_odm->p_channel <= 64))
  2110. AGC_DIFF_CONFIG_MP(8812a, lb);
  2111. else if (100 <= *p_dm_odm->p_channel)
  2112. AGC_DIFF_CONFIG_MP(8812a, hb);
  2113. }
  2114. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() phy:Rtl8812AGCTABArray\n"));
  2115. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8812PHY_REGArray\n"));
  2116. }
  2117. #endif
  2118. #if (RTL8821A_SUPPORT == 1)
  2119. if (p_dm_odm->support_ic_type == ODM_RTL8821) {
  2120. if (config_type == CONFIG_BB_PHY_REG)
  2121. READ_AND_CONFIG_MP(8821a, _phy_reg);
  2122. else if (config_type == CONFIG_BB_AGC_TAB)
  2123. READ_AND_CONFIG_MP(8821a, _agc_tab);
  2124. else if (config_type == CONFIG_BB_PHY_REG_PG) {
  2125. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2126. #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
  2127. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(adapter);
  2128. if ((p_hal_data->EEPROMSVID == 0x1043 && p_hal_data->EEPROMSMID == 0x207F))
  2129. READ_AND_CONFIG_MP(8821a, _phy_reg_pg_e202_sa);
  2130. else
  2131. #endif
  2132. #if (RT_PLATFORM == PLATFORM_MACOSX)
  2133. /*{1827}{1022} for BUFFALO power by rate table. Isaiah 2013-10-18*/
  2134. if (p_mgnt_info->CustomerID == RT_CID_DNI_BUFFALO) {
  2135. /*{1024} for BUFFALO power by rate table. (JP/US)*/
  2136. if (p_mgnt_info->channel_plan == RT_CHANNEL_DOMAIN_US_2G_CANADA_5G)
  2137. READ_AND_CONFIG_MP(8821a, _phy_reg_pg_dni_us);
  2138. else
  2139. READ_AND_CONFIG_MP(8821a, _phy_reg_pg_dni_jp);
  2140. } else
  2141. #endif
  2142. #endif
  2143. READ_AND_CONFIG_MP(8821a, _phy_reg_pg);
  2144. }
  2145. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() phy:Rtl8821AGCTABArray\n"));
  2146. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8821PHY_REGArray\n"));
  2147. }
  2148. #endif
  2149. #if (RTL8192E_SUPPORT == 1)
  2150. if (p_dm_odm->support_ic_type == ODM_RTL8192E) {
  2151. if (config_type == CONFIG_BB_PHY_REG)
  2152. READ_AND_CONFIG_MP(8192e, _phy_reg);
  2153. else if (config_type == CONFIG_BB_AGC_TAB)
  2154. READ_AND_CONFIG_MP(8192e, _agc_tab);
  2155. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2156. READ_AND_CONFIG_MP(8192e, _phy_reg_pg);
  2157. }
  2158. #endif
  2159. #if (RTL8723D_SUPPORT == 1)
  2160. if (p_dm_odm->support_ic_type == ODM_RTL8723D) {
  2161. if (config_type == CONFIG_BB_PHY_REG)
  2162. READ_AND_CONFIG_MP(8723d, _phy_reg);
  2163. else if (config_type == CONFIG_BB_AGC_TAB)
  2164. READ_AND_CONFIG_MP(8723d, _agc_tab);
  2165. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2166. READ_AND_CONFIG_MP(8723d, _phy_reg_pg);
  2167. }
  2168. #endif
  2169. /* JJ ADD 20161014 */
  2170. #if (RTL8710B_SUPPORT == 1)
  2171. if (p_dm_odm->support_ic_type == ODM_RTL8710B) {
  2172. if (config_type == CONFIG_BB_PHY_REG)
  2173. READ_AND_CONFIG_MP(8710b, _phy_reg);
  2174. else if (config_type == CONFIG_BB_AGC_TAB)
  2175. READ_AND_CONFIG_MP(8710b, _agc_tab);
  2176. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2177. READ_AND_CONFIG_MP(8710b, _phy_reg_pg);
  2178. }
  2179. #endif
  2180. #endif/* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  2181. /* 1 All platforms support */
  2182. #if (RTL8188E_SUPPORT == 1)
  2183. if (p_dm_odm->support_ic_type == ODM_RTL8188E) {
  2184. if (config_type == CONFIG_BB_PHY_REG)
  2185. READ_AND_CONFIG_MP(8188e, _phy_reg);
  2186. else if (config_type == CONFIG_BB_AGC_TAB)
  2187. READ_AND_CONFIG_MP(8188e, _agc_tab);
  2188. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2189. READ_AND_CONFIG_MP(8188e, _phy_reg_pg);
  2190. }
  2191. #endif
  2192. #if (RTL8723B_SUPPORT == 1)
  2193. if (p_dm_odm->support_ic_type == ODM_RTL8723B) {
  2194. if (config_type == CONFIG_BB_PHY_REG)
  2195. READ_AND_CONFIG_MP(8723b, _phy_reg);
  2196. else if (config_type == CONFIG_BB_AGC_TAB)
  2197. READ_AND_CONFIG_MP(8723b, _agc_tab);
  2198. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2199. READ_AND_CONFIG_MP(8723b, _phy_reg_pg);
  2200. }
  2201. #endif
  2202. #if (RTL8814A_SUPPORT == 1)
  2203. if (p_dm_odm->support_ic_type == ODM_RTL8814A) {
  2204. if (config_type == CONFIG_BB_PHY_REG)
  2205. READ_AND_CONFIG_MP(8814a, _phy_reg);
  2206. else if (config_type == CONFIG_BB_AGC_TAB)
  2207. READ_AND_CONFIG_MP(8814a, _agc_tab);
  2208. else if (config_type == CONFIG_BB_PHY_REG_PG) {
  2209. if (p_dm_odm->rfe_type == 0)
  2210. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type0);
  2211. else if (p_dm_odm->rfe_type == 2)
  2212. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type2);
  2213. else if (p_dm_odm->rfe_type == 3)
  2214. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type3);
  2215. else if (p_dm_odm->rfe_type == 4)
  2216. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type4);
  2217. else if (p_dm_odm->rfe_type == 5)
  2218. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type5);
  2219. else if (p_dm_odm->rfe_type == 7)
  2220. READ_AND_CONFIG_MP(8814a,_phy_reg_pg_type7);
  2221. else
  2222. READ_AND_CONFIG_MP(8814a,_phy_reg_pg);
  2223. }
  2224. else if (config_type == CONFIG_BB_PHY_REG_MP)
  2225. READ_AND_CONFIG_MP(8814a, _phy_reg_mp);
  2226. }
  2227. #endif
  2228. #if (RTL8703B_SUPPORT == 1)
  2229. if (p_dm_odm->support_ic_type == ODM_RTL8703B) {
  2230. if (config_type == CONFIG_BB_PHY_REG)
  2231. READ_AND_CONFIG_MP(8703b, _phy_reg);
  2232. else if (config_type == CONFIG_BB_AGC_TAB)
  2233. READ_AND_CONFIG_MP(8703b, _agc_tab);
  2234. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2235. READ_AND_CONFIG_MP(8703b, _phy_reg_pg);
  2236. }
  2237. #endif
  2238. #if (RTL8188F_SUPPORT == 1)
  2239. if (p_dm_odm->support_ic_type == ODM_RTL8188F) {
  2240. if (config_type == CONFIG_BB_PHY_REG)
  2241. READ_AND_CONFIG_MP(8188f, _phy_reg);
  2242. else if (config_type == CONFIG_BB_AGC_TAB)
  2243. READ_AND_CONFIG_MP(8188f, _agc_tab);
  2244. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2245. READ_AND_CONFIG_MP(8188f, _phy_reg_pg);
  2246. }
  2247. #endif
  2248. #if (RTL8822B_SUPPORT == 1)
  2249. if (p_dm_odm->support_ic_type == ODM_RTL8822B) {
  2250. if (config_type == CONFIG_BB_PHY_REG)
  2251. {
  2252. READ_AND_CONFIG_MP(8822b, _phy_reg);
  2253. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2254. if(p_dm_odm->halmac_ability & ODM_PHY_PARAM_OFFLOAD)
  2255. {
  2256. RT_STATUS status = RT_STATUS_SUCCESS;
  2257. status = HAL_MAC_Config_PHY_WriteNByte(&GET_HAL_MAC_INFO(p_dm_odm->adapter),
  2258. HALMAC_PARAMETER_CMD_END,
  2259. 0,
  2260. 0,
  2261. FALSE,
  2262. 0,
  2263. TRUE,
  2264. 0,
  2265. 0);
  2266. if(status != RT_STATUS_SUCCESS)
  2267. ret = HAL_STATUS_FAILURE;
  2268. RT_TRACE(COMP_INIT, DBG_LOUD, ("BB PHY REG param. offload status = %x\n",status));
  2269. }
  2270. #endif
  2271. }
  2272. else if (config_type == CONFIG_BB_AGC_TAB)
  2273. {
  2274. READ_AND_CONFIG_MP(8822b, _agc_tab);
  2275. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2276. if(p_dm_odm->halmac_ability & ODM_PHY_PARAM_OFFLOAD)
  2277. {
  2278. RT_STATUS status = RT_STATUS_SUCCESS;
  2279. status = HAL_MAC_Config_PHY_WriteNByte(&GET_HAL_MAC_INFO(p_dm_odm->adapter),
  2280. HALMAC_PARAMETER_CMD_END,
  2281. 0,
  2282. 0,
  2283. FALSE,
  2284. 0,
  2285. TRUE,
  2286. 0,
  2287. 0);
  2288. if(status != RT_STATUS_SUCCESS)
  2289. ret = HAL_STATUS_FAILURE;
  2290. RT_TRACE(COMP_INIT, DBG_LOUD, ("BB AGC TABLE param. offload status = %x\n",status));
  2291. }
  2292. #endif
  2293. }
  2294. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2295. READ_AND_CONFIG_MP(8822b, _phy_reg_pg);
  2296. /*else if (config_type == CONFIG_BB_PHY_REG_MP)*/
  2297. /*READ_AND_CONFIG_MP(8822b, _phy_reg_mp);*/
  2298. }
  2299. #endif
  2300. #if (RTL8197F_SUPPORT == 1)
  2301. if (p_dm_odm->support_ic_type == ODM_RTL8197F) {
  2302. if (config_type == CONFIG_BB_PHY_REG) {
  2303. READ_AND_CONFIG_MP(8197f, _phy_reg);
  2304. if (p_dm_odm->cut_version == ODM_CUT_A)
  2305. phydm_phypara_a_cut(p_dm_odm);
  2306. } else if (config_type == CONFIG_BB_AGC_TAB)
  2307. READ_AND_CONFIG_MP(8197f, _agc_tab);
  2308. /* else if(config_type == CONFIG_BB_PHY_REG_PG)
  2309. READ_AND_CONFIG_MP(8197f, _phy_reg_pg);
  2310. else if(config_type == CONFIG_BB_PHY_REG_MP)
  2311. READ_AND_CONFIG_MP(8197f, _phy_reg_mp); */
  2312. }
  2313. #endif
  2314. #if (RTL8821C_SUPPORT == 1)
  2315. if (p_dm_odm->support_ic_type == ODM_RTL8821C) {
  2316. if (config_type == CONFIG_BB_PHY_REG)
  2317. READ_AND_CONFIG(8821c, _phy_reg);
  2318. else if (config_type == CONFIG_BB_AGC_TAB) {
  2319. READ_AND_CONFIG(8821c, _agc_tab);
  2320. /* According to RFEtype, choosing correct AGC table*/
  2321. if (p_dm_odm->default_rf_set_8821c == SWITCH_TO_BTG)
  2322. AGC_DIFF_CONFIG_MP(8821c, btg);
  2323. } else if (config_type == CONFIG_BB_PHY_REG_PG)
  2324. READ_AND_CONFIG(8821c, _phy_reg_pg);
  2325. else if (config_type == CONFIG_BB_AGC_TAB_DIFF) {
  2326. if (p_dm_odm->current_rf_set_8821c == SWITCH_TO_BTG)
  2327. AGC_DIFF_CONFIG_MP(8821c, btg);
  2328. else if (p_dm_odm->current_rf_set_8821c == SWITCH_TO_WLG)
  2329. AGC_DIFF_CONFIG_MP(8821c, wlg);
  2330. }
  2331. }
  2332. #endif
  2333. #if (RTL8195A_SUPPORT == 1)
  2334. if (p_dm_odm->support_ic_type == ODM_RTL8195A) {
  2335. if (config_type == CONFIG_BB_PHY_REG)
  2336. READ_AND_CONFIG(8195a, _phy_reg);
  2337. else if (config_type == CONFIG_BB_AGC_TAB)
  2338. READ_AND_CONFIG(8195a, _agc_tab);
  2339. else if (config_type == CONFIG_BB_PHY_REG_PG)
  2340. READ_AND_CONFIG(8195a, _phy_reg_pg);
  2341. }
  2342. #endif
  2343. return ret;
  2344. }
  2345. enum hal_status
  2346. odm_config_mac_with_header_file(
  2347. struct PHY_DM_STRUCT *p_dm_odm
  2348. )
  2349. {
  2350. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2351. struct _ADAPTER *adapter = p_dm_odm->adapter;
  2352. #endif
  2353. enum hal_status ret = HAL_STATUS_SUCCESS;
  2354. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  2355. ("===>odm_config_mac_with_header_file (%s)\n", (p_dm_odm->is_mp_chip) ? "MPChip" : "TestChip"));
  2356. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD,
  2357. ("p_dm_odm->support_platform: 0x%X, p_dm_odm->support_interface: 0x%X, p_dm_odm->board_type: 0x%X\n",
  2358. p_dm_odm->support_platform, p_dm_odm->support_interface, p_dm_odm->board_type));
  2359. /* 1 AP doesn't use PHYDM initialization in these ICs */
  2360. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  2361. #if (RTL8812A_SUPPORT == 1)
  2362. if (p_dm_odm->support_ic_type == ODM_RTL8812)
  2363. READ_AND_CONFIG_MP(8812a, _mac_reg);
  2364. #endif
  2365. #if (RTL8821A_SUPPORT == 1)
  2366. if (p_dm_odm->support_ic_type == ODM_RTL8821) {
  2367. READ_AND_CONFIG_MP(8821a, _mac_reg);
  2368. ODM_RT_TRACE(p_dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("<===8821_ODM_ConfigMACwithHeaderFile\n"));
  2369. }
  2370. #endif
  2371. #if (RTL8192E_SUPPORT == 1)
  2372. if (p_dm_odm->support_ic_type == ODM_RTL8192E)
  2373. READ_AND_CONFIG_MP(8192e, _mac_reg);
  2374. #endif
  2375. #if (RTL8723D_SUPPORT == 1)
  2376. if (p_dm_odm->support_ic_type == ODM_RTL8723D)
  2377. READ_AND_CONFIG_MP(8723d, _mac_reg);
  2378. #endif
  2379. /* JJ ADD 20161014 */
  2380. #if (RTL8710B_SUPPORT == 1)
  2381. if (p_dm_odm->support_ic_type == ODM_RTL8710B)
  2382. READ_AND_CONFIG_MP(8710b, _mac_reg);
  2383. #endif
  2384. #endif/* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  2385. /* 1 All platforms support */
  2386. #if (RTL8188E_SUPPORT == 1)
  2387. if (p_dm_odm->support_ic_type == ODM_RTL8188E)
  2388. READ_AND_CONFIG_MP(8188e, _mac_reg);
  2389. #endif
  2390. #if (RTL8723B_SUPPORT == 1)
  2391. if (p_dm_odm->support_ic_type == ODM_RTL8723B)
  2392. READ_AND_CONFIG_MP(8723b, _mac_reg);
  2393. #endif
  2394. #if (RTL8814A_SUPPORT == 1)
  2395. if (p_dm_odm->support_ic_type == ODM_RTL8814A)
  2396. READ_AND_CONFIG_MP(8814a, _mac_reg);
  2397. #endif
  2398. #if (RTL8703B_SUPPORT == 1)
  2399. if (p_dm_odm->support_ic_type == ODM_RTL8703B)
  2400. READ_AND_CONFIG_MP(8703b, _mac_reg);
  2401. #endif
  2402. #if (RTL8188F_SUPPORT == 1)
  2403. if (p_dm_odm->support_ic_type == ODM_RTL8188F)
  2404. READ_AND_CONFIG_MP(8188f, _mac_reg);
  2405. #endif
  2406. #if (RTL8822B_SUPPORT == 1)
  2407. if (p_dm_odm->support_ic_type == ODM_RTL8822B)
  2408. {
  2409. READ_AND_CONFIG_MP(8822b, _mac_reg);
  2410. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  2411. if(p_dm_odm->halmac_ability & ODM_PHY_PARAM_OFFLOAD)
  2412. {
  2413. RT_STATUS status = RT_STATUS_SUCCESS;
  2414. status = HAL_MAC_Config_PHY_WriteNByte(&GET_HAL_MAC_INFO(p_dm_odm->adapter),
  2415. HALMAC_PARAMETER_CMD_END,
  2416. 0,
  2417. 0,
  2418. FALSE,
  2419. 0,
  2420. TRUE,
  2421. 0,
  2422. 0);
  2423. if(status != RT_STATUS_SUCCESS)
  2424. ret = HAL_STATUS_FAILURE;
  2425. RT_TRACE(COMP_INIT, DBG_LOUD, ("MAC param. offload status = %x\n",status));
  2426. }
  2427. #endif
  2428. }
  2429. #endif
  2430. #if (RTL8197F_SUPPORT == 1)
  2431. if (p_dm_odm->support_ic_type == ODM_RTL8197F)
  2432. READ_AND_CONFIG_MP(8197f, _mac_reg);
  2433. #endif
  2434. #if (RTL8821C_SUPPORT == 1)
  2435. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  2436. READ_AND_CONFIG(8821c, _mac_reg);
  2437. #endif
  2438. #if (RTL8195A_SUPPORT == 1)
  2439. if (p_dm_odm->support_ic_type == ODM_RTL8195A)
  2440. READ_AND_CONFIG_MP(8195a, _mac_reg);
  2441. #endif
  2442. return ret;
  2443. }
  2444. enum hal_status
  2445. odm_config_fw_with_header_file(
  2446. struct PHY_DM_STRUCT *p_dm_odm,
  2447. enum odm_fw_config_type config_type,
  2448. u8 *p_firmware,
  2449. u32 *p_size
  2450. )
  2451. {
  2452. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  2453. #if (RTL8188E_SUPPORT == 1)
  2454. if (p_dm_odm->support_ic_type == ODM_RTL8188E) {
  2455. #ifdef CONFIG_SFW_SUPPORTED
  2456. if (config_type == CONFIG_FW_NIC)
  2457. READ_FIRMWARE_MP(8188e_t, _fw_nic);
  2458. else if (config_type == CONFIG_FW_WOWLAN)
  2459. READ_FIRMWARE_MP(8188e_t, _fw_wowlan);
  2460. else if (config_type == CONFIG_FW_NIC_2)
  2461. READ_FIRMWARE_MP(8188e_s, _fw_nic);
  2462. else if (config_type == CONFIG_FW_WOWLAN_2)
  2463. READ_FIRMWARE_MP(8188e_s, _fw_wowlan);
  2464. #ifdef CONFIG_AP_WOWLAN
  2465. if (config_type == CONFIG_FW_AP)
  2466. READ_FIRMWARE_MP(8188e_t, _fw_ap);
  2467. else if (config_type == CONFIG_FW_AP_2)
  2468. READ_FIRMWARE_MP(8188e_s, _fw_ap);
  2469. #endif /* CONFIG_AP_WOWLAN */
  2470. #else
  2471. if (config_type == CONFIG_FW_NIC)
  2472. READ_FIRMWARE_MP(8188e_t, _fw_nic);
  2473. else if (config_type == CONFIG_FW_WOWLAN)
  2474. READ_FIRMWARE_MP(8188e_t, _fw_wowlan);
  2475. #ifdef CONFIG_AP_WOWLAN
  2476. else if (config_type == CONFIG_FW_AP)
  2477. READ_FIRMWARE_MP(8188e_t, _fw_ap);
  2478. #endif /* CONFIG_AP_WOWLAN */
  2479. #endif
  2480. }
  2481. #endif
  2482. #if (RTL8723B_SUPPORT == 1)
  2483. if (p_dm_odm->support_ic_type == ODM_RTL8723B) {
  2484. if (config_type == CONFIG_FW_NIC)
  2485. READ_FIRMWARE_MP(8723b, _fw_nic);
  2486. else if (config_type == CONFIG_FW_WOWLAN)
  2487. READ_FIRMWARE_MP(8723b, _fw_wowlan);
  2488. #ifdef CONFIG_AP_WOWLAN
  2489. else if (config_type == config_fw_ap_wowlan)
  2490. READ_FIRMWARE(8723b, _fw_ap);
  2491. #endif
  2492. }
  2493. #endif /* #if (RTL8723B_SUPPORT == 1) */
  2494. #if (RTL8812A_SUPPORT == 1)
  2495. if (p_dm_odm->support_ic_type == ODM_RTL8812) {
  2496. if (config_type == CONFIG_FW_NIC)
  2497. READ_FIRMWARE_MP(8812a, _fw_nic);
  2498. else if (config_type == CONFIG_FW_WOWLAN)
  2499. READ_FIRMWARE_MP(8812a, _fw_wowlan);
  2500. else if (config_type == CONFIG_FW_BT)
  2501. READ_FIRMWARE_MP(8812a, _fw_nic_bt);
  2502. #ifdef CONFIG_AP_WOWLAN
  2503. else if (config_type == config_fw_ap_wowlan)
  2504. READ_FIRMWARE(8812a, _fw_ap);
  2505. #endif
  2506. }
  2507. #endif
  2508. #if (RTL8821A_SUPPORT == 1)
  2509. if (p_dm_odm->support_ic_type == ODM_RTL8821) {
  2510. if (config_type == CONFIG_FW_NIC)
  2511. READ_FIRMWARE_MP(8821a, _fw_nic);
  2512. else if (config_type == CONFIG_FW_WOWLAN)
  2513. READ_FIRMWARE_MP(8821a, _fw_wowlan);
  2514. #ifdef CONFIG_AP_WOWLAN
  2515. else if (config_type == config_fw_ap_wowlan)
  2516. READ_FIRMWARE_MP(8821a, _fw_ap);
  2517. #endif /*CONFIG_AP_WOWLAN*/
  2518. else if (config_type == CONFIG_FW_BT)
  2519. READ_FIRMWARE_MP(8821a, _fw_nic_bt);
  2520. }
  2521. #endif
  2522. #if (RTL8192E_SUPPORT == 1)
  2523. if (p_dm_odm->support_ic_type == ODM_RTL8192E) {
  2524. if (config_type == CONFIG_FW_NIC)
  2525. READ_FIRMWARE_MP(8192e, _fw_nic);
  2526. else if (config_type == CONFIG_FW_WOWLAN)
  2527. READ_FIRMWARE_MP(8192e, _fw_wowlan);
  2528. #ifdef CONFIG_AP_WOWLAN
  2529. else if (config_type == config_fw_ap_wowlan)
  2530. READ_FIRMWARE_MP(8192e, _fw_ap);
  2531. #endif
  2532. }
  2533. #endif
  2534. #if (RTL8723D_SUPPORT == 1)
  2535. if (p_dm_odm->support_ic_type == ODM_RTL8723D) {
  2536. if (config_type == CONFIG_FW_NIC)
  2537. READ_FIRMWARE_MP(8723d, _fw_nic);
  2538. else if (config_type == CONFIG_FW_WOWLAN) {
  2539. READ_FIRMWARE_MP(8723d, _fw_wowlan);
  2540. #ifdef CONFIG_AP_WOWLAN
  2541. else if (config_type == config_fw_ap_wowlan)
  2542. READ_FIRMWARE_MP(8723d, _fw_ap);
  2543. #endif
  2544. }
  2545. }
  2546. #endif
  2547. /* JJ ADD 20161014 */
  2548. #if (RTL8710B_SUPPORT == 1)
  2549. if (p_dm_odm->support_ic_type == ODM_RTL8710B) {
  2550. if (config_type == CONFIG_FW_NIC)
  2551. READ_FIRMWARE_MP(8710b, _fw_nic);
  2552. else if (config_type == CONFIG_FW_WOWLAN) {
  2553. READ_FIRMWARE_MP(8710b, _fw_wowlan);
  2554. #ifdef CONFIG_AP_WOWLAN
  2555. else if (config_type == config_fw_ap_wowlan)
  2556. READ_FIRMWARE_MP(8710b, _fw_ap);
  2557. #endif
  2558. }
  2559. }
  2560. #endif
  2561. /*#if (RTL8814A_SUPPORT == 1)
  2562. if (p_dm_odm->support_ic_type == ODM_RTL8814A)
  2563. {
  2564. if (config_type == CONFIG_FW_NIC)
  2565. READ_FIRMWARE_MP(8814a, _fw_nic);
  2566. else if (config_type == config_fw_wowlan)
  2567. READ_FIRMWARE_MP(8814a, _fw_wowlan);
  2568. #ifdef CONFIG_AP_WOWLAN
  2569. else if (config_type == config_fw_ap_wowlan)
  2570. READ_FIRMWARE_MP(8814a, _fw_ap);
  2571. #endif
  2572. }
  2573. #endif */
  2574. #if (RTL8814A_SUPPORT == 1)
  2575. if (p_dm_odm->support_ic_type == ODM_RTL8814A) {
  2576. if (config_type == CONFIG_FW_NIC)
  2577. READ_FIRMWARE_MP(8814a, _fw_nic);
  2578. #ifdef CONFIG_AP_WOWLAN
  2579. else if (config_type == config_fw_ap_wowlan)
  2580. READ_FIRMWARE_MP(8814a, _fw_ap);
  2581. #endif
  2582. }
  2583. #endif
  2584. #if (RTL8703B_SUPPORT == 1)
  2585. if (p_dm_odm->support_ic_type == ODM_RTL8703B) {
  2586. if (config_type == CONFIG_FW_NIC)
  2587. READ_FIRMWARE_MP(8703b, _fw_nic);
  2588. else if (config_type == CONFIG_FW_WOWLAN)
  2589. READ_FIRMWARE_MP(8703b, _fw_wowlan);
  2590. #ifdef CONFIG_AP_WOWLAN
  2591. else if (config_type == config_fw_ap_wowlan)
  2592. READ_FIRMWARE(8703b, _fw_ap);
  2593. #endif
  2594. }
  2595. #endif
  2596. #if (RTL8188F_SUPPORT == 1)
  2597. if (p_dm_odm->support_ic_type == ODM_RTL8188F) {
  2598. if (config_type == CONFIG_FW_NIC)
  2599. READ_FIRMWARE_MP(8188f, _fw_nic);
  2600. else if (config_type == CONFIG_FW_WOWLAN)
  2601. READ_FIRMWARE_MP(8188f, _fw_wowlan);
  2602. #ifdef CONFIG_AP_WOWLAN
  2603. else if (config_type == CONFIG_FW_AP)
  2604. READ_FIRMWARE_MP(8188f, _fw_ap);
  2605. #endif
  2606. }
  2607. #endif
  2608. #if (RTL8822B_SUPPORT == 1)
  2609. if (p_dm_odm->support_ic_type == ODM_RTL8822B) {
  2610. if (config_type == CONFIG_FW_NIC)
  2611. READ_FIRMWARE_MP(8822b, _fw_nic);
  2612. else if (config_type == CONFIG_FW_WOWLAN)
  2613. READ_FIRMWARE_MP(8822b, _fw_wowlan);
  2614. #ifdef CONFIG_AP_WOWLAN
  2615. else if (config_type == config_fw_ap_wowlan)
  2616. READ_FIRMWARE(8822b, _fw_ap);
  2617. #endif
  2618. }
  2619. #endif
  2620. #if (RTL8197F_SUPPORT == 1)
  2621. if (p_dm_odm->support_ic_type == ODM_RTL8197F) {
  2622. if (config_type == CONFIG_FW_NIC)
  2623. READ_FIRMWARE_MP(8197f, _fw_nic);
  2624. #ifdef CONFIG_AP_WOWLAN
  2625. else if (config_type == config_fw_ap_wowlan)
  2626. READ_FIRMWARE(8197f, _fw_ap);
  2627. #endif
  2628. }
  2629. #endif
  2630. #if ((DM_ODM_SUPPORT_TYPE == ODM_WIN))
  2631. #if (RTL8821C_SUPPORT == 1)
  2632. if (p_dm_odm->support_ic_type == ODM_RTL8821C) {
  2633. if (config_type == CONFIG_FW_NIC)
  2634. READ_FIRMWARE_MP(8821c, _fw_nic);
  2635. else if (config_type == CONFIG_FW_WOWLAN)
  2636. READ_FIRMWARE_MP(8821c, _fw_wowlan);
  2637. #ifdef CONFIG_AP_WOWLAN
  2638. else if (config_type == config_fw_ap_wowlan)
  2639. READ_FIRMWARE_MP(8821c, _fw_ap);
  2640. #endif /*CONFIG_AP_WOWLAN*/
  2641. }
  2642. #endif
  2643. #endif
  2644. #endif/* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  2645. return HAL_STATUS_SUCCESS;
  2646. }
  2647. u32
  2648. odm_get_hw_img_version(
  2649. struct PHY_DM_STRUCT *p_dm_odm
  2650. )
  2651. {
  2652. u32 version = 0;
  2653. /* 1 AP doesn't use PHYDM initialization in these ICs */
  2654. #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
  2655. #if (RTL8821A_SUPPORT == 1)
  2656. if (p_dm_odm->support_ic_type == ODM_RTL8821)
  2657. version = GET_VERSION_MP(8821a, _mac_reg);
  2658. #endif
  2659. #if (RTL8192E_SUPPORT == 1)
  2660. if (p_dm_odm->support_ic_type == ODM_RTL8192E)
  2661. version = GET_VERSION_MP(8192e, _mac_reg);
  2662. #endif
  2663. #if (RTL8812A_SUPPORT == 1)
  2664. if (p_dm_odm->support_ic_type == ODM_RTL8812)
  2665. version = GET_VERSION_MP(8812a, _mac_reg);
  2666. #endif
  2667. #if (RTL8723D_SUPPORT == 1)
  2668. if (p_dm_odm->support_ic_type == ODM_RTL8723D)
  2669. version = GET_VERSION_MP(8723d, _mac_reg);
  2670. #endif
  2671. /* JJ ADD 20161014 */
  2672. #if (RTL8710B_SUPPORT == 1)
  2673. if (p_dm_odm->support_ic_type == ODM_RTL8710B)
  2674. version = GET_VERSION_MP(8710b, _mac_reg);
  2675. #endif
  2676. #endif /* (DM_ODM_SUPPORT_TYPE != ODM_AP) */
  2677. /*1 All platforms support*/
  2678. #if (RTL8188E_SUPPORT == 1)
  2679. if (p_dm_odm->support_ic_type == ODM_RTL8188E)
  2680. version = GET_VERSION_MP(8188e, _mac_reg);
  2681. #endif
  2682. #if (RTL8723B_SUPPORT == 1)
  2683. if (p_dm_odm->support_ic_type == ODM_RTL8723B)
  2684. version = GET_VERSION_MP(8723b, _mac_reg);
  2685. #endif
  2686. #if (RTL8814A_SUPPORT == 1)
  2687. if (p_dm_odm->support_ic_type == ODM_RTL8814A)
  2688. version = GET_VERSION_MP(8814a, _mac_reg);
  2689. #endif
  2690. #if (RTL8703B_SUPPORT == 1)
  2691. if (p_dm_odm->support_ic_type == ODM_RTL8703B)
  2692. version = GET_VERSION_MP(8703b, _mac_reg);
  2693. #endif
  2694. #if (RTL8188F_SUPPORT == 1)
  2695. if (p_dm_odm->support_ic_type == ODM_RTL8188F)
  2696. version = GET_VERSION_MP(8188f, _mac_reg);
  2697. #endif
  2698. #if (RTL8822B_SUPPORT == 1)
  2699. if (p_dm_odm->support_ic_type == ODM_RTL8822B)
  2700. version = GET_VERSION_MP(8822b, _mac_reg);
  2701. #endif
  2702. #if (RTL8197F_SUPPORT == 1)
  2703. if (p_dm_odm->support_ic_type == ODM_RTL8197F)
  2704. version = GET_VERSION_MP(8197f, _mac_reg);
  2705. #endif
  2706. #if (RTL8821C_SUPPORT == 1)
  2707. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  2708. version = GET_VERSION(8821c, _mac_reg);
  2709. #endif
  2710. return version;
  2711. }
  2712. #if (ODM_PHY_STATUS_NEW_TYPE_SUPPORT == 1)
  2713. /* For 8822B only!! need to move to FW finally */
  2714. /*==============================================*/
  2715. boolean
  2716. phydm_query_is_mu_api(
  2717. struct PHY_DM_STRUCT *p_phydm,
  2718. u8 ppdu_idx,
  2719. u8 *p_data_rate,
  2720. u8 *p_gid
  2721. )
  2722. {
  2723. u8 data_rate = 0, gid = 0;
  2724. boolean is_mu = FALSE;
  2725. data_rate = p_phydm->phy_dbg_info.num_of_ppdu[ppdu_idx];
  2726. gid = p_phydm->phy_dbg_info.gid_num[ppdu_idx];
  2727. if (data_rate & BIT(7)) {
  2728. is_mu = TRUE;
  2729. data_rate = data_rate & ~(BIT(7));
  2730. } else
  2731. is_mu = FALSE;
  2732. *p_data_rate = data_rate;
  2733. *p_gid = gid;
  2734. return is_mu;
  2735. }
  2736. VOID
  2737. phydm_rx_statistic_cal(
  2738. struct PHY_DM_STRUCT *p_phydm,
  2739. u8 *p_phy_status,
  2740. struct _odm_per_pkt_info_ *p_pktinfo
  2741. )
  2742. {
  2743. struct _phy_status_rpt_jaguar2_type1 *p_phy_sta_rpt = (struct _phy_status_rpt_jaguar2_type1 *)p_phy_status;
  2744. u8 date_rate = p_pktinfo->data_rate & ~(BIT(7));
  2745. if ((p_phy_sta_rpt->gid != 0) && (p_phy_sta_rpt->gid != 63)) {
  2746. if (date_rate >= ODM_RATEVHTSS1MCS0) {
  2747. p_phydm->phy_dbg_info.num_qry_mu_vht_pkt[date_rate - 0x2C]++;
  2748. if (p_pktinfo->ppdu_cnt < 4) {
  2749. p_phydm->phy_dbg_info.num_of_ppdu[p_pktinfo->ppdu_cnt] = date_rate | BIT(7);
  2750. p_phydm->phy_dbg_info.gid_num[p_pktinfo->ppdu_cnt] = p_phy_sta_rpt->gid;
  2751. }
  2752. }
  2753. } else {
  2754. if (date_rate >= ODM_RATEVHTSS1MCS0) {
  2755. p_phydm->phy_dbg_info.num_qry_vht_pkt[date_rate - 0x2C]++;
  2756. if (p_pktinfo->ppdu_cnt < 4) {
  2757. p_phydm->phy_dbg_info.num_of_ppdu[p_pktinfo->ppdu_cnt] = date_rate;
  2758. p_phydm->phy_dbg_info.gid_num[p_pktinfo->ppdu_cnt] = p_phy_sta_rpt->gid;
  2759. }
  2760. }
  2761. }
  2762. }
  2763. void
  2764. phydm_reset_phy_info(
  2765. struct PHY_DM_STRUCT *p_phydm,
  2766. struct _odm_phy_status_info_ *p_phy_info
  2767. )
  2768. {
  2769. p_phy_info->rx_pwdb_all = 0;
  2770. p_phy_info->signal_quality = 0;
  2771. p_phy_info->band_width = 0;
  2772. p_phy_info->rx_count = 0;
  2773. odm_memory_set(p_phydm, p_phy_info->rx_mimo_signal_quality, 0, 4);
  2774. odm_memory_set(p_phydm, p_phy_info->rx_mimo_signal_strength, 0, 4);
  2775. odm_memory_set(p_phydm, p_phy_info->rx_snr, 0, 4);
  2776. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  2777. p_phy_info->rx_power = -110;
  2778. p_phy_info->recv_signal_power = -110;
  2779. p_phy_info->bt_rx_rssi_percentage = 0;
  2780. p_phy_info->signal_strength = 0;
  2781. p_phy_info->bt_coex_pwr_adjust = 0;
  2782. p_phy_info->channel = 0;
  2783. p_phy_info->is_mu_packet = 0;
  2784. p_phy_info->is_beamformed = 0;
  2785. p_phy_info->rxsc = 0;
  2786. odm_memory_set(p_phydm, p_phy_info->rx_pwr, -110, 4);
  2787. /*odm_memory_set(p_phydm, p_phy_info->rx_mimo_evm_dbm, 0, 4);*/
  2788. odm_memory_set(p_phydm, p_phy_info->cfo_short, 0, 8);
  2789. odm_memory_set(p_phydm, p_phy_info->cfo_tail, 0, 8);
  2790. #endif
  2791. odm_memory_set(p_phydm, p_phy_info->rx_mimo_evm_dbm, 0, 4);
  2792. }
  2793. void
  2794. phydm_set_per_path_phy_info(
  2795. u8 rx_path,
  2796. s8 rx_pwr,
  2797. s8 rx_evm,
  2798. s8 cfo_tail,
  2799. s8 rx_snr,
  2800. struct _odm_phy_status_info_ *p_phy_info
  2801. )
  2802. {
  2803. u8 evm_dbm = 0;
  2804. u8 evm_percentage = 0;
  2805. /* SNR is S(8,1), EVM is S(8,1), CFO is S(8,7) */
  2806. if (rx_evm < 0) {
  2807. /* Calculate EVM in dBm */
  2808. evm_dbm = ((u8)(0 - rx_evm) >> 1);
  2809. /* Calculate EVM in percentage */
  2810. if (evm_dbm >= 34)
  2811. evm_percentage = 100;
  2812. else
  2813. evm_percentage = (evm_dbm << 1) + (evm_dbm);
  2814. }
  2815. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  2816. p_phy_info->rx_pwr[rx_path] = rx_pwr;
  2817. /*p_phy_info->rx_mimo_evm_dbm[rx_path] = evm_dbm;*/
  2818. /* CFO = CFO_tail * 312.5 / 2^7 ~= CFO tail * 39/512 (kHz)*/
  2819. p_phy_info->cfo_tail[rx_path] = cfo_tail;
  2820. p_phy_info->cfo_tail[rx_path] = ((p_phy_info->cfo_tail[rx_path] << 5) + (p_phy_info->cfo_tail[rx_path] << 2) +
  2821. (p_phy_info->cfo_tail[rx_path] << 1) + (p_phy_info->cfo_tail[rx_path])) >> 9;
  2822. #endif
  2823. if (evm_dbm == 64)
  2824. evm_dbm = 0; /*if 1SS rate, evm_dbm [2nd stream] =64*/
  2825. p_phy_info->rx_mimo_evm_dbm[rx_path] = evm_dbm;
  2826. p_phy_info->rx_mimo_signal_strength[rx_path] = odm_query_rx_pwr_percentage(rx_pwr);
  2827. p_phy_info->rx_mimo_signal_quality[rx_path] = evm_percentage;
  2828. p_phy_info->rx_snr[rx_path] = rx_snr >> 1;
  2829. #if 0
  2830. /* if (p_pktinfo->is_packet_match_bssid) */
  2831. {
  2832. dbg_print("path (%d)--------\n", rx_path);
  2833. dbg_print("rx_pwr = %d, Signal strength = %d\n", p_phy_info->rx_pwr[rx_path], p_phy_info->rx_mimo_signal_strength[rx_path]);
  2834. dbg_print("evm_dbm = %d, Signal quality = %d\n", p_phy_info->rx_mimo_evm_dbm[rx_path], p_phy_info->rx_mimo_signal_quality[rx_path]);
  2835. dbg_print("CFO = %d, SNR = %d\n", p_phy_info->cfo_tail[rx_path], p_phy_info->rx_snr[rx_path]);
  2836. }
  2837. #endif
  2838. }
  2839. void
  2840. phydm_set_common_phy_info(
  2841. s8 rx_power,
  2842. u8 channel,
  2843. boolean is_beamformed,
  2844. boolean is_mu_packet,
  2845. u8 bandwidth,
  2846. u8 signal_quality,
  2847. u8 rxsc,
  2848. struct _odm_phy_status_info_ *p_phy_info
  2849. )
  2850. {
  2851. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
  2852. p_phy_info->rx_power = rx_power; /* RSSI in dB */
  2853. p_phy_info->recv_signal_power = rx_power; /* RSSI in dB */
  2854. p_phy_info->channel = channel; /* channel number */
  2855. p_phy_info->is_beamformed = is_beamformed; /* apply BF */
  2856. p_phy_info->is_mu_packet = is_mu_packet; /* MU packet */
  2857. p_phy_info->rxsc = rxsc;
  2858. #endif
  2859. p_phy_info->rx_pwdb_all = odm_query_rx_pwr_percentage(rx_power); /* RSSI in percentage */
  2860. p_phy_info->signal_quality = signal_quality; /* signal quality */
  2861. p_phy_info->band_width = bandwidth; /* bandwidth */
  2862. #if 0
  2863. /* if (p_pktinfo->is_packet_match_bssid) */
  2864. {
  2865. dbg_print("rx_pwdb_all = %d, rx_power = %d, recv_signal_power = %d\n", p_phy_info->rx_pwdb_all, p_phy_info->rx_power, p_phy_info->recv_signal_power);
  2866. dbg_print("signal_quality = %d\n", p_phy_info->signal_quality);
  2867. dbg_print("is_beamformed = %d, is_mu_packet = %d, rx_count = %d\n", p_phy_info->is_beamformed, p_phy_info->is_mu_packet, p_phy_info->rx_count + 1);
  2868. dbg_print("channel = %d, rxsc = %d, band_width = %d\n", channel, rxsc, bandwidth);
  2869. }
  2870. #endif
  2871. }
  2872. void
  2873. phydm_get_rx_phy_status_type0(
  2874. struct PHY_DM_STRUCT *p_dm_odm,
  2875. u8 *p_phy_status,
  2876. struct _odm_per_pkt_info_ *p_pktinfo,
  2877. struct _odm_phy_status_info_ *p_phy_info
  2878. )
  2879. {
  2880. /* type 0 is used for cck packet */
  2881. struct _phy_status_rpt_jaguar2_type0 *p_phy_sta_rpt = (struct _phy_status_rpt_jaguar2_type0 *)p_phy_status;
  2882. u8 i, SQ = 0;
  2883. s8 rx_power = p_phy_sta_rpt->pwdb - 110;
  2884. #if (RTL8723D_SUPPORT == 1)
  2885. if (p_dm_odm->support_ic_type & ODM_RTL8723D)
  2886. rx_power = p_phy_sta_rpt->pwdb - 97;
  2887. #endif
  2888. /* RTL8710B do not need recalculate the offset By James Liao@20170527 */
  2889. #if (RTL8710B_SUPPORT == 1)
  2890. //if (p_dm_odm->support_ic_type & ODM_RTL8710B)
  2891. //rx_power = p_phy_sta_rpt->pwdb - 97;
  2892. #endif
  2893. #if (RTL8821C_SUPPORT == 1)
  2894. if (p_dm_odm->support_ic_type & ODM_RTL8821C) {
  2895. if (p_phy_sta_rpt->pwdb >= -57)
  2896. rx_power = p_phy_sta_rpt->pwdb - 100;
  2897. else
  2898. rx_power = p_phy_sta_rpt->pwdb - 102;
  2899. }
  2900. #endif
  2901. /* Calculate Signal Quality*/
  2902. if (p_pktinfo->is_packet_match_bssid) {
  2903. if (p_phy_sta_rpt->signal_quality >= 64)
  2904. SQ = 0;
  2905. else if (p_phy_sta_rpt->signal_quality <= 20)
  2906. SQ = 100;
  2907. else {
  2908. /* mapping to 2~99% */
  2909. SQ = 64 - p_phy_sta_rpt->signal_quality;
  2910. SQ = ((SQ << 3) + SQ) >> 2;
  2911. }
  2912. }
  2913. /* Modify CCK PWDB if old AGC */
  2914. if (p_dm_odm->cck_new_agc == false) {
  2915. u8 lna_idx, vga_idx;
  2916. #if (RTL8197F_SUPPORT == 1)
  2917. if (p_dm_odm->support_ic_type & ODM_RTL8197F)
  2918. lna_idx = p_phy_sta_rpt->lna_l;
  2919. else
  2920. #endif
  2921. lna_idx = ((p_phy_sta_rpt->lna_h << 3) | p_phy_sta_rpt->lna_l);
  2922. vga_idx = p_phy_sta_rpt->vga;
  2923. #if (RTL8723D_SUPPORT == 1)
  2924. if (p_dm_odm->support_ic_type & ODM_RTL8723D)
  2925. rx_power = odm_cckrssi_8723d(lna_idx, vga_idx);
  2926. #endif
  2927. /* JJ ADD 20161014 */
  2928. #if (RTL8710B_SUPPORT == 1)
  2929. if (p_dm_odm->support_ic_type & ODM_RTL8710B)
  2930. rx_power = odm_cckrssi_8710b(lna_idx, vga_idx);
  2931. #endif
  2932. #if (RTL8822B_SUPPORT == 1)
  2933. /* Need to do !! */
  2934. /*if (p_dm_odm->support_ic_type & ODM_RTL8822B) */
  2935. /*rx_power = odm_CCKRSSI_8822B(LNA_idx, VGA_idx);*/
  2936. #endif
  2937. #if (RTL8197F_SUPPORT == 1)
  2938. if (p_dm_odm->support_ic_type & ODM_RTL8197F)
  2939. rx_power = odm_cckrssi_8197f(p_dm_odm, lna_idx, vga_idx);
  2940. #endif
  2941. }
  2942. /* Update CCK packet counter */
  2943. p_dm_odm->phy_dbg_info.num_qry_phy_status_cck++;
  2944. /*CCK no STBC and LDPC*/
  2945. p_dm_odm->phy_dbg_info.is_ldpc_pkt = false;
  2946. p_dm_odm->phy_dbg_info.is_stbc_pkt = false;
  2947. /* Update Common information */
  2948. phydm_set_common_phy_info(rx_power, p_phy_sta_rpt->channel, false,
  2949. false, ODM_BW20M, SQ, p_phy_sta_rpt->rxsc, p_phy_info);
  2950. /* Update CCK pwdb */
  2951. phydm_set_per_path_phy_info(ODM_RF_PATH_A, rx_power, 0, 0, 0, p_phy_info); /* Update per-path information */
  2952. p_dm_odm->dm_fat_table.antsel_rx_keep_0 = p_phy_sta_rpt->antidx_a;
  2953. p_dm_odm->dm_fat_table.antsel_rx_keep_1 = p_phy_sta_rpt->antidx_b;
  2954. p_dm_odm->dm_fat_table.antsel_rx_keep_2 = p_phy_sta_rpt->antidx_c;
  2955. p_dm_odm->dm_fat_table.antsel_rx_keep_3 = p_phy_sta_rpt->antidx_d;
  2956. #if 0
  2957. /* if (p_pktinfo->is_packet_match_bssid) */
  2958. {
  2959. dbg_print("pwdb = 0x%x, MP gain index = 0x%x, TRSW = 0x%x\n", p_phy_sta_rpt->pwdb, p_phy_sta_rpt->gain, p_phy_sta_rpt->trsw);
  2960. dbg_print("channel = %d, band = %d, rxsc = %d\n", p_phy_sta_rpt->channel, p_phy_sta_rpt->band, p_phy_sta_rpt->rxsc);
  2961. dbg_print("agc_table = 0x%x, agc_rpt 0x%x, bb_power = 0x%x\n", p_phy_sta_rpt->agc_table, p_phy_sta_rpt->agc_rpt, p_phy_sta_rpt->bb_power);
  2962. dbg_print("length = %d, SQ = %d\n", p_phy_sta_rpt->length, p_phy_sta_rpt->signal_quality);
  2963. dbg_print("antidx a = 0x%x, b = 0x%x, c = 0x%x, d = 0x%x\n", p_phy_sta_rpt->antidx_a, p_phy_sta_rpt->antidx_b, p_phy_sta_rpt->antidx_c, p_phy_sta_rpt->antidx_d);
  2964. dbg_print("rsvd_0 = 0x%x, rsvd_1 = 0x%x, rsvd_2 = 0x%x\n", p_phy_sta_rpt->rsvd_0, p_phy_sta_rpt->rsvd_1, p_phy_sta_rpt->rsvd_2);
  2965. dbg_print("rsvd_3 = 0x%x, rsvd_4 = 0x%x, rsvd_5 = 0x%x\n", p_phy_sta_rpt->rsvd_3, p_phy_sta_rpt->rsvd_4, p_phy_sta_rpt->rsvd_5);
  2966. dbg_print("rsvd_6 = 0x%x, rsvd_7 = 0x%x, rsvd_8 = 0x%x\n", p_phy_sta_rpt->rsvd_6, p_phy_sta_rpt->rsvd_7, p_phy_sta_rpt->rsvd_8);
  2967. }
  2968. #endif
  2969. }
  2970. void
  2971. phydm_get_rx_phy_status_type1(
  2972. struct PHY_DM_STRUCT *p_dm_odm,
  2973. u8 *p_phy_status,
  2974. struct _odm_per_pkt_info_ *p_pktinfo,
  2975. struct _odm_phy_status_info_ *p_phy_info
  2976. )
  2977. {
  2978. /* type 1 is used for ofdm packet */
  2979. struct _phy_status_rpt_jaguar2_type1 *p_phy_sta_rpt = (struct _phy_status_rpt_jaguar2_type1 *)p_phy_status;
  2980. s8 rx_pwr_db = -120;
  2981. u8 i, rxsc, bw = ODM_BW20M, rx_count = 0;
  2982. boolean is_mu;
  2983. u8 num_ss;
  2984. /* Update OFDM packet counter */
  2985. p_dm_odm->phy_dbg_info.num_qry_phy_status_ofdm++;
  2986. /* Update per-path information */
  2987. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX_JAGUAR; i++) {
  2988. if (p_dm_odm->rx_ant_status & BIT(i)) {
  2989. s8 rx_path_pwr_db;
  2990. /* RX path counter */
  2991. rx_count++;
  2992. /* Update per-path information (RSSI_dB RSSI_percentage EVM SNR CFO SQ) */
  2993. /* EVM report is reported by stream, not path */
  2994. rx_path_pwr_db = p_phy_sta_rpt->pwdb[i] - 110; /* per-path pwdb in dB domain */
  2995. phydm_set_per_path_phy_info(i, rx_path_pwr_db, p_phy_sta_rpt->rxevm[rx_count - 1],
  2996. p_phy_sta_rpt->cfo_tail[i], p_phy_sta_rpt->rxsnr[i], p_phy_info);
  2997. /* search maximum pwdb */
  2998. if (rx_path_pwr_db > rx_pwr_db)
  2999. rx_pwr_db = rx_path_pwr_db;
  3000. }
  3001. }
  3002. /* mapping RX counter from 1~4 to 0~3 */
  3003. if (rx_count > 0)
  3004. p_phy_info->rx_count = rx_count - 1;
  3005. /* Check if MU packet or not */
  3006. if ((p_phy_sta_rpt->gid != 0) && (p_phy_sta_rpt->gid != 63)) {
  3007. is_mu = true;
  3008. p_dm_odm->phy_dbg_info.num_qry_mu_pkt++;
  3009. } else
  3010. is_mu = false;
  3011. /* count BF packet */
  3012. p_dm_odm->phy_dbg_info.num_qry_bf_pkt = p_dm_odm->phy_dbg_info.num_qry_bf_pkt + p_phy_sta_rpt->beamformed;
  3013. /*STBC or LDPC pkt*/
  3014. p_dm_odm->phy_dbg_info.is_ldpc_pkt = p_phy_sta_rpt->ldpc;
  3015. p_dm_odm->phy_dbg_info.is_stbc_pkt = p_phy_sta_rpt->stbc;
  3016. /* Check sub-channel */
  3017. if ((p_pktinfo->data_rate > ODM_RATE11M) && (p_pktinfo->data_rate < ODM_RATEMCS0))
  3018. rxsc = p_phy_sta_rpt->l_rxsc;
  3019. else
  3020. rxsc = p_phy_sta_rpt->ht_rxsc;
  3021. /* Check RX bandwidth */
  3022. if (p_dm_odm->support_ic_type & ODM_RTL8822B) {
  3023. if ((rxsc >= 1) && (rxsc <= 8))
  3024. bw = ODM_BW20M;
  3025. else if ((rxsc >= 9) && (rxsc <= 12))
  3026. bw = ODM_BW40M;
  3027. else if (rxsc >= 13)
  3028. bw = ODM_BW80M;
  3029. else
  3030. bw = p_phy_sta_rpt->rf_mode;
  3031. } else if (p_dm_odm->support_ic_type & (ODM_RTL8197F | ODM_RTL8723D | ODM_RTL8710B)) {/* JJ ADD 20161014 */
  3032. if (p_phy_sta_rpt->rf_mode == 0)
  3033. bw = ODM_BW20M;
  3034. else if ((rxsc == 1) || (rxsc == 2))
  3035. bw = ODM_BW20M;
  3036. else
  3037. bw = ODM_BW40M;
  3038. }
  3039. /* Update packet information */
  3040. phydm_set_common_phy_info(rx_pwr_db, p_phy_sta_rpt->channel, (boolean)p_phy_sta_rpt->beamformed,
  3041. is_mu, bw, odm_evm_db_to_percentage(p_phy_sta_rpt->rxevm[0]), rxsc, p_phy_info);
  3042. num_ss = phydm_rate_to_num_ss(p_dm_odm, p_pktinfo->data_rate);
  3043. odm_parsing_cfo(p_dm_odm, p_pktinfo, p_phy_sta_rpt->cfo_tail, num_ss);
  3044. p_dm_odm->dm_fat_table.antsel_rx_keep_0 = p_phy_sta_rpt->antidx_a;
  3045. p_dm_odm->dm_fat_table.antsel_rx_keep_1 = p_phy_sta_rpt->antidx_b;
  3046. p_dm_odm->dm_fat_table.antsel_rx_keep_2 = p_phy_sta_rpt->antidx_c;
  3047. p_dm_odm->dm_fat_table.antsel_rx_keep_3 = p_phy_sta_rpt->antidx_d;
  3048. if (p_pktinfo->is_packet_match_bssid) {
  3049. /*
  3050. dbg_print("channel = %d, band = %d, l_rxsc = %d, ht_rxsc = %d, rf_mode = %d\n", p_phy_sta_rpt->channel, p_phy_sta_rpt->band, p_phy_sta_rpt->l_rxsc, p_phy_sta_rpt->ht_rxsc, p_phy_sta_rpt->rf_mode);
  3051. dbg_print("Antidx A = %d, B = %d, C = %d, D = %d\n", p_phy_sta_rpt->antidx_a, p_phy_sta_rpt->antidx_b, p_phy_sta_rpt->antidx_c, p_phy_sta_rpt->antidx_d);
  3052. dbg_print("pwdb A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->pwdb[0], p_phy_sta_rpt->pwdb[1], p_phy_sta_rpt->pwdb[2], p_phy_sta_rpt->pwdb[3]);
  3053. dbg_print("EVM A: %d, B: %d, C: %d, D: %d\n", p_phy_sta_rpt->rxevm[0], p_phy_sta_rpt->rxevm[1], p_phy_sta_rpt->rxevm[2], p_phy_sta_rpt->rxevm[3]);
  3054. dbg_print("SNR A: %d, B: %d, C: %d, D: %d\n", p_phy_sta_rpt->rxsnr[0], p_phy_sta_rpt->rxsnr[1], p_phy_sta_rpt->rxsnr[2], p_phy_sta_rpt->rxsnr[3]);
  3055. dbg_print("CFO A: %d, B: %d, C: %d, D: %d\n", p_phy_sta_rpt->cfo_tail[0], p_phy_sta_rpt->cfo_tail[1], p_phy_sta_rpt->cfo_tail[2], p_phy_sta_rpt->cfo_tail[3]);
  3056. dbg_print("paid = %d, gid = %d, length = %d\n", (p_phy_sta_rpt->paid + (p_phy_sta_rpt->paid_msb<<8)), p_phy_sta_rpt->gid, p_phy_sta_rpt->lsig_length);
  3057. dbg_print("ldpc: %d, stbc: %d, bf: %d, gnt_bt: %d, antsw: %d\n", p_phy_sta_rpt->ldpc, p_phy_sta_rpt->stbc, p_phy_sta_rpt->beamformed, p_phy_sta_rpt->gnt_bt, p_phy_sta_rpt->hw_antsw_occu);
  3058. dbg_print("NBI: %d, pos: %d\n", p_phy_sta_rpt->nb_intf_flag, (p_phy_sta_rpt->intf_pos + (p_phy_sta_rpt->intf_pos_msb<<8)));
  3059. dbg_print("rsvd_0 = %d, rsvd_1 = %d, rsvd_2 = %d, rsvd_3 = %d, rsvd_4 = %d, rsvd_5 = %d\n", p_phy_sta_rpt->rsvd_0, p_phy_sta_rpt->rsvd_1, p_phy_sta_rpt->rsvd_2, p_phy_sta_rpt->rsvd_3, p_phy_sta_rpt->rsvd_4, p_phy_sta_rpt->rsvd_5);
  3060. */
  3061. phydm_rx_statistic_cal(p_dm_odm, p_phy_status, p_pktinfo);
  3062. }
  3063. /*
  3064. dbg_print("phydm_get_rx_phy_status_type1 p_pktinfo->is_packet_match_bssid = %d\n", p_pktinfo->is_packet_match_bssid);
  3065. dbg_print("p_pktinfo->data_rate = 0x%x\n", p_pktinfo->data_rate);
  3066. */
  3067. }
  3068. void
  3069. phydm_get_rx_phy_status_type2(
  3070. struct PHY_DM_STRUCT *p_dm_odm,
  3071. u8 *p_phy_status,
  3072. struct _odm_per_pkt_info_ *p_pktinfo,
  3073. struct _odm_phy_status_info_ *p_phy_info
  3074. )
  3075. {
  3076. struct _phy_status_rpt_jaguar2_type2 *p_phy_sta_rpt = (struct _phy_status_rpt_jaguar2_type2 *)p_phy_status;
  3077. s8 rx_pwr_db = -120;
  3078. u8 i, rxsc, bw = ODM_BW20M, rx_count = 0;
  3079. /* Update OFDM packet counter */
  3080. p_dm_odm->phy_dbg_info.num_qry_phy_status_ofdm++;
  3081. /* Update per-path information */
  3082. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX_JAGUAR; i++) {
  3083. if (p_dm_odm->rx_ant_status & BIT(i)) {
  3084. s8 rx_path_pwr_db;
  3085. /* RX path counter */
  3086. rx_count++;
  3087. /* Update per-path information (RSSI_dB RSSI_percentage EVM SNR CFO SQ) */
  3088. #if (RTL8197F_SUPPORT == 1)
  3089. if ((p_dm_odm->support_ic_type & ODM_RTL8197F) && (p_phy_sta_rpt->pwdb[i] == 0x7f)) { /*for 97f workaround*/
  3090. if (i == ODM_RF_PATH_A) {
  3091. rx_path_pwr_db = (p_phy_sta_rpt->gain_a) << 1;
  3092. rx_path_pwr_db = rx_path_pwr_db - 110;
  3093. } else if (i == ODM_RF_PATH_B) {
  3094. rx_path_pwr_db = (p_phy_sta_rpt->gain_b) << 1;
  3095. rx_path_pwr_db = rx_path_pwr_db - 110;
  3096. } else
  3097. rx_path_pwr_db = 0;
  3098. } else
  3099. #endif
  3100. rx_path_pwr_db = p_phy_sta_rpt->pwdb[i] - 110; /* per-path pwdb in dB domain */
  3101. phydm_set_per_path_phy_info(i, rx_path_pwr_db, 0, 0, 0, p_phy_info);
  3102. /* search maximum pwdb */
  3103. if (rx_path_pwr_db > rx_pwr_db)
  3104. rx_pwr_db = rx_path_pwr_db;
  3105. }
  3106. }
  3107. /* mapping RX counter from 1~4 to 0~3 */
  3108. if (rx_count > 0)
  3109. p_phy_info->rx_count = rx_count - 1;
  3110. /* Check RX sub-channel */
  3111. if ((p_pktinfo->data_rate > ODM_RATE11M) && (p_pktinfo->data_rate < ODM_RATEMCS0))
  3112. rxsc = p_phy_sta_rpt->l_rxsc;
  3113. else
  3114. rxsc = p_phy_sta_rpt->ht_rxsc;
  3115. /*STBC or LDPC pkt*/
  3116. p_dm_odm->phy_dbg_info.is_ldpc_pkt = p_phy_sta_rpt->ldpc;
  3117. p_dm_odm->phy_dbg_info.is_stbc_pkt = p_phy_sta_rpt->stbc;
  3118. /* Check RX bandwidth */
  3119. /* the BW information of sc=0 is useless, because there is no information of RF mode*/
  3120. if (p_dm_odm->support_ic_type & ODM_RTL8822B) {
  3121. if ((rxsc >= 1) && (rxsc <= 8))
  3122. bw = ODM_BW20M;
  3123. else if ((rxsc >= 9) && (rxsc <= 12))
  3124. bw = ODM_BW40M;
  3125. else if (rxsc >= 13)
  3126. bw = ODM_BW80M;
  3127. else
  3128. bw = ODM_BW20M;
  3129. } else if (p_dm_odm->support_ic_type & (ODM_RTL8197F | ODM_RTL8723D | ODM_RTL8710B)) {/* JJ ADD 20161014 */
  3130. if (rxsc == 3)
  3131. bw = ODM_BW40M;
  3132. else if ((rxsc == 1) || (rxsc == 2))
  3133. bw = ODM_BW20M;
  3134. else
  3135. bw = ODM_BW20M;
  3136. }
  3137. /* Update packet information */
  3138. phydm_set_common_phy_info(rx_pwr_db, p_phy_sta_rpt->channel, (boolean)p_phy_sta_rpt->beamformed,
  3139. false, bw, 0, rxsc, p_phy_info);
  3140. #if 0
  3141. /* if (p_pktinfo->is_packet_match_bssid) */
  3142. {
  3143. dbg_print("channel = %d, band = %d, l_rxsc = %d, ht_rxsc = %d\n", p_phy_sta_rpt->channel, p_phy_sta_rpt->band, p_phy_sta_rpt->l_rxsc, p_phy_sta_rpt->ht_rxsc);
  3144. dbg_print("pwdb A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->pwdb[0], p_phy_sta_rpt->pwdb[1], p_phy_sta_rpt->pwdb[2], p_phy_sta_rpt->pwdb[3]);
  3145. dbg_print("Agc table A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->agc_table_a, p_phy_sta_rpt->agc_table_b, p_phy_sta_rpt->agc_table_c, p_phy_sta_rpt->agc_table_d);
  3146. dbg_print("Gain A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->gain_a, p_phy_sta_rpt->gain_b, p_phy_sta_rpt->gain_c, p_phy_sta_rpt->gain_d);
  3147. dbg_print("TRSW A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->trsw_a, p_phy_sta_rpt->trsw_b, p_phy_sta_rpt->trsw_c, p_phy_sta_rpt->trsw_d);
  3148. dbg_print("AAGC step A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->aagc_step_a, p_phy_sta_rpt->aagc_step_b, p_phy_sta_rpt->aagc_step_c, p_phy_sta_rpt->aagc_step_d);
  3149. dbg_print("HT AAGC gain A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->ht_aagc_gain[0], p_phy_sta_rpt->ht_aagc_gain[1], p_phy_sta_rpt->ht_aagc_gain[2], p_phy_sta_rpt->ht_aagc_gain[3]);
  3150. dbg_print("DAGC gain A: 0x%x, B: 0x%x, C: 0x%x, D: 0x%x\n", p_phy_sta_rpt->dagc_gain[0], p_phy_sta_rpt->dagc_gain[1], p_phy_sta_rpt->dagc_gain[2], p_phy_sta_rpt->dagc_gain[3]);
  3151. dbg_print("ldpc: %d, stbc: %d, bf: %d, gnt_bt: %d, antsw: %d\n", p_phy_sta_rpt->ldpc, p_phy_sta_rpt->stbc, p_phy_sta_rpt->beamformed, p_phy_sta_rpt->gnt_bt, p_phy_sta_rpt->hw_antsw_occu);
  3152. dbg_print("counter: %d, syn_count: %d\n", p_phy_sta_rpt->counter, p_phy_sta_rpt->syn_count);
  3153. dbg_print("cnt_cca2agc_rdy: %d, cnt_pw2cca: %d, shift_l_map\n", p_phy_sta_rpt->cnt_cca2agc_rdy, p_phy_sta_rpt->cnt_pw2cca, p_phy_sta_rpt->shift_l_map);
  3154. dbg_print("rsvd_0 = %d, rsvd_1 = %d, rsvd_2 = %d, rsvd_3 = %d, rsvd_4 = %d, rsvd_5 = %d\n", p_phy_sta_rpt->rsvd_0, p_phy_sta_rpt->rsvd_1, p_phy_sta_rpt->rsvd_2, p_phy_sta_rpt->rsvd_3, p_phy_sta_rpt->rsvd_4);
  3155. dbg_print("rsvd_5 = %d, rsvd_6 = %d, rsvd_6 = %d\n", p_phy_sta_rpt->rsvd_5, p_phy_sta_rpt->rsvd_6, p_phy_sta_rpt->rsvd_7);
  3156. }
  3157. #endif
  3158. }
  3159. void
  3160. phydm_get_rx_phy_status_type5(
  3161. u8 *p_phy_status
  3162. )
  3163. {
  3164. /*
  3165. dbg_print("DW0: 0x%02x%02x%02x%02x\n", *(p_phy_status + 3), *(p_phy_status + 2), *(p_phy_status + 1), *(p_phy_status + 0));
  3166. dbg_print("DW1: 0x%02x%02x%02x%02x\n", *(p_phy_status + 7), *(p_phy_status + 6), *(p_phy_status + 5), *(p_phy_status + 4));
  3167. dbg_print("DW2: 0x%02x%02x%02x%02x\n", *(p_phy_status + 11), *(p_phy_status + 10), *(p_phy_status + 9), *(p_phy_status + 8));
  3168. dbg_print("DW3: 0x%02x%02x%02x%02x\n", *(p_phy_status + 15), *(p_phy_status + 14), *(p_phy_status + 13), *(p_phy_status + 12));
  3169. dbg_print("DW4: 0x%02x%02x%02x%02x\n", *(p_phy_status + 19), *(p_phy_status + 18), *(p_phy_status + 17), *(p_phy_status + 16));
  3170. dbg_print("DW5: 0x%02x%02x%02x%02x\n", *(p_phy_status + 23), *(p_phy_status + 22), *(p_phy_status + 21), *(p_phy_status + 20));
  3171. dbg_print("DW6: 0x%02x%02x%02x%02x\n", *(p_phy_status + 27), *(p_phy_status + 26), *(p_phy_status + 25), *(p_phy_status + 24));
  3172. */
  3173. }
  3174. void
  3175. phydm_process_rssi_for_dm_new_type(
  3176. struct PHY_DM_STRUCT *p_dm_odm,
  3177. struct _odm_phy_status_info_ *p_phy_info,
  3178. struct _odm_per_pkt_info_ *p_pktinfo
  3179. )
  3180. {
  3181. s32 undecorated_smoothed_pwdb, accumulate_pwdb;
  3182. u32 rssi_ave;
  3183. u8 i;
  3184. struct sta_info *p_entry;
  3185. u8 scaling_factor = 4;
  3186. if (p_pktinfo->station_id >= ODM_ASSOCIATE_ENTRY_NUM)
  3187. return;
  3188. p_entry = p_dm_odm->p_odm_sta_info[p_pktinfo->station_id];
  3189. if (!IS_STA_VALID(p_entry))
  3190. return;
  3191. if ((!p_pktinfo->is_packet_match_bssid))/*data frame only*/
  3192. return;
  3193. if (p_pktinfo->is_packet_beacon)
  3194. p_dm_odm->phy_dbg_info.num_qry_beacon_pkt++;
  3195. #if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY))
  3196. if (p_dm_odm->support_ability & ODM_BB_ANT_DIV)
  3197. odm_process_rssi_for_ant_div(p_dm_odm, p_phy_info, p_pktinfo);
  3198. #endif
  3199. #if (CONFIG_DYNAMIC_RX_PATH == 1)
  3200. phydm_process_phy_status_for_dynamic_rx_path(p_dm_odm, p_phy_info, p_pktinfo);
  3201. dbg_print("====>\n");
  3202. #endif
  3203. if (p_pktinfo->is_packet_to_self || p_pktinfo->is_packet_beacon) {
  3204. u32 RSSI_linear = 0;
  3205. p_dm_odm->rx_rate = p_pktinfo->data_rate;
  3206. undecorated_smoothed_pwdb = p_entry->rssi_stat.undecorated_smoothed_pwdb;
  3207. accumulate_pwdb = p_dm_odm->accumulate_pwdb[p_pktinfo->station_id];
  3208. p_dm_odm->RSSI_A = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_A];
  3209. p_dm_odm->RSSI_B = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_B];
  3210. p_dm_odm->RSSI_C = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_C];
  3211. p_dm_odm->RSSI_D = p_phy_info->rx_mimo_signal_strength[ODM_RF_PATH_D];
  3212. for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX_JAGUAR; i++) {
  3213. if (p_phy_info->rx_mimo_signal_strength[i] != 0)
  3214. RSSI_linear += odm_convert_to_linear(p_phy_info->rx_mimo_signal_strength[i]);
  3215. }
  3216. switch (p_phy_info->rx_count + 1) {
  3217. case 2:
  3218. RSSI_linear = (RSSI_linear >> 1);
  3219. break;
  3220. case 3:
  3221. RSSI_linear = ((RSSI_linear) + (RSSI_linear << 1) + (RSSI_linear << 3)) >> 5; /* RSSI_linear/3 ~ RSSI_linear*11/32 */
  3222. break;
  3223. case 4:
  3224. RSSI_linear = (RSSI_linear >> 2);
  3225. break;
  3226. }
  3227. rssi_ave = odm_convert_to_db(RSSI_linear);
  3228. if (undecorated_smoothed_pwdb <= 0) {
  3229. accumulate_pwdb = (p_phy_info->rx_pwdb_all << scaling_factor);
  3230. undecorated_smoothed_pwdb = p_phy_info->rx_pwdb_all;
  3231. } else {
  3232. accumulate_pwdb = accumulate_pwdb - (accumulate_pwdb >> scaling_factor) + rssi_ave;
  3233. undecorated_smoothed_pwdb = (accumulate_pwdb + (1 << (scaling_factor - 1))) >> scaling_factor;
  3234. }
  3235. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  3236. if (p_entry->rssi_stat.undecorated_smoothed_pwdb == -1)
  3237. phydm_ra_rssi_rpt_wk(p_dm_odm);
  3238. #endif
  3239. p_entry->rssi_stat.undecorated_smoothed_pwdb = undecorated_smoothed_pwdb;
  3240. p_dm_odm->accumulate_pwdb[p_pktinfo->station_id] = accumulate_pwdb;
  3241. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  3242. if (p_pktinfo->station_id == 0) {
  3243. HAL_DATA_TYPE *p_hal_data = GET_HAL_DATA(p_dm_odm->adapter);
  3244. p_hal_data->UndecoratedSmoothedPWDB = undecorated_smoothed_pwdb;
  3245. }
  3246. #endif
  3247. }
  3248. }
  3249. void
  3250. phydm_rx_phy_status_new_type(
  3251. struct PHY_DM_STRUCT *p_phydm,
  3252. u8 *p_phy_status,
  3253. struct _odm_per_pkt_info_ *p_pktinfo,
  3254. struct _odm_phy_status_info_ *p_phy_info
  3255. )
  3256. {
  3257. u8 phy_status_type = (*p_phy_status & 0xf);
  3258. /*dbg_print("phydm_rx_phy_status_new_type================> (page: %d)\n", phy_status_type);*/
  3259. /* Memory reset */
  3260. phydm_reset_phy_info(p_phydm, p_phy_info);
  3261. /* Phy status parsing */
  3262. switch (phy_status_type) {
  3263. case 0:
  3264. {
  3265. phydm_get_rx_phy_status_type0(p_phydm, p_phy_status, p_pktinfo, p_phy_info);
  3266. break;
  3267. }
  3268. case 1:
  3269. {
  3270. phydm_get_rx_phy_status_type1(p_phydm, p_phy_status, p_pktinfo, p_phy_info);
  3271. break;
  3272. }
  3273. case 2:
  3274. {
  3275. phydm_get_rx_phy_status_type2(p_phydm, p_phy_status, p_pktinfo, p_phy_info);
  3276. break;
  3277. }
  3278. #if 0
  3279. case 5:
  3280. {
  3281. phydm_get_rx_phy_status_type5(p_phy_status);
  3282. return;
  3283. }
  3284. #endif
  3285. default:
  3286. return;
  3287. }
  3288. /* Update signal strength to UI, and p_phy_info->rx_pwdb_all is the maximum RSSI of all path */
  3289. #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
  3290. p_phy_info->signal_strength = SignalScaleProc(p_phydm->adapter, p_phy_info->rx_pwdb_all, false, false);
  3291. #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
  3292. p_phy_info->signal_strength = (u8)(odm_signal_scale_mapping(p_phydm, p_phy_info->rx_pwdb_all));
  3293. #endif
  3294. /* Calculate average RSSI and smoothed RSSI */
  3295. phydm_process_rssi_for_dm_new_type(p_phydm, p_phy_info, p_pktinfo);
  3296. }
  3297. /*==============================================*/
  3298. #endif
  3299. u32
  3300. query_phydm_trx_capability(
  3301. struct PHY_DM_STRUCT *p_dm_odm
  3302. )
  3303. {
  3304. u32 value32 = 0xFFFFFFFF;
  3305. #if (RTL8821C_SUPPORT == 1)
  3306. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  3307. value32 = query_phydm_trx_capability_8821c(p_dm_odm);
  3308. #endif
  3309. return value32;
  3310. }
  3311. u32
  3312. query_phydm_stbc_capability(
  3313. struct PHY_DM_STRUCT *p_dm_odm
  3314. )
  3315. {
  3316. u32 value32 = 0xFFFFFFFF;
  3317. #if (RTL8821C_SUPPORT == 1)
  3318. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  3319. value32 = query_phydm_stbc_capability_8821c(p_dm_odm);
  3320. #endif
  3321. return value32;
  3322. }
  3323. u32
  3324. query_phydm_ldpc_capability(
  3325. struct PHY_DM_STRUCT *p_dm_odm
  3326. )
  3327. {
  3328. u32 value32 = 0xFFFFFFFF;
  3329. #if (RTL8821C_SUPPORT == 1)
  3330. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  3331. value32 = query_phydm_ldpc_capability_8821c(p_dm_odm);
  3332. #endif
  3333. return value32;
  3334. }
  3335. u32
  3336. query_phydm_txbf_parameters(
  3337. struct PHY_DM_STRUCT *p_dm_odm
  3338. )
  3339. {
  3340. u32 value32 = 0xFFFFFFFF;
  3341. #if (RTL8821C_SUPPORT == 1)
  3342. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  3343. value32 = query_phydm_txbf_parameters_8821c(p_dm_odm);
  3344. #endif
  3345. return value32;
  3346. }
  3347. u32
  3348. query_phydm_txbf_capability(
  3349. struct PHY_DM_STRUCT *p_dm_odm
  3350. )
  3351. {
  3352. u32 value32 = 0xFFFFFFFF;
  3353. #if (RTL8821C_SUPPORT == 1)
  3354. if (p_dm_odm->support_ic_type == ODM_RTL8821C)
  3355. value32 = query_phydm_txbf_capability_8821c(p_dm_odm);
  3356. #endif
  3357. return value32;
  3358. }