From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"thomas.petazzoni@bootlin.com" <thomas.petazzoni@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Luka Perkov <luka.perkov@sartura.hr>,
Robert Marko <robert.marko@sartura.hr>
Subject: Re: [PATCH net-next v5 4/5] net: ipqess: Add out-of-band DSA tagging support
Date: Fri, 21 Oct 2022 14:12:35 +0000 [thread overview]
Message-ID: <20221021141234.rgzd3znogpmm26tf@skbuf> (raw)
In-Reply-To: <20221021124556.100445-5-maxime.chevallier@bootlin.com> <20221021124556.100445-5-maxime.chevallier@bootlin.com>
On Fri, Oct 21, 2022 at 02:45:55PM +0200, Maxime Chevallier wrote:
> +static int ipqess_netdevice_event(struct notifier_block *nb,
> + unsigned long event, void *ptr)
> +{
> + struct ipqess *ess = container_of(nb, struct ipqess, netdev_notifier);
> + struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> + struct netdev_notifier_changeupper_info *info;
> +
> + switch (event) {
> + case NETDEV_CHANGEUPPER:
> + info = ptr;
> +
> + if (dev->netdev_ops != &ipqess_axi_netdev_ops)
> + return NOTIFY_DONE;
> +
> + if (!dsa_slave_dev_check(info->upper_dev))
> + return NOTIFY_DONE;
> +
> + if (info->linking)
> + ess->dsa_ports++;
> + else
> + ess->dsa_ports--;
How many ipqess devices are there in a system? The netdev notifier
should be a singleton, meaning it should be registered at module_init()
and unregistered at module_exit(). You can then get the "ess" pointer as
netdev_priv(dev), once you ensure that dev->netdev_ops is what you expect.
The code is already wrong: you take *ess from the &ess->netdev_notifier
reference, then you increment ess->dsa_ports based on the sole condition
that "dev" (the interface on which the notification was already emitted)
was an ess netdevice. But the "dev" pointer could be ess1, and the "ess"
pointer could be the netdev_priv(ess0). Your logic would increment the
dsa_ports of ess0 when a DSA switch joined ess1 (because all notifier
handlers see the event).
> +
> + return NOTIFY_DONE;
> + }
> + return NOTIFY_OK;
> +}
> +
> @@ -1201,12 +1255,19 @@ static int ipqess_axi_probe(struct platform_device *pdev)
> netif_napi_add(netdev, &ess->rx_ring[i].napi_rx, ipqess_rx_napi);
> }
>
> - err = register_netdev(netdev);
> + ess->netdev_notifier.notifier_call = ipqess_netdevice_event;
> + err = register_netdevice_notifier(&ess->netdev_notifier);
> if (err)
> goto err_hw_stop;
>
> + err = register_netdev(netdev);
> + if (err)
> + goto err_notifier_unregister;
> +
> return 0;
>
> +err_notifier_unregister:
> + unregister_netdevice_notifier(&ess->netdev_notifier);
> err_hw_stop:
> ipqess_hw_stop(ess);
>
> diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> index 9a4ab6ce282a..33cccaf6f143 100644
> --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> @@ -171,6 +171,10 @@ struct ipqess {
> struct platform_device *pdev;
> struct phylink *phylink;
> struct phylink_config phylink_config;
> +
> + struct notifier_block netdev_notifier;
> + int dsa_ports;
> +
> struct ipqess_tx_ring tx_ring[IPQESS_NETDEV_QUEUES];
>
> struct ipqess_statistics ipqess_stats;
> --
> 2.37.3
>
next prev parent reply other threads:[~2022-10-21 14:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 12:45 [PATCH net-next v5 0/5] [PATCH net-next v4 0/5] net: ipqess: introduce Qualcomm IPQESS driver Maxime Chevallier
2022-10-21 12:45 ` [PATCH net-next v5 1/5] net: dt-bindings: Introduce the Qualcomm IPQESS Ethernet controller Maxime Chevallier
2022-10-21 13:33 ` Krzysztof Kozlowski
2022-10-21 14:30 ` Vladimir Oltean
2022-10-21 14:53 ` Rob Herring
2022-10-21 12:45 ` [PATCH net-next v5 2/5] net: ipqess: introduce the Qualcomm IPQESS driver Maxime Chevallier
2022-10-21 13:38 ` Krzysztof Kozlowski
2022-10-21 14:39 ` Andrew Lunn
2022-10-21 17:49 ` kernel test robot
2022-10-21 17:59 ` kernel test robot
2022-10-21 12:45 ` [PATCH net-next v5 3/5] net: dsa: add out-of-band tagging protocol Maxime Chevallier
2022-10-21 14:01 ` Vladimir Oltean
2022-10-21 14:43 ` Andrew Lunn
2022-10-21 14:46 ` Andrew Lunn
2022-10-21 19:51 ` kernel test robot
2022-10-21 12:45 ` [PATCH net-next v5 4/5] net: ipqess: Add out-of-band DSA tagging support Maxime Chevallier
2022-10-21 14:12 ` Vladimir Oltean [this message]
2022-10-21 12:45 ` [PATCH net-next v5 5/5] ARM: dts: qcom: ipq4019: Add description for the IPQESS Ethernet controller Maxime Chevallier
2022-10-21 14:20 ` Vladimir Oltean
2022-10-21 14:29 ` Krzysztof Kozlowski
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=20221021141234.rgzd3znogpmm26tf@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luka.perkov@sartura.hr \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=robert.marko@sartura.hr \
--cc=robh+dt@kernel.org \
--cc=thomas.petazzoni@bootlin.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