All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Hariprasad Kelam <hkelam@marvell.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<davem@davemloft.net>, <willemdebruijn.kernel@gmail.com>,
	<andrew@lunn.ch>, <sgoutham@marvell.com>, <lcherian@marvell.com>,
	<gakula@marvell.com>, <jerinj@marvell.com>, <sbhatta@marvell.com>
Subject: Re: [Patch v3 net-next 3/7] octeontx2-pf: ethtool fec mode support
Date: Tue, 2 Feb 2021 17:12:01 -0800	[thread overview]
Message-ID: <20210202171201.59d2e461@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <1612157084-101715-4-git-send-email-hkelam@marvell.com>

On Mon, 1 Feb 2021 10:54:40 +0530 Hariprasad Kelam wrote:
> From: Christina Jacob <cjacob@marvell.com>
> 
> Add ethtool support to configure fec modes baser/rs and
> support to fecth FEC stats from CGX as well PHY.
> 
> Configure fec mode
> 	- ethtool --set-fec eth0 encoding rs/baser/off/auto
> Query fec mode
> 	- ethtool --show-fec eth0

> +	if (pfvf->linfo.fec) {
> +		sprintf(data, "Fec Corrected Errors: ");
> +		data += ETH_GSTRING_LEN;
> +		sprintf(data, "Fec Uncorrected Errors: ");
> +		data += ETH_GSTRING_LEN;

Once again, you can't dynamically hide stats. ethtool makes 3 separate
system calls - to get the number of stats, get the names, and get the
values. If someone changes the FEC config in between those user space
dumping stats will get confused.

> +	}
>  }

> +static int otx2_get_fecparam(struct net_device *netdev,
> +			     struct ethtool_fecparam *fecparam)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(netdev);
> +	struct cgx_fw_data *rsp;
> +	const int fec[] = {
> +		ETHTOOL_FEC_OFF,
> +		ETHTOOL_FEC_BASER,
> +		ETHTOOL_FEC_RS,
> +		ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
> +#define FEC_MAX_INDEX 3
> +	if (pfvf->linfo.fec < FEC_MAX_INDEX)

This should be <

> +		fecparam->active_fec = fec[pfvf->linfo.fec];


> +	rsp = otx2_get_fwdata(pfvf);
> +	if (IS_ERR(rsp))
> +		return PTR_ERR(rsp);
> +
> +	if (rsp->fwdata.supported_fec <= FEC_MAX_INDEX) {
> +		if (!rsp->fwdata.supported_fec)
> +			fecparam->fec = ETHTOOL_FEC_NONE;
> +		else
> +			fecparam->fec = fec[rsp->fwdata.supported_fec];
> +	}
> +	return 0;
> +}
> +
> +static int otx2_set_fecparam(struct net_device *netdev,
> +			     struct ethtool_fecparam *fecparam)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(netdev);
> +	struct mbox *mbox = &pfvf->mbox;
> +	struct fec_mode *req, *rsp;
> +	int err = 0, fec = 0;
> +
> +	switch (fecparam->fec) {
> +	/* Firmware does not support AUTO mode consider it as FEC_NONE */
> +	case ETHTOOL_FEC_OFF:
> +	case ETHTOOL_FEC_AUTO:
> +	case ETHTOOL_FEC_NONE:

I _think_ NONE is for drivers to report that they don't support FEC
settings. It's an output only parameter. On input OFF should be used.

> +		fec = OTX2_FEC_NONE;
> +		break;
> +	case ETHTOOL_FEC_RS:
> +		fec = OTX2_FEC_RS;
> +		break;
> +	case ETHTOOL_FEC_BASER:
> +		fec = OTX2_FEC_BASER;
> +		break;
> +	default:
> +		netdev_warn(pfvf->netdev, "Unsupported FEC mode: %d",
> +			    fecparam->fec);
> +		return -EINVAL;
> +	}
> +
> +	if (fec == pfvf->linfo.fec)
> +		return 0;
> +
> +	mutex_lock(&mbox->lock);
> +	req = otx2_mbox_alloc_msg_cgx_set_fec_param(&pfvf->mbox);
> +	if (!req) {
> +		err = -ENOMEM;
> +		goto end;
> +	}
> +	req->fec = fec;
> +	err = otx2_sync_mbox_msg(&pfvf->mbox);
> +	if (err)
> +		goto end;
> +
> +	rsp = (struct fec_mode *)otx2_mbox_get_rsp(&pfvf->mbox.mbox,
> +						   0, &req->hdr);
> +	if (rsp->fec >= 0) {
> +		pfvf->linfo.fec = rsp->fec;
> +		/* clear stale counters */
> +		pfvf->hw.cgx_fec_corr_blks = 0;
> +		pfvf->hw.cgx_fec_uncorr_blks = 0;

Stats are supposed to be cumulative. Don't reset the stats just because
someone changed the FEC mode. You can miss errors this way.

> +	} else {
> +		err = rsp->fec;
> +	}

  parent reply	other threads:[~2021-02-03  1:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01  5:24 [Patch v3 net-next 0/7] ethtool support for fec and link configuration Hariprasad Kelam
2021-02-01  5:24 ` [Patch v3 net-next 1/7] octeontx2-af: forward error correction configuration Hariprasad Kelam
2021-02-03  0:43   ` Jesse Brandeburg
2021-02-01  5:24 ` [Patch v3 net-next 2/7] octeontx2-af: Add new CGX_CMD to get PHY FEC statistics Hariprasad Kelam
2021-02-03  0:43   ` Jesse Brandeburg
2021-02-01  5:24 ` [Patch v3 net-next 3/7] octeontx2-pf: ethtool fec mode support Hariprasad Kelam
2021-02-03  0:44   ` Jesse Brandeburg
2021-02-03  1:12   ` Jakub Kicinski [this message]
2021-02-01  5:24 ` [Patch v3 net-next 4/7] octeontx2-af: Physical link configuration support Hariprasad Kelam
2021-02-03  0:44   ` Jesse Brandeburg
2021-02-01  5:24 ` [Patch v3 net-next 5/7] octeontx2-af: advertised link modes support on cgx Hariprasad Kelam
2021-02-03  0:45   ` Jesse Brandeburg
2022-12-01  2:02   ` Chris Packham
2022-12-02  7:56     ` Hariprasad Kelam
2021-02-01  5:24 ` [Patch v3 net-next 6/7] octeontx2-pf: ethtool physical link status Hariprasad Kelam
2021-02-03  0:46   ` Jesse Brandeburg
2021-02-01  5:24 ` [Patch v3 net-next 7/7] octeontx2-pf: ethtool physical link configuration Hariprasad Kelam
2021-02-03  0:48   ` Jesse Brandeburg
2021-02-03  0:41 ` [Patch v3 net-next 0/7] ethtool support for fec and " Jesse Brandeburg
2021-02-04 15:33 [Patch v3 net-next 3/7] octeontx2-pf: ethtool fec mode support 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=20210202171201.59d2e461@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=lcherian@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=willemdebruijn.kernel@gmail.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.