@@ -1148,6 +1148,8 @@ static const struct net_device_ops xennet_netdev_ops = {
11481148 .ndo_change_mtu = xennet_change_mtu ,
11491149 .ndo_set_mac_address = eth_mac_addr ,
11501150 .ndo_validate_addr = eth_validate_addr ,
1151+ .ndo_fix_features = xennet_fix_features ,
1152+ .ndo_set_features = xennet_set_features ,
11511153};
11521154
11531155static 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
12091211 netdev -> netdev_ops = & xennet_netdev_ops ;
12101212
12111213 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 ;
12131217
12141218 SET_ETHTOOL_OPS (netdev , & xennet_ethtool_ops );
12151219 SET_NETDEV_DEV (netdev , & dev -> dev );
@@ -1509,52 +1513,40 @@ static int talk_to_netback(struct xenbus_device *dev,
15091513 return err ;
15101514}
15111515
1512- static int xennet_set_sg (struct net_device * dev , u32 data )
1516+ static u32 xennet_fix_features (struct net_device * dev , u32 features )
15131517{
1514- if (data ) {
1515- struct netfront_info * np = netdev_priv (dev );
1516- int val ;
1518+ struct netfront_info * np = netdev_priv (dev );
1519+ int val ;
15171520
1521+ if (features & NETIF_F_SG ) {
15181522 if (xenbus_scanf (XBT_NIL , np -> xbdev -> otherend , "feature-sg" ,
15191523 "%d" , & val ) < 0 )
15201524 val = 0 ;
1521- if (!val )
1522- return - ENOSYS ;
1523- } else if (dev -> mtu > ETH_DATA_LEN )
1524- dev -> mtu = ETH_DATA_LEN ;
15251525
1526- return ethtool_op_set_sg (dev , data );
1527- }
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 ;
1526+ if (!val )
1527+ features &= ~NETIF_F_SG ;
1528+ }
15341529
1530+ if (features & NETIF_F_TSO ) {
15351531 if (xenbus_scanf (XBT_NIL , np -> xbdev -> otherend ,
15361532 "feature-gso-tcpv4" , "%d" , & val ) < 0 )
15371533 val = 0 ;
1534+
15381535 if (!val )
1539- return - ENOSYS ;
1536+ features &= ~ NETIF_F_TSO ;
15401537 }
15411538
1542- return ethtool_op_set_tso ( dev , data ) ;
1539+ return features ;
15431540}
15441541
1545- static void xennet_set_features (struct net_device * dev )
1542+ static int xennet_set_features (struct net_device * dev , u32 features )
15461543{
1547- /* Turn off all GSO bits except ROBUST. */
1548- dev -> features &= ~NETIF_F_GSO_MASK ;
1549- dev -> features |= NETIF_F_GSO_ROBUST ;
1550- xennet_set_sg (dev , 0 );
1551-
1552- /* We need checksum offload to enable scatter/gather and TSO. */
1553- if (!(dev -> features & NETIF_F_IP_CSUM ))
1554- return ;
1544+ if (!(features & NETIF_F_SG ) && dev -> mtu > ETH_DATA_LEN ) {
1545+ netdev_info (dev , "Reducing MTU because no SG offload" );
1546+ dev -> mtu = ETH_DATA_LEN ;
1547+ }
15551548
1556- if (!xennet_set_sg (dev , 1 ))
1557- xennet_set_tso (dev , 1 );
1549+ return 0 ;
15581550}
15591551
15601552static int xennet_connect (struct net_device * dev )
@@ -1581,7 +1573,7 @@ static int xennet_connect(struct net_device *dev)
15811573 if (err )
15821574 return err ;
15831575
1584- xennet_set_features (dev );
1576+ netdev_update_features (dev );
15851577
15861578 spin_lock_bh (& np -> rx_lock );
15871579 spin_lock_irq (& np -> tx_lock );
@@ -1709,9 +1701,6 @@ static void xennet_get_strings(struct net_device *dev, u32 stringset, u8 * data)
17091701
17101702static const struct ethtool_ops xennet_ethtool_ops =
17111703{
1712- .set_tx_csum = ethtool_op_set_tx_csum ,
1713- .set_sg = xennet_set_sg ,
1714- .set_tso = xennet_set_tso ,
17151704 .get_link = ethtool_op_get_link ,
17161705
17171706 .get_sset_count = xennet_get_sset_count ,
0 commit comments