hal_rx.h 113 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968
  1. /*
  2. * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef _HAL_RX_H_
  19. #define _HAL_RX_H_
  20. #include <hal_api.h>
  21. #define HAL_INVALID_PPDU_ID 0xFFFFFFFF
  22. #define HAL_RX_OFFSET(block, field) block##_##field##_OFFSET
  23. #define HAL_RX_LSB(block, field) block##_##field##_LSB
  24. #define HAL_RX_MASk(block, field) block##_##field##_MASK
  25. #define HAL_RX_GET(_ptr, block, field) \
  26. (((*((volatile uint32_t *)_ptr + (HAL_RX_OFFSET(block, field)>>2))) & \
  27. HAL_RX_MASk(block, field)) >> \
  28. HAL_RX_LSB(block, field))
  29. /* BUFFER_SIZE = 1536 data bytes + 384 RX TLV bytes + some spare bytes */
  30. #ifndef RX_DATA_BUFFER_SIZE
  31. #define RX_DATA_BUFFER_SIZE 2048
  32. #endif
  33. #ifndef RX_MONITOR_BUFFER_SIZE
  34. #define RX_MONITOR_BUFFER_SIZE 2048
  35. #endif
  36. /* MONITOR STATUS BUFFER SIZE = 1536 data bytes, buffer allocation of 2k bytes
  37. * including skb shared info and buffer alignment.
  38. */
  39. #define RX_MON_STATUS_BASE_BUF_SIZE 2048
  40. #define RX_MON_STATUS_BUF_ALIGN 128
  41. #define RX_MON_STATUS_BUF_SIZE (RX_MON_STATUS_BASE_BUF_SIZE - \
  42. RX_MON_STATUS_BUF_ALIGN - QDF_SHINFO_SIZE)
  43. /* HAL_RX_NON_QOS_TID = NON_QOS_TID which is 16 */
  44. #define HAL_RX_NON_QOS_TID 16
  45. enum {
  46. HAL_HW_RX_DECAP_FORMAT_RAW = 0,
  47. HAL_HW_RX_DECAP_FORMAT_NWIFI,
  48. HAL_HW_RX_DECAP_FORMAT_ETH2,
  49. HAL_HW_RX_DECAP_FORMAT_8023,
  50. };
  51. /**
  52. * struct hal_wbm_err_desc_info: structure to hold wbm error codes and reasons
  53. *
  54. * @reo_psh_rsn: REO push reason
  55. * @reo_err_code: REO Error code
  56. * @rxdma_psh_rsn: RXDMA push reason
  57. * @rxdma_err_code: RXDMA Error code
  58. * @reserved_1: Reserved bits
  59. * @wbm_err_src: WBM error source
  60. * @pool_id: pool ID, indicates which rxdma pool
  61. * @reserved_2: Reserved bits
  62. */
  63. struct hal_wbm_err_desc_info {
  64. uint16_t reo_psh_rsn:2,
  65. reo_err_code:5,
  66. rxdma_psh_rsn:2,
  67. rxdma_err_code:5,
  68. reserved_1:2;
  69. uint8_t wbm_err_src:3,
  70. pool_id:2,
  71. msdu_continued:1,
  72. reserved_2:2;
  73. };
  74. /**
  75. * hal_rx_mon_dest_buf_info: Structure to hold rx mon dest buffer info
  76. * @first_buffer: First buffer of MSDU
  77. * @last_buffer: Last buffer of MSDU
  78. * @is_decap_raw: Is RAW Frame
  79. * @reserved_1: Reserved
  80. *
  81. * MSDU with continuation:
  82. * -----------------------------------------------------------
  83. * | first_buffer:1 | first_buffer: 0 | ... | first_buffer: 0 |
  84. * | last_buffer :0 | last_buffer : 0 | ... | last_buffer : 0 |
  85. * | is_decap_raw:1/0 | Same as earlier | Same as earlier|
  86. * -----------------------------------------------------------
  87. *
  88. * Single buffer MSDU:
  89. * ------------------
  90. * | first_buffer:1 |
  91. * | last_buffer :1 |
  92. * | is_decap_raw:1/0 |
  93. * ------------------
  94. */
  95. struct hal_rx_mon_dest_buf_info {
  96. uint8_t first_buffer:1,
  97. last_buffer:1,
  98. is_decap_raw:1,
  99. reserved_1:5;
  100. };
  101. /**
  102. * struct hal_rx_msdu_metadata:Structure to hold rx fast path information.
  103. *
  104. * @l3_hdr_pad: l3 header padding
  105. * @reserved: Reserved bits
  106. * @sa_sw_peer_id: sa sw peer id
  107. * @sa_idx: sa index
  108. * @da_idx: da index
  109. */
  110. struct hal_rx_msdu_metadata {
  111. uint32_t l3_hdr_pad:16,
  112. sa_sw_peer_id:16;
  113. uint32_t sa_idx:16,
  114. da_idx:16;
  115. };
  116. /**
  117. * enum hal_reo_error_code: Enum which encapsulates "reo_push_reason"
  118. *
  119. * @ HAL_REO_ERROR_DETECTED: Packets arrived because of an error detected
  120. * @ HAL_REO_ROUTING_INSTRUCTION: Packets arrived because of REO routing
  121. */
  122. enum hal_reo_error_status {
  123. HAL_REO_ERROR_DETECTED = 0,
  124. HAL_REO_ROUTING_INSTRUCTION = 1,
  125. };
  126. /**
  127. * @msdu_flags: [0] first_msdu_in_mpdu
  128. * [1] last_msdu_in_mpdu
  129. * [2] msdu_continuation - MSDU spread across buffers
  130. * [23] sa_is_valid - SA match in peer table
  131. * [24] sa_idx_timeout - Timeout while searching for SA match
  132. * [25] da_is_valid - Used to identtify intra-bss forwarding
  133. * [26] da_is_MCBC
  134. * [27] da_idx_timeout - Timeout while searching for DA match
  135. *
  136. */
  137. struct hal_rx_msdu_desc_info {
  138. uint32_t msdu_flags;
  139. uint16_t msdu_len; /* 14 bits for length */
  140. };
  141. /**
  142. * enum hal_rx_msdu_desc_flags: Enum for flags in MSDU_DESC_INFO
  143. *
  144. * @ HAL_MSDU_F_FIRST_MSDU_IN_MPDU: First MSDU in MPDU
  145. * @ HAL_MSDU_F_LAST_MSDU_IN_MPDU: Last MSDU in MPDU
  146. * @ HAL_MSDU_F_MSDU_CONTINUATION: MSDU continuation
  147. * @ HAL_MSDU_F_SA_IS_VALID: Found match for SA in AST
  148. * @ HAL_MSDU_F_SA_IDX_TIMEOUT: AST search for SA timed out
  149. * @ HAL_MSDU_F_DA_IS_VALID: Found match for DA in AST
  150. * @ HAL_MSDU_F_DA_IS_MCBC: DA is MC/BC address
  151. * @ HAL_MSDU_F_DA_IDX_TIMEOUT: AST search for DA timed out
  152. */
  153. enum hal_rx_msdu_desc_flags {
  154. HAL_MSDU_F_FIRST_MSDU_IN_MPDU = (0x1 << 0),
  155. HAL_MSDU_F_LAST_MSDU_IN_MPDU = (0x1 << 1),
  156. HAL_MSDU_F_MSDU_CONTINUATION = (0x1 << 2),
  157. HAL_MSDU_F_SA_IS_VALID = (0x1 << 23),
  158. HAL_MSDU_F_SA_IDX_TIMEOUT = (0x1 << 24),
  159. HAL_MSDU_F_DA_IS_VALID = (0x1 << 25),
  160. HAL_MSDU_F_DA_IS_MCBC = (0x1 << 26),
  161. HAL_MSDU_F_DA_IDX_TIMEOUT = (0x1 << 27)
  162. };
  163. /*
  164. * @msdu_count: no. of msdus in the MPDU
  165. * @mpdu_seq: MPDU sequence number
  166. * @mpdu_flags [0] Fragment flag
  167. * [1] MPDU_retry_bit
  168. * [2] AMPDU flag
  169. * [3] raw_ampdu
  170. * @peer_meta_data: Upper bits containing peer id, vdev id
  171. */
  172. struct hal_rx_mpdu_desc_info {
  173. uint16_t msdu_count;
  174. uint16_t mpdu_seq; /* 12 bits for length */
  175. uint32_t mpdu_flags;
  176. uint32_t peer_meta_data; /* sw progamed meta-data:MAC Id & peer Id */
  177. };
  178. /**
  179. * enum hal_rx_mpdu_desc_flags: Enum for flags in MPDU_DESC_INFO
  180. *
  181. * @ HAL_MPDU_F_FRAGMENT: Fragmented MPDU (802.11 fragemtation)
  182. * @ HAL_MPDU_F_RETRY_BIT: Retry bit is set in FC of MPDU
  183. * @ HAL_MPDU_F_AMPDU_FLAG: MPDU received as part of A-MPDU
  184. * @ HAL_MPDU_F_RAW_AMPDU: MPDU is a Raw MDPU
  185. */
  186. enum hal_rx_mpdu_desc_flags {
  187. HAL_MPDU_F_FRAGMENT = (0x1 << 20),
  188. HAL_MPDU_F_RETRY_BIT = (0x1 << 21),
  189. HAL_MPDU_F_AMPDU_FLAG = (0x1 << 22),
  190. HAL_MPDU_F_RAW_AMPDU = (0x1 << 30)
  191. };
  192. /**
  193. * enum hal_rx_ret_buf_manager: Enum for return_buffer_manager field in
  194. * BUFFER_ADDR_INFO structure
  195. *
  196. * @ HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
  197. * @ HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST: Descriptor returned to WBM idle
  198. * descriptor list
  199. * @ HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
  200. * @ HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
  201. * @ HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
  202. * @ HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
  203. * @ HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
  204. */
  205. enum hal_rx_ret_buf_manager {
  206. HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST = 0,
  207. HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST = 1,
  208. HAL_RX_BUF_RBM_FW_BM = 2,
  209. HAL_RX_BUF_RBM_SW0_BM = 3,
  210. HAL_RX_BUF_RBM_SW1_BM = 4,
  211. HAL_RX_BUF_RBM_SW2_BM = 5,
  212. HAL_RX_BUF_RBM_SW3_BM = 6,
  213. };
  214. /*
  215. * Given the offset of a field in bytes, returns uint8_t *
  216. */
  217. #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \
  218. (((uint8_t *)(_ptr)) + (_off_in_bytes))
  219. /*
  220. * Given the offset of a field in bytes, returns uint32_t *
  221. */
  222. #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \
  223. (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
  224. #define _HAL_MS(_word, _mask, _shift) \
  225. (((_word) & (_mask)) >> (_shift))
  226. /*
  227. * macro to set the LSW of the nbuf data physical address
  228. * to the rxdma ring entry
  229. */
  230. #define HAL_RXDMA_PADDR_LO_SET(buff_addr_info, paddr_lo) \
  231. ((*(((unsigned int *) buff_addr_info) + \
  232. (BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET >> 2))) = \
  233. (paddr_lo << BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB) & \
  234. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK)
  235. /*
  236. * macro to set the LSB of MSW of the nbuf data physical address
  237. * to the rxdma ring entry
  238. */
  239. #define HAL_RXDMA_PADDR_HI_SET(buff_addr_info, paddr_hi) \
  240. ((*(((unsigned int *) buff_addr_info) + \
  241. (BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET >> 2))) = \
  242. (paddr_hi << BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB) & \
  243. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK)
  244. #define HAL_RX_COOKIE_INVALID_MASK 0x80000000
  245. /*
  246. * macro to get the invalid bit for sw cookie
  247. */
  248. #define HAL_RX_BUF_COOKIE_INVALID_GET(buff_addr_info) \
  249. ((*(((unsigned int *)buff_addr_info) + \
  250. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) & \
  251. HAL_RX_COOKIE_INVALID_MASK)
  252. /*
  253. * macro to set the invalid bit for sw cookie
  254. */
  255. #define HAL_RX_BUF_COOKIE_INVALID_SET(buff_addr_info) \
  256. ((*(((unsigned int *)buff_addr_info) + \
  257. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  258. HAL_RX_COOKIE_INVALID_MASK)
  259. /*
  260. * macro to set the cookie into the rxdma ring entry
  261. */
  262. #define HAL_RXDMA_COOKIE_SET(buff_addr_info, cookie) \
  263. ((*(((unsigned int *) buff_addr_info) + \
  264. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) &= \
  265. ~BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK); \
  266. ((*(((unsigned int *) buff_addr_info) + \
  267. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  268. (cookie << BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB) & \
  269. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK)
  270. /*
  271. * macro to set the manager into the rxdma ring entry
  272. */
  273. #define HAL_RXDMA_MANAGER_SET(buff_addr_info, manager) \
  274. ((*(((unsigned int *) buff_addr_info) + \
  275. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) &= \
  276. ~BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK); \
  277. ((*(((unsigned int *) buff_addr_info) + \
  278. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) |= \
  279. (manager << BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB) & \
  280. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK)
  281. #define HAL_RX_ERROR_STATUS_GET(reo_desc) \
  282. (_HAL_MS((*_OFFSET_TO_WORD_PTR(reo_desc, \
  283. REO_DESTINATION_RING_7_REO_PUSH_REASON_OFFSET)),\
  284. REO_DESTINATION_RING_7_REO_PUSH_REASON_MASK, \
  285. REO_DESTINATION_RING_7_REO_PUSH_REASON_LSB))
  286. #define HAL_RX_BUF_COOKIE_GET(buff_addr_info) \
  287. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  288. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET)), \
  289. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK, \
  290. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB))
  291. #define HAL_RX_BUFFER_ADDR_39_32_GET(buff_addr_info) \
  292. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  293. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET)), \
  294. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK, \
  295. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB))
  296. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  297. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  298. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET)), \
  299. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK, \
  300. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB))
  301. #define HAL_RX_BUF_RBM_GET(buff_addr_info) \
  302. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  303. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET)),\
  304. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK, \
  305. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB))
  306. #define HAL_RX_LINK_COOKIE_INVALID_MASK 0x40000000
  307. #define HAL_RX_BUF_LINK_COOKIE_INVALID_GET(buff_addr_info) \
  308. ((*(((unsigned int *)buff_addr_info) + \
  309. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) & \
  310. HAL_RX_LINK_COOKIE_INVALID_MASK)
  311. #define HAL_RX_BUF_LINK_COOKIE_INVALID_SET(buff_addr_info) \
  312. ((*(((unsigned int *)buff_addr_info) + \
  313. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  314. HAL_RX_LINK_COOKIE_INVALID_MASK)
  315. #define HAL_RX_REO_BUF_LINK_COOKIE_INVALID_GET(reo_desc) \
  316. (HAL_RX_BUF_LINK_COOKIE_INVALID_GET(& \
  317. (((struct reo_destination_ring *) \
  318. reo_desc)->buf_or_link_desc_addr_info)))
  319. #define HAL_RX_REO_BUF_LINK_COOKIE_INVALID_SET(reo_desc) \
  320. (HAL_RX_BUF_LINK_COOKIE_INVALID_SET(& \
  321. (((struct reo_destination_ring *) \
  322. reo_desc)->buf_or_link_desc_addr_info)))
  323. /* TODO: Convert the following structure fields accesseses to offsets */
  324. #define HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_desc) \
  325. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  326. (((struct reo_destination_ring *) \
  327. reo_desc)->buf_or_link_desc_addr_info)))
  328. #define HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_desc) \
  329. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  330. (((struct reo_destination_ring *) \
  331. reo_desc)->buf_or_link_desc_addr_info)))
  332. #define HAL_RX_REO_BUF_COOKIE_INVALID_GET(reo_desc) \
  333. (HAL_RX_BUF_COOKIE_INVALID_GET(& \
  334. (((struct reo_destination_ring *) \
  335. reo_desc)->buf_or_link_desc_addr_info)))
  336. #define HAL_RX_REO_BUF_COOKIE_INVALID_SET(reo_desc) \
  337. (HAL_RX_BUF_COOKIE_INVALID_SET(& \
  338. (((struct reo_destination_ring *) \
  339. reo_desc)->buf_or_link_desc_addr_info)))
  340. #define HAL_RX_REO_BUF_COOKIE_GET(reo_desc) \
  341. (HAL_RX_BUF_COOKIE_GET(& \
  342. (((struct reo_destination_ring *) \
  343. reo_desc)->buf_or_link_desc_addr_info)))
  344. #define HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info_ptr) \
  345. ((mpdu_info_ptr \
  346. [RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_OFFSET >> 2] & \
  347. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_MASK) >> \
  348. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_LSB)
  349. #define HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info_ptr) \
  350. ((mpdu_info_ptr \
  351. [RX_MPDU_DESC_INFO_1_PEER_META_DATA_OFFSET >> 2] & \
  352. RX_MPDU_DESC_INFO_1_PEER_META_DATA_MASK) >> \
  353. RX_MPDU_DESC_INFO_1_PEER_META_DATA_LSB)
  354. #define HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info_ptr) \
  355. ((mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MSDU_COUNT_OFFSET >> 2] & \
  356. RX_MPDU_DESC_INFO_0_MSDU_COUNT_MASK) >> \
  357. RX_MPDU_DESC_INFO_0_MSDU_COUNT_LSB)
  358. #define HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) \
  359. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_OFFSET >> 2] & \
  360. RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_MASK)
  361. #define HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) \
  362. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_OFFSET >> 2] & \
  363. RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_MASK)
  364. #define HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) \
  365. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_AMPDU_FLAG_OFFSET >> 2] & \
  366. RX_MPDU_DESC_INFO_0_AMPDU_FLAG_MASK)
  367. #define HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr) \
  368. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_RAW_MPDU_OFFSET >> 2] & \
  369. RX_MPDU_DESC_INFO_0_RAW_MPDU_MASK)
  370. #define HAL_RX_MPDU_FLAGS_GET(mpdu_info_ptr) \
  371. (HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) | \
  372. HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) | \
  373. HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) | \
  374. HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr))
  375. #define HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info_ptr) \
  376. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  377. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_OFFSET)), \
  378. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_MASK, \
  379. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_LSB))
  380. /*
  381. * NOTE: None of the following _GET macros need a right
  382. * shift by the corresponding _LSB. This is because, they are
  383. * finally taken and "OR'ed" into a single word again.
  384. */
  385. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  386. ((*(((uint32_t *)msdu_info_ptr) + \
  387. (RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  388. (val << RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_LSB) & \
  389. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  390. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  391. ((*(((uint32_t *)msdu_info_ptr) + \
  392. (RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  393. (val << RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_LSB) & \
  394. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  395. #define HAL_RX_MSDU_CONTINUATION_FLAG_SET(msdu_info_ptr, val) \
  396. ((*(((uint32_t *)msdu_info_ptr) + \
  397. (RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET >> 2))) |= \
  398. (val << RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_LSB) & \
  399. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  400. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  401. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  402. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  403. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  404. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  405. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  406. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  407. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  408. #define HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) \
  409. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  410. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET)) & \
  411. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  412. #define HAL_RX_MSDU_REO_DST_IND_GET(msdu_info_ptr) \
  413. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  414. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_OFFSET)), \
  415. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_MASK, \
  416. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_LSB))
  417. #define HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  418. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  419. RX_MSDU_DESC_INFO_0_SA_IS_VALID_OFFSET)) & \
  420. RX_MSDU_DESC_INFO_0_SA_IS_VALID_MASK)
  421. #define HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  422. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  423. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_OFFSET)) & \
  424. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_MASK)
  425. #define HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  426. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  427. RX_MSDU_DESC_INFO_0_DA_IS_VALID_OFFSET)) & \
  428. RX_MSDU_DESC_INFO_0_DA_IS_VALID_MASK)
  429. #define HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) \
  430. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  431. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_OFFSET)) & \
  432. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_MASK)
  433. #define HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  434. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  435. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_OFFSET)) & \
  436. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_MASK)
  437. #define HAL_RX_MSDU_FLAGS_GET(msdu_info_ptr) \
  438. (HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  439. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  440. HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) | \
  441. HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  442. HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) | \
  443. HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  444. HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) | \
  445. HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr))
  446. #define HAL_RX_MPDU_ENCRYPT_TYPE_GET(_rx_mpdu_info) \
  447. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  448. RX_MPDU_INFO_3_ENCRYPT_TYPE_OFFSET)), \
  449. RX_MPDU_INFO_3_ENCRYPT_TYPE_MASK, \
  450. RX_MPDU_INFO_3_ENCRYPT_TYPE_LSB))
  451. #define HAL_RX_FLD_SET(_ptr, _wrd, _field, _val) \
  452. (*(uint32_t *)(((uint8_t *)_ptr) + \
  453. _wrd ## _ ## _field ## _OFFSET) |= \
  454. ((_val << _wrd ## _ ## _field ## _LSB) & \
  455. _wrd ## _ ## _field ## _MASK))
  456. #define HAL_RX_UNIFORM_HDR_SET(_rx_msdu_link, _field, _val) \
  457. HAL_RX_FLD_SET(_rx_msdu_link, UNIFORM_DESCRIPTOR_HEADER_0, \
  458. _field, _val)
  459. #define HAL_RX_MSDU_DESC_INFO_SET(_msdu_info_ptr, _field, _val) \
  460. HAL_RX_FLD_SET(_msdu_info_ptr, RX_MSDU_DESC_INFO_0, \
  461. _field, _val)
  462. #define HAL_RX_MPDU_DESC_INFO_SET(_mpdu_info_ptr, _field, _val) \
  463. HAL_RX_FLD_SET(_mpdu_info_ptr, RX_MPDU_DESC_INFO_0, \
  464. _field, _val)
  465. static inline void hal_rx_mpdu_desc_info_get(void *desc_addr,
  466. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  467. {
  468. struct reo_destination_ring *reo_dst_ring;
  469. uint32_t *mpdu_info;
  470. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  471. mpdu_info = (uint32_t *)&reo_dst_ring->rx_mpdu_desc_info_details;
  472. mpdu_desc_info->msdu_count = HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info);
  473. mpdu_desc_info->mpdu_seq = HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info);
  474. mpdu_desc_info->mpdu_flags = HAL_RX_MPDU_FLAGS_GET(mpdu_info);
  475. mpdu_desc_info->peer_meta_data =
  476. HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info);
  477. }
  478. /*
  479. * @ hal_rx_msdu_desc_info_get: Gets the flags related to MSDU desciptor.
  480. * @ Specifically flags needed are:
  481. * @ first_msdu_in_mpdu, last_msdu_in_mpdu,
  482. * @ msdu_continuation, sa_is_valid,
  483. * @ sa_idx_timeout, da_is_valid, da_idx_timeout,
  484. * @ da_is_MCBC
  485. *
  486. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to the current
  487. * @ descriptor
  488. * @ msdu_desc_info: Holds MSDU descriptor info from HAL Rx descriptor
  489. * @ Return: void
  490. */
  491. static inline void hal_rx_msdu_desc_info_get(void *desc_addr,
  492. struct hal_rx_msdu_desc_info *msdu_desc_info)
  493. {
  494. struct reo_destination_ring *reo_dst_ring;
  495. uint32_t *msdu_info;
  496. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  497. msdu_info = (uint32_t *)&reo_dst_ring->rx_msdu_desc_info_details;
  498. msdu_desc_info->msdu_flags = HAL_RX_MSDU_FLAGS_GET(msdu_info);
  499. msdu_desc_info->msdu_len = HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info);
  500. }
  501. /*
  502. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  503. * rxdma ring entry.
  504. * @rxdma_entry: descriptor entry
  505. * @paddr: physical address of nbuf data pointer.
  506. * @cookie: SW cookie used as a index to SW rx desc.
  507. * @manager: who owns the nbuf (host, NSS, etc...).
  508. *
  509. */
  510. static inline void hal_rxdma_buff_addr_info_set(void *rxdma_entry,
  511. qdf_dma_addr_t paddr, uint32_t cookie, uint8_t manager)
  512. {
  513. uint32_t paddr_lo = ((u64)paddr & 0x00000000ffffffff);
  514. uint32_t paddr_hi = ((u64)paddr & 0xffffffff00000000) >> 32;
  515. HAL_RXDMA_PADDR_LO_SET(rxdma_entry, paddr_lo);
  516. HAL_RXDMA_PADDR_HI_SET(rxdma_entry, paddr_hi);
  517. HAL_RXDMA_COOKIE_SET(rxdma_entry, cookie);
  518. HAL_RXDMA_MANAGER_SET(rxdma_entry, manager);
  519. }
  520. /*
  521. * Structures & Macros to obtain fields from the TLV's in the Rx packet
  522. * pre-header.
  523. */
  524. /*
  525. * Every Rx packet starts at an offset from the top of the buffer.
  526. * If the host hasn't subscribed to any specific TLV, there is
  527. * still space reserved for the following TLV's from the start of
  528. * the buffer:
  529. * -- RX ATTENTION
  530. * -- RX MPDU START
  531. * -- RX MSDU START
  532. * -- RX MSDU END
  533. * -- RX MPDU END
  534. * -- RX PACKET HEADER (802.11)
  535. * If the host subscribes to any of the TLV's above, that TLV
  536. * if populated by the HW
  537. */
  538. #define NUM_DWORDS_TAG 1
  539. /* By default the packet header TLV is 128 bytes */
  540. #define NUM_OF_BYTES_RX_802_11_HDR_TLV 128
  541. #define NUM_OF_DWORDS_RX_802_11_HDR_TLV \
  542. (NUM_OF_BYTES_RX_802_11_HDR_TLV >> 2)
  543. #define RX_PKT_OFFSET_WORDS \
  544. ( \
  545. NUM_OF_DWORDS_RX_ATTENTION + NUM_DWORDS_TAG \
  546. NUM_OF_DWORDS_RX_MPDU_START + NUM_DWORDS_TAG \
  547. NUM_OF_DWORDS_RX_MSDU_START + NUM_DWORDS_TAG \
  548. NUM_OF_DWORDS_RX_MSDU_END + NUM_DWORDS_TAG \
  549. NUM_OF_DWORDS_RX_MPDU_END + NUM_DWORDS_TAG \
  550. NUM_OF_DWORDS_RX_802_11_HDR_TLV + NUM_DWORDS_TAG \
  551. )
  552. #define RX_PKT_OFFSET_BYTES \
  553. (RX_PKT_OFFSET_WORDS << 2)
  554. #define RX_PKT_HDR_TLV_LEN 120
  555. /*
  556. * Each RX descriptor TLV is preceded by 1 DWORD "tag"
  557. */
  558. struct rx_attention_tlv {
  559. uint32_t tag;
  560. struct rx_attention rx_attn;
  561. };
  562. struct rx_mpdu_start_tlv {
  563. uint32_t tag;
  564. struct rx_mpdu_start rx_mpdu_start;
  565. };
  566. struct rx_msdu_start_tlv {
  567. uint32_t tag;
  568. struct rx_msdu_start rx_msdu_start;
  569. };
  570. struct rx_msdu_end_tlv {
  571. uint32_t tag;
  572. struct rx_msdu_end rx_msdu_end;
  573. };
  574. struct rx_mpdu_end_tlv {
  575. uint32_t tag;
  576. struct rx_mpdu_end rx_mpdu_end;
  577. };
  578. struct rx_pkt_hdr_tlv {
  579. uint32_t tag; /* 4 B */
  580. uint32_t phy_ppdu_id; /* 4 B */
  581. char rx_pkt_hdr[RX_PKT_HDR_TLV_LEN]; /* 120 B */
  582. };
  583. #define RXDMA_OPTIMIZATION
  584. /* rx_pkt_tlvs structure should be used to process Data buffers, monitor status
  585. * buffers, monitor destination buffers and monitor descriptor buffers.
  586. */
  587. #ifdef RXDMA_OPTIMIZATION
  588. /*
  589. * The RX_PADDING_BYTES is required so that the TLV's don't
  590. * spread across the 128 byte boundary
  591. * RXDMA optimization requires:
  592. * 1) MSDU_END & ATTENTION TLV's follow in that order
  593. * 2) TLV's don't span across 128 byte lines
  594. * 3) Rx Buffer is nicely aligned on the 128 byte boundary
  595. */
  596. #define RX_PADDING0_BYTES 4
  597. #define RX_PADDING1_BYTES 16
  598. struct rx_pkt_tlvs {
  599. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  600. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  601. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  602. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  603. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  604. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  605. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  606. #ifndef NO_RX_PKT_HDR_TLV
  607. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  608. #endif
  609. };
  610. #else /* RXDMA_OPTIMIZATION */
  611. struct rx_pkt_tlvs {
  612. struct rx_attention_tlv attn_tlv;
  613. struct rx_mpdu_start_tlv mpdu_start_tlv;
  614. struct rx_msdu_start_tlv msdu_start_tlv;
  615. struct rx_msdu_end_tlv msdu_end_tlv;
  616. struct rx_mpdu_end_tlv mpdu_end_tlv;
  617. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  618. };
  619. #endif /* RXDMA_OPTIMIZATION */
  620. /* rx_mon_pkt_tlvs structure should be used to process monitor data buffers */
  621. #ifdef RXDMA_OPTIMIZATION
  622. struct rx_mon_pkt_tlvs {
  623. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  624. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  625. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  626. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  627. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  628. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  629. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  630. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  631. };
  632. #else /* RXDMA_OPTIMIZATION */
  633. struct rx_mon_pkt_tlvs {
  634. struct rx_attention_tlv attn_tlv;
  635. struct rx_mpdu_start_tlv mpdu_start_tlv;
  636. struct rx_msdu_start_tlv msdu_start_tlv;
  637. struct rx_msdu_end_tlv msdu_end_tlv;
  638. struct rx_mpdu_end_tlv mpdu_end_tlv;
  639. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  640. };
  641. #endif
  642. #define SIZE_OF_MONITOR_TLV sizeof(struct rx_mon_pkt_tlvs)
  643. #define SIZE_OF_DATA_RX_TLV sizeof(struct rx_pkt_tlvs)
  644. #define RX_PKT_TLVS_LEN SIZE_OF_DATA_RX_TLV
  645. #ifdef NO_RX_PKT_HDR_TLV
  646. static inline uint8_t
  647. *hal_rx_pkt_hdr_get(uint8_t *buf)
  648. {
  649. return buf + RX_PKT_TLVS_LEN;
  650. }
  651. #else
  652. static inline uint8_t
  653. *hal_rx_pkt_hdr_get(uint8_t *buf)
  654. {
  655. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  656. return pkt_tlvs->pkt_hdr_tlv.rx_pkt_hdr;
  657. }
  658. #endif
  659. #define RX_PKT_TLV_OFFSET(field) qdf_offsetof(struct rx_pkt_tlvs, field)
  660. #define HAL_RX_PKT_TLV_MPDU_START_OFFSET(hal_soc) \
  661. RX_PKT_TLV_OFFSET(mpdu_start_tlv)
  662. #define HAL_RX_PKT_TLV_MPDU_END_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(mpdu_end_tlv)
  663. #define HAL_RX_PKT_TLV_MSDU_START_OFFSET(hal_soc) \
  664. RX_PKT_TLV_OFFSET(msdu_start_tlv)
  665. #define HAL_RX_PKT_TLV_MSDU_END_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(msdu_end_tlv)
  666. #define HAL_RX_PKT_TLV_ATTN_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(attn_tlv)
  667. #define HAL_RX_PKT_TLV_PKT_HDR_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(pkt_hdr_tlv)
  668. static inline uint8_t
  669. *hal_rx_padding0_get(uint8_t *buf)
  670. {
  671. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  672. return pkt_tlvs->rx_padding0;
  673. }
  674. /*
  675. * hal_rx_encryption_info_valid(): Returns encryption type.
  676. *
  677. * @hal_soc_hdl: hal soc handle
  678. * @buf: rx_tlv_hdr of the received packet
  679. *
  680. * Return: encryption type
  681. */
  682. static inline uint32_t
  683. hal_rx_encryption_info_valid(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  684. {
  685. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  686. return hal_soc->ops->hal_rx_encryption_info_valid(buf);
  687. }
  688. /*
  689. * hal_rx_print_pn: Prints the PN of rx packet.
  690. * @hal_soc_hdl: hal soc handle
  691. * @buf: rx_tlv_hdr of the received packet
  692. *
  693. * Return: void
  694. */
  695. static inline void
  696. hal_rx_print_pn(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  697. {
  698. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  699. hal_soc->ops->hal_rx_print_pn(buf);
  700. }
  701. /*
  702. * Get msdu_done bit from the RX_ATTENTION TLV
  703. */
  704. #define HAL_RX_ATTN_MSDU_DONE_GET(_rx_attn) \
  705. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  706. RX_ATTENTION_2_MSDU_DONE_OFFSET)), \
  707. RX_ATTENTION_2_MSDU_DONE_MASK, \
  708. RX_ATTENTION_2_MSDU_DONE_LSB))
  709. static inline uint32_t
  710. hal_rx_attn_msdu_done_get(uint8_t *buf)
  711. {
  712. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  713. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  714. uint32_t msdu_done;
  715. msdu_done = HAL_RX_ATTN_MSDU_DONE_GET(rx_attn);
  716. return msdu_done;
  717. }
  718. #define HAL_RX_ATTN_FIRST_MPDU_GET(_rx_attn) \
  719. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  720. RX_ATTENTION_1_FIRST_MPDU_OFFSET)), \
  721. RX_ATTENTION_1_FIRST_MPDU_MASK, \
  722. RX_ATTENTION_1_FIRST_MPDU_LSB))
  723. /*
  724. * hal_rx_attn_first_mpdu_get(): get fist_mpdu bit from rx attention
  725. * @buf: pointer to rx_pkt_tlvs
  726. *
  727. * reutm: uint32_t(first_msdu)
  728. */
  729. static inline uint32_t
  730. hal_rx_attn_first_mpdu_get(uint8_t *buf)
  731. {
  732. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  733. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  734. uint32_t first_mpdu;
  735. first_mpdu = HAL_RX_ATTN_FIRST_MPDU_GET(rx_attn);
  736. return first_mpdu;
  737. }
  738. #define HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(_rx_attn) \
  739. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  740. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_OFFSET)), \
  741. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_MASK, \
  742. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_LSB))
  743. /*
  744. * hal_rx_attn_tcp_udp_cksum_fail_get(): get tcp_udp cksum fail bit
  745. * from rx attention
  746. * @buf: pointer to rx_pkt_tlvs
  747. *
  748. * Return: tcp_udp_cksum_fail
  749. */
  750. static inline bool
  751. hal_rx_attn_tcp_udp_cksum_fail_get(uint8_t *buf)
  752. {
  753. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  754. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  755. bool tcp_udp_cksum_fail;
  756. tcp_udp_cksum_fail = HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(rx_attn);
  757. return tcp_udp_cksum_fail;
  758. }
  759. #define HAL_RX_ATTN_IP_CKSUM_FAIL_GET(_rx_attn) \
  760. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  761. RX_ATTENTION_1_IP_CHKSUM_FAIL_OFFSET)), \
  762. RX_ATTENTION_1_IP_CHKSUM_FAIL_MASK, \
  763. RX_ATTENTION_1_IP_CHKSUM_FAIL_LSB))
  764. /*
  765. * hal_rx_attn_ip_cksum_fail_get(): get ip cksum fail bit
  766. * from rx attention
  767. * @buf: pointer to rx_pkt_tlvs
  768. *
  769. * Return: ip_cksum_fail
  770. */
  771. static inline bool
  772. hal_rx_attn_ip_cksum_fail_get(uint8_t *buf)
  773. {
  774. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  775. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  776. bool ip_cksum_fail;
  777. ip_cksum_fail = HAL_RX_ATTN_IP_CKSUM_FAIL_GET(rx_attn);
  778. return ip_cksum_fail;
  779. }
  780. #define HAL_RX_ATTN_PHY_PPDU_ID_GET(_rx_attn) \
  781. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  782. RX_ATTENTION_0_PHY_PPDU_ID_OFFSET)), \
  783. RX_ATTENTION_0_PHY_PPDU_ID_MASK, \
  784. RX_ATTENTION_0_PHY_PPDU_ID_LSB))
  785. /*
  786. * hal_rx_attn_phy_ppdu_id_get(): get phy_ppdu_id value
  787. * from rx attention
  788. * @buf: pointer to rx_pkt_tlvs
  789. *
  790. * Return: phy_ppdu_id
  791. */
  792. static inline uint16_t
  793. hal_rx_attn_phy_ppdu_id_get(uint8_t *buf)
  794. {
  795. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  796. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  797. uint16_t phy_ppdu_id;
  798. phy_ppdu_id = HAL_RX_ATTN_PHY_PPDU_ID_GET(rx_attn);
  799. return phy_ppdu_id;
  800. }
  801. #define HAL_RX_ATTN_CCE_MATCH_GET(_rx_attn) \
  802. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  803. RX_ATTENTION_1_CCE_MATCH_OFFSET)), \
  804. RX_ATTENTION_1_CCE_MATCH_MASK, \
  805. RX_ATTENTION_1_CCE_MATCH_LSB))
  806. /*
  807. * hal_rx_msdu_cce_match_get(): get CCE match bit
  808. * from rx attention
  809. * @buf: pointer to rx_pkt_tlvs
  810. * Return: CCE match value
  811. */
  812. static inline bool
  813. hal_rx_msdu_cce_match_get(uint8_t *buf)
  814. {
  815. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  816. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  817. bool cce_match_val;
  818. cce_match_val = HAL_RX_ATTN_CCE_MATCH_GET(rx_attn);
  819. return cce_match_val;
  820. }
  821. /*
  822. * Get peer_meta_data from RX_MPDU_INFO within RX_MPDU_START
  823. */
  824. #define HAL_RX_MPDU_PEER_META_DATA_GET(_rx_mpdu_info) \
  825. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  826. RX_MPDU_INFO_8_PEER_META_DATA_OFFSET)), \
  827. RX_MPDU_INFO_8_PEER_META_DATA_MASK, \
  828. RX_MPDU_INFO_8_PEER_META_DATA_LSB))
  829. static inline uint32_t
  830. hal_rx_mpdu_peer_meta_data_get(uint8_t *buf)
  831. {
  832. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  833. struct rx_mpdu_start *mpdu_start =
  834. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  835. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  836. uint32_t peer_meta_data;
  837. peer_meta_data = HAL_RX_MPDU_PEER_META_DATA_GET(mpdu_info);
  838. return peer_meta_data;
  839. }
  840. #define HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(_rx_mpdu_info) \
  841. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  842. RX_MPDU_INFO_12_AMPDU_FLAG_OFFSET)), \
  843. RX_MPDU_INFO_12_AMPDU_FLAG_MASK, \
  844. RX_MPDU_INFO_12_AMPDU_FLAG_LSB))
  845. /**
  846. * hal_rx_mpdu_info_ampdu_flag_get(): get ampdu flag bit
  847. * from rx mpdu info
  848. * @buf: pointer to rx_pkt_tlvs
  849. *
  850. * Return: ampdu flag
  851. */
  852. static inline bool
  853. hal_rx_mpdu_info_ampdu_flag_get(uint8_t *buf)
  854. {
  855. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  856. struct rx_mpdu_start *mpdu_start =
  857. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  858. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  859. bool ampdu_flag;
  860. ampdu_flag = HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(mpdu_info);
  861. return ampdu_flag;
  862. }
  863. #define HAL_RX_MPDU_PEER_META_DATA_SET(_rx_mpdu_info, peer_mdata) \
  864. ((*(((uint32_t *)_rx_mpdu_info) + \
  865. (RX_MPDU_INFO_8_PEER_META_DATA_OFFSET >> 2))) = \
  866. (peer_mdata << RX_MPDU_INFO_8_PEER_META_DATA_LSB) & \
  867. RX_MPDU_INFO_8_PEER_META_DATA_MASK)
  868. /*
  869. * @ hal_rx_mpdu_peer_meta_data_set: set peer meta data in RX mpdu start tlv
  870. *
  871. * @ buf: rx_tlv_hdr of the received packet
  872. * @ peer_mdata: peer meta data to be set.
  873. * @ Return: void
  874. */
  875. static inline void
  876. hal_rx_mpdu_peer_meta_data_set(uint8_t *buf, uint32_t peer_mdata)
  877. {
  878. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  879. struct rx_mpdu_start *mpdu_start =
  880. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  881. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  882. HAL_RX_MPDU_PEER_META_DATA_SET(mpdu_info, peer_mdata);
  883. }
  884. /**
  885. * LRO information needed from the TLVs
  886. */
  887. #define HAL_RX_TLV_GET_LRO_ELIGIBLE(buf) \
  888. (_HAL_MS( \
  889. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  890. msdu_end_tlv.rx_msdu_end), \
  891. RX_MSDU_END_9_LRO_ELIGIBLE_OFFSET)), \
  892. RX_MSDU_END_9_LRO_ELIGIBLE_MASK, \
  893. RX_MSDU_END_9_LRO_ELIGIBLE_LSB))
  894. #define HAL_RX_TLV_GET_TCP_ACK(buf) \
  895. (_HAL_MS( \
  896. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  897. msdu_end_tlv.rx_msdu_end), \
  898. RX_MSDU_END_8_TCP_ACK_NUMBER_OFFSET)), \
  899. RX_MSDU_END_8_TCP_ACK_NUMBER_MASK, \
  900. RX_MSDU_END_8_TCP_ACK_NUMBER_LSB))
  901. #define HAL_RX_TLV_GET_TCP_SEQ(buf) \
  902. (_HAL_MS( \
  903. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  904. msdu_end_tlv.rx_msdu_end), \
  905. RX_MSDU_END_7_TCP_SEQ_NUMBER_OFFSET)), \
  906. RX_MSDU_END_7_TCP_SEQ_NUMBER_MASK, \
  907. RX_MSDU_END_7_TCP_SEQ_NUMBER_LSB))
  908. #define HAL_RX_TLV_GET_TCP_WIN(buf) \
  909. (_HAL_MS( \
  910. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  911. msdu_end_tlv.rx_msdu_end), \
  912. RX_MSDU_END_9_WINDOW_SIZE_OFFSET)), \
  913. RX_MSDU_END_9_WINDOW_SIZE_MASK, \
  914. RX_MSDU_END_9_WINDOW_SIZE_LSB))
  915. #define HAL_RX_TLV_GET_TCP_PURE_ACK(buf) \
  916. (_HAL_MS( \
  917. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  918. msdu_start_tlv.rx_msdu_start), \
  919. RX_MSDU_START_2_TCP_ONLY_ACK_OFFSET)), \
  920. RX_MSDU_START_2_TCP_ONLY_ACK_MASK, \
  921. RX_MSDU_START_2_TCP_ONLY_ACK_LSB))
  922. #define HAL_RX_TLV_GET_TCP_PROTO(buf) \
  923. (_HAL_MS( \
  924. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  925. msdu_start_tlv.rx_msdu_start), \
  926. RX_MSDU_START_2_TCP_PROTO_OFFSET)), \
  927. RX_MSDU_START_2_TCP_PROTO_MASK, \
  928. RX_MSDU_START_2_TCP_PROTO_LSB))
  929. #define HAL_RX_TLV_GET_UDP_PROTO(buf) \
  930. (_HAL_MS( \
  931. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  932. msdu_start_tlv.rx_msdu_start), \
  933. RX_MSDU_START_2_UDP_PROTO_OFFSET)), \
  934. RX_MSDU_START_2_UDP_PROTO_MASK, \
  935. RX_MSDU_START_2_UDP_PROTO_LSB))
  936. #define HAL_RX_TLV_GET_IPV6(buf) \
  937. (_HAL_MS( \
  938. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  939. msdu_start_tlv.rx_msdu_start), \
  940. RX_MSDU_START_2_IPV6_PROTO_OFFSET)), \
  941. RX_MSDU_START_2_IPV6_PROTO_MASK, \
  942. RX_MSDU_START_2_IPV6_PROTO_LSB))
  943. #define HAL_RX_TLV_GET_IP_OFFSET(buf) \
  944. (_HAL_MS( \
  945. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  946. msdu_start_tlv.rx_msdu_start), \
  947. RX_MSDU_START_1_L3_OFFSET_OFFSET)), \
  948. RX_MSDU_START_1_L3_OFFSET_MASK, \
  949. RX_MSDU_START_1_L3_OFFSET_LSB))
  950. #define HAL_RX_TLV_GET_TCP_OFFSET(buf) \
  951. (_HAL_MS( \
  952. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  953. msdu_start_tlv.rx_msdu_start), \
  954. RX_MSDU_START_1_L4_OFFSET_OFFSET)), \
  955. RX_MSDU_START_1_L4_OFFSET_MASK, \
  956. RX_MSDU_START_1_L4_OFFSET_LSB))
  957. #define HAL_RX_TLV_GET_FLOW_ID_TOEPLITZ(buf) \
  958. (_HAL_MS( \
  959. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  960. msdu_start_tlv.rx_msdu_start), \
  961. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  962. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  963. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  964. /**
  965. * hal_rx_msdu_end_l3_hdr_padding_get(): API to get the
  966. * l3_header padding from rx_msdu_end TLV
  967. *
  968. * @buf: pointer to the start of RX PKT TLV headers
  969. * Return: number of l3 header padding bytes
  970. */
  971. static inline uint32_t
  972. hal_rx_msdu_end_l3_hdr_padding_get(hal_soc_handle_t hal_soc_hdl,
  973. uint8_t *buf)
  974. {
  975. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  976. return hal_soc->ops->hal_rx_msdu_end_l3_hdr_padding_get(buf);
  977. }
  978. /**
  979. * hal_rx_msdu_end_sa_idx_get(): API to get the
  980. * sa_idx from rx_msdu_end TLV
  981. *
  982. * @ buf: pointer to the start of RX PKT TLV headers
  983. * Return: sa_idx (SA AST index)
  984. */
  985. static inline uint16_t
  986. hal_rx_msdu_end_sa_idx_get(hal_soc_handle_t hal_soc_hdl,
  987. uint8_t *buf)
  988. {
  989. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  990. return hal_soc->ops->hal_rx_msdu_end_sa_idx_get(buf);
  991. }
  992. /**
  993. * hal_rx_msdu_end_sa_is_valid_get(): API to get the
  994. * sa_is_valid bit from rx_msdu_end TLV
  995. *
  996. * @ buf: pointer to the start of RX PKT TLV headers
  997. * Return: sa_is_valid bit
  998. */
  999. static inline uint8_t
  1000. hal_rx_msdu_end_sa_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  1001. uint8_t *buf)
  1002. {
  1003. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1004. return hal_soc->ops->hal_rx_msdu_end_sa_is_valid_get(buf);
  1005. }
  1006. #define HAL_RX_MSDU_START_MSDU_LEN_GET(_rx_msdu_start) \
  1007. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1008. RX_MSDU_START_1_MSDU_LENGTH_OFFSET)), \
  1009. RX_MSDU_START_1_MSDU_LENGTH_MASK, \
  1010. RX_MSDU_START_1_MSDU_LENGTH_LSB))
  1011. /**
  1012. * hal_rx_msdu_start_msdu_len_get(): API to get the MSDU length
  1013. * from rx_msdu_start TLV
  1014. *
  1015. * @ buf: pointer to the start of RX PKT TLV headers
  1016. * Return: msdu length
  1017. */
  1018. static inline uint32_t
  1019. hal_rx_msdu_start_msdu_len_get(uint8_t *buf)
  1020. {
  1021. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1022. struct rx_msdu_start *msdu_start =
  1023. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1024. uint32_t msdu_len;
  1025. msdu_len = HAL_RX_MSDU_START_MSDU_LEN_GET(msdu_start);
  1026. return msdu_len;
  1027. }
  1028. /**
  1029. * hal_rx_msdu_start_msdu_len_set(): API to set the MSDU length
  1030. * from rx_msdu_start TLV
  1031. *
  1032. * @buf: pointer to the start of RX PKT TLV headers
  1033. * @len: msdu length
  1034. *
  1035. * Return: none
  1036. */
  1037. static inline void
  1038. hal_rx_msdu_start_msdu_len_set(uint8_t *buf, uint32_t len)
  1039. {
  1040. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1041. struct rx_msdu_start *msdu_start =
  1042. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1043. void *wrd1;
  1044. wrd1 = (uint8_t *)msdu_start + RX_MSDU_START_1_MSDU_LENGTH_OFFSET;
  1045. *(uint32_t *)wrd1 &= (~RX_MSDU_START_1_MSDU_LENGTH_MASK);
  1046. *(uint32_t *)wrd1 |= len;
  1047. }
  1048. #define HAL_RX_MSDU_START_BW_GET(_rx_msdu_start) \
  1049. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1050. RX_MSDU_START_5_RECEIVE_BANDWIDTH_OFFSET)), \
  1051. RX_MSDU_START_5_RECEIVE_BANDWIDTH_MASK, \
  1052. RX_MSDU_START_5_RECEIVE_BANDWIDTH_LSB))
  1053. /*
  1054. * hal_rx_msdu_start_bw_get(): API to get the Bandwidth
  1055. * Interval from rx_msdu_start
  1056. *
  1057. * @buf: pointer to the start of RX PKT TLV header
  1058. * Return: uint32_t(bw)
  1059. */
  1060. static inline uint32_t
  1061. hal_rx_msdu_start_bw_get(uint8_t *buf)
  1062. {
  1063. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1064. struct rx_msdu_start *msdu_start =
  1065. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1066. uint32_t bw;
  1067. bw = HAL_RX_MSDU_START_BW_GET(msdu_start);
  1068. return bw;
  1069. }
  1070. #define HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(_rx_msdu_start) \
  1071. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1072. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  1073. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  1074. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  1075. /**
  1076. * hal_rx_msdu_start_toeplitz_get: API to get the toeplitz hash
  1077. * from rx_msdu_start TLV
  1078. *
  1079. * @ buf: pointer to the start of RX PKT TLV headers
  1080. * Return: toeplitz hash
  1081. */
  1082. static inline uint32_t
  1083. hal_rx_msdu_start_toeplitz_get(uint8_t *buf)
  1084. {
  1085. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1086. struct rx_msdu_start *msdu_start =
  1087. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1088. return HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(msdu_start);
  1089. }
  1090. /**
  1091. * enum hal_rx_mpdu_info_sw_frame_group_id_type: Enum for group id in MPDU_INFO
  1092. *
  1093. * @ HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME: NDP frame
  1094. * @ HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA: multicast data frame
  1095. * @ HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA: unicast data frame
  1096. * @ HAL_MPDU_SW_FRAME_GROUP_NULL_DATA: NULL data frame
  1097. * @ HAL_MPDU_SW_FRAME_GROUP_MGMT: management frame
  1098. * @ HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ: probe req frame
  1099. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL: control frame
  1100. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA: NDPA frame
  1101. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR: BAR frame
  1102. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS: RTS frame
  1103. * @ HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED: unsupported
  1104. * @ HAL_MPDU_SW_FRAME_GROUP_MAX: max limit
  1105. */
  1106. enum hal_rx_mpdu_info_sw_frame_group_id_type {
  1107. HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME = 0,
  1108. HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA,
  1109. HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA,
  1110. HAL_MPDU_SW_FRAME_GROUP_NULL_DATA,
  1111. HAL_MPDU_SW_FRAME_GROUP_MGMT,
  1112. HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ = 8,
  1113. HAL_MPDU_SW_FRAME_GROUP_MGMT_BEACON = 12,
  1114. HAL_MPDU_SW_FRAME_GROUP_CTRL = 20,
  1115. HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA = 25,
  1116. HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR = 28,
  1117. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS = 31,
  1118. HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED = 36,
  1119. HAL_MPDU_SW_FRAME_GROUP_MAX = 37,
  1120. };
  1121. /**
  1122. * hal_rx_mpdu_start_mpdu_qos_control_valid_get():
  1123. * Retrieve qos control valid bit from the tlv.
  1124. * @hal_soc_hdl: hal_soc handle
  1125. * @buf: pointer to rx pkt TLV.
  1126. *
  1127. * Return: qos control value.
  1128. */
  1129. static inline uint32_t
  1130. hal_rx_mpdu_start_mpdu_qos_control_valid_get(
  1131. hal_soc_handle_t hal_soc_hdl,
  1132. uint8_t *buf)
  1133. {
  1134. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1135. if ((!hal_soc) || (!hal_soc->ops)) {
  1136. hal_err("hal handle is NULL");
  1137. QDF_BUG(0);
  1138. return QDF_STATUS_E_INVAL;
  1139. }
  1140. if (hal_soc->ops->hal_rx_mpdu_start_mpdu_qos_control_valid_get)
  1141. return hal_soc->ops->
  1142. hal_rx_mpdu_start_mpdu_qos_control_valid_get(buf);
  1143. return QDF_STATUS_E_INVAL;
  1144. }
  1145. /**
  1146. * hal_rx_is_unicast: check packet is unicast frame or not.
  1147. * @hal_soc_hdl: hal_soc handle
  1148. * @buf: pointer to rx pkt TLV.
  1149. *
  1150. * Return: true on unicast.
  1151. */
  1152. static inline bool
  1153. hal_rx_is_unicast(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1154. {
  1155. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1156. return hal_soc->ops->hal_rx_is_unicast(buf);
  1157. }
  1158. /**
  1159. * hal_rx_tid_get: get tid based on qos control valid.
  1160. * @hal_soc_hdl: hal soc handle
  1161. * @buf: pointer to rx pkt TLV.
  1162. *
  1163. * Return: tid
  1164. */
  1165. static inline uint32_t
  1166. hal_rx_tid_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1167. {
  1168. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1169. return hal_soc->ops->hal_rx_tid_get(hal_soc_hdl, buf);
  1170. }
  1171. /**
  1172. * hal_rx_mpdu_start_sw_peer_id_get() - Retrieve sw peer id
  1173. * @hal_soc_hdl: hal soc handle
  1174. * @buf: pointer to rx pkt TLV.
  1175. *
  1176. * Return: sw peer_id
  1177. */
  1178. static inline uint32_t
  1179. hal_rx_mpdu_start_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  1180. uint8_t *buf)
  1181. {
  1182. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1183. return hal_soc->ops->hal_rx_mpdu_start_sw_peer_id_get(buf);
  1184. }
  1185. #define HAL_RX_MSDU_START_SGI_GET(_rx_msdu_start) \
  1186. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1187. RX_MSDU_START_5_SGI_OFFSET)), \
  1188. RX_MSDU_START_5_SGI_MASK, \
  1189. RX_MSDU_START_5_SGI_LSB))
  1190. /**
  1191. * hal_rx_msdu_start_msdu_sgi_get(): API to get the Short Gaurd
  1192. * Interval from rx_msdu_start TLV
  1193. *
  1194. * @buf: pointer to the start of RX PKT TLV headers
  1195. * Return: uint32_t(sgi)
  1196. */
  1197. static inline uint32_t
  1198. hal_rx_msdu_start_sgi_get(uint8_t *buf)
  1199. {
  1200. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1201. struct rx_msdu_start *msdu_start =
  1202. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1203. uint32_t sgi;
  1204. sgi = HAL_RX_MSDU_START_SGI_GET(msdu_start);
  1205. return sgi;
  1206. }
  1207. #define HAL_RX_MSDU_START_RATE_MCS_GET(_rx_msdu_start) \
  1208. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1209. RX_MSDU_START_5_RATE_MCS_OFFSET)), \
  1210. RX_MSDU_START_5_RATE_MCS_MASK, \
  1211. RX_MSDU_START_5_RATE_MCS_LSB))
  1212. /**
  1213. * hal_rx_msdu_start_msdu_rate_mcs_get(): API to get the MCS rate
  1214. * from rx_msdu_start TLV
  1215. *
  1216. * @buf: pointer to the start of RX PKT TLV headers
  1217. * Return: uint32_t(rate_mcs)
  1218. */
  1219. static inline uint32_t
  1220. hal_rx_msdu_start_rate_mcs_get(uint8_t *buf)
  1221. {
  1222. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1223. struct rx_msdu_start *msdu_start =
  1224. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1225. uint32_t rate_mcs;
  1226. rate_mcs = HAL_RX_MSDU_START_RATE_MCS_GET(msdu_start);
  1227. return rate_mcs;
  1228. }
  1229. #define HAL_RX_ATTN_DECRYPT_STATUS_GET(_rx_attn) \
  1230. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  1231. RX_ATTENTION_2_DECRYPT_STATUS_CODE_OFFSET)), \
  1232. RX_ATTENTION_2_DECRYPT_STATUS_CODE_MASK, \
  1233. RX_ATTENTION_2_DECRYPT_STATUS_CODE_LSB))
  1234. /*
  1235. * hal_rx_attn_msdu_get_is_decrypted(): API to get the decrypt status of the
  1236. * packet from rx_attention
  1237. *
  1238. * @buf: pointer to the start of RX PKT TLV header
  1239. * Return: uint32_t(decryt status)
  1240. */
  1241. static inline uint32_t
  1242. hal_rx_attn_msdu_get_is_decrypted(uint8_t *buf)
  1243. {
  1244. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1245. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  1246. uint32_t is_decrypt = 0;
  1247. uint32_t decrypt_status;
  1248. decrypt_status = HAL_RX_ATTN_DECRYPT_STATUS_GET(rx_attn);
  1249. if (!decrypt_status)
  1250. is_decrypt = 1;
  1251. return is_decrypt;
  1252. }
  1253. /*
  1254. * Get key index from RX_MSDU_END
  1255. */
  1256. #define HAL_RX_MSDU_END_KEYID_OCTET_GET(_rx_msdu_end) \
  1257. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1258. RX_MSDU_END_2_KEY_ID_OCTET_OFFSET)), \
  1259. RX_MSDU_END_2_KEY_ID_OCTET_MASK, \
  1260. RX_MSDU_END_2_KEY_ID_OCTET_LSB))
  1261. /*
  1262. * hal_rx_msdu_get_keyid(): API to get the key id if the decrypted packet
  1263. * from rx_msdu_end
  1264. *
  1265. * @buf: pointer to the start of RX PKT TLV header
  1266. * Return: uint32_t(key id)
  1267. */
  1268. static inline uint32_t
  1269. hal_rx_msdu_get_keyid(uint8_t *buf)
  1270. {
  1271. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1272. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1273. uint32_t keyid_octet;
  1274. keyid_octet = HAL_RX_MSDU_END_KEYID_OCTET_GET(msdu_end);
  1275. return keyid_octet & 0x3;
  1276. }
  1277. #define HAL_RX_MSDU_START_RSSI_GET(_rx_msdu_start) \
  1278. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1279. RX_MSDU_START_5_USER_RSSI_OFFSET)), \
  1280. RX_MSDU_START_5_USER_RSSI_MASK, \
  1281. RX_MSDU_START_5_USER_RSSI_LSB))
  1282. /*
  1283. * hal_rx_msdu_start_get_rssi(): API to get the rssi of received pkt
  1284. * from rx_msdu_start
  1285. *
  1286. * @buf: pointer to the start of RX PKT TLV header
  1287. * Return: uint32_t(rssi)
  1288. */
  1289. static inline uint32_t
  1290. hal_rx_msdu_start_get_rssi(uint8_t *buf)
  1291. {
  1292. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1293. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1294. uint32_t rssi;
  1295. rssi = HAL_RX_MSDU_START_RSSI_GET(msdu_start);
  1296. return rssi;
  1297. }
  1298. #define HAL_RX_MSDU_START_FREQ_GET(_rx_msdu_start) \
  1299. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1300. RX_MSDU_START_7_SW_PHY_META_DATA_OFFSET)), \
  1301. RX_MSDU_START_7_SW_PHY_META_DATA_MASK, \
  1302. RX_MSDU_START_7_SW_PHY_META_DATA_LSB))
  1303. /*
  1304. * hal_rx_msdu_start_get_freq(): API to get the frequency of operating channel
  1305. * from rx_msdu_start
  1306. *
  1307. * @buf: pointer to the start of RX PKT TLV header
  1308. * Return: uint32_t(frequency)
  1309. */
  1310. static inline uint32_t
  1311. hal_rx_msdu_start_get_freq(uint8_t *buf)
  1312. {
  1313. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1314. struct rx_msdu_start *msdu_start =
  1315. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1316. uint32_t freq;
  1317. freq = HAL_RX_MSDU_START_FREQ_GET(msdu_start);
  1318. return freq;
  1319. }
  1320. #define HAL_RX_MSDU_START_PKT_TYPE_GET(_rx_msdu_start) \
  1321. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1322. RX_MSDU_START_5_PKT_TYPE_OFFSET)), \
  1323. RX_MSDU_START_5_PKT_TYPE_MASK, \
  1324. RX_MSDU_START_5_PKT_TYPE_LSB))
  1325. /*
  1326. * hal_rx_msdu_start_get_pkt_type(): API to get the pkt type
  1327. * from rx_msdu_start
  1328. *
  1329. * @buf: pointer to the start of RX PKT TLV header
  1330. * Return: uint32_t(pkt type)
  1331. */
  1332. static inline uint32_t
  1333. hal_rx_msdu_start_get_pkt_type(uint8_t *buf)
  1334. {
  1335. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1336. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1337. uint32_t pkt_type;
  1338. pkt_type = HAL_RX_MSDU_START_PKT_TYPE_GET(msdu_start);
  1339. return pkt_type;
  1340. }
  1341. /*
  1342. * hal_rx_mpdu_get_tods(): API to get the tods info
  1343. * from rx_mpdu_start
  1344. *
  1345. * @buf: pointer to the start of RX PKT TLV header
  1346. * Return: uint32_t(to_ds)
  1347. */
  1348. static inline uint32_t
  1349. hal_rx_mpdu_get_to_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1350. {
  1351. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1352. return hal_soc->ops->hal_rx_mpdu_get_to_ds(buf);
  1353. }
  1354. /*
  1355. * hal_rx_mpdu_get_fr_ds(): API to get the from ds info
  1356. * from rx_mpdu_start
  1357. * @hal_soc_hdl: hal soc handle
  1358. * @buf: pointer to the start of RX PKT TLV header
  1359. *
  1360. * Return: uint32_t(fr_ds)
  1361. */
  1362. static inline uint32_t
  1363. hal_rx_mpdu_get_fr_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1364. {
  1365. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1366. return hal_soc->ops->hal_rx_mpdu_get_fr_ds(buf);
  1367. }
  1368. #define HAL_RX_MPDU_AD4_31_0_GET(_rx_mpdu_info) \
  1369. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1370. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_OFFSET)), \
  1371. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_MASK, \
  1372. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_LSB))
  1373. #define HAL_RX_MPDU_AD4_47_32_GET(_rx_mpdu_info) \
  1374. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1375. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_OFFSET)), \
  1376. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_MASK, \
  1377. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_LSB))
  1378. /*
  1379. * hal_rx_mpdu_get_addr1(): API to check get address1 of the mpdu
  1380. * @hal_soc_hdl: hal soc handle
  1381. * @buf: pointer to the start of RX PKT TLV headera
  1382. * @mac_addr: pointer to mac address
  1383. *
  1384. * Return: success/failure
  1385. */
  1386. static inline
  1387. QDF_STATUS hal_rx_mpdu_get_addr1(hal_soc_handle_t hal_soc_hdl,
  1388. uint8_t *buf, uint8_t *mac_addr)
  1389. {
  1390. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1391. return hal_soc->ops->hal_rx_mpdu_get_addr1(buf, mac_addr);
  1392. }
  1393. /*
  1394. * hal_rx_mpdu_get_addr2(): API to check get address2 of the mpdu
  1395. * in the packet
  1396. * @hal_soc_hdl: hal soc handle
  1397. * @buf: pointer to the start of RX PKT TLV header
  1398. * @mac_addr: pointer to mac address
  1399. *
  1400. * Return: success/failure
  1401. */
  1402. static inline
  1403. QDF_STATUS hal_rx_mpdu_get_addr2(hal_soc_handle_t hal_soc_hdl,
  1404. uint8_t *buf, uint8_t *mac_addr)
  1405. {
  1406. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1407. return hal_soc->ops->hal_rx_mpdu_get_addr2(buf, mac_addr);
  1408. }
  1409. /*
  1410. * hal_rx_mpdu_get_addr3(): API to get address3 of the mpdu
  1411. * in the packet
  1412. * @hal_soc_hdl: hal soc handle
  1413. * @buf: pointer to the start of RX PKT TLV header
  1414. * @mac_addr: pointer to mac address
  1415. *
  1416. * Return: success/failure
  1417. */
  1418. static inline
  1419. QDF_STATUS hal_rx_mpdu_get_addr3(hal_soc_handle_t hal_soc_hdl,
  1420. uint8_t *buf, uint8_t *mac_addr)
  1421. {
  1422. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1423. return hal_soc->ops->hal_rx_mpdu_get_addr3(buf, mac_addr);
  1424. }
  1425. /*
  1426. * hal_rx_mpdu_get_addr4(): API to get address4 of the mpdu
  1427. * in the packet
  1428. * @hal_soc_hdl: hal_soc handle
  1429. * @buf: pointer to the start of RX PKT TLV header
  1430. * @mac_addr: pointer to mac address
  1431. * Return: success/failure
  1432. */
  1433. static inline
  1434. QDF_STATUS hal_rx_mpdu_get_addr4(hal_soc_handle_t hal_soc_hdl,
  1435. uint8_t *buf, uint8_t *mac_addr)
  1436. {
  1437. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1438. return hal_soc->ops->hal_rx_mpdu_get_addr4(buf, mac_addr);
  1439. }
  1440. /**
  1441. * hal_rx_msdu_end_da_idx_get: API to get da_idx
  1442. * from rx_msdu_end TLV
  1443. *
  1444. * @ buf: pointer to the start of RX PKT TLV headers
  1445. * Return: da index
  1446. */
  1447. static inline uint16_t
  1448. hal_rx_msdu_end_da_idx_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1449. {
  1450. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1451. return hal_soc->ops->hal_rx_msdu_end_da_idx_get(buf);
  1452. }
  1453. /**
  1454. * hal_rx_msdu_end_da_is_valid_get: API to check if da is valid
  1455. * from rx_msdu_end TLV
  1456. * @hal_soc_hdl: hal soc handle
  1457. * @ buf: pointer to the start of RX PKT TLV headers
  1458. *
  1459. * Return: da_is_valid
  1460. */
  1461. static inline uint8_t
  1462. hal_rx_msdu_end_da_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  1463. uint8_t *buf)
  1464. {
  1465. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1466. return hal_soc->ops->hal_rx_msdu_end_da_is_valid_get(buf);
  1467. }
  1468. /**
  1469. * hal_rx_msdu_end_da_is_mcbc_get: API to check if pkt is MCBC
  1470. * from rx_msdu_end TLV
  1471. *
  1472. * @buf: pointer to the start of RX PKT TLV headers
  1473. *
  1474. * Return: da_is_mcbc
  1475. */
  1476. static inline uint8_t
  1477. hal_rx_msdu_end_da_is_mcbc_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1478. {
  1479. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1480. return hal_soc->ops->hal_rx_msdu_end_da_is_mcbc_get(buf);
  1481. }
  1482. /**
  1483. * hal_rx_msdu_end_first_msdu_get: API to get first msdu status
  1484. * from rx_msdu_end TLV
  1485. * @hal_soc_hdl: hal soc handle
  1486. * @buf: pointer to the start of RX PKT TLV headers
  1487. *
  1488. * Return: first_msdu
  1489. */
  1490. static inline uint8_t
  1491. hal_rx_msdu_end_first_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1492. uint8_t *buf)
  1493. {
  1494. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1495. return hal_soc->ops->hal_rx_msdu_end_first_msdu_get(buf);
  1496. }
  1497. /**
  1498. * hal_rx_msdu_end_last_msdu_get: API to get last msdu status
  1499. * from rx_msdu_end TLV
  1500. * @hal_soc_hdl: hal soc handle
  1501. * @buf: pointer to the start of RX PKT TLV headers
  1502. *
  1503. * Return: last_msdu
  1504. */
  1505. static inline uint8_t
  1506. hal_rx_msdu_end_last_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1507. uint8_t *buf)
  1508. {
  1509. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1510. return hal_soc->ops->hal_rx_msdu_end_last_msdu_get(buf);
  1511. }
  1512. /**
  1513. * hal_rx_msdu_cce_metadata_get: API to get CCE metadata
  1514. * from rx_msdu_end TLV
  1515. * @buf: pointer to the start of RX PKT TLV headers
  1516. * Return: cce_meta_data
  1517. */
  1518. static inline uint16_t
  1519. hal_rx_msdu_cce_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1520. uint8_t *buf)
  1521. {
  1522. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1523. return hal_soc->ops->hal_rx_msdu_cce_metadata_get(buf);
  1524. }
  1525. /*******************************************************************************
  1526. * RX ERROR APIS
  1527. ******************************************************************************/
  1528. #define HAL_RX_MPDU_END_DECRYPT_ERR_GET(_rx_mpdu_end) \
  1529. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1530. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_OFFSET)), \
  1531. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_MASK, \
  1532. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_LSB))
  1533. /**
  1534. * hal_rx_mpdu_end_decrypt_err_get(): API to get the Decrypt ERR
  1535. * from rx_mpdu_end TLV
  1536. *
  1537. * @buf: pointer to the start of RX PKT TLV headers
  1538. * Return: uint32_t(decrypt_err)
  1539. */
  1540. static inline uint32_t
  1541. hal_rx_mpdu_end_decrypt_err_get(uint8_t *buf)
  1542. {
  1543. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1544. struct rx_mpdu_end *mpdu_end =
  1545. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1546. uint32_t decrypt_err;
  1547. decrypt_err = HAL_RX_MPDU_END_DECRYPT_ERR_GET(mpdu_end);
  1548. return decrypt_err;
  1549. }
  1550. #define HAL_RX_MPDU_END_MIC_ERR_GET(_rx_mpdu_end) \
  1551. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1552. RX_MPDU_END_1_TKIP_MIC_ERR_OFFSET)), \
  1553. RX_MPDU_END_1_TKIP_MIC_ERR_MASK, \
  1554. RX_MPDU_END_1_TKIP_MIC_ERR_LSB))
  1555. /**
  1556. * hal_rx_mpdu_end_mic_err_get(): API to get the MIC ERR
  1557. * from rx_mpdu_end TLV
  1558. *
  1559. * @buf: pointer to the start of RX PKT TLV headers
  1560. * Return: uint32_t(mic_err)
  1561. */
  1562. static inline uint32_t
  1563. hal_rx_mpdu_end_mic_err_get(uint8_t *buf)
  1564. {
  1565. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1566. struct rx_mpdu_end *mpdu_end =
  1567. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1568. uint32_t mic_err;
  1569. mic_err = HAL_RX_MPDU_END_MIC_ERR_GET(mpdu_end);
  1570. return mic_err;
  1571. }
  1572. /*******************************************************************************
  1573. * RX REO ERROR APIS
  1574. ******************************************************************************/
  1575. #define HAL_RX_NUM_MSDU_DESC 6
  1576. #define HAL_RX_MAX_SAVED_RING_DESC 16
  1577. /* TODO: rework the structure */
  1578. struct hal_rx_msdu_list {
  1579. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  1580. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  1581. uint8_t rbm[HAL_RX_NUM_MSDU_DESC];
  1582. /* physical address of the msdu */
  1583. uint64_t paddr[HAL_RX_NUM_MSDU_DESC];
  1584. };
  1585. struct hal_buf_info {
  1586. uint64_t paddr;
  1587. uint32_t sw_cookie;
  1588. uint8_t rbm;
  1589. };
  1590. /**
  1591. * hal_rx_link_desc_msdu0_ptr - Get pointer to rx_msdu details
  1592. * @msdu_link_ptr - msdu link ptr
  1593. * @hal - pointer to hal_soc
  1594. * Return - Pointer to rx_msdu_details structure
  1595. *
  1596. */
  1597. static inline
  1598. void *hal_rx_link_desc_msdu0_ptr(void *msdu_link_ptr,
  1599. struct hal_soc *hal_soc)
  1600. {
  1601. return hal_soc->ops->hal_rx_link_desc_msdu0_ptr(msdu_link_ptr);
  1602. }
  1603. /**
  1604. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  1605. * @msdu_details_ptr - Pointer to msdu_details_ptr
  1606. * @hal - pointer to hal_soc
  1607. * Return - Pointer to rx_msdu_desc_info structure.
  1608. *
  1609. */
  1610. static inline
  1611. void *hal_rx_msdu_desc_info_get_ptr(void *msdu_details_ptr,
  1612. struct hal_soc *hal_soc)
  1613. {
  1614. return hal_soc->ops->hal_rx_msdu_desc_info_get_ptr(msdu_details_ptr);
  1615. }
  1616. /* This special cookie value will be used to indicate FW allocated buffers
  1617. * received through RXDMA2SW ring for RXDMA WARs
  1618. */
  1619. #define HAL_RX_COOKIE_SPECIAL 0x1fffff
  1620. /**
  1621. * hal_rx_msdu_link_desc_get(): API to get the MSDU information
  1622. * from the MSDU link descriptor
  1623. *
  1624. * @msdu_link_desc: Opaque pointer used by HAL to get to the
  1625. * MSDU link descriptor (struct rx_msdu_link)
  1626. *
  1627. * @msdu_list: Return the list of MSDUs contained in this link descriptor
  1628. *
  1629. * @num_msdus: Number of MSDUs in the MPDU
  1630. *
  1631. * Return: void
  1632. */
  1633. static inline void hal_rx_msdu_list_get(hal_soc_handle_t hal_soc_hdl,
  1634. void *msdu_link_desc,
  1635. struct hal_rx_msdu_list *msdu_list,
  1636. uint16_t *num_msdus)
  1637. {
  1638. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1639. struct rx_msdu_details *msdu_details;
  1640. struct rx_msdu_desc_info *msdu_desc_info;
  1641. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1642. int i;
  1643. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1644. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1645. "[%s][%d] msdu_link=%pK msdu_details=%pK",
  1646. __func__, __LINE__, msdu_link, msdu_details);
  1647. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  1648. /* num_msdus received in mpdu descriptor may be incorrect
  1649. * sometimes due to HW issue. Check msdu buffer address also
  1650. */
  1651. if (!i && (HAL_RX_BUFFER_ADDR_31_0_GET(
  1652. &msdu_details[i].buffer_addr_info_details) == 0))
  1653. break;
  1654. if (HAL_RX_BUFFER_ADDR_31_0_GET(
  1655. &msdu_details[i].buffer_addr_info_details) == 0) {
  1656. /* set the last msdu bit in the prev msdu_desc_info */
  1657. msdu_desc_info =
  1658. hal_rx_msdu_desc_info_get_ptr(&msdu_details[i - 1], hal_soc);
  1659. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1660. break;
  1661. }
  1662. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[i],
  1663. hal_soc);
  1664. /* set first MSDU bit or the last MSDU bit */
  1665. if (!i)
  1666. HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1667. else if (i == (HAL_RX_NUM_MSDU_DESC - 1))
  1668. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1669. msdu_list->msdu_info[i].msdu_flags =
  1670. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  1671. msdu_list->msdu_info[i].msdu_len =
  1672. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  1673. msdu_list->sw_cookie[i] =
  1674. HAL_RX_BUF_COOKIE_GET(
  1675. &msdu_details[i].buffer_addr_info_details);
  1676. msdu_list->rbm[i] = HAL_RX_BUF_RBM_GET(
  1677. &msdu_details[i].buffer_addr_info_details);
  1678. msdu_list->paddr[i] = HAL_RX_BUFFER_ADDR_31_0_GET(
  1679. &msdu_details[i].buffer_addr_info_details) |
  1680. (uint64_t)HAL_RX_BUFFER_ADDR_39_32_GET(
  1681. &msdu_details[i].buffer_addr_info_details) << 32;
  1682. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1683. "[%s][%d] i=%d sw_cookie=%d",
  1684. __func__, __LINE__, i, msdu_list->sw_cookie[i]);
  1685. }
  1686. *num_msdus = i;
  1687. }
  1688. /**
  1689. * hal_rx_msdu_reo_dst_ind_get: Gets the REO
  1690. * destination ring ID from the msdu desc info
  1691. *
  1692. * @msdu_link_desc : Opaque cookie pointer used by HAL to get to
  1693. * the current descriptor
  1694. *
  1695. * Return: dst_ind (REO destination ring ID)
  1696. */
  1697. static inline uint32_t
  1698. hal_rx_msdu_reo_dst_ind_get(hal_soc_handle_t hal_soc_hdl, void *msdu_link_desc)
  1699. {
  1700. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1701. struct rx_msdu_details *msdu_details;
  1702. struct rx_msdu_desc_info *msdu_desc_info;
  1703. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1704. uint32_t dst_ind;
  1705. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1706. /* The first msdu in the link should exsist */
  1707. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[0],
  1708. hal_soc);
  1709. dst_ind = HAL_RX_MSDU_REO_DST_IND_GET(msdu_desc_info);
  1710. return dst_ind;
  1711. }
  1712. /**
  1713. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  1714. * cookie from the REO destination ring element
  1715. *
  1716. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  1717. * the current descriptor
  1718. * @ buf_info: structure to return the buffer information
  1719. * Return: void
  1720. */
  1721. static inline
  1722. void hal_rx_reo_buf_paddr_get(hal_ring_desc_t rx_desc,
  1723. struct hal_buf_info *buf_info)
  1724. {
  1725. struct reo_destination_ring *reo_ring =
  1726. (struct reo_destination_ring *)rx_desc;
  1727. buf_info->paddr =
  1728. (HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_ring) |
  1729. ((uint64_t)(HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_ring)) << 32));
  1730. buf_info->sw_cookie = HAL_RX_REO_BUF_COOKIE_GET(reo_ring);
  1731. }
  1732. /**
  1733. * enum hal_reo_error_code: Indicates that type of buffer or descriptor
  1734. *
  1735. * @ HAL_RX_MSDU_BUF_ADDR_TYPE : Reo buffer address points to the MSDU buffer
  1736. * @ HAL_RX_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  1737. * descriptor
  1738. */
  1739. enum hal_rx_reo_buf_type {
  1740. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  1741. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  1742. };
  1743. #define HAL_RX_REO_BUF_TYPE_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1744. (REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_OFFSET >> 2))) & \
  1745. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_MASK) >> \
  1746. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_LSB)
  1747. #define HAL_RX_REO_QUEUE_NUMBER_GET(reo_desc) (((*(((uint32_t *)reo_desc) + \
  1748. (REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_OFFSET >> 2))) & \
  1749. REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_MASK) >> \
  1750. REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_LSB)
  1751. /**
  1752. * enum hal_reo_error_code: Error code describing the type of error detected
  1753. *
  1754. * @ HAL_REO_ERR_QUEUE_DESC_ADDR_0 : Reo queue descriptor provided in the
  1755. * REO_ENTRANCE ring is set to 0
  1756. * @ HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  1757. * @ HAL_REO_ERR_AMPDU_IN_NON_BA : AMPDU frame received without BA session
  1758. * having been setup
  1759. * @ HAL_REO_ERR_NON_BA_DUPLICATE : Non-BA session, SN equal to SSN,
  1760. * Retry bit set: duplicate frame
  1761. * @ HAL_REO_ERR_BA_DUPLICATE : BA session, duplicate frame
  1762. * @ HAL_REO_ERR_REGULAR_FRAME_2K_JUMP : A normal (management/data frame)
  1763. * received with 2K jump in SN
  1764. * @ HAL_REO_ERR_BAR_FRAME_2K_JUMP : A bar received with 2K jump in SSN
  1765. * @ HAL_REO_ERR_REGULAR_FRAME_OOR : A normal (management/data frame) received
  1766. * with SN falling within the OOR window
  1767. * @ HAL_REO_ERR_BAR_FRAME_OOR : A bar received with SSN falling within the
  1768. * OOR window
  1769. * @ HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION : A bar received without a BA session
  1770. * @ HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN : A bar received with SSN equal to SN
  1771. * @ HAL_REO_ERR_PN_CHECK_FAILED : PN Check Failed packet
  1772. * @ HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1773. * of the Seq_2k_error_detected_flag been set in the REO Queue descriptor
  1774. * @ HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1775. * of the pn_error_detected_flag been set in the REO Queue descriptor
  1776. * @ HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET : Frame is forwarded as a result of
  1777. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  1778. * in the process of making updates to this descriptor
  1779. */
  1780. enum hal_reo_error_code {
  1781. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  1782. HAL_REO_ERR_QUEUE_DESC_INVALID,
  1783. HAL_REO_ERR_AMPDU_IN_NON_BA,
  1784. HAL_REO_ERR_NON_BA_DUPLICATE,
  1785. HAL_REO_ERR_BA_DUPLICATE,
  1786. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  1787. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  1788. HAL_REO_ERR_REGULAR_FRAME_OOR,
  1789. HAL_REO_ERR_BAR_FRAME_OOR,
  1790. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  1791. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  1792. HAL_REO_ERR_PN_CHECK_FAILED,
  1793. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  1794. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  1795. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET,
  1796. HAL_REO_ERR_MAX
  1797. };
  1798. /**
  1799. * enum hal_rxdma_error_code: Code describing the type of RxDMA error detected
  1800. *
  1801. * @HAL_RXDMA_ERR_OVERFLOW: MPDU frame is not complete due to a FIFO overflow
  1802. * @ HAL_RXDMA_ERR_OVERFLOW : MPDU frame is not complete due to a FIFO
  1803. * overflow
  1804. * @ HAL_RXDMA_ERR_MPDU_LENGTH : MPDU frame is not complete due to receiving
  1805. * incomplete
  1806. * MPDU from the PHY
  1807. * @ HAL_RXDMA_ERR_FCS : FCS check on the MPDU frame failed
  1808. * @ HAL_RXDMA_ERR_DECRYPT : Decryption error
  1809. * @ HAL_RXDMA_ERR_TKIP_MIC : TKIP MIC error
  1810. * @ HAL_RXDMA_ERR_UNENCRYPTED : Received a frame that was expected to be
  1811. * encrypted but wasn’t
  1812. * @ HAL_RXDMA_ERR_MSDU_LEN : MSDU related length error
  1813. * @ HAL_RXDMA_ERR_MSDU_LIMIT : Number of MSDUs in the MPDUs exceeded
  1814. * the max allowed
  1815. * @ HAL_RXDMA_ERR_WIFI_PARSE : wifi parsing error
  1816. * @ HAL_RXDMA_ERR_AMSDU_PARSE : Amsdu parsing error
  1817. * @ HAL_RXDMA_ERR_SA_TIMEOUT : Source Address search timeout
  1818. * @ HAL_RXDMA_ERR_DA_TIMEOUT : Destination Address search timeout
  1819. * @ HAL_RXDMA_ERR_FLOW_TIMEOUT : Flow Search Timeout
  1820. * @ HAL_RXDMA_ERR_FLUSH_REQUEST : RxDMA FIFO Flush request
  1821. * @ HAL_RXDMA_ERR_WAR : RxDMA WAR dummy errors
  1822. */
  1823. enum hal_rxdma_error_code {
  1824. HAL_RXDMA_ERR_OVERFLOW = 0,
  1825. HAL_RXDMA_ERR_MPDU_LENGTH,
  1826. HAL_RXDMA_ERR_FCS,
  1827. HAL_RXDMA_ERR_DECRYPT,
  1828. HAL_RXDMA_ERR_TKIP_MIC,
  1829. HAL_RXDMA_ERR_UNENCRYPTED,
  1830. HAL_RXDMA_ERR_MSDU_LEN,
  1831. HAL_RXDMA_ERR_MSDU_LIMIT,
  1832. HAL_RXDMA_ERR_WIFI_PARSE,
  1833. HAL_RXDMA_ERR_AMSDU_PARSE,
  1834. HAL_RXDMA_ERR_SA_TIMEOUT,
  1835. HAL_RXDMA_ERR_DA_TIMEOUT,
  1836. HAL_RXDMA_ERR_FLOW_TIMEOUT,
  1837. HAL_RXDMA_ERR_FLUSH_REQUEST,
  1838. HAL_RXDMA_ERR_WAR = 31,
  1839. HAL_RXDMA_ERR_MAX
  1840. };
  1841. /**
  1842. * HW BM action settings in WBM release ring
  1843. */
  1844. #define HAL_BM_ACTION_PUT_IN_IDLE_LIST 0
  1845. #define HAL_BM_ACTION_RELEASE_MSDU_LIST 1
  1846. /**
  1847. * enum hal_rx_wbm_error_source: Indicates which module initiated the
  1848. * release of this buffer or descriptor
  1849. *
  1850. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1851. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1852. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1853. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1854. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1855. */
  1856. enum hal_rx_wbm_error_source {
  1857. HAL_RX_WBM_ERR_SRC_TQM = 0,
  1858. HAL_RX_WBM_ERR_SRC_RXDMA,
  1859. HAL_RX_WBM_ERR_SRC_REO,
  1860. HAL_RX_WBM_ERR_SRC_FW,
  1861. HAL_RX_WBM_ERR_SRC_SW,
  1862. };
  1863. /**
  1864. * enum hal_rx_wbm_buf_type: Indicates that type of buffer or descriptor
  1865. * released
  1866. *
  1867. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1868. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1869. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1870. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1871. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1872. */
  1873. enum hal_rx_wbm_buf_type {
  1874. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  1875. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  1876. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  1877. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  1878. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  1879. };
  1880. #define HAL_RX_REO_ERROR_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1881. (REO_DESTINATION_RING_7_REO_ERROR_CODE_OFFSET >> 2))) & \
  1882. REO_DESTINATION_RING_7_REO_ERROR_CODE_MASK) >> \
  1883. REO_DESTINATION_RING_7_REO_ERROR_CODE_LSB)
  1884. /**
  1885. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  1886. * PN check failure
  1887. *
  1888. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  1889. *
  1890. * Return: true: error caused by PN check, false: other error
  1891. */
  1892. static inline bool hal_rx_reo_is_pn_error(hal_ring_desc_t rx_desc)
  1893. {
  1894. struct reo_destination_ring *reo_desc =
  1895. (struct reo_destination_ring *)rx_desc;
  1896. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1897. HAL_REO_ERR_PN_CHECK_FAILED) |
  1898. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1899. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  1900. true : false;
  1901. }
  1902. /**
  1903. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  1904. * the sequence number
  1905. *
  1906. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1907. *
  1908. * Return: true: error caused by 2K jump, false: other error
  1909. */
  1910. static inline bool hal_rx_reo_is_2k_jump(hal_ring_desc_t rx_desc)
  1911. {
  1912. struct reo_destination_ring *reo_desc =
  1913. (struct reo_destination_ring *)rx_desc;
  1914. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1915. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) |
  1916. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1917. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  1918. true : false;
  1919. }
  1920. /**
  1921. * hal_rx_reo_is_oor_error() - Indicate if this error was caused by OOR
  1922. *
  1923. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1924. *
  1925. * Return: true: error caused by OOR, false: other error
  1926. */
  1927. static inline bool hal_rx_reo_is_oor_error(void *rx_desc)
  1928. {
  1929. struct reo_destination_ring *reo_desc =
  1930. (struct reo_destination_ring *)rx_desc;
  1931. return (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1932. HAL_REO_ERR_REGULAR_FRAME_OOR) ? true : false;
  1933. }
  1934. #define HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  1935. /**
  1936. * hal_dump_wbm_rel_desc() - dump wbm release descriptor
  1937. * @hal_desc: hardware descriptor pointer
  1938. *
  1939. * This function will print wbm release descriptor
  1940. *
  1941. * Return: none
  1942. */
  1943. static inline void hal_dump_wbm_rel_desc(void *src_srng_desc)
  1944. {
  1945. uint32_t *wbm_comp = (uint32_t *)src_srng_desc;
  1946. uint32_t i;
  1947. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1948. "Current Rx wbm release descriptor is");
  1949. for (i = 0; i < HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS; i++) {
  1950. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1951. "DWORD[i] = 0x%x", wbm_comp[i]);
  1952. }
  1953. }
  1954. /**
  1955. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  1956. *
  1957. * @ hal_soc_hdl : HAL version of the SOC pointer
  1958. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  1959. * @ buf_addr_info : void pointer to the buffer_addr_info
  1960. * @ bm_action : put in IDLE list or release to MSDU_LIST
  1961. *
  1962. * Return: void
  1963. */
  1964. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  1965. static inline
  1966. void hal_rx_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  1967. void *src_srng_desc,
  1968. hal_buff_addrinfo_t buf_addr_info,
  1969. uint8_t bm_action)
  1970. {
  1971. struct wbm_release_ring *wbm_rel_srng =
  1972. (struct wbm_release_ring *)src_srng_desc;
  1973. uint32_t addr_31_0;
  1974. uint8_t addr_39_32;
  1975. /* Structure copy !!! */
  1976. wbm_rel_srng->released_buff_or_desc_addr_info =
  1977. *((struct buffer_addr_info *)buf_addr_info);
  1978. addr_31_0 =
  1979. wbm_rel_srng->released_buff_or_desc_addr_info.buffer_addr_31_0;
  1980. addr_39_32 =
  1981. wbm_rel_srng->released_buff_or_desc_addr_info.buffer_addr_39_32;
  1982. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1983. RELEASE_SOURCE_MODULE, HAL_RX_WBM_ERR_SRC_SW);
  1984. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2, BM_ACTION,
  1985. bm_action);
  1986. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1987. BUFFER_OR_DESC_TYPE, HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC);
  1988. /* WBM error is indicated when any of the link descriptors given to
  1989. * WBM has a NULL address, and one those paths is the link descriptors
  1990. * released from host after processing RXDMA errors,
  1991. * or from Rx defrag path, and we want to add an assert here to ensure
  1992. * host is not releasing descriptors with NULL address.
  1993. */
  1994. if (qdf_unlikely(!addr_31_0 && !addr_39_32)) {
  1995. hal_dump_wbm_rel_desc(src_srng_desc);
  1996. qdf_assert_always(0);
  1997. }
  1998. }
  1999. /*
  2000. * hal_rx_msdu_link_desc_reinject: Re-injects the MSDU link descriptor to
  2001. * REO entrance ring
  2002. *
  2003. * @ soc: HAL version of the SOC pointer
  2004. * @ pa: Physical address of the MSDU Link Descriptor
  2005. * @ cookie: SW cookie to get to the virtual address
  2006. * @ error_enabled_reo_q: Argument to determine whether this needs to go
  2007. * to the error enabled REO queue
  2008. *
  2009. * Return: void
  2010. */
  2011. static inline void hal_rx_msdu_link_desc_reinject(struct hal_soc *soc,
  2012. uint64_t pa, uint32_t cookie, bool error_enabled_reo_q)
  2013. {
  2014. /* TODO */
  2015. }
  2016. /**
  2017. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  2018. * BUFFER_ADDR_INFO, give the RX descriptor
  2019. * (Assumption -- BUFFER_ADDR_INFO is the
  2020. * first field in the descriptor structure)
  2021. */
  2022. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) \
  2023. ((hal_link_desc_t)(ring_desc))
  2024. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  2025. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  2026. /**
  2027. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  2028. * from the BUFFER_ADDR_INFO structure
  2029. * given a REO destination ring descriptor.
  2030. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  2031. *
  2032. * Return: uint8_t (value of the return_buffer_manager)
  2033. */
  2034. static inline
  2035. uint8_t hal_rx_ret_buf_manager_get(hal_ring_desc_t ring_desc)
  2036. {
  2037. /*
  2038. * The following macro takes buf_addr_info as argument,
  2039. * but since buf_addr_info is the first field in ring_desc
  2040. * Hence the following call is OK
  2041. */
  2042. return HAL_RX_BUF_RBM_GET(ring_desc);
  2043. }
  2044. /*******************************************************************************
  2045. * RX WBM ERROR APIS
  2046. ******************************************************************************/
  2047. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  2048. (WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  2049. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >> \
  2050. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB)
  2051. /**
  2052. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  2053. * the frame to this release ring
  2054. *
  2055. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  2056. * frame to this queue
  2057. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  2058. * received routing instructions. No error within REO was detected
  2059. */
  2060. enum hal_rx_wbm_reo_push_reason {
  2061. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  2062. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  2063. };
  2064. /**
  2065. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  2066. * this release ring
  2067. *
  2068. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  2069. * this frame to this queue
  2070. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  2071. * per received routing instructions. No error within RXDMA was detected
  2072. */
  2073. enum hal_rx_wbm_rxdma_push_reason {
  2074. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  2075. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  2076. };
  2077. #define HAL_RX_WBM_FIRST_MSDU_GET(wbm_desc) \
  2078. (((*(((uint32_t *) wbm_desc) + \
  2079. (WBM_RELEASE_RING_4_FIRST_MSDU_OFFSET >> 2))) & \
  2080. WBM_RELEASE_RING_4_FIRST_MSDU_MASK) >> \
  2081. WBM_RELEASE_RING_4_FIRST_MSDU_LSB)
  2082. #define HAL_RX_WBM_LAST_MSDU_GET(wbm_desc) \
  2083. (((*(((uint32_t *) wbm_desc) + \
  2084. (WBM_RELEASE_RING_4_LAST_MSDU_OFFSET >> 2))) & \
  2085. WBM_RELEASE_RING_4_LAST_MSDU_MASK) >> \
  2086. WBM_RELEASE_RING_4_LAST_MSDU_LSB)
  2087. #define HAL_RX_WBM_BUF_COOKIE_GET(wbm_desc) \
  2088. HAL_RX_BUF_COOKIE_GET(&((struct wbm_release_ring *) \
  2089. wbm_desc)->released_buff_or_desc_addr_info)
  2090. /**
  2091. * hal_rx_dump_rx_attention_tlv: dump RX attention TLV in structured
  2092. * humman readable format.
  2093. * @ rx_attn: pointer the rx_attention TLV in pkt.
  2094. * @ dbg_level: log level.
  2095. *
  2096. * Return: void
  2097. */
  2098. static inline void hal_rx_dump_rx_attention_tlv(struct rx_attention *rx_attn,
  2099. uint8_t dbg_level)
  2100. {
  2101. hal_verbose_debug(
  2102. "rx_attention tlv (1/2) - "
  2103. "rxpcu_mpdu_filter_in_category: %x "
  2104. "sw_frame_group_id: %x "
  2105. "reserved_0: %x "
  2106. "phy_ppdu_id: %x "
  2107. "first_mpdu : %x "
  2108. "reserved_1a: %x "
  2109. "mcast_bcast: %x "
  2110. "ast_index_not_found: %x "
  2111. "ast_index_timeout: %x "
  2112. "power_mgmt: %x "
  2113. "non_qos: %x "
  2114. "null_data: %x "
  2115. "mgmt_type: %x "
  2116. "ctrl_type: %x "
  2117. "more_data: %x "
  2118. "eosp: %x "
  2119. "a_msdu_error: %x "
  2120. "fragment_flag: %x "
  2121. "order: %x "
  2122. "cce_match: %x "
  2123. "overflow_err: %x "
  2124. "msdu_length_err: %x "
  2125. "tcp_udp_chksum_fail: %x "
  2126. "ip_chksum_fail: %x "
  2127. "sa_idx_invalid: %x "
  2128. "da_idx_invalid: %x "
  2129. "reserved_1b: %x "
  2130. "rx_in_tx_decrypt_byp: %x ",
  2131. rx_attn->rxpcu_mpdu_filter_in_category,
  2132. rx_attn->sw_frame_group_id,
  2133. rx_attn->reserved_0,
  2134. rx_attn->phy_ppdu_id,
  2135. rx_attn->first_mpdu,
  2136. rx_attn->reserved_1a,
  2137. rx_attn->mcast_bcast,
  2138. rx_attn->ast_index_not_found,
  2139. rx_attn->ast_index_timeout,
  2140. rx_attn->power_mgmt,
  2141. rx_attn->non_qos,
  2142. rx_attn->null_data,
  2143. rx_attn->mgmt_type,
  2144. rx_attn->ctrl_type,
  2145. rx_attn->more_data,
  2146. rx_attn->eosp,
  2147. rx_attn->a_msdu_error,
  2148. rx_attn->fragment_flag,
  2149. rx_attn->order,
  2150. rx_attn->cce_match,
  2151. rx_attn->overflow_err,
  2152. rx_attn->msdu_length_err,
  2153. rx_attn->tcp_udp_chksum_fail,
  2154. rx_attn->ip_chksum_fail,
  2155. rx_attn->sa_idx_invalid,
  2156. rx_attn->da_idx_invalid,
  2157. rx_attn->reserved_1b,
  2158. rx_attn->rx_in_tx_decrypt_byp);
  2159. hal_verbose_debug(
  2160. "rx_attention tlv (2/2) - "
  2161. "encrypt_required: %x "
  2162. "directed: %x "
  2163. "buffer_fragment: %x "
  2164. "mpdu_length_err: %x "
  2165. "tkip_mic_err: %x "
  2166. "decrypt_err: %x "
  2167. "unencrypted_frame_err: %x "
  2168. "fcs_err: %x "
  2169. "flow_idx_timeout: %x "
  2170. "flow_idx_invalid: %x "
  2171. "wifi_parser_error: %x "
  2172. "amsdu_parser_error: %x "
  2173. "sa_idx_timeout: %x "
  2174. "da_idx_timeout: %x "
  2175. "msdu_limit_error: %x "
  2176. "da_is_valid: %x "
  2177. "da_is_mcbc: %x "
  2178. "sa_is_valid: %x "
  2179. "decrypt_status_code: %x "
  2180. "rx_bitmap_not_updated: %x "
  2181. "reserved_2: %x "
  2182. "msdu_done: %x ",
  2183. rx_attn->encrypt_required,
  2184. rx_attn->directed,
  2185. rx_attn->buffer_fragment,
  2186. rx_attn->mpdu_length_err,
  2187. rx_attn->tkip_mic_err,
  2188. rx_attn->decrypt_err,
  2189. rx_attn->unencrypted_frame_err,
  2190. rx_attn->fcs_err,
  2191. rx_attn->flow_idx_timeout,
  2192. rx_attn->flow_idx_invalid,
  2193. rx_attn->wifi_parser_error,
  2194. rx_attn->amsdu_parser_error,
  2195. rx_attn->sa_idx_timeout,
  2196. rx_attn->da_idx_timeout,
  2197. rx_attn->msdu_limit_error,
  2198. rx_attn->da_is_valid,
  2199. rx_attn->da_is_mcbc,
  2200. rx_attn->sa_is_valid,
  2201. rx_attn->decrypt_status_code,
  2202. rx_attn->rx_bitmap_not_updated,
  2203. rx_attn->reserved_2,
  2204. rx_attn->msdu_done);
  2205. }
  2206. static inline void hal_rx_dump_mpdu_start_tlv(struct rx_mpdu_start *mpdu_start,
  2207. uint8_t dbg_level,
  2208. struct hal_soc *hal)
  2209. {
  2210. hal->ops->hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level);
  2211. }
  2212. /**
  2213. * hal_rx_dump_msdu_end_tlv: dump RX msdu_end TLV in structured
  2214. * human readable format.
  2215. * @ msdu_end: pointer the msdu_end TLV in pkt.
  2216. * @ dbg_level: log level.
  2217. *
  2218. * Return: void
  2219. */
  2220. static inline void hal_rx_dump_msdu_end_tlv(struct hal_soc *hal_soc,
  2221. struct rx_msdu_end *msdu_end,
  2222. uint8_t dbg_level)
  2223. {
  2224. hal_soc->ops->hal_rx_dump_msdu_end_tlv(msdu_end, dbg_level);
  2225. }
  2226. /**
  2227. * hal_rx_dump_mpdu_end_tlv: dump RX mpdu_end TLV in structured
  2228. * human readable format.
  2229. * @ mpdu_end: pointer the mpdu_end TLV in pkt.
  2230. * @ dbg_level: log level.
  2231. *
  2232. * Return: void
  2233. */
  2234. static inline void hal_rx_dump_mpdu_end_tlv(struct rx_mpdu_end *mpdu_end,
  2235. uint8_t dbg_level)
  2236. {
  2237. hal_verbose_debug(
  2238. "rx_mpdu_end tlv - "
  2239. "rxpcu_mpdu_filter_in_category: %x "
  2240. "sw_frame_group_id: %x "
  2241. "phy_ppdu_id: %x "
  2242. "unsup_ktype_short_frame: %x "
  2243. "rx_in_tx_decrypt_byp: %x "
  2244. "overflow_err: %x "
  2245. "mpdu_length_err: %x "
  2246. "tkip_mic_err: %x "
  2247. "decrypt_err: %x "
  2248. "unencrypted_frame_err: %x "
  2249. "pn_fields_contain_valid_info: %x "
  2250. "fcs_err: %x "
  2251. "msdu_length_err: %x "
  2252. "rxdma0_destination_ring: %x "
  2253. "rxdma1_destination_ring: %x "
  2254. "decrypt_status_code: %x "
  2255. "rx_bitmap_not_updated: %x ",
  2256. mpdu_end->rxpcu_mpdu_filter_in_category,
  2257. mpdu_end->sw_frame_group_id,
  2258. mpdu_end->phy_ppdu_id,
  2259. mpdu_end->unsup_ktype_short_frame,
  2260. mpdu_end->rx_in_tx_decrypt_byp,
  2261. mpdu_end->overflow_err,
  2262. mpdu_end->mpdu_length_err,
  2263. mpdu_end->tkip_mic_err,
  2264. mpdu_end->decrypt_err,
  2265. mpdu_end->unencrypted_frame_err,
  2266. mpdu_end->pn_fields_contain_valid_info,
  2267. mpdu_end->fcs_err,
  2268. mpdu_end->msdu_length_err,
  2269. mpdu_end->rxdma0_destination_ring,
  2270. mpdu_end->rxdma1_destination_ring,
  2271. mpdu_end->decrypt_status_code,
  2272. mpdu_end->rx_bitmap_not_updated);
  2273. }
  2274. #ifdef NO_RX_PKT_HDR_TLV
  2275. static inline void hal_rx_dump_pkt_hdr_tlv(struct rx_pkt_tlvs *pkt_tlvs,
  2276. uint8_t dbg_level)
  2277. {
  2278. }
  2279. #else
  2280. /**
  2281. * hal_rx_dump_pkt_hdr_tlv: dump RX pkt header TLV in hex format
  2282. * @ pkt_hdr_tlv: pointer the pkt_hdr_tlv in pkt.
  2283. * @ dbg_level: log level.
  2284. *
  2285. * Return: void
  2286. */
  2287. static inline void hal_rx_dump_pkt_hdr_tlv(struct rx_pkt_tlvs *pkt_tlvs,
  2288. uint8_t dbg_level)
  2289. {
  2290. struct rx_pkt_hdr_tlv *pkt_hdr_tlv = &pkt_tlvs->pkt_hdr_tlv;
  2291. hal_verbose_debug(
  2292. "\n---------------\n"
  2293. "rx_pkt_hdr_tlv \n"
  2294. "---------------\n"
  2295. "phy_ppdu_id %d ",
  2296. pkt_hdr_tlv->phy_ppdu_id);
  2297. hal_verbose_hex_dump(pkt_hdr_tlv->rx_pkt_hdr, 128);
  2298. }
  2299. #endif
  2300. /**
  2301. * hal_srng_ring_id_get: API to retrieve ring id from hal ring
  2302. * structure
  2303. * @hal_ring: pointer to hal_srng structure
  2304. *
  2305. * Return: ring_id
  2306. */
  2307. static inline uint8_t hal_srng_ring_id_get(hal_ring_handle_t hal_ring_hdl)
  2308. {
  2309. return ((struct hal_srng *)hal_ring_hdl)->ring_id;
  2310. }
  2311. /* Rx MSDU link pointer info */
  2312. struct hal_rx_msdu_link_ptr_info {
  2313. struct rx_msdu_link msdu_link;
  2314. struct hal_buf_info msdu_link_buf_info;
  2315. };
  2316. /**
  2317. * hal_rx_get_pkt_tlvs(): Function to retrieve pkt tlvs from nbuf
  2318. *
  2319. * @nbuf: Pointer to data buffer field
  2320. * Returns: pointer to rx_pkt_tlvs
  2321. */
  2322. static inline
  2323. struct rx_pkt_tlvs *hal_rx_get_pkt_tlvs(uint8_t *rx_buf_start)
  2324. {
  2325. return (struct rx_pkt_tlvs *)rx_buf_start;
  2326. }
  2327. /**
  2328. * hal_rx_get_mpdu_info(): Function to retrieve mpdu info from pkt tlvs
  2329. *
  2330. * @pkt_tlvs: Pointer to pkt_tlvs
  2331. * Returns: pointer to rx_mpdu_info structure
  2332. */
  2333. static inline
  2334. struct rx_mpdu_info *hal_rx_get_mpdu_info(struct rx_pkt_tlvs *pkt_tlvs)
  2335. {
  2336. return &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start.rx_mpdu_info_details;
  2337. }
  2338. #define DOT11_SEQ_FRAG_MASK 0x000f
  2339. #define DOT11_FC1_MORE_FRAG_OFFSET 0x04
  2340. /**
  2341. * hal_rx_get_rx_fragment_number(): Function to retrieve rx fragment number
  2342. *
  2343. * @nbuf: Network buffer
  2344. * Returns: rx fragment number
  2345. */
  2346. static inline
  2347. uint8_t hal_rx_get_rx_fragment_number(struct hal_soc *hal_soc,
  2348. uint8_t *buf)
  2349. {
  2350. return hal_soc->ops->hal_rx_get_rx_fragment_number(buf);
  2351. }
  2352. #define HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(_rx_mpdu_info) \
  2353. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2354. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_OFFSET)), \
  2355. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_MASK, \
  2356. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_LSB))
  2357. /**
  2358. * hal_rx_get_rx_more_frag_bit(): Function to retrieve more fragment bit
  2359. *
  2360. * @nbuf: Network buffer
  2361. * Returns: rx more fragment bit
  2362. */
  2363. static inline
  2364. uint8_t hal_rx_get_rx_more_frag_bit(uint8_t *buf)
  2365. {
  2366. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2367. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2368. uint16_t frame_ctrl = 0;
  2369. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info) >>
  2370. DOT11_FC1_MORE_FRAG_OFFSET;
  2371. /* more fragment bit if at offset bit 4 */
  2372. return frame_ctrl;
  2373. }
  2374. /**
  2375. * hal_rx_get_frame_ctrl_field(): Function to retrieve frame control field
  2376. *
  2377. * @nbuf: Network buffer
  2378. * Returns: rx more fragment bit
  2379. *
  2380. */
  2381. static inline
  2382. uint16_t hal_rx_get_frame_ctrl_field(uint8_t *buf)
  2383. {
  2384. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2385. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2386. uint16_t frame_ctrl = 0;
  2387. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info);
  2388. return frame_ctrl;
  2389. }
  2390. /*
  2391. * hal_rx_msdu_is_wlan_mcast(): Check if the buffer is for multicast address
  2392. *
  2393. * @nbuf: Network buffer
  2394. * Returns: flag to indicate whether the nbuf has MC/BC address
  2395. */
  2396. static inline
  2397. uint32_t hal_rx_msdu_is_wlan_mcast(qdf_nbuf_t nbuf)
  2398. {
  2399. uint8 *buf = qdf_nbuf_data(nbuf);
  2400. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2401. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2402. return rx_attn->mcast_bcast;
  2403. }
  2404. /*
  2405. * hal_rx_get_mpdu_sequence_control_valid(): Get mpdu sequence control valid
  2406. * @hal_soc_hdl: hal soc handle
  2407. * @nbuf: Network buffer
  2408. *
  2409. * Return: value of sequence control valid field
  2410. */
  2411. static inline
  2412. uint8_t hal_rx_get_mpdu_sequence_control_valid(hal_soc_handle_t hal_soc_hdl,
  2413. uint8_t *buf)
  2414. {
  2415. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2416. return hal_soc->ops->hal_rx_get_mpdu_sequence_control_valid(buf);
  2417. }
  2418. /*
  2419. * hal_rx_get_mpdu_frame_control_valid(): Retrieves mpdu frame control valid
  2420. * @hal_soc_hdl: hal soc handle
  2421. * @nbuf: Network buffer
  2422. *
  2423. * Returns: value of frame control valid field
  2424. */
  2425. static inline
  2426. uint8_t hal_rx_get_mpdu_frame_control_valid(hal_soc_handle_t hal_soc_hdl,
  2427. uint8_t *buf)
  2428. {
  2429. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2430. return hal_soc->ops->hal_rx_get_mpdu_frame_control_valid(buf);
  2431. }
  2432. /**
  2433. * hal_rx_get_mpdu_mac_ad4_valid(): Retrieves if mpdu 4th addr is valid
  2434. * @hal_soc_hdl: hal soc handle
  2435. * @nbuf: Network buffer
  2436. * Returns: value of mpdu 4th address valid field
  2437. */
  2438. static inline
  2439. bool hal_rx_get_mpdu_mac_ad4_valid(hal_soc_handle_t hal_soc_hdl,
  2440. uint8_t *buf)
  2441. {
  2442. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2443. return hal_soc->ops->hal_rx_get_mpdu_mac_ad4_valid(buf);
  2444. }
  2445. /*
  2446. * hal_rx_clear_mpdu_desc_info(): Clears mpdu_desc_info
  2447. *
  2448. * @rx_mpdu_desc_info: HAL view of rx mpdu desc info
  2449. * Returns: None
  2450. */
  2451. static inline
  2452. void hal_rx_clear_mpdu_desc_info(
  2453. struct hal_rx_mpdu_desc_info *rx_mpdu_desc_info)
  2454. {
  2455. qdf_mem_zero(rx_mpdu_desc_info,
  2456. sizeof(*rx_mpdu_desc_info));
  2457. }
  2458. /*
  2459. * hal_rx_clear_msdu_link_ptr(): Clears msdu_link_ptr
  2460. *
  2461. * @msdu_link_ptr: HAL view of msdu link ptr
  2462. * @size: number of msdu link pointers
  2463. * Returns: None
  2464. */
  2465. static inline
  2466. void hal_rx_clear_msdu_link_ptr(struct hal_rx_msdu_link_ptr_info *msdu_link_ptr,
  2467. int size)
  2468. {
  2469. qdf_mem_zero(msdu_link_ptr,
  2470. (sizeof(*msdu_link_ptr) * size));
  2471. }
  2472. /*
  2473. * hal_rx_chain_msdu_links() - Chains msdu link pointers
  2474. * @msdu_link_ptr: msdu link pointer
  2475. * @mpdu_desc_info: mpdu descriptor info
  2476. *
  2477. * Build a list of msdus using msdu link pointer. If the
  2478. * number of msdus are more, chain them together
  2479. *
  2480. * Returns: Number of processed msdus
  2481. */
  2482. static inline
  2483. int hal_rx_chain_msdu_links(struct hal_soc *hal_soc, qdf_nbuf_t msdu,
  2484. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2485. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  2486. {
  2487. int j;
  2488. struct rx_msdu_link *msdu_link_ptr =
  2489. &msdu_link_ptr_info->msdu_link;
  2490. struct rx_msdu_link *prev_msdu_link_ptr = NULL;
  2491. struct rx_msdu_details *msdu_details =
  2492. hal_rx_link_desc_msdu0_ptr(msdu_link_ptr, hal_soc);
  2493. uint8_t num_msdus = mpdu_desc_info->msdu_count;
  2494. struct rx_msdu_desc_info *msdu_desc_info;
  2495. uint8_t fragno, more_frag;
  2496. uint8_t *rx_desc_info;
  2497. struct hal_rx_msdu_list msdu_list;
  2498. for (j = 0; j < num_msdus; j++) {
  2499. msdu_desc_info =
  2500. hal_rx_msdu_desc_info_get_ptr(&msdu_details[j],
  2501. hal_soc);
  2502. msdu_list.msdu_info[j].msdu_flags =
  2503. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  2504. msdu_list.msdu_info[j].msdu_len =
  2505. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  2506. msdu_list.sw_cookie[j] = HAL_RX_BUF_COOKIE_GET(
  2507. &msdu_details[j].buffer_addr_info_details);
  2508. }
  2509. /* Chain msdu links together */
  2510. if (prev_msdu_link_ptr) {
  2511. /* 31-0 bits of the physical address */
  2512. prev_msdu_link_ptr->
  2513. next_msdu_link_desc_addr_info.buffer_addr_31_0 =
  2514. msdu_link_ptr_info->msdu_link_buf_info.paddr &
  2515. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK;
  2516. /* 39-32 bits of the physical address */
  2517. prev_msdu_link_ptr->
  2518. next_msdu_link_desc_addr_info.buffer_addr_39_32
  2519. = ((msdu_link_ptr_info->msdu_link_buf_info.paddr
  2520. >> 32) &
  2521. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK);
  2522. prev_msdu_link_ptr->
  2523. next_msdu_link_desc_addr_info.sw_buffer_cookie =
  2524. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie;
  2525. }
  2526. /* There is space for only 6 MSDUs in a MSDU link descriptor */
  2527. if (num_msdus < HAL_RX_NUM_MSDU_DESC) {
  2528. /* mark first and last MSDUs */
  2529. rx_desc_info = qdf_nbuf_data(msdu);
  2530. fragno = hal_rx_get_rx_fragment_number(hal_soc, rx_desc_info);
  2531. more_frag = hal_rx_get_rx_more_frag_bit(rx_desc_info);
  2532. /* TODO: create skb->fragslist[] */
  2533. if (more_frag == 0) {
  2534. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2535. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK;
  2536. } else if (fragno == 1) {
  2537. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2538. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK;
  2539. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2540. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK;
  2541. }
  2542. num_msdus++;
  2543. /* Number of MSDUs per mpdu descriptor is updated */
  2544. mpdu_desc_info->msdu_count += num_msdus;
  2545. } else {
  2546. num_msdus = 0;
  2547. prev_msdu_link_ptr = msdu_link_ptr;
  2548. }
  2549. return num_msdus;
  2550. }
  2551. /*
  2552. * hal_rx_defrag_update_src_ring_desc(): updates reo src ring desc
  2553. *
  2554. * @ring_desc: HAL view of ring descriptor
  2555. * @mpdu_des_info: saved mpdu desc info
  2556. * @msdu_link_ptr: saved msdu link ptr
  2557. *
  2558. * API used explicitly for rx defrag to update ring desc with
  2559. * mpdu desc info and msdu link ptr before reinjecting the
  2560. * packet back to REO
  2561. *
  2562. * Returns: None
  2563. */
  2564. static inline
  2565. void hal_rx_defrag_update_src_ring_desc(
  2566. hal_ring_desc_t ring_desc,
  2567. void *saved_mpdu_desc_info,
  2568. struct hal_rx_msdu_link_ptr_info *saved_msdu_link_ptr)
  2569. {
  2570. struct reo_entrance_ring *reo_ent_ring;
  2571. struct rx_mpdu_desc_info *reo_ring_mpdu_desc_info;
  2572. struct hal_buf_info buf_info;
  2573. reo_ent_ring = (struct reo_entrance_ring *)ring_desc;
  2574. reo_ring_mpdu_desc_info = &reo_ent_ring->
  2575. reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  2576. qdf_mem_copy(&reo_ring_mpdu_desc_info, saved_mpdu_desc_info,
  2577. sizeof(*reo_ring_mpdu_desc_info));
  2578. /*
  2579. * TODO: Check for additional fields that need configuration in
  2580. * reo_ring_mpdu_desc_info
  2581. */
  2582. /* Update msdu_link_ptr in the reo entrance ring */
  2583. hal_rx_reo_buf_paddr_get(ring_desc, &buf_info);
  2584. buf_info.paddr = saved_msdu_link_ptr->msdu_link_buf_info.paddr;
  2585. buf_info.sw_cookie =
  2586. saved_msdu_link_ptr->msdu_link_buf_info.sw_cookie;
  2587. }
  2588. /*
  2589. * hal_rx_defrag_save_info_from_ring_desc(): Saves info from ring desc
  2590. *
  2591. * @msdu_link_desc_va: msdu link descriptor handle
  2592. * @msdu_link_ptr_info: HAL view of msdu link pointer info
  2593. *
  2594. * API used to save msdu link information along with physical
  2595. * address. The API also copues the sw cookie.
  2596. *
  2597. * Returns: None
  2598. */
  2599. static inline
  2600. void hal_rx_defrag_save_info_from_ring_desc(void *msdu_link_desc_va,
  2601. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2602. struct hal_buf_info *hbi)
  2603. {
  2604. struct rx_msdu_link *msdu_link_ptr =
  2605. (struct rx_msdu_link *)msdu_link_desc_va;
  2606. qdf_mem_copy(&msdu_link_ptr_info->msdu_link, msdu_link_ptr,
  2607. sizeof(struct rx_msdu_link));
  2608. msdu_link_ptr_info->msdu_link_buf_info.paddr = hbi->paddr;
  2609. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie = hbi->sw_cookie;
  2610. }
  2611. /*
  2612. * hal_rx_get_desc_len(): Returns rx descriptor length
  2613. *
  2614. * Returns the size of rx_pkt_tlvs which follows the
  2615. * data in the nbuf
  2616. *
  2617. * Returns: Length of rx descriptor
  2618. */
  2619. static inline
  2620. uint16_t hal_rx_get_desc_len(void)
  2621. {
  2622. return SIZE_OF_DATA_RX_TLV;
  2623. }
  2624. /*
  2625. * hal_rx_reo_ent_rxdma_push_reason_get(): Retrieves RXDMA push reason from
  2626. * reo_entrance_ring descriptor
  2627. *
  2628. * @reo_ent_desc: reo_entrance_ring descriptor
  2629. * Returns: value of rxdma_push_reason
  2630. */
  2631. static inline
  2632. uint8_t hal_rx_reo_ent_rxdma_push_reason_get(hal_rxdma_desc_t reo_ent_desc)
  2633. {
  2634. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2635. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_OFFSET)),
  2636. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_MASK,
  2637. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_LSB);
  2638. }
  2639. /**
  2640. * hal_rx_reo_ent_rxdma_error_code_get(): Retrieves RXDMA error code from
  2641. * reo_entrance_ring descriptor
  2642. * @reo_ent_desc: reo_entrance_ring descriptor
  2643. * Return: value of rxdma_error_code
  2644. */
  2645. static inline
  2646. uint8_t hal_rx_reo_ent_rxdma_error_code_get(hal_rxdma_desc_t reo_ent_desc)
  2647. {
  2648. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2649. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_OFFSET)),
  2650. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_MASK,
  2651. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_LSB);
  2652. }
  2653. /**
  2654. * hal_rx_wbm_err_info_get(): Retrieves WBM error code and reason and
  2655. * save it to hal_wbm_err_desc_info structure passed by caller
  2656. * @wbm_desc: wbm ring descriptor
  2657. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2658. * Return: void
  2659. */
  2660. static inline void hal_rx_wbm_err_info_get(void *wbm_desc,
  2661. struct hal_wbm_err_desc_info *wbm_er_info,
  2662. hal_soc_handle_t hal_soc_hdl)
  2663. {
  2664. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2665. hal_soc->ops->hal_rx_wbm_err_info_get(wbm_desc, (void *)wbm_er_info);
  2666. }
  2667. /**
  2668. * hal_rx_wbm_err_info_set_in_tlv(): Save the wbm error codes and reason to
  2669. * the reserved bytes of rx_tlv_hdr
  2670. * @buf: start of rx_tlv_hdr
  2671. * @wbm_er_info: hal_wbm_err_desc_info structure
  2672. * Return: void
  2673. */
  2674. static inline void hal_rx_wbm_err_info_set_in_tlv(uint8_t *buf,
  2675. struct hal_wbm_err_desc_info *wbm_er_info)
  2676. {
  2677. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2678. qdf_mem_copy(pkt_tlvs->rx_padding0, wbm_er_info,
  2679. sizeof(struct hal_wbm_err_desc_info));
  2680. }
  2681. /**
  2682. * hal_rx_wbm_err_info_get_from_tlv(): retrieve wbm error codes and reason from
  2683. * the reserved bytes of rx_tlv_hdr.
  2684. * @buf: start of rx_tlv_hdr
  2685. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2686. * Return: void
  2687. */
  2688. static inline void hal_rx_wbm_err_info_get_from_tlv(uint8_t *buf,
  2689. struct hal_wbm_err_desc_info *wbm_er_info)
  2690. {
  2691. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2692. qdf_mem_copy(wbm_er_info, pkt_tlvs->rx_padding0,
  2693. sizeof(struct hal_wbm_err_desc_info));
  2694. }
  2695. /**
  2696. * hal_rx_mon_dest_set_buffer_info_to_tlv(): Save the mon dest frame info
  2697. * into the reserved bytes of rx_tlv_hdr.
  2698. * @buf: start of rx_tlv_hdr
  2699. * @buf_info: hal_rx_mon_dest_buf_info structure
  2700. *
  2701. * Return: void
  2702. */
  2703. static inline
  2704. void hal_rx_mon_dest_set_buffer_info_to_tlv(uint8_t *buf,
  2705. struct hal_rx_mon_dest_buf_info *buf_info)
  2706. {
  2707. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2708. qdf_mem_copy(pkt_tlvs->rx_padding0, buf_info,
  2709. sizeof(struct hal_rx_mon_dest_buf_info));
  2710. }
  2711. /**
  2712. * hal_rx_mon_dest_get_buffer_info_from_tlv(): Retrieve mon dest frame info
  2713. * from the reserved bytes of rx_tlv_hdr.
  2714. * @buf: start of rx_tlv_hdr
  2715. * @buf_info: hal_rx_mon_dest_buf_info structure
  2716. *
  2717. * Return: void
  2718. */
  2719. static inline
  2720. void hal_rx_mon_dest_get_buffer_info_from_tlv(uint8_t *buf,
  2721. struct hal_rx_mon_dest_buf_info *buf_info)
  2722. {
  2723. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2724. qdf_mem_copy(buf_info, pkt_tlvs->rx_padding0,
  2725. sizeof(struct hal_rx_mon_dest_buf_info));
  2726. }
  2727. /**
  2728. * hal_rx_wbm_err_msdu_continuation_get(): Get wbm msdu continuation
  2729. * bit from wbm release ring descriptor
  2730. * @wbm_desc: wbm ring descriptor
  2731. * Return: uint8_t
  2732. */
  2733. static inline
  2734. uint8_t hal_rx_wbm_err_msdu_continuation_get(hal_soc_handle_t hal_soc_hdl,
  2735. void *wbm_desc)
  2736. {
  2737. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2738. return hal_soc->ops->hal_rx_wbm_err_msdu_continuation_get(wbm_desc);
  2739. }
  2740. #define HAL_RX_MSDU_START_NSS_GET(_rx_msdu_start) \
  2741. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \
  2742. RX_MSDU_START_5_NSS_OFFSET)), \
  2743. RX_MSDU_START_5_NSS_MASK, \
  2744. RX_MSDU_START_5_NSS_LSB))
  2745. /**
  2746. * hal_rx_mon_hw_desc_get_mpdu_status: Retrieve MPDU status
  2747. *
  2748. * @ hal_soc: HAL version of the SOC pointer
  2749. * @ hw_desc_addr: Start address of Rx HW TLVs
  2750. * @ rs: Status for monitor mode
  2751. *
  2752. * Return: void
  2753. */
  2754. static inline
  2755. void hal_rx_mon_hw_desc_get_mpdu_status(hal_soc_handle_t hal_soc_hdl,
  2756. void *hw_desc_addr,
  2757. struct mon_rx_status *rs)
  2758. {
  2759. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2760. hal_soc->ops->hal_rx_mon_hw_desc_get_mpdu_status(hw_desc_addr, rs);
  2761. }
  2762. /*
  2763. * hal_rx_get_tlv(): API to get the tlv
  2764. *
  2765. * @hal_soc: HAL version of the SOC pointer
  2766. * @rx_tlv: TLV data extracted from the rx packet
  2767. * Return: uint8_t
  2768. */
  2769. static inline uint8_t hal_rx_get_tlv(struct hal_soc *hal_soc, void *rx_tlv)
  2770. {
  2771. return hal_soc->ops->hal_rx_get_tlv(rx_tlv);
  2772. }
  2773. /*
  2774. * hal_rx_msdu_start_nss_get(): API to get the NSS
  2775. * Interval from rx_msdu_start
  2776. *
  2777. * @hal_soc: HAL version of the SOC pointer
  2778. * @buf: pointer to the start of RX PKT TLV header
  2779. * Return: uint32_t(nss)
  2780. */
  2781. static inline
  2782. uint32_t hal_rx_msdu_start_nss_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2783. {
  2784. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2785. return hal_soc->ops->hal_rx_msdu_start_nss_get(buf);
  2786. }
  2787. /**
  2788. * hal_rx_dump_msdu_start_tlv: dump RX msdu_start TLV in structured
  2789. * human readable format.
  2790. * @ msdu_start: pointer the msdu_start TLV in pkt.
  2791. * @ dbg_level: log level.
  2792. *
  2793. * Return: void
  2794. */
  2795. static inline void hal_rx_dump_msdu_start_tlv(struct hal_soc *hal_soc,
  2796. struct rx_msdu_start *msdu_start,
  2797. uint8_t dbg_level)
  2798. {
  2799. hal_soc->ops->hal_rx_dump_msdu_start_tlv(msdu_start, dbg_level);
  2800. }
  2801. /**
  2802. * hal_rx_mpdu_start_tid_get - Return tid info from the rx mpdu start
  2803. * info details
  2804. *
  2805. * @ buf - Pointer to buffer containing rx pkt tlvs.
  2806. *
  2807. *
  2808. */
  2809. static inline uint32_t hal_rx_mpdu_start_tid_get(hal_soc_handle_t hal_soc_hdl,
  2810. uint8_t *buf)
  2811. {
  2812. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2813. return hal_soc->ops->hal_rx_mpdu_start_tid_get(buf);
  2814. }
  2815. /*
  2816. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  2817. * Interval from rx_msdu_start
  2818. *
  2819. * @buf: pointer to the start of RX PKT TLV header
  2820. * Return: uint32_t(reception_type)
  2821. */
  2822. static inline
  2823. uint32_t hal_rx_msdu_start_reception_type_get(hal_soc_handle_t hal_soc_hdl,
  2824. uint8_t *buf)
  2825. {
  2826. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2827. return hal_soc->ops->hal_rx_msdu_start_reception_type_get(buf);
  2828. }
  2829. /**
  2830. * hal_rx_dump_pkt_tlvs: API to print all member elements of
  2831. * RX TLVs
  2832. * @ buf: pointer the pkt buffer.
  2833. * @ dbg_level: log level.
  2834. *
  2835. * Return: void
  2836. */
  2837. static inline void hal_rx_dump_pkt_tlvs(hal_soc_handle_t hal_soc_hdl,
  2838. uint8_t *buf, uint8_t dbg_level)
  2839. {
  2840. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2841. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2842. struct rx_mpdu_start *mpdu_start =
  2843. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  2844. struct rx_msdu_start *msdu_start =
  2845. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  2846. struct rx_mpdu_end *mpdu_end = &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  2847. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  2848. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2849. hal_rx_dump_rx_attention_tlv(rx_attn, dbg_level);
  2850. hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level, hal_soc);
  2851. hal_rx_dump_msdu_start_tlv(hal_soc, msdu_start, dbg_level);
  2852. hal_rx_dump_mpdu_end_tlv(mpdu_end, dbg_level);
  2853. hal_rx_dump_msdu_end_tlv(hal_soc, msdu_end, dbg_level);
  2854. hal_rx_dump_pkt_hdr_tlv(pkt_tlvs, dbg_level);
  2855. }
  2856. /**
  2857. * hal_reo_status_get_header_generic - Process reo desc info
  2858. * @d - Pointer to reo descriptior
  2859. * @b - tlv type info
  2860. * @h - Pointer to hal_reo_status_header where info to be stored
  2861. * @hal- pointer to hal_soc structure
  2862. * Return - none.
  2863. *
  2864. */
  2865. static inline
  2866. void hal_reo_status_get_header(uint32_t *d, int b,
  2867. void *h, struct hal_soc *hal_soc)
  2868. {
  2869. hal_soc->ops->hal_reo_status_get_header(d, b, h);
  2870. }
  2871. /**
  2872. * hal_rx_desc_is_first_msdu() - Check if first msdu
  2873. *
  2874. * @hal_soc_hdl: hal_soc handle
  2875. * @hw_desc_addr: hardware descriptor address
  2876. *
  2877. * Return: 0 - success/ non-zero failure
  2878. */
  2879. static inline
  2880. uint32_t hal_rx_desc_is_first_msdu(hal_soc_handle_t hal_soc_hdl,
  2881. void *hw_desc_addr)
  2882. {
  2883. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2884. return hal_soc->ops->hal_rx_desc_is_first_msdu(hw_desc_addr);
  2885. }
  2886. static inline
  2887. uint32_t
  2888. HAL_RX_DESC_GET_DECAP_FORMAT(void *hw_desc_addr) {
  2889. struct rx_msdu_start *rx_msdu_start;
  2890. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  2891. rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start;
  2892. return HAL_RX_GET(rx_msdu_start, RX_MSDU_START_2, DECAP_FORMAT);
  2893. }
  2894. #ifdef NO_RX_PKT_HDR_TLV
  2895. static inline
  2896. uint8_t *
  2897. HAL_RX_DESC_GET_80211_HDR(void *hw_desc_addr) {
  2898. uint8_t *rx_pkt_hdr;
  2899. struct rx_mon_pkt_tlvs *rx_desc =
  2900. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  2901. rx_pkt_hdr = &rx_desc->pkt_hdr_tlv.rx_pkt_hdr[0];
  2902. return rx_pkt_hdr;
  2903. }
  2904. #else
  2905. static inline
  2906. uint8_t *
  2907. HAL_RX_DESC_GET_80211_HDR(void *hw_desc_addr) {
  2908. uint8_t *rx_pkt_hdr;
  2909. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  2910. rx_pkt_hdr = &rx_desc->pkt_hdr_tlv.rx_pkt_hdr[0];
  2911. return rx_pkt_hdr;
  2912. }
  2913. #endif
  2914. static inline
  2915. bool HAL_IS_DECAP_FORMAT_RAW(hal_soc_handle_t hal_soc_hdl,
  2916. uint8_t *rx_tlv_hdr)
  2917. {
  2918. uint8_t decap_format;
  2919. if (hal_rx_desc_is_first_msdu(hal_soc_hdl, rx_tlv_hdr)) {
  2920. decap_format = HAL_RX_DESC_GET_DECAP_FORMAT(rx_tlv_hdr);
  2921. if (decap_format == HAL_HW_RX_DECAP_FORMAT_RAW)
  2922. return true;
  2923. }
  2924. return false;
  2925. }
  2926. /**
  2927. * hal_rx_msdu_fse_metadata_get: API to get FSE metadata
  2928. * from rx_msdu_end TLV
  2929. * @buf: pointer to the start of RX PKT TLV headers
  2930. *
  2931. * Return: fse metadata value from MSDU END TLV
  2932. */
  2933. static inline uint32_t
  2934. hal_rx_msdu_fse_metadata_get(hal_soc_handle_t hal_soc_hdl,
  2935. uint8_t *buf)
  2936. {
  2937. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2938. return hal_soc->ops->hal_rx_msdu_fse_metadata_get(buf);
  2939. }
  2940. /**
  2941. * hal_rx_msdu_flow_idx_get: API to get flow index
  2942. * from rx_msdu_end TLV
  2943. * @buf: pointer to the start of RX PKT TLV headers
  2944. *
  2945. * Return: flow index value from MSDU END TLV
  2946. */
  2947. static inline uint32_t
  2948. hal_rx_msdu_flow_idx_get(hal_soc_handle_t hal_soc_hdl,
  2949. uint8_t *buf)
  2950. {
  2951. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2952. return hal_soc->ops->hal_rx_msdu_flow_idx_get(buf);
  2953. }
  2954. /**
  2955. * hal_rx_msdu_flow_idx_timeout: API to get flow index timeout
  2956. * from rx_msdu_end TLV
  2957. * @buf: pointer to the start of RX PKT TLV headers
  2958. *
  2959. * Return: flow index timeout value from MSDU END TLV
  2960. */
  2961. static inline bool
  2962. hal_rx_msdu_flow_idx_timeout(hal_soc_handle_t hal_soc_hdl,
  2963. uint8_t *buf)
  2964. {
  2965. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2966. return hal_soc->ops->hal_rx_msdu_flow_idx_timeout(buf);
  2967. }
  2968. /**
  2969. * hal_rx_msdu_flow_idx_invalid: API to get flow index invalid
  2970. * from rx_msdu_end TLV
  2971. * @buf: pointer to the start of RX PKT TLV headers
  2972. *
  2973. * Return: flow index invalid value from MSDU END TLV
  2974. */
  2975. static inline bool
  2976. hal_rx_msdu_flow_idx_invalid(hal_soc_handle_t hal_soc_hdl,
  2977. uint8_t *buf)
  2978. {
  2979. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2980. return hal_soc->ops->hal_rx_msdu_flow_idx_invalid(buf);
  2981. }
  2982. /**
  2983. * hal_rx_hw_desc_get_ppduid_get() - Retrieve ppdu id
  2984. * @hal_soc_hdl: hal_soc handle
  2985. * @rx_tlv_hdr: Rx_tlv_hdr
  2986. * @rxdma_dst_ring_desc: Rx HW descriptor
  2987. *
  2988. * Return: ppdu id
  2989. */
  2990. static inline
  2991. uint32_t hal_rx_hw_desc_get_ppduid_get(hal_soc_handle_t hal_soc_hdl,
  2992. void *rx_tlv_hdr,
  2993. void *rxdma_dst_ring_desc)
  2994. {
  2995. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2996. return hal_soc->ops->hal_rx_hw_desc_get_ppduid_get(rx_tlv_hdr,
  2997. rxdma_dst_ring_desc);
  2998. }
  2999. /**
  3000. * hal_rx_msdu_end_sa_sw_peer_id_get() - get sw peer id
  3001. * @hal_soc_hdl: hal_soc handle
  3002. * @buf: rx tlv address
  3003. *
  3004. * Return: sw peer id
  3005. */
  3006. static inline
  3007. uint32_t hal_rx_msdu_end_sa_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  3008. uint8_t *buf)
  3009. {
  3010. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3011. if ((!hal_soc) || (!hal_soc->ops)) {
  3012. hal_err("hal handle is NULL");
  3013. QDF_BUG(0);
  3014. return QDF_STATUS_E_INVAL;
  3015. }
  3016. if (hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get)
  3017. return hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get(buf);
  3018. return QDF_STATUS_E_INVAL;
  3019. }
  3020. static inline
  3021. void *hal_rx_msdu0_buffer_addr_lsb(hal_soc_handle_t hal_soc_hdl,
  3022. void *link_desc_addr)
  3023. {
  3024. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3025. return hal_soc->ops->hal_rx_msdu0_buffer_addr_lsb(link_desc_addr);
  3026. }
  3027. static inline
  3028. void *hal_rx_msdu_desc_info_ptr_get(hal_soc_handle_t hal_soc_hdl,
  3029. void *msdu_addr)
  3030. {
  3031. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3032. return hal_soc->ops->hal_rx_msdu_desc_info_ptr_get(msdu_addr);
  3033. }
  3034. static inline
  3035. void *hal_ent_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  3036. void *hw_addr)
  3037. {
  3038. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3039. return hal_soc->ops->hal_ent_mpdu_desc_info(hw_addr);
  3040. }
  3041. static inline
  3042. void *hal_dst_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  3043. void *hw_addr)
  3044. {
  3045. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3046. return hal_soc->ops->hal_dst_mpdu_desc_info(hw_addr);
  3047. }
  3048. static inline
  3049. uint8_t hal_rx_get_fc_valid(hal_soc_handle_t hal_soc_hdl,
  3050. uint8_t *buf)
  3051. {
  3052. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3053. return hal_soc->ops->hal_rx_get_fc_valid(buf);
  3054. }
  3055. static inline
  3056. uint8_t hal_rx_get_to_ds_flag(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  3057. {
  3058. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3059. return hal_soc->ops->hal_rx_get_to_ds_flag(buf);
  3060. }
  3061. static inline
  3062. uint8_t hal_rx_get_mac_addr2_valid(hal_soc_handle_t hal_soc_hdl,
  3063. uint8_t *buf)
  3064. {
  3065. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3066. return hal_soc->ops->hal_rx_get_mac_addr2_valid(buf);
  3067. }
  3068. static inline
  3069. uint8_t hal_rx_get_filter_category(hal_soc_handle_t hal_soc_hdl,
  3070. uint8_t *buf)
  3071. {
  3072. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3073. return hal_soc->ops->hal_rx_get_filter_category(buf);
  3074. }
  3075. static inline
  3076. uint32_t hal_rx_get_ppdu_id(hal_soc_handle_t hal_soc_hdl,
  3077. uint8_t *buf)
  3078. {
  3079. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3080. return hal_soc->ops->hal_rx_get_ppdu_id(buf);
  3081. }
  3082. /**
  3083. * hal_reo_config(): Set reo config parameters
  3084. * @soc: hal soc handle
  3085. * @reg_val: value to be set
  3086. * @reo_params: reo parameters
  3087. *
  3088. * Return: void
  3089. */
  3090. static inline
  3091. void hal_reo_config(struct hal_soc *hal_soc,
  3092. uint32_t reg_val,
  3093. struct hal_reo_params *reo_params)
  3094. {
  3095. hal_soc->ops->hal_reo_config(hal_soc,
  3096. reg_val,
  3097. reo_params);
  3098. }
  3099. /**
  3100. * hal_rx_msdu_get_flow_params: API to get flow index,
  3101. * flow index invalid and flow index timeout from rx_msdu_end TLV
  3102. * @buf: pointer to the start of RX PKT TLV headers
  3103. * @flow_invalid: pointer to return value of flow_idx_valid
  3104. * @flow_timeout: pointer to return value of flow_idx_timeout
  3105. * @flow_index: pointer to return value of flow_idx
  3106. *
  3107. * Return: none
  3108. */
  3109. static inline void
  3110. hal_rx_msdu_get_flow_params(hal_soc_handle_t hal_soc_hdl,
  3111. uint8_t *buf,
  3112. bool *flow_invalid,
  3113. bool *flow_timeout,
  3114. uint32_t *flow_index)
  3115. {
  3116. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3117. if ((!hal_soc) || (!hal_soc->ops)) {
  3118. hal_err("hal handle is NULL");
  3119. QDF_BUG(0);
  3120. return;
  3121. }
  3122. if (hal_soc->ops->hal_rx_msdu_get_flow_params)
  3123. hal_soc->ops->
  3124. hal_rx_msdu_get_flow_params(buf,
  3125. flow_invalid,
  3126. flow_timeout,
  3127. flow_index);
  3128. }
  3129. static inline
  3130. uint16_t hal_rx_tlv_get_tcp_chksum(hal_soc_handle_t hal_soc_hdl,
  3131. uint8_t *buf)
  3132. {
  3133. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3134. return hal_soc->ops->hal_rx_tlv_get_tcp_chksum(buf);
  3135. }
  3136. static inline
  3137. uint16_t hal_rx_get_rx_sequence(hal_soc_handle_t hal_soc_hdl,
  3138. uint8_t *buf)
  3139. {
  3140. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3141. return hal_soc->ops->hal_rx_get_rx_sequence(buf);
  3142. }
  3143. static inline void
  3144. hal_rx_get_bb_info(hal_soc_handle_t hal_soc_hdl,
  3145. void *rx_tlv,
  3146. void *ppdu_info)
  3147. {
  3148. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3149. if (hal_soc->ops->hal_rx_get_bb_info)
  3150. hal_soc->ops->hal_rx_get_bb_info(rx_tlv, ppdu_info);
  3151. }
  3152. static inline void
  3153. hal_rx_get_rtt_info(hal_soc_handle_t hal_soc_hdl,
  3154. void *rx_tlv,
  3155. void *ppdu_info)
  3156. {
  3157. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3158. if (hal_soc->ops->hal_rx_get_rtt_info)
  3159. hal_soc->ops->hal_rx_get_rtt_info(rx_tlv, ppdu_info);
  3160. }
  3161. /**
  3162. * hal_rx_msdu_metadata_get(): API to get the
  3163. * fast path information from rx_msdu_end TLV
  3164. *
  3165. * @ hal_soc_hdl: DP soc handle
  3166. * @ buf: pointer to the start of RX PKT TLV headers
  3167. * @ msdu_metadata: Structure to hold msdu end information
  3168. * Return: none
  3169. */
  3170. static inline void
  3171. hal_rx_msdu_metadata_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  3172. struct hal_rx_msdu_metadata *msdu_md)
  3173. {
  3174. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3175. return hal_soc->ops->hal_rx_msdu_packet_metadata_get(buf, msdu_md);
  3176. }
  3177. /**
  3178. * hal_rx_get_fisa_cumulative_l4_checksum: API to get cumulative_l4_checksum
  3179. * from rx_msdu_end TLV
  3180. * @buf: pointer to the start of RX PKT TLV headers
  3181. *
  3182. * Return: cumulative_l4_checksum
  3183. */
  3184. static inline uint16_t
  3185. hal_rx_get_fisa_cumulative_l4_checksum(hal_soc_handle_t hal_soc_hdl,
  3186. uint8_t *buf)
  3187. {
  3188. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3189. if (!hal_soc || !hal_soc->ops) {
  3190. hal_err("hal handle is NULL");
  3191. QDF_BUG(0);
  3192. return 0;
  3193. }
  3194. if (!hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum)
  3195. return 0;
  3196. return hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum(buf);
  3197. }
  3198. /**
  3199. * hal_rx_get_fisa_cumulative_ip_length: API to get cumulative_ip_length
  3200. * from rx_msdu_end TLV
  3201. * @buf: pointer to the start of RX PKT TLV headers
  3202. *
  3203. * Return: cumulative_ip_length
  3204. */
  3205. static inline uint16_t
  3206. hal_rx_get_fisa_cumulative_ip_length(hal_soc_handle_t hal_soc_hdl,
  3207. uint8_t *buf)
  3208. {
  3209. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3210. if (!hal_soc || !hal_soc->ops) {
  3211. hal_err("hal handle is NULL");
  3212. QDF_BUG(0);
  3213. return 0;
  3214. }
  3215. if (hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length)
  3216. return hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length(buf);
  3217. return 0;
  3218. }
  3219. /**
  3220. * hal_rx_get_udp_proto: API to get UDP proto field
  3221. * from rx_msdu_start TLV
  3222. * @buf: pointer to the start of RX PKT TLV headers
  3223. *
  3224. * Return: UDP proto field value
  3225. */
  3226. static inline bool
  3227. hal_rx_get_udp_proto(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  3228. {
  3229. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3230. if (!hal_soc || !hal_soc->ops) {
  3231. hal_err("hal handle is NULL");
  3232. QDF_BUG(0);
  3233. return 0;
  3234. }
  3235. if (hal_soc->ops->hal_rx_get_udp_proto)
  3236. return hal_soc->ops->hal_rx_get_udp_proto(buf);
  3237. return 0;
  3238. }
  3239. /**
  3240. * hal_rx_get_fisa_flow_agg_continuation: API to get fisa flow_agg_continuation
  3241. * from rx_msdu_end TLV
  3242. * @buf: pointer to the start of RX PKT TLV headers
  3243. *
  3244. * Return: flow_agg_continuation bit field value
  3245. */
  3246. static inline bool
  3247. hal_rx_get_fisa_flow_agg_continuation(hal_soc_handle_t hal_soc_hdl,
  3248. uint8_t *buf)
  3249. {
  3250. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3251. if (!hal_soc || !hal_soc->ops) {
  3252. hal_err("hal handle is NULL");
  3253. QDF_BUG(0);
  3254. return 0;
  3255. }
  3256. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation)
  3257. return hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation(buf);
  3258. return 0;
  3259. }
  3260. /**
  3261. * hal_rx_get_fisa_flow_agg_count: API to get fisa flow_agg count from
  3262. * rx_msdu_end TLV
  3263. * @buf: pointer to the start of RX PKT TLV headers
  3264. *
  3265. * Return: flow_agg count value
  3266. */
  3267. static inline uint8_t
  3268. hal_rx_get_fisa_flow_agg_count(hal_soc_handle_t hal_soc_hdl,
  3269. uint8_t *buf)
  3270. {
  3271. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3272. if (!hal_soc || !hal_soc->ops) {
  3273. hal_err("hal handle is NULL");
  3274. QDF_BUG(0);
  3275. return 0;
  3276. }
  3277. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_count)
  3278. return hal_soc->ops->hal_rx_get_fisa_flow_agg_count(buf);
  3279. return 0;
  3280. }
  3281. /**
  3282. * hal_rx_get_fisa_timeout: API to get fisa time out from rx_msdu_end TLV
  3283. * @buf: pointer to the start of RX PKT TLV headers
  3284. *
  3285. * Return: fisa flow_agg timeout bit value
  3286. */
  3287. static inline bool
  3288. hal_rx_get_fisa_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  3289. {
  3290. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3291. if (!hal_soc || !hal_soc->ops) {
  3292. hal_err("hal handle is NULL");
  3293. QDF_BUG(0);
  3294. return 0;
  3295. }
  3296. if (hal_soc->ops->hal_rx_get_fisa_timeout)
  3297. return hal_soc->ops->hal_rx_get_fisa_timeout(buf);
  3298. return 0;
  3299. }
  3300. /**
  3301. * hal_rx_mpdu_start_tlv_tag_valid - API to check if RX_MPDU_START tlv
  3302. * tag is valid
  3303. *
  3304. * @hal_soc_hdl: HAL SOC handle
  3305. * @rx_tlv_hdr: start address of rx_pkt_tlvs
  3306. *
  3307. * Return: true if RX_MPDU_START tlv tag is valid, else false
  3308. */
  3309. static inline uint8_t
  3310. hal_rx_mpdu_start_tlv_tag_valid(hal_soc_handle_t hal_soc_hdl,
  3311. void *rx_tlv_hdr)
  3312. {
  3313. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  3314. if (hal->ops->hal_rx_mpdu_start_tlv_tag_valid)
  3315. return hal->ops->hal_rx_mpdu_start_tlv_tag_valid(rx_tlv_hdr);
  3316. return 0;
  3317. }
  3318. /**
  3319. * hal_rx_buffer_addr_info_get_paddr(): get paddr/sw_cookie from
  3320. * <struct buffer_addr_info> structure
  3321. * @buf_addr_info: pointer to <struct buffer_addr_info> structure
  3322. * @buf_info: structure to return the buffer information including
  3323. * paddr/cookie
  3324. *
  3325. * return: None
  3326. */
  3327. static inline
  3328. void hal_rx_buffer_addr_info_get_paddr(void *buf_addr_info,
  3329. struct hal_buf_info *buf_info)
  3330. {
  3331. buf_info->paddr =
  3332. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  3333. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  3334. buf_info->sw_cookie = HAL_RX_BUF_COOKIE_GET(buf_addr_info);
  3335. }
  3336. /**
  3337. * hal_rx_get_next_msdu_link_desc_buf_addr_info(): get next msdu link desc
  3338. * buffer addr info
  3339. * @link_desc_va: pointer to current msdu link Desc
  3340. * @next_addr_info: buffer to save next msdu link Desc buffer addr info
  3341. *
  3342. * return: None
  3343. */
  3344. static inline
  3345. void hal_rx_get_next_msdu_link_desc_buf_addr_info(
  3346. void *link_desc_va,
  3347. struct buffer_addr_info *next_addr_info)
  3348. {
  3349. struct rx_msdu_link *msdu_link = link_desc_va;
  3350. if (!msdu_link) {
  3351. qdf_mem_zero(next_addr_info,
  3352. sizeof(struct buffer_addr_info));
  3353. return;
  3354. }
  3355. *next_addr_info = msdu_link->next_msdu_link_desc_addr_info;
  3356. }
  3357. /**
  3358. * hal_rx_is_buf_addr_info_valid(): check is the buf_addr_info valid
  3359. *
  3360. * @buf_addr_info: pointer to buf_addr_info structure
  3361. *
  3362. * return: true: has valid paddr, false: not.
  3363. */
  3364. static inline
  3365. bool hal_rx_is_buf_addr_info_valid(
  3366. struct buffer_addr_info *buf_addr_info)
  3367. {
  3368. return (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) == 0) ?
  3369. false : true;
  3370. }
  3371. /**
  3372. * hal_rx_msdu_end_offset_get(): Get the MSDU end offset from
  3373. * rx_pkt_tlvs structure
  3374. *
  3375. * @hal_soc_hdl: HAL SOC handle
  3376. * return: msdu_end_tlv offset value
  3377. */
  3378. static inline
  3379. uint32_t hal_rx_msdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  3380. {
  3381. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3382. if (!hal_soc || !hal_soc->ops) {
  3383. hal_err("hal handle is NULL");
  3384. QDF_BUG(0);
  3385. return 0;
  3386. }
  3387. return hal_soc->ops->hal_rx_msdu_end_offset_get();
  3388. }
  3389. /**
  3390. * hal_rx_msdu_start_offset_get(): Get the MSDU start offset from
  3391. * rx_pkt_tlvs structure
  3392. *
  3393. * @hal_soc_hdl: HAL SOC handle
  3394. * return: msdu_start_tlv offset value
  3395. */
  3396. static inline
  3397. uint32_t hal_rx_msdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  3398. {
  3399. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3400. if (!hal_soc || !hal_soc->ops) {
  3401. hal_err("hal handle is NULL");
  3402. QDF_BUG(0);
  3403. return 0;
  3404. }
  3405. return hal_soc->ops->hal_rx_msdu_start_offset_get();
  3406. }
  3407. /**
  3408. * hal_rx_mpdu_start_offset_get(): Get the MPDU start offset from
  3409. * rx_pkt_tlvs structure
  3410. *
  3411. * @hal_soc_hdl: HAL SOC handle
  3412. * return: mpdu_start_tlv offset value
  3413. */
  3414. static inline
  3415. uint32_t hal_rx_mpdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  3416. {
  3417. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3418. if (!hal_soc || !hal_soc->ops) {
  3419. hal_err("hal handle is NULL");
  3420. QDF_BUG(0);
  3421. return 0;
  3422. }
  3423. return hal_soc->ops->hal_rx_mpdu_start_offset_get();
  3424. }
  3425. /**
  3426. * hal_rx_mpdu_end_offset_get(): Get the MPDU end offset from
  3427. * rx_pkt_tlvs structure
  3428. *
  3429. * @hal_soc_hdl: HAL SOC handle
  3430. * return: mpdu_end_tlv offset value
  3431. */
  3432. static inline
  3433. uint32_t hal_rx_mpdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  3434. {
  3435. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3436. if (!hal_soc || !hal_soc->ops) {
  3437. hal_err("hal handle is NULL");
  3438. QDF_BUG(0);
  3439. return 0;
  3440. }
  3441. return hal_soc->ops->hal_rx_mpdu_end_offset_get();
  3442. }
  3443. /**
  3444. * hal_rx_attn_offset_get(): Get the ATTENTION offset from
  3445. * rx_pkt_tlvs structure
  3446. *
  3447. * @hal_soc_hdl: HAL SOC handle
  3448. * return: attn_tlv offset value
  3449. */
  3450. static inline
  3451. uint32_t hal_rx_attn_offset_get(hal_soc_handle_t hal_soc_hdl)
  3452. {
  3453. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3454. if (!hal_soc || !hal_soc->ops) {
  3455. hal_err("hal handle is NULL");
  3456. QDF_BUG(0);
  3457. return 0;
  3458. }
  3459. return hal_soc->ops->hal_rx_attn_offset_get();
  3460. }
  3461. #endif /* _HAL_RX_H */