lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 13 Apr 2019 12:31:45 +0000
From:   Igor Russkikh <Igor.Russkikh@...antia.com>
To:     "David S . Miller" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Nikita Danilov <Nikita.Danilov@...antia.com>,
        Dmitry Bogdanov <Dmitry.Bogdanov@...antia.com>,
        Igor Russkikh <Igor.Russkikh@...antia.com>,
        Yana Esina <yana.esina@...antia.com>
Subject: [PATCH netnext 02/16] net: aquantia: implement hwmon api for chip
 temperature

From: Yana Esina <yana.esina@...antia.com>

Added support for hwmon api, through the use of the sensors utility

Signed-off-by: Yana Esina <yana.esina@...antia.com>
Signed-off-by: Nikita Danilov <nikita.danilov@...antia.com>
Signed-off-by: Igor Russkikh <igor.russkikh@...antia.com>
---
 .../net/ethernet/aquantia/atlantic/Makefile   |  1 +
 .../ethernet/aquantia/atlantic/aq_drvinfo.c   | 77 +++++++++++++++++++
 .../ethernet/aquantia/atlantic/aq_drvinfo.h   | 16 ++++
 .../ethernet/aquantia/atlantic/aq_pci_func.c  |  4 +
 4 files changed, 98 insertions(+)
 create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c
 create mode 100644 drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.h

diff --git a/drivers/net/ethernet/aquantia/atlantic/Makefile b/drivers/net/ethernet/aquantia/atlantic/Makefile
index 4556630ee286..1f99cf832476 100644
--- a/drivers/net/ethernet/aquantia/atlantic/Makefile
+++ b/drivers/net/ethernet/aquantia/atlantic/Makefile
@@ -36,6 +36,7 @@ atlantic-objs := aq_main.o \
 	aq_ring.o \
 	aq_hw_utils.o \
 	aq_ethtool.o \
+	aq_drvinfo.o \
 	aq_filters.o \
 	hw_atl/hw_atl_a0.o \
 	hw_atl/hw_atl_b0.o \
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c
new file mode 100644
index 000000000000..3f441667ecef
--- /dev/null
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.c
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (C) 2014-2017 aQuantia Corporation. */
+
+/* File aq_drvinfo.c: Definition of common code for firmware info in sys.*/
+
+#include <linux/init.h>
+#include <linux/kobject.h>
+#include <linux/module.h>
+#include <linux/stat.h>
+#include <linux/string.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/uaccess.h>
+
+#include "aq_drvinfo.h"
+
+static ssize_t temperature_show(struct device *ndev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	struct aq_nic_s *aq_nic = pci_get_drvdata(to_pci_dev(ndev));
+	int temp = 0;
+	int err;
+
+	if (!aq_nic->aq_fw_ops->get_temp)
+		return -ENXIO;
+
+	/* Unit: millidegree Celsius */
+	err = aq_nic->aq_fw_ops->get_temp(aq_nic->aq_hw, &temp);
+
+	if (err == 0)
+		return sprintf(buf, "%u\n", temp);
+
+	return -ENXIO;
+}
+
+static ssize_t temp1_label_show(struct device *ndev,
+				struct device_attribute *attr,
+				char *buf)
+{
+	return sprintf(buf, "PHY temperature\n");
+}
+
+static DEVICE_ATTR_RO(temp1_label);
+static SENSOR_DEVICE_ATTR(temp1_input, 0444, temperature_show,
+			  NULL, 0);
+
+static struct attribute *aq_dev_attrs[] = {
+	&dev_attr_temp1_label.attr,
+	&sensor_dev_attr_temp1_input.dev_attr.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(aq_dev);
+
+int aq_drvinfo_init(struct net_device *ndev)
+{
+	struct aq_nic_s *aq_nic = netdev_priv(ndev);
+	struct pci_dev *pdev = aq_nic->pdev;
+	struct device *dev;
+	int err = 0;
+
+	dev =
+	devm_hwmon_device_register_with_groups(&aq_nic->pdev->dev,
+					       ndev->name,
+					       dev_get_drvdata(&pdev->dev),
+					       aq_dev_groups);
+
+	if (IS_ERR(dev))
+		err = PTR_ERR(dev);
+
+	return err;
+}
+
+void aq_drvinfo_exit(struct net_device *ndev)
+{
+}
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.h b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.h
new file mode 100644
index 000000000000..4adb1f84f550
--- /dev/null
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_drvinfo.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* Copyright (C) 2014-2017 aQuantia Corporation. */
+
+/* File aq_drvinfo.h: Declaration of common code for firmware info in sys.*/
+
+#ifndef AQ_DRVINFO_H
+#define AQ_DRVINFO_H
+
+#include "aq_nic.h"
+#include "aq_hw.h"
+#include "hw_atl/hw_atl_utils.h"
+
+int aq_drvinfo_init(struct net_device *ndev);
+void aq_drvinfo_exit(struct net_device *ndev);
+
+#endif /* AQ_DRVINFO_H */
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
index 0217ff4669a4..556b735e5a32 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c
@@ -20,6 +20,7 @@
 #include "hw_atl/hw_atl_a0.h"
 #include "hw_atl/hw_atl_b0.h"
 #include "aq_filters.h"
+#include "aq_drvinfo.h"
 
 static const struct pci_device_id aq_pci_tbl[] = {
 	{ PCI_VDEVICE(AQUANTIA, AQ_DEVICE_ID_0001), },
@@ -289,6 +290,8 @@ static int aq_pci_probe(struct pci_dev *pdev,
 	if (err < 0)
 		goto err_register;
 
+	aq_drvinfo_init(ndev);
+
 	return 0;
 
 err_register:
@@ -317,6 +320,7 @@ static void aq_pci_remove(struct pci_dev *pdev)
 			unregister_netdev(self->ndev);
 		aq_nic_free_vectors(self);
 		aq_pci_free_irq_vectors(self);
+		aq_drvinfo_exit(self->ndev);
 		iounmap(self->aq_hw->mmio);
 		kfree(self->aq_hw);
 		pci_release_regions(pdev);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ