From: Paul Greenwalt <paul.greenwalt@intel.com>
To: intel-wired-lan@lists.osuosl.org
Cc: Paul Greenwalt <paul.greenwalt@intel.com>
Subject: [PATCH iwl-next v2 3/4] idpf: add devlink info support
Date: Thu, 3 Sep 2026 04:27:41 -0400 [thread overview]
Message-ID: <20260903082742.43837-4-paul.greenwalt@intel.com> (raw)
In-Reply-To: <20260903082742.43837-1-paul.greenwalt@intel.com>
Implement the devlink .info_get callback for idpf, reporting:
- serial_number: PCI Device Serial Number, for device identification
- fw.mgmt.api: running version of the driver-device communication
channel (virtchnl)
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. Firmware version
information will be added in future patches as support is exposed
through virtchnl and the driver architecture allows reliable retrieval.
The serial number is omitted on devices that do not implement the PCI
Device Serial Number extended capability, where pci_get_dsn() returns 0,
rather than reporting an all-zero serial number.
$ 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
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 | 30 +++++++++
Documentation/networking/devlink/index.rst | 1 +
.../net/ethernet/intel/idpf/idpf_devlink.c | 65 +++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 Documentation/networking/devlink/idpf.rst
diff --git a/Documentation/networking/devlink/idpf.rst b/Documentation/networking/devlink/idpf.rst
new file mode 100644
index 000000000000..91e25b872f4f
--- /dev/null
+++ b/Documentation/networking/devlink/idpf.rst
@@ -0,0 +1,30 @@
+.. 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, on devices that implement the PCI Device Serial
+Number extended capability.
diff --git a/Documentation/networking/devlink/index.rst b/Documentation/networking/devlink/index.rst
index d4a83fdcff7f..538494b1051b 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
ixd
diff --git a/drivers/net/ethernet/intel/idpf/idpf_devlink.c b/drivers/net/ethernet/intel/idpf/idpf_devlink.c
index 1669bdfc950b..527c7714f9f7 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_devlink.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_devlink.c
@@ -1,10 +1,75 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2026 Intel Corporation */
+#include <linux/pci.h>
+#include <linux/unaligned.h>
+
#include "idpf.h"
#include "idpf_devlink.h"
+#define IDPF_DEVLINK_INFO_LEN 128
+
+/**
+ * idpf_info_get_dsn - format the PCI DSN as the device serial number
+ * @adapter: the idpf adapter structure
+ * @buf: buffer to store the formatted serial number
+ * @buf_size: size of @buf
+ *
+ * Return: true if the device reports a DSN, false otherwise.
+ */
+static bool idpf_info_get_dsn(struct idpf_adapter *adapter, char *buf,
+ size_t buf_size)
+{
+ u64 dsn = pci_get_dsn(adapter->pdev);
+ u8 dsn_be[sizeof(dsn)];
+
+ if (!dsn)
+ return false;
+
+ /* Copy the DSN into an array in Big Endian format */
+ put_unaligned_be64(dsn, dsn_be);
+ snprintf(buf, buf_size, "%8phD", dsn_be);
+
+ return true;
+}
+
+/**
+ * idpf_devlink_info_get - .info_get devlink handler
+ * @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. The instance is registered only after the virtchnl handshake has
+ * completed, so the reported version is the one negotiated by the most recent
+ * successful handshake.
+ *
+ * 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;
+
+ if (idpf_info_get_dsn(adapter, buf, sizeof(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);
+
+ return devlink_info_version_running_put(req,
+ DEVLINK_INFO_VERSION_GENERIC_FW_MGMT_API,
+ buf);
+}
+
static const struct devlink_ops idpf_devlink_ops = {
+ .info_get = idpf_devlink_info_get,
};
/**
--
2.52.0
next prev parent reply other threads:[~2026-09-03 16:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 8:27 [PATCH iwl-next v2 0/4] idpf: add devlink info support with selftest Paul Greenwalt
2026-09-03 8:27 ` [PATCH iwl-next v2 1/4] idpf: clear drvdata in idpf_decfg_device() Paul Greenwalt
2026-09-03 8:27 ` [PATCH iwl-next v2 2/4] idpf: add devlink support Paul Greenwalt
2026-09-03 8:27 ` Paul Greenwalt [this message]
2026-09-03 8:27 ` [PATCH iwl-next v2 4/4] selftests: net: hw: add devlink info test Paul Greenwalt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260903082742.43837-4-paul.greenwalt@intel.com \
--to=paul.greenwalt@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox