dp_tx.c 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613
  1. /*
  2. * Copyright (c) 2016-2018 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. #include "htt.h"
  19. #include "dp_tx.h"
  20. #include "dp_tx_desc.h"
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "hal_tx.h"
  24. #include "qdf_mem.h"
  25. #include "qdf_nbuf.h"
  26. #include "qdf_net_types.h"
  27. #include <wlan_cfg.h>
  28. #ifdef MESH_MODE_SUPPORT
  29. #include "if_meta_hdr.h"
  30. #endif
  31. #define DP_TX_QUEUE_MASK 0x3
  32. /* TODO Add support in TSO */
  33. #define DP_DESC_NUM_FRAG(x) 0
  34. /* disable TQM_BYPASS */
  35. #define TQM_BYPASS_WAR 0
  36. /* invalid peer id for reinject*/
  37. #define DP_INVALID_PEER 0XFFFE
  38. /*mapping between hal encrypt type and cdp_sec_type*/
  39. #define MAX_CDP_SEC_TYPE 12
  40. static const uint8_t sec_type_map[MAX_CDP_SEC_TYPE] = {
  41. HAL_TX_ENCRYPT_TYPE_NO_CIPHER,
  42. HAL_TX_ENCRYPT_TYPE_WEP_128,
  43. HAL_TX_ENCRYPT_TYPE_WEP_104,
  44. HAL_TX_ENCRYPT_TYPE_WEP_40,
  45. HAL_TX_ENCRYPT_TYPE_TKIP_WITH_MIC,
  46. HAL_TX_ENCRYPT_TYPE_TKIP_NO_MIC,
  47. HAL_TX_ENCRYPT_TYPE_AES_CCMP_128,
  48. HAL_TX_ENCRYPT_TYPE_WAPI,
  49. HAL_TX_ENCRYPT_TYPE_AES_CCMP_256,
  50. HAL_TX_ENCRYPT_TYPE_AES_GCMP_128,
  51. HAL_TX_ENCRYPT_TYPE_AES_GCMP_256,
  52. HAL_TX_ENCRYPT_TYPE_WAPI_GCM_SM4};
  53. /**
  54. * dp_tx_get_queue() - Returns Tx queue IDs to be used for this Tx frame
  55. * @vdev: DP Virtual device handle
  56. * @nbuf: Buffer pointer
  57. * @queue: queue ids container for nbuf
  58. *
  59. * TX packet queue has 2 instances, software descriptors id and dma ring id
  60. * Based on tx feature and hardware configuration queue id combination could be
  61. * different.
  62. * For example -
  63. * With XPS enabled,all TX descriptor pools and dma ring are assigned per cpu id
  64. * With no XPS,lock based resource protection, Descriptor pool ids are different
  65. * for each vdev, dma ring id will be same as single pdev id
  66. *
  67. * Return: None
  68. */
  69. #ifdef QCA_OL_TX_MULTIQ_SUPPORT
  70. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  71. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  72. {
  73. uint16_t queue_offset = qdf_nbuf_get_queue_mapping(nbuf) & DP_TX_QUEUE_MASK;
  74. queue->desc_pool_id = queue_offset;
  75. queue->ring_id = vdev->pdev->soc->tx_ring_map[queue_offset];
  76. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  77. "%s, pool_id:%d ring_id: %d",
  78. __func__, queue->desc_pool_id, queue->ring_id);
  79. return;
  80. }
  81. #else /* QCA_OL_TX_MULTIQ_SUPPORT */
  82. static inline void dp_tx_get_queue(struct dp_vdev *vdev,
  83. qdf_nbuf_t nbuf, struct dp_tx_queue *queue)
  84. {
  85. /* get flow id */
  86. queue->desc_pool_id = DP_TX_GET_DESC_POOL_ID(vdev);
  87. queue->ring_id = DP_TX_GET_RING_ID(vdev);
  88. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  89. "%s, pool_id:%d ring_id: %d",
  90. __func__, queue->desc_pool_id, queue->ring_id);
  91. return;
  92. }
  93. #endif
  94. #if defined(FEATURE_TSO)
  95. /**
  96. * dp_tx_tso_desc_release() - Release the tso segment
  97. * after unmapping all the fragments
  98. *
  99. * @pdev - physical device handle
  100. * @tx_desc - Tx software descriptor
  101. */
  102. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  103. struct dp_tx_desc_s *tx_desc)
  104. {
  105. TSO_DEBUG("%s: Free the tso descriptor", __func__);
  106. if (qdf_unlikely(tx_desc->tso_desc == NULL)) {
  107. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  108. "%s %d TSO desc is NULL!",
  109. __func__, __LINE__);
  110. qdf_assert(0);
  111. } else if (qdf_unlikely(tx_desc->tso_num_desc == NULL)) {
  112. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  113. "%s %d TSO common info is NULL!",
  114. __func__, __LINE__);
  115. qdf_assert(0);
  116. } else {
  117. struct qdf_tso_num_seg_elem_t *tso_num_desc =
  118. (struct qdf_tso_num_seg_elem_t *) tx_desc->tso_num_desc;
  119. if (tso_num_desc->num_seg.tso_cmn_num_seg > 1) {
  120. tso_num_desc->num_seg.tso_cmn_num_seg--;
  121. qdf_nbuf_unmap_tso_segment(soc->osdev,
  122. tx_desc->tso_desc, false);
  123. } else {
  124. tso_num_desc->num_seg.tso_cmn_num_seg--;
  125. qdf_assert(tso_num_desc->num_seg.tso_cmn_num_seg == 0);
  126. qdf_nbuf_unmap_tso_segment(soc->osdev,
  127. tx_desc->tso_desc, true);
  128. dp_tso_num_seg_free(soc, tx_desc->pool_id,
  129. tx_desc->tso_num_desc);
  130. tx_desc->tso_num_desc = NULL;
  131. }
  132. dp_tx_tso_desc_free(soc,
  133. tx_desc->pool_id, tx_desc->tso_desc);
  134. tx_desc->tso_desc = NULL;
  135. }
  136. }
  137. #else
  138. static void dp_tx_tso_desc_release(struct dp_soc *soc,
  139. struct dp_tx_desc_s *tx_desc)
  140. {
  141. return;
  142. }
  143. #endif
  144. /**
  145. * dp_tx_desc_release() - Release Tx Descriptor
  146. * @tx_desc : Tx Descriptor
  147. * @desc_pool_id: Descriptor Pool ID
  148. *
  149. * Deallocate all resources attached to Tx descriptor and free the Tx
  150. * descriptor.
  151. *
  152. * Return:
  153. */
  154. static void
  155. dp_tx_desc_release(struct dp_tx_desc_s *tx_desc, uint8_t desc_pool_id)
  156. {
  157. struct dp_pdev *pdev = tx_desc->pdev;
  158. struct dp_soc *soc;
  159. uint8_t comp_status = 0;
  160. qdf_assert(pdev);
  161. soc = pdev->soc;
  162. if (tx_desc->frm_type == dp_tx_frm_tso)
  163. dp_tx_tso_desc_release(soc, tx_desc);
  164. if (tx_desc->flags & DP_TX_DESC_FLAG_FRAG)
  165. dp_tx_ext_desc_free(soc, tx_desc->msdu_ext_desc, desc_pool_id);
  166. if (tx_desc->flags & DP_TX_DESC_FLAG_ME)
  167. dp_tx_me_free_buf(tx_desc->pdev, tx_desc->me_buffer);
  168. qdf_atomic_dec(&pdev->num_tx_outstanding);
  169. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)
  170. qdf_atomic_dec(&pdev->num_tx_exception);
  171. if (HAL_TX_COMP_RELEASE_SOURCE_TQM ==
  172. hal_tx_comp_get_buffer_source(&tx_desc->comp))
  173. comp_status = hal_tx_comp_get_release_reason(&tx_desc->comp);
  174. else
  175. comp_status = HAL_TX_COMP_RELEASE_REASON_FW;
  176. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  177. "Tx Completion Release desc %d status %d outstanding %d",
  178. tx_desc->id, comp_status,
  179. qdf_atomic_read(&pdev->num_tx_outstanding));
  180. dp_tx_desc_free(soc, tx_desc, desc_pool_id);
  181. return;
  182. }
  183. /**
  184. * dp_tx_htt_metadata_prepare() - Prepare HTT metadata for special frames
  185. * @vdev: DP vdev Handle
  186. * @nbuf: skb
  187. *
  188. * Prepares and fills HTT metadata in the frame pre-header for special frames
  189. * that should be transmitted using varying transmit parameters.
  190. * There are 2 VDEV modes that currently needs this special metadata -
  191. * 1) Mesh Mode
  192. * 2) DSRC Mode
  193. *
  194. * Return: HTT metadata size
  195. *
  196. */
  197. static uint8_t dp_tx_prepare_htt_metadata(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  198. uint32_t *meta_data)
  199. {
  200. struct htt_tx_msdu_desc_ext2_t *desc_ext =
  201. (struct htt_tx_msdu_desc_ext2_t *) meta_data;
  202. uint8_t htt_desc_size;
  203. /* Size rounded of multiple of 8 bytes */
  204. uint8_t htt_desc_size_aligned;
  205. uint8_t *hdr = NULL;
  206. /*
  207. * Metadata - HTT MSDU Extension header
  208. */
  209. htt_desc_size = sizeof(struct htt_tx_msdu_desc_ext2_t);
  210. htt_desc_size_aligned = (htt_desc_size + 7) & ~0x7;
  211. if (vdev->mesh_vdev) {
  212. /* Fill and add HTT metaheader */
  213. hdr = qdf_nbuf_push_head(nbuf, htt_desc_size_aligned);
  214. if (hdr == NULL) {
  215. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  216. "Error in filling HTT metadata\n");
  217. return 0;
  218. }
  219. qdf_mem_copy(hdr, desc_ext, htt_desc_size);
  220. } else if (vdev->opmode == wlan_op_mode_ocb) {
  221. /* Todo - Add support for DSRC */
  222. }
  223. return htt_desc_size_aligned;
  224. }
  225. /**
  226. * dp_tx_prepare_tso_ext_desc() - Prepare MSDU extension descriptor for TSO
  227. * @tso_seg: TSO segment to process
  228. * @ext_desc: Pointer to MSDU extension descriptor
  229. *
  230. * Return: void
  231. */
  232. #if defined(FEATURE_TSO)
  233. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  234. void *ext_desc)
  235. {
  236. uint8_t num_frag;
  237. uint32_t tso_flags;
  238. /*
  239. * Set tso_en, tcp_flags(NS, CWR, ECE, URG, ACK, PSH, RST, SYN, FIN),
  240. * tcp_flag_mask
  241. *
  242. * Checksum enable flags are set in TCL descriptor and not in Extension
  243. * Descriptor (H/W ignores checksum_en flags in MSDU ext descriptor)
  244. */
  245. tso_flags = *(uint32_t *) &tso_seg->tso_flags;
  246. hal_tx_ext_desc_set_tso_flags(ext_desc, tso_flags);
  247. hal_tx_ext_desc_set_msdu_length(ext_desc, tso_seg->tso_flags.l2_len,
  248. tso_seg->tso_flags.ip_len);
  249. hal_tx_ext_desc_set_tcp_seq(ext_desc, tso_seg->tso_flags.tcp_seq_num);
  250. hal_tx_ext_desc_set_ip_id(ext_desc, tso_seg->tso_flags.ip_id);
  251. for (num_frag = 0; num_frag < tso_seg->num_frags; num_frag++) {
  252. uint32_t lo = 0;
  253. uint32_t hi = 0;
  254. qdf_dmaaddr_to_32s(
  255. tso_seg->tso_frags[num_frag].paddr, &lo, &hi);
  256. hal_tx_ext_desc_set_buffer(ext_desc, num_frag, lo, hi,
  257. tso_seg->tso_frags[num_frag].length);
  258. }
  259. return;
  260. }
  261. #else
  262. static void dp_tx_prepare_tso_ext_desc(struct qdf_tso_seg_t *tso_seg,
  263. void *ext_desc)
  264. {
  265. return;
  266. }
  267. #endif
  268. #if defined(FEATURE_TSO)
  269. /**
  270. * dp_tx_free_tso_seg() - Loop through the tso segments
  271. * allocated and free them
  272. *
  273. * @soc: soc handle
  274. * @free_seg: list of tso segments
  275. * @msdu_info: msdu descriptor
  276. *
  277. * Return - void
  278. */
  279. static void dp_tx_free_tso_seg(struct dp_soc *soc,
  280. struct qdf_tso_seg_elem_t *free_seg,
  281. struct dp_tx_msdu_info_s *msdu_info)
  282. {
  283. struct qdf_tso_seg_elem_t *next_seg;
  284. while (free_seg) {
  285. next_seg = free_seg->next;
  286. dp_tx_tso_desc_free(soc,
  287. msdu_info->tx_queue.desc_pool_id,
  288. free_seg);
  289. free_seg = next_seg;
  290. }
  291. }
  292. /**
  293. * dp_tx_free_tso_num_seg() - Loop through the tso num segments
  294. * allocated and free them
  295. *
  296. * @soc: soc handle
  297. * @free_seg: list of tso segments
  298. * @msdu_info: msdu descriptor
  299. * Return - void
  300. */
  301. static void dp_tx_free_tso_num_seg(struct dp_soc *soc,
  302. struct qdf_tso_num_seg_elem_t *free_seg,
  303. struct dp_tx_msdu_info_s *msdu_info)
  304. {
  305. struct qdf_tso_num_seg_elem_t *next_seg;
  306. while (free_seg) {
  307. next_seg = free_seg->next;
  308. dp_tso_num_seg_free(soc,
  309. msdu_info->tx_queue.desc_pool_id,
  310. free_seg);
  311. free_seg = next_seg;
  312. }
  313. }
  314. /**
  315. * dp_tx_prepare_tso() - Given a jumbo msdu, prepare the TSO info
  316. * @vdev: virtual device handle
  317. * @msdu: network buffer
  318. * @msdu_info: meta data associated with the msdu
  319. *
  320. * Return: QDF_STATUS_SUCCESS success
  321. */
  322. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  323. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  324. {
  325. struct qdf_tso_seg_elem_t *tso_seg;
  326. int num_seg = qdf_nbuf_get_tso_num_seg(msdu);
  327. struct dp_soc *soc = vdev->pdev->soc;
  328. struct qdf_tso_info_t *tso_info;
  329. struct qdf_tso_num_seg_elem_t *tso_num_seg;
  330. tso_info = &msdu_info->u.tso_info;
  331. tso_info->curr_seg = NULL;
  332. tso_info->tso_seg_list = NULL;
  333. tso_info->num_segs = num_seg;
  334. msdu_info->frm_type = dp_tx_frm_tso;
  335. tso_info->tso_num_seg_list = NULL;
  336. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  337. while (num_seg) {
  338. tso_seg = dp_tx_tso_desc_alloc(
  339. soc, msdu_info->tx_queue.desc_pool_id);
  340. if (tso_seg) {
  341. tso_seg->next = tso_info->tso_seg_list;
  342. tso_info->tso_seg_list = tso_seg;
  343. num_seg--;
  344. } else {
  345. struct qdf_tso_seg_elem_t *free_seg =
  346. tso_info->tso_seg_list;
  347. dp_tx_free_tso_seg(soc, free_seg, msdu_info);
  348. return QDF_STATUS_E_NOMEM;
  349. }
  350. }
  351. TSO_DEBUG(" %s: num_seg: %d", __func__, num_seg);
  352. tso_num_seg = dp_tso_num_seg_alloc(soc,
  353. msdu_info->tx_queue.desc_pool_id);
  354. if (tso_num_seg) {
  355. tso_num_seg->next = tso_info->tso_num_seg_list;
  356. tso_info->tso_num_seg_list = tso_num_seg;
  357. } else {
  358. /* Bug: free tso_num_seg and tso_seg */
  359. /* Free the already allocated num of segments */
  360. struct qdf_tso_seg_elem_t *free_seg =
  361. tso_info->tso_seg_list;
  362. TSO_DEBUG(" %s: Failed alloc - Number of segs for a TSO packet",
  363. __func__);
  364. dp_tx_free_tso_seg(soc, free_seg, msdu_info);
  365. return QDF_STATUS_E_NOMEM;
  366. }
  367. msdu_info->num_seg =
  368. qdf_nbuf_get_tso_info(soc->osdev, msdu, tso_info);
  369. TSO_DEBUG(" %s: msdu_info->num_seg: %d", __func__,
  370. msdu_info->num_seg);
  371. if (!(msdu_info->num_seg)) {
  372. dp_tx_free_tso_seg(soc, tso_info->tso_seg_list, msdu_info);
  373. dp_tx_free_tso_num_seg(soc, tso_info->tso_num_seg_list,
  374. msdu_info);
  375. return QDF_STATUS_E_INVAL;
  376. }
  377. tso_info->curr_seg = tso_info->tso_seg_list;
  378. return QDF_STATUS_SUCCESS;
  379. }
  380. #else
  381. static QDF_STATUS dp_tx_prepare_tso(struct dp_vdev *vdev,
  382. qdf_nbuf_t msdu, struct dp_tx_msdu_info_s *msdu_info)
  383. {
  384. return QDF_STATUS_E_NOMEM;
  385. }
  386. #endif
  387. /**
  388. * dp_tx_prepare_ext_desc() - Allocate and prepare MSDU extension descriptor
  389. * @vdev: DP Vdev handle
  390. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  391. * @desc_pool_id: Descriptor Pool ID
  392. *
  393. * Return:
  394. */
  395. static
  396. struct dp_tx_ext_desc_elem_s *dp_tx_prepare_ext_desc(struct dp_vdev *vdev,
  397. struct dp_tx_msdu_info_s *msdu_info, uint8_t desc_pool_id)
  398. {
  399. uint8_t i;
  400. uint8_t cached_ext_desc[HAL_TX_EXT_DESC_WITH_META_DATA];
  401. struct dp_tx_seg_info_s *seg_info;
  402. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  403. struct dp_soc *soc = vdev->pdev->soc;
  404. /* Allocate an extension descriptor */
  405. msdu_ext_desc = dp_tx_ext_desc_alloc(soc, desc_pool_id);
  406. qdf_mem_zero(&cached_ext_desc[0], HAL_TX_EXT_DESC_WITH_META_DATA);
  407. if (!msdu_ext_desc) {
  408. DP_STATS_INC(vdev, tx_i.dropped.desc_na, 1);
  409. return NULL;
  410. }
  411. if (msdu_info->exception_fw &&
  412. qdf_unlikely(vdev->mesh_vdev)) {
  413. qdf_mem_copy(&cached_ext_desc[HAL_TX_EXTENSION_DESC_LEN_BYTES],
  414. &msdu_info->meta_data[0],
  415. sizeof(struct htt_tx_msdu_desc_ext2_t));
  416. qdf_atomic_inc(&vdev->pdev->num_tx_exception);
  417. }
  418. switch (msdu_info->frm_type) {
  419. case dp_tx_frm_sg:
  420. case dp_tx_frm_me:
  421. case dp_tx_frm_raw:
  422. seg_info = msdu_info->u.sg_info.curr_seg;
  423. /* Update the buffer pointers in MSDU Extension Descriptor */
  424. for (i = 0; i < seg_info->frag_cnt; i++) {
  425. hal_tx_ext_desc_set_buffer(&cached_ext_desc[0], i,
  426. seg_info->frags[i].paddr_lo,
  427. seg_info->frags[i].paddr_hi,
  428. seg_info->frags[i].len);
  429. }
  430. break;
  431. case dp_tx_frm_tso:
  432. dp_tx_prepare_tso_ext_desc(&msdu_info->u.tso_info.curr_seg->seg,
  433. &cached_ext_desc[0]);
  434. break;
  435. default:
  436. break;
  437. }
  438. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  439. cached_ext_desc, HAL_TX_EXT_DESC_WITH_META_DATA);
  440. hal_tx_ext_desc_sync(&cached_ext_desc[0],
  441. msdu_ext_desc->vaddr);
  442. return msdu_ext_desc;
  443. }
  444. /**
  445. * dp_tx_desc_prepare_single - Allocate and prepare Tx descriptor
  446. * @vdev: DP vdev handle
  447. * @nbuf: skb
  448. * @desc_pool_id: Descriptor pool ID
  449. * @meta_data: Metadata to the fw
  450. * @tx_exc_metadata: Handle that holds exception path metadata
  451. * Allocate and prepare Tx descriptor with msdu information.
  452. *
  453. * Return: Pointer to Tx Descriptor on success,
  454. * NULL on failure
  455. */
  456. static
  457. struct dp_tx_desc_s *dp_tx_prepare_desc_single(struct dp_vdev *vdev,
  458. qdf_nbuf_t nbuf, uint8_t desc_pool_id,
  459. struct dp_tx_msdu_info_s *msdu_info,
  460. struct cdp_tx_exception_metadata *tx_exc_metadata)
  461. {
  462. uint8_t align_pad;
  463. uint8_t is_exception = 0;
  464. uint8_t htt_hdr_size;
  465. struct ether_header *eh;
  466. struct dp_tx_desc_s *tx_desc;
  467. struct dp_pdev *pdev = vdev->pdev;
  468. struct dp_soc *soc = pdev->soc;
  469. /* Allocate software Tx descriptor */
  470. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  471. if (qdf_unlikely(!tx_desc)) {
  472. DP_STATS_INC(vdev, tx_i.dropped.desc_na, 1);
  473. return NULL;
  474. }
  475. /* Flow control/Congestion Control counters */
  476. qdf_atomic_inc(&pdev->num_tx_outstanding);
  477. /* Initialize the SW tx descriptor */
  478. tx_desc->nbuf = nbuf;
  479. tx_desc->frm_type = dp_tx_frm_std;
  480. tx_desc->tx_encap_type = (tx_exc_metadata ?
  481. tx_exc_metadata->tx_encap_type : vdev->tx_encap_type);
  482. tx_desc->vdev = vdev;
  483. tx_desc->pdev = pdev;
  484. tx_desc->msdu_ext_desc = NULL;
  485. tx_desc->pkt_offset = 0;
  486. /*
  487. * For special modes (vdev_type == ocb or mesh), data frames should be
  488. * transmitted using varying transmit parameters (tx spec) which include
  489. * transmit rate, power, priority, channel, channel bandwidth , nss etc.
  490. * These are filled in HTT MSDU descriptor and sent in frame pre-header.
  491. * These frames are sent as exception packets to firmware.
  492. *
  493. * HW requirement is that metadata should always point to a
  494. * 8-byte aligned address. So we add alignment pad to start of buffer.
  495. * HTT Metadata should be ensured to be multiple of 8-bytes,
  496. * to get 8-byte aligned start address along with align_pad added
  497. *
  498. * |-----------------------------|
  499. * | |
  500. * |-----------------------------| <-----Buffer Pointer Address given
  501. * | | ^ in HW descriptor (aligned)
  502. * | HTT Metadata | |
  503. * | | |
  504. * | | | Packet Offset given in descriptor
  505. * | | |
  506. * |-----------------------------| |
  507. * | Alignment Pad | v
  508. * |-----------------------------| <----- Actual buffer start address
  509. * | SKB Data | (Unaligned)
  510. * | |
  511. * | |
  512. * | |
  513. * | |
  514. * | |
  515. * |-----------------------------|
  516. */
  517. if (qdf_unlikely((msdu_info->exception_fw)) ||
  518. (vdev->opmode == wlan_op_mode_ocb)) {
  519. align_pad = ((unsigned long) qdf_nbuf_data(nbuf)) & 0x7;
  520. if (qdf_nbuf_push_head(nbuf, align_pad) == NULL) {
  521. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  522. "qdf_nbuf_push_head failed\n");
  523. goto failure;
  524. }
  525. htt_hdr_size = dp_tx_prepare_htt_metadata(vdev, nbuf,
  526. msdu_info->meta_data);
  527. if (htt_hdr_size == 0)
  528. goto failure;
  529. tx_desc->pkt_offset = align_pad + htt_hdr_size;
  530. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  531. is_exception = 1;
  532. }
  533. if (qdf_unlikely(QDF_STATUS_SUCCESS !=
  534. qdf_nbuf_map(soc->osdev, nbuf,
  535. QDF_DMA_TO_DEVICE))) {
  536. /* Handle failure */
  537. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  538. "qdf_nbuf_map failed\n");
  539. DP_STATS_INC(vdev, tx_i.dropped.dma_error, 1);
  540. goto failure;
  541. }
  542. if (qdf_unlikely(vdev->nawds_enabled)) {
  543. eh = (struct ether_header *) qdf_nbuf_data(nbuf);
  544. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  545. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  546. is_exception = 1;
  547. }
  548. }
  549. #if !TQM_BYPASS_WAR
  550. if (is_exception || tx_exc_metadata)
  551. #endif
  552. {
  553. /* Temporary WAR due to TQM VP issues */
  554. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  555. qdf_atomic_inc(&pdev->num_tx_exception);
  556. }
  557. return tx_desc;
  558. failure:
  559. dp_tx_desc_release(tx_desc, desc_pool_id);
  560. return NULL;
  561. }
  562. /**
  563. * dp_tx_prepare_desc() - Allocate and prepare Tx descriptor for multisegment frame
  564. * @vdev: DP vdev handle
  565. * @nbuf: skb
  566. * @msdu_info: Info to be setup in MSDU descriptor and MSDU extension descriptor
  567. * @desc_pool_id : Descriptor Pool ID
  568. *
  569. * Allocate and prepare Tx descriptor with msdu and fragment descritor
  570. * information. For frames wth fragments, allocate and prepare
  571. * an MSDU extension descriptor
  572. *
  573. * Return: Pointer to Tx Descriptor on success,
  574. * NULL on failure
  575. */
  576. static struct dp_tx_desc_s *dp_tx_prepare_desc(struct dp_vdev *vdev,
  577. qdf_nbuf_t nbuf, struct dp_tx_msdu_info_s *msdu_info,
  578. uint8_t desc_pool_id)
  579. {
  580. struct dp_tx_desc_s *tx_desc;
  581. struct dp_tx_ext_desc_elem_s *msdu_ext_desc;
  582. struct dp_pdev *pdev = vdev->pdev;
  583. struct dp_soc *soc = pdev->soc;
  584. /* Allocate software Tx descriptor */
  585. tx_desc = dp_tx_desc_alloc(soc, desc_pool_id);
  586. if (!tx_desc) {
  587. DP_STATS_INC(vdev, tx_i.dropped.desc_na, 1);
  588. return NULL;
  589. }
  590. /* Flow control/Congestion Control counters */
  591. qdf_atomic_inc(&pdev->num_tx_outstanding);
  592. /* Initialize the SW tx descriptor */
  593. tx_desc->nbuf = nbuf;
  594. tx_desc->frm_type = msdu_info->frm_type;
  595. tx_desc->tx_encap_type = vdev->tx_encap_type;
  596. tx_desc->vdev = vdev;
  597. tx_desc->pdev = pdev;
  598. tx_desc->pkt_offset = 0;
  599. tx_desc->tso_desc = msdu_info->u.tso_info.curr_seg;
  600. tx_desc->tso_num_desc = msdu_info->u.tso_info.tso_num_seg_list;
  601. /* Handle scattered frames - TSO/SG/ME */
  602. /* Allocate and prepare an extension descriptor for scattered frames */
  603. msdu_ext_desc = dp_tx_prepare_ext_desc(vdev, msdu_info, desc_pool_id);
  604. if (!msdu_ext_desc) {
  605. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  606. "%s Tx Extension Descriptor Alloc Fail\n",
  607. __func__);
  608. goto failure;
  609. }
  610. #if TQM_BYPASS_WAR
  611. /* Temporary WAR due to TQM VP issues */
  612. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  613. qdf_atomic_inc(&pdev->num_tx_exception);
  614. #endif
  615. if (qdf_unlikely(msdu_info->exception_fw))
  616. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  617. tx_desc->msdu_ext_desc = msdu_ext_desc;
  618. tx_desc->flags |= DP_TX_DESC_FLAG_FRAG;
  619. return tx_desc;
  620. failure:
  621. dp_tx_desc_release(tx_desc, desc_pool_id);
  622. return NULL;
  623. }
  624. /**
  625. * dp_tx_prepare_raw() - Prepare RAW packet TX
  626. * @vdev: DP vdev handle
  627. * @nbuf: buffer pointer
  628. * @seg_info: Pointer to Segment info Descriptor to be prepared
  629. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension
  630. * descriptor
  631. *
  632. * Return:
  633. */
  634. static qdf_nbuf_t dp_tx_prepare_raw(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  635. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  636. {
  637. qdf_nbuf_t curr_nbuf = NULL;
  638. uint16_t total_len = 0;
  639. qdf_dma_addr_t paddr;
  640. int32_t i;
  641. int32_t mapped_buf_num = 0;
  642. struct dp_tx_sg_info_s *sg_info = &msdu_info->u.sg_info;
  643. qdf_dot3_qosframe_t *qos_wh = (qdf_dot3_qosframe_t *) nbuf->data;
  644. DP_STATS_INC_PKT(vdev, tx_i.raw.raw_pkt, 1, qdf_nbuf_len(nbuf));
  645. /* SWAR for HW: Enable WEP bit in the AMSDU frames for RAW mode */
  646. if (qos_wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_QOS)
  647. qos_wh->i_fc[1] |= IEEE80211_FC1_WEP;
  648. for (curr_nbuf = nbuf, i = 0; curr_nbuf;
  649. curr_nbuf = qdf_nbuf_next(curr_nbuf), i++) {
  650. if (QDF_STATUS_SUCCESS != qdf_nbuf_map(vdev->osdev, curr_nbuf,
  651. QDF_DMA_TO_DEVICE)) {
  652. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  653. "%s dma map error \n", __func__);
  654. DP_STATS_INC(vdev, tx_i.raw.dma_map_error, 1);
  655. mapped_buf_num = i;
  656. goto error;
  657. }
  658. paddr = qdf_nbuf_get_frag_paddr(curr_nbuf, 0);
  659. seg_info->frags[i].paddr_lo = paddr;
  660. seg_info->frags[i].paddr_hi = ((uint64_t)paddr >> 32);
  661. seg_info->frags[i].len = qdf_nbuf_len(curr_nbuf);
  662. seg_info->frags[i].vaddr = (void *) curr_nbuf;
  663. total_len += qdf_nbuf_len(curr_nbuf);
  664. }
  665. seg_info->frag_cnt = i;
  666. seg_info->total_len = total_len;
  667. seg_info->next = NULL;
  668. sg_info->curr_seg = seg_info;
  669. msdu_info->frm_type = dp_tx_frm_raw;
  670. msdu_info->num_seg = 1;
  671. return nbuf;
  672. error:
  673. i = 0;
  674. while (nbuf) {
  675. curr_nbuf = nbuf;
  676. if (i < mapped_buf_num) {
  677. qdf_nbuf_unmap(vdev->osdev, curr_nbuf, QDF_DMA_TO_DEVICE);
  678. i++;
  679. }
  680. nbuf = qdf_nbuf_next(nbuf);
  681. qdf_nbuf_free(curr_nbuf);
  682. }
  683. return NULL;
  684. }
  685. /**
  686. * dp_tx_hw_enqueue() - Enqueue to TCL HW for transmit
  687. * @soc: DP Soc Handle
  688. * @vdev: DP vdev handle
  689. * @tx_desc: Tx Descriptor Handle
  690. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  691. * @fw_metadata: Metadata to send to Target Firmware along with frame
  692. * @ring_id: Ring ID of H/W ring to which we enqueue the packet
  693. * @tx_exc_metadata: Handle that holds exception path meta data
  694. *
  695. * Gets the next free TCL HW DMA descriptor and sets up required parameters
  696. * from software Tx descriptor
  697. *
  698. * Return:
  699. */
  700. static QDF_STATUS dp_tx_hw_enqueue(struct dp_soc *soc, struct dp_vdev *vdev,
  701. struct dp_tx_desc_s *tx_desc, uint8_t tid,
  702. uint16_t fw_metadata, uint8_t ring_id,
  703. struct cdp_tx_exception_metadata
  704. *tx_exc_metadata)
  705. {
  706. uint8_t type;
  707. uint16_t length;
  708. void *hal_tx_desc, *hal_tx_desc_cached;
  709. qdf_dma_addr_t dma_addr;
  710. uint8_t cached_desc[HAL_TX_DESC_LEN_BYTES];
  711. enum cdp_sec_type sec_type = (tx_exc_metadata ?
  712. tx_exc_metadata->sec_type : vdev->sec_type);
  713. /* Return Buffer Manager ID */
  714. uint8_t bm_id = ring_id;
  715. void *hal_srng = soc->tcl_data_ring[ring_id].hal_srng;
  716. hal_tx_desc_cached = (void *) cached_desc;
  717. qdf_mem_zero_outline(hal_tx_desc_cached, HAL_TX_DESC_LEN_BYTES);
  718. if (tx_desc->flags & DP_TX_DESC_FLAG_FRAG) {
  719. length = HAL_TX_EXT_DESC_WITH_META_DATA;
  720. type = HAL_TX_BUF_TYPE_EXT_DESC;
  721. dma_addr = tx_desc->msdu_ext_desc->paddr;
  722. } else {
  723. length = qdf_nbuf_len(tx_desc->nbuf) - tx_desc->pkt_offset;
  724. type = HAL_TX_BUF_TYPE_BUFFER;
  725. dma_addr = qdf_nbuf_mapped_paddr_get(tx_desc->nbuf);
  726. }
  727. hal_tx_desc_set_fw_metadata(hal_tx_desc_cached, fw_metadata);
  728. hal_tx_desc_set_buf_addr(hal_tx_desc_cached,
  729. dma_addr , bm_id, tx_desc->id, type);
  730. if (!dp_tx_is_desc_id_valid(soc, tx_desc->id))
  731. return QDF_STATUS_E_RESOURCES;
  732. hal_tx_desc_set_buf_length(hal_tx_desc_cached, length);
  733. hal_tx_desc_set_buf_offset(hal_tx_desc_cached, tx_desc->pkt_offset);
  734. hal_tx_desc_set_encap_type(hal_tx_desc_cached, tx_desc->tx_encap_type);
  735. hal_tx_desc_set_lmac_id(hal_tx_desc_cached,
  736. HAL_TX_DESC_DEFAULT_LMAC_ID);
  737. hal_tx_desc_set_dscp_tid_table_id(hal_tx_desc_cached,
  738. vdev->dscp_tid_map_id);
  739. hal_tx_desc_set_encrypt_type(hal_tx_desc_cached,
  740. sec_type_map[sec_type]);
  741. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  742. "%s length:%d , type = %d, dma_addr %llx, offset %d desc id %u",
  743. __func__, length, type, (uint64_t)dma_addr,
  744. tx_desc->pkt_offset, tx_desc->id);
  745. if (tx_desc->flags & DP_TX_DESC_FLAG_TO_FW)
  746. hal_tx_desc_set_to_fw(hal_tx_desc_cached, 1);
  747. hal_tx_desc_set_addr_search_flags(hal_tx_desc_cached,
  748. vdev->hal_desc_addr_search_flags);
  749. /* verify checksum offload configuration*/
  750. if ((wlan_cfg_get_checksum_offload(soc->wlan_cfg_ctx)) &&
  751. ((qdf_nbuf_get_tx_cksum(tx_desc->nbuf) == QDF_NBUF_TX_CKSUM_TCP_UDP)
  752. || qdf_nbuf_is_tso(tx_desc->nbuf))) {
  753. hal_tx_desc_set_l3_checksum_en(hal_tx_desc_cached, 1);
  754. hal_tx_desc_set_l4_checksum_en(hal_tx_desc_cached, 1);
  755. }
  756. if (tid != HTT_TX_EXT_TID_INVALID)
  757. hal_tx_desc_set_hlos_tid(hal_tx_desc_cached, tid);
  758. if (tx_desc->flags & DP_TX_DESC_FLAG_MESH)
  759. hal_tx_desc_set_mesh_en(hal_tx_desc_cached, 1);
  760. /* Sync cached descriptor with HW */
  761. hal_tx_desc = hal_srng_src_get_next(soc->hal_soc, hal_srng);
  762. if (!hal_tx_desc) {
  763. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  764. "%s TCL ring full ring_id:%d\n", __func__, ring_id);
  765. DP_STATS_INC(soc, tx.tcl_ring_full[ring_id], 1);
  766. DP_STATS_INC(vdev, tx_i.dropped.enqueue_fail, 1);
  767. return QDF_STATUS_E_RESOURCES;
  768. }
  769. tx_desc->flags |= DP_TX_DESC_FLAG_QUEUED_TX;
  770. hal_tx_desc_sync(hal_tx_desc_cached, hal_tx_desc);
  771. DP_STATS_INC_PKT(vdev, tx_i.processed, 1, length);
  772. /*
  773. * If one packet is enqueued in HW, PM usage count needs to be
  774. * incremented by one to prevent future runtime suspend. This
  775. * should be tied with the success of enqueuing. It will be
  776. * decremented after the packet has been sent.
  777. */
  778. hif_pm_runtime_get_noresume(soc->hif_handle);
  779. return QDF_STATUS_SUCCESS;
  780. }
  781. /**
  782. * dp_cce_classify() - Classify the frame based on CCE rules
  783. * @vdev: DP vdev handle
  784. * @nbuf: skb
  785. *
  786. * Classify frames based on CCE rules
  787. * Return: bool( true if classified,
  788. * else false)
  789. */
  790. static bool dp_cce_classify(struct dp_vdev *vdev, qdf_nbuf_t nbuf)
  791. {
  792. struct ether_header *eh = NULL;
  793. uint16_t ether_type;
  794. qdf_llc_t *llcHdr;
  795. qdf_nbuf_t nbuf_clone = NULL;
  796. qdf_dot3_qosframe_t *qos_wh = NULL;
  797. /* for mesh packets don't do any classification */
  798. if (qdf_unlikely(vdev->mesh_vdev))
  799. return false;
  800. if (qdf_likely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  801. eh = (struct ether_header *) qdf_nbuf_data(nbuf);
  802. ether_type = eh->ether_type;
  803. llcHdr = (qdf_llc_t *)(nbuf->data +
  804. sizeof(struct ether_header));
  805. } else {
  806. qos_wh = (qdf_dot3_qosframe_t *) nbuf->data;
  807. /* For encrypted packets don't do any classification */
  808. if (qdf_unlikely(qos_wh->i_fc[1] & IEEE80211_FC1_WEP))
  809. return false;
  810. if (qdf_unlikely(qos_wh->i_fc[0] & QDF_IEEE80211_FC0_SUBTYPE_QOS)) {
  811. if (qdf_unlikely(
  812. qos_wh->i_fc[1] & QDF_IEEE80211_FC1_TODS &&
  813. qos_wh->i_fc[1] & QDF_IEEE80211_FC1_FROMDS)) {
  814. ether_type = *(uint16_t *)(nbuf->data
  815. + QDF_IEEE80211_4ADDR_HDR_LEN
  816. + sizeof(qdf_llc_t)
  817. - sizeof(ether_type));
  818. llcHdr = (qdf_llc_t *)(nbuf->data +
  819. QDF_IEEE80211_4ADDR_HDR_LEN);
  820. } else {
  821. ether_type = *(uint16_t *)(nbuf->data
  822. + QDF_IEEE80211_3ADDR_HDR_LEN
  823. + sizeof(qdf_llc_t)
  824. - sizeof(ether_type));
  825. llcHdr = (qdf_llc_t *)(nbuf->data +
  826. QDF_IEEE80211_3ADDR_HDR_LEN);
  827. }
  828. if (qdf_unlikely(DP_FRAME_IS_SNAP(llcHdr)
  829. && (ether_type ==
  830. qdf_htons(QDF_NBUF_TRAC_EAPOL_ETH_TYPE)))) {
  831. DP_STATS_INC(vdev, tx_i.cce_classified_raw, 1);
  832. return true;
  833. }
  834. }
  835. return false;
  836. }
  837. if (qdf_unlikely(DP_FRAME_IS_SNAP(llcHdr))) {
  838. ether_type = *(uint16_t *)(nbuf->data + 2*ETHER_ADDR_LEN +
  839. sizeof(*llcHdr));
  840. nbuf_clone = qdf_nbuf_clone(nbuf);
  841. if (qdf_unlikely(nbuf_clone)) {
  842. qdf_nbuf_pull_head(nbuf_clone, sizeof(*llcHdr));
  843. if (ether_type == htons(ETHERTYPE_8021Q)) {
  844. qdf_nbuf_pull_head(nbuf_clone,
  845. sizeof(qdf_net_vlanhdr_t));
  846. }
  847. }
  848. } else {
  849. if (ether_type == htons(ETHERTYPE_8021Q)) {
  850. nbuf_clone = qdf_nbuf_clone(nbuf);
  851. if (qdf_unlikely(nbuf_clone)) {
  852. qdf_nbuf_pull_head(nbuf_clone,
  853. sizeof(qdf_net_vlanhdr_t));
  854. }
  855. }
  856. }
  857. if (qdf_unlikely(nbuf_clone))
  858. nbuf = nbuf_clone;
  859. if (qdf_unlikely(qdf_nbuf_is_ipv4_eapol_pkt(nbuf)
  860. || qdf_nbuf_is_ipv4_arp_pkt(nbuf)
  861. || qdf_nbuf_is_ipv4_wapi_pkt(nbuf)
  862. || qdf_nbuf_is_ipv4_tdls_pkt(nbuf)
  863. || (qdf_nbuf_is_ipv4_pkt(nbuf)
  864. && qdf_nbuf_is_ipv4_dhcp_pkt(nbuf))
  865. || (qdf_nbuf_is_ipv6_pkt(nbuf) &&
  866. qdf_nbuf_is_ipv6_dhcp_pkt(nbuf)))) {
  867. if (qdf_unlikely(nbuf_clone != NULL))
  868. qdf_nbuf_free(nbuf_clone);
  869. return true;
  870. }
  871. if (qdf_unlikely(nbuf_clone != NULL))
  872. qdf_nbuf_free(nbuf_clone);
  873. return false;
  874. }
  875. /**
  876. * dp_tx_classify_tid() - Obtain TID to be used for this frame
  877. * @vdev: DP vdev handle
  878. * @nbuf: skb
  879. *
  880. * Extract the DSCP or PCP information from frame and map into TID value.
  881. * Software based TID classification is required when more than 2 DSCP-TID
  882. * mapping tables are needed.
  883. * Hardware supports 2 DSCP-TID mapping tables
  884. *
  885. * Return: void
  886. */
  887. static void dp_tx_classify_tid(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  888. struct dp_tx_msdu_info_s *msdu_info)
  889. {
  890. uint8_t tos = 0, dscp_tid_override = 0;
  891. uint8_t *hdr_ptr, *L3datap;
  892. uint8_t is_mcast = 0;
  893. struct ether_header *eh = NULL;
  894. qdf_ethervlan_header_t *evh = NULL;
  895. uint16_t ether_type;
  896. qdf_llc_t *llcHdr;
  897. struct dp_pdev *pdev = (struct dp_pdev *)vdev->pdev;
  898. DP_TX_TID_OVERRIDE(msdu_info, nbuf);
  899. if (vdev->dscp_tid_map_id <= 1)
  900. return;
  901. /* for mesh packets don't do any classification */
  902. if (qdf_unlikely(vdev->mesh_vdev))
  903. return;
  904. if (qdf_likely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  905. eh = (struct ether_header *) nbuf->data;
  906. hdr_ptr = eh->ether_dhost;
  907. L3datap = hdr_ptr + sizeof(struct ether_header);
  908. } else {
  909. qdf_dot3_qosframe_t *qos_wh =
  910. (qdf_dot3_qosframe_t *) nbuf->data;
  911. msdu_info->tid = qos_wh->i_fc[0] & DP_FC0_SUBTYPE_QOS ?
  912. qos_wh->i_qos[0] & DP_QOS_TID : 0;
  913. return;
  914. }
  915. is_mcast = DP_FRAME_IS_MULTICAST(hdr_ptr);
  916. ether_type = eh->ether_type;
  917. llcHdr = (qdf_llc_t *)(nbuf->data + sizeof(struct ether_header));
  918. /*
  919. * Check if packet is dot3 or eth2 type.
  920. */
  921. if (DP_FRAME_IS_LLC(ether_type) && DP_FRAME_IS_SNAP(llcHdr)) {
  922. ether_type = (uint16_t)*(nbuf->data + 2*ETHER_ADDR_LEN +
  923. sizeof(*llcHdr));
  924. if (ether_type == htons(ETHERTYPE_8021Q)) {
  925. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t) +
  926. sizeof(*llcHdr);
  927. ether_type = (uint16_t)*(nbuf->data + 2*ETHER_ADDR_LEN
  928. + sizeof(*llcHdr) +
  929. sizeof(qdf_net_vlanhdr_t));
  930. } else {
  931. L3datap = hdr_ptr + sizeof(struct ether_header) +
  932. sizeof(*llcHdr);
  933. }
  934. } else {
  935. if (ether_type == htons(ETHERTYPE_8021Q)) {
  936. evh = (qdf_ethervlan_header_t *) eh;
  937. ether_type = evh->ether_type;
  938. L3datap = hdr_ptr + sizeof(qdf_ethervlan_header_t);
  939. }
  940. }
  941. /*
  942. * Find priority from IP TOS DSCP field
  943. */
  944. if (qdf_nbuf_is_ipv4_pkt(nbuf)) {
  945. qdf_net_iphdr_t *ip = (qdf_net_iphdr_t *) L3datap;
  946. if (qdf_nbuf_is_ipv4_dhcp_pkt(nbuf)) {
  947. /* Only for unicast frames */
  948. if (!is_mcast) {
  949. /* send it on VO queue */
  950. msdu_info->tid = DP_VO_TID;
  951. }
  952. } else {
  953. /*
  954. * IP frame: exclude ECN bits 0-1 and map DSCP bits 2-7
  955. * from TOS byte.
  956. */
  957. tos = ip->ip_tos;
  958. dscp_tid_override = 1;
  959. }
  960. } else if (qdf_nbuf_is_ipv6_pkt(nbuf)) {
  961. /* TODO
  962. * use flowlabel
  963. *igmpmld cases to be handled in phase 2
  964. */
  965. unsigned long ver_pri_flowlabel;
  966. unsigned long pri;
  967. ver_pri_flowlabel = *(unsigned long *) L3datap;
  968. pri = (ntohl(ver_pri_flowlabel) & IPV6_FLOWINFO_PRIORITY) >>
  969. DP_IPV6_PRIORITY_SHIFT;
  970. tos = pri;
  971. dscp_tid_override = 1;
  972. } else if (qdf_nbuf_is_ipv4_eapol_pkt(nbuf))
  973. msdu_info->tid = DP_VO_TID;
  974. else if (qdf_nbuf_is_ipv4_arp_pkt(nbuf)) {
  975. /* Only for unicast frames */
  976. if (!is_mcast) {
  977. /* send ucast arp on VO queue */
  978. msdu_info->tid = DP_VO_TID;
  979. }
  980. }
  981. /*
  982. * Assign all MCAST packets to BE
  983. */
  984. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  985. if (is_mcast) {
  986. tos = 0;
  987. dscp_tid_override = 1;
  988. }
  989. }
  990. if (dscp_tid_override == 1) {
  991. tos = (tos >> DP_IP_DSCP_SHIFT) & DP_IP_DSCP_MASK;
  992. msdu_info->tid = pdev->dscp_tid_map[vdev->dscp_tid_map_id][tos];
  993. }
  994. return;
  995. }
  996. #ifdef CONVERGED_TDLS_ENABLE
  997. /**
  998. * dp_tx_update_tdls_flags() - Update descriptor flags for TDLS frame
  999. * @tx_desc: TX descriptor
  1000. *
  1001. * Return: None
  1002. */
  1003. static void dp_tx_update_tdls_flags(struct dp_tx_desc_s *tx_desc)
  1004. {
  1005. if (tx_desc->vdev) {
  1006. if (tx_desc->vdev->is_tdls_frame)
  1007. tx_desc->flags |= DP_TX_DESC_FLAG_TDLS_FRAME;
  1008. tx_desc->vdev->is_tdls_frame = false;
  1009. }
  1010. }
  1011. /**
  1012. * dp_non_std_tx_comp_free_buff() - Free the non std tx packet buffer
  1013. * @tx_desc: TX descriptor
  1014. * @vdev: datapath vdev handle
  1015. *
  1016. * Return: None
  1017. */
  1018. static void dp_non_std_tx_comp_free_buff(struct dp_tx_desc_s *tx_desc,
  1019. struct dp_vdev *vdev)
  1020. {
  1021. struct hal_tx_completion_status ts = {0};
  1022. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1023. hal_tx_comp_get_status(&tx_desc->comp, &ts);
  1024. if (vdev->tx_non_std_data_callback.func) {
  1025. qdf_nbuf_set_next(tx_desc->nbuf, NULL);
  1026. vdev->tx_non_std_data_callback.func(
  1027. vdev->tx_non_std_data_callback.ctxt,
  1028. nbuf, ts.status);
  1029. return;
  1030. }
  1031. }
  1032. #endif
  1033. /**
  1034. * dp_tx_send_msdu_single() - Setup descriptor and enqueue single MSDU to TCL
  1035. * @vdev: DP vdev handle
  1036. * @nbuf: skb
  1037. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  1038. * @meta_data: Metadata to the fw
  1039. * @tx_q: Tx queue to be used for this Tx frame
  1040. * @peer_id: peer_id of the peer in case of NAWDS frames
  1041. * @tx_exc_metadata: Handle that holds exception path metadata
  1042. *
  1043. * Return: NULL on success,
  1044. * nbuf when it fails to send
  1045. */
  1046. static qdf_nbuf_t dp_tx_send_msdu_single(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1047. struct dp_tx_msdu_info_s *msdu_info, uint16_t peer_id,
  1048. struct cdp_tx_exception_metadata *tx_exc_metadata)
  1049. {
  1050. struct dp_pdev *pdev = vdev->pdev;
  1051. struct dp_soc *soc = pdev->soc;
  1052. struct dp_tx_desc_s *tx_desc;
  1053. QDF_STATUS status;
  1054. struct dp_tx_queue *tx_q = &(msdu_info->tx_queue);
  1055. void *hal_srng = soc->tcl_data_ring[tx_q->ring_id].hal_srng;
  1056. uint16_t htt_tcl_metadata = 0;
  1057. uint8_t tid = msdu_info->tid;
  1058. /* Setup Tx descriptor for an MSDU, and MSDU extension descriptor */
  1059. tx_desc = dp_tx_prepare_desc_single(vdev, nbuf, tx_q->desc_pool_id,
  1060. msdu_info, tx_exc_metadata);
  1061. if (!tx_desc) {
  1062. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1063. "%s Tx_desc prepare Fail vdev %pK queue %d\n",
  1064. __func__, vdev, tx_q->desc_pool_id);
  1065. return nbuf;
  1066. }
  1067. if (qdf_unlikely(soc->cce_disable)) {
  1068. if (dp_cce_classify(vdev, nbuf) == true) {
  1069. DP_STATS_INC(vdev, tx_i.cce_classified, 1);
  1070. tid = DP_VO_TID;
  1071. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1072. }
  1073. }
  1074. dp_tx_update_tdls_flags(tx_desc);
  1075. if (qdf_unlikely(hal_srng_access_start(soc->hal_soc, hal_srng))) {
  1076. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1077. "%s %d : HAL RING Access Failed -- %pK\n",
  1078. __func__, __LINE__, hal_srng);
  1079. DP_STATS_INC(vdev, tx_i.dropped.ring_full, 1);
  1080. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1081. goto fail_return;
  1082. }
  1083. if (qdf_unlikely(peer_id == DP_INVALID_PEER)) {
  1084. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1085. HTT_TX_TCL_METADATA_HOST_INSPECTED_SET(htt_tcl_metadata, 1);
  1086. } else if (qdf_unlikely(peer_id != HTT_INVALID_PEER)) {
  1087. HTT_TX_TCL_METADATA_TYPE_SET(htt_tcl_metadata,
  1088. HTT_TCL_METADATA_TYPE_PEER_BASED);
  1089. HTT_TX_TCL_METADATA_PEER_ID_SET(htt_tcl_metadata,
  1090. peer_id);
  1091. } else
  1092. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1093. if (msdu_info->exception_fw) {
  1094. HTT_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  1095. }
  1096. /* Enqueue the Tx MSDU descriptor to HW for transmit */
  1097. status = dp_tx_hw_enqueue(soc, vdev, tx_desc, tid,
  1098. htt_tcl_metadata, tx_q->ring_id, tx_exc_metadata);
  1099. if (status != QDF_STATUS_SUCCESS) {
  1100. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1101. "%s Tx_hw_enqueue Fail tx_desc %pK queue %d\n",
  1102. __func__, tx_desc, tx_q->ring_id);
  1103. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1104. goto fail_return;
  1105. }
  1106. nbuf = NULL;
  1107. fail_return:
  1108. if (hif_pm_runtime_get(soc->hif_handle) == 0) {
  1109. hal_srng_access_end(soc->hal_soc, hal_srng);
  1110. hif_pm_runtime_put(soc->hif_handle);
  1111. } else {
  1112. hal_srng_access_end_reap(soc->hal_soc, hal_srng);
  1113. }
  1114. return nbuf;
  1115. }
  1116. /**
  1117. * dp_tx_send_msdu_multiple() - Enqueue multiple MSDUs
  1118. * @vdev: DP vdev handle
  1119. * @nbuf: skb
  1120. * @msdu_info: MSDU info to be setup in MSDU extension descriptor
  1121. *
  1122. * Prepare descriptors for multiple MSDUs (TSO segments) and enqueue to TCL
  1123. *
  1124. * Return: NULL on success,
  1125. * nbuf when it fails to send
  1126. */
  1127. #if QDF_LOCK_STATS
  1128. static noinline
  1129. #else
  1130. static
  1131. #endif
  1132. qdf_nbuf_t dp_tx_send_msdu_multiple(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1133. struct dp_tx_msdu_info_s *msdu_info)
  1134. {
  1135. uint8_t i;
  1136. struct dp_pdev *pdev = vdev->pdev;
  1137. struct dp_soc *soc = pdev->soc;
  1138. struct dp_tx_desc_s *tx_desc;
  1139. bool is_cce_classified = false;
  1140. QDF_STATUS status;
  1141. uint16_t htt_tcl_metadata = 0;
  1142. struct dp_tx_queue *tx_q = &msdu_info->tx_queue;
  1143. void *hal_srng = soc->tcl_data_ring[tx_q->ring_id].hal_srng;
  1144. if (qdf_unlikely(hal_srng_access_start(soc->hal_soc, hal_srng))) {
  1145. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  1146. "%s %d : HAL RING Access Failed -- %pK\n",
  1147. __func__, __LINE__, hal_srng);
  1148. DP_STATS_INC(vdev, tx_i.dropped.ring_full, 1);
  1149. return nbuf;
  1150. }
  1151. if (qdf_unlikely(soc->cce_disable)) {
  1152. is_cce_classified = dp_cce_classify(vdev, nbuf);
  1153. if (is_cce_classified) {
  1154. DP_STATS_INC(vdev, tx_i.cce_classified, 1);
  1155. msdu_info->tid = DP_VO_TID;
  1156. }
  1157. }
  1158. if (msdu_info->frm_type == dp_tx_frm_me)
  1159. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  1160. i = 0;
  1161. /* Print statement to track i and num_seg */
  1162. /*
  1163. * For each segment (maps to 1 MSDU) , prepare software and hardware
  1164. * descriptors using information in msdu_info
  1165. */
  1166. while (i < msdu_info->num_seg) {
  1167. /*
  1168. * Setup Tx descriptor for an MSDU, and MSDU extension
  1169. * descriptor
  1170. */
  1171. tx_desc = dp_tx_prepare_desc(vdev, nbuf, msdu_info,
  1172. tx_q->desc_pool_id);
  1173. if (!tx_desc) {
  1174. if (msdu_info->frm_type == dp_tx_frm_me) {
  1175. dp_tx_me_free_buf(pdev,
  1176. (void *)(msdu_info->u.sg_info
  1177. .curr_seg->frags[0].vaddr));
  1178. }
  1179. goto done;
  1180. }
  1181. if (msdu_info->frm_type == dp_tx_frm_me) {
  1182. tx_desc->me_buffer =
  1183. msdu_info->u.sg_info.curr_seg->frags[0].vaddr;
  1184. tx_desc->flags |= DP_TX_DESC_FLAG_ME;
  1185. }
  1186. if (is_cce_classified)
  1187. tx_desc->flags |= DP_TX_DESC_FLAG_TO_FW;
  1188. htt_tcl_metadata = vdev->htt_tcl_metadata;
  1189. if (msdu_info->exception_fw) {
  1190. HTT_TX_TCL_METADATA_VALID_HTT_SET(htt_tcl_metadata, 1);
  1191. }
  1192. /*
  1193. * Enqueue the Tx MSDU descriptor to HW for transmit
  1194. */
  1195. status = dp_tx_hw_enqueue(soc, vdev, tx_desc, msdu_info->tid,
  1196. htt_tcl_metadata, tx_q->ring_id, NULL);
  1197. if (status != QDF_STATUS_SUCCESS) {
  1198. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1199. "%s Tx_hw_enqueue Fail tx_desc %pK queue %d\n",
  1200. __func__, tx_desc, tx_q->ring_id);
  1201. if (tx_desc->flags & DP_TX_DESC_FLAG_ME)
  1202. dp_tx_me_free_buf(pdev, tx_desc->me_buffer);
  1203. dp_tx_desc_release(tx_desc, tx_q->desc_pool_id);
  1204. goto done;
  1205. }
  1206. /*
  1207. * TODO
  1208. * if tso_info structure can be modified to have curr_seg
  1209. * as first element, following 2 blocks of code (for TSO and SG)
  1210. * can be combined into 1
  1211. */
  1212. /*
  1213. * For frames with multiple segments (TSO, ME), jump to next
  1214. * segment.
  1215. */
  1216. if (msdu_info->frm_type == dp_tx_frm_tso) {
  1217. if (msdu_info->u.tso_info.curr_seg->next) {
  1218. msdu_info->u.tso_info.curr_seg =
  1219. msdu_info->u.tso_info.curr_seg->next;
  1220. /*
  1221. * If this is a jumbo nbuf, then increment the number of
  1222. * nbuf users for each additional segment of the msdu.
  1223. * This will ensure that the skb is freed only after
  1224. * receiving tx completion for all segments of an nbuf
  1225. */
  1226. qdf_nbuf_inc_users(nbuf);
  1227. /* Check with MCL if this is needed */
  1228. /* nbuf = msdu_info->u.tso_info.curr_seg->nbuf; */
  1229. }
  1230. }
  1231. /*
  1232. * For Multicast-Unicast converted packets,
  1233. * each converted frame (for a client) is represented as
  1234. * 1 segment
  1235. */
  1236. if ((msdu_info->frm_type == dp_tx_frm_sg) ||
  1237. (msdu_info->frm_type == dp_tx_frm_me)) {
  1238. if (msdu_info->u.sg_info.curr_seg->next) {
  1239. msdu_info->u.sg_info.curr_seg =
  1240. msdu_info->u.sg_info.curr_seg->next;
  1241. nbuf = msdu_info->u.sg_info.curr_seg->nbuf;
  1242. }
  1243. }
  1244. i++;
  1245. }
  1246. nbuf = NULL;
  1247. done:
  1248. if (hif_pm_runtime_get(soc->hif_handle) == 0) {
  1249. hal_srng_access_end(soc->hal_soc, hal_srng);
  1250. hif_pm_runtime_put(soc->hif_handle);
  1251. } else {
  1252. hal_srng_access_end_reap(soc->hal_soc, hal_srng);
  1253. }
  1254. return nbuf;
  1255. }
  1256. /**
  1257. * dp_tx_prepare_sg()- Extract SG info from NBUF and prepare msdu_info
  1258. * for SG frames
  1259. * @vdev: DP vdev handle
  1260. * @nbuf: skb
  1261. * @seg_info: Pointer to Segment info Descriptor to be prepared
  1262. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  1263. *
  1264. * Return: NULL on success,
  1265. * nbuf when it fails to send
  1266. */
  1267. static qdf_nbuf_t dp_tx_prepare_sg(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1268. struct dp_tx_seg_info_s *seg_info, struct dp_tx_msdu_info_s *msdu_info)
  1269. {
  1270. uint32_t cur_frag, nr_frags;
  1271. qdf_dma_addr_t paddr;
  1272. struct dp_tx_sg_info_s *sg_info;
  1273. sg_info = &msdu_info->u.sg_info;
  1274. nr_frags = qdf_nbuf_get_nr_frags(nbuf);
  1275. if (QDF_STATUS_SUCCESS != qdf_nbuf_map(vdev->osdev, nbuf,
  1276. QDF_DMA_TO_DEVICE)) {
  1277. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1278. "dma map error\n");
  1279. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  1280. qdf_nbuf_free(nbuf);
  1281. return NULL;
  1282. }
  1283. paddr = qdf_nbuf_get_frag_paddr(nbuf, 0);
  1284. seg_info->frags[0].paddr_lo = paddr;
  1285. seg_info->frags[0].paddr_hi = ((uint64_t) paddr) >> 32;
  1286. seg_info->frags[0].len = qdf_nbuf_headlen(nbuf);
  1287. seg_info->frags[0].vaddr = (void *) nbuf;
  1288. for (cur_frag = 0; cur_frag < nr_frags; cur_frag++) {
  1289. if (QDF_STATUS_E_FAILURE == qdf_nbuf_frag_map(vdev->osdev,
  1290. nbuf, 0, QDF_DMA_TO_DEVICE, cur_frag)) {
  1291. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1292. "frag dma map error\n");
  1293. DP_STATS_INC(vdev, tx_i.sg.dma_map_error, 1);
  1294. qdf_nbuf_free(nbuf);
  1295. return NULL;
  1296. }
  1297. paddr = qdf_nbuf_get_frag_paddr(nbuf, 0);
  1298. seg_info->frags[cur_frag + 1].paddr_lo = paddr;
  1299. seg_info->frags[cur_frag + 1].paddr_hi =
  1300. ((uint64_t) paddr) >> 32;
  1301. seg_info->frags[cur_frag + 1].len =
  1302. qdf_nbuf_get_frag_size(nbuf, cur_frag);
  1303. }
  1304. seg_info->frag_cnt = (cur_frag + 1);
  1305. seg_info->total_len = qdf_nbuf_len(nbuf);
  1306. seg_info->next = NULL;
  1307. sg_info->curr_seg = seg_info;
  1308. msdu_info->frm_type = dp_tx_frm_sg;
  1309. msdu_info->num_seg = 1;
  1310. return nbuf;
  1311. }
  1312. #ifdef MESH_MODE_SUPPORT
  1313. /**
  1314. * dp_tx_extract_mesh_meta_data()- Extract mesh meta hdr info from nbuf
  1315. and prepare msdu_info for mesh frames.
  1316. * @vdev: DP vdev handle
  1317. * @nbuf: skb
  1318. * @msdu_info: MSDU info to be setup in MSDU descriptor and MSDU extension desc.
  1319. *
  1320. * Return: NULL on failure,
  1321. * nbuf when extracted successfully
  1322. */
  1323. static
  1324. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1325. struct dp_tx_msdu_info_s *msdu_info)
  1326. {
  1327. struct meta_hdr_s *mhdr;
  1328. struct htt_tx_msdu_desc_ext2_t *meta_data =
  1329. (struct htt_tx_msdu_desc_ext2_t *)&msdu_info->meta_data[0];
  1330. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  1331. if (CB_FTYPE_MESH_TX_INFO != qdf_nbuf_get_tx_ftype(nbuf)) {
  1332. msdu_info->exception_fw = 0;
  1333. goto remove_meta_hdr;
  1334. }
  1335. msdu_info->exception_fw = 1;
  1336. qdf_mem_set(meta_data, sizeof(struct htt_tx_msdu_desc_ext2_t), 0);
  1337. meta_data->host_tx_desc_pool = 1;
  1338. meta_data->update_peer_cache = 1;
  1339. meta_data->learning_frame = 1;
  1340. if (!(mhdr->flags & METAHDR_FLAG_AUTO_RATE)) {
  1341. meta_data->power = mhdr->power;
  1342. meta_data->mcs_mask = 1 << mhdr->rate_info[0].mcs;
  1343. meta_data->nss_mask = 1 << mhdr->rate_info[0].nss;
  1344. meta_data->pream_type = mhdr->rate_info[0].preamble_type;
  1345. meta_data->retry_limit = mhdr->rate_info[0].max_tries;
  1346. meta_data->dyn_bw = 1;
  1347. meta_data->valid_pwr = 1;
  1348. meta_data->valid_mcs_mask = 1;
  1349. meta_data->valid_nss_mask = 1;
  1350. meta_data->valid_preamble_type = 1;
  1351. meta_data->valid_retries = 1;
  1352. meta_data->valid_bw_info = 1;
  1353. }
  1354. if (mhdr->flags & METAHDR_FLAG_NOENCRYPT) {
  1355. meta_data->encrypt_type = 0;
  1356. meta_data->valid_encrypt_type = 1;
  1357. meta_data->learning_frame = 0;
  1358. }
  1359. meta_data->valid_key_flags = 1;
  1360. meta_data->key_flags = (mhdr->keyix & 0x3);
  1361. remove_meta_hdr:
  1362. if (qdf_nbuf_pull_head(nbuf, sizeof(struct meta_hdr_s)) == NULL) {
  1363. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1364. "qdf_nbuf_pull_head failed\n");
  1365. qdf_nbuf_free(nbuf);
  1366. return NULL;
  1367. }
  1368. if (mhdr->flags & METAHDR_FLAG_NOQOS)
  1369. msdu_info->tid = HTT_TX_EXT_TID_NON_QOS_MCAST_BCAST;
  1370. else
  1371. msdu_info->tid = qdf_nbuf_get_priority(nbuf);
  1372. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_HIGH,
  1373. "%s , Meta hdr %0x %0x %0x %0x %0x %0x"
  1374. " tid %d to_fw %d\n",
  1375. __func__, msdu_info->meta_data[0],
  1376. msdu_info->meta_data[1],
  1377. msdu_info->meta_data[2],
  1378. msdu_info->meta_data[3],
  1379. msdu_info->meta_data[4],
  1380. msdu_info->meta_data[5],
  1381. msdu_info->tid, msdu_info->exception_fw);
  1382. return nbuf;
  1383. }
  1384. #else
  1385. static
  1386. qdf_nbuf_t dp_tx_extract_mesh_meta_data(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1387. struct dp_tx_msdu_info_s *msdu_info)
  1388. {
  1389. return nbuf;
  1390. }
  1391. #endif
  1392. #ifdef DP_FEATURE_NAWDS_TX
  1393. /**
  1394. * dp_tx_prepare_nawds(): Tramit NAWDS frames
  1395. * @vdev: dp_vdev handle
  1396. * @nbuf: skb
  1397. * @tid: TID from HLOS for overriding default DSCP-TID mapping
  1398. * @tx_q: Tx queue to be used for this Tx frame
  1399. * @meta_data: Meta date for mesh
  1400. * @peer_id: peer_id of the peer in case of NAWDS frames
  1401. *
  1402. * return: NULL on success nbuf on failure
  1403. */
  1404. static qdf_nbuf_t dp_tx_prepare_nawds(struct dp_vdev *vdev, qdf_nbuf_t nbuf,
  1405. struct dp_tx_msdu_info_s *msdu_info)
  1406. {
  1407. struct dp_peer *peer = NULL;
  1408. struct dp_soc *soc = vdev->pdev->soc;
  1409. struct dp_ast_entry *ast_entry = NULL;
  1410. struct ether_header *eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  1411. uint16_t peer_id = HTT_INVALID_PEER;
  1412. struct dp_peer *sa_peer = NULL;
  1413. qdf_nbuf_t nbuf_copy;
  1414. qdf_spin_lock_bh(&(soc->ast_lock));
  1415. ast_entry = dp_peer_ast_hash_find(soc, (uint8_t *)(eh->ether_shost));
  1416. if (ast_entry)
  1417. sa_peer = ast_entry->peer;
  1418. qdf_spin_unlock_bh(&(soc->ast_lock));
  1419. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  1420. if ((peer->peer_ids[0] != HTT_INVALID_PEER) &&
  1421. (peer->nawds_enabled)) {
  1422. if (sa_peer == peer) {
  1423. QDF_TRACE(QDF_MODULE_ID_DP,
  1424. QDF_TRACE_LEVEL_DEBUG,
  1425. " %s: broadcast multicast packet",
  1426. __func__);
  1427. DP_STATS_INC(peer, tx.nawds_mcast_drop, 1);
  1428. continue;
  1429. }
  1430. nbuf_copy = qdf_nbuf_copy(nbuf);
  1431. if (!nbuf_copy) {
  1432. QDF_TRACE(QDF_MODULE_ID_DP,
  1433. QDF_TRACE_LEVEL_ERROR,
  1434. "nbuf copy failed");
  1435. }
  1436. peer_id = peer->peer_ids[0];
  1437. nbuf_copy = dp_tx_send_msdu_single(vdev, nbuf_copy,
  1438. msdu_info, peer_id, NULL);
  1439. if (nbuf_copy != NULL) {
  1440. qdf_nbuf_free(nbuf_copy);
  1441. continue;
  1442. }
  1443. DP_STATS_INC_PKT(peer, tx.nawds_mcast,
  1444. 1, qdf_nbuf_len(nbuf));
  1445. }
  1446. }
  1447. if (peer_id == HTT_INVALID_PEER)
  1448. return nbuf;
  1449. return NULL;
  1450. }
  1451. #endif
  1452. /**
  1453. * dp_check_exc_metadata() - Checks if parameters are valid
  1454. * @tx_exc - holds all exception path parameters
  1455. *
  1456. * Returns true when all the parameters are valid else false
  1457. *
  1458. */
  1459. static bool dp_check_exc_metadata(struct cdp_tx_exception_metadata *tx_exc)
  1460. {
  1461. if ((tx_exc->tid > DP_MAX_TIDS && tx_exc->tid != HTT_INVALID_TID) ||
  1462. tx_exc->tx_encap_type > htt_cmn_pkt_num_types ||
  1463. tx_exc->sec_type > cdp_num_sec_types) {
  1464. return false;
  1465. }
  1466. return true;
  1467. }
  1468. /**
  1469. * dp_tx_send_exception() - Transmit a frame on a given VAP in exception path
  1470. * @vap_dev: DP vdev handle
  1471. * @nbuf: skb
  1472. * @tx_exc_metadata: Handle that holds exception path meta data
  1473. *
  1474. * Entry point for Core Tx layer (DP_TX) invoked from
  1475. * hard_start_xmit in OSIF/HDD to transmit frames through fw
  1476. *
  1477. * Return: NULL on success,
  1478. * nbuf when it fails to send
  1479. */
  1480. qdf_nbuf_t dp_tx_send_exception(void *vap_dev, qdf_nbuf_t nbuf,
  1481. struct cdp_tx_exception_metadata *tx_exc_metadata)
  1482. {
  1483. struct ether_header *eh = NULL;
  1484. struct dp_vdev *vdev = (struct dp_vdev *) vap_dev;
  1485. struct dp_tx_msdu_info_s msdu_info;
  1486. qdf_mem_set(&msdu_info, sizeof(msdu_info), 0x0);
  1487. msdu_info.tid = tx_exc_metadata->tid;
  1488. eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  1489. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1490. "%s , skb %pM",
  1491. __func__, nbuf->data);
  1492. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  1493. if (qdf_unlikely(!dp_check_exc_metadata(tx_exc_metadata))) {
  1494. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1495. "Invalid parameters in exception path");
  1496. goto fail;
  1497. }
  1498. /* Basic sanity checks for unsupported packets */
  1499. /* MESH mode */
  1500. if (qdf_unlikely(vdev->mesh_vdev)) {
  1501. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1502. "Mesh mode is not supported in exception path");
  1503. goto fail;
  1504. }
  1505. /* TSO or SG */
  1506. if (qdf_unlikely(qdf_nbuf_is_tso(nbuf)) ||
  1507. qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  1508. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1509. "TSO and SG are not supported in exception path");
  1510. goto fail;
  1511. }
  1512. /* RAW */
  1513. if (qdf_unlikely(tx_exc_metadata->tx_encap_type == htt_cmn_pkt_type_raw)) {
  1514. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1515. "Raw frame is not supported in exception path");
  1516. goto fail;
  1517. }
  1518. /* Mcast enhancement*/
  1519. if (qdf_unlikely(vdev->mcast_enhancement_en > 0)) {
  1520. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  1521. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1522. "Ignoring mcast_enhancement_en which is set and sending the mcast packet to the FW\n");
  1523. }
  1524. }
  1525. /*
  1526. * Get HW Queue to use for this frame.
  1527. * TCL supports upto 4 DMA rings, out of which 3 rings are
  1528. * dedicated for data and 1 for command.
  1529. * "queue_id" maps to one hardware ring.
  1530. * With each ring, we also associate a unique Tx descriptor pool
  1531. * to minimize lock contention for these resources.
  1532. */
  1533. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  1534. /* Reset the control block */
  1535. qdf_nbuf_reset_ctxt(nbuf);
  1536. /* Single linear frame */
  1537. /*
  1538. * If nbuf is a simple linear frame, use send_single function to
  1539. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  1540. * SRNG. There is no need to setup a MSDU extension descriptor.
  1541. */
  1542. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info,
  1543. tx_exc_metadata->peer_id, tx_exc_metadata);
  1544. return nbuf;
  1545. fail:
  1546. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1547. "pkt send failed");
  1548. return nbuf;
  1549. }
  1550. /**
  1551. * dp_tx_send_mesh() - Transmit mesh frame on a given VAP
  1552. * @vap_dev: DP vdev handle
  1553. * @nbuf: skb
  1554. *
  1555. * Entry point for Core Tx layer (DP_TX) invoked from
  1556. * hard_start_xmit in OSIF/HDD
  1557. *
  1558. * Return: NULL on success,
  1559. * nbuf when it fails to send
  1560. */
  1561. #ifdef MESH_MODE_SUPPORT
  1562. qdf_nbuf_t dp_tx_send_mesh(void *vap_dev, qdf_nbuf_t nbuf)
  1563. {
  1564. struct meta_hdr_s *mhdr;
  1565. qdf_nbuf_t nbuf_mesh = NULL;
  1566. qdf_nbuf_t nbuf_clone = NULL;
  1567. struct dp_vdev *vdev = (struct dp_vdev *) vap_dev;
  1568. uint8_t no_enc_frame = 0;
  1569. nbuf_mesh = qdf_nbuf_unshare(nbuf);
  1570. if (nbuf_mesh == NULL) {
  1571. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1572. "qdf_nbuf_unshare failed\n");
  1573. return nbuf;
  1574. }
  1575. nbuf = nbuf_mesh;
  1576. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(nbuf);
  1577. if ((vdev->sec_type != cdp_sec_type_none) &&
  1578. (mhdr->flags & METAHDR_FLAG_NOENCRYPT))
  1579. no_enc_frame = 1;
  1580. if ((mhdr->flags & METAHDR_FLAG_INFO_UPDATED) &&
  1581. !no_enc_frame) {
  1582. nbuf_clone = qdf_nbuf_clone(nbuf);
  1583. if (nbuf_clone == NULL) {
  1584. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1585. "qdf_nbuf_clone failed\n");
  1586. return nbuf;
  1587. }
  1588. qdf_nbuf_set_tx_ftype(nbuf_clone, CB_FTYPE_MESH_TX_INFO);
  1589. }
  1590. if (nbuf_clone) {
  1591. if (!dp_tx_send(vap_dev, nbuf_clone)) {
  1592. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  1593. } else {
  1594. qdf_nbuf_free(nbuf_clone);
  1595. }
  1596. }
  1597. if (no_enc_frame)
  1598. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_MESH_TX_INFO);
  1599. else
  1600. qdf_nbuf_set_tx_ftype(nbuf, CB_FTYPE_INVALID);
  1601. nbuf = dp_tx_send(vap_dev, nbuf);
  1602. if ((nbuf == NULL) && no_enc_frame) {
  1603. DP_STATS_INC(vdev, tx_i.mesh.exception_fw, 1);
  1604. }
  1605. return nbuf;
  1606. }
  1607. #else
  1608. qdf_nbuf_t dp_tx_send_mesh(void *vap_dev, qdf_nbuf_t nbuf)
  1609. {
  1610. return dp_tx_send(vap_dev, nbuf);
  1611. }
  1612. #endif
  1613. /**
  1614. * dp_tx_send() - Transmit a frame on a given VAP
  1615. * @vap_dev: DP vdev handle
  1616. * @nbuf: skb
  1617. *
  1618. * Entry point for Core Tx layer (DP_TX) invoked from
  1619. * hard_start_xmit in OSIF/HDD or from dp_rx_process for intravap forwarding
  1620. * cases
  1621. *
  1622. * Return: NULL on success,
  1623. * nbuf when it fails to send
  1624. */
  1625. qdf_nbuf_t dp_tx_send(void *vap_dev, qdf_nbuf_t nbuf)
  1626. {
  1627. struct ether_header *eh = NULL;
  1628. struct dp_tx_msdu_info_s msdu_info;
  1629. struct dp_tx_seg_info_s seg_info;
  1630. struct dp_vdev *vdev = (struct dp_vdev *) vap_dev;
  1631. uint16_t peer_id = HTT_INVALID_PEER;
  1632. qdf_nbuf_t nbuf_mesh = NULL;
  1633. qdf_mem_set(&msdu_info, sizeof(msdu_info), 0x0);
  1634. qdf_mem_set(&seg_info, sizeof(seg_info), 0x0);
  1635. eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  1636. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1637. "%s , skb %pM",
  1638. __func__, nbuf->data);
  1639. /*
  1640. * Set Default Host TID value to invalid TID
  1641. * (TID override disabled)
  1642. */
  1643. msdu_info.tid = HTT_TX_EXT_TID_INVALID;
  1644. DP_STATS_INC_PKT(vdev, tx_i.rcvd, 1, qdf_nbuf_len(nbuf));
  1645. if (qdf_unlikely(vdev->mesh_vdev)) {
  1646. nbuf_mesh = dp_tx_extract_mesh_meta_data(vdev, nbuf,
  1647. &msdu_info);
  1648. if (nbuf_mesh == NULL) {
  1649. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1650. "Extracting mesh metadata failed\n");
  1651. return nbuf;
  1652. }
  1653. nbuf = nbuf_mesh;
  1654. }
  1655. /*
  1656. * Get HW Queue to use for this frame.
  1657. * TCL supports upto 4 DMA rings, out of which 3 rings are
  1658. * dedicated for data and 1 for command.
  1659. * "queue_id" maps to one hardware ring.
  1660. * With each ring, we also associate a unique Tx descriptor pool
  1661. * to minimize lock contention for these resources.
  1662. */
  1663. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  1664. /*
  1665. * TCL H/W supports 2 DSCP-TID mapping tables.
  1666. * Table 1 - Default DSCP-TID mapping table
  1667. * Table 2 - 1 DSCP-TID override table
  1668. *
  1669. * If we need a different DSCP-TID mapping for this vap,
  1670. * call tid_classify to extract DSCP/ToS from frame and
  1671. * map to a TID and store in msdu_info. This is later used
  1672. * to fill in TCL Input descriptor (per-packet TID override).
  1673. */
  1674. dp_tx_classify_tid(vdev, nbuf, &msdu_info);
  1675. /* Reset the control block */
  1676. qdf_nbuf_reset_ctxt(nbuf);
  1677. /*
  1678. * Classify the frame and call corresponding
  1679. * "prepare" function which extracts the segment (TSO)
  1680. * and fragmentation information (for TSO , SG, ME, or Raw)
  1681. * into MSDU_INFO structure which is later used to fill
  1682. * SW and HW descriptors.
  1683. */
  1684. if (qdf_nbuf_is_tso(nbuf)) {
  1685. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1686. "%s TSO frame %pK\n", __func__, vdev);
  1687. DP_STATS_INC_PKT(vdev, tx_i.tso.tso_pkt, 1,
  1688. qdf_nbuf_len(nbuf));
  1689. if (dp_tx_prepare_tso(vdev, nbuf, &msdu_info)) {
  1690. DP_STATS_INC(vdev, tx_i.tso.dropped_host, 1);
  1691. return nbuf;
  1692. }
  1693. goto send_multiple;
  1694. }
  1695. /* SG */
  1696. if (qdf_unlikely(qdf_nbuf_is_nonlinear(nbuf))) {
  1697. nbuf = dp_tx_prepare_sg(vdev, nbuf, &seg_info, &msdu_info);
  1698. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1699. "%s non-TSO SG frame %pK\n", __func__, vdev);
  1700. DP_STATS_INC_PKT(vdev, tx_i.sg.sg_pkt, 1,
  1701. qdf_nbuf_len(nbuf));
  1702. goto send_multiple;
  1703. }
  1704. #ifdef ATH_SUPPORT_IQUE
  1705. /* Mcast to Ucast Conversion*/
  1706. if (qdf_unlikely(vdev->mcast_enhancement_en > 0)) {
  1707. eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  1708. if (DP_FRAME_IS_MULTICAST((eh)->ether_dhost)) {
  1709. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1710. "%s Mcast frm for ME %pK\n", __func__, vdev);
  1711. DP_STATS_INC_PKT(vdev,
  1712. tx_i.mcast_en.mcast_pkt, 1,
  1713. qdf_nbuf_len(nbuf));
  1714. if (dp_tx_prepare_send_me(vdev, nbuf) ==
  1715. QDF_STATUS_SUCCESS) {
  1716. return NULL;
  1717. }
  1718. }
  1719. }
  1720. #endif
  1721. /* RAW */
  1722. if (qdf_unlikely(vdev->tx_encap_type == htt_cmn_pkt_type_raw)) {
  1723. nbuf = dp_tx_prepare_raw(vdev, nbuf, &seg_info, &msdu_info);
  1724. if (nbuf == NULL)
  1725. return NULL;
  1726. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1727. "%s Raw frame %pK\n", __func__, vdev);
  1728. goto send_multiple;
  1729. }
  1730. /* Single linear frame */
  1731. /*
  1732. * If nbuf is a simple linear frame, use send_single function to
  1733. * prepare direct-buffer type TCL descriptor and enqueue to TCL
  1734. * SRNG. There is no need to setup a MSDU extension descriptor.
  1735. */
  1736. nbuf = dp_tx_send_msdu_single(vdev, nbuf, &msdu_info, peer_id, NULL);
  1737. return nbuf;
  1738. send_multiple:
  1739. nbuf = dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  1740. return nbuf;
  1741. }
  1742. /**
  1743. * dp_tx_reinject_handler() - Tx Reinject Handler
  1744. * @tx_desc: software descriptor head pointer
  1745. * @status : Tx completion status from HTT descriptor
  1746. *
  1747. * This function reinjects frames back to Target.
  1748. * Todo - Host queue needs to be added
  1749. *
  1750. * Return: none
  1751. */
  1752. static
  1753. void dp_tx_reinject_handler(struct dp_tx_desc_s *tx_desc, uint8_t *status)
  1754. {
  1755. struct dp_vdev *vdev;
  1756. struct dp_peer *peer = NULL;
  1757. uint32_t peer_id = HTT_INVALID_PEER;
  1758. qdf_nbuf_t nbuf = tx_desc->nbuf;
  1759. qdf_nbuf_t nbuf_copy = NULL;
  1760. struct dp_tx_msdu_info_s msdu_info;
  1761. struct dp_peer *sa_peer = NULL;
  1762. struct dp_ast_entry *ast_entry = NULL;
  1763. struct dp_soc *soc = NULL;
  1764. struct ether_header *eh = (struct ether_header *)qdf_nbuf_data(nbuf);
  1765. #ifdef WDS_VENDOR_EXTENSION
  1766. int is_mcast = 0, is_ucast = 0;
  1767. int num_peers_3addr = 0;
  1768. struct ether_header *eth_hdr = (struct ether_header *)(qdf_nbuf_data(nbuf));
  1769. struct ieee80211_frame_addr4 *wh = (struct ieee80211_frame_addr4 *)(qdf_nbuf_data(nbuf));
  1770. #endif
  1771. vdev = tx_desc->vdev;
  1772. soc = vdev->pdev->soc;
  1773. qdf_assert(vdev);
  1774. qdf_mem_set(&msdu_info, sizeof(msdu_info), 0x0);
  1775. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  1776. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  1777. "%s Tx reinject path\n", __func__);
  1778. DP_STATS_INC_PKT(vdev, tx_i.reinject_pkts, 1,
  1779. qdf_nbuf_len(tx_desc->nbuf));
  1780. qdf_spin_lock_bh(&(soc->ast_lock));
  1781. ast_entry = dp_peer_ast_hash_find(soc, (uint8_t *)(eh->ether_shost));
  1782. if (ast_entry)
  1783. sa_peer = ast_entry->peer;
  1784. qdf_spin_unlock_bh(&(soc->ast_lock));
  1785. #ifdef WDS_VENDOR_EXTENSION
  1786. if (qdf_unlikely(vdev->tx_encap_type != htt_cmn_pkt_type_raw)) {
  1787. is_mcast = (IS_MULTICAST(wh->i_addr1)) ? 1 : 0;
  1788. } else {
  1789. is_mcast = (IS_MULTICAST(eth_hdr->ether_dhost)) ? 1 : 0;
  1790. }
  1791. is_ucast = !is_mcast;
  1792. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  1793. if (peer->bss_peer)
  1794. continue;
  1795. /* Detect wds peers that use 3-addr framing for mcast.
  1796. * if there are any, the bss_peer is used to send the
  1797. * the mcast frame using 3-addr format. all wds enabled
  1798. * peers that use 4-addr framing for mcast frames will
  1799. * be duplicated and sent as 4-addr frames below.
  1800. */
  1801. if (!peer->wds_enabled || !peer->wds_ecm.wds_tx_mcast_4addr) {
  1802. num_peers_3addr = 1;
  1803. break;
  1804. }
  1805. }
  1806. #endif
  1807. if (qdf_unlikely(vdev->mesh_vdev)) {
  1808. DP_TX_FREE_SINGLE_BUF(vdev->pdev->soc, tx_desc->nbuf);
  1809. } else {
  1810. TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) {
  1811. if ((peer->peer_ids[0] != HTT_INVALID_PEER) &&
  1812. #ifdef WDS_VENDOR_EXTENSION
  1813. /*
  1814. * . if 3-addr STA, then send on BSS Peer
  1815. * . if Peer WDS enabled and accept 4-addr mcast,
  1816. * send mcast on that peer only
  1817. * . if Peer WDS enabled and accept 4-addr ucast,
  1818. * send ucast on that peer only
  1819. */
  1820. ((peer->bss_peer && num_peers_3addr && is_mcast) ||
  1821. (peer->wds_enabled &&
  1822. ((is_mcast && peer->wds_ecm.wds_tx_mcast_4addr) ||
  1823. (is_ucast && peer->wds_ecm.wds_tx_ucast_4addr))))) {
  1824. #else
  1825. ((peer->bss_peer &&
  1826. !(vdev->osif_proxy_arp(vdev->osif_vdev, nbuf))) ||
  1827. peer->nawds_enabled)) {
  1828. #endif
  1829. peer_id = DP_INVALID_PEER;
  1830. if (peer->nawds_enabled) {
  1831. peer_id = peer->peer_ids[0];
  1832. if (sa_peer == peer) {
  1833. QDF_TRACE(
  1834. QDF_MODULE_ID_DP,
  1835. QDF_TRACE_LEVEL_DEBUG,
  1836. " %s: multicast packet",
  1837. __func__);
  1838. DP_STATS_INC(peer,
  1839. tx.nawds_mcast_drop, 1);
  1840. continue;
  1841. }
  1842. }
  1843. nbuf_copy = qdf_nbuf_copy(nbuf);
  1844. if (!nbuf_copy) {
  1845. QDF_TRACE(QDF_MODULE_ID_DP,
  1846. QDF_TRACE_LEVEL_DEBUG,
  1847. FL("nbuf copy failed"));
  1848. break;
  1849. }
  1850. nbuf_copy = dp_tx_send_msdu_single(vdev,
  1851. nbuf_copy,
  1852. &msdu_info,
  1853. peer_id,
  1854. NULL);
  1855. if (nbuf_copy) {
  1856. QDF_TRACE(QDF_MODULE_ID_DP,
  1857. QDF_TRACE_LEVEL_DEBUG,
  1858. FL("pkt send failed"));
  1859. qdf_nbuf_free(nbuf_copy);
  1860. } else {
  1861. if (peer_id != DP_INVALID_PEER)
  1862. DP_STATS_INC_PKT(peer,
  1863. tx.nawds_mcast,
  1864. 1, qdf_nbuf_len(nbuf));
  1865. }
  1866. }
  1867. }
  1868. }
  1869. if (vdev->nawds_enabled) {
  1870. peer_id = DP_INVALID_PEER;
  1871. DP_STATS_INC_PKT(vdev, tx_i.nawds_mcast,
  1872. 1, qdf_nbuf_len(nbuf));
  1873. nbuf = dp_tx_send_msdu_single(vdev,
  1874. nbuf,
  1875. &msdu_info,
  1876. peer_id, NULL);
  1877. if (nbuf) {
  1878. QDF_TRACE(QDF_MODULE_ID_DP,
  1879. QDF_TRACE_LEVEL_DEBUG,
  1880. FL("pkt send failed"));
  1881. qdf_nbuf_free(nbuf);
  1882. }
  1883. } else
  1884. qdf_nbuf_free(nbuf);
  1885. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  1886. }
  1887. /**
  1888. * dp_tx_inspect_handler() - Tx Inspect Handler
  1889. * @tx_desc: software descriptor head pointer
  1890. * @status : Tx completion status from HTT descriptor
  1891. *
  1892. * Handles Tx frames sent back to Host for inspection
  1893. * (ProxyARP)
  1894. *
  1895. * Return: none
  1896. */
  1897. static void dp_tx_inspect_handler(struct dp_tx_desc_s *tx_desc, uint8_t *status)
  1898. {
  1899. struct dp_soc *soc;
  1900. struct dp_pdev *pdev = tx_desc->pdev;
  1901. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  1902. "%s Tx inspect path\n",
  1903. __func__);
  1904. qdf_assert(pdev);
  1905. soc = pdev->soc;
  1906. DP_STATS_INC_PKT(tx_desc->vdev, tx_i.inspect_pkts, 1,
  1907. qdf_nbuf_len(tx_desc->nbuf));
  1908. DP_TX_FREE_SINGLE_BUF(soc, tx_desc->nbuf);
  1909. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  1910. }
  1911. #ifdef FEATURE_PERPKT_INFO
  1912. /**
  1913. * dp_get_completion_indication_for_stack() - send completion to stack
  1914. * @soc : dp_soc handle
  1915. * @pdev: dp_pdev handle
  1916. * @peer_id: peer_id of the peer for which completion came
  1917. * @ppdu_id: ppdu_id
  1918. * @first_msdu: first msdu
  1919. * @last_msdu: last msdu
  1920. * @netbuf: Buffer pointer for free
  1921. *
  1922. * This function is used for indication whether buffer needs to be
  1923. * send to stack for free or not
  1924. */
  1925. QDF_STATUS
  1926. dp_get_completion_indication_for_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1927. uint16_t peer_id, uint32_t ppdu_id, uint8_t first_msdu,
  1928. uint8_t last_msdu, qdf_nbuf_t netbuf)
  1929. {
  1930. struct tx_capture_hdr *ppdu_hdr;
  1931. struct dp_peer *peer = NULL;
  1932. if (qdf_unlikely(!pdev->tx_sniffer_enable && !pdev->mcopy_mode))
  1933. return QDF_STATUS_E_NOSUPPORT;
  1934. peer = (peer_id == HTT_INVALID_PEER) ? NULL :
  1935. dp_peer_find_by_id(soc, peer_id);
  1936. if (!peer) {
  1937. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1938. FL("Peer Invalid"));
  1939. return QDF_STATUS_E_INVAL;
  1940. }
  1941. if (pdev->mcopy_mode) {
  1942. if ((pdev->m_copy_id.tx_ppdu_id == ppdu_id) &&
  1943. (pdev->m_copy_id.tx_peer_id == peer_id)) {
  1944. return QDF_STATUS_E_INVAL;
  1945. }
  1946. pdev->m_copy_id.tx_ppdu_id = ppdu_id;
  1947. pdev->m_copy_id.tx_peer_id = peer_id;
  1948. }
  1949. if (!qdf_nbuf_push_head(netbuf, sizeof(struct tx_capture_hdr))) {
  1950. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  1951. FL("No headroom"));
  1952. return QDF_STATUS_E_NOMEM;
  1953. }
  1954. ppdu_hdr = (struct tx_capture_hdr *)qdf_nbuf_data(netbuf);
  1955. qdf_mem_copy(ppdu_hdr->ta, peer->vdev->mac_addr.raw,
  1956. IEEE80211_ADDR_LEN);
  1957. ppdu_hdr->ppdu_id = ppdu_id;
  1958. qdf_mem_copy(ppdu_hdr->ra, peer->mac_addr.raw,
  1959. IEEE80211_ADDR_LEN);
  1960. ppdu_hdr->peer_id = peer_id;
  1961. ppdu_hdr->first_msdu = first_msdu;
  1962. ppdu_hdr->last_msdu = last_msdu;
  1963. return QDF_STATUS_SUCCESS;
  1964. }
  1965. /**
  1966. * dp_send_completion_to_stack() - send completion to stack
  1967. * @soc : dp_soc handle
  1968. * @pdev: dp_pdev handle
  1969. * @peer_id: peer_id of the peer for which completion came
  1970. * @ppdu_id: ppdu_id
  1971. * @netbuf: Buffer pointer for free
  1972. *
  1973. * This function is used to send completion to stack
  1974. * to free buffer
  1975. */
  1976. void dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1977. uint16_t peer_id, uint32_t ppdu_id,
  1978. qdf_nbuf_t netbuf)
  1979. {
  1980. dp_wdi_event_handler(WDI_EVENT_TX_DATA, soc,
  1981. netbuf, peer_id,
  1982. WDI_NO_VAL, pdev->pdev_id);
  1983. }
  1984. #else
  1985. static QDF_STATUS
  1986. dp_get_completion_indication_for_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1987. uint16_t peer_id, uint32_t ppdu_id, uint8_t first_msdu,
  1988. uint8_t last_msdu, qdf_nbuf_t netbuf)
  1989. {
  1990. return QDF_STATUS_E_NOSUPPORT;
  1991. }
  1992. static void
  1993. dp_send_completion_to_stack(struct dp_soc *soc, struct dp_pdev *pdev,
  1994. uint16_t peer_id, uint32_t ppdu_id, qdf_nbuf_t netbuf)
  1995. {
  1996. }
  1997. #endif
  1998. /**
  1999. * dp_tx_comp_free_buf() - Free nbuf associated with the Tx Descriptor
  2000. * @soc: Soc handle
  2001. * @desc: software Tx descriptor to be processed
  2002. *
  2003. * Return: none
  2004. */
  2005. static inline void dp_tx_comp_free_buf(struct dp_soc *soc,
  2006. struct dp_tx_desc_s *desc)
  2007. {
  2008. struct dp_vdev *vdev = desc->vdev;
  2009. qdf_nbuf_t nbuf = desc->nbuf;
  2010. /* If it is TDLS mgmt, don't unmap or free the frame */
  2011. if (desc->flags & DP_TX_DESC_FLAG_TDLS_FRAME)
  2012. return dp_non_std_tx_comp_free_buff(desc, vdev);
  2013. /* 0 : MSDU buffer, 1 : MLE */
  2014. if (desc->msdu_ext_desc) {
  2015. /* TSO free */
  2016. if (hal_tx_ext_desc_get_tso_enable(
  2017. desc->msdu_ext_desc->vaddr)) {
  2018. /* If remaining number of segment is 0
  2019. * actual TSO may unmap and free */
  2020. if (qdf_nbuf_get_users(nbuf) == 1)
  2021. __qdf_nbuf_unmap_single(soc->osdev,
  2022. nbuf,
  2023. QDF_DMA_TO_DEVICE);
  2024. qdf_nbuf_free(nbuf);
  2025. return;
  2026. }
  2027. }
  2028. qdf_nbuf_unmap(soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  2029. if (qdf_likely(!vdev->mesh_vdev))
  2030. qdf_nbuf_free(nbuf);
  2031. else {
  2032. if (desc->flags & DP_TX_DESC_FLAG_TO_FW) {
  2033. qdf_nbuf_free(nbuf);
  2034. DP_STATS_INC(vdev, tx_i.mesh.completion_fw, 1);
  2035. } else
  2036. vdev->osif_tx_free_ext((nbuf));
  2037. }
  2038. }
  2039. /**
  2040. * dp_tx_mec_handler() - Tx MEC Notify Handler
  2041. * @vdev: pointer to dp dev handler
  2042. * @status : Tx completion status from HTT descriptor
  2043. *
  2044. * Handles MEC notify event sent from fw to Host
  2045. *
  2046. * Return: none
  2047. */
  2048. #ifdef FEATURE_WDS
  2049. void dp_tx_mec_handler(struct dp_vdev *vdev, uint8_t *status)
  2050. {
  2051. struct dp_soc *soc;
  2052. uint32_t flags = IEEE80211_NODE_F_WDS_HM;
  2053. struct dp_peer *peer;
  2054. uint8_t mac_addr[DP_MAC_ADDR_LEN], i;
  2055. if (!vdev->wds_enabled)
  2056. return;
  2057. soc = vdev->pdev->soc;
  2058. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  2059. peer = TAILQ_FIRST(&vdev->peer_list);
  2060. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  2061. if (!peer) {
  2062. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2063. FL("peer is NULL"));
  2064. return;
  2065. }
  2066. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2067. "%s Tx MEC Handler\n",
  2068. __func__);
  2069. for (i = 0; i < DP_MAC_ADDR_LEN; i++)
  2070. mac_addr[(DP_MAC_ADDR_LEN - 1) - i] =
  2071. status[(DP_MAC_ADDR_LEN - 2) + i];
  2072. if (qdf_mem_cmp(mac_addr, vdev->mac_addr.raw, DP_MAC_ADDR_LEN))
  2073. dp_peer_add_ast(soc,
  2074. peer,
  2075. mac_addr,
  2076. CDP_TXRX_AST_TYPE_MEC,
  2077. flags);
  2078. }
  2079. #endif
  2080. /**
  2081. * dp_tx_process_htt_completion() - Tx HTT Completion Indication Handler
  2082. * @tx_desc: software descriptor head pointer
  2083. * @status : Tx completion status from HTT descriptor
  2084. *
  2085. * This function will process HTT Tx indication messages from Target
  2086. *
  2087. * Return: none
  2088. */
  2089. static
  2090. void dp_tx_process_htt_completion(struct dp_tx_desc_s *tx_desc, uint8_t *status)
  2091. {
  2092. uint8_t tx_status;
  2093. struct dp_pdev *pdev;
  2094. struct dp_vdev *vdev;
  2095. struct dp_soc *soc;
  2096. uint32_t *htt_status_word = (uint32_t *) status;
  2097. qdf_assert(tx_desc->pdev);
  2098. pdev = tx_desc->pdev;
  2099. vdev = tx_desc->vdev;
  2100. soc = pdev->soc;
  2101. tx_status = HTT_TX_WBM_COMPLETION_V2_TX_STATUS_GET(htt_status_word[0]);
  2102. switch (tx_status) {
  2103. case HTT_TX_FW2WBM_TX_STATUS_OK:
  2104. case HTT_TX_FW2WBM_TX_STATUS_DROP:
  2105. case HTT_TX_FW2WBM_TX_STATUS_TTL:
  2106. {
  2107. dp_tx_comp_free_buf(soc, tx_desc);
  2108. dp_tx_desc_release(tx_desc, tx_desc->pool_id);
  2109. break;
  2110. }
  2111. case HTT_TX_FW2WBM_TX_STATUS_REINJECT:
  2112. {
  2113. dp_tx_reinject_handler(tx_desc, status);
  2114. break;
  2115. }
  2116. case HTT_TX_FW2WBM_TX_STATUS_INSPECT:
  2117. {
  2118. dp_tx_inspect_handler(tx_desc, status);
  2119. break;
  2120. }
  2121. case HTT_TX_FW2WBM_TX_STATUS_MEC_NOTIFY:
  2122. {
  2123. dp_tx_mec_handler(vdev, status);
  2124. break;
  2125. }
  2126. default:
  2127. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2128. "%s Invalid HTT tx_status %d\n",
  2129. __func__, tx_status);
  2130. break;
  2131. }
  2132. }
  2133. #ifdef MESH_MODE_SUPPORT
  2134. /**
  2135. * dp_tx_comp_fill_tx_completion_stats() - Fill per packet Tx completion stats
  2136. * in mesh meta header
  2137. * @tx_desc: software descriptor head pointer
  2138. * @ts: pointer to tx completion stats
  2139. * Return: none
  2140. */
  2141. static
  2142. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  2143. struct hal_tx_completion_status *ts)
  2144. {
  2145. struct meta_hdr_s *mhdr;
  2146. qdf_nbuf_t netbuf = tx_desc->nbuf;
  2147. if (!tx_desc->msdu_ext_desc) {
  2148. if (qdf_nbuf_pull_head(netbuf, tx_desc->pkt_offset) == NULL) {
  2149. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2150. "netbuf %pK offset %d\n",
  2151. netbuf, tx_desc->pkt_offset);
  2152. return;
  2153. }
  2154. }
  2155. if (qdf_nbuf_push_head(netbuf, sizeof(struct meta_hdr_s)) == NULL) {
  2156. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2157. "netbuf %pK offset %d\n", netbuf,
  2158. sizeof(struct meta_hdr_s));
  2159. return;
  2160. }
  2161. mhdr = (struct meta_hdr_s *)qdf_nbuf_data(netbuf);
  2162. mhdr->rssi = ts->ack_frame_rssi;
  2163. mhdr->channel = tx_desc->pdev->operating_channel;
  2164. }
  2165. #else
  2166. static
  2167. void dp_tx_comp_fill_tx_completion_stats(struct dp_tx_desc_s *tx_desc,
  2168. struct hal_tx_completion_status *ts)
  2169. {
  2170. }
  2171. #endif
  2172. /**
  2173. * dp_tx_update_peer_stats() - Update peer stats from Tx completion indications
  2174. * @peer: Handle to DP peer
  2175. * @ts: pointer to HAL Tx completion stats
  2176. * @length: MSDU length
  2177. *
  2178. * Return: None
  2179. */
  2180. static void dp_tx_update_peer_stats(struct dp_peer *peer,
  2181. struct hal_tx_completion_status *ts, uint32_t length)
  2182. {
  2183. struct dp_pdev *pdev = peer->vdev->pdev;
  2184. struct dp_soc *soc = pdev->soc;
  2185. uint8_t mcs, pkt_type;
  2186. mcs = ts->mcs;
  2187. pkt_type = ts->pkt_type;
  2188. if (!ts->release_src == HAL_TX_COMP_RELEASE_SOURCE_TQM)
  2189. return;
  2190. if (peer->bss_peer) {
  2191. DP_STATS_INC_PKT(peer, tx.mcast, 1, length);
  2192. } else {
  2193. if (ts->status == HAL_TX_TQM_RR_FRAME_ACKED) {
  2194. DP_STATS_INC_PKT(peer, tx.tx_success, 1, length);
  2195. }
  2196. DP_STATS_INC_PKT(peer, tx.ucast, 1, length);
  2197. }
  2198. DP_STATS_INCC(peer, tx.dropped.age_out, 1,
  2199. (ts->status == HAL_TX_TQM_RR_REM_CMD_AGED));
  2200. DP_STATS_INCC(peer, tx.dropped.fw_rem, 1,
  2201. (ts->status == HAL_TX_TQM_RR_REM_CMD_REM));
  2202. DP_STATS_INCC(peer, tx.dropped.fw_rem_notx, 1,
  2203. (ts->status == HAL_TX_TQM_RR_REM_CMD_NOTX));
  2204. DP_STATS_INCC(peer, tx.dropped.fw_rem_tx, 1,
  2205. (ts->status == HAL_TX_TQM_RR_REM_CMD_TX));
  2206. DP_STATS_INCC(peer, tx.dropped.fw_reason1, 1,
  2207. (ts->status == HAL_TX_TQM_RR_FW_REASON1));
  2208. DP_STATS_INCC(peer, tx.dropped.fw_reason2, 1,
  2209. (ts->status == HAL_TX_TQM_RR_FW_REASON2));
  2210. DP_STATS_INCC(peer, tx.dropped.fw_reason3, 1,
  2211. (ts->status == HAL_TX_TQM_RR_FW_REASON3));
  2212. if (!ts->status == HAL_TX_TQM_RR_FRAME_ACKED)
  2213. return;
  2214. DP_STATS_INCC(peer, tx.ofdma, 1, ts->ofdma);
  2215. DP_STATS_INCC(peer, tx.amsdu_cnt, 1, ts->msdu_part_of_amsdu);
  2216. DP_STATS_INCC(peer, tx.non_amsdu_cnt, 1, !ts->msdu_part_of_amsdu);
  2217. if (!(soc->process_tx_status))
  2218. return;
  2219. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  2220. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_A)));
  2221. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  2222. ((mcs < (MAX_MCS_11A)) && (pkt_type == DOT11_A)));
  2223. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  2224. ((mcs >= MAX_MCS_11B) && (pkt_type == DOT11_B)));
  2225. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  2226. ((mcs < MAX_MCS_11B) && (pkt_type == DOT11_B)));
  2227. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  2228. ((mcs >= MAX_MCS_11A) && (pkt_type == DOT11_N)));
  2229. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  2230. ((mcs < MAX_MCS_11A) && (pkt_type == DOT11_N)));
  2231. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  2232. ((mcs >= MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  2233. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  2234. ((mcs < MAX_MCS_11AC) && (pkt_type == DOT11_AC)));
  2235. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[MAX_MCS - 1], 1,
  2236. ((mcs >= (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  2237. DP_STATS_INCC(peer, tx.pkt_type[pkt_type].mcs_count[mcs], 1,
  2238. ((mcs < (MAX_MCS - 1)) && (pkt_type == DOT11_AX)));
  2239. DP_STATS_INC(peer, tx.sgi_count[ts->sgi], 1);
  2240. DP_STATS_INC(peer, tx.bw[ts->bw], 1);
  2241. DP_STATS_UPD(peer, tx.last_ack_rssi, ts->ack_frame_rssi);
  2242. DP_STATS_INC(peer, tx.wme_ac_type[TID_TO_WME_AC(ts->tid)], 1);
  2243. DP_STATS_INCC(peer, tx.stbc, 1, ts->stbc);
  2244. DP_STATS_INCC(peer, tx.ldpc, 1, ts->ldpc);
  2245. DP_STATS_INC_PKT(peer, tx.tx_success, 1, length);
  2246. DP_STATS_INCC(peer, tx.retries, 1, ts->transmit_cnt > 1);
  2247. if (soc->cdp_soc.ol_ops->update_dp_stats) {
  2248. soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev,
  2249. &peer->stats, ts->peer_id,
  2250. UPDATE_PEER_STATS);
  2251. }
  2252. }
  2253. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  2254. /**
  2255. * dp_tx_flow_pool_lock() - take flow pool lock
  2256. * @soc: core txrx main context
  2257. * @tx_desc: tx desc
  2258. *
  2259. * Return: None
  2260. */
  2261. static inline
  2262. void dp_tx_flow_pool_lock(struct dp_soc *soc,
  2263. struct dp_tx_desc_s *tx_desc)
  2264. {
  2265. struct dp_tx_desc_pool_s *pool;
  2266. uint8_t desc_pool_id;
  2267. desc_pool_id = tx_desc->pool_id;
  2268. pool = &soc->tx_desc[desc_pool_id];
  2269. qdf_spin_lock_bh(&pool->flow_pool_lock);
  2270. }
  2271. /**
  2272. * dp_tx_flow_pool_unlock() - release flow pool lock
  2273. * @soc: core txrx main context
  2274. * @tx_desc: tx desc
  2275. *
  2276. * Return: None
  2277. */
  2278. static inline
  2279. void dp_tx_flow_pool_unlock(struct dp_soc *soc,
  2280. struct dp_tx_desc_s *tx_desc)
  2281. {
  2282. struct dp_tx_desc_pool_s *pool;
  2283. uint8_t desc_pool_id;
  2284. desc_pool_id = tx_desc->pool_id;
  2285. pool = &soc->tx_desc[desc_pool_id];
  2286. qdf_spin_unlock_bh(&pool->flow_pool_lock);
  2287. }
  2288. #else
  2289. static inline
  2290. void dp_tx_flow_pool_lock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  2291. {
  2292. }
  2293. static inline
  2294. void dp_tx_flow_pool_unlock(struct dp_soc *soc, struct dp_tx_desc_s *tx_desc)
  2295. {
  2296. }
  2297. #endif
  2298. /**
  2299. * dp_tx_notify_completion() - Notify tx completion for this desc
  2300. * @soc: core txrx main context
  2301. * @tx_desc: tx desc
  2302. * @netbuf: buffer
  2303. *
  2304. * Return: none
  2305. */
  2306. static inline void dp_tx_notify_completion(struct dp_soc *soc,
  2307. struct dp_tx_desc_s *tx_desc,
  2308. qdf_nbuf_t netbuf)
  2309. {
  2310. void *osif_dev;
  2311. ol_txrx_completion_fp tx_compl_cbk = NULL;
  2312. qdf_assert(tx_desc);
  2313. dp_tx_flow_pool_lock(soc, tx_desc);
  2314. if (!tx_desc->vdev ||
  2315. !tx_desc->vdev->osif_vdev) {
  2316. dp_tx_flow_pool_unlock(soc, tx_desc);
  2317. return;
  2318. }
  2319. osif_dev = tx_desc->vdev->osif_vdev;
  2320. tx_compl_cbk = tx_desc->vdev->tx_comp;
  2321. dp_tx_flow_pool_unlock(soc, tx_desc);
  2322. if (tx_compl_cbk)
  2323. tx_compl_cbk(netbuf, osif_dev);
  2324. }
  2325. /**
  2326. * dp_tx_comp_process_tx_status() - Parse and Dump Tx completion status info
  2327. * @tx_desc: software descriptor head pointer
  2328. * @length: packet length
  2329. *
  2330. * Return: none
  2331. */
  2332. static inline void dp_tx_comp_process_tx_status(struct dp_tx_desc_s *tx_desc,
  2333. uint32_t length)
  2334. {
  2335. struct hal_tx_completion_status ts;
  2336. struct dp_soc *soc = NULL;
  2337. struct dp_vdev *vdev = tx_desc->vdev;
  2338. struct dp_peer *peer = NULL;
  2339. struct ether_header *eh =
  2340. (struct ether_header *)qdf_nbuf_data(tx_desc->nbuf);
  2341. hal_tx_comp_get_status(&tx_desc->comp, &ts);
  2342. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
  2343. "-------------------- \n"
  2344. "Tx Completion Stats: \n"
  2345. "-------------------- \n"
  2346. "ack_frame_rssi = %d \n"
  2347. "first_msdu = %d \n"
  2348. "last_msdu = %d \n"
  2349. "msdu_part_of_amsdu = %d \n"
  2350. "rate_stats valid = %d \n"
  2351. "bw = %d \n"
  2352. "pkt_type = %d \n"
  2353. "stbc = %d \n"
  2354. "ldpc = %d \n"
  2355. "sgi = %d \n"
  2356. "mcs = %d \n"
  2357. "ofdma = %d \n"
  2358. "tones_in_ru = %d \n"
  2359. "tsf = %d \n"
  2360. "ppdu_id = %d \n"
  2361. "transmit_cnt = %d \n"
  2362. "tid = %d \n"
  2363. "peer_id = %d \n",
  2364. ts.ack_frame_rssi, ts.first_msdu, ts.last_msdu,
  2365. ts.msdu_part_of_amsdu, ts.valid, ts.bw,
  2366. ts.pkt_type, ts.stbc, ts.ldpc, ts.sgi,
  2367. ts.mcs, ts.ofdma, ts.tones_in_ru, ts.tsf,
  2368. ts.ppdu_id, ts.transmit_cnt, ts.tid,
  2369. ts.peer_id);
  2370. if (!vdev) {
  2371. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2372. "invalid vdev");
  2373. goto out;
  2374. }
  2375. soc = vdev->pdev->soc;
  2376. /* Update SoC level stats */
  2377. DP_STATS_INCC(soc, tx.dropped_fw_removed, 1,
  2378. (ts.status == HAL_TX_TQM_RR_REM_CMD_REM));
  2379. /* Update per-packet stats */
  2380. if (qdf_unlikely(vdev->mesh_vdev) &&
  2381. !(tx_desc->flags & DP_TX_DESC_FLAG_TO_FW))
  2382. dp_tx_comp_fill_tx_completion_stats(tx_desc, &ts);
  2383. /* Update peer level stats */
  2384. peer = dp_peer_find_by_id(soc, ts.peer_id);
  2385. if (!peer) {
  2386. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2387. "invalid peer");
  2388. DP_STATS_INC_PKT(soc, tx.tx_invalid_peer, 1, length);
  2389. goto out;
  2390. }
  2391. if (qdf_likely(peer->vdev->tx_encap_type ==
  2392. htt_cmn_pkt_type_ethernet)) {
  2393. if (peer->bss_peer && IEEE80211_IS_BROADCAST(eh->ether_dhost))
  2394. DP_STATS_INC_PKT(peer, tx.bcast, 1, length);
  2395. }
  2396. dp_tx_update_peer_stats(peer, &ts, length);
  2397. out:
  2398. return;
  2399. }
  2400. /**
  2401. * dp_tx_comp_process_desc() - Tx complete software descriptor handler
  2402. * @soc: core txrx main context
  2403. * @comp_head: software descriptor head pointer
  2404. *
  2405. * This function will process batch of descriptors reaped by dp_tx_comp_handler
  2406. * and release the software descriptors after processing is complete
  2407. *
  2408. * Return: none
  2409. */
  2410. static void dp_tx_comp_process_desc(struct dp_soc *soc,
  2411. struct dp_tx_desc_s *comp_head)
  2412. {
  2413. struct dp_tx_desc_s *desc;
  2414. struct dp_tx_desc_s *next;
  2415. struct hal_tx_completion_status ts = {0};
  2416. uint32_t length;
  2417. struct dp_peer *peer;
  2418. DP_HIST_INIT();
  2419. desc = comp_head;
  2420. while (desc) {
  2421. hal_tx_comp_get_status(&desc->comp, &ts);
  2422. peer = dp_peer_find_by_id(soc, ts.peer_id);
  2423. length = qdf_nbuf_len(desc->nbuf);
  2424. /* check tx completion notification */
  2425. if (QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(desc->nbuf))
  2426. dp_tx_notify_completion(soc, desc, desc->nbuf);
  2427. dp_tx_comp_process_tx_status(desc, length);
  2428. /*currently m_copy/tx_capture is not supported for scatter gather packets*/
  2429. if (!(desc->msdu_ext_desc) && (dp_get_completion_indication_for_stack(soc,
  2430. desc->pdev, ts.peer_id, ts.ppdu_id,
  2431. ts.first_msdu, ts.last_msdu,
  2432. desc->nbuf) == QDF_STATUS_SUCCESS)) {
  2433. qdf_nbuf_unmap(soc->osdev, desc->nbuf,
  2434. QDF_DMA_TO_DEVICE);
  2435. dp_send_completion_to_stack(soc, desc->pdev, ts.peer_id,
  2436. ts.ppdu_id, desc->nbuf);
  2437. } else {
  2438. dp_tx_comp_free_buf(soc, desc);
  2439. }
  2440. DP_HIST_PACKET_COUNT_INC(desc->pdev->pdev_id);
  2441. next = desc->next;
  2442. dp_tx_desc_release(desc, desc->pool_id);
  2443. desc = next;
  2444. }
  2445. DP_TX_HIST_STATS_PER_PDEV();
  2446. }
  2447. /**
  2448. * dp_tx_comp_handler() - Tx completion handler
  2449. * @soc: core txrx main context
  2450. * @ring_id: completion ring id
  2451. * @quota: No. of packets/descriptors that can be serviced in one loop
  2452. *
  2453. * This function will collect hardware release ring element contents and
  2454. * handle descriptor contents. Based on contents, free packet or handle error
  2455. * conditions
  2456. *
  2457. * Return: none
  2458. */
  2459. uint32_t dp_tx_comp_handler(struct dp_soc *soc, void *hal_srng, uint32_t quota)
  2460. {
  2461. void *tx_comp_hal_desc;
  2462. uint8_t buffer_src;
  2463. uint8_t pool_id;
  2464. uint32_t tx_desc_id;
  2465. struct dp_tx_desc_s *tx_desc = NULL;
  2466. struct dp_tx_desc_s *head_desc = NULL;
  2467. struct dp_tx_desc_s *tail_desc = NULL;
  2468. uint32_t num_processed;
  2469. uint32_t count;
  2470. if (qdf_unlikely(hal_srng_access_start(soc->hal_soc, hal_srng))) {
  2471. QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
  2472. "%s %d : HAL RING Access Failed -- %pK\n",
  2473. __func__, __LINE__, hal_srng);
  2474. return 0;
  2475. }
  2476. num_processed = 0;
  2477. count = 0;
  2478. /* Find head descriptor from completion ring */
  2479. while (qdf_likely(tx_comp_hal_desc =
  2480. hal_srng_dst_get_next(soc->hal_soc, hal_srng))) {
  2481. buffer_src = hal_tx_comp_get_buffer_source(tx_comp_hal_desc);
  2482. /* If this buffer was not released by TQM or FW, then it is not
  2483. * Tx completion indication, assert */
  2484. if ((buffer_src != HAL_TX_COMP_RELEASE_SOURCE_TQM) &&
  2485. (buffer_src != HAL_TX_COMP_RELEASE_SOURCE_FW)) {
  2486. QDF_TRACE(QDF_MODULE_ID_DP,
  2487. QDF_TRACE_LEVEL_FATAL,
  2488. "Tx comp release_src != TQM | FW");
  2489. qdf_assert_always(0);
  2490. }
  2491. /* Get descriptor id */
  2492. tx_desc_id = hal_tx_comp_get_desc_id(tx_comp_hal_desc);
  2493. pool_id = (tx_desc_id & DP_TX_DESC_ID_POOL_MASK) >>
  2494. DP_TX_DESC_ID_POOL_OS;
  2495. if (!dp_tx_is_desc_id_valid(soc, tx_desc_id))
  2496. continue;
  2497. /* Find Tx descriptor */
  2498. tx_desc = dp_tx_desc_find(soc, pool_id,
  2499. (tx_desc_id & DP_TX_DESC_ID_PAGE_MASK) >>
  2500. DP_TX_DESC_ID_PAGE_OS,
  2501. (tx_desc_id & DP_TX_DESC_ID_OFFSET_MASK) >>
  2502. DP_TX_DESC_ID_OFFSET_OS);
  2503. /*
  2504. * If the release source is FW, process the HTT status
  2505. */
  2506. if (qdf_unlikely(buffer_src ==
  2507. HAL_TX_COMP_RELEASE_SOURCE_FW)) {
  2508. uint8_t htt_tx_status[HAL_TX_COMP_HTT_STATUS_LEN];
  2509. hal_tx_comp_get_htt_desc(tx_comp_hal_desc,
  2510. htt_tx_status);
  2511. dp_tx_process_htt_completion(tx_desc,
  2512. htt_tx_status);
  2513. } else {
  2514. /* Pool id is not matching. Error */
  2515. if (tx_desc->pool_id != pool_id) {
  2516. QDF_TRACE(QDF_MODULE_ID_DP,
  2517. QDF_TRACE_LEVEL_FATAL,
  2518. "Tx Comp pool id %d not matched %d",
  2519. pool_id, tx_desc->pool_id);
  2520. qdf_assert_always(0);
  2521. }
  2522. if (!(tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED) ||
  2523. !(tx_desc->flags & DP_TX_DESC_FLAG_QUEUED_TX)) {
  2524. QDF_TRACE(QDF_MODULE_ID_DP,
  2525. QDF_TRACE_LEVEL_FATAL,
  2526. "Txdesc invalid, flgs = %x,id = %d",
  2527. tx_desc->flags, tx_desc_id);
  2528. qdf_assert_always(0);
  2529. }
  2530. /* First ring descriptor on the cycle */
  2531. if (!head_desc) {
  2532. head_desc = tx_desc;
  2533. tail_desc = tx_desc;
  2534. }
  2535. tail_desc->next = tx_desc;
  2536. tx_desc->next = NULL;
  2537. tail_desc = tx_desc;
  2538. /* Collect hw completion contents */
  2539. hal_tx_comp_desc_sync(tx_comp_hal_desc,
  2540. &tx_desc->comp, 1);
  2541. }
  2542. num_processed += !(count & DP_TX_NAPI_BUDGET_DIV_MASK);
  2543. /* Decrement PM usage count if the packet has been sent.*/
  2544. hif_pm_runtime_put(soc->hif_handle);
  2545. /*
  2546. * Processed packet count is more than given quota
  2547. * stop to processing
  2548. */
  2549. if ((num_processed >= quota))
  2550. break;
  2551. count++;
  2552. }
  2553. hal_srng_access_end(soc->hal_soc, hal_srng);
  2554. /* Process the reaped descriptors */
  2555. if (head_desc)
  2556. dp_tx_comp_process_desc(soc, head_desc);
  2557. return num_processed;
  2558. }
  2559. #ifdef CONVERGED_TDLS_ENABLE
  2560. /**
  2561. * dp_tx_non_std() - Allow the control-path SW to send data frames
  2562. *
  2563. * @data_vdev - which vdev should transmit the tx data frames
  2564. * @tx_spec - what non-standard handling to apply to the tx data frames
  2565. * @msdu_list - NULL-terminated list of tx MSDUs
  2566. *
  2567. * Return: NULL on success,
  2568. * nbuf when it fails to send
  2569. */
  2570. qdf_nbuf_t dp_tx_non_std(struct cdp_vdev *vdev_handle,
  2571. enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
  2572. {
  2573. struct dp_vdev *vdev = (struct dp_vdev *) vdev_handle;
  2574. if (tx_spec & OL_TX_SPEC_NO_FREE)
  2575. vdev->is_tdls_frame = true;
  2576. return dp_tx_send(vdev_handle, msdu_list);
  2577. }
  2578. #endif
  2579. /**
  2580. * dp_tx_vdev_attach() - attach vdev to dp tx
  2581. * @vdev: virtual device instance
  2582. *
  2583. * Return: QDF_STATUS_SUCCESS: success
  2584. * QDF_STATUS_E_RESOURCES: Error return
  2585. */
  2586. QDF_STATUS dp_tx_vdev_attach(struct dp_vdev *vdev)
  2587. {
  2588. /*
  2589. * Fill HTT TCL Metadata with Vdev ID and MAC ID
  2590. */
  2591. HTT_TX_TCL_METADATA_TYPE_SET(vdev->htt_tcl_metadata,
  2592. HTT_TCL_METADATA_TYPE_VDEV_BASED);
  2593. HTT_TX_TCL_METADATA_VDEV_ID_SET(vdev->htt_tcl_metadata,
  2594. vdev->vdev_id);
  2595. HTT_TX_TCL_METADATA_PDEV_ID_SET(vdev->htt_tcl_metadata,
  2596. DP_SW2HW_MACID(vdev->pdev->pdev_id));
  2597. /*
  2598. * Set HTT Extension Valid bit to 0 by default
  2599. */
  2600. HTT_TX_TCL_METADATA_VALID_HTT_SET(vdev->htt_tcl_metadata, 0);
  2601. dp_tx_vdev_update_search_flags(vdev);
  2602. return QDF_STATUS_SUCCESS;
  2603. }
  2604. /**
  2605. * dp_tx_vdev_update_search_flags() - Update vdev flags as per opmode
  2606. * @vdev: virtual device instance
  2607. *
  2608. * Return: void
  2609. *
  2610. */
  2611. void dp_tx_vdev_update_search_flags(struct dp_vdev *vdev)
  2612. {
  2613. /*
  2614. * Enable both AddrY (SA based search) and AddrX (Da based search)
  2615. * for TDLS link
  2616. *
  2617. * Enable AddrY (SA based search) only for non-WDS STA and
  2618. * ProxySTA VAP modes.
  2619. *
  2620. * In all other VAP modes, only DA based search should be
  2621. * enabled
  2622. */
  2623. if (vdev->opmode == wlan_op_mode_sta &&
  2624. vdev->tdls_link_connected)
  2625. vdev->hal_desc_addr_search_flags =
  2626. (HAL_TX_DESC_ADDRX_EN | HAL_TX_DESC_ADDRY_EN);
  2627. else if ((vdev->opmode == wlan_op_mode_sta &&
  2628. (!vdev->wds_enabled || vdev->proxysta_vdev)))
  2629. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRY_EN;
  2630. else
  2631. vdev->hal_desc_addr_search_flags = HAL_TX_DESC_ADDRX_EN;
  2632. }
  2633. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  2634. static void dp_tx_desc_flush(struct dp_vdev *vdev)
  2635. {
  2636. }
  2637. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  2638. /* dp_tx_desc_flush() - release resources associated
  2639. * to tx_desc
  2640. * @vdev: virtual device instance
  2641. *
  2642. * This function will free all outstanding Tx buffers,
  2643. * including ME buffer for which either free during
  2644. * completion didn't happened or completion is not
  2645. * received.
  2646. */
  2647. static void dp_tx_desc_flush(struct dp_vdev *vdev)
  2648. {
  2649. uint8_t i, num_pool;
  2650. uint32_t j;
  2651. uint32_t num_desc;
  2652. struct dp_soc *soc = vdev->pdev->soc;
  2653. struct dp_tx_desc_s *tx_desc = NULL;
  2654. struct dp_tx_desc_pool_s *tx_desc_pool = NULL;
  2655. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  2656. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  2657. for (i = 0; i < num_pool; i++) {
  2658. for (j = 0; j < num_desc; j++) {
  2659. tx_desc_pool = &((soc)->tx_desc[(i)]);
  2660. if (tx_desc_pool &&
  2661. tx_desc_pool->desc_pages.cacheable_pages) {
  2662. tx_desc = dp_tx_desc_find(soc, i,
  2663. (j & DP_TX_DESC_ID_PAGE_MASK) >>
  2664. DP_TX_DESC_ID_PAGE_OS,
  2665. (j & DP_TX_DESC_ID_OFFSET_MASK) >>
  2666. DP_TX_DESC_ID_OFFSET_OS);
  2667. if (tx_desc && (tx_desc->vdev == vdev) &&
  2668. (tx_desc->flags & DP_TX_DESC_FLAG_ALLOCATED)) {
  2669. dp_tx_comp_free_buf(soc, tx_desc);
  2670. dp_tx_desc_release(tx_desc, i);
  2671. }
  2672. }
  2673. }
  2674. }
  2675. }
  2676. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  2677. /**
  2678. * dp_tx_vdev_detach() - detach vdev from dp tx
  2679. * @vdev: virtual device instance
  2680. *
  2681. * Return: QDF_STATUS_SUCCESS: success
  2682. * QDF_STATUS_E_RESOURCES: Error return
  2683. */
  2684. QDF_STATUS dp_tx_vdev_detach(struct dp_vdev *vdev)
  2685. {
  2686. dp_tx_desc_flush(vdev);
  2687. return QDF_STATUS_SUCCESS;
  2688. }
  2689. /**
  2690. * dp_tx_pdev_attach() - attach pdev to dp tx
  2691. * @pdev: physical device instance
  2692. *
  2693. * Return: QDF_STATUS_SUCCESS: success
  2694. * QDF_STATUS_E_RESOURCES: Error return
  2695. */
  2696. QDF_STATUS dp_tx_pdev_attach(struct dp_pdev *pdev)
  2697. {
  2698. struct dp_soc *soc = pdev->soc;
  2699. /* Initialize Flow control counters */
  2700. qdf_atomic_init(&pdev->num_tx_exception);
  2701. qdf_atomic_init(&pdev->num_tx_outstanding);
  2702. if (wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  2703. /* Initialize descriptors in TCL Ring */
  2704. hal_tx_init_data_ring(soc->hal_soc,
  2705. soc->tcl_data_ring[pdev->pdev_id].hal_srng);
  2706. }
  2707. return QDF_STATUS_SUCCESS;
  2708. }
  2709. /**
  2710. * dp_tx_pdev_detach() - detach pdev from dp tx
  2711. * @pdev: physical device instance
  2712. *
  2713. * Return: QDF_STATUS_SUCCESS: success
  2714. * QDF_STATUS_E_RESOURCES: Error return
  2715. */
  2716. QDF_STATUS dp_tx_pdev_detach(struct dp_pdev *pdev)
  2717. {
  2718. dp_tx_me_exit(pdev);
  2719. return QDF_STATUS_SUCCESS;
  2720. }
  2721. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  2722. /* Pools will be allocated dynamically */
  2723. static int dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  2724. int num_desc)
  2725. {
  2726. uint8_t i;
  2727. for (i = 0; i < num_pool; i++) {
  2728. qdf_spinlock_create(&soc->tx_desc[i].flow_pool_lock);
  2729. soc->tx_desc[i].status = FLOW_POOL_INACTIVE;
  2730. }
  2731. return 0;
  2732. }
  2733. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  2734. {
  2735. uint8_t i;
  2736. for (i = 0; i < num_pool; i++)
  2737. qdf_spinlock_destroy(&soc->tx_desc[i].flow_pool_lock);
  2738. }
  2739. #else /* QCA_LL_TX_FLOW_CONTROL_V2! */
  2740. static int dp_tx_alloc_static_pools(struct dp_soc *soc, int num_pool,
  2741. int num_desc)
  2742. {
  2743. uint8_t i;
  2744. /* Allocate software Tx descriptor pools */
  2745. for (i = 0; i < num_pool; i++) {
  2746. if (dp_tx_desc_pool_alloc(soc, i, num_desc)) {
  2747. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2748. "%s Tx Desc Pool alloc %d failed %pK\n",
  2749. __func__, i, soc);
  2750. return ENOMEM;
  2751. }
  2752. }
  2753. return 0;
  2754. }
  2755. static void dp_tx_delete_static_pools(struct dp_soc *soc, int num_pool)
  2756. {
  2757. uint8_t i;
  2758. for (i = 0; i < num_pool; i++) {
  2759. qdf_assert_always(!soc->tx_desc[i].num_allocated);
  2760. if (dp_tx_desc_pool_free(soc, i)) {
  2761. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2762. "%s Tx Desc Pool Free failed\n", __func__);
  2763. }
  2764. }
  2765. }
  2766. #endif /* !QCA_LL_TX_FLOW_CONTROL_V2 */
  2767. /**
  2768. * dp_tx_soc_detach() - detach soc from dp tx
  2769. * @soc: core txrx main context
  2770. *
  2771. * This function will detach dp tx into main device context
  2772. * will free dp tx resource and initialize resources
  2773. *
  2774. * Return: QDF_STATUS_SUCCESS: success
  2775. * QDF_STATUS_E_RESOURCES: Error return
  2776. */
  2777. QDF_STATUS dp_tx_soc_detach(struct dp_soc *soc)
  2778. {
  2779. uint8_t num_pool;
  2780. uint16_t num_desc;
  2781. uint16_t num_ext_desc;
  2782. uint8_t i;
  2783. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  2784. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  2785. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  2786. dp_tx_flow_control_deinit(soc);
  2787. dp_tx_delete_static_pools(soc, num_pool);
  2788. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2789. "%s Tx Desc Pool Free num_pool = %d, descs = %d\n",
  2790. __func__, num_pool, num_desc);
  2791. for (i = 0; i < num_pool; i++) {
  2792. if (dp_tx_ext_desc_pool_free(soc, i)) {
  2793. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2794. "%s Tx Ext Desc Pool Free failed\n",
  2795. __func__);
  2796. return QDF_STATUS_E_RESOURCES;
  2797. }
  2798. }
  2799. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2800. "%s MSDU Ext Desc Pool %d Free descs = %d\n",
  2801. __func__, num_pool, num_ext_desc);
  2802. for (i = 0; i < num_pool; i++) {
  2803. dp_tx_tso_desc_pool_free(soc, i);
  2804. }
  2805. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2806. "%s TSO Desc Pool %d Free descs = %d\n",
  2807. __func__, num_pool, num_desc);
  2808. for (i = 0; i < num_pool; i++)
  2809. dp_tx_tso_num_seg_pool_free(soc, i);
  2810. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2811. "%s TSO Num of seg Desc Pool %d Free descs = %d\n",
  2812. __func__, num_pool, num_desc);
  2813. return QDF_STATUS_SUCCESS;
  2814. }
  2815. /**
  2816. * dp_tx_soc_attach() - attach soc to dp tx
  2817. * @soc: core txrx main context
  2818. *
  2819. * This function will attach dp tx into main device context
  2820. * will allocate dp tx resource and initialize resources
  2821. *
  2822. * Return: QDF_STATUS_SUCCESS: success
  2823. * QDF_STATUS_E_RESOURCES: Error return
  2824. */
  2825. QDF_STATUS dp_tx_soc_attach(struct dp_soc *soc)
  2826. {
  2827. uint8_t i;
  2828. uint8_t num_pool;
  2829. uint32_t num_desc;
  2830. uint32_t num_ext_desc;
  2831. num_pool = wlan_cfg_get_num_tx_desc_pool(soc->wlan_cfg_ctx);
  2832. num_desc = wlan_cfg_get_num_tx_desc(soc->wlan_cfg_ctx);
  2833. num_ext_desc = wlan_cfg_get_num_tx_ext_desc(soc->wlan_cfg_ctx);
  2834. if (dp_tx_alloc_static_pools(soc, num_pool, num_desc))
  2835. goto fail;
  2836. dp_tx_flow_control_init(soc);
  2837. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2838. "%s Tx Desc Alloc num_pool = %d, descs = %d\n",
  2839. __func__, num_pool, num_desc);
  2840. /* Allocate extension tx descriptor pools */
  2841. for (i = 0; i < num_pool; i++) {
  2842. if (dp_tx_ext_desc_pool_alloc(soc, i, num_ext_desc)) {
  2843. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2844. "MSDU Ext Desc Pool alloc %d failed %pK\n",
  2845. i, soc);
  2846. goto fail;
  2847. }
  2848. }
  2849. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2850. "%s MSDU Ext Desc Alloc %d, descs = %d\n",
  2851. __func__, num_pool, num_ext_desc);
  2852. for (i = 0; i < num_pool; i++) {
  2853. if (dp_tx_tso_desc_pool_alloc(soc, i, num_desc)) {
  2854. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2855. "TSO Desc Pool alloc %d failed %pK\n",
  2856. i, soc);
  2857. goto fail;
  2858. }
  2859. }
  2860. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2861. "%s TSO Desc Alloc %d, descs = %d\n",
  2862. __func__, num_pool, num_desc);
  2863. for (i = 0; i < num_pool; i++) {
  2864. if (dp_tx_tso_num_seg_pool_alloc(soc, i, num_desc)) {
  2865. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2866. "TSO Num of seg Pool alloc %d failed %pK\n",
  2867. i, soc);
  2868. goto fail;
  2869. }
  2870. }
  2871. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2872. "%s TSO Num of seg pool Alloc %d, descs = %d\n",
  2873. __func__, num_pool, num_desc);
  2874. /* Initialize descriptors in TCL Rings */
  2875. if (!wlan_cfg_per_pdev_tx_ring(soc->wlan_cfg_ctx)) {
  2876. for (i = 0; i < soc->num_tcl_data_rings; i++) {
  2877. hal_tx_init_data_ring(soc->hal_soc,
  2878. soc->tcl_data_ring[i].hal_srng);
  2879. }
  2880. }
  2881. /*
  2882. * todo - Add a runtime config option to enable this.
  2883. */
  2884. /*
  2885. * Due to multiple issues on NPR EMU, enable it selectively
  2886. * only for NPR EMU, should be removed, once NPR platforms
  2887. * are stable.
  2888. */
  2889. soc->process_tx_status = CONFIG_PROCESS_TX_STATUS;
  2890. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2891. "%s HAL Tx init Success\n", __func__);
  2892. return QDF_STATUS_SUCCESS;
  2893. fail:
  2894. /* Detach will take care of freeing only allocated resources */
  2895. dp_tx_soc_detach(soc);
  2896. return QDF_STATUS_E_RESOURCES;
  2897. }
  2898. /*
  2899. * dp_tx_me_mem_free(): Function to free allocated memory in mcast enahncement
  2900. * pdev: pointer to DP PDEV structure
  2901. * seg_info_head: Pointer to the head of list
  2902. *
  2903. * return: void
  2904. */
  2905. static void dp_tx_me_mem_free(struct dp_pdev *pdev,
  2906. struct dp_tx_seg_info_s *seg_info_head)
  2907. {
  2908. struct dp_tx_me_buf_t *mc_uc_buf;
  2909. struct dp_tx_seg_info_s *seg_info_new = NULL;
  2910. qdf_nbuf_t nbuf = NULL;
  2911. uint64_t phy_addr;
  2912. while (seg_info_head) {
  2913. nbuf = seg_info_head->nbuf;
  2914. mc_uc_buf = (struct dp_tx_me_buf_t *)
  2915. seg_info_head->frags[0].vaddr;
  2916. phy_addr = seg_info_head->frags[0].paddr_hi;
  2917. phy_addr = (phy_addr << 32) | seg_info_head->frags[0].paddr_lo;
  2918. qdf_mem_unmap_nbytes_single(pdev->soc->osdev,
  2919. phy_addr,
  2920. QDF_DMA_TO_DEVICE , DP_MAC_ADDR_LEN);
  2921. dp_tx_me_free_buf(pdev, mc_uc_buf);
  2922. qdf_nbuf_free(nbuf);
  2923. seg_info_new = seg_info_head;
  2924. seg_info_head = seg_info_head->next;
  2925. qdf_mem_free(seg_info_new);
  2926. }
  2927. }
  2928. /**
  2929. * dp_tx_me_send_convert_ucast(): function to convert multicast to unicast
  2930. * @vdev: DP VDEV handle
  2931. * @nbuf: Multicast nbuf
  2932. * @newmac: Table of the clients to which packets have to be sent
  2933. * @new_mac_cnt: No of clients
  2934. *
  2935. * return: no of converted packets
  2936. */
  2937. uint16_t
  2938. dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle, qdf_nbuf_t nbuf,
  2939. uint8_t newmac[][DP_MAC_ADDR_LEN], uint8_t new_mac_cnt)
  2940. {
  2941. struct dp_vdev *vdev = (struct dp_vdev *) vdev_handle;
  2942. struct dp_pdev *pdev = vdev->pdev;
  2943. struct ether_header *eh;
  2944. uint8_t *data;
  2945. uint16_t len;
  2946. /* reference to frame dst addr */
  2947. uint8_t *dstmac;
  2948. /* copy of original frame src addr */
  2949. uint8_t srcmac[DP_MAC_ADDR_LEN];
  2950. /* local index into newmac */
  2951. uint8_t new_mac_idx = 0;
  2952. struct dp_tx_me_buf_t *mc_uc_buf;
  2953. qdf_nbuf_t nbuf_clone;
  2954. struct dp_tx_msdu_info_s msdu_info;
  2955. struct dp_tx_seg_info_s *seg_info_head = NULL;
  2956. struct dp_tx_seg_info_s *seg_info_tail = NULL;
  2957. struct dp_tx_seg_info_s *seg_info_new;
  2958. struct dp_tx_frag_info_s data_frag;
  2959. qdf_dma_addr_t paddr_data;
  2960. qdf_dma_addr_t paddr_mcbuf = 0;
  2961. uint8_t empty_entry_mac[DP_MAC_ADDR_LEN] = {0};
  2962. QDF_STATUS status;
  2963. qdf_mem_set(&msdu_info, sizeof(msdu_info), 0x0);
  2964. dp_tx_get_queue(vdev, nbuf, &msdu_info.tx_queue);
  2965. eh = (struct ether_header *) nbuf;
  2966. qdf_mem_copy(srcmac, eh->ether_shost, DP_MAC_ADDR_LEN);
  2967. len = qdf_nbuf_len(nbuf);
  2968. data = qdf_nbuf_data(nbuf);
  2969. status = qdf_nbuf_map(vdev->osdev, nbuf,
  2970. QDF_DMA_TO_DEVICE);
  2971. if (status) {
  2972. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  2973. "Mapping failure Error:%d", status);
  2974. DP_STATS_INC(vdev, tx_i.mcast_en.dropped_map_error, 1);
  2975. qdf_nbuf_free(nbuf);
  2976. return 1;
  2977. }
  2978. paddr_data = qdf_nbuf_get_frag_paddr(nbuf, 0) + IEEE80211_ADDR_LEN;
  2979. /*preparing data fragment*/
  2980. data_frag.vaddr = qdf_nbuf_data(nbuf) + IEEE80211_ADDR_LEN;
  2981. data_frag.paddr_lo = (uint32_t)paddr_data;
  2982. data_frag.paddr_hi = (((uint64_t) paddr_data) >> 32);
  2983. data_frag.len = len - DP_MAC_ADDR_LEN;
  2984. for (new_mac_idx = 0; new_mac_idx < new_mac_cnt; new_mac_idx++) {
  2985. dstmac = newmac[new_mac_idx];
  2986. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO,
  2987. "added mac addr (%pM)", dstmac);
  2988. /* Check for NULL Mac Address */
  2989. if (!qdf_mem_cmp(dstmac, empty_entry_mac, DP_MAC_ADDR_LEN))
  2990. continue;
  2991. /* frame to self mac. skip */
  2992. if (!qdf_mem_cmp(dstmac, srcmac, DP_MAC_ADDR_LEN))
  2993. continue;
  2994. /*
  2995. * TODO: optimize to avoid malloc in per-packet path
  2996. * For eg. seg_pool can be made part of vdev structure
  2997. */
  2998. seg_info_new = qdf_mem_malloc(sizeof(*seg_info_new));
  2999. if (!seg_info_new) {
  3000. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3001. "alloc failed");
  3002. DP_STATS_INC(vdev, tx_i.mcast_en.fail_seg_alloc, 1);
  3003. goto fail_seg_alloc;
  3004. }
  3005. mc_uc_buf = dp_tx_me_alloc_buf(pdev);
  3006. if (mc_uc_buf == NULL)
  3007. goto fail_buf_alloc;
  3008. /*
  3009. * TODO: Check if we need to clone the nbuf
  3010. * Or can we just use the reference for all cases
  3011. */
  3012. if (new_mac_idx < (new_mac_cnt - 1)) {
  3013. nbuf_clone = qdf_nbuf_clone((qdf_nbuf_t)nbuf);
  3014. if (nbuf_clone == NULL) {
  3015. DP_STATS_INC(vdev, tx_i.mcast_en.clone_fail, 1);
  3016. goto fail_clone;
  3017. }
  3018. } else {
  3019. /*
  3020. * Update the ref
  3021. * to account for frame sent without cloning
  3022. */
  3023. qdf_nbuf_ref(nbuf);
  3024. nbuf_clone = nbuf;
  3025. }
  3026. qdf_mem_copy(mc_uc_buf->data, dstmac, DP_MAC_ADDR_LEN);
  3027. status = qdf_mem_map_nbytes_single(vdev->osdev, mc_uc_buf->data,
  3028. QDF_DMA_TO_DEVICE, DP_MAC_ADDR_LEN,
  3029. &paddr_mcbuf);
  3030. if (status) {
  3031. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  3032. "Mapping failure Error:%d", status);
  3033. DP_STATS_INC(vdev, tx_i.mcast_en.dropped_map_error, 1);
  3034. goto fail_map;
  3035. }
  3036. seg_info_new->frags[0].vaddr = (uint8_t *)mc_uc_buf;
  3037. seg_info_new->frags[0].paddr_lo = (uint32_t) paddr_mcbuf;
  3038. seg_info_new->frags[0].paddr_hi =
  3039. ((uint64_t) paddr_mcbuf >> 32);
  3040. seg_info_new->frags[0].len = DP_MAC_ADDR_LEN;
  3041. seg_info_new->frags[1] = data_frag;
  3042. seg_info_new->nbuf = nbuf_clone;
  3043. seg_info_new->frag_cnt = 2;
  3044. seg_info_new->total_len = len;
  3045. seg_info_new->next = NULL;
  3046. if (seg_info_head == NULL)
  3047. seg_info_head = seg_info_new;
  3048. else
  3049. seg_info_tail->next = seg_info_new;
  3050. seg_info_tail = seg_info_new;
  3051. }
  3052. if (!seg_info_head) {
  3053. goto free_return;
  3054. }
  3055. msdu_info.u.sg_info.curr_seg = seg_info_head;
  3056. msdu_info.num_seg = new_mac_cnt;
  3057. msdu_info.frm_type = dp_tx_frm_me;
  3058. DP_STATS_INC(vdev, tx_i.mcast_en.ucast, new_mac_cnt);
  3059. dp_tx_send_msdu_multiple(vdev, nbuf, &msdu_info);
  3060. while (seg_info_head->next) {
  3061. seg_info_new = seg_info_head;
  3062. seg_info_head = seg_info_head->next;
  3063. qdf_mem_free(seg_info_new);
  3064. }
  3065. qdf_mem_free(seg_info_head);
  3066. qdf_nbuf_unmap(pdev->soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  3067. qdf_nbuf_free(nbuf);
  3068. return new_mac_cnt;
  3069. fail_map:
  3070. qdf_nbuf_free(nbuf_clone);
  3071. fail_clone:
  3072. dp_tx_me_free_buf(pdev, mc_uc_buf);
  3073. fail_buf_alloc:
  3074. qdf_mem_free(seg_info_new);
  3075. fail_seg_alloc:
  3076. dp_tx_me_mem_free(pdev, seg_info_head);
  3077. free_return:
  3078. qdf_nbuf_unmap(pdev->soc->osdev, nbuf, QDF_DMA_TO_DEVICE);
  3079. qdf_nbuf_free(nbuf);
  3080. return 1;
  3081. }