Add initial devlink support for idpf and a matching selftest.
Patch 1 consolidates the drvdata clear into idpf_decfg_device(), the
declared inverse of idpf_cfg_device() which sets it.
Patch 2 adds the devlink instance and implements .info_get, reporting:
- serial_number: PCI Device Serial Number, for NIPA CI identification
- fw.mgmt.api (running): driver-device communication protocol version
This follows a phased approach and reports stable, readily-available
information. Firmware version support will be added in future patches as
it becomes available through virtchnl.
Patch 3 adds a hardware selftest that logs devlink info in the format
NIPA CI consumes.
The changes in both revisions below address findings from Sashiko AI
review of the series, together with direct review comments on v2.
v2 -> v3:
- Patch 1:
- Drop the comment above pci_set_drvdata().
- Patch 2 (was patches 2 and 3 in v2, now squashed):
- Register the instance in idpf_probe() rather than from the reset
worker, so it stays available for the whole time the driver is
bound, including when the virtchnl handshake never succeeds. This
drops the IDPF_DEVLINK_REGISTERED flag added in v2 and no longer
touches idpf.h or idpf_lib.c.
- Omit the virtchnl version until it has been negotiated, as the
instance is now registered before the handshake runs.
- Read the version fields with READ_ONCE().
- Include linux/pci.h and linux/unaligned.h directly.
- Fix the SPDX identifier and copyright style in idpf_devlink.h.
- Patch 3:
- Report skips through log_test_skip() so that a ksft result line is
emitted for every exit path.
- Do not fail when the driver name is absent; whether it appears in
the JSON depends on the installed iproute2 rather than the kernel.
v1 -> v2:
- Patch 1:
- Move the drvdata clear into idpf_decfg_device() so it pairs with the
set in idpf_cfg_device(), instead of adding a second, redundant
pci_set_drvdata(NULL) at idpf_probe()'s err_free label.
- Patch 2:
- Select NET_DEVLINK in Kconfig.
- Omit serial_number when the device reports no PCI DSN, instead of
reporting an all-zero serial number.
- Pass the buffer size to the DSN helper rather than hardcoding it.
- Patch 3:
- Read NETIF from drivers/net/net.config as documented in
drivers/net/README.rst, in addition to the environment.
- Skip, rather than fail, devices that report no versions and no serial
number; implementing devlink info is optional and devlink reports a
driver name even when info_get is absent.
- Count and log board.serial_number.
- Treat a devlink/ethtool driver name difference as informational; it
is legitimate for e.g. mlx4 and DSA user ports.
- Do not require ethtool; it is only used for an optional fallback
handle lookup and the driver name comparison.
- Query devlink dev info once and validate a single snapshot.
- Log the reported versions.
Paul Greenwalt (3):
idpf: clear drvdata in idpf_decfg_device()
idpf: add devlink support
selftests: net: hw: add devlink info test
Documentation/networking/devlink/idpf.rst | 30 ++++
Documentation/networking/devlink/index.rst | 1 +
drivers/net/ethernet/intel/idpf/Kconfig | 1 +
drivers/net/ethernet/intel/idpf/Makefile | 1 +
.../net/ethernet/intel/idpf/idpf_devlink.c | 98 +++++++++++
.../net/ethernet/intel/idpf/idpf_devlink.h | 45 +++++
drivers/net/ethernet/intel/idpf/idpf_main.c | 16 +-
.../testing/selftests/drivers/net/hw/Makefile | 1 +
.../selftests/drivers/net/hw/devlink_info.sh | 158 ++++++++++++++++++
9 files changed, 347 insertions(+), 4 deletions(-)
create mode 100644 Documentation/networking/devlink/idpf.rst
create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devlink.c
create mode 100644 drivers/net/ethernet/intel/idpf/idpf_devlink.h
create mode 100755 tools/testing/selftests/drivers/net/hw/devlink_info.sh
--
2.52.0