From: Alexander H Duyck <alexander.duyck@gmail.com>
To: mike.marciniszyn@gmail.com,
Alexander Duyck <alexanderduyck@fb.com>,
Jakub Kicinski <kuba@kernel.org>,
kernel-team@meta.com, Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>, Kees Cook <kees@kernel.org>,
Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: pcs: xpcs: Add hooks for xpcs configuration of rsfec
Date: Fri, 15 May 2026 09:52:49 -0700 [thread overview]
Message-ID: <922f2ade4ee5f10e5645e3b1a194d024b88f0d76.camel@gmail.com> (raw)
In-Reply-To: <20260511182604.1338-2-mike.marciniszyn@gmail.com>
On Mon, 2026-05-11 at 14:26 -0400, mike.marciniszyn@gmail.com wrote:
> From: "Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>
>
> The DW PCS IP data sheet calls out the need to populate
> these vendor registers when operating at speeds above 10Gbps.
> This change enables the correct FEC settings to enable RS-FEC
> encoding on the link which is the standard used for most links
> at these higher speeds.
>
> Note that the overwriting of the MDIO_PMA_RSFEC_CTRL register
> is intentional and consistent DW PCS IP requirements.
>
> Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
> Signed-off-by: Mike Marciniszyn (Meta) <mike.marciniszyn@gmail.com>
> ---
> v2:
> - Allow mdiobus probing for addr 0 and addr 1
> - Add xpcs_find* helpers based on phy_find* to avoid hardcoded addresses
> - Remove xpcs_bus write and use mdiodev_c45_write instead
> - Address comment on use of MDIO_PMA_RSFEC_CTRL
> v1: https://lore.kernel.org/all/20260506190904.4029-2-mike.marciniszyn@gmail.com/
>
> drivers/net/ethernet/meta/fbnic/fbnmdiodev_c45_writeic_mdio.c | 3 +-
> drivers/net/pcs/pcs-xpcs.c | 105 +++++++++++++++++++
> drivers/net/pcs/pcs-xpcs.h | 6 ++
> include/uapi/linux/mdio.h | 3 +
> 4 files changed, 115 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mdio.c b/drivers/net/ethernet/meta/fbnic/fbnic_mdio.c
> index fe3a4ce88413..e29534dd1e0c 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_mdio.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_mdio.c
> @@ -263,8 +263,7 @@ int fbnic_mdiobus_create(struct fbnic_dev *fbd)
> bus->read_c45 = &fbnic_mdio_read_c45;
> bus->write_c45 = &fbnic_mdio_write_c45;
>
> - /* Disable PHY auto probing. We will add PCS manually */
> - bus->phy_mask = ~0;
> + bus->phy_mask = GENMASK(31, 2);
>
> bus->parent = fbd->dev;
> bus->priv = fbd;
Why are you messing with the PHY autoprobing mask? That doesn't make
sense to add to this patch. The side effect is that it is going to
expose a phydev that won't be used as we access the PMD direcly.
[...]
> +static struct mdio_device *xpcs_find_first_mdev(struct dw_xpcs *xpcs)
> +{
> + struct phy_device *p = phy_find_first(xpcs->mdiodev->bus);
> +
> + if (!p)
> + return NULL;
> + return &p->mdio;
> +}
> +
> +static struct mdio_device *
> +xpcs_find_next_mdev(struct dw_xpcs *xpcs, struct mdio_device *mdev)
> +{
> + struct phy_device *p = container_of(mdev, struct phy_device, mdio), *n;
> +
> + n = phy_find_next(xpcs->mdiodev->bus, p);
> + if (!n)
> + return NULL;
> + return &n->mdio;
> +}
> +
Okay, the use of these functions explains the issue. You shouldn't be
using phy_find_next. You know the bus will be located on mdio.addr + 1.
You should not need to have a phy_device assigned for each of the PMA
devices.
The general idea is you have mdio_devices you shouldn't be trying to
use the phy_device functions in the PCS driver.
> +static int
> +xpcs_config_rsfec_pma(struct dw_xpcs *xpcs, const struct pma_pcs_values *v)
> +{
> + struct mdio_device *mdev;
> + int ret = 0, i, pma_mmd;
> +
> + pma_mmd = xpcs_get_pma_mmd(xpcs);
> + if (pma_mmd < 1)
> + return pma_mmd;
> +
> + mdev = xpcs_find_first_mdev(xpcs);
> + if (!mdev)
> + return -ENODEV;
> +
There shouldn't be any need for a special for this. You already have
the capabilities to write to the devices you need to write to.
The only things you need to change would be to access the nearest PMA
to the PCS as that is the one that holds the RSFEC configuration. For
that you just need to know what devices are already enabled and you can
access them.
> + for (i = 0; mdev && ret >= 0 && i < v->lanes;
> + i++, mdev = xpcs_find_next_mdev(xpcs, mdev)) {
> + ret = mdiodev_c45_write(mdev, pma_mmd, MDIO_PMA_RSFEC_CTRL,
> + v->rsfec_ctrl);
> + }
You don't need this "find next" logic. It is just the device on the
adjacent bus. Also I am not sure we even need the loop logic since
there are only 2 devices you have to configure as currently only 2
lanes are supported.
[...]
> diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h
> index b2541c948fc1..5219c877b2cf 100644
> --- a/include/uapi/linux/mdio.h
> +++ b/include/uapi/linux/mdio.h
> @@ -317,6 +317,9 @@
> #define MDIO_PMA_10GBR_FECABLE_ABLE 0x0001 /* FEC ability */
> #define MDIO_PMA_10GBR_FECABLE_ERRABLE 0x0002 /* FEC error indic. ability */
>
> +/* RSFEC PMA Control register */
> +#define MDIO_PMA_RSFEC_CTRL_4LANE_PMD BIT(3)
> +
> /* PMA 10GBASE-R Fast Retrain status and control register. */
> #define MDIO_PMA_10GBR_FSRT_ENABLE 0x0001 /* Fast retrain enable */
>
The AI review complaint about this bit seems to be based on an outdated
version of the IEEE specification.
This is called out in 9802.3-2022 as "Four lane PMD indication" so
perhaps sashiko needs to be updated.
next prev parent reply other threads:[~2026-05-15 16:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 18:26 [PATCH net-next v2 0/2] second series for xpcs based rsfec configuration mike.marciniszyn
2026-05-11 18:26 ` [PATCH net-next v2 1/2] net: pcs: xpcs: Add hooks for xpcs configuration of rsfec mike.marciniszyn
2026-05-15 16:52 ` Alexander H Duyck [this message]
2026-05-11 18:26 ` [PATCH net-next v2 2/2] net: pcs: xpcs: Add handling for 4 channel rsfec device mike.marciniszyn
2026-05-15 17:12 ` Alexander H Duyck
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=922f2ade4ee5f10e5645e3b1a194d024b88f0d76.camel@gmail.com \
--to=alexander.duyck@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mike.marciniszyn@gmail.com \
--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 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.