dummy.c (a402eae64d0ad12b1c4a411f250d6c161e67f623) dummy.c (bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221)
1/* dummy.c: a dummy net driver
2
3 The purpose of this driver is to provide a device to point a
4 route through, but not to actually transmit packets.
5
6 Why? If you have a machine whose only connection is an occasional
7 PPP/SLIP/PLIP link, you can only connect to your own hostname
8 when the link is up. Otherwise you have to use localhost.

--- 40 unchanged lines hidden (view full) ---

49}
50
51struct pcpu_dstats {
52 u64 tx_packets;
53 u64 tx_bytes;
54 struct u64_stats_sync syncp;
55};
56
1/* dummy.c: a dummy net driver
2
3 The purpose of this driver is to provide a device to point a
4 route through, but not to actually transmit packets.
5
6 Why? If you have a machine whose only connection is an occasional
7 PPP/SLIP/PLIP link, you can only connect to your own hostname
8 when the link is up. Otherwise you have to use localhost.

--- 40 unchanged lines hidden (view full) ---

49}
50
51struct pcpu_dstats {
52 u64 tx_packets;
53 u64 tx_bytes;
54 struct u64_stats_sync syncp;
55};
56
57static struct rtnl_link_stats64 *dummy_get_stats64(struct net_device *dev,
58 struct rtnl_link_stats64 *stats)
57static void dummy_get_stats64(struct net_device *dev,
58 struct rtnl_link_stats64 *stats)
59{
60 int i;
61
62 for_each_possible_cpu(i) {
63 const struct pcpu_dstats *dstats;
64 u64 tbytes, tpackets;
65 unsigned int start;
66
67 dstats = per_cpu_ptr(dev->dstats, i);
68 do {
69 start = u64_stats_fetch_begin_irq(&dstats->syncp);
70 tbytes = dstats->tx_bytes;
71 tpackets = dstats->tx_packets;
72 } while (u64_stats_fetch_retry_irq(&dstats->syncp, start));
73 stats->tx_bytes += tbytes;
74 stats->tx_packets += tpackets;
75 }
59{
60 int i;
61
62 for_each_possible_cpu(i) {
63 const struct pcpu_dstats *dstats;
64 u64 tbytes, tpackets;
65 unsigned int start;
66
67 dstats = per_cpu_ptr(dev->dstats, i);
68 do {
69 start = u64_stats_fetch_begin_irq(&dstats->syncp);
70 tbytes = dstats->tx_bytes;
71 tpackets = dstats->tx_packets;
72 } while (u64_stats_fetch_retry_irq(&dstats->syncp, start));
73 stats->tx_bytes += tbytes;
74 stats->tx_packets += tpackets;
75 }
76 return stats;
77}
78
79static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
80{
81 struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
82
83 u64_stats_update_begin(&dstats->syncp);
84 dstats->tx_packets++;

--- 150 unchanged lines hidden ---
76}
77
78static netdev_tx_t dummy_xmit(struct sk_buff *skb, struct net_device *dev)
79{
80 struct pcpu_dstats *dstats = this_cpu_ptr(dev->dstats);
81
82 u64_stats_update_begin(&dstats->syncp);
83 dstats->tx_packets++;

--- 150 unchanged lines hidden ---