All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Feiyang Chen <chenfeiyang@loongson.cn>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 01/10] net: phylink: add phylink_limit_mac_speed()
Date: Thu, 24 Aug 2023 14:37:53 +0100	[thread overview]
Message-ID: <E1qZAX3-005pTi-K1@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZOddFH22PWmOmbT5@shell.armlinux.org.uk>

Add a function which can be used to limit the phylink MAC capabilities
to an upper speed limit.

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

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 160bce608c34..0d7354955d62 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -426,6 +426,24 @@ static struct {
 	{ MAC_10HD,     SPEED_10,     DUPLEX_HALF },
 };
 
+/**
+ * phylink_limit_mac_speed - limit the phylink_config to a maximum speed
+ * @config: pointer to a &struct phylink_config
+ * @max_speed: maximum speed
+ *
+ * Mask off MAC capabilities for speeds higher than the @max_speed parameter.
+ * Any further motifications of config.mac_capabilities will override this.
+ */
+void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(phylink_caps_params) &&
+		    phylink_caps_params[i].speed > max_speed; i++)
+		config->mac_capabilities &= ~phylink_caps_params[i].mask;
+}
+EXPORT_SYMBOL_GPL(phylink_limit_mac_speed);
+
 /**
  * phylink_cap_from_speed_duplex - Get mac capability from speed/duplex
  * @speed: the speed to search for
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 789c516c6b4a..7d07f8736431 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -223,6 +223,8 @@ struct phylink_config {
 	unsigned long mac_capabilities;
 };
 
+void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed);
+
 /**
  * struct phylink_mac_ops - MAC operations structure.
  * @validate: Validate and update the link configuration.
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Feiyang Chen <chenfeiyang@loongson.cn>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: [PATCH net-next 01/10] net: phylink: add phylink_limit_mac_speed()
Date: Thu, 24 Aug 2023 14:37:53 +0100	[thread overview]
Message-ID: <E1qZAX3-005pTi-K1@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZOddFH22PWmOmbT5@shell.armlinux.org.uk>

Add a function which can be used to limit the phylink MAC capabilities
to an upper speed limit.

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

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 160bce608c34..0d7354955d62 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -426,6 +426,24 @@ static struct {
 	{ MAC_10HD,     SPEED_10,     DUPLEX_HALF },
 };
 
+/**
+ * phylink_limit_mac_speed - limit the phylink_config to a maximum speed
+ * @config: pointer to a &struct phylink_config
+ * @max_speed: maximum speed
+ *
+ * Mask off MAC capabilities for speeds higher than the @max_speed parameter.
+ * Any further motifications of config.mac_capabilities will override this.
+ */
+void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(phylink_caps_params) &&
+		    phylink_caps_params[i].speed > max_speed; i++)
+		config->mac_capabilities &= ~phylink_caps_params[i].mask;
+}
+EXPORT_SYMBOL_GPL(phylink_limit_mac_speed);
+
 /**
  * phylink_cap_from_speed_duplex - Get mac capability from speed/duplex
  * @speed: the speed to search for
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 789c516c6b4a..7d07f8736431 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -223,6 +223,8 @@ struct phylink_config {
 	unsigned long mac_capabilities;
 };
 
+void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed);
+
 /**
  * struct phylink_mac_ops - MAC operations structure.
  * @validate: Validate and update the link configuration.
-- 
2.30.2


  reply	other threads:[~2023-08-24 13:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 13:37 [PATCH net-next v2 0/10] stmmac cleanups Russell King (Oracle)
2023-08-24 13:37 ` Russell King (Oracle)
2023-08-24 13:37 ` Russell King (Oracle) [this message]
2023-08-24 13:37   ` [PATCH net-next 01/10] net: phylink: add phylink_limit_mac_speed() Russell King (Oracle)
2023-08-24 13:37 ` [PATCH net-next 02/10] net: stmmac: convert plat->phylink_node to fwnode Russell King (Oracle)
2023-08-24 13:37   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 03/10] net: stmmac: clean up passing fwnode to phylink Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 04/10] net: stmmac: use "mdio_bus_data" local variable Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 05/10] net: stmmac: use phylink_limit_mac_speed() Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 06/10] net: stmmac: provide stmmac_mac_phylink_get_caps() Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 07/10] net: stmmac: move gmac4 specific phylink capabilities to gmac4 Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 08/10] net: stmmac: move xgmac specific phylink caps to dwxgmac2 core Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-26 13:32   ` Serge Semin
2023-08-26 13:32     ` Serge Semin
2023-08-26 14:51     ` Russell King (Oracle)
2023-08-26 14:51       ` Russell King (Oracle)
2023-08-26 19:01       ` Serge Semin
2023-08-26 19:01         ` Serge Semin
2023-08-26 13:36   ` Serge Semin
2023-08-26 13:36     ` Serge Semin
2023-08-26 14:53     ` Russell King (Oracle)
2023-08-26 14:53       ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 09/10] net: stmmac: move priv->phylink_config.mac_managed_pm Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-24 13:38 ` [PATCH net-next 10/10] net: stmmac: convert half-duplex support to positive logic Russell King (Oracle)
2023-08-24 13:38   ` Russell King (Oracle)
2023-08-26  2:00 ` [PATCH net-next v2 0/10] stmmac cleanups patchwork-bot+netdevbpf
2023-08-26  2:00   ` patchwork-bot+netdevbpf

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=E1qZAX3-005pTi-K1@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=chenfeiyang@loongson.cn \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --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 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.