hal_rx.h 78 KB

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