From: Ben Greear <greearb@candelatech.com>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: netdev@vger.kernel.org
Subject: Re: [patch] add net_device_stats support to ethtool
Date: Wed, 16 Jan 2008 10:46:58 -0800 [thread overview]
Message-ID: <478E5122.1060009@candelatech.com> (raw)
In-Reply-To: <200801161834.m0GIYCIr027613@sallyv1.ics.uci.edu>
Dan Nicolaescu wrote:
> Ben Greear <greearb@candelatech.com> writes:
>
> > Dan Nicolaescu wrote:
> > > Hi,
> > >
> > > I have posted this patch in the past with absolutely no reply.
> > > I would appreciate some sort of feedback of the form interested/not
> > > interested. Should I just drop it?
> > >
> > >
> > I like it, but why not offer this for all devices since they all have
> > these stats.
> >
> > Could add new handlers called something like .get_strings_generic, or
> > just add this to the higher-level ethtool handling before it looks for
> > handlers.
>
> If I get your point, then the difference would be that drivers would add
> to the initialization of the ethtool structure something like:
>
I meant something more like this (this will not apply..I hand-edited it
to remove
some extraneous crap from my patch...and I'm sure it's white-space damaged).
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index c5e0593..095d1eb 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
+/* Handle some generic ethtool commands here */
+static int ethtool_get_netdev_stats(struct net_device *dev, void
*useraddr) {
+
+ struct ethtool_ndstats* nds = (struct ethtool_ndstats*)(useraddr);
+
+ struct net_device_stats *stats = dev->get_stats(dev);
+ if (stats) {
+ if (copy_to_user(nds->data, stats, sizeof(*stats))) {
+ return -EFAULT;
+ }
+ }
+ else {
+ return -EOPNOTSUPP;
+ }
+ return 0;
+}
+
+
/* The main entry point in this file. Called from net/core/dev.c */
int dev_ethtool(struct ifreq *ifr)
@@ -796,9 +884,6 @@ int dev_ethtool(struct ifreq *ifr)
if (!dev || !netif_device_present(dev))
return -ENODEV;
- if (!dev->ethtool_ops)
- return -EOPNOTSUPP;
-
if (copy_from_user(ðcmd, useraddr, sizeof (ethcmd)))
return -EFAULT;
@@ -823,12 +908,25 @@ int dev_ethtool(struct ifreq *ifr)
return -EPERM;
}
- if (dev->ethtool_ops->begin)
+ if (dev->ethtool_ops && dev->ethtool_ops->begin)
if ((rc = dev->ethtool_ops->begin(dev)) < 0)
return rc;
old_features = dev->features;
+ /* Handle some generic operations that do not require specific
+ * ethtool handlers.
+ */
+ switch (ethcmd) {
+ case ETHTOOL_GNDSTATS:
+ return ethtool_get_netdev_stats(dev, useraddr);
+ default:
+ break;
+ }
+
+ if (!dev->ethtool_ops)
+ return -EOPNOTSUPP;
+
switch (ethcmd) {
case ETHTOOL_GSET:
rc = ethtool_get_settings(dev, useraddr);
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
next prev parent reply other threads:[~2008-01-16 18:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 15:29 [patch] add net_device_stats support to ethtool Dan Nicolaescu
2008-01-16 18:03 ` Ben Greear
2008-01-16 18:34 ` Dan Nicolaescu
2008-01-16 18:46 ` Ben Greear [this message]
2008-01-17 5:13 ` Dan Nicolaescu
2008-01-18 20:14 ` Jeff Garzik
2008-01-18 22:01 ` Dan Nicolaescu
-- strict thread matches above, loose matches on Subject: below --
2006-12-04 17:06 Dan Nicolaescu
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=478E5122.1060009@candelatech.com \
--to=greearb@candelatech.com \
--cc=dann@ics.uci.edu \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.