2 * Copyright (c) 2007-2016 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$");
37 #if EFSYS_OPT_MON_MCDI
43 static const char * const __efx_mon_name[] = {
54 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
56 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
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]);
63 #endif /* EFSYS_OPT_NAMES */
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 #endif /* EFSYS_OPT_MON_STATS */
74 __checkReturn efx_rc_t
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;
83 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
84 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
86 if (enp->en_mod_flags & EFX_MOD_MON) {
91 enp->en_mod_flags |= EFX_MOD_MON;
93 emp->em_type = encp->enc_mon_type;
95 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
96 switch (emp->em_type) {
97 #if EFSYS_OPT_MON_MCDI
100 case EFX_MON_SFC92X0:
101 emop = &__efx_mon_mcdi_ops;
115 emp->em_type = EFX_MON_INVALID;
117 enp->en_mod_flags &= ~EFX_MOD_MON;
120 EFSYS_PROBE1(fail1, efx_rc_t, rc);
125 #if EFSYS_OPT_MON_STATS
129 /* START MKCONFIG GENERATED MonitorStatNamesBlock 5daa2a5725ba734b */
130 static const char * const __mon_stat_name[] = {
141 "controller_cooling",
151 "psu_aoe_temperature",
166 "controller_temperature2",
168 "vreg_0_9v_temperature",
169 "vreg_1_2v_temperature",
171 "controller_internal_adc_temperature",
173 "controller_external_adc_temperature",
174 "ambient_temperature",
177 "vdd08d_vss08d_csr_extadc",
178 "hotpoint_temperature",
179 "phy_power_switch_port0",
180 "phy_power_switch_port1",
188 "ccom_avreg_1v2_supply",
189 "ccom_avreg_1v2_supply_ext_adc",
190 "ccom_avreg_1v8_supply",
191 "ccom_avreg_1v8_supply_ext_adc",
192 "controller_master_vptat",
193 "controller_master_internal_temp",
194 "controller_master_vptat_ext_adc",
195 "controller_master_internal_temp_ext_adc",
196 "controller_slave_vptat",
197 "controller_slave_internal_temp",
198 "controller_slave_vptat_ext_adc",
199 "controller_slave_internal_temp_ext_adc",
205 "controller_tdiode_temp",
210 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
215 __in efx_mon_stat_t id)
217 _NOTE(ARGUNUSED(enp))
218 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
220 EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
221 return (__mon_stat_name[id]);
224 #endif /* EFSYS_OPT_NAMES */
226 __checkReturn efx_rc_t
227 efx_mon_stats_update(
229 __in efsys_mem_t *esmp,
230 __inout_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values)
232 efx_mon_t *emp = &(enp->en_mon);
233 const efx_mon_ops_t *emop = emp->em_emop;
235 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
236 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
238 return (emop->emo_stats_update(enp, esmp, values));
241 #endif /* EFSYS_OPT_MON_STATS */
247 efx_mon_t *emp = &(enp->en_mon);
249 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
250 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
251 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
255 emp->em_type = EFX_MON_INVALID;
257 enp->en_mod_flags &= ~EFX_MOD_MON;