Skip to content

Commit 583024c

Browse files
author
Paolo Abeni
committed
Merge branch 'netdevsim-support-for-l3-hw-stats'
Petr Machata says: ==================== netdevsim: Support for L3 HW stats "L3 stats" is a suite of interface statistics aimed at reflecting traffic taking place in a HW device, on an object corresponding to some software netdevice. Support for this stats suite has been added recently, in commit ca0a53d ("Merge branch 'net-hw-counters-for-soft-devices'"). In this patch set: - Patch #1 adds support for L3 stats to netdevsim. Real devices can have various conditions for when an L3 counter is available. To simulate this, netdevsim maintains a list of devices suitable for HW stats collection. Only when l3_stats is enabled on both a netdevice itself, and in netdevsim, will netdevsim contribute values to L3 stats. This enablement and disablement is done via debugfs: # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/enable_ifindex # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/disable_ifindex Besides this, there is a third toggle to mark a device for future failure: # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/fail_next_enable - This allows HW-independent testing of stats reporting and in-kernel APIs, as well as a test for enablement rollback, which is difficult to do otherwise. This netdevsim-specific selftest is added in patch #2. - Patch #3 adds another driver-specific selftest, namely a test aimed at checking mlxsw-induced stats monitoring events. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 231fdac + ed2ae69 commit 583024c

File tree

7 files changed

+1037
-3
lines changed

7 files changed

+1037
-3
lines changed

drivers/net/netdevsim/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
obj-$(CONFIG_NETDEVSIM) += netdevsim.o
44

55
netdevsim-objs := \
6-
netdev.o dev.o ethtool.o fib.o bus.o health.o udp_tunnels.o
6+
netdev.o dev.o ethtool.o fib.o bus.o health.o hwstats.o udp_tunnels.o
77

88
ifeq ($(CONFIG_BPF_SYSCALL),y)
99
netdevsim-objs += \

drivers/net/netdevsim/dev.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,17 +1498,23 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
14981498
if (err)
14991499
goto err_health_exit;
15001500

1501-
err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
1501+
err = nsim_dev_hwstats_init(nsim_dev);
15021502
if (err)
15031503
goto err_psample_exit;
15041504

1505+
err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
1506+
if (err)
1507+
goto err_hwstats_exit;
1508+
15051509
nsim_dev->take_snapshot = debugfs_create_file("take_snapshot",
15061510
0200,
15071511
nsim_dev->ddir,
15081512
nsim_dev,
15091513
&nsim_dev_take_snapshot_fops);
15101514
return 0;
15111515

1516+
err_hwstats_exit:
1517+
nsim_dev_hwstats_exit(nsim_dev);
15121518
err_psample_exit:
15131519
nsim_dev_psample_exit(nsim_dev);
15141520
err_health_exit:
@@ -1595,15 +1601,21 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
15951601
if (err)
15961602
goto err_bpf_dev_exit;
15971603

1598-
err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
1604+
err = nsim_dev_hwstats_init(nsim_dev);
15991605
if (err)
16001606
goto err_psample_exit;
16011607

1608+
err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
1609+
if (err)
1610+
goto err_hwstats_exit;
1611+
16021612
nsim_dev->esw_mode = DEVLINK_ESWITCH_MODE_LEGACY;
16031613
devlink_set_features(devlink, DEVLINK_F_RELOAD);
16041614
devlink_register(devlink);
16051615
return 0;
16061616

1617+
err_hwstats_exit:
1618+
nsim_dev_hwstats_exit(nsim_dev);
16071619
err_psample_exit:
16081620
nsim_dev_psample_exit(nsim_dev);
16091621
err_bpf_dev_exit:
@@ -1648,6 +1660,7 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
16481660
mutex_unlock(&nsim_dev->vfs_lock);
16491661

16501662
nsim_dev_port_del_all(nsim_dev);
1663+
nsim_dev_hwstats_exit(nsim_dev);
16511664
nsim_dev_psample_exit(nsim_dev);
16521665
nsim_dev_health_exit(nsim_dev);
16531666
nsim_fib_destroy(devlink, nsim_dev->fib_data);

0 commit comments

Comments
 (0)