From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: "Kamil Horák - 2N" <kamilh@axis.com>
Cc: florian.fainelli@broadcom.com,
bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch,
hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 4/4] net: phy: bcm-phy-lib: Implement BroadR-Reach link modes
Date: Wed, 19 Jun 2024 11:34:04 +0100 [thread overview]
Message-ID: <ZnK0HL+pO9/2ZMKz@shell.armlinux.org.uk> (raw)
In-Reply-To: <20240617113841.3694934-5-kamilh@axis.com>
On Mon, Jun 17, 2024 at 01:38:41PM +0200, Kamil Horák - 2N wrote:
> +int bcm_config_lre_advert(struct phy_device *phydev)
> +{
> + int err;
> + u32 adv;
> +
> + /* Only allow advertising what this PHY supports */
> + linkmode_and(phydev->advertising, phydev->advertising,
> + phydev->supported);
Isn't this already done by phy_ethtool_ksettings_set() ?
linkmode_copy(advertising, cmd->link_modes.advertising);
...
/* We make sure that we don't pass unsupported values in to the PHY */
linkmode_and(advertising, advertising, phydev->supported);
...
linkmode_copy(phydev->advertising, advertising);
> diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
> index 370e4ed45098..5e590c8f82c4 100644
> --- a/drivers/net/phy/broadcom.c
> +++ b/drivers/net/phy/broadcom.c
> @@ -5,6 +5,9 @@
> * Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
> * transceivers.
> *
> + * Broadcom BCM54810, BCM54811 BroadR-Reach transceivers.
> + *
> + *
Nit: why two blank lines?
> +static int bcm54811_read_abilities(struct phy_device *phydev)
> +{
> + static const int modes_array[] = { ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
> + ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
> + ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
> + ETHTOOL_LINK_MODE_1000baseX_Full_BIT,
> + ETHTOOL_LINK_MODE_1000baseT_Half_BIT,
> + ETHTOOL_LINK_MODE_100baseT_Full_BIT,
> + ETHTOOL_LINK_MODE_100baseT_Half_BIT,
> + ETHTOOL_LINK_MODE_10baseT_Full_BIT,
> + ETHTOOL_LINK_MODE_10baseT_Half_BIT };
Formatting...
static const int modes_array[] = {
ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
...
ETHTOOL_LINK_MODE_10baseT_Half_BIT
};
please. This avoids wrapping beyond column 80, and is to kernel coding
standards.
> + int i, val, err;
> + u8 brr_mode;
> +
> + for (i = 0; i < ARRAY_SIZE(modes_array); i++)
> + linkmode_clear_bit(modes_array[i], phydev->supported);
> +
> + err = bcm5481x_get_brrmode(phydev, &brr_mode);
> + if (err)
> + return err;
> +
> + if (brr_mode) {
> + linkmode_set_bit_array(phy_basic_ports_array,
> + ARRAY_SIZE(phy_basic_ports_array),
> + phydev->supported);
> +
> + val = phy_read(phydev, MII_BCM54XX_LRESR);
> + if (val < 0)
> + return val;
> +
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> + phydev->supported, 1);
linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->supported);
...
> + /* Ensure LRE or IEEE register set is accessed according to the brr on/off,
> + * thus set the override
> + */
> + return bcm_phy_write_exp(phydev, BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL,
> + BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_EN |
> + (on ? 0 : BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_OVERRIDE_VAL));
Needless parens, wrong formatting. Consider a local variable:
val = BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_EN;
if (!on)
val |= BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL_OVERRIDE_VAL;
return bcm_phy_write_exp(phydev,
BCM54811_EXP_BROADREACH_LRE_OVERLAY_CTL, val);
would be much nicer to read.
> + if (phydev->autoneg != AUTONEG_ENABLE) {
> + if (!phydev->autoneg_complete) {
> + /* aneg not yet done, reset all relevant bits */
> + static const int br_bits[] = { ETHTOOL_LINK_MODE_Autoneg_BIT,
> + ETHTOOL_LINK_MODE_Pause_BIT,
> + ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> + ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
> + ETHTOOL_LINK_MODE_100baseT1_Full_BIT };
More formatting issues. Maybe consider moving these out of the function?
> + for (i = 0; i < ARRAY_SIZE(br_bits); i++)
> + linkmode_clear_bit(br_bits[i], phydev->lp_advertising);
Formatting issue...
...
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
> + phydev->lp_advertising, lrelpa & LRELPA_PAUSE_ASYM);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_Pause_BIT,
> + phydev->lp_advertising, lrelpa & LRELPA_PAUSE);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_100baseT1_Full_BIT,
> + phydev->lp_advertising, lrelpa & LRELPA_100_1PAIR);
> + linkmode_mod_bit(ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT,
> + phydev->lp_advertising, lrelpa & LRELPA_10_1PAIR);
More formatting issues.
> +static int bcm54811_read_status(struct phy_device *phydev)
> +{
> + int err;
> + u8 brr_mode;
Reverse Christmas tree please.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
prev parent reply other threads:[~2024-06-19 10:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-17 11:38 [PATCH v7 0/4] net: phy: bcm5481x: add support for BroadR-Reach mode Kamil Horák - 2N
2024-06-17 11:38 ` [PATCH v7 1/4] net: phy: bcm54811: New link mode for BroadR-Reach Kamil Horák - 2N
2024-06-19 10:35 ` Florian Fainelli
2024-06-17 11:38 ` [PATCH v7 2/4] net: phy: bcm54811: Add LRE registers definitions Kamil Horák - 2N
2024-06-19 10:36 ` Florian Fainelli
2024-06-17 11:38 ` [PATCH v7 3/4] dt-bindings: ethernet-phy: add optional brr-mode flag Kamil Horák - 2N
2024-06-17 16:25 ` Conor Dooley
2024-06-19 10:37 ` Florian Fainelli
2024-06-17 11:38 ` [PATCH v7 4/4] net: phy: bcm-phy-lib: Implement BroadR-Reach link modes Kamil Horák - 2N
2024-06-17 15:17 ` Simon Horman
2024-06-19 1:05 ` Jakub Kicinski
2024-06-19 6:44 ` Ratheesh Kannoth
2024-06-19 10:34 ` Russell King (Oracle) [this message]
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=ZnK0HL+pO9/2ZMKz@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kamilh@axis.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/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).