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.
34 #if EFSYS_OPT_MON_MCDI
40 static const char * const __efx_mon_name[] = {
51 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
53 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
55 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
56 EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES);
57 return (__efx_mon_name[encp->enc_mon_type]);
60 #endif /* EFSYS_OPT_NAMES */
62 #if EFSYS_OPT_MON_MCDI
63 static const efx_mon_ops_t __efx_mon_mcdi_ops = {
64 #if EFSYS_OPT_MON_STATS
65 mcdi_mon_stats_update /* emo_stats_update */
66 #endif /* EFSYS_OPT_MON_STATS */
71 __checkReturn efx_rc_t
75 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
76 efx_mon_t *emp = &(enp->en_mon);
77 const efx_mon_ops_t *emop;
80 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
81 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
83 if (enp->en_mod_flags & EFX_MOD_MON) {
88 enp->en_mod_flags |= EFX_MOD_MON;
90 emp->em_type = encp->enc_mon_type;
92 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
93 switch (emp->em_type) {
94 #if EFSYS_OPT_MON_MCDI
98 emop = &__efx_mon_mcdi_ops;
112 emp->em_type = EFX_MON_INVALID;
114 enp->en_mod_flags &= ~EFX_MOD_MON;
117 EFSYS_PROBE1(fail1, efx_rc_t, rc);
122 #if EFSYS_OPT_MON_STATS
126 /* START MKCONFIG GENERATED MonitorStatNamesBlock 5daa2a5725ba734b */
127 static const char * const __mon_stat_name[] = {
138 "controller_cooling",
148 "psu_aoe_temperature",
163 "controller_temperature2",
165 "vreg_0_9v_temperature",
166 "vreg_1_2v_temperature",
168 "controller_internal_adc_temperature",
170 "controller_external_adc_temperature",
171 "ambient_temperature",
174 "vdd08d_vss08d_csr_extadc",
175 "hotpoint_temperature",
176 "phy_power_switch_port0",
177 "phy_power_switch_port1",
185 "ccom_avreg_1v2_supply",
186 "ccom_avreg_1v2_supply_ext_adc",
187 "ccom_avreg_1v8_supply",
188 "ccom_avreg_1v8_supply_ext_adc",
189 "controller_master_vptat",
190 "controller_master_internal_temp",
191 "controller_master_vptat_ext_adc",
192 "controller_master_internal_temp_ext_adc",
193 "controller_slave_vptat",
194 "controller_slave_internal_temp",
195 "controller_slave_vptat_ext_adc",
196 "controller_slave_internal_temp_ext_adc",
202 "controller_tdiode_temp",
207 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
212 __in efx_mon_stat_t id)
214 _NOTE(ARGUNUSED(enp))
215 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
217 EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
218 return (__mon_stat_name[id]);
221 #endif /* EFSYS_OPT_NAMES */
223 __checkReturn efx_rc_t
224 efx_mon_stats_update(
226 __in efsys_mem_t *esmp,
227 __inout_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values)
229 efx_mon_t *emp = &(enp->en_mon);
230 const efx_mon_ops_t *emop = emp->em_emop;
232 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
233 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
235 return (emop->emo_stats_update(enp, esmp, values));
238 #endif /* EFSYS_OPT_MON_STATS */
244 efx_mon_t *emp = &(enp->en_mon);
246 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
247 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
248 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
252 emp->em_type = EFX_MON_INVALID;
254 enp->en_mod_flags &= ~EFX_MOD_MON;