ath9k: add missing chunk to the BlockAckReq fix (fixes a compile error)
[oweals/openwrt.git] / package / mac80211 / patches / 574-ath9k_limit_qlen.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -235,6 +235,7 @@ struct ath_atx_tid {
4         struct ath_node *an;
5         struct ath_atx_ac *ac;
6         unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)];
7 +       int buf_pending;
8         u16 seq_start;
9         u16 seq_next;
10         u16 baw_size;
11 @@ -283,6 +284,9 @@ struct ath_tx_control {
12   *  (axq_qnum).
13   */
14  struct ath_tx {
15 +       u32 qlen_single;
16 +       u32 qlen_aggr;
17 +
18         u16 seq_no;
19         u32 txqsetup;
20         spinlock_t txbuflock;
21 --- a/drivers/net/wireless/ath/ath9k/debug.c
22 +++ b/drivers/net/wireless/ath/ath9k/debug.c
23 @@ -1250,6 +1250,10 @@ int ath9k_init_debug(struct ath_hw *ah)
24                             sc, &fops_wiphy);
25         debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy, sc,
26                             &fops_xmit);
27 +       debugfs_create_u32("qlen_single", S_IRUSR | S_IWUSR,
28 +                          sc->debug.debugfs_phy, &sc->tx.qlen_single);
29 +       debugfs_create_u32("qlen_aggr", S_IRUSR | S_IWUSR,
30 +                          sc->debug.debugfs_phy, &sc->tx.qlen_aggr);
31         debugfs_create_file("stations", S_IRUSR, sc->debug.debugfs_phy, sc,
32                             &fops_stations);
33         debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy, sc,
34 --- a/drivers/net/wireless/ath/ath9k/xmit.c
35 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
36 @@ -339,6 +339,14 @@ static void ath_tx_count_frames(struct a
37         }
38  }
39  
40 +static struct ath_atx_tid *ath_get_tid(struct ath_node *an, struct sk_buff *skb)
41 +{
42 +       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
43 +       u8 tidno;
44 +
45 +       tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
46 +       return ATH_AN_2_TID(an, tidno);
47 +}
48  
49  static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
50                                  struct ath_buf *bf, struct list_head *bf_q,
51 @@ -433,6 +441,8 @@ static void ath_tx_complete_aggr(struct 
52         __skb_queue_head_init(&bf_pending);
53  
54         ath_tx_count_frames(sc, bf, ts, txok, &nframes, &nbad);
55 +       tid->buf_pending -= nframes;
56 +
57         while (bf) {
58                 txfail = txpending = 0;
59                 bf_next = bf->bf_next;
60 @@ -790,6 +800,7 @@ static enum ATH_AGGR_STATUS ath_tx_form_
61                         ath_tx_addto_baw(sc, tid, fi->seqno);
62                 ath9k_hw_set11n_aggr_middle(sc->sc_ah, bf->bf_desc, ndelim);
63  
64 +               tid->buf_pending++;
65                 __skb_unlink(skb, &tid->buf_q);
66                 list_add_tail(&bf->list, bf_q);
67                 if (bf_prev) {
68 @@ -1441,6 +1452,8 @@ static void ath_tx_send_ampdu(struct ath
69         if (!fi->retries)
70                 ath_tx_addto_baw(sc, tid, fi->seqno);
71  
72 +       tid->buf_pending++;
73 +
74         /* Queue to h/w without aggregation */
75         TX_STAT_INC(txctl->txq->axq_qnum, a_queued_hw);
76         bf->bf_lastbf = bf;
77 @@ -1505,7 +1518,6 @@ static void setup_frame_info(struct ieee
78         struct ath_atx_tid *tid;
79         enum ath9k_key_type keytype;
80         u16 seqno = 0;
81 -       u8 tidno;
82  
83         keytype = ath9k_cmn_get_hw_crypto_keytype(skb);
84  
85 @@ -1516,13 +1528,11 @@ static void setup_frame_info(struct ieee
86         if (an && ieee80211_is_data_qos(hdr->frame_control) &&
87                 conf_is_ht(&hw->conf) && (sc->sc_flags & SC_OP_TXAGGR)) {
88  
89 -               tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
90 -
91                 /*
92                  * Override seqno set by upper layer with the one
93                  * in tx aggregation state.
94                  */
95 -               tid = ATH_AN_2_TID(an, tidno);
96 +               tid = ath_get_tid(an, skb);
97                 seqno = tid->seq_next;
98                 hdr->seq_ctrl = cpu_to_le16(seqno << IEEE80211_SEQ_SEQ_SHIFT);
99                 INCR(tid->seq_next, IEEE80211_SEQ_MAX);
100 @@ -1766,24 +1776,14 @@ static struct ath_buf *ath_tx_setup_buff
101  
102  /* FIXME: tx power */
103  static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf,
104 -                            struct ath_tx_control *txctl)
105 +                            struct ath_tx_control *txctl,
106 +                            struct ath_atx_tid *tid)
107  {
108         struct sk_buff *skb = bf->bf_mpdu;
109         struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
110 -       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
111         struct list_head bf_head;
112 -       struct ath_atx_tid *tid = NULL;
113 -       u8 tidno;
114  
115         spin_lock_bh(&txctl->txq->axq_lock);
116 -       if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an &&
117 -               ieee80211_is_data_qos(hdr->frame_control)) {
118 -               tidno = ieee80211_get_qos_ctl(hdr)[0] &
119 -                       IEEE80211_QOS_CTL_TID_MASK;
120 -               tid = ATH_AN_2_TID(txctl->an, tidno);
121 -
122 -               WARN_ON(tid->ac->txq != txctl->txq);
123 -       }
124  
125         if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
126                 /*
127 @@ -1824,6 +1824,7 @@ int ath_tx_start(struct ieee80211_hw *hw
128         struct ieee80211_vif *vif = info->control.vif;
129         struct ath_softc *sc = hw->priv;
130         struct ath_txq *txq = txctl->txq;
131 +       struct ath_atx_tid *tid = NULL;
132         struct ath_buf *bf;
133         int padpos, padsize;
134         int frmlen = skb->len + FCS_LEN;
135 @@ -1857,6 +1858,7 @@ int ath_tx_start(struct ieee80211_hw *hw
136  
137                 skb_push(skb, padsize);
138                 memmove(skb->data, skb->data + padsize, padpos);
139 +               hdr = (struct ieee80211_hdr *) skb->data;
140         }
141  
142         if ((vif && vif->type != NL80211_IFTYPE_AP &&
143 @@ -1866,6 +1868,24 @@ int ath_tx_start(struct ieee80211_hw *hw
144  
145         setup_frame_info(hw, skb, frmlen);
146  
147 +       if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an &&
148 +           ieee80211_is_data_qos(hdr->frame_control)) {
149 +               tid = ath_get_tid(txctl->an, skb);
150 +
151 +               WARN_ON(tid->ac->txq != txq);
152 +       }
153 +
154 +       if ((info->flags & IEEE80211_TX_CTL_AMPDU) && tid) {
155 +               if (sc->tx.qlen_aggr > 0 && skb_queue_len(&tid->buf_q) +
156 +                   tid->buf_pending >= sc->tx.qlen_aggr)
157 +                       return -ENOMEM;
158 +       } else {
159 +               if (sc->tx.qlen_single > 0 &&
160 +                   txq->axq_depth - txq->axq_ampdu_depth >=
161 +                     sc->tx.qlen_single)
162 +                       return -ENOMEM;
163 +       }
164 +
165         /*
166          * At this point, the vif, hw_key and sta pointers in the tx control
167          * info are no longer valid (overwritten by the ath_frame_info data.
168 @@ -1884,7 +1904,7 @@ int ath_tx_start(struct ieee80211_hw *hw
169         }
170         spin_unlock_bh(&txq->axq_lock);
171  
172 -       ath_tx_start_dma(sc, bf, txctl);
173 +       ath_tx_start_dma(sc, bf, txctl, tid);
174  
175         return 0;
176  }