From: Ben Hutchings <bhutchings@solarflare.com>
To: Mahesh Bandewar <maheshb@google.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Subject: Re: [RFT PATCH 7/9] ethtool: prepare for larger netdev_features_t type
Date: Thu, 23 Jun 2011 19:55:35 +0100 [thread overview]
Message-ID: <1308855335.2712.15.camel@bwh-desktop> (raw)
In-Reply-To: <BANLkTikTquu8jr7U-8s=8kQcqT86Ji1MqnSKug+3zQdgsVKxKA@mail.gmail.com>
On Thu, 2011-06-23 at 11:21 -0700, Mahesh Bandewar wrote:
> On Thu, Jun 23, 2011 at 11:03 AM, Ben Hutchings
> <bhutchings@solarflare.com> wrote:
> > On Thu, 2011-06-23 at 10:50 -0700, Mahesh Bandewar wrote:
> >> On Mon, Jun 20, 2011 at 2:16 PM, Ben Hutchings
> >> <bhutchings@solarflare.com> wrote:
> >> >
> >> > On Mon, 2011-06-20 at 21:14 +0200, Michał Mirosław wrote:
> >> > [...]
> >> > > @@ -125,19 +131,26 @@ static int ethtool_set_features(struct net_device *dev, void __user *useraddr)
> >> > > if (copy_from_user(features, useraddr, sizeof(features)))
> >> > > return -EFAULT;
> >> > >
> >> > > - if (features[0].valid & ~NETIF_F_ETHTOOL_BITS)
> >> > > + /* I wonder if the compiler will be smart enough to loop-unroll
> >> > > + * and optimize this... (no worries if not) --mq */
> >> > > + for (i = ETHTOOL_DEV_FEATURE_WORDS; i-- > 0; ) {
> >> > > + valid = (valid << 32)|features[i].valid;
> >> > > + wanted = (wanted << 32)|features[i].requested;
> >> > > + }
> >> > [...]
> >> >
> >> > I don't know (or care) about optimisation of this, but I would expect
> >> > gcc to complain about shifting a 32-bit value by 32 bits. I suggest you
> >> > write this as:
> >> >
> >> > for (i = 0; i < ETHTOOL_DEV_FEATURE_WORDS; ++i) {
> >> > valid |= (netdev_features_t)features[i].valid << 32 *i;
> >> > wanted |= (netdev_features_t)features[i].requested << 32 *i;
> >>
> >> It's a valid point but this type of typecast or similar usage would
> >> imply that netdev_feature_t is an int of XXX bits. That's not opaque
> >> and would hinder the way you can abstract the feature type.
> >
> > Yes, ethtool_{get,set}_features() will have to be changed if and when
> > the representation of netdev_features_t is changed significantly. I
> > don't think there's any way of avoiding that and I don't think it really
> > matters.
> >
> Well, if you have a conversion routine that converts (whatever the)
> netdev_type_t type is to the ethtool representation (array of u32 for
> example). So the changes would have to be done in that conversion
> routine only and not get/set_features() ethtool methods as such.
These are precisely those conversion routines, because there is no other
place that needs to deal with the ethtool representation...
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2011-06-23 18:55 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-20 19:14 [RFT PATCH 0/9] Cleanup and extension of netdev features Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 4/9] net: introduce and use netdev_features_t for device features sets Michał Mirosław
2011-06-20 21:01 ` Ben Hutchings
2011-06-20 19:14 ` [RFT PATCH 3/9] net: ethtool: break association of ETH_FLAG_* with NETIF_F_* Michał Mirosław
2011-06-20 20:11 ` Ben Hutchings
2011-06-20 20:27 ` David Miller
2011-06-20 20:51 ` Stephen Hemminger
2011-06-20 20:52 ` David Miller
2011-06-20 21:30 ` Ben Hutchings
2011-06-20 19:14 ` [RFT PATCH 5/9] net: Define enum for net device features Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 2/9] net: remove legacy ethtool ops Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 9/9] net: move NOCACHE_COPY checks to netdev_fix_features() Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 6/9] net: ethtool: use C99 array initialization for feature-names table Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 8/9] net: extend netdev_features_t to 64 bits Michał Mirosław
2011-06-20 19:14 ` [RFT PATCH 7/9] ethtool: prepare for larger netdev_features_t type Michał Mirosław
2011-06-20 21:16 ` Ben Hutchings
2011-06-23 17:50 ` Mahesh Bandewar
2011-06-23 18:03 ` Ben Hutchings
2011-06-23 18:21 ` Mahesh Bandewar
2011-06-23 18:55 ` Ben Hutchings [this message]
2011-06-23 20:38 ` Mahesh Bandewar
2011-06-20 19:35 ` [RFT PATCH 0/9] Cleanup and extension of netdev features David Miller
2011-06-20 19:47 ` Michał Mirosław
2011-06-20 19:55 ` [IGNORE PATCH 1/9] Intel net drivers: convert to ndo_fix_features Michał Mirosław
2011-06-21 21:43 ` [RFT PATCH 0/9] Cleanup and extension of netdev features Ben Greear
2011-06-21 21:52 ` Ben Hutchings
2011-06-21 23:27 ` Jeff Kirsher
2011-06-23 17:42 ` Mahesh Bandewar
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=1308855335.2712.15.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=maheshb@google.com \
--cc=mirq-linux@rere.qmqm.pl \
--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 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).