All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Andrew Lunn <andrew@lunn.ch>, Vivien Didelot <vivien.didelot@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org,
	Matthias Schiffer <matthias.schiffer@ew.tq-group.com>,
	Lukasz Majewski <lukma@denx.de>
Subject: [PATCH 1/9] net: dsa: allow switch drivers to override default slave PHY addresses
Date: Tue,  8 Nov 2022 09:23:22 +0100	[thread overview]
Message-ID: <20221108082330.2086671-2-lukma@denx.de> (raw)
In-Reply-To: <20221108082330.2086671-1-lukma@denx.de>

From: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>

Avoid having to define a PHY for every physical port when PHY addresses
are fixed, but port index != PHY address.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
[Adjustments for newest kernel upstreaming]
---
 include/net/dsa.h | 1 +
 net/dsa/slave.c   | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index ee369670e20e..210b0e215ac9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -858,6 +858,7 @@ struct dsa_switch_ops {
 	int	(*port_setup)(struct dsa_switch *ds, int port);
 	void	(*port_teardown)(struct dsa_switch *ds, int port);
 
+	int	(*get_phy_address)(struct dsa_switch *ds, int port);
 	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
 
 	/*
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a9fde48cffd4..8bb1e8770846 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2273,7 +2273,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 	struct device_node *port_dn = dp->dn;
 	struct dsa_switch *ds = dp->ds;
 	u32 phy_flags = 0;
-	int ret;
+	int ret, addr;
 
 	dp->pl_config.dev = &slave_dev->dev;
 	dp->pl_config.type = PHYLINK_NETDEV;
@@ -2299,7 +2299,12 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 		/* We could not connect to a designated PHY or SFP, so try to
 		 * use the switch internal MDIO bus instead
 		 */
-		ret = dsa_slave_phy_connect(slave_dev, dp->index, phy_flags);
+		if (ds->ops->get_phy_address)
+			addr = ds->ops->get_phy_address(ds, dp->index);
+		else
+			addr = dp->index;
+
+		ret = dsa_slave_phy_connect(slave_dev, addr, phy_flags);
 	}
 	if (ret) {
 		netdev_err(slave_dev, "failed to connect to PHY: %pe\n",
-- 
2.37.2


  reply	other threads:[~2022-11-08  8:23 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08  8:23 [PATCH 0/9] net: dsa: Add support for mv88e6020 and mv88e6071 Lukasz Majewski
2022-11-08  8:23 ` Lukasz Majewski [this message]
2022-11-08  9:12   ` [PATCH 1/9] net: dsa: allow switch drivers to override default slave PHY addresses Vladimir Oltean
2022-11-08 10:34     ` Lukasz Majewski
2022-11-08 13:21   ` Andrew Lunn
2022-11-10 15:34     ` Lukasz Majewski
2022-11-10 22:05       ` Andrew Lunn
2022-11-14  8:51         ` Lukasz Majewski
2022-11-08 18:10   ` Florian Fainelli
2022-11-08  8:23 ` [PATCH 2/9] net: dsa: mv88e6xxx: account for PHY base address offset in dual chip mode Lukasz Majewski
2022-11-08 13:26   ` Andrew Lunn
2022-11-10 17:02     ` Lukasz Majewski
2022-11-08  8:23 ` [PATCH 3/9] net: dsa: mv88e6xxx: implement get_phy_address Lukasz Majewski
2022-11-08  9:12   ` Vladimir Oltean
2022-11-08 13:36     ` Andrew Lunn
2022-11-10 17:00       ` Lukasz Majewski
2022-11-11 21:38         ` Vladimir Oltean
2022-11-14 10:10           ` Lukasz Majewski
2022-11-10 16:37     ` Lukasz Majewski
2022-11-08  8:23 ` [PATCH 4/9] net: dsa: mv88e6xxx: add support for MV88E6020 switch Lukasz Majewski
2022-11-08  8:23 ` [PATCH 5/9] net: dsa: mv88e6xxx: Add support for MV88E6071 switch Lukasz Majewski
2022-11-08  8:23 ` [PATCH 6/9] net: dsa: marvell: Provide per device information about max frame size Lukasz Majewski
2022-11-08 13:47   ` Andrew Lunn
2022-11-10 15:36     ` Lukasz Majewski
2022-11-10 22:10       ` Andrew Lunn
2022-11-14  8:52         ` Lukasz Majewski
2022-11-08  8:23 ` [PATCH 7/9] net: dsa: mv88e6071: Define max frame size (2048 bytes) Lukasz Majewski
2022-11-08 13:49   ` Andrew Lunn
2022-11-10 15:42     ` Lukasz Majewski
2022-11-10 22:12       ` Andrew Lunn
2022-11-14  9:06         ` Lukasz Majewski
2022-11-08  8:23 ` [PATCH 8/9] net: dsa: mv88e6071: Provide struct mv88e6xxx_ops Lukasz Majewski
2022-11-08  8:23 ` [PATCH 9/9] net: dsa: mv88e6071: Set .set_max_frame_size callback Lukasz Majewski
2022-11-08 14:03   ` Andrew Lunn
2022-11-10 16:00     ` Lukasz Majewski

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=20221108082330.2086671-2-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --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.