aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Cree <ecree@solarflare.com>2013-09-30 05:52:49 -0400
committerBen Hutchings <bhutchings@solarflare.com>2013-12-12 17:06:52 -0500
commit2b216cef086a5b564a4415d7f1b6095ea1c2089c (patch)
tree4add5a5ae319abbbbb4a1a6180c0237c03316a43
parentf8f3b5ae3ea45ef6b00b471fed0fc90552a3c4af (diff)
sfc: Report units in sensor warnings
Add units to the "Sensor reports condition X for raw value Y" messages. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--drivers/net/ethernet/sfc/mcdi_mon.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/net/ethernet/sfc/mcdi_mon.c b/drivers/net/ethernet/sfc/mcdi_mon.c
index d72ad4fc3617..99c80f8c0a0e 100644
--- a/drivers/net/ethernet/sfc/mcdi_mon.c
+++ b/drivers/net/ethernet/sfc/mcdi_mon.c
@@ -24,6 +24,15 @@ enum efx_hwmon_type {
24 EFX_HWMON_IN, /* voltage */ 24 EFX_HWMON_IN, /* voltage */
25 EFX_HWMON_CURR, /* current */ 25 EFX_HWMON_CURR, /* current */
26 EFX_HWMON_POWER, /* power */ 26 EFX_HWMON_POWER, /* power */
27 EFX_HWMON_TYPES_COUNT
28};
29
30static const char *const efx_hwmon_unit[EFX_HWMON_TYPES_COUNT] = {
31 [EFX_HWMON_TEMP] = " degC",
32 [EFX_HWMON_COOL] = " rpm", /* though nonsense for a heatsink */
33 [EFX_HWMON_IN] = " mV",
34 [EFX_HWMON_CURR] = " mA",
35 [EFX_HWMON_POWER] = " W",
27}; 36};
28 37
29static const struct { 38static const struct {
@@ -91,7 +100,8 @@ static const char *const sensor_status_names[] = {
91void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev) 100void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
92{ 101{
93 unsigned int type, state, value; 102 unsigned int type, state, value;
94 const char *name = NULL, *state_txt; 103 enum efx_hwmon_type hwmon_type = EFX_HWMON_UNKNOWN;
104 const char *name = NULL, *state_txt, *unit;
95 105
96 type = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR); 106 type = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_MONITOR);
97 state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE); 107 state = EFX_QWORD_FIELD(*ev, MCDI_EVENT_SENSOREVT_STATE);
@@ -99,16 +109,22 @@ void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev)
99 109
100 /* Deal gracefully with the board having more drivers than we 110 /* Deal gracefully with the board having more drivers than we
101 * know about, but do not expect new sensor states. */ 111 * know about, but do not expect new sensor states. */
102 if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) 112 if (type < ARRAY_SIZE(efx_mcdi_sensor_type)) {
103 name = efx_mcdi_sensor_type[type].label; 113 name = efx_mcdi_sensor_type[type].label;
114 hwmon_type = efx_mcdi_sensor_type[type].hwmon_type;
115 }
104 if (!name) 116 if (!name)
105 name = "No sensor name available"; 117 name = "No sensor name available";
106 EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names)); 118 EFX_BUG_ON_PARANOID(state >= ARRAY_SIZE(sensor_status_names));
107 state_txt = sensor_status_names[state]; 119 state_txt = sensor_status_names[state];
120 EFX_BUG_ON_PARANOID(hwmon_type >= EFX_HWMON_TYPES_COUNT);
121 unit = efx_hwmon_unit[hwmon_type];
122 if (!unit)
123 unit = "";
108 124
109 netif_err(efx, hw, efx->net_dev, 125 netif_err(efx, hw, efx->net_dev,
110 "Sensor %d (%s) reports condition '%s' for raw value %d\n", 126 "Sensor %d (%s) reports condition '%s' for value %d%s\n",
111 type, name, state_txt, value); 127 type, name, state_txt, value, unit);
112} 128}
113 129
114#ifdef CONFIG_SFC_MCDI_MON 130#ifdef CONFIG_SFC_MCDI_MON