netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
	"vivien.didelot@gmail.com" <vivien.didelot@gmail.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>
Subject: Re: [PATCH net-next v3 6/6] net: lan966x: Add switchdev support
Date: Mon, 13 Dec 2021 16:28:24 +0100	[thread overview]
Message-ID: <20211213152824.22odaltycnotozkw@soft-dev3-1.localhost> (raw)
In-Reply-To: <20211213142907.7s74smjudcecpgik@skbuf>

The 12/13/2021 14:29, Vladimir Oltean wrote:
> 
> On Mon, Dec 13, 2021 at 03:26:56PM +0100, Horatiu Vultur wrote:
> > > They are independent of each other. You deduce the interface on which
> > > the notifier was emitted using switchdev_notifier_info_to_dev() and act
> > > upon it, if lan966x_netdevice_check() is true. The notifier handling
> > > code itself is stateless, all the state is per port / per switch.
> > > If you register one notifier handler per switch, lan966x_netdevice_check()
> > > would return true for each notifier handler instance, and you would
> > > handle each event twice, would you not?
> >
> > That is correct, I will get the event twice which is a problem in the
> > lan966x. The function lan966x_netdevice_check should be per instance, in
> > this way each instance can filter the events.
> > The reason why I am putting the notifier_block inside lan966x is to be
> > able to get to the instance of lan966x even if I get a event that is not
> > for lan966x port.
> 
> That isn't a problem, every netdevice notifier still sees all events.

Yes, that is correct.
Sorry maybe I am still confused, but some things are still not right.

So lets say there are two lan966x instances(A and B) and each one has 2
ports(ethA0, ethA1, ethB0, ethB1).
So with the current behaviour, if for example ethA0 is added in vlan
100, then we get two callbacks for each lan966x instance(A and B) because
each of them registered. And because of lan966x_netdevice_check() is true
for ethA0 will do twice the work.
And you propose to have a singleton notifier so we get only 1 callback
and will be fine for this case. But if you add for example the bridge in
vlan 200 then I will never be able to get to the lan966x instance which
is needed in this case.

That is why if the lan966x_netdevice_check would be per instance, then
we can filter like before, we still get call twice but then we filter for
each instance. We get the lan966x instance from notifier_block and then
we can check if the port netdev_ops is the same as the lan966x
netdev_ops.

And in the other case we will still be able to get to the lan966x instance
in case the bridge is added in a vlan.

> DSA intercepts a lot of events which aren't directly emitted for its own
> interfaces. You don't gain much by having one more, if anything.
> 
> > > notifier handlers should be registered as singletons, like other drivers
> > > do.
> >
> > It looks like not all the other driver register them as singletone. For
> > example: prestera, mlx5, sparx5. (I just have done a git grep for
> > register_switchdev_notifier, I have not looked in details at the
> > implementation).
> 
> Not all driver writers may have realized that it is an issue that needs
> to be thought of.

-- 
/Horatiu

  reply	other threads:[~2021-12-13 15:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09  9:46 [PATCH net-next v3 0/6] net: lan966x: Add switchdev and vlan support Horatiu Vultur
2021-12-09  9:46 ` [PATCH net-next v3 1/6] net: lan966x: Add registers that are used for switch and vlan functionality Horatiu Vultur
2021-12-09  9:46 ` [PATCH net-next v3 2/6] dt-bindings: net: lan966x: Extend with the analyzer interrupt Horatiu Vultur
2021-12-09 10:58   ` Vladimir Oltean
2021-12-09 15:42     ` Horatiu Vultur
2021-12-09 20:23       ` Vladimir Oltean
2021-12-09  9:46 ` [PATCH net-next v3 3/6] net: lan966x: add support for interrupts from analyzer Horatiu Vultur
2021-12-09 11:47   ` Vladimir Oltean
2021-12-09 15:38     ` Horatiu Vultur
2021-12-09  9:46 ` [PATCH net-next v3 4/6] net: lan966x: More MAC table functionality Horatiu Vultur
2021-12-09  9:46 ` [PATCH net-next v3 5/6] net: lan966x: Add vlan support Horatiu Vultur
2021-12-09 13:59   ` Vladimir Oltean
2021-12-09 15:47     ` Horatiu Vultur
2021-12-09  9:46 ` [PATCH net-next v3 6/6] net: lan966x: Add switchdev support Horatiu Vultur
2021-12-09 13:36   ` Vladimir Oltean
2021-12-09 16:43     ` Horatiu Vultur
2021-12-13 10:25       ` Horatiu Vultur
2021-12-13 13:43         ` Vladimir Oltean
2021-12-13 14:26           ` Horatiu Vultur
2021-12-13 14:29             ` Vladimir Oltean
2021-12-13 15:28               ` Horatiu Vultur [this message]
2021-12-13 16:25                 ` Vladimir Oltean
2021-12-13 21:24                   ` Horatiu Vultur
2021-12-14  0:01                     ` Vladimir Oltean
2021-12-14 14:31                       ` Horatiu Vultur
2021-12-15  9:27                         ` Vladimir Oltean
2021-12-13 11:46       ` Vladimir Oltean
2021-12-13 13:37         ` Horatiu Vultur

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=20211213152824.22odaltycnotozkw@soft-dev3-1.localhost \
    --to=horatiu.vultur@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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).