-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'eth-fbnic-add-hardware-monitoring-support'
Sanman Pradhan says: ==================== eth: fbnic: Add hardware monitoring support This patch series adds hardware monitoring support to the fbnic driver. It implements support for reading temperature and voltage sensors via firmware requests, and exposes this data through the HWMON interface. The series is structured as follows: Patch 1: Adds completion infrastructure for firmware requests Patch 2: Implements TSENE sensor message handling Patch 3: Adds HWMON interface support Output: $ ls -l /sys/class/hwmon/hwmon1/ total 0 lrwxrwxrwx 1 root root 0 Sep 10 00:00 device -> ../../../0000:01:00.0 -r--r--r-- 1 root root 4096 Sep 10 00:00 in0_input -r--r--r-- 1 root root 4096 Sep 10 00:00 name lrwxrwxrwx 1 root root 0 Sep 10 00:00 subsystem -> ../../../../../../class/hwmon -r--r--r-- 1 root root 4096 Sep 10 00:00 temp1_input -rw-r--r-- 1 root root 4096 Sep 10 00:00 uevent $ cat /sys/class/hwmon/hwmon1/temp1_input 40480 $ cat /sys/class/hwmon/hwmon1/in0_input 750 ==================== Link: https://patch.msgid.link/20250114000705.2081288-1-sanman.p211993@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Showing
8 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) Meta Platforms, Inc. and affiliates. */ | ||
|
||
#include <linux/hwmon.h> | ||
|
||
#include "fbnic.h" | ||
#include "fbnic_mac.h" | ||
|
||
static int fbnic_hwmon_sensor_id(enum hwmon_sensor_types type) | ||
{ | ||
if (type == hwmon_temp) | ||
return FBNIC_SENSOR_TEMP; | ||
if (type == hwmon_in) | ||
return FBNIC_SENSOR_VOLTAGE; | ||
|
||
return -EOPNOTSUPP; | ||
} | ||
|
||
static umode_t fbnic_hwmon_is_visible(const void *drvdata, | ||
enum hwmon_sensor_types type, | ||
u32 attr, int channel) | ||
{ | ||
if (type == hwmon_temp && attr == hwmon_temp_input) | ||
return 0444; | ||
if (type == hwmon_in && attr == hwmon_in_input) | ||
return 0444; | ||
|
||
return 0; | ||
} | ||
|
||
static int fbnic_hwmon_read(struct device *dev, enum hwmon_sensor_types type, | ||
u32 attr, int channel, long *val) | ||
{ | ||
struct fbnic_dev *fbd = dev_get_drvdata(dev); | ||
const struct fbnic_mac *mac = fbd->mac; | ||
int id; | ||
|
||
id = fbnic_hwmon_sensor_id(type); | ||
return id < 0 ? id : mac->get_sensor(fbd, id, val); | ||
} | ||
|
||
static const struct hwmon_ops fbnic_hwmon_ops = { | ||
.is_visible = fbnic_hwmon_is_visible, | ||
.read = fbnic_hwmon_read, | ||
}; | ||
|
||
static const struct hwmon_channel_info *fbnic_hwmon_info[] = { | ||
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), | ||
HWMON_CHANNEL_INFO(in, HWMON_I_INPUT), | ||
NULL | ||
}; | ||
|
||
static const struct hwmon_chip_info fbnic_chip_info = { | ||
.ops = &fbnic_hwmon_ops, | ||
.info = fbnic_hwmon_info, | ||
}; | ||
|
||
void fbnic_hwmon_register(struct fbnic_dev *fbd) | ||
{ | ||
if (!IS_REACHABLE(CONFIG_HWMON)) | ||
return; | ||
|
||
fbd->hwmon = hwmon_device_register_with_info(fbd->dev, "fbnic", | ||
fbd, &fbnic_chip_info, | ||
NULL); | ||
if (IS_ERR(fbd->hwmon)) { | ||
dev_notice(fbd->dev, | ||
"Failed to register hwmon device %pe\n", | ||
fbd->hwmon); | ||
fbd->hwmon = NULL; | ||
} | ||
} | ||
|
||
void fbnic_hwmon_unregister(struct fbnic_dev *fbd) | ||
{ | ||
if (!IS_REACHABLE(CONFIG_HWMON) || !fbd->hwmon) | ||
return; | ||
|
||
hwmon_device_unregister(fbd->hwmon); | ||
fbd->hwmon = NULL; | ||
} |
Oops, something went wrong.