bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Joe Damato <jdamato@fastly.com>
Cc: netdev@vger.kernel.org, sridhar.samudrala@intel.com,
	Shuah Khan <shuah@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	linux-kernel@vger.kernel.org (open list),
	linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST
	FRAMEWORK),
	bpf@vger.kernel.org (open list:XDP (eXpress Data
	Path):Keyword:(?:\b|_)xdp(?:\b|_))
Subject: Re: [RFC net-next 2/2] selftests: drv-net: Test queue xsk attribute
Date: Wed, 29 Jan 2025 18:07:51 -0800	[thread overview]
Message-ID: <20250129180751.6d30c8c4@kernel.org> (raw)
In-Reply-To: <20250129172431.65773-3-jdamato@fastly.com>

On Wed, 29 Jan 2025 17:24:25 +0000 Joe Damato wrote:
> Test that queues which are used for AF_XDP have the xsk attribute set.

> diff --git a/tools/testing/selftests/drivers/.gitignore b/tools/testing/selftests/drivers/.gitignore
> index 09e23b5afa96..3c109144f7ff 100644
> --- a/tools/testing/selftests/drivers/.gitignore
> +++ b/tools/testing/selftests/drivers/.gitignore
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  /dma-buf/udmabuf
>  /s390x/uvdevice/test_uvdevice
> +/net/xdp_helper

Let's create our own gitignore, under drivers/net
we'll get conflicts with random trees if we add to the shared one

>  def sys_get_queues(ifname, qtype='rx') -> int:
>      folders = glob.glob(f'/sys/class/net/{ifname}/queues/{qtype}-*')
> @@ -21,6 +24,31 @@ def nl_get_queues(cfg, nl, qtype='rx'):
>          return len([q for q in queues if q['type'] == qtype])
>      return None
>  
> +def check_xdp(cfg, nl, xdp_queue_id=0) -> None:
> +    test_dir = os.path.dirname(os.path.realpath(__file__))
> +    xdp = subprocess.Popen([f"{test_dir}/xdp_helper", f"{cfg.ifindex}", f"{xdp_queue_id}"],
> +                           stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=1,
> +                           text=True)

add:
	defer(xdp.kill)

here, to make sure test cleanup will always try to kill the process,
then you can remove the xdp.kill() at the end

> +    stdout, stderr = xdp.communicate(timeout=10)
> +    rx = tx = False
> +
> +    queues = nl.queue_get({'ifindex': cfg.ifindex}, dump=True)
> +    if queues:

if not queues:
	raise KsftSkipEx("Netlink reports no queues")

That said only reason I can think of for no queues to be reported would
be that the device is down, which is very weird and we could as well
crash. So maybe the check for queues is not necessary ?

> +        for q in queues:
> +            if q['id'] == 0:
> +                if q['type'] == 'rx':
> +                    rx = True
> +                if q['type'] == 'tx':
> +                    tx = True
> +
> +                ksft_eq(q['xsk'], 1)
> +            else:
> +                ksft_eq(q['xsk'], 0)
> +
> +    ksft_eq(rx, True)
> +    ksft_eq(tx, True)
> +    xdp.kill()

  reply	other threads:[~2025-01-30  2:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29 17:24 [RFC net-next 0/2] netdevgenl: Add an xsk attribute to queues Joe Damato
2025-01-29 17:24 ` [RFC net-next 2/2] selftests: drv-net: Test queue xsk attribute Joe Damato
2025-01-30  2:07   ` Jakub Kicinski [this message]
2025-01-30 16:29     ` Joe Damato
2025-01-29 17:34 ` [RFC net-next 0/2] netdevgenl: Add an xsk attribute to queues Joe Damato

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=20250129180751.6d30c8c4@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=jdamato@fastly.com \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=sridhar.samudrala@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 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).