Netdev List
 help / color / mirror / Atom feed
From: Eric Joyner <eric.joyner@amd.com>
To: <netdev@vger.kernel.org>
Cc: Brett Creeley <brett.creeley@amd.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	"Nikhil P. Rao" <nikhil.rao@amd.com>,
	Eric Joyner <eric.joyner@amd.com>,
	Eric Dumazet <edumazet@kernel.org>
Subject: [PATCH net-next v4 5/6] ionic: report the operational FEC mode from ethtool --show-fec
Date: Mon, 16 Nov 2026 15:06:58 -0800	[thread overview]
Message-ID: <20261116-ionic-get-fec-stats-v4-5-d25cae9f1e87@amd.com> (raw)
In-Reply-To: <20261116-ionic-get-fec-stats-v4-0-d25cae9f1e87@amd.com>

From: "Nikhil P. Rao" <nikhil.rao@amd.com>

ionic_get_fecparam() fills fec->active_fec from config.fec_type, the mode
the host requested, which on an autoneg link is whatever was last
programmed while the link negotiates something else.  On an autoneg
link, read it from status.fec_type, where firmware reports the
operational mode.

status.fec_type was carved out of the reserved area by commit
c4e7a75a096c ("ionic: updates to ionic FW api description"), and
firmware older than that leaves the byte zero, which reads as FEC off.
With autoneg disabled the port runs the configured mode, so keep
reporting config.fec_type there; only autoneg links on such old
firmware report FEC off.

Fixes: e95f922f4c2f ("ionic: implement ethtool set-fec")
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Signed-off-by: Eric Joyner <eric.joyner@amd.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_ethtool.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
index 8f0f1585116b..ac728b8aa780 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
@@ -440,6 +440,18 @@ static u32 ionic_fec_type_to_ethtool(u8 fec_type)
 	}
 }
 
+/* Firmware that predates status.fec_type leaves it zero, which reads as
+ * FEC off.  With autoneg disabled the port runs the configured mode, so
+ * only trust status.fec_type on an autoneg link.
+ */
+static u8 ionic_active_fec_type(const struct ionic_port_info *port_info)
+{
+	if (READ_ONCE(port_info->config.an_enable))
+		return READ_ONCE(port_info->status.fec_type);
+
+	return READ_ONCE(port_info->config.fec_type);
+}
+
 static int ionic_get_fecparam(struct net_device *netdev,
 			      struct ethtool_fecparam *fec)
 {
@@ -449,8 +461,10 @@ static int ionic_get_fecparam(struct net_device *netdev,
 	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);
+	fec->active_fec =
+		ionic_fec_type_to_ethtool(ionic_active_fec_type(port_info));
+	fec->fec =
+		ionic_fec_type_to_ethtool(READ_ONCE(port_info->config.fec_type));
 
 	return 0;
 }

-- 
2.53.0


  parent reply	other threads:[~2026-11-16 23:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 23:06 [PATCH net-next v4 0/6] ionic: FEC reporting fixes and .get_fec_stats handler Eric Joyner
2026-11-16 23:06 ` [PATCH net-next v4 1/6] ionic: write the extra_stats invalid markers one counter at a time Eric Joyner
2026-11-16 23:06 ` [PATCH net-next v4 2/6] ionic: report FEC off as a supported link mode Eric Joyner
2026-11-17 23:10   ` netdev-bot+sashiko
2026-11-16 23:06 ` [PATCH net-next v4 3/6] ionic: report the configured FEC mode in ethtool_fecparam.fec Eric Joyner
2026-11-16 23:06 ` [PATCH net-next v4 4/6] ionic: map the FEC type through a helper in ionic_get_fecparam() Eric Joyner
2026-11-17 23:10   ` netdev-bot+sashiko
2026-11-16 23:06 ` Eric Joyner [this message]
2026-11-17 23:10   ` [PATCH net-next v4 5/6] ionic: report the operational FEC mode from ethtool --show-fec netdev-bot+sashiko
2026-11-16 23:06 ` [PATCH net-next v4 6/6] ionic: Add .get_fec_stats ethtool handler Eric Joyner

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=20261116-ionic-get-fec-stats-v4-5-d25cae9f1e87@amd.com \
    --to=eric.joyner@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikhil.rao@amd.com \
    --cc=pabeni@redhat.com \
    --cc=vadim.fedorenko@linux.dev \
    /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