ath9k: add some cleanup patches
[oweals/openwrt.git] / package / mac80211 / patches / 542-ath9k_move_seqno.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -211,12 +211,12 @@ struct ath_frame_info {
4         enum ath9k_key_type keytype;
5         u8 keyix;
6         u8 retries;
7 -       u16 seqno;
8  };
9  
10  struct ath_buf_state {
11         u8 bf_type;
12         u8 bfs_paprd;
13 +       u16 seqno;
14         unsigned long bfs_paprd_timestamp;
15  };
16  
17 --- a/drivers/net/wireless/ath/ath9k/xmit.c
18 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
19 @@ -168,7 +168,7 @@ static void ath_tx_flush_tid(struct ath_
20  
21                 spin_unlock_bh(&txq->axq_lock);
22                 if (fi->retries) {
23 -                       ath_tx_update_baw(sc, tid, fi->seqno);
24 +                       ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
25                         ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 1);
26                 } else {
27                         ath_tx_send_normal(sc, txq, NULL, &bf_head);
28 @@ -237,7 +237,7 @@ static void ath_tid_drain(struct ath_sof
29                 list_add_tail(&bf->list, &bf_head);
30  
31                 if (fi->retries)
32 -                       ath_tx_update_baw(sc, tid, fi->seqno);
33 +                       ath_tx_update_baw(sc, tid, bf->bf_state.seqno);
34  
35                 spin_unlock(&txq->axq_lock);
36                 ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0);
37 @@ -327,7 +327,7 @@ static void ath_tx_count_frames(struct a
38  
39         while (bf) {
40                 fi = get_frame_info(bf->bf_mpdu);
41 -               ba_index = ATH_BA_INDEX(seq_st, fi->seqno);
42 +               ba_index = ATH_BA_INDEX(seq_st, bf->bf_state.seqno);
43  
44                 (*nframes)++;
45                 if (!txok || (isaggr && !ATH_BA_ISSET(ba, ba_index)))
46 @@ -428,6 +428,8 @@ static void ath_tx_complete_aggr(struct 
47  
48         ath_tx_count_frames(sc, bf, ts, txok, &nframes, &nbad);
49         while (bf) {
50 +               u16 seqno = bf->bf_state.seqno;
51 +
52                 txfail = txpending = sendbar = 0;
53                 bf_next = bf->bf_next;
54  
55 @@ -435,7 +437,7 @@ static void ath_tx_complete_aggr(struct 
56                 tx_info = IEEE80211_SKB_CB(skb);
57                 fi = get_frame_info(skb);
58  
59 -               if (ATH_BA_ISSET(ba, ATH_BA_INDEX(seq_st, fi->seqno))) {
60 +               if (ATH_BA_ISSET(ba, ATH_BA_INDEX(seq_st, seqno))) {
61                         /* transmit completion, subframe is
62                          * acked by block ack */
63                         acked_cnt++;
64 @@ -479,7 +481,7 @@ static void ath_tx_complete_aggr(struct 
65                          * block-ack window
66                          */
67                         spin_lock_bh(&txq->axq_lock);
68 -                       ath_tx_update_baw(sc, tid, fi->seqno);
69 +                       ath_tx_update_baw(sc, tid, seqno);
70                         spin_unlock_bh(&txq->axq_lock);
71  
72                         if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) {
73 @@ -507,7 +509,7 @@ static void ath_tx_complete_aggr(struct 
74                                          */
75                                         if (!tbf) {
76                                                 spin_lock_bh(&txq->axq_lock);
77 -                                               ath_tx_update_baw(sc, tid, fi->seqno);
78 +                                               ath_tx_update_baw(sc, tid, seqno);
79                                                 spin_unlock_bh(&txq->axq_lock);
80  
81                                                 bf->bf_state.bf_type |=
82 @@ -752,17 +754,19 @@ static enum ATH_AGGR_STATUS ath_tx_form_
83         struct ieee80211_tx_info *tx_info;
84         struct ath_frame_info *fi;
85         struct sk_buff *skb;
86 +       u16 seqno;
87  
88         do {
89                 skb = skb_peek(&tid->buf_q);
90                 fi = get_frame_info(skb);
91                 bf = fi->bf;
92 +               seqno = bf->bf_state.seqno;
93  
94                 if (!bf_first)
95                         bf_first = bf;
96  
97                 /* do not step over block-ack window */
98 -               if (!BAW_WITHIN(tid->seq_start, tid->baw_size, fi->seqno)) {
99 +               if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) {
100                         status = ATH_AGGR_BAW_CLOSED;
101                         break;
102                 }
103 @@ -810,7 +814,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
104  
105                 /* link buffers of this frame to the aggregate */
106                 if (!fi->retries)
107 -                       ath_tx_addto_baw(sc, tid, fi->seqno);
108 +                       ath_tx_addto_baw(sc, tid, seqno);
109                 ath9k_hw_set11n_aggr_middle(sc->sc_ah, bf->bf_desc, ndelim);
110  
111                 __skb_unlink(skb, &tid->buf_q);
112 @@ -1434,6 +1438,7 @@ static void ath_tx_send_ampdu(struct ath
113  {
114         struct ath_frame_info *fi = get_frame_info(bf->bf_mpdu);
115         struct list_head bf_head;
116 +       u16 seqno = bf->bf_state.seqno;
117  
118         bf->bf_state.bf_type |= BUF_AMPDU;
119  
120 @@ -1445,7 +1450,7 @@ static void ath_tx_send_ampdu(struct ath
121          * - h/w queue depth exceeds low water mark
122          */
123         if (!skb_queue_empty(&tid->buf_q) || tid->paused ||
124 -           !BAW_WITHIN(tid->seq_start, tid->baw_size, fi->seqno) ||
125 +           !BAW_WITHIN(tid->seq_start, tid->baw_size, seqno) ||
126             txctl->txq->axq_ampdu_depth >= ATH_AGGR_MIN_QDEPTH) {
127                 /*
128                  * Add this frame to software queue for scheduling later
129 @@ -1463,7 +1468,7 @@ static void ath_tx_send_ampdu(struct ath
130  
131         /* Add sub-frame to BAW */
132         if (!fi->retries)
133 -               ath_tx_addto_baw(sc, tid, fi->seqno);
134 +               ath_tx_addto_baw(sc, tid, seqno);
135  
136         /* Queue to h/w without aggregation */
137         TX_STAT_INC(txctl->txq->axq_qnum, a_queued_hw);
138 @@ -1519,39 +1524,19 @@ static enum ath9k_pkt_type get_hw_packet
139  static void setup_frame_info(struct ieee80211_hw *hw, struct sk_buff *skb,
140                              int framelen)
141  {
142 -       struct ath_softc *sc = hw->priv;
143         struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
144         struct ieee80211_sta *sta = tx_info->control.sta;
145         struct ieee80211_key_conf *hw_key = tx_info->control.hw_key;
146 -       struct ieee80211_hdr *hdr;
147 +       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
148         struct ath_frame_info *fi = get_frame_info(skb);
149         struct ath_node *an = NULL;
150 -       struct ath_atx_tid *tid;
151         enum ath9k_key_type keytype;
152 -       u16 seqno = 0;
153 -       u8 tidno;
154  
155         keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
156  
157         if (sta)
158                 an = (struct ath_node *) sta->drv_priv;
159  
160 -       hdr = (struct ieee80211_hdr *)skb->data;
161 -       if (an && ieee80211_is_data_qos(hdr->frame_control) &&
162 -               conf_is_ht(&hw->conf) && (sc->sc_flags & SC_OP_TXAGGR)) {
163 -
164 -               tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
165 -
166 -               /*
167 -                * Override seqno set by upper layer with the one
168 -                * in tx aggregation state.
169 -                */
170 -               tid = ATH_AN_2_TID(an, tidno);
171 -               seqno = tid->seq_next;
172 -               hdr->seq_ctrl = cpu_to_le16(seqno << IEEE80211_SEQ_SEQ_SHIFT);
173 -               INCR(tid->seq_next, IEEE80211_SEQ_MAX);
174 -       }
175 -
176         memset(fi, 0, sizeof(*fi));
177         if (hw_key)
178                 fi->keyix = hw_key->hw_key_idx;
179 @@ -1561,7 +1546,6 @@ static void setup_frame_info(struct ieee
180                 fi->keyix = ATH9K_TXKEYIX_INVALID;
181         fi->keytype = keytype;
182         fi->framelen = framelen;
183 -       fi->seqno = seqno;
184  }
185  
186  static int setup_tx_flags(struct sk_buff *skb)
187 @@ -1797,6 +1781,7 @@ static void ath_tx_start_dma(struct ath_
188         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
189         struct list_head bf_head;
190         struct ath_atx_tid *tid = NULL;
191 +       u16 seqno;
192         u8 tidno;
193  
194         spin_lock_bh(&txctl->txq->axq_lock);
195 @@ -1806,6 +1791,12 @@ static void ath_tx_start_dma(struct ath_
196                         IEEE80211_QOS_CTL_TID_MASK;
197                 tid = ATH_AN_2_TID(txctl->an, tidno);
198  
199 +               seqno = tid->seq_next;
200 +               hdr->seq_ctrl = cpu_to_le16(tid->seq_next << IEEE80211_SEQ_SEQ_SHIFT);
201 +               INCR(tid->seq_next, IEEE80211_SEQ_MAX);
202 +
203 +               bf->bf_state.seqno = seqno;
204 +
205                 WARN_ON(tid->ac->txq != txctl->txq);
206         }
207