linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>
Cc: "Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Jose Abreu" <joabreu@synopsys.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	davem@davemloft.net, "Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexis Lothoré" <alexis.lothore@bootlin.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/5] net: phylink: add support for PCS supported_interfaces bitmap
Date: Fri, 13 Dec 2024 19:34:51 +0000	[thread overview]
Message-ID: <E1tMBR5-006vaS-Ou@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <Z1yJQikqneoFNJT4@shell.armlinux.org.uk>

Add support for the PCS to specify which interfaces it supports, which
can be used by MAC drivers to build the main supported_interfaces
bitmap. Phylink also validates that the PCS returned by the MAC driver
supports the interface that the MAC was asked for.

An empty supported_interfaces bitmap from the PCS indicates that it
does not provide this information, and we handle that appropriately.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 11 +++++++++++
 include/linux/phylink.h   |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 95fbc363f9a6..3e9960f54550 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -691,6 +691,17 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
 			return -EINVAL;
 		}
 
+		/* Ensure that this PCS supports the interface which the MAC
+		 * returned it for. It is an error for the MAC to return a PCS
+		 * that does not support the interface mode.
+		 */
+		if (!phy_interface_empty(pcs->supported_interfaces) &&
+		    !test_bit(state->interface, pcs->supported_interfaces)) {
+			phylink_err(pl, "MAC returned PCS which does not support %s\n",
+				    phy_modes(state->interface));
+			return -EINVAL;
+		}
+
 		/* Validate the link parameters with the PCS */
 		if (pcs->ops->pcs_validate) {
 			ret = pcs->ops->pcs_validate(pcs, supported, state);
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 5462cc6a37dc..4b7a20620b49 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -393,6 +393,8 @@ struct phylink_pcs_ops;
 
 /**
  * struct phylink_pcs - PHYLINK PCS instance
+ * @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
  * @neg_mode: provide PCS neg mode via "mode" argument
@@ -409,6 +411,7 @@ struct phylink_pcs_ops;
  * the PCS driver.
  */
 struct phylink_pcs {
+	DECLARE_PHY_INTERFACE_MASK(supported_interfaces);
 	const struct phylink_pcs_ops *ops;
 	struct phylink *phylink;
 	bool neg_mode;
-- 
2.30.2



  reply	other threads:[~2024-12-13 19:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  9:05 [PATCH net-next 0/2] net: stmmac: dwmac-socfpga: Allow using 1000BaseX Maxime Chevallier
2024-12-13  9:05 ` [PATCH net-next 1/2] net: stmmac: dwmac-socfpga: Add support for 1000BaseX Maxime Chevallier
2024-12-13  9:05 ` [PATCH net-next 2/2] net: stmmac: dwmac-socfpga: Set interface modes from Lynx PCS as supported Maxime Chevallier
2024-12-13 12:22   ` Russell King (Oracle)
2024-12-13 17:29     ` Maxime Chevallier
2024-12-13 19:21       ` Russell King (Oracle)
2024-12-13 19:34         ` Russell King (Oracle) [this message]
2024-12-17 13:06           ` [PATCH net-next 1/5] net: phylink: add support for PCS supported_interfaces bitmap Maxime Chevallier
2024-12-13 19:34         ` [PATCH net-next 2/5] net: pcs: xpcs: fill in PCS supported_interfaces Russell King (Oracle)
2024-12-17 13:07           ` Maxime Chevallier
2024-12-13 19:35         ` [PATCH net-next 3/5] net: pcs: mtk-lynxi: " Russell King (Oracle)
2024-12-17 13:15           ` Maxime Chevallier
2025-01-02  9:16             ` Russell King (Oracle)
2024-12-13 19:35         ` [PATCH net-next 4/5] net: pcs: lynx: " Russell King (Oracle)
2024-12-17 13:18           ` Maxime Chevallier
2024-12-13 19:35         ` [PATCH net-next 5/5] net: stmmac: use " Russell King (Oracle)
2024-12-17 13:19           ` Maxime Chevallier
2025-01-02  9:08             ` Russell King (Oracle)
2024-12-16  8:42         ` [PATCH net-next 2/2] net: stmmac: dwmac-socfpga: Set interface modes from Lynx PCS as supported Maxime Chevallier
2024-12-17  1:33           ` Jakub Kicinski
2024-12-17 12:59             ` Maxime Chevallier
2024-12-17 14:49               ` Jakub Kicinski
2024-12-17 15:07                 ` Maxime Chevallier

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=E1tMBR5-006vaS-Ou@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=alexandre.torgue@foss.st.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thomas.petazzoni@bootlin.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).