diff options
author | Harish Patil <harish.patil@qlogic.com> | 2014-04-25 17:43:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-04-27 23:20:53 -0400 |
commit | 1f0f467b670eec101419a2a1235e315e4324ea07 (patch) | |
tree | 12ccb0e57d3b3f11f6e2920aeaeb7dfa3f919254 /drivers/net/ethernet | |
parent | ddfbac07c0e87e221596a439e8fb3937b95db228 (diff) |
qlcnic: Add hwmon interface to export board temperature.
Signed-off-by: Harish Patil <harish.patil@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/qlogic/Kconfig | 11 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 15 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 4 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | 66 |
4 files changed, 95 insertions, 1 deletions
diff --git a/drivers/net/ethernet/qlogic/Kconfig b/drivers/net/ethernet/qlogic/Kconfig index c14bd3116e45..b8184323faae 100644 --- a/drivers/net/ethernet/qlogic/Kconfig +++ b/drivers/net/ethernet/qlogic/Kconfig | |||
@@ -66,6 +66,17 @@ config QLCNIC_VXLAN | |||
66 | Say Y here if you want to enable hardware offload support for | 66 | Say Y here if you want to enable hardware offload support for |
67 | Virtual eXtensible Local Area Network (VXLAN) in the driver. | 67 | Virtual eXtensible Local Area Network (VXLAN) in the driver. |
68 | 68 | ||
69 | config QLCNIC_HWMON | ||
70 | bool "QLOGIC QLCNIC 82XX and 83XX family HWMON support" | ||
71 | depends on QLCNIC && HWMON | ||
72 | default y | ||
73 | ---help--- | ||
74 | This configuration parameter can be used to read the | ||
75 | board temperature in Converged Ethernet devices | ||
76 | supported by qlcnic. | ||
77 | |||
78 | This data is available via the hwmon sysfs interface. | ||
79 | |||
69 | config QLGE | 80 | config QLGE |
70 | tristate "QLogic QLGE 10Gb Ethernet Driver Support" | 81 | tristate "QLogic QLGE 10Gb Ethernet Driver Support" |
71 | depends on PCI | 82 | depends on PCI |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 7b52a88923ef..381da04f1b71 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | |||
@@ -537,6 +537,7 @@ struct qlcnic_hardware_context { | |||
537 | u8 phys_port_id[ETH_ALEN]; | 537 | u8 phys_port_id[ETH_ALEN]; |
538 | u8 lb_mode; | 538 | u8 lb_mode; |
539 | u16 vxlan_port; | 539 | u16 vxlan_port; |
540 | struct device *hwmon_dev; | ||
540 | }; | 541 | }; |
541 | 542 | ||
542 | struct qlcnic_adapter_stats { | 543 | struct qlcnic_adapter_stats { |
@@ -2361,4 +2362,18 @@ static inline u32 qlcnic_get_vnic_func_count(struct qlcnic_adapter *adapter) | |||
2361 | else | 2362 | else |
2362 | return QLC_DEFAULT_VNIC_COUNT; | 2363 | return QLC_DEFAULT_VNIC_COUNT; |
2363 | } | 2364 | } |
2365 | |||
2366 | #ifdef CONFIG_QLCNIC_HWMON | ||
2367 | void qlcnic_register_hwmon_dev(struct qlcnic_adapter *); | ||
2368 | void qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *); | ||
2369 | #else | ||
2370 | static inline void qlcnic_register_hwmon_dev(struct qlcnic_adapter *adapter) | ||
2371 | { | ||
2372 | return; | ||
2373 | } | ||
2374 | static inline void qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *adapter) | ||
2375 | { | ||
2376 | return; | ||
2377 | } | ||
2378 | #endif | ||
2364 | #endif /* __QLCNIC_H_ */ | 2379 | #endif /* __QLCNIC_H_ */ |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 73f908a000e9..19878fb393d0 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
@@ -2593,7 +2593,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2593 | qlcnic_alloc_lb_filters_mem(adapter); | 2593 | qlcnic_alloc_lb_filters_mem(adapter); |
2594 | 2594 | ||
2595 | qlcnic_add_sysfs(adapter); | 2595 | qlcnic_add_sysfs(adapter); |
2596 | 2596 | qlcnic_register_hwmon_dev(adapter); | |
2597 | return 0; | 2597 | return 0; |
2598 | 2598 | ||
2599 | err_out_disable_mbx_intr: | 2599 | err_out_disable_mbx_intr: |
@@ -2700,6 +2700,8 @@ static void qlcnic_remove(struct pci_dev *pdev) | |||
2700 | 2700 | ||
2701 | qlcnic_remove_sysfs(adapter); | 2701 | qlcnic_remove_sysfs(adapter); |
2702 | 2702 | ||
2703 | qlcnic_unregister_hwmon_dev(adapter); | ||
2704 | |||
2703 | qlcnic_cleanup_pci_map(adapter->ahw); | 2705 | qlcnic_cleanup_pci_map(adapter->ahw); |
2704 | 2706 | ||
2705 | qlcnic_release_firmware(adapter); | 2707 | qlcnic_release_firmware(adapter); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c index cd346e27f2e1..eee5fc9dd56e 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c | |||
@@ -19,6 +19,10 @@ | |||
19 | #include <linux/sysfs.h> | 19 | #include <linux/sysfs.h> |
20 | #include <linux/aer.h> | 20 | #include <linux/aer.h> |
21 | #include <linux/log2.h> | 21 | #include <linux/log2.h> |
22 | #ifdef CONFIG_QLCNIC_HWMON | ||
23 | #include <linux/hwmon.h> | ||
24 | #include <linux/hwmon-sysfs.h> | ||
25 | #endif | ||
22 | 26 | ||
23 | #define QLC_STATUS_UNSUPPORTED_CMD -2 | 27 | #define QLC_STATUS_UNSUPPORTED_CMD -2 |
24 | 28 | ||
@@ -1243,6 +1247,68 @@ static struct bin_attribute bin_attr_flash = { | |||
1243 | .write = qlcnic_83xx_sysfs_flash_write_handler, | 1247 | .write = qlcnic_83xx_sysfs_flash_write_handler, |
1244 | }; | 1248 | }; |
1245 | 1249 | ||
1250 | #ifdef CONFIG_QLCNIC_HWMON | ||
1251 | |||
1252 | static ssize_t qlcnic_hwmon_show_temp(struct device *dev, | ||
1253 | struct device_attribute *dev_attr, | ||
1254 | char *buf) | ||
1255 | { | ||
1256 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
1257 | unsigned int temperature = 0, value = 0; | ||
1258 | |||
1259 | if (qlcnic_83xx_check(adapter)) | ||
1260 | value = QLCRDX(adapter->ahw, QLC_83XX_ASIC_TEMP); | ||
1261 | else if (qlcnic_82xx_check(adapter)) | ||
1262 | value = QLC_SHARED_REG_RD32(adapter, QLCNIC_ASIC_TEMP); | ||
1263 | |||
1264 | temperature = qlcnic_get_temp_val(value); | ||
1265 | /* display millidegree celcius */ | ||
1266 | temperature *= 1000; | ||
1267 | return sprintf(buf, "%u\n", temperature); | ||
1268 | } | ||
1269 | |||
1270 | /* hwmon-sysfs attributes */ | ||
1271 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | ||
1272 | qlcnic_hwmon_show_temp, NULL, 1); | ||
1273 | |||
1274 | static struct attribute *qlcnic_hwmon_attrs[] = { | ||
1275 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
1276 | NULL | ||
1277 | }; | ||
1278 | |||
1279 | ATTRIBUTE_GROUPS(qlcnic_hwmon); | ||
1280 | |||
1281 | void qlcnic_register_hwmon_dev(struct qlcnic_adapter *adapter) | ||
1282 | { | ||
1283 | struct device *dev = &adapter->pdev->dev; | ||
1284 | struct device *hwmon_dev; | ||
1285 | |||
1286 | /* Skip hwmon registration for a VF device */ | ||
1287 | if (qlcnic_sriov_vf_check(adapter)) { | ||
1288 | adapter->ahw->hwmon_dev = NULL; | ||
1289 | return; | ||
1290 | } | ||
1291 | hwmon_dev = hwmon_device_register_with_groups(dev, qlcnic_driver_name, | ||
1292 | adapter, | ||
1293 | qlcnic_hwmon_groups); | ||
1294 | if (IS_ERR(hwmon_dev)) { | ||
1295 | dev_err(dev, "Cannot register with hwmon, err=%ld\n", | ||
1296 | PTR_ERR(hwmon_dev)); | ||
1297 | hwmon_dev = NULL; | ||
1298 | } | ||
1299 | adapter->ahw->hwmon_dev = hwmon_dev; | ||
1300 | } | ||
1301 | |||
1302 | void qlcnic_unregister_hwmon_dev(struct qlcnic_adapter *adapter) | ||
1303 | { | ||
1304 | struct device *hwmon_dev = adapter->ahw->hwmon_dev; | ||
1305 | if (hwmon_dev) { | ||
1306 | hwmon_device_unregister(hwmon_dev); | ||
1307 | adapter->ahw->hwmon_dev = NULL; | ||
1308 | } | ||
1309 | } | ||
1310 | #endif | ||
1311 | |||
1246 | void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter) | 1312 | void qlcnic_create_sysfs_entries(struct qlcnic_adapter *adapter) |
1247 | { | 1313 | { |
1248 | struct device *dev = &adapter->pdev->dev; | 1314 | struct device *dev = &adapter->pdev->dev; |