netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: sunil.kovvuri@gmail.com, davem@davemloft.net, kubakici@wp.pl,
	Christina Jacob <cjacob@marvell.com>,
	Sunil Goutham <sgoutham@marvell.com>
Subject: Re: [PATCH v2 14/17] octeontx2-pf: Add basic ethtool support
Date: Tue, 14 Jan 2020 11:08:12 +0100	[thread overview]
Message-ID: <20200114100812.GA22304@unicorn.suse.cz> (raw)
In-Reply-To: <1578985340-28775-15-git-send-email-sunil.kovvuri@gmail.com>

On Tue, Jan 14, 2020 at 12:32:17PM +0530, sunil.kovvuri@gmail.com wrote:
> From: Christina Jacob <cjacob@marvell.com>
> 
> This patch adds ethtool support for
>  - Driver stats, Tx/Rx perqueue and CGX LMAC stats
>  - Set/show Rx/Tx queue count
>  - Set/show Rx/Tx ring sizes
>  - Set/show IRQ coalescing parameters
> 
> Signed-off-by: Christina Jacob <cjacob@marvell.com>
> Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
> ---
[...]
> +static void otx2_dev_open(struct net_device *netdev)
> +{
> +	otx2_open(netdev);
> +}
> +
> +static void otx2_dev_stop(struct net_device *netdev)
> +{
> +	otx2_stop(netdev);
> +}

Why don't you call these directly?

[...]
> +/* Get no of queues device supports and current queue count */
> +static void otx2_get_channels(struct net_device *dev,
> +			      struct ethtool_channels *channel)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(dev);
> +
> +	memset(channel, 0, sizeof(*channel));

The structure is already zero initialized in ethtool_get_channels()
(except for cmd).

> +	channel->max_rx = pfvf->hw.max_queues;
> +	channel->max_tx = pfvf->hw.max_queues;
> +
> +	channel->rx_count = pfvf->hw.rx_queues;
> +	channel->tx_count = pfvf->hw.tx_queues;
> +}
> +
> +/* Set no of Tx, Rx queues to be used */
> +static int otx2_set_channels(struct net_device *dev,
> +			     struct ethtool_channels *channel)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(dev);
> +	bool if_up = netif_running(dev);
> +	int err = 0;
> +
> +	if (!channel->rx_count || !channel->tx_count)
> +		return -EINVAL;
> +	if (channel->rx_count > pfvf->hw.max_queues)
> +		return -EINVAL;
> +	if (channel->tx_count > pfvf->hw.max_queues)
> +		return -EINVAL;

The upper bounds are checked in ethtool_set_channels() so that you don't
get here if requested counts are too high.

> +
> +	if (if_up)
> +		otx2_dev_stop(dev);
> +
> +	pfvf->hw.rx_queues = channel->rx_count;
> +	pfvf->hw.tx_queues = channel->tx_count;
> +	err = otx2_set_real_num_queues(dev, pfvf->hw.tx_queues,
> +				       pfvf->hw.rx_queues);
> +	pfvf->qset.cq_cnt = pfvf->hw.tx_queues +  pfvf->hw.rx_queues;
> +	if (err)
> +		return err;
> +
> +	if (if_up)
> +		otx2_dev_open(dev);

Is it intentional that you leave the device down when the change fails?

> +	netdev_info(dev, "Setting num Tx rings to %d, Rx rings to %d success\n",
> +		    pfvf->hw.tx_queues, pfvf->hw.rx_queues);
> +
> +	return err;
> +}
> +
> +static void otx2_get_ringparam(struct net_device *netdev,
> +			       struct ethtool_ringparam *ring)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(netdev);
> +	struct otx2_qset *qs = &pfvf->qset;
> +
> +	ring->rx_max_pending = Q_COUNT(Q_SIZE_MAX);
> +	ring->rx_pending = qs->rqe_cnt ? qs->rqe_cnt : Q_COUNT(Q_SIZE_256);
> +	ring->tx_max_pending = Q_COUNT(Q_SIZE_MAX);
> +	ring->tx_pending = qs->sqe_cnt ? qs->sqe_cnt : Q_COUNT(Q_SIZE_4K);
> +}
> +
> +static int otx2_set_ringparam(struct net_device *netdev,
> +			      struct ethtool_ringparam *ring)
> +{
> +	struct otx2_nic *pfvf = netdev_priv(netdev);
> +	bool if_up = netif_running(netdev);
> +	struct otx2_qset *qs = &pfvf->qset;
> +	u32 rx_count, tx_count;
> +
> +	if (ring->rx_mini_pending || ring->rx_jumbo_pending)
> +		return -EINVAL;
> +
> +	/* Permitted lengths are 16 64 256 1K 4K 16K 64K 256K 1M  */
> +	rx_count = clamp_t(u32, ring->rx_pending,
> +			   Q_COUNT(Q_SIZE_MIN), Q_COUNT(Q_SIZE_MAX));

The upper bound is checked in ethtool_set_ringparam().

Michal Kubecek

> +	/* On some silicon variants a skid or reserved CQEs are
> +	 * needed to avoid CQ overflow.
> +	 */
> +	if (rx_count < pfvf->hw.rq_skid)
> +		rx_count =  pfvf->hw.rq_skid;
> +	rx_count = Q_COUNT(Q_SIZE(rx_count, 3));
> +
> +	/* Due pipelining impact minimum 2000 unused SQ CQE's
> +	 * need to maintain to avoid CQ overflow, hence the
> +	 * minimum 4K size.
> +	 */
> +	tx_count = clamp_t(u32, ring->tx_pending,
> +			   Q_COUNT(Q_SIZE_4K), Q_COUNT(Q_SIZE_MAX));
> +	tx_count = Q_COUNT(Q_SIZE(tx_count, 3));
> +
> +	if (tx_count == qs->sqe_cnt && rx_count == qs->rqe_cnt)
> +		return 0;
> +
> +	if (if_up)
> +		otx2_dev_stop(netdev);
> +
> +	/* Assigned to the nearest possible exponent. */
> +	qs->sqe_cnt = tx_count;
> +	qs->rqe_cnt = rx_count;
> +
> +	if (if_up)
> +		otx2_dev_open(netdev);
> +	return 0;
> +}

  reply	other threads:[~2020-01-14 10:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14  7:02 [PATCH v2 00/17] octeontx2-pf: Add network driver for physical function sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 01/17] octeontx2-pf: Add Marvell OcteonTX2 NIC driver sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 02/17] octeontx2-pf: Mailbox communication with AF sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 03/17] octeontx2-pf: Attach NIX and NPA block LFs sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 04/17] octeontx2-pf: Initialize and config queues sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 05/17] octeontx2-pf: Setup interrupts and NAPI handler sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 06/17] octeontx2-pf: Receive packet handling support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 07/17] octeontx2-pf: Add packet transmission support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 08/17] octeontx2-pf: Register and handle link notifications sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 09/17] octeontx2-pf: MTU, MAC and RX mode config support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 10/17] octeontx2-pf: Error handling support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 11/17] octeontx2-pf: Receive side scaling support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 12/17] octeontx2-pf: TCP segmentation offload support sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 13/17] octeontx2-pf: Add ndo_get_stats64 sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 14/17] octeontx2-pf: Add basic ethtool support sunil.kovvuri
2020-01-14 10:08   ` Michal Kubecek [this message]
2020-01-14 10:26     ` Sunil Kovvuri
2020-01-14 13:17   ` Jakub Kicinski
2020-01-14  7:02 ` [PATCH v2 15/17] octeontx2-pf: ethtool RSS config support sunil.kovvuri
2020-01-14 10:19   ` Michal Kubecek
2020-01-14 10:29     ` Sunil Kovvuri
2020-01-14  7:02 ` [PATCH v2 16/17] Documentation: net: octeontx2: Add RVU HW and drivers overview sunil.kovvuri
2020-01-14  7:02 ` [PATCH v2 17/17] MAINTAINERS: Add entry for Marvell OcteonTX2 Physical Function driver sunil.kovvuri

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=20200114100812.GA22304@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=cjacob@marvell.com \
    --cc=davem@davemloft.net \
    --cc=kubakici@wp.pl \
    --cc=netdev@vger.kernel.org \
    --cc=sgoutham@marvell.com \
    --cc=sunil.kovvuri@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).