linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>
Cc: Alexandru Marginean <alexandru.marginean@nxp.com>,
	Paolo Abeni <pabeni@redhat.com>,
	"David S . Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH v2 03/11] net: phylink: Export phylink_caps_to_linkmodes
Date: Tue, 19 Jul 2022 19:49:53 -0400	[thread overview]
Message-ID: <20220719235002.1944800-4-sean.anderson@seco.com> (raw)
In-Reply-To: <20220719235002.1944800-1-sean.anderson@seco.com>

This function is convenient for MAC drivers. They can use it to add or
remove particular link modes based on capabilities (such as if half
duplex is not supported for a particular interface mode).

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

(no changes since v1)

 drivers/net/phy/phylink.c | 12 ++++++++++--
 include/linux/phylink.h   |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index b08716fe22c1..51e66320526f 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -155,8 +155,15 @@ static const char *phylink_an_mode_str(unsigned int mode)
 	return mode < ARRAY_SIZE(modestr) ? modestr[mode] : "unknown";
 }
 
-static void phylink_caps_to_linkmodes(unsigned long *linkmodes,
-				      unsigned long caps)
+/**
+ * phylink_caps_to_linkmodes() - Convert capabilities to ethtool link modes
+ * @linkmodes: ethtool linkmode mask (must be already initialised)
+ * @caps: bitmask of MAC capabilities
+ *
+ * Set all possible pause, speed and duplex linkmodes in @linkmodes that are
+ * supported by the @caps. @linkmodes must have been initialised previously.
+ */
+void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps)
 {
 	if (caps & MAC_SYM_PAUSE)
 		__set_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes);
@@ -295,6 +302,7 @@ static void phylink_caps_to_linkmodes(unsigned long *linkmodes,
 		__set_bit(ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT, linkmodes);
 	}
 }
+EXPORT_SYMBOL_GPL(phylink_caps_to_linkmodes);
 
 /**
  * phylink_get_linkmodes() - get acceptable link modes
diff --git a/include/linux/phylink.h b/include/linux/phylink.h
index 6d06896fc20d..6463bd64eaa4 100644
--- a/include/linux/phylink.h
+++ b/include/linux/phylink.h
@@ -518,6 +518,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode,
 		 phy_interface_t interface, int speed, int duplex);
 #endif
 
+void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps);
 void phylink_get_linkmodes(unsigned long *linkmodes, phy_interface_t interface,
 			   unsigned long mac_capabilities);
 void phylink_generic_validate(struct phylink_config *config,
-- 
2.35.1.1320.gc452695387.dirty


  parent reply	other threads:[~2022-07-19 23:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19 23:49 [PATCH v2 00/11] net: phy: Add support for rate adaptation Sean Anderson
2022-07-19 23:49 ` [PATCH v2 01/11] net: dpaa: Fix <1G ethernet on LS1046ARDB Sean Anderson
2022-07-21 12:34   ` Camelia Alexandra Groza
2022-07-19 23:49 ` [PATCH v2 02/11] net: phy: Add 1000BASE-KX interface mode Sean Anderson
2022-07-19 23:49 ` Sean Anderson [this message]
2022-07-19 23:49 ` [PATCH v2 04/11] net: phylink: Generate caps and convert to linkmodes separately Sean Anderson
2022-07-19 23:49 ` [PATCH v2 05/11] net: phy: Add support for rate adaptation Sean Anderson
2022-07-19 23:49 ` [PATCH v2 06/11] net: phylink: Support differing link/interface speed/duplex Sean Anderson
2022-07-20  6:43   ` Russell King (Oracle)
2022-07-21 16:15     ` Sean Anderson
2022-07-21 16:40       ` Andrew Lunn
2022-07-19 23:49 ` [PATCH v2 07/11] net: phylink: Adjust link settings based on rate adaptation Sean Anderson
2022-07-20  6:50   ` Russell King (Oracle)
2022-07-20 18:32     ` Russell King (Oracle)
2022-07-21 21:48       ` Sean Anderson
2022-07-22  8:45         ` Russell King (Oracle)
2022-07-21 16:24     ` Sean Anderson
2022-07-20  9:08   ` kernel test robot
2022-07-20  9:28   ` kernel test robot
2022-07-19 23:49 ` [PATCH v2 08/11] net: phylink: Adjust advertisement " Sean Anderson
2022-07-20  7:08   ` Russell King (Oracle)
2022-07-21 16:55     ` Sean Anderson
2022-07-21 18:04       ` Russell King (Oracle)
2022-07-21 18:36         ` Andrew Lunn
2022-07-21 19:02           ` Dave Taht
2022-07-21 19:24           ` Sean Anderson
2022-07-21 21:06           ` Russell King (Oracle)
2022-07-19 23:49 ` [PATCH v2 09/11] [RFC] net: phylink: Add support for CRS-based " Sean Anderson
2022-07-19 23:50 ` [PATCH v2 10/11] net: phy: aquantia: Add some additional phy interfaces Sean Anderson
2022-07-20 11:35   ` Russell King (Oracle)
2022-07-21 17:15     ` Sean Anderson
2022-07-19 23:50 ` [PATCH v2 11/11] net: phy: aquantia: Add support for rate adaptation Sean Anderson
2022-07-20 12:03 ` [PATCH v2 00/11] net: phy: " Russell King (Oracle)
2022-07-21 17:40   ` Sean Anderson

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=20220719235002.1944800-4-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --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=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).