rb532: fix a module dependency issue
[openwrt/openwrt.git] / package / mac80211 / patches / 530-ath9k_queue_fill.patch
1 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
2 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
3 @@ -137,6 +137,8 @@ void ath_descdma_cleanup(struct ath_soft
4 #define ATH_MAX_ANTENNA 3
5 #define ATH_RXBUF 512
6 #define ATH_TXBUF 512
7 +#define ATH_TXBUF_RESERVE 5
8 +#define ATH_MAX_QDEPTH (ATH_TXBUF / 4 - ATH_TXBUF_RESERVE)
9 #define ATH_TXMAXTRY 13
10 #define ATH_MGT_TXMAXTRY 4
11
12 @@ -205,6 +207,7 @@ struct ath_txq {
13 struct list_head txq_fifo_pending;
14 u8 txq_headidx;
15 u8 txq_tailidx;
16 + int pending_frames;
17 };
18
19 struct ath_atx_ac {
20 @@ -242,6 +245,7 @@ struct ath_buf {
21 struct ath_buf_state bf_state;
22 dma_addr_t bf_dmacontext;
23 struct ath_wiphy *aphy;
24 + struct ath_txq *txq;
25 };
26
27 struct ath_atx_tid {
28 @@ -331,7 +335,6 @@ void ath_tx_node_cleanup(struct ath_soft
29 void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
30 int ath_tx_init(struct ath_softc *sc, int nbufs);
31 void ath_tx_cleanup(struct ath_softc *sc);
32 -struct ath_txq *ath_test_get_txq(struct ath_softc *sc, struct sk_buff *skb);
33 int ath_txq_update(struct ath_softc *sc, int qnum,
34 struct ath9k_tx_queue_info *q);
35 int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
36 --- a/drivers/net/wireless/ath/ath9k/xmit.c
37 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
38 @@ -986,32 +986,6 @@ int ath_tx_get_qnum(struct ath_softc *sc
39 return qnum;
40 }
41
42 -struct ath_txq *ath_test_get_txq(struct ath_softc *sc, struct sk_buff *skb)
43 -{
44 - struct ath_txq *txq = NULL;
45 - u16 skb_queue = skb_get_queue_mapping(skb);
46 - int qnum;
47 -
48 - qnum = ath_get_hal_qnum(skb_queue, sc);
49 - txq = &sc->tx.txq[qnum];
50 -
51 - spin_lock_bh(&txq->axq_lock);
52 -
53 - if (txq->axq_depth >= (ATH_TXBUF - 20)) {
54 - ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_XMIT,
55 - "TX queue: %d is full, depth: %d\n",
56 - qnum, txq->axq_depth);
57 - ath_mac80211_stop_queue(sc, skb_queue);
58 - txq->stopped = 1;
59 - spin_unlock_bh(&txq->axq_lock);
60 - return NULL;
61 - }
62 -
63 - spin_unlock_bh(&txq->axq_lock);
64 -
65 - return txq;
66 -}
67 -
68 int ath_txq_update(struct ath_softc *sc, int qnum,
69 struct ath9k_tx_queue_info *qinfo)
70 {
71 @@ -1811,6 +1785,7 @@ int ath_tx_start(struct ieee80211_hw *hw
72 struct ath_wiphy *aphy = hw->priv;
73 struct ath_softc *sc = aphy->sc;
74 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
75 + struct ath_txq *txq = txctl->txq;
76 struct ath_buf *bf;
77 int r;
78
79 @@ -1820,10 +1795,16 @@ int ath_tx_start(struct ieee80211_hw *hw
80 return -1;
81 }
82
83 + bf->txq = txctl->txq;
84 + spin_lock_bh(&bf->txq->axq_lock);
85 + if (++bf->txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
86 + ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
87 + txq->stopped = 1;
88 + }
89 + spin_unlock_bh(&bf->txq->axq_lock);
90 +
91 r = ath_tx_setup_buffer(hw, bf, skb, txctl);
92 if (unlikely(r)) {
93 - struct ath_txq *txq = txctl->txq;
94 -
95 ath_print(common, ATH_DBG_FATAL, "TX mem alloc failure\n");
96
97 /* upon ath_tx_processq() this TX queue will be resumed, we
98 @@ -1831,7 +1812,7 @@ int ath_tx_start(struct ieee80211_hw *hw
99 * we will at least have to run TX completionon one buffer
100 * on the queue */
101 spin_lock_bh(&txq->axq_lock);
102 - if (sc->tx.txq[txq->axq_qnum].axq_depth > 1) {
103 + if (!txq->stopped && txq->axq_depth > 1) {
104 ath_mac80211_stop_queue(sc, skb_get_queue_mapping(skb));
105 txq->stopped = 1;
106 }
107 @@ -1972,6 +1953,13 @@ static void ath_tx_complete_buf(struct a
108 tx_flags |= ATH_TX_XRETRY;
109 }
110
111 + if (bf->txq) {
112 + spin_lock_bh(&bf->txq->axq_lock);
113 + bf->txq->pending_frames--;
114 + spin_unlock_bh(&bf->txq->axq_lock);
115 + bf->txq = NULL;
116 + }
117 +
118 dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
119 ath_tx_complete(sc, skb, bf->aphy, tx_flags);
120 ath_debug_stat_tx(sc, txq, bf, ts);
121 @@ -2060,8 +2048,7 @@ static void ath_wake_mac80211_queue(stru
122 int qnum;
123
124 spin_lock_bh(&txq->axq_lock);
125 - if (txq->stopped &&
126 - sc->tx.txq[txq->axq_qnum].axq_depth <= (ATH_TXBUF - 20)) {
127 + if (txq->stopped && txq->pending_frames < ATH_MAX_QDEPTH) {
128 qnum = ath_get_mac80211_qnum(txq->axq_qnum, sc);
129 if (qnum != -1) {
130 ath_mac80211_start_queue(sc, qnum);
131 --- a/drivers/net/wireless/ath/ath9k/main.c
132 +++ b/drivers/net/wireless/ath/ath9k/main.c
133 @@ -1026,6 +1026,7 @@ static int ath9k_tx(struct ieee80211_hw
134 struct ath_tx_control txctl;
135 int padpos, padsize;
136 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
137 + int qnum;
138
139 if (aphy->state != ATH_WIPHY_ACTIVE && aphy->state != ATH_WIPHY_SCAN) {
140 ath_print(common, ATH_DBG_XMIT,
141 @@ -1098,11 +1099,8 @@ static int ath9k_tx(struct ieee80211_hw
142 memmove(skb->data, skb->data + padsize, padpos);
143 }
144
145 - /* Check if a tx queue is available */
146 -
147 - txctl.txq = ath_test_get_txq(sc, skb);
148 - if (!txctl.txq)
149 - goto exit;
150 + qnum = ath_get_hal_qnum(skb_get_queue_mapping(skb), sc);
151 + txctl.txq = &sc->tx.txq[qnum];
152
153 ath_print(common, ATH_DBG_XMIT, "transmitting packet, skb: %p\n", skb);
154