From: Sean Anderson <sean.anderson@linux.dev>
To: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>
Cc: linux-kernel@vger.kernel.org,
Christian Marangi <ansuelsmth@gmail.com>,
upstream@airoha.com, Heiner Kallweit <hkallweit1@gmail.com>,
Sean Anderson <sean.anderson@linux.dev>
Subject: [RFC net-next PATCH 02/13] net: phylink: Support setting PCS link change callbacks
Date: Thu, 3 Apr 2025 14:18:56 -0400 [thread overview]
Message-ID: <20250403181907.1947517-3-sean.anderson@linux.dev> (raw)
In-Reply-To: <20250403181907.1947517-1-sean.anderson@linux.dev>
Support changing the link change callback, similar to how PHYs do it.
This will allow the PCS wrapper to forward link changes to the wrapped
PCS.
Signed-off-by: Sean Anderson <sean.anderson@linux.dev>
---
drivers/net/phy/phylink.c | 24 +++++++-----------------
include/linux/phylink.h | 27 ++++++++++++++++++++++-----
2 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 69ca765485db..76ce96315c0c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -1205,6 +1205,8 @@ static void phylink_pcs_neg_mode(struct phylink *pl, struct phylink_pcs *pcs,
pl->act_link_an_mode = mode;
}
+static void pcs_change_callback(void *priv, bool up);
+
static void phylink_major_config(struct phylink *pl, bool restart,
const struct phylink_link_state *state)
{
@@ -1260,10 +1262,10 @@ static void phylink_major_config(struct phylink *pl, bool restart,
phylink_pcs_disable(pl->pcs);
if (pl->pcs)
- pl->pcs->phylink = NULL;
-
- pcs->phylink = pl;
+ pl->pcs->link_change_priv = NULL;
+ pcs->link_change = pcs_change_callback;
+ pcs->link_change_priv = pl;
pl->pcs = pcs;
}
@@ -2333,25 +2335,13 @@ void phylink_mac_change(struct phylink *pl, bool up)
}
EXPORT_SYMBOL_GPL(phylink_mac_change);
-/**
- * phylink_pcs_change() - notify phylink of a change to PCS link state
- * @pcs: pointer to &struct phylink_pcs
- * @up: indicates whether the link is currently up.
- *
- * The PCS driver should call this when the state of its link changes
- * (e.g. link failure, new negotiation results, etc.) Note: it should
- * not determine "up" by reading the BMSR. If in doubt about the link
- * state at interrupt time, then pass true if pcs_get_state() returns
- * the latched link-down state, otherwise pass false.
- */
-void phylink_pcs_change(struct phylink_pcs *pcs, bool up)
+static void pcs_change_callback(void *priv, bool up)
{
- struct phylink *pl = pcs->phylink;
+ struct phylink *pl = priv;
if (pl)
phylink_link_changed(pl, up, "pcs");
}
-EXPORT_SYMBOL_GPL(phylink_pcs_change);
static irqreturn_t phylink_link_handler(int irq, void *data)
{
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 1f5773ab5660..a16282ae746d 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -441,7 +441,8 @@ struct phylink_pcs_ops;
* @supported_interfaces: describing which PHY_INTERFACE_MODE_xxx
* are supported by this PCS.
* @ops: a pointer to the &struct phylink_pcs_ops structure
- * @phylink: pointer to &struct phylink_config
+ * @link_change: callback for when the link changes
+ * @link_change_priv: first argument to @link_change
* @poll: poll the PCS for link changes
* @rxc_always_on: The MAC driver requires the reference clock
* to always be on. Standalone PCS drivers which
@@ -451,13 +452,14 @@ struct phylink_pcs_ops;
* This structure is designed to be embedded within the PCS private data,
* and will be passed between phylink and the PCS.
*
- * The @phylink member is private to phylink and must not be touched by
- * the PCS driver.
+ * @link_change, @link_change_priv, and @rxc_always_on will be filled in by
+ * phylink.
*/
struct phylink_pcs {
DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
const struct phylink_pcs_ops *ops;
- struct phylink *phylink;
+ void (*link_change)(void *priv, bool up);
+ void *link_change_priv;
bool poll;
bool rxc_always_on;
};
@@ -699,7 +701,22 @@ int phylink_set_fixed_link(struct phylink *,
const struct phylink_link_state *);
void phylink_mac_change(struct phylink *, bool up);
-void phylink_pcs_change(struct phylink_pcs *, bool up);
+/**
+ * phylink_pcs_change() - notify phylink of a change to PCS link state
+ * @pcs: pointer to &struct phylink_pcs
+ * @up: indicates whether the link is currently up.
+ *
+ * The PCS driver should call this when the state of its link changes
+ * (e.g. link failure, new negotiation results, etc.) Note: it should
+ * not determine "up" by reading the BMSR. If in doubt about the link
+ * state at interrupt time, then pass true if pcs_get_state() returns
+ * the latched link-down state, otherwise pass false.
+ */
+static inline void phylink_pcs_change(struct phylink_pcs *pcs, bool up)
+{
+ if (pcs->link_change)
+ pcs->link_change(pcs->link_change_priv, up);
+}
int phylink_pcs_pre_init(struct phylink *pl, struct phylink_pcs *pcs);
--
2.35.1.1320.gc452695387.dirty
next prev parent reply other threads:[~2025-04-03 18:19 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 18:18 [RFC net-next PATCH 00/13] Add PCS core support Sean Anderson
2025-04-03 18:18 ` [RFC net-next PATCH 01/13] dt-bindings: net: Add binding for Xilinx PCS Sean Anderson
2025-04-04 10:37 ` Krzysztof Kozlowski
2025-04-04 10:39 ` Krzysztof Kozlowski
2025-04-04 15:12 ` Sean Anderson
2025-04-04 15:19 ` Sean Anderson
2025-04-03 18:18 ` Sean Anderson [this message]
2025-04-03 18:18 ` [RFC net-next PATCH 03/13] net: pcs: Add subsystem Sean Anderson
2025-04-03 18:18 ` [RFC net-next PATCH 04/13] net: dsa: ocelot: suppress PHY device scanning on the internal MDIO bus Sean Anderson
2025-04-03 18:18 ` [RFC net-next PATCH 05/13] net: pcs: lynx: Convert to an MDIO driver Sean Anderson
2025-04-03 18:19 ` [RFC net-next PATCH 06/13] net: phy: Export some functions Sean Anderson
2025-04-03 18:37 ` Florian Fainelli
2025-04-03 19:08 ` Sean Anderson
2025-04-03 18:19 ` [RFC net-next PATCH 07/13] net: pcs: Add Xilinx PCS driver Sean Anderson
2025-04-03 20:27 ` Russell King (Oracle)
2025-04-03 20:51 ` Sean Anderson
2025-04-03 18:19 ` [RFC net-next PATCH 08/13] net: axienet: Convert to use PCS subsystem Sean Anderson
2025-04-03 18:19 ` [RFC net-next PATCH 09/13] net: macb: Move most of mac_config to mac_prepare Sean Anderson
2025-04-03 18:27 ` [RFC net-next PATCH 10/13] net: macb: Support external PCSs Sean Anderson
2025-04-03 20:31 ` Russell King (Oracle)
2025-04-03 18:27 ` [RFC net-next PATCH 11/13] of: property: Add device link support for PCS Sean Anderson
2025-04-03 18:32 ` Saravana Kannan
2025-04-03 19:04 ` Sean Anderson
2025-04-03 18:28 ` [RFC net-next PATCH 12/13] arm64: dts: Add compatible strings for Lynx PCSs Sean Anderson
2025-04-03 18:30 ` [RFC net-next PATCH 13/13] powerpc: " Sean Anderson
2025-04-07 16:27 ` [RFC net-next PATCH 00/13] Add PCS core support Kory Maincent
2025-04-07 16:33 ` Sean Anderson
2025-04-07 16:46 ` Christian Marangi (Ansuel)
2025-04-07 17:00 ` Sean Anderson
2025-04-07 17:21 ` Christian Marangi (Ansuel)
2025-04-07 17:25 ` Daniel Golle
2025-04-07 17:40 ` Sean Anderson
2025-04-08 15:17 ` Sean Anderson
2025-04-07 18:06 ` Sean Anderson
2025-04-07 16:51 ` Kory Maincent
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=20250403181907.1947517-3-sean.anderson@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=upstream@airoha.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).