From: Ben Hutchings <bhutchings@solarflare.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
Mahesh Bandewar <maheshb@google.com>,
Matt Carlson <mcarlson@broadcom.com>,
David Miller <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>,
Michael Chan <mchan@broadcom.com>,
Tom Herbert <therbert@google.com>
Subject: Re: [PATCHv3 2/2] tg3: Allow ethtool to enable/disable loopback.
Date: Wed, 04 May 2011 17:08:53 +0100 [thread overview]
Message-ID: <1304525333.2926.2.camel@bwh-desktop> (raw)
In-Reply-To: <20110504160521.GA2035@rere.qmqm.pl>
On Wed, 2011-05-04 at 18:05 +0200, Michał Mirosław wrote:
> On Wed, May 04, 2011 at 08:04:08AM -0700, Stephen Hemminger wrote:
> > On Wed, 4 May 2011 13:11:12 +0200
> > Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
> > > On Tue, May 03, 2011 at 06:18:55PM -0700, Mahesh Bandewar wrote:
> > > > This patch adds tg3_set_features() to handle loopback mode. Currently the
> > > > capability is added for the devices which support internal MAC loopback mode.
> > > > So when enabled, it enables internal-MAC loopback.
> > > [...]
> > > > diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
> > > > index 7c7c9a8..46de633 100644
> > > > --- a/drivers/net/tg3.c
> > > > +++ b/drivers/net/tg3.c
> > > > @@ -6319,6 +6319,51 @@ static u32 tg3_fix_features(struct net_device *dev, u32 features)
> > > > return features;
> > > > }
> > > >
> > > > +static int tg3_set_features(struct net_device *dev, u32 features)
> > > > +{
> > > > + struct tg3 *tp = netdev_priv(dev);
> > > > + u32 cur_mode = 0;
> > > > + int err = 0;
> > > > +
> > > > + if (!netif_running(dev)) {
> > > > + err = -EAGAIN;
> > > > + goto sfeatures_out;
> > > > + }
> > > netdev_update_features() is not designed to handle -EAGAIN from
> > > ndo_set_features callback. It might be useful to implement this
> > > handling, but in this case you should just return 0 and check
> > > dev->features in ndo_open callback.
> >
> > EAGAIN is a bad choice of error code anyway. It implies that the
> > application should retry, which in this case is not true.
> >
> > This error code is used for things like flow controlled sockets where
> > the application should do a select/poll and the condition will clear
> > when other side has read.
> >
> > Why not use ENETDOWN instead?
>
> The "application" here is netdev_update_features() here. Whatever the
> error code, it would need to be handled there.
The important point - which I think you already stated - is that when
the device is down this function is not expected to apply changes to the
hardware and therefore it should return 0.
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-05-04 16:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 1:18 [PATCHv3 0/2] Loopback Mahesh Bandewar
2011-05-04 1:18 ` [PATCH 1/2] net: Allow ethtool to set interface in loopback mode Mahesh Bandewar
2011-05-04 1:18 ` [PATCHv3 2/2] tg3: Allow ethtool to enable/disable loopback Mahesh Bandewar
2011-05-04 1:52 ` Matt Carlson
2011-05-04 11:11 ` Michał Mirosław
2011-05-04 15:04 ` Stephen Hemminger
2011-05-04 16:05 ` Michał Mirosław
2011-05-04 16:08 ` Ben Hutchings [this message]
2011-05-05 1:34 ` [PATCHv4 " Mahesh Bandewar
2011-05-05 6:59 ` Michał Mirosław
2011-05-05 17:47 ` Mahesh Bandewar
2011-05-05 18:35 ` Michał Mirosław
2011-05-05 23:16 ` Mahesh Bandewar
2011-05-06 6:35 ` Michał Mirosław
2011-05-07 6:18 ` [PATCHv5 " Mahesh Bandewar
2011-05-07 7:43 ` Michał Mirosław
2011-05-08 16:50 ` Mahesh Bandewar
2011-05-08 16:51 ` [PATCHv6 " Mahesh Bandewar
2011-05-12 22:04 ` David Miller
2011-05-04 11:15 ` [PATCH 1/2] net: Allow ethtool to set interface in loopback mode Michał Mirosław
2011-05-05 1:30 ` [PATCHv2 " Mahesh Bandewar
2011-05-05 1:52 ` Ben Hutchings
2011-05-08 23:00 ` David Miller
2011-05-06 0:12 ` [PATCH net-next-2.6] sfc: Implement NETIF_F_LOOPBACK Ben Hutchings
2011-05-09 7:36 ` Michał Mirosław
2011-05-09 13:47 ` Ben Hutchings
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=1304525333.2926.2.camel@bwh-desktop \
--to=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=maheshb@google.com \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
--cc=therbert@google.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).