[RFC PATCH 05/12] net: ethtool: use ndo_fix_features for ethtool_ops->set_flags

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?=
Date: Wednesday, December 15, 2010 - 3:24 pm

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 net/core/ethtool.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 15e00b8..2f532d5 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -215,6 +215,25 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
 	return 0;
 }
 
+static int __ethtool_set_flags(struct net_device *dev, u32 data)
+{
+	if (data & ~flags_dup_features)
+		return -EINVAL;
+
+	if (!(dev->hw_features & flags_dup_features)) {
+		if (!dev->ethtool_ops->set_flags)
+			return -EOPNOTSUPP;
+		return dev->ethtool_ops->set_flags(dev, data);
+	}
+
+	dev->wanted_features =
+		(dev->wanted_features & ~flags_dup_features) | data;
+
+	netdev_update_features(dev);
+
+	return 0;
+}
+
 static unsigned long ethtool_get_feature_mask(u32 eth_cmd)
 {
 	switch (eth_cmd) {
@@ -1635,8 +1654,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 					ethtool_op_get_flags));
 		break;
 	case ETHTOOL_SFLAGS:
-		rc = ethtool_set_value(dev, useraddr,
-				       dev->ethtool_ops->set_flags);
+		rc = ethtool_set_value(dev, useraddr, __ethtool_set_flags);
 		break;
 	case ETHTOOL_GPFLAGS:
 		rc = ethtool_get_value(dev, useraddr, ethcmd,
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH 05/12] net: ethtool: use ndo_fix_features for e ..., =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 04/12] net: introduce NETIF_F_RXCSUM, =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 06/12] bridge: convert br_features_recompute() ..., =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 03/12] net: ethtool: use ndo_fix_features for o ..., =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 01/12] net: Move check of checksum features to ..., =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 00/12] net: Unified offload configuration, =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 09/12] virtio_net: convert to ndo_fix_features, =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
[RFC PATCH 10/12] Intel net drivers: convert to ndo_fix_fe ..., =?UTF-8?q?Micha=C5=8 ..., (Wed Dec 15, 3:24 pm)
Re: [RFC PATCH 04/12] net: introduce NETIF_F_RXCSUM, Ben Hutchings, (Thu Dec 16, 4:27 pm)
Re: [RFC PATCH 03/12] net: ethtool: use ndo_fix_features f ..., Michał Mirosław, (Sat Dec 18, 5:54 pm)
Re: [RFC PATCH 04/12] net: introduce NETIF_F_RXCSUM, Michał Mirosław, (Sat Dec 18, 5:57 pm)
Re: [RFC PATCH 04/12] net: introduce NETIF_F_RXCSUM, Michał Mirosław, (Tue Jan 4, 11:33 am)