All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <sdf@google.com>
To: Tushar Vyavahare <tushar.vyavahare@intel.com>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, bjorn@kernel.org,
	 magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
	 jonathan.lemon@gmail.com, davem@davemloft.net, kuba@kernel.org,
	 pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net,
	 tirthendu.sarkar@intel.com
Subject: Re: [PATCH bpf-next 4/6] selftests/xsk: implement set_hw_ring_size function to configure interface ring size
Date: Fri, 15 Mar 2024 10:44:17 -0700	[thread overview]
Message-ID: <ZfSI8UftKDGWTgUC@google.com> (raw)
In-Reply-To: <20240315140726.22291-5-tushar.vyavahare@intel.com>

On 03/15, Tushar Vyavahare wrote:
> Introduce a new function called set_hw_ring_size that allows for the
> dynamic configuration of the ring size within the interface.
> 
> Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com>
> ---
>  tools/testing/selftests/bpf/xskxceiver.c | 35 ++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
> index 32005bfb9c9f..aafa78307586 100644
> --- a/tools/testing/selftests/bpf/xskxceiver.c
> +++ b/tools/testing/selftests/bpf/xskxceiver.c
> @@ -441,6 +441,41 @@ static int get_hw_ring_size(struct ifobject *ifobj)
>  	return 0;
>  }
>  
> +static int set_hw_ring_size(struct ifobject *ifobj, u32 tx, u32 rx)

Hmm, now that we have set/get, should we put them into
network_helpers.c? These seem pretty generic if you accept
iface_name + ethtool_ringparam in the api.

> +{
> +	struct ethtool_ringparam ring_param = {0};
> +	struct ifreq ifr = {0};
> +	int sockfd, ret;
> +	u32 ctr = 0;
> +
> +	sockfd = socket(AF_INET, SOCK_DGRAM, 0);
> +	if (sockfd < 0)
> +		return errno;
> +
> +	memcpy(ifr.ifr_name, ifobj->ifname, sizeof(ifr.ifr_name));
> +
> +	ring_param.tx_pending = tx;
> +	ring_param.rx_pending = rx;
> +
> +	ring_param.cmd = ETHTOOL_SRINGPARAM;
> +	ifr.ifr_data = (char *)&ring_param;
> +

[..]

> +	while (ctr++ < SOCK_RECONF_CTR) {

Is it to retry EINTR? Retrying something else doesn't make sense
probably? So maybe do only errno==EINTR cases? Will make it more
generic and not dependent on SOCK_RECONF_CTR.


> +		ret = ioctl(sockfd, SIOCETHTOOL, &ifr);
> +		if (!ret)
> +			break;
> +		/* Retry if it fails */
> +		if (ctr >= SOCK_RECONF_CTR) {
> +			close(sockfd);
> +			return errno;
> +		}

[..]

> +		usleep(USLEEP_MAX);

Same here. Not sure what's the purpose of sleep? Alternatively, maybe
clarify in the commit description what particular error case we want
to retry.

  parent reply	other threads:[~2024-03-15 17:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 14:07 [PATCH bpf-next 0/6] Enhancing selftests/xsk Framework: Maximum and Minimum Ring Configurations Tushar Vyavahare
2024-03-15 14:07 ` [PATCH bpf-next 1/6] tools/include: add ethtool_ringparam definition to UAPI header Tushar Vyavahare
2024-03-15 17:33   ` Stanislav Fomichev
2024-03-19  6:42     ` Vyavahare, Tushar
2024-03-15 14:07 ` [PATCH bpf-next 2/6] selftests/xsk: make batch size variable Tushar Vyavahare
2024-03-15 14:07 ` [PATCH bpf-next 3/6] selftests/xsk: implement get_hw_ring_size function to retrieve current and max interface size Tushar Vyavahare
2024-03-15 17:40   ` Stanislav Fomichev
2024-03-19  6:47     ` Vyavahare, Tushar
2024-03-15 14:07 ` [PATCH bpf-next 4/6] selftests/xsk: implement set_hw_ring_size function to configure interface ring size Tushar Vyavahare
2024-03-15 15:47   ` Alexei Starovoitov
2024-03-19  6:54     ` Vyavahare, Tushar
2024-03-15 17:44   ` Stanislav Fomichev [this message]
2024-03-19  6:52     ` Vyavahare, Tushar
2024-03-15 14:07 ` [PATCH bpf-next 5/6] selftests/xsk: test AF_XDP functionality under minimal ring configurations Tushar Vyavahare
2024-03-15 14:07 ` [PATCH bpf-next 6/6] selftests/xsk: enhance framework with a new test case for AF_XDP under max ring sizes Tushar Vyavahare

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=ZfSI8UftKDGWTgUC@google.com \
    --to=sdf@google.com \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jonathan.lemon@gmail.com \
    --cc=kuba@kernel.org \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tirthendu.sarkar@intel.com \
    --cc=tushar.vyavahare@intel.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.