diff options
Diffstat (limited to 'drivers/net/loopback.c')
-rw-r--r-- | drivers/net/loopback.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 9a0996795321..4ce9e5f2c069 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -64,7 +64,6 @@ struct pcpu_lstats { | |||
64 | u64 packets; | 64 | u64 packets; |
65 | u64 bytes; | 65 | u64 bytes; |
66 | struct u64_stats_sync syncp; | 66 | struct u64_stats_sync syncp; |
67 | unsigned long drops; | ||
68 | }; | 67 | }; |
69 | 68 | ||
70 | /* | 69 | /* |
@@ -74,7 +73,6 @@ struct pcpu_lstats { | |||
74 | static netdev_tx_t loopback_xmit(struct sk_buff *skb, | 73 | static netdev_tx_t loopback_xmit(struct sk_buff *skb, |
75 | struct net_device *dev) | 74 | struct net_device *dev) |
76 | { | 75 | { |
77 | struct pcpu_lstats __percpu *pcpu_lstats; | ||
78 | struct pcpu_lstats *lb_stats; | 76 | struct pcpu_lstats *lb_stats; |
79 | int len; | 77 | int len; |
80 | 78 | ||
@@ -83,8 +81,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, | |||
83 | skb->protocol = eth_type_trans(skb, dev); | 81 | skb->protocol = eth_type_trans(skb, dev); |
84 | 82 | ||
85 | /* it's OK to use per_cpu_ptr() because BHs are off */ | 83 | /* it's OK to use per_cpu_ptr() because BHs are off */ |
86 | pcpu_lstats = (void __percpu __force *)dev->ml_priv; | 84 | lb_stats = this_cpu_ptr(dev->lstats); |
87 | lb_stats = this_cpu_ptr(pcpu_lstats); | ||
88 | 85 | ||
89 | len = skb->len; | 86 | len = skb->len; |
90 | if (likely(netif_rx(skb) == NET_RX_SUCCESS)) { | 87 | if (likely(netif_rx(skb) == NET_RX_SUCCESS)) { |
@@ -92,8 +89,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, | |||
92 | lb_stats->bytes += len; | 89 | lb_stats->bytes += len; |
93 | lb_stats->packets++; | 90 | lb_stats->packets++; |
94 | u64_stats_update_end(&lb_stats->syncp); | 91 | u64_stats_update_end(&lb_stats->syncp); |
95 | } else | 92 | } |
96 | lb_stats->drops++; | ||
97 | 93 | ||
98 | return NETDEV_TX_OK; | 94 | return NETDEV_TX_OK; |
99 | } | 95 | } |
@@ -101,32 +97,26 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb, | |||
101 | static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev, | 97 | static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev, |
102 | struct rtnl_link_stats64 *stats) | 98 | struct rtnl_link_stats64 *stats) |
103 | { | 99 | { |
104 | const struct pcpu_lstats __percpu *pcpu_lstats; | ||
105 | u64 bytes = 0; | 100 | u64 bytes = 0; |
106 | u64 packets = 0; | 101 | u64 packets = 0; |
107 | u64 drops = 0; | ||
108 | int i; | 102 | int i; |
109 | 103 | ||
110 | pcpu_lstats = (void __percpu __force *)dev->ml_priv; | ||
111 | for_each_possible_cpu(i) { | 104 | for_each_possible_cpu(i) { |
112 | const struct pcpu_lstats *lb_stats; | 105 | const struct pcpu_lstats *lb_stats; |
113 | u64 tbytes, tpackets; | 106 | u64 tbytes, tpackets; |
114 | unsigned int start; | 107 | unsigned int start; |
115 | 108 | ||
116 | lb_stats = per_cpu_ptr(pcpu_lstats, i); | 109 | lb_stats = per_cpu_ptr(dev->lstats, i); |
117 | do { | 110 | do { |
118 | start = u64_stats_fetch_begin(&lb_stats->syncp); | 111 | start = u64_stats_fetch_begin(&lb_stats->syncp); |
119 | tbytes = lb_stats->bytes; | 112 | tbytes = lb_stats->bytes; |
120 | tpackets = lb_stats->packets; | 113 | tpackets = lb_stats->packets; |
121 | } while (u64_stats_fetch_retry(&lb_stats->syncp, start)); | 114 | } while (u64_stats_fetch_retry(&lb_stats->syncp, start)); |
122 | drops += lb_stats->drops; | ||
123 | bytes += tbytes; | 115 | bytes += tbytes; |
124 | packets += tpackets; | 116 | packets += tpackets; |
125 | } | 117 | } |
126 | stats->rx_packets = packets; | 118 | stats->rx_packets = packets; |
127 | stats->tx_packets = packets; | 119 | stats->tx_packets = packets; |
128 | stats->rx_dropped = drops; | ||
129 | stats->rx_errors = drops; | ||
130 | stats->rx_bytes = bytes; | 120 | stats->rx_bytes = bytes; |
131 | stats->tx_bytes = bytes; | 121 | stats->tx_bytes = bytes; |
132 | return stats; | 122 | return stats; |
@@ -139,30 +129,20 @@ static u32 always_on(struct net_device *dev) | |||
139 | 129 | ||
140 | static const struct ethtool_ops loopback_ethtool_ops = { | 130 | static const struct ethtool_ops loopback_ethtool_ops = { |
141 | .get_link = always_on, | 131 | .get_link = always_on, |
142 | .set_tso = ethtool_op_set_tso, | ||
143 | .get_tx_csum = always_on, | ||
144 | .get_sg = always_on, | ||
145 | .get_rx_csum = always_on, | ||
146 | }; | 132 | }; |
147 | 133 | ||
148 | static int loopback_dev_init(struct net_device *dev) | 134 | static int loopback_dev_init(struct net_device *dev) |
149 | { | 135 | { |
150 | struct pcpu_lstats __percpu *lstats; | 136 | dev->lstats = alloc_percpu(struct pcpu_lstats); |
151 | 137 | if (!dev->lstats) | |
152 | lstats = alloc_percpu(struct pcpu_lstats); | ||
153 | if (!lstats) | ||
154 | return -ENOMEM; | 138 | return -ENOMEM; |
155 | 139 | ||
156 | dev->ml_priv = (void __force *)lstats; | ||
157 | return 0; | 140 | return 0; |
158 | } | 141 | } |
159 | 142 | ||
160 | static void loopback_dev_free(struct net_device *dev) | 143 | static void loopback_dev_free(struct net_device *dev) |
161 | { | 144 | { |
162 | struct pcpu_lstats __percpu *lstats = | 145 | free_percpu(dev->lstats); |
163 | (void __percpu __force *)dev->ml_priv; | ||
164 | |||
165 | free_percpu(lstats); | ||
166 | free_netdev(dev); | 146 | free_netdev(dev); |
167 | } | 147 | } |
168 | 148 | ||
@@ -185,12 +165,17 @@ static void loopback_setup(struct net_device *dev) | |||
185 | dev->type = ARPHRD_LOOPBACK; /* 0x0001*/ | 165 | dev->type = ARPHRD_LOOPBACK; /* 0x0001*/ |
186 | dev->flags = IFF_LOOPBACK; | 166 | dev->flags = IFF_LOOPBACK; |
187 | dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; | 167 | dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; |
168 | dev->hw_features = NETIF_F_ALL_TSO | NETIF_F_UFO; | ||
188 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | 169 | dev->features = NETIF_F_SG | NETIF_F_FRAGLIST |
189 | | NETIF_F_TSO | 170 | | NETIF_F_ALL_TSO |
171 | | NETIF_F_UFO | ||
190 | | NETIF_F_NO_CSUM | 172 | | NETIF_F_NO_CSUM |
173 | | NETIF_F_RXCSUM | ||
191 | | NETIF_F_HIGHDMA | 174 | | NETIF_F_HIGHDMA |
192 | | NETIF_F_LLTX | 175 | | NETIF_F_LLTX |
193 | | NETIF_F_NETNS_LOCAL; | 176 | | NETIF_F_NETNS_LOCAL |
177 | | NETIF_F_VLAN_CHALLENGED | ||
178 | | NETIF_F_LOOPBACK; | ||
194 | dev->ethtool_ops = &loopback_ethtool_ops; | 179 | dev->ethtool_ops = &loopback_ethtool_ops; |
195 | dev->header_ops = ð_header_ops; | 180 | dev->header_ops = ð_header_ops; |
196 | dev->netdev_ops = &loopback_ops; | 181 | dev->netdev_ops = &loopback_ops; |