All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Horatiu Vultur <horatiu.vultur@microchip.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 13:43:20 +0000	[thread overview]
Message-ID: <20211213134319.dp6b3or24pl3p4en@skbuf> (raw)
In-Reply-To: <20211213102529.tzdvekwwngo4zgex@soft-dev3-1.localhost>

On Mon, Dec 13, 2021 at 11:25:29AM +0100, Horatiu Vultur wrote:
> The 12/09/2021 17:43, Horatiu Vultur wrote:
> > > > +int lan966x_register_notifier_blocks(struct lan966x *lan966x)
> > > > +{
> > > > +     int err;
> > > > +
> > > > +     lan966x->netdevice_nb.notifier_call = lan966x_netdevice_event;
> > > > +     err = register_netdevice_notifier(&lan966x->netdevice_nb);
> > > > +     if (err)
> > > > +             return err;
> > > > +
> > > > +     lan966x->switchdev_nb.notifier_call = lan966x_switchdev_event;
> > > > +     err = register_switchdev_notifier(&lan966x->switchdev_nb);
> > > > +     if (err)
> > > > +             goto err_switchdev_nb;
> > > > +
> > > > +     lan966x->switchdev_blocking_nb.notifier_call = lan966x_switchdev_blocking_event;
> > > > +     err = register_switchdev_blocking_notifier(&lan966x->switchdev_blocking_nb);
> > > > +     if (err)
> > > > +             goto err_switchdev_blocking_nb;
> > > > +
> > > > +     lan966x_owq = alloc_ordered_workqueue("lan966x_order", 0);
> > > > +     if (!lan966x_owq) {
> > > > +             err = -ENOMEM;
> > > > +             goto err_switchdev_blocking_nb;
> > > > +     }
> > > 
> > > These should be singleton objects, otherwise things get problematic if
> > > you have more than one switch device instantiated in the system.
> > 
> > Yes, I will update this.
> 
> Actually I think they need to be part of lan966x.
> Because we want each lan966x instance to be independent of each other.
> This is not seen in this version but is more clear in the next version
> (v4).

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? This is why I'm saying that the
notifier handlers should be registered as singletons, like other drivers
do.

  reply	other threads:[~2021-12-13 13:43 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 [this message]
2021-12-13 14:26           ` Horatiu Vultur
2021-12-13 14:29             ` Vladimir Oltean
2021-12-13 15:28               ` Horatiu Vultur
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=20211213134319.dp6b3or24pl3p4en@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.