* [PATCH 3/4] net: Fix ETHTOOL_GFEATURES compatibility
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
2011-02-23 2:52 ` [PATCH 2/4] net: avoid initial "Features changed" message Michał Mirosław
@ 2011-02-23 2:52 ` Michał Mirosław
2011-02-23 2:52 ` [PATCH 1/4] Fix "(unregistered net_device): Features changed" message Michał Mirosław
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Mirosław @ 2011-02-23 2:52 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
Implement getting rx checksum state for not updated drivers.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
net/core/ethtool.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 66cdc76..69a3edc 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -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;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 0/4] Fixes for unified offload configuration
@ 2011-02-23 2:52 Michał Mirosław
2011-02-23 2:52 ` [PATCH 2/4] net: avoid initial "Features changed" message Michał Mirosław
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Michał Mirosław @ 2011-02-23 2:52 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
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(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] net: avoid initial "Features changed" message
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
@ 2011-02-23 2:52 ` Michał Mirosław
2011-02-23 2:52 ` [PATCH 3/4] net: Fix ETHTOOL_GFEATURES compatibility Michał Mirosław
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Michał Mirosław @ 2011-02-23 2:52 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
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.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
net/core/dev.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 77e5edb..69a3c08 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/4] Fix "(unregistered net_device): Features changed" message
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
2011-02-23 2:52 ` [PATCH 2/4] net: avoid initial "Features changed" message Michał Mirosław
2011-02-23 2:52 ` [PATCH 3/4] net: Fix ETHTOOL_GFEATURES compatibility Michał Mirosław
@ 2011-02-23 2:52 ` Michał Mirosław
2011-02-23 2:52 ` [PATCH 4/4] net: Implement SFEATURES compatibility for not updated drivers Michał Mirosław
2011-02-23 22:24 ` [PATCH 0/4] Fixes for unified offload configuration David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Michał Mirosław @ 2011-02-23 2:52 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
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.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
net/core/dev.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 578415c..77e5edb 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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.
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] net: Implement SFEATURES compatibility for not updated drivers
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
` (2 preceding siblings ...)
2011-02-23 2:52 ` [PATCH 1/4] Fix "(unregistered net_device): Features changed" message Michał Mirosław
@ 2011-02-23 2:52 ` Michał Mirosław
2011-02-23 22:24 ` [PATCH 0/4] Fixes for unified offload configuration David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Michał Mirosław @ 2011-02-23 2:52 UTC (permalink / raw)
To: netdev; +Cc: Ben Hutchings, David Miller
Use discrete setting ops for not updated drivers. This will not make
them conform to full G/SFEATURES semantics, though.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
include/linux/ethtool.h | 5 ++++
net/core/ethtool.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 54d776c..aac3e2e 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -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__
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 69a3edc..c1a71bb 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -178,6 +178,64 @@ static void ethtool_get_features_compat(struct net_device *dev,
if (dev->ethtool_ops->get_rx_csum)
if (dev->ethtool_ops->get_rx_csum(dev))
features[0].active |= NETIF_F_RXCSUM;
+
+ /* mark legacy-changeable features */
+ if (dev->ethtool_ops->set_sg)
+ features[0].available |= NETIF_F_SG;
+ if (dev->ethtool_ops->set_tx_csum)
+ features[0].available |= NETIF_F_ALL_CSUM;
+ if (dev->ethtool_ops->set_tso)
+ features[0].available |= NETIF_F_ALL_TSO;
+ if (dev->ethtool_ops->set_rx_csum)
+ features[0].available |= NETIF_F_RXCSUM;
+ if (dev->ethtool_ops->set_flags)
+ features[0].available |= flags_dup_features;
+}
+
+static int ethtool_set_feature_compat(struct net_device *dev,
+ int (*legacy_set)(struct net_device *, u32),
+ struct ethtool_set_features_block *features, u32 mask)
+{
+ u32 do_set;
+
+ if (!legacy_set)
+ return 0;
+
+ if (!(features[0].valid & mask))
+ return 0;
+
+ features[0].valid &= ~mask;
+
+ do_set = !!(features[0].requested & mask);
+
+ if (legacy_set(dev, do_set) < 0)
+ netdev_info(dev,
+ "Legacy feature change (%s) failed for 0x%08x\n",
+ do_set ? "set" : "clear", mask);
+
+ return 1;
+}
+
+static int ethtool_set_features_compat(struct net_device *dev,
+ struct ethtool_set_features_block *features)
+{
+ int compat;
+
+ if (!dev->ethtool_ops)
+ return 0;
+
+ compat = ethtool_set_feature_compat(dev, dev->ethtool_ops->set_sg,
+ features, NETIF_F_SG);
+ compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_tx_csum,
+ features, NETIF_F_ALL_CSUM);
+ compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_tso,
+ features, NETIF_F_ALL_TSO);
+ compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_rx_csum,
+ features, NETIF_F_RXCSUM);
+ compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_flags,
+ features, flags_dup_features);
+
+ return compat;
}
static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
@@ -234,6 +292,9 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
if (features[0].valid & ~NETIF_F_ETHTOOL_BITS)
return -EINVAL;
+ if (ethtool_set_features_compat(dev, features))
+ ret |= ETHTOOL_F_COMPAT;
+
if (features[0].valid & ~dev->hw_features) {
features[0].valid &= dev->hw_features;
ret |= ETHTOOL_F_UNSUPPORTED;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Fixes for unified offload configuration
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
` (3 preceding siblings ...)
2011-02-23 2:52 ` [PATCH 4/4] net: Implement SFEATURES compatibility for not updated drivers Michał Mirosław
@ 2011-02-23 22:24 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-02-23 22:24 UTC (permalink / raw)
To: mirq-linux; +Cc: netdev, bhutchings
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Wed, 23 Feb 2011 03:52:28 +0100 (CET)
> 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-23 22:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-23 2:52 [PATCH 0/4] Fixes for unified offload configuration Michał Mirosław
2011-02-23 2:52 ` [PATCH 2/4] net: avoid initial "Features changed" message Michał Mirosław
2011-02-23 2:52 ` [PATCH 3/4] net: Fix ETHTOOL_GFEATURES compatibility Michał Mirosław
2011-02-23 2:52 ` [PATCH 1/4] Fix "(unregistered net_device): Features changed" message Michał Mirosław
2011-02-23 2:52 ` [PATCH 4/4] net: Implement SFEATURES compatibility for not updated drivers Michał Mirosław
2011-02-23 22:24 ` [PATCH 0/4] Fixes for unified offload configuration David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).