Fresh pull from upstream 17.01 branch
[librecmc/librecmc.git] / package / kernel / mac80211 / patches / 313-ath9k-fix-block-ack-window-tracking-issues.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Tue, 30 Aug 2016 12:44:08 +0200
3 Subject: [PATCH] ath9k: fix block-ack window tracking issues
4
5 Ensure that a buffer gets tracked as part of the block-ack window as
6 soon as it's dequeued from the tid for the first time. Ensure that
7 double calls to ath_tx_addto_baw (e.g. on retransmission) don't cause
8 any issues.
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 ---
12
13 --- a/drivers/net/wireless/ath/ath9k/xmit.c
14 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
15 @@ -62,7 +62,7 @@ static void ath_tx_rc_status(struct ath_
16                              struct ath_tx_status *ts, int nframes, int nbad,
17                              int txok);
18  static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
19 -                             int seqno);
20 +                             struct ath_buf *bf);
21  static struct ath_buf *ath_tx_setup_buffer(struct ath_softc *sc,
22                                            struct ath_txq *txq,
23                                            struct ath_atx_tid *tid,
24 @@ -311,7 +311,7 @@ static void ath_tx_flush_tid(struct ath_
25                 }
26  
27                 if (fi->baw_tracked) {
28 -                       ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
29 +                       ath_tx_update_baw(sc, tid, bf);
30                         sendbar = true;
31                 }
32  
33 @@ -327,10 +327,15 @@ static void ath_tx_flush_tid(struct ath_
34  }
35  
36  static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
37 -                             int seqno)
38 +                             struct ath_buf *bf)
39  {
40 +       struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
41 +       u16 seqno = bf->bf_state.seqno;
42         int index, cindex;
43  
44 +       if (!fi->baw_tracked)
45 +               return;
46 +
47         index  = ATH_BA_INDEX(tid->seq_start, seqno);
48         cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
49  
50 @@ -351,6 +356,9 @@ static void ath_tx_addto_baw(struct ath_
51         u16 seqno = bf->bf_state.seqno;
52         int index, cindex;
53  
54 +       if (fi->baw_tracked)
55 +               return;
56 +
57         index  = ATH_BA_INDEX(tid->seq_start, seqno);
58         cindex = (tid->baw_head + index) & (ATH_TID_MAX_BUFS - 1);
59         __set_bit(cindex, tid->tx_buf);
60 @@ -627,7 +635,7 @@ static void ath_tx_complete_aggr(struct
61                          * complete the acked-ones/xretried ones; update
62                          * block-ack window
63                          */
64 -                       ath_tx_update_baw(sc, tid, seqno);
65 +                       ath_tx_update_baw(sc, tid, bf);
66  
67                         if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
68                                 memcpy(tx_info->control.rates, rates, sizeof(rates));
69 @@ -657,7 +665,7 @@ static void ath_tx_complete_aggr(struct
70                                  * run out of tx buf.
71                                  */
72                                 if (!tbf) {
73 -                                       ath_tx_update_baw(sc, tid, seqno);
74 +                                       ath_tx_update_baw(sc, tid, bf);
75  
76                                         ath_tx_complete_buf(sc, bf, txq,
77                                                             &bf_head, NULL, ts,
78 @@ -1046,11 +1054,14 @@ ath_tx_get_tid_subframe(struct ath_softc
79  
80                         INIT_LIST_HEAD(&bf_head);
81                         list_add(&bf->list, &bf_head);
82 -                       ath_tx_update_baw(sc, tid, seqno);
83 +                       ath_tx_update_baw(sc, tid, bf);
84                         ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
85                         continue;
86                 }
87  
88 +               if (bf_isampdu(bf))
89 +                       ath_tx_addto_baw(sc, tid, bf);
90 +
91                 return bf;
92         }
93  
94 @@ -1108,8 +1119,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s
95                 bf->bf_next = NULL;
96  
97                 /* link buffers of this frame to the aggregate */
98 -               if (!fi->baw_tracked)
99 -                       ath_tx_addto_baw(sc, tid, bf);
100                 bf->bf_state.ndelim = ndelim;
101  
102                 list_add_tail(&bf->list, bf_q);
103 @@ -1745,10 +1754,8 @@ void ath9k_release_buffered_frames(struc
104                         ath9k_set_moredata(sc, bf, true);
105                         list_add_tail(&bf->list, &bf_q);
106                         ath_set_rates(tid->an->vif, tid->an->sta, bf, true);
107 -                       if (bf_isampdu(bf)) {
108 -                               ath_tx_addto_baw(sc, tid, bf);
109 +                       if (bf_isampdu(bf))
110                                 bf->bf_state.bf_type &= ~BUF_AGGR;
111 -                       }
112                         if (bf_tail)
113                                 bf_tail->bf_next = bf;
114