hal_rx.h 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643
  1. /*
  2. * Copyright (c) 2016-2020 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. #define HAL_RX_OFFSET(block, field) block##_##field##_OFFSET
  22. #define HAL_RX_LSB(block, field) block##_##field##_LSB
  23. #define HAL_RX_MASk(block, field) block##_##field##_MASK
  24. #define HAL_RX_GET(_ptr, block, field) \
  25. (((*((volatile uint32_t *)_ptr + (HAL_RX_OFFSET(block, field)>>2))) & \
  26. HAL_RX_MASk(block, field)) >> \
  27. HAL_RX_LSB(block, field))
  28. /* BUFFER_SIZE = 1536 data bytes + 384 RX TLV bytes + some spare bytes */
  29. #ifndef RX_DATA_BUFFER_SIZE
  30. #define RX_DATA_BUFFER_SIZE 2048
  31. #endif
  32. #ifndef RX_MONITOR_BUFFER_SIZE
  33. #define RX_MONITOR_BUFFER_SIZE 2048
  34. #endif
  35. /* HAL_RX_NON_QOS_TID = NON_QOS_TID which is 16 */
  36. #define HAL_RX_NON_QOS_TID 16
  37. enum {
  38. HAL_HW_RX_DECAP_FORMAT_RAW = 0,
  39. HAL_HW_RX_DECAP_FORMAT_NWIFI,
  40. HAL_HW_RX_DECAP_FORMAT_ETH2,
  41. HAL_HW_RX_DECAP_FORMAT_8023,
  42. };
  43. /**
  44. * struct hal_wbm_err_desc_info: structure to hold wbm error codes and reasons
  45. *
  46. * @reo_psh_rsn: REO push reason
  47. * @reo_err_code: REO Error code
  48. * @rxdma_psh_rsn: RXDMA push reason
  49. * @rxdma_err_code: RXDMA Error code
  50. * @reserved_1: Reserved bits
  51. * @wbm_err_src: WBM error source
  52. * @pool_id: pool ID, indicates which rxdma pool
  53. * @reserved_2: Reserved bits
  54. */
  55. struct hal_wbm_err_desc_info {
  56. uint16_t reo_psh_rsn:2,
  57. reo_err_code:5,
  58. rxdma_psh_rsn:2,
  59. rxdma_err_code:5,
  60. reserved_1:2;
  61. uint8_t wbm_err_src:3,
  62. pool_id:2,
  63. reserved_2:3;
  64. };
  65. /**
  66. * struct hal_rx_msdu_metadata:Structure to hold rx fast path information.
  67. *
  68. * @l3_hdr_pad: l3 header padding
  69. * @reserved: Reserved bits
  70. * @sa_sw_peer_id: sa sw peer id
  71. * @sa_idx: sa index
  72. * @da_idx: da index
  73. */
  74. struct hal_rx_msdu_metadata {
  75. uint32_t l3_hdr_pad:16,
  76. sa_sw_peer_id:16;
  77. uint32_t sa_idx:16,
  78. da_idx:16;
  79. };
  80. /**
  81. * enum hal_reo_error_code: Enum which encapsulates "reo_push_reason"
  82. *
  83. * @ HAL_REO_ERROR_DETECTED: Packets arrived because of an error detected
  84. * @ HAL_REO_ROUTING_INSTRUCTION: Packets arrived because of REO routing
  85. */
  86. enum hal_reo_error_status {
  87. HAL_REO_ERROR_DETECTED = 0,
  88. HAL_REO_ROUTING_INSTRUCTION = 1,
  89. };
  90. /**
  91. * @msdu_flags: [0] first_msdu_in_mpdu
  92. * [1] last_msdu_in_mpdu
  93. * [2] msdu_continuation - MSDU spread across buffers
  94. * [23] sa_is_valid - SA match in peer table
  95. * [24] sa_idx_timeout - Timeout while searching for SA match
  96. * [25] da_is_valid - Used to identtify intra-bss forwarding
  97. * [26] da_is_MCBC
  98. * [27] da_idx_timeout - Timeout while searching for DA match
  99. *
  100. */
  101. struct hal_rx_msdu_desc_info {
  102. uint32_t msdu_flags;
  103. uint16_t msdu_len; /* 14 bits for length */
  104. };
  105. /**
  106. * enum hal_rx_msdu_desc_flags: Enum for flags in MSDU_DESC_INFO
  107. *
  108. * @ HAL_MSDU_F_FIRST_MSDU_IN_MPDU: First MSDU in MPDU
  109. * @ HAL_MSDU_F_LAST_MSDU_IN_MPDU: Last MSDU in MPDU
  110. * @ HAL_MSDU_F_MSDU_CONTINUATION: MSDU continuation
  111. * @ HAL_MSDU_F_SA_IS_VALID: Found match for SA in AST
  112. * @ HAL_MSDU_F_SA_IDX_TIMEOUT: AST search for SA timed out
  113. * @ HAL_MSDU_F_DA_IS_VALID: Found match for DA in AST
  114. * @ HAL_MSDU_F_DA_IS_MCBC: DA is MC/BC address
  115. * @ HAL_MSDU_F_DA_IDX_TIMEOUT: AST search for DA timed out
  116. */
  117. enum hal_rx_msdu_desc_flags {
  118. HAL_MSDU_F_FIRST_MSDU_IN_MPDU = (0x1 << 0),
  119. HAL_MSDU_F_LAST_MSDU_IN_MPDU = (0x1 << 1),
  120. HAL_MSDU_F_MSDU_CONTINUATION = (0x1 << 2),
  121. HAL_MSDU_F_SA_IS_VALID = (0x1 << 23),
  122. HAL_MSDU_F_SA_IDX_TIMEOUT = (0x1 << 24),
  123. HAL_MSDU_F_DA_IS_VALID = (0x1 << 25),
  124. HAL_MSDU_F_DA_IS_MCBC = (0x1 << 26),
  125. HAL_MSDU_F_DA_IDX_TIMEOUT = (0x1 << 27)
  126. };
  127. /*
  128. * @msdu_count: no. of msdus in the MPDU
  129. * @mpdu_seq: MPDU sequence number
  130. * @mpdu_flags [0] Fragment flag
  131. * [1] MPDU_retry_bit
  132. * [2] AMPDU flag
  133. * [3] raw_ampdu
  134. * @peer_meta_data: Upper bits containing peer id, vdev id
  135. */
  136. struct hal_rx_mpdu_desc_info {
  137. uint16_t msdu_count;
  138. uint16_t mpdu_seq; /* 12 bits for length */
  139. uint32_t mpdu_flags;
  140. uint32_t peer_meta_data; /* sw progamed meta-data:MAC Id & peer Id */
  141. };
  142. /**
  143. * enum hal_rx_mpdu_desc_flags: Enum for flags in MPDU_DESC_INFO
  144. *
  145. * @ HAL_MPDU_F_FRAGMENT: Fragmented MPDU (802.11 fragemtation)
  146. * @ HAL_MPDU_F_RETRY_BIT: Retry bit is set in FC of MPDU
  147. * @ HAL_MPDU_F_AMPDU_FLAG: MPDU received as part of A-MPDU
  148. * @ HAL_MPDU_F_RAW_AMPDU: MPDU is a Raw MDPU
  149. */
  150. enum hal_rx_mpdu_desc_flags {
  151. HAL_MPDU_F_FRAGMENT = (0x1 << 20),
  152. HAL_MPDU_F_RETRY_BIT = (0x1 << 21),
  153. HAL_MPDU_F_AMPDU_FLAG = (0x1 << 22),
  154. HAL_MPDU_F_RAW_AMPDU = (0x1 << 30)
  155. };
  156. /**
  157. * enum hal_rx_ret_buf_manager: Enum for return_buffer_manager field in
  158. * BUFFER_ADDR_INFO structure
  159. *
  160. * @ HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST: Buffer returned to WBM idle buffer list
  161. * @ HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST: Descriptor returned to WBM idle
  162. * descriptor list
  163. * @ HAL_RX_BUF_RBM_FW_BM: Buffer returned to FW
  164. * @ HAL_RX_BUF_RBM_SW0_BM: For Tx completion -- returned to host
  165. * @ HAL_RX_BUF_RBM_SW1_BM: For Tx completion -- returned to host
  166. * @ HAL_RX_BUF_RBM_SW2_BM: For Tx completion -- returned to host
  167. * @ HAL_RX_BUF_RBM_SW3_BM: For Rx release -- returned to host
  168. */
  169. enum hal_rx_ret_buf_manager {
  170. HAL_RX_BUF_RBM_WBM_IDLE_BUF_LIST = 0,
  171. HAL_RX_BUF_RBM_WBM_IDLE_DESC_LIST = 1,
  172. HAL_RX_BUF_RBM_FW_BM = 2,
  173. HAL_RX_BUF_RBM_SW0_BM = 3,
  174. HAL_RX_BUF_RBM_SW1_BM = 4,
  175. HAL_RX_BUF_RBM_SW2_BM = 5,
  176. HAL_RX_BUF_RBM_SW3_BM = 6,
  177. };
  178. /*
  179. * Given the offset of a field in bytes, returns uint8_t *
  180. */
  181. #define _OFFSET_TO_BYTE_PTR(_ptr, _off_in_bytes) \
  182. (((uint8_t *)(_ptr)) + (_off_in_bytes))
  183. /*
  184. * Given the offset of a field in bytes, returns uint32_t *
  185. */
  186. #define _OFFSET_TO_WORD_PTR(_ptr, _off_in_bytes) \
  187. (((uint32_t *)(_ptr)) + ((_off_in_bytes) >> 2))
  188. #define _HAL_MS(_word, _mask, _shift) \
  189. (((_word) & (_mask)) >> (_shift))
  190. /*
  191. * macro to set the LSW of the nbuf data physical address
  192. * to the rxdma ring entry
  193. */
  194. #define HAL_RXDMA_PADDR_LO_SET(buff_addr_info, paddr_lo) \
  195. ((*(((unsigned int *) buff_addr_info) + \
  196. (BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET >> 2))) = \
  197. (paddr_lo << BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB) & \
  198. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK)
  199. /*
  200. * macro to set the LSB of MSW of the nbuf data physical address
  201. * to the rxdma ring entry
  202. */
  203. #define HAL_RXDMA_PADDR_HI_SET(buff_addr_info, paddr_hi) \
  204. ((*(((unsigned int *) buff_addr_info) + \
  205. (BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET >> 2))) = \
  206. (paddr_hi << BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB) & \
  207. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK)
  208. /*
  209. * macro to set the cookie into the rxdma ring entry
  210. */
  211. #define HAL_RXDMA_COOKIE_SET(buff_addr_info, cookie) \
  212. ((*(((unsigned int *) buff_addr_info) + \
  213. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) &= \
  214. ~BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK); \
  215. ((*(((unsigned int *) buff_addr_info) + \
  216. (BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET >> 2))) |= \
  217. (cookie << BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB) & \
  218. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK)
  219. /*
  220. * macro to set the manager into the rxdma ring entry
  221. */
  222. #define HAL_RXDMA_MANAGER_SET(buff_addr_info, manager) \
  223. ((*(((unsigned int *) buff_addr_info) + \
  224. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) &= \
  225. ~BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK); \
  226. ((*(((unsigned int *) buff_addr_info) + \
  227. (BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET >> 2))) |= \
  228. (manager << BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB) & \
  229. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK)
  230. #define HAL_RX_ERROR_STATUS_GET(reo_desc) \
  231. (_HAL_MS((*_OFFSET_TO_WORD_PTR(reo_desc, \
  232. REO_DESTINATION_RING_7_REO_PUSH_REASON_OFFSET)),\
  233. REO_DESTINATION_RING_7_REO_PUSH_REASON_MASK, \
  234. REO_DESTINATION_RING_7_REO_PUSH_REASON_LSB))
  235. #define HAL_RX_BUF_COOKIE_GET(buff_addr_info) \
  236. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  237. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_OFFSET)), \
  238. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_MASK, \
  239. BUFFER_ADDR_INFO_1_SW_BUFFER_COOKIE_LSB))
  240. #define HAL_RX_BUFFER_ADDR_39_32_GET(buff_addr_info) \
  241. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  242. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_OFFSET)), \
  243. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK, \
  244. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_LSB))
  245. #define HAL_RX_BUFFER_ADDR_31_0_GET(buff_addr_info) \
  246. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  247. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_OFFSET)), \
  248. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK, \
  249. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_LSB))
  250. #define HAL_RX_BUF_RBM_GET(buff_addr_info) \
  251. (_HAL_MS((*_OFFSET_TO_WORD_PTR(buff_addr_info, \
  252. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_OFFSET)),\
  253. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_MASK, \
  254. BUFFER_ADDR_INFO_1_RETURN_BUFFER_MANAGER_LSB))
  255. /* TODO: Convert the following structure fields accesseses to offsets */
  256. #define HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_desc) \
  257. (HAL_RX_BUFFER_ADDR_39_32_GET(& \
  258. (((struct reo_destination_ring *) \
  259. reo_desc)->buf_or_link_desc_addr_info)))
  260. #define HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_desc) \
  261. (HAL_RX_BUFFER_ADDR_31_0_GET(& \
  262. (((struct reo_destination_ring *) \
  263. reo_desc)->buf_or_link_desc_addr_info)))
  264. #define HAL_RX_REO_BUF_COOKIE_GET(reo_desc) \
  265. (HAL_RX_BUF_COOKIE_GET(& \
  266. (((struct reo_destination_ring *) \
  267. reo_desc)->buf_or_link_desc_addr_info)))
  268. #define HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info_ptr) \
  269. ((mpdu_info_ptr \
  270. [RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_OFFSET >> 2] & \
  271. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_MASK) >> \
  272. RX_MPDU_DESC_INFO_0_MPDU_SEQUENCE_NUMBER_LSB)
  273. #define HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info_ptr) \
  274. ((mpdu_info_ptr \
  275. [RX_MPDU_DESC_INFO_1_PEER_META_DATA_OFFSET >> 2] & \
  276. RX_MPDU_DESC_INFO_1_PEER_META_DATA_MASK) >> \
  277. RX_MPDU_DESC_INFO_1_PEER_META_DATA_LSB)
  278. #define HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info_ptr) \
  279. ((mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MSDU_COUNT_OFFSET >> 2] & \
  280. RX_MPDU_DESC_INFO_0_MSDU_COUNT_MASK) >> \
  281. RX_MPDU_DESC_INFO_0_MSDU_COUNT_LSB)
  282. #define HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) \
  283. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_OFFSET >> 2] & \
  284. RX_MPDU_DESC_INFO_0_FRAGMENT_FLAG_MASK)
  285. #define HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) \
  286. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_OFFSET >> 2] & \
  287. RX_MPDU_DESC_INFO_0_MPDU_RETRY_BIT_MASK)
  288. #define HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) \
  289. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_AMPDU_FLAG_OFFSET >> 2] & \
  290. RX_MPDU_DESC_INFO_0_AMPDU_FLAG_MASK)
  291. #define HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr) \
  292. (mpdu_info_ptr[RX_MPDU_DESC_INFO_0_RAW_MPDU_OFFSET >> 2] & \
  293. RX_MPDU_DESC_INFO_0_RAW_MPDU_MASK)
  294. #define HAL_RX_MPDU_FLAGS_GET(mpdu_info_ptr) \
  295. (HAL_RX_MPDU_FRAGMENT_FLAG_GET(mpdu_info_ptr) | \
  296. HAL_RX_MPDU_RETRY_BIT_GET(mpdu_info_ptr) | \
  297. HAL_RX_MPDU_AMPDU_FLAG_GET(mpdu_info_ptr) | \
  298. HAL_RX_MPDU_RAW_MPDU_GET(mpdu_info_ptr))
  299. #define HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info_ptr) \
  300. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  301. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_OFFSET)), \
  302. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_MASK, \
  303. RX_MSDU_DESC_INFO_0_MSDU_LENGTH_LSB))
  304. /*
  305. * NOTE: None of the following _GET macros need a right
  306. * shift by the corresponding _LSB. This is because, they are
  307. * finally taken and "OR'ed" into a single word again.
  308. */
  309. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  310. ((*(((uint32_t *)msdu_info_ptr) + \
  311. (RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  312. (val << RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_LSB) & \
  313. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  314. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_info_ptr, val) \
  315. ((*(((uint32_t *)msdu_info_ptr) + \
  316. (RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET >> 2))) |= \
  317. (val << RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_LSB) & \
  318. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  319. #define HAL_RX_MSDU_CONTINUATION_FLAG_SET(msdu_info_ptr, val) \
  320. ((*(((uint32_t *)msdu_info_ptr) + \
  321. (RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET >> 2))) |= \
  322. (val << RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_LSB) & \
  323. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  324. #define HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  325. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  326. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  327. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK)
  328. #define HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) \
  329. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  330. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_OFFSET)) & \
  331. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK)
  332. #define HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) \
  333. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  334. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_OFFSET)) & \
  335. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK)
  336. #define HAL_RX_MSDU_REO_DST_IND_GET(msdu_info_ptr) \
  337. (_HAL_MS((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  338. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_OFFSET)), \
  339. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_MASK, \
  340. RX_MSDU_DESC_INFO_0_REO_DESTINATION_INDICATION_LSB))
  341. #define HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  342. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  343. RX_MSDU_DESC_INFO_0_SA_IS_VALID_OFFSET)) & \
  344. RX_MSDU_DESC_INFO_0_SA_IS_VALID_MASK)
  345. #define HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  346. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  347. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_OFFSET)) & \
  348. RX_MSDU_DESC_INFO_0_SA_IDX_TIMEOUT_MASK)
  349. #define HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) \
  350. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  351. RX_MSDU_DESC_INFO_0_DA_IS_VALID_OFFSET)) & \
  352. RX_MSDU_DESC_INFO_0_DA_IS_VALID_MASK)
  353. #define HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) \
  354. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  355. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_OFFSET)) & \
  356. RX_MSDU_DESC_INFO_0_DA_IS_MCBC_MASK)
  357. #define HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) \
  358. ((*_OFFSET_TO_WORD_PTR(msdu_info_ptr, \
  359. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_OFFSET)) & \
  360. RX_MSDU_DESC_INFO_0_DA_IDX_TIMEOUT_MASK)
  361. #define HAL_RX_MSDU_FLAGS_GET(msdu_info_ptr) \
  362. (HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  363. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_GET(msdu_info_ptr) | \
  364. HAL_RX_MSDU_CONTINUATION_FLAG_GET(msdu_info_ptr) | \
  365. HAL_RX_MSDU_SA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  366. HAL_RX_MSDU_SA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr) | \
  367. HAL_RX_MSDU_DA_IS_VALID_FLAG_GET(msdu_info_ptr) | \
  368. HAL_RX_MSDU_DA_IS_MCBC_FLAG_GET(msdu_info_ptr) | \
  369. HAL_RX_MSDU_DA_IDX_TIMEOUT_FLAG_GET(msdu_info_ptr))
  370. #define HAL_RX_MPDU_ENCRYPT_TYPE_GET(_rx_mpdu_info) \
  371. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  372. RX_MPDU_INFO_3_ENCRYPT_TYPE_OFFSET)), \
  373. RX_MPDU_INFO_3_ENCRYPT_TYPE_MASK, \
  374. RX_MPDU_INFO_3_ENCRYPT_TYPE_LSB))
  375. #define HAL_RX_FLD_SET(_ptr, _wrd, _field, _val) \
  376. (*(uint32_t *)(((uint8_t *)_ptr) + \
  377. _wrd ## _ ## _field ## _OFFSET) |= \
  378. ((_val << _wrd ## _ ## _field ## _LSB) & \
  379. _wrd ## _ ## _field ## _MASK))
  380. #define HAL_RX_UNIFORM_HDR_SET(_rx_msdu_link, _field, _val) \
  381. HAL_RX_FLD_SET(_rx_msdu_link, UNIFORM_DESCRIPTOR_HEADER_0, \
  382. _field, _val)
  383. #define HAL_RX_MSDU_DESC_INFO_SET(_msdu_info_ptr, _field, _val) \
  384. HAL_RX_FLD_SET(_msdu_info_ptr, RX_MSDU_DESC_INFO_0, \
  385. _field, _val)
  386. #define HAL_RX_MPDU_DESC_INFO_SET(_mpdu_info_ptr, _field, _val) \
  387. HAL_RX_FLD_SET(_mpdu_info_ptr, RX_MPDU_DESC_INFO_0, \
  388. _field, _val)
  389. static inline void hal_rx_mpdu_desc_info_get(void *desc_addr,
  390. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  391. {
  392. struct reo_destination_ring *reo_dst_ring;
  393. uint32_t *mpdu_info;
  394. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  395. mpdu_info = (uint32_t *)&reo_dst_ring->rx_mpdu_desc_info_details;
  396. mpdu_desc_info->msdu_count = HAL_RX_MPDU_MSDU_COUNT_GET(mpdu_info);
  397. mpdu_desc_info->mpdu_seq = HAL_RX_MPDU_SEQUENCE_NUMBER_GET(mpdu_info);
  398. mpdu_desc_info->mpdu_flags = HAL_RX_MPDU_FLAGS_GET(mpdu_info);
  399. mpdu_desc_info->peer_meta_data =
  400. HAL_RX_MPDU_DESC_PEER_META_DATA_GET(mpdu_info);
  401. }
  402. /*
  403. * @ hal_rx_msdu_desc_info_get: Gets the flags related to MSDU desciptor.
  404. * @ Specifically flags needed are:
  405. * @ first_msdu_in_mpdu, last_msdu_in_mpdu,
  406. * @ msdu_continuation, sa_is_valid,
  407. * @ sa_idx_timeout, da_is_valid, da_idx_timeout,
  408. * @ da_is_MCBC
  409. *
  410. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to the current
  411. * @ descriptor
  412. * @ msdu_desc_info: Holds MSDU descriptor info from HAL Rx descriptor
  413. * @ Return: void
  414. */
  415. static inline void hal_rx_msdu_desc_info_get(void *desc_addr,
  416. struct hal_rx_msdu_desc_info *msdu_desc_info)
  417. {
  418. struct reo_destination_ring *reo_dst_ring;
  419. uint32_t *msdu_info;
  420. reo_dst_ring = (struct reo_destination_ring *) desc_addr;
  421. msdu_info = (uint32_t *)&reo_dst_ring->rx_msdu_desc_info_details;
  422. msdu_desc_info->msdu_flags = HAL_RX_MSDU_FLAGS_GET(msdu_info);
  423. msdu_desc_info->msdu_len = HAL_RX_MSDU_PKT_LENGTH_GET(msdu_info);
  424. }
  425. /*
  426. * hal_rxdma_buff_addr_info_set() - set the buffer_addr_info of the
  427. * rxdma ring entry.
  428. * @rxdma_entry: descriptor entry
  429. * @paddr: physical address of nbuf data pointer.
  430. * @cookie: SW cookie used as a index to SW rx desc.
  431. * @manager: who owns the nbuf (host, NSS, etc...).
  432. *
  433. */
  434. static inline void hal_rxdma_buff_addr_info_set(void *rxdma_entry,
  435. qdf_dma_addr_t paddr, uint32_t cookie, uint8_t manager)
  436. {
  437. uint32_t paddr_lo = ((u64)paddr & 0x00000000ffffffff);
  438. uint32_t paddr_hi = ((u64)paddr & 0xffffffff00000000) >> 32;
  439. HAL_RXDMA_PADDR_LO_SET(rxdma_entry, paddr_lo);
  440. HAL_RXDMA_PADDR_HI_SET(rxdma_entry, paddr_hi);
  441. HAL_RXDMA_COOKIE_SET(rxdma_entry, cookie);
  442. HAL_RXDMA_MANAGER_SET(rxdma_entry, manager);
  443. }
  444. /*
  445. * Structures & Macros to obtain fields from the TLV's in the Rx packet
  446. * pre-header.
  447. */
  448. /*
  449. * Every Rx packet starts at an offset from the top of the buffer.
  450. * If the host hasn't subscribed to any specific TLV, there is
  451. * still space reserved for the following TLV's from the start of
  452. * the buffer:
  453. * -- RX ATTENTION
  454. * -- RX MPDU START
  455. * -- RX MSDU START
  456. * -- RX MSDU END
  457. * -- RX MPDU END
  458. * -- RX PACKET HEADER (802.11)
  459. * If the host subscribes to any of the TLV's above, that TLV
  460. * if populated by the HW
  461. */
  462. #define NUM_DWORDS_TAG 1
  463. /* By default the packet header TLV is 128 bytes */
  464. #define NUM_OF_BYTES_RX_802_11_HDR_TLV 128
  465. #define NUM_OF_DWORDS_RX_802_11_HDR_TLV \
  466. (NUM_OF_BYTES_RX_802_11_HDR_TLV >> 2)
  467. #define RX_PKT_OFFSET_WORDS \
  468. ( \
  469. NUM_OF_DWORDS_RX_ATTENTION + NUM_DWORDS_TAG \
  470. NUM_OF_DWORDS_RX_MPDU_START + NUM_DWORDS_TAG \
  471. NUM_OF_DWORDS_RX_MSDU_START + NUM_DWORDS_TAG \
  472. NUM_OF_DWORDS_RX_MSDU_END + NUM_DWORDS_TAG \
  473. NUM_OF_DWORDS_RX_MPDU_END + NUM_DWORDS_TAG \
  474. NUM_OF_DWORDS_RX_802_11_HDR_TLV + NUM_DWORDS_TAG \
  475. )
  476. #define RX_PKT_OFFSET_BYTES \
  477. (RX_PKT_OFFSET_WORDS << 2)
  478. #define RX_PKT_HDR_TLV_LEN 120
  479. /*
  480. * Each RX descriptor TLV is preceded by 1 DWORD "tag"
  481. */
  482. struct rx_attention_tlv {
  483. uint32_t tag;
  484. struct rx_attention rx_attn;
  485. };
  486. struct rx_mpdu_start_tlv {
  487. uint32_t tag;
  488. struct rx_mpdu_start rx_mpdu_start;
  489. };
  490. struct rx_msdu_start_tlv {
  491. uint32_t tag;
  492. struct rx_msdu_start rx_msdu_start;
  493. };
  494. struct rx_msdu_end_tlv {
  495. uint32_t tag;
  496. struct rx_msdu_end rx_msdu_end;
  497. };
  498. struct rx_mpdu_end_tlv {
  499. uint32_t tag;
  500. struct rx_mpdu_end rx_mpdu_end;
  501. };
  502. struct rx_pkt_hdr_tlv {
  503. uint32_t tag; /* 4 B */
  504. uint32_t phy_ppdu_id; /* 4 B */
  505. char rx_pkt_hdr[RX_PKT_HDR_TLV_LEN]; /* 120 B */
  506. };
  507. #define RXDMA_OPTIMIZATION
  508. /* rx_pkt_tlvs structure should be used to process Data buffers, monitor status
  509. * buffers, monitor destination buffers and monitor descriptor buffers.
  510. */
  511. #ifdef RXDMA_OPTIMIZATION
  512. /*
  513. * The RX_PADDING_BYTES is required so that the TLV's don't
  514. * spread across the 128 byte boundary
  515. * RXDMA optimization requires:
  516. * 1) MSDU_END & ATTENTION TLV's follow in that order
  517. * 2) TLV's don't span across 128 byte lines
  518. * 3) Rx Buffer is nicely aligned on the 128 byte boundary
  519. */
  520. #define RX_PADDING0_BYTES 4
  521. #define RX_PADDING1_BYTES 16
  522. struct rx_pkt_tlvs {
  523. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  524. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  525. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  526. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  527. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  528. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  529. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  530. #ifndef NO_RX_PKT_HDR_TLV
  531. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  532. #endif
  533. };
  534. #else /* RXDMA_OPTIMIZATION */
  535. struct rx_pkt_tlvs {
  536. struct rx_attention_tlv attn_tlv;
  537. struct rx_mpdu_start_tlv mpdu_start_tlv;
  538. struct rx_msdu_start_tlv msdu_start_tlv;
  539. struct rx_msdu_end_tlv msdu_end_tlv;
  540. struct rx_mpdu_end_tlv mpdu_end_tlv;
  541. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  542. };
  543. #endif /* RXDMA_OPTIMIZATION */
  544. /* rx_mon_pkt_tlvs structure should be used to process monitor data buffers */
  545. #ifdef RXDMA_OPTIMIZATION
  546. struct rx_mon_pkt_tlvs {
  547. struct rx_msdu_end_tlv msdu_end_tlv; /* 72 bytes */
  548. struct rx_attention_tlv attn_tlv; /* 16 bytes */
  549. struct rx_msdu_start_tlv msdu_start_tlv;/* 40 bytes */
  550. uint8_t rx_padding0[RX_PADDING0_BYTES]; /* 4 bytes */
  551. struct rx_mpdu_start_tlv mpdu_start_tlv;/* 96 bytes */
  552. struct rx_mpdu_end_tlv mpdu_end_tlv; /* 12 bytes */
  553. uint8_t rx_padding1[RX_PADDING1_BYTES]; /* 16 bytes */
  554. struct rx_pkt_hdr_tlv pkt_hdr_tlv; /* 128 bytes */
  555. };
  556. #else /* RXDMA_OPTIMIZATION */
  557. struct rx_mon_pkt_tlvs {
  558. struct rx_attention_tlv attn_tlv;
  559. struct rx_mpdu_start_tlv mpdu_start_tlv;
  560. struct rx_msdu_start_tlv msdu_start_tlv;
  561. struct rx_msdu_end_tlv msdu_end_tlv;
  562. struct rx_mpdu_end_tlv mpdu_end_tlv;
  563. struct rx_pkt_hdr_tlv pkt_hdr_tlv;
  564. };
  565. #endif
  566. #define SIZE_OF_MONITOR_TLV sizeof(struct rx_mon_pkt_tlvs)
  567. #define SIZE_OF_DATA_RX_TLV sizeof(struct rx_pkt_tlvs)
  568. #define RX_PKT_TLVS_LEN SIZE_OF_DATA_RX_TLV
  569. #ifdef NO_RX_PKT_HDR_TLV
  570. static inline uint8_t
  571. *hal_rx_pkt_hdr_get(uint8_t *buf)
  572. {
  573. return buf + RX_PKT_TLVS_LEN;
  574. }
  575. #else
  576. static inline uint8_t
  577. *hal_rx_pkt_hdr_get(uint8_t *buf)
  578. {
  579. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  580. return pkt_tlvs->pkt_hdr_tlv.rx_pkt_hdr;
  581. }
  582. #endif
  583. #define RX_PKT_TLV_OFFSET(field) qdf_offsetof(struct rx_pkt_tlvs, field)
  584. #define HAL_RX_PKT_TLV_MPDU_START_OFFSET(hal_soc) \
  585. RX_PKT_TLV_OFFSET(mpdu_start_tlv)
  586. #define HAL_RX_PKT_TLV_MPDU_END_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(mpdu_end_tlv)
  587. #define HAL_RX_PKT_TLV_MSDU_START_OFFSET(hal_soc) \
  588. RX_PKT_TLV_OFFSET(msdu_start_tlv)
  589. #define HAL_RX_PKT_TLV_MSDU_END_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(msdu_end_tlv)
  590. #define HAL_RX_PKT_TLV_ATTN_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(attn_tlv)
  591. #define HAL_RX_PKT_TLV_PKT_HDR_OFFSET(hal_soc) RX_PKT_TLV_OFFSET(pkt_hdr_tlv)
  592. static inline uint8_t
  593. *hal_rx_padding0_get(uint8_t *buf)
  594. {
  595. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  596. return pkt_tlvs->rx_padding0;
  597. }
  598. /*
  599. * hal_rx_encryption_info_valid(): Returns encryption type.
  600. *
  601. * @hal_soc_hdl: hal soc handle
  602. * @buf: rx_tlv_hdr of the received packet
  603. *
  604. * Return: encryption type
  605. */
  606. static inline uint32_t
  607. hal_rx_encryption_info_valid(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  608. {
  609. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  610. return hal_soc->ops->hal_rx_encryption_info_valid(buf);
  611. }
  612. /*
  613. * hal_rx_print_pn: Prints the PN of rx packet.
  614. * @hal_soc_hdl: hal soc handle
  615. * @buf: rx_tlv_hdr of the received packet
  616. *
  617. * Return: void
  618. */
  619. static inline void
  620. hal_rx_print_pn(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  621. {
  622. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  623. hal_soc->ops->hal_rx_print_pn(buf);
  624. }
  625. /*
  626. * Get msdu_done bit from the RX_ATTENTION TLV
  627. */
  628. #define HAL_RX_ATTN_MSDU_DONE_GET(_rx_attn) \
  629. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  630. RX_ATTENTION_2_MSDU_DONE_OFFSET)), \
  631. RX_ATTENTION_2_MSDU_DONE_MASK, \
  632. RX_ATTENTION_2_MSDU_DONE_LSB))
  633. static inline uint32_t
  634. hal_rx_attn_msdu_done_get(uint8_t *buf)
  635. {
  636. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  637. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  638. uint32_t msdu_done;
  639. msdu_done = HAL_RX_ATTN_MSDU_DONE_GET(rx_attn);
  640. return msdu_done;
  641. }
  642. #define HAL_RX_ATTN_FIRST_MPDU_GET(_rx_attn) \
  643. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  644. RX_ATTENTION_1_FIRST_MPDU_OFFSET)), \
  645. RX_ATTENTION_1_FIRST_MPDU_MASK, \
  646. RX_ATTENTION_1_FIRST_MPDU_LSB))
  647. /*
  648. * hal_rx_attn_first_mpdu_get(): get fist_mpdu bit from rx attention
  649. * @buf: pointer to rx_pkt_tlvs
  650. *
  651. * reutm: uint32_t(first_msdu)
  652. */
  653. static inline uint32_t
  654. hal_rx_attn_first_mpdu_get(uint8_t *buf)
  655. {
  656. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  657. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  658. uint32_t first_mpdu;
  659. first_mpdu = HAL_RX_ATTN_FIRST_MPDU_GET(rx_attn);
  660. return first_mpdu;
  661. }
  662. #define HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(_rx_attn) \
  663. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  664. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_OFFSET)), \
  665. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_MASK, \
  666. RX_ATTENTION_1_TCP_UDP_CHKSUM_FAIL_LSB))
  667. /*
  668. * hal_rx_attn_tcp_udp_cksum_fail_get(): get tcp_udp cksum fail bit
  669. * from rx attention
  670. * @buf: pointer to rx_pkt_tlvs
  671. *
  672. * Return: tcp_udp_cksum_fail
  673. */
  674. static inline bool
  675. hal_rx_attn_tcp_udp_cksum_fail_get(uint8_t *buf)
  676. {
  677. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  678. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  679. bool tcp_udp_cksum_fail;
  680. tcp_udp_cksum_fail = HAL_RX_ATTN_TCP_UDP_CKSUM_FAIL_GET(rx_attn);
  681. return tcp_udp_cksum_fail;
  682. }
  683. #define HAL_RX_ATTN_IP_CKSUM_FAIL_GET(_rx_attn) \
  684. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  685. RX_ATTENTION_1_IP_CHKSUM_FAIL_OFFSET)), \
  686. RX_ATTENTION_1_IP_CHKSUM_FAIL_MASK, \
  687. RX_ATTENTION_1_IP_CHKSUM_FAIL_LSB))
  688. /*
  689. * hal_rx_attn_ip_cksum_fail_get(): get ip cksum fail bit
  690. * from rx attention
  691. * @buf: pointer to rx_pkt_tlvs
  692. *
  693. * Return: ip_cksum_fail
  694. */
  695. static inline bool
  696. hal_rx_attn_ip_cksum_fail_get(uint8_t *buf)
  697. {
  698. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  699. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  700. bool ip_cksum_fail;
  701. ip_cksum_fail = HAL_RX_ATTN_IP_CKSUM_FAIL_GET(rx_attn);
  702. return ip_cksum_fail;
  703. }
  704. #define HAL_RX_ATTN_PHY_PPDU_ID_GET(_rx_attn) \
  705. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  706. RX_ATTENTION_0_PHY_PPDU_ID_OFFSET)), \
  707. RX_ATTENTION_0_PHY_PPDU_ID_MASK, \
  708. RX_ATTENTION_0_PHY_PPDU_ID_LSB))
  709. /*
  710. * hal_rx_attn_phy_ppdu_id_get(): get phy_ppdu_id value
  711. * from rx attention
  712. * @buf: pointer to rx_pkt_tlvs
  713. *
  714. * Return: phy_ppdu_id
  715. */
  716. static inline uint16_t
  717. hal_rx_attn_phy_ppdu_id_get(uint8_t *buf)
  718. {
  719. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  720. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  721. uint16_t phy_ppdu_id;
  722. phy_ppdu_id = HAL_RX_ATTN_PHY_PPDU_ID_GET(rx_attn);
  723. return phy_ppdu_id;
  724. }
  725. #define HAL_RX_ATTN_CCE_MATCH_GET(_rx_attn) \
  726. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  727. RX_ATTENTION_1_CCE_MATCH_OFFSET)), \
  728. RX_ATTENTION_1_CCE_MATCH_MASK, \
  729. RX_ATTENTION_1_CCE_MATCH_LSB))
  730. /*
  731. * hal_rx_msdu_cce_match_get(): get CCE match bit
  732. * from rx attention
  733. * @buf: pointer to rx_pkt_tlvs
  734. * Return: CCE match value
  735. */
  736. static inline bool
  737. hal_rx_msdu_cce_match_get(uint8_t *buf)
  738. {
  739. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  740. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  741. bool cce_match_val;
  742. cce_match_val = HAL_RX_ATTN_CCE_MATCH_GET(rx_attn);
  743. return cce_match_val;
  744. }
  745. /*
  746. * Get peer_meta_data from RX_MPDU_INFO within RX_MPDU_START
  747. */
  748. #define HAL_RX_MPDU_PEER_META_DATA_GET(_rx_mpdu_info) \
  749. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  750. RX_MPDU_INFO_8_PEER_META_DATA_OFFSET)), \
  751. RX_MPDU_INFO_8_PEER_META_DATA_MASK, \
  752. RX_MPDU_INFO_8_PEER_META_DATA_LSB))
  753. static inline uint32_t
  754. hal_rx_mpdu_peer_meta_data_get(uint8_t *buf)
  755. {
  756. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  757. struct rx_mpdu_start *mpdu_start =
  758. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  759. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  760. uint32_t peer_meta_data;
  761. peer_meta_data = HAL_RX_MPDU_PEER_META_DATA_GET(mpdu_info);
  762. return peer_meta_data;
  763. }
  764. #define HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(_rx_mpdu_info) \
  765. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  766. RX_MPDU_INFO_12_AMPDU_FLAG_OFFSET)), \
  767. RX_MPDU_INFO_12_AMPDU_FLAG_MASK, \
  768. RX_MPDU_INFO_12_AMPDU_FLAG_LSB))
  769. /**
  770. * hal_rx_mpdu_info_ampdu_flag_get(): get ampdu flag bit
  771. * from rx mpdu info
  772. * @buf: pointer to rx_pkt_tlvs
  773. *
  774. * Return: ampdu flag
  775. */
  776. static inline bool
  777. hal_rx_mpdu_info_ampdu_flag_get(uint8_t *buf)
  778. {
  779. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  780. struct rx_mpdu_start *mpdu_start =
  781. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  782. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  783. bool ampdu_flag;
  784. ampdu_flag = HAL_RX_MPDU_INFO_AMPDU_FLAG_GET(mpdu_info);
  785. return ampdu_flag;
  786. }
  787. #define HAL_RX_MPDU_PEER_META_DATA_SET(_rx_mpdu_info, peer_mdata) \
  788. ((*(((uint32_t *)_rx_mpdu_info) + \
  789. (RX_MPDU_INFO_8_PEER_META_DATA_OFFSET >> 2))) = \
  790. (peer_mdata << RX_MPDU_INFO_8_PEER_META_DATA_LSB) & \
  791. RX_MPDU_INFO_8_PEER_META_DATA_MASK)
  792. /*
  793. * @ hal_rx_mpdu_peer_meta_data_set: set peer meta data in RX mpdu start tlv
  794. *
  795. * @ buf: rx_tlv_hdr of the received packet
  796. * @ peer_mdata: peer meta data to be set.
  797. * @ Return: void
  798. */
  799. static inline void
  800. hal_rx_mpdu_peer_meta_data_set(uint8_t *buf, uint32_t peer_mdata)
  801. {
  802. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  803. struct rx_mpdu_start *mpdu_start =
  804. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  805. struct rx_mpdu_info *mpdu_info = &mpdu_start->rx_mpdu_info_details;
  806. HAL_RX_MPDU_PEER_META_DATA_SET(mpdu_info, peer_mdata);
  807. }
  808. /**
  809. * LRO information needed from the TLVs
  810. */
  811. #define HAL_RX_TLV_GET_LRO_ELIGIBLE(buf) \
  812. (_HAL_MS( \
  813. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  814. msdu_end_tlv.rx_msdu_end), \
  815. RX_MSDU_END_9_LRO_ELIGIBLE_OFFSET)), \
  816. RX_MSDU_END_9_LRO_ELIGIBLE_MASK, \
  817. RX_MSDU_END_9_LRO_ELIGIBLE_LSB))
  818. #define HAL_RX_TLV_GET_TCP_ACK(buf) \
  819. (_HAL_MS( \
  820. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  821. msdu_end_tlv.rx_msdu_end), \
  822. RX_MSDU_END_8_TCP_ACK_NUMBER_OFFSET)), \
  823. RX_MSDU_END_8_TCP_ACK_NUMBER_MASK, \
  824. RX_MSDU_END_8_TCP_ACK_NUMBER_LSB))
  825. #define HAL_RX_TLV_GET_TCP_SEQ(buf) \
  826. (_HAL_MS( \
  827. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  828. msdu_end_tlv.rx_msdu_end), \
  829. RX_MSDU_END_7_TCP_SEQ_NUMBER_OFFSET)), \
  830. RX_MSDU_END_7_TCP_SEQ_NUMBER_MASK, \
  831. RX_MSDU_END_7_TCP_SEQ_NUMBER_LSB))
  832. #define HAL_RX_TLV_GET_TCP_WIN(buf) \
  833. (_HAL_MS( \
  834. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  835. msdu_end_tlv.rx_msdu_end), \
  836. RX_MSDU_END_9_WINDOW_SIZE_OFFSET)), \
  837. RX_MSDU_END_9_WINDOW_SIZE_MASK, \
  838. RX_MSDU_END_9_WINDOW_SIZE_LSB))
  839. #define HAL_RX_TLV_GET_TCP_PURE_ACK(buf) \
  840. (_HAL_MS( \
  841. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  842. msdu_start_tlv.rx_msdu_start), \
  843. RX_MSDU_START_2_TCP_ONLY_ACK_OFFSET)), \
  844. RX_MSDU_START_2_TCP_ONLY_ACK_MASK, \
  845. RX_MSDU_START_2_TCP_ONLY_ACK_LSB))
  846. #define HAL_RX_TLV_GET_TCP_PROTO(buf) \
  847. (_HAL_MS( \
  848. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  849. msdu_start_tlv.rx_msdu_start), \
  850. RX_MSDU_START_2_TCP_PROTO_OFFSET)), \
  851. RX_MSDU_START_2_TCP_PROTO_MASK, \
  852. RX_MSDU_START_2_TCP_PROTO_LSB))
  853. #define HAL_RX_TLV_GET_UDP_PROTO(buf) \
  854. (_HAL_MS( \
  855. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  856. msdu_start_tlv.rx_msdu_start), \
  857. RX_MSDU_START_2_UDP_PROTO_OFFSET)), \
  858. RX_MSDU_START_2_UDP_PROTO_MASK, \
  859. RX_MSDU_START_2_UDP_PROTO_LSB))
  860. #define HAL_RX_TLV_GET_IPV6(buf) \
  861. (_HAL_MS( \
  862. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  863. msdu_start_tlv.rx_msdu_start), \
  864. RX_MSDU_START_2_IPV6_PROTO_OFFSET)), \
  865. RX_MSDU_START_2_IPV6_PROTO_MASK, \
  866. RX_MSDU_START_2_IPV6_PROTO_LSB))
  867. #define HAL_RX_TLV_GET_IP_OFFSET(buf) \
  868. (_HAL_MS( \
  869. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  870. msdu_start_tlv.rx_msdu_start), \
  871. RX_MSDU_START_1_L3_OFFSET_OFFSET)), \
  872. RX_MSDU_START_1_L3_OFFSET_MASK, \
  873. RX_MSDU_START_1_L3_OFFSET_LSB))
  874. #define HAL_RX_TLV_GET_TCP_OFFSET(buf) \
  875. (_HAL_MS( \
  876. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  877. msdu_start_tlv.rx_msdu_start), \
  878. RX_MSDU_START_1_L4_OFFSET_OFFSET)), \
  879. RX_MSDU_START_1_L4_OFFSET_MASK, \
  880. RX_MSDU_START_1_L4_OFFSET_LSB))
  881. #define HAL_RX_TLV_GET_FLOW_ID_TOEPLITZ(buf) \
  882. (_HAL_MS( \
  883. (*_OFFSET_TO_WORD_PTR(&(((struct rx_pkt_tlvs *)(buf))->\
  884. msdu_start_tlv.rx_msdu_start), \
  885. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  886. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  887. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  888. /**
  889. * hal_rx_msdu_end_l3_hdr_padding_get(): API to get the
  890. * l3_header padding from rx_msdu_end TLV
  891. *
  892. * @buf: pointer to the start of RX PKT TLV headers
  893. * Return: number of l3 header padding bytes
  894. */
  895. static inline uint32_t
  896. hal_rx_msdu_end_l3_hdr_padding_get(hal_soc_handle_t hal_soc_hdl,
  897. uint8_t *buf)
  898. {
  899. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  900. return hal_soc->ops->hal_rx_msdu_end_l3_hdr_padding_get(buf);
  901. }
  902. /**
  903. * hal_rx_msdu_end_sa_idx_get(): API to get the
  904. * sa_idx from rx_msdu_end TLV
  905. *
  906. * @ buf: pointer to the start of RX PKT TLV headers
  907. * Return: sa_idx (SA AST index)
  908. */
  909. static inline uint16_t
  910. hal_rx_msdu_end_sa_idx_get(hal_soc_handle_t hal_soc_hdl,
  911. uint8_t *buf)
  912. {
  913. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  914. return hal_soc->ops->hal_rx_msdu_end_sa_idx_get(buf);
  915. }
  916. /**
  917. * hal_rx_msdu_end_sa_is_valid_get(): API to get the
  918. * sa_is_valid bit from rx_msdu_end TLV
  919. *
  920. * @ buf: pointer to the start of RX PKT TLV headers
  921. * Return: sa_is_valid bit
  922. */
  923. static inline uint8_t
  924. hal_rx_msdu_end_sa_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  925. uint8_t *buf)
  926. {
  927. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  928. return hal_soc->ops->hal_rx_msdu_end_sa_is_valid_get(buf);
  929. }
  930. #define HAL_RX_MSDU_START_MSDU_LEN_GET(_rx_msdu_start) \
  931. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  932. RX_MSDU_START_1_MSDU_LENGTH_OFFSET)), \
  933. RX_MSDU_START_1_MSDU_LENGTH_MASK, \
  934. RX_MSDU_START_1_MSDU_LENGTH_LSB))
  935. /**
  936. * hal_rx_msdu_start_msdu_len_get(): API to get the MSDU length
  937. * from rx_msdu_start TLV
  938. *
  939. * @ buf: pointer to the start of RX PKT TLV headers
  940. * Return: msdu length
  941. */
  942. static inline uint32_t
  943. hal_rx_msdu_start_msdu_len_get(uint8_t *buf)
  944. {
  945. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  946. struct rx_msdu_start *msdu_start =
  947. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  948. uint32_t msdu_len;
  949. msdu_len = HAL_RX_MSDU_START_MSDU_LEN_GET(msdu_start);
  950. return msdu_len;
  951. }
  952. /**
  953. * hal_rx_msdu_start_msdu_len_set(): API to set the MSDU length
  954. * from rx_msdu_start TLV
  955. *
  956. * @buf: pointer to the start of RX PKT TLV headers
  957. * @len: msdu length
  958. *
  959. * Return: none
  960. */
  961. static inline void
  962. hal_rx_msdu_start_msdu_len_set(uint8_t *buf, uint32_t len)
  963. {
  964. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  965. struct rx_msdu_start *msdu_start =
  966. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  967. void *wrd1;
  968. wrd1 = (uint8_t *)msdu_start + RX_MSDU_START_1_MSDU_LENGTH_OFFSET;
  969. *(uint32_t *)wrd1 &= (~RX_MSDU_START_1_MSDU_LENGTH_MASK);
  970. *(uint32_t *)wrd1 |= len;
  971. }
  972. #define HAL_RX_MSDU_START_BW_GET(_rx_msdu_start) \
  973. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  974. RX_MSDU_START_5_RECEIVE_BANDWIDTH_OFFSET)), \
  975. RX_MSDU_START_5_RECEIVE_BANDWIDTH_MASK, \
  976. RX_MSDU_START_5_RECEIVE_BANDWIDTH_LSB))
  977. /*
  978. * hal_rx_msdu_start_bw_get(): API to get the Bandwidth
  979. * Interval from rx_msdu_start
  980. *
  981. * @buf: pointer to the start of RX PKT TLV header
  982. * Return: uint32_t(bw)
  983. */
  984. static inline uint32_t
  985. hal_rx_msdu_start_bw_get(uint8_t *buf)
  986. {
  987. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  988. struct rx_msdu_start *msdu_start =
  989. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  990. uint32_t bw;
  991. bw = HAL_RX_MSDU_START_BW_GET(msdu_start);
  992. return bw;
  993. }
  994. #define HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(_rx_msdu_start) \
  995. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  996. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_OFFSET)), \
  997. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_MASK, \
  998. RX_MSDU_START_4_FLOW_ID_TOEPLITZ_LSB))
  999. /**
  1000. * hal_rx_msdu_start_toeplitz_get: API to get the toeplitz hash
  1001. * from rx_msdu_start TLV
  1002. *
  1003. * @ buf: pointer to the start of RX PKT TLV headers
  1004. * Return: toeplitz hash
  1005. */
  1006. static inline uint32_t
  1007. hal_rx_msdu_start_toeplitz_get(uint8_t *buf)
  1008. {
  1009. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1010. struct rx_msdu_start *msdu_start =
  1011. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1012. return HAL_RX_MSDU_START_FLOWID_TOEPLITZ_GET(msdu_start);
  1013. }
  1014. /**
  1015. * enum hal_rx_mpdu_info_sw_frame_group_id_type: Enum for group id in MPDU_INFO
  1016. *
  1017. * @ HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME: NDP frame
  1018. * @ HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA: multicast data frame
  1019. * @ HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA: unicast data frame
  1020. * @ HAL_MPDU_SW_FRAME_GROUP_NULL_DATA: NULL data frame
  1021. * @ HAL_MPDU_SW_FRAME_GROUP_MGMT: management frame
  1022. * @ HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ: probe req frame
  1023. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL: control frame
  1024. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA: NDPA frame
  1025. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR: BAR frame
  1026. * @ HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS: RTS frame
  1027. * @ HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED: unsupported
  1028. * @ HAL_MPDU_SW_FRAME_GROUP_MAX: max limit
  1029. */
  1030. enum hal_rx_mpdu_info_sw_frame_group_id_type {
  1031. HAL_MPDU_SW_FRAME_GROUP_NDP_FRAME = 0,
  1032. HAL_MPDU_SW_FRAME_GROUP_MULTICAST_DATA,
  1033. HAL_MPDU_SW_FRAME_GROUP_UNICAST_DATA,
  1034. HAL_MPDU_SW_FRAME_GROUP_NULL_DATA,
  1035. HAL_MPDU_SW_FRAME_GROUP_MGMT,
  1036. HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ = 8,
  1037. HAL_MPDU_SW_FRAME_GROUP_MGMT_BEACON = 12,
  1038. HAL_MPDU_SW_FRAME_GROUP_CTRL = 20,
  1039. HAL_MPDU_SW_FRAME_GROUP_CTRL_NDPA = 25,
  1040. HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR = 28,
  1041. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS = 31,
  1042. HAL_MPDU_SW_FRAME_GROUP_UNSUPPORTED = 36,
  1043. HAL_MPDU_SW_FRAME_GROUP_MAX = 37,
  1044. };
  1045. /**
  1046. * hal_rx_mpdu_start_mpdu_qos_control_valid_get():
  1047. * Retrieve qos control valid bit from the tlv.
  1048. * @hal_soc_hdl: hal_soc handle
  1049. * @buf: pointer to rx pkt TLV.
  1050. *
  1051. * Return: qos control value.
  1052. */
  1053. static inline uint32_t
  1054. hal_rx_mpdu_start_mpdu_qos_control_valid_get(
  1055. hal_soc_handle_t hal_soc_hdl,
  1056. uint8_t *buf)
  1057. {
  1058. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1059. if ((!hal_soc) || (!hal_soc->ops)) {
  1060. hal_err("hal handle is NULL");
  1061. QDF_BUG(0);
  1062. return QDF_STATUS_E_INVAL;
  1063. }
  1064. if (hal_soc->ops->hal_rx_mpdu_start_mpdu_qos_control_valid_get)
  1065. return hal_soc->ops->
  1066. hal_rx_mpdu_start_mpdu_qos_control_valid_get(buf);
  1067. return QDF_STATUS_E_INVAL;
  1068. }
  1069. /**
  1070. * hal_rx_is_unicast: check packet is unicast frame or not.
  1071. * @hal_soc_hdl: hal_soc handle
  1072. * @buf: pointer to rx pkt TLV.
  1073. *
  1074. * Return: true on unicast.
  1075. */
  1076. static inline bool
  1077. hal_rx_is_unicast(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1078. {
  1079. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1080. return hal_soc->ops->hal_rx_is_unicast(buf);
  1081. }
  1082. /**
  1083. * hal_rx_tid_get: get tid based on qos control valid.
  1084. * @hal_soc_hdl: hal soc handle
  1085. * @buf: pointer to rx pkt TLV.
  1086. *
  1087. * Return: tid
  1088. */
  1089. static inline uint32_t
  1090. hal_rx_tid_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1091. {
  1092. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1093. return hal_soc->ops->hal_rx_tid_get(hal_soc_hdl, buf);
  1094. }
  1095. /**
  1096. * hal_rx_mpdu_start_sw_peer_id_get() - Retrieve sw peer id
  1097. * @hal_soc_hdl: hal soc handle
  1098. * @buf: pointer to rx pkt TLV.
  1099. *
  1100. * Return: sw peer_id
  1101. */
  1102. static inline uint32_t
  1103. hal_rx_mpdu_start_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  1104. uint8_t *buf)
  1105. {
  1106. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1107. return hal_soc->ops->hal_rx_mpdu_start_sw_peer_id_get(buf);
  1108. }
  1109. #define HAL_RX_MSDU_START_SGI_GET(_rx_msdu_start) \
  1110. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1111. RX_MSDU_START_5_SGI_OFFSET)), \
  1112. RX_MSDU_START_5_SGI_MASK, \
  1113. RX_MSDU_START_5_SGI_LSB))
  1114. /**
  1115. * hal_rx_msdu_start_msdu_sgi_get(): API to get the Short Gaurd
  1116. * Interval from rx_msdu_start TLV
  1117. *
  1118. * @buf: pointer to the start of RX PKT TLV headers
  1119. * Return: uint32_t(sgi)
  1120. */
  1121. static inline uint32_t
  1122. hal_rx_msdu_start_sgi_get(uint8_t *buf)
  1123. {
  1124. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1125. struct rx_msdu_start *msdu_start =
  1126. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1127. uint32_t sgi;
  1128. sgi = HAL_RX_MSDU_START_SGI_GET(msdu_start);
  1129. return sgi;
  1130. }
  1131. #define HAL_RX_MSDU_START_RATE_MCS_GET(_rx_msdu_start) \
  1132. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start),\
  1133. RX_MSDU_START_5_RATE_MCS_OFFSET)), \
  1134. RX_MSDU_START_5_RATE_MCS_MASK, \
  1135. RX_MSDU_START_5_RATE_MCS_LSB))
  1136. /**
  1137. * hal_rx_msdu_start_msdu_rate_mcs_get(): API to get the MCS rate
  1138. * from rx_msdu_start TLV
  1139. *
  1140. * @buf: pointer to the start of RX PKT TLV headers
  1141. * Return: uint32_t(rate_mcs)
  1142. */
  1143. static inline uint32_t
  1144. hal_rx_msdu_start_rate_mcs_get(uint8_t *buf)
  1145. {
  1146. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1147. struct rx_msdu_start *msdu_start =
  1148. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1149. uint32_t rate_mcs;
  1150. rate_mcs = HAL_RX_MSDU_START_RATE_MCS_GET(msdu_start);
  1151. return rate_mcs;
  1152. }
  1153. #define HAL_RX_ATTN_DECRYPT_STATUS_GET(_rx_attn) \
  1154. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_attn, \
  1155. RX_ATTENTION_2_DECRYPT_STATUS_CODE_OFFSET)), \
  1156. RX_ATTENTION_2_DECRYPT_STATUS_CODE_MASK, \
  1157. RX_ATTENTION_2_DECRYPT_STATUS_CODE_LSB))
  1158. /*
  1159. * hal_rx_attn_msdu_get_is_decrypted(): API to get the decrypt status of the
  1160. * packet from rx_attention
  1161. *
  1162. * @buf: pointer to the start of RX PKT TLV header
  1163. * Return: uint32_t(decryt status)
  1164. */
  1165. static inline uint32_t
  1166. hal_rx_attn_msdu_get_is_decrypted(uint8_t *buf)
  1167. {
  1168. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1169. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  1170. uint32_t is_decrypt = 0;
  1171. uint32_t decrypt_status;
  1172. decrypt_status = HAL_RX_ATTN_DECRYPT_STATUS_GET(rx_attn);
  1173. if (!decrypt_status)
  1174. is_decrypt = 1;
  1175. return is_decrypt;
  1176. }
  1177. /*
  1178. * Get key index from RX_MSDU_END
  1179. */
  1180. #define HAL_RX_MSDU_END_KEYID_OCTET_GET(_rx_msdu_end) \
  1181. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_end, \
  1182. RX_MSDU_END_2_KEY_ID_OCTET_OFFSET)), \
  1183. RX_MSDU_END_2_KEY_ID_OCTET_MASK, \
  1184. RX_MSDU_END_2_KEY_ID_OCTET_LSB))
  1185. /*
  1186. * hal_rx_msdu_get_keyid(): API to get the key id if the decrypted packet
  1187. * from rx_msdu_end
  1188. *
  1189. * @buf: pointer to the start of RX PKT TLV header
  1190. * Return: uint32_t(key id)
  1191. */
  1192. static inline uint32_t
  1193. hal_rx_msdu_get_keyid(uint8_t *buf)
  1194. {
  1195. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1196. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  1197. uint32_t keyid_octet;
  1198. keyid_octet = HAL_RX_MSDU_END_KEYID_OCTET_GET(msdu_end);
  1199. return keyid_octet & 0x3;
  1200. }
  1201. #define HAL_RX_MSDU_START_RSSI_GET(_rx_msdu_start) \
  1202. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1203. RX_MSDU_START_5_USER_RSSI_OFFSET)), \
  1204. RX_MSDU_START_5_USER_RSSI_MASK, \
  1205. RX_MSDU_START_5_USER_RSSI_LSB))
  1206. /*
  1207. * hal_rx_msdu_start_get_rssi(): API to get the rssi of received pkt
  1208. * from rx_msdu_start
  1209. *
  1210. * @buf: pointer to the start of RX PKT TLV header
  1211. * Return: uint32_t(rssi)
  1212. */
  1213. static inline uint32_t
  1214. hal_rx_msdu_start_get_rssi(uint8_t *buf)
  1215. {
  1216. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1217. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1218. uint32_t rssi;
  1219. rssi = HAL_RX_MSDU_START_RSSI_GET(msdu_start);
  1220. return rssi;
  1221. }
  1222. #define HAL_RX_MSDU_START_FREQ_GET(_rx_msdu_start) \
  1223. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1224. RX_MSDU_START_7_SW_PHY_META_DATA_OFFSET)), \
  1225. RX_MSDU_START_7_SW_PHY_META_DATA_MASK, \
  1226. RX_MSDU_START_7_SW_PHY_META_DATA_LSB))
  1227. /*
  1228. * hal_rx_msdu_start_get_freq(): API to get the frequency of operating channel
  1229. * from rx_msdu_start
  1230. *
  1231. * @buf: pointer to the start of RX PKT TLV header
  1232. * Return: uint32_t(frequency)
  1233. */
  1234. static inline uint32_t
  1235. hal_rx_msdu_start_get_freq(uint8_t *buf)
  1236. {
  1237. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1238. struct rx_msdu_start *msdu_start =
  1239. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1240. uint32_t freq;
  1241. freq = HAL_RX_MSDU_START_FREQ_GET(msdu_start);
  1242. return freq;
  1243. }
  1244. #define HAL_RX_MSDU_START_PKT_TYPE_GET(_rx_msdu_start) \
  1245. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_msdu_start, \
  1246. RX_MSDU_START_5_PKT_TYPE_OFFSET)), \
  1247. RX_MSDU_START_5_PKT_TYPE_MASK, \
  1248. RX_MSDU_START_5_PKT_TYPE_LSB))
  1249. /*
  1250. * hal_rx_msdu_start_get_pkt_type(): API to get the pkt type
  1251. * from rx_msdu_start
  1252. *
  1253. * @buf: pointer to the start of RX PKT TLV header
  1254. * Return: uint32_t(pkt type)
  1255. */
  1256. static inline uint32_t
  1257. hal_rx_msdu_start_get_pkt_type(uint8_t *buf)
  1258. {
  1259. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1260. struct rx_msdu_start *msdu_start = &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  1261. uint32_t pkt_type;
  1262. pkt_type = HAL_RX_MSDU_START_PKT_TYPE_GET(msdu_start);
  1263. return pkt_type;
  1264. }
  1265. /*
  1266. * hal_rx_mpdu_get_tods(): API to get the tods info
  1267. * from rx_mpdu_start
  1268. *
  1269. * @buf: pointer to the start of RX PKT TLV header
  1270. * Return: uint32_t(to_ds)
  1271. */
  1272. static inline uint32_t
  1273. hal_rx_mpdu_get_to_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1274. {
  1275. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1276. return hal_soc->ops->hal_rx_mpdu_get_to_ds(buf);
  1277. }
  1278. /*
  1279. * hal_rx_mpdu_get_fr_ds(): API to get the from ds info
  1280. * from rx_mpdu_start
  1281. * @hal_soc_hdl: hal soc handle
  1282. * @buf: pointer to the start of RX PKT TLV header
  1283. *
  1284. * Return: uint32_t(fr_ds)
  1285. */
  1286. static inline uint32_t
  1287. hal_rx_mpdu_get_fr_ds(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1288. {
  1289. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1290. return hal_soc->ops->hal_rx_mpdu_get_fr_ds(buf);
  1291. }
  1292. #define HAL_RX_MPDU_AD4_31_0_GET(_rx_mpdu_info) \
  1293. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1294. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_OFFSET)), \
  1295. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_MASK, \
  1296. RX_MPDU_INFO_20_MAC_ADDR_AD4_31_0_LSB))
  1297. #define HAL_RX_MPDU_AD4_47_32_GET(_rx_mpdu_info) \
  1298. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  1299. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_OFFSET)), \
  1300. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_MASK, \
  1301. RX_MPDU_INFO_21_MAC_ADDR_AD4_47_32_LSB))
  1302. /*
  1303. * hal_rx_mpdu_get_addr1(): API to check get address1 of the mpdu
  1304. * @hal_soc_hdl: hal soc handle
  1305. * @buf: pointer to the start of RX PKT TLV headera
  1306. * @mac_addr: pointer to mac address
  1307. *
  1308. * Return: success/failure
  1309. */
  1310. static inline
  1311. QDF_STATUS hal_rx_mpdu_get_addr1(hal_soc_handle_t hal_soc_hdl,
  1312. uint8_t *buf, uint8_t *mac_addr)
  1313. {
  1314. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1315. return hal_soc->ops->hal_rx_mpdu_get_addr1(buf, mac_addr);
  1316. }
  1317. /*
  1318. * hal_rx_mpdu_get_addr2(): API to check get address2 of the mpdu
  1319. * in the packet
  1320. * @hal_soc_hdl: hal soc handle
  1321. * @buf: pointer to the start of RX PKT TLV header
  1322. * @mac_addr: pointer to mac address
  1323. *
  1324. * Return: success/failure
  1325. */
  1326. static inline
  1327. QDF_STATUS hal_rx_mpdu_get_addr2(hal_soc_handle_t hal_soc_hdl,
  1328. uint8_t *buf, uint8_t *mac_addr)
  1329. {
  1330. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1331. return hal_soc->ops->hal_rx_mpdu_get_addr2(buf, mac_addr);
  1332. }
  1333. /*
  1334. * hal_rx_mpdu_get_addr3(): API to get address3 of the mpdu
  1335. * in the packet
  1336. * @hal_soc_hdl: hal soc handle
  1337. * @buf: pointer to the start of RX PKT TLV header
  1338. * @mac_addr: pointer to mac address
  1339. *
  1340. * Return: success/failure
  1341. */
  1342. static inline
  1343. QDF_STATUS hal_rx_mpdu_get_addr3(hal_soc_handle_t hal_soc_hdl,
  1344. uint8_t *buf, uint8_t *mac_addr)
  1345. {
  1346. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1347. return hal_soc->ops->hal_rx_mpdu_get_addr3(buf, mac_addr);
  1348. }
  1349. /*
  1350. * hal_rx_mpdu_get_addr4(): API to get address4 of the mpdu
  1351. * in the packet
  1352. * @hal_soc_hdl: hal_soc handle
  1353. * @buf: pointer to the start of RX PKT TLV header
  1354. * @mac_addr: pointer to mac address
  1355. * Return: success/failure
  1356. */
  1357. static inline
  1358. QDF_STATUS hal_rx_mpdu_get_addr4(hal_soc_handle_t hal_soc_hdl,
  1359. uint8_t *buf, uint8_t *mac_addr)
  1360. {
  1361. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1362. return hal_soc->ops->hal_rx_mpdu_get_addr4(buf, mac_addr);
  1363. }
  1364. /**
  1365. * hal_rx_msdu_end_da_idx_get: API to get da_idx
  1366. * from rx_msdu_end TLV
  1367. *
  1368. * @ buf: pointer to the start of RX PKT TLV headers
  1369. * Return: da index
  1370. */
  1371. static inline uint16_t
  1372. hal_rx_msdu_end_da_idx_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1373. {
  1374. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1375. return hal_soc->ops->hal_rx_msdu_end_da_idx_get(buf);
  1376. }
  1377. /**
  1378. * hal_rx_msdu_end_da_is_valid_get: API to check if da is valid
  1379. * from rx_msdu_end TLV
  1380. * @hal_soc_hdl: hal soc handle
  1381. * @ buf: pointer to the start of RX PKT TLV headers
  1382. *
  1383. * Return: da_is_valid
  1384. */
  1385. static inline uint8_t
  1386. hal_rx_msdu_end_da_is_valid_get(hal_soc_handle_t hal_soc_hdl,
  1387. uint8_t *buf)
  1388. {
  1389. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1390. return hal_soc->ops->hal_rx_msdu_end_da_is_valid_get(buf);
  1391. }
  1392. /**
  1393. * hal_rx_msdu_end_da_is_mcbc_get: API to check if pkt is MCBC
  1394. * from rx_msdu_end TLV
  1395. *
  1396. * @buf: pointer to the start of RX PKT TLV headers
  1397. *
  1398. * Return: da_is_mcbc
  1399. */
  1400. static inline uint8_t
  1401. hal_rx_msdu_end_da_is_mcbc_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  1402. {
  1403. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1404. return hal_soc->ops->hal_rx_msdu_end_da_is_mcbc_get(buf);
  1405. }
  1406. /**
  1407. * hal_rx_msdu_end_first_msdu_get: API to get first msdu status
  1408. * from rx_msdu_end TLV
  1409. * @hal_soc_hdl: hal soc handle
  1410. * @buf: pointer to the start of RX PKT TLV headers
  1411. *
  1412. * Return: first_msdu
  1413. */
  1414. static inline uint8_t
  1415. hal_rx_msdu_end_first_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1416. uint8_t *buf)
  1417. {
  1418. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1419. return hal_soc->ops->hal_rx_msdu_end_first_msdu_get(buf);
  1420. }
  1421. /**
  1422. * hal_rx_msdu_end_last_msdu_get: API to get last msdu status
  1423. * from rx_msdu_end TLV
  1424. * @hal_soc_hdl: hal soc handle
  1425. * @buf: pointer to the start of RX PKT TLV headers
  1426. *
  1427. * Return: last_msdu
  1428. */
  1429. static inline uint8_t
  1430. hal_rx_msdu_end_last_msdu_get(hal_soc_handle_t hal_soc_hdl,
  1431. uint8_t *buf)
  1432. {
  1433. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1434. return hal_soc->ops->hal_rx_msdu_end_last_msdu_get(buf);
  1435. }
  1436. /**
  1437. * hal_rx_msdu_cce_metadata_get: API to get CCE metadata
  1438. * from rx_msdu_end TLV
  1439. * @buf: pointer to the start of RX PKT TLV headers
  1440. * Return: cce_meta_data
  1441. */
  1442. static inline uint16_t
  1443. hal_rx_msdu_cce_metadata_get(hal_soc_handle_t hal_soc_hdl,
  1444. uint8_t *buf)
  1445. {
  1446. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1447. return hal_soc->ops->hal_rx_msdu_cce_metadata_get(buf);
  1448. }
  1449. /*******************************************************************************
  1450. * RX ERROR APIS
  1451. ******************************************************************************/
  1452. #define HAL_RX_MPDU_END_DECRYPT_ERR_GET(_rx_mpdu_end) \
  1453. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1454. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_OFFSET)), \
  1455. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_MASK, \
  1456. RX_MPDU_END_1_RX_IN_TX_DECRYPT_BYP_LSB))
  1457. /**
  1458. * hal_rx_mpdu_end_decrypt_err_get(): API to get the Decrypt ERR
  1459. * from rx_mpdu_end TLV
  1460. *
  1461. * @buf: pointer to the start of RX PKT TLV headers
  1462. * Return: uint32_t(decrypt_err)
  1463. */
  1464. static inline uint32_t
  1465. hal_rx_mpdu_end_decrypt_err_get(uint8_t *buf)
  1466. {
  1467. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1468. struct rx_mpdu_end *mpdu_end =
  1469. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1470. uint32_t decrypt_err;
  1471. decrypt_err = HAL_RX_MPDU_END_DECRYPT_ERR_GET(mpdu_end);
  1472. return decrypt_err;
  1473. }
  1474. #define HAL_RX_MPDU_END_MIC_ERR_GET(_rx_mpdu_end) \
  1475. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_mpdu_end),\
  1476. RX_MPDU_END_1_TKIP_MIC_ERR_OFFSET)), \
  1477. RX_MPDU_END_1_TKIP_MIC_ERR_MASK, \
  1478. RX_MPDU_END_1_TKIP_MIC_ERR_LSB))
  1479. /**
  1480. * hal_rx_mpdu_end_mic_err_get(): API to get the MIC ERR
  1481. * from rx_mpdu_end TLV
  1482. *
  1483. * @buf: pointer to the start of RX PKT TLV headers
  1484. * Return: uint32_t(mic_err)
  1485. */
  1486. static inline uint32_t
  1487. hal_rx_mpdu_end_mic_err_get(uint8_t *buf)
  1488. {
  1489. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  1490. struct rx_mpdu_end *mpdu_end =
  1491. &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  1492. uint32_t mic_err;
  1493. mic_err = HAL_RX_MPDU_END_MIC_ERR_GET(mpdu_end);
  1494. return mic_err;
  1495. }
  1496. /*******************************************************************************
  1497. * RX REO ERROR APIS
  1498. ******************************************************************************/
  1499. #define HAL_RX_NUM_MSDU_DESC 6
  1500. #define HAL_RX_MAX_SAVED_RING_DESC 16
  1501. /* TODO: rework the structure */
  1502. struct hal_rx_msdu_list {
  1503. struct hal_rx_msdu_desc_info msdu_info[HAL_RX_NUM_MSDU_DESC];
  1504. uint32_t sw_cookie[HAL_RX_NUM_MSDU_DESC];
  1505. uint8_t rbm[HAL_RX_NUM_MSDU_DESC];
  1506. /* physical address of the msdu */
  1507. uint64_t paddr[HAL_RX_NUM_MSDU_DESC];
  1508. };
  1509. struct hal_buf_info {
  1510. uint64_t paddr;
  1511. uint32_t sw_cookie;
  1512. uint8_t rbm;
  1513. };
  1514. /**
  1515. * hal_rx_link_desc_msdu0_ptr - Get pointer to rx_msdu details
  1516. * @msdu_link_ptr - msdu link ptr
  1517. * @hal - pointer to hal_soc
  1518. * Return - Pointer to rx_msdu_details structure
  1519. *
  1520. */
  1521. static inline
  1522. void *hal_rx_link_desc_msdu0_ptr(void *msdu_link_ptr,
  1523. struct hal_soc *hal_soc)
  1524. {
  1525. return hal_soc->ops->hal_rx_link_desc_msdu0_ptr(msdu_link_ptr);
  1526. }
  1527. /**
  1528. * hal_rx_msdu_desc_info_get_ptr() - Get msdu desc info ptr
  1529. * @msdu_details_ptr - Pointer to msdu_details_ptr
  1530. * @hal - pointer to hal_soc
  1531. * Return - Pointer to rx_msdu_desc_info structure.
  1532. *
  1533. */
  1534. static inline
  1535. void *hal_rx_msdu_desc_info_get_ptr(void *msdu_details_ptr,
  1536. struct hal_soc *hal_soc)
  1537. {
  1538. return hal_soc->ops->hal_rx_msdu_desc_info_get_ptr(msdu_details_ptr);
  1539. }
  1540. /* This special cookie value will be used to indicate FW allocated buffers
  1541. * received through RXDMA2SW ring for RXDMA WARs
  1542. */
  1543. #define HAL_RX_COOKIE_SPECIAL 0x1fffff
  1544. /**
  1545. * hal_rx_msdu_link_desc_get(): API to get the MSDU information
  1546. * from the MSDU link descriptor
  1547. *
  1548. * @msdu_link_desc: Opaque pointer used by HAL to get to the
  1549. * MSDU link descriptor (struct rx_msdu_link)
  1550. *
  1551. * @msdu_list: Return the list of MSDUs contained in this link descriptor
  1552. *
  1553. * @num_msdus: Number of MSDUs in the MPDU
  1554. *
  1555. * Return: void
  1556. */
  1557. static inline void hal_rx_msdu_list_get(hal_soc_handle_t hal_soc_hdl,
  1558. void *msdu_link_desc,
  1559. struct hal_rx_msdu_list *msdu_list,
  1560. uint16_t *num_msdus)
  1561. {
  1562. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1563. struct rx_msdu_details *msdu_details;
  1564. struct rx_msdu_desc_info *msdu_desc_info;
  1565. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1566. int i;
  1567. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1568. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1569. "[%s][%d] msdu_link=%pK msdu_details=%pK",
  1570. __func__, __LINE__, msdu_link, msdu_details);
  1571. for (i = 0; i < HAL_RX_NUM_MSDU_DESC; i++) {
  1572. /* num_msdus received in mpdu descriptor may be incorrect
  1573. * sometimes due to HW issue. Check msdu buffer address also
  1574. */
  1575. if (HAL_RX_BUFFER_ADDR_31_0_GET(
  1576. &msdu_details[i].buffer_addr_info_details) == 0) {
  1577. /* set the last msdu bit in the prev msdu_desc_info */
  1578. msdu_desc_info =
  1579. hal_rx_msdu_desc_info_get_ptr(&msdu_details[i - 1], hal_soc);
  1580. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1581. break;
  1582. }
  1583. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[i],
  1584. hal_soc);
  1585. /* set first MSDU bit or the last MSDU bit */
  1586. if (!i)
  1587. HAL_RX_FIRST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1588. else if (i == (HAL_RX_NUM_MSDU_DESC - 1))
  1589. HAL_RX_LAST_MSDU_IN_MPDU_FLAG_SET(msdu_desc_info, 1);
  1590. msdu_list->msdu_info[i].msdu_flags =
  1591. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  1592. msdu_list->msdu_info[i].msdu_len =
  1593. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  1594. msdu_list->sw_cookie[i] =
  1595. HAL_RX_BUF_COOKIE_GET(
  1596. &msdu_details[i].buffer_addr_info_details);
  1597. msdu_list->rbm[i] = HAL_RX_BUF_RBM_GET(
  1598. &msdu_details[i].buffer_addr_info_details);
  1599. msdu_list->paddr[i] = HAL_RX_BUFFER_ADDR_31_0_GET(
  1600. &msdu_details[i].buffer_addr_info_details) |
  1601. (uint64_t)HAL_RX_BUFFER_ADDR_39_32_GET(
  1602. &msdu_details[i].buffer_addr_info_details) << 32;
  1603. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1604. "[%s][%d] i=%d sw_cookie=%d",
  1605. __func__, __LINE__, i, msdu_list->sw_cookie[i]);
  1606. }
  1607. *num_msdus = i;
  1608. }
  1609. /**
  1610. * hal_rx_msdu_reo_dst_ind_get: Gets the REO
  1611. * destination ring ID from the msdu desc info
  1612. *
  1613. * @msdu_link_desc : Opaque cookie pointer used by HAL to get to
  1614. * the current descriptor
  1615. *
  1616. * Return: dst_ind (REO destination ring ID)
  1617. */
  1618. static inline uint32_t
  1619. hal_rx_msdu_reo_dst_ind_get(hal_soc_handle_t hal_soc_hdl, void *msdu_link_desc)
  1620. {
  1621. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  1622. struct rx_msdu_details *msdu_details;
  1623. struct rx_msdu_desc_info *msdu_desc_info;
  1624. struct rx_msdu_link *msdu_link = (struct rx_msdu_link *)msdu_link_desc;
  1625. uint32_t dst_ind;
  1626. msdu_details = hal_rx_link_desc_msdu0_ptr(msdu_link, hal_soc);
  1627. /* The first msdu in the link should exsist */
  1628. msdu_desc_info = hal_rx_msdu_desc_info_get_ptr(&msdu_details[0],
  1629. hal_soc);
  1630. dst_ind = HAL_RX_MSDU_REO_DST_IND_GET(msdu_desc_info);
  1631. return dst_ind;
  1632. }
  1633. /**
  1634. * hal_rx_reo_buf_paddr_get: Gets the physical address and
  1635. * cookie from the REO destination ring element
  1636. *
  1637. * @ hal_rx_desc_cookie: Opaque cookie pointer used by HAL to get to
  1638. * the current descriptor
  1639. * @ buf_info: structure to return the buffer information
  1640. * Return: void
  1641. */
  1642. static inline
  1643. void hal_rx_reo_buf_paddr_get(hal_ring_desc_t rx_desc,
  1644. struct hal_buf_info *buf_info)
  1645. {
  1646. struct reo_destination_ring *reo_ring =
  1647. (struct reo_destination_ring *)rx_desc;
  1648. buf_info->paddr =
  1649. (HAL_RX_REO_BUFFER_ADDR_31_0_GET(reo_ring) |
  1650. ((uint64_t)(HAL_RX_REO_BUFFER_ADDR_39_32_GET(reo_ring)) << 32));
  1651. buf_info->sw_cookie = HAL_RX_REO_BUF_COOKIE_GET(reo_ring);
  1652. }
  1653. /**
  1654. * enum hal_reo_error_code: Indicates that type of buffer or descriptor
  1655. *
  1656. * @ HAL_RX_MSDU_BUF_ADDR_TYPE : Reo buffer address points to the MSDU buffer
  1657. * @ HAL_RX_MSDU_LINK_DESC_TYPE: Reo buffer address points to the link
  1658. * descriptor
  1659. */
  1660. enum hal_rx_reo_buf_type {
  1661. HAL_RX_REO_MSDU_BUF_ADDR_TYPE = 0,
  1662. HAL_RX_REO_MSDU_LINK_DESC_TYPE,
  1663. };
  1664. #define HAL_RX_REO_BUF_TYPE_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1665. (REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_OFFSET >> 2))) & \
  1666. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_MASK) >> \
  1667. REO_DESTINATION_RING_7_REO_DEST_BUFFER_TYPE_LSB)
  1668. #define HAL_RX_REO_QUEUE_NUMBER_GET(reo_desc) (((*(((uint32_t *)reo_desc) + \
  1669. (REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_OFFSET >> 2))) & \
  1670. REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_MASK) >> \
  1671. REO_DESTINATION_RING_7_RECEIVE_QUEUE_NUMBER_LSB)
  1672. /**
  1673. * enum hal_reo_error_code: Error code describing the type of error detected
  1674. *
  1675. * @ HAL_REO_ERR_QUEUE_DESC_ADDR_0 : Reo queue descriptor provided in the
  1676. * REO_ENTRANCE ring is set to 0
  1677. * @ HAL_REO_ERR_QUEUE_DESC_INVALID: Reo queue descriptor valid bit is NOT set
  1678. * @ HAL_REO_ERR_AMPDU_IN_NON_BA : AMPDU frame received without BA session
  1679. * having been setup
  1680. * @ HAL_REO_ERR_NON_BA_DUPLICATE : Non-BA session, SN equal to SSN,
  1681. * Retry bit set: duplicate frame
  1682. * @ HAL_REO_ERR_BA_DUPLICATE : BA session, duplicate frame
  1683. * @ HAL_REO_ERR_REGULAR_FRAME_2K_JUMP : A normal (management/data frame)
  1684. * received with 2K jump in SN
  1685. * @ HAL_REO_ERR_BAR_FRAME_2K_JUMP : A bar received with 2K jump in SSN
  1686. * @ HAL_REO_ERR_REGULAR_FRAME_OOR : A normal (management/data frame) received
  1687. * with SN falling within the OOR window
  1688. * @ HAL_REO_ERR_BAR_FRAME_OOR : A bar received with SSN falling within the
  1689. * OOR window
  1690. * @ HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION : A bar received without a BA session
  1691. * @ HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN : A bar received with SSN equal to SN
  1692. * @ HAL_REO_ERR_PN_CHECK_FAILED : PN Check Failed packet
  1693. * @ HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1694. * of the Seq_2k_error_detected_flag been set in the REO Queue descriptor
  1695. * @ HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET : Frame is forwarded as a result
  1696. * of the pn_error_detected_flag been set in the REO Queue descriptor
  1697. * @ HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET : Frame is forwarded as a result of
  1698. * the queue descriptor(address) being blocked as SW/FW seems to be currently
  1699. * in the process of making updates to this descriptor
  1700. */
  1701. enum hal_reo_error_code {
  1702. HAL_REO_ERR_QUEUE_DESC_ADDR_0 = 0,
  1703. HAL_REO_ERR_QUEUE_DESC_INVALID,
  1704. HAL_REO_ERR_AMPDU_IN_NON_BA,
  1705. HAL_REO_ERR_NON_BA_DUPLICATE,
  1706. HAL_REO_ERR_BA_DUPLICATE,
  1707. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP,
  1708. HAL_REO_ERR_BAR_FRAME_2K_JUMP,
  1709. HAL_REO_ERR_REGULAR_FRAME_OOR,
  1710. HAL_REO_ERR_BAR_FRAME_OOR,
  1711. HAL_REO_ERR_BAR_FRAME_NO_BA_SESSION,
  1712. HAL_REO_ERR_BAR_FRAME_SN_EQUALS_SSN,
  1713. HAL_REO_ERR_PN_CHECK_FAILED,
  1714. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET,
  1715. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET,
  1716. HAL_REO_ERR_QUEUE_DESC_BLOCKED_SET,
  1717. HAL_REO_ERR_MAX
  1718. };
  1719. /**
  1720. * enum hal_rxdma_error_code: Code describing the type of RxDMA error detected
  1721. *
  1722. * @HAL_RXDMA_ERR_OVERFLOW: MPDU frame is not complete due to a FIFO overflow
  1723. * @ HAL_RXDMA_ERR_OVERFLOW : MPDU frame is not complete due to a FIFO
  1724. * overflow
  1725. * @ HAL_RXDMA_ERR_MPDU_LENGTH : MPDU frame is not complete due to receiving
  1726. * incomplete
  1727. * MPDU from the PHY
  1728. * @ HAL_RXDMA_ERR_FCS : FCS check on the MPDU frame failed
  1729. * @ HAL_RXDMA_ERR_DECRYPT : Decryption error
  1730. * @ HAL_RXDMA_ERR_TKIP_MIC : TKIP MIC error
  1731. * @ HAL_RXDMA_ERR_UNENCRYPTED : Received a frame that was expected to be
  1732. * encrypted but wasn’t
  1733. * @ HAL_RXDMA_ERR_MSDU_LEN : MSDU related length error
  1734. * @ HAL_RXDMA_ERR_MSDU_LIMIT : Number of MSDUs in the MPDUs exceeded
  1735. * the max allowed
  1736. * @ HAL_RXDMA_ERR_WIFI_PARSE : wifi parsing error
  1737. * @ HAL_RXDMA_ERR_AMSDU_PARSE : Amsdu parsing error
  1738. * @ HAL_RXDMA_ERR_SA_TIMEOUT : Source Address search timeout
  1739. * @ HAL_RXDMA_ERR_DA_TIMEOUT : Destination Address search timeout
  1740. * @ HAL_RXDMA_ERR_FLOW_TIMEOUT : Flow Search Timeout
  1741. * @ HAL_RXDMA_ERR_FLUSH_REQUEST : RxDMA FIFO Flush request
  1742. * @ HAL_RXDMA_ERR_WAR : RxDMA WAR dummy errors
  1743. */
  1744. enum hal_rxdma_error_code {
  1745. HAL_RXDMA_ERR_OVERFLOW = 0,
  1746. HAL_RXDMA_ERR_MPDU_LENGTH,
  1747. HAL_RXDMA_ERR_FCS,
  1748. HAL_RXDMA_ERR_DECRYPT,
  1749. HAL_RXDMA_ERR_TKIP_MIC,
  1750. HAL_RXDMA_ERR_UNENCRYPTED,
  1751. HAL_RXDMA_ERR_MSDU_LEN,
  1752. HAL_RXDMA_ERR_MSDU_LIMIT,
  1753. HAL_RXDMA_ERR_WIFI_PARSE,
  1754. HAL_RXDMA_ERR_AMSDU_PARSE,
  1755. HAL_RXDMA_ERR_SA_TIMEOUT,
  1756. HAL_RXDMA_ERR_DA_TIMEOUT,
  1757. HAL_RXDMA_ERR_FLOW_TIMEOUT,
  1758. HAL_RXDMA_ERR_FLUSH_REQUEST,
  1759. HAL_RXDMA_ERR_WAR = 31,
  1760. HAL_RXDMA_ERR_MAX
  1761. };
  1762. /**
  1763. * HW BM action settings in WBM release ring
  1764. */
  1765. #define HAL_BM_ACTION_PUT_IN_IDLE_LIST 0
  1766. #define HAL_BM_ACTION_RELEASE_MSDU_LIST 1
  1767. /**
  1768. * enum hal_rx_wbm_error_source: Indicates which module initiated the
  1769. * release of this buffer or descriptor
  1770. *
  1771. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1772. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1773. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1774. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1775. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1776. */
  1777. enum hal_rx_wbm_error_source {
  1778. HAL_RX_WBM_ERR_SRC_TQM = 0,
  1779. HAL_RX_WBM_ERR_SRC_RXDMA,
  1780. HAL_RX_WBM_ERR_SRC_REO,
  1781. HAL_RX_WBM_ERR_SRC_FW,
  1782. HAL_RX_WBM_ERR_SRC_SW,
  1783. };
  1784. /**
  1785. * enum hal_rx_wbm_buf_type: Indicates that type of buffer or descriptor
  1786. * released
  1787. *
  1788. * @ HAL_RX_WBM_ERR_SRC_TQM : TQM released this buffer or descriptor
  1789. * @ HAL_RX_WBM_ERR_SRC_RXDMA: RXDMA released this buffer or descriptor
  1790. * @ HAL_RX_WBM_ERR_SRC_REO: REO released this buffer or descriptor
  1791. * @ HAL_RX_WBM_ERR_SRC_FW: FW released this buffer or descriptor
  1792. * @ HAL_RX_WBM_ERR_SRC_SW: SW released this buffer or descriptor
  1793. */
  1794. enum hal_rx_wbm_buf_type {
  1795. HAL_RX_WBM_BUF_TYPE_REL_BUF = 0,
  1796. HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC,
  1797. HAL_RX_WBM_BUF_TYPE_MPDU_LINK_DESC,
  1798. HAL_RX_WBM_BUF_TYPE_MSDU_EXT_DESC,
  1799. HAL_RX_WBM_BUF_TYPE_Q_EXT_DESC,
  1800. };
  1801. #define HAL_RX_REO_ERROR_GET(reo_desc) (((*(((uint32_t *) reo_desc)+ \
  1802. (REO_DESTINATION_RING_7_REO_ERROR_CODE_OFFSET >> 2))) & \
  1803. REO_DESTINATION_RING_7_REO_ERROR_CODE_MASK) >> \
  1804. REO_DESTINATION_RING_7_REO_ERROR_CODE_LSB)
  1805. /**
  1806. * hal_rx_is_pn_error() - Indicate if this error was caused by a
  1807. * PN check failure
  1808. *
  1809. * @reo_desc: opaque pointer used by HAL to get the REO destination entry
  1810. *
  1811. * Return: true: error caused by PN check, false: other error
  1812. */
  1813. static inline bool hal_rx_reo_is_pn_error(hal_ring_desc_t rx_desc)
  1814. {
  1815. struct reo_destination_ring *reo_desc =
  1816. (struct reo_destination_ring *)rx_desc;
  1817. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1818. HAL_REO_ERR_PN_CHECK_FAILED) |
  1819. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1820. HAL_REO_ERR_PN_ERROR_HANDLING_FLAG_SET)) ?
  1821. true : false;
  1822. }
  1823. /**
  1824. * hal_rx_is_2k_jump() - Indicate if this error was caused by a 2K jump in
  1825. * the sequence number
  1826. *
  1827. * @ring_desc: opaque pointer used by HAL to get the REO destination entry
  1828. *
  1829. * Return: true: error caused by 2K jump, false: other error
  1830. */
  1831. static inline bool hal_rx_reo_is_2k_jump(hal_ring_desc_t rx_desc)
  1832. {
  1833. struct reo_destination_ring *reo_desc =
  1834. (struct reo_destination_ring *)rx_desc;
  1835. return ((HAL_RX_REO_ERROR_GET(reo_desc) ==
  1836. HAL_REO_ERR_REGULAR_FRAME_2K_JUMP) |
  1837. (HAL_RX_REO_ERROR_GET(reo_desc) ==
  1838. HAL_REO_ERR_2K_ERROR_HANDLING_FLAG_SET)) ?
  1839. true : false;
  1840. }
  1841. #define HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS (NUM_OF_DWORDS_WBM_RELEASE_RING)
  1842. /**
  1843. * hal_dump_wbm_rel_desc() - dump wbm release descriptor
  1844. * @hal_desc: hardware descriptor pointer
  1845. *
  1846. * This function will print wbm release descriptor
  1847. *
  1848. * Return: none
  1849. */
  1850. static inline void hal_dump_wbm_rel_desc(void *src_srng_desc)
  1851. {
  1852. uint32_t *wbm_comp = (uint32_t *)src_srng_desc;
  1853. uint32_t i;
  1854. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1855. "Current Rx wbm release descriptor is");
  1856. for (i = 0; i < HAL_WBM_RELEASE_RING_DESC_LEN_DWORDS; i++) {
  1857. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL,
  1858. "DWORD[i] = 0x%x", wbm_comp[i]);
  1859. }
  1860. }
  1861. /**
  1862. * hal_rx_msdu_link_desc_set: Retrieves MSDU Link Descriptor to WBM
  1863. *
  1864. * @ hal_soc_hdl : HAL version of the SOC pointer
  1865. * @ src_srng_desc : void pointer to the WBM Release Ring descriptor
  1866. * @ buf_addr_info : void pointer to the buffer_addr_info
  1867. * @ bm_action : put in IDLE list or release to MSDU_LIST
  1868. *
  1869. * Return: void
  1870. */
  1871. /* look at implementation at dp_hw_link_desc_pool_setup()*/
  1872. static inline
  1873. void hal_rx_msdu_link_desc_set(hal_soc_handle_t hal_soc_hdl,
  1874. void *src_srng_desc,
  1875. hal_buff_addrinfo_t buf_addr_info,
  1876. uint8_t bm_action)
  1877. {
  1878. struct wbm_release_ring *wbm_rel_srng =
  1879. (struct wbm_release_ring *)src_srng_desc;
  1880. uint32_t addr_31_0;
  1881. uint8_t addr_39_32;
  1882. /* Structure copy !!! */
  1883. wbm_rel_srng->released_buff_or_desc_addr_info =
  1884. *((struct buffer_addr_info *)buf_addr_info);
  1885. addr_31_0 =
  1886. wbm_rel_srng->released_buff_or_desc_addr_info.buffer_addr_31_0;
  1887. addr_39_32 =
  1888. wbm_rel_srng->released_buff_or_desc_addr_info.buffer_addr_39_32;
  1889. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1890. RELEASE_SOURCE_MODULE, HAL_RX_WBM_ERR_SRC_SW);
  1891. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2, BM_ACTION,
  1892. bm_action);
  1893. HAL_DESC_SET_FIELD(src_srng_desc, WBM_RELEASE_RING_2,
  1894. BUFFER_OR_DESC_TYPE, HAL_RX_WBM_BUF_TYPE_MSDU_LINK_DESC);
  1895. /* WBM error is indicated when any of the link descriptors given to
  1896. * WBM has a NULL address, and one those paths is the link descriptors
  1897. * released from host after processing RXDMA errors,
  1898. * or from Rx defrag path, and we want to add an assert here to ensure
  1899. * host is not releasing descriptors with NULL address.
  1900. */
  1901. if (qdf_unlikely(!addr_31_0 && !addr_39_32)) {
  1902. hal_dump_wbm_rel_desc(src_srng_desc);
  1903. qdf_assert_always(0);
  1904. }
  1905. }
  1906. /*
  1907. * hal_rx_msdu_link_desc_reinject: Re-injects the MSDU link descriptor to
  1908. * REO entrance ring
  1909. *
  1910. * @ soc: HAL version of the SOC pointer
  1911. * @ pa: Physical address of the MSDU Link Descriptor
  1912. * @ cookie: SW cookie to get to the virtual address
  1913. * @ error_enabled_reo_q: Argument to determine whether this needs to go
  1914. * to the error enabled REO queue
  1915. *
  1916. * Return: void
  1917. */
  1918. static inline void hal_rx_msdu_link_desc_reinject(struct hal_soc *soc,
  1919. uint64_t pa, uint32_t cookie, bool error_enabled_reo_q)
  1920. {
  1921. /* TODO */
  1922. }
  1923. /**
  1924. * HAL_RX_BUF_ADDR_INFO_GET: Returns the address of the
  1925. * BUFFER_ADDR_INFO, give the RX descriptor
  1926. * (Assumption -- BUFFER_ADDR_INFO is the
  1927. * first field in the descriptor structure)
  1928. */
  1929. #define HAL_RX_BUF_ADDR_INFO_GET(ring_desc) \
  1930. ((hal_link_desc_t)(ring_desc))
  1931. #define HAL_RX_REO_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1932. #define HAL_RX_WBM_BUF_ADDR_INFO_GET HAL_RX_BUF_ADDR_INFO_GET
  1933. /**
  1934. * hal_rx_ret_buf_manager_get: Returns the "return_buffer_manager"
  1935. * from the BUFFER_ADDR_INFO structure
  1936. * given a REO destination ring descriptor.
  1937. * @ ring_desc: RX(REO/WBM release) destination ring descriptor
  1938. *
  1939. * Return: uint8_t (value of the return_buffer_manager)
  1940. */
  1941. static inline
  1942. uint8_t hal_rx_ret_buf_manager_get(hal_ring_desc_t ring_desc)
  1943. {
  1944. /*
  1945. * The following macro takes buf_addr_info as argument,
  1946. * but since buf_addr_info is the first field in ring_desc
  1947. * Hence the following call is OK
  1948. */
  1949. return HAL_RX_BUF_RBM_GET(ring_desc);
  1950. }
  1951. /*******************************************************************************
  1952. * RX WBM ERROR APIS
  1953. ******************************************************************************/
  1954. #define HAL_RX_WBM_BUF_TYPE_GET(wbm_desc) (((*(((uint32_t *) wbm_desc)+ \
  1955. (WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_OFFSET >> 2))) & \
  1956. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_MASK) >> \
  1957. WBM_RELEASE_RING_2_BUFFER_OR_DESC_TYPE_LSB)
  1958. /**
  1959. * enum - hal_rx_wbm_reo_push_reason: Indicates why REO pushed
  1960. * the frame to this release ring
  1961. *
  1962. * @ HAL_RX_WBM_REO_PSH_RSN_ERROR : Reo detected an error and pushed this
  1963. * frame to this queue
  1964. * @ HAL_RX_WBM_REO_PSH_RSN_ROUTE: Reo pushed the frame to this queue per
  1965. * received routing instructions. No error within REO was detected
  1966. */
  1967. enum hal_rx_wbm_reo_push_reason {
  1968. HAL_RX_WBM_REO_PSH_RSN_ERROR = 0,
  1969. HAL_RX_WBM_REO_PSH_RSN_ROUTE,
  1970. };
  1971. /**
  1972. * enum hal_rx_wbm_rxdma_push_reason: Indicates why REO pushed the frame to
  1973. * this release ring
  1974. *
  1975. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ERROR : RXDMA detected an error and pushed
  1976. * this frame to this queue
  1977. * @ HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE: RXDMA pushed the frame to this queue
  1978. * per received routing instructions. No error within RXDMA was detected
  1979. */
  1980. enum hal_rx_wbm_rxdma_push_reason {
  1981. HAL_RX_WBM_RXDMA_PSH_RSN_ERROR = 0,
  1982. HAL_RX_WBM_RXDMA_PSH_RSN_ROUTE,
  1983. };
  1984. #define HAL_RX_WBM_FIRST_MSDU_GET(wbm_desc) \
  1985. (((*(((uint32_t *) wbm_desc) + \
  1986. (WBM_RELEASE_RING_4_FIRST_MSDU_OFFSET >> 2))) & \
  1987. WBM_RELEASE_RING_4_FIRST_MSDU_MASK) >> \
  1988. WBM_RELEASE_RING_4_FIRST_MSDU_LSB)
  1989. #define HAL_RX_WBM_LAST_MSDU_GET(wbm_desc) \
  1990. (((*(((uint32_t *) wbm_desc) + \
  1991. (WBM_RELEASE_RING_4_LAST_MSDU_OFFSET >> 2))) & \
  1992. WBM_RELEASE_RING_4_LAST_MSDU_MASK) >> \
  1993. WBM_RELEASE_RING_4_LAST_MSDU_LSB)
  1994. #define HAL_RX_WBM_BUF_COOKIE_GET(wbm_desc) \
  1995. HAL_RX_BUF_COOKIE_GET(&((struct wbm_release_ring *) \
  1996. wbm_desc)->released_buff_or_desc_addr_info)
  1997. /**
  1998. * hal_rx_dump_rx_attention_tlv: dump RX attention TLV in structured
  1999. * humman readable format.
  2000. * @ rx_attn: pointer the rx_attention TLV in pkt.
  2001. * @ dbg_level: log level.
  2002. *
  2003. * Return: void
  2004. */
  2005. static inline void hal_rx_dump_rx_attention_tlv(struct rx_attention *rx_attn,
  2006. uint8_t dbg_level)
  2007. {
  2008. hal_verbose_debug(
  2009. "rx_attention tlv (1/2) - "
  2010. "rxpcu_mpdu_filter_in_category: %x "
  2011. "sw_frame_group_id: %x "
  2012. "reserved_0: %x "
  2013. "phy_ppdu_id: %x "
  2014. "first_mpdu : %x "
  2015. "reserved_1a: %x "
  2016. "mcast_bcast: %x "
  2017. "ast_index_not_found: %x "
  2018. "ast_index_timeout: %x "
  2019. "power_mgmt: %x "
  2020. "non_qos: %x "
  2021. "null_data: %x "
  2022. "mgmt_type: %x "
  2023. "ctrl_type: %x "
  2024. "more_data: %x "
  2025. "eosp: %x "
  2026. "a_msdu_error: %x "
  2027. "fragment_flag: %x "
  2028. "order: %x "
  2029. "cce_match: %x "
  2030. "overflow_err: %x "
  2031. "msdu_length_err: %x "
  2032. "tcp_udp_chksum_fail: %x "
  2033. "ip_chksum_fail: %x "
  2034. "sa_idx_invalid: %x "
  2035. "da_idx_invalid: %x "
  2036. "reserved_1b: %x "
  2037. "rx_in_tx_decrypt_byp: %x ",
  2038. rx_attn->rxpcu_mpdu_filter_in_category,
  2039. rx_attn->sw_frame_group_id,
  2040. rx_attn->reserved_0,
  2041. rx_attn->phy_ppdu_id,
  2042. rx_attn->first_mpdu,
  2043. rx_attn->reserved_1a,
  2044. rx_attn->mcast_bcast,
  2045. rx_attn->ast_index_not_found,
  2046. rx_attn->ast_index_timeout,
  2047. rx_attn->power_mgmt,
  2048. rx_attn->non_qos,
  2049. rx_attn->null_data,
  2050. rx_attn->mgmt_type,
  2051. rx_attn->ctrl_type,
  2052. rx_attn->more_data,
  2053. rx_attn->eosp,
  2054. rx_attn->a_msdu_error,
  2055. rx_attn->fragment_flag,
  2056. rx_attn->order,
  2057. rx_attn->cce_match,
  2058. rx_attn->overflow_err,
  2059. rx_attn->msdu_length_err,
  2060. rx_attn->tcp_udp_chksum_fail,
  2061. rx_attn->ip_chksum_fail,
  2062. rx_attn->sa_idx_invalid,
  2063. rx_attn->da_idx_invalid,
  2064. rx_attn->reserved_1b,
  2065. rx_attn->rx_in_tx_decrypt_byp);
  2066. hal_verbose_debug(
  2067. "rx_attention tlv (2/2) - "
  2068. "encrypt_required: %x "
  2069. "directed: %x "
  2070. "buffer_fragment: %x "
  2071. "mpdu_length_err: %x "
  2072. "tkip_mic_err: %x "
  2073. "decrypt_err: %x "
  2074. "unencrypted_frame_err: %x "
  2075. "fcs_err: %x "
  2076. "flow_idx_timeout: %x "
  2077. "flow_idx_invalid: %x "
  2078. "wifi_parser_error: %x "
  2079. "amsdu_parser_error: %x "
  2080. "sa_idx_timeout: %x "
  2081. "da_idx_timeout: %x "
  2082. "msdu_limit_error: %x "
  2083. "da_is_valid: %x "
  2084. "da_is_mcbc: %x "
  2085. "sa_is_valid: %x "
  2086. "decrypt_status_code: %x "
  2087. "rx_bitmap_not_updated: %x "
  2088. "reserved_2: %x "
  2089. "msdu_done: %x ",
  2090. rx_attn->encrypt_required,
  2091. rx_attn->directed,
  2092. rx_attn->buffer_fragment,
  2093. rx_attn->mpdu_length_err,
  2094. rx_attn->tkip_mic_err,
  2095. rx_attn->decrypt_err,
  2096. rx_attn->unencrypted_frame_err,
  2097. rx_attn->fcs_err,
  2098. rx_attn->flow_idx_timeout,
  2099. rx_attn->flow_idx_invalid,
  2100. rx_attn->wifi_parser_error,
  2101. rx_attn->amsdu_parser_error,
  2102. rx_attn->sa_idx_timeout,
  2103. rx_attn->da_idx_timeout,
  2104. rx_attn->msdu_limit_error,
  2105. rx_attn->da_is_valid,
  2106. rx_attn->da_is_mcbc,
  2107. rx_attn->sa_is_valid,
  2108. rx_attn->decrypt_status_code,
  2109. rx_attn->rx_bitmap_not_updated,
  2110. rx_attn->reserved_2,
  2111. rx_attn->msdu_done);
  2112. }
  2113. static inline void hal_rx_dump_mpdu_start_tlv(struct rx_mpdu_start *mpdu_start,
  2114. uint8_t dbg_level,
  2115. struct hal_soc *hal)
  2116. {
  2117. hal->ops->hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level);
  2118. }
  2119. /**
  2120. * hal_rx_dump_msdu_end_tlv: dump RX msdu_end TLV in structured
  2121. * human readable format.
  2122. * @ msdu_end: pointer the msdu_end TLV in pkt.
  2123. * @ dbg_level: log level.
  2124. *
  2125. * Return: void
  2126. */
  2127. static inline void hal_rx_dump_msdu_end_tlv(struct hal_soc *hal_soc,
  2128. struct rx_msdu_end *msdu_end,
  2129. uint8_t dbg_level)
  2130. {
  2131. hal_soc->ops->hal_rx_dump_msdu_end_tlv(msdu_end, dbg_level);
  2132. }
  2133. /**
  2134. * hal_rx_dump_mpdu_end_tlv: dump RX mpdu_end TLV in structured
  2135. * human readable format.
  2136. * @ mpdu_end: pointer the mpdu_end TLV in pkt.
  2137. * @ dbg_level: log level.
  2138. *
  2139. * Return: void
  2140. */
  2141. static inline void hal_rx_dump_mpdu_end_tlv(struct rx_mpdu_end *mpdu_end,
  2142. uint8_t dbg_level)
  2143. {
  2144. hal_verbose_debug(
  2145. "rx_mpdu_end tlv - "
  2146. "rxpcu_mpdu_filter_in_category: %x "
  2147. "sw_frame_group_id: %x "
  2148. "phy_ppdu_id: %x "
  2149. "unsup_ktype_short_frame: %x "
  2150. "rx_in_tx_decrypt_byp: %x "
  2151. "overflow_err: %x "
  2152. "mpdu_length_err: %x "
  2153. "tkip_mic_err: %x "
  2154. "decrypt_err: %x "
  2155. "unencrypted_frame_err: %x "
  2156. "pn_fields_contain_valid_info: %x "
  2157. "fcs_err: %x "
  2158. "msdu_length_err: %x "
  2159. "rxdma0_destination_ring: %x "
  2160. "rxdma1_destination_ring: %x "
  2161. "decrypt_status_code: %x "
  2162. "rx_bitmap_not_updated: %x ",
  2163. mpdu_end->rxpcu_mpdu_filter_in_category,
  2164. mpdu_end->sw_frame_group_id,
  2165. mpdu_end->phy_ppdu_id,
  2166. mpdu_end->unsup_ktype_short_frame,
  2167. mpdu_end->rx_in_tx_decrypt_byp,
  2168. mpdu_end->overflow_err,
  2169. mpdu_end->mpdu_length_err,
  2170. mpdu_end->tkip_mic_err,
  2171. mpdu_end->decrypt_err,
  2172. mpdu_end->unencrypted_frame_err,
  2173. mpdu_end->pn_fields_contain_valid_info,
  2174. mpdu_end->fcs_err,
  2175. mpdu_end->msdu_length_err,
  2176. mpdu_end->rxdma0_destination_ring,
  2177. mpdu_end->rxdma1_destination_ring,
  2178. mpdu_end->decrypt_status_code,
  2179. mpdu_end->rx_bitmap_not_updated);
  2180. }
  2181. #ifdef NO_RX_PKT_HDR_TLV
  2182. static inline void hal_rx_dump_pkt_hdr_tlv(struct rx_pkt_tlvs *pkt_tlvs,
  2183. uint8_t dbg_level)
  2184. {
  2185. }
  2186. #else
  2187. /**
  2188. * hal_rx_dump_pkt_hdr_tlv: dump RX pkt header TLV in hex format
  2189. * @ pkt_hdr_tlv: pointer the pkt_hdr_tlv in pkt.
  2190. * @ dbg_level: log level.
  2191. *
  2192. * Return: void
  2193. */
  2194. static inline void hal_rx_dump_pkt_hdr_tlv(struct rx_pkt_tlvs *pkt_tlvs,
  2195. uint8_t dbg_level)
  2196. {
  2197. struct rx_pkt_hdr_tlv *pkt_hdr_tlv = &pkt_tlvs->pkt_hdr_tlv;
  2198. hal_verbose_debug(
  2199. "\n---------------\n"
  2200. "rx_pkt_hdr_tlv \n"
  2201. "---------------\n"
  2202. "phy_ppdu_id %d ",
  2203. pkt_hdr_tlv->phy_ppdu_id);
  2204. hal_verbose_hex_dump(pkt_hdr_tlv->rx_pkt_hdr, 128);
  2205. }
  2206. #endif
  2207. /**
  2208. * hal_srng_ring_id_get: API to retrieve ring id from hal ring
  2209. * structure
  2210. * @hal_ring: pointer to hal_srng structure
  2211. *
  2212. * Return: ring_id
  2213. */
  2214. static inline uint8_t hal_srng_ring_id_get(hal_ring_handle_t hal_ring_hdl)
  2215. {
  2216. return ((struct hal_srng *)hal_ring_hdl)->ring_id;
  2217. }
  2218. /* Rx MSDU link pointer info */
  2219. struct hal_rx_msdu_link_ptr_info {
  2220. struct rx_msdu_link msdu_link;
  2221. struct hal_buf_info msdu_link_buf_info;
  2222. };
  2223. /**
  2224. * hal_rx_get_pkt_tlvs(): Function to retrieve pkt tlvs from nbuf
  2225. *
  2226. * @nbuf: Pointer to data buffer field
  2227. * Returns: pointer to rx_pkt_tlvs
  2228. */
  2229. static inline
  2230. struct rx_pkt_tlvs *hal_rx_get_pkt_tlvs(uint8_t *rx_buf_start)
  2231. {
  2232. return (struct rx_pkt_tlvs *)rx_buf_start;
  2233. }
  2234. /**
  2235. * hal_rx_get_mpdu_info(): Function to retrieve mpdu info from pkt tlvs
  2236. *
  2237. * @pkt_tlvs: Pointer to pkt_tlvs
  2238. * Returns: pointer to rx_mpdu_info structure
  2239. */
  2240. static inline
  2241. struct rx_mpdu_info *hal_rx_get_mpdu_info(struct rx_pkt_tlvs *pkt_tlvs)
  2242. {
  2243. return &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start.rx_mpdu_info_details;
  2244. }
  2245. #define DOT11_SEQ_FRAG_MASK 0x000f
  2246. #define DOT11_FC1_MORE_FRAG_OFFSET 0x04
  2247. /**
  2248. * hal_rx_get_rx_fragment_number(): Function to retrieve rx fragment number
  2249. *
  2250. * @nbuf: Network buffer
  2251. * Returns: rx fragment number
  2252. */
  2253. static inline
  2254. uint8_t hal_rx_get_rx_fragment_number(struct hal_soc *hal_soc,
  2255. uint8_t *buf)
  2256. {
  2257. return hal_soc->ops->hal_rx_get_rx_fragment_number(buf);
  2258. }
  2259. #define HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(_rx_mpdu_info) \
  2260. (_HAL_MS((*_OFFSET_TO_WORD_PTR(_rx_mpdu_info, \
  2261. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_OFFSET)), \
  2262. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_MASK, \
  2263. RX_MPDU_INFO_14_MPDU_FRAME_CONTROL_FIELD_LSB))
  2264. /**
  2265. * hal_rx_get_rx_more_frag_bit(): Function to retrieve more fragment bit
  2266. *
  2267. * @nbuf: Network buffer
  2268. * Returns: rx more fragment bit
  2269. */
  2270. static inline
  2271. uint8_t hal_rx_get_rx_more_frag_bit(uint8_t *buf)
  2272. {
  2273. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2274. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2275. uint16_t frame_ctrl = 0;
  2276. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info) >>
  2277. DOT11_FC1_MORE_FRAG_OFFSET;
  2278. /* more fragment bit if at offset bit 4 */
  2279. return frame_ctrl;
  2280. }
  2281. /**
  2282. * hal_rx_get_frame_ctrl_field(): Function to retrieve frame control field
  2283. *
  2284. * @nbuf: Network buffer
  2285. * Returns: rx more fragment bit
  2286. *
  2287. */
  2288. static inline
  2289. uint16_t hal_rx_get_frame_ctrl_field(uint8_t *buf)
  2290. {
  2291. struct rx_pkt_tlvs *pkt_tlvs = hal_rx_get_pkt_tlvs(buf);
  2292. struct rx_mpdu_info *rx_mpdu_info = hal_rx_get_mpdu_info(pkt_tlvs);
  2293. uint16_t frame_ctrl = 0;
  2294. frame_ctrl = HAL_RX_MPDU_GET_FRAME_CONTROL_FIELD(rx_mpdu_info);
  2295. return frame_ctrl;
  2296. }
  2297. /*
  2298. * hal_rx_msdu_is_wlan_mcast(): Check if the buffer is for multicast address
  2299. *
  2300. * @nbuf: Network buffer
  2301. * Returns: flag to indicate whether the nbuf has MC/BC address
  2302. */
  2303. static inline
  2304. uint32_t hal_rx_msdu_is_wlan_mcast(qdf_nbuf_t nbuf)
  2305. {
  2306. uint8 *buf = qdf_nbuf_data(nbuf);
  2307. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2308. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2309. return rx_attn->mcast_bcast;
  2310. }
  2311. /*
  2312. * hal_rx_get_mpdu_sequence_control_valid(): Get mpdu sequence control valid
  2313. * @hal_soc_hdl: hal soc handle
  2314. * @nbuf: Network buffer
  2315. *
  2316. * Return: value of sequence control valid field
  2317. */
  2318. static inline
  2319. uint8_t hal_rx_get_mpdu_sequence_control_valid(hal_soc_handle_t hal_soc_hdl,
  2320. uint8_t *buf)
  2321. {
  2322. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2323. return hal_soc->ops->hal_rx_get_mpdu_sequence_control_valid(buf);
  2324. }
  2325. /*
  2326. * hal_rx_get_mpdu_frame_control_valid(): Retrieves mpdu frame control valid
  2327. * @hal_soc_hdl: hal soc handle
  2328. * @nbuf: Network buffer
  2329. *
  2330. * Returns: value of frame control valid field
  2331. */
  2332. static inline
  2333. uint8_t hal_rx_get_mpdu_frame_control_valid(hal_soc_handle_t hal_soc_hdl,
  2334. uint8_t *buf)
  2335. {
  2336. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2337. return hal_soc->ops->hal_rx_get_mpdu_frame_control_valid(buf);
  2338. }
  2339. /**
  2340. * hal_rx_get_mpdu_mac_ad4_valid(): Retrieves if mpdu 4th addr is valid
  2341. * @hal_soc_hdl: hal soc handle
  2342. * @nbuf: Network buffer
  2343. * Returns: value of mpdu 4th address valid field
  2344. */
  2345. static inline
  2346. bool hal_rx_get_mpdu_mac_ad4_valid(hal_soc_handle_t hal_soc_hdl,
  2347. uint8_t *buf)
  2348. {
  2349. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2350. return hal_soc->ops->hal_rx_get_mpdu_mac_ad4_valid(buf);
  2351. }
  2352. /*
  2353. * hal_rx_clear_mpdu_desc_info(): Clears mpdu_desc_info
  2354. *
  2355. * @rx_mpdu_desc_info: HAL view of rx mpdu desc info
  2356. * Returns: None
  2357. */
  2358. static inline
  2359. void hal_rx_clear_mpdu_desc_info(
  2360. struct hal_rx_mpdu_desc_info *rx_mpdu_desc_info)
  2361. {
  2362. qdf_mem_zero(rx_mpdu_desc_info,
  2363. sizeof(*rx_mpdu_desc_info));
  2364. }
  2365. /*
  2366. * hal_rx_clear_msdu_link_ptr(): Clears msdu_link_ptr
  2367. *
  2368. * @msdu_link_ptr: HAL view of msdu link ptr
  2369. * @size: number of msdu link pointers
  2370. * Returns: None
  2371. */
  2372. static inline
  2373. void hal_rx_clear_msdu_link_ptr(struct hal_rx_msdu_link_ptr_info *msdu_link_ptr,
  2374. int size)
  2375. {
  2376. qdf_mem_zero(msdu_link_ptr,
  2377. (sizeof(*msdu_link_ptr) * size));
  2378. }
  2379. /*
  2380. * hal_rx_chain_msdu_links() - Chains msdu link pointers
  2381. * @msdu_link_ptr: msdu link pointer
  2382. * @mpdu_desc_info: mpdu descriptor info
  2383. *
  2384. * Build a list of msdus using msdu link pointer. If the
  2385. * number of msdus are more, chain them together
  2386. *
  2387. * Returns: Number of processed msdus
  2388. */
  2389. static inline
  2390. int hal_rx_chain_msdu_links(struct hal_soc *hal_soc, qdf_nbuf_t msdu,
  2391. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2392. struct hal_rx_mpdu_desc_info *mpdu_desc_info)
  2393. {
  2394. int j;
  2395. struct rx_msdu_link *msdu_link_ptr =
  2396. &msdu_link_ptr_info->msdu_link;
  2397. struct rx_msdu_link *prev_msdu_link_ptr = NULL;
  2398. struct rx_msdu_details *msdu_details =
  2399. hal_rx_link_desc_msdu0_ptr(msdu_link_ptr, hal_soc);
  2400. uint8_t num_msdus = mpdu_desc_info->msdu_count;
  2401. struct rx_msdu_desc_info *msdu_desc_info;
  2402. uint8_t fragno, more_frag;
  2403. uint8_t *rx_desc_info;
  2404. struct hal_rx_msdu_list msdu_list;
  2405. for (j = 0; j < num_msdus; j++) {
  2406. msdu_desc_info =
  2407. hal_rx_msdu_desc_info_get_ptr(&msdu_details[j],
  2408. hal_soc);
  2409. msdu_list.msdu_info[j].msdu_flags =
  2410. HAL_RX_MSDU_FLAGS_GET(msdu_desc_info);
  2411. msdu_list.msdu_info[j].msdu_len =
  2412. HAL_RX_MSDU_PKT_LENGTH_GET(msdu_desc_info);
  2413. msdu_list.sw_cookie[j] = HAL_RX_BUF_COOKIE_GET(
  2414. &msdu_details[j].buffer_addr_info_details);
  2415. }
  2416. /* Chain msdu links together */
  2417. if (prev_msdu_link_ptr) {
  2418. /* 31-0 bits of the physical address */
  2419. prev_msdu_link_ptr->
  2420. next_msdu_link_desc_addr_info.buffer_addr_31_0 =
  2421. msdu_link_ptr_info->msdu_link_buf_info.paddr &
  2422. BUFFER_ADDR_INFO_0_BUFFER_ADDR_31_0_MASK;
  2423. /* 39-32 bits of the physical address */
  2424. prev_msdu_link_ptr->
  2425. next_msdu_link_desc_addr_info.buffer_addr_39_32
  2426. = ((msdu_link_ptr_info->msdu_link_buf_info.paddr
  2427. >> 32) &
  2428. BUFFER_ADDR_INFO_1_BUFFER_ADDR_39_32_MASK);
  2429. prev_msdu_link_ptr->
  2430. next_msdu_link_desc_addr_info.sw_buffer_cookie =
  2431. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie;
  2432. }
  2433. /* There is space for only 6 MSDUs in a MSDU link descriptor */
  2434. if (num_msdus < HAL_RX_NUM_MSDU_DESC) {
  2435. /* mark first and last MSDUs */
  2436. rx_desc_info = qdf_nbuf_data(msdu);
  2437. fragno = hal_rx_get_rx_fragment_number(hal_soc, rx_desc_info);
  2438. more_frag = hal_rx_get_rx_more_frag_bit(rx_desc_info);
  2439. /* TODO: create skb->fragslist[] */
  2440. if (more_frag == 0) {
  2441. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2442. RX_MSDU_DESC_INFO_0_LAST_MSDU_IN_MPDU_FLAG_MASK;
  2443. } else if (fragno == 1) {
  2444. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2445. RX_MSDU_DESC_INFO_0_FIRST_MSDU_IN_MPDU_FLAG_MASK;
  2446. msdu_list.msdu_info[num_msdus].msdu_flags |=
  2447. RX_MSDU_DESC_INFO_0_MSDU_CONTINUATION_MASK;
  2448. }
  2449. num_msdus++;
  2450. /* Number of MSDUs per mpdu descriptor is updated */
  2451. mpdu_desc_info->msdu_count += num_msdus;
  2452. } else {
  2453. num_msdus = 0;
  2454. prev_msdu_link_ptr = msdu_link_ptr;
  2455. }
  2456. return num_msdus;
  2457. }
  2458. /*
  2459. * hal_rx_defrag_update_src_ring_desc(): updates reo src ring desc
  2460. *
  2461. * @ring_desc: HAL view of ring descriptor
  2462. * @mpdu_des_info: saved mpdu desc info
  2463. * @msdu_link_ptr: saved msdu link ptr
  2464. *
  2465. * API used explicitly for rx defrag to update ring desc with
  2466. * mpdu desc info and msdu link ptr before reinjecting the
  2467. * packet back to REO
  2468. *
  2469. * Returns: None
  2470. */
  2471. static inline
  2472. void hal_rx_defrag_update_src_ring_desc(
  2473. hal_ring_desc_t ring_desc,
  2474. void *saved_mpdu_desc_info,
  2475. struct hal_rx_msdu_link_ptr_info *saved_msdu_link_ptr)
  2476. {
  2477. struct reo_entrance_ring *reo_ent_ring;
  2478. struct rx_mpdu_desc_info *reo_ring_mpdu_desc_info;
  2479. struct hal_buf_info buf_info;
  2480. reo_ent_ring = (struct reo_entrance_ring *)ring_desc;
  2481. reo_ring_mpdu_desc_info = &reo_ent_ring->
  2482. reo_level_mpdu_frame_info.rx_mpdu_desc_info_details;
  2483. qdf_mem_copy(&reo_ring_mpdu_desc_info, saved_mpdu_desc_info,
  2484. sizeof(*reo_ring_mpdu_desc_info));
  2485. /*
  2486. * TODO: Check for additional fields that need configuration in
  2487. * reo_ring_mpdu_desc_info
  2488. */
  2489. /* Update msdu_link_ptr in the reo entrance ring */
  2490. hal_rx_reo_buf_paddr_get(ring_desc, &buf_info);
  2491. buf_info.paddr = saved_msdu_link_ptr->msdu_link_buf_info.paddr;
  2492. buf_info.sw_cookie =
  2493. saved_msdu_link_ptr->msdu_link_buf_info.sw_cookie;
  2494. }
  2495. /*
  2496. * hal_rx_defrag_save_info_from_ring_desc(): Saves info from ring desc
  2497. *
  2498. * @msdu_link_desc_va: msdu link descriptor handle
  2499. * @msdu_link_ptr_info: HAL view of msdu link pointer info
  2500. *
  2501. * API used to save msdu link information along with physical
  2502. * address. The API also copues the sw cookie.
  2503. *
  2504. * Returns: None
  2505. */
  2506. static inline
  2507. void hal_rx_defrag_save_info_from_ring_desc(void *msdu_link_desc_va,
  2508. struct hal_rx_msdu_link_ptr_info *msdu_link_ptr_info,
  2509. struct hal_buf_info *hbi)
  2510. {
  2511. struct rx_msdu_link *msdu_link_ptr =
  2512. (struct rx_msdu_link *)msdu_link_desc_va;
  2513. qdf_mem_copy(&msdu_link_ptr_info->msdu_link, msdu_link_ptr,
  2514. sizeof(struct rx_msdu_link));
  2515. msdu_link_ptr_info->msdu_link_buf_info.paddr = hbi->paddr;
  2516. msdu_link_ptr_info->msdu_link_buf_info.sw_cookie = hbi->sw_cookie;
  2517. }
  2518. /*
  2519. * hal_rx_get_desc_len(): Returns rx descriptor length
  2520. *
  2521. * Returns the size of rx_pkt_tlvs which follows the
  2522. * data in the nbuf
  2523. *
  2524. * Returns: Length of rx descriptor
  2525. */
  2526. static inline
  2527. uint16_t hal_rx_get_desc_len(void)
  2528. {
  2529. return SIZE_OF_DATA_RX_TLV;
  2530. }
  2531. /*
  2532. * hal_rx_reo_ent_rxdma_push_reason_get(): Retrieves RXDMA push reason from
  2533. * reo_entrance_ring descriptor
  2534. *
  2535. * @reo_ent_desc: reo_entrance_ring descriptor
  2536. * Returns: value of rxdma_push_reason
  2537. */
  2538. static inline
  2539. uint8_t hal_rx_reo_ent_rxdma_push_reason_get(hal_rxdma_desc_t reo_ent_desc)
  2540. {
  2541. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2542. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_OFFSET)),
  2543. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_MASK,
  2544. REO_ENTRANCE_RING_6_RXDMA_PUSH_REASON_LSB);
  2545. }
  2546. /**
  2547. * hal_rx_reo_ent_rxdma_error_code_get(): Retrieves RXDMA error code from
  2548. * reo_entrance_ring descriptor
  2549. * @reo_ent_desc: reo_entrance_ring descriptor
  2550. * Return: value of rxdma_error_code
  2551. */
  2552. static inline
  2553. uint8_t hal_rx_reo_ent_rxdma_error_code_get(hal_rxdma_desc_t reo_ent_desc)
  2554. {
  2555. return _HAL_MS((*_OFFSET_TO_WORD_PTR(reo_ent_desc,
  2556. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_OFFSET)),
  2557. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_MASK,
  2558. REO_ENTRANCE_RING_6_RXDMA_ERROR_CODE_LSB);
  2559. }
  2560. /**
  2561. * hal_rx_wbm_err_info_get(): Retrieves WBM error code and reason and
  2562. * save it to hal_wbm_err_desc_info structure passed by caller
  2563. * @wbm_desc: wbm ring descriptor
  2564. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2565. * Return: void
  2566. */
  2567. static inline void hal_rx_wbm_err_info_get(void *wbm_desc,
  2568. struct hal_wbm_err_desc_info *wbm_er_info,
  2569. hal_soc_handle_t hal_soc_hdl)
  2570. {
  2571. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2572. hal_soc->ops->hal_rx_wbm_err_info_get(wbm_desc, (void *)wbm_er_info);
  2573. }
  2574. /**
  2575. * hal_rx_wbm_err_info_set_in_tlv(): Save the wbm error codes and reason to
  2576. * the reserved bytes of rx_tlv_hdr
  2577. * @buf: start of rx_tlv_hdr
  2578. * @wbm_er_info: hal_wbm_err_desc_info structure
  2579. * Return: void
  2580. */
  2581. static inline void hal_rx_wbm_err_info_set_in_tlv(uint8_t *buf,
  2582. struct hal_wbm_err_desc_info *wbm_er_info)
  2583. {
  2584. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2585. qdf_mem_copy(pkt_tlvs->rx_padding0, wbm_er_info,
  2586. sizeof(struct hal_wbm_err_desc_info));
  2587. }
  2588. /**
  2589. * hal_rx_wbm_err_info_get_from_tlv(): retrieve wbm error codes and reason from
  2590. * the reserved bytes of rx_tlv_hdr.
  2591. * @buf: start of rx_tlv_hdr
  2592. * @wbm_er_info: hal_wbm_err_desc_info structure, output parameter.
  2593. * Return: void
  2594. */
  2595. static inline void hal_rx_wbm_err_info_get_from_tlv(uint8_t *buf,
  2596. struct hal_wbm_err_desc_info *wbm_er_info)
  2597. {
  2598. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2599. qdf_mem_copy(wbm_er_info, pkt_tlvs->rx_padding0,
  2600. sizeof(struct hal_wbm_err_desc_info));
  2601. }
  2602. #define HAL_RX_MSDU_START_NSS_GET(_rx_msdu_start) \
  2603. (_HAL_MS((*_OFFSET_TO_WORD_PTR((_rx_msdu_start), \
  2604. RX_MSDU_START_5_NSS_OFFSET)), \
  2605. RX_MSDU_START_5_NSS_MASK, \
  2606. RX_MSDU_START_5_NSS_LSB))
  2607. /**
  2608. * hal_rx_mon_hw_desc_get_mpdu_status: Retrieve MPDU status
  2609. *
  2610. * @ hal_soc: HAL version of the SOC pointer
  2611. * @ hw_desc_addr: Start address of Rx HW TLVs
  2612. * @ rs: Status for monitor mode
  2613. *
  2614. * Return: void
  2615. */
  2616. static inline
  2617. void hal_rx_mon_hw_desc_get_mpdu_status(hal_soc_handle_t hal_soc_hdl,
  2618. void *hw_desc_addr,
  2619. struct mon_rx_status *rs)
  2620. {
  2621. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2622. hal_soc->ops->hal_rx_mon_hw_desc_get_mpdu_status(hw_desc_addr, rs);
  2623. }
  2624. /*
  2625. * hal_rx_get_tlv(): API to get the tlv
  2626. *
  2627. * @hal_soc: HAL version of the SOC pointer
  2628. * @rx_tlv: TLV data extracted from the rx packet
  2629. * Return: uint8_t
  2630. */
  2631. static inline uint8_t hal_rx_get_tlv(struct hal_soc *hal_soc, void *rx_tlv)
  2632. {
  2633. return hal_soc->ops->hal_rx_get_tlv(rx_tlv);
  2634. }
  2635. /*
  2636. * hal_rx_msdu_start_nss_get(): API to get the NSS
  2637. * Interval from rx_msdu_start
  2638. *
  2639. * @hal_soc: HAL version of the SOC pointer
  2640. * @buf: pointer to the start of RX PKT TLV header
  2641. * Return: uint32_t(nss)
  2642. */
  2643. static inline
  2644. uint32_t hal_rx_msdu_start_nss_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2645. {
  2646. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2647. return hal_soc->ops->hal_rx_msdu_start_nss_get(buf);
  2648. }
  2649. /**
  2650. * hal_rx_dump_msdu_start_tlv: dump RX msdu_start TLV in structured
  2651. * human readable format.
  2652. * @ msdu_start: pointer the msdu_start TLV in pkt.
  2653. * @ dbg_level: log level.
  2654. *
  2655. * Return: void
  2656. */
  2657. static inline void hal_rx_dump_msdu_start_tlv(struct hal_soc *hal_soc,
  2658. struct rx_msdu_start *msdu_start,
  2659. uint8_t dbg_level)
  2660. {
  2661. hal_soc->ops->hal_rx_dump_msdu_start_tlv(msdu_start, dbg_level);
  2662. }
  2663. /**
  2664. * hal_rx_mpdu_start_tid_get - Return tid info from the rx mpdu start
  2665. * info details
  2666. *
  2667. * @ buf - Pointer to buffer containing rx pkt tlvs.
  2668. *
  2669. *
  2670. */
  2671. static inline uint32_t hal_rx_mpdu_start_tid_get(hal_soc_handle_t hal_soc_hdl,
  2672. uint8_t *buf)
  2673. {
  2674. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2675. return hal_soc->ops->hal_rx_mpdu_start_tid_get(buf);
  2676. }
  2677. /*
  2678. * hal_rx_msdu_start_reception_type_get(): API to get the reception type
  2679. * Interval from rx_msdu_start
  2680. *
  2681. * @buf: pointer to the start of RX PKT TLV header
  2682. * Return: uint32_t(reception_type)
  2683. */
  2684. static inline
  2685. uint32_t hal_rx_msdu_start_reception_type_get(hal_soc_handle_t hal_soc_hdl,
  2686. uint8_t *buf)
  2687. {
  2688. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2689. return hal_soc->ops->hal_rx_msdu_start_reception_type_get(buf);
  2690. }
  2691. /**
  2692. * hal_rx_dump_pkt_tlvs: API to print all member elements of
  2693. * RX TLVs
  2694. * @ buf: pointer the pkt buffer.
  2695. * @ dbg_level: log level.
  2696. *
  2697. * Return: void
  2698. */
  2699. static inline void hal_rx_dump_pkt_tlvs(hal_soc_handle_t hal_soc_hdl,
  2700. uint8_t *buf, uint8_t dbg_level)
  2701. {
  2702. struct rx_pkt_tlvs *pkt_tlvs = (struct rx_pkt_tlvs *)buf;
  2703. struct rx_attention *rx_attn = &pkt_tlvs->attn_tlv.rx_attn;
  2704. struct rx_mpdu_start *mpdu_start =
  2705. &pkt_tlvs->mpdu_start_tlv.rx_mpdu_start;
  2706. struct rx_msdu_start *msdu_start =
  2707. &pkt_tlvs->msdu_start_tlv.rx_msdu_start;
  2708. struct rx_mpdu_end *mpdu_end = &pkt_tlvs->mpdu_end_tlv.rx_mpdu_end;
  2709. struct rx_msdu_end *msdu_end = &pkt_tlvs->msdu_end_tlv.rx_msdu_end;
  2710. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2711. hal_rx_dump_rx_attention_tlv(rx_attn, dbg_level);
  2712. hal_rx_dump_mpdu_start_tlv(mpdu_start, dbg_level, hal_soc);
  2713. hal_rx_dump_msdu_start_tlv(hal_soc, msdu_start, dbg_level);
  2714. hal_rx_dump_mpdu_end_tlv(mpdu_end, dbg_level);
  2715. hal_rx_dump_msdu_end_tlv(hal_soc, msdu_end, dbg_level);
  2716. hal_rx_dump_pkt_hdr_tlv(pkt_tlvs, dbg_level);
  2717. }
  2718. /**
  2719. * hal_reo_status_get_header_generic - Process reo desc info
  2720. * @d - Pointer to reo descriptior
  2721. * @b - tlv type info
  2722. * @h - Pointer to hal_reo_status_header where info to be stored
  2723. * @hal- pointer to hal_soc structure
  2724. * Return - none.
  2725. *
  2726. */
  2727. static inline
  2728. void hal_reo_status_get_header(uint32_t *d, int b,
  2729. void *h, struct hal_soc *hal_soc)
  2730. {
  2731. hal_soc->ops->hal_reo_status_get_header(d, b, h);
  2732. }
  2733. /**
  2734. * hal_rx_desc_is_first_msdu() - Check if first msdu
  2735. *
  2736. * @hal_soc_hdl: hal_soc handle
  2737. * @hw_desc_addr: hardware descriptor address
  2738. *
  2739. * Return: 0 - success/ non-zero failure
  2740. */
  2741. static inline
  2742. uint32_t hal_rx_desc_is_first_msdu(hal_soc_handle_t hal_soc_hdl,
  2743. void *hw_desc_addr)
  2744. {
  2745. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2746. return hal_soc->ops->hal_rx_desc_is_first_msdu(hw_desc_addr);
  2747. }
  2748. static inline
  2749. uint32_t
  2750. HAL_RX_DESC_GET_DECAP_FORMAT(void *hw_desc_addr) {
  2751. struct rx_msdu_start *rx_msdu_start;
  2752. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  2753. rx_msdu_start = &rx_desc->msdu_start_tlv.rx_msdu_start;
  2754. return HAL_RX_GET(rx_msdu_start, RX_MSDU_START_2, DECAP_FORMAT);
  2755. }
  2756. #ifdef NO_RX_PKT_HDR_TLV
  2757. static inline
  2758. uint8_t *
  2759. HAL_RX_DESC_GET_80211_HDR(void *hw_desc_addr) {
  2760. uint8_t *rx_pkt_hdr;
  2761. struct rx_mon_pkt_tlvs *rx_desc =
  2762. (struct rx_mon_pkt_tlvs *)hw_desc_addr;
  2763. rx_pkt_hdr = &rx_desc->pkt_hdr_tlv.rx_pkt_hdr[0];
  2764. return rx_pkt_hdr;
  2765. }
  2766. #else
  2767. static inline
  2768. uint8_t *
  2769. HAL_RX_DESC_GET_80211_HDR(void *hw_desc_addr) {
  2770. uint8_t *rx_pkt_hdr;
  2771. struct rx_pkt_tlvs *rx_desc = (struct rx_pkt_tlvs *)hw_desc_addr;
  2772. rx_pkt_hdr = &rx_desc->pkt_hdr_tlv.rx_pkt_hdr[0];
  2773. return rx_pkt_hdr;
  2774. }
  2775. #endif
  2776. static inline
  2777. bool HAL_IS_DECAP_FORMAT_RAW(hal_soc_handle_t hal_soc_hdl,
  2778. uint8_t *rx_tlv_hdr)
  2779. {
  2780. uint8_t decap_format;
  2781. if (hal_rx_desc_is_first_msdu(hal_soc_hdl, rx_tlv_hdr)) {
  2782. decap_format = HAL_RX_DESC_GET_DECAP_FORMAT(rx_tlv_hdr);
  2783. if (decap_format == HAL_HW_RX_DECAP_FORMAT_RAW)
  2784. return true;
  2785. }
  2786. return false;
  2787. }
  2788. /**
  2789. * hal_rx_msdu_fse_metadata_get: API to get FSE metadata
  2790. * from rx_msdu_end TLV
  2791. * @buf: pointer to the start of RX PKT TLV headers
  2792. *
  2793. * Return: fse metadata value from MSDU END TLV
  2794. */
  2795. static inline uint32_t
  2796. hal_rx_msdu_fse_metadata_get(hal_soc_handle_t hal_soc_hdl,
  2797. uint8_t *buf)
  2798. {
  2799. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2800. return hal_soc->ops->hal_rx_msdu_fse_metadata_get(buf);
  2801. }
  2802. /**
  2803. * hal_rx_msdu_flow_idx_get: API to get flow index
  2804. * from rx_msdu_end TLV
  2805. * @buf: pointer to the start of RX PKT TLV headers
  2806. *
  2807. * Return: flow index value from MSDU END TLV
  2808. */
  2809. static inline uint32_t
  2810. hal_rx_msdu_flow_idx_get(hal_soc_handle_t hal_soc_hdl,
  2811. uint8_t *buf)
  2812. {
  2813. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2814. return hal_soc->ops->hal_rx_msdu_flow_idx_get(buf);
  2815. }
  2816. /**
  2817. * hal_rx_msdu_flow_idx_timeout: API to get flow index timeout
  2818. * from rx_msdu_end TLV
  2819. * @buf: pointer to the start of RX PKT TLV headers
  2820. *
  2821. * Return: flow index timeout value from MSDU END TLV
  2822. */
  2823. static inline bool
  2824. hal_rx_msdu_flow_idx_timeout(hal_soc_handle_t hal_soc_hdl,
  2825. uint8_t *buf)
  2826. {
  2827. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2828. return hal_soc->ops->hal_rx_msdu_flow_idx_timeout(buf);
  2829. }
  2830. /**
  2831. * hal_rx_msdu_flow_idx_invalid: API to get flow index invalid
  2832. * from rx_msdu_end TLV
  2833. * @buf: pointer to the start of RX PKT TLV headers
  2834. *
  2835. * Return: flow index invalid value from MSDU END TLV
  2836. */
  2837. static inline bool
  2838. hal_rx_msdu_flow_idx_invalid(hal_soc_handle_t hal_soc_hdl,
  2839. uint8_t *buf)
  2840. {
  2841. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2842. return hal_soc->ops->hal_rx_msdu_flow_idx_invalid(buf);
  2843. }
  2844. /**
  2845. * hal_rx_hw_desc_get_ppduid_get() - Retrieve ppdu id
  2846. * @hal_soc_hdl: hal_soc handle
  2847. * @rx_tlv_hdr: Rx_tlv_hdr
  2848. * @rxdma_dst_ring_desc: Rx HW descriptor
  2849. *
  2850. * Return: ppdu id
  2851. */
  2852. static inline
  2853. uint32_t hal_rx_hw_desc_get_ppduid_get(hal_soc_handle_t hal_soc_hdl,
  2854. void *rx_tlv_hdr,
  2855. void *rxdma_dst_ring_desc)
  2856. {
  2857. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2858. return hal_soc->ops->hal_rx_hw_desc_get_ppduid_get(rx_tlv_hdr,
  2859. rxdma_dst_ring_desc);
  2860. }
  2861. /**
  2862. * hal_rx_msdu_end_sa_sw_peer_id_get() - get sw peer id
  2863. * @hal_soc_hdl: hal_soc handle
  2864. * @buf: rx tlv address
  2865. *
  2866. * Return: sw peer id
  2867. */
  2868. static inline
  2869. uint32_t hal_rx_msdu_end_sa_sw_peer_id_get(hal_soc_handle_t hal_soc_hdl,
  2870. uint8_t *buf)
  2871. {
  2872. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2873. if ((!hal_soc) || (!hal_soc->ops)) {
  2874. hal_err("hal handle is NULL");
  2875. QDF_BUG(0);
  2876. return QDF_STATUS_E_INVAL;
  2877. }
  2878. if (hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get)
  2879. return hal_soc->ops->hal_rx_msdu_end_sa_sw_peer_id_get(buf);
  2880. return QDF_STATUS_E_INVAL;
  2881. }
  2882. static inline
  2883. void *hal_rx_msdu0_buffer_addr_lsb(hal_soc_handle_t hal_soc_hdl,
  2884. void *link_desc_addr)
  2885. {
  2886. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2887. return hal_soc->ops->hal_rx_msdu0_buffer_addr_lsb(link_desc_addr);
  2888. }
  2889. static inline
  2890. void *hal_rx_msdu_desc_info_ptr_get(hal_soc_handle_t hal_soc_hdl,
  2891. void *msdu_addr)
  2892. {
  2893. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2894. return hal_soc->ops->hal_rx_msdu_desc_info_ptr_get(msdu_addr);
  2895. }
  2896. static inline
  2897. void *hal_ent_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  2898. void *hw_addr)
  2899. {
  2900. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2901. return hal_soc->ops->hal_ent_mpdu_desc_info(hw_addr);
  2902. }
  2903. static inline
  2904. void *hal_dst_mpdu_desc_info(hal_soc_handle_t hal_soc_hdl,
  2905. void *hw_addr)
  2906. {
  2907. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2908. return hal_soc->ops->hal_dst_mpdu_desc_info(hw_addr);
  2909. }
  2910. static inline
  2911. uint8_t hal_rx_get_fc_valid(hal_soc_handle_t hal_soc_hdl,
  2912. uint8_t *buf)
  2913. {
  2914. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2915. return hal_soc->ops->hal_rx_get_fc_valid(buf);
  2916. }
  2917. static inline
  2918. uint8_t hal_rx_get_to_ds_flag(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  2919. {
  2920. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2921. return hal_soc->ops->hal_rx_get_to_ds_flag(buf);
  2922. }
  2923. static inline
  2924. uint8_t hal_rx_get_mac_addr2_valid(hal_soc_handle_t hal_soc_hdl,
  2925. uint8_t *buf)
  2926. {
  2927. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2928. return hal_soc->ops->hal_rx_get_mac_addr2_valid(buf);
  2929. }
  2930. static inline
  2931. uint8_t hal_rx_get_filter_category(hal_soc_handle_t hal_soc_hdl,
  2932. uint8_t *buf)
  2933. {
  2934. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2935. return hal_soc->ops->hal_rx_get_filter_category(buf);
  2936. }
  2937. static inline
  2938. uint32_t hal_rx_get_ppdu_id(hal_soc_handle_t hal_soc_hdl,
  2939. uint8_t *buf)
  2940. {
  2941. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2942. return hal_soc->ops->hal_rx_get_ppdu_id(buf);
  2943. }
  2944. /**
  2945. * hal_reo_config(): Set reo config parameters
  2946. * @soc: hal soc handle
  2947. * @reg_val: value to be set
  2948. * @reo_params: reo parameters
  2949. *
  2950. * Return: void
  2951. */
  2952. static inline
  2953. void hal_reo_config(struct hal_soc *hal_soc,
  2954. uint32_t reg_val,
  2955. struct hal_reo_params *reo_params)
  2956. {
  2957. hal_soc->ops->hal_reo_config(hal_soc,
  2958. reg_val,
  2959. reo_params);
  2960. }
  2961. /**
  2962. * hal_rx_msdu_get_flow_params: API to get flow index,
  2963. * flow index invalid and flow index timeout from rx_msdu_end TLV
  2964. * @buf: pointer to the start of RX PKT TLV headers
  2965. * @flow_invalid: pointer to return value of flow_idx_valid
  2966. * @flow_timeout: pointer to return value of flow_idx_timeout
  2967. * @flow_index: pointer to return value of flow_idx
  2968. *
  2969. * Return: none
  2970. */
  2971. static inline void
  2972. hal_rx_msdu_get_flow_params(hal_soc_handle_t hal_soc_hdl,
  2973. uint8_t *buf,
  2974. bool *flow_invalid,
  2975. bool *flow_timeout,
  2976. uint32_t *flow_index)
  2977. {
  2978. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2979. if ((!hal_soc) || (!hal_soc->ops)) {
  2980. hal_err("hal handle is NULL");
  2981. QDF_BUG(0);
  2982. return;
  2983. }
  2984. if (hal_soc->ops->hal_rx_msdu_get_flow_params)
  2985. hal_soc->ops->
  2986. hal_rx_msdu_get_flow_params(buf,
  2987. flow_invalid,
  2988. flow_timeout,
  2989. flow_index);
  2990. }
  2991. static inline
  2992. uint16_t hal_rx_tlv_get_tcp_chksum(hal_soc_handle_t hal_soc_hdl,
  2993. uint8_t *buf)
  2994. {
  2995. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  2996. return hal_soc->ops->hal_rx_tlv_get_tcp_chksum(buf);
  2997. }
  2998. static inline
  2999. uint16_t hal_rx_get_rx_sequence(hal_soc_handle_t hal_soc_hdl,
  3000. uint8_t *buf)
  3001. {
  3002. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3003. return hal_soc->ops->hal_rx_get_rx_sequence(buf);
  3004. }
  3005. static inline void
  3006. hal_rx_get_bb_info(hal_soc_handle_t hal_soc_hdl,
  3007. void *rx_tlv,
  3008. void *ppdu_info)
  3009. {
  3010. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3011. if (hal_soc->ops->hal_rx_get_bb_info)
  3012. hal_soc->ops->hal_rx_get_bb_info(rx_tlv, ppdu_info);
  3013. }
  3014. static inline void
  3015. hal_rx_get_rtt_info(hal_soc_handle_t hal_soc_hdl,
  3016. void *rx_tlv,
  3017. void *ppdu_info)
  3018. {
  3019. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3020. if (hal_soc->ops->hal_rx_get_rtt_info)
  3021. hal_soc->ops->hal_rx_get_rtt_info(rx_tlv, ppdu_info);
  3022. }
  3023. /**
  3024. * hal_rx_msdu_metadata_get(): API to get the
  3025. * fast path information from rx_msdu_end TLV
  3026. *
  3027. * @ hal_soc_hdl: DP soc handle
  3028. * @ buf: pointer to the start of RX PKT TLV headers
  3029. * @ msdu_metadata: Structure to hold msdu end information
  3030. * Return: none
  3031. */
  3032. static inline void
  3033. hal_rx_msdu_metadata_get(hal_soc_handle_t hal_soc_hdl, uint8_t *buf,
  3034. struct hal_rx_msdu_metadata *msdu_md)
  3035. {
  3036. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3037. return hal_soc->ops->hal_rx_msdu_packet_metadata_get(buf, msdu_md);
  3038. }
  3039. /**
  3040. * hal_rx_get_fisa_cumulative_l4_checksum: API to get cumulative_l4_checksum
  3041. * from rx_msdu_end TLV
  3042. * @buf: pointer to the start of RX PKT TLV headers
  3043. *
  3044. * Return: cumulative_l4_checksum
  3045. */
  3046. static inline uint16_t
  3047. hal_rx_get_fisa_cumulative_l4_checksum(hal_soc_handle_t hal_soc_hdl,
  3048. uint8_t *buf)
  3049. {
  3050. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3051. if (!hal_soc || !hal_soc->ops) {
  3052. hal_err("hal handle is NULL");
  3053. QDF_BUG(0);
  3054. return 0;
  3055. }
  3056. if (!hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum)
  3057. return 0;
  3058. return hal_soc->ops->hal_rx_get_fisa_cumulative_l4_checksum(buf);
  3059. }
  3060. /**
  3061. * hal_rx_get_fisa_cumulative_ip_length: API to get cumulative_ip_length
  3062. * from rx_msdu_end TLV
  3063. * @buf: pointer to the start of RX PKT TLV headers
  3064. *
  3065. * Return: cumulative_ip_length
  3066. */
  3067. static inline uint16_t
  3068. hal_rx_get_fisa_cumulative_ip_length(hal_soc_handle_t hal_soc_hdl,
  3069. uint8_t *buf)
  3070. {
  3071. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3072. if (!hal_soc || !hal_soc->ops) {
  3073. hal_err("hal handle is NULL");
  3074. QDF_BUG(0);
  3075. return 0;
  3076. }
  3077. if (hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length)
  3078. return hal_soc->ops->hal_rx_get_fisa_cumulative_ip_length(buf);
  3079. return 0;
  3080. }
  3081. /**
  3082. * hal_rx_get_udp_proto: API to get UDP proto field
  3083. * from rx_msdu_start TLV
  3084. * @buf: pointer to the start of RX PKT TLV headers
  3085. *
  3086. * Return: UDP proto field value
  3087. */
  3088. static inline bool
  3089. hal_rx_get_udp_proto(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  3090. {
  3091. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3092. if (!hal_soc || !hal_soc->ops) {
  3093. hal_err("hal handle is NULL");
  3094. QDF_BUG(0);
  3095. return 0;
  3096. }
  3097. if (hal_soc->ops->hal_rx_get_udp_proto)
  3098. return hal_soc->ops->hal_rx_get_udp_proto(buf);
  3099. return 0;
  3100. }
  3101. /**
  3102. * hal_rx_get_fisa_flow_agg_continuation: API to get fisa flow_agg_continuation
  3103. * from rx_msdu_end TLV
  3104. * @buf: pointer to the start of RX PKT TLV headers
  3105. *
  3106. * Return: flow_agg_continuation bit field value
  3107. */
  3108. static inline bool
  3109. hal_rx_get_fisa_flow_agg_continuation(hal_soc_handle_t hal_soc_hdl,
  3110. uint8_t *buf)
  3111. {
  3112. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3113. if (!hal_soc || !hal_soc->ops) {
  3114. hal_err("hal handle is NULL");
  3115. QDF_BUG(0);
  3116. return 0;
  3117. }
  3118. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation)
  3119. return hal_soc->ops->hal_rx_get_fisa_flow_agg_continuation(buf);
  3120. return 0;
  3121. }
  3122. /**
  3123. * hal_rx_get_fisa_flow_agg_count: API to get fisa flow_agg count from
  3124. * rx_msdu_end TLV
  3125. * @buf: pointer to the start of RX PKT TLV headers
  3126. *
  3127. * Return: flow_agg count value
  3128. */
  3129. static inline uint8_t
  3130. hal_rx_get_fisa_flow_agg_count(hal_soc_handle_t hal_soc_hdl,
  3131. uint8_t *buf)
  3132. {
  3133. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3134. if (!hal_soc || !hal_soc->ops) {
  3135. hal_err("hal handle is NULL");
  3136. QDF_BUG(0);
  3137. return 0;
  3138. }
  3139. if (hal_soc->ops->hal_rx_get_fisa_flow_agg_count)
  3140. return hal_soc->ops->hal_rx_get_fisa_flow_agg_count(buf);
  3141. return 0;
  3142. }
  3143. /**
  3144. * hal_rx_get_fisa_timeout: API to get fisa time out from rx_msdu_end TLV
  3145. * @buf: pointer to the start of RX PKT TLV headers
  3146. *
  3147. * Return: fisa flow_agg timeout bit value
  3148. */
  3149. static inline bool
  3150. hal_rx_get_fisa_timeout(hal_soc_handle_t hal_soc_hdl, uint8_t *buf)
  3151. {
  3152. struct hal_soc *hal_soc = (struct hal_soc *)hal_soc_hdl;
  3153. if (!hal_soc || !hal_soc->ops) {
  3154. hal_err("hal handle is NULL");
  3155. QDF_BUG(0);
  3156. return 0;
  3157. }
  3158. if (hal_soc->ops->hal_rx_get_fisa_timeout)
  3159. return hal_soc->ops->hal_rx_get_fisa_timeout(buf);
  3160. return 0;
  3161. }
  3162. /**
  3163. * hal_rx_mpdu_start_tlv_tag_valid - API to check if RX_MPDU_START tlv
  3164. * tag is valid
  3165. *
  3166. * @hal_soc_hdl: HAL SOC handle
  3167. * @rx_tlv_hdr: start address of rx_pkt_tlvs
  3168. *
  3169. * Return: true if RX_MPDU_START tlv tag is valid, else false
  3170. */
  3171. static inline uint8_t
  3172. hal_rx_mpdu_start_tlv_tag_valid(hal_soc_handle_t hal_soc_hdl,
  3173. void *rx_tlv_hdr)
  3174. {
  3175. struct hal_soc *hal = (struct hal_soc *)hal_soc_hdl;
  3176. return hal->ops->hal_rx_mpdu_start_tlv_tag_valid(rx_tlv_hdr);
  3177. }
  3178. #endif /* _HAL_RX_H */