From: Amritha Nambiar <amritha.nambiar@intel.com>
Enable initial support for the devlink interface with the ixd driver. The
ixd hardware is a single function PCIe device. So, the PCIe adapter gets
its own devlink instance to manage device-wide resources or configuration.
$ devlink dev show
pci/0000:83:00.6
$ devlink dev info pci/0000:83:00.6
pci/0000:83:00.6:
driver ixd
serial_number 00-a0-c9-ff-ff-23-45-67
versions:
fixed:
device.type MEV
running:
cp 0.0
virtchnl 2.0
Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
Documentation/networking/devlink/index.rst | 1 +
Documentation/networking/devlink/ixd.rst | 35 +++++++
drivers/net/ethernet/intel/ixd/Kconfig | 1 +
drivers/net/ethernet/intel/ixd/Makefile | 1 +
drivers/net/ethernet/intel/ixd/ixd_devlink.c | 105 +++++++++++++++++++
drivers/net/ethernet/intel/ixd/ixd_devlink.h | 44 ++++++++
drivers/net/ethernet/intel/ixd/ixd_main.c | 16 ++-
7 files changed, 200 insertions(+), 3 deletions(-)
create mode 100644 Documentation/networking/devlink/ixd.rst
create mode 100644 drivers/net/ethernet/intel/ixd/ixd_devlink.c
create mode 100644 drivers/net/ethernet/intel/ixd/ixd_devlink.h
diff --git a/Documentation/networking/devlink/index.rst b/Documentation/networking/devlink/index.rst
index 35b12a2bfeba..efd138d8e7d3 100644
--- a/Documentation/networking/devlink/index.rst
+++ b/Documentation/networking/devlink/index.rst
@@ -87,6 +87,7 @@ parameters, info versions, and other features it supports.
ionic
iosm
ixgbe
+ ixd
kvaser_pciefd
kvaser_usb
mlx4
diff --git a/Documentation/networking/devlink/ixd.rst b/Documentation/networking/devlink/ixd.rst
new file mode 100644
index 000000000000..81b28ffb00f6
--- /dev/null
+++ b/Documentation/networking/devlink/ixd.rst
@@ -0,0 +1,35 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===================
+ixd devlink support
+===================
+
+This document describes the devlink features implemented by the ``ixd``
+device driver.
+
+Info versions
+=============
+
+The ``ixd`` driver reports the following versions
+
+.. list-table:: devlink info versions implemented
+ :widths: 5 5 5 90
+
+ * - Name
+ - Type
+ - Example
+ - Description
+ * - ``device.type``
+ - fixed
+ - MEV
+ - The hardware type for this device
+ * - ``cp``
+ - running
+ - 0.0
+ - Version number (major.minor) of the Control Plane software
+ running on the device.
+ * - ``virtchnl``
+ - running
+ - 2.0
+ - 2-digit version number (major.minor) of the communication channel
+ (virtchnl) used by the device.
diff --git a/drivers/net/ethernet/intel/ixd/Kconfig b/drivers/net/ethernet/intel/ixd/Kconfig
index 24510c50070e..34181c59dcdc 100644
--- a/drivers/net/ethernet/intel/ixd/Kconfig
+++ b/drivers/net/ethernet/intel/ixd/Kconfig
@@ -7,6 +7,7 @@ config IXD
select LIBETH
select LIBIE_CP
select LIBIE_PCI
+ select NET_DEVLINK
help
This driver supports Intel(R) Control Plane PCI Function
of Intel E2100 and later IPUs and FNICs.
diff --git a/drivers/net/ethernet/intel/ixd/Makefile b/drivers/net/ethernet/intel/ixd/Makefile
index 90abf231fb16..03760a2580b9 100644
--- a/drivers/net/ethernet/intel/ixd/Makefile
+++ b/drivers/net/ethernet/intel/ixd/Makefile
@@ -8,5 +8,6 @@ obj-$(CONFIG_IXD) += ixd.o
ixd-y := ixd_main.o
ixd-y += ixd_ctlq.o
ixd-y += ixd_dev.o
+ixd-y += ixd_devlink.o
ixd-y += ixd_lib.o
ixd-y += ixd_virtchnl.o
diff --git a/drivers/net/ethernet/intel/ixd/ixd_devlink.c b/drivers/net/ethernet/intel/ixd/ixd_devlink.c
new file mode 100644
index 000000000000..6f60cfe4fab2
--- /dev/null
+++ b/drivers/net/ethernet/intel/ixd/ixd_devlink.c
@@ -0,0 +1,105 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2025, Intel Corporation. */
+
+#include "ixd.h"
+#include "ixd_devlink.h"
+
+#define IXD_DEVLINK_INFO_LEN 128
+
+/**
+ * ixd_fill_dsn - Get the serial number for the ixd device
+ * @adapter: adapter to query
+ * @buf: storage buffer for the info request
+ */
+static void ixd_fill_dsn(struct ixd_adapter *adapter, char *buf)
+{
+ u8 dsn[8];
+
+ /* Copy the DSN into an array in Big Endian format */
+ put_unaligned_be64(pci_get_dsn(adapter->cp_ctx.mmio_info.pdev), dsn);
+
+ snprintf(buf, IXD_DEVLINK_INFO_LEN, "%8phD", dsn);
+}
+
+/**
+ * ixd_fill_device_name - Get the name of the underlying hardware
+ * @adapter: adapter to query
+ * @buf: storage buffer for the info request
+ * @buf_size: size of the storage buffer
+ */
+static void ixd_fill_device_name(struct ixd_adapter *adapter, char *buf,
+ size_t buf_size)
+{
+ if (adapter->caps.device_type == VIRTCHNL2_MEV_DEVICE)
+ snprintf(buf, buf_size, "%s", "MEV");
+ else
+ snprintf(buf, buf_size, "%s", "UNKNOWN");
+}
+
+/**
+ * ixd_devlink_info_get - .info_get devlink handler
+ * @devlink: devlink instance structure
+ * @req: the devlink info request
+ * @extack: extended netdev ack structure
+ *
+ * Callback for the devlink .info_get operation. Reports information about the
+ * device.
+ *
+ * Return: zero on success or an error code on failure.
+ */
+static int ixd_devlink_info_get(struct devlink *devlink,
+ struct devlink_info_req *req,
+ struct netlink_ext_ack *extack)
+{
+ struct ixd_adapter *adapter = devlink_priv(devlink);
+ char buf[IXD_DEVLINK_INFO_LEN];
+ int err;
+
+ ixd_fill_dsn(adapter, buf);
+ err = devlink_info_serial_number_put(req, buf);
+ if (err)
+ return err;
+
+ ixd_fill_device_name(adapter, buf, IXD_DEVLINK_INFO_LEN);
+ err = devlink_info_version_fixed_put(req, "device.type", buf);
+ if (err)
+ return err;
+
+ snprintf(buf, sizeof(buf), "%u.%u",
+ le16_to_cpu(adapter->caps.cp_ver_major),
+ le16_to_cpu(adapter->caps.cp_ver_minor));
+
+ err = devlink_info_version_running_put(req, "cp", buf);
+ if (err)
+ return err;
+
+ snprintf(buf, sizeof(buf), "%u.%u",
+ adapter->vc_ver.major, adapter->vc_ver.minor);
+
+ return devlink_info_version_running_put(req, "virtchnl", buf);
+}
+
+static const struct devlink_ops ixd_devlink_ops = {
+ .info_get = ixd_devlink_info_get,
+};
+
+/**
+ * ixd_adapter_alloc - Allocate devlink and return adapter pointer
+ * @dev: the 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 ixd_adapter *ixd_adapter_alloc(struct device *dev)
+{
+ struct devlink *devlink;
+
+ devlink = devlink_alloc(&ixd_devlink_ops, sizeof(struct ixd_adapter),
+ dev);
+ if (!devlink)
+ return NULL;
+
+ return devlink_priv(devlink);
+}
diff --git a/drivers/net/ethernet/intel/ixd/ixd_devlink.h b/drivers/net/ethernet/intel/ixd/ixd_devlink.h
new file mode 100644
index 000000000000..c43ce0655de2
--- /dev/null
+++ b/drivers/net/ethernet/intel/ixd/ixd_devlink.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2025, Intel Corporation. */
+
+#ifndef _IXD_DEVLINK_H_
+#define _IXD_DEVLINK_H_
+#include <net/devlink.h>
+
+struct ixd_adapter *ixd_adapter_alloc(struct device *dev);
+
+/**
+ * ixd_devlink_free - teardown the devlink
+ * @adapter: the adapter structure to free
+ *
+ */
+static inline void ixd_devlink_free(struct ixd_adapter *adapter)
+{
+ struct devlink *devlink = priv_to_devlink(adapter);
+
+ devlink_free(devlink);
+}
+
+/**
+ * ixd_devlink_unregister - Unregister devlink resources for this adapter.
+ * @adapter: the adapter structure to cleanup
+ *
+ * Releases resources used by devlink and cleans up associated memory.
+ */
+static inline void ixd_devlink_unregister(struct ixd_adapter *adapter)
+{
+ devlink_unregister(priv_to_devlink(adapter));
+}
+
+/**
+ * ixd_devlink_register - Register devlink interface for this adapter
+ * @adapter: pointer to ixd adapter structure to be associated with devlink
+ *
+ * Register the devlink instance associated with this adapter
+ */
+static inline void ixd_devlink_register(struct ixd_adapter *adapter)
+{
+ devlink_register(priv_to_devlink(adapter));
+}
+
+#endif /* _IXD_DEVLINK_H_ */
diff --git a/drivers/net/ethernet/intel/ixd/ixd_main.c b/drivers/net/ethernet/intel/ixd/ixd_main.c
index 6d5e6aca77df..ea6aa793a6a7 100644
--- a/drivers/net/ethernet/intel/ixd/ixd_main.c
+++ b/drivers/net/ethernet/intel/ixd/ixd_main.c
@@ -4,6 +4,7 @@
#include "ixd.h"
#include "ixd_ctlq.h"
#include "ixd_lan_regs.h"
+#include "ixd_devlink.h"
MODULE_DESCRIPTION("Intel(R) Control Plane Function Device Driver");
MODULE_IMPORT_NS("LIBIE_CP");
@@ -21,11 +22,14 @@ static void ixd_remove(struct pci_dev *pdev)
/* Do not mix removal with (re)initialization */
cancel_delayed_work_sync(&adapter->init_task.init_work);
+ ixd_devlink_unregister(adapter);
+
/* Leave the device clean on exit */
ixd_trigger_reset(adapter);
ixd_deinit_dflt_mbx(adapter);
libie_pci_unmap_all_mmio_regions(&adapter->cp_ctx.mmio_info);
+ ixd_devlink_free(adapter);
}
/**
@@ -93,7 +97,7 @@ static int ixd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (WARN_ON(ent->device != IXD_DEV_ID_CPF))
return -EINVAL;
- adapter = devm_kzalloc(&pdev->dev, sizeof(*adapter), GFP_KERNEL);
+ adapter = ixd_adapter_alloc(&pdev->dev);
if (!adapter)
return -ENOMEM;
@@ -102,13 +106,13 @@ static int ixd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err = libie_pci_init_dev(pdev);
if (err)
- return err;
+ goto free_adapter;
pci_set_drvdata(pdev, adapter);
err = ixd_iomap_regions(adapter);
if (err)
- return err;
+ goto free_adapter;
INIT_DELAYED_WORK(&adapter->init_task.init_work,
ixd_init_task);
@@ -118,7 +122,13 @@ static int ixd_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
queue_delayed_work(system_unbound_wq, &adapter->init_task.init_work,
msecs_to_jiffies(500));
+ ixd_devlink_register(adapter);
+
return 0;
+
+free_adapter:
+ ixd_devlink_free(adapter);
+ return err;
}
static const struct pci_device_id ixd_pci_tbl[] = {
--
2.47.0
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Larysa Zaremba
> Sent: Monday, November 17, 2025 2:49 PM
> To: intel-wired-lan@lists.osuosl.org; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>
> Cc: Lobakin, Aleksander <aleksander.lobakin@intel.com>; Samudrala,
> Sridhar <sridhar.samudrala@intel.com>; Singhai, Anjali
> <anjali.singhai@intel.com>; Michal Swiatkowski
> <michal.swiatkowski@linux.intel.com>; Zaremba, Larysa
> <larysa.zaremba@intel.com>; Fijalkowski, Maciej
> <maciej.fijalkowski@intel.com>; Tantilov, Emil S
> <emil.s.tantilov@intel.com>; Chittim, Madhu <madhu.chittim@intel.com>;
> Hay, Joshua A <joshua.a.hay@intel.com>; Keller, Jacob E
> <jacob.e.keller@intel.com>; Shanmugam, Jayaprakash
> <jayaprakash.shanmugam@intel.com>; Wochtman, Natalia
> <natalia.wochtman@intel.com>; Jiri Pirko <jiri@resnulli.us>; David S.
> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>;
> Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>;
> Simon Horman <horms@kernel.org>; Jonathan Corbet <corbet@lwn.net>;
> Richard Cochran <richardcochran@gmail.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> netdev@vger.kernel.org; linux-doc@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [Intel-wired-lan] [PATCH iwl-next v5 15/15] ixd: add devlink
> support
>
> From: Amritha Nambiar <amritha.nambiar@intel.com>
>
> Enable initial support for the devlink interface with the ixd driver.
> The ixd hardware is a single function PCIe device. So, the PCIe
> adapter gets its own devlink instance to manage device-wide resources
> or configuration.
>
> $ devlink dev show
> pci/0000:83:00.6
>
> $ devlink dev info pci/0000:83:00.6
> pci/0000:83:00.6:
> driver ixd
> serial_number 00-a0-c9-ff-ff-23-45-67
> versions:
> fixed:
> device.type MEV
> running:
> cp 0.0
> virtchnl 2.0
>
This commit mentions MEV without expansion.
Kernel docs require expanding uncommon abbreviations.
> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
> ---
> Documentation/networking/devlink/index.rst | 1 +
> Documentation/networking/devlink/ixd.rst | 35 +++++++
> drivers/net/ethernet/intel/ixd/Kconfig | 1 +
> drivers/net/ethernet/intel/ixd/Makefile | 1 +
> drivers/net/ethernet/intel/ixd/ixd_devlink.c | 105
> +++++++++++++++++++ drivers/net/ethernet/intel/ixd/ixd_devlink.h |
> 44 ++++++++
> drivers/net/ethernet/intel/ixd/ixd_main.c | 16 ++-
> 7 files changed, 200 insertions(+), 3 deletions(-) create mode
> 100644 Documentation/networking/devlink/ixd.rst
> create mode 100644 drivers/net/ethernet/intel/ixd/ixd_devlink.c
> create mode 100644 drivers/net/ethernet/intel/ixd/ixd_devlink.h
>
> diff --git a/Documentation/networking/devlink/index.rst
> b/Documentation/networking/devlink/index.rst
> index 35b12a2bfeba..efd138d8e7d3 100644
> --- a/Documentation/networking/devlink/index.rst
> +++ b/Documentation/networking/devlink/index.rst
> @@ -87,6 +87,7 @@ parameters, info versions, and other features it
> supports.
> ionic
> iosm
> ixgbe
> + ixd
> kvaser_pciefd
> kvaser_usb
> mlx4
> diff --git a/Documentation/networking/devlink/ixd.rst
> b/Documentation/networking/devlink/ixd.rst
> new file mode 100644
> index 000000000000..81b28ffb00f6
> --- /dev/null
> +++ b/Documentation/networking/devlink/ixd.rst
> @@ -0,0 +1,35 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +===================
> +ixd devlink support
> +===================
> +
> +This document describes the devlink features implemented by the
> ``ixd``
> +device driver.
> +
> +Info versions
> +=============
> +
> +The ``ixd`` driver reports the following versions
> +
> +.. list-table:: devlink info versions implemented
> + :widths: 5 5 5 90
> +
> + * - Name
> + - Type
> + - Example
> + - Description
> + * - ``device.type``
> + - fixed
> + - MEV
> + - The hardware type for this device
> + * - ``cp``
> + - running
> + - 0.0
> + - Version number (major.minor) of the Control Plane software
> + running on the device.
> + * - ``virtchnl``
> + - running
> + - 2.0
> + - 2-digit version number (major.minor) of the communication
> channel
> + (virtchnl) used by the device.
...
> +++ b/drivers/net/ethernet/intel/ixd/ixd_devlink.c
> @@ -0,0 +1,105 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2025, Intel Corporation. */
> +
> +#include "ixd.h"
> +#include "ixd_devlink.h"
> +
> +#define IXD_DEVLINK_INFO_LEN 128
> +
> +/**
> + * ixd_fill_dsn - Get the serial number for the ixd device
> + * @adapter: adapter to query
> + * @buf: storage buffer for the info request */ static void
> +ixd_fill_dsn(struct ixd_adapter *adapter, char *buf) {
> + u8 dsn[8];
> +
> + /* Copy the DSN into an array in Big Endian format */
> + put_unaligned_be64(pci_get_dsn(adapter->cp_ctx.mmio_info.pdev),
> dsn);
> +
> + snprintf(buf, IXD_DEVLINK_INFO_LEN, "%8phD", dsn); }
> +
Hardcoded buffer length.
Better pass len as a parameter.
> +/**
> + * ixd_fill_device_name - Get the name of the underlying hardware
> + * @adapter: adapter to query
> + * @buf: storage buffer for the info request
> + * @buf_size: size of the storage buffer */ static void
> +ixd_fill_device_name(struct ixd_adapter *adapter, char *buf,
> + size_t buf_size)
> +{
> + if (adapter->caps.device_type == VIRTCHNL2_MEV_DEVICE)
> + snprintf(buf, buf_size, "%s", "MEV");
> + else
> + snprintf(buf, buf_size, "%s", "UNKNOWN"); }
> +
I'd recommend to use strscpy() for fixed strings instead of snprintf() with "%s".
...
> --
> 2.47.0
On 11/17/2025 6:28 AM, Loktionov, Aleksandr wrote: > > >> -----Original Message----- >> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf >> Of Larysa Zaremba >> Sent: Monday, November 17, 2025 2:49 PM >> To: intel-wired-lan@lists.osuosl.org; Nguyen, Anthony L >> <anthony.l.nguyen@intel.com> >> Cc: Lobakin, Aleksander <aleksander.lobakin@intel.com>; Samudrala, >> Sridhar <sridhar.samudrala@intel.com>; Singhai, Anjali >> <anjali.singhai@intel.com>; Michal Swiatkowski >> <michal.swiatkowski@linux.intel.com>; Zaremba, Larysa >> <larysa.zaremba@intel.com>; Fijalkowski, Maciej >> <maciej.fijalkowski@intel.com>; Tantilov, Emil S >> <emil.s.tantilov@intel.com>; Chittim, Madhu <madhu.chittim@intel.com>; >> Hay, Joshua A <joshua.a.hay@intel.com>; Keller, Jacob E >> <jacob.e.keller@intel.com>; Shanmugam, Jayaprakash >> <jayaprakash.shanmugam@intel.com>; Wochtman, Natalia >> <natalia.wochtman@intel.com>; Jiri Pirko <jiri@resnulli.us>; David S. >> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; >> Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; >> Simon Horman <horms@kernel.org>; Jonathan Corbet <corbet@lwn.net>; >> Richard Cochran <richardcochran@gmail.com>; Kitszel, Przemyslaw >> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>; >> netdev@vger.kernel.org; linux-doc@vger.kernel.org; linux- >> kernel@vger.kernel.org >> Subject: [Intel-wired-lan] [PATCH iwl-next v5 15/15] ixd: add devlink >> support >> >> From: Amritha Nambiar <amritha.nambiar@intel.com> >> >> Enable initial support for the devlink interface with the ixd driver. >> The ixd hardware is a single function PCIe device. So, the PCIe >> adapter gets its own devlink instance to manage device-wide resources >> or configuration. >> >> $ devlink dev show >> pci/0000:83:00.6 >> >> $ devlink dev info pci/0000:83:00.6 >> pci/0000:83:00.6: >> driver ixd >> serial_number 00-a0-c9-ff-ff-23-45-67 >> versions: >> fixed: >> device.type MEV >> running: >> cp 0.0 >> virtchnl 2.0 >> > This commit mentions MEV without expansion. > Kernel docs require expanding uncommon abbreviations. > This is an example of the output of devlink, so if devlink literally does print MEV, this should stay as-is. You could provide an area which explains what each device type means and has the expanded definition.
© 2016 - 2025 Red Hat, Inc.