hal_rx.h 80 KB

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