diff options
author | Don Skidmore <donald.c.skidmore@intel.com> | 2012-04-11 20:33:31 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2012-05-02 05:12:23 -0400 |
commit | 3ca8bc6de2b336d483bb9d83e0dfe16cde535fa6 (patch) | |
tree | 272c13b6566dc91f53456d8b61714597647dec8f /drivers | |
parent | e1ea9158e377de6dd6d88be8e1e039c0b34dba1a (diff) |
ixgbe: add hwmon interface to export thermal data
Some of our adapters have thermal data available, this patch exports
this data via hwmon sysfs interface.
Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com>
Tested-by: Stephen Ko <stephen.s.ko@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/intel/Kconfig | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe.h | 26 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c | 271 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c | 2 |
9 files changed, 322 insertions, 7 deletions
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig index 74215c05d799..546efe30c9b8 100644 --- a/drivers/net/ethernet/intel/Kconfig +++ b/drivers/net/ethernet/intel/Kconfig | |||
@@ -193,6 +193,14 @@ config IXGBE | |||
193 | To compile this driver as a module, choose M here. The module | 193 | To compile this driver as a module, choose M here. The module |
194 | will be called ixgbe. | 194 | will be called ixgbe. |
195 | 195 | ||
196 | config IXGBE_HWMON | ||
197 | bool "Intel(R) 10GbE PCI Express adapters HWMON support" | ||
198 | default y | ||
199 | depends on IXGBE && HWMON && !(IXGBE=y && HWMON=m) | ||
200 | ---help--- | ||
201 | Say Y if you want to expose the thermal sensor data on some of | ||
202 | our cards, via a hwmon sysfs interface. | ||
203 | |||
196 | config IXGBE_DCA | 204 | config IXGBE_DCA |
197 | bool "Direct Cache Access (DCA) Support" | 205 | bool "Direct Cache Access (DCA) Support" |
198 | default y | 206 | default y |
diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile index 8be1d1b2132e..0708d7eb4668 100644 --- a/drivers/net/ethernet/intel/ixgbe/Makefile +++ b/drivers/net/ethernet/intel/ixgbe/Makefile | |||
@@ -34,7 +34,7 @@ obj-$(CONFIG_IXGBE) += ixgbe.o | |||
34 | 34 | ||
35 | ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \ | 35 | ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \ |
36 | ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ | 36 | ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ |
37 | ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o | 37 | ixgbe_mbx.o ixgbe_x540.o ixgbe_sysfs.o ixgbe_lib.o |
38 | 38 | ||
39 | ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \ | 39 | ixgbe-$(CONFIG_IXGBE_DCB) += ixgbe_dcb.o ixgbe_dcb_82598.o \ |
40 | ixgbe_dcb_82599.o ixgbe_dcb_nl.o | 40 | ixgbe_dcb_82599.o ixgbe_dcb_nl.o |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 8e082f257efb..89cebc812ab9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h | |||
@@ -331,6 +331,26 @@ struct ixgbe_q_vector { | |||
331 | /* for dynamic allocation of rings associated with this q_vector */ | 331 | /* for dynamic allocation of rings associated with this q_vector */ |
332 | struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp; | 332 | struct ixgbe_ring ring[0] ____cacheline_internodealigned_in_smp; |
333 | }; | 333 | }; |
334 | #ifdef CONFIG_IXGBE_HWMON | ||
335 | |||
336 | #define IXGBE_HWMON_TYPE_LOC 0 | ||
337 | #define IXGBE_HWMON_TYPE_TEMP 1 | ||
338 | #define IXGBE_HWMON_TYPE_CAUTION 2 | ||
339 | #define IXGBE_HWMON_TYPE_MAX 3 | ||
340 | |||
341 | struct hwmon_attr { | ||
342 | struct device_attribute dev_attr; | ||
343 | struct ixgbe_hw *hw; | ||
344 | struct ixgbe_thermal_diode_data *sensor; | ||
345 | char name[12]; | ||
346 | }; | ||
347 | |||
348 | struct hwmon_buff { | ||
349 | struct device *device; | ||
350 | struct hwmon_attr *hwmon_list; | ||
351 | unsigned int n_hwmon; | ||
352 | }; | ||
353 | #endif /* CONFIG_IXGBE_HWMON */ | ||
334 | 354 | ||
335 | /* | 355 | /* |
336 | * microsecond values for various ITR rates shifted by 2 to fit itr register | 356 | * microsecond values for various ITR rates shifted by 2 to fit itr register |
@@ -535,6 +555,10 @@ struct ixgbe_adapter { | |||
535 | 555 | ||
536 | u32 timer_event_accumulator; | 556 | u32 timer_event_accumulator; |
537 | u32 vferr_refcount; | 557 | u32 vferr_refcount; |
558 | struct kobject *info_kobj; | ||
559 | #ifdef CONFIG_IXGBE_HWMON | ||
560 | struct hwmon_buff ixgbe_hwmon_buff; | ||
561 | #endif /* CONFIG_IXGBE_HWMON */ | ||
538 | }; | 562 | }; |
539 | 563 | ||
540 | struct ixgbe_fdir_filter { | 564 | struct ixgbe_fdir_filter { |
@@ -635,6 +659,8 @@ extern int ixgbe_setup_tc(struct net_device *dev, u8 tc); | |||
635 | #endif | 659 | #endif |
636 | extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); | 660 | extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32); |
637 | extern void ixgbe_do_reset(struct net_device *netdev); | 661 | extern void ixgbe_do_reset(struct net_device *netdev); |
662 | extern void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter); | ||
663 | extern int ixgbe_sysfs_init(struct ixgbe_adapter *adapter); | ||
638 | #ifdef IXGBE_FCOE | 664 | #ifdef IXGBE_FCOE |
639 | extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); | 665 | extern void ixgbe_configure_fcoe(struct ixgbe_adapter *adapter); |
640 | extern int ixgbe_fso(struct ixgbe_ring *tx_ring, | 666 | extern int ixgbe_fso(struct ixgbe_ring *tx_ring, |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c index 56fd46844f65..6175845df11d 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c | |||
@@ -1277,6 +1277,8 @@ static struct ixgbe_mac_operations mac_ops_82598 = { | |||
1277 | .set_fw_drv_ver = NULL, | 1277 | .set_fw_drv_ver = NULL, |
1278 | .acquire_swfw_sync = &ixgbe_acquire_swfw_sync, | 1278 | .acquire_swfw_sync = &ixgbe_acquire_swfw_sync, |
1279 | .release_swfw_sync = &ixgbe_release_swfw_sync, | 1279 | .release_swfw_sync = &ixgbe_release_swfw_sync, |
1280 | .get_thermal_sensor_data = NULL, | ||
1281 | .init_thermal_sensor_thresh = NULL, | ||
1280 | }; | 1282 | }; |
1281 | 1283 | ||
1282 | static struct ixgbe_eeprom_operations eeprom_ops_82598 = { | 1284 | static struct ixgbe_eeprom_operations eeprom_ops_82598 = { |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index 9c14685358eb..dee64d2703f0 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c | |||
@@ -2119,6 +2119,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = { | |||
2119 | .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, | 2119 | .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, |
2120 | .acquire_swfw_sync = &ixgbe_acquire_swfw_sync, | 2120 | .acquire_swfw_sync = &ixgbe_acquire_swfw_sync, |
2121 | .release_swfw_sync = &ixgbe_release_swfw_sync, | 2121 | .release_swfw_sync = &ixgbe_release_swfw_sync, |
2122 | .get_thermal_sensor_data = &ixgbe_get_thermal_sensor_data_generic, | ||
2123 | .init_thermal_sensor_thresh = &ixgbe_init_thermal_sensor_thresh_generic, | ||
2122 | 2124 | ||
2123 | }; | 2125 | }; |
2124 | 2126 | ||
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 6c6c66eace6c..e2b0519ff8cf 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | |||
@@ -3669,9 +3669,8 @@ s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) | |||
3669 | u8 i; | 3669 | u8 i; |
3670 | struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; | 3670 | struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; |
3671 | 3671 | ||
3672 | /* Only support thermal sensors attached to 82599 physical port 0 */ | 3672 | /* Only support thermal sensors attached to physical port 0 */ |
3673 | if ((hw->mac.type != ixgbe_mac_82599EB) || | 3673 | if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { |
3674 | (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { | ||
3675 | status = IXGBE_NOT_IMPLEMENTED; | 3674 | status = IXGBE_NOT_IMPLEMENTED; |
3676 | goto out; | 3675 | goto out; |
3677 | } | 3676 | } |
@@ -3732,9 +3731,8 @@ s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) | |||
3732 | 3731 | ||
3733 | memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data)); | 3732 | memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data)); |
3734 | 3733 | ||
3735 | /* Only support thermal sensors attached to 82599 physical port 0 */ | 3734 | /* Only support thermal sensors attached to physical port 0 */ |
3736 | if ((hw->mac.type != ixgbe_mac_82599EB) || | 3735 | if ((IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { |
3737 | (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { | ||
3738 | status = IXGBE_NOT_IMPLEMENTED; | 3736 | status = IXGBE_NOT_IMPLEMENTED; |
3739 | goto out; | 3737 | goto out; |
3740 | } | 3738 | } |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index aa29edb950f2..e8897cce8d0f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
@@ -7219,6 +7219,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev, | |||
7219 | 7219 | ||
7220 | e_dev_info("%s\n", ixgbe_default_device_descr); | 7220 | e_dev_info("%s\n", ixgbe_default_device_descr); |
7221 | cards_found++; | 7221 | cards_found++; |
7222 | |||
7223 | if (ixgbe_sysfs_init(adapter)) | ||
7224 | e_err(probe, "failed to allocate sysfs resources\n"); | ||
7225 | |||
7222 | return 0; | 7226 | return 0; |
7223 | 7227 | ||
7224 | err_register: | 7228 | err_register: |
@@ -7265,6 +7269,8 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev) | |||
7265 | } | 7269 | } |
7266 | 7270 | ||
7267 | #endif | 7271 | #endif |
7272 | ixgbe_sysfs_exit(adapter); | ||
7273 | |||
7268 | #ifdef IXGBE_FCOE | 7274 | #ifdef IXGBE_FCOE |
7269 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) | 7275 | if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) |
7270 | ixgbe_cleanup_fcoe(adapter); | 7276 | ixgbe_cleanup_fcoe(adapter); |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c new file mode 100644 index 000000000000..aa41fb705469 --- /dev/null +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c | |||
@@ -0,0 +1,271 @@ | |||
1 | /******************************************************************************* | ||
2 | |||
3 | Intel 10 Gigabit PCI Express Linux driver | ||
4 | Copyright(c) 1999 - 2012 Intel Corporation. | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify it | ||
7 | under the terms and conditions of the GNU General Public License, | ||
8 | version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License along with | ||
16 | this program; if not, write to the Free Software Foundation, Inc., | ||
17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | |||
19 | The full GNU General Public License is included in this distribution in | ||
20 | the file called "COPYING". | ||
21 | |||
22 | Contact Information: | ||
23 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> | ||
24 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
25 | |||
26 | *******************************************************************************/ | ||
27 | |||
28 | #include "ixgbe.h" | ||
29 | #include "ixgbe_common.h" | ||
30 | #include "ixgbe_type.h" | ||
31 | |||
32 | #include <linux/module.h> | ||
33 | #include <linux/types.h> | ||
34 | #include <linux/sysfs.h> | ||
35 | #include <linux/kobject.h> | ||
36 | #include <linux/device.h> | ||
37 | #include <linux/netdevice.h> | ||
38 | #include <linux/hwmon.h> | ||
39 | |||
40 | /* | ||
41 | * This file provides a sysfs interface to export information from the | ||
42 | * driver. The information presented is READ-ONLY. | ||
43 | */ | ||
44 | #ifdef CONFIG_IXGBE_HWMON | ||
45 | |||
46 | /* hwmon callback functions */ | ||
47 | static ssize_t ixgbe_hwmon_show_location(struct device *dev, | ||
48 | struct device_attribute *attr, | ||
49 | char *buf) | ||
50 | { | ||
51 | struct hwmon_attr *ixgbe_attr = container_of(attr, struct hwmon_attr, | ||
52 | dev_attr); | ||
53 | return sprintf(buf, "loc%u\n", | ||
54 | ixgbe_attr->sensor->location); | ||
55 | } | ||
56 | |||
57 | static ssize_t ixgbe_hwmon_show_temp(struct device *dev, | ||
58 | struct device_attribute *attr, | ||
59 | char *buf) | ||
60 | { | ||
61 | struct hwmon_attr *ixgbe_attr = container_of(attr, struct hwmon_attr, | ||
62 | dev_attr); | ||
63 | unsigned int value; | ||
64 | |||
65 | /* reset the temp field */ | ||
66 | ixgbe_attr->hw->mac.ops.get_thermal_sensor_data(ixgbe_attr->hw); | ||
67 | |||
68 | value = ixgbe_attr->sensor->temp; | ||
69 | |||
70 | /* display millidegree */ | ||
71 | value *= 1000; | ||
72 | |||
73 | return sprintf(buf, "%u\n", value); | ||
74 | } | ||
75 | |||
76 | static ssize_t ixgbe_hwmon_show_cautionthresh(struct device *dev, | ||
77 | struct device_attribute *attr, | ||
78 | char *buf) | ||
79 | { | ||
80 | struct hwmon_attr *ixgbe_attr = container_of(attr, struct hwmon_attr, | ||
81 | dev_attr); | ||
82 | unsigned int value = ixgbe_attr->sensor->caution_thresh; | ||
83 | |||
84 | /* display millidegree */ | ||
85 | value *= 1000; | ||
86 | |||
87 | return sprintf(buf, "%u\n", value); | ||
88 | } | ||
89 | |||
90 | static ssize_t ixgbe_hwmon_show_maxopthresh(struct device *dev, | ||
91 | struct device_attribute *attr, | ||
92 | char *buf) | ||
93 | { | ||
94 | struct hwmon_attr *ixgbe_attr = container_of(attr, struct hwmon_attr, | ||
95 | dev_attr); | ||
96 | unsigned int value = ixgbe_attr->sensor->max_op_thresh; | ||
97 | |||
98 | /* display millidegree */ | ||
99 | value *= 1000; | ||
100 | |||
101 | return sprintf(buf, "%u\n", value); | ||
102 | } | ||
103 | |||
104 | /* | ||
105 | * ixgbe_add_hwmon_attr - Create hwmon attr table for a hwmon sysfs file. | ||
106 | * @ adapter: pointer to the adapter structure | ||
107 | * @ offset: offset in the eeprom sensor data table | ||
108 | * @ type: type of sensor data to display | ||
109 | * | ||
110 | * For each file we want in hwmon's sysfs interface we need a device_attribute | ||
111 | * This is included in our hwmon_attr struct that contains the references to | ||
112 | * the data structures we need to get the data to display. | ||
113 | */ | ||
114 | static int ixgbe_add_hwmon_attr(struct ixgbe_adapter *adapter, | ||
115 | unsigned int offset, int type) { | ||
116 | int rc; | ||
117 | unsigned int n_attr; | ||
118 | struct hwmon_attr *ixgbe_attr; | ||
119 | |||
120 | n_attr = adapter->ixgbe_hwmon_buff.n_hwmon; | ||
121 | ixgbe_attr = &adapter->ixgbe_hwmon_buff.hwmon_list[n_attr]; | ||
122 | |||
123 | switch (type) { | ||
124 | case IXGBE_HWMON_TYPE_LOC: | ||
125 | ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location; | ||
126 | snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), | ||
127 | "temp%u_label", offset); | ||
128 | break; | ||
129 | case IXGBE_HWMON_TYPE_TEMP: | ||
130 | ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp; | ||
131 | snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), | ||
132 | "temp%u_input", offset); | ||
133 | break; | ||
134 | case IXGBE_HWMON_TYPE_CAUTION: | ||
135 | ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh; | ||
136 | snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), | ||
137 | "temp%u_max", offset); | ||
138 | break; | ||
139 | case IXGBE_HWMON_TYPE_MAX: | ||
140 | ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh; | ||
141 | snprintf(ixgbe_attr->name, sizeof(ixgbe_attr->name), | ||
142 | "temp%u_crit", offset); | ||
143 | break; | ||
144 | default: | ||
145 | rc = -EPERM; | ||
146 | return rc; | ||
147 | } | ||
148 | |||
149 | /* These always the same regardless of type */ | ||
150 | ixgbe_attr->sensor = | ||
151 | &adapter->hw.mac.thermal_sensor_data.sensor[offset]; | ||
152 | ixgbe_attr->hw = &adapter->hw; | ||
153 | ixgbe_attr->dev_attr.store = NULL; | ||
154 | ixgbe_attr->dev_attr.attr.mode = S_IRUGO; | ||
155 | ixgbe_attr->dev_attr.attr.name = ixgbe_attr->name; | ||
156 | |||
157 | rc = device_create_file(&adapter->pdev->dev, | ||
158 | &ixgbe_attr->dev_attr); | ||
159 | |||
160 | if (rc == 0) | ||
161 | ++adapter->ixgbe_hwmon_buff.n_hwmon; | ||
162 | |||
163 | return rc; | ||
164 | } | ||
165 | #endif /* CONFIG_IXGBE_HWMON */ | ||
166 | |||
167 | static void ixgbe_sysfs_del_adapter(struct ixgbe_adapter *adapter) | ||
168 | { | ||
169 | #ifdef CONFIG_IXGBE_HWMON | ||
170 | int i; | ||
171 | #endif /* CONFIG_IXGBE_HWMON */ | ||
172 | |||
173 | if (adapter == NULL) | ||
174 | return; | ||
175 | #ifdef CONFIG_IXGBE_HWMON | ||
176 | |||
177 | for (i = 0; i < adapter->ixgbe_hwmon_buff.n_hwmon; i++) { | ||
178 | device_remove_file(&adapter->pdev->dev, | ||
179 | &adapter->ixgbe_hwmon_buff.hwmon_list[i].dev_attr); | ||
180 | } | ||
181 | |||
182 | kfree(adapter->ixgbe_hwmon_buff.hwmon_list); | ||
183 | |||
184 | if (adapter->ixgbe_hwmon_buff.device) | ||
185 | hwmon_device_unregister(adapter->ixgbe_hwmon_buff.device); | ||
186 | #endif /* CONFIG_IXGBE_HWMON */ | ||
187 | |||
188 | if (adapter->info_kobj != NULL) | ||
189 | kobject_put(adapter->info_kobj); | ||
190 | } | ||
191 | |||
192 | /* called from ixgbe_main.c */ | ||
193 | void ixgbe_sysfs_exit(struct ixgbe_adapter *adapter) | ||
194 | { | ||
195 | ixgbe_sysfs_del_adapter(adapter); | ||
196 | } | ||
197 | |||
198 | /* called from ixgbe_main.c */ | ||
199 | int ixgbe_sysfs_init(struct ixgbe_adapter *adapter) | ||
200 | { | ||
201 | #ifdef CONFIG_IXGBE_HWMON | ||
202 | struct hwmon_buff *ixgbe_hwmon = &adapter->ixgbe_hwmon_buff; | ||
203 | unsigned int i; | ||
204 | int n_attrs; | ||
205 | #endif /* CONFIG_IXGBE_HWMON */ | ||
206 | struct net_device *netdev = adapter->netdev; | ||
207 | int rc = 0; | ||
208 | |||
209 | /* create info kobj and attribute listings in kobj */ | ||
210 | adapter->info_kobj = kobject_create_and_add("info", &netdev->dev.kobj); | ||
211 | if (adapter->info_kobj == NULL) { | ||
212 | rc = -ENOMEM; | ||
213 | goto err; | ||
214 | } | ||
215 | |||
216 | #ifdef CONFIG_IXGBE_HWMON | ||
217 | /* If this method isn't defined we don't support thermals */ | ||
218 | if (adapter->hw.mac.ops.init_thermal_sensor_thresh == NULL) { | ||
219 | rc = -EPERM; | ||
220 | goto err; | ||
221 | } | ||
222 | |||
223 | /* Don't create thermal hwmon interface if no sensors present */ | ||
224 | rc = adapter->hw.mac.ops.init_thermal_sensor_thresh(&adapter->hw); | ||
225 | if (rc) | ||
226 | goto err; | ||
227 | |||
228 | /* | ||
229 | * Allocation space for max attributs | ||
230 | * max num sensors * values (loc, temp, max, caution) | ||
231 | */ | ||
232 | n_attrs = IXGBE_MAX_SENSORS * 4; | ||
233 | ixgbe_hwmon->hwmon_list = kcalloc(n_attrs, sizeof(struct hwmon_attr), | ||
234 | GFP_KERNEL); | ||
235 | if (!ixgbe_hwmon->hwmon_list) { | ||
236 | rc = -ENOMEM; | ||
237 | goto err; | ||
238 | } | ||
239 | |||
240 | ixgbe_hwmon->device = hwmon_device_register(&adapter->pdev->dev); | ||
241 | if (IS_ERR(ixgbe_hwmon->device)) { | ||
242 | rc = PTR_ERR(ixgbe_hwmon->device); | ||
243 | goto err; | ||
244 | } | ||
245 | |||
246 | for (i = 0; i < IXGBE_MAX_SENSORS; i++) { | ||
247 | /* | ||
248 | * Only create hwmon sysfs entries for sensors that have | ||
249 | * meaningful data for. | ||
250 | */ | ||
251 | if (adapter->hw.mac.thermal_sensor_data.sensor[i].location == 0) | ||
252 | continue; | ||
253 | |||
254 | /* Bail if any hwmon attr struct fails to initialize */ | ||
255 | rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_CAUTION); | ||
256 | rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_LOC); | ||
257 | rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_TEMP); | ||
258 | rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_MAX); | ||
259 | if (rc) | ||
260 | goto err; | ||
261 | } | ||
262 | #endif /* CONFIG_IXGBE_HWMON */ | ||
263 | |||
264 | goto exit; | ||
265 | |||
266 | err: | ||
267 | ixgbe_sysfs_del_adapter(adapter); | ||
268 | exit: | ||
269 | return rc; | ||
270 | } | ||
271 | |||
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index 97a991403bbd..f90ec078ece2 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c | |||
@@ -849,6 +849,8 @@ static struct ixgbe_mac_operations mac_ops_X540 = { | |||
849 | .release_swfw_sync = &ixgbe_release_swfw_sync_X540, | 849 | .release_swfw_sync = &ixgbe_release_swfw_sync_X540, |
850 | .disable_rx_buff = &ixgbe_disable_rx_buff_generic, | 850 | .disable_rx_buff = &ixgbe_disable_rx_buff_generic, |
851 | .enable_rx_buff = &ixgbe_enable_rx_buff_generic, | 851 | .enable_rx_buff = &ixgbe_enable_rx_buff_generic, |
852 | .get_thermal_sensor_data = NULL, | ||
853 | .init_thermal_sensor_thresh = NULL, | ||
852 | }; | 854 | }; |
853 | 855 | ||
854 | static struct ixgbe_eeprom_operations eeprom_ops_X540 = { | 856 | static struct ixgbe_eeprom_operations eeprom_ops_X540 = { |