๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Tue, 17 Nov 2026 23:10
Re: [PATCH net-next v4 4/6] ionic: map the FEC type through a helper in ionic_get_fecparam()
#18166
Author: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 23:10
89 lines
11086 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In drivers/net/ethernet/pensando/ionic/ionic_ethtool.c, the
  refactor changes ionic_get_fecparam() so that it reads the device-โ€ฆ

--

ionic: map the FEC type through a helper in ionic_get_fecparam()

This patch moves the mapping from config.fec_type to the ethtool FEC
values out of ionic_get_fecparam() and into a new helper,
ionic_fec_type_to_ethtool(). The helper is then called once for
fec->active_fec and once for fec->fec. The commit message says there
is no functional change.

> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> index 13b5874fe5ad4..8f0f1585116bc 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c

[ ... ]

> +static int ionic_get_fecparam(struct net_device *netdev,
> +			      struct ethtool_fecparam *fec)
> +{
> +	struct ionic_port_info *port_info;
> +	struct ionic_lif *lif;
> +
> +	lif = netdev_priv(netdev);
> +	port_info = lif->ionic->idev.port_info;
> +
> +	fec->active_fec = ionic_fec_type_to_ethtool(port_info->config.fec_type);
> +	fec->fec = ionic_fec_type_to_ethtool(port_info->config.fec_type);

[Severity: Low]
Could active_fec and fec end up built from two different values of
port_info->config.fec_type here?

The old code loaded config.fec_type once, as the switch expression, and
set both fields from that one value. The new code does two separate
plain loads, one per ionic_fec_type_to_ethtool() call. There is no
local snapshot, no READ_ONCE() and no lock.

port_info is coherent DMA memory shared with the device:

ionic_main.c:ionic_port_init() {
    ...
	idev->port_info = dma_alloc_coherent(ionic->dev,
				     idev->port_info_sz,
				     &idev->port_info_pa,
				     GFP_KERNEL);
    ...
}

Its address is passed to firmware in ionic_dev_cmd_port_init():

	.port_init.info_pa = cpu_to_le64(idev->port_info_pa),

>From that point, firmware writes config.fec_type. RTNL does not
serialize those writes.

If firmware updates the field between the two loads, ethtool --show-fec
could report a configured/active pair that never existed together. The
compiler cannot merge the two loads either: with -fno-strict-aliasing,
the u32 store to fec->active_fec may alias the u8 source.

Given this, is "No functional change" in the commit message quite
accurate?

The later patch in this series, "ionic: report the operational FEC mode
from ethtool --show-fec", rewrites these lines but keeps the double
read. When autoneg is off, ionic_active_fec_type() returns
READ_ONCE(port_info->config.fec_type), and ionic_get_fecparam() then
reads READ_ONCE(port_info->config.fec_type) again for fec->fec.

Would it be simpler to read config.fec_type once into a local u8 and
use that for both fields?

>  
>  	return 0;
>  }

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-ionic-get-fec-stats-v4-0-d25cae9f1e87%40amd.com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads