2 * Copyright 2007-2009 Solarflare Communications Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
31 #include "efx_types.h"
35 #if EFSYS_OPT_MON_NULL
39 #if EFSYS_OPT_MON_LM87
43 #if EFSYS_OPT_MON_MAX6647
49 static const char __cs * __cs __efx_mon_name[] = {
61 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
63 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
65 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
66 EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES);
67 return (__efx_mon_name[encp->enc_mon_type]);
70 #endif /* EFSYS_OPT_NAMES */
72 #if EFSYS_OPT_MON_NULL
73 static efx_mon_ops_t __cs __efx_mon_null_ops = {
74 nullmon_reset, /* emo_reset */
75 nullmon_reconfigure, /* emo_reconfigure */
76 #if EFSYS_OPT_MON_STATS
77 nullmon_stats_update /* emo_stat_update */
78 #endif /* EFSYS_OPT_MON_STATS */
82 #if EFSYS_OPT_MON_LM87
83 static efx_mon_ops_t __cs __efx_mon_lm87_ops = {
84 lm87_reset, /* emo_reset */
85 lm87_reconfigure, /* emo_reconfigure */
86 #if EFSYS_OPT_MON_STATS
87 lm87_stats_update /* emo_stat_update */
88 #endif /* EFSYS_OPT_MON_STATS */
92 #if EFSYS_OPT_MON_MAX6647
93 static efx_mon_ops_t __cs __efx_mon_max6647_ops = {
94 max6647_reset, /* emo_reset */
95 max6647_reconfigure, /* emo_reconfigure */
96 #if EFSYS_OPT_MON_STATS
97 max6647_stats_update /* emo_stat_update */
98 #endif /* EFSYS_OPT_MON_STATS */
102 #if EFSYS_OPT_MON_SIENA
103 static efx_mon_ops_t __cs __efx_mon_siena_ops = {
104 siena_mon_reset, /* emo_reset */
105 siena_mon_reconfigure, /* emo_reconfigure */
106 #if EFSYS_OPT_MON_STATS
107 siena_mon_stats_update /* emo_stat_update */
108 #endif /* EFSYS_OPT_MON_STATS */
113 static efx_mon_ops_t __cs * __cs __efx_mon_ops[] = {
115 #if EFSYS_OPT_MON_NULL
120 #if EFSYS_OPT_MON_LM87
125 #if EFSYS_OPT_MON_MAX6647
126 &__efx_mon_max6647_ops,
130 #if EFSYS_OPT_MON_SIENA
141 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
142 efx_mon_t *emp = &(enp->en_mon);
146 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
147 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
149 if (enp->en_mod_flags & EFX_MOD_MON) {
154 enp->en_mod_flags |= EFX_MOD_MON;
156 emp->em_type = encp->enc_mon_type;
158 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
159 EFSYS_ASSERT3U(emp->em_type, <, EFX_MON_NTYPES);
160 if ((emop = (efx_mon_ops_t *)__efx_mon_ops[emp->em_type]) == NULL) {
165 if ((rc = emop->emo_reset(enp)) != 0)
168 if ((rc = emop->emo_reconfigure(enp)) != 0)
177 (void) emop->emo_reset(enp);
184 emp->em_type = EFX_MON_INVALID;
186 enp->en_mod_flags &= ~EFX_MOD_MON;
189 EFSYS_PROBE1(fail1, int, rc);
194 #if EFSYS_OPT_MON_STATS
198 /* START MKCONFIG GENERATED MonitorStatNamesBlock 08518fd1fb4e2612 */
199 static const char __cs * __cs __mon_stat_name[] = {
210 "controller_cooling",
218 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
220 extern const char __cs *
223 __in efx_mon_stat_t id)
225 _NOTE(ARGUNUSED(enp))
226 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
228 EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
229 return (__mon_stat_name[id]);
232 #endif /* EFSYS_OPT_NAMES */
235 efx_mon_stats_update(
237 __in efsys_mem_t *esmp,
238 __out_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values)
240 efx_mon_t *emp = &(enp->en_mon);
241 efx_mon_ops_t *emop = emp->em_emop;
243 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
244 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
246 return (emop->emo_stats_update(enp, esmp, values));
249 #endif /* EFSYS_OPT_MON_STATS */
255 efx_mon_t *emp = &(enp->en_mon);
256 efx_mon_ops_t *emop = emp->em_emop;
259 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
260 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
261 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
265 rc = emop->emo_reset(enp);
267 EFSYS_PROBE1(fail1, int, rc);
269 emp->em_type = EFX_MON_INVALID;
271 enp->en_mod_flags &= ~EFX_MOD_MON;