diff mbox series

[bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests

Message ID 20221130094142.545051-1-tirthendu.sarkar@intel.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 12 maintainers not CCed: linux-kselftest@vger.kernel.org kpsingh@kernel.org haoluo@google.com song@kernel.org yhs@fb.com andrii@kernel.org martin.lau@linux.dev sdf@google.com john.fastabend@gmail.com shuah@kernel.org jolsa@kernel.org mykolal@fb.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc

Commit Message

Tirthendu Sarkar Nov. 30, 2022, 9:41 a.m. UTC
ETH devies need to be set up for running xsk self-tests, like enable
loopback, set promiscuous mode, MTU etc. This patch adds those settings
before running xsk self-tests and reverts them back once done.

Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
---
 tools/testing/selftests/bpf/test_xsk.sh | 27 ++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Comments

Fijalkowski, Maciej Nov. 30, 2022, 11:57 a.m. UTC | #1
On Wed, Nov 30, 2022 at 03:11:42PM +0530, Tirthendu Sarkar wrote:
> ETH devies need to be set up for running xsk self-tests, like enable
> loopback, set promiscuous mode, MTU etc. This patch adds those settings
> before running xsk self-tests and reverts them back once done.
> 
> Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
> ---
>  tools/testing/selftests/bpf/test_xsk.sh | 27 ++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> index d821fd098504..e7a5c5fc4f71 100755
> --- a/tools/testing/selftests/bpf/test_xsk.sh
> +++ b/tools/testing/selftests/bpf/test_xsk.sh
> @@ -106,7 +106,11 @@ MTU=1500
>  trap ctrl_c INT
>  
>  function ctrl_c() {
> -        cleanup_exit ${VETH0} ${VETH1} ${NS1}
> +	if [ ! -z $ETH ]; then
> +		cleanup_exit ${VETH0} ${VETH1} ${NS1}
> +	else
> +		cleanup_eth
> +	fi
>  	exit 1
>  }
>  
> @@ -138,9 +142,28 @@ setup_vethPairs() {
>  	ip link set ${VETH0} up
>  }
>  
> +setup_eth() {
> +       sudo ethtool -L ${ETH} combined 1

what if particular device has a different way of configuring single
channel? like

$ sudo ethtool -L ${ETH} tx 1 rx 1

I am not sure if we want to proceed with settings that are specific to
Intel devices. What if mlx5 will this in a much different way?

> +       sudo ethtool -K ${ETH} loopback on
> +       sudo ip link set ${ETH} promisc on
> +       sudo ip link set ${ETH} mtu ${MTU}
> +       sudo ip link set ${ETH} up
> +       IPV6_DISABLE_CMD="sudo sysctl -n net.ipv6.conf.${ETH}.disable_ipv6"
> +       IPV6_DISABLE=`$IPV6_DISABLE_CMD 2> /dev/null`
> +       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=1
> +       sleep 1
> +}
> +
> +cleanup_eth() {
> +       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=0
> +       sudo ethtool -K ${ETH} loopback off
> +       sudo ip link set ${ETH} promisc off
> +}
> +
>  if [ ! -z $ETH ]; then
>  	VETH0=${ETH}
>  	VETH1=${ETH}
> +	setup_eth
>  	NS1=""
>  else
>  	validate_root_exec
> @@ -191,6 +214,8 @@ exec_xskxceiver
>  
>  if [ -z $ETH ]; then
>  	cleanup_exit ${VETH0} ${VETH1} ${NS1}
> +else
> +	cleanup_eth
>  fi
>  
>  failures=0
> -- 
> 2.34.1
>
Magnus Karlsson Nov. 30, 2022, 12:13 p.m. UTC | #2
On Wed, Nov 30, 2022 at 1:09 PM Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> On Wed, Nov 30, 2022 at 03:11:42PM +0530, Tirthendu Sarkar wrote:
> > ETH devies need to be set up for running xsk self-tests, like enable
> > loopback, set promiscuous mode, MTU etc. This patch adds those settings
> > before running xsk self-tests and reverts them back once done.
> >
> > Signed-off-by: Tirthendu Sarkar <tirthendu.sarkar@intel.com>
> > ---
> >  tools/testing/selftests/bpf/test_xsk.sh | 27 ++++++++++++++++++++++++-
> >  1 file changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
> > index d821fd098504..e7a5c5fc4f71 100755
> > --- a/tools/testing/selftests/bpf/test_xsk.sh
> > +++ b/tools/testing/selftests/bpf/test_xsk.sh
> > @@ -106,7 +106,11 @@ MTU=1500
> >  trap ctrl_c INT
> >
> >  function ctrl_c() {
> > -        cleanup_exit ${VETH0} ${VETH1} ${NS1}
> > +     if [ ! -z $ETH ]; then
> > +             cleanup_exit ${VETH0} ${VETH1} ${NS1}
> > +     else
> > +             cleanup_eth
> > +     fi
> >       exit 1
> >  }
> >
> > @@ -138,9 +142,28 @@ setup_vethPairs() {
> >       ip link set ${VETH0} up
> >  }
> >
> > +setup_eth() {
> > +       sudo ethtool -L ${ETH} combined 1
>
> what if particular device has a different way of configuring single
> channel? like
>
> $ sudo ethtool -L ${ETH} tx 1 rx 1
>
> I am not sure if we want to proceed with settings that are specific to
> Intel devices. What if mlx5 will this in a much different way?

Adding Saeed as he will know. How does Mellanox set the number of
channels to 1 and how do you enable loopback mode? At least the rest
should be the same.

> > +       sudo ethtool -K ${ETH} loopback on
> > +       sudo ip link set ${ETH} promisc on
> > +       sudo ip link set ${ETH} mtu ${MTU}
> > +       sudo ip link set ${ETH} up
> > +       IPV6_DISABLE_CMD="sudo sysctl -n net.ipv6.conf.${ETH}.disable_ipv6"
> > +       IPV6_DISABLE=`$IPV6_DISABLE_CMD 2> /dev/null`
> > +       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=1
> > +       sleep 1
> > +}
> > +
> > +cleanup_eth() {
> > +       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=0
> > +       sudo ethtool -K ${ETH} loopback off
> > +       sudo ip link set ${ETH} promisc off
> > +}
> > +
> >  if [ ! -z $ETH ]; then
> >       VETH0=${ETH}
> >       VETH1=${ETH}
> > +     setup_eth
> >       NS1=""
> >  else
> >       validate_root_exec
> > @@ -191,6 +214,8 @@ exec_xskxceiver
> >
> >  if [ -z $ETH ]; then
> >       cleanup_exit ${VETH0} ${VETH1} ${NS1}
> > +else
> > +     cleanup_eth
> >  fi
> >
> >  failures=0
> > --
> > 2.34.1
> >
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
index d821fd098504..e7a5c5fc4f71 100755
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/bpf/test_xsk.sh
@@ -106,7 +106,11 @@  MTU=1500
 trap ctrl_c INT
 
 function ctrl_c() {
-        cleanup_exit ${VETH0} ${VETH1} ${NS1}
+	if [ ! -z $ETH ]; then
+		cleanup_exit ${VETH0} ${VETH1} ${NS1}
+	else
+		cleanup_eth
+	fi
 	exit 1
 }
 
@@ -138,9 +142,28 @@  setup_vethPairs() {
 	ip link set ${VETH0} up
 }
 
+setup_eth() {
+       sudo ethtool -L ${ETH} combined 1
+       sudo ethtool -K ${ETH} loopback on
+       sudo ip link set ${ETH} promisc on
+       sudo ip link set ${ETH} mtu ${MTU}
+       sudo ip link set ${ETH} up
+       IPV6_DISABLE_CMD="sudo sysctl -n net.ipv6.conf.${ETH}.disable_ipv6"
+       IPV6_DISABLE=`$IPV6_DISABLE_CMD 2> /dev/null`
+       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=1
+       sleep 1
+}
+
+cleanup_eth() {
+       [[ $IPV6_DISABLE == "0" ]] && $IPV6_DISABLE_CMD=0
+       sudo ethtool -K ${ETH} loopback off
+       sudo ip link set ${ETH} promisc off
+}
+
 if [ ! -z $ETH ]; then
 	VETH0=${ETH}
 	VETH1=${ETH}
+	setup_eth
 	NS1=""
 else
 	validate_root_exec
@@ -191,6 +214,8 @@  exec_xskxceiver
 
 if [ -z $ETH ]; then
 	cleanup_exit ${VETH0} ${VETH1} ${NS1}
+else
+	cleanup_eth
 fi
 
 failures=0