From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 2/3] net: dsa: allow DSA switch drivers to provide their own phylink mac ops
Date: Mon, 08 Apr 2024 12:19:25 +0100 [thread overview]
Message-ID: <E1rtn25-0065p0-2C@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZhPSpvJfvLqWi0Hu@shell.armlinux.org.uk>
Rather than having a shim for each and every phylink MAC operation,
allow DSA switch drivers to provide their own ops structure.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
include/net/dsa.h | 5 +++++
net/dsa/port.c | 29 ++++++++++++++++++++++++-----
2 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index f228b479a5fd..7edfd8de8882 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -457,6 +457,11 @@ struct dsa_switch {
*/
const struct dsa_switch_ops *ops;
+ /*
+ * Allow a DSA switch driver to override the phylink MAC ops
+ */
+ const struct phylink_mac_ops *phylink_mac_ops;
+
/*
* User mii_bus and devices for the individual ports.
*/
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 02bf1c306bdc..bfacf41344df 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1662,6 +1662,7 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = {
int dsa_port_phylink_create(struct dsa_port *dp)
{
+ const struct phylink_mac_ops *mac_ops;
struct dsa_switch *ds = dp->ds;
phy_interface_t mode;
struct phylink *pl;
@@ -1685,8 +1686,12 @@ int dsa_port_phylink_create(struct dsa_port *dp)
}
}
- pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn),
- mode, &dsa_port_phylink_mac_ops);
+ mac_ops = &dsa_port_phylink_mac_ops;
+ if (ds->phylink_mac_ops)
+ mac_ops = ds->phylink_mac_ops;
+
+ pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode,
+ mac_ops);
if (IS_ERR(pl)) {
pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl));
return PTR_ERR(pl);
@@ -1952,6 +1957,22 @@ static void dsa_shared_port_validate_of(struct dsa_port *dp,
dn, dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
}
+static void dsa_shared_port_link_down(struct dsa_port *dp)
+{
+ struct dsa_switch *ds = dp->ds;
+
+ if (ds->phylink_mac_ops) {
+ if (ds->phylink_mac_ops->mac_link_down)
+ ds->phylink_mac_ops->mac_link_down(&dp->pl_config,
+ MLO_AN_FIXED,
+ PHY_INTERFACE_MODE_NA);
+ } else {
+ if (ds->ops->phylink_mac_link_down)
+ ds->ops->phylink_mac_link_down(ds, dp->index,
+ MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
+ }
+}
+
int dsa_shared_port_link_register_of(struct dsa_port *dp)
{
struct dsa_switch *ds = dp->ds;
@@ -1973,9 +1994,7 @@ int dsa_shared_port_link_register_of(struct dsa_port *dp)
"Skipping phylink registration for %s port %d\n",
dsa_port_is_cpu(dp) ? "CPU" : "DSA", dp->index);
} else {
- if (ds->ops->phylink_mac_link_down)
- ds->ops->phylink_mac_link_down(ds, port,
- MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
+ dsa_shared_port_link_down(dp);
return dsa_shared_port_phylink_register(dp);
}
--
2.30.2
next prev parent reply other threads:[~2024-04-08 11:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 11:19 [PATCH net-next 0/3] net: dsa: allow phylink_mac_ops in DSA drivers Russell King (Oracle)
2024-04-08 11:19 ` [PATCH net-next 1/3] net: dsa: introduce dsa_phylink_to_port() Russell King (Oracle)
2024-04-08 23:41 ` Andrew Lunn
2024-04-08 23:50 ` Florian Fainelli
2024-04-08 11:19 ` Russell King (Oracle) [this message]
2024-04-08 23:45 ` [PATCH net-next 2/3] net: dsa: allow DSA switch drivers to provide their own phylink mac ops Andrew Lunn
2024-04-08 23:51 ` Florian Fainelli
2024-04-09 3:15 ` kernel test robot
2024-04-09 8:04 ` Russell King (Oracle)
2024-04-09 12:37 ` Vladimir Oltean
2024-04-09 15:33 ` Vladimir Oltean
2024-04-09 16:29 ` Russell King (Oracle)
2024-04-09 16:52 ` Vladimir Oltean
2024-04-09 18:22 ` Russell King (Oracle)
2024-04-08 11:19 ` [PATCH net-next 3/3] net: dsa: mv88e6xxx: provide own phylink MAC operations Russell King (Oracle)
2024-04-08 23:45 ` Andrew Lunn
2024-04-08 23:51 ` Florian Fainelli
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=E1rtn25-0065p0-2C@rmk-PC.armlinux.org.uk \
--to=rmk+kernel@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).