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