ethtool: add ETHTOOL_COALESCE_ALL_PARAMS define
Subsystems (6)
PATCH v3 1/4 ethtool: add ETHTOOL_COALESCE_ALL_PARAMS define
This bitmask represents all existing coalesce parameters.
--- include/linux/ethtool.h | 1 + 1 file changed, 1 insertion(+)
include/linux/ethtool.h +1 -0
@@ -215,6 +215,7 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,#define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)#define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20)#define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) +#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(21, 0)#define ETHTOOL_COALESCE_USECS \ (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
Signature · 1 line
2.28.0
PATCH v3 2/4 netdevsim: support ethtool ring and coalesce settings
Add ethtool ring and coalesce settings support for testing.
--- drivers/net/netdevsim/ethtool.c | 82 ++++++++++++++++++++++++++----- drivers/net/netdevsim/netdevsim.h | 9 +++- 2 files changed, 79 insertions(+), 12 deletions(-)
drivers/net/netdevsim/ethtool.c +71 -11
@@ -13,9 +13,9 @@ nsim_get_pause_stats(struct net_device *dev, {struct netdevsim *ns =netdev_priv (dev); -if (ns->ethtool.report_stats_rx) +if (ns->ethtool.pauseparam.report_stats_rx) pause_stats->rx_pause_frames =1 ; -if (ns->ethtool.report_stats_tx) +if (ns->ethtool.pauseparam.report_stats_tx) pause_stats->tx_pause_frames =2 ; }
@@ -25,8 +25,8 @@ nsim_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)struct netdevsim *ns =netdev_priv (dev); pause->autoneg =0 ;/* We don't support ksettings, so can't pretend */ - pause->rx_pause = ns->ethtool.rx; - pause->tx_pause = ns->ethtool.tx; + pause->rx_pause = ns->ethtool.pauseparam.rx; + pause->tx_pause = ns->ethtool.pauseparam.tx; } static int
@@ -37,28 +37,88 @@ nsim_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)if (pause->autoneg)return -EINVAL ; - ns->ethtool.rx = pause->rx_pause; - ns->ethtool.tx = pause->tx_pause; + ns->ethtool.pauseparam.rx = pause->rx_pause; + ns->ethtool.pauseparam.tx = pause->tx_pause; +return 0 ; +} + +static int nsim_get_coalesce (struct net_device *dev, +struct ethtool_coalesce *coal) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (coal, &ns->ethtool.coalesce,sizeof (ns->ethtool.coalesce)); +return 0 ; +} + +static int nsim_set_coalesce (struct net_device *dev, +struct ethtool_coalesce *coal) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (&ns->ethtool.coalesce, coal,sizeof (ns->ethtool.coalesce)); +return 0 ; +} + +static void nsim_get_ringparam (struct net_device *dev, +struct ethtool_ringparam *ring) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (ring, &ns->ethtool.ring,sizeof (ns->ethtool.ring)); +} + +static int nsim_set_ringparam (struct net_device *dev, +struct ethtool_ringparam *ring) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (&ns->ethtool.ring, ring,sizeof (ns->ethtool.ring));return 0 ; }static const struct ethtool_ops nsim_ethtool_ops = { - .get_pause_stats = nsim_get_pause_stats, - .get_pauseparam = nsim_get_pauseparam, - .set_pauseparam = nsim_set_pauseparam, + .get_pause_stats = nsim_get_pause_stats, + .get_pauseparam = nsim_get_pauseparam, + .set_pauseparam = nsim_set_pauseparam, + .supported_coalesce_params =ETHTOOL_COALESCE_ALL_PARAMS , + .set_coalesce = nsim_set_coalesce, + .get_coalesce = nsim_get_coalesce, + .get_ringparam = nsim_get_ringparam, + .set_ringparam = nsim_set_ringparam, }; +static void nsim_ethtool_ring_init (struct netdevsim *ns) +{ + ns->ethtool.ring.rx_max_pending =4096 ; + ns->ethtool.ring.rx_jumbo_max_pending =4096 ; + ns->ethtool.ring.rx_mini_max_pending =4096 ; + ns->ethtool.ring.tx_max_pending =4096 ; +} +void nsim_ethtool_init (struct netdevsim *ns) {struct dentry *ethtool, *dir; ns->netdev->ethtool_ops = &nsim_ethtool_ops; +nsim_ethtool_ring_init (ns); + ethtool =debugfs_create_dir ("ethtool" , ns->nsim_dev_port->ddir); dir =debugfs_create_dir ("pause" , ethtool);debugfs_create_bool ("report_stats_rx" ,0600 , dir, - &ns->ethtool.report_stats_rx); + &ns->ethtool.pauseparam.report_stats_rx);debugfs_create_bool ("report_stats_tx" ,0600 , dir, - &ns->ethtool.report_stats_tx); + &ns->ethtool.pauseparam.report_stats_tx); + + dir =debugfs_create_dir ("ring" , ethtool); +debugfs_create_u32 ("rx_max_pending" ,0600 , dir, + &ns->ethtool.ring.rx_max_pending); +debugfs_create_u32 ("rx_jumbo_max_pending" ,0600 , dir, + &ns->ethtool.ring.rx_jumbo_max_pending); +debugfs_create_u32 ("rx_mini_max_pending" ,0600 , dir, + &ns->ethtool.ring.rx_mini_max_pending); +debugfs_create_u32 ("tx_max_pending" ,0600 , dir, + &ns->ethtool.ring.tx_max_pending); }
drivers/net/netdevsim/netdevsim.h +8 -1
@@ -15,6 +15,7 @@#include <linux/debugfs.h> #include <linux/device.h> +#include <linux/ethtool.h> #include <linux/kernel.h> #include <linux/list.h> #include <linux/netdevice.h>
@@ -51,13 +52,19 @@ struct nsim_ipsec {u32 ok; }; -struct nsim_ethtool { +struct nsim_ethtool_pauseparam {bool rx;bool tx;bool report_stats_rx;bool report_stats_tx; }; +struct nsim_ethtool { +struct nsim_ethtool_pauseparam pauseparam; +struct ethtool_coalesce coalesce; +struct ethtool_ringparam ring; +}; +struct netdevsim {struct net_device *netdev;struct nsim_dev *nsim_dev;
Signature · 1 line
2.28.0
Re: [PATCH net-next v3 2/4] netdevsim: support ethtool ring and coalesce settings
Quoted 3 lines · Antonio Cardace
Add ethtool ring and coalesce settings support for testing.
Signed-off-by Antonio Cardace <[email protected]>
Jakub Kicinski
maintainerRe: [PATCH net-next v3 2/4] netdevsim: support ethtool ring and coalesce settings
In reply to Antonio CardaceQuoted 28 lines · On Sat, 14 Nov 2020 00:16:53 +0100 Antonio Cardace wrote:
drivers/net/netdevsim/ethtool.c +4
-4@@ -13,9 +13,9 @@ nsim_get_pause_stats(struct net_device *dev, {struct netdevsim *ns =netdev_priv (dev); -if (ns->ethtool.report_stats_rx) +if (ns->ethtool.pauseparam.report_stats_rx) pause_stats->rx_pause_frames =1 ; -if (ns->ethtool.report_stats_tx) +if (ns->ethtool.pauseparam.report_stats_tx) pause_stats->tx_pause_frames =2 ; }@@ -25,8 +25,8 @@ nsim_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)struct netdevsim *ns =netdev_priv (dev); pause->autoneg =0 ;/* We don't support ksettings, so can't pretend */ - pause->rx_pause = ns->ethtool.rx; - pause->tx_pause = ns->ethtool.tx; + pause->rx_pause = ns->ethtool.pauseparam.rx; + pause->tx_pause = ns->ethtool.pauseparam.tx; } static int
drivers/net/netdevsim/ethtool.c nsim_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) · line 43
Quoted 9 lines
drivers/net/netdevsim/ethtool.c +4
-2@@ -37,28 +37,88 @@ nsim_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)if (pause->autoneg)return -EINVAL ; - ns->ethtool.rx = pause->rx_pause; - ns->ethtool.tx = pause->tx_pause; + ns->ethtool.pauseparam.rx = pause->rx_pause; + ns->ethtool.pauseparam.tx = pause->tx_pause; +return 0 ; +}
Please separate the refactoring / moving pauseparam into another struct out to its own patch. This makes review easier.
Quoted 33 lines
drivers/net/netdevsim/ethtool.c +32
-0+static int nsim_get_coalesce (struct net_device *dev, +struct ethtool_coalesce *coal) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (coal, &ns->ethtool.coalesce,sizeof (ns->ethtool.coalesce)); +return 0 ; +} + +static int nsim_set_coalesce (struct net_device *dev, +struct ethtool_coalesce *coal) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (&ns->ethtool.coalesce, coal,sizeof (ns->ethtool.coalesce)); +return 0 ; +} + +static void nsim_get_ringparam (struct net_device *dev, +struct ethtool_ringparam *ring) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (ring, &ns->ethtool.ring,sizeof (ns->ethtool.ring)); +} + +static int nsim_set_ringparam (struct net_device *dev, +struct ethtool_ringparam *ring) +{ +struct netdevsim *ns =netdev_priv (dev); + +memcpy (&ns->ethtool.ring, ring,sizeof (ns->ethtool.ring));return 0 ;
drivers/net/netdevsim/ethtool.c nsim_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause) · line 84
Quoted 10 lines
drivers/net/netdevsim/ethtool.c +4
-3}static const struct ethtool_ops nsim_ethtool_ops = { - .get_pause_stats = nsim_get_pause_stats, - .get_pauseparam = nsim_get_pauseparam, - .set_pauseparam = nsim_set_pauseparam, + .get_pause_stats = nsim_get_pause_stats, + .get_pauseparam = nsim_get_pauseparam, + .set_pauseparam = nsim_set_pauseparam, + .supported_coalesce_params =ETHTOOL_COALESCE_ALL_PARAMS ,
Please make this member first. I think that's what all drivers do.
Quoted 5 lines
drivers/net/netdevsim/ethtool.c +4
-0+ .set_coalesce = nsim_set_coalesce, + .get_coalesce = nsim_get_coalesce, + .get_ringparam = nsim_get_ringparam, + .set_ringparam = nsim_set_ringparam, };
PATCH v3 3/4 selftests: extract common functions in ethtool-common.sh
In reply to Antonio CardaceFactor out some useful functions so that they can be reused by other ethtool-netdevsim scripts.
--- .../drivers/net/netdevsim/ethtool-common.sh | 69 +++++++++++++++++++ .../drivers/net/netdevsim/ethtool-pause.sh | 63 +---------------- 2 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh new file +69 -0
@@ -0,0 +1,69 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +NSIM_ID=$((RANDOM % 1024)) +NSIM_DEV_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_ID +NSIM_DEV_DFS=/sys/kernel/debug/netdevsim/netdevsim$NSIM_ID/ports/0 +NSIM_NETDEV= +num_passes=0 +num_errors=0 + +function cleanup_nsim { + if [ -e $NSIM_DEV_SYS ]; then + echo $NSIM_ID > /sys/bus/netdevsim/del_device + fi +} + +function cleanup { + cleanup_nsim +} + +trap cleanup EXIT + +function get_netdev_name { + local -n old=$1 + + new=$(ls /sys/class/net) + + for netdev in $new; do + for check in $old; do + [ $netdev == $check ] && break + done + + if [ $netdev != $check ]; then + echo $netdev + break + fi + done +} + +function check { + local code=$1 + local str=$2 + local exp_str=$3 + + if [ $code -ne 0 ]; then + ((num_errors++)) + return + fi + + if [ "$str" != "$exp_str" ]; then + echo -e "Expected: '$exp_str', got '$str'" + ((num_errors++)) + return + fi + + ((num_passes++)) +} + +function make_netdev { + # Make a netdevsim + old_netdevs=$(ls /sys/class/net) + + if ! $(lsmod | grep -q netdevsim); then + modprobe netdevsim + fi + + echo $NSIM_ID > /sys/bus/netdevsim/new_device + echo `get_netdev_name old_netdevs` +}
tools/testing/selftests/drivers/net/netdevsim/ethtool-pause.sh +2 -61
75 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH net-next v3 3/4] selftests: extract common functions in ethtool-common.sh
Quoted 4 lines · Antonio Cardace
Factor out some useful functions so that they can be reused by other ethtool-netdevsim scripts.
Signed-off-by Antonio Cardace <[email protected]>
Just one comment:
[...]
Quoted 16 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh new file +16
-0+function get_netdev_name { + local -n old=$1 + + new=$(ls /sys/class/net) + + for netdev in $new; do + for check in $old; do + [ $netdev == $check ] && break + done + + if [ $netdev != $check ]; then + echo $netdev + break + fi + done +}
[...]
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh line 69
Quoted 11 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh new file +11
-0+function make_netdev { + # Make a netdevsim + old_netdevs=$(ls /sys/class/net) + + if ! $(lsmod | grep -q netdevsim); then + modprobe netdevsim + fi + + echo $NSIM_ID > /sys/bus/netdevsim/new_device + echo `get_netdev_name old_netdevs` +}
This would be rather unpredictable if someone ran another selftest (or anything else that would create a network device) in parallel. IMHO it would be safer (and easier) to get the name of the new device from
/sys/bus/netdevsim/devices/netdevsim${NSIM_ID}/net/But as this is not new code and you are just moving existing code, it can be done in a separate patch.
Michal
Re: [PATCH net-next v3 3/4] selftests: extract common functions in ethtool-common.sh
Quoted 44 lines · Michal Kubecek
Quoted 4 lines · Antonio Cardace
Factor out some useful functions so that they can be reused by other ethtool-netdevsim scripts.
Signed-off-by Antonio Cardace <[email protected]>Reviewed-by Michal Kubecek <[email protected]>Just one comment:
[...]
Quoted 16 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh new file +16
-0+function get_netdev_name { + local -n old=$1 + + new=$(ls /sys/class/net) + + for netdev in $new; do + for check in $old; do + [ $netdev == $check ] && break + done + + if [ $netdev != $check ]; then + echo $netdev + break + fi + done +}[...]
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh line 69
Quoted 11 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-common.sh new file +11
-0+function make_netdev { + # Make a netdevsim + old_netdevs=$(ls /sys/class/net) + + if ! $(lsmod | grep -q netdevsim); then + modprobe netdevsim + fi + + echo $NSIM_ID > /sys/bus/netdevsim/new_device + echo `get_netdev_name old_netdevs` +}This would be rather unpredictable if someone ran another selftest (or anything else that would create a network device) in parallel. IMHO it would be safer (and easier) to get the name of the new device from
Quoted 4 lines
/sys/bus/netdevsim/devices/netdevsim${NSIM_ID}/net/But as this is not new code and you are just moving existing code, it can be done in a separate patch.
Yes it does make sense, I can send a patch for this once this is merged.
Thanks for the review.
Antonio
PATCH v3 4/4 selftests: add ring and coalesce selftests
In reply to Antonio CardaceAdd scripts to test ring and coalesce settings
of netdevsim.
--- .../drivers/net/netdevsim/ethtool-coalesce.sh | 68 +++++++++++++++++++ .../drivers/net/netdevsim/ethtool-ring.sh | 53 +++++++++++++++ 2 files changed, 121 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh create mode 100755 tools/testing/selftests/drivers/net/netdevsim/ethtool-ring.sh
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +68 -0
@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh + +function get_value { + local key=$1 + + echo $(ethtool -c $NSIM_NETDEV | \ + awk -F':' -v pattern="$key:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}') +} + +if ! ethtool -h | grep -q coalesce; then + echo "SKIP: No --coalesce support in ethtool" + exit 4 +fi + +NSIM_NETDEV=$(make_netdev) + +set -o pipefail + +declare -A SETTINGS_MAP=( + ["rx-frames-low"]="rx-frame-low" + ["tx-frames-low"]="tx-frame-low" + ["rx-frames-high"]="rx-frame-high" + ["tx-frames-high"]="tx-frame-high" + ["rx-usecs"]="rx-usecs" + ["rx-frames"]="rx-frames" + ["rx-usecs-irq"]="rx-usecs-irq" + ["rx-frames-irq"]="rx-frames-irq" + ["tx-usecs"]="tx-usecs" + ["tx-frames"]="tx-frames" + ["tx-usecs-irq"]="tx-usecs-irq" + ["tx-frames-irq"]="tx-frames-irq" + ["stats-block-usecs"]="stats-block-usecs" + ["pkt-rate-low"]="pkt-rate-low" + ["rx-usecs-low"]="rx-usecs-low" + ["tx-usecs-low"]="tx-usecs-low" + ["pkt-rate-high"]="pkt-rate-high" + ["rx-usecs-high"]="rx-usecs-high" + ["tx-usecs-high"]="tx-usecs-high" + ["sample-interval"]="sample-interval" +) + +for key in ${!SETTINGS_MAP[@]}; do + query_key=${SETTINGS_MAP[$key]} + value=$((RANDOM % $((2**32-1)))) + ethtool -C $NSIM_NETDEV "$key" "$value" + s=$(get_value "$query_key") + check $? "$s" "$value" +done + +# bool settings which ethtool displays on the same line +ethtool -C $NSIM_NETDEV adaptive-rx on +s=$(ethtool -c $NSIM_NETDEV | grep -q "Adaptive RX: on TX: off") +check $? "$s" "" + +ethtool -C $NSIM_NETDEV adaptive-tx on +s=$(ethtool -c $NSIM_NETDEV | grep -q "Adaptive RX: on TX: on") +check $? "$s" "" + +if [ $num_errors -eq 0 ]; then + echo "PASSED all $((num_passes)) checks" + exit 0 +else + echo "FAILED $num_errors/$((num_errors+num_passes)) checks" + exit 1 +fi
tools/testing/selftests/drivers/net/netdevsim/ethtool-ring.sh new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
2.28.0
Jakub Kicinski
maintainerRe: [PATCH net-next v3 4/4] selftests: add ring and coalesce selftests
Quoted 11 lines · On Sat, 14 Nov 2020 00:16:55 +0100 Antonio Cardace wrote:
Add scripts to test ring and coalesce settings
of netdevsim.Signed-off-by Antonio Cardace <[email protected]>tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +5
-0@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh +
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 15
Quoted 10 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +10
-0+function get_value { + local key=$1 + + echo $(ethtool -c $NSIM_NETDEV | \ + awk -F':' -v pattern="$key:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}') +} + +if ! ethtool -h | grep -q coalesce; then + echo "SKIP: No --coalesce support in ethtool" + exit 4
I think the skip exit code for selftests is 2
Quoted 24 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +24
-0+fi + +NSIM_NETDEV=$(make_netdev) + +set -o pipefail + +declare -A SETTINGS_MAP=( + ["rx-frames-low"]="rx-frame-low" + ["tx-frames-low"]="tx-frame-low" + ["rx-frames-high"]="rx-frame-high" + ["tx-frames-high"]="tx-frame-high" + ["rx-usecs"]="rx-usecs" + ["rx-frames"]="rx-frames" + ["rx-usecs-irq"]="rx-usecs-irq" + ["rx-frames-irq"]="rx-frames-irq" + ["tx-usecs"]="tx-usecs" + ["tx-frames"]="tx-frames" + ["tx-usecs-irq"]="tx-usecs-irq" + ["tx-frames-irq"]="tx-frames-irq" + ["stats-block-usecs"]="stats-block-usecs" + ["pkt-rate-low"]="pkt-rate-low" + ["rx-usecs-low"]="rx-usecs-low" + ["tx-usecs-low"]="tx-usecs-low" + ["pkt-rate-high"]="pkt-rate-high"
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 49
Quoted 10 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +10
-0+ ["rx-usecs-high"]="rx-usecs-high" + ["tx-usecs-high"]="tx-usecs-high" + ["sample-interval"]="sample-interval" +) + +for key in ${!SETTINGS_MAP[@]}; do + query_key=${SETTINGS_MAP[$key]} + value=$((RANDOM % $((2**32-1)))) + ethtool -C $NSIM_NETDEV "$key" "$value" + s=$(get_value "$query_key")
It would be better to validate the entire config, not just the most recently set key. This way we would catch the cases where setting attr breaks the value of another.
Quoted 2 lines
(quoted diff) +2
-0+ check $? "$s" "$value" +done
Re: [PATCH net-next v3 4/4] selftests: add ring and coalesce selftests
Quoted 16 lines · Jakub Kicinski
Quoted 15 lines · On Sat, 14 Nov 2020 00:16:55 +0100 Antonio Cardace wrote:
Add scripts to test ring and coalesce settings
of netdevsim.Signed-off-by Antonio Cardace <[email protected]>tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +9
-0@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh + +function get_value { + local key=$1 + + echo $(ethtool -c $NSIM_NETDEV | \
Quoted 8 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 15
Quoted 6 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +6
-0+ awk -F':' -v pattern="$key:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}') +} + +if ! ethtool -h | grep -q coalesce; then + echo "SKIP: No --coalesce support in ethtool" + exit 4I think the skip exit code for selftests is 2
In the ethtool-pause.sh selftest the exit code is 4 (I copied it from there), should I change that too?
Quoted 31 lines
Quoted 31 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +30
-0+fi + +NSIM_NETDEV=$(make_netdev) + +set -o pipefail + +declare -A SETTINGS_MAP=( + ["rx-frames-low"]="rx-frame-low" + ["tx-frames-low"]="tx-frame-low" + ["rx-frames-high"]="rx-frame-high" + ["tx-frames-high"]="tx-frame-high" + ["rx-usecs"]="rx-usecs" + ["rx-frames"]="rx-frames" + ["rx-usecs-irq"]="rx-usecs-irq" + ["rx-frames-irq"]="rx-frames-irq" + ["tx-usecs"]="tx-usecs" + ["tx-frames"]="tx-frames" + ["tx-usecs-irq"]="tx-usecs-irq" + ["tx-frames-irq"]="tx-frames-irq" + ["stats-block-usecs"]="stats-block-usecs" + ["pkt-rate-low"]="pkt-rate-low" + ["rx-usecs-low"]="rx-usecs-low" + ["tx-usecs-low"]="tx-usecs-low" + ["pkt-rate-high"]="pkt-rate-high" + ["rx-usecs-high"]="rx-usecs-high" + ["tx-usecs-high"]="tx-usecs-high" + ["sample-interval"]="sample-interval" +) + +for key in ${!SETTINGS_MAP[@]}; do
Quoted 9 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 49
Quoted 4 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +4
-0+ query_key=${SETTINGS_MAP[$key]} + value=$((RANDOM % $((2**32-1)))) + ethtool -C $NSIM_NETDEV "$key" "$value" + s=$(get_value "$query_key")It would be better to validate the entire config, not just the most recently set key. This way we would catch the cases where setting attr breaks the value of another.
Good idea, will do.
Thanks,
Antonio
Jakub Kicinski
maintainerRe: [PATCH net-next v3 4/4] selftests: add ring and coalesce selftests
Quoted 25 lines · On Tue, 17 Nov 2020 12:32:36 +0100 Antonio Cardace wrote:
Quoted 16 lines · Jakub Kicinski
Quoted 15 lines · On Sat, 14 Nov 2020 00:16:55 +0100 Antonio Cardace wrote:
Add scripts to test ring and coalesce settings
of netdevsim.Signed-off-by Antonio Cardace <[email protected]>tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +9
-0@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh + +function get_value { + local key=$1 + + echo $(ethtool -c $NSIM_NETDEV | \Quoted 8 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 15
Quoted 6 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +6
-0+ awk -F':' -v pattern="$key:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}') +} + +if ! ethtool -h | grep -q coalesce; then + echo "SKIP: No --coalesce support in ethtool" + exit 4I think the skip exit code for selftests is 2
Quoted 2 lines
In the
ethtool-pause.shselftest the exit code is 4 (I copied it from there), should I change that too?
Sorry I misremembered it's 4. We can leave that as is.
Re: [PATCH net-next v3 4/4] selftests: add ring and coalesce selftests
Quoted 27 lines · Jakub Kicinski
Quoted 25 lines · On Tue, 17 Nov 2020 12:32:36 +0100 Antonio Cardace wrote:
Quoted 24 lines · Jakub Kicinski
Quoted 11 lines · On Sat, 14 Nov 2020 00:16:55 +0100 Antonio Cardace wrote:
Add scripts to test ring and coalesce settings
of netdevsim.Signed-off-by Antonio Cardace <[email protected]>tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +5
-0@@ -0,0 +1,68 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +source ethtool-common.sh +tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh line 15
Quoted 10 lines
tools/testing/selftests/drivers/net/netdevsim/ethtool-coalesce.sh new file +10
-0+function get_value { + local key=$1 + + echo $(ethtool -c $NSIM_NETDEV | \ + awk -F':' -v pattern="$key:" '$0 ~ pattern {gsub(/[ \t]/, "", $2); print $2}') +} + +if ! ethtool -h | grep -q coalesce; then + echo "SKIP: No --coalesce support in ethtool" + exit 4I think the skip exit code for selftests is 2
Quoted 4 lines
Quoted 2 lines
In the
ethtool-pause.shselftest the exit code is 4 (I copied it from there), should I change that too?Sorry I misremembered it's 4. We can leave that as is.
Instead of having to remember, maybe we should have a file in tools/testing/selftest to define constants?
I defined them one-off in tools/testing/selftests/net/udpgso_bench.sh
readonly KSFT_PASS=0
readonly KSFT_FAIL=1
readonly KSFT_SKIP=4
along with some other kselftest shell support infra. But having each test figure this out independently is duplicative and error prone.
Jakub Kicinski
maintainerRe: [PATCH net-next v3 4/4] selftests: add ring and coalesce selftests
Quoted 6 lines · On Wed, 18 Nov 2020 16:43:33 -0500 Willem de Bruijn wrote:
Quoted 1 line · Jakub Kicinski
Sorry I misremembered it's 4. We can leave that as is.
Instead of having to remember, maybe we should have a file in
tools/testing/selftestto define constants?
Quoted 8 lines
I defined them one-off in
tools/testing/selftests/net/udpgso_bench.shreadonly KSFT_PASS=0
readonly KSFT_FAIL=1
readonly KSFT_SKIP=4along with some other kselftest shell support infra. But having each test figure this out independently is duplicative and error prone.
Sounds like a good idea, I was surprised it wasn't already defined in any lib.
CCing the selftest ML.
Quoted 3 lines · Antonio Cardace
This bitmask represents all existing coalesce parameters.
Signed-off-by Antonio Cardace <[email protected]>
Quoted 19 lines
--- include/linux/ethtool.h | 1 + 1 file changed, 1 insertion(+)include/linux/ethtool.h +1
-0@@ -215,6 +215,7 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,#define ETHTOOL_COALESCE_TX_USECS_HIGH BIT(19)#define ETHTOOL_COALESCE_TX_MAX_FRAMES_HIGH BIT(20)#define ETHTOOL_COALESCE_RATE_SAMPLE_INTERVAL BIT(21) +#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(21, 0)#define ETHTOOL_COALESCE_USECS \ (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)Signature · 1 line
2.28.0
Jakub Kicinski
maintainerPlease add a cover letter to this series.
Preferably with the output of the test passing :)