hal_rx.h 80 KB

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