developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame^] | 1 | From 26a73e67325cd28ff295afacfb875c14ea8e1988 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Tue, 22 Aug 2023 05:02:53 +0800 |
| 4 | Subject: [PATCH 1/2] mac80211: mtk: add packet count input for |
| 5 | dev_sw_netstat_rx_add |
| 6 | |
| 7 | --- |
| 8 | backport-include/linux/netdevice.h | 12 ++++++++---- |
| 9 | drivers/net/usb/qmi_wwan.c | 2 +- |
| 10 | .../net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c | 2 +- |
| 11 | .../net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c | 2 +- |
| 12 | net/mac80211/rx.c | 8 ++++---- |
| 13 | 5 files changed, 15 insertions(+), 11 deletions(-) |
| 14 | |
| 15 | diff --git a/backport-include/linux/netdevice.h b/backport-include/linux/netdevice.h |
| 16 | index 1d2ac66..04d76d7 100644 |
| 17 | --- a/backport-include/linux/netdevice.h |
| 18 | +++ b/backport-include/linux/netdevice.h |
| 19 | @@ -112,13 +112,15 @@ void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s, |
| 20 | #define netif_rx_any_context LINUX_BACKPORT(netif_rx_any_context) |
| 21 | int netif_rx_any_context(struct sk_buff *skb); |
| 22 | |
| 23 | -static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int len) |
| 24 | +static inline void dev_sw_netstats_rx_add(struct net_device *dev, |
| 25 | + unsigned int packets, |
| 26 | + unsigned int len) |
| 27 | { |
| 28 | struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); |
| 29 | |
| 30 | u64_stats_update_begin(&tstats->syncp); |
| 31 | tstats->rx_bytes += len; |
| 32 | - tstats->rx_packets++; |
| 33 | + tstats->rx_packets += packets; |
| 34 | u64_stats_update_end(&tstats->syncp); |
| 35 | } |
| 36 | |
| 37 | @@ -140,13 +142,15 @@ static inline void dev_sw_netstats_tx_add(struct net_device *dev, |
| 38 | |
| 39 | #if LINUX_VERSION_IS_LESS(5,10,0) |
| 40 | #define dev_sw_netstats_rx_add LINUX_BACKPORT(dev_sw_netstats_rx_add) |
| 41 | -static inline void dev_sw_netstats_rx_add(struct net_device *dev, unsigned int len) |
| 42 | +static inline void dev_sw_netstats_rx_add(struct net_device *dev, |
| 43 | + unsigned int packets, |
| 44 | + unsigned int len) |
| 45 | { |
| 46 | struct pcpu_sw_netstats *tstats = this_cpu_ptr(dev->tstats); |
| 47 | |
| 48 | u64_stats_update_begin(&tstats->syncp); |
| 49 | tstats->rx_bytes += len; |
| 50 | - tstats->rx_packets++; |
| 51 | + tstats->rx_packets += packets; |
| 52 | u64_stats_update_end(&tstats->syncp); |
| 53 | } |
| 54 | #endif /* < 5.10 */ |
| 55 | diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c |
| 56 | index adbcfdf..f93359a 100644 |
| 57 | --- a/drivers/net/usb/qmi_wwan.c |
| 58 | +++ b/drivers/net/usb/qmi_wwan.c |
| 59 | @@ -210,7 +210,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb) |
| 60 | net->stats.rx_errors++; |
| 61 | return 0; |
| 62 | } else { |
| 63 | - dev_sw_netstats_rx_add(net, pkt_len); |
| 64 | + dev_sw_netstats_rx_add(net, 1, pkt_len); |
| 65 | } |
| 66 | |
| 67 | skip: |
| 68 | diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c |
| 69 | index 8c23a77..8f201ea 100644 |
| 70 | --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c |
| 71 | +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/pearl_pcie.c |
| 72 | @@ -756,7 +756,7 @@ static int qtnf_pcie_pearl_rx_poll(struct napi_struct *napi, int budget) |
| 73 | skb_put(skb, psize); |
| 74 | ndev = qtnf_classify_skb(bus, skb); |
| 75 | if (likely(ndev)) { |
| 76 | - dev_sw_netstats_rx_add(ndev, skb->len); |
| 77 | + dev_sw_netstats_rx_add(ndev, 1, skb->len); |
| 78 | skb->protocol = eth_type_trans(skb, ndev); |
| 79 | napi_gro_receive(napi, skb); |
| 80 | } else { |
| 81 | diff --git a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c |
| 82 | index d833625..0a7bb97 100644 |
| 83 | --- a/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c |
| 84 | +++ b/drivers/net/wireless/quantenna/qtnfmac/pcie/topaz_pcie.c |
| 85 | @@ -662,7 +662,7 @@ static int qtnf_topaz_rx_poll(struct napi_struct *napi, int budget) |
| 86 | skb_put(skb, psize); |
| 87 | ndev = qtnf_classify_skb(bus, skb); |
| 88 | if (likely(ndev)) { |
| 89 | - dev_sw_netstats_rx_add(ndev, skb->len); |
| 90 | + dev_sw_netstats_rx_add(ndev, 1, skb->len); |
| 91 | skb->protocol = eth_type_trans(skb, ndev); |
| 92 | netif_receive_skb(skb); |
| 93 | } else { |
| 94 | diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c |
| 95 | index fb3d2e4..347867c 100644 |
| 96 | --- a/net/mac80211/rx.c |
| 97 | +++ b/net/mac80211/rx.c |
| 98 | @@ -853,7 +853,7 @@ ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb, |
| 99 | |
| 100 | if (skb) { |
| 101 | skb->dev = sdata->dev; |
| 102 | - dev_sw_netstats_rx_add(skb->dev, skb->len); |
| 103 | + dev_sw_netstats_rx_add(skb->dev, 1, skb->len); |
| 104 | netif_receive_skb(skb); |
| 105 | } |
| 106 | } |
| 107 | @@ -2632,7 +2632,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) |
| 108 | skb = rx->skb; |
| 109 | xmit_skb = NULL; |
| 110 | |
| 111 | - dev_sw_netstats_rx_add(dev, skb->len); |
| 112 | + dev_sw_netstats_rx_add(dev, 1, skb->len); |
| 113 | |
| 114 | if (rx->sta) { |
| 115 | /* The seqno index has the same property as needed |
| 116 | @@ -4050,7 +4050,7 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, |
| 117 | } |
| 118 | |
| 119 | prev_dev = sdata->dev; |
| 120 | - dev_sw_netstats_rx_add(sdata->dev, skb->len); |
| 121 | + dev_sw_netstats_rx_add(sdata->dev, 1, skb->len); |
| 122 | } |
| 123 | |
| 124 | if (prev_dev) { |
| 125 | @@ -4762,7 +4762,7 @@ static void ieee80211_rx_8023(struct ieee80211_rx_data *rx, |
| 126 | |
| 127 | skb->dev = fast_rx->dev; |
| 128 | |
| 129 | - dev_sw_netstats_rx_add(fast_rx->dev, skb->len); |
| 130 | + dev_sw_netstats_rx_add(fast_rx->dev, 1, skb->len); |
| 131 | |
| 132 | /* The seqno index has the same property as needed |
| 133 | * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS |
| 134 | -- |
| 135 | 2.18.0 |
| 136 | |