hal_rx.h 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218
  1. /*
  2. * Copyright (c) 2016-2018 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_internal.h>
  21. /**
  22. * struct hal_wbm_err_desc_info: structure to hold wbm error codes and reasons
  23. *
  24. * @reo_psh_rsn: REO push reason
  25. * @reo_err_code: REO Error code
  26. * @rxdma_psh_rsn: RXDMA push reason
  27. * @rxdma_err_code: RXDMA Error code
  28. * @reserved_1: Reserved bits
  29. * @wbm_err_src: WBM error source
  30. * @pool_id: pool ID, indicates which rxdma pool
  31. * @reserved_2: Reserved bits
  32. */
  33. struct hal_wbm_err_desc_info {
  34. uint16_t reo_psh_rsn:2,
  35. reo_err_code:5,
  36. rxdma_psh_rsn:2,
  37. rxdma_err_code:5,
  38. reserved_1:2;
  39. uint8_t wbm_err_src:3,
  40. pool_id:2,
  41. reserved_2:3;
  42. };
  43. /**
  44. * enum hal_reo_error_code: Enum which encapsulates "reo_push_reason"
  45. *
  46. * @ HAL_REO_ERROR_DETECTED: Packets arrived because of an error detected
  47. * @ HAL_REO_ROUTING_INSTRUCTION: Packets arrived because of REO routing
  48. */
  49. enum hal_reo_error_status {
  50. HAL_REO_ERROR_DETECTED = 0,
  51. HAL_REO_ROUTING_INSTRUCTION = 1,
  52. };
  53. /**
  54. * @msdu_flags: [0] first_msdu_in_mpdu
  55. * [1] last_msdu_in_mpdu
  56. * [2] msdu_continuation - MSDU spread across buffers
  57. * [23] sa_is_valid - SA match in peer table
  58. * [24] sa_idx_timeout - Timeout while searching for SA match
  59. * [25] da_is_valid - Used to identtify intra-bss forwarding
  60. * [26] da_is_MCBC
  61. * [27] da_idx_timeout - Timeout while searching for DA match
  62. *
  63. */
  64. struct hal_rx_msdu_desc_info {
  65. uint32_t msdu_flags;
  66. uint16_t msdu_len; /* 14 bits for length */
  67. };
  68. /**
  69. * enum hal_rx_msdu_desc_flags: Enum for flags in MSDU_DESC_INFO
  70. *
  71. * @ HAL_MSDU_F_FIRST_MSDU_IN_MPDU: First MSDU in MPDU
  72. * @ HAL_MSDU_F_LAST_MSDU_IN_MPDU: Last MSDU in MPDU
  73. * @ HAL_MSDU_F_MSDU_CONTINUATION: MSDU continuation
  74. * @ HAL_MSDU_F_SA_IS_VALID: Found match for SA in AST
  75. * @ HAL_MSDU_F_SA_IDX_TIMEOUT: AST search for SA timed out
  76. * @ HAL_MSDU_F_DA_IS_VALID: Found match for DA in AST
  77. * @ HAL_MSDU_F_DA_IS_MCBC: DA is MC/BC address
  78. * @ HAL_MSDU_F_DA_IDX_TIMEOUT: AST search for DA timed out
  79. */
  80. enum hal_rx_msdu_desc_flags {
  81. HAL_MSDU_F_FIRST_MSDU_IN_MPDU = (0x1 << 0),
  82. HAL_MSDU_F_LAST_MSDU_IN_MPDU = (0x1 << 1),
  83. HAL_MSDU_F_MSDU_CONTINUATION = (0x1 << 2),
  84. HAL_MSDU_F_SA_IS_VALID = (0x1 << 23),
  85. HAL_MSDU_F_SA_IDX_TIMEOUT = (0x1 << 24),
  86. HAL_MSDU_F_DA_IS_VALID = (0x1 << 25),
  87. HAL_MSDU_F_DA_IS_MCBC = (0x1 << 26),
  88. HAL_MSDU_F_DA_IDX_TIMEOUT = (0x1 << 27)
  89. };
  90. /*
  91. * @msdu_count: no. of msdus in the MPDU
  92. * @mpdu_seq: MPDU sequence number
  93. * @mpdu_flags [0] Fragment flag
  94. * [1] MPDU_retry_bit
  95. * [2] AMPDU flag
  96. * [3] raw_ampdu
  97. * @peer_meta_data: Upper bits containing peer id, vdev id
  98. */
  99. struct hal_rx_mpdu_desc_info {
  100. uint16_t msdu_count;
  101. uint16_t mpdu_seq; /* 12 bits for length */
  102. uint32_t mpdu_flags;
  103. uint32_t peer_meta_data; /* sw progamed meta-data:MAC Id & peer Id */
  104. };
  105. /**
  106. * enum hal_rx_mpdu_desc_flags: Enum for flags in MPDU_DESC_INFO
  107. *
  108. * @ HAL_MPDU_F_FRAGMENT: Fragmented MPDU (802.11 fragemtation)
  109. * @ HAL_MPDU_F_RETRY_BIT: Retry bit is set in FC of MPDU
  110. * @ HAL_MPDU_F_AMPDU_FLAG: MPDU received as part of A-MPDU
  111. * @ HAL_MPDU_F_RAW_AMPDU: MPDU is a Raw MDPU
  112. */
  113. enum hal_rx_mpdu_desc_flags {
  114. HAL_MPDU_F_FRAGMENT = (0x1 << 20),
  115. HAL_MPDU_F_RETRY_BIT = (0x1 << 21),
  116. HAL_MPDU_F_AMPDU_FLAG = (0x1 << 22),
  117. HAL_MPDU_F_RAW_AMPDU = (0x1 << 30)
  118. };
  119. /**
  120. * enum hal_rx_ret_buf_manager: Enum for return_buffer_manager field in
  121. * BUFFER_ADDR_INFO structure
  122. *
  123. * @ HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
  124. * @ HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST: Descriptor returned to WBM idle
  125. * descriptor list
  126. * @ HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
  127. * @ HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
  128. * @ HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
  129. * @ HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
  130. * @ HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
  131. */
  132. enum hal_rx_ret_buf_manager {
  133. HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST = 0,
  134. HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST = 1,
  135. HAL_RX_BUF_RBM_FW_BM = 2,
  136. HAL_RX_BUF_RBM_SW0_BM = 3,
  137. HAL_RX_BUF_RBM_SW1_BM = 4,
  138. HAL_RX_BUF_RBM_SW2_BM = 5,
  139. HAL_RX_BUF_RBM_SW3_BM = 6,
  140. };
  141. /*
  142. * Given the offset of a field in bytes, returns uint8_t *
  143. */
  144. #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \
  145. (((uint8_t *)(_ptr)) + (_off_in_bytes))
  146. /*
  147. * Given the offset of a field in bytes, returns uint32_t *
  148. */
  149. #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \
  150. (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
  151. #define _HAL_MS(_word, _mask, _shift) \
  152. (((_word) & (_mask)) >> (_shift))
  153. /*
  154. * macro to set the LSW of the nbuf data physical address
  155. * to the rxdma ring entry
  156. */
  157. #define HAL_RXDMA_PADDR_LO_SET(buff_addr_info, paddr_lo) \
  158. ((*(((unsigned int *) buff_addr_info) + \
  159. (BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET >> 2))) = \
  160. (paddr_lo << BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB) & \
  161. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK)
  162. /*
  163. * macro to set the LSB of MSW of the nbuf data physical address
  164. * to the rxdma ring entry
  165. */
  166. #define HAL_RXDMA_PADDR_HI_SET(buff_addr_info, paddr_hi) \
  167. ((*(((unsigned int *) buff_addr_info) + \
  168. (BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET >> 2))) = \
  169. (paddr_hi << BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB) & \
  170. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK)
  171. /*
  172. * macro to set the cookie into the rxdma ring entry
  173. */
  174. #define HAL_RXDMA_COOKIE_SET(buff_addr_info, cookie) \
  175. ((*(((unsigned int *) buff_addr_info) + \
  176. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) &= \
  177. ~BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK); \
  178. ((*(((unsigned int *) buff_addr_info) + \
  179. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  180. (cookie << BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB) & \
  181. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK)
  182. /*
  183. * macro to set the manager into the rxdma ring entry
  184. */
  185. #define HAL_RXDMA_MANAGER_SET(buff_addr_info, manager) \
  186. ((*(((unsigned int *) buff_addr_info) + \
  187. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) &= \
  188. ~BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK); \
  189. ((*(((unsigned int *) buff_addr_info) + \
  190. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) |= \
  191. (manager << BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB) & \
  192. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK)
  193. #define HAL_RX_ERROR_STATUS_GET(reo_desc) \
  194. (_HAL_MS((*_OFFSET_TO_WORD_PTR(reo_desc, \
  195. REO_DESTINATION_RING_7_REO_PUSH_REASON_OFFSET)),\
  196. REO_DESTINATION_RING_7_REO_PUSH_REASON_MASK, \
  197. REO_DESTINATION_RING_7_REO_PUSH_REASON_LSB))
  198. #define HAL_RX_BUF_COOKIE_GET(buff_addr_info) \
  199. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  200. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET)), \
  201. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK, \
  202. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB))
  203. #define HAL_RX_BUFFER_ADDR_39_32_GET(buff_addr_info) \
  204. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  205. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET)), \
  206. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK, \
  207. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB))
  208. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  209. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  210. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET)), \
  211. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK, \
  212. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB))
  213. #define HAL_RX_BUF_RBM_GET(buff_addr_info) \
  214. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  215. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET)),\
  216. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK, \
  217. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB))
  218. /* TODO: Convert the following structure fields accesseses to offsets */
  219. #define HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_desc) \
  220. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  221. (((struct reo_destination_ring *) \
  222. reo_desc)->buf_or_link_desc_addr_info)))
  223. #define HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_desc) \
  224. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  225. (((struct reo_destination_ring *) \
  226. reo_desc)->buf_or_link_desc_addr_info)))
  227. #define HAL_RX_REO_BUF_COOKIE_GET(reo_desc) \
  228. (HAL_RX_BUF_COOKIE_GET(& \
  229. (((struct reo_destination_ring *) \
  230. reo_desc)->buf_or_link_desc_addr_info)))
  231. #define HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info_ptr) \
  232. ((mpdu_info_ptr \
  233. [RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_OFFSET >> 2] & \
  234. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_MASK) >> \
  235. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_LSB)
  236. #define HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info_ptr) \
  237. ((mpdu_info_ptr \
  238. [RX_MPDU_DESC_INFO_1_PEER_META_DATA_OFFSET >> 2] & \
  239. RX_MPDU_DESC_INFO_1_PEER_META_DATA_MASK) >> \
  240. RX_MPDU_DESC_INFO_1_PEER_META_DATA_LSB)
  241. #define HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info_ptr) \
  242. ((mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MSDU_COUNT_OFFSET >> 2] & \
  243. RX_MPDU_DESC_INFO_0_MSDU_COUNT_MASK) >> \
  244. RX_MPDU_DESC_INFO_0_MSDU_COUNT_LSB)
  245. #define HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) \
  246. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_OFFSET >> 2] & \
  247. RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_MASK)
  248. #define HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) \
  249. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_OFFSET >> 2] & \
  250. RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_MASK)
  251. #define HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) \
  252. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_AMPDU_FLAG_OFFSET >> 2] & \
  253. RX_MPDU_DESC_INFO_0_AMPDU_FLAG_MASK)
  254. #define HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr) \
  255. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_RAW_MPDU_OFFSET >> 2] & \
  256. RX_MPDU_DESC_INFO_0_RAW_MPDU_MASK)
  257. #define HAL_RX_MPDU_FLAGS_GET(mpdu_info_ptr) \
  258. (HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) | \
  259. HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) | \
  260. HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) | \
  261. HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr))
  262. #define HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info_ptr) \
  263. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  264. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_OFFSET)), \
  265. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_MASK, \
  266. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_LSB))
  267. /*
  268. * NOTE: None of the following _GET macros need a right
  269. * shift by the corresponding _LSB. This is because, they are
  270. * finally taken and "OR'ed" into a single word again.
  271. */
  272. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  273. ((*(((uint32_t *)msdu_info_ptr) + \
  274. (RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  275. (val << RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_LSB) & \
  276. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  277. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  278. ((*(((uint32_t *)msdu_info_ptr) + \
  279. (RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  280. (val << RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_LSB) & \
  281. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  282. #define HAL_RX_MSDU_CONTINUATION_FLAG_SET(msdu_info_ptr, val) \
  283. ((*(((uint32_t *)msdu_info_ptr) + \
  284. (RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET >> 2))) |= \
  285. (val << RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_LSB) & \
  286. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  287. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  288. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  289. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  290. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  291. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  292. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  293. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  294. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  295. #define HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) \
  296. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  297. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET)) & \
  298. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  299. #define HAL_RX_MSDU_REO_DST_IND_GET(msdu_info_ptr) \
  300. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  301. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_OFFSET)), \
  302. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_MASK, \
  303. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_LSB))
  304. #define HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  305. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  306. RX_MSDU_DESC_INFO_0_SA_IS_VALID_OFFSET)) & \
  307. RX_MSDU_DESC_INFO_0_SA_IS_VALID_MASK)
  308. #define HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  309. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  310. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_OFFSET)) & \
  311. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_MASK)
  312. #define HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  313. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  314. RX_MSDU_DESC_INFO_0_DA_IS_VALID_OFFSET)) & \
  315. RX_MSDU_DESC_INFO_0_DA_IS_VALID_MASK)
  316. #define HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) \
  317. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  318. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_OFFSET)) & \
  319. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_MASK)
  320. #define HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  321. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  322. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_OFFSET)) & \
  323. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_MASK)
  324. #define HAL_RX_MSDU_FLAGS_GET(msdu_info_ptr) \
  325. (HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  326. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  327. HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) | \
  328. HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  329. HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) | \
  330. HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  331. HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) | \
  332. HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr))
  333. #define HAL_RX_MPDU_PN_31_0_GET(_rx_mpdu_info) \
  334. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  335. RX_MPDU_INFO_4_PN_31_0_OFFSET)), \
  336. RX_MPDU_INFO_4_PN_31_0_MASK, \
  337. RX_MPDU_INFO_4_PN_31_0_LSB))
  338. #define HAL_RX_MPDU_PN_63_32_GET(_rx_mpdu_info) \
  339. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  340. RX_MPDU_INFO_5_PN_63_32_OFFSET)), \
  341. RX_MPDU_INFO_5_PN_63_32_MASK, \
  342. RX_MPDU_INFO_5_PN_63_32_LSB))
  343. #define HAL_RX_MPDU_PN_95_64_GET(_rx_mpdu_info) \
  344. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  345. RX_MPDU_INFO_6_PN_95_64_OFFSET)), \
  346. RX_MPDU_INFO_6_PN_95_64_MASK, \
  347. RX_MPDU_INFO_6_PN_95_64_LSB))
  348. #define HAL_RX_MPDU_PN_127_96_GET(_rx_mpdu_info) \
  349. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  350. RX_MPDU_INFO_7_PN_127_96_OFFSET)), \
  351. RX_MPDU_INFO_7_PN_127_96_MASK, \
  352. RX_MPDU_INFO_7_PN_127_96_LSB))
  353. #define HAL_RX_MPDU_ENCRYPT_TYPE_GET(_rx_mpdu_info) \
  354. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  355. RX_MPDU_INFO_3_ENCRYPT_TYPE_OFFSET)), \
  356. RX_MPDU_INFO_3_ENCRYPT_TYPE_MASK, \
  357. RX_MPDU_INFO_3_ENCRYPT_TYPE_LSB))
  358. #define HAL_RX_MPDU_ENCRYPTION_INFO_VALID(_rx_mpdu_info) \
  359. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  360. RX_MPDU_INFO_2_FRAME_ENCRYPTION_INFO_VALID_OFFSET)), \
  361. RX_MPDU_INFO_2_FRAME_ENCRYPTION_INFO_VALID_MASK, \
  362. RX_MPDU_INFO_2_FRAME_ENCRYPTION_INFO_VALID_LSB))
  363. #define HAL_RX_FLD_SET(_ptr, _wrd, _field, _val) \
  364. (*(uint32_t *)(((uint8_t *)_ptr) + \
  365. _wrd ## _ ## _field ## _OFFSET) |= \
  366. ((_val << _wrd ## _ ## _field ## _LSB) & \
  367. _wrd ## _ ## _field ## _MASK))
  368. #define HAL_RX_UNIFORM_HDR_SET(_rx_msdu_link, _field, _val) \
  369. HAL_RX_FLD_SET(_rx_msdu_link, UNIFORM_DESCRIPTOR_HEADER_0, \
  370. _field, _val)
  371. #define HAL_RX_MSDU_DESC_INFO_SET(_msdu_info_ptr, _field, _val) \
  372. HAL_RX_FLD_SET(_msdu_info_ptr, RX_MSDU_DESC_INFO_0, \
  373. _field, _val)
  374. #define HAL_RX_MPDU_DESC_INFO_SET(_mpdu_info_ptr, _field, _val) \
  375. HAL_RX_FLD_SET(_mpdu_info_ptr, RX_MPDU_DESC_INFO_0, \
  376. _field, _val)
  377. static inline void hal_rx_mpdu_desc_info_get(void *desc_addr,
  378. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  379. {
  380. struct reo_destination_ring *reo_dst_ring;
  381. uint32_t mpdu_info[NUM_OF_DWORDS_RX_MPDU_DESC_INFO];
  382. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  383. qdf_mem_copy(&mpdu_info,
  384. (const void *)&reo_dst_ring->rx_mpdu_desc_info_details,
  385. sizeof(struct rx_mpdu_desc_info));
  386. mpdu_desc_info->msdu_count = HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info);
  387. mpdu_desc_info->mpdu_seq = HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info);
  388. mpdu_desc_info->mpdu_flags = HAL_RX_MPDU_FLAGS_GET(mpdu_info);
  389. mpdu_desc_info->peer_meta_data =
  390. HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info);
  391. }
  392. /*
  393. * @ hal_rx_msdu_desc_info_get: Gets the flags related to MSDU desciptor.
  394. * @ Specifically flags needed are:
  395. * @ first_msdu_in_mpdu, last_msdu_in_mpdu,
  396. * @ msdu_continuation, sa_is_valid,
  397. * @ sa_idx_timeout, da_is_valid, da_idx_timeout,
  398. * @ da_is_MCBC
  399. *
  400. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to the current
  401. * @ descriptor
  402. * @ msdu_desc_info: Holds MSDU descriptor info from HAL Rx descriptor
  403. * @ Return: void
  404. */
  405. static inline void hal_rx_msdu_desc_info_get(void *desc_addr,
  406. struct hal_rx_msdu_desc_info *msdu_desc_info)
  407. {
  408. struct reo_destination_ring *reo_dst_ring;
  409. uint32_t msdu_info[NUM_OF_DWORDS_RX_MSDU_DESC_INFO];
  410. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  411. qdf_mem_copy(&msdu_info,
  412. (const void *)&reo_dst_ring->rx_msdu_desc_info_details,
  413. sizeof(struct rx_msdu_desc_info));
  414. msdu_desc_info->msdu_flags = HAL_RX_MSDU_FLAGS_GET(msdu_info);
  415. msdu_desc_info->msdu_len = HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info);
  416. }
  417. /*
  418. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  419. * rxdma ring entry.
  420. * @rxdma_entry: descriptor entry
  421. * @paddr: physical address of nbuf data pointer.
  422. * @cookie: SW cookie used as a index to SW rx desc.
  423. * @manager: who owns the nbuf (host, NSS, etc...).
  424. *
  425. */
  426. static inline void hal_rxdma_buff_addr_info_set(void *rxdma_entry,
  427. qdf_dma_addr_t paddr, uint32_t cookie, uint8_t manager)
  428. {
  429. uint32_t paddr_lo = ((u64)paddr & 0x00000000ffffffff);
  430. uint32_t paddr_hi = ((u64)paddr & 0xffffffff00000000) >> 32;
  431. HAL_RXDMA_PADDR_LO_SET(rxdma_entry, paddr_lo);
  432. HAL_RXDMA_PADDR_HI_SET(rxdma_entry, paddr_hi);
  433. HAL_RXDMA_COOKIE_SET(rxdma_entry, cookie);
  434. HAL_RXDMA_MANAGER_SET(rxdma_entry, manager);
  435. }
  436. /*
  437. * Structures & Macros to obtain fields from the TLV's in the Rx packet
  438. * pre-header.
  439. */
  440. /*
  441. * Every Rx packet starts at an offset from the top of the buffer.
  442. * If the host hasn't subscribed to any specific TLV, there is
  443. * still space reserved for the following TLV's from the start of
  444. * the buffer:
  445. * -- RX ATTENTION
  446. * -- RX MPDU START
  447. * -- RX MSDU START
  448. * -- RX MSDU END
  449. * -- RX MPDU END
  450. * -- RX PACKET HEADER (802.11)
  451. * If the host subscribes to any of the TLV's above, that TLV
  452. * if populated by the HW
  453. */
  454. #define NUM_DWORDS_TAG 1
  455. /* By default the packet header TLV is 128 bytes */
  456. #define NUM_OF_BYTES_RX_802_11_HDR_TLV 128
  457. #define NUM_OF_DWORDS_RX_802_11_HDR_TLV \
  458. (NUM_OF_BYTES_RX_802_11_HDR_TLV >> 2)
  459. #define RX_PKT_OFFSET_WORDS \
  460. ( \
  461. NUM_OF_DWORDS_RX_ATTENTION + NUM_DWORDS_TAG \
  462. NUM_OF_DWORDS_RX_MPDU_START + NUM_DWORDS_TAG \
  463. NUM_OF_DWORDS_RX_MSDU_START + NUM_DWORDS_TAG \
  464. NUM_OF_DWORDS_RX_MSDU_END + NUM_DWORDS_TAG \
  465. NUM_OF_DWORDS_RX_MPDU_END + NUM_DWORDS_TAG \
  466. NUM_OF_DWORDS_RX_802_11_HDR_TLV + NUM_DWORDS_TAG \
  467. )
  468. #define RX_PKT_OFFSET_BYTES \
  469. (RX_PKT_OFFSET_WORDS << 2)
  470. #define RX_PKT_HDR_TLV_LEN 120
  471. /*
  472. * Each RX descriptor TLV is preceded by 1 DWORD "tag"
  473. */
  474. struct rx_attention_tlv {
  475. uint32_t tag;
  476. struct rx_attention rx_attn;
  477. };
  478. struct rx_mpdu_start_tlv {
  479. uint32_t tag;
  480. struct rx_mpdu_start rx_mpdu_start;
  481. };
  482. struct rx_msdu_start_tlv {
  483. uint32_t tag;
  484. struct rx_msdu_start rx_msdu_start;
  485. };
  486. struct rx_msdu_end_tlv {
  487. uint32_t tag;
  488. struct rx_msdu_end rx_msdu_end;
  489. };
  490. struct rx_mpdu_end_tlv {
  491. uint32_t tag;
  492. struct rx_mpdu_end rx_mpdu_end;
  493. };
  494. struct rx_pkt_hdr_tlv {
  495. uint32_t tag; /* 4 B */
  496. uint32_t phy_ppdu_id; /* 4 B */
  497. char rx_pkt_hdr[RX_PKT_HDR_TLV_LEN]; /* 120 B */
  498. };
  499. #define RXDMA_OPTIMIZATION
  500. #ifdef RXDMA_OPTIMIZATION
  501. /*
  502. * The RX_PADDING_BYTES is required so that the TLV's don't
  503. * spread across the 128 byte boundary
  504. * RXDMA optimization requires:
  505. * 1) MSDU_END & ATTENTION TLV's follow in that order
  506. * 2) TLV's don't span across 128 byte lines
  507. * 3) Rx Buffer is nicely aligned on the 128 byte boundary
  508. */
  509. #if defined(WCSS_VERSION) && \
  510. ((defined(CONFIG_WIN) && (WCSS_VERSION >= 96)) || \
  511. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  512. #define RX_PADDING0_BYTES 4
  513. #endif
  514. #define RX_PADDING1_BYTES 16
  515. struct rx_pkt_tlvs {
  516. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  517. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  518. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  519. #if defined(WCSS_VERSION) && \
  520. ((defined(CONFIG_WIN) && (WCSS_VERSION >= 96)) || \
  521. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  522. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  523. #endif
  524. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  525. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  526. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  527. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  528. };
  529. #else /* RXDMA_OPTIMIZATION */
  530. struct rx_pkt_tlvs {
  531. struct rx_attention_tlv attn_tlv;
  532. struct rx_mpdu_start_tlv mpdu_start_tlv;
  533. struct rx_msdu_start_tlv msdu_start_tlv;
  534. struct rx_msdu_end_tlv msdu_end_tlv;
  535. struct rx_mpdu_end_tlv mpdu_end_tlv;
  536. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  537. };
  538. #endif /* RXDMA_OPTIMIZATION */
  539. #define RX_PKT_TLVS_LEN (sizeof(struct rx_pkt_tlvs))
  540. static inline uint8_t
  541. *hal_rx_pkt_hdr_get(uint8_t *buf)
  542. {
  543. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  544. return pkt_tlvs->pkt_hdr_tlv.rx_pkt_hdr;
  545. }
  546. static inline uint8_t
  547. *hal_rx_padding0_get(uint8_t *buf)
  548. {
  549. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  550. return pkt_tlvs->rx_padding0;
  551. }
  552. /*
  553. * @ hal_rx_encryption_info_valid: Returns encryption type.
  554. *
  555. * @ buf: rx_tlv_hdr of the received packet
  556. * @ Return: encryption type
  557. */
  558. static inline uint32_t
  559. hal_rx_encryption_info_valid(uint8_t *buf)
  560. {
  561. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  562. struct rx_mpdu_start *mpdu_start =
  563. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  564. struct rx_mpdu_info *mpdu_info = &(mpdu_start->rx_mpdu_info_details);
  565. uint32_t encryption_info = HAL_RX_MPDU_ENCRYPTION_INFO_VALID(mpdu_info);
  566. return encryption_info;
  567. }
  568. /*
  569. * @ hal_rx_print_pn: Prints the PN of rx packet.
  570. *
  571. * @ buf: rx_tlv_hdr of the received packet
  572. * @ Return: void
  573. */
  574. static inline void
  575. hal_rx_print_pn(uint8_t *buf)
  576. {
  577. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  578. struct rx_mpdu_start *mpdu_start =
  579. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  580. struct rx_mpdu_info *mpdu_info = &(mpdu_start->rx_mpdu_info_details);
  581. uint32_t pn_31_0 = HAL_RX_MPDU_PN_31_0_GET(mpdu_info);
  582. uint32_t pn_63_32 = HAL_RX_MPDU_PN_63_32_GET(mpdu_info);
  583. uint32_t pn_95_64 = HAL_RX_MPDU_PN_95_64_GET(mpdu_info);
  584. uint32_t pn_127_96 = HAL_RX_MPDU_PN_127_96_GET(mpdu_info);
  585. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  586. "PN number pn_127_96 0x%x pn_95_64 0x%x pn_63_32 0x%x pn_31_0 0x%x ",
  587. pn_127_96, pn_95_64, pn_63_32, pn_31_0);
  588. }
  589. /*
  590. * Get msdu_done bit from the RX_ATTENTION TLV
  591. */
  592. #define HAL_RX_ATTN_MSDU_DONE_GET(_rx_attn) \
  593. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  594. RX_ATTENTION_2_MSDU_DONE_OFFSET)), \
  595. RX_ATTENTION_2_MSDU_DONE_MASK, \
  596. RX_ATTENTION_2_MSDU_DONE_LSB))
  597. static inline uint32_t
  598. hal_rx_attn_msdu_done_get(uint8_t *buf)
  599. {
  600. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  601. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  602. uint32_t msdu_done;
  603. msdu_done = HAL_RX_ATTN_MSDU_DONE_GET(rx_attn);
  604. return msdu_done;
  605. }
  606. #define HAL_RX_ATTN_FIRST_MPDU_GET(_rx_attn) \
  607. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  608. RX_ATTENTION_1_FIRST_MPDU_OFFSET)), \
  609. RX_ATTENTION_1_FIRST_MPDU_MASK, \
  610. RX_ATTENTION_1_FIRST_MPDU_LSB))
  611. /*
  612. * hal_rx_attn_first_mpdu_get(): get fist_mpdu bit from rx attention
  613. * @buf: pointer to rx_pkt_tlvs
  614. *
  615. * reutm: uint32_t(first_msdu)
  616. */
  617. static inline uint32_t
  618. hal_rx_attn_first_mpdu_get(uint8_t *buf)
  619. {
  620. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  621. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  622. uint32_t first_mpdu;
  623. first_mpdu = HAL_RX_ATTN_FIRST_MPDU_GET(rx_attn);
  624. return first_mpdu;
  625. }
  626. #define HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(_rx_attn) \
  627. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  628. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_OFFSET)), \
  629. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_MASK, \
  630. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_LSB))
  631. /*
  632. * hal_rx_attn_tcp_udp_cksum_fail_get(): get tcp_udp cksum fail bit
  633. * from rx attention
  634. * @buf: pointer to rx_pkt_tlvs
  635. *
  636. * Return: tcp_udp_cksum_fail
  637. */
  638. static inline bool
  639. hal_rx_attn_tcp_udp_cksum_fail_get(uint8_t *buf)
  640. {
  641. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  642. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  643. bool tcp_udp_cksum_fail;
  644. tcp_udp_cksum_fail = HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(rx_attn);
  645. return tcp_udp_cksum_fail;
  646. }
  647. #define HAL_RX_ATTN_IP_CKSUM_FAIL_GET(_rx_attn) \
  648. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  649. RX_ATTENTION_1_IP_CHKSUM_FAIL_OFFSET)), \
  650. RX_ATTENTION_1_IP_CHKSUM_FAIL_MASK, \
  651. RX_ATTENTION_1_IP_CHKSUM_FAIL_LSB))
  652. /*
  653. * hal_rx_attn_ip_cksum_fail_get(): get ip cksum fail bit
  654. * from rx attention
  655. * @buf: pointer to rx_pkt_tlvs
  656. *
  657. * Return: ip_cksum_fail
  658. */
  659. static inline bool
  660. hal_rx_attn_ip_cksum_fail_get(uint8_t *buf)
  661. {
  662. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  663. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  664. bool ip_cksum_fail;
  665. ip_cksum_fail = HAL_RX_ATTN_IP_CKSUM_FAIL_GET(rx_attn);
  666. return ip_cksum_fail;
  667. }
  668. #define HAL_RX_ATTN_PHY_PPDU_ID_GET(_rx_attn) \
  669. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  670. RX_ATTENTION_0_PHY_PPDU_ID_OFFSET)), \
  671. RX_ATTENTION_0_PHY_PPDU_ID_MASK, \
  672. RX_ATTENTION_0_PHY_PPDU_ID_LSB))
  673. /*
  674. * hal_rx_attn_phy_ppdu_id_get(): get phy_ppdu_id value
  675. * from rx attention
  676. * @buf: pointer to rx_pkt_tlvs
  677. *
  678. * Return: phy_ppdu_id
  679. */
  680. static inline uint16_t
  681. hal_rx_attn_phy_ppdu_id_get(uint8_t *buf)
  682. {
  683. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  684. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  685. uint16_t phy_ppdu_id;
  686. phy_ppdu_id = HAL_RX_ATTN_PHY_PPDU_ID_GET(rx_attn);
  687. return phy_ppdu_id;
  688. }
  689. /*
  690. * Get peer_meta_data from RX_MPDU_INFO within RX_MPDU_START
  691. */
  692. #define HAL_RX_MPDU_PEER_META_DATA_GET(_rx_mpdu_info) \
  693. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  694. RX_MPDU_INFO_8_PEER_META_DATA_OFFSET)), \
  695. RX_MPDU_INFO_8_PEER_META_DATA_MASK, \
  696. RX_MPDU_INFO_8_PEER_META_DATA_LSB))
  697. static inline uint32_t
  698. hal_rx_mpdu_peer_meta_data_get(uint8_t *buf)
  699. {
  700. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  701. struct rx_mpdu_start *mpdu_start =
  702. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  703. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  704. uint32_t peer_meta_data;
  705. peer_meta_data = HAL_RX_MPDU_PEER_META_DATA_GET(mpdu_info);
  706. return peer_meta_data;
  707. }
  708. #define HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(_rx_mpdu_info) \
  709. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  710. RX_MPDU_INFO_12_AMPDU_FLAG_OFFSET)), \
  711. RX_MPDU_INFO_12_AMPDU_FLAG_MASK, \
  712. RX_MPDU_INFO_12_AMPDU_FLAG_LSB))
  713. /**
  714. * hal_rx_mpdu_info_ampdu_flag_get(): get ampdu flag bit
  715. * from rx mpdu info
  716. * @buf: pointer to rx_pkt_tlvs
  717. *
  718. * Return: ampdu flag
  719. */
  720. static inline bool
  721. hal_rx_mpdu_info_ampdu_flag_get(uint8_t *buf)
  722. {
  723. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  724. struct rx_mpdu_start *mpdu_start =
  725. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  726. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  727. bool ampdu_flag;
  728. ampdu_flag = HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(mpdu_info);
  729. return ampdu_flag;
  730. }
  731. #define HAL_RX_MPDU_PEER_META_DATA_SET(_rx_mpdu_info, peer_mdata) \
  732. ((*(((uint32_t *)_rx_mpdu_info) + \
  733. (RX_MPDU_INFO_8_PEER_META_DATA_OFFSET >> 2))) = \
  734. (peer_mdata << RX_MPDU_INFO_8_PEER_META_DATA_LSB) & \
  735. RX_MPDU_INFO_8_PEER_META_DATA_MASK)
  736. /*
  737. * @ hal_rx_mpdu_peer_meta_data_set: set peer meta data in RX mpdu start tlv
  738. *
  739. * @ buf: rx_tlv_hdr of the received packet
  740. * @ peer_mdata: peer meta data to be set.
  741. * @ Return: void
  742. */
  743. static inline void
  744. hal_rx_mpdu_peer_meta_data_set(uint8_t *buf, uint32_t peer_mdata)
  745. {
  746. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  747. struct rx_mpdu_start *mpdu_start =
  748. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  749. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  750. HAL_RX_MPDU_PEER_META_DATA_SET(mpdu_info, peer_mdata);
  751. }
  752. #if defined(WCSS_VERSION) && \
  753. ((defined(CONFIG_WIN) && (WCSS_VERSION > 81)) || \
  754. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  755. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  756. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  757. RX_MSDU_END_5_L3_HEADER_PADDING_OFFSET)), \
  758. RX_MSDU_END_5_L3_HEADER_PADDING_MASK, \
  759. RX_MSDU_END_5_L3_HEADER_PADDING_LSB))
  760. #else
  761. #define HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(_rx_msdu_end) \
  762. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  763. RX_MSDU_END_9_L3_HEADER_PADDING_OFFSET)), \
  764. RX_MSDU_END_9_L3_HEADER_PADDING_MASK, \
  765. RX_MSDU_END_9_L3_HEADER_PADDING_LSB))
  766. #endif
  767. /**
  768. * LRO information needed from the TLVs
  769. */
  770. #define HAL_RX_TLV_GET_LRO_ELIGIBLE(buf) \
  771. (_HAL_MS( \
  772. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  773. msdu_end_tlv.rx_msdu_end), \
  774. RX_MSDU_END_9_LRO_ELIGIBLE_OFFSET)), \
  775. RX_MSDU_END_9_LRO_ELIGIBLE_MASK, \
  776. RX_MSDU_END_9_LRO_ELIGIBLE_LSB))
  777. #define HAL_RX_TLV_GET_TCP_CHKSUM(buf) \
  778. (_HAL_MS( \
  779. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  780. msdu_end_tlv.rx_msdu_end), \
  781. RX_MSDU_END_1_TCP_UDP_CHKSUM_OFFSET)), \
  782. RX_MSDU_END_1_TCP_UDP_CHKSUM_MASK, \
  783. RX_MSDU_END_1_TCP_UDP_CHKSUM_LSB))
  784. #define HAL_RX_TLV_GET_TCP_ACK(buf) \
  785. (_HAL_MS( \
  786. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  787. msdu_end_tlv.rx_msdu_end), \
  788. RX_MSDU_END_8_TCP_ACK_NUMBER_OFFSET)), \
  789. RX_MSDU_END_8_TCP_ACK_NUMBER_MASK, \
  790. RX_MSDU_END_8_TCP_ACK_NUMBER_LSB))
  791. #define HAL_RX_TLV_GET_TCP_SEQ(buf) \
  792. (_HAL_MS( \
  793. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  794. msdu_end_tlv.rx_msdu_end), \
  795. RX_MSDU_END_7_TCP_SEQ_NUMBER_OFFSET)), \
  796. RX_MSDU_END_7_TCP_SEQ_NUMBER_MASK, \
  797. RX_MSDU_END_7_TCP_SEQ_NUMBER_LSB))
  798. #define HAL_RX_TLV_GET_TCP_WIN(buf) \
  799. (_HAL_MS( \
  800. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  801. msdu_end_tlv.rx_msdu_end), \
  802. RX_MSDU_END_9_WINDOW_SIZE_OFFSET)), \
  803. RX_MSDU_END_9_WINDOW_SIZE_MASK, \
  804. RX_MSDU_END_9_WINDOW_SIZE_LSB))
  805. #define HAL_RX_TLV_GET_TCP_PURE_ACK(buf) \
  806. (_HAL_MS( \
  807. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  808. msdu_start_tlv.rx_msdu_start), \
  809. RX_MSDU_START_2_TCP_ONLY_ACK_OFFSET)), \
  810. RX_MSDU_START_2_TCP_ONLY_ACK_MASK, \
  811. RX_MSDU_START_2_TCP_ONLY_ACK_LSB))
  812. #define HAL_RX_TLV_GET_TCP_PROTO(buf) \
  813. (_HAL_MS( \
  814. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  815. msdu_start_tlv.rx_msdu_start), \
  816. RX_MSDU_START_2_TCP_PROTO_OFFSET)), \
  817. RX_MSDU_START_2_TCP_PROTO_MASK, \
  818. RX_MSDU_START_2_TCP_PROTO_LSB))
  819. #define HAL_RX_TLV_GET_IPV6(buf) \
  820. (_HAL_MS( \
  821. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  822. msdu_start_tlv.rx_msdu_start), \
  823. RX_MSDU_START_2_IPV6_PROTO_OFFSET)), \
  824. RX_MSDU_START_2_IPV6_PROTO_MASK, \
  825. RX_MSDU_START_2_IPV6_PROTO_LSB))
  826. #define HAL_RX_TLV_GET_IP_OFFSET(buf) \
  827. (_HAL_MS( \
  828. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  829. msdu_start_tlv.rx_msdu_start), \
  830. RX_MSDU_START_1_L3_OFFSET_OFFSET)), \
  831. RX_MSDU_START_1_L3_OFFSET_MASK, \
  832. RX_MSDU_START_1_L3_OFFSET_LSB))
  833. #define HAL_RX_TLV_GET_TCP_OFFSET(buf) \
  834. (_HAL_MS( \
  835. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  836. msdu_start_tlv.rx_msdu_start), \
  837. RX_MSDU_START_1_L4_OFFSET_OFFSET)), \
  838. RX_MSDU_START_1_L4_OFFSET_MASK, \
  839. RX_MSDU_START_1_L4_OFFSET_LSB))
  840. #define HAL_RX_TLV_GET_FLOW_ID_TOEPLITZ(buf) \
  841. (_HAL_MS( \
  842. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  843. msdu_start_tlv.rx_msdu_start), \
  844. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  845. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  846. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  847. /**
  848. * hal_rx_msdu_end_l3_hdr_padding_get(): API to get the
  849. * l3_header padding from rx_msdu_end TLV
  850. *
  851. * @ buf: pointer to the start of RX PKT TLV headers
  852. * Return: number of l3 header padding bytes
  853. */
  854. static inline uint32_t
  855. hal_rx_msdu_end_l3_hdr_padding_get(uint8_t *buf)
  856. {
  857. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  858. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  859. uint32_t l3_header_padding;
  860. l3_header_padding = HAL_RX_MSDU_END_L3_HEADER_PADDING_GET(msdu_end);
  861. return l3_header_padding;
  862. }
  863. #define HAL_RX_MSDU_END_SA_IDX_GET(_rx_msdu_end) \
  864. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  865. RX_MSDU_END_13_SA_IDX_OFFSET)), \
  866. RX_MSDU_END_13_SA_IDX_MASK, \
  867. RX_MSDU_END_13_SA_IDX_LSB))
  868. /**
  869. * hal_rx_msdu_end_sa_idx_get(): API to get the
  870. * sa_idx from rx_msdu_end TLV
  871. *
  872. * @ buf: pointer to the start of RX PKT TLV headers
  873. * Return: sa_idx (SA AST index)
  874. */
  875. static inline uint16_t
  876. hal_rx_msdu_end_sa_idx_get(uint8_t *buf)
  877. {
  878. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  879. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  880. uint16_t sa_idx;
  881. sa_idx = HAL_RX_MSDU_END_SA_IDX_GET(msdu_end);
  882. return sa_idx;
  883. }
  884. #define HAL_RX_MSDU_END_SA_IS_VALID_GET(_rx_msdu_end) \
  885. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  886. RX_MSDU_END_5_SA_IS_VALID_OFFSET)), \
  887. RX_MSDU_END_5_SA_IS_VALID_MASK, \
  888. RX_MSDU_END_5_SA_IS_VALID_LSB))
  889. /**
  890. * hal_rx_msdu_end_sa_is_valid_get(): API to get the
  891. * sa_is_valid bit from rx_msdu_end TLV
  892. *
  893. * @ buf: pointer to the start of RX PKT TLV headers
  894. * Return: sa_is_valid bit
  895. */
  896. static inline uint8_t
  897. hal_rx_msdu_end_sa_is_valid_get(uint8_t *buf)
  898. {
  899. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  900. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  901. uint8_t sa_is_valid;
  902. sa_is_valid = HAL_RX_MSDU_END_SA_IS_VALID_GET(msdu_end);
  903. return sa_is_valid;
  904. }
  905. #define HAL_RX_MSDU_END_SA_SW_PEER_ID_GET(_rx_msdu_end) \
  906. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  907. RX_MSDU_END_16_SA_SW_PEER_ID_OFFSET)), \
  908. RX_MSDU_END_16_SA_SW_PEER_ID_MASK, \
  909. RX_MSDU_END_16_SA_SW_PEER_ID_LSB))
  910. /**
  911. * hal_rx_msdu_end_sa_sw_peer_id_get(): API to get the
  912. * sa_sw_peer_id from rx_msdu_end TLV
  913. *
  914. * @ buf: pointer to the start of RX PKT TLV headers
  915. * Return: sa_sw_peer_id index
  916. */
  917. static inline uint32_t
  918. hal_rx_msdu_end_sa_sw_peer_id_get(uint8_t *buf)
  919. {
  920. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  921. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  922. uint32_t sa_sw_peer_id;
  923. sa_sw_peer_id = HAL_RX_MSDU_END_SA_SW_PEER_ID_GET(msdu_end);
  924. return sa_sw_peer_id;
  925. }
  926. #define HAL_RX_MSDU_START_MSDU_LEN_GET(_rx_msdu_start) \
  927. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  928. RX_MSDU_START_1_MSDU_LENGTH_OFFSET)), \
  929. RX_MSDU_START_1_MSDU_LENGTH_MASK, \
  930. RX_MSDU_START_1_MSDU_LENGTH_LSB))
  931. /**
  932. * hal_rx_msdu_start_msdu_len_get(): API to get the MSDU length
  933. * from rx_msdu_start TLV
  934. *
  935. * @ buf: pointer to the start of RX PKT TLV headers
  936. * Return: msdu length
  937. */
  938. static inline uint32_t
  939. hal_rx_msdu_start_msdu_len_get(uint8_t *buf)
  940. {
  941. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  942. struct rx_msdu_start *msdu_start =
  943. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  944. uint32_t msdu_len;
  945. msdu_len = HAL_RX_MSDU_START_MSDU_LEN_GET(msdu_start);
  946. return msdu_len;
  947. }
  948. /**
  949. * hal_rx_msdu_start_msdu_len_set(): API to set the MSDU length
  950. * from rx_msdu_start TLV
  951. *
  952. * @buf: pointer to the start of RX PKT TLV headers
  953. * @len: msdu length
  954. *
  955. * Return: none
  956. */
  957. static inline void
  958. hal_rx_msdu_start_msdu_len_set(uint8_t *buf, uint32_t len)
  959. {
  960. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  961. struct rx_msdu_start *msdu_start =
  962. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  963. void *wrd1;
  964. wrd1 = (uint8_t *)msdu_start + RX_MSDU_START_1_MSDU_LENGTH_OFFSET;
  965. *(uint32_t *)wrd1 &= (~RX_MSDU_START_1_MSDU_LENGTH_MASK);
  966. *(uint32_t *)wrd1 |= len;
  967. }
  968. #define HAL_RX_MSDU_START_BW_GET(_rx_msdu_start) \
  969. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  970. RX_MSDU_START_5_RECEIVE_BANDWIDTH_OFFSET)), \
  971. RX_MSDU_START_5_RECEIVE_BANDWIDTH_MASK, \
  972. RX_MSDU_START_5_RECEIVE_BANDWIDTH_LSB))
  973. /*
  974. * hal_rx_msdu_start_bw_get(): API to get the Bandwidth
  975. * Interval from rx_msdu_start
  976. *
  977. * @buf: pointer to the start of RX PKT TLV header
  978. * Return: uint32_t(bw)
  979. */
  980. static inline uint32_t
  981. hal_rx_msdu_start_bw_get(uint8_t *buf)
  982. {
  983. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  984. struct rx_msdu_start *msdu_start =
  985. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  986. uint32_t bw;
  987. bw = HAL_RX_MSDU_START_BW_GET(msdu_start);
  988. return bw;
  989. }
  990. #define HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(_rx_msdu_start) \
  991. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  992. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  993. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  994. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  995. /**
  996. * hal_rx_msdu_start_toeplitz_get: API to get the toeplitz hash
  997. * from rx_msdu_start TLV
  998. *
  999. * @ buf: pointer to the start of RX PKT TLV headers
  1000. * Return: toeplitz hash
  1001. */
  1002. static inline uint32_t
  1003. hal_rx_msdu_start_toeplitz_get(uint8_t *buf)
  1004. {
  1005. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1006. struct rx_msdu_start *msdu_start =
  1007. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1008. return HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(msdu_start);
  1009. }
  1010. /*
  1011. * Get qos_control_valid from RX_MPDU_START
  1012. */
  1013. #define HAL_RX_MPDU_INFO_QOS_CONTROL_VALID_GET(_rx_mpdu_info) \
  1014. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \
  1015. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_OFFSET)), \
  1016. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_MASK, \
  1017. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_LSB))
  1018. static inline uint32_t
  1019. hal_rx_mpdu_start_mpdu_qos_control_valid_get(uint8_t *buf)
  1020. {
  1021. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1022. struct rx_mpdu_start *mpdu_start =
  1023. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1024. uint32_t qos_control_valid;
  1025. qos_control_valid = HAL_RX_MPDU_INFO_QOS_CONTROL_VALID_GET(
  1026. &(mpdu_start->rx_mpdu_info_details));
  1027. return qos_control_valid;
  1028. }
  1029. /*
  1030. * Get SW peer id from RX_MPDU_START
  1031. */
  1032. #define HAL_RX_MPDU_INFO_SW_PEER_ID_GET(_rx_mpdu_info) \
  1033. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_info), \
  1034. RX_MPDU_INFO_1_SW_PEER_ID_OFFSET)), \
  1035. RX_MPDU_INFO_1_SW_PEER_ID_MASK, \
  1036. RX_MPDU_INFO_1_SW_PEER_ID_LSB))
  1037. static inline uint32_t
  1038. hal_rx_mpdu_start_sw_peer_id_get(uint8_t *buf)
  1039. {
  1040. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1041. struct rx_mpdu_start *mpdu_start =
  1042. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1043. uint32_t sw_peer_id;
  1044. sw_peer_id = HAL_RX_MPDU_INFO_SW_PEER_ID_GET(
  1045. &(mpdu_start->rx_mpdu_info_details));
  1046. return sw_peer_id;
  1047. }
  1048. #if defined(WCSS_VERSION) && \
  1049. ((defined(CONFIG_WIN) && (WCSS_VERSION > 81)) || \
  1050. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  1051. #define HAL_RX_MSDU_START_SGI_GET(_rx_msdu_start) \
  1052. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1053. RX_MSDU_START_5_SGI_OFFSET)), \
  1054. RX_MSDU_START_5_SGI_MASK, \
  1055. RX_MSDU_START_5_SGI_LSB))
  1056. #else
  1057. #define HAL_RX_MSDU_START_SGI_GET(_rx_msdu_start) \
  1058. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1059. RX_MSDU_START_6_SGI_OFFSET)), \
  1060. RX_MSDU_START_6_SGI_MASK, \
  1061. RX_MSDU_START_6_SGI_LSB))
  1062. #endif
  1063. /**
  1064. * hal_rx_msdu_start_msdu_sgi_get(): API to get the Short Gaurd
  1065. * Interval from rx_msdu_start TLV
  1066. *
  1067. * @buf: pointer to the start of RX PKT TLV headers
  1068. * Return: uint32_t(sgi)
  1069. */
  1070. static inline uint32_t
  1071. hal_rx_msdu_start_sgi_get(uint8_t *buf)
  1072. {
  1073. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1074. struct rx_msdu_start *msdu_start =
  1075. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1076. uint32_t sgi;
  1077. sgi = HAL_RX_MSDU_START_SGI_GET(msdu_start);
  1078. return sgi;
  1079. }
  1080. #if defined(WCSS_VERSION) && \
  1081. ((defined(CONFIG_WIN) && (WCSS_VERSION > 81)) || \
  1082. (defined(CONFIG_MCL) && (WCSS_VERSION >= 72)))
  1083. #define HAL_RX_MSDU_START_RATE_MCS_GET(_rx_msdu_start) \
  1084. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1085. RX_MSDU_START_5_RATE_MCS_OFFSET)), \
  1086. RX_MSDU_START_5_RATE_MCS_MASK, \
  1087. RX_MSDU_START_5_RATE_MCS_LSB))
  1088. #else
  1089. #define HAL_RX_MSDU_START_RATE_MCS_GET(_rx_msdu_start) \
  1090. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1091. RX_MSDU_START_6_RATE_MCS_OFFSET)), \
  1092. RX_MSDU_START_6_RATE_MCS_MASK, \
  1093. RX_MSDU_START_6_RATE_MCS_LSB))
  1094. #endif
  1095. /**
  1096. * hal_rx_msdu_start_msdu_rate_mcs_get(): API to get the MCS rate
  1097. * from rx_msdu_start TLV
  1098. *
  1099. * @buf: pointer to the start of RX PKT TLV headers
  1100. * Return: uint32_t(rate_mcs)
  1101. */
  1102. static inline uint32_t
  1103. hal_rx_msdu_start_rate_mcs_get(uint8_t *buf)
  1104. {
  1105. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1106. struct rx_msdu_start *msdu_start =
  1107. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1108. uint32_t rate_mcs;
  1109. rate_mcs = HAL_RX_MSDU_START_RATE_MCS_GET(msdu_start);
  1110. return rate_mcs;
  1111. }
  1112. #define HAL_RX_ATTN_DECRYPT_STATUS_GET(_rx_attn) \
  1113. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  1114. RX_ATTENTION_2_DECRYPT_STATUS_CODE_OFFSET)), \
  1115. RX_ATTENTION_2_DECRYPT_STATUS_CODE_MASK, \
  1116. RX_ATTENTION_2_DECRYPT_STATUS_CODE_LSB))
  1117. /*
  1118. * hal_rx_attn_msdu_get_is_decrypted(): API to get the decrypt status of the
  1119. * packet from rx_attention
  1120. *
  1121. * @buf: pointer to the start of RX PKT TLV header
  1122. * Return: uint32_t(decryt status)
  1123. */
  1124. static inline uint32_t
  1125. hal_rx_attn_msdu_get_is_decrypted(uint8_t *buf)
  1126. {
  1127. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1128. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  1129. uint32_t is_decrypt = 0;
  1130. uint32_t decrypt_status;
  1131. decrypt_status = HAL_RX_ATTN_DECRYPT_STATUS_GET(rx_attn);
  1132. if (!decrypt_status)
  1133. is_decrypt = 1;
  1134. return is_decrypt;
  1135. }
  1136. /*
  1137. * Get key index from RX_MSDU_END
  1138. */
  1139. #define HAL_RX_MSDU_END_KEYID_OCTET_GET(_rx_msdu_end) \
  1140. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1141. RX_MSDU_END_2_KEY_ID_OCTET_OFFSET)), \
  1142. RX_MSDU_END_2_KEY_ID_OCTET_MASK, \
  1143. RX_MSDU_END_2_KEY_ID_OCTET_LSB))
  1144. /*
  1145. * hal_rx_msdu_get_keyid(): API to get the key id if the decrypted packet
  1146. * from rx_msdu_end
  1147. *
  1148. * @buf: pointer to the start of RX PKT TLV header
  1149. * Return: uint32_t(key id)
  1150. */
  1151. static inline uint32_t
  1152. hal_rx_msdu_get_keyid(uint8_t *buf)
  1153. {
  1154. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1155. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1156. uint32_t keyid_octet;
  1157. keyid_octet = HAL_RX_MSDU_END_KEYID_OCTET_GET(msdu_end);
  1158. return keyid_octet & 0x3;
  1159. }
  1160. #define HAL_RX_MSDU_START_RSSI_GET(_rx_msdu_start) \
  1161. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1162. RX_MSDU_START_5_USER_RSSI_OFFSET)), \
  1163. RX_MSDU_START_5_USER_RSSI_MASK, \
  1164. RX_MSDU_START_5_USER_RSSI_LSB))
  1165. /*
  1166. * hal_rx_msdu_start_get_rssi(): API to get the rssi of received pkt
  1167. * from rx_msdu_start
  1168. *
  1169. * @buf: pointer to the start of RX PKT TLV header
  1170. * Return: uint32_t(rssi)
  1171. */
  1172. static inline uint32_t
  1173. hal_rx_msdu_start_get_rssi(uint8_t *buf)
  1174. {
  1175. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1176. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1177. uint32_t rssi;
  1178. rssi = HAL_RX_MSDU_START_RSSI_GET(msdu_start);
  1179. return rssi;
  1180. }
  1181. #define HAL_RX_MSDU_START_FREQ_GET(_rx_msdu_start) \
  1182. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1183. RX_MSDU_START_7_SW_PHY_META_DATA_OFFSET)), \
  1184. RX_MSDU_START_7_SW_PHY_META_DATA_MASK, \
  1185. RX_MSDU_START_7_SW_PHY_META_DATA_LSB))
  1186. /*
  1187. * hal_rx_msdu_start_get_freq(): API to get the frequency of operating channel
  1188. * from rx_msdu_start
  1189. *
  1190. * @buf: pointer to the start of RX PKT TLV header
  1191. * Return: uint32_t(frequency)
  1192. */
  1193. static inline uint32_t
  1194. hal_rx_msdu_start_get_freq(uint8_t *buf)
  1195. {
  1196. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1197. struct rx_msdu_start *msdu_start =
  1198. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1199. uint32_t freq;
  1200. freq = HAL_RX_MSDU_START_FREQ_GET(msdu_start);
  1201. return freq;
  1202. }
  1203. #define HAL_RX_MSDU_START_PKT_TYPE_GET(_rx_msdu_start) \
  1204. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1205. RX_MSDU_START_5_PKT_TYPE_OFFSET)), \
  1206. RX_MSDU_START_5_PKT_TYPE_MASK, \
  1207. RX_MSDU_START_5_PKT_TYPE_LSB))
  1208. /*
  1209. * hal_rx_msdu_start_get_pkt_type(): API to get the pkt type
  1210. * from rx_msdu_start
  1211. *
  1212. * @buf: pointer to the start of RX PKT TLV header
  1213. * Return: uint32_t(pkt type)
  1214. */
  1215. static inline uint32_t
  1216. hal_rx_msdu_start_get_pkt_type(uint8_t *buf)
  1217. {
  1218. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1219. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1220. uint32_t pkt_type;
  1221. pkt_type = HAL_RX_MSDU_START_PKT_TYPE_GET(msdu_start);
  1222. return pkt_type;
  1223. }
  1224. #define HAL_RX_MPDU_GET_TODS(_rx_mpdu_info) \
  1225. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1226. RX_MPDU_INFO_2_TO_DS_OFFSET)), \
  1227. RX_MPDU_INFO_2_TO_DS_MASK, \
  1228. RX_MPDU_INFO_2_TO_DS_LSB))
  1229. /*
  1230. * hal_rx_mpdu_get_tods(): API to get the tods info
  1231. * from rx_mpdu_start
  1232. *
  1233. * @buf: pointer to the start of RX PKT TLV header
  1234. * Return: uint32_t(to_ds)
  1235. */
  1236. static inline uint32_t
  1237. hal_rx_mpdu_get_to_ds(uint8_t *buf)
  1238. {
  1239. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1240. struct rx_mpdu_start *mpdu_start =
  1241. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1242. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1243. uint32_t to_ds;
  1244. to_ds = HAL_RX_MPDU_GET_TODS(mpdu_info);
  1245. return to_ds;
  1246. }
  1247. #define HAL_RX_MPDU_GET_FROMDS(_rx_mpdu_info) \
  1248. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1249. RX_MPDU_INFO_2_FR_DS_OFFSET)), \
  1250. RX_MPDU_INFO_2_FR_DS_MASK, \
  1251. RX_MPDU_INFO_2_FR_DS_LSB))
  1252. /*
  1253. * hal_rx_mpdu_get_fr_ds(): API to get the from ds info
  1254. * from rx_mpdu_start
  1255. *
  1256. * @buf: pointer to the start of RX PKT TLV header
  1257. * Return: uint32_t(fr_ds)
  1258. */
  1259. static inline uint32_t
  1260. hal_rx_mpdu_get_fr_ds(uint8_t *buf)
  1261. {
  1262. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1263. struct rx_mpdu_start *mpdu_start =
  1264. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1265. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1266. uint32_t fr_ds;
  1267. fr_ds = HAL_RX_MPDU_GET_FROMDS(mpdu_info);
  1268. return fr_ds;
  1269. }
  1270. #define HAL_RX_MPDU_MAC_ADDR_AD1_VALID_GET(_rx_mpdu_info) \
  1271. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1272. RX_MPDU_INFO_2_MAC_ADDR_AD1_VALID_OFFSET)), \
  1273. RX_MPDU_INFO_2_MAC_ADDR_AD1_VALID_MASK, \
  1274. RX_MPDU_INFO_2_MAC_ADDR_AD1_VALID_LSB))
  1275. #define HAL_RX_MPDU_MAC_ADDR_AD2_VALID_GET(_rx_mpdu_info) \
  1276. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1277. RX_MPDU_INFO_2_MAC_ADDR_AD2_VALID_OFFSET)), \
  1278. RX_MPDU_INFO_2_MAC_ADDR_AD2_VALID_MASK, \
  1279. RX_MPDU_INFO_2_MAC_ADDR_AD2_VALID_LSB))
  1280. #define HAL_RX_MPDU_MAC_ADDR_AD3_VALID_GET(_rx_mpdu_info) \
  1281. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1282. RX_MPDU_INFO_2_MAC_ADDR_AD3_VALID_OFFSET)), \
  1283. RX_MPDU_INFO_2_MAC_ADDR_AD3_VALID_MASK, \
  1284. RX_MPDU_INFO_2_MAC_ADDR_AD3_VALID_LSB))
  1285. #define HAL_RX_MPDU_MAC_ADDR_AD4_VALID_GET(_rx_mpdu_info) \
  1286. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1287. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_OFFSET)), \
  1288. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_MASK, \
  1289. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_LSB))
  1290. #define HAL_RX_MPDU_AD1_31_0_GET(_rx_mpdu_info) \
  1291. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1292. RX_MPDU_INFO_15_MAC_ADDR_AD1_31_0_OFFSET)), \
  1293. RX_MPDU_INFO_15_MAC_ADDR_AD1_31_0_MASK, \
  1294. RX_MPDU_INFO_15_MAC_ADDR_AD1_31_0_LSB))
  1295. #define HAL_RX_MPDU_AD1_47_32_GET(_rx_mpdu_info) \
  1296. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1297. RX_MPDU_INFO_16_MAC_ADDR_AD1_47_32_OFFSET)), \
  1298. RX_MPDU_INFO_16_MAC_ADDR_AD1_47_32_MASK, \
  1299. RX_MPDU_INFO_16_MAC_ADDR_AD1_47_32_LSB))
  1300. #define HAL_RX_MPDU_AD2_15_0_GET(_rx_mpdu_info) \
  1301. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1302. RX_MPDU_INFO_16_MAC_ADDR_AD2_15_0_OFFSET)), \
  1303. RX_MPDU_INFO_16_MAC_ADDR_AD2_15_0_MASK, \
  1304. RX_MPDU_INFO_16_MAC_ADDR_AD2_15_0_LSB))
  1305. #define HAL_RX_MPDU_AD2_47_16_GET(_rx_mpdu_info) \
  1306. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1307. RX_MPDU_INFO_17_MAC_ADDR_AD2_47_16_OFFSET)), \
  1308. RX_MPDU_INFO_17_MAC_ADDR_AD2_47_16_MASK, \
  1309. RX_MPDU_INFO_17_MAC_ADDR_AD2_47_16_LSB))
  1310. #define HAL_RX_MPDU_AD3_31_0_GET(_rx_mpdu_info) \
  1311. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1312. RX_MPDU_INFO_18_MAC_ADDR_AD3_31_0_OFFSET)), \
  1313. RX_MPDU_INFO_18_MAC_ADDR_AD3_31_0_MASK, \
  1314. RX_MPDU_INFO_18_MAC_ADDR_AD3_31_0_LSB))
  1315. #define HAL_RX_MPDU_AD3_47_32_GET(_rx_mpdu_info) \
  1316. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1317. RX_MPDU_INFO_19_MAC_ADDR_AD3_47_32_OFFSET)), \
  1318. RX_MPDU_INFO_19_MAC_ADDR_AD3_47_32_MASK, \
  1319. RX_MPDU_INFO_19_MAC_ADDR_AD3_47_32_LSB))
  1320. #define HAL_RX_MPDU_AD4_31_0_GET(_rx_mpdu_info) \
  1321. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1322. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_OFFSET)), \
  1323. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_MASK, \
  1324. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_LSB))
  1325. #define HAL_RX_MPDU_AD4_47_32_GET(_rx_mpdu_info) \
  1326. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1327. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_OFFSET)), \
  1328. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_MASK, \
  1329. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_LSB))
  1330. /*
  1331. * hal_rx_mpdu_get_addr1(): API to check get address1 of the mpdu
  1332. *
  1333. * @buf: pointer to the start of RX PKT TLV headera
  1334. * @mac_addr: pointer to mac address
  1335. * Return: success/failure
  1336. */
  1337. static inline
  1338. QDF_STATUS hal_rx_mpdu_get_addr1(uint8_t *buf, uint8_t *mac_addr)
  1339. {
  1340. struct __attribute__((__packed__)) hal_addr1 {
  1341. uint32_t ad1_31_0;
  1342. uint16_t ad1_47_32;
  1343. };
  1344. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1345. struct rx_mpdu_start *mpdu_start =
  1346. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1347. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1348. struct hal_addr1 *addr = (struct hal_addr1 *)mac_addr;
  1349. uint32_t mac_addr_ad1_valid;
  1350. mac_addr_ad1_valid = HAL_RX_MPDU_MAC_ADDR_AD1_VALID_GET(mpdu_info);
  1351. if (mac_addr_ad1_valid) {
  1352. addr->ad1_31_0 = HAL_RX_MPDU_AD1_31_0_GET(mpdu_info);
  1353. addr->ad1_47_32 = HAL_RX_MPDU_AD1_47_32_GET(mpdu_info);
  1354. return QDF_STATUS_SUCCESS;
  1355. }
  1356. return QDF_STATUS_E_FAILURE;
  1357. }
  1358. /*
  1359. * hal_rx_mpdu_get_addr2(): API to check get address2 of the mpdu
  1360. * in the packet
  1361. *
  1362. * @buf: pointer to the start of RX PKT TLV header
  1363. * @mac_addr: pointer to mac address
  1364. * Return: success/failure
  1365. */
  1366. static inline
  1367. QDF_STATUS hal_rx_mpdu_get_addr2(uint8_t *buf, uint8_t *mac_addr)
  1368. {
  1369. struct __attribute__((__packed__)) hal_addr2 {
  1370. uint16_t ad2_15_0;
  1371. uint32_t ad2_47_16;
  1372. };
  1373. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1374. struct rx_mpdu_start *mpdu_start =
  1375. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1376. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1377. struct hal_addr2 *addr = (struct hal_addr2 *)mac_addr;
  1378. uint32_t mac_addr_ad2_valid;
  1379. mac_addr_ad2_valid = HAL_RX_MPDU_MAC_ADDR_AD2_VALID_GET(mpdu_info);
  1380. if (mac_addr_ad2_valid) {
  1381. addr->ad2_15_0 = HAL_RX_MPDU_AD2_15_0_GET(mpdu_info);
  1382. addr->ad2_47_16 = HAL_RX_MPDU_AD2_47_16_GET(mpdu_info);
  1383. return QDF_STATUS_SUCCESS;
  1384. }
  1385. return QDF_STATUS_E_FAILURE;
  1386. }
  1387. /*
  1388. * hal_rx_mpdu_get_addr3(): API to get address3 of the mpdu
  1389. * in the packet
  1390. *
  1391. * @buf: pointer to the start of RX PKT TLV header
  1392. * @mac_addr: pointer to mac address
  1393. * Return: success/failure
  1394. */
  1395. static inline
  1396. QDF_STATUS hal_rx_mpdu_get_addr3(uint8_t *buf, uint8_t *mac_addr)
  1397. {
  1398. struct __attribute__((__packed__)) hal_addr3 {
  1399. uint32_t ad3_31_0;
  1400. uint16_t ad3_47_32;
  1401. };
  1402. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1403. struct rx_mpdu_start *mpdu_start =
  1404. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1405. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1406. struct hal_addr3 *addr = (struct hal_addr3 *)mac_addr;
  1407. uint32_t mac_addr_ad3_valid;
  1408. mac_addr_ad3_valid = HAL_RX_MPDU_MAC_ADDR_AD3_VALID_GET(mpdu_info);
  1409. if (mac_addr_ad3_valid) {
  1410. addr->ad3_31_0 = HAL_RX_MPDU_AD3_31_0_GET(mpdu_info);
  1411. addr->ad3_47_32 = HAL_RX_MPDU_AD3_47_32_GET(mpdu_info);
  1412. return QDF_STATUS_SUCCESS;
  1413. }
  1414. return QDF_STATUS_E_FAILURE;
  1415. }
  1416. /*
  1417. * hal_rx_mpdu_get_addr4(): API to get address4 of the mpdu
  1418. * in the packet
  1419. *
  1420. * @buf: pointer to the start of RX PKT TLV header
  1421. * @mac_addr: pointer to mac address
  1422. * Return: success/failure
  1423. */
  1424. static inline
  1425. QDF_STATUS hal_rx_mpdu_get_addr4(uint8_t *buf, uint8_t *mac_addr)
  1426. {
  1427. struct __attribute__((__packed__)) hal_addr4 {
  1428. uint32_t ad4_31_0;
  1429. uint16_t ad4_47_32;
  1430. };
  1431. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1432. struct rx_mpdu_start *mpdu_start =
  1433. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  1434. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  1435. struct hal_addr4 *addr = (struct hal_addr4 *)mac_addr;
  1436. uint32_t mac_addr_ad4_valid;
  1437. mac_addr_ad4_valid = HAL_RX_MPDU_MAC_ADDR_AD4_VALID_GET(mpdu_info);
  1438. if (mac_addr_ad4_valid) {
  1439. addr->ad4_31_0 = HAL_RX_MPDU_AD4_31_0_GET(mpdu_info);
  1440. addr->ad4_47_32 = HAL_RX_MPDU_AD4_47_32_GET(mpdu_info);
  1441. return QDF_STATUS_SUCCESS;
  1442. }
  1443. return QDF_STATUS_E_FAILURE;
  1444. }
  1445. /**
  1446. * hal_rx_msdu_end_da_idx_get: API to get da_idx
  1447. * from rx_msdu_end TLV
  1448. *
  1449. * @ buf: pointer to the start of RX PKT TLV headers
  1450. * Return: da index
  1451. */
  1452. static inline uint16_t
  1453. hal_rx_msdu_end_da_idx_get(struct hal_soc *hal_soc, uint8_t *buf)
  1454. {
  1455. return hal_soc->ops->hal_rx_msdu_end_da_idx_get(buf);
  1456. }
  1457. #define HAL_RX_MSDU_END_DA_IS_VALID_GET(_rx_msdu_end) \
  1458. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1459. RX_MSDU_END_5_DA_IS_VALID_OFFSET)), \
  1460. RX_MSDU_END_5_DA_IS_VALID_MASK, \
  1461. RX_MSDU_END_5_DA_IS_VALID_LSB))
  1462. /**
  1463. * hal_rx_msdu_end_da_is_valid_get: API to check if da is valid
  1464. * from rx_msdu_end TLV
  1465. *
  1466. * @ buf: pointer to the start of RX PKT TLV headers
  1467. * Return: da_is_valid
  1468. */
  1469. static inline uint8_t
  1470. hal_rx_msdu_end_da_is_valid_get(uint8_t *buf)
  1471. {
  1472. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1473. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1474. uint8_t da_is_valid;
  1475. da_is_valid = HAL_RX_MSDU_END_DA_IS_VALID_GET(msdu_end);
  1476. return da_is_valid;
  1477. }
  1478. #define HAL_RX_MSDU_END_DA_IS_MCBC_GET(_rx_msdu_end) \
  1479. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1480. RX_MSDU_END_5_DA_IS_MCBC_OFFSET)), \
  1481. RX_MSDU_END_5_DA_IS_MCBC_MASK, \
  1482. RX_MSDU_END_5_DA_IS_MCBC_LSB))
  1483. /**
  1484. * hal_rx_msdu_end_da_is_mcbc_get: API to check if pkt is MCBC
  1485. * from rx_msdu_end TLV
  1486. *
  1487. * @ buf: pointer to the start of RX PKT TLV headers
  1488. * Return: da_is_mcbc
  1489. */
  1490. static inline uint8_t
  1491. hal_rx_msdu_end_da_is_mcbc_get(uint8_t *buf)
  1492. {
  1493. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1494. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1495. uint8_t da_is_mcbc;
  1496. da_is_mcbc = HAL_RX_MSDU_END_DA_IS_MCBC_GET(msdu_end);
  1497. return da_is_mcbc;
  1498. }
  1499. #define HAL_RX_MSDU_END_FIRST_MSDU_GET(_rx_msdu_end) \
  1500. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1501. RX_MSDU_END_5_FIRST_MSDU_OFFSET)), \
  1502. RX_MSDU_END_5_FIRST_MSDU_MASK, \
  1503. RX_MSDU_END_5_FIRST_MSDU_LSB))
  1504. /**
  1505. * hal_rx_msdu_end_first_msdu_get: API to get first msdu status
  1506. * from rx_msdu_end TLV
  1507. *
  1508. * @ buf: pointer to the start of RX PKT TLV headers
  1509. * Return: first_msdu
  1510. */
  1511. static inline uint8_t
  1512. hal_rx_msdu_end_first_msdu_get(uint8_t *buf)
  1513. {
  1514. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1515. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1516. uint8_t first_msdu;
  1517. first_msdu = HAL_RX_MSDU_END_FIRST_MSDU_GET(msdu_end);
  1518. return first_msdu;
  1519. }
  1520. #define HAL_RX_MSDU_END_LAST_MSDU_GET(_rx_msdu_end) \
  1521. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1522. RX_MSDU_END_5_LAST_MSDU_OFFSET)), \
  1523. RX_MSDU_END_5_LAST_MSDU_MASK, \
  1524. RX_MSDU_END_5_LAST_MSDU_LSB))
  1525. /**
  1526. * hal_rx_msdu_end_last_msdu_get: API to get last msdu status
  1527. * from rx_msdu_end TLV
  1528. *
  1529. * @ buf: pointer to the start of RX PKT TLV headers
  1530. * Return: last_msdu
  1531. */
  1532. static inline uint8_t
  1533. hal_rx_msdu_end_last_msdu_get(uint8_t *buf)
  1534. {
  1535. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1536. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1537. uint8_t last_msdu;
  1538. last_msdu = HAL_RX_MSDU_END_LAST_MSDU_GET(msdu_end);
  1539. return last_msdu;
  1540. }
  1541. /*******************************************************************************
  1542. * RX ERROR APIS
  1543. ******************************************************************************/
  1544. #define HAL_RX_MPDU_END_DECRYPT_ERR_GET(_rx_mpdu_end) \
  1545. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1546. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_OFFSET)), \
  1547. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_MASK, \
  1548. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_LSB))
  1549. /**
  1550. * hal_rx_mpdu_end_decrypt_err_get(): API to get the Decrypt ERR
  1551. * from rx_mpdu_end TLV
  1552. *
  1553. * @buf: pointer to the start of RX PKT TLV headers
  1554. * Return: uint32_t(decrypt_err)
  1555. */
  1556. static inline uint32_t
  1557. hal_rx_mpdu_end_decrypt_err_get(uint8_t *buf)
  1558. {
  1559. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1560. struct rx_mpdu_end *mpdu_end =
  1561. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1562. uint32_t decrypt_err;
  1563. decrypt_err = HAL_RX_MPDU_END_DECRYPT_ERR_GET(mpdu_end);
  1564. return decrypt_err;
  1565. }
  1566. #define HAL_RX_MPDU_END_MIC_ERR_GET(_rx_mpdu_end) \
  1567. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1568. RX_MPDU_END_1_TKIP_MIC_ERR_OFFSET)), \
  1569. RX_MPDU_END_1_TKIP_MIC_ERR_MASK, \
  1570. RX_MPDU_END_1_TKIP_MIC_ERR_LSB))
  1571. /**
  1572. * hal_rx_mpdu_end_mic_err_get(): API to get the MIC ERR
  1573. * from rx_mpdu_end TLV
  1574. *
  1575. * @buf: pointer to the start of RX PKT TLV headers
  1576. * Return: uint32_t(mic_err)
  1577. */
  1578. static inline uint32_t
  1579. hal_rx_mpdu_end_mic_err_get(uint8_t *buf)
  1580. {
  1581. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1582. struct rx_mpdu_end *mpdu_end =
  1583. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1584. uint32_t mic_err;
  1585. mic_err = HAL_RX_MPDU_END_MIC_ERR_GET(mpdu_end);
  1586. return mic_err;
  1587. }
  1588. /*******************************************************************************
  1589. * RX REO ERROR APIS
  1590. ******************************************************************************/
  1591. #define HAL_RX_NUM_MSDU_DESC 6
  1592. #define HAL_RX_MAX_SAVED_RING_DESC 16
  1593. /* TODO: rework the structure */
  1594. struct hal_rx_msdu_list {
  1595. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  1596. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  1597. uint8_t rbm[HAL_RX_NUM_MSDU_DESC];
  1598. };
  1599. struct hal_buf_info {
  1600. uint64_t paddr;
  1601. uint32_t sw_cookie;
  1602. };
  1603. /**
  1604. * hal_rx_link_desc_msdu0_ptr - Get pointer to rx_msdu details
  1605. * @msdu_link_ptr - msdu link ptr
  1606. * @hal - pointer to hal_soc
  1607. * Return - Pointer to rx_msdu_details structure
  1608. *
  1609. */
  1610. static inline void *hal_rx_link_desc_msdu0_ptr(void *msdu_link_ptr, void *hal)
  1611. {
  1612. struct hal_soc *hal_soc = (struct hal_soc *)hal;
  1613. return hal_soc->ops->hal_rx_link_desc_msdu0_ptr(msdu_link_ptr);
  1614. }
  1615. /**
  1616. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  1617. * @msdu_details_ptr - Pointer to msdu_details_ptr
  1618. * @hal - pointer to hal_soc
  1619. * Return - Pointer to rx_msdu_desc_info structure.
  1620. *
  1621. */
  1622. static inline void *hal_rx_msdu_desc_info_get_ptr(void *msdu_details_ptr, void *hal)
  1623. {
  1624. struct hal_soc *hal_soc = (struct hal_soc *)hal;
  1625. return hal_soc->ops->hal_rx_msdu_desc_info_get_ptr(msdu_details_ptr);
  1626. }
  1627. /* This special cookie value will be used to indicate FW allocated buffers
  1628. * received through RXDMA2SW ring for RXDMA WARs
  1629. */
  1630. #define HAL_RX_COOKIE_SPECIAL 0x1fffff
  1631. /**
  1632. * hal_rx_msdu_link_desc_get(): API to get the MSDU information
  1633. * from the MSDU link descriptor
  1634. *
  1635. * @msdu_link_desc: Opaque pointer used by HAL to get to the
  1636. * MSDU link descriptor (struct rx_msdu_link)
  1637. *
  1638. * @msdu_list: Return the list of MSDUs contained in this link descriptor
  1639. *
  1640. * @num_msdus: Number of MSDUs in the MPDU
  1641. *
  1642. * Return: void
  1643. */
  1644. static inline void hal_rx_msdu_list_get(struct hal_soc *hal_soc,
  1645. void *msdu_link_desc,
  1646. struct hal_rx_msdu_list *msdu_list,
  1647. uint16_t *num_msdus)
  1648. {
  1649. struct rx_msdu_details *msdu_details;
  1650. struct rx_msdu_desc_info *msdu_desc_info;
  1651. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1652. int i;
  1653. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1654. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1655. "[%s][%d] msdu_link=%pK msdu_details=%pK",
  1656. __func__, __LINE__, msdu_link, msdu_details);
  1657. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  1658. /* num_msdus received in mpdu descriptor may be incorrect
  1659. * sometimes due to HW issue. Check msdu buffer address also
  1660. */
  1661. if (HAL_RX_BUFFER_ADDR_31_0_GET(
  1662. &msdu_details[i].buffer_addr_info_details) == 0) {
  1663. /* set the last msdu bit in the prev msdu_desc_info */
  1664. msdu_desc_info =
  1665. hal_rx_msdu_desc_info_get_ptr(&msdu_details[i - 1], hal_soc);
  1666. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1667. break;
  1668. }
  1669. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[i],
  1670. hal_soc);
  1671. /* set first MSDU bit or the last MSDU bit */
  1672. if (!i)
  1673. HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1674. else if (i == (HAL_RX_NUM_MSDU_DESC - 1))
  1675. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1676. msdu_list->msdu_info[i].msdu_flags =
  1677. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  1678. msdu_list->msdu_info[i].msdu_len =
  1679. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  1680. msdu_list->sw_cookie[i] =
  1681. HAL_RX_BUF_COOKIE_GET(
  1682. &msdu_details[i].buffer_addr_info_details);
  1683. msdu_list->rbm[i] = HAL_RX_BUF_RBM_GET(
  1684. &msdu_details[i].buffer_addr_info_details);
  1685. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1686. "[%s][%d] i=%d sw_cookie=%d",
  1687. __func__, __LINE__, i, msdu_list->sw_cookie[i]);
  1688. }
  1689. *num_msdus = i;
  1690. }
  1691. /**
  1692. * hal_rx_msdu_reo_dst_ind_get: Gets the REO
  1693. * destination ring ID from the msdu desc info
  1694. *
  1695. * @msdu_link_desc : Opaque cookie pointer used by HAL to get to
  1696. * the current descriptor
  1697. *
  1698. * Return: dst_ind (REO destination ring ID)
  1699. */
  1700. static inline uint32_t
  1701. hal_rx_msdu_reo_dst_ind_get(struct hal_soc *hal_soc, void *msdu_link_desc)
  1702. {
  1703. struct rx_msdu_details *msdu_details;
  1704. struct rx_msdu_desc_info *msdu_desc_info;
  1705. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1706. uint32_t dst_ind;
  1707. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1708. /* The first msdu in the link should exsist */
  1709. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[0],
  1710. hal_soc);
  1711. dst_ind = HAL_RX_MSDU_REO_DST_IND_GET(msdu_desc_info);
  1712. return dst_ind;
  1713. }
  1714. /**
  1715. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  1716. * cookie from the REO destination ring element
  1717. *
  1718. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  1719. * the current descriptor
  1720. * @ buf_info: structure to return the buffer information
  1721. * Return: void
  1722. */
  1723. static inline void hal_rx_reo_buf_paddr_get(void *rx_desc,
  1724. struct hal_buf_info *buf_info)
  1725. {
  1726. struct reo_destination_ring *reo_ring =
  1727. (struct reo_destination_ring *)rx_desc;
  1728. buf_info->paddr =
  1729. (HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_ring) |
  1730. ((uint64_t)(HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_ring)) << 32));
  1731. buf_info->sw_cookie = HAL_RX_REO_BUF_COOKIE_GET(reo_ring);
  1732. }
  1733. /**
  1734. * enum hal_reo_error_code: Indicates that type of buffer or descriptor
  1735. *
  1736. * @ HAL_RX_MSDU_BUF_ADDR_TYPE : Reo buffer address points to the MSDU buffer
  1737. * @ HAL_RX_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  1738. * descriptor
  1739. */
  1740. enum hal_rx_reo_buf_type {
  1741. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  1742. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  1743. };
  1744. #define HAL_RX_REO_BUF_TYPE_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1745. (REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_OFFSET >> 2))) & \
  1746. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_MASK) >> \
  1747. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_LSB)
  1748. /**
  1749. * enum hal_reo_error_code: Error code describing the type of error detected
  1750. *
  1751. * @ HAL_REO_ERR_QUEUE_DESC_ADDR_0 : Reo queue descriptor provided in the
  1752. * REO_ENTRANCE ring is set to 0
  1753. * @ HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  1754. * @ HAL_REO_ERR_AMPDU_IN_NON_BA : AMPDU frame received without BA session
  1755. * having been setup
  1756. * @ HAL_REO_ERR_NON_BA_DUPLICATE : Non-BA session, SN equal to SSN,
  1757. * Retry bit set: duplicate frame
  1758. * @ HAL_REO_ERR_BA_DUPLICATE : BA session, duplicate frame
  1759. * @ HAL_REO_ERR_REGULAR_FRAME_2K_JUMP : A normal (management/data frame)
  1760. * received with 2K jump in SN
  1761. * @ HAL_REO_ERR_BAR_FRAME_2K_JUMP : A bar received with 2K jump in SSN
  1762. * @ HAL_REO_ERR_REGULAR_FRAME_OOR : A normal (management/data frame) received
  1763. * with SN falling within the OOR window
  1764. * @ HAL_REO_ERR_BAR_FRAME_OOR : A bar received with SSN falling within the
  1765. * OOR window
  1766. * @ HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION : A bar received without a BA session
  1767. * @ HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN : A bar received with SSN equal to SN
  1768. * @ HAL_REO_ERR_PN_CHECK_FAILED : PN Check Failed packet
  1769. * @ HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1770. * of the Seq_2k_error_detected_flag been set in the REO Queue descriptor
  1771. * @ HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1772. * of the pn_error_detected_flag been set in the REO Queue descriptor
  1773. * @ HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET : Frame is forwarded as a result of
  1774. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  1775. * in the process of making updates to this descriptor
  1776. */
  1777. enum hal_reo_error_code {
  1778. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  1779. HAL_REO_ERR_QUEUE_DESC_INVALID,
  1780. HAL_REO_ERR_AMPDU_IN_NON_BA,
  1781. HAL_REO_ERR_NON_BA_DUPLICATE,
  1782. HAL_REO_ERR_BA_DUPLICATE,
  1783. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  1784. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  1785. HAL_REO_ERR_REGULAR_FRAME_OOR,
  1786. HAL_REO_ERR_BAR_FRAME_OOR,
  1787. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  1788. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  1789. HAL_REO_ERR_PN_CHECK_FAILED,
  1790. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  1791. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  1792. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET,
  1793. HAL_REO_ERR_MAX
  1794. };
  1795. /**
  1796. * enum hal_rxdma_error_code: Code describing the type of RxDMA error detected
  1797. *
  1798. * @HAL_RXDMA_ERR_OVERFLOW: MPDU frame is not complete due to a FIFO overflow
  1799. * @ HAL_RXDMA_ERR_OVERFLOW : MPDU frame is not complete due to a FIFO
  1800. * overflow
  1801. * @ HAL_RXDMA_ERR_MPDU_LENGTH : MPDU frame is not complete due to receiving
  1802. * incomplete
  1803. * MPDU from the PHY
  1804. * @ HAL_RXDMA_ERR_FCS : FCS check on the MPDU frame failed
  1805. * @ HAL_RXDMA_ERR_DECRYPT : Decryption error
  1806. * @ HAL_RXDMA_ERR_TKIP_MIC : TKIP MIC error
  1807. * @ HAL_RXDMA_ERR_UNENCRYPTED : Received a frame that was expected to be
  1808. * encrypted but wasn’t
  1809. * @ HAL_RXDMA_ERR_MSDU_LEN : MSDU related length error
  1810. * @ HAL_RXDMA_ERR_MSDU_LIMIT : Number of MSDUs in the MPDUs exceeded
  1811. * the max allowed
  1812. * @ HAL_RXDMA_ERR_WIFI_PARSE : wifi parsing error
  1813. * @ HAL_RXDMA_ERR_AMSDU_PARSE : Amsdu parsing error
  1814. * @ HAL_RXDMA_ERR_SA_TIMEOUT : Source Address search timeout
  1815. * @ HAL_RXDMA_ERR_DA_TIMEOUT : Destination Address search timeout
  1816. * @ HAL_RXDMA_ERR_FLOW_TIMEOUT : Flow Search Timeout
  1817. * @ HAL_RXDMA_ERR_FLUSH_REQUEST : RxDMA FIFO Flush request
  1818. * @ HAL_RXDMA_ERR_WAR : RxDMA WAR dummy errors
  1819. */
  1820. enum hal_rxdma_error_code {
  1821. HAL_RXDMA_ERR_OVERFLOW = 0,
  1822. HAL_RXDMA_ERR_MPDU_LENGTH,
  1823. HAL_RXDMA_ERR_FCS,
  1824. HAL_RXDMA_ERR_DECRYPT,
  1825. HAL_RXDMA_ERR_TKIP_MIC,
  1826. HAL_RXDMA_ERR_UNENCRYPTED,
  1827. HAL_RXDMA_ERR_MSDU_LEN,
  1828. HAL_RXDMA_ERR_MSDU_LIMIT,
  1829. HAL_RXDMA_ERR_WIFI_PARSE,
  1830. HAL_RXDMA_ERR_AMSDU_PARSE,
  1831. HAL_RXDMA_ERR_SA_TIMEOUT,
  1832. HAL_RXDMA_ERR_DA_TIMEOUT,
  1833. HAL_RXDMA_ERR_FLOW_TIMEOUT,
  1834. HAL_RXDMA_ERR_FLUSH_REQUEST,
  1835. HAL_RXDMA_ERR_WAR = 31,
  1836. HAL_RXDMA_ERR_MAX
  1837. };
  1838. /**
  1839. * HW BM action settings in WBM release ring
  1840. */
  1841. #define HAL_BM_ACTION_PUT_IN_IDLE_LIST 0
  1842. #define HAL_BM_ACTION_RELEASE_MSDU_LIST 1
  1843. /**
  1844. * enum hal_rx_wbm_error_source: Indicates which module initiated the
  1845. * release of this buffer or descriptor
  1846. *
  1847. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1848. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1849. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1850. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1851. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1852. */
  1853. enum hal_rx_wbm_error_source {
  1854. HAL_RX_WBM_ERR_SRC_TQM = 0,
  1855. HAL_RX_WBM_ERR_SRC_RXDMA,
  1856. HAL_RX_WBM_ERR_SRC_REO,
  1857. HAL_RX_WBM_ERR_SRC_FW,
  1858. HAL_RX_WBM_ERR_SRC_SW,
  1859. };
  1860. /**
  1861. * enum hal_rx_wbm_buf_type: Indicates that type of buffer or descriptor
  1862. * released
  1863. *
  1864. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1865. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1866. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1867. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1868. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1869. */
  1870. enum hal_rx_wbm_buf_type {
  1871. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  1872. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  1873. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  1874. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  1875. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  1876. };
  1877. #define HAL_RX_REO_ERROR_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1878. (REO_DESTINATION_RING_7_REO_ERROR_CODE_OFFSET >> 2))) & \
  1879. REO_DESTINATION_RING_7_REO_ERROR_CODE_MASK) >> \
  1880. REO_DESTINATION_RING_7_REO_ERROR_CODE_LSB)
  1881. /**
  1882. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  1883. * PN check failure
  1884. *
  1885. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  1886. *
  1887. * Return: true: error caused by PN check, false: other error
  1888. */
  1889. static inline bool hal_rx_reo_is_pn_error(void *rx_desc)
  1890. {
  1891. struct reo_destination_ring *reo_desc =
  1892. (struct reo_destination_ring *)rx_desc;
  1893. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1894. HAL_REO_ERR_PN_CHECK_FAILED) |
  1895. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1896. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  1897. true : false;
  1898. }
  1899. /**
  1900. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  1901. * the sequence number
  1902. *
  1903. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1904. *
  1905. * Return: true: error caused by 2K jump, false: other error
  1906. */
  1907. static inline bool hal_rx_reo_is_2k_jump(void *rx_desc)
  1908. {
  1909. struct reo_destination_ring *reo_desc =
  1910. (struct reo_destination_ring *)rx_desc;
  1911. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1912. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) |
  1913. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1914. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  1915. true : false;
  1916. }
  1917. /**
  1918. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  1919. *
  1920. * @ soc : HAL version of the SOC pointer
  1921. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  1922. * @ buf_addr_info : void pointer to the buffer_addr_info
  1923. * @ bm_action : put in IDLE list or release to MSDU_LIST
  1924. *
  1925. * Return: void
  1926. */
  1927. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  1928. static inline void hal_rx_msdu_link_desc_set(struct hal_soc *soc,
  1929. void *src_srng_desc, void *buf_addr_info,
  1930. uint8_t bm_action)
  1931. {
  1932. struct wbm_release_ring *wbm_rel_srng =
  1933. (struct wbm_release_ring *)src_srng_desc;
  1934. /* Structure copy !!! */
  1935. wbm_rel_srng->released_buff_or_desc_addr_info =
  1936. *((struct buffer_addr_info *)buf_addr_info);
  1937. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1938. RELEASE_SOURCE_MODULE, HAL_RX_WBM_ERR_SRC_SW);
  1939. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2, BM_ACTION,
  1940. bm_action);
  1941. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1942. BUFFER_OR_DESC_TYPE, HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC);
  1943. }
  1944. /*
  1945. * hal_rx_msdu_link_desc_reinject: Re-injects the MSDU link descriptor to
  1946. * REO entrance ring
  1947. *
  1948. * @ soc: HAL version of the SOC pointer
  1949. * @ pa: Physical address of the MSDU Link Descriptor
  1950. * @ cookie: SW cookie to get to the virtual address
  1951. * @ error_enabled_reo_q: Argument to determine whether this needs to go
  1952. * to the error enabled REO queue
  1953. *
  1954. * Return: void
  1955. */
  1956. static inline void hal_rx_msdu_link_desc_reinject(struct hal_soc *soc,
  1957. uint64_t pa, uint32_t cookie, bool error_enabled_reo_q)
  1958. {
  1959. /* TODO */
  1960. }
  1961. /**
  1962. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  1963. * BUFFER_ADDR_INFO, give the RX descriptor
  1964. * (Assumption -- BUFFER_ADDR_INFO is the
  1965. * first field in the descriptor structure)
  1966. */
  1967. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) ((void *)(ring_desc))
  1968. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1969. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1970. /**
  1971. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  1972. * from the BUFFER_ADDR_INFO structure
  1973. * given a REO destination ring descriptor.
  1974. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  1975. *
  1976. * Return: uint8_t (value of the return_buffer_manager)
  1977. */
  1978. static inline
  1979. uint8_t hal_rx_ret_buf_manager_get(void *ring_desc)
  1980. {
  1981. /*
  1982. * The following macro takes buf_addr_info as argument,
  1983. * but since buf_addr_info is the first field in ring_desc
  1984. * Hence the following call is OK
  1985. */
  1986. return HAL_RX_BUF_RBM_GET(ring_desc);
  1987. }
  1988. /*******************************************************************************
  1989. * RX WBM ERROR APIS
  1990. ******************************************************************************/
  1991. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  1992. (WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  1993. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >> \
  1994. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB)
  1995. /**
  1996. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  1997. * the frame to this release ring
  1998. *
  1999. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  2000. * frame to this queue
  2001. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  2002. * received routing instructions. No error within REO was detected
  2003. */
  2004. enum hal_rx_wbm_reo_push_reason {
  2005. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  2006. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  2007. };
  2008. /**
  2009. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  2010. * this release ring
  2011. *
  2012. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  2013. * this frame to this queue
  2014. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  2015. * per received routing instructions. No error within RXDMA was detected
  2016. */
  2017. enum hal_rx_wbm_rxdma_push_reason {
  2018. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  2019. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  2020. };
  2021. #define HAL_RX_WBM_FIRST_MSDU_GET(wbm_desc) \
  2022. (((*(((uint32_t *) wbm_desc) + \
  2023. (WBM_RELEASE_RING_4_FIRST_MSDU_OFFSET >> 2))) & \
  2024. WBM_RELEASE_RING_4_FIRST_MSDU_MASK) >> \
  2025. WBM_RELEASE_RING_4_FIRST_MSDU_LSB)
  2026. #define HAL_RX_WBM_LAST_MSDU_GET(wbm_desc) \
  2027. (((*(((uint32_t *) wbm_desc) + \
  2028. (WBM_RELEASE_RING_4_LAST_MSDU_OFFSET >> 2))) & \
  2029. WBM_RELEASE_RING_4_LAST_MSDU_MASK) >> \
  2030. WBM_RELEASE_RING_4_LAST_MSDU_LSB)
  2031. #define HAL_RX_WBM_BUF_COOKIE_GET(wbm_desc) \
  2032. HAL_RX_BUF_COOKIE_GET(&((struct wbm_release_ring *) \
  2033. wbm_desc)->released_buff_or_desc_addr_info)
  2034. /**
  2035. * hal_rx_dump_rx_attention_tlv: dump RX attention TLV in structured
  2036. * humman readable format.
  2037. * @ rx_attn: pointer the rx_attention TLV in pkt.
  2038. * @ dbg_level: log level.
  2039. *
  2040. * Return: void
  2041. */
  2042. static inline void hal_rx_dump_rx_attention_tlv(struct rx_attention *rx_attn,
  2043. uint8_t dbg_level)
  2044. {
  2045. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  2046. "rx_attention tlv (1/2) - "
  2047. "rxpcu_mpdu_filter_in_category: %x "
  2048. "sw_frame_group_id: %x "
  2049. "reserved_0: %x "
  2050. "phy_ppdu_id: %x "
  2051. "first_mpdu : %x "
  2052. "reserved_1a: %x "
  2053. "mcast_bcast: %x "
  2054. "ast_index_not_found: %x "
  2055. "ast_index_timeout: %x "
  2056. "power_mgmt: %x "
  2057. "non_qos: %x "
  2058. "null_data: %x "
  2059. "mgmt_type: %x "
  2060. "ctrl_type: %x "
  2061. "more_data: %x "
  2062. "eosp: %x "
  2063. "a_msdu_error: %x "
  2064. "fragment_flag: %x "
  2065. "order: %x "
  2066. "cce_match: %x "
  2067. "overflow_err: %x "
  2068. "msdu_length_err: %x "
  2069. "tcp_udp_chksum_fail: %x "
  2070. "ip_chksum_fail: %x "
  2071. "sa_idx_invalid: %x "
  2072. "da_idx_invalid: %x "
  2073. "reserved_1b: %x "
  2074. "rx_in_tx_decrypt_byp: %x ",
  2075. rx_attn->rxpcu_mpdu_filter_in_category,
  2076. rx_attn->sw_frame_group_id,
  2077. rx_attn->reserved_0,
  2078. rx_attn->phy_ppdu_id,
  2079. rx_attn->first_mpdu,
  2080. rx_attn->reserved_1a,
  2081. rx_attn->mcast_bcast,
  2082. rx_attn->ast_index_not_found,
  2083. rx_attn->ast_index_timeout,
  2084. rx_attn->power_mgmt,
  2085. rx_attn->non_qos,
  2086. rx_attn->null_data,
  2087. rx_attn->mgmt_type,
  2088. rx_attn->ctrl_type,
  2089. rx_attn->more_data,
  2090. rx_attn->eosp,
  2091. rx_attn->a_msdu_error,
  2092. rx_attn->fragment_flag,
  2093. rx_attn->order,
  2094. rx_attn->cce_match,
  2095. rx_attn->overflow_err,
  2096. rx_attn->msdu_length_err,
  2097. rx_attn->tcp_udp_chksum_fail,
  2098. rx_attn->ip_chksum_fail,
  2099. rx_attn->sa_idx_invalid,
  2100. rx_attn->da_idx_invalid,
  2101. rx_attn->reserved_1b,
  2102. rx_attn->rx_in_tx_decrypt_byp);
  2103. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  2104. "rx_attention tlv (2/2) - "
  2105. "encrypt_required: %x "
  2106. "directed: %x "
  2107. "buffer_fragment: %x "
  2108. "mpdu_length_err: %x "
  2109. "tkip_mic_err: %x "
  2110. "decrypt_err: %x "
  2111. "unencrypted_frame_err: %x "
  2112. "fcs_err: %x "
  2113. "flow_idx_timeout: %x "
  2114. "flow_idx_invalid: %x "
  2115. "wifi_parser_error: %x "
  2116. "amsdu_parser_error: %x "
  2117. "sa_idx_timeout: %x "
  2118. "da_idx_timeout: %x "
  2119. "msdu_limit_error: %x "
  2120. "da_is_valid: %x "
  2121. "da_is_mcbc: %x "
  2122. "sa_is_valid: %x "
  2123. "decrypt_status_code: %x "
  2124. "rx_bitmap_not_updated: %x "
  2125. "reserved_2: %x "
  2126. "msdu_done: %x ",
  2127. rx_attn->encrypt_required,
  2128. rx_attn->directed,
  2129. rx_attn->buffer_fragment,
  2130. rx_attn->mpdu_length_err,
  2131. rx_attn->tkip_mic_err,
  2132. rx_attn->decrypt_err,
  2133. rx_attn->unencrypted_frame_err,
  2134. rx_attn->fcs_err,
  2135. rx_attn->flow_idx_timeout,
  2136. rx_attn->flow_idx_invalid,
  2137. rx_attn->wifi_parser_error,
  2138. rx_attn->amsdu_parser_error,
  2139. rx_attn->sa_idx_timeout,
  2140. rx_attn->da_idx_timeout,
  2141. rx_attn->msdu_limit_error,
  2142. rx_attn->da_is_valid,
  2143. rx_attn->da_is_mcbc,
  2144. rx_attn->sa_is_valid,
  2145. rx_attn->decrypt_status_code,
  2146. rx_attn->rx_bitmap_not_updated,
  2147. rx_attn->reserved_2,
  2148. rx_attn->msdu_done);
  2149. }
  2150. static inline void hal_rx_dump_mpdu_start_tlv(struct rx_mpdu_start *mpdu_start,
  2151. uint8_t dbg_level,
  2152. struct hal_soc *hal)
  2153. {
  2154. hal->ops->hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level);
  2155. }
  2156. /**
  2157. * hal_rx_dump_msdu_end_tlv: dump RX msdu_end TLV in structured
  2158. * human readable format.
  2159. * @ msdu_end: pointer the msdu_end TLV in pkt.
  2160. * @ dbg_level: log level.
  2161. *
  2162. * Return: void
  2163. */
  2164. static inline void hal_rx_dump_msdu_end_tlv(struct hal_soc *hal_soc,
  2165. struct rx_msdu_end *msdu_end,
  2166. uint8_t dbg_level)
  2167. {
  2168. hal_soc->ops->hal_rx_dump_msdu_end_tlv(msdu_end, dbg_level);
  2169. }
  2170. /**
  2171. * hal_rx_dump_mpdu_end_tlv: dump RX mpdu_end TLV in structured
  2172. * human readable format.
  2173. * @ mpdu_end: pointer the mpdu_end TLV in pkt.
  2174. * @ dbg_level: log level.
  2175. *
  2176. * Return: void
  2177. */
  2178. static inline void hal_rx_dump_mpdu_end_tlv(struct rx_mpdu_end *mpdu_end,
  2179. uint8_t dbg_level)
  2180. {
  2181. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  2182. "rx_mpdu_end tlv - "
  2183. "rxpcu_mpdu_filter_in_category: %x "
  2184. "sw_frame_group_id: %x "
  2185. "phy_ppdu_id: %x "
  2186. "unsup_ktype_short_frame: %x "
  2187. "rx_in_tx_decrypt_byp: %x "
  2188. "overflow_err: %x "
  2189. "mpdu_length_err: %x "
  2190. "tkip_mic_err: %x "
  2191. "decrypt_err: %x "
  2192. "unencrypted_frame_err: %x "
  2193. "pn_fields_contain_valid_info: %x "
  2194. "fcs_err: %x "
  2195. "msdu_length_err: %x "
  2196. "rxdma0_destination_ring: %x "
  2197. "rxdma1_destination_ring: %x "
  2198. "decrypt_status_code: %x "
  2199. "rx_bitmap_not_updated: %x ",
  2200. mpdu_end->rxpcu_mpdu_filter_in_category,
  2201. mpdu_end->sw_frame_group_id,
  2202. mpdu_end->phy_ppdu_id,
  2203. mpdu_end->unsup_ktype_short_frame,
  2204. mpdu_end->rx_in_tx_decrypt_byp,
  2205. mpdu_end->overflow_err,
  2206. mpdu_end->mpdu_length_err,
  2207. mpdu_end->tkip_mic_err,
  2208. mpdu_end->decrypt_err,
  2209. mpdu_end->unencrypted_frame_err,
  2210. mpdu_end->pn_fields_contain_valid_info,
  2211. mpdu_end->fcs_err,
  2212. mpdu_end->msdu_length_err,
  2213. mpdu_end->rxdma0_destination_ring,
  2214. mpdu_end->rxdma1_destination_ring,
  2215. mpdu_end->decrypt_status_code,
  2216. mpdu_end->rx_bitmap_not_updated);
  2217. }
  2218. /**
  2219. * hal_rx_dump_pkt_hdr_tlv: dump RX pkt header TLV in hex format
  2220. * @ pkt_hdr_tlv: pointer the pkt_hdr_tlv in pkt.
  2221. * @ dbg_level: log level.
  2222. *
  2223. * Return: void
  2224. */
  2225. static inline void hal_rx_dump_pkt_hdr_tlv(struct rx_pkt_hdr_tlv *pkt_hdr_tlv,
  2226. uint8_t dbg_level)
  2227. {
  2228. QDF_TRACE(QDF_MODULE_ID_DP, dbg_level,
  2229. "\n---------------\n"
  2230. "rx_pkt_hdr_tlv \n"
  2231. "---------------\n"
  2232. "phy_ppdu_id %d ",
  2233. pkt_hdr_tlv->phy_ppdu_id);
  2234. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, dbg_level,
  2235. pkt_hdr_tlv->rx_pkt_hdr, 128);
  2236. }
  2237. /**
  2238. * hal_srng_ring_id_get: API to retrieve ring id from hal ring
  2239. * structure
  2240. * @hal_ring: pointer to hal_srng structure
  2241. *
  2242. * Return: ring_id
  2243. */
  2244. static inline uint8_t hal_srng_ring_id_get(void *hal_ring)
  2245. {
  2246. return ((struct hal_srng *)hal_ring)->ring_id;
  2247. }
  2248. /* Rx MSDU link pointer info */
  2249. struct hal_rx_msdu_link_ptr_info {
  2250. struct rx_msdu_link msdu_link;
  2251. struct hal_buf_info msdu_link_buf_info;
  2252. };
  2253. /**
  2254. * hal_rx_get_pkt_tlvs(): Function to retrieve pkt tlvs from nbuf
  2255. *
  2256. * @nbuf: Pointer to data buffer field
  2257. * Returns: pointer to rx_pkt_tlvs
  2258. */
  2259. static inline
  2260. struct rx_pkt_tlvs *hal_rx_get_pkt_tlvs(uint8_t *rx_buf_start)
  2261. {
  2262. return (struct rx_pkt_tlvs *)rx_buf_start;
  2263. }
  2264. /**
  2265. * hal_rx_get_mpdu_info(): Function to retrieve mpdu info from pkt tlvs
  2266. *
  2267. * @pkt_tlvs: Pointer to pkt_tlvs
  2268. * Returns: pointer to rx_mpdu_info structure
  2269. */
  2270. static inline
  2271. struct rx_mpdu_info *hal_rx_get_mpdu_info(struct rx_pkt_tlvs *pkt_tlvs)
  2272. {
  2273. return &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start.rx_mpdu_info_details;
  2274. }
  2275. /**
  2276. * hal_rx_get_rx_sequence(): Function to retrieve rx sequence number
  2277. *
  2278. * @nbuf: Network buffer
  2279. * Returns: rx sequence number
  2280. */
  2281. #define DOT11_SEQ_FRAG_MASK 0x000f
  2282. #define DOT11_FC1_MORE_FRAG_OFFSET 0x04
  2283. #define HAL_RX_MPDU_GET_SEQUENCE_NUMBER(_rx_mpdu_info) \
  2284. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2285. RX_MPDU_INFO_2_MPDU_SEQUENCE_NUMBER_OFFSET)), \
  2286. RX_MPDU_INFO_2_MPDU_SEQUENCE_NUMBER_MASK, \
  2287. RX_MPDU_INFO_2_MPDU_SEQUENCE_NUMBER_LSB))
  2288. static inline
  2289. uint16_t hal_rx_get_rx_sequence(uint8_t *buf)
  2290. {
  2291. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2292. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2293. uint16_t seq_number = 0;
  2294. seq_number =
  2295. HAL_RX_MPDU_GET_SEQUENCE_NUMBER(rx_mpdu_info) >> 4;
  2296. /* Skip first 4-bits for fragment number */
  2297. return seq_number;
  2298. }
  2299. /**
  2300. * hal_rx_get_rx_fragment_number(): Function to retrieve rx fragment number
  2301. *
  2302. * @nbuf: Network buffer
  2303. * Returns: rx fragment number
  2304. */
  2305. static inline
  2306. uint8_t hal_rx_get_rx_fragment_number(uint8_t *buf)
  2307. {
  2308. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2309. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2310. uint8_t frag_number = 0;
  2311. frag_number = HAL_RX_MPDU_GET_SEQUENCE_NUMBER(rx_mpdu_info) &
  2312. DOT11_SEQ_FRAG_MASK;
  2313. /* Return first 4 bits as fragment number */
  2314. return frag_number;
  2315. }
  2316. #define HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(_rx_mpdu_info) \
  2317. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2318. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_OFFSET)), \
  2319. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_MASK, \
  2320. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_LSB))
  2321. /**
  2322. * hal_rx_get_rx_more_frag_bit(): Function to retrieve more fragment bit
  2323. *
  2324. * @nbuf: Network buffer
  2325. * Returns: rx more fragment bit
  2326. */
  2327. static inline
  2328. uint8_t hal_rx_get_rx_more_frag_bit(uint8_t *buf)
  2329. {
  2330. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2331. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2332. uint16_t frame_ctrl = 0;
  2333. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info) >>
  2334. DOT11_FC1_MORE_FRAG_OFFSET;
  2335. /* more fragment bit if at offset bit 4 */
  2336. return frame_ctrl;
  2337. }
  2338. /**
  2339. * hal_rx_get_frame_ctrl_field(): Function to retrieve frame control field
  2340. *
  2341. * @nbuf: Network buffer
  2342. * Returns: rx more fragment bit
  2343. *
  2344. */
  2345. static inline
  2346. uint16_t hal_rx_get_frame_ctrl_field(uint8_t *buf)
  2347. {
  2348. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2349. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2350. uint16_t frame_ctrl = 0;
  2351. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info);
  2352. return frame_ctrl;
  2353. }
  2354. /*
  2355. * hal_rx_msdu_is_wlan_mcast(): Check if the buffer is for multicast address
  2356. *
  2357. * @nbuf: Network buffer
  2358. * Returns: flag to indicate whether the nbuf has MC/BC address
  2359. */
  2360. static inline
  2361. uint32_t hal_rx_msdu_is_wlan_mcast(qdf_nbuf_t nbuf)
  2362. {
  2363. uint8 *buf = qdf_nbuf_data(nbuf);
  2364. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2365. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2366. return rx_attn->mcast_bcast;
  2367. }
  2368. #define HAL_RX_MPDU_GET_SEQUENCE_CONTROL_VALID(_rx_mpdu_info) \
  2369. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2370. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_OFFSET)), \
  2371. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_MASK, \
  2372. RX_MPDU_INFO_2_MPDU_SEQUENCE_CONTROL_VALID_LSB))
  2373. /*
  2374. * hal_rx_get_mpdu_sequence_control_valid(): Get mpdu sequence control valid
  2375. *
  2376. * @nbuf: Network buffer
  2377. * Returns: value of sequence control valid field
  2378. */
  2379. static inline
  2380. uint8_t hal_rx_get_mpdu_sequence_control_valid(uint8_t *buf)
  2381. {
  2382. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2383. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2384. uint8_t seq_ctrl_valid = 0;
  2385. seq_ctrl_valid =
  2386. HAL_RX_MPDU_GET_SEQUENCE_CONTROL_VALID(rx_mpdu_info);
  2387. return seq_ctrl_valid;
  2388. }
  2389. #define HAL_RX_MPDU_GET_FRAME_CONTROL_VALID(_rx_mpdu_info) \
  2390. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2391. RX_MPDU_INFO_2_MPDU_FRAME_CONTROL_VALID_OFFSET)), \
  2392. RX_MPDU_INFO_2_MPDU_FRAME_CONTROL_VALID_MASK, \
  2393. RX_MPDU_INFO_2_MPDU_FRAME_CONTROL_VALID_LSB))
  2394. /*
  2395. * hal_rx_get_mpdu_frame_control_valid(): Retrieves mpdu frame control valid
  2396. *
  2397. * @nbuf: Network buffer
  2398. * Returns: value of frame control valid field
  2399. */
  2400. static inline
  2401. uint8_t hal_rx_get_mpdu_frame_control_valid(uint8_t *buf)
  2402. {
  2403. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2404. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2405. uint8_t frm_ctrl_valid = 0;
  2406. frm_ctrl_valid =
  2407. HAL_RX_MPDU_GET_FRAME_CONTROL_VALID(rx_mpdu_info);
  2408. return frm_ctrl_valid;
  2409. }
  2410. #define HAL_RX_MPDU_GET_MAC_AD4_VALID(_rx_mpdu_info) \
  2411. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2412. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_OFFSET)), \
  2413. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_MASK, \
  2414. RX_MPDU_INFO_2_MAC_ADDR_AD4_VALID_LSB))
  2415. /*
  2416. * hal_rx_get_mpdu_mac_ad4_valid(): Retrieves if mpdu 4th addr is valid
  2417. *
  2418. * @nbuf: Network buffer
  2419. * Returns: value of mpdu 4th address valid field
  2420. */
  2421. static inline
  2422. bool hal_rx_get_mpdu_mac_ad4_valid(uint8_t *buf)
  2423. {
  2424. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2425. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2426. bool ad4_valid = 0;
  2427. ad4_valid = HAL_RX_MPDU_GET_MAC_AD4_VALID(rx_mpdu_info);
  2428. return ad4_valid;
  2429. }
  2430. /*
  2431. * hal_rx_clear_mpdu_desc_info(): Clears mpdu_desc_info
  2432. *
  2433. * @rx_mpdu_desc_info: HAL view of rx mpdu desc info
  2434. * Returns: None
  2435. */
  2436. static inline
  2437. void hal_rx_clear_mpdu_desc_info(
  2438. struct hal_rx_mpdu_desc_info *rx_mpdu_desc_info)
  2439. {
  2440. qdf_mem_zero(rx_mpdu_desc_info,
  2441. sizeof(*rx_mpdu_desc_info));
  2442. }
  2443. /*
  2444. * hal_rx_clear_msdu_link_ptr(): Clears msdu_link_ptr
  2445. *
  2446. * @msdu_link_ptr: HAL view of msdu link ptr
  2447. * @size: number of msdu link pointers
  2448. * Returns: None
  2449. */
  2450. static inline
  2451. void hal_rx_clear_msdu_link_ptr(struct hal_rx_msdu_link_ptr_info *msdu_link_ptr,
  2452. int size)
  2453. {
  2454. qdf_mem_zero(msdu_link_ptr,
  2455. (sizeof(*msdu_link_ptr) * size));
  2456. }
  2457. /*
  2458. * hal_rx_chain_msdu_links() - Chains msdu link pointers
  2459. * @msdu_link_ptr: msdu link pointer
  2460. * @mpdu_desc_info: mpdu descriptor info
  2461. *
  2462. * Build a list of msdus using msdu link pointer. If the
  2463. * number of msdus are more, chain them together
  2464. *
  2465. * Returns: Number of processed msdus
  2466. */
  2467. static inline
  2468. int hal_rx_chain_msdu_links(struct hal_soc *hal_soc, qdf_nbuf_t msdu,
  2469. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2470. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  2471. {
  2472. int j;
  2473. struct rx_msdu_link *msdu_link_ptr =
  2474. &msdu_link_ptr_info->msdu_link;
  2475. struct rx_msdu_link *prev_msdu_link_ptr = NULL;
  2476. struct rx_msdu_details *msdu_details =
  2477. hal_rx_link_desc_msdu0_ptr(msdu_link_ptr, hal_soc);
  2478. uint8_t num_msdus = mpdu_desc_info->msdu_count;
  2479. struct rx_msdu_desc_info *msdu_desc_info;
  2480. uint8_t fragno, more_frag;
  2481. uint8_t *rx_desc_info;
  2482. struct hal_rx_msdu_list msdu_list;
  2483. for (j = 0; j < num_msdus; j++) {
  2484. msdu_desc_info =
  2485. hal_rx_msdu_desc_info_get_ptr(&msdu_details[j],
  2486. hal_soc);
  2487. msdu_list.msdu_info[j].msdu_flags =
  2488. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  2489. msdu_list.msdu_info[j].msdu_len =
  2490. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  2491. msdu_list.sw_cookie[j] = HAL_RX_BUF_COOKIE_GET(
  2492. &msdu_details[j].buffer_addr_info_details);
  2493. }
  2494. /* Chain msdu links together */
  2495. if (prev_msdu_link_ptr) {
  2496. /* 31-0 bits of the physical address */
  2497. prev_msdu_link_ptr->
  2498. next_msdu_link_desc_addr_info.buffer_addr_31_0 =
  2499. msdu_link_ptr_info->msdu_link_buf_info.paddr &
  2500. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK;
  2501. /* 39-32 bits of the physical address */
  2502. prev_msdu_link_ptr->
  2503. next_msdu_link_desc_addr_info.buffer_addr_39_32
  2504. = ((msdu_link_ptr_info->msdu_link_buf_info.paddr
  2505. >> 32) &
  2506. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK);
  2507. prev_msdu_link_ptr->
  2508. next_msdu_link_desc_addr_info.sw_buffer_cookie =
  2509. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie;
  2510. }
  2511. /* There is space for only 6 MSDUs in a MSDU link descriptor */
  2512. if (num_msdus < HAL_RX_NUM_MSDU_DESC) {
  2513. /* mark first and last MSDUs */
  2514. rx_desc_info = qdf_nbuf_data(msdu);
  2515. fragno = hal_rx_get_rx_fragment_number(rx_desc_info);
  2516. more_frag = hal_rx_get_rx_more_frag_bit(rx_desc_info);
  2517. /* TODO: create skb->fragslist[] */
  2518. if (more_frag == 0) {
  2519. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2520. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK;
  2521. } else if (fragno == 1) {
  2522. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2523. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK;
  2524. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2525. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK;
  2526. }
  2527. num_msdus++;
  2528. /* Number of MSDUs per mpdu descriptor is updated */
  2529. mpdu_desc_info->msdu_count += num_msdus;
  2530. } else {
  2531. num_msdus = 0;
  2532. prev_msdu_link_ptr = msdu_link_ptr;
  2533. }
  2534. return num_msdus;
  2535. }
  2536. /*
  2537. * hal_rx_defrag_update_src_ring_desc(): updates reo src ring desc
  2538. *
  2539. * @ring_desc: HAL view of ring descriptor
  2540. * @mpdu_des_info: saved mpdu desc info
  2541. * @msdu_link_ptr: saved msdu link ptr
  2542. *
  2543. * API used explicitly for rx defrag to update ring desc with
  2544. * mpdu desc info and msdu link ptr before reinjecting the
  2545. * packet back to REO
  2546. *
  2547. * Returns: None
  2548. */
  2549. static inline
  2550. void hal_rx_defrag_update_src_ring_desc(void *ring_desc,
  2551. void *saved_mpdu_desc_info,
  2552. struct hal_rx_msdu_link_ptr_info *saved_msdu_link_ptr)
  2553. {
  2554. struct reo_entrance_ring *reo_ent_ring;
  2555. struct rx_mpdu_desc_info *reo_ring_mpdu_desc_info;
  2556. struct hal_buf_info buf_info;
  2557. reo_ent_ring = (struct reo_entrance_ring *)ring_desc;
  2558. reo_ring_mpdu_desc_info = &reo_ent_ring->
  2559. reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  2560. qdf_mem_copy(&reo_ring_mpdu_desc_info, saved_mpdu_desc_info,
  2561. sizeof(*reo_ring_mpdu_desc_info));
  2562. /*
  2563. * TODO: Check for additional fields that need configuration in
  2564. * reo_ring_mpdu_desc_info
  2565. */
  2566. /* Update msdu_link_ptr in the reo entrance ring */
  2567. hal_rx_reo_buf_paddr_get(ring_desc, &buf_info);
  2568. buf_info.paddr = saved_msdu_link_ptr->msdu_link_buf_info.paddr;
  2569. buf_info.sw_cookie =
  2570. saved_msdu_link_ptr->msdu_link_buf_info.sw_cookie;
  2571. }
  2572. /*
  2573. * hal_rx_defrag_save_info_from_ring_desc(): Saves info from ring desc
  2574. *
  2575. * @msdu_link_desc_va: msdu link descriptor handle
  2576. * @msdu_link_ptr_info: HAL view of msdu link pointer info
  2577. *
  2578. * API used to save msdu link information along with physical
  2579. * address. The API also copues the sw cookie.
  2580. *
  2581. * Returns: None
  2582. */
  2583. static inline
  2584. void hal_rx_defrag_save_info_from_ring_desc(void *msdu_link_desc_va,
  2585. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2586. struct hal_buf_info *hbi)
  2587. {
  2588. struct rx_msdu_link *msdu_link_ptr =
  2589. (struct rx_msdu_link *)msdu_link_desc_va;
  2590. qdf_mem_copy(&msdu_link_ptr_info->msdu_link, msdu_link_ptr,
  2591. sizeof(struct rx_msdu_link));
  2592. msdu_link_ptr_info->msdu_link_buf_info.paddr = hbi->paddr;
  2593. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie = hbi->sw_cookie;
  2594. }
  2595. /*
  2596. * hal_rx_get_desc_len(): Returns rx descriptor length
  2597. *
  2598. * Returns the size of rx_pkt_tlvs which follows the
  2599. * data in the nbuf
  2600. *
  2601. * Returns: Length of rx descriptor
  2602. */
  2603. static inline
  2604. uint16_t hal_rx_get_desc_len(void)
  2605. {
  2606. return sizeof(struct rx_pkt_tlvs);
  2607. }
  2608. /*
  2609. * hal_rx_reo_ent_rxdma_push_reason_get(): Retrieves RXDMA push reason from
  2610. * reo_entrance_ring descriptor
  2611. *
  2612. * @reo_ent_desc: reo_entrance_ring descriptor
  2613. * Returns: value of rxdma_push_reason
  2614. */
  2615. static inline
  2616. uint8_t hal_rx_reo_ent_rxdma_push_reason_get(void *reo_ent_desc)
  2617. {
  2618. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2619. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_OFFSET)),
  2620. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_MASK,
  2621. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_LSB);
  2622. }
  2623. /**
  2624. * hal_rx_reo_ent_rxdma_error_code_get(): Retrieves RXDMA error code from
  2625. * reo_entrance_ring descriptor
  2626. * @reo_ent_desc: reo_entrance_ring descriptor
  2627. * Return: value of rxdma_error_code
  2628. */
  2629. static inline
  2630. uint8_t hal_rx_reo_ent_rxdma_error_code_get(void *reo_ent_desc)
  2631. {
  2632. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2633. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_OFFSET)),
  2634. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_MASK,
  2635. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_LSB);
  2636. }
  2637. /**
  2638. * hal_rx_wbm_err_info_get(): Retrieves WBM error code and reason and
  2639. * save it to hal_wbm_err_desc_info structure passed by caller
  2640. * @wbm_desc: wbm ring descriptor
  2641. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2642. * Return: void
  2643. */
  2644. static inline void hal_rx_wbm_err_info_get(void *wbm_desc,
  2645. struct hal_wbm_err_desc_info *wbm_er_info,
  2646. struct hal_soc *hal_soc)
  2647. {
  2648. hal_soc->ops->hal_rx_wbm_err_info_get(wbm_desc, (void *)wbm_er_info);
  2649. }
  2650. /**
  2651. * hal_rx_wbm_err_info_set_in_tlv(): Save the wbm error codes and reason to
  2652. * the reserved bytes of rx_tlv_hdr
  2653. * @buf: start of rx_tlv_hdr
  2654. * @wbm_er_info: hal_wbm_err_desc_info structure
  2655. * Return: void
  2656. */
  2657. static inline void hal_rx_wbm_err_info_set_in_tlv(uint8_t *buf,
  2658. struct hal_wbm_err_desc_info *wbm_er_info)
  2659. {
  2660. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2661. qdf_mem_copy(pkt_tlvs->rx_padding0, wbm_er_info,
  2662. sizeof(struct hal_wbm_err_desc_info));
  2663. }
  2664. /**
  2665. * hal_rx_wbm_err_info_get_from_tlv(): retrieve wbm error codes and reason from
  2666. * the reserved bytes of rx_tlv_hdr.
  2667. * @buf: start of rx_tlv_hdr
  2668. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2669. * Return: void
  2670. */
  2671. static inline void hal_rx_wbm_err_info_get_from_tlv(uint8_t *buf,
  2672. struct hal_wbm_err_desc_info *wbm_er_info)
  2673. {
  2674. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2675. qdf_mem_copy(wbm_er_info, pkt_tlvs->rx_padding0,
  2676. sizeof(struct hal_wbm_err_desc_info));
  2677. }
  2678. #define HAL_RX_MSDU_START_NSS_GET(_rx_msdu_start) \
  2679. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \
  2680. RX_MSDU_START_5_NSS_OFFSET)), \
  2681. RX_MSDU_START_5_NSS_MASK, \
  2682. RX_MSDU_START_5_NSS_LSB))
  2683. /**
  2684. * hal_rx_mon_hw_desc_get_mpdu_status: Retrieve MPDU status
  2685. *
  2686. * @ hal_soc: HAL version of the SOC pointer
  2687. * @ hw_desc_addr: Start address of Rx HW TLVs
  2688. * @ rs: Status for monitor mode
  2689. *
  2690. * Return: void
  2691. */
  2692. static inline void hal_rx_mon_hw_desc_get_mpdu_status(struct hal_soc *hal_soc,
  2693. void *hw_desc_addr,
  2694. struct mon_rx_status *rs)
  2695. {
  2696. hal_soc->ops->hal_rx_mon_hw_desc_get_mpdu_status(hw_desc_addr, rs);
  2697. }
  2698. /*
  2699. * hal_rx_get_tlv(): API to get the tlv
  2700. *
  2701. * @hal_soc: HAL version of the SOC pointer
  2702. * @rx_tlv: TLV data extracted from the rx packet
  2703. * Return: uint8_t
  2704. */
  2705. static inline uint8_t hal_rx_get_tlv(struct hal_soc *hal_soc, void *rx_tlv)
  2706. {
  2707. return hal_soc->ops->hal_rx_get_tlv(rx_tlv);
  2708. }
  2709. /*
  2710. * hal_rx_msdu_start_nss_get(): API to get the NSS
  2711. * Interval from rx_msdu_start
  2712. *
  2713. * @hal_soc: HAL version of the SOC pointer
  2714. * @buf: pointer to the start of RX PKT TLV header
  2715. * Return: uint32_t(nss)
  2716. */
  2717. static inline uint32_t hal_rx_msdu_start_nss_get(struct hal_soc *hal_soc,
  2718. uint8_t *buf)
  2719. {
  2720. return hal_soc->ops->hal_rx_msdu_start_nss_get(buf);
  2721. }
  2722. /**
  2723. * hal_rx_dump_msdu_start_tlv: dump RX msdu_start TLV in structured
  2724. * human readable format.
  2725. * @ msdu_start: pointer the msdu_start TLV in pkt.
  2726. * @ dbg_level: log level.
  2727. *
  2728. * Return: void
  2729. */
  2730. static inline void hal_rx_dump_msdu_start_tlv(struct hal_soc *hal_soc,
  2731. struct rx_msdu_start *msdu_start,
  2732. uint8_t dbg_level)
  2733. {
  2734. hal_soc->ops->hal_rx_dump_msdu_start_tlv(msdu_start, dbg_level);
  2735. }
  2736. /**
  2737. * hal_rx_mpdu_start_tid_get - Return tid info from the rx mpdu start
  2738. * info details
  2739. *
  2740. * @ buf - Pointer to buffer containing rx pkt tlvs.
  2741. *
  2742. *
  2743. */
  2744. static inline uint32_t hal_rx_mpdu_start_tid_get(struct hal_soc *hal_soc,
  2745. uint8_t *buf)
  2746. {
  2747. return hal_soc->ops->hal_rx_mpdu_start_tid_get(buf);
  2748. }
  2749. /*
  2750. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  2751. * Interval from rx_msdu_start
  2752. *
  2753. * @buf: pointer to the start of RX PKT TLV header
  2754. * Return: uint32_t(reception_type)
  2755. */
  2756. static inline
  2757. uint32_t hal_rx_msdu_start_reception_type_get(struct hal_soc *hal_soc,
  2758. uint8_t *buf)
  2759. {
  2760. return hal_soc->ops->hal_rx_msdu_start_reception_type_get(buf);
  2761. }
  2762. /**
  2763. * hal_rx_dump_pkt_tlvs: API to print all member elements of
  2764. * RX TLVs
  2765. * @ buf: pointer the pkt buffer.
  2766. * @ dbg_level: log level.
  2767. *
  2768. * Return: void
  2769. */
  2770. static inline void hal_rx_dump_pkt_tlvs(struct hal_soc *hal_soc,
  2771. uint8_t *buf, uint8_t dbg_level)
  2772. {
  2773. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2774. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2775. struct rx_mpdu_start *mpdu_start =
  2776. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  2777. struct rx_msdu_start *msdu_start =
  2778. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  2779. struct rx_mpdu_end *mpdu_end = &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  2780. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  2781. struct rx_pkt_hdr_tlv *pkt_hdr_tlv = &pkt_tlvs->pkt_hdr_tlv;
  2782. hal_rx_dump_rx_attention_tlv(rx_attn, dbg_level);
  2783. hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level, hal_soc);
  2784. hal_rx_dump_msdu_start_tlv(hal_soc, msdu_start, dbg_level);
  2785. hal_rx_dump_mpdu_end_tlv(mpdu_end, dbg_level);
  2786. hal_rx_dump_msdu_end_tlv(hal_soc, msdu_end, dbg_level);
  2787. hal_rx_dump_pkt_hdr_tlv(pkt_hdr_tlv, dbg_level);
  2788. }
  2789. /**
  2790. * hal_reo_status_get_header_generic - Process reo desc info
  2791. * @d - Pointer to reo descriptior
  2792. * @b - tlv type info
  2793. * @h - Pointer to hal_reo_status_header where info to be stored
  2794. * @hal- pointer to hal_soc structure
  2795. * Return - none.
  2796. *
  2797. */
  2798. static inline void hal_reo_status_get_header(uint32_t *d, int b,
  2799. void *h, void *hal)
  2800. {
  2801. struct hal_soc *hal_soc = (struct hal_soc *)hal;
  2802. hal_soc->ops->hal_reo_status_get_header(d, b, h);
  2803. }
  2804. #endif /* _HAL_RX_H */