netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] dpaa2-eth: setup the of_node
@ 2021-05-21 13:25 Ioana Ciornei
  2021-05-21 13:25 ` [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device Ioana Ciornei
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ioana Ciornei @ 2021-05-21 13:25 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

This patch set allows DSA to work with a DPAA2 master device by setting
up the of_node to point to the corresponding MAC DTS node, so that
of_find_net_device_by_node() can find it.
As an added benefit, udev rules can now be used to create a naming
scheme based on the physical MAC.

The second patch renames the debugfs directory to use the DPNI name
instead of the netdev name, since the latter can be changed after probe
time.

Ioana Ciornei (2):
  dpaa2-eth: setup the of_node field of the device
  dpaa2-eth: name the debugfs directory after the DPNI object

 .../freescale/dpaa2/dpaa2-eth-debugfs.c       |  6 ++++-
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 25 ++++++++++---------
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.h  |  1 +
 3 files changed, 19 insertions(+), 13 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device
  2021-05-21 13:25 [PATCH net-next 0/2] dpaa2-eth: setup the of_node Ioana Ciornei
@ 2021-05-21 13:25 ` Ioana Ciornei
  2021-05-21 14:22   ` Vladimir Oltean
  2021-05-21 13:25 ` [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object Ioana Ciornei
  2021-05-21 21:10 ` [PATCH net-next 0/2] dpaa2-eth: setup the of_node patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ioana Ciornei @ 2021-05-21 13:25 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

When the DPNI object is connected to a DPMAC, setup the of_node to point
to the DTS device node of that specific MAC. This enables other drivers,
for example the DSA subsystem, to find the net_device by its device
node.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.c  | 25 ++++++++++---------
 .../net/ethernet/freescale/dpaa2/dpaa2-mac.h  |  1 +
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
index ccaf7e35abeb..4dfadf2b70d6 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
@@ -289,17 +289,15 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 
 	mac->if_link_type = mac->attr.link_type;
 
-	dpmac_node = dpaa2_mac_get_node(mac->attr.id);
+	dpmac_node = mac->of_node;
 	if (!dpmac_node) {
 		netdev_err(net_dev, "No dpmac@%d node found.\n", mac->attr.id);
 		return -ENODEV;
 	}
 
 	err = dpaa2_mac_get_if_mode(dpmac_node, mac->attr);
-	if (err < 0) {
-		err = -EINVAL;
-		goto err_put_node;
-	}
+	if (err < 0)
+		return -EINVAL;
 	mac->if_mode = err;
 
 	/* The MAC does not have the capability to add RGMII delays so
@@ -311,8 +309,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_RXID ||
 	     mac->if_mode == PHY_INTERFACE_MODE_RGMII_TXID)) {
 		netdev_err(net_dev, "RGMII delay not supported\n");
-		err = -EINVAL;
-		goto err_put_node;
+		return -EINVAL;
 	}
 
 	if ((mac->attr.link_type == DPMAC_LINK_TYPE_PHY &&
@@ -320,7 +317,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 	    mac->attr.link_type == DPMAC_LINK_TYPE_BACKPLANE) {
 		err = dpaa2_pcs_create(mac, dpmac_node, mac->attr.id);
 		if (err)
-			goto err_put_node;
+			return err;
 	}
 
 	mac->phylink_config.dev = &net_dev->dev;
@@ -344,16 +341,12 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
 		goto err_phylink_destroy;
 	}
 
-	of_node_put(dpmac_node);
-
 	return 0;
 
 err_phylink_destroy:
 	phylink_destroy(mac->phylink);
 err_pcs_destroy:
 	dpaa2_pcs_destroy(mac);
-err_put_node:
-	of_node_put(dpmac_node);
 
 	return err;
 }
@@ -388,6 +381,12 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
 		goto err_close_dpmac;
 	}
 
+	/* Find the device node representing the MAC device and link the device
+	 * behind the associated netdev to it.
+	 */
+	mac->of_node = dpaa2_mac_get_node(mac->attr.id);
+	net_dev->dev.of_node = mac->of_node;
+
 	return 0;
 
 err_close_dpmac:
@@ -400,6 +399,8 @@ void dpaa2_mac_close(struct dpaa2_mac *mac)
 	struct fsl_mc_device *dpmac_dev = mac->mc_dev;
 
 	dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle);
+	if (mac->of_node)
+		of_node_put(mac->of_node);
 }
 
 static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = {
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
index 13d42dd58ec9..8ebcb3420d02 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.h
@@ -24,6 +24,7 @@ struct dpaa2_mac {
 	phy_interface_t if_mode;
 	enum dpmac_link_type if_link_type;
 	struct lynx_pcs *pcs;
+	struct device_node *of_node;
 };
 
 bool dpaa2_mac_is_type_fixed(struct fsl_mc_device *dpmac_dev,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object
  2021-05-21 13:25 [PATCH net-next 0/2] dpaa2-eth: setup the of_node Ioana Ciornei
  2021-05-21 13:25 ` [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device Ioana Ciornei
@ 2021-05-21 13:25 ` Ioana Ciornei
  2021-05-21 14:24   ` Vladimir Oltean
  2021-05-21 21:10 ` [PATCH net-next 0/2] dpaa2-eth: setup the of_node patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ioana Ciornei @ 2021-05-21 13:25 UTC (permalink / raw)
  To: davem, kuba, netdev; +Cc: Ioana Ciornei

From: Ioana Ciornei <ioana.ciornei@nxp.com>

Name the debugfs directory after the DPNI object instead of the netdev
name since this can be changed after probe by udev rules.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
index b87db0846e10..8356af4631fd 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
@@ -121,10 +121,14 @@ DEFINE_SHOW_ATTRIBUTE(dpaa2_dbg_ch);
 
 void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
 {
+	struct fsl_mc_device *dpni_dev;
 	struct dentry *dir;
+	char name[10];
 
 	/* Create a directory for the interface */
-	dir = debugfs_create_dir(priv->net_dev->name, dpaa2_dbg_root);
+	dpni_dev = to_fsl_mc_device(priv->net_dev->dev.parent);
+	snprintf(name, 10, "dpni.%d", dpni_dev->obj_desc.id);
+	dir = debugfs_create_dir(name, dpaa2_dbg_root);
 	priv->dbg.dir = dir;
 
 	/* per-cpu stats file */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device
  2021-05-21 13:25 ` [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device Ioana Ciornei
@ 2021-05-21 14:22   ` Vladimir Oltean
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-05-21 14:22 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, kuba, netdev, Ioana Ciornei

On Fri, May 21, 2021 at 04:25:29PM +0300, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> When the DPNI object is connected to a DPMAC, setup the of_node to point
> to the DTS device node of that specific MAC. This enables other drivers,
> for example the DSA subsystem, to find the net_device by its device
> node.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object
  2021-05-21 13:25 ` [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object Ioana Ciornei
@ 2021-05-21 14:24   ` Vladimir Oltean
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir Oltean @ 2021-05-21 14:24 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, kuba, netdev, Ioana Ciornei

On Fri, May 21, 2021 at 04:25:30PM +0300, Ioana Ciornei wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> Name the debugfs directory after the DPNI object instead of the netdev
> name since this can be changed after probe by udev rules.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/2] dpaa2-eth: setup the of_node
  2021-05-21 13:25 [PATCH net-next 0/2] dpaa2-eth: setup the of_node Ioana Ciornei
  2021-05-21 13:25 ` [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device Ioana Ciornei
  2021-05-21 13:25 ` [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object Ioana Ciornei
@ 2021-05-21 21:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-21 21:10 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, kuba, netdev, ioana.ciornei

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Fri, 21 May 2021 16:25:28 +0300 you wrote:
> From: Ioana Ciornei <ioana.ciornei@nxp.com>
> 
> This patch set allows DSA to work with a DPAA2 master device by setting
> up the of_node to point to the corresponding MAC DTS node, so that
> of_find_net_device_by_node() can find it.
> As an added benefit, udev rules can now be used to create a naming
> scheme based on the physical MAC.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] dpaa2-eth: setup the of_node field of the device
    https://git.kernel.org/netdev/net-next/c/b193f2ed533f
  - [net-next,2/2] dpaa2-eth: name the debugfs directory after the DPNI object
    https://git.kernel.org/netdev/net-next/c/30f43d6f1cab

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-21 21:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 13:25 [PATCH net-next 0/2] dpaa2-eth: setup the of_node Ioana Ciornei
2021-05-21 13:25 ` [PATCH net-next 1/2] dpaa2-eth: setup the of_node field of the device Ioana Ciornei
2021-05-21 14:22   ` Vladimir Oltean
2021-05-21 13:25 ` [PATCH net-next 2/2] dpaa2-eth: name the debugfs directory after the DPNI object Ioana Ciornei
2021-05-21 14:24   ` Vladimir Oltean
2021-05-21 21:10 ` [PATCH net-next 0/2] dpaa2-eth: setup the of_node patchwork-bot+netdevbpf

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).