2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2007-2016 Solarflare Communications Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
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.
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.
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.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
39 #if EFSYS_OPT_MON_MCDI
45 static const char * const __efx_mon_name[] = {
56 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
58 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
60 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
61 EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES);
62 return (__efx_mon_name[encp->enc_mon_type]);
65 #endif /* EFSYS_OPT_NAMES */
67 #if EFSYS_OPT_MON_MCDI
68 static const efx_mon_ops_t __efx_mon_mcdi_ops = {
69 #if EFSYS_OPT_MON_STATS
70 mcdi_mon_stats_update /* emo_stats_update */
71 #endif /* EFSYS_OPT_MON_STATS */
76 __checkReturn efx_rc_t
80 efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
81 efx_mon_t *emp = &(enp->en_mon);
82 const efx_mon_ops_t *emop;
85 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
86 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
88 if (enp->en_mod_flags & EFX_MOD_MON) {
93 enp->en_mod_flags |= EFX_MOD_MON;
95 emp->em_type = encp->enc_mon_type;
97 EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID);
98 switch (emp->em_type) {
99 #if EFSYS_OPT_MON_MCDI
100 case EFX_MON_SFC90X0:
101 case EFX_MON_SFC91X0:
102 case EFX_MON_SFC92X0:
103 emop = &__efx_mon_mcdi_ops;
117 emp->em_type = EFX_MON_INVALID;
119 enp->en_mod_flags &= ~EFX_MOD_MON;
122 EFSYS_PROBE1(fail1, efx_rc_t, rc);
127 #if EFSYS_OPT_MON_STATS
131 /* START MKCONFIG GENERATED MonitorStatNamesBlock 5daa2a5725ba734b */
132 static const char * const __mon_stat_name[] = {
143 "controller_cooling",
153 "psu_aoe_temperature",
168 "controller_temperature2",
170 "vreg_0_9v_temperature",
171 "vreg_1_2v_temperature",
173 "controller_internal_adc_temperature",
175 "controller_external_adc_temperature",
176 "ambient_temperature",
179 "vdd08d_vss08d_csr_extadc",
180 "hotpoint_temperature",
181 "phy_power_switch_port0",
182 "phy_power_switch_port1",
190 "ccom_avreg_1v2_supply",
191 "ccom_avreg_1v2_supply_ext_adc",
192 "ccom_avreg_1v8_supply",
193 "ccom_avreg_1v8_supply_ext_adc",
194 "controller_master_vptat",
195 "controller_master_internal_temp",
196 "controller_master_vptat_ext_adc",
197 "controller_master_internal_temp_ext_adc",
198 "controller_slave_vptat",
199 "controller_slave_internal_temp",
200 "controller_slave_vptat_ext_adc",
201 "controller_slave_internal_temp_ext_adc",
207 "controller_tdiode_temp",
212 /* END MKCONFIG GENERATED MonitorStatNamesBlock */
217 __in efx_mon_stat_t id)
219 _NOTE(ARGUNUSED(enp))
220 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
222 EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS);
223 return (__mon_stat_name[id]);
226 #endif /* EFSYS_OPT_NAMES */
228 __checkReturn efx_rc_t
229 efx_mon_stats_update(
231 __in efsys_mem_t *esmp,
232 __inout_ecount(EFX_MON_NSTATS) efx_mon_stat_value_t *values)
234 efx_mon_t *emp = &(enp->en_mon);
235 const efx_mon_ops_t *emop = emp->em_emop;
237 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
238 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
240 return (emop->emo_stats_update(enp, esmp, values));
243 #endif /* EFSYS_OPT_MON_STATS */
249 efx_mon_t *emp = &(enp->en_mon);
251 EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
252 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
253 EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON);
257 emp->em_type = EFX_MON_INVALID;
259 enp->en_mod_flags &= ~EFX_MOD_MON;