From 5a490510ba5fce8a10746525357a297f8f076bb1 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 22 Apr 2015 17:10:38 +0200 Subject: mac80211: use per-CPU TX/RX statistics This isn't all that relevant for RX right now, but TX can be concurrent due to multi-queue and the accounting is therefore broken. Use the standard per-CPU statistics to avoid this. Signed-off-by: Johannes Berg --- net/mac80211/tx.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'net/mac80211/tx.c') diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 83e3261dbf67..745fdf5c2722 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -37,6 +37,16 @@ /* misc utils */ +static inline void ieee80211_tx_stats(struct net_device *dev, u32 len) +{ + struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); + + u64_stats_update_begin(&tstats->syncp); + tstats->tx_packets++; + tstats->tx_bytes += len; + u64_stats_update_end(&tstats->syncp); +} + static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, struct sk_buff *skb, int group_addr, int next_frag_len) @@ -2727,8 +2737,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, return true; } - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len + extra_head; + ieee80211_tx_stats(dev, skb->len + extra_head); /* will not be crypto-handled beyond what we do here, so use false * as the may-encrypt argument for the resize to not account for @@ -2909,8 +2918,7 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, if (IS_ERR(skb)) goto out; - dev->stats.tx_packets++; - dev->stats.tx_bytes += skb->len; + ieee80211_tx_stats(dev, skb->len); ieee80211_xmit(sdata, sta, skb); } -- cgit v1.2.3