hal_rx.h 92 KB

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