xref: /freebsd/sys/dev/sfxge/common/efx_mon.c (revision 123af6ec70016f5556da5972d4d63c7d175c06d3)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2007-2016 Solarflare Communications Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  *    this list of conditions and the following disclaimer in the documentation
14  *    and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * The views and conclusions contained in the software and documentation are
29  * those of the authors and should not be interpreted as representing official
30  * policies, either expressed or implied, of the FreeBSD Project.
31  */
32 
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35 
36 #include "efx.h"
37 #include "efx_impl.h"
38 
39 #if EFSYS_OPT_MON_MCDI
40 #include "mcdi_mon.h"
41 #endif
42 
43 #if EFSYS_OPT_NAMES
44 
45 static const char * const __efx_mon_name[] = {
46 	"",
47 	"sfx90x0",
48 	"sfx91x0",
49 	"sfx92x0"
50 };
51 
52 		const char *
53 efx_mon_name(
54 	__in	efx_nic_t *enp)
55 {
56 	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
57 
58 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
59 
60 	EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
61 	EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES);
62 	return (__efx_mon_name[encp->enc_mon_type]);
63 }
64 
65 #endif	/* EFSYS_OPT_NAMES */
66 
67 #if EFSYS_OPT_MON_MCDI
68 static const efx_mon_ops_t	__efx_mon_mcdi_ops = {
69 #if EFSYS_OPT_MON_STATS
70 	mcdi_mon_stats_update,		/* emo_stats_update */
71 	mcdi_mon_limits_update,		/* emo_limits_update */
72 #endif	/* EFSYS_OPT_MON_STATS */
73 };
74 #endif
75 
76 
77 	__checkReturn	efx_rc_t
78 efx_mon_init(
79 	__in		efx_nic_t *enp)
80 {
81 	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
82 	efx_mon_t *emp = &(enp->en_mon);
83 	const efx_mon_ops_t *emop;
84 	efx_rc_t rc;
85 
86 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
87 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
88 
89 	if (enp->en_mod_flags & EFX_MOD_MON) {
90 		rc = EINVAL;
91 		goto fail1;
92 	}
93 
94 	enp->en_mod_flags |= EFX_MOD_MON;
95 
96 	emp->em_type = encp->enc_mon_type;
97 
98 	EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
99 	switch (emp->em_type) {
100 #if EFSYS_OPT_MON_MCDI
101 	case EFX_MON_SFC90X0:
102 	case EFX_MON_SFC91X0:
103 	case EFX_MON_SFC92X0:
104 		emop = &__efx_mon_mcdi_ops;
105 		break;
106 #endif
107 	default:
108 		rc = ENOTSUP;
109 		goto fail2;
110 	}
111 
112 	emp->em_emop = emop;
113 	return (0);
114 
115 fail2:
116 	EFSYS_PROBE(fail2);
117 
118 	emp->em_type = EFX_MON_INVALID;
119 
120 	enp->en_mod_flags &= ~EFX_MOD_MON;
121 
122 fail1:
123 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
124 
125 	return (rc);
126 }
127 
128 #if EFSYS_OPT_MON_STATS
129 
130 #if EFSYS_OPT_NAMES
131 
132 /* START MKCONFIG GENERATED MonitorStatNamesBlock 277c17eda1a6d1a4 */
133 static const char * const __mon_stat_name[] = {
134 	"controller_temp",
135 	"phy_common_temp",
136 	"controller_cooling",
137 	"phy0_temp",
138 	"phy0_cooling",
139 	"phy1_temp",
140 	"phy1_cooling",
141 	"in_1v0",
142 	"in_1v2",
143 	"in_1v8",
144 	"in_2v5",
145 	"in_3v3",
146 	"in_12v0",
147 	"in_1v2a",
148 	"in_vref",
149 	"out_vaoe",
150 	"aoe_temp",
151 	"psu_aoe_temp",
152 	"psu_temp",
153 	"fan_0",
154 	"fan_1",
155 	"fan_2",
156 	"fan_3",
157 	"fan_4",
158 	"in_vaoe",
159 	"out_iaoe",
160 	"in_iaoe",
161 	"nic_power",
162 	"in_0v9",
163 	"in_i0v9",
164 	"in_i1v2",
165 	"in_0v9_adc",
166 	"controller_2_temp",
167 	"vreg_internal_temp",
168 	"vreg_0v9_temp",
169 	"vreg_1v2_temp",
170 	"controller_vptat",
171 	"controller_internal_temp",
172 	"controller_vptat_extadc",
173 	"controller_internal_temp_extadc",
174 	"ambient_temp",
175 	"airflow",
176 	"vdd08d_vss08d_csr",
177 	"vdd08d_vss08d_csr_extadc",
178 	"hotpoint_temp",
179 	"phy_power_port0",
180 	"phy_power_port1",
181 	"mum_vcc",
182 	"in_0v9_a",
183 	"in_i0v9_a",
184 	"vreg_0v9_a_temp",
185 	"in_0v9_b",
186 	"in_i0v9_b",
187 	"vreg_0v9_b_temp",
188 	"ccom_avreg_1v2_supply",
189 	"ccom_avreg_1v2_supply_extadc",
190 	"ccom_avreg_1v8_supply",
191 	"ccom_avreg_1v8_supply_extadc",
192 	"controller_master_vptat",
193 	"controller_master_internal_temp",
194 	"controller_master_vptat_extadc",
195 	"controller_master_internal_temp_extadc",
196 	"controller_slave_vptat",
197 	"controller_slave_internal_temp",
198 	"controller_slave_vptat_extadc",
199 	"controller_slave_internal_temp_extadc",
200 	"sodimm_vout",
201 	"sodimm_0_temp",
202 	"sodimm_1_temp",
203 	"phy0_vcc",
204 	"phy1_vcc",
205 	"controller_tdiode_temp",
206 	"board_front_temp",
207 	"board_back_temp",
208 	"in_i1v8",
209 	"in_i2v5",
210 	"in_i3v3",
211 	"in_i12v0",
212 	"in_1v3",
213 	"in_i1v3",
214 };
215 
216 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
217 
218 					const char *
219 efx_mon_stat_name(
220 	__in				efx_nic_t *enp,
221 	__in				efx_mon_stat_t id)
222 {
223 	_NOTE(ARGUNUSED(enp))
224 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
225 
226 	EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
227 	return (__mon_stat_name[id]);
228 }
229 
230 typedef struct _stat_description_t {
231 	efx_mon_stat_t	stat;
232 	const char	*desc;
233 } stat_description_t;
234 
235 /* START MKCONFIG GENERATED MonitorStatDescriptionsBlock f072138f16d2e1f8 */
236 static const char *__mon_stat_description[] = {
237 	MC_CMD_SENSOR_CONTROLLER_TEMP_ENUM_STR,
238 	MC_CMD_SENSOR_PHY_COMMON_TEMP_ENUM_STR,
239 	MC_CMD_SENSOR_CONTROLLER_COOLING_ENUM_STR,
240 	MC_CMD_SENSOR_PHY0_TEMP_ENUM_STR,
241 	MC_CMD_SENSOR_PHY0_COOLING_ENUM_STR,
242 	MC_CMD_SENSOR_PHY1_TEMP_ENUM_STR,
243 	MC_CMD_SENSOR_PHY1_COOLING_ENUM_STR,
244 	MC_CMD_SENSOR_IN_1V0_ENUM_STR,
245 	MC_CMD_SENSOR_IN_1V2_ENUM_STR,
246 	MC_CMD_SENSOR_IN_1V8_ENUM_STR,
247 	MC_CMD_SENSOR_IN_2V5_ENUM_STR,
248 	MC_CMD_SENSOR_IN_3V3_ENUM_STR,
249 	MC_CMD_SENSOR_IN_12V0_ENUM_STR,
250 	MC_CMD_SENSOR_IN_1V2A_ENUM_STR,
251 	MC_CMD_SENSOR_IN_VREF_ENUM_STR,
252 	MC_CMD_SENSOR_OUT_VAOE_ENUM_STR,
253 	MC_CMD_SENSOR_AOE_TEMP_ENUM_STR,
254 	MC_CMD_SENSOR_PSU_AOE_TEMP_ENUM_STR,
255 	MC_CMD_SENSOR_PSU_TEMP_ENUM_STR,
256 	MC_CMD_SENSOR_FAN_0_ENUM_STR,
257 	MC_CMD_SENSOR_FAN_1_ENUM_STR,
258 	MC_CMD_SENSOR_FAN_2_ENUM_STR,
259 	MC_CMD_SENSOR_FAN_3_ENUM_STR,
260 	MC_CMD_SENSOR_FAN_4_ENUM_STR,
261 	MC_CMD_SENSOR_IN_VAOE_ENUM_STR,
262 	MC_CMD_SENSOR_OUT_IAOE_ENUM_STR,
263 	MC_CMD_SENSOR_IN_IAOE_ENUM_STR,
264 	MC_CMD_SENSOR_NIC_POWER_ENUM_STR,
265 	MC_CMD_SENSOR_IN_0V9_ENUM_STR,
266 	MC_CMD_SENSOR_IN_I0V9_ENUM_STR,
267 	MC_CMD_SENSOR_IN_I1V2_ENUM_STR,
268 	MC_CMD_SENSOR_IN_0V9_ADC_ENUM_STR,
269 	MC_CMD_SENSOR_CONTROLLER_2_TEMP_ENUM_STR,
270 	MC_CMD_SENSOR_VREG_INTERNAL_TEMP_ENUM_STR,
271 	MC_CMD_SENSOR_VREG_0V9_TEMP_ENUM_STR,
272 	MC_CMD_SENSOR_VREG_1V2_TEMP_ENUM_STR,
273 	MC_CMD_SENSOR_CONTROLLER_VPTAT_ENUM_STR,
274 	MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP_ENUM_STR,
275 	MC_CMD_SENSOR_CONTROLLER_VPTAT_EXTADC_ENUM_STR,
276 	MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP_EXTADC_ENUM_STR,
277 	MC_CMD_SENSOR_AMBIENT_TEMP_ENUM_STR,
278 	MC_CMD_SENSOR_AIRFLOW_ENUM_STR,
279 	MC_CMD_SENSOR_VDD08D_VSS08D_CSR_ENUM_STR,
280 	MC_CMD_SENSOR_VDD08D_VSS08D_CSR_EXTADC_ENUM_STR,
281 	MC_CMD_SENSOR_HOTPOINT_TEMP_ENUM_STR,
282 	MC_CMD_SENSOR_PHY_POWER_PORT0_ENUM_STR,
283 	MC_CMD_SENSOR_PHY_POWER_PORT1_ENUM_STR,
284 	MC_CMD_SENSOR_MUM_VCC_ENUM_STR,
285 	MC_CMD_SENSOR_IN_0V9_A_ENUM_STR,
286 	MC_CMD_SENSOR_IN_I0V9_A_ENUM_STR,
287 	MC_CMD_SENSOR_VREG_0V9_A_TEMP_ENUM_STR,
288 	MC_CMD_SENSOR_IN_0V9_B_ENUM_STR,
289 	MC_CMD_SENSOR_IN_I0V9_B_ENUM_STR,
290 	MC_CMD_SENSOR_VREG_0V9_B_TEMP_ENUM_STR,
291 	MC_CMD_SENSOR_CCOM_AVREG_1V2_SUPPLY_ENUM_STR,
292 	MC_CMD_SENSOR_CCOM_AVREG_1V2_SUPPLY_EXTADC_ENUM_STR,
293 	MC_CMD_SENSOR_CCOM_AVREG_1V8_SUPPLY_ENUM_STR,
294 	MC_CMD_SENSOR_CCOM_AVREG_1V8_SUPPLY_EXTADC_ENUM_STR,
295 	MC_CMD_SENSOR_CONTROLLER_MASTER_VPTAT_ENUM_STR,
296 	MC_CMD_SENSOR_CONTROLLER_MASTER_INTERNAL_TEMP_ENUM_STR,
297 	MC_CMD_SENSOR_CONTROLLER_MASTER_VPTAT_EXTADC_ENUM_STR,
298 	MC_CMD_SENSOR_CONTROLLER_MASTER_INTERNAL_TEMP_EXTADC_ENUM_STR,
299 	MC_CMD_SENSOR_CONTROLLER_SLAVE_VPTAT_ENUM_STR,
300 	MC_CMD_SENSOR_CONTROLLER_SLAVE_INTERNAL_TEMP_ENUM_STR,
301 	MC_CMD_SENSOR_CONTROLLER_SLAVE_VPTAT_EXTADC_ENUM_STR,
302 	MC_CMD_SENSOR_CONTROLLER_SLAVE_INTERNAL_TEMP_EXTADC_ENUM_STR,
303 	MC_CMD_SENSOR_SODIMM_VOUT_ENUM_STR,
304 	MC_CMD_SENSOR_SODIMM_0_TEMP_ENUM_STR,
305 	MC_CMD_SENSOR_SODIMM_1_TEMP_ENUM_STR,
306 	MC_CMD_SENSOR_PHY0_VCC_ENUM_STR,
307 	MC_CMD_SENSOR_PHY1_VCC_ENUM_STR,
308 	MC_CMD_SENSOR_CONTROLLER_TDIODE_TEMP_ENUM_STR,
309 	MC_CMD_SENSOR_BOARD_FRONT_TEMP_ENUM_STR,
310 	MC_CMD_SENSOR_BOARD_BACK_TEMP_ENUM_STR,
311 	MC_CMD_SENSOR_IN_I1V8_ENUM_STR,
312 	MC_CMD_SENSOR_IN_I2V5_ENUM_STR,
313 	MC_CMD_SENSOR_IN_I3V3_ENUM_STR,
314 	MC_CMD_SENSOR_IN_I12V0_ENUM_STR,
315 	MC_CMD_SENSOR_IN_1V3_ENUM_STR,
316 	MC_CMD_SENSOR_IN_I1V3_ENUM_STR,
317 };
318 
319 /* END MKCONFIG GENERATED MonitorStatDescriptionsBlock */
320 
321 					const char *
322 efx_mon_stat_description(
323 	__in				efx_nic_t *enp,
324 	__in				efx_mon_stat_t id)
325 {
326 	_NOTE(ARGUNUSED(enp))
327 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
328 
329 	EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
330 	return (__mon_stat_description[id]);
331 }
332 
333 #endif	/* EFSYS_OPT_NAMES */
334 
335 /* START MKCONFIG GENERATED MonitorMcdiMappingBlock 173eee0a5599996a */
336 	__checkReturn			boolean_t
337 efx_mon_mcdi_to_efx_stat(
338 	__in				int mcdi_index,
339 	__out				efx_mon_stat_t *statp)
340 {
341 
342 	if ((mcdi_index % (MC_CMD_SENSOR_PAGE0_NEXT + 1)) ==
343 	    MC_CMD_SENSOR_PAGE0_NEXT) {
344 		*statp = EFX_MON_NSTATS;
345 		return (B_FALSE);
346 	}
347 
348 	switch (mcdi_index) {
349 	case MC_CMD_SENSOR_IN_I0V9:
350 		*statp = EFX_MON_STAT_IN_I0V9;
351 		break;
352 	case MC_CMD_SENSOR_CONTROLLER_SLAVE_VPTAT_EXTADC:
353 		*statp = EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXTADC;
354 		break;
355 	case MC_CMD_SENSOR_CONTROLLER_SLAVE_VPTAT:
356 		*statp = EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT;
357 		break;
358 	case MC_CMD_SENSOR_PSU_TEMP:
359 		*statp = EFX_MON_STAT_PSU_TEMP;
360 		break;
361 	case MC_CMD_SENSOR_FAN_2:
362 		*statp = EFX_MON_STAT_FAN_2;
363 		break;
364 	case MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP_EXTADC:
365 		*statp = EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP_EXTADC;
366 		break;
367 	case MC_CMD_SENSOR_BOARD_BACK_TEMP:
368 		*statp = EFX_MON_STAT_BOARD_BACK_TEMP;
369 		break;
370 	case MC_CMD_SENSOR_IN_1V3:
371 		*statp = EFX_MON_STAT_IN_1V3;
372 		break;
373 	case MC_CMD_SENSOR_CONTROLLER_TDIODE_TEMP:
374 		*statp = EFX_MON_STAT_CONTROLLER_TDIODE_TEMP;
375 		break;
376 	case MC_CMD_SENSOR_IN_2V5:
377 		*statp = EFX_MON_STAT_IN_2V5;
378 		break;
379 	case MC_CMD_SENSOR_PHY_COMMON_TEMP:
380 		*statp = EFX_MON_STAT_PHY_COMMON_TEMP;
381 		break;
382 	case MC_CMD_SENSOR_PHY1_TEMP:
383 		*statp = EFX_MON_STAT_PHY1_TEMP;
384 		break;
385 	case MC_CMD_SENSOR_VREG_INTERNAL_TEMP:
386 		*statp = EFX_MON_STAT_VREG_INTERNAL_TEMP;
387 		break;
388 	case MC_CMD_SENSOR_IN_1V0:
389 		*statp = EFX_MON_STAT_IN_1V0;
390 		break;
391 	case MC_CMD_SENSOR_FAN_1:
392 		*statp = EFX_MON_STAT_FAN_1;
393 		break;
394 	case MC_CMD_SENSOR_IN_1V2:
395 		*statp = EFX_MON_STAT_IN_1V2;
396 		break;
397 	case MC_CMD_SENSOR_FAN_3:
398 		*statp = EFX_MON_STAT_FAN_3;
399 		break;
400 	case MC_CMD_SENSOR_IN_1V2A:
401 		*statp = EFX_MON_STAT_IN_1V2A;
402 		break;
403 	case MC_CMD_SENSOR_SODIMM_0_TEMP:
404 		*statp = EFX_MON_STAT_SODIMM_0_TEMP;
405 		break;
406 	case MC_CMD_SENSOR_IN_1V8:
407 		*statp = EFX_MON_STAT_IN_1V8;
408 		break;
409 	case MC_CMD_SENSOR_IN_VREF:
410 		*statp = EFX_MON_STAT_IN_VREF;
411 		break;
412 	case MC_CMD_SENSOR_SODIMM_VOUT:
413 		*statp = EFX_MON_STAT_SODIMM_VOUT;
414 		break;
415 	case MC_CMD_SENSOR_CCOM_AVREG_1V2_SUPPLY:
416 		*statp = EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY;
417 		break;
418 	case MC_CMD_SENSOR_IN_I1V2:
419 		*statp = EFX_MON_STAT_IN_I1V2;
420 		break;
421 	case MC_CMD_SENSOR_IN_I1V3:
422 		*statp = EFX_MON_STAT_IN_I1V3;
423 		break;
424 	case MC_CMD_SENSOR_AIRFLOW:
425 		*statp = EFX_MON_STAT_AIRFLOW;
426 		break;
427 	case MC_CMD_SENSOR_HOTPOINT_TEMP:
428 		*statp = EFX_MON_STAT_HOTPOINT_TEMP;
429 		break;
430 	case MC_CMD_SENSOR_VDD08D_VSS08D_CSR:
431 		*statp = EFX_MON_STAT_VDD08D_VSS08D_CSR;
432 		break;
433 	case MC_CMD_SENSOR_AOE_TEMP:
434 		*statp = EFX_MON_STAT_AOE_TEMP;
435 		break;
436 	case MC_CMD_SENSOR_IN_I1V8:
437 		*statp = EFX_MON_STAT_IN_I1V8;
438 		break;
439 	case MC_CMD_SENSOR_IN_I2V5:
440 		*statp = EFX_MON_STAT_IN_I2V5;
441 		break;
442 	case MC_CMD_SENSOR_PHY1_COOLING:
443 		*statp = EFX_MON_STAT_PHY1_COOLING;
444 		break;
445 	case MC_CMD_SENSOR_CCOM_AVREG_1V8_SUPPLY_EXTADC:
446 		*statp = EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXTADC;
447 		break;
448 	case MC_CMD_SENSOR_IN_0V9_ADC:
449 		*statp = EFX_MON_STAT_IN_0V9_ADC;
450 		break;
451 	case MC_CMD_SENSOR_VREG_0V9_A_TEMP:
452 		*statp = EFX_MON_STAT_VREG_0V9_A_TEMP;
453 		break;
454 	case MC_CMD_SENSOR_CONTROLLER_MASTER_VPTAT:
455 		*statp = EFX_MON_STAT_CONTROLLER_MASTER_VPTAT;
456 		break;
457 	case MC_CMD_SENSOR_PHY0_VCC:
458 		*statp = EFX_MON_STAT_PHY0_VCC;
459 		break;
460 	case MC_CMD_SENSOR_PHY0_COOLING:
461 		*statp = EFX_MON_STAT_PHY0_COOLING;
462 		break;
463 	case MC_CMD_SENSOR_PSU_AOE_TEMP:
464 		*statp = EFX_MON_STAT_PSU_AOE_TEMP;
465 		break;
466 	case MC_CMD_SENSOR_VREG_0V9_TEMP:
467 		*statp = EFX_MON_STAT_VREG_0V9_TEMP;
468 		break;
469 	case MC_CMD_SENSOR_IN_I0V9_A:
470 		*statp = EFX_MON_STAT_IN_I0V9_A;
471 		break;
472 	case MC_CMD_SENSOR_IN_I3V3:
473 		*statp = EFX_MON_STAT_IN_I3V3;
474 		break;
475 	case MC_CMD_SENSOR_BOARD_FRONT_TEMP:
476 		*statp = EFX_MON_STAT_BOARD_FRONT_TEMP;
477 		break;
478 	case MC_CMD_SENSOR_OUT_VAOE:
479 		*statp = EFX_MON_STAT_OUT_VAOE;
480 		break;
481 	case MC_CMD_SENSOR_VDD08D_VSS08D_CSR_EXTADC:
482 		*statp = EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC;
483 		break;
484 	case MC_CMD_SENSOR_IN_I12V0:
485 		*statp = EFX_MON_STAT_IN_I12V0;
486 		break;
487 	case MC_CMD_SENSOR_PHY_POWER_PORT1:
488 		*statp = EFX_MON_STAT_PHY_POWER_PORT1;
489 		break;
490 	case MC_CMD_SENSOR_PHY_POWER_PORT0:
491 		*statp = EFX_MON_STAT_PHY_POWER_PORT0;
492 		break;
493 	case MC_CMD_SENSOR_CONTROLLER_SLAVE_INTERNAL_TEMP_EXTADC:
494 		*statp = EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXTADC;
495 		break;
496 	case MC_CMD_SENSOR_CONTROLLER_MASTER_INTERNAL_TEMP:
497 		*statp = EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP;
498 		break;
499 	case MC_CMD_SENSOR_CONTROLLER_TEMP:
500 		*statp = EFX_MON_STAT_CONTROLLER_TEMP;
501 		break;
502 	case MC_CMD_SENSOR_IN_IAOE:
503 		*statp = EFX_MON_STAT_IN_IAOE;
504 		break;
505 	case MC_CMD_SENSOR_IN_VAOE:
506 		*statp = EFX_MON_STAT_IN_VAOE;
507 		break;
508 	case MC_CMD_SENSOR_CONTROLLER_MASTER_VPTAT_EXTADC:
509 		*statp = EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXTADC;
510 		break;
511 	case MC_CMD_SENSOR_CCOM_AVREG_1V8_SUPPLY:
512 		*statp = EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY;
513 		break;
514 	case MC_CMD_SENSOR_PHY1_VCC:
515 		*statp = EFX_MON_STAT_PHY1_VCC;
516 		break;
517 	case MC_CMD_SENSOR_CONTROLLER_COOLING:
518 		*statp = EFX_MON_STAT_CONTROLLER_COOLING;
519 		break;
520 	case MC_CMD_SENSOR_AMBIENT_TEMP:
521 		*statp = EFX_MON_STAT_AMBIENT_TEMP;
522 		break;
523 	case MC_CMD_SENSOR_IN_3V3:
524 		*statp = EFX_MON_STAT_IN_3V3;
525 		break;
526 	case MC_CMD_SENSOR_PHY0_TEMP:
527 		*statp = EFX_MON_STAT_PHY0_TEMP;
528 		break;
529 	case MC_CMD_SENSOR_SODIMM_1_TEMP:
530 		*statp = EFX_MON_STAT_SODIMM_1_TEMP;
531 		break;
532 	case MC_CMD_SENSOR_MUM_VCC:
533 		*statp = EFX_MON_STAT_MUM_VCC;
534 		break;
535 	case MC_CMD_SENSOR_VREG_0V9_B_TEMP:
536 		*statp = EFX_MON_STAT_VREG_0V9_B_TEMP;
537 		break;
538 	case MC_CMD_SENSOR_CONTROLLER_SLAVE_INTERNAL_TEMP:
539 		*statp = EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP;
540 		break;
541 	case MC_CMD_SENSOR_FAN_4:
542 		*statp = EFX_MON_STAT_FAN_4;
543 		break;
544 	case MC_CMD_SENSOR_CONTROLLER_2_TEMP:
545 		*statp = EFX_MON_STAT_CONTROLLER_2_TEMP;
546 		break;
547 	case MC_CMD_SENSOR_CCOM_AVREG_1V2_SUPPLY_EXTADC:
548 		*statp = EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXTADC;
549 		break;
550 	case MC_CMD_SENSOR_IN_0V9_A:
551 		*statp = EFX_MON_STAT_IN_0V9_A;
552 		break;
553 	case MC_CMD_SENSOR_CONTROLLER_VPTAT_EXTADC:
554 		*statp = EFX_MON_STAT_CONTROLLER_VPTAT_EXTADC;
555 		break;
556 	case MC_CMD_SENSOR_IN_0V9:
557 		*statp = EFX_MON_STAT_IN_0V9;
558 		break;
559 	case MC_CMD_SENSOR_IN_I0V9_B:
560 		*statp = EFX_MON_STAT_IN_I0V9_B;
561 		break;
562 	case MC_CMD_SENSOR_NIC_POWER:
563 		*statp = EFX_MON_STAT_NIC_POWER;
564 		break;
565 	case MC_CMD_SENSOR_IN_12V0:
566 		*statp = EFX_MON_STAT_IN_12V0;
567 		break;
568 	case MC_CMD_SENSOR_OUT_IAOE:
569 		*statp = EFX_MON_STAT_OUT_IAOE;
570 		break;
571 	case MC_CMD_SENSOR_CONTROLLER_VPTAT:
572 		*statp = EFX_MON_STAT_CONTROLLER_VPTAT;
573 		break;
574 	case MC_CMD_SENSOR_CONTROLLER_MASTER_INTERNAL_TEMP_EXTADC:
575 		*statp = EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXTADC;
576 		break;
577 	case MC_CMD_SENSOR_CONTROLLER_INTERNAL_TEMP:
578 		*statp = EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP;
579 		break;
580 	case MC_CMD_SENSOR_FAN_0:
581 		*statp = EFX_MON_STAT_FAN_0;
582 		break;
583 	case MC_CMD_SENSOR_VREG_1V2_TEMP:
584 		*statp = EFX_MON_STAT_VREG_1V2_TEMP;
585 		break;
586 	case MC_CMD_SENSOR_IN_0V9_B:
587 		*statp = EFX_MON_STAT_IN_0V9_B;
588 		break;
589 	default:
590 		*statp = EFX_MON_NSTATS;
591 		break;
592 	};
593 
594 	if (*statp == EFX_MON_NSTATS)
595 		goto fail1;
596 
597 	return (B_TRUE);
598 
599 fail1:
600 	EFSYS_PROBE1(fail1, boolean_t, B_TRUE);
601 	return (B_FALSE);
602 };
603 
604 /* END MKCONFIG GENERATED MonitorMcdiMappingBlock */
605 
606 /* START MKCONFIG GENERATED MonitorStatisticUnitsBlock 2d447c656cc2d01d */
607 	__checkReturn			boolean_t
608 efx_mon_get_stat_unit(
609 	__in				efx_mon_stat_t stat,
610 	__out				efx_mon_stat_unit_t *unitp)
611 {
612 	switch (stat) {
613 	case EFX_MON_STAT_IN_1V0:
614 	case EFX_MON_STAT_IN_1V2:
615 	case EFX_MON_STAT_IN_1V8:
616 	case EFX_MON_STAT_IN_2V5:
617 	case EFX_MON_STAT_IN_3V3:
618 	case EFX_MON_STAT_IN_12V0:
619 	case EFX_MON_STAT_IN_1V2A:
620 	case EFX_MON_STAT_IN_VREF:
621 	case EFX_MON_STAT_OUT_VAOE:
622 	case EFX_MON_STAT_IN_VAOE:
623 	case EFX_MON_STAT_IN_0V9:
624 	case EFX_MON_STAT_IN_0V9_ADC:
625 	case EFX_MON_STAT_CONTROLLER_VPTAT_EXTADC:
626 	case EFX_MON_STAT_VDD08D_VSS08D_CSR:
627 	case EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC:
628 	case EFX_MON_STAT_MUM_VCC:
629 	case EFX_MON_STAT_IN_0V9_A:
630 	case EFX_MON_STAT_IN_0V9_B:
631 	case EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY:
632 	case EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXTADC:
633 	case EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY:
634 	case EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXTADC:
635 	case EFX_MON_STAT_CONTROLLER_MASTER_VPTAT:
636 	case EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXTADC:
637 	case EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT:
638 	case EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXTADC:
639 	case EFX_MON_STAT_SODIMM_VOUT:
640 	case EFX_MON_STAT_PHY0_VCC:
641 	case EFX_MON_STAT_PHY1_VCC:
642 	case EFX_MON_STAT_IN_1V3:
643 		*unitp = EFX_MON_STAT_UNIT_VOLTAGE_MV;
644 		break;
645 	case EFX_MON_STAT_CONTROLLER_TEMP:
646 	case EFX_MON_STAT_PHY_COMMON_TEMP:
647 	case EFX_MON_STAT_PHY0_TEMP:
648 	case EFX_MON_STAT_PHY1_TEMP:
649 	case EFX_MON_STAT_AOE_TEMP:
650 	case EFX_MON_STAT_PSU_AOE_TEMP:
651 	case EFX_MON_STAT_PSU_TEMP:
652 	case EFX_MON_STAT_CONTROLLER_2_TEMP:
653 	case EFX_MON_STAT_VREG_INTERNAL_TEMP:
654 	case EFX_MON_STAT_VREG_0V9_TEMP:
655 	case EFX_MON_STAT_VREG_1V2_TEMP:
656 	case EFX_MON_STAT_CONTROLLER_VPTAT:
657 	case EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP:
658 	case EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP_EXTADC:
659 	case EFX_MON_STAT_AMBIENT_TEMP:
660 	case EFX_MON_STAT_HOTPOINT_TEMP:
661 	case EFX_MON_STAT_VREG_0V9_A_TEMP:
662 	case EFX_MON_STAT_VREG_0V9_B_TEMP:
663 	case EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP:
664 	case EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXTADC:
665 	case EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP:
666 	case EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXTADC:
667 	case EFX_MON_STAT_SODIMM_0_TEMP:
668 	case EFX_MON_STAT_SODIMM_1_TEMP:
669 	case EFX_MON_STAT_CONTROLLER_TDIODE_TEMP:
670 	case EFX_MON_STAT_BOARD_FRONT_TEMP:
671 	case EFX_MON_STAT_BOARD_BACK_TEMP:
672 		*unitp = EFX_MON_STAT_UNIT_TEMP_C;
673 		break;
674 	case EFX_MON_STAT_CONTROLLER_COOLING:
675 	case EFX_MON_STAT_PHY0_COOLING:
676 	case EFX_MON_STAT_PHY1_COOLING:
677 	case EFX_MON_STAT_AIRFLOW:
678 	case EFX_MON_STAT_PHY_POWER_PORT0:
679 	case EFX_MON_STAT_PHY_POWER_PORT1:
680 		*unitp = EFX_MON_STAT_UNIT_BOOL;
681 		break;
682 	case EFX_MON_STAT_NIC_POWER:
683 		*unitp = EFX_MON_STAT_UNIT_POWER_W;
684 		break;
685 	case EFX_MON_STAT_OUT_IAOE:
686 	case EFX_MON_STAT_IN_IAOE:
687 	case EFX_MON_STAT_IN_I0V9:
688 	case EFX_MON_STAT_IN_I1V2:
689 	case EFX_MON_STAT_IN_I0V9_A:
690 	case EFX_MON_STAT_IN_I0V9_B:
691 	case EFX_MON_STAT_IN_I1V8:
692 	case EFX_MON_STAT_IN_I2V5:
693 	case EFX_MON_STAT_IN_I3V3:
694 	case EFX_MON_STAT_IN_I12V0:
695 	case EFX_MON_STAT_IN_I1V3:
696 		*unitp = EFX_MON_STAT_UNIT_CURRENT_MA;
697 		break;
698 	case EFX_MON_STAT_FAN_0:
699 	case EFX_MON_STAT_FAN_1:
700 	case EFX_MON_STAT_FAN_2:
701 	case EFX_MON_STAT_FAN_3:
702 	case EFX_MON_STAT_FAN_4:
703 		*unitp = EFX_MON_STAT_UNIT_RPM;
704 		break;
705 	default:
706 		*unitp = EFX_MON_STAT_UNIT_UNKNOWN;
707 		break;
708 	};
709 
710 	if (*unitp == EFX_MON_STAT_UNIT_UNKNOWN)
711 		goto fail1;
712 
713 	return (B_TRUE);
714 
715 fail1:
716 	EFSYS_PROBE1(fail1, boolean_t, B_TRUE);
717 	return (B_FALSE);
718 };
719 
720 /* END MKCONFIG GENERATED MonitorStatisticUnitsBlock */
721 
722 /* START MKCONFIG GENERATED MonitorStatisticPortsBlock 1719b751d842534f */
723 	__checkReturn			boolean_t
724 efx_mon_get_stat_portmap(
725 	__in				efx_mon_stat_t stat,
726 	__out				efx_mon_stat_portmask_t *maskp)
727 {
728 
729 	switch (stat) {
730 	case EFX_MON_STAT_PHY1_TEMP:
731 	case EFX_MON_STAT_PHY1_COOLING:
732 	case EFX_MON_STAT_PHY_POWER_PORT1:
733 		*maskp = EFX_MON_STAT_PORTMAP_PORT1;
734 		break;
735 	case EFX_MON_STAT_CONTROLLER_TEMP:
736 	case EFX_MON_STAT_PHY_COMMON_TEMP:
737 	case EFX_MON_STAT_CONTROLLER_COOLING:
738 	case EFX_MON_STAT_IN_1V0:
739 	case EFX_MON_STAT_IN_1V2:
740 	case EFX_MON_STAT_IN_1V8:
741 	case EFX_MON_STAT_IN_2V5:
742 	case EFX_MON_STAT_IN_3V3:
743 	case EFX_MON_STAT_IN_12V0:
744 	case EFX_MON_STAT_IN_1V2A:
745 	case EFX_MON_STAT_IN_VREF:
746 	case EFX_MON_STAT_OUT_VAOE:
747 	case EFX_MON_STAT_AOE_TEMP:
748 	case EFX_MON_STAT_PSU_AOE_TEMP:
749 	case EFX_MON_STAT_PSU_TEMP:
750 	case EFX_MON_STAT_FAN_0:
751 	case EFX_MON_STAT_FAN_1:
752 	case EFX_MON_STAT_FAN_2:
753 	case EFX_MON_STAT_FAN_3:
754 	case EFX_MON_STAT_FAN_4:
755 	case EFX_MON_STAT_IN_VAOE:
756 	case EFX_MON_STAT_OUT_IAOE:
757 	case EFX_MON_STAT_IN_IAOE:
758 	case EFX_MON_STAT_NIC_POWER:
759 	case EFX_MON_STAT_IN_0V9:
760 	case EFX_MON_STAT_IN_I0V9:
761 	case EFX_MON_STAT_IN_I1V2:
762 	case EFX_MON_STAT_IN_0V9_ADC:
763 	case EFX_MON_STAT_CONTROLLER_2_TEMP:
764 	case EFX_MON_STAT_VREG_INTERNAL_TEMP:
765 	case EFX_MON_STAT_VREG_0V9_TEMP:
766 	case EFX_MON_STAT_VREG_1V2_TEMP:
767 	case EFX_MON_STAT_CONTROLLER_VPTAT:
768 	case EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP:
769 	case EFX_MON_STAT_CONTROLLER_VPTAT_EXTADC:
770 	case EFX_MON_STAT_CONTROLLER_INTERNAL_TEMP_EXTADC:
771 	case EFX_MON_STAT_AMBIENT_TEMP:
772 	case EFX_MON_STAT_AIRFLOW:
773 	case EFX_MON_STAT_VDD08D_VSS08D_CSR:
774 	case EFX_MON_STAT_VDD08D_VSS08D_CSR_EXTADC:
775 	case EFX_MON_STAT_HOTPOINT_TEMP:
776 	case EFX_MON_STAT_MUM_VCC:
777 	case EFX_MON_STAT_IN_0V9_A:
778 	case EFX_MON_STAT_IN_I0V9_A:
779 	case EFX_MON_STAT_VREG_0V9_A_TEMP:
780 	case EFX_MON_STAT_IN_0V9_B:
781 	case EFX_MON_STAT_IN_I0V9_B:
782 	case EFX_MON_STAT_VREG_0V9_B_TEMP:
783 	case EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY:
784 	case EFX_MON_STAT_CCOM_AVREG_1V2_SUPPLY_EXTADC:
785 	case EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY:
786 	case EFX_MON_STAT_CCOM_AVREG_1V8_SUPPLY_EXTADC:
787 	case EFX_MON_STAT_CONTROLLER_MASTER_VPTAT:
788 	case EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP:
789 	case EFX_MON_STAT_CONTROLLER_MASTER_VPTAT_EXTADC:
790 	case EFX_MON_STAT_CONTROLLER_MASTER_INTERNAL_TEMP_EXTADC:
791 	case EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT:
792 	case EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP:
793 	case EFX_MON_STAT_CONTROLLER_SLAVE_VPTAT_EXTADC:
794 	case EFX_MON_STAT_CONTROLLER_SLAVE_INTERNAL_TEMP_EXTADC:
795 	case EFX_MON_STAT_SODIMM_VOUT:
796 	case EFX_MON_STAT_SODIMM_0_TEMP:
797 	case EFX_MON_STAT_SODIMM_1_TEMP:
798 	case EFX_MON_STAT_PHY0_VCC:
799 	case EFX_MON_STAT_PHY1_VCC:
800 	case EFX_MON_STAT_CONTROLLER_TDIODE_TEMP:
801 	case EFX_MON_STAT_BOARD_FRONT_TEMP:
802 	case EFX_MON_STAT_BOARD_BACK_TEMP:
803 	case EFX_MON_STAT_IN_I1V8:
804 	case EFX_MON_STAT_IN_I2V5:
805 	case EFX_MON_STAT_IN_I3V3:
806 	case EFX_MON_STAT_IN_I12V0:
807 	case EFX_MON_STAT_IN_1V3:
808 	case EFX_MON_STAT_IN_I1V3:
809 		*maskp = EFX_MON_STAT_PORTMAP_ALL;
810 		break;
811 	case EFX_MON_STAT_PHY0_TEMP:
812 	case EFX_MON_STAT_PHY0_COOLING:
813 	case EFX_MON_STAT_PHY_POWER_PORT0:
814 		*maskp = EFX_MON_STAT_PORTMAP_PORT0;
815 		break;
816 	default:
817 		*maskp = EFX_MON_STAT_PORTMAP_UNKNOWN;
818 		break;
819 	};
820 
821 	if (*maskp == EFX_MON_STAT_PORTMAP_UNKNOWN)
822 		goto fail1;
823 
824 	return (B_TRUE);
825 
826 fail1:
827 	EFSYS_PROBE1(fail1, boolean_t, B_TRUE);
828 	return (B_FALSE);
829 };
830 
831 /* END MKCONFIG GENERATED MonitorStatisticPortsBlock */
832 
833 	__checkReturn			efx_rc_t
834 efx_mon_stats_update(
835 	__in				efx_nic_t *enp,
836 	__in				efsys_mem_t *esmp,
837 	__inout_ecount(EFX_MON_NSTATS)	efx_mon_stat_value_t *values)
838 {
839 	efx_mon_t *emp = &(enp->en_mon);
840 	const efx_mon_ops_t *emop = emp->em_emop;
841 
842 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
843 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
844 
845 	return (emop->emo_stats_update(enp, esmp, values));
846 }
847 
848 	__checkReturn			efx_rc_t
849 efx_mon_limits_update(
850 	__in				efx_nic_t *enp,
851 	__inout_ecount(EFX_MON_NSTATS)	efx_mon_stat_limits_t *values)
852 {
853 	efx_mon_t *emp = &(enp->en_mon);
854 	const efx_mon_ops_t *emop = emp->em_emop;
855 
856 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
857 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
858 
859 	return (emop->emo_limits_update(enp, values));
860 }
861 
862 #endif	/* EFSYS_OPT_MON_STATS */
863 
864 		void
865 efx_mon_fini(
866 	__in	efx_nic_t *enp)
867 {
868 	efx_mon_t *emp = &(enp->en_mon);
869 
870 	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
871 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
872 	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
873 
874 	emp->em_emop = NULL;
875 
876 	emp->em_type = EFX_MON_INVALID;
877 
878 	enp->en_mod_flags &= ~EFX_MOD_MON;
879 }
880