Skip to contentSkip to conversation

Fixes for unified offload configuration

PATCH In review Michał Mirosław 2 participants 6 messages Feb 23, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fixes for unified offload configuration

this series contains couple of fixes to ethtool unification work in net-next.

patches 1 and 2 (resend):

	fix following message at device registration:
	(unregistered net_device): features changed: 0x00011065 -> 0x00015065

patches 3 and 4:
implement compatibility fallback in ethtool_{g,s}features for drivers not converted to new offload setting scheme.

only compile tested for now as my test box has some hardware issues lately.

best regards,
michał mirosław

michał Mirosław (4):
Fix "(unregistered net_device): Features changed" message
net: avoid initial "Features changed" message
net: Fix ETHTOOL_GFEATURES compatibility
net: Implement SFEATURES compatibility for not updated drivers

 include/linux/ethtool.h |    5 +++
 net/core/dev.c          |   12 ++++---
 net/core/ethtool.c      |   75 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/4 Fix "(unregistered net_device): Features changed" message

Fix netdev_update_features() messages on register time by moving the call further in register_netdevice(). When netdev->reg_state != NETREG_REGISTERED, netdev_name() returns "(unregistered netdevice)" even if the dev's name is already filled.

---
 net/core/dev.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
net/core/dev.c +2 -2
index 578415c..77e5edb 100644
@@ -5483,8 +5483,6 @@ int register_netdevice(struct net_device *dev)
 	if (!(dev->wanted_features & NETIF_F_SG))
 		dev->wanted_features &= ~NETIF_F_GSO;
 
-	netdev_update_features(dev);
-
 	/* Enable GRO and NETIF_F_HIGHDMA for vlans by default,
 	 * vlan_dev_init() will do the dev->features check, so these features
 	 * are enabled only if supported by underlying device.
@@ -5501,6 +5499,8 @@ int register_netdevice(struct net_device *dev)
 		goto err_uninit;
 	dev->reg_state = NETREG_REGISTERED;
 
+	netdev_update_features(dev);
+
 	/*
 	 *	Default initial state at registry is that the
 	 *	device is present.
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 2/4 net: avoid initial "Features changed" message

In reply to Michał Mirosław

Avoid "Features changed" message and ndo_set_features call on device registration caused by automatic enabling of GSO and GRO. Driver should have enabled hardware offloads it set in features, so the ndo_set_features() is not needed at registration time.

---
 net/core/dev.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
net/core/dev.c +5 -3
index 77e5edb..69a3c08 100644
@@ -5476,12 +5476,14 @@ int register_netdevice(struct net_device *dev)
 	 * software offloads (GSO and GRO).
 	 */
 	dev->hw_features |= NETIF_F_SOFT_FEATURES;
-	dev->wanted_features = (dev->features & dev->hw_features)
-		| NETIF_F_SOFT_FEATURES;
+	dev->features |= NETIF_F_SOFT_FEATURES;
+	dev->wanted_features = dev->features & dev->hw_features;
 
 	/* Avoid warning from netdev_fix_features() for GSO without SG */
-	if (!(dev->wanted_features & NETIF_F_SG))
+	if (!(dev->wanted_features & NETIF_F_SG)) {
 		dev->wanted_features &= ~NETIF_F_GSO;
+		dev->features &= ~NETIF_F_GSO;
+	}
 
 	/* Enable GRO and NETIF_F_HIGHDMA for vlans by default,
 	 * vlan_dev_init() will do the dev->features check, so these features
Signature · 1 line
1.7.2.3
#3 lore raw

PATCH 3/4 net: Fix ETHTOOL_GFEATURES compatibility

In reply to Michał Mirosław

Implement getting rx checksum state for not updated drivers.

---
 net/core/ethtool.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
net/core/ethtool.c +14 -0
index 66cdc76..69a3edc 100644
@@ -168,6 +168,18 @@ EXPORT_SYMBOL(ethtool_ntuple_flush);
 
 #define ETHTOOL_DEV_FEATURE_WORDS	1
 
+static void ethtool_get_features_compat(struct net_device *dev,
+	struct ethtool_get_features_block *features)
+{
+	if (!dev->ethtool_ops)
+		return;
+
+	/* getting RX checksum */
+	if (dev->ethtool_ops->get_rx_csum)
+		if (dev->ethtool_ops->get_rx_csum(dev))
+			features[0].active |= NETIF_F_RXCSUM;
+}
+
 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
 {
 	struct ethtool_gfeatures cmd = {
@@ -185,6 +197,8 @@ static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
 	u32 __user *sizeaddr;
 	u32 copy_size;
 
+	ethtool_get_features_compat(dev, features);
+
 	sizeaddr = useraddr + offsetof(struct ethtool_gfeatures, size);
 	if (get_user(copy_size, sizeaddr))
 		return -EFAULT;
Signature · 1 line
1.7.2.3
#4 lore raw

PATCH 4/4 net: Implement SFEATURES compatibility for not updated drivers

In reply to Michał Mirosław

Use discrete setting ops for not updated drivers. This will not make them conform to full G/SFEATURES semantics, though.

---
 include/linux/ethtool.h |    5 ++++
 net/core/ethtool.c      |   61 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
include/linux/ethtool.h +5 -0
index 54d776c..aac3e2e 100644
@@ -591,6 +591,9 @@ struct ethtool_sfeatures {
  *      Probably there are other device-specific constraints on some features
  *      in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered
  *      here as though ignored bits were cleared.
+ *   %ETHTOOL_F_COMPAT - some or all changes requested were made by calling
+ *      compatibility functions. Requested offload state cannot be properly
+ *      managed by kernel.
  *
  * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of
  * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands
@@ -600,10 +603,12 @@ struct ethtool_sfeatures {
 enum ethtool_sfeatures_retval_bits {
 	ETHTOOL_F_UNSUPPORTED__BIT,
 	ETHTOOL_F_WISH__BIT,
+	ETHTOOL_F_COMPAT__BIT,
 };
 
 #define ETHTOOL_F_UNSUPPORTED   (1 << ETHTOOL_F_UNSUPPORTED__BIT)
 #define ETHTOOL_F_WISH          (1 << ETHTOOL_F_WISH__BIT)
+#define ETHTOOL_F_COMPAT        (1 << ETHTOOL_F_COMPAT__BIT)
 
 #ifdef __KERNEL__
 
net/core/ethtool.c +61 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.2.3
maintainer
#5 lore raw
In reply to Michał Mirosław

From: Michał Mirosław <[email protected]>
Date: Wed, 23 Feb 2011 03:52:28 +0100 (CET)

Quoted 11 lines

this series contains couple of fixes to ethtool unification work in net-next.

patches 1 and 2 (resend):

	fix following message at device registration:
	(unregistered net_device): features changed: 0x00011065 -> 0x00015065

patches 3 and 4:
implement compatibility fallback in ethtool_{g,s}features for drivers not converted to new offload setting scheme.

only compile tested for now as my test box has some hardware issues lately.

All applied, thanks.