| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * 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 |
|---|
| 17 | 4 | */ |
|---|
| 18 | 5 | |
|---|
| 19 | 6 | #include <linux/if_vlan.h> |
|---|
| .. | .. |
|---|
| 99 | 86 | static void |
|---|
| 100 | 87 | internal_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) |
|---|
| 101 | 88 | { |
|---|
| 102 | | - int i; |
|---|
| 103 | | - |
|---|
| 104 | 89 | memset(stats, 0, sizeof(*stats)); |
|---|
| 105 | 90 | stats->rx_errors = dev->stats.rx_errors; |
|---|
| 106 | 91 | stats->tx_errors = dev->stats.tx_errors; |
|---|
| 107 | 92 | stats->tx_dropped = dev->stats.tx_dropped; |
|---|
| 108 | 93 | stats->rx_dropped = dev->stats.rx_dropped; |
|---|
| 109 | 94 | |
|---|
| 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); |
|---|
| 127 | 96 | } |
|---|
| 128 | 97 | |
|---|
| 129 | 98 | static const struct net_device_ops internal_dev_netdev_ops = { |
|---|
| .. | .. |
|---|
| 238 | 207 | static netdev_tx_t internal_dev_recv(struct sk_buff *skb) |
|---|
| 239 | 208 | { |
|---|
| 240 | 209 | struct net_device *netdev = skb->dev; |
|---|
| 241 | | - struct pcpu_sw_netstats *stats; |
|---|
| 242 | 210 | |
|---|
| 243 | 211 | if (unlikely(!(netdev->flags & IFF_UP))) { |
|---|
| 244 | 212 | kfree_skb(skb); |
|---|
| .. | .. |
|---|
| 247 | 215 | } |
|---|
| 248 | 216 | |
|---|
| 249 | 217 | skb_dst_drop(skb); |
|---|
| 250 | | - nf_reset(skb); |
|---|
| 218 | + nf_reset_ct(skb); |
|---|
| 251 | 219 | secpath_reset(skb); |
|---|
| 252 | 220 | |
|---|
| 253 | 221 | skb->pkt_type = PACKET_HOST; |
|---|
| 254 | 222 | skb->protocol = eth_type_trans(skb, netdev); |
|---|
| 255 | 223 | 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); |
|---|
| 262 | 225 | |
|---|
| 263 | 226 | netif_rx(skb); |
|---|
| 264 | 227 | return NETDEV_TX_OK; |
|---|