0073-ath9k-remove-intermediate-queueing-patch-until-it-is-fixed-properly.patch 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 13 Oct 2016 10:01:19 +0200
  3. Subject: ath9k: remove intermediate queueing patch until it is fixed properly
  4. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  5. Backport of LEDE 04a69843198f2252992812e35ac05016db4a1a94
  6. diff --git a/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch b/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch
  7. deleted file mode 100644
  8. index f8b8f86..0000000
  9. --- a/package/kernel/mac80211/patches/320-ath9k-Switch-to-using-mac80211-intermediate-software.patch
  10. +++ /dev/null
  11. @@ -1,871 +0,0 @@
  12. -From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
  13. -Date: Wed, 6 Jul 2016 21:34:17 +0200
  14. -Subject: [PATCH] ath9k: Switch to using mac80211 intermediate software queues.
  15. -MIME-Version: 1.0
  16. -Content-Type: text/plain; charset=UTF-8
  17. -Content-Transfer-Encoding: 8bit
  18. -
  19. -This switches ath9k over to using the mac80211 intermediate software
  20. -queueing mechanism for data packets. It removes the queueing inside the
  21. -driver, except for the retry queue, and instead pulls from mac80211 when
  22. -a packet is needed. The retry queue is used to store a packet that was
  23. -pulled but can't be sent immediately.
  24. -
  25. -The old code path in ath_tx_start that would queue packets has been
  26. -removed completely, as has the qlen limit tunables (since there's no
  27. -longer a queue in the driver to limit).
  28. -
  29. -Based on Tim's original patch set, but reworked quite thoroughly.
  30. -
  31. -Cc: Tim Shepard <shep@alum.mit.edu>
  32. -Cc: Felix Fietkau <nbd@nbd.name>
  33. -Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
  34. ----
  35. -
  36. ---- a/drivers/net/wireless/ath/ath9k/ath9k.h
  37. -+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
  38. -@@ -91,7 +91,6 @@ int ath_descdma_setup(struct ath_softc *
  39. - #define ATH_RXBUF 512
  40. - #define ATH_TXBUF 512
  41. - #define ATH_TXBUF_RESERVE 5
  42. --#define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
  43. - #define ATH_TXMAXTRY 13
  44. - #define ATH_MAX_SW_RETRIES 30
  45. -
  46. -@@ -145,7 +144,9 @@ int ath_descdma_setup(struct ath_softc *
  47. - #define BAW_WITHIN(_start, _bawsz, _seqno) \
  48. - ((((_seqno) - (_start)) & 4095) < (_bawsz))
  49. -
  50. --#define ATH_AN_2_TID(_an, _tidno) (&(_an)->tid[(_tidno)])
  51. -+#define ATH_STA_2_TID(_sta, _tidno) ((struct ath_atx_tid *)(_sta)->txq[_tidno]->drv_priv)
  52. -+#define ATH_VIF_2_TID(_vif) ((struct ath_atx_tid *)(_vif)->txq->drv_priv)
  53. -+#define ATH_AN_2_TID(_an, _tidno) ((_an)->sta ? ATH_STA_2_TID((_an)->sta, _tidno) : ATH_VIF_2_TID((_an)->vif))
  54. -
  55. - #define IS_HT_RATE(rate) (rate & 0x80)
  56. - #define IS_CCK_RATE(rate) ((rate >= 0x18) && (rate <= 0x1e))
  57. -@@ -164,7 +165,6 @@ struct ath_txq {
  58. - spinlock_t axq_lock;
  59. - u32 axq_depth;
  60. - u32 axq_ampdu_depth;
  61. -- bool stopped;
  62. - bool axq_tx_inprogress;
  63. - struct list_head txq_fifo[ATH_TXFIFO_DEPTH];
  64. - u8 txq_headidx;
  65. -@@ -232,7 +232,6 @@ struct ath_buf {
  66. -
  67. - struct ath_atx_tid {
  68. - struct list_head list;
  69. -- struct sk_buff_head buf_q;
  70. - struct sk_buff_head retry_q;
  71. - struct ath_node *an;
  72. - struct ath_txq *txq;
  73. -@@ -247,13 +246,13 @@ struct ath_atx_tid {
  74. - s8 bar_index;
  75. - bool active;
  76. - bool clear_ps_filter;
  77. -+ bool has_queued;
  78. - };
  79. -
  80. - struct ath_node {
  81. - struct ath_softc *sc;
  82. - struct ieee80211_sta *sta; /* station struct we're part of */
  83. - struct ieee80211_vif *vif; /* interface with which we're associated */
  84. -- struct ath_atx_tid tid[IEEE80211_NUM_TIDS];
  85. -
  86. - u16 maxampdu;
  87. - u8 mpdudensity;
  88. -@@ -276,7 +275,6 @@ struct ath_tx_control {
  89. - struct ath_node *an;
  90. - struct ieee80211_sta *sta;
  91. - u8 paprd;
  92. -- bool force_channel;
  93. - };
  94. -
  95. -
  96. -@@ -293,7 +291,6 @@ struct ath_tx {
  97. - struct ath_descdma txdma;
  98. - struct ath_txq *txq_map[IEEE80211_NUM_ACS];
  99. - struct ath_txq *uapsdq;
  100. -- u32 txq_max_pending[IEEE80211_NUM_ACS];
  101. - u16 max_aggr_framelen[IEEE80211_NUM_ACS][4][32];
  102. - };
  103. -
  104. -@@ -585,6 +582,7 @@ void ath9k_release_buffered_frames(struc
  105. - u16 tids, int nframes,
  106. - enum ieee80211_frame_release_type reason,
  107. - bool more_data);
  108. -+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue);
  109. -
  110. - /********/
  111. - /* VIFs */
  112. ---- a/drivers/net/wireless/ath/ath9k/channel.c
  113. -+++ b/drivers/net/wireless/ath/ath9k/channel.c
  114. -@@ -1007,7 +1007,6 @@ static void ath_scan_send_probe(struct a
  115. - goto error;
  116. -
  117. - txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
  118. -- txctl.force_channel = true;
  119. - if (ath_tx_start(sc->hw, skb, &txctl))
  120. - goto error;
  121. -
  122. -@@ -1130,7 +1129,6 @@ ath_chanctx_send_vif_ps_frame(struct ath
  123. - memset(&txctl, 0, sizeof(txctl));
  124. - txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
  125. - txctl.sta = sta;
  126. -- txctl.force_channel = true;
  127. - if (ath_tx_start(sc->hw, skb, &txctl)) {
  128. - ieee80211_free_txskb(sc->hw, skb);
  129. - return false;
  130. ---- a/drivers/net/wireless/ath/ath9k/debug.c
  131. -+++ b/drivers/net/wireless/ath/ath9k/debug.c
  132. -@@ -600,7 +600,6 @@ static int read_file_xmit(struct seq_fil
  133. - PR("MPDUs XRetried: ", xretries);
  134. - PR("Aggregates: ", a_aggr);
  135. - PR("AMPDUs Queued HW:", a_queued_hw);
  136. -- PR("AMPDUs Queued SW:", a_queued_sw);
  137. - PR("AMPDUs Completed:", a_completed);
  138. - PR("AMPDUs Retried: ", a_retries);
  139. - PR("AMPDUs XRetried: ", a_xretries);
  140. -@@ -629,8 +628,7 @@ static void print_queue(struct ath_softc
  141. - seq_printf(file, "%s: %d ", "qnum", txq->axq_qnum);
  142. - seq_printf(file, "%s: %2d ", "qdepth", txq->axq_depth);
  143. - seq_printf(file, "%s: %2d ", "ampdu-depth", txq->axq_ampdu_depth);
  144. -- seq_printf(file, "%s: %3d ", "pending", txq->pending_frames);
  145. -- seq_printf(file, "%s: %d\n", "stopped", txq->stopped);
  146. -+ seq_printf(file, "%s: %3d\n", "pending", txq->pending_frames);
  147. -
  148. - ath_txq_unlock(sc, txq);
  149. - }
  150. -@@ -1208,7 +1206,6 @@ static const char ath9k_gstrings_stats[]
  151. - AMKSTR(d_tx_mpdu_xretries),
  152. - AMKSTR(d_tx_aggregates),
  153. - AMKSTR(d_tx_ampdus_queued_hw),
  154. -- AMKSTR(d_tx_ampdus_queued_sw),
  155. - AMKSTR(d_tx_ampdus_completed),
  156. - AMKSTR(d_tx_ampdu_retries),
  157. - AMKSTR(d_tx_ampdu_xretries),
  158. -@@ -1288,7 +1285,6 @@ void ath9k_get_et_stats(struct ieee80211
  159. - AWDATA(xretries);
  160. - AWDATA(a_aggr);
  161. - AWDATA(a_queued_hw);
  162. -- AWDATA(a_queued_sw);
  163. - AWDATA(a_completed);
  164. - AWDATA(a_retries);
  165. - AWDATA(a_xretries);
  166. -@@ -1346,14 +1342,6 @@ int ath9k_init_debug(struct ath_hw *ah)
  167. - read_file_xmit);
  168. - debugfs_create_devm_seqfile(sc->dev, "queues", sc->debug.debugfs_phy,
  169. - read_file_queues);
  170. -- debugfs_create_u32("qlen_bk", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  171. -- &sc->tx.txq_max_pending[IEEE80211_AC_BK]);
  172. -- debugfs_create_u32("qlen_be", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  173. -- &sc->tx.txq_max_pending[IEEE80211_AC_BE]);
  174. -- debugfs_create_u32("qlen_vi", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  175. -- &sc->tx.txq_max_pending[IEEE80211_AC_VI]);
  176. -- debugfs_create_u32("qlen_vo", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy,
  177. -- &sc->tx.txq_max_pending[IEEE80211_AC_VO]);
  178. - debugfs_create_devm_seqfile(sc->dev, "misc", sc->debug.debugfs_phy,
  179. - read_file_misc);
  180. - debugfs_create_devm_seqfile(sc->dev, "reset", sc->debug.debugfs_phy,
  181. ---- a/drivers/net/wireless/ath/ath9k/debug.h
  182. -+++ b/drivers/net/wireless/ath/ath9k/debug.h
  183. -@@ -147,7 +147,6 @@ struct ath_interrupt_stats {
  184. - * @completed: Total MPDUs (non-aggr) completed
  185. - * @a_aggr: Total no. of aggregates queued
  186. - * @a_queued_hw: Total AMPDUs queued to hardware
  187. -- * @a_queued_sw: Total AMPDUs queued to software queues
  188. - * @a_completed: Total AMPDUs completed
  189. - * @a_retries: No. of AMPDUs retried (SW)
  190. - * @a_xretries: No. of AMPDUs dropped due to xretries
  191. -@@ -174,7 +173,6 @@ struct ath_tx_stats {
  192. - u32 xretries;
  193. - u32 a_aggr;
  194. - u32 a_queued_hw;
  195. -- u32 a_queued_sw;
  196. - u32 a_completed;
  197. - u32 a_retries;
  198. - u32 a_xretries;
  199. ---- a/drivers/net/wireless/ath/ath9k/debug_sta.c
  200. -+++ b/drivers/net/wireless/ath/ath9k/debug_sta.c
  201. -@@ -52,8 +52,8 @@ static ssize_t read_file_node_aggr(struc
  202. - "TID", "SEQ_START", "SEQ_NEXT", "BAW_SIZE",
  203. - "BAW_HEAD", "BAW_TAIL", "BAR_IDX", "SCHED", "PAUSED");
  204. -
  205. -- for (tidno = 0, tid = &an->tid[tidno];
  206. -- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  207. -+ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
  208. -+ tid = ATH_STA_2_TID(an->sta, tidno);
  209. - txq = tid->txq;
  210. - ath_txq_lock(sc, txq);
  211. - if (tid->active) {
  212. ---- a/drivers/net/wireless/ath/ath9k/init.c
  213. -+++ b/drivers/net/wireless/ath/ath9k/init.c
  214. -@@ -358,7 +358,6 @@ static int ath9k_init_queues(struct ath_
  215. - for (i = 0; i < IEEE80211_NUM_ACS; i++) {
  216. - sc->tx.txq_map[i] = ath_txq_setup(sc, ATH9K_TX_QUEUE_DATA, i);
  217. - sc->tx.txq_map[i]->mac80211_qnum = i;
  218. -- sc->tx.txq_max_pending[i] = ATH_MAX_QDEPTH;
  219. - }
  220. - return 0;
  221. - }
  222. -@@ -873,6 +872,7 @@ static void ath9k_set_hw_capab(struct at
  223. - hw->max_rate_tries = 10;
  224. - hw->sta_data_size = sizeof(struct ath_node);
  225. - hw->vif_data_size = sizeof(struct ath_vif);
  226. -+ hw->txq_data_size = sizeof(struct ath_atx_tid);
  227. - hw->extra_tx_headroom = 4;
  228. -
  229. - hw->wiphy->available_antennas_rx = BIT(ah->caps.max_rxchains) - 1;
  230. ---- a/drivers/net/wireless/ath/ath9k/main.c
  231. -+++ b/drivers/net/wireless/ath/ath9k/main.c
  232. -@@ -2695,4 +2695,5 @@ struct ieee80211_ops ath9k_ops = {
  233. - .sw_scan_start = ath9k_sw_scan_start,
  234. - .sw_scan_complete = ath9k_sw_scan_complete,
  235. - .get_txpower = ath9k_get_txpower,
  236. -+ .wake_tx_queue = ath9k_wake_tx_queue,
  237. - };
  238. ---- a/drivers/net/wireless/ath/ath9k/xmit.c
  239. -+++ b/drivers/net/wireless/ath/ath9k/xmit.c
  240. -@@ -65,6 +65,8 @@ static struct ath_buf *ath_tx_setup_buff
  241. - struct ath_txq *txq,
  242. - struct ath_atx_tid *tid,
  243. - struct sk_buff *skb);
  244. -+static int ath_tx_prepare(struct ieee80211_hw *hw, struct sk_buff *skb,
  245. -+ struct ath_tx_control *txctl);
  246. -
  247. - enum {
  248. - MCS_HT20,
  249. -@@ -118,6 +120,26 @@ static void ath_tx_queue_tid(struct ath_
  250. - list_add_tail(&tid->list, list);
  251. - }
  252. -
  253. -+void ath9k_wake_tx_queue(struct ieee80211_hw *hw, struct ieee80211_txq *queue)
  254. -+{
  255. -+ struct ath_softc *sc = hw->priv;
  256. -+ struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  257. -+ struct ath_atx_tid *tid = (struct ath_atx_tid *) queue->drv_priv;
  258. -+ struct ath_txq *txq = tid->txq;
  259. -+
  260. -+ ath_dbg(common, QUEUE, "Waking TX queue: %pM (%d)\n",
  261. -+ queue->sta ? queue->sta->addr : queue->vif->addr,
  262. -+ tid->tidno);
  263. -+
  264. -+ ath_txq_lock(sc, txq);
  265. -+
  266. -+ tid->has_queued = true;
  267. -+ ath_tx_queue_tid(sc, txq, tid);
  268. -+ ath_txq_schedule(sc, txq);
  269. -+
  270. -+ ath_txq_unlock(sc, txq);
  271. -+}
  272. -+
  273. - static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
  274. - {
  275. - struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  276. -@@ -160,7 +182,6 @@ static void ath_set_rates(struct ieee802
  277. - static void ath_txq_skb_done(struct ath_softc *sc, struct ath_txq *txq,
  278. - struct sk_buff *skb)
  279. - {
  280. -- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  281. - struct ath_frame_info *fi = get_frame_info(skb);
  282. - int q = fi->txq;
  283. -
  284. -@@ -171,14 +192,6 @@ static void ath_txq_skb_done(struct ath_
  285. - if (WARN_ON(--txq->pending_frames < 0))
  286. - txq->pending_frames = 0;
  287. -
  288. -- if (txq->stopped &&
  289. -- txq->pending_frames < sc->tx.txq_max_pending[q]) {
  290. -- if (ath9k_is_chanctx_enabled())
  291. -- ieee80211_wake_queue(sc->hw, info->hw_queue);
  292. -- else
  293. -- ieee80211_wake_queue(sc->hw, q);
  294. -- txq->stopped = false;
  295. -- }
  296. - }
  297. -
  298. - static struct ath_atx_tid *
  299. -@@ -188,9 +201,47 @@ ath_get_skb_tid(struct ath_softc *sc, st
  300. - return ATH_AN_2_TID(an, tidno);
  301. - }
  302. -
  303. -+static struct sk_buff *
  304. -+ath_tid_pull(struct ath_atx_tid *tid)
  305. -+{
  306. -+ struct ath_softc *sc = tid->an->sc;
  307. -+ struct ieee80211_hw *hw = sc->hw;
  308. -+ struct ath_tx_control txctl = {
  309. -+ .txq = tid->txq,
  310. -+ .sta = tid->an->sta,
  311. -+ };
  312. -+ struct sk_buff *skb;
  313. -+ struct ath_frame_info *fi;
  314. -+ int q;
  315. -+
  316. -+ if (!tid->has_queued)
  317. -+ return NULL;
  318. -+
  319. -+ skb = ieee80211_tx_dequeue(hw, container_of((void*)tid, struct ieee80211_txq, drv_priv));
  320. -+ if (!skb) {
  321. -+ tid->has_queued = false;
  322. -+ return NULL;
  323. -+ }
  324. -+
  325. -+ if (ath_tx_prepare(hw, skb, &txctl)) {
  326. -+ ieee80211_free_txskb(hw, skb);
  327. -+ return NULL;
  328. -+ }
  329. -+
  330. -+ q = skb_get_queue_mapping(skb);
  331. -+ if (tid->txq == sc->tx.txq_map[q]) {
  332. -+ fi = get_frame_info(skb);
  333. -+ fi->txq = q;
  334. -+ ++tid->txq->pending_frames;
  335. -+ }
  336. -+
  337. -+ return skb;
  338. -+ }
  339. -+
  340. -+
  341. - static bool ath_tid_has_buffered(struct ath_atx_tid *tid)
  342. - {
  343. -- return !skb_queue_empty(&tid->buf_q) || !skb_queue_empty(&tid->retry_q);
  344. -+ return !skb_queue_empty(&tid->retry_q) || tid->has_queued;
  345. - }
  346. -
  347. - static struct sk_buff *ath_tid_dequeue(struct ath_atx_tid *tid)
  348. -@@ -199,46 +250,11 @@ static struct sk_buff *ath_tid_dequeue(s
  349. -
  350. - skb = __skb_dequeue(&tid->retry_q);
  351. - if (!skb)
  352. -- skb = __skb_dequeue(&tid->buf_q);
  353. -+ skb = ath_tid_pull(tid);
  354. -
  355. - return skb;
  356. - }
  357. -
  358. --/*
  359. -- * ath_tx_tid_change_state:
  360. -- * - clears a-mpdu flag of previous session
  361. -- * - force sequence number allocation to fix next BlockAck Window
  362. -- */
  363. --static void
  364. --ath_tx_tid_change_state(struct ath_softc *sc, struct ath_atx_tid *tid)
  365. --{
  366. -- struct ath_txq *txq = tid->txq;
  367. -- struct ieee80211_tx_info *tx_info;
  368. -- struct sk_buff *skb, *tskb;
  369. -- struct ath_buf *bf;
  370. -- struct ath_frame_info *fi;
  371. --
  372. -- skb_queue_walk_safe(&tid->buf_q, skb, tskb) {
  373. -- fi = get_frame_info(skb);
  374. -- bf = fi->bf;
  375. --
  376. -- tx_info = IEEE80211_SKB_CB(skb);
  377. -- tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  378. --
  379. -- if (bf)
  380. -- continue;
  381. --
  382. -- bf = ath_tx_setup_buffer(sc, txq, tid, skb);
  383. -- if (!bf) {
  384. -- __skb_unlink(skb, &tid->buf_q);
  385. -- ath_txq_skb_done(sc, txq, skb);
  386. -- ieee80211_free_txskb(sc->hw, skb);
  387. -- continue;
  388. -- }
  389. -- }
  390. --
  391. --}
  392. --
  393. - static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
  394. - {
  395. - struct ath_txq *txq = tid->txq;
  396. -@@ -873,20 +889,16 @@ static int ath_compute_num_delims(struct
  397. -
  398. - static struct ath_buf *
  399. - ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
  400. -- struct ath_atx_tid *tid, struct sk_buff_head **q)
  401. -+ struct ath_atx_tid *tid)
  402. - {
  403. - struct ieee80211_tx_info *tx_info;
  404. - struct ath_frame_info *fi;
  405. -- struct sk_buff *skb;
  406. -+ struct sk_buff *skb, *first_skb = NULL;
  407. - struct ath_buf *bf;
  408. - u16 seqno;
  409. -
  410. - while (1) {
  411. -- *q = &tid->retry_q;
  412. -- if (skb_queue_empty(*q))
  413. -- *q = &tid->buf_q;
  414. --
  415. -- skb = skb_peek(*q);
  416. -+ skb = ath_tid_dequeue(tid);
  417. - if (!skb)
  418. - break;
  419. -
  420. -@@ -898,7 +910,6 @@ ath_tx_get_tid_subframe(struct ath_softc
  421. - bf->bf_state.stale = false;
  422. -
  423. - if (!bf) {
  424. -- __skb_unlink(skb, *q);
  425. - ath_txq_skb_done(sc, txq, skb);
  426. - ieee80211_free_txskb(sc->hw, skb);
  427. - continue;
  428. -@@ -927,8 +938,19 @@ ath_tx_get_tid_subframe(struct ath_softc
  429. - seqno = bf->bf_state.seqno;
  430. -
  431. - /* do not step over block-ack window */
  432. -- if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno))
  433. -+ if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
  434. -+ __skb_queue_tail(&tid->retry_q, skb);
  435. -+
  436. -+ /* If there are other skbs in the retry q, they are
  437. -+ * probably within the BAW, so loop immediately to get
  438. -+ * one of them. Otherwise the queue can get stuck. */
  439. -+ if (!skb_queue_is_first(&tid->retry_q, skb) && skb != first_skb) {
  440. -+ if(!first_skb) /* infinite loop prevention */
  441. -+ first_skb = skb;
  442. -+ continue;
  443. -+ }
  444. - break;
  445. -+ }
  446. -
  447. - if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) {
  448. - struct ath_tx_status ts = {};
  449. -@@ -936,7 +958,6 @@ ath_tx_get_tid_subframe(struct ath_softc
  450. -
  451. - INIT_LIST_HEAD(&bf_head);
  452. - list_add(&bf->list, &bf_head);
  453. -- __skb_unlink(skb, *q);
  454. - ath_tx_update_baw(sc, tid, seqno);
  455. - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
  456. - continue;
  457. -@@ -948,11 +969,10 @@ ath_tx_get_tid_subframe(struct ath_softc
  458. - return NULL;
  459. - }
  460. -
  461. --static bool
  462. -+static int
  463. - ath_tx_form_aggr(struct ath_softc *sc, struct ath_txq *txq,
  464. - struct ath_atx_tid *tid, struct list_head *bf_q,
  465. -- struct ath_buf *bf_first, struct sk_buff_head *tid_q,
  466. -- int *aggr_len)
  467. -+ struct ath_buf *bf_first)
  468. - {
  469. - #define PADBYTES(_len) ((4 - ((_len) % 4)) % 4)
  470. - struct ath_buf *bf = bf_first, *bf_prev = NULL;
  471. -@@ -962,12 +982,13 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  472. - struct ieee80211_tx_info *tx_info;
  473. - struct ath_frame_info *fi;
  474. - struct sk_buff *skb;
  475. -- bool closed = false;
  476. -+
  477. -
  478. - bf = bf_first;
  479. - aggr_limit = ath_lookup_rate(sc, bf, tid);
  480. -
  481. -- do {
  482. -+ while (bf)
  483. -+ {
  484. - skb = bf->bf_mpdu;
  485. - fi = get_frame_info(skb);
  486. -
  487. -@@ -976,12 +997,12 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  488. - if (nframes) {
  489. - if (aggr_limit < al + bpad + al_delta ||
  490. - ath_lookup_legacy(bf) || nframes >= h_baw)
  491. -- break;
  492. -+ goto stop;
  493. -
  494. - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
  495. - if ((tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) ||
  496. - !(tx_info->flags & IEEE80211_TX_CTL_AMPDU))
  497. -- break;
  498. -+ goto stop;
  499. - }
  500. -
  501. - /* add padding for previous frame to aggregation length */
  502. -@@ -1003,20 +1024,18 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  503. - ath_tx_addto_baw(sc, tid, bf);
  504. - bf->bf_state.ndelim = ndelim;
  505. -
  506. -- __skb_unlink(skb, tid_q);
  507. - list_add_tail(&bf->list, bf_q);
  508. - if (bf_prev)
  509. - bf_prev->bf_next = bf;
  510. -
  511. - bf_prev = bf;
  512. -
  513. -- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
  514. -- if (!bf) {
  515. -- closed = true;
  516. -- break;
  517. -- }
  518. -- } while (ath_tid_has_buffered(tid));
  519. --
  520. -+ bf = ath_tx_get_tid_subframe(sc, txq, tid);
  521. -+ }
  522. -+ goto finish;
  523. -+stop:
  524. -+ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
  525. -+finish:
  526. - bf = bf_first;
  527. - bf->bf_lastbf = bf_prev;
  528. -
  529. -@@ -1027,9 +1046,7 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  530. - TX_STAT_INC(txq->axq_qnum, a_aggr);
  531. - }
  532. -
  533. -- *aggr_len = al;
  534. --
  535. -- return closed;
  536. -+ return al;
  537. - #undef PADBYTES
  538. - }
  539. -
  540. -@@ -1406,18 +1423,15 @@ static void ath_tx_fill_desc(struct ath_
  541. - static void
  542. - ath_tx_form_burst(struct ath_softc *sc, struct ath_txq *txq,
  543. - struct ath_atx_tid *tid, struct list_head *bf_q,
  544. -- struct ath_buf *bf_first, struct sk_buff_head *tid_q)
  545. -+ struct ath_buf *bf_first)
  546. - {
  547. - struct ath_buf *bf = bf_first, *bf_prev = NULL;
  548. -- struct sk_buff *skb;
  549. - int nframes = 0;
  550. -
  551. - do {
  552. - struct ieee80211_tx_info *tx_info;
  553. -- skb = bf->bf_mpdu;
  554. -
  555. - nframes++;
  556. -- __skb_unlink(skb, tid_q);
  557. - list_add_tail(&bf->list, bf_q);
  558. - if (bf_prev)
  559. - bf_prev->bf_next = bf;
  560. -@@ -1426,13 +1440,15 @@ ath_tx_form_burst(struct ath_softc *sc,
  561. - if (nframes >= 2)
  562. - break;
  563. -
  564. -- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
  565. -+ bf = ath_tx_get_tid_subframe(sc, txq, tid);
  566. - if (!bf)
  567. - break;
  568. -
  569. - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
  570. -- if (tx_info->flags & IEEE80211_TX_CTL_AMPDU)
  571. -+ if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) {
  572. -+ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
  573. - break;
  574. -+ }
  575. -
  576. - ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
  577. - } while (1);
  578. -@@ -1443,34 +1459,33 @@ static bool ath_tx_sched_aggr(struct ath
  579. - {
  580. - struct ath_buf *bf;
  581. - struct ieee80211_tx_info *tx_info;
  582. -- struct sk_buff_head *tid_q;
  583. - struct list_head bf_q;
  584. - int aggr_len = 0;
  585. -- bool aggr, last = true;
  586. -+ bool aggr;
  587. -
  588. - if (!ath_tid_has_buffered(tid))
  589. - return false;
  590. -
  591. - INIT_LIST_HEAD(&bf_q);
  592. -
  593. -- bf = ath_tx_get_tid_subframe(sc, txq, tid, &tid_q);
  594. -+ bf = ath_tx_get_tid_subframe(sc, txq, tid);
  595. - if (!bf)
  596. - return false;
  597. -
  598. - tx_info = IEEE80211_SKB_CB(bf->bf_mpdu);
  599. - aggr = !!(tx_info->flags & IEEE80211_TX_CTL_AMPDU);
  600. - if ((aggr && txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) ||
  601. -- (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
  602. -+ (!aggr && txq->axq_depth >= ATH_NON_AGGR_MIN_QDEPTH)) {
  603. -+ __skb_queue_tail(&tid->retry_q, bf->bf_mpdu);
  604. - *stop = true;
  605. - return false;
  606. - }
  607. -
  608. - ath_set_rates(tid->an->vif, tid->an->sta, bf, false);
  609. - if (aggr)
  610. -- last = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf,
  611. -- tid_q, &aggr_len);
  612. -+ aggr_len = ath_tx_form_aggr(sc, txq, tid, &bf_q, bf);
  613. - else
  614. -- ath_tx_form_burst(sc, txq, tid, &bf_q, bf, tid_q);
  615. -+ ath_tx_form_burst(sc, txq, tid, &bf_q, bf);
  616. -
  617. - if (list_empty(&bf_q))
  618. - return false;
  619. -@@ -1513,9 +1528,6 @@ int ath_tx_aggr_start(struct ath_softc *
  620. - an->mpdudensity = density;
  621. - }
  622. -
  623. -- /* force sequence number allocation for pending frames */
  624. -- ath_tx_tid_change_state(sc, txtid);
  625. --
  626. - txtid->active = true;
  627. - *ssn = txtid->seq_start = txtid->seq_next;
  628. - txtid->bar_index = -1;
  629. -@@ -1540,7 +1552,6 @@ void ath_tx_aggr_stop(struct ath_softc *
  630. - ath_txq_lock(sc, txq);
  631. - txtid->active = false;
  632. - ath_tx_flush_tid(sc, txtid);
  633. -- ath_tx_tid_change_state(sc, txtid);
  634. - ath_txq_unlock_complete(sc, txq);
  635. - }
  636. -
  637. -@@ -1550,14 +1561,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
  638. - struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  639. - struct ath_atx_tid *tid;
  640. - struct ath_txq *txq;
  641. -- bool buffered;
  642. - int tidno;
  643. -
  644. - ath_dbg(common, XMIT, "%s called\n", __func__);
  645. -
  646. -- for (tidno = 0, tid = &an->tid[tidno];
  647. -- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  648. --
  649. -+ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
  650. -+ tid = ATH_AN_2_TID(an, tidno);
  651. - txq = tid->txq;
  652. -
  653. - ath_txq_lock(sc, txq);
  654. -@@ -1567,13 +1576,12 @@ void ath_tx_aggr_sleep(struct ieee80211_
  655. - continue;
  656. - }
  657. -
  658. -- buffered = ath_tid_has_buffered(tid);
  659. -+ if (!skb_queue_empty(&tid->retry_q))
  660. -+ ieee80211_sta_set_buffered(sta, tid->tidno, true);
  661. -
  662. - list_del_init(&tid->list);
  663. -
  664. - ath_txq_unlock(sc, txq);
  665. --
  666. -- ieee80211_sta_set_buffered(sta, tidno, buffered);
  667. - }
  668. - }
  669. -
  670. -@@ -1586,19 +1594,16 @@ void ath_tx_aggr_wakeup(struct ath_softc
  671. -
  672. - ath_dbg(common, XMIT, "%s called\n", __func__);
  673. -
  674. -- for (tidno = 0, tid = &an->tid[tidno];
  675. -- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  676. --
  677. -+ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
  678. -+ tid = ATH_AN_2_TID(an, tidno);
  679. - txq = tid->txq;
  680. -
  681. - ath_txq_lock(sc, txq);
  682. - tid->clear_ps_filter = true;
  683. --
  684. - if (ath_tid_has_buffered(tid)) {
  685. - ath_tx_queue_tid(sc, txq, tid);
  686. - ath_txq_schedule(sc, txq);
  687. - }
  688. --
  689. - ath_txq_unlock_complete(sc, txq);
  690. - }
  691. - }
  692. -@@ -1621,11 +1626,6 @@ void ath_tx_aggr_resume(struct ath_softc
  693. -
  694. - tid->baw_size = IEEE80211_MIN_AMPDU_BUF << sta->ht_cap.ampdu_factor;
  695. -
  696. -- if (ath_tid_has_buffered(tid)) {
  697. -- ath_tx_queue_tid(sc, txq, tid);
  698. -- ath_txq_schedule(sc, txq);
  699. -- }
  700. --
  701. - ath_txq_unlock_complete(sc, txq);
  702. - }
  703. -
  704. -@@ -1641,7 +1641,6 @@ void ath9k_release_buffered_frames(struc
  705. - struct ieee80211_tx_info *info;
  706. - struct list_head bf_q;
  707. - struct ath_buf *bf_tail = NULL, *bf;
  708. -- struct sk_buff_head *tid_q;
  709. - int sent = 0;
  710. - int i;
  711. -
  712. -@@ -1656,11 +1655,10 @@ void ath9k_release_buffered_frames(struc
  713. -
  714. - ath_txq_lock(sc, tid->txq);
  715. - while (nframes > 0) {
  716. -- bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid, &tid_q);
  717. -+ bf = ath_tx_get_tid_subframe(sc, sc->tx.uapsdq, tid);
  718. - if (!bf)
  719. - break;
  720. -
  721. -- __skb_unlink(bf->bf_mpdu, tid_q);
  722. - list_add_tail(&bf->list, &bf_q);
  723. - ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
  724. - if (bf_isampdu(bf)) {
  725. -@@ -1675,7 +1673,7 @@ void ath9k_release_buffered_frames(struc
  726. - sent++;
  727. - TX_STAT_INC(txq->axq_qnum, a_queued_hw);
  728. -
  729. -- if (an->sta && !ath_tid_has_buffered(tid))
  730. -+ if (an->sta && skb_queue_empty(&tid->retry_q))
  731. - ieee80211_sta_set_buffered(an->sta, i, false);
  732. - }
  733. - ath_txq_unlock_complete(sc, tid->txq);
  734. -@@ -1902,13 +1900,7 @@ bool ath_drain_all_txq(struct ath_softc
  735. - if (!ATH_TXQ_SETUP(sc, i))
  736. - continue;
  737. -
  738. -- /*
  739. -- * The caller will resume queues with ieee80211_wake_queues.
  740. -- * Mark the queue as not stopped to prevent ath_tx_complete
  741. -- * from waking the queue too early.
  742. -- */
  743. - txq = &sc->tx.txq[i];
  744. -- txq->stopped = false;
  745. - ath_draintxq(sc, txq);
  746. - }
  747. -
  748. -@@ -2308,15 +2300,12 @@ int ath_tx_start(struct ieee80211_hw *hw
  749. - struct ath_txq *txq = txctl->txq;
  750. - struct ath_atx_tid *tid = NULL;
  751. - struct ath_buf *bf;
  752. -- bool queue, ps_resp;
  753. -+ bool ps_resp;
  754. - int q, ret;
  755. -
  756. - if (vif)
  757. - avp = (void *)vif->drv_priv;
  758. -
  759. -- if (info->flags & IEEE80211_TX_CTL_TX_OFFCHAN)
  760. -- txctl->force_channel = true;
  761. --
  762. - ps_resp = !!(info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE);
  763. -
  764. - ret = ath_tx_prepare(hw, skb, txctl);
  765. -@@ -2331,63 +2320,13 @@ int ath_tx_start(struct ieee80211_hw *hw
  766. -
  767. - q = skb_get_queue_mapping(skb);
  768. -
  769. -+ if (ps_resp)
  770. -+ txq = sc->tx.uapsdq;
  771. -+
  772. - ath_txq_lock(sc, txq);
  773. - if (txq == sc->tx.txq_map[q]) {
  774. - fi->txq = q;
  775. -- if (++txq->pending_frames > sc->tx.txq_max_pending[q] &&
  776. -- !txq->stopped) {
  777. -- if (ath9k_is_chanctx_enabled())
  778. -- ieee80211_stop_queue(sc->hw, info->hw_queue);
  779. -- else
  780. -- ieee80211_stop_queue(sc->hw, q);
  781. -- txq->stopped = true;
  782. -- }
  783. -- }
  784. --
  785. -- queue = ieee80211_is_data_present(hdr->frame_control);
  786. --
  787. -- /* If chanctx, queue all null frames while NOA could be there */
  788. -- if (ath9k_is_chanctx_enabled() &&
  789. -- ieee80211_is_nullfunc(hdr->frame_control) &&
  790. -- !txctl->force_channel)
  791. -- queue = true;
  792. --
  793. -- /* Force queueing of all frames that belong to a virtual interface on
  794. -- * a different channel context, to ensure that they are sent on the
  795. -- * correct channel.
  796. -- */
  797. -- if (((avp && avp->chanctx != sc->cur_chan) ||
  798. -- sc->cur_chan->stopped) && !txctl->force_channel) {
  799. -- if (!txctl->an)
  800. -- txctl->an = &avp->mcast_node;
  801. -- queue = true;
  802. -- ps_resp = false;
  803. -- }
  804. --
  805. -- if (txctl->an && queue)
  806. -- tid = ath_get_skb_tid(sc, txctl->an, skb);
  807. --
  808. -- if (ps_resp) {
  809. -- ath_txq_unlock(sc, txq);
  810. -- txq = sc->tx.uapsdq;
  811. -- ath_txq_lock(sc, txq);
  812. -- } else if (txctl->an && queue) {
  813. -- WARN_ON(tid->txq != txctl->txq);
  814. --
  815. -- if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
  816. -- tid->clear_ps_filter = true;
  817. --
  818. -- /*
  819. -- * Add this frame to software queue for scheduling later
  820. -- * for aggregation.
  821. -- */
  822. -- TX_STAT_INC(txq->axq_qnum, a_queued_sw);
  823. -- __skb_queue_tail(&tid->buf_q, skb);
  824. -- if (!txctl->an->sleeping)
  825. -- ath_tx_queue_tid(sc, txq, tid);
  826. --
  827. -- ath_txq_schedule(sc, txq);
  828. -- goto out;
  829. -+ ++txq->pending_frames;
  830. - }
  831. -
  832. - bf = ath_tx_setup_buffer(sc, txq, tid, skb);
  833. -@@ -2871,9 +2810,8 @@ void ath_tx_node_init(struct ath_softc *
  834. - struct ath_atx_tid *tid;
  835. - int tidno, acno;
  836. -
  837. -- for (tidno = 0, tid = &an->tid[tidno];
  838. -- tidno < IEEE80211_NUM_TIDS;
  839. -- tidno++, tid++) {
  840. -+ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
  841. -+ tid = ATH_AN_2_TID(an, tidno);
  842. - tid->an = an;
  843. - tid->tidno = tidno;
  844. - tid->seq_start = tid->seq_next = 0;
  845. -@@ -2881,11 +2819,14 @@ void ath_tx_node_init(struct ath_softc *
  846. - tid->baw_head = tid->baw_tail = 0;
  847. - tid->active = false;
  848. - tid->clear_ps_filter = true;
  849. -- __skb_queue_head_init(&tid->buf_q);
  850. -+ tid->has_queued = false;
  851. - __skb_queue_head_init(&tid->retry_q);
  852. - INIT_LIST_HEAD(&tid->list);
  853. - acno = TID_TO_WME_AC(tidno);
  854. - tid->txq = sc->tx.txq_map[acno];
  855. -+
  856. -+ if (!an->sta)
  857. -+ break; /* just one multicast ath_atx_tid */
  858. - }
  859. - }
  860. -
  861. -@@ -2895,9 +2836,8 @@ void ath_tx_node_cleanup(struct ath_soft
  862. - struct ath_txq *txq;
  863. - int tidno;
  864. -
  865. -- for (tidno = 0, tid = &an->tid[tidno];
  866. -- tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  867. --
  868. -+ for (tidno = 0; tidno < IEEE80211_NUM_TIDS; tidno++) {
  869. -+ tid = ATH_AN_2_TID(an, tidno);
  870. - txq = tid->txq;
  871. -
  872. - ath_txq_lock(sc, txq);
  873. -@@ -2909,6 +2849,9 @@ void ath_tx_node_cleanup(struct ath_soft
  874. - tid->active = false;
  875. -
  876. - ath_txq_unlock(sc, txq);
  877. -+
  878. -+ if (!an->sta)
  879. -+ break; /* just one multicast ath_atx_tid */
  880. - }
  881. - }
  882. -