hal_rx.h 78 KB

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