All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH REPOST net-next 0/2] net: mii clause 37 helpers
@ 2020-03-14 10:09 Russell King - ARM Linux admin
  2020-03-14 10:09 ` [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Russell King - ARM Linux admin @ 2020-03-14 10:09 UTC (permalink / raw
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit; +Cc: David S. Miller, netdev

This is a re-post of two patches that are common to two series that
I've sent in recent weeks; I'm re-posting them separately in the hope
that they can be merged.  No changes from either of the previous
postings.

These patches:

1. convert the existing (unused) mii_lpa_to_ethtool_lpa_x() function
   to a linkmode variant.

2. add a helper for clause 37 advertisements, supporting both the
   1000baseX and defacto 2500baseX variants. Note that ethtool does
   not support half duplex for either of these, and we make no effort
   to do so.

 include/linux/mii.h | 57 ++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 18 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant
  2020-03-14 10:09 [PATCH REPOST net-next 0/2] net: mii clause 37 helpers Russell King - ARM Linux admin
@ 2020-03-14 10:09 ` Russell King
  2020-03-14 18:30   ` Andrew Lunn
  2020-03-14 10:09 ` [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
  2020-03-16  0:10 ` [PATCH REPOST net-next 0/2] net: mii clause 37 helpers David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Russell King @ 2020-03-14 10:09 UTC (permalink / raw
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit; +Cc: David S. Miller, netdev

Add a LPA to linkmode decoder for 1000BASE-X protocols; this decoder
only provides the modify semantics similar to other such decoders.
This replaces the unused mii_lpa_to_ethtool_lpa_x() helper.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 include/linux/mii.h | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/include/linux/mii.h b/include/linux/mii.h
index 18c6208f56fc..309de4a3e6e7 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -354,24 +354,6 @@ static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
 	return result;
 }
 
-/**
- * mii_lpa_to_ethtool_lpa_x
- * @adv: value of the MII_LPA register
- *
- * A small helper function that translates MII_LPA
- * bits, when in 1000Base-X mode, to ethtool
- * LP advertisement settings.
- */
-static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
-{
-	u32 result = 0;
-
-	if (lpa & LPA_LPACK)
-		result |= ADVERTISED_Autoneg;
-
-	return result | mii_adv_to_ethtool_adv_x(lpa);
-}
-
 /**
  * mii_lpa_mod_linkmode_adv_sgmii
  * @lp_advertising: pointer to destination link mode.
@@ -535,6 +517,25 @@ static inline u32 linkmode_adv_to_lcl_adv_t(unsigned long *advertising)
 	return lcl_adv;
 }
 
+/**
+ * mii_lpa_mod_linkmode_x - decode the link partner's config_reg to linkmodes
+ * @linkmodes: link modes array
+ * @lpa: config_reg word from link partner
+ * @fd_bit: link mode for 1000XFULL bit
+ */
+static inline void mii_lpa_mod_linkmode_x(unsigned long *linkmodes, u16 lpa,
+					 int fd_bit)
+{
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, linkmodes,
+			 lpa & LPA_LPACK);
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes,
+			 lpa & LPA_1000XPAUSE);
+	linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, linkmodes,
+			 lpa & LPA_1000XPAUSE_ASYM);
+	linkmode_mod_bit(fd_bit, linkmodes,
+			 lpa & LPA_1000XFULL);
+}
+
 /**
  * mii_advertise_flowctrl - get flow control advertisement flags
  * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x()
  2020-03-14 10:09 [PATCH REPOST net-next 0/2] net: mii clause 37 helpers Russell King - ARM Linux admin
  2020-03-14 10:09 ` [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
@ 2020-03-14 10:09 ` Russell King
  2020-03-14 18:31   ` Andrew Lunn
  2020-03-16  0:10 ` [PATCH REPOST net-next 0/2] net: mii clause 37 helpers David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Russell King @ 2020-03-14 10:09 UTC (permalink / raw
  To: Andrew Lunn, Florian Fainelli, Heiner Kallweit; +Cc: David S. Miller, netdev

Add a helper to convert a linkmode advertisement to a clause 37
advertisement value for 1000base-x and 2500base-x.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 include/linux/mii.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/linux/mii.h b/include/linux/mii.h
index 309de4a3e6e7..219b93cad1dd 100644
--- a/include/linux/mii.h
+++ b/include/linux/mii.h
@@ -536,6 +536,26 @@ static inline void mii_lpa_mod_linkmode_x(unsigned long *linkmodes, u16 lpa,
 			 lpa & LPA_1000XFULL);
 }
 
+/**
+ * linkmode_adv_to_mii_adv_x - encode a linkmode to config_reg
+ * @linkmodes: linkmodes
+ * @fd_bit: full duplex bit
+ */
+static inline u16 linkmode_adv_to_mii_adv_x(const unsigned long *linkmodes,
+					    int fd_bit)
+{
+	u16 adv = 0;
+
+	if (linkmode_test_bit(fd_bit, linkmodes))
+		adv |= ADVERTISE_1000XFULL;
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, linkmodes))
+		adv |= ADVERTISE_1000XPAUSE;
+	if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, linkmodes))
+		adv |= ADVERTISE_1000XPSE_ASYM;
+
+	return adv;
+}
+
 /**
  * mii_advertise_flowctrl - get flow control advertisement flags
  * @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant
  2020-03-14 10:09 ` [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
@ 2020-03-14 18:30   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-03-14 18:30 UTC (permalink / raw
  To: Russell King; +Cc: Florian Fainelli, Heiner Kallweit, David S. Miller, netdev

On Sat, Mar 14, 2020 at 10:09:53AM +0000, Russell King wrote:
> Add a LPA to linkmode decoder for 1000BASE-X protocols; this decoder
> only provides the modify semantics similar to other such decoders.
> This replaces the unused mii_lpa_to_ethtool_lpa_x() helper.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x()
  2020-03-14 10:09 ` [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
@ 2020-03-14 18:31   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2020-03-14 18:31 UTC (permalink / raw
  To: Russell King; +Cc: Florian Fainelli, Heiner Kallweit, David S. Miller, netdev

On Sat, Mar 14, 2020 at 10:09:58AM +0000, Russell King wrote:
> Add a helper to convert a linkmode advertisement to a clause 37
> advertisement value for 1000base-x and 2500base-x.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH REPOST net-next 0/2] net: mii clause 37 helpers
  2020-03-14 10:09 [PATCH REPOST net-next 0/2] net: mii clause 37 helpers Russell King - ARM Linux admin
  2020-03-14 10:09 ` [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
  2020-03-14 10:09 ` [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
@ 2020-03-16  0:10 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2020-03-16  0:10 UTC (permalink / raw
  To: linux; +Cc: andrew, f.fainelli, hkallweit1, netdev

From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Date: Sat, 14 Mar 2020 10:09:16 +0000

> This is a re-post of two patches that are common to two series that
> I've sent in recent weeks; I'm re-posting them separately in the hope
> that they can be merged.  No changes from either of the previous
> postings.
> 
> These patches:
> 
> 1. convert the existing (unused) mii_lpa_to_ethtool_lpa_x() function
>    to a linkmode variant.
> 
> 2. add a helper for clause 37 advertisements, supporting both the
>    1000baseX and defacto 2500baseX variants. Note that ethtool does
>    not support half duplex for either of these, and we make no effort
>    to do so.

Series applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-16  0:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-14 10:09 [PATCH REPOST net-next 0/2] net: mii clause 37 helpers Russell King - ARM Linux admin
2020-03-14 10:09 ` [PATCH net-next 1/2] net: mii: convert mii_lpa_to_ethtool_lpa_x() to linkmode variant Russell King
2020-03-14 18:30   ` Andrew Lunn
2020-03-14 10:09 ` [PATCH net-next 2/2] net: mii: add linkmode_adv_to_mii_adv_x() Russell King
2020-03-14 18:31   ` Andrew Lunn
2020-03-16  0:10 ` [PATCH REPOST net-next 0/2] net: mii clause 37 helpers David Miller

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.