diff options
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | 2011-03-30 21:01:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-01 23:56:29 -0400 |
commit | fb507934fd6faa00b3d833facb53b90c71ddc307 (patch) | |
tree | c2871d863a9f0bd601bfc737cda441e27d6a577d /drivers/net/xen-netfront.c | |
parent | 78e47fe4194ca7fac2cc29d25f1327db86922724 (diff) |
net: convert xen-netfront to hw_features
Not tested in any way. The original code for offload setting seems broken
as it resets the features on every netback reconnect.
This will set GSO_ROBUST at device creation time (earlier than connect time).
RX checksum offload is forced on - so advertise as it is.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/xen-netfront.c')
-rw-r--r-- | drivers/net/xen-netfront.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index c06f5a09b263..f6e7e2726f6b 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -1148,6 +1148,8 @@ static const struct net_device_ops xennet_netdev_ops = { | |||
1148 | .ndo_change_mtu = xennet_change_mtu, | 1148 | .ndo_change_mtu = xennet_change_mtu, |
1149 | .ndo_set_mac_address = eth_mac_addr, | 1149 | .ndo_set_mac_address = eth_mac_addr, |
1150 | .ndo_validate_addr = eth_validate_addr, | 1150 | .ndo_validate_addr = eth_validate_addr, |
1151 | .ndo_fix_features = xennet_fix_features, | ||
1152 | .ndo_set_features = xennet_set_features, | ||
1151 | }; | 1153 | }; |
1152 | 1154 | ||
1153 | static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev) | 1155 | static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev) |
@@ -1209,7 +1211,9 @@ static struct net_device * __devinit xennet_create_dev(struct xenbus_device *dev | |||
1209 | netdev->netdev_ops = &xennet_netdev_ops; | 1211 | netdev->netdev_ops = &xennet_netdev_ops; |
1210 | 1212 | ||
1211 | netif_napi_add(netdev, &np->napi, xennet_poll, 64); | 1213 | netif_napi_add(netdev, &np->napi, xennet_poll, 64); |
1212 | netdev->features = NETIF_F_IP_CSUM; | 1214 | netdev->features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM | |
1215 | NETIF_F_GSO_ROBUST; | ||
1216 | netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO; | ||
1213 | 1217 | ||
1214 | SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops); | 1218 | SET_ETHTOOL_OPS(netdev, &xennet_ethtool_ops); |
1215 | SET_NETDEV_DEV(netdev, &dev->dev); | 1219 | SET_NETDEV_DEV(netdev, &dev->dev); |
@@ -1509,52 +1513,40 @@ again: | |||
1509 | return err; | 1513 | return err; |
1510 | } | 1514 | } |
1511 | 1515 | ||
1512 | static int xennet_set_sg(struct net_device *dev, u32 data) | 1516 | static u32 xennet_fix_features(struct net_device *dev, u32 features) |
1513 | { | 1517 | { |
1514 | if (data) { | 1518 | struct netfront_info *np = netdev_priv(dev); |
1515 | struct netfront_info *np = netdev_priv(dev); | 1519 | int val; |
1516 | int val; | ||
1517 | 1520 | ||
1521 | if (features & NETIF_F_SG) { | ||
1518 | if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg", | 1522 | if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, "feature-sg", |
1519 | "%d", &val) < 0) | 1523 | "%d", &val) < 0) |
1520 | val = 0; | 1524 | val = 0; |
1521 | if (!val) | ||
1522 | return -ENOSYS; | ||
1523 | } else if (dev->mtu > ETH_DATA_LEN) | ||
1524 | dev->mtu = ETH_DATA_LEN; | ||
1525 | 1525 | ||
1526 | return ethtool_op_set_sg(dev, data); | 1526 | if (!val) |
1527 | } | 1527 | features &= ~NETIF_F_SG; |
1528 | 1528 | } | |
1529 | static int xennet_set_tso(struct net_device *dev, u32 data) | ||
1530 | { | ||
1531 | if (data) { | ||
1532 | struct netfront_info *np = netdev_priv(dev); | ||
1533 | int val; | ||
1534 | 1529 | ||
1530 | if (features & NETIF_F_TSO) { | ||
1535 | if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, | 1531 | if (xenbus_scanf(XBT_NIL, np->xbdev->otherend, |
1536 | "feature-gso-tcpv4", "%d", &val) < 0) | 1532 | "feature-gso-tcpv4", "%d", &val) < 0) |
1537 | val = 0; | 1533 | val = 0; |
1534 | |||
1538 | if (!val) | 1535 | if (!val) |
1539 | return -ENOSYS; | 1536 | features &= ~NETIF_F_TSO; |
1540 | } | 1537 | } |
1541 | 1538 | ||
1542 | return ethtool_op_set_tso(dev, data); | 1539 | return features; |
1543 | } | 1540 | } |
1544 | 1541 | ||
1545 | static void xennet_set_features(struct net_device *dev) | 1542 | static int xennet_set_features(struct net_device *dev, u32 features) |
1546 | { | 1543 | { |
1547 | /* Turn off all GSO bits except ROBUST. */ | 1544 | if (!(features & NETIF_F_SG) && dev->mtu > ETH_DATA_LEN) { |
1548 | dev->features &= ~NETIF_F_GSO_MASK; | 1545 | netdev_info(dev, "Reducing MTU because no SG offload"); |
1549 | dev->features |= NETIF_F_GSO_ROBUST; | 1546 | dev->mtu = ETH_DATA_LEN; |
1550 | xennet_set_sg(dev, 0); | 1547 | } |
1551 | |||
1552 | /* We need checksum offload to enable scatter/gather and TSO. */ | ||
1553 | if (!(dev->features & NETIF_F_IP_CSUM)) | ||
1554 | return; | ||
1555 | 1548 | ||
1556 | if (!xennet_set_sg(dev, 1)) | 1549 | return 0; |
1557 | xennet_set_tso(dev, 1); | ||
1558 | } | 1550 | } |
1559 | 1551 | ||
1560 | static int xennet_connect(struct net_device *dev) | 1552 | static int xennet_connect(struct net_device *dev) |
@@ -1581,7 +1573,7 @@ static int xennet_connect(struct net_device *dev) | |||
1581 | if (err) | 1573 | if (err) |
1582 | return err; | 1574 | return err; |
1583 | 1575 | ||
1584 | xennet_set_features(dev); | 1576 | netdev_update_features(dev); |
1585 | 1577 | ||
1586 | spin_lock_bh(&np->rx_lock); | 1578 | spin_lock_bh(&np->rx_lock); |
1587 | spin_lock_irq(&np->tx_lock); | 1579 | spin_lock_irq(&np->tx_lock); |
@@ -1709,9 +1701,6 @@ static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data) | |||
1709 | 1701 | ||
1710 | static const struct ethtool_ops xennet_ethtool_ops = | 1702 | static const struct ethtool_ops xennet_ethtool_ops = |
1711 | { | 1703 | { |
1712 | .set_tx_csum = ethtool_op_set_tx_csum, | ||
1713 | .set_sg = xennet_set_sg, | ||
1714 | .set_tso = xennet_set_tso, | ||
1715 | .get_link = ethtool_op_get_link, | 1704 | .get_link = ethtool_op_get_link, |
1716 | 1705 | ||
1717 | .get_sset_count = xennet_get_sset_count, | 1706 | .get_sset_count = xennet_get_sset_count, |