aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/xmit.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2010-04-19 13:57:30 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-04-20 11:50:53 -0400
commit0a8cea844d93d5fd689140ac913acc5fdcf1fdb1 (patch)
tree9202769cf3f523ac5dbea8e709cbce519d7dce9d /drivers/net/wireless/ath/ath9k/xmit.c
parentc9c99e5e440013c420fd8ec41ee83e89909d5186 (diff)
ath9k: clean up tx buffer handling
Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/xmit.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c67
1 files changed, 32 insertions, 35 deletions
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index cac178a6bd9b..fcbb4a856a00 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -261,19 +261,40 @@ static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq,
261 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_RETRY); 261 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_RETRY);
262} 262}
263 263
264static struct ath_buf* ath_clone_txbuf(struct ath_softc *sc, struct ath_buf *bf) 264static struct ath_buf *ath_tx_get_buffer(struct ath_softc *sc)
265{ 265{
266 struct ath_buf *tbf; 266 struct ath_buf *bf = NULL;
267 267
268 spin_lock_bh(&sc->tx.txbuflock); 268 spin_lock_bh(&sc->tx.txbuflock);
269 if (WARN_ON(list_empty(&sc->tx.txbuf))) { 269
270 if (unlikely(list_empty(&sc->tx.txbuf))) {
270 spin_unlock_bh(&sc->tx.txbuflock); 271 spin_unlock_bh(&sc->tx.txbuflock);
271 return NULL; 272 return NULL;
272 } 273 }
273 tbf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list); 274
274 list_del(&tbf->list); 275 bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list);
276 list_del(&bf->list);
277
275 spin_unlock_bh(&sc->tx.txbuflock); 278 spin_unlock_bh(&sc->tx.txbuflock);
276 279
280 return bf;
281}
282
283static void ath_tx_return_buffer(struct ath_softc *sc, struct ath_buf *bf)
284{
285 spin_lock_bh(&sc->tx.txbuflock);
286 list_add_tail(&bf->list, &sc->tx.txbuf);
287 spin_unlock_bh(&sc->tx.txbuflock);
288}
289
290static struct ath_buf* ath_clone_txbuf(struct ath_softc *sc, struct ath_buf *bf)
291{
292 struct ath_buf *tbf;
293
294 tbf = ath_tx_get_buffer(sc);
295 if (WARN_ON(!tbf))
296 return NULL;
297
277 ATH_TXBUF_RESET(tbf); 298 ATH_TXBUF_RESET(tbf);
278 299
279 tbf->aphy = bf->aphy; 300 tbf->aphy = bf->aphy;
@@ -1081,9 +1102,7 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
1081 list_del(&bf->list); 1102 list_del(&bf->list);
1082 spin_unlock_bh(&txq->axq_lock); 1103 spin_unlock_bh(&txq->axq_lock);
1083 1104
1084 spin_lock_bh(&sc->tx.txbuflock); 1105 ath_tx_return_buffer(sc, bf);
1085 list_add_tail(&bf->list, &sc->tx.txbuf);
1086 spin_unlock_bh(&sc->tx.txbuflock);
1087 continue; 1106 continue;
1088 } 1107 }
1089 } 1108 }
@@ -1325,25 +1344,6 @@ static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
1325 txq->axq_depth++; 1344 txq->axq_depth++;
1326} 1345}
1327 1346
1328static struct ath_buf *ath_tx_get_buffer(struct ath_softc *sc)
1329{
1330 struct ath_buf *bf = NULL;
1331
1332 spin_lock_bh(&sc->tx.txbuflock);
1333
1334 if (unlikely(list_empty(&sc->tx.txbuf))) {
1335 spin_unlock_bh(&sc->tx.txbuflock);
1336 return NULL;
1337 }
1338
1339 bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list);
1340 list_del(&bf->list);
1341
1342 spin_unlock_bh(&sc->tx.txbuflock);
1343
1344 return bf;
1345}
1346
1347static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_atx_tid *tid, 1347static void ath_tx_send_ampdu(struct ath_softc *sc, struct ath_atx_tid *tid,
1348 struct list_head *bf_head, 1348 struct list_head *bf_head,
1349 struct ath_tx_control *txctl) 1349 struct ath_tx_control *txctl)
@@ -1825,9 +1825,7 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb,
1825 } 1825 }
1826 spin_unlock_bh(&txq->axq_lock); 1826 spin_unlock_bh(&txq->axq_lock);
1827 1827
1828 spin_lock_bh(&sc->tx.txbuflock); 1828 ath_tx_return_buffer(sc, bf);
1829 list_add_tail(&bf->list, &sc->tx.txbuf);
1830 spin_unlock_bh(&sc->tx.txbuflock);
1831 1829
1832 return r; 1830 return r;
1833 } 1831 }
@@ -2141,13 +2139,12 @@ static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)
2141 txq->axq_depth--; 2139 txq->axq_depth--;
2142 txok = !(ts.ts_status & ATH9K_TXERR_MASK); 2140 txok = !(ts.ts_status & ATH9K_TXERR_MASK);
2143 txq->axq_tx_inprogress = false; 2141 txq->axq_tx_inprogress = false;
2142 if (bf_held)
2143 list_del(&bf_held->list);
2144 spin_unlock_bh(&txq->axq_lock); 2144 spin_unlock_bh(&txq->axq_lock);
2145 2145
2146 if (bf_held) { 2146 if (bf_held)
2147 spin_lock_bh(&sc->tx.txbuflock); 2147 ath_tx_return_buffer(sc, bf_held);
2148 list_move_tail(&bf_held->list, &sc->tx.txbuf);
2149 spin_unlock_bh(&sc->tx.txbuflock);
2150 }
2151 2148
2152 if (!bf_isampdu(bf)) { 2149 if (!bf_isampdu(bf)) {
2153 /* 2150 /*