[PATCH net-next] net: ethernet: ti: cpsw_new: populate netdev of_node

A. Sverdlin posted 1 patch 9 months, 3 weeks ago
There is a newer version of this series
drivers/net/ethernet/ti/cpsw_new.c | 1 +
1 file changed, 1 insertion(+)
[PATCH net-next] net: ethernet: ti: cpsw_new: populate netdev of_node
Posted by A. Sverdlin 9 months, 3 weeks ago
From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

So that of_find_net_device_by_node() can find cpsw-nuss ports and other DSA
switches can be stacked downstream. Tested in conjunction with KSZ8873.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
 drivers/net/ethernet/ti/cpsw_new.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
index cec0a90659d94..66713bc931741 100644
--- a/drivers/net/ethernet/ti/cpsw_new.c
+++ b/drivers/net/ethernet/ti/cpsw_new.c
@@ -1418,6 +1418,7 @@ static int cpsw_create_ports(struct cpsw_common *cpsw)
 		ndev->netdev_ops = &cpsw_netdev_ops;
 		ndev->ethtool_ops = &cpsw_ethtool_ops;
 		SET_NETDEV_DEV(ndev, dev);
+		ndev->dev.of_node = slave_data->slave_node;
 
 		if (!napi_ndev) {
 			/* CPSW Host port CPDMA interface is shared between
-- 
2.48.1
Re: [PATCH net-next] net: ethernet: ti: cpsw_new: populate netdev of_node
Posted by Andrew Lunn 9 months, 3 weeks ago
On Thu, Feb 27, 2025 at 08:46:46AM +0100, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> So that of_find_net_device_by_node() can find cpsw-nuss ports and other DSA
> switches can be stacked downstream. Tested in conjunction with KSZ8873.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Consistent with other TI drivers. But it looks like only TI drivers
need this, which suggests they are all doing something wrong, maybe
for legacy reasons.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Re: [PATCH net-next] net: ethernet: ti: cpsw_new: populate netdev of_node
Posted by Sverdlin, Alexander 9 months, 3 weeks ago
Hi Andrew,

On Thu, 2025-02-27 at 14:24 +0100, Andrew Lunn wrote:
> On Thu, Feb 27, 2025 at 08:46:46AM +0100, A. Sverdlin wrote:
> > From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> > 
> > So that of_find_net_device_by_node() can find cpsw-nuss ports and other DSA
                                                      ^^^^^

Oops, copy-paste failure here, nuss was for the am65-cpsw-nuss driver,
maybe "-nuss" could be simply deleted from the commit message on "apply"...

> > switches can be stacked downstream. Tested in conjunction with KSZ8873.
> > 
> > Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> Consistent with other TI drivers. But it looks like only TI drivers
> need this, which suggests they are all doing something wrong, maybe
> for legacy reasons.

Well, yes, they re-invent the wheel, mimicking the DSA infrastructure
without using it. CPSW is a switch, as the name suggests, but the
effort has not been spent to bring it to DSA home ;-)

So what happens here actually is, I'm assigning a DT node to "user port"
in DSA terms, and dsa_register_switch() would for sure do it...

> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com
Re: [PATCH net-next] net: ethernet: ti: cpsw_new: populate netdev of_node
Posted by Siddharth Vadapalli 9 months, 3 weeks ago
On Thu, Feb 27, 2025 at 08:46:46AM +0100, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> 
> So that of_find_net_device_by_node() can find cpsw-nuss ports and other DSA
> switches can be stacked downstream. Tested in conjunction with KSZ8873.
> 
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>

> ---
>  drivers/net/ethernet/ti/cpsw_new.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
> index cec0a90659d94..66713bc931741 100644
> --- a/drivers/net/ethernet/ti/cpsw_new.c
> +++ b/drivers/net/ethernet/ti/cpsw_new.c
> @@ -1418,6 +1418,7 @@ static int cpsw_create_ports(struct cpsw_common *cpsw)
>  		ndev->netdev_ops = &cpsw_netdev_ops;
>  		ndev->ethtool_ops = &cpsw_ethtool_ops;
>  		SET_NETDEV_DEV(ndev, dev);
> +		ndev->dev.of_node = slave_data->slave_node;
>  
>  		if (!napi_ndev) {
>  			/* CPSW Host port CPDMA interface is shared between

Regards,
Siddharth.