netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: "Jubran, Samih" <sameehj@amazon.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"Woodhouse, David" <dwmw@amazon.co.uk>,
	"Machulsky, Zorik" <zorik@amazon.com>,
	"Matushevsky, Alexander" <matua@amazon.com>,
	"Bshara, Saeed" <saeedb@amazon.com>,
	"Wilson, Matt" <msw@amazon.com>,
	"Liguori, Anthony" <aliguori@amazon.com>,
	"Bshara, Nafea" <nafea@amazon.com>,
	"Tzalik, Guy" <gtzalik@amazon.com>,
	"Belgazal, Netanel" <netanel@amazon.com>,
	"Saidi, Ali" <alisaidi@amazon.com>,
	"Herrenschmidt, Benjamin" <benh@amazon.com>,
	"Kiyanovski, Arthur" <akiyano@amazon.com>
Subject: Re: [PATCH V1 net-next 5/6] net: ena: add ethtool function for changing io queue sizes
Date: Mon, 10 Jun 2019 14:21:02 +0200	[thread overview]
Message-ID: <20190610122102.GD31797@unicorn.suse.cz> (raw)
In-Reply-To: <45419c297d5241d9a7768b4d9af7d9f6@EX13D11EUB003.ant.amazon.com>

On Mon, Jun 10, 2019 at 07:46:08AM +0000, Jubran, Samih wrote:
> > -----Original Message-----
> > From: Michal Kubecek <mkubecek@suse.cz>
> > Sent: Thursday, June 6, 2019 5:48 PM
> > To: netdev@vger.kernel.org
> > Cc: Jubran, Samih <sameehj@amazon.com>; davem@davemloft.net;
> > Woodhouse, David <dwmw@amazon.co.uk>; Machulsky, Zorik
> > <zorik@amazon.com>; Matushevsky, Alexander <matua@amazon.com>;
> > Bshara, Saeed <saeedb@amazon.com>; Wilson, Matt <msw@amazon.com>;
> > Liguori, Anthony <aliguori@amazon.com>; Bshara, Nafea
> > <nafea@amazon.com>; Tzalik, Guy <gtzalik@amazon.com>; Belgazal,
> > Netanel <netanel@amazon.com>; Saidi, Ali <alisaidi@amazon.com>;
> > Herrenschmidt, Benjamin <benh@amazon.com>; Kiyanovski, Arthur
> > <akiyano@amazon.com>
> > Subject: Re: [PATCH V1 net-next 5/6] net: ena: add ethtool function for
> > changing io queue sizes
> > 
> > On Thu, Jun 06, 2019 at 02:55:19PM +0300, sameehj@amazon.com wrote:
> > > From: Sameeh Jubran <sameehj@amazon.com>
> > >
> > > Implement the set_ringparam() function of the ethtool interface to
> > > enable the changing of io queue sizes.
> > >
> > > Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
> > > Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
> > > ---
> > >  drivers/net/ethernet/amazon/ena/ena_ethtool.c | 25
> > > +++++++++++++++++++
> > drivers/net/ethernet/amazon/ena/ena_netdev.c  |
> > > 14 +++++++++++  drivers/net/ethernet/amazon/ena/ena_netdev.h  |  5
> > > +++-
> > >  3 files changed, 43 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
> > > b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
> > > index 101d93f16..33e28ad71 100644
> > > --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c
> > > +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c
> > > @@ -495,6 +495,30 @@ static void ena_get_ringparam(struct net_device
> > *netdev,
> > >  	ring->rx_pending = adapter->rx_ring[0].ring_size;  }
> > >
> > > +static int ena_set_ringparam(struct net_device *netdev,
> > > +			     struct ethtool_ringparam *ring) {
> > > +	struct ena_adapter *adapter = netdev_priv(netdev);
> > > +	u32 new_tx_size, new_rx_size;
> > > +
> > > +	if (ring->rx_mini_pending || ring->rx_jumbo_pending)
> > > +		return -EINVAL;
> > 
> > This check is superfluous as ethtool_set_ringparam() checks supplied values
> > against maximum returned by ->get_ringparam() which will be 0 in this case.
> > 
> > > +
> > > +	new_tx_size = clamp_val(ring->tx_pending, ENA_MIN_RING_SIZE,
> > > +				adapter->max_tx_ring_size);
> > > +	new_tx_size = rounddown_pow_of_two(new_tx_size);
> > > +
> > > +	new_rx_size = clamp_val(ring->rx_pending, ENA_MIN_RING_SIZE,
> > > +				adapter->max_rx_ring_size);
> > > +	new_rx_size = rounddown_pow_of_two(new_rx_size);
> > 
> > For the same reason, clamping from below would suffice here.
> > 
> > Michal Kubecek
> > 
> > > +
> > > +	if (new_tx_size == adapter->requested_tx_ring_size &&
> > > +	    new_rx_size == adapter->requested_rx_ring_size)
> > > +		return 0;
> > > +
> > > +	return ena_update_queue_sizes(adapter, new_tx_size,
> > new_rx_size); }
> 
> You are right with both arguments the way the code is written now,
> however, in the future the code might change and we prefer to be extra
> cautious.

If we accept this logic, commit 37e2d99b59c4 ("ethtool: Ensure new ring
parameters are within bounds during SRINGPARAM") would be useless as
every driver would have to duplicate the checks anyway.

Michal Kubecek

  reply	other threads:[~2019-06-10 12:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 11:55 [PATCH V1 net-next 0/6] Support for dynamic queue size changes sameehj
2019-06-06 11:55 ` [PATCH V1 net-next 1/6] net: ena: add MAX_QUEUES_EXT get feature admin command sameehj
2019-06-06 11:55 ` [PATCH V1 net-next 2/6] net: ena: enable negotiating larger Rx ring size sameehj
2019-06-06 11:55 ` [PATCH V1 net-next 3/6] net: ena: make ethtool show correct current and max queue sizes sameehj
2019-06-06 11:55 ` [PATCH V1 net-next 4/6] net: ena: allow queue allocation backoff when low on memory sameehj
2019-06-06 11:55 ` [PATCH V1 net-next 5/6] net: ena: add ethtool function for changing io queue sizes sameehj
2019-06-06 14:48   ` Michal Kubecek
2019-06-10  7:46     ` Jubran, Samih
2019-06-10 12:21       ` Michal Kubecek [this message]
2019-06-06 17:11   ` Michal Kubecek
2019-06-06 11:55 ` [PATCH V1 net-next 6/6] net: ena: update driver version from 2.0.3 to 2.1.0 sameehj

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=20190610122102.GD31797@unicorn.suse.cz \
    --to=mkubecek@suse.cz \
    --cc=akiyano@amazon.com \
    --cc=aliguori@amazon.com \
    --cc=alisaidi@amazon.com \
    --cc=benh@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dwmw@amazon.co.uk \
    --cc=gtzalik@amazon.com \
    --cc=matua@amazon.com \
    --cc=msw@amazon.com \
    --cc=nafea@amazon.com \
    --cc=netanel@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedb@amazon.com \
    --cc=sameehj@amazon.com \
    --cc=zorik@amazon.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).