From: "Michał Mirosław" <mirqus@gmail.com>
To: Mahesh Bandewar <maheshb@google.com>
Cc: 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: [PATCHv4 2/2] tg3: Allow ethtool to enable/disable loopback.
Date: Fri, 6 May 2011 08:35:07 +0200 [thread overview]
Message-ID: <BANLkTimYK-qpjnVAsW7H78-RrkmcpXPeCw@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=UxTgBU0ZEJ2PMAef1NzvJGqT_ZA@mail.gmail.com>
W dniu 6 maja 2011 01:16 użytkownik Mahesh Bandewar
<maheshb@google.com> napisał:
> On Thu, May 5, 2011 at 11:35 AM, Michał Mirosław <mirqus@gmail.com> wrote:
>> W dniu 5 maja 2011 19:47 użytkownik Mahesh Bandewar
>> <maheshb@google.com> napisał:
>>> On Wed, May 4, 2011 at 11:59 PM, Michał Mirosław <mirqus@gmail.com> wrote:
>>>> 2011/5/5 Mahesh Bandewar <maheshb@google.com>:
>>>>> 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.
>> [...]
>>>>> @@ -9485,6 +9533,15 @@ static int tg3_open(struct net_device *dev)
>>>>>
>>>>> netif_tx_start_all_queues(dev);
>>>>>
>>>>> + /*
>>>>> + * Reset loopback feature if it was turned on while the device was down
>>>>> + * to avoid and any discrepancy in features reporting.
>>>>> + */
>>>>> + if (dev->features & NETIF_F_LOOPBACK) {
>>>>> + dev->features &= ~NETIF_F_LOOPBACK;
>>>>> + dev->wanted_features &= ~NETIF_F_LOOPBACK;
>>>>> + }
>>>>> +
>>>>
>>>> if (dev->features & NETIF_F_LOOPBACK)
>>>> tg3_set_loopback(dev, dev->features);
>>>>
>>> Unfortunately at this stage device will not be able to set-loopback so
>>> I resorted to clearing the bit(s).
>> ndo_fix_features+ndo_set_features might be caled before ndo_open - the
>> first might be just from register_netdev() so even before ndo_open
>> callback.
> ndo_open is the triggering event, so anything before that point does
> not really help.
You're right - I forgot that netif_running() becomes true just before
ndo_open is called. I have a hard time to convince myself that you
can't program the hardware for loopback just at the end of ndo_open
callback.
>>>> Whatever you do, don't modify wanted_features in drivers.
>>> Since just clearing the 'features' would leave wanted_features in
>>> discrepant state, I thought this will bring it to a sane state. So
>>> what is a preferred way?
>> If you really can't do other way, driver should keep additional state
>> that is checked in ndo_fix_features callback.
> ndo_fix_features callback is called just before calling
> ndo_set_features callback. Also this is called during update_features,
> so having the state maintained is not really going to help in this
> scenario since that is not happening when device reaches ready state
> (to remove this discrepancy in the feature-set).
You can call netdev_update_features() at the end of ndo_open. But that
would be the same in the end as just enabling the loopback there.
> There must be a reason (that you did not explain!) why driver code
> should not alter wanted_feature set. So in this scenario, just leaving
> the wanted_features as it is and clearing the features bit is correct
> / enough?
wanted_features reflects a set of features the user wants. I assume
that no code can change the user himself, so changing wanted_features
instead would break this connection. You can view wanted_features as a
cache of user's intention. ;-)
Best Regards,
Michał Mirosław
next prev parent reply other threads:[~2011-05-06 6:35 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
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 [this message]
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=BANLkTimYK-qpjnVAsW7H78-RrkmcpXPeCw@mail.gmail.com \
--to=mirqus@gmail.com \
--cc=davem@davemloft.net \
--cc=maheshb@google.com \
--cc=mcarlson@broadcom.com \
--cc=mchan@broadcom.com \
--cc=netdev@vger.kernel.org \
--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).