hal_rx.h 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868
  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_match_get: API to get CCE match
  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 bool
  1026. hal_rx_msdu_cce_match_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_match_get(buf);
  1031. }
  1032. /**
  1033. * hal_rx_msdu_cce_metadata_get: API to get CCE metadata
  1034. * from rx_msdu_end TLV
  1035. * @buf: pointer to the start of RX PKT TLV headers
  1036. * Return: cce_meta_data
  1037. */
  1038. static inline uint16_t
  1039. hal_rx_msdu_cce_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1040. uint8_t *buf)
  1041. {
  1042. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1043. return hal_soc->ops->hal_rx_msdu_cce_metadata_get(buf);
  1044. }
  1045. /*******************************************************************************
  1046. * RX REO ERROR APIS
  1047. ******************************************************************************/
  1048. /**
  1049. * hal_rx_link_desc_msdu0_ptr - Get pointer to rx_msdu details
  1050. * @msdu_link_ptr - msdu link ptr
  1051. * @hal - pointer to hal_soc
  1052. * Return - Pointer to rx_msdu_details structure
  1053. *
  1054. */
  1055. static inline
  1056. void *hal_rx_link_desc_msdu0_ptr(void *msdu_link_ptr,
  1057. struct hal_soc *hal_soc)
  1058. {
  1059. return hal_soc->ops->hal_rx_link_desc_msdu0_ptr(msdu_link_ptr);
  1060. }
  1061. /**
  1062. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  1063. * @msdu_details_ptr - Pointer to msdu_details_ptr
  1064. * @hal - pointer to hal_soc
  1065. * Return - Pointer to rx_msdu_desc_info structure.
  1066. *
  1067. */
  1068. static inline
  1069. void *hal_rx_msdu_desc_info_get_ptr(void *msdu_details_ptr,
  1070. struct hal_soc *hal_soc)
  1071. {
  1072. return hal_soc->ops->hal_rx_msdu_desc_info_get_ptr(msdu_details_ptr);
  1073. }
  1074. /**
  1075. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  1076. * cookie from the REO destination ring element
  1077. *
  1078. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  1079. * the current descriptor
  1080. * @ buf_info: structure to return the buffer information
  1081. * Return: void
  1082. */
  1083. static inline
  1084. void hal_rx_reo_buf_paddr_get(hal_soc_handle_t hal_soc_hdl,
  1085. hal_ring_desc_t rx_desc,
  1086. struct hal_buf_info *buf_info)
  1087. {
  1088. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1089. if (hal_soc->ops->hal_rx_reo_buf_paddr_get)
  1090. return hal_soc->ops->hal_rx_reo_buf_paddr_get(
  1091. rx_desc,
  1092. buf_info);
  1093. }
  1094. /**
  1095. * hal_rx_buf_cookie_rbm_get: Gets the physical address and
  1096. * cookie from the REO entrance ring element
  1097. *
  1098. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  1099. * the current descriptor
  1100. * @ buf_info: structure to return the buffer information
  1101. * @ msdu_cnt: pointer to msdu count in MPDU
  1102. * Return: void
  1103. */
  1104. static inline
  1105. void hal_rx_buf_cookie_rbm_get(hal_soc_handle_t hal_soc_hdl,
  1106. uint32_t *buf_addr_info,
  1107. struct hal_buf_info *buf_info)
  1108. {
  1109. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1110. return hal_soc->ops->hal_rx_buf_cookie_rbm_get(
  1111. buf_addr_info,
  1112. buf_info);
  1113. }
  1114. /**
  1115. * hal_rx_msdu_link_desc_get(): API to get the MSDU information
  1116. * from the MSDU link descriptor
  1117. *
  1118. * @msdu_link_desc: Opaque pointer used by HAL to get to the
  1119. * MSDU link descriptor (struct rx_msdu_link)
  1120. *
  1121. * @msdu_list: Return the list of MSDUs contained in this link descriptor
  1122. *
  1123. * @num_msdus: Number of MSDUs in the MPDU
  1124. *
  1125. * Return: void
  1126. */
  1127. static inline void hal_rx_msdu_list_get(hal_soc_handle_t hal_soc_hdl,
  1128. void *msdu_link_desc,
  1129. struct hal_rx_msdu_list *msdu_list,
  1130. uint16_t *num_msdus)
  1131. {
  1132. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1133. struct rx_msdu_details *msdu_details;
  1134. struct rx_msdu_desc_info *msdu_desc_info;
  1135. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1136. int i;
  1137. struct hal_buf_info buf_info;
  1138. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1139. dp_nofl_debug("[%s][%d] msdu_link=%pK msdu_details=%pK",
  1140. __func__, __LINE__, msdu_link, msdu_details);
  1141. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  1142. /* num_msdus received in mpdu descriptor may be incorrect
  1143. * sometimes due to HW issue. Check msdu buffer address also
  1144. */
  1145. if (!i && (HAL_RX_BUFFER_ADDR_31_0_GET(
  1146. &msdu_details[i].buffer_addr_info_details) == 0))
  1147. break;
  1148. if (HAL_RX_BUFFER_ADDR_31_0_GET(
  1149. &msdu_details[i].buffer_addr_info_details) == 0) {
  1150. /* set the last msdu bit in the prev msdu_desc_info */
  1151. msdu_desc_info =
  1152. hal_rx_msdu_desc_info_get_ptr(&msdu_details[i - 1], hal_soc);
  1153. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1154. break;
  1155. }
  1156. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[i],
  1157. hal_soc);
  1158. /* set first MSDU bit or the last MSDU bit */
  1159. if (!i)
  1160. HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1161. else if (i == (HAL_RX_NUM_MSDU_DESC - 1))
  1162. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1163. msdu_list->msdu_info[i].msdu_flags =
  1164. hal_rx_msdu_flags_get(hal_soc_hdl, msdu_desc_info);
  1165. msdu_list->msdu_info[i].msdu_len =
  1166. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  1167. /* addr field in buf_info will not be valid */
  1168. hal_rx_buf_cookie_rbm_get(
  1169. hal_soc_hdl,
  1170. (uint32_t *)&msdu_details[i].buffer_addr_info_details,
  1171. &buf_info);
  1172. msdu_list->sw_cookie[i] = buf_info.sw_cookie;
  1173. msdu_list->rbm[i] = buf_info.rbm;
  1174. msdu_list->paddr[i] = HAL_RX_BUFFER_ADDR_31_0_GET(
  1175. &msdu_details[i].buffer_addr_info_details) |
  1176. (uint64_t)HAL_RX_BUFFER_ADDR_39_32_GET(
  1177. &msdu_details[i].buffer_addr_info_details) << 32;
  1178. dp_nofl_debug("[%s][%d] i=%d sw_cookie=%d",
  1179. __func__, __LINE__, i, msdu_list->sw_cookie[i]);
  1180. }
  1181. *num_msdus = i;
  1182. }
  1183. /**
  1184. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  1185. * PN check failure
  1186. *
  1187. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  1188. *
  1189. * Return: true: error caused by PN check, false: other error
  1190. */
  1191. static inline bool hal_rx_reo_is_pn_error(uint32_t error_code)
  1192. {
  1193. return ((error_code == HAL_REO_ERR_PN_CHECK_FAILED) ||
  1194. (error_code == HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  1195. true : false;
  1196. }
  1197. /**
  1198. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  1199. * the sequence number
  1200. *
  1201. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1202. *
  1203. * Return: true: error caused by 2K jump, false: other error
  1204. */
  1205. static inline bool hal_rx_reo_is_2k_jump(uint32_t error_code)
  1206. {
  1207. return ((error_code == HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) ||
  1208. (error_code == HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  1209. true : false;
  1210. }
  1211. /**
  1212. * hal_rx_reo_is_oor_error() - Indicate if this error was caused by OOR
  1213. *
  1214. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1215. *
  1216. * Return: true: error caused by OOR, false: other error
  1217. */
  1218. static inline bool hal_rx_reo_is_oor_error(uint32_t error_code)
  1219. {
  1220. return (error_code == HAL_REO_ERR_REGULAR_FRAME_OOR) ?
  1221. true : false;
  1222. }
  1223. /**
  1224. * hal_rx_reo_is_bar_oor_2k_jump() - Check if the error is 2k-jump or OOR error
  1225. * @error_code: error code obtained from ring descriptor.
  1226. *
  1227. * Return: true, if the error code is 2k-jump or OOR
  1228. * false, for other error codes.
  1229. */
  1230. static inline bool hal_rx_reo_is_bar_oor_2k_jump(uint32_t error_code)
  1231. {
  1232. return ((error_code == HAL_REO_ERR_BAR_FRAME_2K_JUMP) ||
  1233. (error_code == HAL_REO_ERR_BAR_FRAME_OOR)) ?
  1234. true : false;
  1235. }
  1236. /**
  1237. * hal_dump_wbm_rel_desc() - dump wbm release descriptor
  1238. * @hal_desc: hardware descriptor pointer
  1239. *
  1240. * This function will print wbm release descriptor
  1241. *
  1242. * Return: none
  1243. */
  1244. static inline void hal_dump_wbm_rel_desc(void *src_srng_desc)
  1245. {
  1246. uint32_t *wbm_comp = (uint32_t *)src_srng_desc;
  1247. uint32_t i;
  1248. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1249. "Current Rx wbm release descriptor is");
  1250. for (i = 0; i < HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS; i++) {
  1251. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1252. "DWORD[i] = 0x%x", wbm_comp[i]);
  1253. }
  1254. }
  1255. /**
  1256. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  1257. *
  1258. * @ hal_soc_hdl : HAL version of the SOC pointer
  1259. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  1260. * @ buf_addr_info : void pointer to the buffer_addr_info
  1261. * @ bm_action : put in IDLE list or release to MSDU_LIST
  1262. *
  1263. * Return: void
  1264. */
  1265. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  1266. static inline
  1267. void hal_rx_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  1268. void *src_srng_desc,
  1269. hal_buff_addrinfo_t buf_addr_info,
  1270. uint8_t bm_action)
  1271. {
  1272. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1273. if (hal_soc->ops->hal_rx_msdu_link_desc_set)
  1274. return hal_soc->ops->hal_rx_msdu_link_desc_set(hal_soc_hdl,
  1275. src_srng_desc,
  1276. buf_addr_info,
  1277. bm_action);
  1278. }
  1279. /**
  1280. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  1281. * BUFFER_ADDR_INFO, give the RX descriptor
  1282. * (Assumption -- BUFFER_ADDR_INFO is the
  1283. * first field in the descriptor structure)
  1284. */
  1285. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) \
  1286. ((hal_link_desc_t)(ring_desc))
  1287. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1288. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1289. /*******************************************************************************
  1290. * RX WBM ERROR APIS
  1291. ******************************************************************************/
  1292. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  1293. (WBM_ERR_RING_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  1294. WBM_ERR_RING_BUFFER_OR_DESC_TYPE_MASK) >> \
  1295. WBM_ERR_RING_BUFFER_OR_DESC_TYPE_LSB)
  1296. /**
  1297. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  1298. * the frame to this release ring
  1299. *
  1300. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  1301. * frame to this queue
  1302. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  1303. * received routing instructions. No error within REO was detected
  1304. */
  1305. enum hal_rx_wbm_reo_push_reason {
  1306. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  1307. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  1308. };
  1309. /**
  1310. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  1311. * this release ring
  1312. *
  1313. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  1314. * this frame to this queue
  1315. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  1316. * per received routing instructions. No error within RXDMA was detected
  1317. */
  1318. enum hal_rx_wbm_rxdma_push_reason {
  1319. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  1320. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  1321. HAL_RX_WBM_RXDMA_PSH_RSN_FLUSH,
  1322. };
  1323. static inline void hal_rx_dump_mpdu_start_tlv(struct rx_mpdu_start *mpdu_start,
  1324. uint8_t dbg_level,
  1325. struct hal_soc *hal)
  1326. {
  1327. hal->ops->hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level);
  1328. }
  1329. /**
  1330. * hal_rx_dump_msdu_end_tlv: dump RX msdu_end TLV in structured
  1331. * human readable format.
  1332. * @ msdu_end: pointer the msdu_end TLV in pkt.
  1333. * @ dbg_level: log level.
  1334. *
  1335. * Return: void
  1336. */
  1337. static inline void hal_rx_dump_msdu_end_tlv(struct hal_soc *hal_soc,
  1338. struct rx_msdu_end *msdu_end,
  1339. uint8_t dbg_level)
  1340. {
  1341. hal_soc->ops->hal_rx_dump_msdu_end_tlv(msdu_end, dbg_level);
  1342. }
  1343. /**
  1344. * hal_srng_ring_id_get: API to retrieve ring id from hal ring
  1345. * structure
  1346. * @hal_ring: pointer to hal_srng structure
  1347. *
  1348. * Return: ring_id
  1349. */
  1350. static inline uint8_t hal_srng_ring_id_get(hal_ring_handle_t hal_ring_hdl)
  1351. {
  1352. return ((struct hal_srng *)hal_ring_hdl)->ring_id;
  1353. }
  1354. #define DOT11_SEQ_FRAG_MASK 0x000f
  1355. #define DOT11_FC1_MORE_FRAG_OFFSET 0x04
  1356. /**
  1357. * hal_rx_get_rx_fragment_number(): Function to retrieve rx fragment number
  1358. *
  1359. * @nbuf: Network buffer
  1360. * Returns: rx fragment number
  1361. */
  1362. static inline
  1363. uint8_t hal_rx_get_rx_fragment_number(struct hal_soc *hal_soc,
  1364. uint8_t *buf)
  1365. {
  1366. return hal_soc->ops->hal_rx_get_rx_fragment_number(buf);
  1367. }
  1368. /*
  1369. * hal_rx_get_mpdu_sequence_control_valid(): Get mpdu sequence control valid
  1370. * @hal_soc_hdl: hal soc handle
  1371. * @nbuf: Network buffer
  1372. *
  1373. * Return: value of sequence control valid field
  1374. */
  1375. static inline
  1376. uint8_t hal_rx_get_mpdu_sequence_control_valid(hal_soc_handle_t hal_soc_hdl,
  1377. uint8_t *buf)
  1378. {
  1379. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1380. return hal_soc->ops->hal_rx_get_mpdu_sequence_control_valid(buf);
  1381. }
  1382. /*
  1383. * hal_rx_get_mpdu_frame_control_valid(): Retrieves mpdu frame control valid
  1384. * @hal_soc_hdl: hal soc handle
  1385. * @nbuf: Network buffer
  1386. *
  1387. * Returns: value of frame control valid field
  1388. */
  1389. static inline
  1390. uint8_t hal_rx_get_mpdu_frame_control_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_frame_control_valid(buf);
  1395. }
  1396. /**
  1397. * hal_rx_get_mpdu_mac_ad4_valid(): Retrieves if mpdu 4th addr is valid
  1398. * @hal_soc_hdl: hal soc handle
  1399. * @nbuf: Network buffer
  1400. * Returns: value of mpdu 4th address valid field
  1401. */
  1402. static inline
  1403. bool hal_rx_get_mpdu_mac_ad4_valid(hal_soc_handle_t hal_soc_hdl,
  1404. uint8_t *buf)
  1405. {
  1406. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1407. return hal_soc->ops->hal_rx_get_mpdu_mac_ad4_valid(buf);
  1408. }
  1409. /*
  1410. * hal_rx_clear_mpdu_desc_info(): Clears mpdu_desc_info
  1411. *
  1412. * @rx_mpdu_desc_info: HAL view of rx mpdu desc info
  1413. * Returns: None
  1414. */
  1415. static inline void
  1416. hal_rx_clear_mpdu_desc_info(struct hal_rx_mpdu_desc_info *rx_mpdu_desc_info)
  1417. {
  1418. qdf_mem_zero(rx_mpdu_desc_info, sizeof(*rx_mpdu_desc_info));
  1419. }
  1420. /**
  1421. * hal_rx_wbm_err_info_get(): Retrieves WBM error code and reason and
  1422. * save it to hal_wbm_err_desc_info structure passed by caller
  1423. * @wbm_desc: wbm ring descriptor
  1424. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  1425. * Return: void
  1426. */
  1427. static inline
  1428. void hal_rx_wbm_err_info_get(void *wbm_desc,
  1429. struct hal_wbm_err_desc_info *wbm_er_info,
  1430. hal_soc_handle_t hal_soc_hdl)
  1431. {
  1432. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1433. hal_soc->ops->hal_rx_wbm_err_info_get(wbm_desc, (void *)wbm_er_info);
  1434. }
  1435. /**
  1436. * hal_rx_wbm_err_msdu_continuation_get(): Get wbm msdu continuation
  1437. * bit from wbm release ring descriptor
  1438. * @wbm_desc: wbm ring descriptor
  1439. * Return: uint8_t
  1440. */
  1441. static inline
  1442. uint8_t hal_rx_wbm_err_msdu_continuation_get(hal_soc_handle_t hal_soc_hdl,
  1443. void *wbm_desc)
  1444. {
  1445. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1446. return hal_soc->ops->hal_rx_wbm_err_msdu_continuation_get(wbm_desc);
  1447. }
  1448. /**
  1449. * hal_rx_mon_hw_desc_get_mpdu_status: Retrieve MPDU status
  1450. *
  1451. * @ hal_soc: HAL version of the SOC pointer
  1452. * @ hw_desc_addr: Start address of Rx HW TLVs
  1453. * @ rs: Status for monitor mode
  1454. *
  1455. * Return: void
  1456. */
  1457. static inline
  1458. void hal_rx_mon_hw_desc_get_mpdu_status(hal_soc_handle_t hal_soc_hdl,
  1459. void *hw_desc_addr,
  1460. struct mon_rx_status *rs)
  1461. {
  1462. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1463. hal_soc->ops->hal_rx_mon_hw_desc_get_mpdu_status(hw_desc_addr, rs);
  1464. }
  1465. /*
  1466. * hal_rx_get_tlv(): API to get the tlv
  1467. *
  1468. * @hal_soc: HAL version of the SOC pointer
  1469. * @rx_tlv: TLV data extracted from the rx packet
  1470. * Return: uint8_t
  1471. */
  1472. static inline uint8_t hal_rx_get_tlv(struct hal_soc *hal_soc, void *rx_tlv)
  1473. {
  1474. return hal_soc->ops->hal_rx_get_tlv(rx_tlv);
  1475. }
  1476. /*
  1477. * hal_rx_msdu_start_nss_get(): API to get the NSS
  1478. * Interval from rx_msdu_start
  1479. *
  1480. * @hal_soc: HAL version of the SOC pointer
  1481. * @buf: pointer to the start of RX PKT TLV header
  1482. * Return: uint32_t(nss)
  1483. */
  1484. static inline
  1485. uint32_t hal_rx_msdu_start_nss_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1486. {
  1487. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1488. return hal_soc->ops->hal_rx_msdu_start_nss_get(buf);
  1489. }
  1490. /**
  1491. * hal_rx_dump_msdu_start_tlv: dump RX msdu_start TLV in structured
  1492. * human readable format.
  1493. * @ msdu_start: pointer the msdu_start TLV in pkt.
  1494. * @ dbg_level: log level.
  1495. *
  1496. * Return: void
  1497. */
  1498. static inline void hal_rx_dump_msdu_start_tlv(struct hal_soc *hal_soc,
  1499. struct rx_msdu_start *msdu_start,
  1500. uint8_t dbg_level)
  1501. {
  1502. hal_soc->ops->hal_rx_dump_msdu_start_tlv(msdu_start, dbg_level);
  1503. }
  1504. /**
  1505. * hal_rx_mpdu_start_tid_get - Return tid info from the rx mpdu start
  1506. * info details
  1507. *
  1508. * @ buf - Pointer to buffer containing rx pkt tlvs.
  1509. *
  1510. *
  1511. */
  1512. static inline uint32_t hal_rx_mpdu_start_tid_get(hal_soc_handle_t hal_soc_hdl,
  1513. uint8_t *buf)
  1514. {
  1515. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1516. return hal_soc->ops->hal_rx_mpdu_start_tid_get(buf);
  1517. }
  1518. /*
  1519. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  1520. * Interval from rx_msdu_start
  1521. *
  1522. * @buf: pointer to the start of RX PKT TLV header
  1523. * Return: uint32_t(reception_type)
  1524. */
  1525. static inline
  1526. uint32_t hal_rx_msdu_start_reception_type_get(hal_soc_handle_t hal_soc_hdl,
  1527. uint8_t *buf)
  1528. {
  1529. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1530. return hal_soc->ops->hal_rx_msdu_start_reception_type_get(buf);
  1531. }
  1532. /**
  1533. * hal_reo_status_get_header_generic - Process reo desc info
  1534. * @d - Pointer to reo descriptior
  1535. * @b - tlv type info
  1536. * @h - Pointer to hal_reo_status_header where info to be stored
  1537. * @hal- pointer to hal_soc structure
  1538. * Return - none.
  1539. *
  1540. */
  1541. static inline
  1542. void hal_reo_status_get_header(hal_ring_desc_t ring_desc, int b,
  1543. void *h, struct hal_soc *hal_soc)
  1544. {
  1545. hal_soc->ops->hal_reo_status_get_header(ring_desc, b, h);
  1546. }
  1547. /**
  1548. * hal_rx_desc_is_first_msdu() - Check if first msdu
  1549. *
  1550. * @hal_soc_hdl: hal_soc handle
  1551. * @hw_desc_addr: hardware descriptor address
  1552. *
  1553. * Return: 0 - success/ non-zero failure
  1554. */
  1555. static inline
  1556. uint32_t hal_rx_desc_is_first_msdu(hal_soc_handle_t hal_soc_hdl,
  1557. void *hw_desc_addr)
  1558. {
  1559. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1560. return hal_soc->ops->hal_rx_desc_is_first_msdu(hw_desc_addr);
  1561. }
  1562. /**
  1563. * hal_rx_tlv_populate_mpdu_desc_info() - Populate mpdu_desc_info fields from
  1564. * the rx tlv fields.
  1565. * @hal_soc_hdl: HAL SoC handle
  1566. * @buf: rx tlv start address [To be validated by caller]
  1567. * @mpdu_desc_info_hdl: Buffer where the mpdu_desc_info is to be populated.
  1568. *
  1569. * Return: None
  1570. */
  1571. static inline void
  1572. hal_rx_tlv_populate_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1573. uint8_t *buf,
  1574. void *mpdu_desc_info_hdl)
  1575. {
  1576. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1577. if (hal_soc->ops->hal_rx_tlv_populate_mpdu_desc_info)
  1578. return hal_soc->ops->hal_rx_tlv_populate_mpdu_desc_info(buf,
  1579. mpdu_desc_info_hdl);
  1580. }
  1581. static inline uint32_t
  1582. hal_rx_tlv_decap_format_get(hal_soc_handle_t hal_soc_hdl, void *hw_desc_addr)
  1583. {
  1584. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1585. return hal_soc->ops->hal_rx_tlv_decap_format_get(hw_desc_addr);
  1586. }
  1587. static inline
  1588. bool HAL_IS_DECAP_FORMAT_RAW(hal_soc_handle_t hal_soc_hdl,
  1589. uint8_t *rx_tlv_hdr)
  1590. {
  1591. uint8_t decap_format;
  1592. if (hal_rx_desc_is_first_msdu(hal_soc_hdl, rx_tlv_hdr)) {
  1593. decap_format = hal_rx_tlv_decap_format_get(hal_soc_hdl,
  1594. rx_tlv_hdr);
  1595. if (decap_format == HAL_HW_RX_DECAP_FORMAT_RAW)
  1596. return true;
  1597. }
  1598. return false;
  1599. }
  1600. /**
  1601. * hal_rx_msdu_fse_metadata_get: API to get FSE metadata
  1602. * from rx_msdu_end TLV
  1603. * @buf: pointer to the start of RX PKT TLV headers
  1604. *
  1605. * Return: fse metadata value from MSDU END TLV
  1606. */
  1607. static inline uint32_t
  1608. hal_rx_msdu_fse_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1609. uint8_t *buf)
  1610. {
  1611. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1612. return hal_soc->ops->hal_rx_msdu_fse_metadata_get(buf);
  1613. }
  1614. /**
  1615. * hal_rx_buffer_addr_info_get_paddr(): get paddr/sw_cookie from
  1616. * <struct buffer_addr_info> structure
  1617. * @buf_addr_info: pointer to <struct buffer_addr_info> structure
  1618. * @buf_info: structure to return the buffer information including
  1619. * paddr/cookie
  1620. *
  1621. * return: None
  1622. */
  1623. static inline
  1624. void hal_rx_buffer_addr_info_get_paddr(void *buf_addr_info,
  1625. struct hal_buf_info *buf_info)
  1626. {
  1627. buf_info->paddr =
  1628. (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) |
  1629. ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(buf_addr_info)) << 32));
  1630. }
  1631. /**
  1632. * hal_rx_msdu_flow_idx_get: API to get flow index
  1633. * from rx_msdu_end TLV
  1634. * @buf: pointer to the start of RX PKT TLV headers
  1635. *
  1636. * Return: flow index value from MSDU END TLV
  1637. */
  1638. static inline uint32_t
  1639. hal_rx_msdu_flow_idx_get(hal_soc_handle_t hal_soc_hdl,
  1640. uint8_t *buf)
  1641. {
  1642. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1643. return hal_soc->ops->hal_rx_msdu_flow_idx_get(buf);
  1644. }
  1645. /**
  1646. * hal_rx_msdu_get_reo_destination_indication: API to get reo
  1647. * destination index from rx_msdu_end TLV
  1648. * @buf: pointer to the start of RX PKT TLV headers
  1649. * @reo_destination_indication: pointer to return value of
  1650. * reo_destination_indication
  1651. *
  1652. * Return: reo_destination_indication value from MSDU END TLV
  1653. */
  1654. static inline void
  1655. hal_rx_msdu_get_reo_destination_indication(hal_soc_handle_t hal_soc_hdl,
  1656. uint8_t *buf,
  1657. uint32_t *reo_destination_indication)
  1658. {
  1659. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1660. hal_soc->ops->hal_rx_msdu_get_reo_destination_indication(buf,
  1661. reo_destination_indication);
  1662. }
  1663. /**
  1664. * hal_rx_msdu_flow_idx_timeout: API to get flow index timeout
  1665. * from rx_msdu_end TLV
  1666. * @buf: pointer to the start of RX PKT TLV headers
  1667. *
  1668. * Return: flow index timeout value from MSDU END TLV
  1669. */
  1670. static inline bool
  1671. hal_rx_msdu_flow_idx_timeout(hal_soc_handle_t hal_soc_hdl,
  1672. uint8_t *buf)
  1673. {
  1674. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1675. return hal_soc->ops->hal_rx_msdu_flow_idx_timeout(buf);
  1676. }
  1677. /**
  1678. * hal_rx_msdu_flow_idx_invalid: API to get flow index invalid
  1679. * from rx_msdu_end TLV
  1680. * @buf: pointer to the start of RX PKT TLV headers
  1681. *
  1682. * Return: flow index invalid value from MSDU END TLV
  1683. */
  1684. static inline bool
  1685. hal_rx_msdu_flow_idx_invalid(hal_soc_handle_t hal_soc_hdl,
  1686. uint8_t *buf)
  1687. {
  1688. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1689. return hal_soc->ops->hal_rx_msdu_flow_idx_invalid(buf);
  1690. }
  1691. /**
  1692. * hal_rx_hw_desc_get_ppduid_get() - Retrieve ppdu id
  1693. * @hal_soc_hdl: hal_soc handle
  1694. * @rx_tlv_hdr: Rx_tlv_hdr
  1695. * @rxdma_dst_ring_desc: Rx HW descriptor
  1696. *
  1697. * Return: ppdu id
  1698. */
  1699. static inline
  1700. uint32_t hal_rx_hw_desc_get_ppduid_get(hal_soc_handle_t hal_soc_hdl,
  1701. void *rx_tlv_hdr,
  1702. void *rxdma_dst_ring_desc)
  1703. {
  1704. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1705. return hal_soc->ops->hal_rx_hw_desc_get_ppduid_get(rx_tlv_hdr,
  1706. rxdma_dst_ring_desc);
  1707. }
  1708. /**
  1709. * hal_rx_msdu_end_sa_sw_peer_id_get() - get sw peer id
  1710. * @hal_soc_hdl: hal_soc handle
  1711. * @buf: rx tlv address
  1712. *
  1713. * Return: sw peer id
  1714. */
  1715. static inline
  1716. uint32_t hal_rx_msdu_end_sa_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  1717. uint8_t *buf)
  1718. {
  1719. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1720. return hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get(buf);
  1721. }
  1722. static inline
  1723. void *hal_rx_msdu0_buffer_addr_lsb(hal_soc_handle_t hal_soc_hdl,
  1724. void *link_desc_addr)
  1725. {
  1726. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1727. return hal_soc->ops->hal_rx_msdu0_buffer_addr_lsb(link_desc_addr);
  1728. }
  1729. static inline
  1730. void *hal_rx_msdu_desc_info_ptr_get(hal_soc_handle_t hal_soc_hdl,
  1731. void *msdu_addr)
  1732. {
  1733. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1734. return hal_soc->ops->hal_rx_msdu_desc_info_ptr_get(msdu_addr);
  1735. }
  1736. static inline
  1737. void *hal_ent_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1738. void *hw_addr)
  1739. {
  1740. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1741. return hal_soc->ops->hal_ent_mpdu_desc_info(hw_addr);
  1742. }
  1743. static inline
  1744. void *hal_dst_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  1745. void *hw_addr)
  1746. {
  1747. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1748. return hal_soc->ops->hal_dst_mpdu_desc_info(hw_addr);
  1749. }
  1750. static inline
  1751. uint8_t hal_rx_get_fc_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_fc_valid(buf);
  1756. }
  1757. static inline
  1758. uint8_t hal_rx_get_to_ds_flag(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1759. {
  1760. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1761. return hal_soc->ops->hal_rx_get_to_ds_flag(buf);
  1762. }
  1763. static inline
  1764. uint8_t hal_rx_get_mac_addr2_valid(hal_soc_handle_t hal_soc_hdl,
  1765. uint8_t *buf)
  1766. {
  1767. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1768. return hal_soc->ops->hal_rx_get_mac_addr2_valid(buf);
  1769. }
  1770. static inline
  1771. uint8_t hal_rx_get_filter_category(hal_soc_handle_t hal_soc_hdl,
  1772. uint8_t *buf)
  1773. {
  1774. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1775. return hal_soc->ops->hal_rx_get_filter_category(buf);
  1776. }
  1777. static inline
  1778. uint32_t hal_rx_get_ppdu_id(hal_soc_handle_t hal_soc_hdl,
  1779. uint8_t *buf)
  1780. {
  1781. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1782. return hal_soc->ops->hal_rx_get_ppdu_id(buf);
  1783. }
  1784. /**
  1785. * hal_reo_config(): Set reo config parameters
  1786. * @soc: hal soc handle
  1787. * @reg_val: value to be set
  1788. * @reo_params: reo parameters
  1789. *
  1790. * Return: void
  1791. */
  1792. static inline
  1793. void hal_reo_config(struct hal_soc *hal_soc,
  1794. uint32_t reg_val,
  1795. struct hal_reo_params *reo_params)
  1796. {
  1797. hal_soc->ops->hal_reo_config(hal_soc,
  1798. reg_val,
  1799. reo_params);
  1800. }
  1801. /**
  1802. * hal_rx_msdu_get_flow_params: API to get flow index,
  1803. * flow index invalid and flow index timeout from rx_msdu_end TLV
  1804. * @buf: pointer to the start of RX PKT TLV headers
  1805. * @flow_invalid: pointer to return value of flow_idx_valid
  1806. * @flow_timeout: pointer to return value of flow_idx_timeout
  1807. * @flow_index: pointer to return value of flow_idx
  1808. *
  1809. * Return: none
  1810. */
  1811. static inline void
  1812. hal_rx_msdu_get_flow_params(hal_soc_handle_t hal_soc_hdl,
  1813. uint8_t *buf,
  1814. bool *flow_invalid,
  1815. bool *flow_timeout,
  1816. uint32_t *flow_index)
  1817. {
  1818. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1819. hal_soc->ops->hal_rx_msdu_get_flow_params(buf,
  1820. flow_invalid,
  1821. flow_timeout,
  1822. flow_index);
  1823. }
  1824. static inline
  1825. uint16_t hal_rx_tlv_get_tcp_chksum(hal_soc_handle_t hal_soc_hdl,
  1826. uint8_t *buf)
  1827. {
  1828. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1829. return hal_soc->ops->hal_rx_tlv_get_tcp_chksum(buf);
  1830. }
  1831. static inline
  1832. uint16_t hal_rx_get_rx_sequence(hal_soc_handle_t hal_soc_hdl,
  1833. uint8_t *buf)
  1834. {
  1835. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1836. return hal_soc->ops->hal_rx_get_rx_sequence(buf);
  1837. }
  1838. static inline void
  1839. hal_rx_get_bb_info(hal_soc_handle_t hal_soc_hdl,
  1840. void *rx_tlv,
  1841. void *ppdu_info)
  1842. {
  1843. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1844. if (hal_soc->ops->hal_rx_get_bb_info)
  1845. hal_soc->ops->hal_rx_get_bb_info(rx_tlv, ppdu_info);
  1846. }
  1847. static inline void
  1848. hal_rx_get_rtt_info(hal_soc_handle_t hal_soc_hdl,
  1849. void *rx_tlv,
  1850. void *ppdu_info)
  1851. {
  1852. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1853. if (hal_soc->ops->hal_rx_get_rtt_info)
  1854. hal_soc->ops->hal_rx_get_rtt_info(rx_tlv, ppdu_info);
  1855. }
  1856. /**
  1857. * hal_rx_msdu_metadata_get(): API to get the
  1858. * fast path information from rx_msdu_end TLV
  1859. *
  1860. * @ hal_soc_hdl: DP soc handle
  1861. * @ buf: pointer to the start of RX PKT TLV headers
  1862. * @ msdu_metadata: Structure to hold msdu end information
  1863. * Return: none
  1864. */
  1865. static inline void
  1866. hal_rx_msdu_metadata_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  1867. struct hal_rx_msdu_metadata *msdu_md)
  1868. {
  1869. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1870. return hal_soc->ops->hal_rx_msdu_packet_metadata_get(buf, msdu_md);
  1871. }
  1872. /**
  1873. * hal_rx_get_fisa_cumulative_l4_checksum: API to get cumulative_l4_checksum
  1874. * from rx_msdu_end TLV
  1875. * @buf: pointer to the start of RX PKT TLV headers
  1876. *
  1877. * Return: cumulative_l4_checksum
  1878. */
  1879. static inline uint16_t
  1880. hal_rx_get_fisa_cumulative_l4_checksum(hal_soc_handle_t hal_soc_hdl,
  1881. uint8_t *buf)
  1882. {
  1883. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1884. if (!hal_soc || !hal_soc->ops) {
  1885. hal_err("hal handle is NULL");
  1886. QDF_BUG(0);
  1887. return 0;
  1888. }
  1889. if (!hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum)
  1890. return 0;
  1891. return hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum(buf);
  1892. }
  1893. /**
  1894. * hal_rx_get_fisa_cumulative_ip_length: API to get cumulative_ip_length
  1895. * from rx_msdu_end TLV
  1896. * @buf: pointer to the start of RX PKT TLV headers
  1897. *
  1898. * Return: cumulative_ip_length
  1899. */
  1900. static inline uint16_t
  1901. hal_rx_get_fisa_cumulative_ip_length(hal_soc_handle_t hal_soc_hdl,
  1902. uint8_t *buf)
  1903. {
  1904. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1905. if (!hal_soc || !hal_soc->ops) {
  1906. hal_err("hal handle is NULL");
  1907. QDF_BUG(0);
  1908. return 0;
  1909. }
  1910. if (hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length)
  1911. return hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length(buf);
  1912. return 0;
  1913. }
  1914. /**
  1915. * hal_rx_get_udp_proto: API to get UDP proto field
  1916. * from rx_msdu_start TLV
  1917. * @buf: pointer to the start of RX PKT TLV headers
  1918. *
  1919. * Return: UDP proto field value
  1920. */
  1921. static inline bool
  1922. hal_rx_get_udp_proto(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1923. {
  1924. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1925. if (!hal_soc || !hal_soc->ops) {
  1926. hal_err("hal handle is NULL");
  1927. QDF_BUG(0);
  1928. return 0;
  1929. }
  1930. if (hal_soc->ops->hal_rx_get_udp_proto)
  1931. return hal_soc->ops->hal_rx_get_udp_proto(buf);
  1932. return 0;
  1933. }
  1934. /**
  1935. * hal_rx_get_fisa_flow_agg_continuation: API to get fisa flow_agg_continuation
  1936. * from rx_msdu_end TLV
  1937. * @buf: pointer to the start of RX PKT TLV headers
  1938. *
  1939. * Return: flow_agg_continuation bit field value
  1940. */
  1941. static inline bool
  1942. hal_rx_get_fisa_flow_agg_continuation(hal_soc_handle_t hal_soc_hdl,
  1943. uint8_t *buf)
  1944. {
  1945. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1946. if (!hal_soc || !hal_soc->ops) {
  1947. hal_err("hal handle is NULL");
  1948. QDF_BUG(0);
  1949. return 0;
  1950. }
  1951. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation)
  1952. return hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation(buf);
  1953. return 0;
  1954. }
  1955. /**
  1956. * hal_rx_get_fisa_flow_agg_count: API to get fisa flow_agg count from
  1957. * rx_msdu_end TLV
  1958. * @buf: pointer to the start of RX PKT TLV headers
  1959. *
  1960. * Return: flow_agg count value
  1961. */
  1962. static inline uint8_t
  1963. hal_rx_get_fisa_flow_agg_count(hal_soc_handle_t hal_soc_hdl,
  1964. uint8_t *buf)
  1965. {
  1966. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1967. if (!hal_soc || !hal_soc->ops) {
  1968. hal_err("hal handle is NULL");
  1969. QDF_BUG(0);
  1970. return 0;
  1971. }
  1972. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_count)
  1973. return hal_soc->ops->hal_rx_get_fisa_flow_agg_count(buf);
  1974. return 0;
  1975. }
  1976. /**
  1977. * hal_rx_get_fisa_timeout: API to get fisa time out from rx_msdu_end TLV
  1978. * @buf: pointer to the start of RX PKT TLV headers
  1979. *
  1980. * Return: fisa flow_agg timeout bit value
  1981. */
  1982. static inline bool
  1983. hal_rx_get_fisa_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1984. {
  1985. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1986. if (!hal_soc || !hal_soc->ops) {
  1987. hal_err("hal handle is NULL");
  1988. QDF_BUG(0);
  1989. return 0;
  1990. }
  1991. if (hal_soc->ops->hal_rx_get_fisa_timeout)
  1992. return hal_soc->ops->hal_rx_get_fisa_timeout(buf);
  1993. return 0;
  1994. }
  1995. /**
  1996. * hal_rx_mpdu_start_tlv_tag_valid - API to check if RX_MPDU_START tlv
  1997. * tag is valid
  1998. *
  1999. * @hal_soc_hdl: HAL SOC handle
  2000. * @rx_tlv_hdr: start address of rx_pkt_tlvs
  2001. *
  2002. * Return: true if RX_MPDU_START tlv tag is valid, else false
  2003. */
  2004. static inline uint8_t
  2005. hal_rx_mpdu_start_tlv_tag_valid(hal_soc_handle_t hal_soc_hdl,
  2006. void *rx_tlv_hdr)
  2007. {
  2008. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  2009. if (hal->ops->hal_rx_mpdu_start_tlv_tag_valid)
  2010. return hal->ops->hal_rx_mpdu_start_tlv_tag_valid(rx_tlv_hdr);
  2011. return 0;
  2012. }
  2013. /**
  2014. * hal_rx_get_next_msdu_link_desc_buf_addr_info(): get next msdu link desc
  2015. * buffer addr info
  2016. * @link_desc_va: pointer to current msdu link Desc
  2017. * @next_addr_info: buffer to save next msdu link Desc buffer addr info
  2018. *
  2019. * return: None
  2020. */
  2021. static inline void hal_rx_get_next_msdu_link_desc_buf_addr_info(
  2022. void *link_desc_va,
  2023. struct buffer_addr_info *next_addr_info)
  2024. {
  2025. struct rx_msdu_link *msdu_link = link_desc_va;
  2026. if (!msdu_link) {
  2027. qdf_mem_zero(next_addr_info, sizeof(struct buffer_addr_info));
  2028. return;
  2029. }
  2030. *next_addr_info = msdu_link->next_msdu_link_desc_addr_info;
  2031. }
  2032. /**
  2033. * hal_rx_clear_next_msdu_link_desc_buf_addr_info(): clear next msdu link desc
  2034. * buffer addr info
  2035. * @link_desc_va: pointer to current msdu link Desc
  2036. *
  2037. * return: None
  2038. */
  2039. static inline
  2040. void hal_rx_clear_next_msdu_link_desc_buf_addr_info(void *link_desc_va)
  2041. {
  2042. struct rx_msdu_link *msdu_link = link_desc_va;
  2043. if (msdu_link)
  2044. qdf_mem_zero(&msdu_link->next_msdu_link_desc_addr_info,
  2045. sizeof(msdu_link->next_msdu_link_desc_addr_info));
  2046. }
  2047. /**
  2048. * hal_rx_is_buf_addr_info_valid(): check is the buf_addr_info valid
  2049. *
  2050. * @buf_addr_info: pointer to buf_addr_info structure
  2051. *
  2052. * return: true: has valid paddr, false: not.
  2053. */
  2054. static inline
  2055. bool hal_rx_is_buf_addr_info_valid(struct buffer_addr_info *buf_addr_info)
  2056. {
  2057. return (HAL_RX_BUFFER_ADDR_31_0_GET(buf_addr_info) == 0) ?
  2058. false : true;
  2059. }
  2060. /**
  2061. * hal_rx_msdu_end_offset_get(): Get the MSDU end offset from
  2062. * rx_pkt_tlvs structure
  2063. *
  2064. * @hal_soc_hdl: HAL SOC handle
  2065. * return: msdu_end_tlv offset value
  2066. */
  2067. static inline
  2068. uint32_t hal_rx_msdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  2069. {
  2070. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2071. if (!hal_soc || !hal_soc->ops) {
  2072. hal_err("hal handle is NULL");
  2073. QDF_BUG(0);
  2074. return 0;
  2075. }
  2076. return hal_soc->ops->hal_rx_msdu_end_offset_get();
  2077. }
  2078. /**
  2079. * hal_rx_msdu_start_offset_get(): Get the MSDU start offset from
  2080. * rx_pkt_tlvs structure
  2081. *
  2082. * @hal_soc_hdl: HAL SOC handle
  2083. * return: msdu_start_tlv offset value
  2084. */
  2085. static inline
  2086. uint32_t hal_rx_msdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  2087. {
  2088. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2089. if (!hal_soc || !hal_soc->ops) {
  2090. hal_err("hal handle is NULL");
  2091. QDF_BUG(0);
  2092. return 0;
  2093. }
  2094. return hal_soc->ops->hal_rx_msdu_start_offset_get();
  2095. }
  2096. /**
  2097. * hal_rx_mpdu_start_offset_get(): Get the MPDU start offset from
  2098. * rx_pkt_tlvs structure
  2099. *
  2100. * @hal_soc_hdl: HAL SOC handle
  2101. * return: mpdu_start_tlv offset value
  2102. */
  2103. static inline
  2104. uint32_t hal_rx_mpdu_start_offset_get(hal_soc_handle_t hal_soc_hdl)
  2105. {
  2106. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2107. if (!hal_soc || !hal_soc->ops) {
  2108. hal_err("hal handle is NULL");
  2109. QDF_BUG(0);
  2110. return 0;
  2111. }
  2112. return hal_soc->ops->hal_rx_mpdu_start_offset_get();
  2113. }
  2114. static inline
  2115. uint32_t hal_rx_pkt_tlv_offset_get(hal_soc_handle_t hal_soc_hdl)
  2116. {
  2117. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2118. if (!hal_soc || !hal_soc->ops) {
  2119. hal_err("hal handle is NULL");
  2120. QDF_BUG(0);
  2121. return 0;
  2122. }
  2123. return hal_soc->ops->hal_rx_pkt_tlv_offset_get();
  2124. }
  2125. /**
  2126. * hal_rx_mpdu_end_offset_get(): Get the MPDU end offset from
  2127. * rx_pkt_tlvs structure
  2128. *
  2129. * @hal_soc_hdl: HAL SOC handle
  2130. * return: mpdu_end_tlv offset value
  2131. */
  2132. static inline
  2133. uint32_t hal_rx_mpdu_end_offset_get(hal_soc_handle_t hal_soc_hdl)
  2134. {
  2135. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2136. if (!hal_soc || !hal_soc->ops) {
  2137. hal_err("hal handle is NULL");
  2138. QDF_BUG(0);
  2139. return 0;
  2140. }
  2141. return hal_soc->ops->hal_rx_mpdu_end_offset_get();
  2142. }
  2143. /**
  2144. * hal_rx_attn_offset_get(): Get the ATTENTION offset from
  2145. * rx_pkt_tlvs structure
  2146. *
  2147. * @hal_soc_hdl: HAL SOC handle
  2148. * return: attn_tlv offset value
  2149. */
  2150. static inline
  2151. uint32_t hal_rx_attn_offset_get(hal_soc_handle_t hal_soc_hdl)
  2152. {
  2153. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2154. if (!hal_soc || !hal_soc->ops) {
  2155. hal_err("hal handle is NULL");
  2156. QDF_BUG(0);
  2157. return 0;
  2158. }
  2159. return hal_soc->ops->hal_rx_attn_offset_get();
  2160. }
  2161. /**
  2162. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  2163. * @msdu_details_ptr - Pointer to msdu_details_ptr
  2164. * @hal - pointer to hal_soc
  2165. * Return - Pointer to rx_msdu_desc_info structure.
  2166. *
  2167. */
  2168. static inline
  2169. void *hal_rx_msdu_ext_desc_info_get_ptr(void *msdu_details_ptr,
  2170. struct hal_soc *hal_soc)
  2171. {
  2172. return hal_soc->ops->hal_rx_msdu_ext_desc_info_get_ptr(
  2173. msdu_details_ptr);
  2174. }
  2175. static inline void
  2176. hal_rx_dump_pkt_tlvs(hal_soc_handle_t hal_soc_hdl,
  2177. uint8_t *buf, uint8_t dbg_level)
  2178. {
  2179. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2180. hal_soc->ops->hal_rx_dump_pkt_tlvs(hal_soc_hdl, buf, dbg_level);
  2181. }
  2182. //TODO - Change the names to not include tlv names
  2183. static inline uint16_t
  2184. hal_rx_attn_phy_ppdu_id_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2185. {
  2186. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2187. return hal_soc->ops->hal_rx_tlv_phy_ppdu_id_get(buf);
  2188. }
  2189. static inline uint32_t
  2190. hal_rx_attn_msdu_done_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2191. {
  2192. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2193. return hal_soc->ops->hal_rx_tlv_msdu_done_get(buf);
  2194. }
  2195. static inline uint32_t
  2196. hal_rx_msdu_start_msdu_len_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2197. {
  2198. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2199. return hal_soc->ops->hal_rx_tlv_msdu_len_get(buf);
  2200. }
  2201. static inline uint16_t
  2202. hal_rx_get_frame_ctrl_field(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2203. {
  2204. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2205. return hal_soc->ops->hal_rx_get_frame_ctrl_field(buf);
  2206. }
  2207. static inline int
  2208. hal_rx_tlv_get_offload_info(hal_soc_handle_t hal_soc_hdl,
  2209. uint8_t *rx_pkt_tlv,
  2210. struct hal_offload_info *offload_info)
  2211. {
  2212. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2213. return hal_soc->ops->hal_rx_tlv_get_offload_info(rx_pkt_tlv,
  2214. offload_info);
  2215. }
  2216. static inline int
  2217. hal_rx_get_proto_params(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  2218. void *proto_params)
  2219. {
  2220. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2221. return hal_soc->ops->hal_rx_get_proto_params(buf, proto_params);
  2222. }
  2223. static inline int
  2224. hal_rx_get_l3_l4_offsets(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  2225. uint32_t *l3_hdr_offset, uint32_t *l4_hdr_offset)
  2226. {
  2227. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2228. return hal_soc->ops->hal_rx_get_l3_l4_offsets(buf,
  2229. l3_hdr_offset,
  2230. l4_hdr_offset);
  2231. }
  2232. static inline uint32_t
  2233. hal_rx_tlv_mic_err_get(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_mic_err_get(buf);
  2237. }
  2238. /*
  2239. * hal_rx_tlv_get_pkt_type(): API to get the pkt type
  2240. * from rx_msdu_start
  2241. *
  2242. * @buf: pointer to the start of RX PKT TLV header
  2243. * Return: uint32_t(pkt type)
  2244. */
  2245. static inline uint32_t
  2246. hal_rx_tlv_get_pkt_type(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2247. {
  2248. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2249. return hal_soc->ops->hal_rx_tlv_get_pkt_type(buf);
  2250. }
  2251. static inline void
  2252. hal_rx_tlv_get_pn_num(hal_soc_handle_t hal_soc_hdl,
  2253. uint8_t *buf, uint64_t *pn_num)
  2254. {
  2255. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2256. hal_soc->ops->hal_rx_tlv_get_pn_num(buf, pn_num);
  2257. }
  2258. static inline uint8_t *
  2259. hal_get_reo_ent_desc_qdesc_addr(hal_soc_handle_t hal_soc_hdl, uint8_t *desc)
  2260. {
  2261. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2262. if (hal_soc->ops->hal_get_reo_ent_desc_qdesc_addr)
  2263. return hal_soc->ops->hal_get_reo_ent_desc_qdesc_addr(desc);
  2264. return NULL;
  2265. }
  2266. static inline uint64_t
  2267. hal_rx_get_qdesc_addr(hal_soc_handle_t hal_soc_hdl, uint8_t *dst_ring_desc,
  2268. uint8_t *buf)
  2269. {
  2270. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2271. if (hal_soc->ops->hal_rx_get_qdesc_addr)
  2272. return hal_soc->ops->hal_rx_get_qdesc_addr(dst_ring_desc, buf);
  2273. return 0;
  2274. }
  2275. static inline void
  2276. hal_set_reo_ent_desc_reo_dest_ind(hal_soc_handle_t hal_soc_hdl,
  2277. uint8_t *desc, uint32_t dst_ind)
  2278. {
  2279. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2280. if (hal_soc->ops->hal_set_reo_ent_desc_reo_dest_ind)
  2281. hal_soc->ops->hal_set_reo_ent_desc_reo_dest_ind(desc, dst_ind);
  2282. }
  2283. static inline uint32_t
  2284. hal_rx_tlv_get_is_decrypted(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2285. {
  2286. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2287. if (hal_soc->ops->hal_rx_tlv_get_is_decrypted)
  2288. return hal_soc->ops->hal_rx_tlv_get_is_decrypted(buf);
  2289. return 0;
  2290. }
  2291. static inline uint8_t *
  2292. hal_rx_pkt_hdr_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2293. {
  2294. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2295. return hal_soc->ops->hal_rx_pkt_hdr_get(buf);
  2296. }
  2297. static inline uint8_t
  2298. hal_rx_msdu_get_keyid(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2299. {
  2300. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2301. if (hal_soc->ops->hal_rx_msdu_get_keyid)
  2302. return hal_soc->ops->hal_rx_msdu_get_keyid(buf);
  2303. return 0;
  2304. }
  2305. static inline uint32_t
  2306. hal_rx_tlv_get_freq(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2307. {
  2308. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2309. if (hal_soc->ops->hal_rx_tlv_get_freq)
  2310. return hal_soc->ops->hal_rx_tlv_get_freq(buf);
  2311. return 0;
  2312. }
  2313. static inline void hal_mpdu_desc_info_set(hal_soc_handle_t hal_soc_hdl,
  2314. void *mpdu_desc_info, uint32_t val)
  2315. {
  2316. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2317. if (hal_soc->ops->hal_mpdu_desc_info_set)
  2318. return hal_soc->ops->hal_mpdu_desc_info_set(
  2319. hal_soc_hdl, mpdu_desc_info, val);
  2320. }
  2321. static inline void hal_msdu_desc_info_set(hal_soc_handle_t hal_soc_hdl,
  2322. void *msdu_desc_info,
  2323. uint32_t val, uint32_t nbuf_len)
  2324. {
  2325. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2326. if (hal_soc->ops->hal_msdu_desc_info_set)
  2327. return hal_soc->ops->hal_msdu_desc_info_set(
  2328. hal_soc_hdl, msdu_desc_info, val, nbuf_len);
  2329. }
  2330. static inline uint32_t
  2331. hal_rx_msdu_reo_dst_ind_get(hal_soc_handle_t hal_soc_hdl, void *msdu_link_desc)
  2332. {
  2333. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2334. if (hal_soc->ops->hal_rx_msdu_reo_dst_ind_get)
  2335. return hal_soc->ops->hal_rx_msdu_reo_dst_ind_get(
  2336. hal_soc_hdl, msdu_link_desc);
  2337. return 0;
  2338. }
  2339. static inline uint32_t
  2340. hal_rx_tlv_sgi_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2341. {
  2342. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2343. return hal_soc->ops->hal_rx_tlv_sgi_get(buf);
  2344. }
  2345. static inline uint32_t
  2346. hal_rx_tlv_rate_mcs_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2347. {
  2348. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2349. return hal_soc->ops->hal_rx_tlv_rate_mcs_get(buf);
  2350. }
  2351. static inline uint32_t
  2352. hal_rx_tlv_decrypt_err_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2353. {
  2354. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2355. return hal_soc->ops->hal_rx_tlv_decrypt_err_get(buf);
  2356. }
  2357. static inline uint32_t
  2358. hal_rx_tlv_first_mpdu_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2359. {
  2360. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2361. return hal_soc->ops->hal_rx_tlv_first_mpdu_get(buf);
  2362. }
  2363. static inline uint32_t
  2364. hal_rx_tlv_bw_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2365. {
  2366. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2367. return hal_soc->ops->hal_rx_tlv_bw_get(buf);
  2368. }
  2369. static inline uint32_t
  2370. hal_rx_wbm_err_src_get(hal_soc_handle_t hal_soc_hdl,
  2371. hal_ring_desc_t ring_desc)
  2372. {
  2373. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2374. return hal_soc->ops->hal_rx_wbm_err_src_get(ring_desc);
  2375. }
  2376. /**
  2377. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  2378. * from the BUFFER_ADDR_INFO structure
  2379. * given a REO destination ring descriptor.
  2380. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  2381. *
  2382. * Return: uint8_t (value of the return_buffer_manager)
  2383. */
  2384. static inline uint8_t
  2385. hal_rx_ret_buf_manager_get(hal_soc_handle_t hal_soc_hdl,
  2386. hal_ring_desc_t ring_desc)
  2387. {
  2388. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2389. return hal_soc->ops->hal_rx_ret_buf_manager_get(ring_desc);
  2390. }
  2391. /*
  2392. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  2393. * rxdma ring entry.
  2394. * @rxdma_entry: descriptor entry
  2395. * @paddr: physical address of nbuf data pointer.
  2396. * @cookie: SW cookie used as a index to SW rx desc.
  2397. * @manager: who owns the nbuf (host, NSS, etc...).
  2398. *
  2399. */
  2400. static inline void hal_rxdma_buff_addr_info_set(hal_soc_handle_t hal_soc_hdl,
  2401. void *rxdma_entry,
  2402. qdf_dma_addr_t paddr,
  2403. uint32_t cookie,
  2404. uint8_t manager)
  2405. {
  2406. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2407. return hal_soc->ops->hal_rxdma_buff_addr_info_set(rxdma_entry,
  2408. paddr,
  2409. cookie,
  2410. manager);
  2411. }
  2412. static inline uint32_t
  2413. hal_rx_get_reo_error_code(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2414. {
  2415. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2416. return hal_soc->ops->hal_rx_get_reo_error_code(rx_desc);
  2417. }
  2418. static inline void
  2419. hal_rx_tlv_csum_err_get(hal_soc_handle_t hal_soc_hdl, uint8_t *rx_tlv_hdr,
  2420. uint32_t *ip_csum_err, uint32_t *tcp_udp_csum_err)
  2421. {
  2422. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2423. return hal_soc->ops->hal_rx_tlv_csum_err_get(rx_tlv_hdr,
  2424. ip_csum_err,
  2425. tcp_udp_csum_err);
  2426. }
  2427. static inline void
  2428. hal_rx_tlv_get_pkt_capture_flags(hal_soc_handle_t hal_soc_hdl,
  2429. uint8_t *rx_tlv_hdr,
  2430. struct hal_rx_pkt_capture_flags *flags)
  2431. {
  2432. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2433. return hal_soc->ops->hal_rx_tlv_get_pkt_capture_flags(rx_tlv_hdr,
  2434. flags);
  2435. }
  2436. static inline uint8_t
  2437. hal_rx_err_status_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2438. {
  2439. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2440. return hal_soc->ops->hal_rx_err_status_get(rx_desc);
  2441. }
  2442. static inline uint8_t
  2443. hal_rx_reo_buf_type_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t rx_desc)
  2444. {
  2445. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2446. return hal_soc->ops->hal_rx_reo_buf_type_get(rx_desc);
  2447. }
  2448. /**
  2449. * hal_rx_reo_prev_pn_get() - Get the previous pn from ring descriptor.
  2450. * @hal_soc_hdl: HAL SoC handle
  2451. * @ring_desc: REO ring descriptor
  2452. * @prev_pn: Buffer to populate the previos PN
  2453. *
  2454. * Return: None
  2455. */
  2456. static inline void
  2457. hal_rx_reo_prev_pn_get(hal_soc_handle_t hal_soc_hdl, hal_ring_desc_t ring_desc,
  2458. uint64_t *prev_pn)
  2459. {
  2460. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2461. if (hal_soc->ops->hal_rx_reo_prev_pn_get)
  2462. return hal_soc->ops->hal_rx_reo_prev_pn_get(ring_desc, prev_pn);
  2463. }
  2464. /**
  2465. * hal_rx_mpdu_info_ampdu_flag_get(): get ampdu flag bit
  2466. * from rx mpdu info
  2467. * @buf: pointer to rx_pkt_tlvs
  2468. *
  2469. * No input validdataion, since this function is supposed to be
  2470. * called from fastpath.
  2471. *
  2472. * Return: ampdu flag
  2473. */
  2474. static inline bool
  2475. hal_rx_mpdu_info_ampdu_flag_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2476. {
  2477. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2478. return hal_soc->ops->hal_rx_mpdu_info_ampdu_flag_get(buf);
  2479. }
  2480. #endif /* _HAL_RX_H */