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