dp_tx_capture.c 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530
  1. /*
  2. * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include <htt.h>
  19. #include "qdf_trace.h"
  20. #include "qdf_nbuf.h"
  21. #include "dp_peer.h"
  22. #include "dp_types.h"
  23. #include "dp_internal.h"
  24. #include "dp_rx_mon.h"
  25. #include "htt_ppdu_stats.h"
  26. #include "dp_htt.h"
  27. #include "qdf_mem.h" /* qdf_mem_malloc,free */
  28. #include "cdp_txrx_cmn_struct.h"
  29. #include <enet.h>
  30. #include "dp_tx_capture.h"
  31. #define MAX_MONITOR_HEADER (512)
  32. #define MAX_DUMMY_FRM_BODY (128)
  33. #define DP_BA_ACK_FRAME_SIZE (sizeof(struct ieee80211_ctlframe_addr2) + 36)
  34. #define DP_ACK_FRAME_SIZE (sizeof(struct ieee80211_frame_min_one))
  35. #define DP_CTS_FRAME_SIZE (sizeof(struct ieee80211_frame_min_one))
  36. #define DP_MAX_MPDU_64 64
  37. #define DP_NUM_WORDS_PER_PPDU_BITMAP_64 (DP_MAX_MPDU_64 >> 5)
  38. #define DP_NUM_BYTES_PER_PPDU_BITMAP_64 (DP_MAX_MPDU_64 >> 3)
  39. #define DP_NUM_BYTES_PER_PPDU_BITMAP (HAL_RX_MAX_MPDU >> 3)
  40. #define DP_IEEE80211_BAR_CTL_TID_S 12
  41. #define DP_IEEE80211_BA_S_SEQ_S 4
  42. #define DP_IEEE80211_BAR_CTL_COMBA 0x0004
  43. #define INVALID_PPDU_ID 0xFFFF
  44. #define MAX_END_TSF 0xFFFFFFFF
  45. /* Macros to handle sequence number bitmaps */
  46. /* HW generated rts frame flag */
  47. #define SEND_WIFIRTS_LEGACY_E 1
  48. /* HW generated 11 AC static bw flag */
  49. #define SEND_WIFIRTS_11AC_STATIC_BW_E 2
  50. /* HW generated 11 AC dynamic bw flag */
  51. #define SEND_WIFIRTS_11AC_DYNAMIC_BW_E 3
  52. /* HW generated cts frame flag */
  53. #define SEND_WIFICTS2SELF_E 4
  54. /* Size (in bits) of a segment of sequence number bitmap */
  55. #define SEQ_SEG_SZ_BITS(_seqarr) (sizeof(_seqarr[0]) << 3)
  56. /* Array index of a segment of sequence number bitmap */
  57. #define SEQ_SEG_INDEX(_seqarr, _seqno) ((_seqno) / SEQ_SEG_SZ_BITS(_seqarr))
  58. /* Bit mask of a seqno within a segment of sequence bitmap */
  59. #define SEQ_SEG_MSK(_seqseg, _index) \
  60. (1 << ((_index) & ((sizeof(_seqseg) << 3) - 1)))
  61. /* Check seqno bit in a segment of sequence bitmap */
  62. #define SEQ_SEG_BIT(_seqseg, _index) \
  63. ((_seqseg) & SEQ_SEG_MSK((_seqseg), _index))
  64. /* Segment of sequence bitmap containing a given sequence number */
  65. #define SEQ_SEG(_seqarr, _seqno) \
  66. (_seqarr[(_seqno) / (sizeof(_seqarr[0]) << 3)])
  67. /* Check seqno bit in the sequence bitmap */
  68. #define SEQ_BIT(_seqarr, _seqno) \
  69. SEQ_SEG_BIT(SEQ_SEG(_seqarr, (_seqno)), (_seqno))
  70. /* Lower 32 mask for timestamp us as completion path has 32 bits timestamp */
  71. #define LOWER_32_MASK 0xFFFFFFFF
  72. /* Maximum time taken to enqueue next mgmt pkt */
  73. #define MAX_MGMT_ENQ_DELAY 10000
  74. /* Schedule id counter mask in ppdu_id */
  75. #define SCH_ID_MASK 0xFF
  76. #ifdef WLAN_TX_PKT_CAPTURE_ENH
  77. /*
  78. * dp_tx_capture_htt_frame_counter: increment counter for htt_frame_type
  79. * pdev: DP pdev handle
  80. * htt_frame_type: htt frame type received from fw
  81. *
  82. * return: void
  83. */
  84. void dp_tx_capture_htt_frame_counter(struct dp_pdev *pdev,
  85. uint32_t htt_frame_type)
  86. {
  87. if (htt_frame_type >= TX_CAP_HTT_MAX_FTYPE)
  88. return;
  89. pdev->tx_capture.htt_frame_type[htt_frame_type]++;
  90. }
  91. /*
  92. * dp_tx_cature_stats: print tx capture stats
  93. * @pdev: DP PDEV handle
  94. *
  95. * return: void
  96. */
  97. void dp_print_pdev_tx_capture_stats(struct dp_pdev *pdev)
  98. {
  99. struct dp_pdev_tx_capture *ptr_tx_cap;
  100. uint8_t i = 0, j = 0;
  101. ptr_tx_cap = &(pdev->tx_capture);
  102. DP_PRINT_STATS("tx capture stats:");
  103. DP_PRINT_STATS(" mgmt control enqueue stats:");
  104. for (i = 0; i < TXCAP_MAX_TYPE; i++) {
  105. for (j = 0; j < TXCAP_MAX_SUBTYPE; j++) {
  106. if (ptr_tx_cap->ctl_mgmt_q[i][j].qlen)
  107. DP_PRINT_STATS(" ctl_mgmt_q[%d][%d] = queue_len[%d]",
  108. i, j, ptr_tx_cap->ctl_mgmt_q[i][j].qlen);
  109. }
  110. }
  111. DP_PRINT_STATS(" mgmt control retry queue stats:");
  112. for (i = 0; i < TXCAP_MAX_TYPE; i++) {
  113. for (j = 0; j < TXCAP_MAX_SUBTYPE; j++) {
  114. if (ptr_tx_cap->ctl_mgmt_q[i][j].qlen)
  115. DP_PRINT_STATS(" retries_ctl_mgmt_q[%d][%d] = queue_len[%d]",
  116. i, j,
  117. ptr_tx_cap->retries_ctl_mgmt_q[i][j].qlen);
  118. }
  119. }
  120. for (i = 0; i < TX_CAP_HTT_MAX_FTYPE; i++) {
  121. if (!ptr_tx_cap->htt_frame_type[i])
  122. continue;
  123. DP_PRINT_STATS(" sgen htt frame type[%d] = %d",
  124. i, ptr_tx_cap->htt_frame_type[i]);
  125. }
  126. }
  127. /**
  128. * dp_peer_or_pdev_tx_cap_enabled - Returns status of tx_cap_enabled
  129. * based on global per-pdev setting or per-peer setting
  130. * @pdev: Datapath pdev handle
  131. * @peer: Datapath peer
  132. *
  133. * Return: true if feature is enabled on a per-pdev basis or if
  134. * enabled for the given peer when per-peer mode is set, false otherwise
  135. */
  136. inline bool
  137. dp_peer_or_pdev_tx_cap_enabled(struct dp_pdev *pdev,
  138. struct dp_peer *peer)
  139. {
  140. if ((pdev->tx_capture_enabled ==
  141. CDP_TX_ENH_CAPTURE_ENABLE_ALL_PEERS) ||
  142. ((pdev->tx_capture_enabled ==
  143. CDP_TX_ENH_CAPTURE_ENDIS_PER_PEER) &&
  144. peer->tx_cap_enabled))
  145. return true;
  146. return false;
  147. }
  148. /*
  149. * dp_peer_tid_queue_init() – Initialize ppdu stats queue per TID
  150. * @peer: Datapath peer
  151. *
  152. */
  153. void dp_peer_tid_queue_init(struct dp_peer *peer)
  154. {
  155. int tid;
  156. struct dp_tx_tid *tx_tid;
  157. for (tid = 0; tid < DP_MAX_TIDS; tid++) {
  158. tx_tid = &peer->tx_capture.tx_tid[tid];
  159. tx_tid->tid = tid;
  160. qdf_nbuf_queue_init(&tx_tid->msdu_comp_q);
  161. qdf_nbuf_queue_init(&tx_tid->pending_ppdu_q);
  162. tx_tid->max_ppdu_id = 0;
  163. /* spinlock create */
  164. qdf_spinlock_create(&tx_tid->tid_lock);
  165. }
  166. }
  167. static
  168. void dp_peer_tx_cap_tid_queue_flush(struct dp_peer *peer)
  169. {
  170. int tid;
  171. struct dp_tx_tid *tx_tid;
  172. for (tid = 0; tid < DP_MAX_TIDS; tid++) {
  173. tx_tid = &peer->tx_capture.tx_tid[tid];
  174. qdf_spin_lock_bh(&tx_tid->tid_lock);
  175. qdf_nbuf_queue_free(&tx_tid->msdu_comp_q);
  176. qdf_spin_unlock_bh(&tx_tid->tid_lock);
  177. tx_tid->max_ppdu_id = 0;
  178. }
  179. }
  180. /*
  181. * dp_peer_tid_queue_cleanup() – remove ppdu stats queue per TID
  182. * @peer: Datapath peer
  183. *
  184. */
  185. void dp_peer_tid_queue_cleanup(struct dp_peer *peer)
  186. {
  187. int tid;
  188. struct dp_tx_tid *tx_tid;
  189. for (tid = 0; tid < DP_MAX_TIDS; tid++) {
  190. tx_tid = &peer->tx_capture.tx_tid[tid];
  191. qdf_spin_lock_bh(&tx_tid->tid_lock);
  192. qdf_nbuf_queue_free(&tx_tid->msdu_comp_q);
  193. qdf_spin_unlock_bh(&tx_tid->tid_lock);
  194. /* spinlock destroy */
  195. qdf_spinlock_destroy(&tx_tid->tid_lock);
  196. tx_tid->max_ppdu_id = 0;
  197. }
  198. }
  199. /*
  200. * dp_peer_update_80211_hdr: update 80211 hdr
  201. * @vdev: DP VDEV
  202. * @peer: DP PEER
  203. *
  204. * return: void
  205. */
  206. void dp_peer_update_80211_hdr(struct dp_vdev *vdev, struct dp_peer *peer)
  207. {
  208. struct ieee80211_frame *ptr_wh;
  209. ptr_wh = &peer->tx_capture.tx_wifi_hdr;
  210. /* i_addr1 - Receiver mac address */
  211. /* i_addr2 - Transmitter mac address */
  212. /* i_addr3 - Destination mac address */
  213. qdf_mem_copy(ptr_wh->i_addr1,
  214. peer->mac_addr.raw,
  215. QDF_MAC_ADDR_SIZE);
  216. qdf_mem_copy(ptr_wh->i_addr3,
  217. peer->mac_addr.raw,
  218. QDF_MAC_ADDR_SIZE);
  219. qdf_mem_copy(ptr_wh->i_addr2,
  220. vdev->mac_addr.raw,
  221. QDF_MAC_ADDR_SIZE);
  222. }
  223. /*
  224. * dp_deliver_mgmt_frm: Process
  225. * @pdev: DP PDEV handle
  226. * @nbuf: buffer containing the htt_ppdu_stats_tx_mgmtctrl_payload_tlv
  227. *
  228. * return: void
  229. */
  230. void dp_deliver_mgmt_frm(struct dp_pdev *pdev, qdf_nbuf_t nbuf)
  231. {
  232. if (pdev->tx_sniffer_enable || pdev->mcopy_mode) {
  233. dp_wdi_event_handler(WDI_EVENT_TX_MGMT_CTRL, pdev->soc,
  234. nbuf, HTT_INVALID_PEER,
  235. WDI_NO_VAL, pdev->pdev_id);
  236. return;
  237. }
  238. if (pdev->tx_capture_enabled == CDP_TX_ENH_CAPTURE_ENABLE_ALL_PEERS ||
  239. pdev->tx_capture_enabled == CDP_TX_ENH_CAPTURE_ENDIS_PER_PEER) {
  240. /* invoke WDI event handler here send mgmt pkt here */
  241. struct ieee80211_frame *wh;
  242. uint8_t type, subtype;
  243. struct cdp_tx_mgmt_comp_info *ptr_mgmt_hdr;
  244. ptr_mgmt_hdr = (struct cdp_tx_mgmt_comp_info *)
  245. qdf_nbuf_data(nbuf);
  246. wh = (struct ieee80211_frame *)(qdf_nbuf_data(nbuf) +
  247. sizeof(struct cdp_tx_mgmt_comp_info));
  248. type = (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) >>
  249. IEEE80211_FC0_TYPE_SHIFT;
  250. subtype = (wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) >>
  251. IEEE80211_FC0_SUBTYPE_SHIFT;
  252. if (!ptr_mgmt_hdr->ppdu_id || !ptr_mgmt_hdr->tx_tsf ||
  253. (!type && !subtype)) {
  254. /*
  255. * if either ppdu_id and tx_tsf are zero then
  256. * storing the payload won't be useful
  257. * in constructing the packet
  258. * Hence freeing the packet
  259. */
  260. qdf_nbuf_free(nbuf);
  261. return;
  262. }
  263. qdf_spin_lock_bh(
  264. &pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  265. qdf_nbuf_queue_add(&pdev->tx_capture.ctl_mgmt_q[type][subtype],
  266. nbuf);
  267. qdf_spin_unlock_bh(
  268. &pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  269. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_DEBUG,
  270. "dlvr mgmt frm(0x%08x): fc 0x%x %x, dur 0x%x%x\n",
  271. ptr_mgmt_hdr->ppdu_id, wh->i_fc[1], wh->i_fc[0],
  272. wh->i_dur[1], wh->i_dur[0]);
  273. }
  274. }
  275. /**
  276. * dp_tx_ppdu_stats_attach - Initialize Tx PPDU stats and enhanced capture
  277. * @pdev: DP PDEV
  278. *
  279. * Return: none
  280. */
  281. void dp_tx_ppdu_stats_attach(struct dp_pdev *pdev)
  282. {
  283. int i, j;
  284. /* Work queue setup for HTT stats and tx capture handling */
  285. qdf_create_work(0, &pdev->tx_capture.ppdu_stats_work,
  286. dp_tx_ppdu_stats_process,
  287. pdev);
  288. pdev->tx_capture.ppdu_stats_workqueue =
  289. qdf_alloc_unbound_workqueue("ppdu_stats_work_queue");
  290. STAILQ_INIT(&pdev->tx_capture.ppdu_stats_queue);
  291. STAILQ_INIT(&pdev->tx_capture.ppdu_stats_defer_queue);
  292. qdf_spinlock_create(&pdev->tx_capture.ppdu_stats_lock);
  293. pdev->tx_capture.ppdu_stats_queue_depth = 0;
  294. pdev->tx_capture.ppdu_stats_next_sched = 0;
  295. pdev->tx_capture.ppdu_stats_defer_queue_depth = 0;
  296. pdev->tx_capture.ppdu_dropped = 0;
  297. for (i = 0; i < TXCAP_MAX_TYPE; i++) {
  298. for (j = 0; j < TXCAP_MAX_SUBTYPE; j++) {
  299. qdf_nbuf_queue_init(
  300. &pdev->tx_capture.ctl_mgmt_q[i][j]);
  301. qdf_spinlock_create(
  302. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  303. }
  304. }
  305. qdf_mem_zero(&pdev->tx_capture.dummy_ppdu_desc,
  306. sizeof(struct cdp_tx_completion_ppdu));
  307. }
  308. /**
  309. * dp_tx_ppdu_stats_detach - Cleanup Tx PPDU stats and enhanced capture
  310. * @pdev: DP PDEV
  311. *
  312. * Return: none
  313. */
  314. void dp_tx_ppdu_stats_detach(struct dp_pdev *pdev)
  315. {
  316. struct ppdu_info *ppdu_info, *tmp_ppdu_info = NULL;
  317. int i, j;
  318. if (!pdev || !pdev->tx_capture.ppdu_stats_workqueue)
  319. return;
  320. qdf_flush_workqueue(0, pdev->tx_capture.ppdu_stats_workqueue);
  321. qdf_destroy_workqueue(0, pdev->tx_capture.ppdu_stats_workqueue);
  322. qdf_spinlock_destroy(&pdev->tx_capture.ppdu_stats_lock);
  323. STAILQ_FOREACH_SAFE(ppdu_info,
  324. &pdev->tx_capture.ppdu_stats_queue,
  325. ppdu_info_queue_elem, tmp_ppdu_info) {
  326. STAILQ_REMOVE(&pdev->tx_capture.ppdu_stats_queue,
  327. ppdu_info, ppdu_info, ppdu_info_queue_elem);
  328. qdf_nbuf_free(ppdu_info->nbuf);
  329. qdf_mem_free(ppdu_info);
  330. }
  331. STAILQ_FOREACH_SAFE(ppdu_info,
  332. &pdev->tx_capture.ppdu_stats_defer_queue,
  333. ppdu_info_queue_elem, tmp_ppdu_info) {
  334. STAILQ_REMOVE(&pdev->tx_capture.ppdu_stats_defer_queue,
  335. ppdu_info, ppdu_info, ppdu_info_queue_elem);
  336. qdf_nbuf_free(ppdu_info->nbuf);
  337. qdf_mem_free(ppdu_info);
  338. }
  339. for (i = 0; i < TXCAP_MAX_TYPE; i++) {
  340. for (j = 0; j < TXCAP_MAX_SUBTYPE; j++) {
  341. qdf_spin_lock_bh(
  342. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  343. qdf_nbuf_queue_free(
  344. &pdev->tx_capture.ctl_mgmt_q[i][j]);
  345. qdf_spin_unlock_bh(
  346. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  347. qdf_spinlock_destroy(
  348. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  349. }
  350. }
  351. }
  352. /**
  353. * dp_update_msdu_to_list(): Function to queue msdu from wbm
  354. * @pdev: dp_pdev
  355. * @peer: dp_peer
  356. * @ts: hal tx completion status
  357. * @netbuf: msdu
  358. *
  359. * return: status
  360. */
  361. QDF_STATUS
  362. dp_update_msdu_to_list(struct dp_soc *soc,
  363. struct dp_pdev *pdev,
  364. struct dp_peer *peer,
  365. struct hal_tx_completion_status *ts,
  366. qdf_nbuf_t netbuf)
  367. {
  368. struct dp_tx_tid *tx_tid;
  369. struct msdu_completion_info *msdu_comp_info;
  370. if (!peer) {
  371. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  372. "%s: %d peer NULL !", __func__, __LINE__);
  373. return QDF_STATUS_E_FAILURE;
  374. }
  375. if (ts->tid > DP_MAX_TIDS) {
  376. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  377. "%s: %d peer_id %d, tid %d > NON_QOS_TID!",
  378. __func__, __LINE__, ts->peer_id, ts->tid);
  379. return QDF_STATUS_E_FAILURE;
  380. }
  381. tx_tid = &peer->tx_capture.tx_tid[ts->tid];
  382. if (!tx_tid) {
  383. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  384. "%s: %d tid[%d] NULL !", __func__, __LINE__, ts->tid);
  385. return QDF_STATUS_E_FAILURE;
  386. }
  387. qdf_nbuf_unmap(soc->osdev, netbuf, QDF_DMA_TO_DEVICE);
  388. if (!qdf_nbuf_push_head(netbuf, sizeof(struct msdu_completion_info))) {
  389. QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
  390. FL("No headroom"));
  391. return QDF_STATUS_E_NOMEM;
  392. }
  393. msdu_comp_info = (struct msdu_completion_info *)qdf_nbuf_data(netbuf);
  394. /* copy msdu_completion_info to control buffer */
  395. msdu_comp_info->ppdu_id = ts->ppdu_id;
  396. msdu_comp_info->peer_id = ts->peer_id;
  397. msdu_comp_info->tid = ts->tid;
  398. msdu_comp_info->first_msdu = ts->first_msdu;
  399. msdu_comp_info->last_msdu = ts->last_msdu;
  400. msdu_comp_info->msdu_part_of_amsdu = ts->msdu_part_of_amsdu;
  401. msdu_comp_info->transmit_cnt = ts->transmit_cnt;
  402. msdu_comp_info->tsf = ts->tsf;
  403. msdu_comp_info->status = ts->status;
  404. /* update max ppdu_id */
  405. tx_tid->max_ppdu_id = ts->ppdu_id;
  406. pdev->tx_capture.last_msdu_id = ts->ppdu_id;
  407. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_INFO,
  408. "msdu_completion: ppdu_id[%d] peer_id[%d] tid[%d] rel_src[%d] status[%d] tsf[%u] A[%d] CNT[%d]",
  409. ts->ppdu_id, ts->peer_id, ts->tid, ts->release_src,
  410. ts->status, ts->tsf, ts->msdu_part_of_amsdu,
  411. ts->transmit_cnt);
  412. /* lock here */
  413. qdf_spin_lock_bh(&tx_tid->tid_lock);
  414. /* add nbuf to tail queue per peer tid */
  415. qdf_nbuf_queue_add(&tx_tid->msdu_comp_q, netbuf);
  416. qdf_spin_unlock_bh(&tx_tid->tid_lock);
  417. return QDF_STATUS_SUCCESS;
  418. }
  419. /**
  420. * dp_tx_add_to_comp_queue() - add completion msdu to queue
  421. * @soc: DP Soc handle
  422. * @tx_desc: software Tx descriptor
  423. * @ts : Tx completion status from HAL/HTT descriptor
  424. * @peer: DP peer
  425. *
  426. * Return: none
  427. */
  428. QDF_STATUS dp_tx_add_to_comp_queue(struct dp_soc *soc,
  429. struct dp_tx_desc_s *desc,
  430. struct hal_tx_completion_status *ts,
  431. struct dp_peer *peer)
  432. {
  433. int ret = QDF_STATUS_E_FAILURE;
  434. if (peer && dp_peer_or_pdev_tx_cap_enabled(desc->pdev, peer) &&
  435. ((ts->status == HAL_TX_TQM_RR_FRAME_ACKED) ||
  436. (ts->status == HAL_TX_TQM_RR_REM_CMD_TX) ||
  437. ((ts->status == HAL_TX_TQM_RR_REM_CMD_AGED) && ts->transmit_cnt))) {
  438. ret = dp_update_msdu_to_list(soc, desc->pdev,
  439. peer, ts, desc->nbuf);
  440. }
  441. return ret;
  442. }
  443. /**
  444. * dp_process_ppdu_stats_update_failed_bitmap(): update failed bitmap
  445. * @pdev: dp_pdev
  446. * @data: tx completion ppdu desc
  447. * @ppdu_id: ppdu id
  448. * @size: size of bitmap
  449. *
  450. * return: status
  451. */
  452. void dp_process_ppdu_stats_update_failed_bitmap(struct dp_pdev *pdev,
  453. void *data,
  454. uint32_t ppdu_id,
  455. uint32_t size)
  456. {
  457. struct cdp_tx_completion_ppdu_user *user;
  458. uint32_t mpdu_tried;
  459. uint32_t ba_seq_no;
  460. uint32_t start_seq;
  461. uint32_t num_mpdu;
  462. uint32_t diff;
  463. uint32_t carry = 0;
  464. uint32_t bitmask = 0;
  465. uint32_t i;
  466. uint32_t k;
  467. uint32_t ba_bitmap = 0;
  468. int last_set_bit;
  469. user = (struct cdp_tx_completion_ppdu_user *)data;
  470. /* get number of mpdu from ppdu_desc */
  471. mpdu_tried = user->mpdu_tried_mcast + user->mpdu_tried_ucast;
  472. ba_seq_no = user->ba_seq_no;
  473. start_seq = user->start_seq;
  474. num_mpdu = user->num_mpdu;
  475. /* assumption: number of mpdu will be less than 32 */
  476. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_INFO,
  477. "ppdu_id[%d] ba_seq_no[%d] start_seq_no[%d] mpdu_tried[%d]",
  478. ppdu_id, ba_seq_no, start_seq, mpdu_tried);
  479. for (i = 0; i < size; i++) {
  480. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_INFO,
  481. "ppdu_id[%d] ba_bitmap[%x] enqueue_bitmap[%x]",
  482. ppdu_id, user->ba_bitmap[i], user->enq_bitmap[i]);
  483. }
  484. /* Handle sequence no. wraparound */
  485. if (start_seq <= ba_seq_no) {
  486. diff = ba_seq_no - start_seq;
  487. /* Sequence delta of more than 2048 is considered wraparound
  488. * and we extend start_seq to be more than ba_seq just to
  489. * adjust failed_bitmap
  490. */
  491. if (qdf_unlikely(diff > (IEEE80211_SEQ_MAX / 2))) {
  492. diff = (start_seq - ba_seq_no) &
  493. (IEEE80211_SEQ_MAX - 1);
  494. start_seq = ba_seq_no + diff;
  495. }
  496. } else {
  497. diff = start_seq - ba_seq_no;
  498. /* Sequence delta of more than 2048 is considered wraparound
  499. * and we extend ba_seq to be more than start_seq just to
  500. * adjust failed_bitmap
  501. */
  502. if (qdf_unlikely(diff > (IEEE80211_SEQ_MAX / 2))) {
  503. diff = (ba_seq_no - start_seq) &
  504. (IEEE80211_SEQ_MAX - 1);
  505. ba_seq_no = start_seq + diff;
  506. }
  507. }
  508. /* Adjust failed_bitmap to start from same seq_no as enq_bitmap */
  509. last_set_bit = 0;
  510. if (start_seq <= ba_seq_no) {
  511. bitmask = (1 << diff) - 1;
  512. for (i = 0; i < size; i++) {
  513. ba_bitmap = user->ba_bitmap[i];
  514. user->failed_bitmap[i] = (ba_bitmap << diff);
  515. user->failed_bitmap[i] |= (bitmask & carry);
  516. carry = ((ba_bitmap & (bitmask << (32 - diff))) >>
  517. (32 - diff));
  518. user->failed_bitmap[i] = user->enq_bitmap[i] &
  519. user->failed_bitmap[i];
  520. if (user->enq_bitmap[i]) {
  521. last_set_bit = i * 32 +
  522. qdf_fls(user->enq_bitmap[i]) - 1;
  523. }
  524. }
  525. } else {
  526. /* array index */
  527. k = diff >> 5;
  528. diff = diff & 0x1F;
  529. bitmask = (1 << diff) - 1;
  530. for (i = 0; i < size; i++, k++) {
  531. ba_bitmap = user->ba_bitmap[k];
  532. user->failed_bitmap[i] = ba_bitmap >> diff;
  533. /* get next ba_bitmap */
  534. ba_bitmap = user->ba_bitmap[k + 1];
  535. carry = (ba_bitmap & bitmask);
  536. user->failed_bitmap[i] |=
  537. ((carry & bitmask) << (32 - diff));
  538. user->failed_bitmap[i] = user->enq_bitmap[i] &
  539. user->failed_bitmap[i];
  540. if (user->enq_bitmap[i]) {
  541. last_set_bit = i * 32 +
  542. qdf_fls(user->enq_bitmap[i]) - 1;
  543. }
  544. }
  545. }
  546. user->last_enq_seq = user->start_seq + last_set_bit;
  547. user->ba_size = user->last_enq_seq - user->start_seq + 1;
  548. }
  549. /*
  550. * dp_soc_set_txrx_ring_map_single()
  551. * @dp_soc: DP handler for soc
  552. *
  553. * Return: Void
  554. */
  555. static void dp_soc_set_txrx_ring_map_single(struct dp_soc *soc)
  556. {
  557. uint32_t i;
  558. for (i = 0; i < WLAN_CFG_INT_NUM_CONTEXTS; i++) {
  559. soc->tx_ring_map[i] =
  560. dp_cpu_ring_map[DP_SINGLE_TX_RING_MAP][i];
  561. }
  562. }
  563. /*
  564. * dp_iterate_free_peer_msdu_q()- API to free msdu queue
  565. * @pdev_handle: DP_PDEV handle
  566. *
  567. * Return: void
  568. */
  569. static void dp_iterate_free_peer_msdu_q(void *pdev_hdl)
  570. {
  571. struct dp_pdev *pdev = (struct dp_pdev *)pdev_hdl;
  572. struct dp_soc *soc = pdev->soc;
  573. struct dp_vdev *vdev = NULL;
  574. struct dp_peer *peer = NULL;
  575. qdf_spin_lock_bh(&soc->peer_ref_mutex);
  576. qdf_spin_lock_bh(&pdev->vdev_list_lock);
  577. DP_PDEV_ITERATE_VDEV_LIST(pdev, vdev) {
  578. DP_VDEV_ITERATE_PEER_LIST(vdev, peer) {
  579. int tid;
  580. struct dp_tx_tid *tx_tid;
  581. for (tid = 0; tid < DP_MAX_TIDS; tid++) {
  582. qdf_nbuf_t ppdu_nbuf = NULL;
  583. struct cdp_tx_completion_ppdu *ppdu_desc =
  584. NULL;
  585. int i;
  586. tx_tid = &peer->tx_capture.tx_tid[tid];
  587. /* spinlock hold */
  588. qdf_spin_lock_bh(&tx_tid->tid_lock);
  589. qdf_nbuf_queue_free(&tx_tid->msdu_comp_q);
  590. qdf_spin_unlock_bh(&tx_tid->tid_lock);
  591. while ((ppdu_nbuf = qdf_nbuf_queue_remove(
  592. &tx_tid->pending_ppdu_q))) {
  593. ppdu_desc =
  594. (struct cdp_tx_completion_ppdu *)
  595. qdf_nbuf_data(ppdu_nbuf);
  596. if (!ppdu_desc->mpdus) {
  597. qdf_nbuf_free(ppdu_nbuf);
  598. continue;
  599. }
  600. for (i = 0; i <
  601. ppdu_desc->user[0].ba_size; i++) {
  602. if (!ppdu_desc->mpdus[i])
  603. continue;
  604. qdf_nbuf_free(
  605. ppdu_desc->mpdus[i]);
  606. }
  607. qdf_mem_free(ppdu_desc->mpdus);
  608. ppdu_desc->mpdus = NULL;
  609. qdf_nbuf_free(ppdu_nbuf);
  610. }
  611. }
  612. }
  613. }
  614. qdf_spin_unlock_bh(&pdev->vdev_list_lock);
  615. qdf_spin_unlock_bh(&soc->peer_ref_mutex);
  616. }
  617. /*
  618. * dp_config_enh_tx_capture()- API to enable/disable enhanced tx capture
  619. * @pdev_handle: DP_PDEV handle
  620. * @val: user provided value
  621. *
  622. * Return: QDF_STATUS
  623. */
  624. QDF_STATUS
  625. dp_config_enh_tx_capture(struct dp_pdev *pdev, uint8_t val)
  626. {
  627. int i, j;
  628. qdf_spin_lock(&pdev->tx_capture.config_lock);
  629. pdev->tx_capture_enabled = val;
  630. if (pdev->tx_capture_enabled == CDP_TX_ENH_CAPTURE_ENABLE_ALL_PEERS ||
  631. pdev->tx_capture_enabled == CDP_TX_ENH_CAPTURE_ENDIS_PER_PEER) {
  632. dp_soc_set_txrx_ring_map_single(pdev->soc);
  633. if (!pdev->pktlog_ppdu_stats)
  634. dp_h2t_cfg_stats_msg_send(pdev,
  635. DP_PPDU_STATS_CFG_SNIFFER,
  636. pdev->pdev_id);
  637. } else {
  638. dp_soc_set_txrx_ring_map(pdev->soc);
  639. dp_h2t_cfg_stats_msg_send(pdev,
  640. DP_PPDU_STATS_CFG_ENH_STATS,
  641. pdev->pdev_id);
  642. dp_iterate_free_peer_msdu_q(pdev);
  643. for (i = 0; i < TXCAP_MAX_TYPE; i++) {
  644. for (j = 0; j < TXCAP_MAX_SUBTYPE; j++) {
  645. qdf_spin_lock_bh(
  646. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  647. qdf_nbuf_queue_free(
  648. &pdev->tx_capture.ctl_mgmt_q[i][j]);
  649. qdf_spin_unlock_bh(
  650. &pdev->tx_capture.ctl_mgmt_lock[i][j]);
  651. }
  652. }
  653. }
  654. qdf_spin_unlock(&pdev->tx_capture.config_lock);
  655. return QDF_STATUS_SUCCESS;
  656. }
  657. /**
  658. * get_number_of_1s(): Function to get number of 1s
  659. * @value: value to find
  660. *
  661. * return: number of 1s
  662. */
  663. static
  664. inline uint32_t get_number_of_1s(uint32_t value)
  665. {
  666. uint32_t shift[] = {1, 2, 4, 8, 16};
  667. uint32_t magic_number[] = { 0x55555555, 0x33333333, 0x0F0F0F0F,
  668. 0x00FF00FF, 0x0000FFFF};
  669. uint8_t k = 0;
  670. for (; k <= 4; k++) {
  671. value = (value & magic_number[k]) +
  672. ((value >> shift[k]) & magic_number[k]);
  673. }
  674. return value;
  675. }
  676. /**
  677. * dp_tx_print_bitmap(): Function to print bitmap
  678. * @pdev: dp_pdev
  679. * @ppdu_desc: ppdu completion descriptor
  680. * @user_inder: user index
  681. * @ppdu_id: ppdu id
  682. *
  683. * return: status
  684. */
  685. static
  686. QDF_STATUS dp_tx_print_bitmap(struct dp_pdev *pdev,
  687. struct cdp_tx_completion_ppdu *ppdu_desc,
  688. uint32_t user_index,
  689. uint32_t ppdu_id)
  690. {
  691. struct cdp_tx_completion_ppdu_user *user;
  692. uint8_t i;
  693. uint32_t mpdu_tried;
  694. uint32_t ba_seq_no;
  695. uint32_t start_seq;
  696. uint32_t num_mpdu;
  697. uint32_t fail_num_mpdu = 0;
  698. user = &ppdu_desc->user[user_index];
  699. /* get number of mpdu from ppdu_desc */
  700. mpdu_tried = user->mpdu_tried_mcast + user->mpdu_tried_ucast;
  701. ba_seq_no = user->ba_seq_no;
  702. start_seq = user->start_seq;
  703. num_mpdu = user->mpdu_success;
  704. if (user->tid > DP_MAX_TIDS) {
  705. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  706. "%s: ppdu[%d] peer_id[%d] TID[%d] > NON_QOS_TID!",
  707. __func__, ppdu_id, user->peer_id, user->tid);
  708. return QDF_STATUS_E_FAILURE;
  709. }
  710. if (mpdu_tried != num_mpdu) {
  711. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_INFO,
  712. "%s: ppdu[%d] peer[%d] tid[%d] ba[%d] start[%d] mpdu_tri[%d] num_mpdu[%d] is_mcast[%d]",
  713. __func__, ppdu_id, user->peer_id, user->tid,
  714. ba_seq_no, start_seq, mpdu_tried,
  715. num_mpdu, user->is_mcast);
  716. for (i = 0; i < CDP_BA_256_BIT_MAP_SIZE_DWORDS; i++) {
  717. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  718. QDF_TRACE_LEVEL_INFO,
  719. "ppdu_id[%d] ba_bitmap[0x%x] enqueue_bitmap[0x%x] failed_bitmap[0x%x]",
  720. ppdu_id, user->ba_bitmap[i],
  721. user->enq_bitmap[i],
  722. user->failed_bitmap[i]);
  723. fail_num_mpdu +=
  724. get_number_of_1s(user->failed_bitmap[i]);
  725. }
  726. }
  727. if (fail_num_mpdu == num_mpdu && num_mpdu)
  728. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_DEBUG,
  729. "%s: %d ppdu_id[%d] num_mpdu[%d, %d]",
  730. __func__, __LINE__, ppdu_id, num_mpdu, fail_num_mpdu);
  731. return QDF_STATUS_SUCCESS;
  732. }
  733. static uint32_t dp_tx_update_80211_hdr(struct dp_pdev *pdev,
  734. struct dp_peer *peer,
  735. void *data,
  736. qdf_nbuf_t nbuf,
  737. uint16_t ether_type,
  738. uint8_t *src_addr)
  739. {
  740. struct cdp_tx_completion_ppdu *ppdu_desc;
  741. struct ieee80211_frame *ptr_wh;
  742. struct ieee80211_qoscntl *ptr_qoscntl;
  743. uint32_t mpdu_buf_len;
  744. uint8_t *ptr_hdr;
  745. uint16_t eth_type = qdf_htons(ether_type);
  746. ppdu_desc = (struct cdp_tx_completion_ppdu *)data;
  747. ptr_wh = &peer->tx_capture.tx_wifi_hdr;
  748. ptr_qoscntl = &peer->tx_capture.tx_qoscntl;
  749. /*
  750. * update framectrl only for first ppdu_id
  751. * rest of mpdu will have same frame ctrl
  752. * mac address and duration
  753. */
  754. if (ppdu_desc->ppdu_id != peer->tx_capture.tx_wifi_ppdu_id) {
  755. ptr_wh->i_fc[1] = (ppdu_desc->frame_ctrl & 0xFF00) >> 8;
  756. ptr_wh->i_fc[0] = (ppdu_desc->frame_ctrl & 0xFF);
  757. ptr_wh->i_dur[1] = (ppdu_desc->tx_duration & 0xFF00) >> 8;
  758. ptr_wh->i_dur[0] = (ppdu_desc->tx_duration & 0xFF);
  759. ptr_qoscntl->i_qos[1] = (ppdu_desc->user[0].qos_ctrl &
  760. 0xFF00) >> 8;
  761. ptr_qoscntl->i_qos[0] = (ppdu_desc->user[0].qos_ctrl & 0xFF);
  762. /* Update Addr 3 (SA) with SA derived from ether packet */
  763. qdf_mem_copy(ptr_wh->i_addr3, src_addr, QDF_MAC_ADDR_SIZE);
  764. peer->tx_capture.tx_wifi_ppdu_id = ppdu_desc->ppdu_id;
  765. }
  766. mpdu_buf_len = sizeof(struct ieee80211_frame) + LLC_SNAP_HDR_LEN;
  767. if (qdf_likely(ppdu_desc->user[0].tid != DP_NON_QOS_TID))
  768. mpdu_buf_len += sizeof(struct ieee80211_qoscntl);
  769. nbuf->protocol = qdf_htons(ETH_P_802_2);
  770. /* update ieee80211_frame header */
  771. if (!qdf_nbuf_push_head(nbuf, mpdu_buf_len)) {
  772. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  773. FL("No headroom"));
  774. return QDF_STATUS_E_NOMEM;
  775. }
  776. ptr_hdr = (void *)qdf_nbuf_data(nbuf);
  777. qdf_mem_copy(ptr_hdr, ptr_wh, sizeof(struct ieee80211_frame));
  778. ptr_hdr = ptr_hdr + (sizeof(struct ieee80211_frame));
  779. /* update qoscntl header */
  780. if (qdf_likely(ppdu_desc->user[0].tid != DP_NON_QOS_TID)) {
  781. qdf_mem_copy(ptr_hdr, ptr_qoscntl,
  782. sizeof(struct ieee80211_qoscntl));
  783. ptr_hdr = ptr_hdr + sizeof(struct ieee80211_qoscntl);
  784. }
  785. /* update LLC */
  786. *ptr_hdr = LLC_SNAP_LSAP;
  787. *(ptr_hdr + 1) = LLC_SNAP_LSAP;
  788. *(ptr_hdr + 2) = LLC_UI;
  789. *(ptr_hdr + 3) = 0x00;
  790. *(ptr_hdr + 4) = 0x00;
  791. *(ptr_hdr + 5) = 0x00;
  792. *(ptr_hdr + 6) = (eth_type & 0xFF00) >> 8;
  793. *(ptr_hdr + 7) = (eth_type & 0xFF);
  794. qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - mpdu_buf_len);
  795. return 0;
  796. }
  797. /**
  798. * dp_tx_mon_restitch_mpdu(): Function to restitch msdu to mpdu
  799. * @pdev: dp_pdev
  800. * @peer: dp_peer
  801. * @head_msdu: head msdu queue
  802. *
  803. * return: status
  804. */
  805. static uint32_t
  806. dp_tx_mon_restitch_mpdu(struct dp_pdev *pdev, struct dp_peer *peer,
  807. struct cdp_tx_completion_ppdu *ppdu_desc,
  808. qdf_nbuf_queue_t *head_msdu,
  809. qdf_nbuf_queue_t *mpdu_q)
  810. {
  811. qdf_nbuf_t curr_nbuf = NULL;
  812. qdf_nbuf_t first_nbuf = NULL;
  813. qdf_nbuf_t prev_nbuf = NULL;
  814. qdf_nbuf_t mpdu_nbuf = NULL;
  815. struct msdu_completion_info *ptr_msdu_info = NULL;
  816. uint8_t first_msdu = 0;
  817. uint8_t last_msdu = 0;
  818. uint32_t frag_list_sum_len = 0;
  819. uint8_t first_msdu_not_seen = 1;
  820. uint16_t ether_type = 0;
  821. qdf_ether_header_t *eh = NULL;
  822. curr_nbuf = qdf_nbuf_queue_remove(head_msdu);
  823. while (curr_nbuf) {
  824. ptr_msdu_info =
  825. (struct msdu_completion_info *)qdf_nbuf_data(curr_nbuf);
  826. first_msdu = ptr_msdu_info->first_msdu;
  827. last_msdu = ptr_msdu_info->last_msdu;
  828. eh = (qdf_ether_header_t *)(curr_nbuf->data +
  829. sizeof(struct msdu_completion_info));
  830. ether_type = eh->ether_type;
  831. /* pull msdu_completion_info added in pre header */
  832. qdf_nbuf_pull_head(curr_nbuf,
  833. sizeof(struct msdu_completion_info));
  834. if (first_msdu && first_msdu_not_seen) {
  835. first_nbuf = curr_nbuf;
  836. frag_list_sum_len = 0;
  837. first_msdu_not_seen = 0;
  838. /* pull ethernet header from first MSDU alone */
  839. qdf_nbuf_pull_head(curr_nbuf,
  840. sizeof(qdf_ether_header_t));
  841. mpdu_nbuf = qdf_nbuf_alloc(pdev->soc->osdev,
  842. MAX_MONITOR_HEADER,
  843. MAX_MONITOR_HEADER,
  844. 4, FALSE);
  845. if (!mpdu_nbuf) {
  846. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  847. QDF_TRACE_LEVEL_FATAL,
  848. "MPDU head allocation failed !!!");
  849. goto free_ppdu_desc_mpdu_q;
  850. }
  851. dp_tx_update_80211_hdr(pdev, peer,
  852. ppdu_desc, mpdu_nbuf,
  853. ether_type, eh->ether_shost);
  854. /* update first buffer to previous buffer */
  855. prev_nbuf = curr_nbuf;
  856. } else if (first_msdu && !first_msdu_not_seen) {
  857. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  858. QDF_TRACE_LEVEL_FATAL,
  859. "!!!!! NO LAST MSDU\n");
  860. /*
  861. * no last msdu in a mpdu
  862. * handle this case
  863. */
  864. qdf_nbuf_free(curr_nbuf);
  865. /*
  866. * No last msdu found because WBM comes out
  867. * of order, free the pkt
  868. */
  869. goto free_ppdu_desc_mpdu_q;
  870. } else if (!first_msdu && first_msdu_not_seen) {
  871. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  872. QDF_TRACE_LEVEL_FATAL,
  873. "!!!!! NO FIRST MSDU\n");
  874. /*
  875. * no first msdu in a mpdu
  876. * handle this case
  877. */
  878. qdf_nbuf_free(curr_nbuf);
  879. /*
  880. * no first msdu found beacuse WBM comes out
  881. * of order, free the pkt
  882. */
  883. goto free_ppdu_desc_mpdu_q;
  884. } else {
  885. /* update current buffer to previous buffer next */
  886. prev_nbuf->next = curr_nbuf;
  887. /* move the previous buffer to next buffer */
  888. prev_nbuf = prev_nbuf->next;
  889. }
  890. frag_list_sum_len += qdf_nbuf_len(curr_nbuf);
  891. if (last_msdu) {
  892. /*
  893. * first nbuf will hold list of msdu
  894. * stored in prev_nbuf
  895. */
  896. qdf_nbuf_append_ext_list(mpdu_nbuf,
  897. first_nbuf,
  898. frag_list_sum_len);
  899. /* add mpdu to mpdu queue */
  900. qdf_nbuf_queue_add(mpdu_q, mpdu_nbuf);
  901. first_nbuf = NULL;
  902. mpdu_nbuf = NULL;
  903. /* next msdu will start with first msdu */
  904. first_msdu_not_seen = 1;
  905. goto check_for_next_msdu;
  906. }
  907. /* get next msdu from the head_msdu */
  908. curr_nbuf = qdf_nbuf_queue_remove(head_msdu);
  909. if (!curr_nbuf) {
  910. /* msdu missed in list */
  911. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  912. QDF_TRACE_LEVEL_FATAL,
  913. "!!!! WAITING for msdu but list empty !!!!");
  914. }
  915. continue;
  916. check_for_next_msdu:
  917. if (qdf_nbuf_is_queue_empty(head_msdu))
  918. return 0;
  919. curr_nbuf = qdf_nbuf_queue_remove(head_msdu);
  920. }
  921. return 0;
  922. free_ppdu_desc_mpdu_q:
  923. /* free already chained msdu pkt */
  924. while (first_nbuf) {
  925. curr_nbuf = first_nbuf;
  926. first_nbuf = first_nbuf->next;
  927. qdf_nbuf_free(curr_nbuf);
  928. }
  929. /* free allocated mpdu hdr */
  930. if (mpdu_nbuf)
  931. qdf_nbuf_free(mpdu_nbuf);
  932. /* free queued remaining msdu pkt per ppdu */
  933. qdf_nbuf_queue_free(head_msdu);
  934. /* free queued mpdu per ppdu */
  935. qdf_nbuf_queue_free(mpdu_q);
  936. return 0;
  937. }
  938. /**
  939. * dp_tx_msdu_dequeue(): Function to dequeue msdu from peer based tid
  940. * @peer: dp_peer
  941. * @ppdu_id: ppdu_id
  942. * @tid: tid
  943. * @num_msdu: number of msdu
  944. * @head: head queue
  945. * @start_tsf: start tsf from ppdu_desc
  946. * @end_tsf: end tsf from ppdu_desc
  947. *
  948. * return: status
  949. */
  950. static
  951. uint32_t dp_tx_msdu_dequeue(struct dp_peer *peer, uint32_t ppdu_id,
  952. uint16_t tid, uint32_t num_msdu,
  953. qdf_nbuf_queue_t *head,
  954. qdf_nbuf_queue_t *head_xretries,
  955. uint32_t start_tsf, uint32_t end_tsf)
  956. {
  957. struct dp_tx_tid *tx_tid = NULL;
  958. uint32_t msdu_ppdu_id;
  959. qdf_nbuf_t curr_msdu = NULL;
  960. qdf_nbuf_t prev_msdu = NULL;
  961. struct msdu_completion_info *ptr_msdu_info = NULL;
  962. uint32_t wbm_tsf;
  963. uint32_t matched = 0;
  964. if (qdf_unlikely(!peer))
  965. return 0;
  966. /* Non-QOS frames are being indicated with TID 0
  967. * in WBM completion path, an hence we should
  968. * TID 0 to reap MSDUs from completion path
  969. */
  970. if (qdf_unlikely(tid == DP_NON_QOS_TID))
  971. tid = 0;
  972. tx_tid = &peer->tx_capture.tx_tid[tid];
  973. if (qdf_unlikely(!tx_tid))
  974. return 0;
  975. if (qdf_nbuf_is_queue_empty(&tx_tid->msdu_comp_q))
  976. return 0;
  977. /* lock here */
  978. qdf_spin_lock_bh(&tx_tid->tid_lock);
  979. curr_msdu = qdf_nbuf_queue_first(&tx_tid->msdu_comp_q);
  980. while (curr_msdu) {
  981. if (qdf_nbuf_queue_len(head) == num_msdu) {
  982. matched = 1;
  983. break;
  984. }
  985. ptr_msdu_info =
  986. (struct msdu_completion_info *)qdf_nbuf_data(curr_msdu);
  987. msdu_ppdu_id = ptr_msdu_info->ppdu_id;
  988. wbm_tsf = ptr_msdu_info->tsf;
  989. if ((ptr_msdu_info->status == HAL_TX_TQM_RR_REM_CMD_TX) ||
  990. (ptr_msdu_info->status == HAL_TX_TQM_RR_REM_CMD_AGED)) {
  991. /* Frames removed due to excessive retries */
  992. qdf_nbuf_queue_remove(&tx_tid->msdu_comp_q);
  993. qdf_nbuf_queue_add(head_xretries, curr_msdu);
  994. curr_msdu = qdf_nbuf_queue_first(
  995. &tx_tid->msdu_comp_q);
  996. prev_msdu = NULL;
  997. continue;
  998. }
  999. if (wbm_tsf > end_tsf) {
  1000. /* PPDU being matched is older than MSDU at head of
  1001. * completion queue. Return matched=1 to skip PPDU
  1002. */
  1003. matched = 1;
  1004. break;
  1005. }
  1006. if (wbm_tsf && (wbm_tsf < start_tsf)) {
  1007. /* remove the aged packet */
  1008. qdf_nbuf_queue_remove(&tx_tid->msdu_comp_q);
  1009. qdf_nbuf_free(curr_msdu);
  1010. curr_msdu = qdf_nbuf_queue_first(
  1011. &tx_tid->msdu_comp_q);
  1012. prev_msdu = NULL;
  1013. continue;
  1014. }
  1015. if (msdu_ppdu_id == ppdu_id) {
  1016. if (qdf_likely(!prev_msdu)) {
  1017. /* remove head */
  1018. qdf_nbuf_queue_remove(&tx_tid->msdu_comp_q);
  1019. /* add msdu to head queue */
  1020. qdf_nbuf_queue_add(head, curr_msdu);
  1021. /* get next msdu from msdu_comp_q */
  1022. curr_msdu = qdf_nbuf_queue_first(
  1023. &tx_tid->msdu_comp_q);
  1024. continue;
  1025. } else {
  1026. /* update prev_msdu next to current msdu next */
  1027. prev_msdu->next = curr_msdu->next;
  1028. /* set current msdu next as NULL */
  1029. curr_msdu->next = NULL;
  1030. /* decrement length */
  1031. ((qdf_nbuf_queue_t *)(
  1032. &tx_tid->msdu_comp_q))->qlen--;
  1033. /* add msdu to head queue */
  1034. qdf_nbuf_queue_add(head, curr_msdu);
  1035. /* set previous msdu to current msdu */
  1036. curr_msdu = prev_msdu->next;
  1037. continue;
  1038. }
  1039. }
  1040. prev_msdu = curr_msdu;
  1041. curr_msdu = prev_msdu->next;
  1042. }
  1043. qdf_spin_unlock_bh(&tx_tid->tid_lock);
  1044. return matched;
  1045. }
  1046. /**
  1047. * get_mpdu_clone_from_next_ppdu(): Function to clone missing mpdu from
  1048. * next ppdu
  1049. * @nbuf_ppdu_desc_list: nbuf list
  1050. * @ppdu_desc_cnt: ppdu_desc_cnt
  1051. * @missed_seq_no:
  1052. * @ppdu_id: ppdu_id
  1053. * @mpdu_info: cdp_tx_indication_mpdu_info
  1054. *
  1055. * return: void
  1056. */
  1057. static
  1058. qdf_nbuf_t get_mpdu_clone_from_next_ppdu(qdf_nbuf_t nbuf_ppdu_desc_list[],
  1059. uint32_t ppdu_desc_cnt,
  1060. uint16_t missed_seq_no,
  1061. uint16_t peer_id, uint32_t ppdu_id)
  1062. {
  1063. uint32_t i = 0;
  1064. uint32_t found = 0;
  1065. uint32_t seq_no = 0;
  1066. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  1067. qdf_nbuf_t mpdu = NULL;
  1068. for (i = 1; i < ppdu_desc_cnt; i++) {
  1069. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1070. qdf_nbuf_data(nbuf_ppdu_desc_list[i]);
  1071. /* check if seq number is between the range */
  1072. if ((peer_id == ppdu_desc->user[0].peer_id) &&
  1073. ((missed_seq_no >= ppdu_desc->user[0].start_seq) &&
  1074. (missed_seq_no <= ppdu_desc->user[0].last_enq_seq))) {
  1075. seq_no = ppdu_desc->user[0].start_seq;
  1076. if (SEQ_BIT(ppdu_desc->user[0].failed_bitmap,
  1077. (missed_seq_no - seq_no))) {
  1078. found = 1;
  1079. break;
  1080. }
  1081. }
  1082. }
  1083. if (found == 0) {
  1084. /* mpdu not found in sched cmd id */
  1085. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_DEBUG,
  1086. "%s: missed seq_no[%d] ppdu_id[%d] [%d] not found!!!",
  1087. __func__, missed_seq_no, ppdu_id, ppdu_desc_cnt);
  1088. return NULL;
  1089. }
  1090. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_DEBUG,
  1091. "%s: seq_no[%d] missed ppdu_id[%d] m[%d] found in ppdu_id[%d]!!",
  1092. __func__,
  1093. missed_seq_no, ppdu_id,
  1094. (missed_seq_no - seq_no), ppdu_desc->ppdu_id);
  1095. mpdu = qdf_nbuf_queue_first(&ppdu_desc->mpdu_q);
  1096. if (!mpdu) {
  1097. /* bitmap shows it found sequence number, but
  1098. * MPDU not found in PPDU
  1099. */
  1100. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE, QDF_TRACE_LEVEL_ERROR,
  1101. "%s: missed seq_no[%d] ppdu_id[%d] [%d] found but queue empty!!!",
  1102. __func__, missed_seq_no, ppdu_id, ppdu_desc_cnt);
  1103. return NULL;
  1104. }
  1105. for (i = 0; i < (missed_seq_no - seq_no); i++) {
  1106. mpdu = mpdu->next;
  1107. if (!mpdu) {
  1108. /*
  1109. * bitmap shows it found sequence number,
  1110. * but queue empty, do we need to allocate
  1111. * skb and send instead of NULL ?
  1112. * add counter here:
  1113. */
  1114. return NULL;
  1115. }
  1116. }
  1117. return qdf_nbuf_copy_expand(mpdu, MAX_MONITOR_HEADER, 0);
  1118. }
  1119. /**
  1120. * dp_tx_update_user_mpdu_info(): Function to update mpdu info
  1121. * from ppdu_desc
  1122. * @ppdu_id: ppdu_id
  1123. * @mpdu_info: cdp_tx_indication_mpdu_info
  1124. * @user: cdp_tx_completion_ppdu_user
  1125. *
  1126. * return: void
  1127. */
  1128. static void
  1129. dp_tx_update_user_mpdu_info(uint32_t ppdu_id,
  1130. struct cdp_tx_indication_mpdu_info *mpdu_info,
  1131. struct cdp_tx_completion_ppdu_user *user)
  1132. {
  1133. mpdu_info->ppdu_id = ppdu_id;
  1134. mpdu_info->frame_ctrl = user->frame_ctrl;
  1135. mpdu_info->qos_ctrl = user->qos_ctrl;
  1136. mpdu_info->tid = user->tid;
  1137. mpdu_info->ltf_size = user->ltf_size;
  1138. mpdu_info->he_re = user->he_re;
  1139. mpdu_info->txbf = user->txbf;
  1140. mpdu_info->bw = user->bw;
  1141. mpdu_info->nss = user->nss;
  1142. mpdu_info->mcs = user->mcs;
  1143. mpdu_info->preamble = user->preamble;
  1144. mpdu_info->gi = user->gi;
  1145. mpdu_info->ack_rssi = user->ack_rssi[0];
  1146. mpdu_info->tx_rate = user->tx_rate;
  1147. mpdu_info->ldpc = user->ldpc;
  1148. mpdu_info->ppdu_cookie = user->ppdu_cookie;
  1149. mpdu_info->long_retries = user->long_retries;
  1150. mpdu_info->short_retries = user->short_retries;
  1151. mpdu_info->completion_status = user->completion_status;
  1152. qdf_mem_copy(mpdu_info->mac_address, user->mac_addr, 6);
  1153. mpdu_info->ba_start_seq = user->ba_seq_no;
  1154. qdf_mem_copy(mpdu_info->ba_bitmap, user->ba_bitmap,
  1155. CDP_BA_256_BIT_MAP_SIZE_DWORDS * sizeof(uint32_t));
  1156. }
  1157. static inline
  1158. void dp_tx_update_sequence_number(qdf_nbuf_t nbuf, uint32_t seq_no)
  1159. {
  1160. struct ieee80211_frame *ptr_wh = NULL;
  1161. uint16_t wh_seq = 0;
  1162. if (!nbuf)
  1163. return;
  1164. /* update sequence number in frame header */
  1165. ptr_wh = (struct ieee80211_frame *)qdf_nbuf_data(nbuf);
  1166. wh_seq = (seq_no & 0xFFF) << 4;
  1167. qdf_mem_copy(ptr_wh->i_seq, &wh_seq, sizeof(uint16_t));
  1168. }
  1169. static inline
  1170. void dp_update_frame_ctrl_from_frame_type(void *desc)
  1171. {
  1172. struct cdp_tx_completion_ppdu *ppdu_desc = desc;
  1173. /* frame control is not set properly, sometimes it is zero */
  1174. switch (ppdu_desc->htt_frame_type) {
  1175. case HTT_STATS_FTYPE_SGEN_NDPA:
  1176. case HTT_STATS_FTYPE_SGEN_NDP:
  1177. case HTT_STATS_FTYPE_SGEN_AX_NDPA:
  1178. case HTT_STATS_FTYPE_SGEN_AX_NDP:
  1179. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_NDPA |
  1180. IEEE80211_FC0_TYPE_CTL);
  1181. break;
  1182. case HTT_STATS_FTYPE_SGEN_BRP:
  1183. case HTT_STATS_FTYPE_SGEN_MU_BRP:
  1184. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_BRPOLL |
  1185. IEEE80211_FC0_TYPE_CTL);
  1186. break;
  1187. case HTT_STATS_FTYPE_SGEN_RTS:
  1188. case HTT_STATS_FTYPE_SGEN_MU_RTS:
  1189. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_RTS |
  1190. IEEE80211_FC0_TYPE_CTL);
  1191. break;
  1192. case HTT_STATS_FTYPE_SGEN_CTS:
  1193. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_CTS |
  1194. IEEE80211_FC0_TYPE_CTL);
  1195. break;
  1196. case HTT_STATS_FTYPE_SGEN_CFEND:
  1197. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_CF_END |
  1198. IEEE80211_FC0_TYPE_CTL);
  1199. break;
  1200. case HTT_STATS_FTYPE_SGEN_MU_TRIG:
  1201. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_TRIGGER |
  1202. IEEE80211_FC0_TYPE_CTL);
  1203. break;
  1204. case HTT_STATS_FTYPE_SGEN_BAR:
  1205. case HTT_STATS_FTYPE_SGEN_MU_BAR:
  1206. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_BAR |
  1207. IEEE80211_FC0_TYPE_CTL);
  1208. break;
  1209. }
  1210. }
  1211. /**
  1212. * dp_send_dummy_mpdu_info_to_stack(): send dummy payload to stack
  1213. * to upper layer if complete
  1214. * @pdev: DP pdev handle
  1215. * @desc: cdp tx completion ppdu desc
  1216. *
  1217. * return: status
  1218. */
  1219. static inline
  1220. QDF_STATUS dp_send_dummy_mpdu_info_to_stack(struct dp_pdev *pdev,
  1221. void *desc)
  1222. {
  1223. struct dp_peer *peer;
  1224. struct cdp_tx_completion_ppdu *ppdu_desc = desc;
  1225. struct cdp_tx_completion_ppdu_user *user = &ppdu_desc->user[0];
  1226. struct ieee80211_ctlframe_addr2 *wh_min;
  1227. uint16_t frame_ctrl_le, duration_le;
  1228. struct cdp_tx_indication_info tx_capture_info;
  1229. struct cdp_tx_indication_mpdu_info *mpdu_info;
  1230. uint8_t type, subtype;
  1231. qdf_mem_set(&tx_capture_info,
  1232. sizeof(struct cdp_tx_indication_info),
  1233. 0);
  1234. tx_capture_info.mpdu_nbuf =
  1235. qdf_nbuf_alloc(pdev->soc->osdev,
  1236. MAX_MONITOR_HEADER + MAX_DUMMY_FRM_BODY,
  1237. MAX_MONITOR_HEADER,
  1238. 4, FALSE);
  1239. if (!tx_capture_info.mpdu_nbuf)
  1240. return QDF_STATUS_E_ABORTED;
  1241. mpdu_info = &tx_capture_info.mpdu_info;
  1242. mpdu_info->resp_type = ppdu_desc->resp_type;
  1243. mpdu_info->mprot_type = ppdu_desc->mprot_type;
  1244. mpdu_info->rts_success = ppdu_desc->rts_success;
  1245. mpdu_info->rts_failure = ppdu_desc->rts_failure;
  1246. /* update cdp_tx_indication_mpdu_info */
  1247. dp_tx_update_user_mpdu_info(ppdu_desc->bar_ppdu_id,
  1248. &tx_capture_info.mpdu_info,
  1249. &ppdu_desc->user[0]);
  1250. tx_capture_info.ppdu_desc = ppdu_desc;
  1251. mpdu_info->ppdu_id = ppdu_desc->ppdu_id;
  1252. mpdu_info->channel_num = pdev->operating_channel;
  1253. mpdu_info->channel = ppdu_desc->channel;
  1254. mpdu_info->frame_type = ppdu_desc->frame_type;
  1255. mpdu_info->ppdu_start_timestamp = ppdu_desc->ppdu_start_timestamp;
  1256. mpdu_info->ppdu_end_timestamp = ppdu_desc->ppdu_end_timestamp;
  1257. mpdu_info->tx_duration = ppdu_desc->tx_duration;
  1258. mpdu_info->seq_no = user->start_seq;
  1259. qdf_mem_copy(mpdu_info->mac_address, user->mac_addr, QDF_MAC_ADDR_SIZE);
  1260. mpdu_info->ba_start_seq = user->ba_seq_no;
  1261. qdf_mem_copy(mpdu_info->ba_bitmap, user->ba_bitmap,
  1262. CDP_BA_256_BIT_MAP_SIZE_DWORDS * sizeof(uint32_t));
  1263. mpdu_info->frame_ctrl = ppdu_desc->frame_ctrl;
  1264. type = (ppdu_desc->frame_ctrl & IEEE80211_FC0_TYPE_MASK);
  1265. subtype = (ppdu_desc->frame_ctrl & IEEE80211_FC0_SUBTYPE_MASK);
  1266. if (type == IEEE80211_FC0_TYPE_CTL &&
  1267. subtype == IEEE80211_FC0_SUBTYPE_BAR) {
  1268. mpdu_info->frame_ctrl = (IEEE80211_FC0_SUBTYPE_BAR |
  1269. IEEE80211_FC0_TYPE_CTL);
  1270. mpdu_info->ppdu_id = ppdu_desc->bar_ppdu_id;
  1271. mpdu_info->ppdu_start_timestamp =
  1272. ppdu_desc->bar_ppdu_start_timestamp;
  1273. mpdu_info->ppdu_end_timestamp =
  1274. ppdu_desc->bar_ppdu_end_timestamp;
  1275. mpdu_info->tx_duration = ppdu_desc->bar_tx_duration;
  1276. }
  1277. wh_min = (struct ieee80211_ctlframe_addr2 *)
  1278. qdf_nbuf_data(
  1279. tx_capture_info.mpdu_nbuf);
  1280. qdf_mem_zero(wh_min, MAX_DUMMY_FRM_BODY);
  1281. frame_ctrl_le =
  1282. qdf_cpu_to_le16(mpdu_info->frame_ctrl);
  1283. duration_le =
  1284. qdf_cpu_to_le16(ppdu_desc->bar_tx_duration);
  1285. wh_min->i_fc[1] = (frame_ctrl_le & 0xFF00) >> 8;
  1286. wh_min->i_fc[0] = (frame_ctrl_le & 0xFF);
  1287. wh_min->i_aidordur[1] = (duration_le & 0xFF00) >> 8;
  1288. wh_min->i_aidordur[0] = (duration_le & 0xFF);
  1289. qdf_mem_copy(wh_min->i_addr1,
  1290. mpdu_info->mac_address,
  1291. QDF_MAC_ADDR_SIZE);
  1292. if (subtype == IEEE80211_FC0_SUBTYPE_ACK)
  1293. qdf_nbuf_set_pktlen(tx_capture_info.mpdu_nbuf,
  1294. sizeof(struct ieee80211_frame_min_one));
  1295. else {
  1296. peer = dp_peer_find_by_id(pdev->soc, user->peer_id);
  1297. if (peer) {
  1298. struct dp_vdev *vdev = NULL;
  1299. vdev = peer->vdev;
  1300. if (vdev)
  1301. qdf_mem_copy(wh_min->i_addr2,
  1302. vdev->mac_addr.raw,
  1303. QDF_MAC_ADDR_SIZE);
  1304. dp_peer_unref_del_find_by_id(peer);
  1305. }
  1306. qdf_nbuf_set_pktlen(tx_capture_info.mpdu_nbuf, sizeof(*wh_min));
  1307. }
  1308. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1309. QDF_TRACE_LEVEL_DEBUG,
  1310. "HTT_FTYPE[%d] frm(0x%08x): fc %x %x, dur 0x%x%x\n",
  1311. ppdu_desc->htt_frame_type, mpdu_info->ppdu_id,
  1312. wh_min->i_fc[1], wh_min->i_fc[0],
  1313. wh_min->i_aidordur[1], wh_min->i_aidordur[0]);
  1314. /*
  1315. * send MPDU to osif layer
  1316. */
  1317. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  1318. &tx_capture_info, HTT_INVALID_PEER,
  1319. WDI_NO_VAL, pdev->pdev_id);
  1320. if (tx_capture_info.mpdu_nbuf)
  1321. qdf_nbuf_free(tx_capture_info.mpdu_nbuf);
  1322. return QDF_STATUS_SUCCESS;
  1323. }
  1324. /**
  1325. * dp_send_dummy_rts_cts_frame(): send dummy rts and cts frame out
  1326. * to upper layer if complete
  1327. * @pdev: DP pdev handle
  1328. * @cur_ppdu_desc: cdp tx completion ppdu desc
  1329. *
  1330. * return: void
  1331. */
  1332. static
  1333. void dp_send_dummy_rts_cts_frame(struct dp_pdev *pdev,
  1334. struct cdp_tx_completion_ppdu *cur_ppdu_desc)
  1335. {
  1336. struct cdp_tx_completion_ppdu *ppdu_desc;
  1337. struct dp_pdev_tx_capture *ptr_tx_cap;
  1338. struct dp_peer *peer;
  1339. uint8_t rts_send;
  1340. rts_send = 0;
  1341. ptr_tx_cap = &pdev->tx_capture;
  1342. ppdu_desc = &ptr_tx_cap->dummy_ppdu_desc;
  1343. ppdu_desc->channel = cur_ppdu_desc->channel;
  1344. ppdu_desc->num_mpdu = 1;
  1345. ppdu_desc->num_msdu = 1;
  1346. ppdu_desc->user[0].ppdu_type = HTT_PPDU_STATS_PPDU_TYPE_SU;
  1347. ppdu_desc->bar_num_users = 0;
  1348. ppdu_desc->num_users = 1;
  1349. if (cur_ppdu_desc->mprot_type == SEND_WIFIRTS_LEGACY_E ||
  1350. cur_ppdu_desc->mprot_type == SEND_WIFIRTS_11AC_DYNAMIC_BW_E ||
  1351. cur_ppdu_desc->mprot_type == SEND_WIFIRTS_11AC_STATIC_BW_E) {
  1352. rts_send = 1;
  1353. /*
  1354. * send dummy RTS frame followed by CTS
  1355. * update frame_ctrl and htt_frame_type
  1356. */
  1357. ppdu_desc->htt_frame_type = HTT_STATS_FTYPE_SGEN_RTS;
  1358. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  1359. ppdu_desc->ppdu_start_timestamp =
  1360. cur_ppdu_desc->ppdu_start_timestamp;
  1361. ppdu_desc->ppdu_end_timestamp =
  1362. cur_ppdu_desc->ppdu_end_timestamp;
  1363. ppdu_desc->user[0].peer_id = cur_ppdu_desc->user[0].peer_id;
  1364. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_RTS |
  1365. IEEE80211_FC0_TYPE_CTL);
  1366. qdf_mem_copy(&ppdu_desc->user[0].mac_addr,
  1367. &cur_ppdu_desc->user[0].mac_addr,
  1368. QDF_MAC_ADDR_SIZE);
  1369. dp_send_dummy_mpdu_info_to_stack(pdev, ppdu_desc);
  1370. }
  1371. if ((rts_send && cur_ppdu_desc->rts_success) ||
  1372. cur_ppdu_desc->mprot_type == SEND_WIFICTS2SELF_E) {
  1373. /* send dummy CTS frame */
  1374. ppdu_desc->htt_frame_type = HTT_STATS_FTYPE_SGEN_CTS;
  1375. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  1376. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_CTS |
  1377. IEEE80211_FC0_TYPE_CTL);
  1378. ppdu_desc->ppdu_start_timestamp =
  1379. cur_ppdu_desc->ppdu_start_timestamp;
  1380. ppdu_desc->ppdu_end_timestamp =
  1381. cur_ppdu_desc->ppdu_end_timestamp;
  1382. ppdu_desc->user[0].peer_id = cur_ppdu_desc->user[0].peer_id;
  1383. peer = dp_peer_find_by_id(pdev->soc,
  1384. cur_ppdu_desc->user[0].peer_id);
  1385. if (peer) {
  1386. struct dp_vdev *vdev = NULL;
  1387. vdev = peer->vdev;
  1388. if (vdev)
  1389. qdf_mem_copy(&ppdu_desc->user[0].mac_addr,
  1390. vdev->mac_addr.raw,
  1391. QDF_MAC_ADDR_SIZE);
  1392. dp_peer_unref_del_find_by_id(peer);
  1393. }
  1394. dp_send_dummy_mpdu_info_to_stack(pdev, ppdu_desc);
  1395. }
  1396. }
  1397. static void dp_gen_ack_rx_frame(struct dp_pdev *pdev,
  1398. struct cdp_tx_indication_info *tx_capture_info)
  1399. {
  1400. struct cdp_tx_completion_ppdu *ppdu_desc;
  1401. struct dp_peer *peer;
  1402. struct dp_pdev_tx_capture *ptr_tx_cap;
  1403. ptr_tx_cap = &pdev->tx_capture;
  1404. ppdu_desc = &ptr_tx_cap->dummy_ppdu_desc;
  1405. ppdu_desc->channel = tx_capture_info->ppdu_desc->channel;
  1406. ppdu_desc->num_mpdu = 1;
  1407. ppdu_desc->num_msdu = 1;
  1408. ppdu_desc->user[0].ppdu_type = HTT_PPDU_STATS_PPDU_TYPE_SU;
  1409. ppdu_desc->bar_num_users = 0;
  1410. ppdu_desc->num_users = 1;
  1411. ppdu_desc->frame_type = CDP_PPDU_FTYPE_CTRL;
  1412. ppdu_desc->frame_ctrl = (IEEE80211_FC0_SUBTYPE_ACK |
  1413. IEEE80211_FC0_TYPE_CTL);
  1414. ppdu_desc->ppdu_start_timestamp =
  1415. tx_capture_info->ppdu_desc->ppdu_start_timestamp;
  1416. ppdu_desc->ppdu_end_timestamp =
  1417. tx_capture_info->ppdu_desc->ppdu_end_timestamp;
  1418. ppdu_desc->user[0].peer_id =
  1419. tx_capture_info->ppdu_desc->user[0].peer_id;
  1420. peer = dp_peer_find_by_id(pdev->soc,
  1421. tx_capture_info->ppdu_desc->user[0].peer_id);
  1422. if (peer) {
  1423. struct dp_vdev *vdev = NULL;
  1424. vdev = peer->vdev;
  1425. if (vdev)
  1426. qdf_mem_copy(&ppdu_desc->user[0].mac_addr,
  1427. vdev->mac_addr.raw,
  1428. QDF_MAC_ADDR_SIZE);
  1429. dp_peer_unref_del_find_by_id(peer);
  1430. }
  1431. dp_send_dummy_mpdu_info_to_stack(pdev, ppdu_desc);
  1432. }
  1433. /**
  1434. * dp_send_data_to_stack(): Function to deliver mpdu info to stack
  1435. * to upper layer
  1436. * @pdev: DP pdev handle
  1437. * @nbuf_ppdu_desc_list: ppdu_desc_list per sched cmd id
  1438. * @ppdu_desc_cnt: number of ppdu_desc_cnt
  1439. *
  1440. * return: status
  1441. */
  1442. static
  1443. void dp_send_data_to_stack(struct dp_pdev *pdev,
  1444. struct cdp_tx_completion_ppdu *ppdu_desc)
  1445. {
  1446. struct cdp_tx_indication_info tx_capture_info;
  1447. struct cdp_tx_indication_mpdu_info *mpdu_info;
  1448. int i;
  1449. uint32_t seq_no, start_seq;
  1450. uint32_t ppdu_id = ppdu_desc->ppdu_id;
  1451. qdf_mem_set(&tx_capture_info,
  1452. sizeof(struct cdp_tx_indication_info),
  1453. 0);
  1454. mpdu_info = &tx_capture_info.mpdu_info;
  1455. mpdu_info->channel = ppdu_desc->channel;
  1456. mpdu_info->frame_type = ppdu_desc->frame_type;
  1457. mpdu_info->ppdu_start_timestamp =
  1458. ppdu_desc->ppdu_start_timestamp;
  1459. mpdu_info->ppdu_end_timestamp =
  1460. ppdu_desc->ppdu_end_timestamp;
  1461. mpdu_info->tx_duration = ppdu_desc->tx_duration;
  1462. mpdu_info->num_msdu = ppdu_desc->num_msdu;
  1463. mpdu_info->resp_type = ppdu_desc->resp_type;
  1464. mpdu_info->mprot_type = ppdu_desc->mprot_type;
  1465. mpdu_info->rts_success = ppdu_desc->rts_success;
  1466. mpdu_info->rts_failure = ppdu_desc->rts_failure;
  1467. /* update cdp_tx_indication_mpdu_info */
  1468. dp_tx_update_user_mpdu_info(ppdu_id,
  1469. &tx_capture_info.mpdu_info,
  1470. &ppdu_desc->user[0]);
  1471. tx_capture_info.ppdu_desc = ppdu_desc;
  1472. tx_capture_info.mpdu_info.channel_num =
  1473. pdev->operating_channel;
  1474. if (ppdu_desc->mprot_type)
  1475. dp_send_dummy_rts_cts_frame(pdev, ppdu_desc);
  1476. start_seq = ppdu_desc->user[0].start_seq;
  1477. for (i = 0; i < ppdu_desc->user[0].ba_size; i++) {
  1478. if (qdf_likely(ppdu_desc->user[0].tid !=
  1479. DP_NON_QOS_TID) &&
  1480. !(SEQ_BIT(ppdu_desc->user[0].enq_bitmap, i))) {
  1481. continue;
  1482. }
  1483. seq_no = start_seq + i;
  1484. if (!ppdu_desc->mpdus[i])
  1485. continue;
  1486. tx_capture_info.mpdu_nbuf = ppdu_desc->mpdus[i];
  1487. ppdu_desc->mpdus[i] = NULL;
  1488. mpdu_info->seq_no = seq_no;
  1489. dp_tx_update_sequence_number(tx_capture_info.mpdu_nbuf, seq_no);
  1490. /*
  1491. * send MPDU to osif layer
  1492. * do we need to update mpdu_info before tranmit
  1493. * get current mpdu_nbuf
  1494. */
  1495. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  1496. &tx_capture_info,
  1497. HTT_INVALID_PEER,
  1498. WDI_NO_VAL, pdev->pdev_id);
  1499. if (tx_capture_info.mpdu_nbuf)
  1500. qdf_nbuf_free(tx_capture_info.mpdu_nbuf);
  1501. }
  1502. if (ppdu_desc->resp_type == HTT_PPDU_STATS_ACK_EXPECTED_E &&
  1503. ppdu_desc->user[0].completion_status ==
  1504. HTT_PPDU_STATS_USER_STATUS_OK)
  1505. dp_gen_ack_rx_frame(pdev, &tx_capture_info);
  1506. }
  1507. static void
  1508. dp_tx_mon_proc_xretries(struct dp_pdev *pdev, struct dp_peer *peer,
  1509. uint16_t tid)
  1510. {
  1511. struct dp_tx_tid *tx_tid = &peer->tx_capture.tx_tid[tid];
  1512. struct cdp_tx_completion_ppdu *ppdu_desc;
  1513. struct cdp_tx_completion_ppdu *xretry_ppdu;
  1514. qdf_nbuf_t ppdu_nbuf;
  1515. qdf_nbuf_t mpdu_nbuf;
  1516. uint32_t mpdu_tried = 0;
  1517. int i;
  1518. uint32_t seq_no;
  1519. xretry_ppdu = &tx_tid->xretry_ppdu;
  1520. if (qdf_nbuf_is_queue_empty(&tx_tid->pending_ppdu_q)) {
  1521. qdf_nbuf_queue_free(&xretry_ppdu->mpdu_q);
  1522. return;
  1523. }
  1524. if (qdf_nbuf_is_queue_empty(&xretry_ppdu->mpdu_q))
  1525. return;
  1526. ppdu_nbuf = qdf_nbuf_queue_first(&tx_tid->pending_ppdu_q);
  1527. while (ppdu_nbuf) {
  1528. struct msdu_completion_info *ptr_msdu_info = NULL;
  1529. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1530. qdf_nbuf_data(ppdu_nbuf);
  1531. if (ppdu_desc->pending_retries) {
  1532. uint32_t start_seq = ppdu_desc->user[0].start_seq;
  1533. mpdu_tried = ppdu_desc->user[0].mpdu_tried_ucast +
  1534. ppdu_desc->user[0].mpdu_tried_mcast;
  1535. mpdu_nbuf = qdf_nbuf_queue_first(&xretry_ppdu->mpdu_q);
  1536. for (i = 0; (mpdu_tried > 0) && mpdu_nbuf; i++) {
  1537. if (!(SEQ_BIT(ppdu_desc->user[0].enq_bitmap,
  1538. i)))
  1539. continue;
  1540. mpdu_tried--;
  1541. /* missed seq number */
  1542. seq_no = start_seq + i;
  1543. if (SEQ_BIT(ppdu_desc->user[0].failed_bitmap, i))
  1544. continue;
  1545. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1546. QDF_TRACE_LEVEL_INFO,
  1547. "%s: fill seqno %d from xretries",
  1548. __func__, seq_no);
  1549. ptr_msdu_info = (struct msdu_completion_info *)
  1550. (qdf_nbuf_data(qdf_nbuf_get_ext_list(
  1551. mpdu_nbuf)) -
  1552. (sizeof(struct msdu_completion_info) +
  1553. sizeof(qdf_ether_header_t)));
  1554. ptr_msdu_info->transmit_cnt--;
  1555. SEQ_SEG(ppdu_desc->user[0].failed_bitmap, i) |=
  1556. SEQ_SEG_MSK(ppdu_desc->user[0].failed_bitmap[0],
  1557. i);
  1558. ppdu_desc->pending_retries--;
  1559. if (ptr_msdu_info->transmit_cnt == 0) {
  1560. ppdu_desc->mpdus[seq_no - start_seq] =
  1561. mpdu_nbuf;
  1562. qdf_nbuf_queue_remove(
  1563. &xretry_ppdu->mpdu_q);
  1564. mpdu_nbuf = qdf_nbuf_queue_first(
  1565. &xretry_ppdu->mpdu_q);
  1566. } else {
  1567. ppdu_desc->mpdus[seq_no - start_seq] =
  1568. qdf_nbuf_copy_expand(mpdu_nbuf,
  1569. MAX_MONITOR_HEADER,
  1570. 0);
  1571. mpdu_nbuf =
  1572. qdf_nbuf_queue_next(mpdu_nbuf);
  1573. }
  1574. }
  1575. }
  1576. if ((ppdu_desc->pending_retries == 0) && (ppdu_nbuf ==
  1577. qdf_nbuf_queue_first(&tx_tid->pending_ppdu_q))) {
  1578. qdf_nbuf_queue_remove(&tx_tid->pending_ppdu_q);
  1579. /* Deliver PPDU */
  1580. dp_send_data_to_stack(pdev, ppdu_desc);
  1581. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  1582. qdf_mem_free(ppdu_desc->mpdus);
  1583. ppdu_desc->mpdus = NULL;
  1584. qdf_nbuf_free(ppdu_nbuf);
  1585. ppdu_nbuf = qdf_nbuf_queue_first(
  1586. &tx_tid->pending_ppdu_q);
  1587. } else {
  1588. ppdu_nbuf = qdf_nbuf_queue_next(ppdu_nbuf);
  1589. }
  1590. }
  1591. qdf_nbuf_queue_free(&xretry_ppdu->mpdu_q);
  1592. }
  1593. #define MAX_PENDING_PPDUS 32
  1594. static void
  1595. dp_tx_mon_proc_pending_ppdus(struct dp_pdev *pdev, struct dp_tx_tid *tx_tid,
  1596. qdf_nbuf_t nbuf_ppdu_desc_list[], uint32_t
  1597. ppdu_desc_cnt, qdf_nbuf_queue_t *head_ppdu,
  1598. uint32_t peer_id)
  1599. {
  1600. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  1601. struct cdp_tx_completion_ppdu *cur_ppdu_desc = NULL;
  1602. qdf_nbuf_t pend_ppdu;
  1603. uint32_t ppdu_cnt;
  1604. uint32_t failed_seq;
  1605. uint32_t cur_index, cur_start_seq, cur_last_seq;
  1606. int i, k;
  1607. bool last_pend_ppdu = false;
  1608. qdf_nbuf_t tmp_nbuf;
  1609. pend_ppdu = qdf_nbuf_queue_first(&tx_tid->pending_ppdu_q);
  1610. if (!pend_ppdu) {
  1611. for (ppdu_cnt = 0; ppdu_cnt < ppdu_desc_cnt; ppdu_cnt++) {
  1612. if (!nbuf_ppdu_desc_list[ppdu_cnt])
  1613. continue;
  1614. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1615. qdf_nbuf_data(
  1616. nbuf_ppdu_desc_list[ppdu_cnt]);
  1617. if (!ppdu_desc || (peer_id !=
  1618. ppdu_desc->user[0].peer_id) || (tx_tid->tid !=
  1619. ppdu_desc->user[0].tid))
  1620. continue;
  1621. if ((ppdu_desc->pending_retries == 0) &&
  1622. qdf_nbuf_is_queue_empty(&tx_tid->pending_ppdu_q) &&
  1623. qdf_nbuf_is_queue_empty(head_ppdu)) {
  1624. dp_send_data_to_stack(pdev, ppdu_desc);
  1625. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  1626. qdf_mem_free(ppdu_desc->mpdus);
  1627. ppdu_desc->mpdus = NULL;
  1628. tmp_nbuf = nbuf_ppdu_desc_list[ppdu_cnt];
  1629. nbuf_ppdu_desc_list[ppdu_cnt] = NULL;
  1630. qdf_nbuf_free(tmp_nbuf);
  1631. } else {
  1632. qdf_nbuf_queue_add(head_ppdu,
  1633. nbuf_ppdu_desc_list[ppdu_cnt]);
  1634. nbuf_ppdu_desc_list[ppdu_cnt] = NULL;
  1635. }
  1636. }
  1637. return;
  1638. }
  1639. while (pend_ppdu) {
  1640. qdf_nbuf_t mpdu_nbuf;
  1641. /* Find missing mpdus from current schedule list */
  1642. ppdu_cnt = 0;
  1643. if (!nbuf_ppdu_desc_list[ppdu_cnt]) {
  1644. ppdu_cnt++;
  1645. if (ppdu_cnt < ppdu_desc_cnt)
  1646. continue;
  1647. break;
  1648. }
  1649. ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(
  1650. pend_ppdu);
  1651. cur_ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(
  1652. nbuf_ppdu_desc_list[ppdu_cnt]);
  1653. if (pend_ppdu == qdf_nbuf_queue_last(
  1654. &tx_tid->pending_ppdu_q)) {
  1655. last_pend_ppdu = true;
  1656. qdf_nbuf_queue_add(head_ppdu,
  1657. nbuf_ppdu_desc_list[ppdu_cnt]);
  1658. nbuf_ppdu_desc_list[ppdu_cnt] = NULL;
  1659. }
  1660. cur_index = 0;
  1661. cur_start_seq = cur_ppdu_desc->user[0].start_seq;
  1662. cur_last_seq = cur_ppdu_desc->user[0].last_enq_seq;
  1663. if (qdf_unlikely(ppdu_desc->user[0].ba_size >
  1664. CDP_BA_256_BIT_MAP_SIZE_DWORDS *
  1665. SEQ_SEG_SZ_BITS(ppdu_desc->user[0].failed_bitmap))) {
  1666. qdf_assert_always(0);
  1667. return;
  1668. }
  1669. for (i = 0; (i < ppdu_desc->user[0].ba_size) && cur_ppdu_desc;
  1670. i++) {
  1671. if (!(i & (SEQ_SEG_SZ_BITS(
  1672. ppdu_desc->user[0].failed_bitmap) - 1))) {
  1673. k =
  1674. SEQ_SEG_INDEX(ppdu_desc->user[0].failed_bitmap,
  1675. i);
  1676. failed_seq =
  1677. ppdu_desc->user[0].failed_bitmap[k] ^
  1678. ppdu_desc->user[0].enq_bitmap[k];
  1679. }
  1680. /* Skip to next bitmap segment if there are no
  1681. * more holes in current segment
  1682. */
  1683. if (!failed_seq) {
  1684. i = ((k + 1) *
  1685. SEQ_SEG_SZ_BITS(ppdu_desc->user[0].failed_bitmap))
  1686. - 1;
  1687. continue;
  1688. }
  1689. if (!(SEQ_SEG_BIT(failed_seq, i)))
  1690. continue;
  1691. failed_seq ^= SEQ_SEG_MSK(failed_seq, i);
  1692. mpdu_nbuf = cur_ppdu_desc->mpdus[cur_index];
  1693. if (mpdu_nbuf) {
  1694. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1695. QDF_TRACE_LEVEL_INFO,
  1696. "%s: fill seqno %d (%d) from swretries",
  1697. __func__,
  1698. ppdu_desc->user[0].start_seq + i,
  1699. ppdu_desc->ppdu_id);
  1700. ppdu_desc->mpdus[i] =
  1701. qdf_nbuf_copy_expand(mpdu_nbuf,
  1702. MAX_MONITOR_HEADER, 0);
  1703. ppdu_desc->user[0].failed_bitmap[k] |=
  1704. SEQ_SEG_MSK(ppdu_desc->user[0].failed_bitmap[k],
  1705. i);
  1706. ppdu_desc->pending_retries--;
  1707. }
  1708. cur_index++;
  1709. if (cur_index >= cur_ppdu_desc->user[0].ba_size) {
  1710. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1711. QDF_TRACE_LEVEL_INFO,
  1712. "%s: ba_size[%d] cur_index[%d]\n",
  1713. __func__,
  1714. cur_ppdu_desc->user[0].ba_size,
  1715. cur_index);
  1716. break;
  1717. }
  1718. /* Skip through empty slots in current PPDU */
  1719. while (!(SEQ_BIT(cur_ppdu_desc->user[0].enq_bitmap,
  1720. cur_index))) {
  1721. struct cdp_tx_completion_ppdu *next_ppdu = NULL;
  1722. cur_index++;
  1723. if (cur_index <= (cur_last_seq -
  1724. cur_start_seq))
  1725. continue;
  1726. cur_ppdu_desc = NULL;
  1727. /* Check if subsequent PPDUs in this schedule
  1728. * has higher sequence numbers enqueued
  1729. */
  1730. while (ppdu_cnt < (ppdu_desc_cnt - 1)) {
  1731. ppdu_cnt++;
  1732. if (!nbuf_ppdu_desc_list[ppdu_cnt])
  1733. continue;
  1734. next_ppdu =
  1735. (struct cdp_tx_completion_ppdu *)
  1736. qdf_nbuf_data(
  1737. nbuf_ppdu_desc_list[
  1738. ppdu_cnt]);
  1739. if (!next_ppdu || (peer_id !=
  1740. next_ppdu->user[0].peer_id))
  1741. continue;
  1742. if (last_pend_ppdu) {
  1743. qdf_nbuf_queue_add(head_ppdu,
  1744. nbuf_ppdu_desc_list[ppdu_cnt]);
  1745. nbuf_ppdu_desc_list[ppdu_cnt] =
  1746. NULL;
  1747. }
  1748. if (next_ppdu->user[0].last_enq_seq >
  1749. cur_last_seq) {
  1750. cur_ppdu_desc = next_ppdu;
  1751. break;
  1752. }
  1753. }
  1754. if (!cur_ppdu_desc)
  1755. break;
  1756. /* Start from seq. no following cur_last_seq
  1757. * since everything before is already populated
  1758. * from previous PPDU
  1759. */
  1760. cur_start_seq =
  1761. cur_ppdu_desc->user[0].start_seq;
  1762. cur_index = (cur_last_seq >= cur_start_seq) ?
  1763. cur_last_seq - cur_start_seq + 1 : 0;
  1764. cur_last_seq =
  1765. cur_ppdu_desc->user[0].last_enq_seq;
  1766. }
  1767. }
  1768. if ((pend_ppdu ==
  1769. qdf_nbuf_queue_first(&tx_tid->pending_ppdu_q)) &&
  1770. (ppdu_desc->pending_retries == 0)) {
  1771. qdf_nbuf_queue_remove(&tx_tid->pending_ppdu_q);
  1772. dp_send_data_to_stack(pdev, ppdu_desc);
  1773. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  1774. qdf_mem_free(ppdu_desc->mpdus);
  1775. ppdu_desc->mpdus = NULL;
  1776. qdf_nbuf_free(pend_ppdu);
  1777. pend_ppdu = qdf_nbuf_queue_first(
  1778. &tx_tid->pending_ppdu_q);
  1779. } else {
  1780. pend_ppdu = qdf_nbuf_queue_next(pend_ppdu);
  1781. }
  1782. }
  1783. }
  1784. static uint32_t
  1785. dp_send_mgmt_ctrl_to_stack(struct dp_pdev *pdev,
  1786. qdf_nbuf_t nbuf_ppdu_desc,
  1787. struct cdp_tx_indication_info *ptr_tx_cap_info,
  1788. qdf_nbuf_t mgmt_ctl_nbuf,
  1789. bool is_payload)
  1790. {
  1791. struct cdp_tx_completion_ppdu *ppdu_desc;
  1792. struct cdp_tx_indication_mpdu_info *mpdu_info;
  1793. struct ieee80211_frame *wh;
  1794. uint16_t duration_le, seq_le;
  1795. struct ieee80211_frame_min_one *wh_min;
  1796. uint16_t frame_ctrl_le;
  1797. uint8_t type, subtype;
  1798. mpdu_info = &ptr_tx_cap_info->mpdu_info;
  1799. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1800. qdf_nbuf_data(nbuf_ppdu_desc);
  1801. type = (ppdu_desc->frame_ctrl &
  1802. IEEE80211_FC0_TYPE_MASK) >>
  1803. IEEE80211_FC0_TYPE_SHIFT;
  1804. subtype = (ppdu_desc->frame_ctrl &
  1805. IEEE80211_FC0_SUBTYPE_MASK) >>
  1806. IEEE80211_FC0_SUBTYPE_SHIFT;
  1807. if (is_payload) {
  1808. wh = (struct ieee80211_frame *)qdf_nbuf_data(mgmt_ctl_nbuf);
  1809. if (subtype != IEEE80211_FC0_SUBTYPE_BEACON) {
  1810. duration_le = qdf_cpu_to_le16(ppdu_desc->tx_duration);
  1811. wh->i_dur[1] = (duration_le & 0xFF00) >> 8;
  1812. wh->i_dur[0] = duration_le & 0xFF;
  1813. seq_le = qdf_cpu_to_le16(ppdu_desc->user[0].start_seq <<
  1814. IEEE80211_SEQ_SEQ_SHIFT);
  1815. wh->i_seq[1] = (seq_le & 0xFF00) >> 8;
  1816. wh->i_seq[0] = seq_le & 0xFF;
  1817. }
  1818. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1819. QDF_TRACE_LEVEL_DEBUG,
  1820. "ctrl/mgmt frm(0x%08x): fc 0x%x 0x%x\n",
  1821. ptr_tx_cap_info->mpdu_info.ppdu_id,
  1822. wh->i_fc[1], wh->i_fc[0]);
  1823. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1824. QDF_TRACE_LEVEL_DEBUG,
  1825. "desc->ppdu_id 0x%08x\n", ppdu_desc->ppdu_id);
  1826. /* append ext list */
  1827. qdf_nbuf_append_ext_list(ptr_tx_cap_info->mpdu_nbuf,
  1828. mgmt_ctl_nbuf,
  1829. qdf_nbuf_len(mgmt_ctl_nbuf));
  1830. } else {
  1831. wh_min = (struct ieee80211_frame_min_one *)
  1832. qdf_nbuf_data(ptr_tx_cap_info->mpdu_nbuf);
  1833. qdf_mem_zero(wh_min, MAX_DUMMY_FRM_BODY);
  1834. frame_ctrl_le = qdf_cpu_to_le16(ppdu_desc->frame_ctrl);
  1835. duration_le = qdf_cpu_to_le16(ppdu_desc->tx_duration);
  1836. wh_min->i_fc[1] = (frame_ctrl_le & 0xFF00) >> 8;
  1837. wh_min->i_fc[0] = (frame_ctrl_le & 0xFF);
  1838. wh_min->i_dur[1] = (duration_le & 0xFF00) >> 8;
  1839. wh_min->i_dur[0] = (duration_le & 0xFF);
  1840. qdf_mem_copy(wh_min->i_addr1, mpdu_info->mac_address,
  1841. QDF_MAC_ADDR_SIZE);
  1842. qdf_nbuf_set_pktlen(ptr_tx_cap_info->mpdu_nbuf,
  1843. sizeof(*wh_min));
  1844. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1845. QDF_TRACE_LEVEL_DEBUG,
  1846. "frm(0x%08x): fc %x %x, dur 0x%x%x\n",
  1847. ptr_tx_cap_info->mpdu_info.ppdu_id,
  1848. wh_min->i_fc[1], wh_min->i_fc[0],
  1849. wh_min->i_dur[1], wh_min->i_dur[0]);
  1850. }
  1851. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  1852. ptr_tx_cap_info, HTT_INVALID_PEER,
  1853. WDI_NO_VAL, pdev->pdev_id);
  1854. if (ptr_tx_cap_info->mpdu_nbuf)
  1855. qdf_nbuf_free(ptr_tx_cap_info->mpdu_nbuf);
  1856. return 0;
  1857. }
  1858. static uint32_t
  1859. dp_update_tx_cap_info(struct dp_pdev *pdev,
  1860. qdf_nbuf_t nbuf_ppdu_desc,
  1861. void *tx_info, bool is_payload)
  1862. {
  1863. struct cdp_tx_completion_ppdu *ppdu_desc;
  1864. struct cdp_tx_indication_info *tx_capture_info =
  1865. (struct cdp_tx_indication_info *)tx_info;
  1866. struct cdp_tx_indication_mpdu_info *mpdu_info;
  1867. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1868. qdf_nbuf_data(nbuf_ppdu_desc);
  1869. qdf_mem_set(tx_capture_info, sizeof(struct cdp_tx_indication_info), 0);
  1870. mpdu_info = &tx_capture_info->mpdu_info;
  1871. mpdu_info->channel = ppdu_desc->channel;
  1872. mpdu_info->frame_type = ppdu_desc->frame_type;
  1873. mpdu_info->ppdu_start_timestamp = ppdu_desc->ppdu_start_timestamp;
  1874. mpdu_info->ppdu_end_timestamp = ppdu_desc->ppdu_end_timestamp;
  1875. mpdu_info->tx_duration = ppdu_desc->tx_duration;
  1876. mpdu_info->seq_no = ppdu_desc->user[0].start_seq;
  1877. mpdu_info->num_msdu = ppdu_desc->num_msdu;
  1878. /* update cdp_tx_indication_mpdu_info */
  1879. dp_tx_update_user_mpdu_info(ppdu_desc->ppdu_id,
  1880. &tx_capture_info->mpdu_info,
  1881. &ppdu_desc->user[0]);
  1882. tx_capture_info->ppdu_desc = ppdu_desc;
  1883. tx_capture_info->mpdu_info.channel_num = pdev->operating_channel;
  1884. tx_capture_info->mpdu_info.ppdu_id = ppdu_desc->ppdu_id;
  1885. if (is_payload)
  1886. tx_capture_info->mpdu_nbuf = qdf_nbuf_alloc(pdev->soc->osdev,
  1887. MAX_MONITOR_HEADER,
  1888. MAX_MONITOR_HEADER,
  1889. 4, FALSE);
  1890. else
  1891. tx_capture_info->mpdu_nbuf = qdf_nbuf_alloc(pdev->soc->osdev,
  1892. MAX_MONITOR_HEADER +
  1893. MAX_DUMMY_FRM_BODY,
  1894. MAX_MONITOR_HEADER,
  1895. 4, FALSE);
  1896. return 0;
  1897. }
  1898. static uint32_t
  1899. dp_check_mgmt_ctrl_ppdu(struct dp_pdev *pdev,
  1900. qdf_nbuf_t nbuf_ppdu_desc)
  1901. {
  1902. struct cdp_tx_indication_info tx_capture_info;
  1903. qdf_nbuf_t mgmt_ctl_nbuf;
  1904. uint8_t type, subtype;
  1905. bool is_sgen_pkt;
  1906. struct cdp_tx_mgmt_comp_info *ptr_comp_info;
  1907. qdf_nbuf_queue_t *retries_q;
  1908. struct cdp_tx_completion_ppdu *ppdu_desc;
  1909. uint32_t ppdu_id;
  1910. size_t head_size;
  1911. uint32_t status = 1;
  1912. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  1913. qdf_nbuf_data(nbuf_ppdu_desc);
  1914. /*
  1915. * only for host generated frame we do have
  1916. * timestamp and retries count.
  1917. */
  1918. head_size = sizeof(struct cdp_tx_mgmt_comp_info);
  1919. type = (ppdu_desc->frame_ctrl &
  1920. IEEE80211_FC0_TYPE_MASK) >>
  1921. IEEE80211_FC0_TYPE_SHIFT;
  1922. subtype = (ppdu_desc->frame_ctrl &
  1923. IEEE80211_FC0_SUBTYPE_MASK) >>
  1924. IEEE80211_FC0_SUBTYPE_SHIFT;
  1925. if (ppdu_desc->htt_frame_type == HTT_STATS_FTYPE_SGEN_NDP) {
  1926. dp_update_frame_ctrl_from_frame_type(ppdu_desc);
  1927. type = 0;
  1928. subtype = 0;
  1929. }
  1930. switch (ppdu_desc->htt_frame_type) {
  1931. case HTT_STATS_FTYPE_TIDQ_DATA_SU:
  1932. case HTT_STATS_FTYPE_TIDQ_DATA_MU:
  1933. is_sgen_pkt = false;
  1934. break;
  1935. default:
  1936. is_sgen_pkt = true;
  1937. break;
  1938. }
  1939. retries_q = &pdev->tx_capture.retries_ctl_mgmt_q[type][subtype];
  1940. get_mgmt_pkt_from_queue:
  1941. qdf_spin_lock_bh(
  1942. &pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  1943. mgmt_ctl_nbuf = qdf_nbuf_queue_remove(
  1944. &pdev->tx_capture.ctl_mgmt_q[type][subtype]);
  1945. qdf_spin_unlock_bh(&pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  1946. if (mgmt_ctl_nbuf) {
  1947. qdf_nbuf_t tmp_mgmt_ctl_nbuf;
  1948. uint32_t start_tsf;
  1949. ptr_comp_info = (struct cdp_tx_mgmt_comp_info *)
  1950. qdf_nbuf_data(mgmt_ctl_nbuf);
  1951. is_sgen_pkt = ptr_comp_info->is_sgen_pkt;
  1952. ppdu_id = ptr_comp_info->ppdu_id;
  1953. if (!is_sgen_pkt && ptr_comp_info->tx_tsf <
  1954. ppdu_desc->ppdu_start_timestamp) {
  1955. /*
  1956. * free the older mgmt buffer from
  1957. * the queue and get new mgmt buffer
  1958. */
  1959. qdf_nbuf_free(mgmt_ctl_nbuf);
  1960. goto get_mgmt_pkt_from_queue;
  1961. }
  1962. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  1963. QDF_TRACE_LEVEL_INFO_HIGH,
  1964. "ppdu_id [%d 0x%x] type_subtype[%d %d] is_sgen[%d] h_sz[%d]",
  1965. ppdu_id, ppdu_id, type, subtype,
  1966. is_sgen_pkt, head_size);
  1967. QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_TX_CAPTURE,
  1968. QDF_TRACE_LEVEL_INFO_HIGH,
  1969. qdf_nbuf_data(mgmt_ctl_nbuf), 32);
  1970. /*
  1971. * for sgen frame we won't have, retries count
  1972. * and 64 bits tsf in the head.
  1973. */
  1974. if (ppdu_id != ppdu_desc->ppdu_id) {
  1975. if (is_sgen_pkt) {
  1976. start_tsf = (ppdu_desc->ppdu_start_timestamp &
  1977. LOWER_32_MASK);
  1978. if ((ptr_comp_info->tx_tsf <
  1979. (start_tsf + MAX_MGMT_ENQ_DELAY)) &&
  1980. ((ppdu_id & SCH_ID_MASK) <
  1981. (ppdu_desc->ppdu_id & SCH_ID_MASK))) {
  1982. /*
  1983. * free the older mgmt buffer from
  1984. * the queue and get new mgmt buffer
  1985. */
  1986. qdf_nbuf_free(mgmt_ctl_nbuf);
  1987. goto get_mgmt_pkt_from_queue;
  1988. }
  1989. }
  1990. /*
  1991. * only for the packets send over the air are handled
  1992. * packets drop by firmware is not handled in this
  1993. * feature
  1994. */
  1995. if (ppdu_desc->user[0].completion_status ==
  1996. HTT_PPDU_STATS_USER_STATUS_FILTERED) {
  1997. qdf_nbuf_free(nbuf_ppdu_desc);
  1998. status = 0;
  1999. goto free_ppdu_desc;
  2000. }
  2001. /*
  2002. * add the ppdu_desc into retry queue
  2003. */
  2004. qdf_nbuf_queue_add(retries_q, nbuf_ppdu_desc);
  2005. status = 0;
  2006. /*
  2007. * insert the mgmt_ctl buffer back to
  2008. * the queue
  2009. */
  2010. qdf_spin_lock_bh(
  2011. &pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  2012. qdf_nbuf_queue_insert_head(
  2013. &pdev->tx_capture.ctl_mgmt_q[type][subtype],
  2014. mgmt_ctl_nbuf);
  2015. qdf_spin_unlock_bh(
  2016. &pdev->tx_capture.ctl_mgmt_lock[type][subtype]);
  2017. } else {
  2018. qdf_nbuf_t nbuf_retry_ppdu;
  2019. struct cdp_tx_completion_ppdu *tmp_ppdu_desc;
  2020. uint16_t frame_ctrl_le;
  2021. struct ieee80211_frame *wh;
  2022. /*
  2023. * only for the packets send over the air are handled
  2024. * packets drop by firmware is not handled in this
  2025. * feature
  2026. */
  2027. if (ppdu_desc->user[0].completion_status ==
  2028. HTT_PPDU_STATS_USER_STATUS_FILTERED) {
  2029. qdf_nbuf_free(nbuf_ppdu_desc);
  2030. qdf_nbuf_free(mgmt_ctl_nbuf);
  2031. status = 0;
  2032. goto free_ppdu_desc;
  2033. }
  2034. while (!!qdf_nbuf_queue_len(retries_q)) {
  2035. /*
  2036. * send retried packet stored
  2037. * in queue
  2038. */
  2039. nbuf_retry_ppdu =
  2040. qdf_nbuf_queue_remove(retries_q);
  2041. tmp_ppdu_desc =
  2042. (struct cdp_tx_completion_ppdu *)
  2043. qdf_nbuf_data(nbuf_retry_ppdu);
  2044. tmp_mgmt_ctl_nbuf =
  2045. skb_copy_expand(mgmt_ctl_nbuf,
  2046. 0, 0, GFP_ATOMIC);
  2047. dp_update_tx_cap_info(pdev, nbuf_retry_ppdu,
  2048. &tx_capture_info, true);
  2049. if (!tx_capture_info.mpdu_nbuf) {
  2050. qdf_nbuf_free(nbuf_retry_ppdu);
  2051. qdf_nbuf_free(tmp_mgmt_ctl_nbuf);
  2052. continue;
  2053. }
  2054. /* pull head based on sgen pkt or mgmt pkt */
  2055. qdf_nbuf_pull_head(tmp_mgmt_ctl_nbuf,
  2056. head_size);
  2057. /*
  2058. * frame control from ppdu_desc has
  2059. * retry flag set
  2060. */
  2061. frame_ctrl_le =
  2062. qdf_cpu_to_le16(tmp_ppdu_desc->frame_ctrl);
  2063. wh = (struct ieee80211_frame *)
  2064. (qdf_nbuf_data(tmp_mgmt_ctl_nbuf));
  2065. wh->i_fc[1] = (frame_ctrl_le & 0xFF00) >> 8;
  2066. wh->i_fc[0] = (frame_ctrl_le & 0xFF);
  2067. tx_capture_info.ppdu_desc = tmp_ppdu_desc;
  2068. /*
  2069. * send MPDU to osif layer
  2070. */
  2071. dp_send_mgmt_ctrl_to_stack(pdev,
  2072. nbuf_retry_ppdu,
  2073. &tx_capture_info,
  2074. tmp_mgmt_ctl_nbuf,
  2075. true);
  2076. /* free retried queue nbuf ppdu_desc */
  2077. qdf_nbuf_free(nbuf_retry_ppdu);
  2078. }
  2079. dp_update_tx_cap_info(pdev, nbuf_ppdu_desc,
  2080. &tx_capture_info, true);
  2081. if (!tx_capture_info.mpdu_nbuf) {
  2082. qdf_nbuf_free(mgmt_ctl_nbuf);
  2083. goto free_ppdu_desc;
  2084. }
  2085. tx_capture_info.mpdu_info.ppdu_id =
  2086. *(uint32_t *)qdf_nbuf_data(mgmt_ctl_nbuf);
  2087. /* pull head based on sgen pkt or mgmt pkt */
  2088. qdf_nbuf_pull_head(mgmt_ctl_nbuf, head_size);
  2089. /* frame control from ppdu_desc has retry flag set */
  2090. frame_ctrl_le = qdf_cpu_to_le16(ppdu_desc->frame_ctrl);
  2091. wh = (struct ieee80211_frame *)
  2092. (qdf_nbuf_data(mgmt_ctl_nbuf));
  2093. wh->i_fc[1] = (frame_ctrl_le & 0xFF00) >> 8;
  2094. wh->i_fc[0] = (frame_ctrl_le & 0xFF);
  2095. tx_capture_info.ppdu_desc = ppdu_desc;
  2096. /*
  2097. * send MPDU to osif layer
  2098. */
  2099. dp_send_mgmt_ctrl_to_stack(pdev, nbuf_ppdu_desc,
  2100. &tx_capture_info,
  2101. mgmt_ctl_nbuf, true);
  2102. }
  2103. } else if (!is_sgen_pkt) {
  2104. /*
  2105. * only for the packets send over the air are handled
  2106. * packets drop by firmware is not handled in this
  2107. * feature
  2108. */
  2109. if (ppdu_desc->user[0].completion_status ==
  2110. HTT_PPDU_STATS_USER_STATUS_FILTERED) {
  2111. qdf_nbuf_free(nbuf_ppdu_desc);
  2112. status = 0;
  2113. goto free_ppdu_desc;
  2114. }
  2115. /*
  2116. * add the ppdu_desc into retry queue
  2117. */
  2118. qdf_nbuf_queue_add(retries_q, nbuf_ppdu_desc);
  2119. status = 0;
  2120. } else if ((ppdu_desc->frame_ctrl &
  2121. IEEE80211_FC0_TYPE_MASK) ==
  2122. IEEE80211_FC0_TYPE_CTL) {
  2123. /*
  2124. * only for the packets send over the air are handled
  2125. * packets drop by firmware is not handled in this
  2126. * feature
  2127. */
  2128. if (ppdu_desc->user[0].completion_status ==
  2129. HTT_PPDU_STATS_USER_STATUS_FILTERED) {
  2130. qdf_nbuf_free(nbuf_ppdu_desc);
  2131. status = 0;
  2132. goto free_ppdu_desc;
  2133. }
  2134. dp_update_tx_cap_info(pdev, nbuf_ppdu_desc,
  2135. &tx_capture_info, false);
  2136. if (!tx_capture_info.mpdu_nbuf)
  2137. goto free_ppdu_desc;
  2138. /*
  2139. * send MPDU to osif layer
  2140. */
  2141. dp_send_mgmt_ctrl_to_stack(pdev, nbuf_ppdu_desc,
  2142. &tx_capture_info, NULL, false);
  2143. }
  2144. free_ppdu_desc:
  2145. return status;
  2146. }
  2147. /**
  2148. * dp_peer_tx_cap_tid_queue_flush_tlv(): Function to dequeue peer queue
  2149. * @pdev: DP pdev handle
  2150. * @peer; DP peer handle
  2151. * @ppdu_desc: ppdu_desc
  2152. *
  2153. * return: void
  2154. */
  2155. static void
  2156. dp_peer_tx_cap_tid_queue_flush_tlv(struct dp_pdev *pdev,
  2157. struct dp_peer *peer,
  2158. struct cdp_tx_completion_ppdu *ppdu_desc)
  2159. {
  2160. int tid;
  2161. struct dp_tx_tid *tx_tid;
  2162. qdf_nbuf_queue_t head_xretries;
  2163. qdf_nbuf_queue_t head_msdu;
  2164. uint32_t qlen = 0;
  2165. uint32_t qlen_curr = 0;
  2166. tid = ppdu_desc->user[0].tid;
  2167. tx_tid = &peer->tx_capture.tx_tid[tid];
  2168. qdf_nbuf_queue_init(&head_msdu);
  2169. qdf_nbuf_queue_init(&head_xretries);
  2170. qlen = qdf_nbuf_queue_len(&tx_tid->msdu_comp_q);
  2171. dp_tx_msdu_dequeue(peer, INVALID_PPDU_ID,
  2172. tid, ppdu_desc->num_msdu,
  2173. &head_msdu,
  2174. &head_xretries,
  2175. 0, MAX_END_TSF);
  2176. if (!qdf_nbuf_is_queue_empty(&head_xretries)) {
  2177. struct cdp_tx_completion_ppdu *xretry_ppdu =
  2178. &tx_tid->xretry_ppdu;
  2179. xretry_ppdu->ppdu_id = peer->tx_capture.tx_wifi_ppdu_id;
  2180. /* Restitch MPDUs from xretry MSDUs */
  2181. dp_tx_mon_restitch_mpdu(pdev, peer,
  2182. xretry_ppdu,
  2183. &head_xretries,
  2184. &xretry_ppdu->mpdu_q);
  2185. }
  2186. qdf_nbuf_queue_free(&head_msdu);
  2187. qdf_nbuf_queue_free(&head_xretries);
  2188. qlen_curr = qdf_nbuf_queue_len(&tx_tid->msdu_comp_q);
  2189. dp_tx_mon_proc_xretries(pdev, peer, tid);
  2190. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2191. QDF_TRACE_LEVEL_INFO_MED,
  2192. "peer_id [%d 0x%x] tid[%d] qlen[%d -> %d]",
  2193. ppdu_desc->user[0].peer_id, peer, tid, qlen, qlen_curr);
  2194. }
  2195. /**
  2196. * dp_tx_ppdu_stats_flush(): Function to flush pending retried ppdu desc
  2197. * @pdev: DP pdev handle
  2198. * @nbuf: ppdu_desc
  2199. *
  2200. * return: void
  2201. */
  2202. static void
  2203. dp_tx_ppdu_stats_flush(struct dp_pdev *pdev,
  2204. struct cdp_tx_completion_ppdu *ppdu_desc)
  2205. {
  2206. struct dp_peer *peer;
  2207. peer = dp_peer_find_by_id(pdev->soc,
  2208. ppdu_desc->user[0].peer_id);
  2209. if (!peer)
  2210. return;
  2211. dp_peer_tx_cap_tid_queue_flush_tlv(pdev, peer, ppdu_desc);
  2212. dp_peer_unref_del_find_by_id(peer);
  2213. return;
  2214. }
  2215. /**
  2216. * dp_check_ppdu_and_deliver(): Check PPDUs for any holes and deliver
  2217. * to upper layer if complete
  2218. * @pdev: DP pdev handle
  2219. * @nbuf_ppdu_desc_list: ppdu_desc_list per sched cmd id
  2220. * @ppdu_desc_cnt: number of ppdu_desc_cnt
  2221. *
  2222. * return: status
  2223. */
  2224. static void
  2225. dp_check_ppdu_and_deliver(struct dp_pdev *pdev,
  2226. qdf_nbuf_t nbuf_ppdu_desc_list[],
  2227. uint32_t ppdu_desc_cnt)
  2228. {
  2229. uint32_t ppdu_id;
  2230. uint32_t desc_cnt;
  2231. qdf_nbuf_t tmp_nbuf;
  2232. struct dp_tx_tid *tx_tid = NULL;
  2233. int i;
  2234. for (desc_cnt = 0; desc_cnt < ppdu_desc_cnt; desc_cnt++) {
  2235. struct cdp_tx_completion_ppdu *ppdu_desc;
  2236. uint32_t num_mpdu;
  2237. uint16_t start_seq, seq_no = 0;
  2238. int i;
  2239. uint32_t len;
  2240. qdf_nbuf_t mpdu_nbuf;
  2241. struct dp_peer *peer;
  2242. uint8_t type;
  2243. if (!nbuf_ppdu_desc_list[desc_cnt])
  2244. continue;
  2245. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2246. qdf_nbuf_data(nbuf_ppdu_desc_list[desc_cnt]);
  2247. ppdu_id = ppdu_desc->ppdu_id;
  2248. type = (ppdu_desc->frame_ctrl & IEEE80211_FC0_TYPE_MASK) >>
  2249. IEEE80211_FC0_TYPE_SHIFT;
  2250. if (ppdu_desc->is_flush) {
  2251. dp_tx_ppdu_stats_flush(pdev, ppdu_desc);
  2252. tmp_nbuf = nbuf_ppdu_desc_list[desc_cnt];
  2253. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2254. qdf_nbuf_free(tmp_nbuf);
  2255. continue;
  2256. }
  2257. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_CTRL ||
  2258. ppdu_desc->htt_frame_type ==
  2259. HTT_STATS_FTYPE_SGEN_QOS_NULL ||
  2260. type != FRAME_CTRL_TYPE_DATA) {
  2261. qdf_nbuf_t nbuf_ppdu = nbuf_ppdu_desc_list[desc_cnt];
  2262. if (dp_check_mgmt_ctrl_ppdu(pdev, nbuf_ppdu)) {
  2263. tmp_nbuf = nbuf_ppdu_desc_list[desc_cnt];
  2264. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2265. qdf_nbuf_free(tmp_nbuf);
  2266. continue;
  2267. }
  2268. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2269. continue;
  2270. }
  2271. peer = dp_peer_find_by_id(pdev->soc,
  2272. ppdu_desc->user[0].peer_id);
  2273. if (!peer) {
  2274. tmp_nbuf = nbuf_ppdu_desc_list[desc_cnt];
  2275. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2276. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  2277. qdf_nbuf_free(tmp_nbuf);
  2278. continue;
  2279. }
  2280. tx_tid = &peer->tx_capture.tx_tid[ppdu_desc->user[0].tid];
  2281. ppdu_id = ppdu_desc->ppdu_id;
  2282. /* find mpdu tried is same as success mpdu */
  2283. num_mpdu = ppdu_desc->user[0].mpdu_success;
  2284. /* get length */
  2285. len = qdf_nbuf_queue_len(&ppdu_desc->mpdu_q);
  2286. /* ba_size is updated in BA bitmap TLVs, which are not received
  2287. * in case of non-QoS TID.
  2288. */
  2289. if (qdf_unlikely(ppdu_desc->user[0].tid == DP_NON_QOS_TID)) {
  2290. ppdu_desc->user[0].ba_size = 1;
  2291. ppdu_desc->user[0].last_enq_seq =
  2292. ppdu_desc->user[0].start_seq;
  2293. }
  2294. if (ppdu_desc->user[0].ba_size == 0)
  2295. ppdu_desc->user[0].ba_size = 1;
  2296. /* find list of missing sequence */
  2297. ppdu_desc->mpdus = qdf_mem_malloc(sizeof(qdf_nbuf_t) *
  2298. ppdu_desc->user[0].ba_size);
  2299. if (ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR)
  2300. dp_send_dummy_mpdu_info_to_stack(pdev,
  2301. ppdu_desc);
  2302. if (qdf_unlikely(!ppdu_desc->mpdus)) {
  2303. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2304. QDF_TRACE_LEVEL_FATAL,
  2305. "%s: ppdu_desc->mpdus allocation failed",
  2306. __func__);
  2307. tmp_nbuf = nbuf_ppdu_desc_list[desc_cnt];
  2308. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2309. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  2310. qdf_nbuf_free(tmp_nbuf);
  2311. dp_peer_unref_del_find_by_id(peer);
  2312. continue;
  2313. }
  2314. if (qdf_unlikely(ppdu_desc->user[0].ba_size >
  2315. CDP_BA_256_BIT_MAP_SIZE_DWORDS *
  2316. SEQ_SEG_SZ_BITS(ppdu_desc->user[0].failed_bitmap))) {
  2317. dp_peer_unref_del_find_by_id(peer);
  2318. qdf_assert_always(0);
  2319. return;
  2320. }
  2321. /* Fill seq holes within current schedule list */
  2322. start_seq = ppdu_desc->user[0].start_seq;
  2323. for (i = 0; i < ppdu_desc->user[0].ba_size; i++) {
  2324. if (qdf_likely(ppdu_desc->user[0].tid !=
  2325. DP_NON_QOS_TID) &&
  2326. !(SEQ_BIT(ppdu_desc->user[0].enq_bitmap, i)))
  2327. continue;
  2328. /* missed seq number */
  2329. seq_no = start_seq + i;
  2330. /* Fill failed MPDUs in AMPDU if they're available in
  2331. * subsequent PPDUs in current burst schedule. This
  2332. * is not applicable for non-QoS TIDs (no AMPDUs)
  2333. */
  2334. if (qdf_likely(ppdu_desc->user[0].tid !=
  2335. DP_NON_QOS_TID) &&
  2336. !(SEQ_BIT(ppdu_desc->user[0].failed_bitmap, i))) {
  2337. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2338. QDF_TRACE_LEVEL_DEBUG,
  2339. "%s:find seq %d in next ppdu %d",
  2340. __func__, seq_no,
  2341. ppdu_desc_cnt);
  2342. mpdu_nbuf = get_mpdu_clone_from_next_ppdu(
  2343. nbuf_ppdu_desc_list +
  2344. desc_cnt,
  2345. ppdu_desc_cnt -
  2346. desc_cnt, seq_no,
  2347. ppdu_desc->user[0].peer_id,
  2348. ppdu_id);
  2349. /* check mpdu_nbuf NULL */
  2350. if (!mpdu_nbuf) {
  2351. ppdu_desc->pending_retries++;
  2352. continue;
  2353. }
  2354. ppdu_desc->mpdus[seq_no - start_seq] =
  2355. mpdu_nbuf;
  2356. SEQ_SEG(ppdu_desc->user[0].failed_bitmap, i) |=
  2357. SEQ_SEG_MSK(ppdu_desc->user[0].failed_bitmap[0],
  2358. i);
  2359. } else {
  2360. /* any error case we need to handle */
  2361. ppdu_desc->mpdus[seq_no - start_seq] =
  2362. qdf_nbuf_queue_remove(
  2363. &ppdu_desc->mpdu_q);
  2364. }
  2365. }
  2366. dp_peer_unref_del_find_by_id(peer);
  2367. if ((ppdu_desc->pending_retries == 0) &&
  2368. qdf_nbuf_is_queue_empty(&tx_tid->pending_ppdu_q)) {
  2369. dp_send_data_to_stack(pdev, ppdu_desc);
  2370. qdf_nbuf_queue_free(&ppdu_desc->mpdu_q);
  2371. qdf_mem_free(ppdu_desc->mpdus);
  2372. ppdu_desc->mpdus = NULL;
  2373. tmp_nbuf = nbuf_ppdu_desc_list[desc_cnt];
  2374. nbuf_ppdu_desc_list[desc_cnt] = NULL;
  2375. qdf_nbuf_free(tmp_nbuf);
  2376. }
  2377. }
  2378. for (i = 0; i < ppdu_desc_cnt; i++) {
  2379. uint32_t pending_ppdus;
  2380. struct cdp_tx_completion_ppdu *cur_ppdu_desc;
  2381. struct dp_peer *peer;
  2382. qdf_nbuf_queue_t head_ppdu;
  2383. if (!nbuf_ppdu_desc_list[i])
  2384. continue;
  2385. cur_ppdu_desc = (struct cdp_tx_completion_ppdu *)qdf_nbuf_data(
  2386. nbuf_ppdu_desc_list[i]);
  2387. if (!cur_ppdu_desc)
  2388. continue;
  2389. peer = dp_peer_find_by_id(pdev->soc,
  2390. cur_ppdu_desc->user[0].peer_id);
  2391. if (!peer) {
  2392. tmp_nbuf = nbuf_ppdu_desc_list[i];
  2393. nbuf_ppdu_desc_list[i] = NULL;
  2394. qdf_nbuf_queue_free(&cur_ppdu_desc->mpdu_q);
  2395. qdf_mem_free(cur_ppdu_desc->mpdus);
  2396. cur_ppdu_desc->mpdus = NULL;
  2397. qdf_nbuf_free(tmp_nbuf);
  2398. continue;
  2399. }
  2400. tx_tid = &peer->tx_capture.tx_tid[cur_ppdu_desc->user[0].tid];
  2401. qdf_nbuf_queue_init(&head_ppdu);
  2402. dp_tx_mon_proc_pending_ppdus(pdev, tx_tid,
  2403. nbuf_ppdu_desc_list + i,
  2404. ppdu_desc_cnt - i, &head_ppdu,
  2405. cur_ppdu_desc->user[0].peer_id);
  2406. if (qdf_nbuf_is_queue_empty(&tx_tid->pending_ppdu_q)) {
  2407. while ((tmp_nbuf = qdf_nbuf_queue_first(&head_ppdu))) {
  2408. cur_ppdu_desc =
  2409. (struct cdp_tx_completion_ppdu *)
  2410. qdf_nbuf_data(tmp_nbuf);
  2411. if (cur_ppdu_desc->pending_retries)
  2412. break;
  2413. dp_send_data_to_stack(pdev, cur_ppdu_desc);
  2414. qdf_nbuf_queue_free(&cur_ppdu_desc->mpdu_q);
  2415. qdf_mem_free(cur_ppdu_desc->mpdus);
  2416. cur_ppdu_desc->mpdus = NULL;
  2417. qdf_nbuf_queue_remove(&head_ppdu);
  2418. qdf_nbuf_free(tmp_nbuf);
  2419. }
  2420. }
  2421. qdf_nbuf_queue_append(&tx_tid->pending_ppdu_q, &head_ppdu);
  2422. dp_tx_mon_proc_xretries(pdev, peer, tx_tid->tid);
  2423. dp_peer_unref_del_find_by_id(peer);
  2424. pending_ppdus = qdf_nbuf_queue_len(&tx_tid->pending_ppdu_q);
  2425. if (pending_ppdus > MAX_PENDING_PPDUS) {
  2426. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2427. QDF_TRACE_LEVEL_FATAL,
  2428. "pending ppdus (%d, %d) : %d\n",
  2429. cur_ppdu_desc->user[0].peer_id,
  2430. tx_tid->tid, pending_ppdus);
  2431. }
  2432. }
  2433. }
  2434. /**
  2435. * dp_tx_ppdu_stats_process - Deferred PPDU stats handler
  2436. * @context: Opaque work context (PDEV)
  2437. *
  2438. * Return: none
  2439. */
  2440. void dp_tx_ppdu_stats_process(void *context)
  2441. {
  2442. uint32_t curr_sched_cmdid;
  2443. uint32_t last_ppdu_id;
  2444. uint32_t ppdu_cnt;
  2445. uint32_t ppdu_desc_cnt = 0;
  2446. struct dp_pdev *pdev = (struct dp_pdev *)context;
  2447. struct ppdu_info *ppdu_info, *tmp_ppdu_info = NULL;
  2448. uint32_t now_ms = qdf_system_ticks_to_msecs(qdf_system_ticks());
  2449. struct ppdu_info *sched_ppdu_info = NULL;
  2450. STAILQ_HEAD(, ppdu_info) sched_ppdu_queue;
  2451. struct ppdu_info *sched_ppdu_list_last_ptr;
  2452. qdf_nbuf_t *nbuf_ppdu_desc_list;
  2453. qdf_nbuf_t tmp_nbuf;
  2454. struct dp_pdev_tx_capture *ptr_tx_cap = &pdev->tx_capture;
  2455. qdf_nbuf_queue_t head_xretries;
  2456. STAILQ_INIT(&sched_ppdu_queue);
  2457. /* Move the PPDU entries to defer list */
  2458. qdf_spin_lock_bh(&ptr_tx_cap->ppdu_stats_lock);
  2459. STAILQ_CONCAT(&ptr_tx_cap->ppdu_stats_defer_queue,
  2460. &ptr_tx_cap->ppdu_stats_queue);
  2461. ptr_tx_cap->ppdu_stats_defer_queue_depth +=
  2462. ptr_tx_cap->ppdu_stats_queue_depth;
  2463. ptr_tx_cap->ppdu_stats_queue_depth = 0;
  2464. qdf_spin_unlock_bh(&ptr_tx_cap->ppdu_stats_lock);
  2465. while (!STAILQ_EMPTY(&ptr_tx_cap->ppdu_stats_defer_queue)) {
  2466. ppdu_info =
  2467. STAILQ_FIRST(&ptr_tx_cap->ppdu_stats_defer_queue);
  2468. curr_sched_cmdid = ppdu_info->sched_cmdid;
  2469. ppdu_cnt = 0;
  2470. STAILQ_FOREACH_SAFE(ppdu_info,
  2471. &ptr_tx_cap->ppdu_stats_defer_queue,
  2472. ppdu_info_queue_elem, tmp_ppdu_info) {
  2473. if (curr_sched_cmdid != ppdu_info->sched_cmdid)
  2474. break;
  2475. sched_ppdu_list_last_ptr = ppdu_info;
  2476. ppdu_cnt++;
  2477. }
  2478. if (ppdu_info && (curr_sched_cmdid == ppdu_info->sched_cmdid) &&
  2479. ptr_tx_cap->ppdu_stats_next_sched < now_ms)
  2480. break;
  2481. last_ppdu_id = sched_ppdu_list_last_ptr->ppdu_id;
  2482. STAILQ_FIRST(&sched_ppdu_queue) =
  2483. STAILQ_FIRST(&ptr_tx_cap->ppdu_stats_defer_queue);
  2484. STAILQ_REMOVE_HEAD_UNTIL(&ptr_tx_cap->ppdu_stats_defer_queue,
  2485. sched_ppdu_list_last_ptr,
  2486. ppdu_info_queue_elem);
  2487. STAILQ_NEXT(sched_ppdu_list_last_ptr,
  2488. ppdu_info_queue_elem) = NULL;
  2489. ptr_tx_cap->ppdu_stats_defer_queue_depth -= ppdu_cnt;
  2490. nbuf_ppdu_desc_list =
  2491. (qdf_nbuf_t *) qdf_mem_malloc(sizeof(qdf_nbuf_t) *
  2492. ppdu_cnt);
  2493. /*
  2494. * if there is no memory allocated we need to free sched ppdu
  2495. * list, no ppdu stats will be updated.
  2496. */
  2497. if (!nbuf_ppdu_desc_list) {
  2498. STAILQ_FOREACH_SAFE(sched_ppdu_info,
  2499. &sched_ppdu_queue,
  2500. ppdu_info_queue_elem,
  2501. tmp_ppdu_info) {
  2502. ppdu_info = sched_ppdu_info;
  2503. tmp_nbuf = ppdu_info->nbuf;
  2504. qdf_mem_free(ppdu_info);
  2505. qdf_nbuf_free(tmp_nbuf);
  2506. }
  2507. continue;
  2508. }
  2509. qdf_spin_lock(&ptr_tx_cap->config_lock);
  2510. ppdu_desc_cnt = 0;
  2511. STAILQ_FOREACH_SAFE(sched_ppdu_info,
  2512. &sched_ppdu_queue,
  2513. ppdu_info_queue_elem, tmp_ppdu_info) {
  2514. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2515. struct dp_peer *peer = NULL;
  2516. qdf_nbuf_t nbuf;
  2517. uint32_t retries = 0;
  2518. uint32_t ret = 0;
  2519. qdf_nbuf_queue_t head_msdu;
  2520. uint32_t start_tsf = 0;
  2521. uint32_t end_tsf = 0;
  2522. uint16_t tid = 0;
  2523. uint32_t num_msdu = 0;
  2524. uint32_t qlen = 0;
  2525. qdf_nbuf_queue_init(&head_msdu);
  2526. qdf_nbuf_queue_init(&head_xretries);
  2527. ppdu_info = sched_ppdu_info;
  2528. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2529. qdf_nbuf_data(ppdu_info->nbuf);
  2530. pdev->tx_ppdu_proc++;
  2531. dp_ppdu_desc_user_stats_update(pdev, ppdu_info);
  2532. /*
  2533. * While processing/corelating Tx buffers, we should
  2534. * hold the entire PPDU list for the give sched_cmdid
  2535. * instead of freeing below.
  2536. */
  2537. nbuf = ppdu_info->nbuf;
  2538. qdf_mem_free(ppdu_info);
  2539. qdf_assert_always(nbuf);
  2540. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2541. qdf_nbuf_data(nbuf);
  2542. /* send WDI event */
  2543. if (pdev->tx_capture_enabled ==
  2544. CDP_TX_ENH_CAPTURE_DISABLED) {
  2545. /**
  2546. * Deliver PPDU stats only for valid (acked)
  2547. * data frames if sniffer mode is not enabled.
  2548. * If sniffer mode is enabled,
  2549. * PPDU stats for all frames including
  2550. * mgmt/control frames should be delivered
  2551. * to upper layer
  2552. */
  2553. if (pdev->tx_sniffer_enable ||
  2554. pdev->mcopy_mode) {
  2555. dp_wdi_event_handler(
  2556. WDI_EVENT_TX_PPDU_DESC,
  2557. pdev->soc,
  2558. nbuf,
  2559. HTT_INVALID_PEER,
  2560. WDI_NO_VAL,
  2561. pdev->pdev_id);
  2562. } else {
  2563. if (ppdu_desc->num_mpdu != 0 &&
  2564. ppdu_desc->num_users != 0 &&
  2565. (ppdu_desc->frame_ctrl &
  2566. HTT_FRAMECTRL_DATATYPE)) {
  2567. dp_wdi_event_handler(
  2568. WDI_EVENT_TX_PPDU_DESC,
  2569. pdev->soc,
  2570. nbuf,
  2571. HTT_INVALID_PEER,
  2572. WDI_NO_VAL,
  2573. pdev->pdev_id);
  2574. } else {
  2575. qdf_nbuf_free(nbuf);
  2576. }
  2577. }
  2578. continue;
  2579. }
  2580. peer = dp_peer_find_by_id(pdev->soc,
  2581. ppdu_desc->user[0].peer_id);
  2582. /**
  2583. * peer can be NULL
  2584. */
  2585. if (!peer) {
  2586. qdf_nbuf_free(nbuf);
  2587. continue;
  2588. }
  2589. if ((ppdu_desc->frame_type == CDP_PPDU_FTYPE_DATA) ||
  2590. (ppdu_desc->num_mpdu &&
  2591. ppdu_desc->frame_type == CDP_PPDU_FTYPE_BAR)) {
  2592. /**
  2593. * check whether it is bss peer,
  2594. * if bss_peer no need to process further
  2595. * check whether tx_capture feature is enabled
  2596. * for this peer or globally for all peers
  2597. */
  2598. if (peer->bss_peer ||
  2599. !dp_peer_or_pdev_tx_cap_enabled(pdev,
  2600. peer)) {
  2601. dp_peer_unref_del_find_by_id(peer);
  2602. qdf_nbuf_free(nbuf);
  2603. continue;
  2604. }
  2605. /* print the bit map */
  2606. dp_tx_print_bitmap(pdev, ppdu_desc,
  2607. 0, ppdu_desc->ppdu_id);
  2608. if (ppdu_desc->user[0].tid > DP_MAX_TIDS) {
  2609. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2610. QDF_TRACE_LEVEL_ERROR,
  2611. "%s: ppdu[%d] peer_id[%d] TID[%d] > NON_QOS_TID!",
  2612. __func__,
  2613. ppdu_desc->ppdu_id,
  2614. ppdu_desc->user[0].peer_id,
  2615. ppdu_desc->user[0].tid);
  2616. dp_peer_unref_del_find_by_id(peer);
  2617. qdf_nbuf_free(nbuf);
  2618. continue;
  2619. }
  2620. tid = ppdu_desc->user[0].tid;
  2621. dequeue_msdu_again:
  2622. num_msdu = ppdu_desc->user[0].num_msdu;
  2623. start_tsf = ppdu_desc->ppdu_start_timestamp;
  2624. end_tsf = ppdu_desc->ppdu_end_timestamp;
  2625. /*
  2626. * retrieve msdu buffer based on ppdu_id & tid
  2627. * based msdu queue and store it in local queue
  2628. * sometimes, wbm comes later than per ppdu
  2629. * stats. Assumption: all packets are SU,
  2630. * and packets comes in order
  2631. */
  2632. ret = dp_tx_msdu_dequeue(peer,
  2633. ppdu_desc->ppdu_id,
  2634. ppdu_desc->user[0].tid,
  2635. num_msdu,
  2636. &head_msdu,
  2637. &head_xretries,
  2638. start_tsf, end_tsf);
  2639. if (!ret && (++retries < 2)) {
  2640. /* wait for wbm to complete */
  2641. qdf_mdelay(2);
  2642. goto dequeue_msdu_again;
  2643. }
  2644. if (!qdf_nbuf_is_queue_empty(&head_xretries)) {
  2645. struct dp_tx_tid *tx_tid =
  2646. &peer->tx_capture.tx_tid[tid];
  2647. struct cdp_tx_completion_ppdu
  2648. *xretry_ppdu =
  2649. &tx_tid->xretry_ppdu;
  2650. xretry_ppdu->ppdu_id =
  2651. peer->tx_capture.tx_wifi_ppdu_id;
  2652. /* Restitch MPDUs from xretry MSDUs */
  2653. dp_tx_mon_restitch_mpdu(pdev, peer,
  2654. xretry_ppdu,
  2655. &head_xretries,
  2656. &xretry_ppdu->mpdu_q);
  2657. }
  2658. if (!qdf_nbuf_is_queue_empty(&head_msdu)) {
  2659. /*
  2660. * now head_msdu hold - msdu list for
  2661. * that particular ppdu_id, restitch
  2662. * mpdu from msdu and create a mpdu
  2663. * queue
  2664. */
  2665. dp_tx_mon_restitch_mpdu(pdev, peer,
  2666. ppdu_desc,
  2667. &head_msdu,
  2668. &ppdu_desc->mpdu_q);
  2669. /*
  2670. * sanity: free local head msdu queue
  2671. * do we need this ?
  2672. */
  2673. qdf_nbuf_queue_free(&head_msdu);
  2674. qlen =
  2675. qdf_nbuf_queue_len(&ppdu_desc->mpdu_q);
  2676. if (!qlen) {
  2677. qdf_nbuf_free(nbuf);
  2678. dp_peer_unref_del_find_by_id(peer);
  2679. continue;
  2680. }
  2681. }
  2682. nbuf_ppdu_desc_list[ppdu_desc_cnt++] = nbuf;
  2683. /* print ppdu_desc info for debugging purpose */
  2684. QDF_TRACE(QDF_MODULE_ID_TX_CAPTURE,
  2685. QDF_TRACE_LEVEL_INFO,
  2686. "%s: ppdu[%d], p_id[%d], tid[%d], n_mpdu[%d %d] n_msdu[%d] retr[%d] qlen[%d] s_tsf[%u] dur[%u] seq[%d] [%d %d]",
  2687. __func__, ppdu_desc->ppdu_id,
  2688. ppdu_desc->user[0].peer_id,
  2689. ppdu_desc->user[0].tid,
  2690. ppdu_desc->num_mpdu,
  2691. ppdu_desc->user[0].mpdu_success,
  2692. ppdu_desc->num_msdu, retries,
  2693. qlen,
  2694. ppdu_desc->ppdu_start_timestamp,
  2695. ppdu_desc->tx_duration,
  2696. ppdu_desc->user[0].start_seq,
  2697. ppdu_cnt,
  2698. ppdu_desc_cnt);
  2699. } else {
  2700. /*
  2701. * other packet frame also added to
  2702. * descriptor list
  2703. */
  2704. nbuf_ppdu_desc_list[ppdu_desc_cnt++] = nbuf;
  2705. }
  2706. dp_peer_unref_del_find_by_id(peer);
  2707. }
  2708. /*
  2709. * At this point we have mpdu queued per ppdu_desc
  2710. * based on packet capture flags send mpdu info to upper stack
  2711. */
  2712. if (ppdu_desc_cnt) {
  2713. dp_check_ppdu_and_deliver(pdev, nbuf_ppdu_desc_list,
  2714. ppdu_desc_cnt);
  2715. }
  2716. qdf_spin_unlock(&ptr_tx_cap->config_lock);
  2717. qdf_mem_free(nbuf_ppdu_desc_list);
  2718. }
  2719. }
  2720. /**
  2721. * dp_ppdu_desc_deliver(): Function to deliver Tx PPDU status descriptor
  2722. * to upper layer
  2723. * @pdev: DP pdev handle
  2724. * @ppdu_info: per PPDU TLV descriptor
  2725. *
  2726. * return: void
  2727. */
  2728. void dp_ppdu_desc_deliver(struct dp_pdev *pdev,
  2729. struct ppdu_info *ppdu_info)
  2730. {
  2731. uint32_t now_ms = qdf_system_ticks_to_msecs(qdf_system_ticks());
  2732. struct cdp_tx_completion_ppdu *ppdu_desc = NULL;
  2733. TAILQ_REMOVE(&pdev->ppdu_info_list, ppdu_info, ppdu_info_list_elem);
  2734. pdev->list_depth--;
  2735. ppdu_desc = (struct cdp_tx_completion_ppdu *)
  2736. qdf_nbuf_data(ppdu_info->nbuf);
  2737. qdf_spin_lock_bh(&pdev->tx_capture.ppdu_stats_lock);
  2738. if (qdf_unlikely(!pdev->tx_capture_enabled &&
  2739. (pdev->tx_capture.ppdu_stats_queue_depth +
  2740. pdev->tx_capture.ppdu_stats_defer_queue_depth) >
  2741. DP_TX_PPDU_PROC_MAX_DEPTH)) {
  2742. qdf_nbuf_free(ppdu_info->nbuf);
  2743. qdf_mem_free(ppdu_info);
  2744. pdev->tx_capture.ppdu_dropped++;
  2745. } else {
  2746. STAILQ_INSERT_TAIL(&pdev->tx_capture.ppdu_stats_queue,
  2747. ppdu_info, ppdu_info_queue_elem);
  2748. pdev->tx_capture.ppdu_stats_queue_depth++;
  2749. }
  2750. qdf_spin_unlock_bh(&pdev->tx_capture.ppdu_stats_lock);
  2751. if ((pdev->tx_capture.ppdu_stats_queue_depth >
  2752. DP_TX_PPDU_PROC_THRESHOLD) ||
  2753. (pdev->tx_capture.ppdu_stats_next_sched <= now_ms)) {
  2754. qdf_queue_work(0, pdev->tx_capture.ppdu_stats_workqueue,
  2755. &pdev->tx_capture.ppdu_stats_work);
  2756. pdev->tx_capture.ppdu_stats_next_sched =
  2757. now_ms + DP_TX_PPDU_PROC_TIMEOUT;
  2758. }
  2759. }
  2760. static void set_mpdu_info(
  2761. struct cdp_tx_indication_info *tx_capture_info,
  2762. struct mon_rx_status *rx_status,
  2763. struct mon_rx_user_status *rx_user_status)
  2764. {
  2765. struct cdp_tx_indication_mpdu_info *mpdu_info;
  2766. qdf_mem_set(tx_capture_info,
  2767. sizeof(struct cdp_tx_indication_info), 0);
  2768. mpdu_info = &tx_capture_info->mpdu_info;
  2769. mpdu_info->ppdu_start_timestamp = rx_status->tsft + 16;
  2770. mpdu_info->channel_num = rx_status->chan_num;
  2771. mpdu_info->bw = 0;
  2772. if (mpdu_info->channel_num < 20)
  2773. mpdu_info->preamble = DOT11_B;
  2774. else
  2775. mpdu_info->preamble = DOT11_A;
  2776. mpdu_info->mcs = CDP_LEGACY_MCS3;
  2777. }
  2778. static void dp_gen_ack_frame(struct hal_rx_ppdu_info *ppdu_info,
  2779. struct dp_peer *peer,
  2780. qdf_nbuf_t mpdu_nbuf)
  2781. {
  2782. struct ieee80211_frame_min_one *wh_addr1;
  2783. wh_addr1 = (struct ieee80211_frame_min_one *)
  2784. qdf_nbuf_data(mpdu_nbuf);
  2785. wh_addr1->i_fc[0] = 0;
  2786. wh_addr1->i_fc[1] = 0;
  2787. wh_addr1->i_fc[0] = IEEE80211_FC0_VERSION_0 |
  2788. IEEE80211_FC0_TYPE_CTL |
  2789. IEEE80211_FC0_SUBTYPE_ACK;
  2790. if (peer) {
  2791. qdf_mem_copy(wh_addr1->i_addr1,
  2792. &peer->mac_addr.raw[0],
  2793. QDF_MAC_ADDR_SIZE);
  2794. } else {
  2795. qdf_mem_copy(wh_addr1->i_addr1,
  2796. &ppdu_info->nac_info.mac_addr2[0],
  2797. QDF_MAC_ADDR_SIZE);
  2798. }
  2799. *(u_int16_t *)(&wh_addr1->i_dur) = qdf_cpu_to_le16(0x0000);
  2800. qdf_nbuf_set_pktlen(mpdu_nbuf, sizeof(*wh_addr1));
  2801. }
  2802. static void dp_gen_block_ack_frame(
  2803. struct mon_rx_user_status *rx_user_status,
  2804. struct mon_rx_user_info *rx_user_info,
  2805. struct dp_peer *peer,
  2806. qdf_nbuf_t mpdu_nbuf)
  2807. {
  2808. struct dp_vdev *vdev = NULL;
  2809. uint32_t tid;
  2810. struct dp_tx_tid *tx_tid;
  2811. struct ieee80211_ctlframe_addr2 *wh_addr2;
  2812. uint8_t *frm;
  2813. tid = rx_user_status->tid;
  2814. tx_tid = &peer->tx_capture.tx_tid[tid];
  2815. if (!rx_user_info->bar_frame) {
  2816. tx_tid->first_data_seq_ctrl =
  2817. rx_user_status->first_data_seq_ctrl;
  2818. tx_tid->mpdu_cnt = rx_user_status->mpdu_cnt_fcs_ok +
  2819. rx_user_status->mpdu_cnt_fcs_err;
  2820. if (tx_tid->mpdu_cnt > DP_MAX_MPDU_64)
  2821. qdf_mem_copy(tx_tid->mpdu_fcs_ok_bitmap,
  2822. rx_user_status->mpdu_fcs_ok_bitmap,
  2823. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP * sizeof(
  2824. rx_user_status->mpdu_fcs_ok_bitmap[0]));
  2825. else
  2826. qdf_mem_copy(tx_tid->mpdu_fcs_ok_bitmap,
  2827. rx_user_status->mpdu_fcs_ok_bitmap,
  2828. DP_NUM_WORDS_PER_PPDU_BITMAP_64 * sizeof(
  2829. rx_user_status->mpdu_fcs_ok_bitmap[0]));
  2830. }
  2831. wh_addr2 = (struct ieee80211_ctlframe_addr2 *)
  2832. qdf_nbuf_data(mpdu_nbuf);
  2833. qdf_mem_zero(wh_addr2, DP_BA_ACK_FRAME_SIZE);
  2834. wh_addr2->i_fc[0] = 0;
  2835. wh_addr2->i_fc[1] = 0;
  2836. wh_addr2->i_fc[0] = IEEE80211_FC0_VERSION_0 |
  2837. IEEE80211_FC0_TYPE_CTL |
  2838. IEEE80211_FC0_BLOCK_ACK;
  2839. *(u_int16_t *)(&wh_addr2->i_aidordur) = qdf_cpu_to_le16(0x0000);
  2840. vdev = peer->vdev;
  2841. if (vdev)
  2842. qdf_mem_copy(wh_addr2->i_addr2, vdev->mac_addr.raw,
  2843. QDF_MAC_ADDR_SIZE);
  2844. qdf_mem_copy(wh_addr2->i_addr1, &peer->mac_addr.raw[0],
  2845. QDF_MAC_ADDR_SIZE);
  2846. frm = (uint8_t *)&wh_addr2[1];
  2847. *((uint16_t *)frm) =
  2848. qdf_cpu_to_le16((rx_user_status->tid <<
  2849. DP_IEEE80211_BAR_CTL_TID_S) |
  2850. DP_IEEE80211_BAR_CTL_COMBA);
  2851. frm += 2;
  2852. *((uint16_t *)frm) =
  2853. tx_tid->first_data_seq_ctrl;
  2854. frm += 2;
  2855. if (tx_tid->mpdu_cnt > DP_MAX_MPDU_64) {
  2856. qdf_mem_copy(frm,
  2857. tx_tid->mpdu_fcs_ok_bitmap,
  2858. HAL_RX_NUM_WORDS_PER_PPDU_BITMAP *
  2859. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  2860. frm += DP_NUM_BYTES_PER_PPDU_BITMAP;
  2861. } else {
  2862. qdf_mem_copy(frm,
  2863. tx_tid->mpdu_fcs_ok_bitmap,
  2864. DP_NUM_WORDS_PER_PPDU_BITMAP_64 *
  2865. sizeof(rx_user_status->mpdu_fcs_ok_bitmap[0]));
  2866. frm += DP_NUM_BYTES_PER_PPDU_BITMAP_64;
  2867. }
  2868. qdf_nbuf_set_pktlen(mpdu_nbuf,
  2869. (frm - (uint8_t *)qdf_nbuf_data(mpdu_nbuf)));
  2870. }
  2871. static void dp_gen_cts_frame(struct hal_rx_ppdu_info *ppdu_info,
  2872. struct dp_peer *peer,
  2873. qdf_nbuf_t mpdu_nbuf)
  2874. {
  2875. struct ieee80211_frame_min_one *wh_addr1;
  2876. uint16_t duration;
  2877. wh_addr1 = (struct ieee80211_frame_min_one *)
  2878. qdf_nbuf_data(mpdu_nbuf);
  2879. wh_addr1->i_fc[0] = 0;
  2880. wh_addr1->i_fc[1] = 0;
  2881. wh_addr1->i_fc[0] = IEEE80211_FC0_VERSION_0 |
  2882. IEEE80211_FC0_TYPE_CTL |
  2883. IEEE80211_FC0_SUBTYPE_CTS;
  2884. qdf_mem_copy(wh_addr1->i_addr1, &peer->mac_addr.raw[0],
  2885. QDF_MAC_ADDR_SIZE);
  2886. duration = (ppdu_info->rx_status.duration > SIFS_INTERVAL) ?
  2887. ppdu_info->rx_status.duration - SIFS_INTERVAL : 0;
  2888. wh_addr1->i_dur[0] = duration & 0xff;
  2889. wh_addr1->i_dur[1] = (duration >> 8) & 0xff;
  2890. qdf_nbuf_set_pktlen(mpdu_nbuf, sizeof(*wh_addr1));
  2891. }
  2892. /**
  2893. * dp_send_cts_frame_to_stack(): Function to deliver HW generated CTS frame
  2894. * in reponse to RTS
  2895. * @soc: core txrx main context
  2896. * @pdev: DP pdev object
  2897. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  2898. *
  2899. * return: status
  2900. */
  2901. QDF_STATUS dp_send_cts_frame_to_stack(struct dp_soc *soc,
  2902. struct dp_pdev *pdev,
  2903. struct hal_rx_ppdu_info *ppdu_info)
  2904. {
  2905. struct cdp_tx_indication_info tx_capture_info;
  2906. struct mon_rx_user_status *rx_user_status =
  2907. &ppdu_info->rx_user_status[0];
  2908. struct dp_ast_entry *ast_entry;
  2909. uint32_t peer_id;
  2910. struct dp_peer *peer;
  2911. if (rx_user_status->ast_index >=
  2912. wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  2913. return QDF_STATUS_E_FAILURE;
  2914. }
  2915. qdf_spin_lock_bh(&soc->ast_lock);
  2916. ast_entry = soc->ast_table[rx_user_status->ast_index];
  2917. if (!ast_entry) {
  2918. qdf_spin_unlock_bh(&soc->ast_lock);
  2919. return QDF_STATUS_E_FAILURE;
  2920. }
  2921. peer = ast_entry->peer;
  2922. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  2923. qdf_spin_unlock_bh(&soc->ast_lock);
  2924. return QDF_STATUS_E_FAILURE;
  2925. }
  2926. peer_id = peer->peer_ids[0];
  2927. qdf_spin_unlock_bh(&soc->ast_lock);
  2928. peer = dp_peer_find_by_id(soc, peer_id);
  2929. if (!peer)
  2930. return QDF_STATUS_E_FAILURE;
  2931. if (!dp_peer_or_pdev_tx_cap_enabled(pdev,
  2932. peer)) {
  2933. dp_peer_unref_del_find_by_id(peer);
  2934. return QDF_STATUS_E_FAILURE;
  2935. }
  2936. set_mpdu_info(&tx_capture_info,
  2937. &ppdu_info->rx_status, rx_user_status);
  2938. tx_capture_info.mpdu_info.mcs = rx_user_status->mcs;
  2939. /* ppdu_desc is not required for legacy frames */
  2940. tx_capture_info.ppdu_desc = NULL;
  2941. tx_capture_info.mpdu_nbuf =
  2942. qdf_nbuf_alloc(pdev->soc->osdev,
  2943. MAX_MONITOR_HEADER +
  2944. DP_CTS_FRAME_SIZE,
  2945. MAX_MONITOR_HEADER,
  2946. 4, FALSE);
  2947. if (!tx_capture_info.mpdu_nbuf) {
  2948. dp_peer_unref_del_find_by_id(peer);
  2949. return QDF_STATUS_E_NOMEM;
  2950. }
  2951. dp_gen_cts_frame(ppdu_info, peer,
  2952. tx_capture_info.mpdu_nbuf);
  2953. dp_peer_unref_del_find_by_id(peer);
  2954. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  2955. &tx_capture_info, HTT_INVALID_PEER,
  2956. WDI_NO_VAL, pdev->pdev_id);
  2957. return QDF_STATUS_SUCCESS;
  2958. }
  2959. /**
  2960. * dp_send_ack_frame_to_stack(): Function to generate BA or ACK frame and
  2961. * send to upper layer on received unicast frame
  2962. * @soc: core txrx main context
  2963. * @pdev: DP pdev object
  2964. * @ppdu_info: HAL RX PPDU info retrieved from status ring TLV
  2965. *
  2966. * return: status
  2967. */
  2968. QDF_STATUS dp_send_ack_frame_to_stack(struct dp_soc *soc,
  2969. struct dp_pdev *pdev,
  2970. struct hal_rx_ppdu_info *ppdu_info)
  2971. {
  2972. struct cdp_tx_indication_info tx_capture_info;
  2973. struct dp_peer *peer;
  2974. struct dp_ast_entry *ast_entry;
  2975. uint32_t peer_id;
  2976. struct mon_rx_status *rx_status;
  2977. struct mon_rx_user_status *rx_user_status;
  2978. struct mon_rx_user_info *rx_user_info;
  2979. uint32_t ast_index;
  2980. uint32_t i;
  2981. bool bar_frame;
  2982. rx_status = &ppdu_info->rx_status;
  2983. if (!rx_status->rxpcu_filter_pass)
  2984. return QDF_STATUS_SUCCESS;
  2985. if (ppdu_info->sw_frame_group_id ==
  2986. HAL_MPDU_SW_FRAME_GROUP_MGMT_BEACON)
  2987. return QDF_STATUS_SUCCESS;
  2988. if (ppdu_info->sw_frame_group_id == HAL_MPDU_SW_FRAME_GROUP_MGMT_PROBE_REQ &&
  2989. (ppdu_info->rx_info.mac_addr1[0] & 1)) {
  2990. return QDF_STATUS_SUCCESS;
  2991. }
  2992. if (ppdu_info->sw_frame_group_id ==
  2993. HAL_MPDU_SW_FRAME_GROUP_CTRL_RTS)
  2994. return dp_send_cts_frame_to_stack(soc, pdev, ppdu_info);
  2995. if (ppdu_info->sw_frame_group_id == HAL_MPDU_SW_FRAME_GROUP_CTRL_BAR)
  2996. bar_frame = true;
  2997. else
  2998. bar_frame = false;
  2999. for (i = 0; i < ppdu_info->com_info.num_users; i++) {
  3000. if (i > OFDMA_NUM_USERS)
  3001. return QDF_STATUS_E_FAULT;
  3002. rx_user_status = &ppdu_info->rx_user_status[i];
  3003. rx_user_info = &ppdu_info->rx_user_info[i];
  3004. rx_user_info->bar_frame = bar_frame;
  3005. if (rx_user_info->qos_control_info_valid &&
  3006. ((rx_user_info->qos_control &
  3007. IEEE80211_QOS_ACKPOLICY) >> IEEE80211_QOS_ACKPOLICY_S)
  3008. == IEEE80211_BAR_CTL_NOACK)
  3009. continue;
  3010. ast_index = rx_user_status->ast_index;
  3011. if (ast_index >=
  3012. wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
  3013. set_mpdu_info(&tx_capture_info,
  3014. rx_status, rx_user_status);
  3015. tx_capture_info.mpdu_nbuf =
  3016. qdf_nbuf_alloc(pdev->soc->osdev,
  3017. MAX_MONITOR_HEADER +
  3018. DP_BA_ACK_FRAME_SIZE,
  3019. MAX_MONITOR_HEADER,
  3020. 4, FALSE);
  3021. if (!tx_capture_info.mpdu_nbuf)
  3022. continue;
  3023. dp_gen_ack_frame(ppdu_info, NULL,
  3024. tx_capture_info.mpdu_nbuf);
  3025. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  3026. &tx_capture_info, HTT_INVALID_PEER,
  3027. WDI_NO_VAL, pdev->pdev_id);
  3028. continue;
  3029. }
  3030. qdf_spin_lock_bh(&soc->ast_lock);
  3031. ast_entry = soc->ast_table[ast_index];
  3032. if (!ast_entry) {
  3033. qdf_spin_unlock_bh(&soc->ast_lock);
  3034. continue;
  3035. }
  3036. peer = ast_entry->peer;
  3037. if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
  3038. qdf_spin_unlock_bh(&soc->ast_lock);
  3039. continue;
  3040. }
  3041. peer_id = peer->peer_ids[0];
  3042. qdf_spin_unlock_bh(&soc->ast_lock);
  3043. peer = dp_peer_find_by_id(soc, peer_id);
  3044. if (!peer)
  3045. continue;
  3046. if (!dp_peer_or_pdev_tx_cap_enabled(pdev,
  3047. peer)) {
  3048. dp_peer_unref_del_find_by_id(peer);
  3049. continue;
  3050. }
  3051. set_mpdu_info(&tx_capture_info,
  3052. rx_status, rx_user_status);
  3053. tx_capture_info.mpdu_nbuf =
  3054. qdf_nbuf_alloc(pdev->soc->osdev,
  3055. MAX_MONITOR_HEADER +
  3056. DP_BA_ACK_FRAME_SIZE,
  3057. MAX_MONITOR_HEADER,
  3058. 4, FALSE);
  3059. if (!tx_capture_info.mpdu_nbuf) {
  3060. dp_peer_unref_del_find_by_id(peer);
  3061. return QDF_STATUS_E_NOMEM;
  3062. }
  3063. if (peer->rx_tid[rx_user_status->tid].ba_status ==
  3064. DP_RX_BA_ACTIVE) {
  3065. dp_gen_block_ack_frame(rx_user_status,
  3066. rx_user_info,
  3067. peer,
  3068. tx_capture_info.mpdu_nbuf);
  3069. tx_capture_info.mpdu_info.tid = rx_user_status->tid;
  3070. } else {
  3071. dp_gen_ack_frame(ppdu_info, peer,
  3072. tx_capture_info.mpdu_nbuf);
  3073. }
  3074. dp_peer_unref_del_find_by_id(peer);
  3075. dp_wdi_event_handler(WDI_EVENT_TX_DATA, pdev->soc,
  3076. &tx_capture_info, HTT_INVALID_PEER,
  3077. WDI_NO_VAL, pdev->pdev_id);
  3078. }
  3079. return QDF_STATUS_SUCCESS;
  3080. }
  3081. /**
  3082. * dp_peer_set_tx_capture_enabled: Set tx_cap_enabled bit in peer
  3083. * @peer: Peer handle
  3084. * @value: Enable/disable setting for tx_cap_enabled
  3085. *
  3086. * Return: None
  3087. */
  3088. void
  3089. dp_peer_set_tx_capture_enabled(struct dp_peer *peer, bool value)
  3090. {
  3091. peer->tx_cap_enabled = value;
  3092. if (!value)
  3093. dp_peer_tx_cap_tid_queue_flush(peer);
  3094. }
  3095. #endif