kernel: add a recent upstream commit (post-3.3) to the ssb update patch, required...
[openwrt.git] / package / mac80211 / patches / 560-ath9k_rework_send_bar.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -159,6 +159,9 @@ void ath_descdma_cleanup(struct ath_soft
4  /* return block-ack bitmap index given sequence and starting sequence */
5  #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1))
6  
7 +/* return the seqno for _start + _offset */
8 +#define ATH_BA_INDEX2SEQ(_seq, _offset) (((_seq) + (_offset)) & (IEEE80211_SEQ_MAX - 1))
9 +
10  /* returns delimiter padding required given the packet length */
11  #define ATH_AGGR_GET_NDELIM(_len)                                      \
12         (((_len) >= ATH_AGGR_MINPLEN) ? 0 :                             \
13 @@ -253,9 +256,9 @@ struct ath_atx_tid {
14  struct ath_node {
15  #ifdef CONFIG_ATH9K_DEBUGFS
16         struct list_head list; /* for sc->nodes */
17 +#endif
18         struct ieee80211_sta *sta; /* station struct we're part of */
19         struct ieee80211_vif *vif; /* interface with which we're associated */
20 -#endif
21         struct ath_atx_tid tid[WME_NUM_TID];
22         struct ath_atx_ac ac[WME_NUM_AC];
23         int ps_key;
24 @@ -277,7 +280,6 @@ struct ath_tx_control {
25  };
26  
27  #define ATH_TX_ERROR        0x01
28 -#define ATH_TX_BAR          0x02
29  
30  /**
31   * @txq_map:  Index is mac80211 queue number.  This is
32 --- a/drivers/net/wireless/ath/ath9k/main.c
33 +++ b/drivers/net/wireless/ath/ath9k/main.c
34 @@ -644,9 +644,9 @@ static void ath_node_attach(struct ath_s
35         spin_lock(&sc->nodes_lock);
36         list_add(&an->list, &sc->nodes);
37         spin_unlock(&sc->nodes_lock);
38 +#endif
39         an->sta = sta;
40         an->vif = vif;
41 -#endif
42         if (sc->sc_flags & SC_OP_TXAGGR) {
43                 ath_tx_node_init(sc, an);
44                 an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
45 --- a/drivers/net/wireless/ath/ath9k/xmit.c
46 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
47 @@ -53,7 +53,7 @@ static void ath_tx_complete(struct ath_s
48                             int tx_flags, struct ath_txq *txq);
49  static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
50                                 struct ath_txq *txq, struct list_head *bf_q,
51 -                               struct ath_tx_status *ts, int txok, int sendbar);
52 +                               struct ath_tx_status *ts, int txok);
53  static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
54                              struct list_head *head, bool internal);
55  static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf,
56 @@ -150,6 +150,12 @@ static struct ath_frame_info *get_frame_
57         return (struct ath_frame_info *) &tx_info->rate_driver_data[0];
58  }
59  
60 +static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno)
61 +{
62 +       ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno,
63 +                          seqno << IEEE80211_SEQ_SEQ_SHIFT);
64 +}
65 +
66  static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
67  {
68         struct ath_txq *txq = tid->ac->txq;
69 @@ -158,6 +164,7 @@ static void ath_tx_flush_tid(struct ath_
70         struct list_head bf_head;
71         struct ath_tx_status ts;
72         struct ath_frame_info *fi;
73 +       bool sendbar = false;
74  
75         INIT_LIST_HEAD(&bf_head);
76  
77 @@ -172,7 +179,8 @@ static void ath_tx_flush_tid(struct ath_
78                 if (bf && fi->retries) {
79                         list_add_tail(&bf->list, &bf_head);
80                         ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
81 -                       ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 1);
82 +                       ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
83 +                       sendbar = true;
84                 } else {
85                         ath_tx_send_normal(sc, txq, NULL, skb);
86                 }
87 @@ -185,6 +193,9 @@ static void ath_tx_flush_tid(struct ath_
88         }
89  
90         spin_unlock_bh(&txq->axq_lock);
91 +
92 +       if (sendbar)
93 +               ath_send_bar(tid, tid->seq_start);
94  }
95  
96  static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
97 @@ -255,7 +266,7 @@ static void ath_tid_drain(struct ath_sof
98                         ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
99  
100                 spin_unlock(&txq->axq_lock);
101 -               ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
102 +               ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
103                 spin_lock(&txq->axq_lock);
104         }
105  
106 @@ -381,7 +392,7 @@ static void ath_tx_complete_aggr(struct 
107         struct ath_buf *bf_next, *bf_last = bf->bf_lastbf;
108         struct list_head bf_head;
109         struct sk_buff_head bf_pending;
110 -       u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0;
111 +       u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first;
112         u32 ba[WME_BA_BMP_SIZE >> 5];
113         int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
114         bool rc_update = true;
115 @@ -391,6 +402,7 @@ static void ath_tx_complete_aggr(struct 
116         u8 tidno;
117         bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH);
118         int i, retries;
119 +       int bar_index = -1;
120  
121         skb = bf->bf_mpdu;
122         hdr = (struct ieee80211_hdr *)skb->data;
123 @@ -416,8 +428,7 @@ static void ath_tx_complete_aggr(struct 
124                         if (!bf->bf_stale || bf_next != NULL)
125                                 list_move_tail(&bf->list, &bf_head);
126  
127 -                       ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
128 -                               0, 0);
129 +                       ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0);
130  
131                         bf = bf_next;
132                 }
133 @@ -427,6 +438,7 @@ static void ath_tx_complete_aggr(struct 
134         an = (struct ath_node *)sta->drv_priv;
135         tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
136         tid = ATH_AN_2_TID(an, tidno);
137 +       seq_first = tid->seq_start;
138  
139         /*
140          * The hardware occasionally sends a tx status for the wrong TID.
141 @@ -495,8 +507,9 @@ static void ath_tx_complete_aggr(struct 
142                                 txpending = 1;
143                         } else {
144                                 txfail = 1;
145 -                               sendbar = 1;
146                                 txfail_cnt++;
147 +                               bar_index = max_t(int, bar_index,
148 +                                       ATH_BA_INDEX(seq_first, seqno));
149                         }
150                 }
151  
152 @@ -525,7 +538,7 @@ static void ath_tx_complete_aggr(struct 
153                         }
154  
155                         ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
156 -                               !txfail, sendbar);
157 +                               !txfail);
158                 } else {
159                         /* retry the un-acked ones */
160                         if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) {
161 @@ -545,8 +558,10 @@ static void ath_tx_complete_aggr(struct 
162  
163                                                 ath_tx_complete_buf(sc, bf, txq,
164                                                                     &bf_head,
165 -                                                                   ts, 0,
166 -                                                                   !flush);
167 +                                                                   ts, 0);
168 +                                               bar_index = max_t(int, bar_index,
169 +                                                       ATH_BA_INDEX(seq_first,
170 +                                                               seqno));
171                                                 break;
172                                         }
173  
174 @@ -564,6 +579,9 @@ static void ath_tx_complete_aggr(struct 
175                 bf = bf_next;
176         }
177  
178 +       if (bar_index >= 0)
179 +               ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1));
180 +
181         /* prepend un-acked frames to the beginning of the pending frame queue */
182         if (!skb_queue_empty(&bf_pending)) {
183                 if (an->sleeping)
184 @@ -1452,7 +1470,7 @@ static void ath_drain_txq_list(struct at
185                         ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, 0,
186                                              retry_tx);
187                 else
188 -                       ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
189 +                       ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
190                 spin_lock_bh(&txq->axq_lock);
191         }
192  }
193 @@ -1967,9 +1985,6 @@ static void ath_tx_complete(struct ath_s
194  
195         ath_dbg(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb);
196  
197 -       if (tx_flags & ATH_TX_BAR)
198 -               tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK;
199 -
200         if (!(tx_flags & ATH_TX_ERROR))
201                 /* Frame was ACKed */
202                 tx_info->flags |= IEEE80211_TX_STAT_ACK;
203 @@ -2013,16 +2028,13 @@ static void ath_tx_complete(struct ath_s
204  
205  static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
206                                 struct ath_txq *txq, struct list_head *bf_q,
207 -                               struct ath_tx_status *ts, int txok, int sendbar)
208 +                               struct ath_tx_status *ts, int txok)
209  {
210         struct sk_buff *skb = bf->bf_mpdu;
211         struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
212         unsigned long flags;
213         int tx_flags = 0;
214  
215 -       if (sendbar)
216 -               tx_flags = ATH_TX_BAR;
217 -
218         if (!txok)
219                 tx_flags |= ATH_TX_ERROR;
220  
221 @@ -2129,7 +2141,7 @@ static void ath_tx_process_buffer(struct
222  
223         if (!bf_isampdu(bf)) {
224                 ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok);
225 -               ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok, 0);
226 +               ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok);
227         } else
228                 ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok, true);
229  
230 --- a/drivers/net/wireless/ath/ath9k/debug.c
231 +++ b/drivers/net/wireless/ath/ath9k/debug.c
232 @@ -856,7 +856,7 @@ void ath_debug_stat_tx(struct ath_softc 
233         sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len;
234  
235         if (bf_isampdu(bf)) {
236 -               if (flags & ATH_TX_BAR)
237 +               if (flags & ATH_TX_ERROR)
238                         TX_STAT_INC(qnum, a_xretries);
239                 else
240                         TX_STAT_INC(qnum, a_completed);