netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Lijun Pan <ljp@linux.vnet.ibm.com>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next] mlx5: count all link events
Date: Thu, 20 May 2021 11:03:22 -0700	[thread overview]
Message-ID: <4ba9e15179c5515c91baa6cee470e19bf0ed6bf0.camel@kernel.org> (raw)
In-Reply-To: <20210520084817.6bd770e5@kicinski-fedora-PC1C0HJN>

On Thu, 2021-05-20 at 08:48 -0700, Jakub Kicinski wrote:
> On Wed, 19 May 2021 22:36:10 -0700 Saeed Mahameed wrote:
> > On Wed, 2021-05-19 at 13:56 -0700, Jakub Kicinski wrote:
> > > On Wed, 19 May 2021 13:18:36 -0700 Saeed Mahameed wrote:  
> > > > then according to the above assumption it is safe to make
> > > > netif_carrier_event() do everything.
> > > > 
> > > > netif_carrier_event(netdev, up) {
> > > >         if (dev->reg_state == NETREG_UNINITIALIZED)
> > > >                 return;
> > > > 
> > > >         if (up == netif_carrier_ok(netdev) {
> > > >                 atomic_inc(&netdev->carrier_up_count);
> > > >                 atomic_inc(&netdev->carrier_down_count);
> > > >                 linkwatch_fire_event(netdev);
> > > >         }
> > > > 
> > > >         if (up) {
> > > >                 netdev_info(netdev, "Link up\n");
> > > >                 netif_carrier_on(netdev);
> > > >         } else {
> > > >                 netdev_info(netdev, "Link down\n");
> > > >                 netif_carrier_off(netdev);
> > > >         }
> > > > }  
> > > 
> > > Two things to consider are:
> > >  - some drivers print more info than just "link up/link down" so
> > > they'd
> > >    have to drop that extra stuff (as much as I'd like the
> > > consistency)  
> > 
> > +1 for the consistency
> > 
> > >  - again with the unnecessary events I was afraid that drivers
> > > reuse 
> > >    the same handler for device events and to read the state in
> > > which
> > >    case we may do something like:
> > > 
> > >         if (from_event && up == netif_carrier_ok(netdev)
> > >   
> > 
> > I don't actually understand your point here .. what kind of
> > scenarios
> > it is wrong to use this function ? 
> > 
> > But anyway, the name of the function makes it very clear this is
> > from
> > event.. also we can document this.
> 
> I don't have any proof of this but drivers may check link state
> periodically from a service job or such.
> 

I see.

> > > Maybe we can revisit when there's more users?  
> > goes both ways :), we can do what fits the requirement for mlx5 now
> > and
> > revisit in the future, if we do believe this should be general
> > behavior
> > for all/most vendors of-course!
> 
> I think it'd be more of a "add this function so the future drivers
> can
> use it". I've scanned the drivers I'm familiar with and none of them
> seemed like they could make use of the "wider" version of the helper.
> Does mlx4 need it?
> 

No, mlx4 relies on the event type.

> The problem seems slightly unusual, I feel like targeted helper would
> lead to a cleaner API, but can change if we really need to..

Sure, I have no strong opinion on the matter.



  reply	other threads:[~2021-05-20 18:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 17:18 [PATCH net-next] mlx5: count all link events Jakub Kicinski
2021-05-19 19:34 ` Lijun Pan
2021-05-19 19:51   ` Jakub Kicinski
2021-05-19 20:18     ` Saeed Mahameed
2021-05-19 20:56       ` Jakub Kicinski
2021-05-20  5:36         ` Saeed Mahameed
2021-05-20 15:48           ` Jakub Kicinski
2021-05-20 18:03             ` Saeed Mahameed [this message]
2021-05-19 20:49 ` Saeed Mahameed
2021-05-19 21:06   ` Jakub Kicinski
2021-05-20  0:07     ` Saeed Mahameed
2021-05-20  0:44       ` Jakub Kicinski

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=4ba9e15179c5515c91baa6cee470e19bf0ed6bf0.camel@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=ljp@linux.vnet.ibm.com \
    --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).