aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/veth.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/veth.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/veth.c')
-rw-r--r--drivers/net/veth.c54
1 files changed, 10 insertions, 44 deletions
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 5ec542dd5b50..8461576fa015 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -22,7 +22,6 @@
22 22
23#define MIN_MTU 68 /* Min L3 MTU */ 23#define MIN_MTU 68 /* Min L3 MTU */
24#define MAX_MTU 65535 /* Max L3 MTU (arbitrary) */ 24#define MAX_MTU 65535 /* Max L3 MTU (arbitrary) */
25#define MTU_PAD (ETH_HLEN + 4) /* Max difference between L2 and L3 size MTU */
26 25
27struct veth_net_stats { 26struct veth_net_stats {
28 unsigned long rx_packets; 27 unsigned long rx_packets;
@@ -36,7 +35,6 @@ struct veth_net_stats {
36struct veth_priv { 35struct veth_priv {
37 struct net_device *peer; 36 struct net_device *peer;
38 struct veth_net_stats __percpu *stats; 37 struct veth_net_stats __percpu *stats;
39 unsigned ip_summed;
40}; 38};
41 39
42/* 40/*
@@ -53,7 +51,7 @@ static int veth_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
53{ 51{
54 cmd->supported = 0; 52 cmd->supported = 0;
55 cmd->advertising = 0; 53 cmd->advertising = 0;
56 cmd->speed = SPEED_10000; 54 ethtool_cmd_speed_set(cmd, SPEED_10000);
57 cmd->duplex = DUPLEX_FULL; 55 cmd->duplex = DUPLEX_FULL;
58 cmd->port = PORT_TP; 56 cmd->port = PORT_TP;
59 cmd->phy_address = 0; 57 cmd->phy_address = 0;
@@ -99,47 +97,10 @@ static void veth_get_ethtool_stats(struct net_device *dev,
99 data[0] = priv->peer->ifindex; 97 data[0] = priv->peer->ifindex;
100} 98}
101 99
102static u32 veth_get_rx_csum(struct net_device *dev)
103{
104 struct veth_priv *priv;
105
106 priv = netdev_priv(dev);
107 return priv->ip_summed == CHECKSUM_UNNECESSARY;
108}
109
110static int veth_set_rx_csum(struct net_device *dev, u32 data)
111{
112 struct veth_priv *priv;
113
114 priv = netdev_priv(dev);
115 priv->ip_summed = data ? CHECKSUM_UNNECESSARY : CHECKSUM_NONE;
116 return 0;
117}
118
119static u32 veth_get_tx_csum(struct net_device *dev)
120{
121 return (dev->features & NETIF_F_NO_CSUM) != 0;
122}
123
124static int veth_set_tx_csum(struct net_device *dev, u32 data)
125{
126 if (data)
127 dev->features |= NETIF_F_NO_CSUM;
128 else
129 dev->features &= ~NETIF_F_NO_CSUM;
130 return 0;
131}
132
133static const struct ethtool_ops veth_ethtool_ops = { 100static const struct ethtool_ops veth_ethtool_ops = {
134 .get_settings = veth_get_settings, 101 .get_settings = veth_get_settings,
135 .get_drvinfo = veth_get_drvinfo, 102 .get_drvinfo = veth_get_drvinfo,
136 .get_link = ethtool_op_get_link, 103 .get_link = ethtool_op_get_link,
137 .get_rx_csum = veth_get_rx_csum,
138 .set_rx_csum = veth_set_rx_csum,
139 .get_tx_csum = veth_get_tx_csum,
140 .set_tx_csum = veth_set_tx_csum,
141 .get_sg = ethtool_op_get_sg,
142 .set_sg = ethtool_op_set_sg,
143 .get_strings = veth_get_strings, 104 .get_strings = veth_get_strings,
144 .get_sset_count = veth_get_sset_count, 105 .get_sset_count = veth_get_sset_count,
145 .get_ethtool_stats = veth_get_ethtool_stats, 106 .get_ethtool_stats = veth_get_ethtool_stats,
@@ -166,10 +127,13 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
166 if (!(rcv->flags & IFF_UP)) 127 if (!(rcv->flags & IFF_UP))
167 goto tx_drop; 128 goto tx_drop;
168 129
169 if (dev->features & NETIF_F_NO_CSUM) 130 /* don't change ip_summed == CHECKSUM_PARTIAL, as that
170 skb->ip_summed = rcv_priv->ip_summed; 131 will cause bad checksum on forwarded packets */
132 if (skb->ip_summed == CHECKSUM_NONE &&
133 rcv->features & NETIF_F_RXCSUM)
134 skb->ip_summed = CHECKSUM_UNNECESSARY;
171 135
172 length = skb->len + ETH_HLEN; 136 length = skb->len;
173 if (dev_forward_skb(rcv, skb) != NET_RX_SUCCESS) 137 if (dev_forward_skb(rcv, skb) != NET_RX_SUCCESS)
174 goto rx_drop; 138 goto rx_drop;
175 139
@@ -250,7 +214,7 @@ static int veth_close(struct net_device *dev)
250 214
251static int is_valid_veth_mtu(int new_mtu) 215static int is_valid_veth_mtu(int new_mtu)
252{ 216{
253 return (new_mtu >= MIN_MTU && new_mtu <= MAX_MTU); 217 return new_mtu >= MIN_MTU && new_mtu <= MAX_MTU;
254} 218}
255 219
256static int veth_change_mtu(struct net_device *dev, int new_mtu) 220static int veth_change_mtu(struct net_device *dev, int new_mtu)
@@ -302,6 +266,8 @@ static void veth_setup(struct net_device *dev)
302 dev->ethtool_ops = &veth_ethtool_ops; 266 dev->ethtool_ops = &veth_ethtool_ops;
303 dev->features |= NETIF_F_LLTX; 267 dev->features |= NETIF_F_LLTX;
304 dev->destructor = veth_dev_free; 268 dev->destructor = veth_dev_free;
269
270 dev->hw_features = NETIF_F_NO_CSUM | NETIF_F_SG | NETIF_F_RXCSUM;
305} 271}
306 272
307/* 273/*