mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hariprasad Kelam <hkelam@marvell.com>
To: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <kuba@kernel.org>, <davem@davemloft.net>, <pabeni@redhat.com>,
	<edumazet@google.com>, <sgoutham@marvell.com>,
	<lcherian@marvell.com>, <gakula@marvell.com>,
	<jerinj@marvell.com>, <sbhatta@marvell.com>
Subject: [net-next PATCH V2 3/4] octeontx2-pf: ethtool: Implement get_fec_stats
Date: Tue, 29 Nov 2022 10:44:08 +0530	[thread overview]
Message-ID: <20221129051409.20034-4-hkelam@marvell.com> (raw)
In-Reply-To: <20221129051409.20034-1-hkelam@marvell.com>

The current implementation is such that FEC statistics are reported as
part of ethtool statistics that is the user can fetch them from the
below command

"ethtool -S eth0"

Fec Corrected Errors:
Fec Uncorrected Errors:

This patch removes this logic and registers a callback for get_fec_stats
such that FEC stats can be queried from the below command
"ethtool -I --show-fec eth0"

Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
---
 .../marvell/octeontx2/nic/otx2_ethtool.c      | 75 ++++++++++---------
 1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 0eb74e8c553d..0dd7bce2b866 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -135,10 +135,6 @@ static void otx2_get_strings(struct net_device *netdev, u32 sset, u8 *data)
 
 	strcpy(data, "reset_count");
 	data += ETH_GSTRING_LEN;
-	sprintf(data, "Fec Corrected Errors: ");
-	data += ETH_GSTRING_LEN;
-	sprintf(data, "Fec Uncorrected Errors: ");
-	data += ETH_GSTRING_LEN;
 }
 
 static void otx2_get_qset_stats(struct otx2_nic *pfvf,
@@ -193,8 +189,6 @@ static void otx2_get_ethtool_stats(struct net_device *netdev,
 				   struct ethtool_stats *stats, u64 *data)
 {
 	struct otx2_nic *pfvf = netdev_priv(netdev);
-	u64 fec_corr_blks, fec_uncorr_blks;
-	struct cgx_fw_data *rsp;
 	int stat;
 
 	otx2_get_dev_stats(pfvf);
@@ -217,32 +211,6 @@ static void otx2_get_ethtool_stats(struct net_device *netdev,
 	}
 
 	*(data++) = pfvf->reset_count;
-
-	fec_corr_blks = pfvf->hw.cgx_fec_corr_blks;
-	fec_uncorr_blks = pfvf->hw.cgx_fec_uncorr_blks;
-
-	rsp = otx2_get_fwdata(pfvf);
-	if (!IS_ERR(rsp) && rsp->fwdata.phy.misc.has_fec_stats &&
-	    !otx2_get_phy_fec_stats(pfvf)) {
-		/* Fetch fwdata again because it's been recently populated with
-		 * latest PHY FEC stats.
-		 */
-		rsp = otx2_get_fwdata(pfvf);
-		if (!IS_ERR(rsp)) {
-			struct fec_stats_s *p = &rsp->fwdata.phy.fec_stats;
-
-			if (pfvf->linfo.fec == OTX2_FEC_BASER) {
-				fec_corr_blks   = p->brfec_corr_blks;
-				fec_uncorr_blks = p->brfec_uncorr_blks;
-			} else {
-				fec_corr_blks   = p->rsfec_corr_cws;
-				fec_uncorr_blks = p->rsfec_uncorr_cws;
-			}
-		}
-	}
-
-	*(data++) = fec_corr_blks;
-	*(data++) = fec_uncorr_blks;
 }
 
 static int otx2_get_sset_count(struct net_device *netdev, int sset)
@@ -257,10 +225,9 @@ static int otx2_get_sset_count(struct net_device *netdev, int sset)
 		       (pfvf->hw.rx_queues + pfvf->hw.tx_queues);
 	if (!test_bit(CN10K_RPM, &pfvf->hw.cap_flag))
 		mac_stats = CGX_RX_STATS_COUNT + CGX_TX_STATS_COUNT;
-	otx2_update_lmac_fec_stats(pfvf);
 
 	return otx2_n_dev_stats + otx2_n_drv_stats + qstats_count +
-	       mac_stats + OTX2_FEC_STATS_CNT + 1;
+	       mac_stats + 1;
 }
 
 /* Get no of queues device supports and current queue count */
@@ -1268,6 +1235,45 @@ static int otx2_set_link_ksettings(struct net_device *netdev,
 	return err;
 }
 
+static void otx2_get_fec_stats(struct net_device *netdev,
+			       struct ethtool_fec_stats *fec_stats)
+{
+	struct otx2_nic *pfvf = netdev_priv(netdev);
+	struct cgx_fw_data *rsp;
+
+	otx2_update_lmac_fec_stats(pfvf);
+
+	rsp = otx2_get_fwdata(pfvf);
+	if (!IS_ERR(rsp) && rsp->fwdata.phy.misc.has_fec_stats &&
+	    !otx2_get_phy_fec_stats(pfvf)) {
+		/* Fetch fwdata again because it's been recently populated with
+		 * latest PHY FEC stats.
+		 */
+		rsp = otx2_get_fwdata(pfvf);
+		if (!IS_ERR(rsp)) {
+			struct fec_stats_s *p = &rsp->fwdata.phy.fec_stats;
+
+			if (pfvf->linfo.fec == OTX2_FEC_BASER) {
+				fec_stats->corrected_blocks.total     =
+					p->brfec_corr_blks;
+				fec_stats->uncorrectable_blocks.total =
+					p->brfec_uncorr_blks;
+			} else {
+				fec_stats->corrected_blocks.total     =
+					p->rsfec_corr_cws;
+				fec_stats->uncorrectable_blocks.total =
+					p->rsfec_uncorr_cws;
+			}
+		}
+	} else {
+		/* Report MAC FEC stats */
+		fec_stats->corrected_blocks.total     =
+			pfvf->hw.cgx_fec_corr_blks;
+		fec_stats->uncorrectable_blocks.total =
+			pfvf->hw.cgx_fec_uncorr_blks;
+	}
+}
+
 static const struct ethtool_ops otx2_ethtool_ops = {
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
 				     ETHTOOL_COALESCE_MAX_FRAMES |
@@ -1298,6 +1304,7 @@ static const struct ethtool_ops otx2_ethtool_ops = {
 	.get_pauseparam		= otx2_get_pauseparam,
 	.set_pauseparam		= otx2_set_pauseparam,
 	.get_ts_info		= otx2_get_ts_info,
+	.get_fec_stats		= otx2_get_fec_stats,
 	.get_fecparam		= otx2_get_fecparam,
 	.set_fecparam		= otx2_set_fecparam,
 	.get_link_ksettings     = otx2_get_link_ksettings,
-- 
2.17.1


  parent reply	other threads:[~2022-11-29  5:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  5:14 [net-next PATCH V2 0/4] CN10KB MAC block support Hariprasad Kelam
2022-11-29  5:14 ` [net-next PATCH V2 1/4] octeontx2-af: Support variable number of lmacs Hariprasad Kelam
2022-11-29  5:14 ` [net-next PATCH V2 2/4] octeontx2-af: cn10kb: Add RPM_USX MAC support Hariprasad Kelam
2022-11-29  5:14 ` Hariprasad Kelam [this message]
2022-11-29 18:45   ` [net-next PATCH V2 3/4] octeontx2-pf: ethtool: Implement get_fec_stats Andrew Lunn
2022-11-30  8:54     ` Hariprasad Kelam
2022-11-29  5:14 ` [net-next PATCH V2 4/4] octeontx2-af: Add FEC stats for RPM/RPM_USX block Hariprasad Kelam

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=20221129051409.20034-4-hkelam@marvell.com \
    --to=hkelam@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=kuba@kernel.org \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®