hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/net/openvswitch/vport-internal_dev.c
....@@ -1,19 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (c) 2007-2012 Nicira, Inc.
3
- *
4
- * This program is free software; you can redistribute it and/or
5
- * modify it under the terms of version 2 of the GNU General Public
6
- * License as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope that it will be useful, but
9
- * WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
- * General Public License for more details.
12
- *
13
- * You should have received a copy of the GNU General Public License
14
- * along with this program; if not, write to the Free Software
15
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16
- * 02110-1301, USA
174 */
185
196 #include <linux/if_vlan.h>
....@@ -99,31 +86,13 @@
9986 static void
10087 internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
10188 {
102
- int i;
103
-
10489 memset(stats, 0, sizeof(*stats));
10590 stats->rx_errors = dev->stats.rx_errors;
10691 stats->tx_errors = dev->stats.tx_errors;
10792 stats->tx_dropped = dev->stats.tx_dropped;
10893 stats->rx_dropped = dev->stats.rx_dropped;
10994
110
- for_each_possible_cpu(i) {
111
- const struct pcpu_sw_netstats *percpu_stats;
112
- struct pcpu_sw_netstats local_stats;
113
- unsigned int start;
114
-
115
- percpu_stats = per_cpu_ptr(dev->tstats, i);
116
-
117
- do {
118
- start = u64_stats_fetch_begin_irq(&percpu_stats->syncp);
119
- local_stats = *percpu_stats;
120
- } while (u64_stats_fetch_retry_irq(&percpu_stats->syncp, start));
121
-
122
- stats->rx_bytes += local_stats.rx_bytes;
123
- stats->rx_packets += local_stats.rx_packets;
124
- stats->tx_bytes += local_stats.tx_bytes;
125
- stats->tx_packets += local_stats.tx_packets;
126
- }
95
+ dev_fetch_sw_netstats(stats, dev->tstats);
12796 }
12897
12998 static const struct net_device_ops internal_dev_netdev_ops = {
....@@ -238,7 +207,6 @@
238207 static netdev_tx_t internal_dev_recv(struct sk_buff *skb)
239208 {
240209 struct net_device *netdev = skb->dev;
241
- struct pcpu_sw_netstats *stats;
242210
243211 if (unlikely(!(netdev->flags & IFF_UP))) {
244212 kfree_skb(skb);
....@@ -247,18 +215,13 @@
247215 }
248216
249217 skb_dst_drop(skb);
250
- nf_reset(skb);
218
+ nf_reset_ct(skb);
251219 secpath_reset(skb);
252220
253221 skb->pkt_type = PACKET_HOST;
254222 skb->protocol = eth_type_trans(skb, netdev);
255223 skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
256
-
257
- stats = this_cpu_ptr(netdev->tstats);
258
- u64_stats_update_begin(&stats->syncp);
259
- stats->rx_packets++;
260
- stats->rx_bytes += skb->len;
261
- u64_stats_update_end(&stats->syncp);
224
+ dev_sw_netstats_rx_add(netdev, skb->len);
262225
263226 netif_rx(skb);
264227 return NETDEV_TX_OK;