hal_rx.h 78 KB

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