hal_rx.h 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HAL_RX_H_
  20. #define _HAL_RX_H_
  21. #include <hal_api.h>
  22. #include "hal_rx_hw_defines.h"
  23. #include "hal_hw_headers.h"
  24. /*************************************
  25. * Ring desc offset/shift/masks
  26. *************************************/
  27. #define HAL_INVALID_PPDU_ID 0xFFFFFFFF
  28. #define HAL_RX_OFFSET(block, field) block##_##field##_OFFSET
  29. #define HAL_RX_LSB(block, field) block##_##field##_LSB
  30. #define HAL_RX_MASK(block, field) block##_##field##_MASK
  31. #define HAL_RX_TLV_L3_TYPE_INVALID 0xFFFF
  32. #define HAL_RX_GET(_ptr, block, field) \
  33. (((*((volatile uint32_t *)_ptr + (HAL_RX_OFFSET(block, field)>>2))) & \
  34. HAL_RX_MASK(block, field)) >> \
  35. HAL_RX_LSB(block, field))
  36. #define HAL_RX_GET_64(_ptr, block, field) \
  37. (((*((volatile uint64_t *)(_ptr) + \
  38. (HAL_RX_OFFSET(block, field) >> 3))) & \
  39. HAL_RX_MASK(block, field)) >> \
  40. HAL_RX_LSB(block, field))
  41. #define HAL_RX_FLD_SET(_ptr, _wrd, _field, _val) \
  42. (*(uint32_t *)(((uint8_t *)_ptr) + \
  43. _wrd ## _ ## _field ## _OFFSET) |= \
  44. (((_val) << _wrd ## _ ## _field ## _LSB) & \
  45. _wrd ## _ ## _field ## _MASK))
  46. /* BUFFER_SIZE = 1536 data bytes + 384 RX TLV bytes + some spare bytes */
  47. #ifndef RX_DATA_BUFFER_SIZE
  48. #define RX_DATA_BUFFER_SIZE 2048
  49. #endif
  50. #ifndef RX_MONITOR_BUFFER_SIZE
  51. #define RX_MONITOR_BUFFER_SIZE 2048
  52. #endif
  53. #define RXDMA_OPTIMIZATION
  54. /* MONITOR STATUS BUFFER SIZE = 1408 data bytes, buffer allocation of 2k bytes
  55. * including buffer reservation, buffer alignment and skb shared info size.
  56. */
  57. #define RX_MON_STATUS_BASE_BUF_SIZE 2048
  58. #define RX_MON_STATUS_BUF_ALIGN 128
  59. #define RX_MON_STATUS_BUF_RESERVATION 128
  60. #define RX_MON_STATUS_BUF_SIZE (RX_MON_STATUS_BASE_BUF_SIZE - \
  61. (RX_MON_STATUS_BUF_RESERVATION + \
  62. RX_MON_STATUS_BUF_ALIGN + QDF_SHINFO_SIZE))
  63. #define NUM_OF_DWORDS_BUFFER_ADDR_INFO 2
  64. /* HAL_RX_NON_QOS_TID = NON_QOS_TID which is 16 */
  65. #define HAL_RX_NON_QOS_TID 16
  66. enum {
  67. HAL_HW_RX_DECAP_FORMAT_RAW = 0,
  68. HAL_HW_RX_DECAP_FORMAT_NWIFI,
  69. HAL_HW_RX_DECAP_FORMAT_ETH2,
  70. HAL_HW_RX_DECAP_FORMAT_8023,
  71. };
  72. /**
  73. * struct hal_wbm_err_desc_info - structure to hold wbm error codes and reasons
  74. *
  75. * The fields of this structure is aligned to HAL Rx WBM2SW Ring desc,
  76. * inorder to efficiently copy the data from desc to struct.
  77. * Do not change the sequence of the fields.
  78. *
  79. * @wbm_err_src: Module which initiated the buffer release
  80. * @bm_action: BM action
  81. * @buffer_or_desc_type: Type of Buffer or Desc released
  82. * @return_buffer_manager: Buffer address Info for debug
  83. * @pool_id: pool ID, indicates which rxdma pool
  84. * @cache_id: cache Id
  85. * @cookie_conversion_status: cookie conversion status
  86. * @rxdma_psh_rsn: RXDMA push reason
  87. * @rxdma_err_code: RXDMA Error code
  88. * @reo_psh_rsn: REO push reason
  89. * @reo_err_code: REO Error code
  90. * @wbm_internal_error: WBM Internal error
  91. */
  92. struct hal_wbm_err_desc_info {
  93. #ifndef WIFI_BIT_ORDER_BIG_ENDIAN
  94. uint32_t wbm_err_src : 3,
  95. bm_action : 3,
  96. buffer_or_desc_type : 3,
  97. return_buffer_manager : 4,
  98. pool_id : 2,
  99. cache_id : 1,
  100. cookie_conversion_status : 1,
  101. rxdma_psh_rsn : 2,
  102. rxdma_err_code : 5,
  103. reo_psh_rsn : 2,
  104. reo_err_code : 5,
  105. wbm_internal_error : 1;
  106. #else
  107. uint32_t wbm_internal_error : 1,
  108. reo_err_code : 5,
  109. reo_psh_rsn : 2,
  110. rxdma_err_code : 5,
  111. rxdma_psh_rsn : 2,
  112. cookie_conversion_status : 1,
  113. cache_id : 1,
  114. pool_id : 2,
  115. return_buffer_manager : 4,
  116. buffer_or_desc_type : 3,
  117. bm_action : 3,
  118. wbm_err_src : 3;
  119. #endif
  120. };
  121. /**
  122. * union hal_wbm_err_info_u - Union to hold wbm error information
  123. * @info_bit: hal_wbm_err_desc_info: structure to hold wbm error info bit fields
  124. * @info: variable to hold wbm error info
  125. *
  126. */
  127. union hal_wbm_err_info_u {
  128. struct hal_wbm_err_desc_info info_bit;
  129. uint32_t info;
  130. };
  131. /**
  132. * struct hal_rx_mon_dest_buf_info - Structure to hold rx mon dest buffer info
  133. * @first_buffer: First buffer of MSDU
  134. * @last_buffer: Last buffer of MSDU
  135. * @is_decap_raw: Is RAW Frame
  136. * @mpdu_len_err: Is there an MPDU length error
  137. * @l2_hdr_pad: Amount of layer 2 header padding
  138. * @reserved_1: Reserved
  139. *
  140. * MSDU with continuation:
  141. * -----------------------------------------------------------
  142. * | first_buffer:1 | first_buffer: 0 | ... | first_buffer: 0 |
  143. * | last_buffer :0 | last_buffer : 0 | ... | last_buffer : 0 |
  144. * | is_decap_raw:1/0 | Same as earlier | Same as earlier|
  145. * -----------------------------------------------------------
  146. *
  147. * Single buffer MSDU:
  148. * ------------------
  149. * | first_buffer:1 |
  150. * | last_buffer :1 |
  151. * | is_decap_raw:1/0 |
  152. * ------------------
  153. */
  154. struct hal_rx_mon_dest_buf_info {
  155. uint8_t first_buffer:1,
  156. last_buffer:1,
  157. is_decap_raw:1,
  158. mpdu_len_err:1,
  159. l2_hdr_pad:2,
  160. reserved_1:2;
  161. };
  162. /**
  163. * struct hal_rx_msdu_metadata - Structure to hold rx fast path information.
  164. *
  165. * @l3_hdr_pad: l3 header padding
  166. * @reserved: Reserved bits
  167. * @sa_sw_peer_id: sa sw peer id
  168. * @sa_idx: sa index
  169. * @da_idx: da index
  170. */
  171. struct hal_rx_msdu_metadata {
  172. uint32_t l3_hdr_pad:16,
  173. sa_sw_peer_id:16;
  174. uint32_t sa_idx:16,
  175. da_idx:16;
  176. };
  177. struct hal_proto_params {
  178. uint8_t tcp_proto;
  179. uint8_t udp_proto;
  180. uint8_t ipv6_proto;
  181. };
  182. /**
  183. * enum hal_reo_error_status - Enum which encapsulates "reo_push_reason"
  184. *
  185. * @HAL_REO_ERROR_DETECTED: Packets arrived because of an error detected
  186. * @HAL_REO_ROUTING_INSTRUCTION: Packets arrived because of REO routing
  187. */
  188. enum hal_reo_error_status {
  189. HAL_REO_ERROR_DETECTED = 0,
  190. HAL_REO_ROUTING_INSTRUCTION = 1,
  191. };
  192. /**
  193. * struct hal_rx_msdu_desc_info - RX MSDU Descriptor
  194. * @msdu_flags: [0] first_msdu_in_mpdu
  195. * [1] last_msdu_in_mpdu
  196. * [2] msdu_continuation - MSDU spread across buffers
  197. * [23] sa_is_valid - SA match in peer table
  198. * [24] sa_idx_timeout - Timeout while searching for SA match
  199. * [25] da_is_valid - Used to identtify intra-bss forwarding
  200. * [26] da_is_MCBC
  201. * [27] da_idx_timeout - Timeout while searching for DA match
  202. * @msdu_len: length of the MSDU (14 bits of length)
  203. *
  204. */
  205. struct hal_rx_msdu_desc_info {
  206. uint32_t msdu_flags;
  207. uint16_t msdu_len;
  208. };
  209. /**
  210. * enum hal_rx_msdu_desc_flags - Enum for flags in MSDU_DESC_INFO
  211. *
  212. * @HAL_MSDU_F_FIRST_MSDU_IN_MPDU: First MSDU in MPDU
  213. * @HAL_MSDU_F_LAST_MSDU_IN_MPDU: Last MSDU in MPDU
  214. * @HAL_MSDU_F_MSDU_CONTINUATION: MSDU continuation
  215. * @HAL_MSDU_F_SA_IS_VALID: Found match for SA in AST
  216. * @HAL_MSDU_F_SA_IDX_TIMEOUT: AST search for SA timed out
  217. * @HAL_MSDU_F_DA_IS_VALID: Found match for DA in AST
  218. * @HAL_MSDU_F_DA_IS_MCBC: DA is MC/BC address
  219. * @HAL_MSDU_F_DA_IDX_TIMEOUT: AST search for DA timed out
  220. * @HAL_MSDU_F_INTRA_BSS: This is an intrabss packet
  221. */
  222. enum hal_rx_msdu_desc_flags {
  223. HAL_MSDU_F_FIRST_MSDU_IN_MPDU = (0x1 << 0),
  224. HAL_MSDU_F_LAST_MSDU_IN_MPDU = (0x1 << 1),
  225. HAL_MSDU_F_MSDU_CONTINUATION = (0x1 << 2),
  226. HAL_MSDU_F_SA_IS_VALID = (0x1 << 23),
  227. HAL_MSDU_F_SA_IDX_TIMEOUT = (0x1 << 24),
  228. HAL_MSDU_F_DA_IS_VALID = (0x1 << 25),
  229. HAL_MSDU_F_DA_IS_MCBC = (0x1 << 26),
  230. HAL_MSDU_F_DA_IDX_TIMEOUT = (0x1 << 27),
  231. HAL_MSDU_F_INTRA_BSS = (0x1 << 28),
  232. };
  233. /**
  234. * struct hal_rx_mpdu_desc_info - RX MPDU descriptor
  235. * @msdu_count: no. of msdus in the MPDU
  236. * @mpdu_seq: MPDU sequence number
  237. * @mpdu_flags: [0] Fragment flag
  238. * [1] MPDU_retry_bit
  239. * [2] AMPDU flag
  240. * [3] raw_ampdu
  241. * @peer_meta_data: Upper bits containing peer id, vdev id
  242. * @bar_frame: indicates if received frame is a bar frame
  243. * @tid: tid value of received MPDU
  244. * @reserved: spare bits
  245. */
  246. struct hal_rx_mpdu_desc_info {
  247. uint16_t msdu_count;
  248. uint16_t mpdu_seq; /* 12 bits for length */
  249. uint32_t mpdu_flags;
  250. uint32_t peer_meta_data; /* sw programmed meta-data:MAC Id & peer Id */
  251. uint16_t bar_frame;
  252. uint8_t tid:4,
  253. reserved:4;
  254. };
  255. /**
  256. * enum hal_rx_mpdu_desc_flags - Enum for flags in MPDU_DESC_INFO
  257. *
  258. * @HAL_MPDU_F_FRAGMENT: Fragmented MPDU (802.11 fragemtation)
  259. * @HAL_MPDU_F_RETRY_BIT: Retry bit is set in FC of MPDU
  260. * @HAL_MPDU_F_AMPDU_FLAG: MPDU received as part of A-MPDU
  261. * @HAL_MPDU_F_RAW_AMPDU: MPDU is a Raw MDPU
  262. * @HAL_MPDU_F_QOS_CONTROL_VALID: MPDU has a QoS control field
  263. */
  264. enum hal_rx_mpdu_desc_flags {
  265. HAL_MPDU_F_FRAGMENT = (0x1 << 20),
  266. HAL_MPDU_F_RETRY_BIT = (0x1 << 21),
  267. HAL_MPDU_F_AMPDU_FLAG = (0x1 << 22),
  268. HAL_MPDU_F_RAW_AMPDU = (0x1 << 30),
  269. HAL_MPDU_F_QOS_CONTROL_VALID = (0x1 << 31)
  270. };
  271. /* Return Buffer manager ID */
  272. #define HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST 0
  273. #define HAL_RX_BUF_RBM_WBM_CHIP0_IDLE_DESC_LIST 1
  274. #define HAL_RX_BUF_RBM_WBM_CHIP1_IDLE_DESC_LIST 2
  275. #define HAL_RX_BUF_RBM_WBM_CHIP2_IDLE_DESC_LIST 3
  276. #define HAL_RX_BUF_RBM_SW0_BM(sw0_bm_id) (sw0_bm_id)
  277. #define HAL_RX_BUF_RBM_SW1_BM(sw0_bm_id) (sw0_bm_id + 1)
  278. #define HAL_RX_BUF_RBM_SW2_BM(sw0_bm_id) (sw0_bm_id + 2)
  279. #define HAL_RX_BUF_RBM_SW3_BM(sw0_bm_id) (sw0_bm_id + 3)
  280. #define HAL_RX_BUF_RBM_SW4_BM(sw0_bm_id) (sw0_bm_id + 4)
  281. #define HAL_RX_BUF_RBM_SW5_BM(sw0_bm_id) (sw0_bm_id + 5)
  282. #define HAL_RX_BUF_RBM_SW6_BM(sw0_bm_id) (sw0_bm_id + 6)
  283. #define HAL_RX_BUF_RBM_SW_BM(sw0_bm_id, wbm2sw_id) (sw0_bm_id + wbm2sw_id)
  284. #define HAL_REO_DESTINATION_RING_MSDU_COUNT_OFFSET 0x8
  285. #define HAL_REO_DESTINATION_RING_MSDU_COUNT_LSB 0
  286. #define HAL_REO_DESTINATION_RING_MSDU_COUNT_MASK 0x000000ff
  287. #define HAL_RX_REO_DESC_MSDU_COUNT_GET(reo_desc) \
  288. (_HAL_MS((*_OFFSET_TO_WORD_PTR(reo_desc, \
  289. HAL_REO_DESTINATION_RING_MSDU_COUNT_OFFSET)), \
  290. HAL_REO_DESTINATION_RING_MSDU_COUNT_MASK, \
  291. HAL_REO_DESTINATION_RING_MSDU_COUNT_LSB))
  292. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET 0x0
  293. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_LSB 0
  294. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_MASK 0xffffffff
  295. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_OFFSET 0x4
  296. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_LSB 0
  297. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_MASK 0x000000ff
  298. /*
  299. * macro to set the LSW of the nbuf data physical address
  300. * to the rxdma ring entry
  301. */
  302. #define HAL_RXDMA_PADDR_LO_SET(buff_addr_info, paddr_lo) \
  303. ((*(((unsigned int *) buff_addr_info) + \
  304. (HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET >> 2))) = \
  305. (paddr_lo << HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_LSB) & \
  306. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_MASK)
  307. /*
  308. * macro to set the LSB of MSW of the nbuf data physical address
  309. * to the rxdma ring entry
  310. */
  311. #define HAL_RXDMA_PADDR_HI_SET(buff_addr_info, paddr_hi) \
  312. ((*(((unsigned int *) buff_addr_info) + \
  313. (HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_OFFSET >> 2))) = \
  314. (paddr_hi << HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_LSB) & \
  315. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_MASK)
  316. #ifdef DP_RX_DESC_COOKIE_INVALIDATE
  317. #define HAL_RX_COOKIE_INVALID_MASK 0x80000000
  318. /*
  319. * macro to get the invalid bit for sw cookie
  320. */
  321. #define HAL_RX_BUF_COOKIE_INVALID_GET(buff_addr_info) \
  322. ((*(((unsigned int *)buff_addr_info) + \
  323. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) & \
  324. HAL_RX_COOKIE_INVALID_MASK)
  325. /*
  326. * macro to set the invalid bit for sw cookie
  327. */
  328. #define HAL_RX_BUF_COOKIE_INVALID_SET(buff_addr_info) \
  329. ((*(((unsigned int *)buff_addr_info) + \
  330. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  331. HAL_RX_COOKIE_INVALID_MASK)
  332. /*
  333. * macro to reset the invalid bit for sw cookie
  334. */
  335. #define HAL_RX_BUF_COOKIE_INVALID_RESET(buff_addr_info) \
  336. ((*(((unsigned int *)buff_addr_info) + \
  337. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) &= \
  338. ~HAL_RX_COOKIE_INVALID_MASK)
  339. #define HAL_RX_REO_BUF_COOKIE_INVALID_GET(reo_desc) \
  340. (HAL_RX_BUF_COOKIE_INVALID_GET(& \
  341. (((struct reo_destination_ring *) \
  342. reo_desc)->buf_or_link_desc_addr_info)))
  343. #define HAL_RX_REO_BUF_COOKIE_INVALID_SET(reo_desc) \
  344. (HAL_RX_BUF_COOKIE_INVALID_SET(& \
  345. (((struct reo_destination_ring *) \
  346. reo_desc)->buf_or_link_desc_addr_info)))
  347. #define HAL_RX_LINK_COOKIE_INVALID_MASK 0x40000000
  348. #define HAL_RX_BUF_LINK_COOKIE_INVALID_GET(buff_addr_info) \
  349. ((*(((unsigned int *)buff_addr_info) + \
  350. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) & \
  351. HAL_RX_LINK_COOKIE_INVALID_MASK)
  352. #define HAL_RX_BUF_LINK_COOKIE_INVALID_SET(buff_addr_info) \
  353. ((*(((unsigned int *)buff_addr_info) + \
  354. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  355. HAL_RX_LINK_COOKIE_INVALID_MASK)
  356. #define HAL_RX_REO_BUF_LINK_COOKIE_INVALID_GET(reo_desc) \
  357. (HAL_RX_BUF_LINK_COOKIE_INVALID_GET(& \
  358. (((struct reo_destination_ring *) \
  359. reo_desc)->buf_or_link_desc_addr_info)))
  360. #define HAL_RX_REO_BUF_LINK_COOKIE_INVALID_SET(reo_desc) \
  361. (HAL_RX_BUF_LINK_COOKIE_INVALID_SET(& \
  362. (((struct reo_destination_ring *) \
  363. reo_desc)->buf_or_link_desc_addr_info)))
  364. #endif
  365. /* TODO: Convert the following structure fields accesseses to offsets */
  366. #define HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_desc) \
  367. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  368. (((struct reo_destination_ring *) \
  369. reo_desc)->buf_or_link_desc_addr_info)))
  370. #define HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_desc) \
  371. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  372. (((struct reo_destination_ring *) \
  373. reo_desc)->buf_or_link_desc_addr_info)))
  374. #define HAL_RX_REO_BUF_COOKIE_INVALID_RESET(reo_desc) \
  375. (HAL_RX_BUF_COOKIE_INVALID_RESET(& \
  376. (((struct reo_destination_ring *) \
  377. reo_desc)->buf_or_link_desc_addr_info)))
  378. #define HAL_RX_UNIFORM_HDR_SET(_rx_msdu_link, _field, _val) \
  379. HAL_RX_FLD_SET(_rx_msdu_link, HAL_UNIFORM_DESCRIPTOR_HEADER, \
  380. _field, _val)
  381. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET 0x0
  382. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_LSB 0
  383. #define HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_MASK 0xffffffff
  384. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  385. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  386. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_OFFSET)), \
  387. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_MASK, \
  388. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_31_0_LSB))
  389. #define HAL_RX_BUFFER_ADDR_39_32_GET(buff_addr_info) \
  390. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  391. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_OFFSET)), \
  392. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_MASK, \
  393. HAL_BUFFER_ADDR_INFO_BUFFER_ADDR_39_32_LSB))
  394. #define HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_OFFSET 0x0
  395. #define HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_LSB 0
  396. #define HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_MASK 0x00000001
  397. #define HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_OFFSET 0x0
  398. #define HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_LSB 1
  399. #define HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_MASK 0x00000002
  400. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  401. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  402. HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) |= \
  403. (val << HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_LSB) & \
  404. HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  405. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  406. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  407. HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) |= \
  408. (val << HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_LSB) & \
  409. HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_MASK)
  410. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  411. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  412. HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  413. HAL_RX_MSDU_DESC_INFO_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  414. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  415. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  416. HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  417. HAL_RX_MSDU_DESC_INFO_LAST_MSDU_IN_MPDU_FLAG_MASK)
  418. #define HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_OFFSET 0x0
  419. #define HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_LSB 3
  420. #define HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_MASK 0x0001fff8
  421. #define HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info_ptr) \
  422. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  423. HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_OFFSET)), \
  424. HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_MASK, \
  425. HAL_RX_MSDU_DESC_INFO_MSDU_LENGTH_LSB))
  426. static inline uint32_t
  427. hal_rx_msdu_flags_get(hal_soc_handle_t hal_soc_hdl,
  428. rx_msdu_desc_info_t msdu_desc_info_hdl)
  429. {
  430. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  431. return hal_soc->ops->hal_rx_msdu_flags_get(msdu_desc_info_hdl);
  432. }
  433. /*
  434. * Structures & Macros to obtain fields from the TLV's in the Rx packet
  435. * pre-header.
  436. */
  437. static inline uint8_t *hal_rx_desc_get_80211_hdr(hal_soc_handle_t hal_soc_hdl,
  438. void *hw_desc_addr)
  439. {
  440. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  441. return hal_soc->ops->hal_rx_desc_get_80211_hdr(hw_desc_addr);
  442. }
  443. /**
  444. * hal_rx_mpdu_desc_info_get() - Get MDPU desc info params
  445. * @hal_soc_hdl: hal soc handle
  446. * @desc_addr: ring descriptor
  447. * @mpdu_desc_info: Buffer to fill the mpdu desc info params
  448. *
  449. * Return: None
  450. */
  451. static inline void
  452. hal_rx_mpdu_desc_info_get(hal_soc_handle_t hal_soc_hdl, void *desc_addr,
  453. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  454. {
  455. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  456. return hal_soc->ops->hal_rx_mpdu_desc_info_get(desc_addr,
  457. mpdu_desc_info);
  458. }
  459. #define HAL_RX_NUM_MSDU_DESC 6
  460. #define HAL_RX_MAX_SAVED_RING_DESC 16
  461. /* TODO: rework the structure */
  462. struct hal_rx_msdu_list {
  463. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  464. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  465. uint8_t rbm[HAL_RX_NUM_MSDU_DESC];
  466. /* physical address of the msdu */
  467. uint64_t paddr[HAL_RX_NUM_MSDU_DESC];
  468. };
  469. struct hal_buf_info {
  470. uint64_t paddr;
  471. uint32_t sw_cookie;
  472. uint8_t rbm;
  473. };
  474. /* This special cookie value will be used to indicate FW allocated buffers
  475. * received through RXDMA2SW ring for RXDMA WARs
  476. */
  477. #define HAL_RX_COOKIE_SPECIAL 0x1fffff
  478. /**
  479. * enum hal_rx_reo_buf_type - Indicates that type of buffer or descriptor
  480. *
  481. * @HAL_RX_REO_MSDU_BUF_ADDR_TYPE: Reo buffer address points to the MSDU buffer
  482. * @HAL_RX_REO_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  483. * descriptor
  484. */
  485. enum hal_rx_reo_buf_type {
  486. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  487. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  488. };
  489. /**
  490. * enum hal_reo_error_code - Error code describing the type of error detected
  491. *
  492. * @HAL_REO_ERR_QUEUE_DESC_ADDR_0: Reo queue descriptor provided in the
  493. * REO_ENTRANCE ring is set to 0
  494. * @HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  495. * @HAL_REO_ERR_AMPDU_IN_NON_BA: AMPDU frame received without BA session
  496. * having been setup
  497. * @HAL_REO_ERR_NON_BA_DUPLICATE: Non-BA session, SN equal to SSN,
  498. * Retry bit set: duplicate frame
  499. * @HAL_REO_ERR_BA_DUPLICATE: BA session, duplicate frame
  500. * @HAL_REO_ERR_REGULAR_FRAME_2K_JUMP: A normal (management/data frame)
  501. * received with 2K jump in SN
  502. * @HAL_REO_ERR_BAR_FRAME_2K_JUMP: A bar received with 2K jump in SSN
  503. * @HAL_REO_ERR_REGULAR_FRAME_OOR: A normal (management/data frame) received
  504. * with SN falling within the OOR window
  505. * @HAL_REO_ERR_BAR_FRAME_OOR: A bar received with SSN falling within the
  506. * OOR window
  507. * @HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION: A bar received without a BA session
  508. * @HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN: A bar received with SSN equal to SN
  509. * @HAL_REO_ERR_PN_CHECK_FAILED: PN Check Failed packet
  510. * @HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET: Frame is forwarded as a result
  511. * of the Seq_2k_error_detected_flag been set in the REO Queue descriptor
  512. * @HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET: Frame is forwarded as a result
  513. * of the pn_error_detected_flag been set in the REO Queue descriptor
  514. * @HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET: Frame is forwarded as a result of
  515. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  516. * in the process of making updates to this descriptor
  517. * @HAL_REO_ERR_MAX: count of number of enumerators
  518. */
  519. enum hal_reo_error_code {
  520. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  521. HAL_REO_ERR_QUEUE_DESC_INVALID,
  522. HAL_REO_ERR_AMPDU_IN_NON_BA,
  523. HAL_REO_ERR_NON_BA_DUPLICATE,
  524. HAL_REO_ERR_BA_DUPLICATE,
  525. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  526. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  527. HAL_REO_ERR_REGULAR_FRAME_OOR,
  528. HAL_REO_ERR_BAR_FRAME_OOR,
  529. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  530. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  531. HAL_REO_ERR_PN_CHECK_FAILED,
  532. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  533. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  534. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET,
  535. HAL_REO_ERR_MAX
  536. };
  537. /**
  538. * enum hal_rxdma_error_code - Code describing the type of RxDMA error detected
  539. *
  540. * @HAL_RXDMA_ERR_OVERFLOW: MPDU frame is not complete due to a FIFO overflow
  541. * @HAL_RXDMA_ERR_MPDU_LENGTH: MPDU frame is not complete due to receiving
  542. * incomplete MPDU from the PHY
  543. * @HAL_RXDMA_ERR_FCS: FCS check on the MPDU frame failed
  544. * @HAL_RXDMA_ERR_DECRYPT: Decryption error
  545. * @HAL_RXDMA_ERR_TKIP_MIC: TKIP MIC error
  546. * @HAL_RXDMA_ERR_UNENCRYPTED: Received a frame that was expected to be
  547. * encrypted but wasn’t
  548. * @HAL_RXDMA_ERR_MSDU_LEN: MSDU related length error
  549. * @HAL_RXDMA_ERR_MSDU_LIMIT: Number of MSDUs in the MPDUs exceeded
  550. * the max allowed
  551. * @HAL_RXDMA_ERR_WIFI_PARSE: wifi parsing error
  552. * @HAL_RXDMA_ERR_AMSDU_PARSE: Amsdu parsing error
  553. * @HAL_RXDMA_ERR_SA_TIMEOUT: Source Address search timeout
  554. * @HAL_RXDMA_ERR_DA_TIMEOUT: Destination Address search timeout
  555. * @HAL_RXDMA_ERR_FLOW_TIMEOUT: Flow Search Timeout
  556. * @HAL_RXDMA_ERR_FLUSH_REQUEST: RxDMA FIFO Flush request
  557. * @HAL_RXDMA_AMSDU_FRAGMENT: Rx PCU reported A-MSDU
  558. * present as well as a fragmented MPDU
  559. * @HAL_RXDMA_MULTICAST_ECHO: RX OLE reported a multicast echo
  560. * @HAL_RXDMA_AMSDU_ADDR_MISMATCH: RX OLE reported AMSDU address mismatch
  561. * @HAL_RXDMA_UNAUTHORIZED_WDS: RX PCU reported unauthorized wds
  562. * @HAL_RXDMA_GROUPCAST_AMSDU_OR_WDS: RX PCU reported group cast AMSDU or WDS
  563. * @HAL_RXDMA_ERR_WAR: RxDMA WAR dummy errors
  564. * @HAL_RXDMA_ERR_MAX: count of number of enumerators
  565. */
  566. enum hal_rxdma_error_code {
  567. HAL_RXDMA_ERR_OVERFLOW = 0,
  568. HAL_RXDMA_ERR_MPDU_LENGTH,
  569. HAL_RXDMA_ERR_FCS,
  570. HAL_RXDMA_ERR_DECRYPT,
  571. HAL_RXDMA_ERR_TKIP_MIC,
  572. HAL_RXDMA_ERR_UNENCRYPTED,
  573. HAL_RXDMA_ERR_MSDU_LEN,
  574. HAL_RXDMA_ERR_MSDU_LIMIT,
  575. HAL_RXDMA_ERR_WIFI_PARSE,
  576. HAL_RXDMA_ERR_AMSDU_PARSE,
  577. HAL_RXDMA_ERR_SA_TIMEOUT,
  578. HAL_RXDMA_ERR_DA_TIMEOUT,
  579. HAL_RXDMA_ERR_FLOW_TIMEOUT,
  580. HAL_RXDMA_ERR_FLUSH_REQUEST,
  581. HAL_RXDMA_AMSDU_FRAGMENT,
  582. HAL_RXDMA_MULTICAST_ECHO,
  583. HAL_RXDMA_AMSDU_ADDR_MISMATCH,
  584. HAL_RXDMA_UNAUTHORIZED_WDS,
  585. HAL_RXDMA_GROUPCAST_AMSDU_OR_WDS,
  586. HAL_RXDMA_ERR_WAR = 31,
  587. HAL_RXDMA_ERR_MAX
  588. };
  589. /*
  590. * HW BM action settings in WBM release ring
  591. */
  592. #define HAL_BM_ACTION_PUT_IN_IDLE_LIST 0
  593. #define HAL_BM_ACTION_RELEASE_MSDU_LIST 1
  594. /**
  595. * enum hal_rx_wbm_error_source - Indicates which module initiated the
  596. * release of this buffer or descriptor
  597. *
  598. * @HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  599. * @HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  600. * @HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  601. * @HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  602. * @HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  603. */
  604. enum hal_rx_wbm_error_source {
  605. HAL_RX_WBM_ERR_SRC_TQM = 0,
  606. HAL_RX_WBM_ERR_SRC_RXDMA,
  607. HAL_RX_WBM_ERR_SRC_REO,
  608. HAL_RX_WBM_ERR_SRC_FW,
  609. HAL_RX_WBM_ERR_SRC_SW,
  610. };
  611. /**
  612. * enum hal_rx_wbm_buf_type - Indicates that type of buffer or descriptor
  613. * released
  614. *
  615. * @HAL_RX_WBM_BUF_TYPE_REL_BUF:
  616. * @HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC:
  617. * @HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC:
  618. * @HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC:
  619. * @HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC:
  620. */
  621. enum hal_rx_wbm_buf_type {
  622. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  623. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  624. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  625. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  626. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  627. };
  628. #define HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  629. /**
  630. * hal_rx_msdu_is_wlan_mcast() - Check if the buffer is for multicast address
  631. * @hal_soc_hdl: hal soc handle
  632. * @nbuf: Network buffer
  633. *
  634. * Return: flag to indicate whether the nbuf has MC/BC address
  635. */
  636. static inline uint32_t
  637. hal_rx_msdu_is_wlan_mcast(hal_soc_handle_t hal_soc_hdl,
  638. qdf_nbuf_t nbuf)
  639. {
  640. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  641. return hal_soc->ops->hal_rx_msdu_is_wlan_mcast(nbuf);
  642. }
  643. /**
  644. * hal_rx_priv_info_set_in_tlv() - Save the private info to
  645. * the reserved bytes of rx_tlv_hdr
  646. * @hal_soc_hdl: hal soc handle
  647. * @buf: start of rx_tlv_hdr
  648. * @priv_data: private info to store
  649. * @len: length of @priv_data
  650. *
  651. * Return: void
  652. */
  653. static inline void
  654. hal_rx_priv_info_set_in_tlv(hal_soc_handle_t hal_soc_hdl,
  655. uint8_t *buf, uint8_t *priv_data,
  656. uint32_t len)
  657. {
  658. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  659. return hal_soc->ops->hal_rx_priv_info_set_in_tlv(buf,
  660. priv_data,
  661. len);
  662. }
  663. /**
  664. * hal_rx_reo_ent_rxdma_push_reason_get() - Retrieves RXDMA push reason from
  665. * reo_entrance_ring descriptor
  666. *
  667. * @reo_ent_desc: reo_entrance_ring descriptor
  668. *
  669. * Return: value of rxdma_push_reason
  670. */
  671. static inline
  672. uint8_t hal_rx_reo_ent_rxdma_push_reason_get(hal_rxdma_desc_t reo_ent_desc)
  673. {
  674. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  675. HAL_REO_ENTRANCE_RING_RXDMA_PUSH_REASON_OFFSET)),
  676. HAL_REO_ENTRANCE_RING_RXDMA_PUSH_REASON_MASK,
  677. HAL_REO_ENTRANCE_RING_RXDMA_PUSH_REASON_LSB);
  678. }
  679. /**
  680. * hal_rx_reo_ent_rxdma_error_code_get() - Retrieves RXDMA error code from
  681. * reo_entrance_ring descriptor
  682. * @reo_ent_desc: reo_entrance_ring descriptor
  683. *
  684. * Return: value of rxdma_error_code
  685. */
  686. static inline
  687. uint8_t hal_rx_reo_ent_rxdma_error_code_get(hal_rxdma_desc_t reo_ent_desc)
  688. {
  689. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  690. HAL_REO_ENTRANCE_RING_RXDMA_ERROR_CODE_OFFSET)),
  691. HAL_REO_ENTRANCE_RING_RXDMA_ERROR_CODE_MASK,
  692. HAL_REO_ENTRANCE_RING_RXDMA_ERROR_CODE_LSB);
  693. }
  694. /**
  695. * hal_rx_priv_info_get_from_tlv() - retrieve the private data from
  696. * the reserved bytes of rx_tlv_hdr.
  697. * @hal_soc_hdl: hal soc handle
  698. * @buf: start of rx_tlv_hdr
  699. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  700. * @len: length of the buffer
  701. *
  702. * Return: void
  703. */
  704. static inline void
  705. hal_rx_priv_info_get_from_tlv(hal_soc_handle_t hal_soc_hdl,
  706. uint8_t *buf, uint8_t *wbm_er_info,
  707. uint32_t len)
  708. {
  709. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  710. return hal_soc->ops->hal_rx_priv_info_get_from_tlv(buf,
  711. wbm_er_info,
  712. len);
  713. }
  714. static inline void
  715. hal_rx_get_tlv_size(hal_soc_handle_t hal_soc_hdl, uint16_t *rx_pkt_tlv_size,
  716. uint16_t *rx_mon_pkt_tlv_size)
  717. {
  718. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  719. return hal_soc->ops->hal_rx_get_tlv_size(rx_pkt_tlv_size,
  720. rx_mon_pkt_tlv_size);
  721. }
  722. /**
  723. * hal_rx_encryption_info_valid() - Returns encryption type.
  724. * @hal_soc_hdl: hal soc handle
  725. * @buf: rx_tlv_hdr of the received packet
  726. *
  727. * Return: encryption type
  728. */
  729. static inline uint32_t
  730. hal_rx_encryption_info_valid(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  731. {
  732. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  733. return hal_soc->ops->hal_rx_encryption_info_valid(buf);
  734. }
  735. /**
  736. * hal_rx_print_pn() - Prints the PN of rx packet.
  737. * @hal_soc_hdl: hal soc handle
  738. * @buf: rx_tlv_hdr of the received packet
  739. *
  740. * Return: void
  741. */
  742. static inline void
  743. hal_rx_print_pn(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  744. {
  745. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  746. hal_soc->ops->hal_rx_print_pn(buf);
  747. }
  748. /**
  749. * hal_rx_msdu_end_l3_hdr_padding_get() - API to get the
  750. * l3_header padding from rx_msdu_end TLV
  751. * @hal_soc_hdl: hal_soc handle
  752. * @buf: pointer to the start of RX PKT TLV headers
  753. *
  754. * Return: number of l3 header padding bytes
  755. */
  756. static inline uint32_t
  757. hal_rx_msdu_end_l3_hdr_padding_get(hal_soc_handle_t hal_soc_hdl,
  758. uint8_t *buf)
  759. {
  760. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  761. return hal_soc->ops->hal_rx_msdu_end_l3_hdr_padding_get(buf);
  762. }
  763. /**
  764. * hal_rx_msdu_end_sa_idx_get() - API to get the sa_idx from rx_msdu_end TLV
  765. * @hal_soc_hdl: hal_soc handle
  766. * @buf: pointer to the start of RX PKT TLV headers
  767. *
  768. * Return: sa_idx (SA AST index)
  769. */
  770. static inline uint16_t
  771. hal_rx_msdu_end_sa_idx_get(hal_soc_handle_t hal_soc_hdl,
  772. uint8_t *buf)
  773. {
  774. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  775. return hal_soc->ops->hal_rx_msdu_end_sa_idx_get(buf);
  776. }
  777. /**
  778. * hal_rx_msdu_end_sa_is_valid_get() - API to get the
  779. * sa_is_valid bit from rx_msdu_end TLV
  780. * @hal_soc_hdl: hal_soc handle
  781. * @buf: pointer to the start of RX PKT TLV headers
  782. *
  783. * Return: sa_is_valid bit
  784. */
  785. static inline uint8_t
  786. hal_rx_msdu_end_sa_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  787. uint8_t *buf)
  788. {
  789. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  790. return hal_soc->ops->hal_rx_msdu_end_sa_is_valid_get(buf);
  791. }
  792. /**
  793. * hal_rx_tlv_msdu_len_set() - API to set the MSDU length from rx_msdu_start TLV
  794. * @hal_soc_hdl: hal_soc handle
  795. * @buf: pointer to the start of RX PKT TLV headers
  796. * @len: msdu length
  797. *
  798. * Return: none
  799. */
  800. static inline void
  801. hal_rx_tlv_msdu_len_set(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  802. uint32_t len)
  803. {
  804. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  805. return hal_soc->ops->hal_rx_tlv_msdu_len_set(buf, len);
  806. }
  807. /**
  808. * enum hal_rx_mpdu_info_sw_frame_group_id_type - Enum for group id in MPDU_INFO
  809. *
  810. * @HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME: NDP frame
  811. * @HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA: multicast data frame
  812. * @HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA: unicast data frame
  813. * @HAL_MPDU_SW_FRAME_GROUP_NULL_DATA: NULL data frame
  814. * @HAL_MPDU_SW_FRAME_GROUP_MGMT: management frame
  815. * @HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ: probe req frame
  816. * @HAL_MPDU_SW_FRAME_GROUP_MGMT_BEACON: beacon frame
  817. * @HAL_MPDU_SW_FRAME_GROUP_CTRL: control frame
  818. * @HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA: NDPA frame
  819. * @HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR: BAR frame
  820. * @HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS: RTS frame
  821. * @HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED: unsupported
  822. * @HAL_MPDU_SW_FRAME_GROUP_MAX: max limit
  823. */
  824. enum hal_rx_mpdu_info_sw_frame_group_id_type {
  825. HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME = 0,
  826. HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA,
  827. HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA,
  828. HAL_MPDU_SW_FRAME_GROUP_NULL_DATA,
  829. HAL_MPDU_SW_FRAME_GROUP_MGMT,
  830. HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ = 8,
  831. HAL_MPDU_SW_FRAME_GROUP_MGMT_BEACON = 12,
  832. HAL_MPDU_SW_FRAME_GROUP_CTRL = 20,
  833. HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA = 25,
  834. HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR = 28,
  835. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS = 31,
  836. HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED = 36,
  837. HAL_MPDU_SW_FRAME_GROUP_MAX = 37,
  838. };
  839. /**
  840. * hal_rx_mpdu_start_mpdu_qos_control_valid_get() -
  841. * Retrieve qos control valid bit from the tlv.
  842. * @hal_soc_hdl: hal_soc handle
  843. * @buf: pointer to rx pkt TLV.
  844. *
  845. * Return: qos control value.
  846. */
  847. static inline uint32_t
  848. hal_rx_mpdu_start_mpdu_qos_control_valid_get(
  849. hal_soc_handle_t hal_soc_hdl,
  850. uint8_t *buf)
  851. {
  852. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  853. if ((!hal_soc) || (!hal_soc->ops)) {
  854. hal_err("hal handle is NULL");
  855. QDF_BUG(0);
  856. return QDF_STATUS_E_INVAL;
  857. }
  858. if (hal_soc->ops->hal_rx_mpdu_start_mpdu_qos_control_valid_get)
  859. return hal_soc->ops->
  860. hal_rx_mpdu_start_mpdu_qos_control_valid_get(buf);
  861. return QDF_STATUS_E_INVAL;
  862. }
  863. /**
  864. * hal_rx_is_unicast() - check packet is unicast frame or not.
  865. * @hal_soc_hdl: hal_soc handle
  866. * @buf: pointer to rx pkt TLV.
  867. *
  868. * Return: true on unicast.
  869. */
  870. static inline bool
  871. hal_rx_is_unicast(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  872. {
  873. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  874. return hal_soc->ops->hal_rx_is_unicast(buf);
  875. }
  876. /**
  877. * hal_rx_tid_get() - get tid based on qos control valid.
  878. * @hal_soc_hdl: hal soc handle
  879. * @buf: pointer to rx pkt TLV.
  880. *
  881. * Return: tid
  882. */
  883. static inline uint32_t
  884. hal_rx_tid_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  885. {
  886. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  887. return hal_soc->ops->hal_rx_tid_get(hal_soc_hdl, buf);
  888. }
  889. /**
  890. * hal_rx_mpdu_start_sw_peer_id_get() - Retrieve sw peer id
  891. * @hal_soc_hdl: hal soc handle
  892. * @buf: pointer to rx pkt TLV.
  893. *
  894. * Return: sw peer_id
  895. */
  896. static inline uint32_t
  897. hal_rx_mpdu_start_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  898. uint8_t *buf)
  899. {
  900. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  901. return hal_soc->ops->hal_rx_mpdu_start_sw_peer_id_get(buf);
  902. }
  903. /**
  904. * hal_rx_tlv_peer_meta_data_get() - Retrieve PEER_META_DATA
  905. * @hal_soc_hdl: hal soc handle
  906. * @buf: pointer to rx pkt TLV.
  907. *
  908. * Return: peer meta data
  909. */
  910. static inline uint32_t
  911. hal_rx_tlv_peer_meta_data_get(hal_soc_handle_t hal_soc_hdl,
  912. uint8_t *buf)
  913. {
  914. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  915. return hal_soc->ops->hal_rx_tlv_peer_meta_data_get(buf);
  916. }
  917. /**
  918. * hal_rx_mpdu_get_to_ds() - API to get the tods info from rx_mpdu_start
  919. * @hal_soc_hdl: hal_soc handle
  920. * @buf: pointer to the start of RX PKT TLV header
  921. *
  922. * Return: uint32_t(to_ds)
  923. */
  924. static inline uint32_t
  925. hal_rx_mpdu_get_to_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  926. {
  927. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  928. return hal_soc->ops->hal_rx_mpdu_get_to_ds(buf);
  929. }
  930. /**
  931. * hal_rx_mpdu_get_fr_ds() - API to get the from ds info
  932. * from rx_mpdu_start
  933. * @hal_soc_hdl: hal soc handle
  934. * @buf: pointer to the start of RX PKT TLV header
  935. *
  936. * Return: uint32_t(fr_ds)
  937. */
  938. static inline uint32_t
  939. hal_rx_mpdu_get_fr_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  940. {
  941. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  942. return hal_soc->ops->hal_rx_mpdu_get_fr_ds(buf);
  943. }
  944. /**
  945. * hal_rx_mpdu_get_addr1() - API to check get address1 of the mpdu
  946. * @hal_soc_hdl: hal soc handle
  947. * @buf: pointer to the start of RX PKT TLV headera
  948. * @mac_addr: pointer to mac address
  949. *
  950. * Return: success/failure
  951. */
  952. static inline
  953. QDF_STATUS hal_rx_mpdu_get_addr1(hal_soc_handle_t hal_soc_hdl,
  954. uint8_t *buf, uint8_t *mac_addr)
  955. {
  956. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  957. return hal_soc->ops->hal_rx_mpdu_get_addr1(buf, mac_addr);
  958. }
  959. /**
  960. * hal_rx_mpdu_get_addr2() - API to check get address2 of the mpdu
  961. * in the packet
  962. * @hal_soc_hdl: hal soc handle
  963. * @buf: pointer to the start of RX PKT TLV header
  964. * @mac_addr: pointer to mac address
  965. *
  966. * Return: success/failure
  967. */
  968. static inline
  969. QDF_STATUS hal_rx_mpdu_get_addr2(hal_soc_handle_t hal_soc_hdl,
  970. uint8_t *buf, uint8_t *mac_addr)
  971. {
  972. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  973. return hal_soc->ops->hal_rx_mpdu_get_addr2(buf, mac_addr);
  974. }
  975. /**
  976. * hal_rx_mpdu_get_addr3() - API to get address3 of the mpdu
  977. * in the packet
  978. * @hal_soc_hdl: hal soc handle
  979. * @buf: pointer to the start of RX PKT TLV header
  980. * @mac_addr: pointer to mac address
  981. *
  982. * Return: success/failure
  983. */
  984. static inline
  985. QDF_STATUS hal_rx_mpdu_get_addr3(hal_soc_handle_t hal_soc_hdl,
  986. uint8_t *buf, uint8_t *mac_addr)
  987. {
  988. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  989. return hal_soc->ops->hal_rx_mpdu_get_addr3(buf, mac_addr);
  990. }
  991. /**
  992. * hal_rx_mpdu_get_addr4() - API to get address4 of the mpdu
  993. * in the packet
  994. * @hal_soc_hdl: hal_soc handle
  995. * @buf: pointer to the start of RX PKT TLV header
  996. * @mac_addr: pointer to mac address
  997. * Return: success/failure
  998. */
  999. static inline
  1000. QDF_STATUS hal_rx_mpdu_get_addr4(hal_soc_handle_t hal_soc_hdl,
  1001. uint8_t *buf, uint8_t *mac_addr)
  1002. {
  1003. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1004. return hal_soc->ops->hal_rx_mpdu_get_addr4(buf, mac_addr);
  1005. }
  1006. /**
  1007. * hal_rx_msdu_end_da_idx_get() - API to get da_idx from rx_msdu_end TLV
  1008. * @hal_soc_hdl: hal_soc handle
  1009. * @buf: pointer to the start of RX PKT TLV headers
  1010. *
  1011. * Return: da index
  1012. */
  1013. static inline uint16_t
  1014. hal_rx_msdu_end_da_idx_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1015. {
  1016. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1017. return hal_soc->ops->hal_rx_msdu_end_da_idx_get(buf);
  1018. }
  1019. /**
  1020. * hal_rx_msdu_end_da_is_valid_get() - API to check if da is valid
  1021. * from rx_msdu_end TLV
  1022. * @hal_soc_hdl: hal soc handle
  1023. * @buf: pointer to the start of RX PKT TLV headers
  1024. *
  1025. * Return: da_is_valid
  1026. */
  1027. static inline uint8_t
  1028. hal_rx_msdu_end_da_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  1029. uint8_t *buf)
  1030. {
  1031. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1032. return hal_soc->ops->hal_rx_msdu_end_da_is_valid_get(buf);
  1033. }
  1034. /**
  1035. * hal_rx_msdu_end_da_is_mcbc_get() - API to check if pkt is MCBC
  1036. * from rx_msdu_end TLV
  1037. * @hal_soc_hdl: HAL SOC handle
  1038. * @buf: pointer to the start of RX PKT TLV headers
  1039. *
  1040. * Return: da_is_mcbc
  1041. */
  1042. static inline uint8_t
  1043. hal_rx_msdu_end_da_is_mcbc_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1044. {
  1045. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1046. return hal_soc->ops->hal_rx_msdu_end_da_is_mcbc_get(buf);
  1047. }
  1048. /**
  1049. * hal_rx_msdu_end_is_tkip_mic_err() - API to check if pkt has mic error
  1050. * from rx_msdu_end TLV
  1051. * @hal_soc_hdl: HAL SOC handle
  1052. * @buf: pointer to the start of RX PKT TLV headers
  1053. *
  1054. * Return: tkip_mic_err
  1055. */
  1056. static inline uint8_t
  1057. hal_rx_msdu_end_is_tkip_mic_err(hal_soc_handle_t hal_soc_hdl,
  1058. uint8_t *buf)
  1059. {
  1060. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1061. if (hal_soc->ops->hal_rx_msdu_end_is_tkip_mic_err)
  1062. return hal_soc->ops->hal_rx_msdu_end_is_tkip_mic_err(buf);
  1063. else
  1064. return 0;
  1065. }
  1066. /**
  1067. * hal_rx_msdu_end_first_msdu_get() - API to get first msdu status
  1068. * from rx_msdu_end TLV
  1069. * @hal_soc_hdl: hal soc handle
  1070. * @buf: pointer to the start of RX PKT TLV headers
  1071. *
  1072. * Return: first_msdu
  1073. */
  1074. static inline uint8_t
  1075. hal_rx_msdu_end_first_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1076. uint8_t *buf)
  1077. {
  1078. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1079. return hal_soc->ops->hal_rx_msdu_end_first_msdu_get(buf);
  1080. }
  1081. /**
  1082. * hal_rx_msdu_end_last_msdu_get() - API to get last msdu status
  1083. * from rx_msdu_end TLV
  1084. * @hal_soc_hdl: hal soc handle
  1085. * @buf: pointer to the start of RX PKT TLV headers
  1086. *
  1087. * Return: last_msdu
  1088. */
  1089. static inline uint8_t
  1090. hal_rx_msdu_end_last_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1091. uint8_t *buf)
  1092. {
  1093. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1094. return hal_soc->ops->hal_rx_msdu_end_last_msdu_get(buf);
  1095. }
  1096. /**
  1097. * hal_rx_msdu_cce_match_get() - API to get CCE match from rx_msdu_end TLV
  1098. * @hal_soc_hdl: HAL SOC handle
  1099. * @buf: pointer to the start of RX PKT TLV headers
  1100. *
  1101. * Return: cce_meta_data
  1102. */
  1103. static inline bool
  1104. hal_rx_msdu_cce_match_get(hal_soc_handle_t hal_soc_hdl,
  1105. uint8_t *buf)
  1106. {
  1107. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1108. return hal_soc->ops->hal_rx_msdu_cce_match_get(buf);
  1109. }
  1110. /**
  1111. * hal_rx_msdu_cce_metadata_get() - API to get CCE metadata
  1112. * from rx_msdu_end TLV
  1113. * @hal_soc_hdl: HAL SOC handle
  1114. * @buf: pointer to the start of RX PKT TLV headers
  1115. *
  1116. * Return: cce_meta_data
  1117. */
  1118. static inline uint16_t
  1119. hal_rx_msdu_cce_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1120. uint8_t *buf)
  1121. {
  1122. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1123. return hal_soc->ops->hal_rx_msdu_cce_metadata_get(buf);
  1124. }
  1125. /*******************************************************************************
  1126. * RX REO ERROR APIS
  1127. ******************************************************************************/
  1128. /**
  1129. * hal_rx_link_desc_msdu0_ptr() - Get pointer to rx_msdu details
  1130. * @msdu_link_ptr: msdu link ptr
  1131. * @hal_soc: pointer to hal_soc
  1132. *
  1133. * Return: Pointer to rx_msdu_details structure
  1134. *
  1135. */
  1136. static inline
  1137. void *hal_rx_link_desc_msdu0_ptr(void *msdu_link_ptr,
  1138. struct hal_soc *hal_soc)
  1139. {
  1140. return hal_soc->ops->hal_rx_link_desc_msdu0_ptr(msdu_link_ptr);
  1141. }
  1142. /**
  1143. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  1144. * @msdu_details_ptr: Pointer to msdu_details_ptr
  1145. * @hal_soc: pointer to hal_soc
  1146. *
  1147. * Return: Pointer to rx_msdu_desc_info structure.
  1148. *
  1149. */
  1150. static inline
  1151. void *hal_rx_msdu_desc_info_get_ptr(void *msdu_details_ptr,
  1152. struct hal_soc *hal_soc)
  1153. {
  1154. return hal_soc->ops->hal_rx_msdu_desc_info_get_ptr(msdu_details_ptr);
  1155. }
  1156. /**
  1157. * hal_rx_reo_buf_paddr_get() - Gets the physical address and
  1158. * cookie from the REO destination ring element
  1159. * @hal_soc_hdl: HAL SOC handle
  1160. * @rx_desc: the current descriptor
  1161. * @buf_info: structure to return the buffer information
  1162. *
  1163. * Return: void
  1164. */
  1165. static inline
  1166. void hal_rx_reo_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  1167. hal_ring_desc_t rx_desc,
  1168. struct hal_buf_info *buf_info)
  1169. {
  1170. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1171. if (hal_soc->ops->hal_rx_reo_buf_paddr_get)
  1172. return hal_soc->ops->hal_rx_reo_buf_paddr_get(
  1173. rx_desc,
  1174. buf_info);
  1175. }
  1176. /**
  1177. * hal_rx_wbm_rel_buf_paddr_get() - Gets the physical address and
  1178. * cookie from the WBM release ring element
  1179. * @hal_soc_hdl: HAL SOC handle
  1180. * @rx_desc: the current descriptor
  1181. * @buf_info: structure to return the buffer information
  1182. *
  1183. * Return: void
  1184. */
  1185. static inline
  1186. void hal_rx_wbm_rel_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  1187. hal_ring_desc_t rx_desc,
  1188. struct hal_buf_info *buf_info)
  1189. {
  1190. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1191. if (hal_soc->ops->hal_rx_wbm_rel_buf_paddr_get)
  1192. return hal_soc->ops->hal_rx_wbm_rel_buf_paddr_get(rx_desc,
  1193. buf_info);
  1194. }
  1195. /**
  1196. * hal_rx_buf_cookie_rbm_get() - Gets the physical address and cookie
  1197. * from the REO entrance ring element
  1198. * @hal_soc_hdl: hal soc handle
  1199. * @buf_addr_info: pointer to buf_addr_info structure
  1200. * @buf_info: structure to return the buffer information
  1201. *
  1202. * Return: void
  1203. */
  1204. static inline
  1205. void hal_rx_buf_cookie_rbm_get(hal_soc_handle_t hal_soc_hdl,
  1206. uint32_t *buf_addr_info,
  1207. struct hal_buf_info *buf_info)
  1208. {
  1209. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1210. return hal_soc->ops->hal_rx_buf_cookie_rbm_get(
  1211. buf_addr_info,
  1212. buf_info);
  1213. }
  1214. /**
  1215. * hal_rx_msdu_list_get() - API to get the MSDU information
  1216. * from the MSDU link descriptor
  1217. * @hal_soc_hdl: hal soc handle
  1218. * @msdu_link_desc: Opaque pointer used by HAL to get to the
  1219. * MSDU link descriptor (struct rx_msdu_link)
  1220. * @msdu_list: Return the list of MSDUs contained in this link descriptor
  1221. * @num_msdus: Number of MSDUs in the MPDU
  1222. *
  1223. * Return: void
  1224. */
  1225. static inline void hal_rx_msdu_list_get(hal_soc_handle_t hal_soc_hdl,
  1226. void *msdu_link_desc,
  1227. struct hal_rx_msdu_list *msdu_list,
  1228. uint16_t *num_msdus)
  1229. {
  1230. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1231. struct rx_msdu_details *msdu_details;
  1232. struct rx_msdu_desc_info *msdu_desc_info;
  1233. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1234. int i;
  1235. struct hal_buf_info buf_info;
  1236. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1237. dp_nofl_debug("[%s][%d] msdu_link=%pK msdu_details=%pK",
  1238. __func__, __LINE__, msdu_link, msdu_details);
  1239. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  1240. /* num_msdus received in mpdu descriptor may be incorrect
  1241. * sometimes due to HW issue. Check msdu buffer address also
  1242. */
  1243. if (!i && (HAL_RX_BUFFER_ADDR_31_0_GET(
  1244. &msdu_details[i].buffer_addr_info_details) == 0))
  1245. break;
  1246. if (HAL_RX_BUFFER_ADDR_31_0_GET(
  1247. &msdu_details[i].buffer_addr_info_details) == 0) {
  1248. /* set the last msdu bit in the prev msdu_desc_info */
  1249. msdu_desc_info =
  1250. hal_rx_msdu_desc_info_get_ptr(&msdu_details[i - 1], hal_soc);
  1251. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1252. break;
  1253. }
  1254. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[i],
  1255. hal_soc);
  1256. /* set first MSDU bit or the last MSDU bit */
  1257. if (!i)
  1258. HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1259. else if (i == (HAL_RX_NUM_MSDU_DESC - 1))
  1260. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1261. msdu_list->msdu_info[i].msdu_flags =
  1262. hal_rx_msdu_flags_get(hal_soc_hdl, msdu_desc_info);
  1263. msdu_list->msdu_info[i].msdu_len =
  1264. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  1265. /* addr field in buf_info will not be valid */
  1266. hal_rx_buf_cookie_rbm_get(
  1267. hal_soc_hdl,
  1268. (uint32_t *)&msdu_details[i].buffer_addr_info_details,
  1269. &buf_info);
  1270. msdu_list->sw_cookie[i] = buf_info.sw_cookie;
  1271. msdu_list->rbm[i] = buf_info.rbm;
  1272. msdu_list->paddr[i] = HAL_RX_BUFFER_ADDR_31_0_GET(
  1273. &msdu_details[i].buffer_addr_info_details) |
  1274. (uint64_t)HAL_RX_BUFFER_ADDR_39_32_GET(
  1275. &msdu_details[i].buffer_addr_info_details) << 32;
  1276. dp_nofl_debug("[%s][%d] i=%d sw_cookie=%d",
  1277. __func__, __LINE__, i, msdu_list->sw_cookie[i]);
  1278. }
  1279. *num_msdus = i;
  1280. }
  1281. /**
  1282. * hal_rx_reo_is_pn_error() - Indicate if this error was caused by a
  1283. * PN check failure
  1284. * @error_code: error code obtained from ring descriptor.
  1285. *
  1286. * Return: true: error caused by PN check, false: other error
  1287. */
  1288. static inline bool hal_rx_reo_is_pn_error(uint32_t error_code)
  1289. {
  1290. return ((error_code == HAL_REO_ERR_PN_CHECK_FAILED) ||
  1291. (error_code == HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  1292. true : false;
  1293. }
  1294. /**
  1295. * hal_rx_reo_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  1296. * the sequence number
  1297. * @error_code: error code obtained from ring descriptor.
  1298. *
  1299. * Return: true: error caused by 2K jump, false: other error
  1300. */
  1301. static inline bool hal_rx_reo_is_2k_jump(uint32_t error_code)
  1302. {
  1303. return ((error_code == HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) ||
  1304. (error_code == HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  1305. true : false;
  1306. }
  1307. /**
  1308. * hal_rx_reo_is_oor_error() - Indicate if this error was caused by OOR
  1309. * @error_code: error code obtained from ring descriptor.
  1310. *
  1311. * Return: true: error caused by OOR, false: other error
  1312. */
  1313. static inline bool hal_rx_reo_is_oor_error(uint32_t error_code)
  1314. {
  1315. return (error_code == HAL_REO_ERR_REGULAR_FRAME_OOR) ?
  1316. true : false;
  1317. }
  1318. /**
  1319. * hal_rx_reo_is_bar_oor_2k_jump() - Check if the error is 2k-jump or OOR error
  1320. * @error_code: error code obtained from ring descriptor.
  1321. *
  1322. * Return: true, if the error code is 2k-jump or OOR
  1323. * false, for other error codes.
  1324. */
  1325. static inline bool hal_rx_reo_is_bar_oor_2k_jump(uint32_t error_code)
  1326. {
  1327. return ((error_code == HAL_REO_ERR_BAR_FRAME_2K_JUMP) ||
  1328. (error_code == HAL_REO_ERR_BAR_FRAME_OOR)) ?
  1329. true : false;
  1330. }
  1331. /**
  1332. * hal_dump_wbm_rel_desc() - dump wbm release descriptor
  1333. * @src_srng_desc: hardware descriptor pointer
  1334. *
  1335. * This function will print wbm release descriptor
  1336. *
  1337. * Return: none
  1338. */
  1339. static inline void hal_dump_wbm_rel_desc(void *src_srng_desc)
  1340. {
  1341. uint32_t *wbm_comp = (uint32_t *)src_srng_desc;
  1342. uint32_t i;
  1343. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1344. "Current Rx wbm release descriptor is");
  1345. for (i = 0; i < HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS; i++) {
  1346. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1347. "DWORD[i] = 0x%x", wbm_comp[i]);
  1348. }
  1349. }
  1350. /**
  1351. * hal_rx_msdu_link_desc_set() - Retrieves MSDU Link Descriptor to WBM
  1352. *
  1353. * @hal_soc_hdl: HAL version of the SOC pointer
  1354. * @src_srng_desc: void pointer to the WBM Release Ring descriptor
  1355. * @buf_addr_info: void pointer to the buffer_addr_info
  1356. * @bm_action: put in IDLE list or release to MSDU_LIST
  1357. *
  1358. * Return: void
  1359. */
  1360. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  1361. static inline
  1362. void hal_rx_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  1363. void *src_srng_desc,
  1364. hal_buff_addrinfo_t buf_addr_info,
  1365. uint8_t bm_action)
  1366. {
  1367. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1368. if (hal_soc->ops->hal_rx_msdu_link_desc_set)
  1369. return hal_soc->ops->hal_rx_msdu_link_desc_set(hal_soc_hdl,
  1370. src_srng_desc,
  1371. buf_addr_info,
  1372. bm_action);
  1373. }
  1374. /**
  1375. * HAL_RX_BUF_ADDR_INFO_GET() - Returns the address of the
  1376. * BUFFER_ADDR_INFO, give the RX descriptor
  1377. * (Assumption -- BUFFER_ADDR_INFO is the
  1378. * first field in the descriptor structure)
  1379. * @ring_desc: RX descriptor
  1380. *
  1381. * Return: pointer to buffer addr info
  1382. */
  1383. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) \
  1384. ((hal_link_desc_t)(ring_desc))
  1385. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1386. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1387. /*******************************************************************************
  1388. * RX WBM ERROR APIS
  1389. ******************************************************************************/
  1390. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  1391. (WBM_ERR_RING_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  1392. WBM_ERR_RING_BUFFER_OR_DESC_TYPE_MASK) >> \
  1393. WBM_ERR_RING_BUFFER_OR_DESC_TYPE_LSB)
  1394. /**
  1395. * enum hal_rx_wbm_reo_push_reason - Indicates why REO pushed
  1396. * the frame to this release ring
  1397. *
  1398. * @HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  1399. * frame to this queue
  1400. * @HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  1401. * received routing instructions. No error within REO was detected
  1402. */
  1403. enum hal_rx_wbm_reo_push_reason {
  1404. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  1405. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  1406. };
  1407. /**
  1408. * enum hal_rx_wbm_rxdma_push_reason - Indicates why REO pushed the frame to
  1409. * this release ring
  1410. *
  1411. * @HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  1412. * this frame to this queue
  1413. * @HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  1414. * per received routing instructions. No error within RXDMA was detected
  1415. * @HAL_RX_WBM_RXDMA_PSH_RSN_FLUSH:
  1416. */
  1417. enum hal_rx_wbm_rxdma_push_reason {
  1418. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  1419. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  1420. HAL_RX_WBM_RXDMA_PSH_RSN_FLUSH,
  1421. };
  1422. static inline void hal_rx_dump_mpdu_start_tlv(struct rx_mpdu_start *mpdu_start,
  1423. uint8_t dbg_level,
  1424. struct hal_soc *hal)
  1425. {
  1426. hal->ops->hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level);
  1427. }
  1428. /**
  1429. * hal_rx_dump_msdu_end_tlv() - dump RX msdu_end TLV in structured
  1430. * human readable format.
  1431. * @hal_soc: HAL soc
  1432. * @msdu_end: pointer the msdu_end TLV in pkt.
  1433. * @dbg_level: log level.
  1434. *
  1435. * Return: void
  1436. */
  1437. static inline void hal_rx_dump_msdu_end_tlv(struct hal_soc *hal_soc,
  1438. struct rx_msdu_end *msdu_end,
  1439. uint8_t dbg_level)
  1440. {
  1441. hal_soc->ops->hal_rx_dump_msdu_end_tlv(msdu_end, dbg_level);
  1442. }
  1443. /**
  1444. * hal_srng_ring_id_get() - API to retrieve ring id from hal ring
  1445. * structure
  1446. * @hal_ring_hdl: handle to hal_srng structure
  1447. *
  1448. * Return: ring_id
  1449. */
  1450. static inline uint8_t hal_srng_ring_id_get(hal_ring_handle_t hal_ring_hdl)
  1451. {
  1452. return ((struct hal_srng *)hal_ring_hdl)->ring_id;
  1453. }
  1454. #define DOT11_SEQ_FRAG_MASK 0x000f
  1455. #define DOT11_FC1_MORE_FRAG_OFFSET 0x04
  1456. /**
  1457. * hal_rx_get_rx_fragment_number() - Function to retrieve rx fragment number
  1458. * @hal_soc: HAL soc
  1459. * @buf: Network buffer
  1460. *
  1461. * Return: rx fragment number
  1462. */
  1463. static inline
  1464. uint8_t hal_rx_get_rx_fragment_number(struct hal_soc *hal_soc,
  1465. uint8_t *buf)
  1466. {
  1467. return hal_soc->ops->hal_rx_get_rx_fragment_number(buf);
  1468. }
  1469. /**
  1470. * hal_rx_get_mpdu_sequence_control_valid() - Get mpdu sequence control valid
  1471. * @hal_soc_hdl: hal soc handle
  1472. * @buf: Network buffer
  1473. *
  1474. * Return: value of sequence control valid field
  1475. */
  1476. static inline
  1477. uint8_t hal_rx_get_mpdu_sequence_control_valid(hal_soc_handle_t hal_soc_hdl,
  1478. uint8_t *buf)
  1479. {
  1480. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1481. return hal_soc->ops->hal_rx_get_mpdu_sequence_control_valid(buf);
  1482. }
  1483. /**
  1484. * hal_rx_get_mpdu_frame_control_valid() - Retrieves mpdu frame control valid
  1485. * @hal_soc_hdl: hal soc handle
  1486. * @buf: Network buffer
  1487. *
  1488. * Return: value of frame control valid field
  1489. */
  1490. static inline
  1491. uint8_t hal_rx_get_mpdu_frame_control_valid(hal_soc_handle_t hal_soc_hdl,
  1492. uint8_t *buf)
  1493. {
  1494. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1495. return hal_soc->ops->hal_rx_get_mpdu_frame_control_valid(buf);
  1496. }
  1497. /**
  1498. * hal_rx_get_mpdu_mac_ad4_valid() - Retrieves if mpdu 4th addr is valid
  1499. * @hal_soc_hdl: hal soc handle
  1500. * @buf: Network buffer
  1501. *
  1502. * Return: value of mpdu 4th address valid field
  1503. */
  1504. static inline
  1505. bool hal_rx_get_mpdu_mac_ad4_valid(hal_soc_handle_t hal_soc_hdl,
  1506. uint8_t *buf)
  1507. {
  1508. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1509. return hal_soc->ops->hal_rx_get_mpdu_mac_ad4_valid(buf);
  1510. }
  1511. /**
  1512. * hal_rx_clear_mpdu_desc_info() - Clears mpdu_desc_info
  1513. * @rx_mpdu_desc_info: HAL view of rx mpdu desc info
  1514. *
  1515. * Return: None
  1516. */
  1517. static inline void
  1518. hal_rx_clear_mpdu_desc_info(struct hal_rx_mpdu_desc_info *rx_mpdu_desc_info)
  1519. {
  1520. qdf_mem_zero(rx_mpdu_desc_info, sizeof(*rx_mpdu_desc_info));
  1521. }
  1522. /**
  1523. * hal_rx_wbm_err_info_get() - Retrieves WBM error code and reason and
  1524. * save it to hal_wbm_err_desc_info structure passed by caller
  1525. * @wbm_desc: wbm ring descriptor
  1526. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  1527. * @hal_soc_hdl: HAL SOC handle
  1528. *
  1529. * Return: void
  1530. */
  1531. static inline
  1532. void hal_rx_wbm_err_info_get(void *wbm_desc,
  1533. struct hal_wbm_err_desc_info *wbm_er_info,
  1534. hal_soc_handle_t hal_soc_hdl)
  1535. {
  1536. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1537. hal_soc->ops->hal_rx_wbm_err_info_get(wbm_desc, (void *)wbm_er_info);
  1538. }
  1539. /**
  1540. * hal_rx_wbm_err_msdu_continuation_get() - Get wbm msdu continuation
  1541. * bit from wbm release ring descriptor
  1542. * @hal_soc_hdl: HAL SOC handle
  1543. * @wbm_desc: wbm ring descriptor
  1544. *
  1545. * Return: uint8_t
  1546. */
  1547. static inline
  1548. uint8_t hal_rx_wbm_err_msdu_continuation_get(hal_soc_handle_t hal_soc_hdl,
  1549. void *wbm_desc)
  1550. {
  1551. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1552. return hal_soc->ops->hal_rx_wbm_err_msdu_continuation_get(wbm_desc);
  1553. }
  1554. /**
  1555. * hal_rx_mon_hw_desc_get_mpdu_status() - Retrieve MPDU status
  1556. * @hal_soc_hdl: HAL SOC handle
  1557. * @hw_desc_addr: Start address of Rx HW TLVs
  1558. * @rs: Status for monitor mode
  1559. *
  1560. * Return: void
  1561. */
  1562. static inline
  1563. void hal_rx_mon_hw_desc_get_mpdu_status(hal_soc_handle_t hal_soc_hdl,
  1564. void *hw_desc_addr,
  1565. struct mon_rx_status *rs)
  1566. {
  1567. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1568. hal_soc->ops->hal_rx_mon_hw_desc_get_mpdu_status(hw_desc_addr, rs);
  1569. }
  1570. /**
  1571. * hal_rx_get_tlv() - API to get the tlv
  1572. *
  1573. * @hal_soc: HAL version of the SOC pointer
  1574. * @rx_tlv: TLV data extracted from the rx packet
  1575. *
  1576. * Return: uint8_t
  1577. */
  1578. static inline uint8_t hal_rx_get_tlv(struct hal_soc *hal_soc, void *rx_tlv)
  1579. {
  1580. return hal_soc->ops->hal_rx_get_tlv(rx_tlv);
  1581. }
  1582. /**
  1583. * hal_rx_msdu_start_nss_get() - API to get the NSS
  1584. * Interval from rx_msdu_start
  1585. * @hal_soc_hdl: HAL SOC handle
  1586. * @buf: pointer to the start of RX PKT TLV header
  1587. *
  1588. * Return: uint32_t(nss)
  1589. */
  1590. static inline
  1591. uint32_t hal_rx_msdu_start_nss_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1592. {
  1593. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1594. return hal_soc->ops->hal_rx_msdu_start_nss_get(buf);
  1595. }
  1596. /**
  1597. * hal_rx_dump_msdu_start_tlv() - dump RX msdu_start TLV in structured
  1598. * human readable format.
  1599. * @hal_soc: HAL SOC
  1600. * @msdu_start: pointer the msdu_start TLV in pkt.
  1601. * @dbg_level: log level.
  1602. *
  1603. * Return: void
  1604. */
  1605. static inline void hal_rx_dump_msdu_start_tlv(struct hal_soc *hal_soc,
  1606. struct rx_msdu_start *msdu_start,
  1607. uint8_t dbg_level)
  1608. {
  1609. hal_soc->ops->hal_rx_dump_msdu_start_tlv(msdu_start, dbg_level);
  1610. }
  1611. /**
  1612. * hal_rx_mpdu_start_tid_get() - Return tid info from the rx mpdu start
  1613. * info details
  1614. * @hal_soc_hdl: HAL SOC handle
  1615. * @buf: Pointer to buffer containing rx pkt tlvs.
  1616. *
  1617. *
  1618. */
  1619. static inline uint32_t hal_rx_mpdu_start_tid_get(hal_soc_handle_t hal_soc_hdl,
  1620. uint8_t *buf)
  1621. {
  1622. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1623. return hal_soc->ops->hal_rx_mpdu_start_tid_get(buf);
  1624. }
  1625. /**
  1626. * hal_rx_msdu_start_reception_type_get() - API to get the reception type
  1627. * Interval from rx_msdu_start
  1628. * @hal_soc_hdl: hal_soc handle
  1629. * @buf: pointer to the start of RX PKT TLV header
  1630. *
  1631. * Return: uint32_t(reception_type)
  1632. */
  1633. static inline
  1634. uint32_t hal_rx_msdu_start_reception_type_get(hal_soc_handle_t hal_soc_hdl,
  1635. uint8_t *buf)
  1636. {
  1637. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1638. return hal_soc->ops->hal_rx_msdu_start_reception_type_get(buf);
  1639. }
  1640. /**
  1641. * hal_reo_status_get_header() - Process reo desc info
  1642. * @ring_desc: Pointer to reo descriptor
  1643. * @b: tlv type info
  1644. * @h: Pointer to hal_reo_status_header where info to be stored
  1645. * @hal_soc: pointer to hal_soc structure
  1646. *
  1647. * Return: none.
  1648. *
  1649. */
  1650. static inline
  1651. void hal_reo_status_get_header(hal_ring_desc_t ring_desc, int b,
  1652. void *h, struct hal_soc *hal_soc)
  1653. {
  1654. hal_soc->ops->hal_reo_status_get_header(ring_desc, b, h);
  1655. }
  1656. /**
  1657. * hal_rx_desc_is_first_msdu() - Check if first msdu
  1658. *
  1659. * @hal_soc_hdl: hal_soc handle
  1660. * @hw_desc_addr: hardware descriptor address
  1661. *
  1662. * Return: 0 - success/ non-zero failure
  1663. */
  1664. static inline
  1665. uint32_t hal_rx_desc_is_first_msdu(hal_soc_handle_t hal_soc_hdl,
  1666. void *hw_desc_addr)
  1667. {
  1668. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1669. return hal_soc->ops->hal_rx_desc_is_first_msdu(hw_desc_addr);
  1670. }
  1671. /**
  1672. * hal_rx_tlv_populate_mpdu_desc_info() - Populate mpdu_desc_info fields from
  1673. * the rx tlv fields.
  1674. * @hal_soc_hdl: HAL SoC handle
  1675. * @buf: rx tlv start address [To be validated by caller]
  1676. * @mpdu_desc_info_hdl: Buffer where the mpdu_desc_info is to be populated.
  1677. *
  1678. * Return: None
  1679. */
  1680. static inline void
  1681. hal_rx_tlv_populate_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1682. uint8_t *buf,
  1683. void *mpdu_desc_info_hdl)
  1684. {
  1685. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1686. if (hal_soc->ops->hal_rx_tlv_populate_mpdu_desc_info)
  1687. return hal_soc->ops->hal_rx_tlv_populate_mpdu_desc_info(buf,
  1688. mpdu_desc_info_hdl);
  1689. }
  1690. static inline uint32_t
  1691. hal_rx_tlv_decap_format_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  1692. {
  1693. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1694. return hal_soc->ops->hal_rx_tlv_decap_format_get(hw_desc_addr);
  1695. }
  1696. static inline
  1697. bool HAL_IS_DECAP_FORMAT_RAW(hal_soc_handle_t hal_soc_hdl,
  1698. uint8_t *rx_tlv_hdr)
  1699. {
  1700. uint8_t decap_format;
  1701. if (hal_rx_desc_is_first_msdu(hal_soc_hdl, rx_tlv_hdr)) {
  1702. decap_format = hal_rx_tlv_decap_format_get(hal_soc_hdl,
  1703. rx_tlv_hdr);
  1704. if (decap_format == HAL_HW_RX_DECAP_FORMAT_RAW)
  1705. return true;
  1706. }
  1707. return false;
  1708. }
  1709. /**
  1710. * hal_rx_msdu_fse_metadata_get() - API to get FSE metadata
  1711. * from rx_msdu_end TLV
  1712. * @hal_soc_hdl: HAL SOC handle
  1713. * @buf: pointer to the start of RX PKT TLV headers
  1714. *
  1715. * Return: fse metadata value from MSDU END TLV
  1716. */
  1717. static inline uint32_t
  1718. hal_rx_msdu_fse_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1719. uint8_t *buf)
  1720. {
  1721. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1722. return hal_soc->ops->hal_rx_msdu_fse_metadata_get(buf);
  1723. }
  1724. /**
  1725. * hal_rx_buffer_addr_info_get_paddr() - get paddr/sw_cookie from
  1726. * <struct buffer_addr_info> structure
  1727. * @buf_addr_info: pointer to <struct buffer_addr_info> structure
  1728. * @buf_info: structure to return the buffer information including
  1729. * paddr/cookie
  1730. *
  1731. * Return: None
  1732. */
  1733. static inline
  1734. void hal_rx_buffer_addr_info_get_paddr(void *buf_addr_info,
  1735. struct hal_buf_info *buf_info)
  1736. {
  1737. buf_info->paddr =
  1738. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  1739. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  1740. }
  1741. /**
  1742. * hal_rx_msdu_flow_idx_get() - API to get flow index from rx_msdu_end TLV
  1743. * @hal_soc_hdl: HAL SOC handle
  1744. * @buf: pointer to the start of RX PKT TLV headers
  1745. *
  1746. * Return: flow index value from MSDU END TLV
  1747. */
  1748. static inline uint32_t
  1749. hal_rx_msdu_flow_idx_get(hal_soc_handle_t hal_soc_hdl,
  1750. uint8_t *buf)
  1751. {
  1752. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1753. return hal_soc->ops->hal_rx_msdu_flow_idx_get(buf);
  1754. }
  1755. /**
  1756. * hal_rx_msdu_get_reo_destination_indication() - API to get reo
  1757. * destination index from rx_msdu_end TLV
  1758. * @hal_soc_hdl: HAL SOC handle
  1759. * @buf: pointer to the start of RX PKT TLV headers
  1760. * @reo_destination_indication: pointer to return value of
  1761. * reo_destination_indication
  1762. *
  1763. * Return: reo_destination_indication value from MSDU END TLV
  1764. */
  1765. static inline void
  1766. hal_rx_msdu_get_reo_destination_indication(hal_soc_handle_t hal_soc_hdl,
  1767. uint8_t *buf,
  1768. uint32_t *reo_destination_indication)
  1769. {
  1770. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1771. hal_soc->ops->hal_rx_msdu_get_reo_destination_indication(buf,
  1772. reo_destination_indication);
  1773. }
  1774. /**
  1775. * hal_rx_msdu_flow_idx_timeout() - API to get flow index timeout
  1776. * from rx_msdu_end TLV
  1777. * @hal_soc_hdl: HAL SOC handle
  1778. * @buf: pointer to the start of RX PKT TLV headers
  1779. *
  1780. * Return: flow index timeout value from MSDU END TLV
  1781. */
  1782. static inline bool
  1783. hal_rx_msdu_flow_idx_timeout(hal_soc_handle_t hal_soc_hdl,
  1784. uint8_t *buf)
  1785. {
  1786. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1787. return hal_soc->ops->hal_rx_msdu_flow_idx_timeout(buf);
  1788. }
  1789. /**
  1790. * hal_rx_msdu_flow_idx_invalid() - API to get flow index invalid
  1791. * from rx_msdu_end TLV
  1792. * @hal_soc_hdl: HAL SOC handle
  1793. * @buf: pointer to the start of RX PKT TLV headers
  1794. *
  1795. * Return: flow index invalid value from MSDU END TLV
  1796. */
  1797. static inline bool
  1798. hal_rx_msdu_flow_idx_invalid(hal_soc_handle_t hal_soc_hdl,
  1799. uint8_t *buf)
  1800. {
  1801. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1802. return hal_soc->ops->hal_rx_msdu_flow_idx_invalid(buf);
  1803. }
  1804. /**
  1805. * hal_rx_hw_desc_get_ppduid_get() - Retrieve ppdu id
  1806. * @hal_soc_hdl: hal_soc handle
  1807. * @rx_tlv_hdr: Rx_tlv_hdr
  1808. * @rxdma_dst_ring_desc: Rx HW descriptor
  1809. *
  1810. * Return: ppdu id
  1811. */
  1812. static inline
  1813. uint32_t hal_rx_hw_desc_get_ppduid_get(hal_soc_handle_t hal_soc_hdl,
  1814. void *rx_tlv_hdr,
  1815. void *rxdma_dst_ring_desc)
  1816. {
  1817. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1818. return hal_soc->ops->hal_rx_hw_desc_get_ppduid_get(rx_tlv_hdr,
  1819. rxdma_dst_ring_desc);
  1820. }
  1821. /**
  1822. * hal_rx_msdu_end_sa_sw_peer_id_get() - get sw peer id
  1823. * @hal_soc_hdl: hal_soc handle
  1824. * @buf: rx tlv address
  1825. *
  1826. * Return: sw peer id
  1827. */
  1828. static inline
  1829. uint32_t hal_rx_msdu_end_sa_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  1830. uint8_t *buf)
  1831. {
  1832. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1833. return hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get(buf);
  1834. }
  1835. static inline
  1836. void *hal_rx_msdu0_buffer_addr_lsb(hal_soc_handle_t hal_soc_hdl,
  1837. void *link_desc_addr)
  1838. {
  1839. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1840. return hal_soc->ops->hal_rx_msdu0_buffer_addr_lsb(link_desc_addr);
  1841. }
  1842. static inline
  1843. void *hal_rx_msdu_desc_info_ptr_get(hal_soc_handle_t hal_soc_hdl,
  1844. void *msdu_addr)
  1845. {
  1846. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1847. return hal_soc->ops->hal_rx_msdu_desc_info_ptr_get(msdu_addr);
  1848. }
  1849. static inline
  1850. void *hal_ent_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1851. void *hw_addr)
  1852. {
  1853. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1854. return hal_soc->ops->hal_ent_mpdu_desc_info(hw_addr);
  1855. }
  1856. static inline
  1857. void *hal_dst_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1858. void *hw_addr)
  1859. {
  1860. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1861. return hal_soc->ops->hal_dst_mpdu_desc_info(hw_addr);
  1862. }
  1863. static inline
  1864. uint8_t hal_rx_get_fc_valid(hal_soc_handle_t hal_soc_hdl,
  1865. uint8_t *buf)
  1866. {
  1867. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1868. return hal_soc->ops->hal_rx_get_fc_valid(buf);
  1869. }
  1870. static inline
  1871. uint8_t hal_rx_get_to_ds_flag(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1872. {
  1873. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1874. return hal_soc->ops->hal_rx_get_to_ds_flag(buf);
  1875. }
  1876. static inline
  1877. uint8_t hal_rx_get_mac_addr2_valid(hal_soc_handle_t hal_soc_hdl,
  1878. uint8_t *buf)
  1879. {
  1880. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1881. return hal_soc->ops->hal_rx_get_mac_addr2_valid(buf);
  1882. }
  1883. static inline
  1884. uint8_t hal_rx_get_filter_category(hal_soc_handle_t hal_soc_hdl,
  1885. uint8_t *buf)
  1886. {
  1887. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1888. return hal_soc->ops->hal_rx_get_filter_category(buf);
  1889. }
  1890. static inline
  1891. uint32_t hal_rx_get_ppdu_id(hal_soc_handle_t hal_soc_hdl,
  1892. uint8_t *buf)
  1893. {
  1894. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1895. return hal_soc->ops->hal_rx_get_ppdu_id(buf);
  1896. }
  1897. /**
  1898. * hal_reo_config() - Set reo config parameters
  1899. * @hal_soc: hal soc handle
  1900. * @reg_val: value to be set
  1901. * @reo_params: reo parameters
  1902. *
  1903. * Return: void
  1904. */
  1905. static inline
  1906. void hal_reo_config(struct hal_soc *hal_soc,
  1907. uint32_t reg_val,
  1908. struct hal_reo_params *reo_params)
  1909. {
  1910. hal_soc->ops->hal_reo_config(hal_soc,
  1911. reg_val,
  1912. reo_params);
  1913. }
  1914. /**
  1915. * hal_rx_msdu_get_flow_params() - API to get flow index,
  1916. * flow index invalid and flow index timeout from rx_msdu_end TLV
  1917. * @hal_soc_hdl: HAL SOC handle
  1918. * @buf: pointer to the start of RX PKT TLV headers
  1919. * @flow_invalid: pointer to return value of flow_idx_valid
  1920. * @flow_timeout: pointer to return value of flow_idx_timeout
  1921. * @flow_index: pointer to return value of flow_idx
  1922. *
  1923. * Return: none
  1924. */
  1925. static inline void
  1926. hal_rx_msdu_get_flow_params(hal_soc_handle_t hal_soc_hdl,
  1927. uint8_t *buf,
  1928. bool *flow_invalid,
  1929. bool *flow_timeout,
  1930. uint32_t *flow_index)
  1931. {
  1932. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1933. hal_soc->ops->hal_rx_msdu_get_flow_params(buf,
  1934. flow_invalid,
  1935. flow_timeout,
  1936. flow_index);
  1937. }
  1938. static inline
  1939. uint16_t hal_rx_tlv_get_tcp_chksum(hal_soc_handle_t hal_soc_hdl,
  1940. uint8_t *buf)
  1941. {
  1942. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1943. return hal_soc->ops->hal_rx_tlv_get_tcp_chksum(buf);
  1944. }
  1945. static inline
  1946. uint16_t hal_rx_get_rx_sequence(hal_soc_handle_t hal_soc_hdl,
  1947. uint8_t *buf)
  1948. {
  1949. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1950. return hal_soc->ops->hal_rx_get_rx_sequence(buf);
  1951. }
  1952. static inline void
  1953. hal_rx_get_bb_info(hal_soc_handle_t hal_soc_hdl,
  1954. void *rx_tlv,
  1955. void *ppdu_info)
  1956. {
  1957. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1958. if (hal_soc->ops->hal_rx_get_bb_info)
  1959. hal_soc->ops->hal_rx_get_bb_info(rx_tlv, ppdu_info);
  1960. }
  1961. static inline void
  1962. hal_rx_get_rtt_info(hal_soc_handle_t hal_soc_hdl,
  1963. void *rx_tlv,
  1964. void *ppdu_info)
  1965. {
  1966. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1967. if (hal_soc->ops->hal_rx_get_rtt_info)
  1968. hal_soc->ops->hal_rx_get_rtt_info(rx_tlv, ppdu_info);
  1969. }
  1970. /**
  1971. * hal_rx_msdu_metadata_get() - API to get the
  1972. * fast path information from rx_msdu_end TLV
  1973. *
  1974. * @hal_soc_hdl: DP soc handle
  1975. * @buf: pointer to the start of RX PKT TLV headers
  1976. * @msdu_md: Structure to hold msdu end information
  1977. * Return: none
  1978. */
  1979. static inline void
  1980. hal_rx_msdu_metadata_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  1981. struct hal_rx_msdu_metadata *msdu_md)
  1982. {
  1983. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1984. return hal_soc->ops->hal_rx_msdu_packet_metadata_get(buf, msdu_md);
  1985. }
  1986. /**
  1987. * hal_rx_get_fisa_cumulative_l4_checksum() - API to get cumulative_l4_checksum
  1988. * from rx_msdu_end TLV
  1989. * @hal_soc_hdl: HAL SOC handle
  1990. * @buf: pointer to the start of RX PKT TLV headers
  1991. *
  1992. * Return: cumulative_l4_checksum
  1993. */
  1994. static inline uint16_t
  1995. hal_rx_get_fisa_cumulative_l4_checksum(hal_soc_handle_t hal_soc_hdl,
  1996. uint8_t *buf)
  1997. {
  1998. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1999. if (!hal_soc || !hal_soc->ops) {
  2000. hal_err("hal handle is NULL");
  2001. QDF_BUG(0);
  2002. return 0;
  2003. }
  2004. if (!hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum)
  2005. return 0;
  2006. return hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum(buf);
  2007. }
  2008. /**
  2009. * hal_rx_get_fisa_cumulative_ip_length() - API to get cumulative_ip_length
  2010. * from rx_msdu_end TLV
  2011. * @hal_soc_hdl: HAL SOC handle
  2012. * @buf: pointer to the start of RX PKT TLV headers
  2013. *
  2014. * Return: cumulative_ip_length
  2015. */
  2016. static inline uint16_t
  2017. hal_rx_get_fisa_cumulative_ip_length(hal_soc_handle_t hal_soc_hdl,
  2018. uint8_t *buf)
  2019. {
  2020. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2021. if (!hal_soc || !hal_soc->ops) {
  2022. hal_err("hal handle is NULL");
  2023. QDF_BUG(0);
  2024. return 0;
  2025. }
  2026. if (hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length)
  2027. return hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length(buf);
  2028. return 0;
  2029. }
  2030. /**
  2031. * hal_rx_get_udp_proto() - API to get UDP proto field
  2032. * from rx_msdu_start TLV
  2033. * @hal_soc_hdl: HAL SOC handle
  2034. * @buf: pointer to the start of RX PKT TLV headers
  2035. *
  2036. * Return: UDP proto field value
  2037. */
  2038. static inline bool
  2039. hal_rx_get_udp_proto(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2040. {
  2041. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2042. if (!hal_soc || !hal_soc->ops) {
  2043. hal_err("hal handle is NULL");
  2044. QDF_BUG(0);
  2045. return 0;
  2046. }
  2047. if (hal_soc->ops->hal_rx_get_udp_proto)
  2048. return hal_soc->ops->hal_rx_get_udp_proto(buf);
  2049. return 0;
  2050. }
  2051. /**
  2052. * hal_rx_get_fisa_flow_agg_continuation() - API to get fisa
  2053. * flow_agg_continuation from rx_msdu_end TLV
  2054. * @hal_soc_hdl: HAL SOC handle
  2055. * @buf: pointer to the start of RX PKT TLV headers
  2056. *
  2057. * Return: flow_agg_continuation bit field value
  2058. */
  2059. static inline bool
  2060. hal_rx_get_fisa_flow_agg_continuation(hal_soc_handle_t hal_soc_hdl,
  2061. uint8_t *buf)
  2062. {
  2063. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2064. if (!hal_soc || !hal_soc->ops) {
  2065. hal_err("hal handle is NULL");
  2066. QDF_BUG(0);
  2067. return 0;
  2068. }
  2069. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation)
  2070. return hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation(buf);
  2071. return 0;
  2072. }
  2073. /**
  2074. * hal_rx_get_fisa_flow_agg_count() - API to get fisa flow_agg count from
  2075. * rx_msdu_end TLV
  2076. * @hal_soc_hdl: HAL SOC handle
  2077. * @buf: pointer to the start of RX PKT TLV headers
  2078. *
  2079. * Return: flow_agg count value
  2080. */
  2081. static inline uint8_t
  2082. hal_rx_get_fisa_flow_agg_count(hal_soc_handle_t hal_soc_hdl,
  2083. uint8_t *buf)
  2084. {
  2085. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2086. if (!hal_soc || !hal_soc->ops) {
  2087. hal_err("hal handle is NULL");
  2088. QDF_BUG(0);
  2089. return 0;
  2090. }
  2091. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_count)
  2092. return hal_soc->ops->hal_rx_get_fisa_flow_agg_count(buf);
  2093. return 0;
  2094. }
  2095. /**
  2096. * hal_rx_get_fisa_timeout() - API to get fisa time out from rx_msdu_end TLV
  2097. * @hal_soc_hdl: HAL SOC handle
  2098. * @buf: pointer to the start of RX PKT TLV headers
  2099. *
  2100. * Return: fisa flow_agg timeout bit value
  2101. */
  2102. static inline bool
  2103. hal_rx_get_fisa_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2104. {
  2105. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2106. if (!hal_soc || !hal_soc->ops) {
  2107. hal_err("hal handle is NULL");
  2108. QDF_BUG(0);
  2109. return 0;
  2110. }
  2111. if (hal_soc->ops->hal_rx_get_fisa_timeout)
  2112. return hal_soc->ops->hal_rx_get_fisa_timeout(buf);
  2113. return 0;
  2114. }
  2115. /**
  2116. * hal_rx_mpdu_start_tlv_tag_valid() - API to check if RX_MPDU_START tlv
  2117. * tag is valid
  2118. *
  2119. * @hal_soc_hdl: HAL SOC handle
  2120. * @rx_tlv_hdr: start address of rx_pkt_tlvs
  2121. *
  2122. * Return: true if RX_MPDU_START tlv tag is valid, else false
  2123. */
  2124. static inline uint8_t
  2125. hal_rx_mpdu_start_tlv_tag_valid(hal_soc_handle_t hal_soc_hdl,
  2126. void *rx_tlv_hdr)
  2127. {
  2128. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2129. if (hal->ops->hal_rx_mpdu_start_tlv_tag_valid)
  2130. return hal->ops->hal_rx_mpdu_start_tlv_tag_valid(rx_tlv_hdr);
  2131. return 0;
  2132. }
  2133. /**
  2134. * hal_rx_get_next_msdu_link_desc_buf_addr_info() - get next msdu link desc
  2135. * buffer addr info
  2136. * @link_desc_va: pointer to current msdu link Desc
  2137. * @next_addr_info: buffer to save next msdu link Desc buffer addr info
  2138. *
  2139. * return: None
  2140. */
  2141. static inline void hal_rx_get_next_msdu_link_desc_buf_addr_info(
  2142. void *link_desc_va,
  2143. struct buffer_addr_info *next_addr_info)
  2144. {
  2145. struct rx_msdu_link *msdu_link = link_desc_va;
  2146. if (!msdu_link) {
  2147. qdf_mem_zero(next_addr_info, sizeof(struct buffer_addr_info));
  2148. return;
  2149. }
  2150. *next_addr_info = msdu_link->next_msdu_link_desc_addr_info;
  2151. }
  2152. /**
  2153. * hal_rx_clear_next_msdu_link_desc_buf_addr_info() - clear next msdu link desc
  2154. * buffer addr info
  2155. * @link_desc_va: pointer to current msdu link Desc
  2156. *
  2157. * return: None
  2158. */
  2159. static inline
  2160. void hal_rx_clear_next_msdu_link_desc_buf_addr_info(void *link_desc_va)
  2161. {
  2162. struct rx_msdu_link *msdu_link = link_desc_va;
  2163. if (msdu_link)
  2164. qdf_mem_zero(&msdu_link->next_msdu_link_desc_addr_info,
  2165. sizeof(msdu_link->next_msdu_link_desc_addr_info));
  2166. }
  2167. /**
  2168. * hal_rx_is_buf_addr_info_valid() - check is the buf_addr_info valid
  2169. *
  2170. * @buf_addr_info: pointer to buf_addr_info structure
  2171. *
  2172. * return: true: has valid paddr, false: not.
  2173. */
  2174. static inline
  2175. bool hal_rx_is_buf_addr_info_valid(struct buffer_addr_info *buf_addr_info)
  2176. {
  2177. return (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) == 0) ?
  2178. false : true;
  2179. }
  2180. /**
  2181. * hal_rx_msdu_end_offset_get() - Get the MSDU end offset from
  2182. * rx_pkt_tlvs structure
  2183. *
  2184. * @hal_soc_hdl: HAL SOC handle
  2185. * return: msdu_end_tlv offset value
  2186. */
  2187. static inline
  2188. uint32_t hal_rx_msdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  2189. {
  2190. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2191. if (!hal_soc || !hal_soc->ops) {
  2192. hal_err("hal handle is NULL");
  2193. QDF_BUG(0);
  2194. return 0;
  2195. }
  2196. return hal_soc->ops->hal_rx_msdu_end_offset_get();
  2197. }
  2198. /**
  2199. * hal_rx_msdu_start_offset_get() - Get the MSDU start offset from
  2200. * rx_pkt_tlvs structure
  2201. *
  2202. * @hal_soc_hdl: HAL SOC handle
  2203. * return: msdu_start_tlv offset value
  2204. */
  2205. static inline
  2206. uint32_t hal_rx_msdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  2207. {
  2208. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2209. if (!hal_soc || !hal_soc->ops) {
  2210. hal_err("hal handle is NULL");
  2211. QDF_BUG(0);
  2212. return 0;
  2213. }
  2214. return hal_soc->ops->hal_rx_msdu_start_offset_get();
  2215. }
  2216. /**
  2217. * hal_rx_mpdu_start_offset_get() - Get the MPDU start offset from
  2218. * rx_pkt_tlvs structure
  2219. *
  2220. * @hal_soc_hdl: HAL SOC handle
  2221. * return: mpdu_start_tlv offset value
  2222. */
  2223. static inline
  2224. uint32_t hal_rx_mpdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  2225. {
  2226. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2227. if (!hal_soc || !hal_soc->ops) {
  2228. hal_err("hal handle is NULL");
  2229. QDF_BUG(0);
  2230. return 0;
  2231. }
  2232. return hal_soc->ops->hal_rx_mpdu_start_offset_get();
  2233. }
  2234. static inline
  2235. uint32_t hal_rx_pkt_tlv_offset_get(hal_soc_handle_t hal_soc_hdl)
  2236. {
  2237. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2238. if (!hal_soc || !hal_soc->ops) {
  2239. hal_err("hal handle is NULL");
  2240. QDF_BUG(0);
  2241. return 0;
  2242. }
  2243. return hal_soc->ops->hal_rx_pkt_tlv_offset_get();
  2244. }
  2245. /**
  2246. * hal_rx_mpdu_end_offset_get() - Get the MPDU end offset from
  2247. * rx_pkt_tlvs structure
  2248. *
  2249. * @hal_soc_hdl: HAL SOC handle
  2250. * return: mpdu_end_tlv offset value
  2251. */
  2252. static inline
  2253. uint32_t hal_rx_mpdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  2254. {
  2255. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2256. if (!hal_soc || !hal_soc->ops) {
  2257. hal_err("hal handle is NULL");
  2258. QDF_BUG(0);
  2259. return 0;
  2260. }
  2261. return hal_soc->ops->hal_rx_mpdu_end_offset_get();
  2262. }
  2263. #ifdef CONFIG_WORD_BASED_TLV
  2264. /**
  2265. * hal_rx_mpdu_start_wmask_get() - Get the MPDU start word mask
  2266. *
  2267. * @hal_soc_hdl: HAL SOC handle
  2268. * return: mpdu_start_tlv word mask value
  2269. */
  2270. static inline
  2271. uint32_t hal_rx_mpdu_start_wmask_get(hal_soc_handle_t hal_soc_hdl)
  2272. {
  2273. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2274. if (!hal_soc || !hal_soc->ops) {
  2275. hal_err("hal handle is NULL");
  2276. QDF_BUG(0);
  2277. return 0;
  2278. }
  2279. return hal_soc->ops->hal_rx_mpdu_start_wmask_get();
  2280. }
  2281. /**
  2282. * hal_rx_msdu_end_wmask_get() - Get the MSDU END word mask
  2283. *
  2284. * @hal_soc_hdl: HAL SOC handle
  2285. * return: msdu_end_tlv word mask value
  2286. */
  2287. static inline
  2288. uint32_t hal_rx_msdu_end_wmask_get(hal_soc_handle_t hal_soc_hdl)
  2289. {
  2290. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2291. if (!hal_soc || !hal_soc->ops) {
  2292. hal_err("hal handle is NULL");
  2293. QDF_BUG(0);
  2294. return 0;
  2295. }
  2296. return hal_soc->ops->hal_rx_msdu_end_wmask_get();
  2297. }
  2298. #endif
  2299. /**
  2300. * hal_rx_attn_offset_get() - Get the ATTENTION offset from
  2301. * rx_pkt_tlvs structure
  2302. *
  2303. * @hal_soc_hdl: HAL SOC handle
  2304. * return: attn_tlv offset value
  2305. */
  2306. static inline
  2307. uint32_t hal_rx_attn_offset_get(hal_soc_handle_t hal_soc_hdl)
  2308. {
  2309. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2310. if (!hal_soc || !hal_soc->ops) {
  2311. hal_err("hal handle is NULL");
  2312. QDF_BUG(0);
  2313. return 0;
  2314. }
  2315. return hal_soc->ops->hal_rx_attn_offset_get();
  2316. }
  2317. /**
  2318. * hal_rx_msdu_ext_desc_info_get_ptr() - Get msdu extension desc info ptr
  2319. * @msdu_details_ptr: Pointer to msdu_details_ptr
  2320. * @hal_soc: pointer to hal_soc
  2321. *
  2322. * Return: Pointer to rx_msdu_desc_info structure.
  2323. *
  2324. */
  2325. static inline
  2326. void *hal_rx_msdu_ext_desc_info_get_ptr(void *msdu_details_ptr,
  2327. struct hal_soc *hal_soc)
  2328. {
  2329. return hal_soc->ops->hal_rx_msdu_ext_desc_info_get_ptr(
  2330. msdu_details_ptr);
  2331. }
  2332. static inline void
  2333. hal_rx_dump_pkt_tlvs(hal_soc_handle_t hal_soc_hdl,
  2334. uint8_t *buf, uint8_t dbg_level)
  2335. {
  2336. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2337. hal_soc->ops->hal_rx_dump_pkt_tlvs(hal_soc_hdl, buf, dbg_level);
  2338. }
  2339. //TODO - Change the names to not include tlv names
  2340. static inline uint16_t
  2341. hal_rx_attn_phy_ppdu_id_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2342. {
  2343. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2344. return hal_soc->ops->hal_rx_tlv_phy_ppdu_id_get(buf);
  2345. }
  2346. static inline uint32_t
  2347. hal_rx_attn_msdu_done_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2348. {
  2349. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2350. return hal_soc->ops->hal_rx_tlv_msdu_done_get(buf);
  2351. }
  2352. static inline uint32_t
  2353. hal_rx_msdu_start_msdu_len_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2354. {
  2355. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2356. return hal_soc->ops->hal_rx_tlv_msdu_len_get(buf);
  2357. }
  2358. static inline uint16_t
  2359. hal_rx_get_frame_ctrl_field(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2360. {
  2361. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2362. return hal_soc->ops->hal_rx_get_frame_ctrl_field(buf);
  2363. }
  2364. static inline int
  2365. hal_rx_tlv_get_offload_info(hal_soc_handle_t hal_soc_hdl,
  2366. uint8_t *rx_pkt_tlv,
  2367. struct hal_offload_info *offload_info)
  2368. {
  2369. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2370. return hal_soc->ops->hal_rx_tlv_get_offload_info(rx_pkt_tlv,
  2371. offload_info);
  2372. }
  2373. static inline int
  2374. hal_rx_get_proto_params(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  2375. void *proto_params)
  2376. {
  2377. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2378. return hal_soc->ops->hal_rx_get_proto_params(buf, proto_params);
  2379. }
  2380. static inline int
  2381. hal_rx_get_l3_l4_offsets(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  2382. uint32_t *l3_hdr_offset, uint32_t *l4_hdr_offset)
  2383. {
  2384. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2385. return hal_soc->ops->hal_rx_get_l3_l4_offsets(buf,
  2386. l3_hdr_offset,
  2387. l4_hdr_offset);
  2388. }
  2389. static inline uint32_t
  2390. hal_rx_tlv_mic_err_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2391. {
  2392. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2393. return hal_soc->ops->hal_rx_tlv_mic_err_get(buf);
  2394. }
  2395. /**
  2396. * hal_rx_tlv_get_pkt_type() - API to get the pkt type
  2397. * from rx_msdu_start
  2398. * @hal_soc_hdl: hal_soc handle
  2399. * @buf: pointer to the start of RX PKT TLV header
  2400. * Return: uint32_t(pkt type)
  2401. */
  2402. static inline uint32_t
  2403. hal_rx_tlv_get_pkt_type(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2404. {
  2405. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2406. return hal_soc->ops->hal_rx_tlv_get_pkt_type(buf);
  2407. }
  2408. static inline void
  2409. hal_rx_tlv_get_pn_num(hal_soc_handle_t hal_soc_hdl,
  2410. uint8_t *buf, uint64_t *pn_num)
  2411. {
  2412. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2413. hal_soc->ops->hal_rx_tlv_get_pn_num(buf, pn_num);
  2414. }
  2415. static inline uint8_t *
  2416. hal_get_reo_ent_desc_qdesc_addr(hal_soc_handle_t hal_soc_hdl, uint8_t *desc)
  2417. {
  2418. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2419. if (hal_soc->ops->hal_get_reo_ent_desc_qdesc_addr)
  2420. return hal_soc->ops->hal_get_reo_ent_desc_qdesc_addr(desc);
  2421. return NULL;
  2422. }
  2423. static inline uint64_t
  2424. hal_rx_get_qdesc_addr(hal_soc_handle_t hal_soc_hdl, uint8_t *dst_ring_desc,
  2425. uint8_t *buf)
  2426. {
  2427. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2428. if (hal_soc->ops->hal_rx_get_qdesc_addr)
  2429. return hal_soc->ops->hal_rx_get_qdesc_addr(dst_ring_desc, buf);
  2430. return 0;
  2431. }
  2432. static inline void
  2433. hal_set_reo_ent_desc_reo_dest_ind(hal_soc_handle_t hal_soc_hdl,
  2434. uint8_t *desc, uint32_t dst_ind)
  2435. {
  2436. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2437. if (hal_soc->ops->hal_set_reo_ent_desc_reo_dest_ind)
  2438. hal_soc->ops->hal_set_reo_ent_desc_reo_dest_ind(desc, dst_ind);
  2439. }
  2440. static inline uint32_t
  2441. hal_rx_tlv_get_is_decrypted(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2442. {
  2443. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2444. if (hal_soc->ops->hal_rx_tlv_get_is_decrypted)
  2445. return hal_soc->ops->hal_rx_tlv_get_is_decrypted(buf);
  2446. return 0;
  2447. }
  2448. static inline uint8_t *
  2449. hal_rx_pkt_hdr_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2450. {
  2451. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2452. return hal_soc->ops->hal_rx_pkt_hdr_get(buf);
  2453. }
  2454. static inline uint8_t
  2455. hal_rx_msdu_get_keyid(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2456. {
  2457. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2458. if (hal_soc->ops->hal_rx_msdu_get_keyid)
  2459. return hal_soc->ops->hal_rx_msdu_get_keyid(buf);
  2460. return 0;
  2461. }
  2462. static inline uint32_t
  2463. hal_rx_tlv_get_freq(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2464. {
  2465. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2466. if (hal_soc->ops->hal_rx_tlv_get_freq)
  2467. return hal_soc->ops->hal_rx_tlv_get_freq(buf);
  2468. return 0;
  2469. }
  2470. static inline void hal_mpdu_desc_info_set(hal_soc_handle_t hal_soc_hdl,
  2471. void *desc,
  2472. void *mpdu_desc_info,
  2473. uint32_t val)
  2474. {
  2475. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2476. if (hal_soc->ops->hal_mpdu_desc_info_set)
  2477. return hal_soc->ops->hal_mpdu_desc_info_set(
  2478. hal_soc_hdl, desc, mpdu_desc_info, val);
  2479. }
  2480. static inline void hal_msdu_desc_info_set(hal_soc_handle_t hal_soc_hdl,
  2481. void *msdu_desc_info,
  2482. uint32_t val, uint32_t nbuf_len)
  2483. {
  2484. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2485. if (hal_soc->ops->hal_msdu_desc_info_set)
  2486. return hal_soc->ops->hal_msdu_desc_info_set(
  2487. hal_soc_hdl, msdu_desc_info, val, nbuf_len);
  2488. }
  2489. static inline uint32_t
  2490. hal_rx_msdu_reo_dst_ind_get(hal_soc_handle_t hal_soc_hdl, void *msdu_link_desc)
  2491. {
  2492. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2493. if (hal_soc->ops->hal_rx_msdu_reo_dst_ind_get)
  2494. return hal_soc->ops->hal_rx_msdu_reo_dst_ind_get(
  2495. hal_soc_hdl, msdu_link_desc);
  2496. return 0;
  2497. }
  2498. static inline uint32_t
  2499. hal_rx_tlv_sgi_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2500. {
  2501. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2502. return hal_soc->ops->hal_rx_tlv_sgi_get(buf);
  2503. }
  2504. static inline uint32_t
  2505. hal_rx_tlv_rate_mcs_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2506. {
  2507. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2508. return hal_soc->ops->hal_rx_tlv_rate_mcs_get(buf);
  2509. }
  2510. static inline uint32_t
  2511. hal_rx_tlv_decrypt_err_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2512. {
  2513. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2514. return hal_soc->ops->hal_rx_tlv_decrypt_err_get(buf);
  2515. }
  2516. static inline uint32_t
  2517. hal_rx_tlv_first_mpdu_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2518. {
  2519. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2520. return hal_soc->ops->hal_rx_tlv_first_mpdu_get(buf);
  2521. }
  2522. static inline uint32_t
  2523. hal_rx_tlv_bw_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2524. {
  2525. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2526. return hal_soc->ops->hal_rx_tlv_bw_get(buf);
  2527. }
  2528. static inline uint32_t
  2529. hal_rx_wbm_err_src_get(hal_soc_handle_t hal_soc_hdl,
  2530. hal_ring_desc_t ring_desc)
  2531. {
  2532. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2533. return hal_soc->ops->hal_rx_wbm_err_src_get(ring_desc);
  2534. }
  2535. /**
  2536. * hal_rx_ret_buf_manager_get() - Returns the "return_buffer_manager"
  2537. * from the BUFFER_ADDR_INFO structure
  2538. * given a REO destination ring descriptor.
  2539. * @hal_soc_hdl: hal soc handle
  2540. * @ring_desc: RX(REO/WBM release) destination ring descriptor
  2541. *
  2542. * Return: uint8_t (value of the return_buffer_manager)
  2543. */
  2544. static inline uint8_t
  2545. hal_rx_ret_buf_manager_get(hal_soc_handle_t hal_soc_hdl,
  2546. hal_ring_desc_t ring_desc)
  2547. {
  2548. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2549. return hal_soc->ops->hal_rx_ret_buf_manager_get(ring_desc);
  2550. }
  2551. /**
  2552. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  2553. * rxdma ring entry.
  2554. * @hal_soc_hdl: hal soc handle
  2555. * @rxdma_entry: descriptor entry
  2556. * @paddr: physical address of nbuf data pointer.
  2557. * @cookie: SW cookie used as a index to SW rx desc.
  2558. * @manager: who owns the nbuf (host, NSS, etc...).
  2559. *
  2560. */
  2561. static inline void hal_rxdma_buff_addr_info_set(hal_soc_handle_t hal_soc_hdl,
  2562. void *rxdma_entry,
  2563. qdf_dma_addr_t paddr,
  2564. uint32_t cookie,
  2565. uint8_t manager)
  2566. {
  2567. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2568. return hal_soc->ops->hal_rxdma_buff_addr_info_set(rxdma_entry,
  2569. paddr,
  2570. cookie,
  2571. manager);
  2572. }
  2573. static inline uint32_t
  2574. hal_rx_get_reo_error_code(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2575. {
  2576. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2577. return hal_soc->ops->hal_rx_get_reo_error_code(rx_desc);
  2578. }
  2579. static inline void
  2580. hal_rx_tlv_csum_err_get(hal_soc_handle_t hal_soc_hdl, uint8_t *rx_tlv_hdr,
  2581. uint32_t *ip_csum_err, uint32_t *tcp_udp_csum_err)
  2582. {
  2583. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2584. return hal_soc->ops->hal_rx_tlv_csum_err_get(rx_tlv_hdr,
  2585. ip_csum_err,
  2586. tcp_udp_csum_err);
  2587. }
  2588. static inline void
  2589. hal_rx_tlv_get_pkt_capture_flags(hal_soc_handle_t hal_soc_hdl,
  2590. uint8_t *rx_tlv_hdr,
  2591. struct hal_rx_pkt_capture_flags *flags)
  2592. {
  2593. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2594. return hal_soc->ops->hal_rx_tlv_get_pkt_capture_flags(rx_tlv_hdr,
  2595. flags);
  2596. }
  2597. static inline uint8_t
  2598. hal_rx_err_status_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2599. {
  2600. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2601. return hal_soc->ops->hal_rx_err_status_get(rx_desc);
  2602. }
  2603. static inline uint8_t
  2604. hal_rx_reo_buf_type_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2605. {
  2606. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2607. return hal_soc->ops->hal_rx_reo_buf_type_get(rx_desc);
  2608. }
  2609. /**
  2610. * hal_rx_reo_prev_pn_get() - Get the previous pn from ring descriptor.
  2611. * @hal_soc_hdl: HAL SoC handle
  2612. * @ring_desc: REO ring descriptor
  2613. * @prev_pn: Buffer to populate the previous PN
  2614. *
  2615. * Return: None
  2616. */
  2617. static inline void
  2618. hal_rx_reo_prev_pn_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t ring_desc,
  2619. uint64_t *prev_pn)
  2620. {
  2621. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2622. if (hal_soc->ops->hal_rx_reo_prev_pn_get)
  2623. return hal_soc->ops->hal_rx_reo_prev_pn_get(ring_desc, prev_pn);
  2624. }
  2625. /**
  2626. * hal_rx_mpdu_info_ampdu_flag_get() - get ampdu flag bit from rx mpdu info
  2627. * @hal_soc_hdl: hal soc handle
  2628. * @buf: pointer to rx_pkt_tlvs
  2629. *
  2630. * No input validdataion, since this function is supposed to be
  2631. * called from fastpath.
  2632. *
  2633. * Return: ampdu flag
  2634. */
  2635. static inline bool
  2636. hal_rx_mpdu_info_ampdu_flag_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2637. {
  2638. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2639. return hal_soc->ops->hal_rx_mpdu_info_ampdu_flag_get(buf);
  2640. }
  2641. #ifdef REO_SHARED_QREF_TABLE_EN
  2642. /**
  2643. * hal_reo_shared_qaddr_write() - Write REo tid queue addr
  2644. * LUT shared by SW and HW at the index given by peer id
  2645. * and tid.
  2646. *
  2647. * @hal_soc_hdl: hal soc handle
  2648. * @peer_id: peer_id
  2649. * @tid: tid queue number
  2650. * @hw_qdesc_paddr: reo queue addr
  2651. */
  2652. static inline void
  2653. hal_reo_shared_qaddr_write(hal_soc_handle_t hal_soc_hdl,
  2654. uint16_t peer_id,
  2655. int tid,
  2656. qdf_dma_addr_t hw_qdesc_paddr)
  2657. {
  2658. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2659. if (hal_soc->ops->hal_reo_shared_qaddr_write)
  2660. return hal_soc->ops->hal_reo_shared_qaddr_write(hal_soc_hdl,
  2661. peer_id, tid, hw_qdesc_paddr);
  2662. }
  2663. /**
  2664. * hal_reo_shared_qaddr_init() - Initialize reo qref LUT
  2665. * @hal_soc_hdl: Hal soc handle
  2666. * @qref_reset: reset qref LUT
  2667. *
  2668. * Write MLO and Non MLO table start addr to HW reg
  2669. *
  2670. * Return: void
  2671. */
  2672. static inline void
  2673. hal_reo_shared_qaddr_init(hal_soc_handle_t hal_soc_hdl, int qref_reset)
  2674. {
  2675. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2676. if (hal_soc->ops->hal_reo_shared_qaddr_init)
  2677. return hal_soc->ops->hal_reo_shared_qaddr_init(hal_soc_hdl,
  2678. qref_reset);
  2679. }
  2680. /**
  2681. * hal_reo_shared_qaddr_cache_clear() - Set and unset 'clear_qdesc_array'
  2682. * bit in reo reg for shared qref feature. This is done for every MLO
  2683. * connection to clear HW reo internal storage for clearing stale entry
  2684. * of prev peer having same peer id
  2685. *
  2686. * @hal_soc_hdl: Hal soc handle
  2687. *
  2688. * Write MLO and Non MLO table start addr to HW reg
  2689. *
  2690. * Return: void
  2691. */
  2692. static inline void hal_reo_shared_qaddr_cache_clear(hal_soc_handle_t hal_soc_hdl)
  2693. {
  2694. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2695. if (hal_soc->ops->hal_reo_shared_qaddr_cache_clear)
  2696. return hal_soc->ops->hal_reo_shared_qaddr_cache_clear(hal_soc_hdl);
  2697. }
  2698. #else
  2699. static inline void
  2700. hal_reo_shared_qaddr_write(hal_soc_handle_t hal_soc_hdl,
  2701. uint16_t peer_id,
  2702. int tid,
  2703. qdf_dma_addr_t hw_qdesc_paddr) {}
  2704. static inline void
  2705. hal_reo_shared_qaddr_init(hal_soc_handle_t hal_soc_hdl, int qref_reset) {}
  2706. static inline void
  2707. hal_reo_shared_qaddr_cache_clear(hal_soc_handle_t hal_soc_hdl) {}
  2708. #endif /* REO_SHARED_QREF_TABLE_EN */
  2709. static inline uint8_t
  2710. hal_reo_shared_qaddr_is_enable(hal_soc_handle_t hal_soc_hdl)
  2711. {
  2712. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2713. return hal->reo_qref.reo_qref_table_en;
  2714. }
  2715. #ifdef WLAN_FEATURE_MARK_FIRST_WAKEUP_PACKET
  2716. static inline uint8_t
  2717. hal_get_first_wow_wakeup_packet(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2718. {
  2719. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2720. return hal_soc->ops->hal_get_first_wow_wakeup_packet(buf);
  2721. }
  2722. #endif
  2723. static inline uint32_t
  2724. hal_rx_tlv_l3_type_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2725. {
  2726. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2727. return hal_soc->ops->hal_rx_tlv_l3_type_get ?
  2728. hal_soc->ops->hal_rx_tlv_l3_type_get(buf) :
  2729. HAL_RX_TLV_L3_TYPE_INVALID;
  2730. }
  2731. /**
  2732. * hal_get_tsf_time() - Get tsf time
  2733. * @hal_soc_hdl: HAL soc handle
  2734. * @tsf_id:
  2735. * @mac_id: mac_id
  2736. * @tsf: pointer to update tsf value
  2737. * @tsf_sync_soc_time: pointer to update tsf sync time
  2738. *
  2739. * Return: None.
  2740. */
  2741. static inline void
  2742. hal_get_tsf_time(hal_soc_handle_t hal_soc_hdl, uint32_t tsf_id,
  2743. uint32_t mac_id, uint64_t *tsf,
  2744. uint64_t *tsf_sync_soc_time)
  2745. {
  2746. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2747. if (hal_soc->ops->hal_get_tsf_time)
  2748. hal_soc->ops->hal_get_tsf_time(hal_soc_hdl, tsf_id, mac_id,
  2749. tsf, tsf_sync_soc_time);
  2750. }
  2751. /**
  2752. * hal_rx_en_mcast_fp_data_filter() - Is mcast filter pass enabled
  2753. * @hal_soc_hdl: HAL soc handle
  2754. *
  2755. * Return: false for BE MCC, true for WIN
  2756. */
  2757. static inline
  2758. bool hal_rx_en_mcast_fp_data_filter(hal_soc_handle_t hal_soc_hdl)
  2759. {
  2760. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2761. return hal_soc->ops->hal_rx_en_mcast_fp_data_filter();
  2762. }
  2763. /**
  2764. * hal_rx_get_phy_ppdu_id_size() - Get phy ppdu id size
  2765. * @hal_soc_hdl: HAL soc handle
  2766. *
  2767. * Return: phy ppdu id size
  2768. */
  2769. static inline uint8_t
  2770. hal_rx_get_phy_ppdu_id_size(hal_soc_handle_t hal_soc_hdl)
  2771. {
  2772. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2773. return hal_soc->ops->hal_rx_get_phy_ppdu_id_size();
  2774. }
  2775. #endif /* _HAL_RX_H */