0075-ath9k-remove-patch-causing-stability-issues-with-powersave-devices-FS-176.patch 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Fri, 30 Sep 2016 16:58:01 +0200
  3. Subject: ath9k: remove patch causing stability issues with powersave devices (FS#176)
  4. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  5. Backport of LEDE fc88eb3fdfce6d39b4c62158cf6f42605a360a1e
  6. diff --git a/package/kernel/mac80211/patches/341-ath9k-release-PS-buffered-frames-as-A-MPDU-if-enable.patch b/package/kernel/mac80211/patches/341-ath9k-release-PS-buffered-frames-as-A-MPDU-if-enable.patch
  7. deleted file mode 100644
  8. index 1cc1667..0000000
  9. --- a/package/kernel/mac80211/patches/341-ath9k-release-PS-buffered-frames-as-A-MPDU-if-enable.patch
  10. +++ /dev/null
  11. @@ -1,40 +0,0 @@
  12. -From: Felix Fietkau <nbd@nbd.name>
  13. -Date: Sun, 28 Aug 2016 13:15:10 +0200
  14. -Subject: [PATCH] ath9k: release PS buffered frames as A-MPDU if enabled
  15. -
  16. -Signed-off-by: Felix Fietkau <nbd@nbd.name>
  17. ----
  18. -
  19. ---- a/drivers/net/wireless/ath/ath9k/xmit.c
  20. -+++ b/drivers/net/wireless/ath/ath9k/xmit.c
  21. -@@ -1660,10 +1660,11 @@ void ath9k_release_buffered_frames(struc
  22. - struct ath_node *an = (struct ath_node *)sta->drv_priv;
  23. - struct ath_txq *txq = sc->tx.uapsdq;
  24. - struct ieee80211_tx_info *info;
  25. -+ struct ath_frame_info *fi;
  26. - struct list_head bf_q;
  27. - struct ath_buf *bf_tail = NULL, *bf;
  28. - int sent = 0;
  29. -- int i;
  30. -+ int n, i;
  31. -
  32. - INIT_LIST_HEAD(&bf_q);
  33. - for (i = 0; tids && nframes; i++, tids >>= 1) {
  34. -@@ -1683,10 +1684,15 @@ void ath9k_release_buffered_frames(struc
  35. - ath9k_set_moredata(sc, bf, true);
  36. - list_add_tail(&bf->list, &bf_q);
  37. - ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
  38. -- if (bf_isampdu(bf)) {
  39. -+ if (bf_isampdu(bf))
  40. - ath_tx_addto_baw(sc, tid, bf);
  41. -- bf->bf_state.bf_type &= ~BUF_AGGR;
  42. -+ if (bf_isaggr(bf)) {
  43. -+ fi = get_frame_info(bf->bf_mpdu);
  44. -+ n = ath_compute_num_delims(sc, tid, bf,
  45. -+ fi->framelen, true);
  46. -+ bf->bf_state.ndelim = n;
  47. - }
  48. -+
  49. - if (bf_tail)
  50. - bf_tail->bf_next = bf;
  51. -
  52. diff --git a/package/kernel/mac80211/patches/341-ath9k-report-tx-status-on-EOSP.patch b/package/kernel/mac80211/patches/341-ath9k-report-tx-status-on-EOSP.patch
  53. new file mode 100644
  54. index 0000000..80a3074
  55. --- /dev/null
  56. +++ b/package/kernel/mac80211/patches/341-ath9k-report-tx-status-on-EOSP.patch
  57. @@ -0,0 +1,19 @@
  58. +From: Felix Fietkau <nbd@nbd.name>
  59. +Date: Sun, 28 Aug 2016 13:23:27 +0200
  60. +Subject: [PATCH] ath9k: report tx status on EOSP
  61. +
  62. +Signed-off-by: Felix Fietkau <nbd@nbd.name>
  63. +---
  64. +
  65. +--- a/drivers/net/wireless/ath/ath9k/xmit.c
  66. ++++ b/drivers/net/wireless/ath/ath9k/xmit.c
  67. +@@ -86,7 +86,8 @@ static void ath_tx_status(struct ieee802
  68. + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  69. + struct ieee80211_sta *sta = info->status.status_driver_data[0];
  70. +
  71. +- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
  72. ++ if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
  73. ++ IEEE80211_TX_STATUS_EOSP)) {
  74. + ieee80211_tx_status(hw, skb);
  75. + return;
  76. + }
  77. diff --git a/package/kernel/mac80211/patches/342-ath9k-fix-block-ack-window-tracking-issues.patch b/package/kernel/mac80211/patches/342-ath9k-fix-block-ack-window-tracking-issues.patch
  78. new file mode 100644
  79. index 0000000..fea147b
  80. --- /dev/null
  81. +++ b/package/kernel/mac80211/patches/342-ath9k-fix-block-ack-window-tracking-issues.patch
  82. @@ -0,0 +1,114 @@
  83. +From: Felix Fietkau <nbd@nbd.name>
  84. +Date: Tue, 30 Aug 2016 12:44:08 +0200
  85. +Subject: [PATCH] ath9k: fix block-ack window tracking issues
  86. +
  87. +Ensure that a buffer gets tracked as part of the block-ack window as
  88. +soon as it's dequeued from the tid for the first time. Ensure that
  89. +double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause
  90. +any issues.
  91. +
  92. +Signed-off-by: Felix Fietkau <nbd@nbd.name>
  93. +---
  94. +
  95. +--- a/drivers/net/wireless/ath/ath9k/xmit.c
  96. ++++ b/drivers/net/wireless/ath/ath9k/xmit.c
  97. +@@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_
  98. + struct ath_tx_status *ts, int nframes, int nbad,
  99. + int txok);
  100. + static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
  101. +- int seqno);
  102. ++ struct ath_buf *bf);
  103. + static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
  104. + struct ath_txq *txq,
  105. + struct ath_atx_tid *tid,
  106. +@@ -300,7 +300,7 @@ static void ath_tx_flush_tid(struct ath_
  107. + }
  108. +
  109. + if (fi->baw_tracked) {
  110. +- ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
  111. ++ ath_tx_update_baw(sc, tid, bf);
  112. + sendbar = true;
  113. + }
  114. +
  115. +@@ -316,10 +316,15 @@ static void ath_tx_flush_tid(struct ath_
  116. + }
  117. +
  118. + static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
  119. +- int seqno)
  120. ++ struct ath_buf *bf)
  121. + {
  122. ++ struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
  123. ++ u16 seqno = bf->bf_state.seqno;
  124. + int index, cindex;
  125. +
  126. ++ if (!fi->baw_tracked)
  127. ++ return;
  128. ++
  129. + index = ATH_BA_INDEX(tid->seq_start, seqno);
  130. + cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
  131. +
  132. +@@ -340,6 +345,9 @@ static void ath_tx_addto_baw(struct ath_
  133. + u16 seqno = bf->bf_state.seqno;
  134. + int index, cindex;
  135. +
  136. ++ if (fi->baw_tracked)
  137. ++ return;
  138. ++
  139. + index = ATH_BA_INDEX(tid->seq_start, seqno);
  140. + cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
  141. + __set_bit(cindex, tid->tx_buf);
  142. +@@ -616,7 +624,7 @@ static void ath_tx_complete_aggr(struct
  143. + * complete the acked-ones/xretried ones; update
  144. + * block-ack window
  145. + */
  146. +- ath_tx_update_baw(sc, tid, seqno);
  147. ++ ath_tx_update_baw(sc, tid, bf);
  148. +
  149. + if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
  150. + memcpy(tx_info->control.rates, rates, sizeof(rates));
  151. +@@ -646,7 +654,7 @@ static void ath_tx_complete_aggr(struct
  152. + * run out of tx buf.
  153. + */
  154. + if (!tbf) {
  155. +- ath_tx_update_baw(sc, tid, seqno);
  156. ++ ath_tx_update_baw(sc, tid, bf);
  157. +
  158. + ath_tx_complete_buf(sc, bf, txq,
  159. + &bf_head, NULL, ts,
  160. +@@ -986,11 +994,14 @@ ath_tx_get_tid_subframe(struct ath_softc
  161. +
  162. + INIT_LIST_HEAD(&bf_head);
  163. + list_add(&bf->list, &bf_head);
  164. +- ath_tx_update_baw(sc, tid, seqno);
  165. ++ ath_tx_update_baw(sc, tid, bf);
  166. + ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
  167. + continue;
  168. + }
  169. +
  170. ++ if (bf_isampdu(bf))
  171. ++ ath_tx_addto_baw(sc, tid, bf);
  172. ++
  173. + return bf;
  174. + }
  175. +
  176. +@@ -1048,8 +1059,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  177. + bf->bf_next = NULL;
  178. +
  179. + /* link buffers of this frame to the aggregate */
  180. +- if (!fi->baw_tracked)
  181. +- ath_tx_addto_baw(sc, tid, bf);
  182. + bf->bf_state.ndelim = ndelim;
  183. +
  184. + list_add_tail(&bf->list, bf_q);
  185. +@@ -1684,10 +1693,8 @@ void ath9k_release_buffered_frames(struc
  186. + ath9k_set_moredata(sc, bf, true);
  187. + list_add_tail(&bf->list, &bf_q);
  188. + ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
  189. +- if (bf_isampdu(bf)) {
  190. +- ath_tx_addto_baw(sc, tid, bf);
  191. ++ if (bf_isampdu(bf))
  192. + bf->bf_state.bf_type &= ~BUF_AGGR;
  193. +- }
  194. + if (bf_tail)
  195. + bf_tail->bf_next = bf;
  196. +
  197. diff --git a/package/kernel/mac80211/patches/342-ath9k-report-tx-status-on-EOSP.patch b/package/kernel/mac80211/patches/342-ath9k-report-tx-status-on-EOSP.patch
  198. deleted file mode 100644
  199. index 80a3074..0000000
  200. --- a/package/kernel/mac80211/patches/342-ath9k-report-tx-status-on-EOSP.patch
  201. +++ /dev/null
  202. @@ -1,19 +0,0 @@
  203. -From: Felix Fietkau <nbd@nbd.name>
  204. -Date: Sun, 28 Aug 2016 13:23:27 +0200
  205. -Subject: [PATCH] ath9k: report tx status on EOSP
  206. -
  207. -Signed-off-by: Felix Fietkau <nbd@nbd.name>
  208. ----
  209. -
  210. ---- a/drivers/net/wireless/ath/ath9k/xmit.c
  211. -+++ b/drivers/net/wireless/ath/ath9k/xmit.c
  212. -@@ -86,7 +86,8 @@ static void ath_tx_status(struct ieee802
  213. - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  214. - struct ieee80211_sta *sta = info->status.status_driver_data[0];
  215. -
  216. -- if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
  217. -+ if (info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
  218. -+ IEEE80211_TX_STATUS_EOSP)) {
  219. - ieee80211_tx_status(hw, skb);
  220. - return;
  221. - }
  222. diff --git a/package/kernel/mac80211/patches/343-ath9k-fix-block-ack-window-tracking-issues.patch b/package/kernel/mac80211/patches/343-ath9k-fix-block-ack-window-tracking-issues.patch
  223. deleted file mode 100644
  224. index 007a8d7d..0000000
  225. --- a/package/kernel/mac80211/patches/343-ath9k-fix-block-ack-window-tracking-issues.patch
  226. +++ /dev/null
  227. @@ -1,111 +0,0 @@
  228. -From: Felix Fietkau <nbd@nbd.name>
  229. -Date: Tue, 30 Aug 2016 12:44:08 +0200
  230. -Subject: [PATCH] ath9k: fix block-ack window tracking issues
  231. -
  232. -Ensure that a buffer gets tracked as part of the block-ack window as
  233. -soon as it's dequeued from the tid for the first time. Ensure that
  234. -double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause
  235. -any issues.
  236. -
  237. -Signed-off-by: Felix Fietkau <nbd@nbd.name>
  238. ----
  239. -
  240. ---- a/drivers/net/wireless/ath/ath9k/xmit.c
  241. -+++ b/drivers/net/wireless/ath/ath9k/xmit.c
  242. -@@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_
  243. - struct ath_tx_status *ts, int nframes, int nbad,
  244. - int txok);
  245. - static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
  246. -- int seqno);
  247. -+ struct ath_buf *bf);
  248. - static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
  249. - struct ath_txq *txq,
  250. - struct ath_atx_tid *tid,
  251. -@@ -300,7 +300,7 @@ static void ath_tx_flush_tid(struct ath_
  252. - }
  253. -
  254. - if (fi->baw_tracked) {
  255. -- ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
  256. -+ ath_tx_update_baw(sc, tid, bf);
  257. - sendbar = true;
  258. - }
  259. -
  260. -@@ -316,10 +316,15 @@ static void ath_tx_flush_tid(struct ath_
  261. - }
  262. -
  263. - static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
  264. -- int seqno)
  265. -+ struct ath_buf *bf)
  266. - {
  267. -+ struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
  268. -+ u16 seqno = bf->bf_state.seqno;
  269. - int index, cindex;
  270. -
  271. -+ if (!fi->baw_tracked)
  272. -+ return;
  273. -+
  274. - index = ATH_BA_INDEX(tid->seq_start, seqno);
  275. - cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
  276. -
  277. -@@ -340,6 +345,9 @@ static void ath_tx_addto_baw(struct ath_
  278. - u16 seqno = bf->bf_state.seqno;
  279. - int index, cindex;
  280. -
  281. -+ if (fi->baw_tracked)
  282. -+ return;
  283. -+
  284. - index = ATH_BA_INDEX(tid->seq_start, seqno);
  285. - cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
  286. - __set_bit(cindex, tid->tx_buf);
  287. -@@ -616,7 +624,7 @@ static void ath_tx_complete_aggr(struct
  288. - * complete the acked-ones/xretried ones; update
  289. - * block-ack window
  290. - */
  291. -- ath_tx_update_baw(sc, tid, seqno);
  292. -+ ath_tx_update_baw(sc, tid, bf);
  293. -
  294. - if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
  295. - memcpy(tx_info->control.rates, rates, sizeof(rates));
  296. -@@ -646,7 +654,7 @@ static void ath_tx_complete_aggr(struct
  297. - * run out of tx buf.
  298. - */
  299. - if (!tbf) {
  300. -- ath_tx_update_baw(sc, tid, seqno);
  301. -+ ath_tx_update_baw(sc, tid, bf);
  302. -
  303. - ath_tx_complete_buf(sc, bf, txq,
  304. - &bf_head, NULL, ts,
  305. -@@ -986,11 +994,14 @@ ath_tx_get_tid_subframe(struct ath_softc
  306. -
  307. - INIT_LIST_HEAD(&bf_head);
  308. - list_add(&bf->list, &bf_head);
  309. -- ath_tx_update_baw(sc, tid, seqno);
  310. -+ ath_tx_update_baw(sc, tid, bf);
  311. - ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
  312. - continue;
  313. - }
  314. -
  315. -+ if (bf_isampdu(bf))
  316. -+ ath_tx_addto_baw(sc, tid, bf);
  317. -+
  318. - return bf;
  319. - }
  320. -
  321. -@@ -1048,8 +1059,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s
  322. - bf->bf_next = NULL;
  323. -
  324. - /* link buffers of this frame to the aggregate */
  325. -- if (!fi->baw_tracked)
  326. -- ath_tx_addto_baw(sc, tid, bf);
  327. - bf->bf_state.ndelim = ndelim;
  328. -
  329. - list_add_tail(&bf->list, bf_q);
  330. -@@ -1685,8 +1694,6 @@ void ath9k_release_buffered_frames(struc
  331. - ath9k_set_moredata(sc, bf, true);
  332. - list_add_tail(&bf->list, &bf_q);
  333. - ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
  334. -- if (bf_isampdu(bf))
  335. -- ath_tx_addto_baw(sc, tid, bf);
  336. - if (bf_isaggr(bf)) {
  337. - fi = get_frame_info(bf->bf_mpdu);
  338. - n = ath_compute_num_delims(sc, tid, bf,
  339. diff --git a/package/kernel/mac80211/patches/343-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch b/package/kernel/mac80211/patches/343-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch
  340. new file mode 100644
  341. index 0000000..3bbca22
  342. --- /dev/null
  343. +++ b/package/kernel/mac80211/patches/343-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch
  344. @@ -0,0 +1,64 @@
  345. +From: Johannes Berg <johannes.berg@intel.com>
  346. +Date: Mon, 29 Aug 2016 23:25:18 +0300
  347. +Subject: [PATCH] mac80211: send delBA on unexpected BlockAck data frames
  348. +
  349. +When we receive data frames with ACK policy BlockAck, send
  350. +delBA as requested by the 802.11 spec. Since this would be
  351. +happening for every frame inside an A-MPDU if it's really
  352. +received outside a session, limit it to a single attempt.
  353. +
  354. +Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  355. +---
  356. +
  357. +--- a/net/mac80211/agg-rx.c
  358. ++++ b/net/mac80211/agg-rx.c
  359. +@@ -388,8 +388,10 @@ void __ieee80211_start_rx_ba_session(str
  360. + }
  361. +
  362. + end:
  363. +- if (status == WLAN_STATUS_SUCCESS)
  364. ++ if (status == WLAN_STATUS_SUCCESS) {
  365. + __set_bit(tid, sta->ampdu_mlme.agg_session_valid);
  366. ++ __clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
  367. ++ }
  368. + mutex_unlock(&sta->ampdu_mlme.mtx);
  369. +
  370. + end_no_lock:
  371. +--- a/net/mac80211/rx.c
  372. ++++ b/net/mac80211/rx.c
  373. +@@ -1072,8 +1072,15 @@ static void ieee80211_rx_reorder_ampdu(s
  374. + tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
  375. +
  376. + tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
  377. +- if (!tid_agg_rx)
  378. ++ if (!tid_agg_rx) {
  379. ++ if (ack_policy == IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK &&
  380. ++ !test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) &&
  381. ++ !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg))
  382. ++ ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid,
  383. ++ WLAN_BACK_RECIPIENT,
  384. ++ WLAN_REASON_QSTA_REQUIRE_SETUP);
  385. + goto dont_reorder;
  386. ++ }
  387. +
  388. + /* qos null data frames are excluded */
  389. + if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC)))
  390. +--- a/net/mac80211/sta_info.h
  391. ++++ b/net/mac80211/sta_info.h
  392. +@@ -230,6 +230,8 @@ struct tid_ampdu_rx {
  393. + * @tid_rx_stop_requested: bitmap indicating which BA sessions per TID the
  394. + * driver requested to close until the work for it runs
  395. + * @agg_session_valid: bitmap indicating which TID has a rx BA session open on
  396. ++ * @unexpected_agg: bitmap indicating which TID already sent a delBA due to
  397. ++ * unexpected aggregation related frames outside a session
  398. + * @work: work struct for starting/stopping aggregation
  399. + * @tid_tx: aggregation info for Tx per TID
  400. + * @tid_start_tx: sessions where start was requested
  401. +@@ -244,6 +246,7 @@ struct sta_ampdu_mlme {
  402. + unsigned long tid_rx_timer_expired[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  403. + unsigned long tid_rx_stop_requested[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  404. + unsigned long agg_session_valid[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  405. ++ unsigned long unexpected_agg[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  406. + /* tx */
  407. + struct work_struct work;
  408. + struct tid_ampdu_tx __rcu *tid_tx[IEEE80211_NUM_TIDS];
  409. diff --git a/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch b/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch
  410. new file mode 100644
  411. index 0000000..c3d3118
  412. --- /dev/null
  413. +++ b/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch
  414. @@ -0,0 +1,26 @@
  415. +From: Johannes Berg <johannes.berg@intel.com>
  416. +Date: Mon, 29 Aug 2016 23:25:19 +0300
  417. +Subject: [PATCH] mac80211: send delBA on unexpected BlockAck Request
  418. +
  419. +If we don't have a BA session, send delBA, as requested by the
  420. +IEEE 802.11 spec. Apply the same limit of sending such a delBA
  421. +only once as in the previous patch.
  422. +
  423. +Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  424. +---
  425. +
  426. +--- a/net/mac80211/rx.c
  427. ++++ b/net/mac80211/rx.c
  428. +@@ -2537,6 +2537,12 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_
  429. +
  430. + tid = le16_to_cpu(bar_data.control) >> 12;
  431. +
  432. ++ if (!test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) &&
  433. ++ !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg))
  434. ++ ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid,
  435. ++ WLAN_BACK_RECIPIENT,
  436. ++ WLAN_REASON_QSTA_REQUIRE_SETUP);
  437. ++
  438. + tid_agg_rx = rcu_dereference(rx->sta->ampdu_mlme.tid_rx[tid]);
  439. + if (!tid_agg_rx)
  440. + return RX_DROP_MONITOR;
  441. diff --git a/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch b/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch
  442. deleted file mode 100644
  443. index 3bbca22..0000000
  444. --- a/package/kernel/mac80211/patches/344-mac80211-send-delBA-on-unexpected-BlockAck-data-fram.patch
  445. +++ /dev/null
  446. @@ -1,64 +0,0 @@
  447. -From: Johannes Berg <johannes.berg@intel.com>
  448. -Date: Mon, 29 Aug 2016 23:25:18 +0300
  449. -Subject: [PATCH] mac80211: send delBA on unexpected BlockAck data frames
  450. -
  451. -When we receive data frames with ACK policy BlockAck, send
  452. -delBA as requested by the 802.11 spec. Since this would be
  453. -happening for every frame inside an A-MPDU if it's really
  454. -received outside a session, limit it to a single attempt.
  455. -
  456. -Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  457. ----
  458. -
  459. ---- a/net/mac80211/agg-rx.c
  460. -+++ b/net/mac80211/agg-rx.c
  461. -@@ -388,8 +388,10 @@ void __ieee80211_start_rx_ba_session(str
  462. - }
  463. -
  464. - end:
  465. -- if (status == WLAN_STATUS_SUCCESS)
  466. -+ if (status == WLAN_STATUS_SUCCESS) {
  467. - __set_bit(tid, sta->ampdu_mlme.agg_session_valid);
  468. -+ __clear_bit(tid, sta->ampdu_mlme.unexpected_agg);
  469. -+ }
  470. - mutex_unlock(&sta->ampdu_mlme.mtx);
  471. -
  472. - end_no_lock:
  473. ---- a/net/mac80211/rx.c
  474. -+++ b/net/mac80211/rx.c
  475. -@@ -1072,8 +1072,15 @@ static void ieee80211_rx_reorder_ampdu(s
  476. - tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
  477. -
  478. - tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
  479. -- if (!tid_agg_rx)
  480. -+ if (!tid_agg_rx) {
  481. -+ if (ack_policy == IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK &&
  482. -+ !test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) &&
  483. -+ !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg))
  484. -+ ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid,
  485. -+ WLAN_BACK_RECIPIENT,
  486. -+ WLAN_REASON_QSTA_REQUIRE_SETUP);
  487. - goto dont_reorder;
  488. -+ }
  489. -
  490. - /* qos null data frames are excluded */
  491. - if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC)))
  492. ---- a/net/mac80211/sta_info.h
  493. -+++ b/net/mac80211/sta_info.h
  494. -@@ -230,6 +230,8 @@ struct tid_ampdu_rx {
  495. - * @tid_rx_stop_requested: bitmap indicating which BA sessions per TID the
  496. - * driver requested to close until the work for it runs
  497. - * @agg_session_valid: bitmap indicating which TID has a rx BA session open on
  498. -+ * @unexpected_agg: bitmap indicating which TID already sent a delBA due to
  499. -+ * unexpected aggregation related frames outside a session
  500. - * @work: work struct for starting/stopping aggregation
  501. - * @tid_tx: aggregation info for Tx per TID
  502. - * @tid_start_tx: sessions where start was requested
  503. -@@ -244,6 +246,7 @@ struct sta_ampdu_mlme {
  504. - unsigned long tid_rx_timer_expired[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  505. - unsigned long tid_rx_stop_requested[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  506. - unsigned long agg_session_valid[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  507. -+ unsigned long unexpected_agg[BITS_TO_LONGS(IEEE80211_NUM_TIDS)];
  508. - /* tx */
  509. - struct work_struct work;
  510. - struct tid_ampdu_tx __rcu *tid_tx[IEEE80211_NUM_TIDS];
  511. diff --git a/package/kernel/mac80211/patches/345-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch b/package/kernel/mac80211/patches/345-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch
  512. new file mode 100644
  513. index 0000000..aba1ff4
  514. --- /dev/null
  515. +++ b/package/kernel/mac80211/patches/345-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch
  516. @@ -0,0 +1,478 @@
  517. +From: Felix Fietkau <nbd@nbd.name>
  518. +Date: Sun, 4 Sep 2016 17:46:24 +0200
  519. +Subject: [PATCH] mac80211: fix sequence number assignment for PS response
  520. + frames
  521. +
  522. +When using intermediate queues, sequence number allocation is deferred
  523. +until dequeue. This doesn't work for PS response frames, which bypass
  524. +those queues.
  525. +
  526. +Signed-off-by: Felix Fietkau <nbd@nbd.name>
  527. +---
  528. +
  529. +--- a/net/mac80211/tx.c
  530. ++++ b/net/mac80211/tx.c
  531. +@@ -38,6 +38,12 @@
  532. + #include "wme.h"
  533. + #include "rate.h"
  534. +
  535. ++static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx);
  536. ++static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  537. ++ struct sta_info *sta, u8 pn_offs,
  538. ++ struct ieee80211_key_conf *key_conf,
  539. ++ struct sk_buff *skb);
  540. ++
  541. + /* misc utils */
  542. +
  543. + static inline void ieee80211_tx_stats(struct net_device *dev, u32 len)
  544. +@@ -849,8 +855,7 @@ ieee80211_tx_h_sequence(struct ieee80211
  545. + tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
  546. + tx->sta->tx_stats.msdu[tid]++;
  547. +
  548. +- if (!tx->sta->sta.txq[0])
  549. +- hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
  550. ++ hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
  551. +
  552. + return TX_CONTINUE;
  553. + }
  554. +@@ -1398,6 +1403,7 @@ void ieee80211_txq_init(struct ieee80211
  555. + fq_tin_init(&txqi->tin);
  556. + fq_flow_init(&txqi->def_flow);
  557. + codel_vars_init(&txqi->def_cvars);
  558. ++ __skb_queue_head_init(&txqi->frags);
  559. +
  560. + txqi->txq.vif = &sdata->vif;
  561. +
  562. +@@ -1420,6 +1426,7 @@ void ieee80211_txq_purge(struct ieee8021
  563. + struct fq_tin *tin = &txqi->tin;
  564. +
  565. + fq_tin_reset(fq, tin, fq_skb_free_func);
  566. ++ ieee80211_purge_tx_queue(&local->hw, &txqi->frags);
  567. + }
  568. +
  569. + int ieee80211_txq_setup_flows(struct ieee80211_local *local)
  570. +@@ -1476,12 +1483,19 @@ struct sk_buff *ieee80211_tx_dequeue(str
  571. + struct sk_buff *skb = NULL;
  572. + struct fq *fq = &local->fq;
  573. + struct fq_tin *tin = &txqi->tin;
  574. ++ struct ieee80211_tx_info *info;
  575. +
  576. + spin_lock_bh(&fq->lock);
  577. +
  578. + if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags))
  579. + goto out;
  580. +
  581. ++ /* Make sure fragments stay together. */
  582. ++ skb = __skb_dequeue(&txqi->frags);
  583. ++ if (skb)
  584. ++ goto out;
  585. ++
  586. ++begin:
  587. + skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);
  588. + if (!skb)
  589. + goto out;
  590. +@@ -1489,16 +1503,38 @@ struct sk_buff *ieee80211_tx_dequeue(str
  591. + ieee80211_set_skb_vif(skb, txqi);
  592. +
  593. + hdr = (struct ieee80211_hdr *)skb->data;
  594. +- if (txq->sta && ieee80211_is_data_qos(hdr->frame_control)) {
  595. ++ info = IEEE80211_SKB_CB(skb);
  596. ++ if (txq->sta && info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) {
  597. + struct sta_info *sta = container_of(txq->sta, struct sta_info,
  598. + sta);
  599. +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  600. ++ u8 pn_offs = 0;
  601. +
  602. +- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, txq->tid);
  603. +- if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))
  604. +- info->flags |= IEEE80211_TX_CTL_AMPDU;
  605. +- else
  606. +- info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  607. ++ if (info->control.hw_key)
  608. ++ pn_offs = ieee80211_padded_hdrlen(hw, hdr->frame_control);
  609. ++
  610. ++ ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
  611. ++ info->control.hw_key, skb);
  612. ++ } else {
  613. ++ struct ieee80211_tx_data tx = { };
  614. ++
  615. ++ __skb_queue_head_init(&tx.skbs);
  616. ++ tx.local = local;
  617. ++ tx.skb = skb;
  618. ++ tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
  619. ++ if (txq->sta) {
  620. ++ tx.sta = container_of(txq->sta, struct sta_info, sta);
  621. ++ tx.sdata = tx.sta->sdata;
  622. ++ } else {
  623. ++ tx.sdata = vif_to_sdata(info->control.vif);
  624. ++ }
  625. ++
  626. ++ if (invoke_tx_handlers_late(&tx))
  627. ++ goto begin;
  628. ++
  629. ++ skb = __skb_dequeue(&tx.skbs);
  630. ++
  631. ++ if (!skb_queue_empty(&tx.skbs))
  632. ++ skb_queue_splice_tail(&tx.skbs, &txqi->frags);
  633. + }
  634. +
  635. + out:
  636. +@@ -1512,6 +1548,47 @@ out:
  637. + }
  638. + EXPORT_SYMBOL(ieee80211_tx_dequeue);
  639. +
  640. ++static bool ieee80211_queue_skb(struct ieee80211_local *local,
  641. ++ struct ieee80211_sub_if_data *sdata,
  642. ++ struct sta_info *sta,
  643. ++ struct sk_buff *skb)
  644. ++{
  645. ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  646. ++ struct fq *fq = &local->fq;
  647. ++ struct ieee80211_vif *vif;
  648. ++ struct txq_info *txqi;
  649. ++ struct ieee80211_sta *pubsta;
  650. ++
  651. ++ if (!local->ops->wake_tx_queue ||
  652. ++ sdata->vif.type == NL80211_IFTYPE_MONITOR)
  653. ++ return false;
  654. ++
  655. ++ if (sta && sta->uploaded)
  656. ++ pubsta = &sta->sta;
  657. ++ else
  658. ++ pubsta = NULL;
  659. ++
  660. ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  661. ++ sdata = container_of(sdata->bss,
  662. ++ struct ieee80211_sub_if_data, u.ap);
  663. ++
  664. ++ vif = &sdata->vif;
  665. ++ txqi = ieee80211_get_txq(local, vif, pubsta, skb);
  666. ++
  667. ++ if (!txqi)
  668. ++ return false;
  669. ++
  670. ++ info->control.vif = vif;
  671. ++
  672. ++ spin_lock_bh(&fq->lock);
  673. ++ ieee80211_txq_enqueue(local, txqi, skb);
  674. ++ spin_unlock_bh(&fq->lock);
  675. ++
  676. ++ drv_wake_tx_queue(local, txqi);
  677. ++
  678. ++ return true;
  679. ++}
  680. ++
  681. + static bool ieee80211_tx_frags(struct ieee80211_local *local,
  682. + struct ieee80211_vif *vif,
  683. + struct ieee80211_sta *sta,
  684. +@@ -1519,9 +1596,7 @@ static bool ieee80211_tx_frags(struct ie
  685. + bool txpending)
  686. + {
  687. + struct ieee80211_tx_control control = {};
  688. +- struct fq *fq = &local->fq;
  689. + struct sk_buff *skb, *tmp;
  690. +- struct txq_info *txqi;
  691. + unsigned long flags;
  692. +
  693. + skb_queue_walk_safe(skbs, skb, tmp) {
  694. +@@ -1536,21 +1611,6 @@ static bool ieee80211_tx_frags(struct ie
  695. + }
  696. + #endif
  697. +
  698. +- txqi = ieee80211_get_txq(local, vif, sta, skb);
  699. +- if (txqi) {
  700. +- info->control.vif = vif;
  701. +-
  702. +- __skb_unlink(skb, skbs);
  703. +-
  704. +- spin_lock_bh(&fq->lock);
  705. +- ieee80211_txq_enqueue(local, txqi, skb);
  706. +- spin_unlock_bh(&fq->lock);
  707. +-
  708. +- drv_wake_tx_queue(local, txqi);
  709. +-
  710. +- continue;
  711. +- }
  712. +-
  713. + spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  714. + if (local->queue_stop_reasons[q] ||
  715. + (!txpending && !skb_queue_empty(&local->pending[q]))) {
  716. +@@ -1671,10 +1731,13 @@ static bool __ieee80211_tx(struct ieee80
  717. + /*
  718. + * Invoke TX handlers, return 0 on success and non-zero if the
  719. + * frame was dropped or queued.
  720. ++ *
  721. ++ * The handlers are split into an early and late part. The latter is everything
  722. ++ * that can be sensitive to reordering, and will be deferred to after packets
  723. ++ * are dequeued from the intermediate queues (when they are enabled).
  724. + */
  725. +-static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
  726. ++static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)
  727. + {
  728. +- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
  729. + ieee80211_tx_result res = TX_DROP;
  730. +
  731. + #define CALL_TXH(txh) \
  732. +@@ -1688,16 +1751,42 @@ static int invoke_tx_handlers(struct iee
  733. + CALL_TXH(ieee80211_tx_h_check_assoc);
  734. + CALL_TXH(ieee80211_tx_h_ps_buf);
  735. + CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
  736. +- CALL_TXH(ieee80211_tx_h_select_key);
  737. ++
  738. + if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
  739. + CALL_TXH(ieee80211_tx_h_rate_ctrl);
  740. +
  741. ++ txh_done:
  742. ++ if (unlikely(res == TX_DROP)) {
  743. ++ I802_DEBUG_INC(tx->local->tx_handlers_drop);
  744. ++ if (tx->skb)
  745. ++ ieee80211_free_txskb(&tx->local->hw, tx->skb);
  746. ++ else
  747. ++ ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
  748. ++ return -1;
  749. ++ } else if (unlikely(res == TX_QUEUED)) {
  750. ++ I802_DEBUG_INC(tx->local->tx_handlers_queued);
  751. ++ return -1;
  752. ++ }
  753. ++
  754. ++ return 0;
  755. ++}
  756. ++
  757. ++/*
  758. ++ * Late handlers can be called while the sta lock is held. Handlers that can
  759. ++ * cause packets to be generated will cause deadlock!
  760. ++ */
  761. ++static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx)
  762. ++{
  763. ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
  764. ++ ieee80211_tx_result res = TX_CONTINUE;
  765. ++
  766. + if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {
  767. + __skb_queue_tail(&tx->skbs, tx->skb);
  768. + tx->skb = NULL;
  769. + goto txh_done;
  770. + }
  771. +
  772. ++ CALL_TXH(ieee80211_tx_h_select_key);
  773. + CALL_TXH(ieee80211_tx_h_michael_mic_add);
  774. + CALL_TXH(ieee80211_tx_h_sequence);
  775. + CALL_TXH(ieee80211_tx_h_fragment);
  776. +@@ -1724,6 +1813,15 @@ static int invoke_tx_handlers(struct iee
  777. + return 0;
  778. + }
  779. +
  780. ++static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
  781. ++{
  782. ++ int r = invoke_tx_handlers_early(tx);
  783. ++ if (r)
  784. ++ return r;
  785. ++
  786. ++ return invoke_tx_handlers_late(tx);
  787. ++}
  788. ++
  789. + bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
  790. + struct ieee80211_vif *vif, struct sk_buff *skb,
  791. + int band, struct ieee80211_sta **sta)
  792. +@@ -1798,7 +1896,13 @@ static bool ieee80211_tx(struct ieee8021
  793. + info->hw_queue =
  794. + sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  795. +
  796. +- if (!invoke_tx_handlers(&tx))
  797. ++ if (invoke_tx_handlers_early(&tx))
  798. ++ return false;
  799. ++
  800. ++ if (ieee80211_queue_skb(local, sdata, tx.sta, tx.skb))
  801. ++ return true;
  802. ++
  803. ++ if (!invoke_tx_handlers_late(&tx))
  804. + result = __ieee80211_tx(local, &tx.skbs, led_len,
  805. + tx.sta, txpending);
  806. +
  807. +@@ -3181,7 +3285,7 @@ out:
  808. + }
  809. +
  810. + static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
  811. +- struct net_device *dev, struct sta_info *sta,
  812. ++ struct sta_info *sta,
  813. + struct ieee80211_fast_tx *fast_tx,
  814. + struct sk_buff *skb)
  815. + {
  816. +@@ -3192,9 +3296,9 @@ static bool ieee80211_xmit_fast(struct i
  817. + struct ethhdr eth;
  818. + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  819. + struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
  820. +- struct ieee80211_tx_data tx;
  821. +- ieee80211_tx_result r;
  822. + struct tid_ampdu_tx *tid_tx = NULL;
  823. ++ ieee80211_tx_result r;
  824. ++ struct ieee80211_tx_data tx;
  825. + u8 tid = IEEE80211_NUM_TIDS;
  826. +
  827. + /* control port protocol needs a lot of special handling */
  828. +@@ -3232,8 +3336,6 @@ static bool ieee80211_xmit_fast(struct i
  829. + return true;
  830. + }
  831. +
  832. +- ieee80211_tx_stats(dev, skb->len + extra_head);
  833. +-
  834. + if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&
  835. + ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb))
  836. + return true;
  837. +@@ -3262,24 +3364,7 @@ static bool ieee80211_xmit_fast(struct i
  838. + info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT |
  839. + IEEE80211_TX_CTL_DONTFRAG |
  840. + (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0);
  841. +-
  842. +- if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
  843. +- *ieee80211_get_qos_ctl(hdr) = tid;
  844. +- if (!sta->sta.txq[0])
  845. +- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
  846. +- } else {
  847. +- info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
  848. +- hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
  849. +- sdata->sequence_number += 0x10;
  850. +- }
  851. +-
  852. +- if (skb_shinfo(skb)->gso_size)
  853. +- sta->tx_stats.msdu[tid] +=
  854. +- DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
  855. +- else
  856. +- sta->tx_stats.msdu[tid]++;
  857. +-
  858. +- info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  859. ++ info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT;
  860. +
  861. + __skb_queue_head_init(&tx.skbs);
  862. +
  863. +@@ -3305,22 +3390,71 @@ static bool ieee80211_xmit_fast(struct i
  864. + }
  865. + }
  866. +
  867. ++ if (ieee80211_queue_skb(local, sdata, sta, skb))
  868. ++ return true;
  869. ++
  870. ++ ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
  871. ++ &fast_tx->key->conf, skb);
  872. ++
  873. ++ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  874. ++ sdata = container_of(sdata->bss,
  875. ++ struct ieee80211_sub_if_data, u.ap);
  876. ++
  877. ++ __skb_queue_tail(&tx.skbs, skb);
  878. ++ ieee80211_tx_frags(local, &sdata->vif, &sta->sta, &tx.skbs, false);
  879. ++
  880. ++ return true;
  881. ++}
  882. ++
  883. ++/*
  884. ++ * Can be called while the sta lock is held. Anything that can cause packets to
  885. ++ * be generated will cause deadlock!
  886. ++ */
  887. ++static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  888. ++ struct sta_info *sta, u8 pn_offs,
  889. ++ struct ieee80211_key_conf *key_conf,
  890. ++ struct sk_buff *skb)
  891. ++{
  892. ++ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  893. ++ struct ieee80211_hdr *hdr = (void *)skb->data;
  894. ++ u8 tid = IEEE80211_NUM_TIDS;
  895. ++
  896. ++ ieee80211_tx_stats(skb->dev, skb->len);
  897. ++
  898. ++ if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
  899. ++ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
  900. ++ *ieee80211_get_qos_ctl(hdr) = tid;
  901. ++ hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
  902. ++ } else {
  903. ++ info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
  904. ++ hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
  905. ++ sdata->sequence_number += 0x10;
  906. ++ }
  907. ++
  908. ++ if (skb_shinfo(skb)->gso_size)
  909. ++ sta->tx_stats.msdu[tid] +=
  910. ++ DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
  911. ++ else
  912. ++ sta->tx_stats.msdu[tid]++;
  913. ++
  914. ++ info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  915. ++
  916. + /* statistics normally done by ieee80211_tx_h_stats (but that
  917. + * has to consider fragmentation, so is more complex)
  918. + */
  919. + sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
  920. + sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
  921. +
  922. +- if (fast_tx->pn_offs) {
  923. ++ if (pn_offs && (key_conf->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
  924. + u64 pn;
  925. +- u8 *crypto_hdr = skb->data + fast_tx->pn_offs;
  926. ++ u8 *crypto_hdr = skb->data + pn_offs;
  927. +
  928. +- switch (fast_tx->key->conf.cipher) {
  929. ++ switch (key_conf->cipher) {
  930. + case WLAN_CIPHER_SUITE_CCMP:
  931. + case WLAN_CIPHER_SUITE_CCMP_256:
  932. + case WLAN_CIPHER_SUITE_GCMP:
  933. + case WLAN_CIPHER_SUITE_GCMP_256:
  934. +- pn = atomic64_inc_return(&fast_tx->key->conf.tx_pn);
  935. ++ pn = atomic64_inc_return(&key_conf->tx_pn);
  936. + crypto_hdr[0] = pn;
  937. + crypto_hdr[1] = pn >> 8;
  938. + crypto_hdr[4] = pn >> 16;
  939. +@@ -3331,12 +3465,6 @@ static bool ieee80211_xmit_fast(struct i
  940. + }
  941. + }
  942. +
  943. +- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  944. +- sdata = container_of(sdata->bss,
  945. +- struct ieee80211_sub_if_data, u.ap);
  946. +-
  947. +- __skb_queue_tail(&tx.skbs, skb);
  948. +- ieee80211_tx_frags(local, &sdata->vif, &sta->sta, &tx.skbs, false);
  949. + return true;
  950. + }
  951. +
  952. +@@ -3364,7 +3492,7 @@ void __ieee80211_subif_start_xmit(struct
  953. + fast_tx = rcu_dereference(sta->fast_tx);
  954. +
  955. + if (fast_tx &&
  956. +- ieee80211_xmit_fast(sdata, dev, sta, fast_tx, skb))
  957. ++ ieee80211_xmit_fast(sdata, sta, fast_tx, skb))
  958. + goto out;
  959. + }
  960. +
  961. +--- a/include/net/mac80211.h
  962. ++++ b/include/net/mac80211.h
  963. +@@ -715,6 +715,7 @@ enum mac80211_tx_info_flags {
  964. + * frame (PS-Poll or uAPSD).
  965. + * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  966. + * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
  967. ++ * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
  968. + *
  969. + * These flags are used in tx_info->control.flags.
  970. + */
  971. +@@ -723,6 +724,7 @@ enum mac80211_tx_control_flags {
  972. + IEEE80211_TX_CTRL_PS_RESPONSE = BIT(1),
  973. + IEEE80211_TX_CTRL_RATE_INJECT = BIT(2),
  974. + IEEE80211_TX_CTRL_AMSDU = BIT(3),
  975. ++ IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
  976. + };
  977. +
  978. + /*
  979. +--- a/net/mac80211/ieee80211_i.h
  980. ++++ b/net/mac80211/ieee80211_i.h
  981. +@@ -814,11 +814,13 @@ enum txq_info_flags {
  982. + * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
  983. + * a fq_flow which is already owned by a different tin
  984. + * @def_cvars: codel vars for @def_flow
  985. ++ * @frags: used to keep fragments created after dequeue
  986. + */
  987. + struct txq_info {
  988. + struct fq_tin tin;
  989. + struct fq_flow def_flow;
  990. + struct codel_vars def_cvars;
  991. ++ struct sk_buff_head frags;
  992. + unsigned long flags;
  993. +
  994. + /* keep last! */
  995. diff --git a/package/kernel/mac80211/patches/345-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch b/package/kernel/mac80211/patches/345-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch
  996. deleted file mode 100644
  997. index c3d3118..0000000
  998. --- a/package/kernel/mac80211/patches/345-mac80211-send-delBA-on-unexpected-BlockAck-Request.patch
  999. +++ /dev/null
  1000. @@ -1,26 +0,0 @@
  1001. -From: Johannes Berg <johannes.berg@intel.com>
  1002. -Date: Mon, 29 Aug 2016 23:25:19 +0300
  1003. -Subject: [PATCH] mac80211: send delBA on unexpected BlockAck Request
  1004. -
  1005. -If we don't have a BA session, send delBA, as requested by the
  1006. -IEEE 802.11 spec. Apply the same limit of sending such a delBA
  1007. -only once as in the previous patch.
  1008. -
  1009. -Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  1010. ----
  1011. -
  1012. ---- a/net/mac80211/rx.c
  1013. -+++ b/net/mac80211/rx.c
  1014. -@@ -2537,6 +2537,12 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_
  1015. -
  1016. - tid = le16_to_cpu(bar_data.control) >> 12;
  1017. -
  1018. -+ if (!test_bit(tid, rx->sta->ampdu_mlme.agg_session_valid) &&
  1019. -+ !test_and_set_bit(tid, rx->sta->ampdu_mlme.unexpected_agg))
  1020. -+ ieee80211_send_delba(rx->sdata, rx->sta->sta.addr, tid,
  1021. -+ WLAN_BACK_RECIPIENT,
  1022. -+ WLAN_REASON_QSTA_REQUIRE_SETUP);
  1023. -+
  1024. - tid_agg_rx = rcu_dereference(rx->sta->ampdu_mlme.tid_rx[tid]);
  1025. - if (!tid_agg_rx)
  1026. - return RX_DROP_MONITOR;
  1027. diff --git a/package/kernel/mac80211/patches/346-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch b/package/kernel/mac80211/patches/346-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch
  1028. deleted file mode 100644
  1029. index aba1ff4..0000000
  1030. --- a/package/kernel/mac80211/patches/346-mac80211-Move-reorder-sensitive-TX-handlers-to-after.patch
  1031. +++ /dev/null
  1032. @@ -1,478 +0,0 @@
  1033. -From: Felix Fietkau <nbd@nbd.name>
  1034. -Date: Sun, 4 Sep 2016 17:46:24 +0200
  1035. -Subject: [PATCH] mac80211: fix sequence number assignment for PS response
  1036. - frames
  1037. -
  1038. -When using intermediate queues, sequence number allocation is deferred
  1039. -until dequeue. This doesn't work for PS response frames, which bypass
  1040. -those queues.
  1041. -
  1042. -Signed-off-by: Felix Fietkau <nbd@nbd.name>
  1043. ----
  1044. -
  1045. ---- a/net/mac80211/tx.c
  1046. -+++ b/net/mac80211/tx.c
  1047. -@@ -38,6 +38,12 @@
  1048. - #include "wme.h"
  1049. - #include "rate.h"
  1050. -
  1051. -+static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx);
  1052. -+static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  1053. -+ struct sta_info *sta, u8 pn_offs,
  1054. -+ struct ieee80211_key_conf *key_conf,
  1055. -+ struct sk_buff *skb);
  1056. -+
  1057. - /* misc utils */
  1058. -
  1059. - static inline void ieee80211_tx_stats(struct net_device *dev, u32 len)
  1060. -@@ -849,8 +855,7 @@ ieee80211_tx_h_sequence(struct ieee80211
  1061. - tid = *qc & IEEE80211_QOS_CTL_TID_MASK;
  1062. - tx->sta->tx_stats.msdu[tid]++;
  1063. -
  1064. -- if (!tx->sta->sta.txq[0])
  1065. -- hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
  1066. -+ hdr->seq_ctrl = ieee80211_tx_next_seq(tx->sta, tid);
  1067. -
  1068. - return TX_CONTINUE;
  1069. - }
  1070. -@@ -1398,6 +1403,7 @@ void ieee80211_txq_init(struct ieee80211
  1071. - fq_tin_init(&txqi->tin);
  1072. - fq_flow_init(&txqi->def_flow);
  1073. - codel_vars_init(&txqi->def_cvars);
  1074. -+ __skb_queue_head_init(&txqi->frags);
  1075. -
  1076. - txqi->txq.vif = &sdata->vif;
  1077. -
  1078. -@@ -1420,6 +1426,7 @@ void ieee80211_txq_purge(struct ieee8021
  1079. - struct fq_tin *tin = &txqi->tin;
  1080. -
  1081. - fq_tin_reset(fq, tin, fq_skb_free_func);
  1082. -+ ieee80211_purge_tx_queue(&local->hw, &txqi->frags);
  1083. - }
  1084. -
  1085. - int ieee80211_txq_setup_flows(struct ieee80211_local *local)
  1086. -@@ -1476,12 +1483,19 @@ struct sk_buff *ieee80211_tx_dequeue(str
  1087. - struct sk_buff *skb = NULL;
  1088. - struct fq *fq = &local->fq;
  1089. - struct fq_tin *tin = &txqi->tin;
  1090. -+ struct ieee80211_tx_info *info;
  1091. -
  1092. - spin_lock_bh(&fq->lock);
  1093. -
  1094. - if (test_bit(IEEE80211_TXQ_STOP, &txqi->flags))
  1095. - goto out;
  1096. -
  1097. -+ /* Make sure fragments stay together. */
  1098. -+ skb = __skb_dequeue(&txqi->frags);
  1099. -+ if (skb)
  1100. -+ goto out;
  1101. -+
  1102. -+begin:
  1103. - skb = fq_tin_dequeue(fq, tin, fq_tin_dequeue_func);
  1104. - if (!skb)
  1105. - goto out;
  1106. -@@ -1489,16 +1503,38 @@ struct sk_buff *ieee80211_tx_dequeue(str
  1107. - ieee80211_set_skb_vif(skb, txqi);
  1108. -
  1109. - hdr = (struct ieee80211_hdr *)skb->data;
  1110. -- if (txq->sta && ieee80211_is_data_qos(hdr->frame_control)) {
  1111. -+ info = IEEE80211_SKB_CB(skb);
  1112. -+ if (txq->sta && info->control.flags & IEEE80211_TX_CTRL_FAST_XMIT) {
  1113. - struct sta_info *sta = container_of(txq->sta, struct sta_info,
  1114. - sta);
  1115. -- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  1116. -+ u8 pn_offs = 0;
  1117. -
  1118. -- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, txq->tid);
  1119. -- if (test_bit(IEEE80211_TXQ_AMPDU, &txqi->flags))
  1120. -- info->flags |= IEEE80211_TX_CTL_AMPDU;
  1121. -- else
  1122. -- info->flags &= ~IEEE80211_TX_CTL_AMPDU;
  1123. -+ if (info->control.hw_key)
  1124. -+ pn_offs = ieee80211_padded_hdrlen(hw, hdr->frame_control);
  1125. -+
  1126. -+ ieee80211_xmit_fast_finish(sta->sdata, sta, pn_offs,
  1127. -+ info->control.hw_key, skb);
  1128. -+ } else {
  1129. -+ struct ieee80211_tx_data tx = { };
  1130. -+
  1131. -+ __skb_queue_head_init(&tx.skbs);
  1132. -+ tx.local = local;
  1133. -+ tx.skb = skb;
  1134. -+ tx.hdrlen = ieee80211_padded_hdrlen(hw, hdr->frame_control);
  1135. -+ if (txq->sta) {
  1136. -+ tx.sta = container_of(txq->sta, struct sta_info, sta);
  1137. -+ tx.sdata = tx.sta->sdata;
  1138. -+ } else {
  1139. -+ tx.sdata = vif_to_sdata(info->control.vif);
  1140. -+ }
  1141. -+
  1142. -+ if (invoke_tx_handlers_late(&tx))
  1143. -+ goto begin;
  1144. -+
  1145. -+ skb = __skb_dequeue(&tx.skbs);
  1146. -+
  1147. -+ if (!skb_queue_empty(&tx.skbs))
  1148. -+ skb_queue_splice_tail(&tx.skbs, &txqi->frags);
  1149. - }
  1150. -
  1151. - out:
  1152. -@@ -1512,6 +1548,47 @@ out:
  1153. - }
  1154. - EXPORT_SYMBOL(ieee80211_tx_dequeue);
  1155. -
  1156. -+static bool ieee80211_queue_skb(struct ieee80211_local *local,
  1157. -+ struct ieee80211_sub_if_data *sdata,
  1158. -+ struct sta_info *sta,
  1159. -+ struct sk_buff *skb)
  1160. -+{
  1161. -+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  1162. -+ struct fq *fq = &local->fq;
  1163. -+ struct ieee80211_vif *vif;
  1164. -+ struct txq_info *txqi;
  1165. -+ struct ieee80211_sta *pubsta;
  1166. -+
  1167. -+ if (!local->ops->wake_tx_queue ||
  1168. -+ sdata->vif.type == NL80211_IFTYPE_MONITOR)
  1169. -+ return false;
  1170. -+
  1171. -+ if (sta && sta->uploaded)
  1172. -+ pubsta = &sta->sta;
  1173. -+ else
  1174. -+ pubsta = NULL;
  1175. -+
  1176. -+ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  1177. -+ sdata = container_of(sdata->bss,
  1178. -+ struct ieee80211_sub_if_data, u.ap);
  1179. -+
  1180. -+ vif = &sdata->vif;
  1181. -+ txqi = ieee80211_get_txq(local, vif, pubsta, skb);
  1182. -+
  1183. -+ if (!txqi)
  1184. -+ return false;
  1185. -+
  1186. -+ info->control.vif = vif;
  1187. -+
  1188. -+ spin_lock_bh(&fq->lock);
  1189. -+ ieee80211_txq_enqueue(local, txqi, skb);
  1190. -+ spin_unlock_bh(&fq->lock);
  1191. -+
  1192. -+ drv_wake_tx_queue(local, txqi);
  1193. -+
  1194. -+ return true;
  1195. -+}
  1196. -+
  1197. - static bool ieee80211_tx_frags(struct ieee80211_local *local,
  1198. - struct ieee80211_vif *vif,
  1199. - struct ieee80211_sta *sta,
  1200. -@@ -1519,9 +1596,7 @@ static bool ieee80211_tx_frags(struct ie
  1201. - bool txpending)
  1202. - {
  1203. - struct ieee80211_tx_control control = {};
  1204. -- struct fq *fq = &local->fq;
  1205. - struct sk_buff *skb, *tmp;
  1206. -- struct txq_info *txqi;
  1207. - unsigned long flags;
  1208. -
  1209. - skb_queue_walk_safe(skbs, skb, tmp) {
  1210. -@@ -1536,21 +1611,6 @@ static bool ieee80211_tx_frags(struct ie
  1211. - }
  1212. - #endif
  1213. -
  1214. -- txqi = ieee80211_get_txq(local, vif, sta, skb);
  1215. -- if (txqi) {
  1216. -- info->control.vif = vif;
  1217. --
  1218. -- __skb_unlink(skb, skbs);
  1219. --
  1220. -- spin_lock_bh(&fq->lock);
  1221. -- ieee80211_txq_enqueue(local, txqi, skb);
  1222. -- spin_unlock_bh(&fq->lock);
  1223. --
  1224. -- drv_wake_tx_queue(local, txqi);
  1225. --
  1226. -- continue;
  1227. -- }
  1228. --
  1229. - spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  1230. - if (local->queue_stop_reasons[q] ||
  1231. - (!txpending && !skb_queue_empty(&local->pending[q]))) {
  1232. -@@ -1671,10 +1731,13 @@ static bool __ieee80211_tx(struct ieee80
  1233. - /*
  1234. - * Invoke TX handlers, return 0 on success and non-zero if the
  1235. - * frame was dropped or queued.
  1236. -+ *
  1237. -+ * The handlers are split into an early and late part. The latter is everything
  1238. -+ * that can be sensitive to reordering, and will be deferred to after packets
  1239. -+ * are dequeued from the intermediate queues (when they are enabled).
  1240. - */
  1241. --static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
  1242. -+static int invoke_tx_handlers_early(struct ieee80211_tx_data *tx)
  1243. - {
  1244. -- struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
  1245. - ieee80211_tx_result res = TX_DROP;
  1246. -
  1247. - #define CALL_TXH(txh) \
  1248. -@@ -1688,16 +1751,42 @@ static int invoke_tx_handlers(struct iee
  1249. - CALL_TXH(ieee80211_tx_h_check_assoc);
  1250. - CALL_TXH(ieee80211_tx_h_ps_buf);
  1251. - CALL_TXH(ieee80211_tx_h_check_control_port_protocol);
  1252. -- CALL_TXH(ieee80211_tx_h_select_key);
  1253. -+
  1254. - if (!ieee80211_hw_check(&tx->local->hw, HAS_RATE_CONTROL))
  1255. - CALL_TXH(ieee80211_tx_h_rate_ctrl);
  1256. -
  1257. -+ txh_done:
  1258. -+ if (unlikely(res == TX_DROP)) {
  1259. -+ I802_DEBUG_INC(tx->local->tx_handlers_drop);
  1260. -+ if (tx->skb)
  1261. -+ ieee80211_free_txskb(&tx->local->hw, tx->skb);
  1262. -+ else
  1263. -+ ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
  1264. -+ return -1;
  1265. -+ } else if (unlikely(res == TX_QUEUED)) {
  1266. -+ I802_DEBUG_INC(tx->local->tx_handlers_queued);
  1267. -+ return -1;
  1268. -+ }
  1269. -+
  1270. -+ return 0;
  1271. -+}
  1272. -+
  1273. -+/*
  1274. -+ * Late handlers can be called while the sta lock is held. Handlers that can
  1275. -+ * cause packets to be generated will cause deadlock!
  1276. -+ */
  1277. -+static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx)
  1278. -+{
  1279. -+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
  1280. -+ ieee80211_tx_result res = TX_CONTINUE;
  1281. -+
  1282. - if (unlikely(info->flags & IEEE80211_TX_INTFL_RETRANSMISSION)) {
  1283. - __skb_queue_tail(&tx->skbs, tx->skb);
  1284. - tx->skb = NULL;
  1285. - goto txh_done;
  1286. - }
  1287. -
  1288. -+ CALL_TXH(ieee80211_tx_h_select_key);
  1289. - CALL_TXH(ieee80211_tx_h_michael_mic_add);
  1290. - CALL_TXH(ieee80211_tx_h_sequence);
  1291. - CALL_TXH(ieee80211_tx_h_fragment);
  1292. -@@ -1724,6 +1813,15 @@ static int invoke_tx_handlers(struct iee
  1293. - return 0;
  1294. - }
  1295. -
  1296. -+static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
  1297. -+{
  1298. -+ int r = invoke_tx_handlers_early(tx);
  1299. -+ if (r)
  1300. -+ return r;
  1301. -+
  1302. -+ return invoke_tx_handlers_late(tx);
  1303. -+}
  1304. -+
  1305. - bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
  1306. - struct ieee80211_vif *vif, struct sk_buff *skb,
  1307. - int band, struct ieee80211_sta **sta)
  1308. -@@ -1798,7 +1896,13 @@ static bool ieee80211_tx(struct ieee8021
  1309. - info->hw_queue =
  1310. - sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  1311. -
  1312. -- if (!invoke_tx_handlers(&tx))
  1313. -+ if (invoke_tx_handlers_early(&tx))
  1314. -+ return false;
  1315. -+
  1316. -+ if (ieee80211_queue_skb(local, sdata, tx.sta, tx.skb))
  1317. -+ return true;
  1318. -+
  1319. -+ if (!invoke_tx_handlers_late(&tx))
  1320. - result = __ieee80211_tx(local, &tx.skbs, led_len,
  1321. - tx.sta, txpending);
  1322. -
  1323. -@@ -3181,7 +3285,7 @@ out:
  1324. - }
  1325. -
  1326. - static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
  1327. -- struct net_device *dev, struct sta_info *sta,
  1328. -+ struct sta_info *sta,
  1329. - struct ieee80211_fast_tx *fast_tx,
  1330. - struct sk_buff *skb)
  1331. - {
  1332. -@@ -3192,9 +3296,9 @@ static bool ieee80211_xmit_fast(struct i
  1333. - struct ethhdr eth;
  1334. - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  1335. - struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
  1336. -- struct ieee80211_tx_data tx;
  1337. -- ieee80211_tx_result r;
  1338. - struct tid_ampdu_tx *tid_tx = NULL;
  1339. -+ ieee80211_tx_result r;
  1340. -+ struct ieee80211_tx_data tx;
  1341. - u8 tid = IEEE80211_NUM_TIDS;
  1342. -
  1343. - /* control port protocol needs a lot of special handling */
  1344. -@@ -3232,8 +3336,6 @@ static bool ieee80211_xmit_fast(struct i
  1345. - return true;
  1346. - }
  1347. -
  1348. -- ieee80211_tx_stats(dev, skb->len + extra_head);
  1349. --
  1350. - if ((hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) &&
  1351. - ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb))
  1352. - return true;
  1353. -@@ -3262,24 +3364,7 @@ static bool ieee80211_xmit_fast(struct i
  1354. - info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT |
  1355. - IEEE80211_TX_CTL_DONTFRAG |
  1356. - (tid_tx ? IEEE80211_TX_CTL_AMPDU : 0);
  1357. --
  1358. -- if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
  1359. -- *ieee80211_get_qos_ctl(hdr) = tid;
  1360. -- if (!sta->sta.txq[0])
  1361. -- hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
  1362. -- } else {
  1363. -- info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
  1364. -- hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
  1365. -- sdata->sequence_number += 0x10;
  1366. -- }
  1367. --
  1368. -- if (skb_shinfo(skb)->gso_size)
  1369. -- sta->tx_stats.msdu[tid] +=
  1370. -- DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
  1371. -- else
  1372. -- sta->tx_stats.msdu[tid]++;
  1373. --
  1374. -- info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  1375. -+ info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT;
  1376. -
  1377. - __skb_queue_head_init(&tx.skbs);
  1378. -
  1379. -@@ -3305,22 +3390,71 @@ static bool ieee80211_xmit_fast(struct i
  1380. - }
  1381. - }
  1382. -
  1383. -+ if (ieee80211_queue_skb(local, sdata, sta, skb))
  1384. -+ return true;
  1385. -+
  1386. -+ ieee80211_xmit_fast_finish(sdata, sta, fast_tx->pn_offs,
  1387. -+ &fast_tx->key->conf, skb);
  1388. -+
  1389. -+ if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  1390. -+ sdata = container_of(sdata->bss,
  1391. -+ struct ieee80211_sub_if_data, u.ap);
  1392. -+
  1393. -+ __skb_queue_tail(&tx.skbs, skb);
  1394. -+ ieee80211_tx_frags(local, &sdata->vif, &sta->sta, &tx.skbs, false);
  1395. -+
  1396. -+ return true;
  1397. -+}
  1398. -+
  1399. -+/*
  1400. -+ * Can be called while the sta lock is held. Anything that can cause packets to
  1401. -+ * be generated will cause deadlock!
  1402. -+ */
  1403. -+static bool ieee80211_xmit_fast_finish(struct ieee80211_sub_if_data *sdata,
  1404. -+ struct sta_info *sta, u8 pn_offs,
  1405. -+ struct ieee80211_key_conf *key_conf,
  1406. -+ struct sk_buff *skb)
  1407. -+{
  1408. -+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  1409. -+ struct ieee80211_hdr *hdr = (void *)skb->data;
  1410. -+ u8 tid = IEEE80211_NUM_TIDS;
  1411. -+
  1412. -+ ieee80211_tx_stats(skb->dev, skb->len);
  1413. -+
  1414. -+ if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
  1415. -+ tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
  1416. -+ *ieee80211_get_qos_ctl(hdr) = tid;
  1417. -+ hdr->seq_ctrl = ieee80211_tx_next_seq(sta, tid);
  1418. -+ } else {
  1419. -+ info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ;
  1420. -+ hdr->seq_ctrl = cpu_to_le16(sdata->sequence_number);
  1421. -+ sdata->sequence_number += 0x10;
  1422. -+ }
  1423. -+
  1424. -+ if (skb_shinfo(skb)->gso_size)
  1425. -+ sta->tx_stats.msdu[tid] +=
  1426. -+ DIV_ROUND_UP(skb->len, skb_shinfo(skb)->gso_size);
  1427. -+ else
  1428. -+ sta->tx_stats.msdu[tid]++;
  1429. -+
  1430. -+ info->hw_queue = sdata->vif.hw_queue[skb_get_queue_mapping(skb)];
  1431. -+
  1432. - /* statistics normally done by ieee80211_tx_h_stats (but that
  1433. - * has to consider fragmentation, so is more complex)
  1434. - */
  1435. - sta->tx_stats.bytes[skb_get_queue_mapping(skb)] += skb->len;
  1436. - sta->tx_stats.packets[skb_get_queue_mapping(skb)]++;
  1437. -
  1438. -- if (fast_tx->pn_offs) {
  1439. -+ if (pn_offs && (key_conf->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
  1440. - u64 pn;
  1441. -- u8 *crypto_hdr = skb->data + fast_tx->pn_offs;
  1442. -+ u8 *crypto_hdr = skb->data + pn_offs;
  1443. -
  1444. -- switch (fast_tx->key->conf.cipher) {
  1445. -+ switch (key_conf->cipher) {
  1446. - case WLAN_CIPHER_SUITE_CCMP:
  1447. - case WLAN_CIPHER_SUITE_CCMP_256:
  1448. - case WLAN_CIPHER_SUITE_GCMP:
  1449. - case WLAN_CIPHER_SUITE_GCMP_256:
  1450. -- pn = atomic64_inc_return(&fast_tx->key->conf.tx_pn);
  1451. -+ pn = atomic64_inc_return(&key_conf->tx_pn);
  1452. - crypto_hdr[0] = pn;
  1453. - crypto_hdr[1] = pn >> 8;
  1454. - crypto_hdr[4] = pn >> 16;
  1455. -@@ -3331,12 +3465,6 @@ static bool ieee80211_xmit_fast(struct i
  1456. - }
  1457. - }
  1458. -
  1459. -- if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  1460. -- sdata = container_of(sdata->bss,
  1461. -- struct ieee80211_sub_if_data, u.ap);
  1462. --
  1463. -- __skb_queue_tail(&tx.skbs, skb);
  1464. -- ieee80211_tx_frags(local, &sdata->vif, &sta->sta, &tx.skbs, false);
  1465. - return true;
  1466. - }
  1467. -
  1468. -@@ -3364,7 +3492,7 @@ void __ieee80211_subif_start_xmit(struct
  1469. - fast_tx = rcu_dereference(sta->fast_tx);
  1470. -
  1471. - if (fast_tx &&
  1472. -- ieee80211_xmit_fast(sdata, dev, sta, fast_tx, skb))
  1473. -+ ieee80211_xmit_fast(sdata, sta, fast_tx, skb))
  1474. - goto out;
  1475. - }
  1476. -
  1477. ---- a/include/net/mac80211.h
  1478. -+++ b/include/net/mac80211.h
  1479. -@@ -715,6 +715,7 @@ enum mac80211_tx_info_flags {
  1480. - * frame (PS-Poll or uAPSD).
  1481. - * @IEEE80211_TX_CTRL_RATE_INJECT: This frame is injected with rate information
  1482. - * @IEEE80211_TX_CTRL_AMSDU: This frame is an A-MSDU frame
  1483. -+ * @IEEE80211_TX_CTRL_FAST_XMIT: This frame is going through the fast_xmit path
  1484. - *
  1485. - * These flags are used in tx_info->control.flags.
  1486. - */
  1487. -@@ -723,6 +724,7 @@ enum mac80211_tx_control_flags {
  1488. - IEEE80211_TX_CTRL_PS_RESPONSE = BIT(1),
  1489. - IEEE80211_TX_CTRL_RATE_INJECT = BIT(2),
  1490. - IEEE80211_TX_CTRL_AMSDU = BIT(3),
  1491. -+ IEEE80211_TX_CTRL_FAST_XMIT = BIT(4),
  1492. - };
  1493. -
  1494. - /*
  1495. ---- a/net/mac80211/ieee80211_i.h
  1496. -+++ b/net/mac80211/ieee80211_i.h
  1497. -@@ -814,11 +814,13 @@ enum txq_info_flags {
  1498. - * @def_flow: used as a fallback flow when a packet destined to @tin hashes to
  1499. - * a fq_flow which is already owned by a different tin
  1500. - * @def_cvars: codel vars for @def_flow
  1501. -+ * @frags: used to keep fragments created after dequeue
  1502. - */
  1503. - struct txq_info {
  1504. - struct fq_tin tin;
  1505. - struct fq_flow def_flow;
  1506. - struct codel_vars def_cvars;
  1507. -+ struct sk_buff_head frags;
  1508. - unsigned long flags;
  1509. -
  1510. - /* keep last! */