Commit Graph

2 Commits

Author SHA1 Message Date
Ivan Vecera 52b6ac2417 netdevsim: Fix hwstats debugfs file permissions
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2140149

commit 34513ada53eb3e3f711250d8dbc2de4de493d510
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Fri Sep 9 18:38:30 2022 +0300

    netdevsim: Fix hwstats debugfs file permissions

    The hwstats debugfs files are only writeable, but they are created with
    read and write permissions, causing certain selftests to fail [1].

    Fix by creating the files with write permission only.

    [1]
     # ./test_offload.py
     Test destruction of generic XDP...
     Traceback (most recent call last):
       File "/home/idosch/code/linux/tools/testing/selftests/bpf/./test_offload.py", line 810, in <module>
         simdev = NetdevSimDev()
     [...]
     Exception: Command failed: cat /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/hwstats/l3/disable_ifindex

     cat: /sys/kernel/debug/netdevsim/netdevsim0//ports/0/dev/hwstats/l3/disable_ifindex: Invalid argument

    Fixes: 1a6d7ae7d63c ("netdevsim: Introduce support for L3 offload xstats")
    Reported-by: Jie2x Zhou <jie2x.zhou@intel.com>
    Tested-by: Jie2x Zhou <jie2x.zhou@intel.com>
    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Petr Machata <petrm@nvidia.com>
    Link: https://lore.kernel.org/r/20220909153830.3732504-1-idosch@nvidia.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-11-04 20:01:06 +01:00
Ivan Vecera 6a03fa2a91 netdevsim: Introduce support for L3 offload xstats
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2140149

commit 1a6d7ae7d63c4572676f4cc94aa35a73dc14a757
Author: Petr Machata <petrm@nvidia.com>
Date:   Mon Mar 14 15:01:15 2022 +0100

    netdevsim: Introduce support for L3 offload xstats

    Add support for testing of HW stats support that was added recently, namely
    the L3 stats support. L3 stats are provided for devices for which the L3
    stats have been turned on, and that were enabled for netdevsim through a
    debugfs toggle:

        # echo $ifindex > /sys/kernel/debug/netdevsim/$DEV/hwstats/l3/enable_ifindex

    For fully enabled netdevices, netdevsim counts 10pps of ingress traffic and
    20pps of egress traffic. Similarly, L3 stats can be disabled for a given
    device, and netdevsim ceases pretending there is any HW traffic going on:

        # 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

    A future request to enable L3 stats on such netdevice will be bounced by
    netdevsim:

        # ip -j l sh dev d | jq '.[].ifindex'
        66
        # echo 66 > /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/enable_ifindex
        # echo 66 > /sys/kernel/debug/netdevsim/netdevsim10/hwstats/l3/fail_next_enable
        # ip stats set dev d l3_stats on
        Error: netdevsim: Stats enablement set to fail.

    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2022-11-04 17:25:41 +01:00