netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests
@ 2022-11-30  9:41 Tirthendu Sarkar
  2022-11-30 11:57 ` Maciej Fijalkowski
  0 siblings, 1 reply; 3+ messages in thread
From: Tirthendu Sarkar @ 2022-11-30  9:41 UTC (permalink / raw)
  To: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, ast,
	daniel
  Cc: netdev, bpf

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
+       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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests
  2022-11-30  9:41 [PATCH bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests Tirthendu Sarkar
@ 2022-11-30 11:57 ` Maciej Fijalkowski
  2022-11-30 12:13   ` Magnus Karlsson
  0 siblings, 1 reply; 3+ messages in thread
From: Maciej Fijalkowski @ 2022-11-30 11:57 UTC (permalink / raw)
  To: Tirthendu Sarkar
  Cc: bjorn, magnus.karlsson, jonathan.lemon, ast, daniel, netdev, bpf

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
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests
  2022-11-30 11:57 ` Maciej Fijalkowski
@ 2022-11-30 12:13   ` Magnus Karlsson
  0 siblings, 0 replies; 3+ messages in thread
From: Magnus Karlsson @ 2022-11-30 12:13 UTC (permalink / raw)
  To: Maciej Fijalkowski, Saeed Mahameed
  Cc: Tirthendu Sarkar, bjorn, magnus.karlsson, jonathan.lemon, ast,
	daniel, netdev, bpf

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
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-30 12:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-30  9:41 [PATCH bpf-next] selftests: xsk: changes for setting up NICs to run xsk self-tests Tirthendu Sarkar
2022-11-30 11:57 ` Maciej Fijalkowski
2022-11-30 12:13   ` Magnus Karlsson

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).