Skip to content

Commit d94a461

Browse files
nbd168kvalo
authored andcommitted
ath9k: use ieee80211_tx_status_noskb where possible
It removes the need for undoing the padding changes to skb->data and it improves performance by eliminating one tx status lookup per MPDU in the status path. It is also useful for preparing a follow-up fix to better handle powersave filtering. A side effect is that these counters, available via debugfs, become now invalid: * dot11TransmittedFragmentCount * dot11FrameDuplicateCount, * dot11ReceivedFragmentCount * dot11MulticastReceivedFrameCount Signed-off-by: Felix Fietkau <[email protected]> [[email protected]: add a note about counters, thanks to Zefir Kurtisi] Signed-off-by: Kalle Valo <[email protected]>
1 parent 18f53fe commit d94a461

File tree

1 file changed

+62
-32
lines changed
  • drivers/net/wireless/ath/ath9k

1 file changed

+62
-32
lines changed

drivers/net/wireless/ath/ath9k/xmit.c

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ static u16 bits_per_symbol[][2] = {
5050
static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
5151
struct ath_atx_tid *tid, struct sk_buff *skb);
5252
static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
53-
int tx_flags, struct ath_txq *txq);
53+
int tx_flags, struct ath_txq *txq,
54+
struct ieee80211_sta *sta);
5455
static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
5556
struct ath_txq *txq, struct list_head *bf_q,
57+
struct ieee80211_sta *sta,
5658
struct ath_tx_status *ts, int txok);
5759
static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
5860
struct list_head *head, bool internal);
@@ -77,6 +79,22 @@ enum {
7779
/* Aggregation logic */
7880
/*********************/
7981

82+
static void ath_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb)
83+
{
84+
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
85+
struct ieee80211_sta *sta = info->status.status_driver_data[0];
86+
87+
if (info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
88+
ieee80211_tx_status(hw, skb);
89+
return;
90+
}
91+
92+
if (sta)
93+
ieee80211_tx_status_noskb(hw, sta, info);
94+
95+
dev_kfree_skb(skb);
96+
}
97+
8098
void ath_txq_lock(struct ath_softc *sc, struct ath_txq *txq)
8199
__acquires(&txq->axq_lock)
82100
{
@@ -92,6 +110,7 @@ void ath_txq_unlock(struct ath_softc *sc, struct ath_txq *txq)
92110
void ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq)
93111
__releases(&txq->axq_lock)
94112
{
113+
struct ieee80211_hw *hw = sc->hw;
95114
struct sk_buff_head q;
96115
struct sk_buff *skb;
97116

@@ -100,7 +119,7 @@ void ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq)
100119
spin_unlock_bh(&txq->axq_lock);
101120

102121
while ((skb = __skb_dequeue(&q)))
103-
ieee80211_tx_status(sc->hw, skb);
122+
ath_tx_status(hw, skb);
104123
}
105124

106125
static void ath_tx_queue_tid(struct ath_softc *sc, struct ath_txq *txq,
@@ -253,7 +272,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid)
253272
}
254273

255274
list_add_tail(&bf->list, &bf_head);
256-
ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
275+
ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
257276
}
258277

259278
if (sendbar) {
@@ -318,12 +337,12 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq,
318337
bf = fi->bf;
319338

320339
if (!bf) {
321-
ath_tx_complete(sc, skb, ATH_TX_ERROR, txq);
340+
ath_tx_complete(sc, skb, ATH_TX_ERROR, txq, NULL);
322341
continue;
323342
}
324343

325344
list_add_tail(&bf->list, &bf_head);
326-
ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
345+
ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
327346
}
328347
}
329348

@@ -426,12 +445,11 @@ static void ath_tx_count_frames(struct ath_softc *sc, struct ath_buf *bf,
426445

427446
static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
428447
struct ath_buf *bf, struct list_head *bf_q,
448+
struct ieee80211_sta *sta,
429449
struct ath_tx_status *ts, int txok)
430450
{
431451
struct ath_node *an = NULL;
432452
struct sk_buff *skb;
433-
struct ieee80211_sta *sta;
434-
struct ieee80211_hw *hw = sc->hw;
435453
struct ieee80211_hdr *hdr;
436454
struct ieee80211_tx_info *tx_info;
437455
struct ath_atx_tid *tid = NULL;
@@ -460,20 +478,15 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
460478
for (i = 0; i < ts->ts_rateindex; i++)
461479
retries += rates[i].count;
462480

463-
rcu_read_lock();
464-
465-
sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
466481
if (!sta) {
467-
rcu_read_unlock();
468-
469482
INIT_LIST_HEAD(&bf_head);
470483
while (bf) {
471484
bf_next = bf->bf_next;
472485

473486
if (!bf->bf_state.stale || bf_next != NULL)
474487
list_move_tail(&bf->list, &bf_head);
475488

476-
ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0);
489+
ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, ts, 0);
477490

478491
bf = bf_next;
479492
}
@@ -583,7 +596,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
583596
ts);
584597
}
585598

586-
ath_tx_complete_buf(sc, bf, txq, &bf_head, ts,
599+
ath_tx_complete_buf(sc, bf, txq, &bf_head, sta, ts,
587600
!txfail);
588601
} else {
589602
if (tx_info->flags & IEEE80211_TX_STATUS_EOSP) {
@@ -604,7 +617,8 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
604617
ath_tx_update_baw(sc, tid, seqno);
605618

606619
ath_tx_complete_buf(sc, bf, txq,
607-
&bf_head, ts, 0);
620+
&bf_head, NULL, ts,
621+
0);
608622
bar_index = max_t(int, bar_index,
609623
ATH_BA_INDEX(seq_first, seqno));
610624
break;
@@ -648,8 +662,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
648662
ath_txq_lock(sc, txq);
649663
}
650664

651-
rcu_read_unlock();
652-
653665
if (needreset)
654666
ath9k_queue_reset(sc, RESET_TYPE_TX_ERROR);
655667
}
@@ -664,7 +676,10 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
664676
struct ath_tx_status *ts, struct ath_buf *bf,
665677
struct list_head *bf_head)
666678
{
679+
struct ieee80211_hw *hw = sc->hw;
667680
struct ieee80211_tx_info *info;
681+
struct ieee80211_sta *sta;
682+
struct ieee80211_hdr *hdr;
668683
bool txok, flush;
669684

670685
txok = !(ts->ts_status & ATH9K_TXERR_MASK);
@@ -677,6 +692,10 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
677692

678693
ts->duration = ath9k_hw_get_duration(sc->sc_ah, bf->bf_desc,
679694
ts->ts_rateindex);
695+
696+
hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
697+
sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2);
698+
680699
if (!bf_isampdu(bf)) {
681700
if (!flush) {
682701
info = IEEE80211_SKB_CB(bf->bf_mpdu);
@@ -685,9 +704,9 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq,
685704
ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok);
686705
ath_dynack_sample_tx_ts(sc->sc_ah, bf->bf_mpdu, ts);
687706
}
688-
ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok);
707+
ath_tx_complete_buf(sc, bf, txq, bf_head, sta, ts, txok);
689708
} else
690-
ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok);
709+
ath_tx_complete_aggr(sc, txq, bf, bf_head, sta, ts, txok);
691710

692711
if (!flush)
693712
ath_txq_schedule(sc, txq);
@@ -923,7 +942,7 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq,
923942
list_add(&bf->list, &bf_head);
924943
__skb_unlink(skb, *q);
925944
ath_tx_update_baw(sc, tid, seqno);
926-
ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0);
945+
ath_tx_complete_buf(sc, bf, txq, &bf_head, NULL, &ts, 0);
927946
continue;
928947
}
929948

@@ -1832,6 +1851,7 @@ static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq,
18321851
*/
18331852
void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq)
18341853
{
1854+
rcu_read_lock();
18351855
ath_txq_lock(sc, txq);
18361856

18371857
if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
@@ -1850,6 +1870,7 @@ void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq)
18501870
ath_drain_txq_list(sc, txq, &txq->axq_q);
18511871

18521872
ath_txq_unlock_complete(sc, txq);
1873+
rcu_read_unlock();
18531874
}
18541875

18551876
bool ath_drain_all_txq(struct ath_softc *sc)
@@ -2472,7 +2493,8 @@ void ath_tx_cabq(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
24722493
/*****************/
24732494

24742495
static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
2475-
int tx_flags, struct ath_txq *txq)
2496+
int tx_flags, struct ath_txq *txq,
2497+
struct ieee80211_sta *sta)
24762498
{
24772499
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
24782500
struct ath_common *common = ath9k_hw_common(sc->sc_ah);
@@ -2492,15 +2514,17 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
24922514
tx_info->flags |= IEEE80211_TX_STAT_ACK;
24932515
}
24942516

2495-
padpos = ieee80211_hdrlen(hdr->frame_control);
2496-
padsize = padpos & 3;
2497-
if (padsize && skb->len>padpos+padsize) {
2498-
/*
2499-
* Remove MAC header padding before giving the frame back to
2500-
* mac80211.
2501-
*/
2502-
memmove(skb->data + padsize, skb->data, padpos);
2503-
skb_pull(skb, padsize);
2517+
if (tx_info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS) {
2518+
padpos = ieee80211_hdrlen(hdr->frame_control);
2519+
padsize = padpos & 3;
2520+
if (padsize && skb->len>padpos+padsize) {
2521+
/*
2522+
* Remove MAC header padding before giving the frame back to
2523+
* mac80211.
2524+
*/
2525+
memmove(skb->data + padsize, skb->data, padpos);
2526+
skb_pull(skb, padsize);
2527+
}
25042528
}
25052529

25062530
spin_lock_irqsave(&sc->sc_pm_lock, flags);
@@ -2515,12 +2539,14 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
25152539
}
25162540
spin_unlock_irqrestore(&sc->sc_pm_lock, flags);
25172541

2518-
__skb_queue_tail(&txq->complete_q, skb);
25192542
ath_txq_skb_done(sc, txq, skb);
2543+
tx_info->status.status_driver_data[0] = sta;
2544+
__skb_queue_tail(&txq->complete_q, skb);
25202545
}
25212546

25222547
static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
25232548
struct ath_txq *txq, struct list_head *bf_q,
2549+
struct ieee80211_sta *sta,
25242550
struct ath_tx_status *ts, int txok)
25252551
{
25262552
struct sk_buff *skb = bf->bf_mpdu;
@@ -2548,7 +2574,7 @@ static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
25482574
complete(&sc->paprd_complete);
25492575
} else {
25502576
ath_debug_stat_tx(sc, bf, ts, txq, tx_flags);
2551-
ath_tx_complete(sc, skb, tx_flags, txq);
2577+
ath_tx_complete(sc, skb, tx_flags, txq, sta);
25522578
}
25532579
skip_tx_complete:
25542580
/* At this point, skb (bf->bf_mpdu) is consumed...make sure we don't
@@ -2700,10 +2726,12 @@ void ath_tx_tasklet(struct ath_softc *sc)
27002726
u32 qcumask = ((1 << ATH9K_NUM_TX_QUEUES) - 1) & ah->intr_txqs;
27012727
int i;
27022728

2729+
rcu_read_lock();
27032730
for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
27042731
if (ATH_TXQ_SETUP(sc, i) && (qcumask & (1 << i)))
27052732
ath_tx_processq(sc, &sc->tx.txq[i]);
27062733
}
2734+
rcu_read_unlock();
27072735
}
27082736

27092737
void ath_tx_edma_tasklet(struct ath_softc *sc)
@@ -2717,6 +2745,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
27172745
struct list_head *fifo_list;
27182746
int status;
27192747

2748+
rcu_read_lock();
27202749
for (;;) {
27212750
if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
27222751
break;
@@ -2787,6 +2816,7 @@ void ath_tx_edma_tasklet(struct ath_softc *sc)
27872816
ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
27882817
ath_txq_unlock_complete(sc, txq);
27892818
}
2819+
rcu_read_unlock();
27902820
}
27912821

27922822
/*****************/

0 commit comments

Comments
 (0)