netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>
Cc: "Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Marek Behún" <kabel@kernel.org>,
	netdev@vger.kernel.org, "Paolo Abeni" <pabeni@redhat.com>
Subject: [PATCH net-next 06/10] net: phylink: split out per-interface validation
Date: Fri, 24 Nov 2023 12:28:19 +0000	[thread overview]
Message-ID: <E1r6VIB-00DDLr-7g@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <ZWCWn+uNkVLPaQhn@shell.armlinux.org.uk>

Split out the internals of phylink_validate_mask() to make the code
easier to read.

Tested-by: Luo Jie <quic_luoj@quicinc.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 42 ++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 12 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index c276f9482f78..11dd743141d5 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -689,26 +689,44 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
 	return phylink_is_empty_linkmode(supported) ? -EINVAL : 0;
 }
 
+static void phylink_validate_one(struct phylink *pl,
+				 const unsigned long *supported,
+				 const struct phylink_link_state *state,
+				 phy_interface_t interface,
+				 unsigned long *accum_supported,
+				 unsigned long *accum_advertising)
+{
+	__ETHTOOL_DECLARE_LINK_MODE_MASK(tmp_supported);
+	struct phylink_link_state tmp_state;
+
+	linkmode_copy(tmp_supported, supported);
+
+	tmp_state = *state;
+	tmp_state.interface = interface;
+
+	if (!phylink_validate_mac_and_pcs(pl, tmp_supported, &tmp_state)) {
+		phylink_dbg(pl, " interface %u (%s) rate match %s supports %*pbl\n",
+			    interface, phy_modes(interface),
+			    phy_rate_matching_to_str(tmp_state.rate_matching),
+			    __ETHTOOL_LINK_MODE_MASK_NBITS, tmp_supported);
+
+		linkmode_or(accum_supported, accum_supported, tmp_supported);
+		linkmode_or(accum_advertising, accum_advertising,
+			    tmp_state.advertising);
+	}
+}
+
 static int phylink_validate_mask(struct phylink *pl, unsigned long *supported,
 				 struct phylink_link_state *state,
 				 const unsigned long *interfaces)
 {
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(all_adv) = { 0, };
 	__ETHTOOL_DECLARE_LINK_MODE_MASK(all_s) = { 0, };
-	__ETHTOOL_DECLARE_LINK_MODE_MASK(s);
-	struct phylink_link_state t;
 	int interface;
 
-	for_each_set_bit(interface, interfaces, PHY_INTERFACE_MODE_MAX) {
-		linkmode_copy(s, supported);
-
-		t = *state;
-		t.interface = interface;
-		if (!phylink_validate_mac_and_pcs(pl, s, &t)) {
-			linkmode_or(all_s, all_s, s);
-			linkmode_or(all_adv, all_adv, t.advertising);
-		}
-	}
+	for_each_set_bit(interface, interfaces, PHY_INTERFACE_MODE_MAX)
+		phylink_validate_one(pl, supported, state, interface,
+				     all_s, all_adv);
 
 	linkmode_copy(supported, all_s);
 	linkmode_copy(state->advertising, all_adv);
-- 
2.30.2


  parent reply	other threads:[~2023-11-24 12:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 12:27 [PATCH net-next 00/10] net: phylink: improve PHY validation Russell King (Oracle)
2023-11-24 12:27 ` [PATCH net-next 01/10] net: phy: add possible interfaces Russell King (Oracle)
2023-11-25 17:06   ` Andrew Lunn
2023-11-24 12:27 ` [PATCH net-next 02/10] net: phy: marvell10g: table driven mactype decode Russell King (Oracle)
2023-11-24 12:28 ` [PATCH net-next 03/10] net: phy: marvell10g: fill in possible_interfaces Russell King (Oracle)
2023-11-25 17:09   ` Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 04/10] net: phy: bcm84881: " Russell King (Oracle)
2023-11-25 17:10   ` Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 05/10] net: phy: aquantia: fill in possible_interfaces for AQR113C Russell King (Oracle)
2023-11-25 17:11   ` Andrew Lunn
2023-11-24 12:28 ` Russell King (Oracle) [this message]
2023-11-25 17:12   ` [PATCH net-next 06/10] net: phylink: split out per-interface validation Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 07/10] net: phylink: pass PHY into phylink_validate_one() Russell King (Oracle)
2023-11-25 17:13   ` Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 08/10] net: phylink: pass PHY into phylink_validate_mask() Russell King (Oracle)
2023-11-25 17:13   ` Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 09/10] net: phylink: split out PHY validation from phylink_bringup_phy() Russell King (Oracle)
2023-11-25 17:15   ` Andrew Lunn
2023-11-24 12:28 ` [PATCH net-next 10/10] net: phylink: use the PHY's possible_interfaces if populated Russell King (Oracle)
2023-11-25 17:18   ` Andrew Lunn
2023-11-28  2:08 ` [PATCH net-next 00/10] net: phylink: improve PHY validation Jakub Kicinski
2023-11-28  2:20 ` 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=E1r6VIB-00DDLr-7g@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=hkallweit1@gmail.com \
    --cc=kabel@kernel.org \
    --cc=kuba@kernel.org \
    --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 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).