hal_rx.h 76 KB

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