From: Jeff Garzik <jgarzik@pobox.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: bhutchings@solarflare.com, rick.jones2@hp.com,
davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] Make possible speeds known to ethtool
Date: Fri, 09 Jan 2009 00:03:57 -0500 [thread overview]
Message-ID: <4966DABD.1000203@pobox.com> (raw)
In-Reply-To: <20090109041952.GA12087@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
Herbert Xu wrote:
> Jeff Garzik <jgarzik@pobox.com> wrote:
>> For generic net stack flags outside the driver's control, that can
>> easily be added to ethtool_{get,set}_flags() overriding or ignoring
>> whatever the driver may have done.
>
> To use the flags interface as is, you'd have to go through every
> single driver to get them to call ethtool_op_set_flags. I'm sorry
> but I'm sticking with the current interface.
I think you misunderstand. You don't have touch any drivers at all...
see attached demonstration patch.
The more general point is that it is silly to add two ethtool ioctls
each time you want to twiddle a single boolean flag (whatever that flag
may be, generic or driver-specific or whatnot).
If you still desire separation from ->{get,set}_flags() ops, then at
least create an ETHTOOL_[GS]STACK_FLAGS.
Jeff
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 2511 bytes --]
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 27c67a5..75fab70 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -285,6 +285,7 @@ struct ethtool_perm_addr {
*/
enum ethtool_flags {
ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */
+ ETH_FLAG_GRO = (1 << 14), /* GRO is enabled */
};
struct ethtool_rxnfc {
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 947710a..a114afa 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -864,6 +864,60 @@ static int ethtool_set_value(struct net_device *dev, char __user *useraddr,
return actor(dev, edata.data);
}
+static int ethtool_get_generic_flags(struct net_device *dev, u32 *val_out)
+{
+ if (dev->features & NETIF_F_GRO)
+ *val_out |= ETH_FLAG_GRO;
+
+ return 0;
+}
+
+static int ethtool_set_generic_flags(struct net_device *dev, u32 val_in)
+{
+ if (val_in & ETH_FLAG_GRO) {
+ if (!dev->ethtool_ops->get_rx_csum ||
+ !dev->ethtool_ops->get_rx_csum(dev))
+ return -EINVAL;
+ dev->features |= NETIF_F_GRO;
+ } else
+ dev->features &= ~NETIF_F_GRO;
+
+ return 0;
+}
+
+static int ethtool_get_flags(struct net_device *dev, char __user *useraddr)
+{
+ struct ethtool_value edata = { ETHTOOL_GFLAGS };
+ int rc;
+
+ if (dev->ethtool_ops->get_flags)
+ edata.data = dev->ethtool_ops->get_flags(dev);
+
+ rc = ethtool_get_generic_flags(dev, &edata.data);
+ if (rc)
+ return rc;
+
+ if (copy_to_user(useraddr, &edata, sizeof(edata)))
+ return -EFAULT;
+ return 0;
+}
+
+static int ethtool_set_flags(struct net_device *dev, char __user *useraddr)
+{
+ struct ethtool_value edata;
+ int rc;
+
+ if (copy_from_user(&edata, useraddr, sizeof(edata)))
+ return -EFAULT;
+
+ rc = ethtool_set_generic_flags(dev, edata.data);
+
+ if (rc == 0 && dev->ethtool_ops->set_flags)
+ rc = dev->ethtool_ops->set_flags(dev, edata.data);
+
+ return rc;
+}
+
/* The main entry point in this file. Called from net/core/dev.c */
int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -1036,12 +1090,10 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
rc = ethtool_set_gso(dev, useraddr);
break;
case ETHTOOL_GFLAGS:
- rc = ethtool_get_value(dev, useraddr, ethcmd,
- dev->ethtool_ops->get_flags);
+ rc = ethtool_get_flags(dev, useraddr);
break;
case ETHTOOL_SFLAGS:
- rc = ethtool_set_value(dev, useraddr,
- dev->ethtool_ops->set_flags);
+ rc = ethtool_set_flags(dev, useraddr);
break;
case ETHTOOL_GPFLAGS:
rc = ethtool_get_value(dev, useraddr, ethcmd,
next prev parent reply other threads:[~2009-01-09 5:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-09 4:19 [PATCH] Make possible speeds known to ethtool Herbert Xu
2009-01-09 5:00 ` David Miller
2009-01-09 5:05 ` Jeff Garzik
2009-01-09 5:03 ` Jeff Garzik [this message]
2009-01-09 5:15 ` Herbert Xu
2009-01-09 5:30 ` Jeff Garzik
2009-01-09 5:35 ` Herbert Xu
2009-01-09 6:28 ` Jeff Garzik
2009-01-09 6:30 ` Herbert Xu
-- strict thread matches above, loose matches on Subject: below --
2009-01-09 3:48 Herbert Xu
2009-01-09 3:58 ` Jeff Garzik
2009-01-08 2:03 Rick Jones
2009-01-08 3:14 ` Ben Hutchings
2009-01-08 3:12 ` Jeff Garzik
2009-01-08 19:11 ` Rick Jones
2009-01-08 19:25 ` Ben Hutchings
2009-01-08 19:50 ` Rick Jones
2009-01-09 2:52 ` Herbert Xu
2009-01-09 3:20 ` Jeff Garzik
2009-03-06 11:19 ` Jeff Garzik
2009-03-06 13:52 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4966DABD.1000203@pobox.com \
--to=jgarzik@pobox.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=rick.jones2@hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).