From: Michael Chan <michael.chan@broadcom•com>
To: davem@davemloft•net
Cc: netdev@vger•kernel.org, edumazet@google•com, kuba@kernel•org,
pabeni@redhat•com, gospo@broadcom•com,
Kalesh AP <kalesh-anakkur.purayil@broadcom•com>,
Andy Gospodarek <andrew.gospodarek@broadcom•com>
Subject: [PATCH net-next v2 6/9] bnxt_en: Use non-standard attribute to expose shutdown temperature
Date: Tue, 26 Sep 2023 20:57:31 -0700 [thread overview]
Message-ID: <20230927035734.42816-7-michael.chan@broadcom.com> (raw)
In-Reply-To: <20230927035734.42816-1-michael.chan@broadcom.com>
[-- Attachment #1: Type: text/plain, Size: 2918 bytes --]
From: Kalesh AP <kalesh-anakkur.purayil@broadcom•com>
Implement the sysfs attributes directly in the driver for
shutdown threshold temperature and pass an extra attribute group
to the hwmon core when registering the hwmon device.
Link: https://lore.kernel.org/netdev/20230815045658.80494-12-michael.chan@broadcom.com/
Cc: Jean Delvare <jdelvare@suse•com>
Cc: Guenter Roeck <linux@roeck-us•net>
Cc: linux-hwmon@vger•kernel.org
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom•com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom•com>
Signed-off-by: Michael Chan <michael.chan@broadcom•com>
---
.../net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 54 ++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c
index 6a2cad5cc159..6d36158df26e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c
@@ -131,6 +131,57 @@ static const struct hwmon_chip_info bnxt_hwmon_chip_info = {
.info = bnxt_hwmon_info,
};
+static ssize_t temp1_shutdown_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct bnxt *bp = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%u\n", bp->shutdown_thresh_temp * 1000);
+}
+
+static ssize_t temp1_shutdown_alarm_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct bnxt *bp = dev_get_drvdata(dev);
+ u8 temp;
+ int rc;
+
+ rc = bnxt_hwrm_temp_query(bp, &temp);
+ if (rc)
+ return -EIO;
+
+ return sysfs_emit(buf, "%u\n", temp >= bp->shutdown_thresh_temp);
+}
+
+static DEVICE_ATTR_RO(temp1_shutdown);
+static DEVICE_ATTR_RO(temp1_shutdown_alarm);
+
+static struct attribute *bnxt_temp_extra_attrs[] = {
+ &dev_attr_temp1_shutdown.attr,
+ &dev_attr_temp1_shutdown_alarm.attr,
+ NULL,
+};
+
+static umode_t bnxt_temp_extra_attrs_visible(struct kobject *kobj,
+ struct attribute *attr, int index)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct bnxt *bp = dev_get_drvdata(dev);
+
+ /* Shutdown temperature setting in NVM is optional */
+ if (!(bp->fw_cap & BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED) ||
+ !bp->shutdown_thresh_temp)
+ return 0;
+
+ return attr->mode;
+}
+
+static const struct attribute_group bnxt_temp_extra_group = {
+ .attrs = bnxt_temp_extra_attrs,
+ .is_visible = bnxt_temp_extra_attrs_visible,
+};
+__ATTRIBUTE_GROUPS(bnxt_temp_extra);
+
void bnxt_hwmon_uninit(struct bnxt *bp)
{
if (bp->hwmon_dev) {
@@ -156,7 +207,8 @@ void bnxt_hwmon_init(struct bnxt *bp)
bp->hwmon_dev = hwmon_device_register_with_info(&pdev->dev,
DRV_MODULE_NAME, bp,
- &bnxt_hwmon_chip_info, NULL);
+ &bnxt_hwmon_chip_info,
+ bnxt_temp_extra_groups);
if (IS_ERR(bp->hwmon_dev)) {
bp->hwmon_dev = NULL;
dev_warn(&pdev->dev, "Cannot register hwmon device\n");
--
2.30.1
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]
next prev parent reply other threads:[~2023-09-27 3:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 3:57 [PATCH net-next v2 0/9] bnxt_en: hwmon and SRIOV updates Michael Chan
2023-09-27 3:57 ` [PATCH net-next v2 1/9] bnxt_en: Update firmware interface to 1.10.2.171 Michael Chan
2023-09-27 12:34 ` Andrew Lunn
2023-09-27 17:20 ` Michael Chan
2023-09-27 3:57 ` [PATCH net-next v2 2/9] bnxt_en: Enhance hwmon temperature reporting Michael Chan
2023-09-27 3:57 ` [PATCH net-next v2 3/9] bnxt_en: Move hwmon functions into a dedicated file Michael Chan
2023-09-27 13:55 ` Guenter Roeck
2023-09-27 3:57 ` [PATCH net-next v2 4/9] bnxt_en: Modify the driver to use hwmon_device_register_with_info Michael Chan
2023-09-27 13:56 ` Guenter Roeck
2023-09-27 3:57 ` [PATCH net-next v2 5/9] bnxt_en: Expose threshold temperatures through hwmon Michael Chan
2023-09-27 14:04 ` Guenter Roeck
2023-09-27 3:57 ` Michael Chan [this message]
2023-09-27 3:57 ` [PATCH net-next v2 7/9] bnxt_en: Event handler for Thermal event Michael Chan
2023-09-27 14:05 ` Guenter Roeck
2023-09-27 3:57 ` [PATCH net-next v2 8/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Michael Chan
2023-10-04 18:22 ` Jakub Kicinski
2023-09-27 3:57 ` [PATCH net-next v2 9/9] bnxt_en: Update VNIC resource calculation for VFs Michael Chan
2023-10-03 9:11 ` [PATCH net-next v2 0/9] bnxt_en: hwmon and SRIOV updates Simon Horman
2023-10-04 10:30 ` patchwork-bot+netdevbpf
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=20230927035734.42816-7-michael.chan@broadcom.com \
--to=michael.chan@broadcom$(echo .)com \
--cc=andrew.gospodarek@broadcom$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=gospo@broadcom$(echo .)com \
--cc=kalesh-anakkur.purayil@broadcom$(echo .)com \
--cc=kuba@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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