Re: [PATCH net-next v3 2/5] net: rnpgbe: Report link settings through ethtool
From: Yibo Dong
Date: Wed Nov 25 2026 - 02:10:39 EST
On Wed, Nov 25, 2026 at 06:36:01AM +0000, netdev-bot+sashiko@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 2 · Low: 2
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] rnpgbe_setup_default_link() builds the PHY_LINK_SET
> advertisement as hw->link_config.supported & RNPGBE_DEFAULT_ADV, where…
> - [Medium] rnpgbe_add_adapter() now calls rnpgbe_init_link_config(),
> which sends GET_LANE_STATUS (0x0610) through mucse_mbx_get_link() and…
> - [Low] The commit message leaves out some changes in the patch.
> - [Low] ST_STATUS_MDIX_MASK is GENMASK(11, 10), a 2-bit field that can
> hold 0-3.
>
> > diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c
> > index dcc8233e024e1..3a2f62f0630da 100644
> > --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c
> > +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c
> > @@ -64,12 +64,42 @@ int rnpgbe_reset_hw(struct mucse_hw *hw)
> > * rnpgbe_setup_default_link - Configure the default link settings
> > * @hw: hardware information structure
> > *
> > + * The default configuration relies on GET_LANE_STATUS reporting at least
> > + * one mode in RNPGBE_DEFAULT_ADV for TP ports and RNPGBE_FW_ADV_1000_FULL
> > + * for fibre and backplane ports. TP ports use the supported subset of the
> > + * default mask for autonegotiation. Fibre and backplane use fixed 1 Gb/s
> > + * full duplex.
> > + *
> > * Return: 0 on success, negative errno on failure
> > **/
> > int rnpgbe_setup_default_link(struct mucse_hw *hw)
> > {
> > - return mucse_mbx_set_link(hw, RNPGBE_DEFAULT_ADV, true, 0, 0,
> > - ETH_TP_MDI_AUTO);
> > + u32 advertising = hw->link_config.supported & RNPGBE_DEFAULT_ADV;
> > + bool autoneg = hw->link_config.status & MUCSE_LINK_TP;
> > + u8 duplex = DUPLEX_UNKNOWN;
> > + u32 speed = SPEED_UNKNOWN;
> > + int err;
> > +
> > + if (!autoneg) {
> > + advertising &= RNPGBE_FW_ADV_1000_FULL;
> > + speed = SPEED_1000;
> > + duplex = DUPLEX_FULL;
> > + }
> > +
> > + err = mucse_mbx_set_link(hw, advertising, autoneg,
> > + autoneg ? 0 : speed, autoneg ? 0 : duplex,
> > + ETH_TP_MDI_AUTO);
>
> [Severity: Medium]
> What happens if advertising is 0 at this point?
>
> The kernel-doc above states the assumption, but nothing checks it. Take
> a TP port where firmware reports none of the RNPGBE_DEFAULT_ADV modes.
> Autoneg is requested with advertising == 0. On ACK,
> MUCSE_LINK_AUTONEG and advertising = 0 are cached, and probe still
> succeeds.
>
> Could the link then stay down forever, with nothing logged?
>
> Now take a fibre or backplane port whose supported mask lacks
> RNPGBE_FW_ADV_1000_FULL. 1000/Full is still forced and cached. Then in
> rnpgbe_get_link_ksettings():
>
> if (supported & RNPGBE_FW_ADV_1000_FULL)
> linkmode_set_bit(mode, cmd->link_modes.supported);
> ...
> if (cmd->base.autoneg == AUTONEG_DISABLE) {
> cmd->base.speed = hw->link_config.speed;
> cmd->base.duplex = hw->link_config.duplex;
> }
>
> Would ethtool then show speed 1000 without listing 1000baseX or
> 1000baseKX as a supported mode?
>
> The old code always advertised the full RNPGBE_DEFAULT_ADV mask,
> whatever firmware reported. The later patch "net: rnpgbe: Support copper
> link configuration" rejects an empty autoneg advertisement in
> set_link_ksettings. This default path still has no such check.
>
> [ ... ]
>
The firmware interface guarantees at least one usable TP mode, or
1 Gb/s full duplex for fibre and backplane ports, as documented above
the function.
An empty usable capability mask would violate this firmware contract.
Given that guarantee, I think it is reasonable for the driver to rely
on it without adding an explicit check here.
> > diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
> > index 46981ef2542ad..31871b244882d 100644
> > --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
> > +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c
>
> [ ... ]
>
> > @@ -258,6 +260,11 @@ static int rnpgbe_add_adapter(struct pci_dev *pdev,
> > dev_err(&pdev->dev, "Hw reset failed %d\n", err);
> > goto err_powerdown;
> > }
> > + err = rnpgbe_init_link_config(hw);
> > + if (err) {
> > + dev_err(&pdev->dev, "Get link capabilities failed %d\n", err);
> > + goto err_powerdown;
> > + }
>
> [Severity: Medium]
> Will the device still probe if its firmware doesn't implement
> GET_LANE_STATUS (0x0610), or rejects it?
>
> The call chain is:
>
> rnpgbe_init_link_config()
> mucse_mbx_get_link()
> mucse_fw_send_cmd_wait_resp()
>
> This returns -ETIMEDOUT if no reply with a matching opcode arrives. It
> returns -EIO if the reply has a non-zero error_code. Either error jumps
> to err_powerdown, so no netdev is registered.
>
> There is no fallback to the old defaults, and the commit message doesn't
> give a minimum firmware version.
>
> Does every firmware version this driver binds to support
> GET_LANE_STATUS?
>
Yes. GET_LANE_STATUS is part of the baseline firmware interface and is
supported by all firmware versions for these devices.
The previous driver sent a common default advertisement mask without
first querying the port capabilities. Firmware handles settings that do
not apply to the port. For example, on fibre ports it ignores the
autonegotiation request and the 10/100 Mb/s advertisement bits, and uses
fixed 1 Gb/s full duplex.
This patch queries GET_LANE_STATUS to obtain the actual port type and
capabilities, select the corresponding defaults explicitly, and report
them through ethtool. The command is supported by all firmware versions
for these devices; its absence from the previous driver was not due to
a firmware compatibility limitation.
> [ ... ]
>
> > diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
> > index 4a18937927514..469818b83d70f 100644
> > --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
> > +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
>
> [ ... ]
>
> > @@ -435,6 +462,8 @@ static void mucse_mbx_fw_req_handler(struct mucse_hw *hw,
> >
> > hw->speed = le16_to_cpu(req->link_stat.st.speed);
> > hw->duplex = req->link_stat.st.flags & DUPLEX_BIT;
> > + hw->mdix = FIELD_GET(ST_STATUS_MDIX_MASK,
> > + le16_to_cpu(req->link_stat.st.status));
>
> [Severity: Low]
> ST_STATUS_MDIX_MASK is GENMASK(11, 10), so the field can hold 0 to 3.
> The comment in rnpgbe_mbx_fw.h lists only three values:
>
> /* MDI-X status uses ETH_TP_MDI_* encoding: 0 on link down, 1 MDI, 2 MDI-X. */
>
> The raw value is stored here without a range check.
> rnpgbe_get_link_ksettings() then copies it into cmd->base.eth_tp_mdix:
>
> if (status & MUCSE_LINK_TP)
> cmd->base.eth_tp_mdix = hw->mdix;
>
> If firmware ever reported 3, ETH_TP_MDI_AUTO would show up in the
> resolved MDI-X status field. That value is only meant for
> eth_tp_mdix_ctrl.
>
> Should values other than ETH_TP_MDI and ETH_TP_MDI_X be reported as
> ETH_TP_MDI_INVALID instead?
The direct assignment therefore follows the firmware protocol.
0 when the link is down, 1 for MDI, and 2 for MDI-X. It does not Report
3 as a resolved MDI-X status.
>
> [ ... ]
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/6C54E9FB2E95869E%2B20261124060436.410989-1-dong100%40mucse.com
>