32 #include <linux/module.h>
33 #include <linux/types.h>
36 #include <linux/device.h>
37 #include <linux/netdevice.h>
45 struct hwmon_attr *ixgbe_attr =
container_of(attr,
struct hwmon_attr,
48 ixgbe_attr->sensor->location);
55 struct hwmon_attr *ixgbe_attr =
container_of(attr,
struct hwmon_attr,
60 ixgbe_attr->hw->mac.ops.get_thermal_sensor_data(ixgbe_attr->hw);
62 value = ixgbe_attr->sensor->temp;
67 return sprintf(buf,
"%u\n", value);
70 static ssize_t ixgbe_hwmon_show_cautionthresh(
struct device *dev,
74 struct hwmon_attr *ixgbe_attr =
container_of(attr,
struct hwmon_attr,
76 unsigned int value = ixgbe_attr->sensor->caution_thresh;
81 return sprintf(buf,
"%u\n", value);
84 static ssize_t ixgbe_hwmon_show_maxopthresh(
struct device *dev,
88 struct hwmon_attr *ixgbe_attr =
container_of(attr,
struct hwmon_attr,
90 unsigned int value = ixgbe_attr->sensor->max_op_thresh;
95 return sprintf(buf,
"%u\n", value);
112 struct hwmon_attr *ixgbe_attr;
114 n_attr = adapter->ixgbe_hwmon_buff.n_hwmon;
115 ixgbe_attr = &adapter->ixgbe_hwmon_buff.hwmon_list[n_attr];
118 case IXGBE_HWMON_TYPE_LOC:
119 ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_location;
120 snprintf(ixgbe_attr->name,
sizeof(ixgbe_attr->name),
121 "temp%u_label", offset);
123 case IXGBE_HWMON_TYPE_TEMP:
124 ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_temp;
125 snprintf(ixgbe_attr->name,
sizeof(ixgbe_attr->name),
126 "temp%u_input", offset);
128 case IXGBE_HWMON_TYPE_CAUTION:
129 ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_cautionthresh;
130 snprintf(ixgbe_attr->name,
sizeof(ixgbe_attr->name),
131 "temp%u_max", offset);
133 case IXGBE_HWMON_TYPE_MAX:
134 ixgbe_attr->dev_attr.show = ixgbe_hwmon_show_maxopthresh;
135 snprintf(ixgbe_attr->name,
sizeof(ixgbe_attr->name),
136 "temp%u_crit", offset);
145 &adapter->
hw.mac.thermal_sensor_data.sensor[
offset];
146 ixgbe_attr->hw = &adapter->
hw;
147 ixgbe_attr->dev_attr.store =
NULL;
148 ixgbe_attr->dev_attr.attr.mode =
S_IRUGO;
149 ixgbe_attr->dev_attr.attr.name = ixgbe_attr->name;
152 &ixgbe_attr->dev_attr);
155 ++adapter->ixgbe_hwmon_buff.n_hwmon;
160 static void ixgbe_sysfs_del_adapter(
struct ixgbe_adapter *adapter)
167 for (i = 0; i < adapter->ixgbe_hwmon_buff.n_hwmon; i++) {
169 &adapter->ixgbe_hwmon_buff.hwmon_list[i].dev_attr);
172 kfree(adapter->ixgbe_hwmon_buff.hwmon_list);
174 if (adapter->ixgbe_hwmon_buff.device)
181 ixgbe_sysfs_del_adapter(adapter);
187 struct hwmon_buff *ixgbe_hwmon = &adapter->ixgbe_hwmon_buff;
193 if (adapter->
hw.mac.ops.init_thermal_sensor_thresh ==
NULL) {
198 if (adapter->
hw.mac.ops.init_thermal_sensor_thresh(&adapter->
hw))
206 ixgbe_hwmon->hwmon_list = kcalloc(n_attrs,
sizeof(
struct hwmon_attr),
208 if (!ixgbe_hwmon->hwmon_list) {
214 if (IS_ERR(ixgbe_hwmon->device)) {
215 rc = PTR_ERR(ixgbe_hwmon->device);
224 if (adapter->
hw.mac.thermal_sensor_data.sensor[i].location == 0)
228 rc = ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_CAUTION);
229 rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_LOC);
230 rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_TEMP);
231 rc |= ixgbe_add_hwmon_attr(adapter, i, IXGBE_HWMON_TYPE_MAX);
239 ixgbe_sysfs_del_adapter(adapter);