ionic: report on-board sensors through an hwmon auxiliary driver
Subsystems (5)
cover ionic: report on-board sensors through an hwmon auxiliary driver
AMD Pensando adapters can report board and ASIC sensors (temperature, voltage and power) through the device firmware. This series exposes them through hwmon.
Following the discussion in [1], ionic creates an "ionic.hwmon" auxiliary device and a new driver in drivers/hwmon/ binds to it. Guenter suggested taking the series through net-next with his Ack on the hwmon driver, and agreed to his off-list reply being quoted here:
Quoted 3 lines
For b), an Ack from me and applying it through the network subsystem would probably be the easiest approach, but I am open to anything.
The set of sensors depends on the board and the firmware, so firmware describes it at runtime:
- Patch 1 registers ionic's auxiliary devices from a table of device types, so a second type can be added next to the RDMA device.
- Patch 2 adds the device interface: a capability bit, IONIC_CMD_HWMON_GETCAPS, which returns a buffer describing the sensor types, their channels, and each channel's attributes, permissions and label, and IONIC_CMD_HWMON_GETATTR, which reads one attribute.
- Patch 3 creates the "ionic.hwmon" auxiliary device when the firmware advertises the capability, and exports the calls the hwmon driver uses to issue those commands.
- Patch 4 adds the ionic-hwmon driver. It parses the capability buffer into hwmon channel configuration at probe, and serves each sensor read with one GETATTR admin command. Only standard hwmon attributes are exposed.
Tested on an AMD Pensando adapter, including driver unbind and PCI reset with concurrent sensor reads.
This series was developed with the help of an LLM-based coding assistant (Claude).
[1] https://lore.kernel.org/all/[email protected]/
---
Arun Kumar Prakash (2):
ionic: add device interface definitions for hardware monitoring
hwmon: add AMD Pensando ionic sensor driver
Nikhil P. Rao (2):
ionic: register auxiliary devices from a table of device types
ionic: add an auxiliary device for hardware monitoring
Documentation/hwmon/index.rst | 1 + Documentation/hwmon/ionic-hwmon.rst | 61 +++ MAINTAINERS | 9 + drivers/hwmon/Kconfig | 13 + drivers/hwmon/Makefile | 1 + drivers/hwmon/ionic-hwmon.c | 492 +++++++++++++++++++++ drivers/net/ethernet/pensando/ionic/ionic.h | 3 + drivers/net/ethernet/pensando/ionic/ionic_aux.c | 203 +++++++-- drivers/net/ethernet/pensando/ionic/ionic_aux.h | 2 +- .../net/ethernet/pensando/ionic/ionic_bus_pci.c | 14 +- drivers/net/ethernet/pensando/ionic/ionic_dev.h | 8 + drivers/net/ethernet/pensando/ionic/ionic_if.h | 104 +++++ drivers/net/ethernet/pensando/ionic/ionic_lif.h | 8 +- drivers/net/ethernet/pensando/ionic/ionic_main.c | 4 + include/linux/ionic/ionic_hwmon.h | 178 ++++++++ 15 files changed, 1069 insertions(+), 32 deletions(-)
---
base-commit: 4dd16e31135ea8437a720222df34e8745f385d6d
change-id: 20261102-pr46-b4-4967f18fd3a2
Best regards,
Signature · 1 line
Nikhil P. Rao <[email protected]>
PATCH 1/4 ionic: register auxiliary devices from a table of device types
A later patch adds a hardware monitoring auxiliary device alongside the rdma one. Describe the auxiliary device types in a table, so that adding one takes an enum value and a table entry.
Allocate the auxiliary device id once per ionic device instead of on every add, so all of a device's auxiliary devices share one id, for example ionic.rdma.0 and ionic.hwmon.0.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 1 + drivers/net/ethernet/pensando/ionic/ionic_aux.c | 94 +++++++++++++++------- drivers/net/ethernet/pensando/ionic/ionic_aux.h | 2 +- .../net/ethernet/pensando/ionic/ionic_bus_pci.c | 14 +++- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 7 +- 5 files changed, 86 insertions(+), 32 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -0
@@ -49,6 +49,7 @@ struct ionic {struct ionic_identity ident;struct workqueue_struct *wq;struct ionic_lif *lif; +int aux_id;unsigned int nnqs_per_lif;unsigned int neqs_per_lif;unsigned int ntxqs_per_lif;
drivers/net/ethernet/pensando/ionic/ionic_aux.c +66 -28
140 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_aux.h +1 -1
@@ -4,7 +4,7 @@#ifndef _IONIC_AUX_H_#define _IONIC_AUX_H_ -int ionic_auxbus_register (struct ionic_lif *lif); +void ionic_auxbus_register (struct ionic_lif *lif);void ionic_auxbus_unregister (struct ionic_lif *lif);#endif /* _IONIC_AUX_H_ */
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +12 -2
@@ -20,6 +20,8 @@ static const struct pci_device_id ionic_id_table[] = { };MODULE_DEVICE_TABLE (pci, ionic_id_table); +static DEFINE_IDA (ionic_ida); +int ionic_bus_get_irq (struct ionic *ionic,unsigned int num) {return pci_irq_vector (ionic->pdev, num);
@@ -321,12 +323,17 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)pci_set_drvdata (pdev, ionic);mutex_init (&ionic->dev_cmd_lock); + err =ida_alloc (&ionic_ida,GFP_KERNEL ); +if (err <0 ) + goto err_out; + ionic->aux_id = err; +/* Query system for DMA addressing limitation for the device. */ err =dma_set_mask_and_coherent (dev,DMA_BIT_MASK (IONIC_ADDR_LEN ));if (err) {dev_err (dev,"Unable to obtain 64-bit DMA for consistent allocations, aborting. err=%d\n" , err); - goto err_out; + goto err_out_free_id; }#ifdef CONFIG_PPC64
@@ -336,7 +343,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err =ionic_setup_one (ionic);if (err) - goto err_out; + goto err_out_free_id;/* Allocate and init the LIF */ err =ionic_lif_size (ionic);
@@ -401,6 +408,8 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)ionic_dev_teardown (ionic);ionic_clear_pci (ionic);ionic_debugfs_del_dev (ionic); +err_out_free_id: +ida_free (&ionic_ida, ionic->aux_id); err_out:mutex_destroy (&ionic->dev_cmd_lock);ionic_devlink_free (ionic);
@@ -437,6 +446,7 @@ static void ionic_remove(struct pci_dev *pdev)ionic_dev_teardown (ionic);ionic_clear_pci (ionic);ionic_debugfs_del_dev (ionic); +ida_free (&ionic_ida, ionic->aux_id);mutex_destroy (&ionic->dev_cmd_lock);ionic_devlink_free (ionic); }
drivers/net/ethernet/pensando/ionic/ionic_lif.h +6 -1
@@ -180,6 +180,11 @@ struct ionic_qtype_info {struct ionic_phc ; +enum ionic_aux_type { +IONIC_AUX_RDMA , +IONIC_AUX_MAX , +}; +#define IONIC_LIF_NAME_MAX_SZ 32struct ionic_lif {struct net_device *netdev;
@@ -225,7 +230,7 @@ struct ionic_lif {dma_addr_t info_pa;u32 info_sz;struct ionic_qtype_info qtype_info[IONIC_QTYPE_MAX ]; -struct ionic_aux_dev *ionic_adev; +struct ionic_aux_dev *aux_devs[IONIC_AUX_MAX ];struct mutex adev_lock;/* lock for aux_dev actions */ u8 rss_hash_key[IONIC_RSS_HASH_KEY_SIZE ];
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/4] ionic: register auxiliary devices from a table of device types
Quoted 10 lines · Nikhil P. Rao
A later patch adds a hardware monitoring auxiliary device alongside the rdma one. Describe the auxiliary device types in a table, so that adding one takes an enum value and a table entry.
Allocate the auxiliary device id once per ionic device instead of on every add, so all of a device's auxiliary devices share one id, for example ionic.rdma.0 and ionic.hwmon.0.
Reviewed-by Brett Creeley <[email protected]>Signed-off-by Nikhil P. Rao <[email protected]>
PATCH 2/4 ionic: add device interface definitions for hardware monitoring
In reply to Nikhil P. RaoFrom: Arun Kumar Prakash <[email protected]>
Add the admin queue commands the device uses to describe and report its
sensors: IONIC_CMD_HWMON_GETCAPS returns a buffer enumerating the sensor types, their channel counts and per-channel attribute capabilities, and IONIC_CMD_HWMON_GETATTR reads a single attribute of a single channel.
The capability buffer has a variable layout that depends on the number of sensor types the firmware supports, so it cannot be expressed as a C struct and its format is documented in a comment instead.
The sensor types, attribute IDs and capability buffer layout go in a new public header, include/linux/ionic/ionic_hwmon.h, because the hwmon driver that parses the buffer lives outside the ionic directory.
--- MAINTAINERS | 1 + drivers/net/ethernet/pensando/ionic/ionic_dev.h | 8 ++ drivers/net/ethernet/pensando/ionic/ionic_if.h | 104 +++++++++++++++++ drivers/net/ethernet/pensando/ionic/ionic_main.c | 4 + include/linux/ionic/ionic_hwmon.h | 138 +++++++++++++++++++++++ 5 files changed, 255 insertions(+)
MAINTAINERS +1 -0
@@ -21804,6 +21804,7 @@ L: [email protected] S: Maintained F: Documentation/networking/device_drivers/ethernet/pensando/ionic.rst F: drivers/net/ethernet/pensando/ +F: include/linux/ionic/ PER-CPU MEMORY ALLOCATOR M: Dennis Zhou <[email protected]>
drivers/net/ethernet/pensando/ionic/ionic_dev.h +8 -0
@@ -9,6 +9,7 @@#include <linux/workqueue.h> #include <linux/skbuff.h> #include <linux/bpf_trace.h> +#include <linux/ionic/ionic_hwmon.h> #include "ionic_if.h" #include "ionic_regs.h"
@@ -116,6 +117,13 @@ static_assert(sizeof(ionic_rx_filter_del_comp) == 16);static_assert (sizeof (struct ionic_rdma_reset_cmd ) ==64 );static_assert (sizeof (struct ionic_rdma_queue_cmd ) ==64 ); +/* HWMON commands */ +static_assert (sizeof (struct ionic_hwmon_getattr_cmd ) ==64 ); +static_assert (sizeof (struct ionic_hwmon_getattr_comp ) ==16 ); +static_assert (sizeof (struct ionic_hwmon_getcaps_cmd ) ==64 ); +static_assert (sizeof (struct ionic_hwmon_getcaps_comp ) ==16 ); +static_assert (sizeof (struct ionic_hwmon_chan_caps ) ==164 ); +/* Events */ static_assert (sizeof (struct ionic_notifyq_cmd ) ==4 );static_assert (sizeof (union ionic_notifyq_comp ) ==64 );
drivers/net/ethernet/pensando/ionic/ionic_if.h +104 -0
139 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_main.c +4 -0
@@ -185,6 +185,10 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode)return "IONIC_CMD_VF_GETATTR" ;case IONIC_CMD_VF_SETATTR :return "IONIC_CMD_VF_SETATTR" ; +case IONIC_CMD_HWMON_GETATTR : +return "IONIC_CMD_HWMON_GETATTR" ; +case IONIC_CMD_HWMON_GETCAPS : +return "IONIC_CMD_HWMON_GETCAPS" ;default :return "DEVCMD_UNKNOWN" ; }
include/linux/ionic/ionic_hwmon.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next 2/4] ionic: add device interface definitions for hardware monitoring
Quoted 15 lines · Nikhil P. Rao
From: Arun Kumar Prakash <[email protected]>
Add the admin queue commands the device uses to describe and report its
sensors:IONIC_CMD_HWMON_GETCAPSreturns a buffer enumerating the sensor types, their channel counts and per-channel attribute capabilities, andIONIC_CMD_HWMON_GETATTRreads a single attribute of a single channel.The capability buffer has a variable layout that depends on the number of sensor types the firmware supports, so it cannot be expressed as a C struct and its format is documented in a comment instead.
The sensor types, attribute IDs and capability buffer layout go in a new public header,
include/linux/ionic/ionic_hwmon.h, because the hwmon driver that parses the buffer lives outside the ionic directory.
Quoted 5 lines
Signed-off-by Arun Kumar Prakash <[email protected]>Signed-off-by Eric Joyner <[email protected]>Reviewed-by Brett Creeley <[email protected]>Co-developed-by Nikhil P. Rao <[email protected]>Signed-off-by Nikhil P. Rao <[email protected]>
PATCH 3/4 ionic: add an auxiliary device for hardware monitoring
In reply to Nikhil P. RaoWhen the firmware sets IONIC_DEV_CAP_HWMON, create an "hwmon" auxiliary device so the adapter's sensors can be exposed by a driver in drivers/hwmon/ rather than by the Ethernet driver.
The GETCAPS response buffer belongs to ionic for the life of the device, not to the hwmon driver, so a command abandoned on timeout or unbind can only write into that buffer, never into freed memory.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 2 + drivers/net/ethernet/pensando/ionic/ionic_aux.c | 109 ++++++++++++++++++++++++ drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 + include/linux/ionic/ionic_hwmon.h | 40 +++++++++ 4 files changed, 152 insertions(+)
drivers/net/ethernet/pensando/ionic/ionic.h +2 -0
@@ -64,6 +64,8 @@ struct ionic {int num_vfs;struct timer_list watchdog_timer;int watchdog_period; +void *hwmon_caps_buf; +dma_addr_t hwmon_caps_pa; };int ionic_adminq_post (struct ionic_lif *lif,struct ionic_admin_ctx *ctx);
drivers/net/ethernet/pensando/ionic/ionic_aux.c +109 -0
132 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -0
@@ -182,6 +182,7 @@ struct ionic_phc;enum ionic_aux_type {IONIC_AUX_RDMA , +IONIC_AUX_HWMON ,IONIC_AUX_MAX , };
include/linux/ionic/ionic_hwmon.h +40 -0
@@ -135,4 +135,44 @@ struct ionic_hwmon_caps_hdr { __le16 n_channels[]; }; +struct auxiliary_device ; +struct device ; + +/** +* ionic_hwmon_get_caps - Read the sensor capabilities from the device +* @adev: ionic "hwmon" auxiliary device +* @max_ver: highest capabilities buffer layout version the caller parses +* @buf: set to the capabilities buffer +* @len: set to the length of @buf +* @ver: set to the layout version of @buf, as reported by the device +* +* The buffer belongs to ionic and is overwritten by the next call. +* +* Return: zero or negative error status +*/ +int ionic_hwmon_get_caps (struct auxiliary_device *adev,u8 max_ver, +const void **buf,size_t *len,u8 *ver); + +/** +* ionic_hwmon_get_attr - Read one sensor attribute from the device +* @adev: ionic "hwmon" auxiliary device +* @type: sensor type from enum ionic_hwmon_sensor_type +* @channel: channel index within @type +* @attr: attribute ID from the attribute enum for @type +* @val: set to the attribute value, in the units documented for +* struct ionic_hwmon_getattr_comp +* +* Return: zero or negative error status +*/ +int ionic_hwmon_get_attr (struct auxiliary_device *adev,u8 type,u8 channel, +u8 attr,u32 *val); + +/** +* ionic_hwmon_dev - Device to parent the hwmon device to +* @adev: ionic "hwmon" auxiliary device +* +* Return: the PCI function's device +*/ +struct device *ionic_hwmon_dev (struct auxiliary_device *adev); +#endif /* _LINUX_IONIC_HWMON_H_ */
Signature · 1 line
2.43.0
Re: [PATCH net-next 3/4] ionic: add an auxiliary device for hardware monitoring
Quoted 10 lines · Nikhil P. Rao
When the firmware sets
IONIC_DEV_CAP_HWMON, create an "hwmon" auxiliary device so the adapter's sensors can be exposed by a driver indrivers/hwmon/rather than by the Ethernet driver.The GETCAPS response buffer belongs to ionic for the life of the device, not to the hwmon driver, so a command abandoned on timeout or unbind can only write into that buffer, never into freed memory.
Reviewed-by Brett Creeley <[email protected]>Signed-off-by Nikhil P. Rao <[email protected]>
PATCH 4/4 hwmon: add AMD Pensando ionic sensor driver
In reply to Nikhil P. RaoFrom: Arun Kumar Prakash <[email protected]>
Add an auxiliary driver that binds to the "ionic.hwmon" device created by the ionic Ethernet driver and reports the adapter's temperature, voltage and power sensors through hwmon.
The sensor set depends on the board and firmware, so the driver reads it from the device at probe rather than hard-coding it. A sensor type with a channel the driver does not recognise is skipped as a whole, since hwmon channel numbers must match the firmware's.
The hwmon device is parented to the adapter's PCI function rather than to the auxiliary device, so lm-sensors names it by PCI address instead of as a virtual device.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/ionic-hwmon.rst | 61 +++++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 13 + drivers/hwmon/Makefile | 1 + drivers/hwmon/ionic-hwmon.c | 492 ++++++++++++++++++++++++++++++++++++ 6 files changed, 576 insertions(+)
Documentation/hwmon/index.rst +1 -0
@@ -106,6 +106,7 @@ Hardware Monitoring Kernel Drivers ina3221 inspur-ipsps1 intel-m10-bmc-hwmon + ionic-hwmon ir35221 ir38064 ir36021
Documentation/hwmon/ionic-hwmon.rst new file +61 -0
61 lines not on this page · raw message
MAINTAINERS +8 -0
@@ -1276,6 +1276,14 @@ F: Documentation/networking/device_drivers/ethernet/amd/pds_core.rst F: drivers/net/ethernet/amd/pds_core/ F: include/linux/pds/ +AMD PENSANDO IONIC HARDWARE MONITORING DRIVER +M: Brett Creeley <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/ionic-hwmon.rst +F: drivers/hwmon/ionic-hwmon.c +F: include/linux/ionic/ionic_hwmon.h + AMD PENSANDO RDMA DRIVER M: Abhijit Gangurde <[email protected]> M: Allen Hubbe <[email protected]>
drivers/hwmon/Kconfig +13 -0
@@ -914,6 +914,19 @@ config SENSORS_IIO_HWMON for those channels specified in the map. This map can be provided either via platform data or the device tree bindings. +config SENSORS_IONIC + tristate "AMD Pensando ionic adapter sensors" + depends on IONIC + help + If you say yes here you get support for the on-board sensors of + AMD Pensando Ethernet adapters, such as temperature, voltage and + power. The adapter firmware describes which sensors are present, + so the set of attributes varies between adapters and firmware + versions. + + This driver can also be built as a module. If so, the module + will be called ionic-hwmon. + config SENSORS_I5500 tristate "Intel 5500/5520/X58 temperature sensor" depends on X86 && PCI
drivers/hwmon/Makefile +1 -0
@@ -111,6 +111,7 @@ obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o obj-$(CONFIG_SENSORS_INA238) += ina238.o obj-$(CONFIG_SENSORS_INA3221) += ina3221.o obj-$(CONFIG_SENSORS_INTEL_M10_BMC_HWMON) += intel-m10-bmc-hwmon.o +obj-$(CONFIG_SENSORS_IONIC) += ionic-hwmon.o obj-$(CONFIG_SENSORS_ISL28022) += isl28022.o obj-$(CONFIG_SENSORS_IT87) += it87.o obj-$(CONFIG_SENSORS_JC42) += jc42.o
drivers/hwmon/ionic-hwmon.c new file +492 -0
492 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH net-next 4/4] hwmon: add AMD Pensando ionic sensor driver
Quoted 15 lines · Nikhil P. Rao
From: Arun Kumar Prakash <[email protected]>
Add an auxiliary driver that binds to the "ionic.hwmon" device created by the ionic Ethernet driver and reports the adapter's temperature, voltage and power sensors through hwmon.
The sensor set depends on the board and firmware, so the driver reads it from the device at probe rather than hard-coding it. A sensor type with a channel the driver does not recognise is skipped as a whole, since hwmon channel numbers must match the firmware's.
The hwmon device is parented to the adapter's PCI function rather than to the auxiliary device, so lm-sensors names it by PCI address instead of as a virtual device.
Quoted 5 lines
Signed-off-by Arun Kumar Prakash <[email protected]>Signed-off-by Eric Joyner <[email protected]>Reviewed-by Brett Creeley <[email protected]>Co-developed-by Nikhil P. Rao <[email protected]>Signed-off-by Nikhil P. Rao <[email protected]>
Thanks,
Guenter
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 3 Nov 2026 18:14:45 +0000 you wrote:
AMD Pensando adapters can report board and ASIC sensors (temperature, voltage and power) through the device firmware. This series exposes them through hwmon.
Following the discussion in [1], ionic creates an "ionic.hwmon" auxiliary device and a new driver in
drivers/hwmon/binds to it. Guenter suggested taking the series through net-next with his Ack on the hwmon driver, and agreed to his off-list reply being quoted here:[...]
Here is the summary with links:
- [net-next,1/4] ionic: register auxiliary devices from a table of device types
https://git.kernel.org/netdev/net-next/c/ead2c8476c46 - [net-next,2/4] ionic: add device interface definitions for hardware monitoring https://git.kernel.org/netdev/net-next/c/5794c810b920 - [net-next,3/4] ionic: add an auxiliary device for hardware monitoring https://git.kernel.org/netdev/net-next/c/ae5d56bb947e - [net-next,4/4] hwmon: add AMD Pensando ionic sensor driver https://git.kernel.org/netdev/net-next/c/007548a7238d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html