* [PATCH iwl-next 0/3] idpf: add devlink info support with selftest
@ 2026-08-14 17:49 Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 1/3] idpf: clear drvdata on probe error path Paul Greenwalt
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paul Greenwalt @ 2026-08-14 17:49 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, Paul Greenwalt
Add initial devlink info support for idpf and a matching selftest.
Patch 1 fixes probe unwind by clearing drvdata on the error path.
Patch 2 introduces an idpf devlink instance and reports:
- serial_number: 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 validates basic devlink info
reporting and matches test patterns used by NIPA CI.
Paul Greenwalt (3):
idpf: clear drvdata on probe error path
idpf: add devlink info support
selftests: net: hw: add devlink info test
Documentation/networking/devlink/idpf.rst | 29 +++++
Documentation/networking/devlink/index.rst | 1 +
drivers/net/ethernet/intel/idpf/Makefile | 1 +
.../net/ethernet/intel/idpf/idpf_devlink.c | 79 ++++++++++++
.../net/ethernet/intel/idpf/idpf_devlink.h | 45 +++++++
drivers/net/ethernet/intel/idpf/idpf_main.c | 13 +-
.../testing/selftests/drivers/net/hw/Makefile | 1 +
.../selftests/drivers/net/hw/devlink_info.sh | 119 ++++++++++++++++++
8 files changed, 285 insertions(+), 3 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH iwl-next 1/3] idpf: clear drvdata on probe error path
2026-08-14 17:49 [PATCH iwl-next 0/3] idpf: add devlink info support with selftest Paul Greenwalt
@ 2026-08-14 17:49 ` Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 2/3] idpf: add devlink info support Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 3/3] selftests: net: hw: add devlink info test Paul Greenwalt
2 siblings, 0 replies; 4+ messages in thread
From: Paul Greenwalt @ 2026-08-14 17:49 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, Paul Greenwalt, Przemek Kitszel, Aleksandr Loktionov
If idpf_probe() fails after idpf_cfg_device() succeeds,
pci_set_drvdata() leaves a pointer to freed memory. Clear
it before freeing the adapter to prevent potential
use-after-free if anything accesses pci_get_drvdata().
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
---
drivers/net/ethernet/intel/idpf/idpf_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
index 807608899084..6f9579c39342 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_main.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
@@ -364,6 +364,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_init_wq:
idpf_decfg_device(adapter);
err_free:
+ pci_set_drvdata(pdev, NULL);
kfree(adapter);
return err;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iwl-next 2/3] idpf: add devlink info support
2026-08-14 17:49 [PATCH iwl-next 0/3] idpf: add devlink info support with selftest Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 1/3] idpf: clear drvdata on probe error path Paul Greenwalt
@ 2026-08-14 17:49 ` Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 3/3] selftests: net: hw: add devlink info test Paul Greenwalt
2 siblings, 0 replies; 4+ messages in thread
From: Paul Greenwalt @ 2026-08-14 17:49 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, Paul Greenwalt, Przemek Kitszel, Aleksandr Loktionov
Add devlink info support for idpf, reporting:
- serial_number: device serial number (DSN) for device identification
- fw.mgmt.api: running version reporting driver-device communication
version
This enables NIPA CI and other tools to uniquely identify devices under
test and track device capabilities. This phased implementation initially
focuses on stable, readily available information (serial number and
virtchnl version from negotiation). Firmware version information will be
added in future patches as support is exposed through virtchnl and the
driver architecture allows reliable retrieval.
$ devlink dev show
pci/0000:85:00.0
$ devlink dev info pci/0000:85:00.0
pci/0000:85:00.0:
driver idpf
serial_number 00-a0-c9-ff-ff-23-45-67
versions:
running:
fw.mgmt.api 2.0
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Link: https://github.com/linux-netdev/nipa/wiki/Netdev-CI-system#device-information
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
---
Documentation/networking/devlink/idpf.rst | 29 +++++++
Documentation/networking/devlink/index.rst | 1 +
drivers/net/ethernet/intel/idpf/Makefile | 1 +
.../net/ethernet/intel/idpf/idpf_devlink.c | 79 +++++++++++++++++++
.../net/ethernet/intel/idpf/idpf_devlink.h | 45 +++++++++++
drivers/net/ethernet/intel/idpf/idpf_main.c | 12 ++-
6 files changed, 164 insertions(+), 3 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
diff --git a/Documentation/networking/devlink/idpf.rst b/Documentation/networking/devlink/idpf.rst
new file mode 100644
index 000000000000..9262844a1b3f
--- /dev/null
+++ b/Documentation/networking/devlink/idpf.rst
@@ -0,0 +1,29 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+====================
+idpf devlink support
+====================
+
+This document describes the devlink features implemented by the ``idpf``
+device driver.
+
+Info versions
+=============
+
+The following table lists the version reported by the ``idpf`` driver.
+
+.. list-table:: devlink info versions implemented
+ :widths: 5 5 5 90
+
+ * - Name
+ - Type
+ - Example
+ - Description
+ * - ``fw.mgmt.api``
+ - running
+ - 2.0
+ - 2-digit version number (major.minor) of the communication channel
+ (virtchnl) used by the device.
+
+The driver also reports the PCI Device Serial Number through the
+``serial_number`` attribute.
diff --git a/Documentation/networking/devlink/index.rst b/Documentation/networking/devlink/index.rst
index e371be30b99e..09e49b74712c 100644
--- a/Documentation/networking/devlink/index.rst
+++ b/Documentation/networking/devlink/index.rst
@@ -85,6 +85,7 @@ parameters, info versions, and other features it supports.
hns3
i40e
ice
+ idpf
ionic
iosm
ixgbe
diff --git a/drivers/net/ethernet/intel/idpf/Makefile b/drivers/net/ethernet/intel/idpf/Makefile
index 4aaafa175ec3..81b27a406747 100644
--- a/drivers/net/ethernet/intel/idpf/Makefile
+++ b/drivers/net/ethernet/intel/idpf/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_IDPF) += idpf.o
idpf-y := \
idpf_dev.o \
+ idpf_devlink.o \
idpf_ethtool.o \
idpf_idc.o \
idpf_lib.o \
diff --git a/drivers/net/ethernet/intel/idpf/idpf_devlink.c b/drivers/net/ethernet/intel/idpf/idpf_devlink.c
new file mode 100644
index 000000000000..70de76c88aa5
--- /dev/null
+++ b/drivers/net/ethernet/intel/idpf/idpf_devlink.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Copyright (C) 2026 Intel Corporation */
+
+#include "idpf.h"
+#include "idpf_devlink.h"
+
+/**
+ * idpf_info_get_dsn - format the DSN as the serial number
+ * @adapter: the idpf adapter structure
+ * @buf: buffer to store the formatted serial number
+ */
+static void idpf_info_get_dsn(struct idpf_adapter *adapter, char *buf)
+{
+ u8 dsn[8];
+
+ /* Copy the DSN into an array in Big Endian format */
+ put_unaligned_be64(pci_get_dsn(adapter->pdev), dsn);
+
+ snprintf(buf, IDPF_DEVLINK_INFO_LEN, "%8phD", dsn);
+}
+
+/**
+ * idpf_devlink_info_get - get IDPF devlink info
+ * @devlink: devlink instance structure
+ * @req: the devlink info request
+ * @extack: extended netlink ack structure
+ *
+ * Callback for the devlink .info_get operation. Reports information about the
+ * device.
+ *
+ * Return: zero on success or a negative error code on failure.
+ */
+static int idpf_devlink_info_get(struct devlink *devlink,
+ struct devlink_info_req *req,
+ struct netlink_ext_ack *extack)
+{
+ struct idpf_adapter *adapter = devlink_priv(devlink);
+ char buf[IDPF_DEVLINK_INFO_LEN];
+ int err;
+
+ idpf_info_get_dsn(adapter, buf);
+ err = devlink_info_serial_number_put(req, buf);
+ if (err)
+ return err;
+
+ snprintf(buf, sizeof(buf), "%u.%u",
+ adapter->virt_ver_maj, adapter->virt_ver_min);
+
+ err = devlink_info_version_running_put(req, "fw.mgmt.api", buf);
+ if (err)
+ return err;
+
+ return 0;
+}
+
+static const struct devlink_ops idpf_devlink_ops = {
+ .info_get = idpf_devlink_info_get,
+};
+
+/**
+ * idpf_adapter_alloc - allocate devlink and return adapter
+ * @dev: IDPF device to allocate for
+ *
+ * Allocate a devlink instance for this device and return the private area as
+ * the adapter structure.
+ *
+ * Return: adapter structure on success, NULL on failure
+ */
+struct idpf_adapter *idpf_adapter_alloc(struct device *dev)
+{
+ struct devlink *devlink;
+
+ devlink = devlink_alloc(&idpf_devlink_ops, sizeof(struct idpf_adapter),
+ dev);
+ if (!devlink)
+ return NULL;
+
+ return devlink_priv(devlink);
+}
diff --git a/drivers/net/ethernet/intel/idpf/idpf_devlink.h b/drivers/net/ethernet/intel/idpf/idpf_devlink.h
new file mode 100644
index 000000000000..ff18b4e7358d
--- /dev/null
+++ b/drivers/net/ethernet/intel/idpf/idpf_devlink.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2026, Intel Corporation. */
+
+#ifndef _IDPF_DEVLINK_H_
+#define _IDPF_DEVLINK_H_
+#include <net/devlink.h>
+
+#define IDPF_DEVLINK_INFO_LEN 128
+
+struct idpf_adapter *idpf_adapter_alloc(struct device *dev);
+
+/**
+ * idpf_devlink_free - teardown the devlink
+ * @adapter: IDPF adapter structure to free
+ */
+static inline void idpf_devlink_free(struct idpf_adapter *adapter)
+{
+ struct devlink *devlink = priv_to_devlink(adapter);
+
+ devlink_free(devlink);
+}
+
+/**
+ * idpf_devlink_register - register the devlink
+ * @adapter: IDPF adapter structure
+ */
+static inline void idpf_devlink_register(struct idpf_adapter *adapter)
+{
+ struct devlink *devlink = priv_to_devlink(adapter);
+
+ devlink_register(devlink);
+}
+
+/**
+ * idpf_devlink_unregister - unregister the devlink
+ * @adapter: IDPF adapter structure
+ */
+static inline void idpf_devlink_unregister(struct idpf_adapter *adapter)
+{
+ struct devlink *devlink = priv_to_devlink(adapter);
+
+ devlink_unregister(devlink);
+}
+
+#endif /* _IDPF_DEVLINK_H_ */
diff --git a/drivers/net/ethernet/intel/idpf/idpf_main.c b/drivers/net/ethernet/intel/idpf/idpf_main.c
index 6f9579c39342..a1156b142119 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_main.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_main.c
@@ -3,6 +3,7 @@
#include "idpf.h"
#include "idpf_devids.h"
+#include "idpf_devlink.h"
#include "idpf_lan_vf_regs.h"
#include "idpf_virtchnl.h"
@@ -123,6 +124,8 @@ static void idpf_remove(struct pci_dev *pdev)
set_bit(IDPF_REMOVE_IN_PROG, adapter->flags);
+ idpf_devlink_unregister(adapter);
+
/* Wait until vc_event_task is done to consider if any hard reset is
* in progress else we may go ahead and release the resources but the
* thread doing the hard reset might continue the init path and
@@ -181,7 +184,8 @@ static void idpf_remove(struct pci_dev *pdev)
idpf_decfg_device(adapter);
pci_set_drvdata(pdev, NULL);
- kfree(adapter);
+
+ idpf_devlink_free(adapter);
}
/**
@@ -260,7 +264,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct idpf_adapter *adapter;
int err;
- adapter = kzalloc_obj(*adapter);
+ adapter = idpf_adapter_alloc(dev);
if (!adapter)
return -ENOMEM;
@@ -346,6 +350,8 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
INIT_DELAYED_WORK(&adapter->stats_task, idpf_statistics_task);
INIT_DELAYED_WORK(&adapter->vc_event_task, idpf_vc_event_task);
+ idpf_devlink_register(adapter);
+
adapter->dev_ops.reg_ops.reset_reg_init(adapter);
set_bit(IDPF_HR_DRV_LOAD, adapter->flags);
queue_delayed_work(adapter->vc_event_wq, &adapter->vc_event_task,
@@ -365,7 +371,7 @@ static int idpf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
idpf_decfg_device(adapter);
err_free:
pci_set_drvdata(pdev, NULL);
- kfree(adapter);
+ idpf_devlink_free(adapter);
return err;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iwl-next 3/3] selftests: net: hw: add devlink info test
2026-08-14 17:49 [PATCH iwl-next 0/3] idpf: add devlink info support with selftest Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 1/3] idpf: clear drvdata on probe error path Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 2/3] idpf: add devlink info support Paul Greenwalt
@ 2026-08-14 17:49 ` Paul Greenwalt
2 siblings, 0 replies; 4+ messages in thread
From: Paul Greenwalt @ 2026-08-14 17:49 UTC (permalink / raw)
To: intel-wired-lan
Cc: netdev, Paul Greenwalt, Przemek Kitszel, Aleksandr Loktionov
Add a selftest that verifies drivers properly report device information
through the devlink info interface. This test validates:
- devlink dev info command succeeds
- driver name is reported and matches ethtool output
- at least one version or serial_number is reported
The output format matches what NIPA CI uses for device regression
tracking, helping maintainers identify pass/fail status changes due
to FW updates.
Example usage:
sudo NETIF=eth0 ./tools/testing/selftests/drivers/net/hw/devlink_info.sh
INFO: driver: idpf
INFO: serial_number: 00-a0-c9-ff-ff-23-45-67
TEST: devlink info [ OK ]
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Link: https://github.com/linux-netdev/nipa/wiki/Netdev-CI-system#device-information
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
---
.../testing/selftests/drivers/net/hw/Makefile | 1 +
.../selftests/drivers/net/hw/devlink_info.sh | 119 ++++++++++++++++++
2 files changed, 120 insertions(+)
create mode 100755 tools/testing/selftests/drivers/net/hw/devlink_info.sh
diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile
index 78bb0169350b..edd353f27a39 100644
--- a/tools/testing/selftests/drivers/net/hw/Makefile
+++ b/tools/testing/selftests/drivers/net/hw/Makefile
@@ -19,6 +19,7 @@ TEST_GEN_FILES := \
TEST_PROGS = \
csum.py \
+ devlink_info.sh \
devlink_rate_cross_esw.py \
devlink_rate_tc_bw.py \
devmem.py \
diff --git a/tools/testing/selftests/drivers/net/hw/devlink_info.sh b/tools/testing/selftests/drivers/net/hw/devlink_info.sh
new file mode 100755
index 000000000000..b2ee880590c4
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/hw/devlink_info.sh
@@ -0,0 +1,119 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# Test devlink info support
+#
+# This test verifies that the driver properly reports device information
+# through the devlink info interface. The output format matches what
+# NIPA CI uses for regression tracking (see Device information section
+# at https://github.com/linux-netdev/nipa/wiki/Netdev-CI-system).
+#
+# Validates:
+# - devlink dev info command succeeds
+# - driver name is reported and matches ethtool
+# - at least one version or serial_number is reported
+# - serial_number is logged if present
+#
+# Usage:
+# NETIF=eth0 ./devlink_info.sh
+
+lib_dir=$(dirname "$0")/../../../net
+
+ALL_TESTS="devlink_info_test"
+source "$lib_dir"/lib.sh
+
+require_command devlink
+require_command jq
+require_command ethtool
+
+DL_HANDLE=""
+
+setup_prepare()
+{
+ # Try to get devlink handle from devlink port first
+ DL_HANDLE=$(devlink -j port show 2>/dev/null |
+ jq -r --arg netif "$NETIF" \
+ '.port | to_entries[] |
+ select(.value.netdev == $netif) | .key' 2>/dev/null |
+ cut -d/ -f1-2)
+
+ # Fallback: get PCI address from ethtool and check if devlink device exists
+ if [ -z "$DL_HANDLE" ]; then
+ local bus_info
+ bus_info=$(ethtool -i "$NETIF" 2>/dev/null | awk '/^bus-info:/ {print $2}')
+ if [ -n "$bus_info" ]; then
+ DL_HANDLE="pci/$bus_info"
+ # Verify this devlink device exists
+ if ! devlink dev show "$DL_HANDLE" &>/dev/null; then
+ DL_HANDLE=""
+ fi
+ fi
+ fi
+
+ if [ -z "$DL_HANDLE" ]; then
+ echo "SKIP: Could not find devlink handle for $NETIF"
+ exit $ksft_skip
+ fi
+}
+
+info_get()
+{
+ local name
+
+ name=$1
+ cmd_jq "devlink dev info $DL_HANDLE -j" ".[][][\"$name\"]" "-e"
+}
+
+has_any_version()
+{
+ local info
+ info=$(devlink -j dev info $DL_HANDLE)
+
+ # Check if any version category exists and has at least one entry
+ echo "$info" | jq -e '.[][].versions | length > 0' > /dev/null 2>&1
+}
+
+devlink_info_test()
+{
+ RET=0
+
+ # Test devlink info command succeeds
+ devlink dev info $DL_HANDLE > /dev/null
+ check_err $? "devlink dev info failed for $DL_HANDLE"
+
+ # Test driver name is reported
+ local driver
+ driver=$(info_get "driver")
+ check_err $? "Failed to get driver name"
+
+ # Verify driver matches ethtool output
+ local expected_driver
+ expected_driver=$(ethtool -i "$NETIF" | awk '/^driver:/ {print $2}')
+ check_err $? "Failed to get driver from ethtool"
+ if [ -z "$expected_driver" ]; then
+ check_err 1 "Failed to get driver from ethtool"
+ fi
+ if [ "$driver" != "$expected_driver" ]; then
+ check_err 1 "Driver mismatch: devlink='$driver' ethtool='$expected_driver'"
+ else
+ log_info "driver: $driver"
+ fi
+
+ # Test at least one version OR serial_number is reported (needed for device tracking)
+ local serial
+ serial=$(info_get "serial_number" 2>/dev/null)
+ if [ -n "$serial" ]; then
+ log_info "serial_number: $serial"
+ fi
+
+ if ! has_any_version && [ -z "$serial" ]; then
+ check_err 1 "No versions or serial_number reported"
+ fi
+
+ log_test "devlink info"
+}
+
+setup_prepare
+tests_run
+
+exit $EXIT_STATUS
--
2.52.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-15 1:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14 17:49 [PATCH iwl-next 0/3] idpf: add devlink info support with selftest Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 1/3] idpf: clear drvdata on probe error path Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 2/3] idpf: add devlink info support Paul Greenwalt
2026-08-14 17:49 ` [PATCH iwl-next 3/3] selftests: net: hw: add devlink info test Paul Greenwalt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox