2 * Copyright (c) 2007-2015 Solarflare Communications Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
36 #include "efx_types.h"
40 #if EFSYS_OPT_MON_NULL
44 #if EFSYS_OPT_MON_LM87
48 #if EFSYS_OPT_MON_MAX6647
52 #if EFSYS_OPT_MON_MCDI
58 static const char *__efx_mon_name[] = {
71 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
73 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
75 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
76 EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES);
77 return (__efx_mon_name[encp->enc_mon_type]);
80 #endif /* EFSYS_OPT_NAMES */
82 #if EFSYS_OPT_MON_NULL
83 static efx_mon_ops_t __efx_mon_null_ops = {
84 nullmon_reset, /* emo_reset */
85 nullmon_reconfigure, /* emo_reconfigure */
86 #if EFSYS_OPT_MON_STATS
87 nullmon_stats_update /* emo_stats_update */
88 #endif /* EFSYS_OPT_MON_STATS */
92 #if EFSYS_OPT_MON_LM87
93 static efx_mon_ops_t __efx_mon_lm87_ops = {
94 lm87_reset, /* emo_reset */
95 lm87_reconfigure, /* emo_reconfigure */
96 #if EFSYS_OPT_MON_STATS
97 lm87_stats_update /* emo_stats_update */
98 #endif /* EFSYS_OPT_MON_STATS */
102 #if EFSYS_OPT_MON_MAX6647
103 static efx_mon_ops_t __efx_mon_max6647_ops = {
104 max6647_reset, /* emo_reset */
105 max6647_reconfigure, /* emo_reconfigure */
106 #if EFSYS_OPT_MON_STATS
107 max6647_stats_update /* emo_stats_update */
108 #endif /* EFSYS_OPT_MON_STATS */
112 #if EFSYS_OPT_MON_MCDI
113 static efx_mon_ops_t __efx_mon_mcdi_ops = {
114 NULL, /* emo_reset */
115 NULL, /* emo_reconfigure */
116 #if EFSYS_OPT_MON_STATS
117 mcdi_mon_stats_update /* emo_stats_update */
118 #endif /* EFSYS_OPT_MON_STATS */
122 static efx_mon_ops_t *__efx_mon_ops[] = {
124 #if EFSYS_OPT_MON_NULL
129 #if EFSYS_OPT_MON_LM87
134 #if EFSYS_OPT_MON_MAX6647
135 &__efx_mon_max6647_ops,
139 #if EFSYS_OPT_MON_MCDI
144 #if EFSYS_OPT_MON_MCDI
155 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
156 efx_mon_t *emp = &(enp->en_mon);
160 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
161 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
163 if (enp->en_mod_flags & EFX_MOD_MON) {
168 enp->en_mod_flags |= EFX_MOD_MON;
170 emp->em_type = encp->enc_mon_type;
172 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
173 EFSYS_ASSERT3U(emp->em_type, <, EFX_MON_NTYPES);
174 if ((emop = (efx_mon_ops_t *)__efx_mon_ops[emp->em_type]) == NULL) {
179 if (emop->emo_reset != NULL) {
180 if ((rc = emop->emo_reset(enp)) != 0)
184 if (emop->emo_reconfigure != NULL) {
185 if ((rc = emop->emo_reconfigure(enp)) != 0)
195 if (emop->emo_reset != NULL)
196 (void) emop->emo_reset(enp);
203 emp->em_type = EFX_MON_INVALID;
205 enp->en_mod_flags &= ~EFX_MOD_MON;
208 EFSYS_PROBE1(fail1, int, rc);
213 #if EFSYS_OPT_MON_STATS
217 /* START MKCONFIG GENERATED MonitorStatNamesBlock b9328f15438c4d01 */
218 static const char *__mon_stat_name[] = {
229 "controller_cooling",
239 "psu_aoe_temperature",
254 "controller_temperature2",
256 "vreg_0_9v_temperature",
257 "vreg_1_2v_temperature",
259 "controller_internal_adc_temperature",
261 "controller_external_adc_temperature",
262 "ambient_temperature",
265 "vdd08d_vss08d_csr_extadc",
266 "hotpoint_temperature",
267 "phy_power_switch_port0",
268 "phy_power_switch_port1",
276 "ccom_avreg_1v2_supply",
277 "ccom_avreg_1v2_supply_ext_adc",
278 "ccom_avreg_1v8_supply",
279 "ccom_avreg_1v8_supply_ext_adc",
280 "controller_master_vptat",
281 "controller_master_internal_temp",
282 "controller_master_vptat_ext_adc",
283 "controller_master_internal_temp_ext_adc",
284 "controller_slave_vptat",
285 "controller_slave_internal_temp",
286 "controller_slave_vptat_ext_adc",
287 "controller_slave_internal_temp_ext_adc",
290 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
295 __in efx_mon_stat_t id)
297 _NOTE(ARGUNUSED(enp))
298 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
300 EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
301 return (__mon_stat_name[id]);
304 #endif /* EFSYS_OPT_NAMES */
307 efx_mon_stats_update(
309 __in efsys_mem_t *esmp,
310 __out_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values)
312 efx_mon_t *emp = &(enp->en_mon);
313 efx_mon_ops_t *emop = emp->em_emop;
315 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
316 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
318 return (emop->emo_stats_update(enp, esmp, values));
321 #endif /* EFSYS_OPT_MON_STATS */
327 efx_mon_t *emp = &(enp->en_mon);
328 efx_mon_ops_t *emop = emp->em_emop;
331 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
332 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
333 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
337 if (emop->emo_reset != NULL) {
338 rc = emop->emo_reset(enp);
340 EFSYS_PROBE1(fail1, int, rc);
343 emp->em_type = EFX_MON_INVALID;
345 enp->en_mod_flags &= ~EFX_MOD_MON;