Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/sfxge/common/efx_mon.c
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
/*- | /*- | ||||
* Copyright 2007-2009 Solarflare Communications Inc. All rights reserved. | * Copyright (c) 2007-2015 Solarflare Communications Inc. | ||||
* All rights reserved. | |||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions are met: | ||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | * | ||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND | * 1. Redistributions of source code must retain the above copyright notice, | ||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | * this list of conditions and the following disclaimer. | ||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | * 2. Redistributions in binary form must reproduce the above copyright notice, | ||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | * this list of conditions and the following disclaimer in the documentation | ||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | * and/or other materials provided with the distribution. | ||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | * | ||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||||
* SUCH DAMAGE. | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||||
* | |||||
* The views and conclusions contained in the software and documentation are | |||||
* those of the authors and should not be interpreted as representing official | |||||
* policies, either expressed or implied, of the FreeBSD Project. | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "efsys.h" | #include "efsys.h" | ||||
#include "efx.h" | #include "efx.h" | ||||
#include "efx_types.h" | #include "efx_types.h" | ||||
#include "efx_regs.h" | #include "efx_regs.h" | ||||
#include "efx_impl.h" | #include "efx_impl.h" | ||||
#if EFSYS_OPT_MON_NULL | #if EFSYS_OPT_MON_NULL | ||||
#include "nullmon.h" | #include "nullmon.h" | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_LM87 | #if EFSYS_OPT_MON_LM87 | ||||
#include "lm87.h" | #include "lm87.h" | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_MAX6647 | #if EFSYS_OPT_MON_MAX6647 | ||||
#include "max6647.h" | #include "max6647.h" | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_MCDI | |||||
#include "mcdi_mon.h" | |||||
#endif | |||||
#if EFSYS_OPT_NAMES | #if EFSYS_OPT_NAMES | ||||
static const char __cs * __cs __efx_mon_name[] = { | static const char *__efx_mon_name[] = { | ||||
"", | "", | ||||
"nullmon", | "nullmon", | ||||
"lm87", | "lm87", | ||||
"max6647", | "max6647", | ||||
"sfx90x0" | "sfx90x0", | ||||
"sfx91x0" | |||||
}; | }; | ||||
const char __cs * | const char * | ||||
efx_mon_name( | efx_mon_name( | ||||
__in efx_nic_t *enp) | __in efx_nic_t *enp) | ||||
{ | { | ||||
efx_nic_cfg_t *encp = &(enp->en_nic_cfg); | efx_nic_cfg_t *encp = &(enp->en_nic_cfg); | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID); | EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID); | ||||
EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES); | EFSYS_ASSERT3U(encp->enc_mon_type, <, EFX_MON_NTYPES); | ||||
return (__efx_mon_name[encp->enc_mon_type]); | return (__efx_mon_name[encp->enc_mon_type]); | ||||
} | } | ||||
#endif /* EFSYS_OPT_NAMES */ | #endif /* EFSYS_OPT_NAMES */ | ||||
#if EFSYS_OPT_MON_NULL | #if EFSYS_OPT_MON_NULL | ||||
static efx_mon_ops_t __cs __efx_mon_null_ops = { | static efx_mon_ops_t __efx_mon_null_ops = { | ||||
nullmon_reset, /* emo_reset */ | nullmon_reset, /* emo_reset */ | ||||
nullmon_reconfigure, /* emo_reconfigure */ | nullmon_reconfigure, /* emo_reconfigure */ | ||||
#if EFSYS_OPT_MON_STATS | #if EFSYS_OPT_MON_STATS | ||||
nullmon_stats_update /* emo_stat_update */ | nullmon_stats_update /* emo_stats_update */ | ||||
#endif /* EFSYS_OPT_MON_STATS */ | #endif /* EFSYS_OPT_MON_STATS */ | ||||
}; | }; | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_LM87 | #if EFSYS_OPT_MON_LM87 | ||||
static efx_mon_ops_t __cs __efx_mon_lm87_ops = { | static efx_mon_ops_t __efx_mon_lm87_ops = { | ||||
lm87_reset, /* emo_reset */ | lm87_reset, /* emo_reset */ | ||||
lm87_reconfigure, /* emo_reconfigure */ | lm87_reconfigure, /* emo_reconfigure */ | ||||
#if EFSYS_OPT_MON_STATS | #if EFSYS_OPT_MON_STATS | ||||
lm87_stats_update /* emo_stat_update */ | lm87_stats_update /* emo_stats_update */ | ||||
#endif /* EFSYS_OPT_MON_STATS */ | #endif /* EFSYS_OPT_MON_STATS */ | ||||
}; | }; | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_MAX6647 | #if EFSYS_OPT_MON_MAX6647 | ||||
static efx_mon_ops_t __cs __efx_mon_max6647_ops = { | static efx_mon_ops_t __efx_mon_max6647_ops = { | ||||
max6647_reset, /* emo_reset */ | max6647_reset, /* emo_reset */ | ||||
max6647_reconfigure, /* emo_reconfigure */ | max6647_reconfigure, /* emo_reconfigure */ | ||||
#if EFSYS_OPT_MON_STATS | #if EFSYS_OPT_MON_STATS | ||||
max6647_stats_update /* emo_stat_update */ | max6647_stats_update /* emo_stats_update */ | ||||
#endif /* EFSYS_OPT_MON_STATS */ | #endif /* EFSYS_OPT_MON_STATS */ | ||||
}; | }; | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_SIENA | #if EFSYS_OPT_MON_MCDI | ||||
static efx_mon_ops_t __cs __efx_mon_siena_ops = { | static efx_mon_ops_t __efx_mon_mcdi_ops = { | ||||
siena_mon_reset, /* emo_reset */ | NULL, /* emo_reset */ | ||||
siena_mon_reconfigure, /* emo_reconfigure */ | NULL, /* emo_reconfigure */ | ||||
#if EFSYS_OPT_MON_STATS | #if EFSYS_OPT_MON_STATS | ||||
siena_mon_stats_update /* emo_stat_update */ | mcdi_mon_stats_update /* emo_stats_update */ | ||||
#endif /* EFSYS_OPT_MON_STATS */ | #endif /* EFSYS_OPT_MON_STATS */ | ||||
}; | }; | ||||
#endif | #endif | ||||
static efx_mon_ops_t *__efx_mon_ops[] = { | |||||
static efx_mon_ops_t __cs * __cs __efx_mon_ops[] = { | |||||
NULL, | NULL, | ||||
#if EFSYS_OPT_MON_NULL | #if EFSYS_OPT_MON_NULL | ||||
&__efx_mon_null_ops, | &__efx_mon_null_ops, | ||||
#else | #else | ||||
NULL, | NULL, | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_LM87 | #if EFSYS_OPT_MON_LM87 | ||||
&__efx_mon_lm87_ops, | &__efx_mon_lm87_ops, | ||||
#else | #else | ||||
NULL, | NULL, | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_MAX6647 | #if EFSYS_OPT_MON_MAX6647 | ||||
&__efx_mon_max6647_ops, | &__efx_mon_max6647_ops, | ||||
#else | #else | ||||
NULL, | NULL, | ||||
#endif | #endif | ||||
#if EFSYS_OPT_MON_SIENA | #if EFSYS_OPT_MON_MCDI | ||||
&__efx_mon_siena_ops | &__efx_mon_mcdi_ops, | ||||
#else | #else | ||||
NULL, | |||||
#endif | |||||
#if EFSYS_OPT_MON_MCDI | |||||
&__efx_mon_mcdi_ops | |||||
#else | |||||
NULL | NULL | ||||
#endif | #endif | ||||
}; | }; | ||||
__checkReturn int | __checkReturn int | ||||
efx_mon_init( | efx_mon_init( | ||||
__in efx_nic_t *enp) | __in efx_nic_t *enp) | ||||
{ | { | ||||
Show All 16 Lines | efx_mon_init( | ||||
EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID); | EFSYS_ASSERT(encp->enc_mon_type != EFX_MON_INVALID); | ||||
EFSYS_ASSERT3U(emp->em_type, <, EFX_MON_NTYPES); | EFSYS_ASSERT3U(emp->em_type, <, EFX_MON_NTYPES); | ||||
if ((emop = (efx_mon_ops_t *)__efx_mon_ops[emp->em_type]) == NULL) { | if ((emop = (efx_mon_ops_t *)__efx_mon_ops[emp->em_type]) == NULL) { | ||||
rc = ENOTSUP; | rc = ENOTSUP; | ||||
goto fail2; | goto fail2; | ||||
} | } | ||||
if (emop->emo_reset != NULL) { | |||||
if ((rc = emop->emo_reset(enp)) != 0) | if ((rc = emop->emo_reset(enp)) != 0) | ||||
goto fail3; | goto fail3; | ||||
} | |||||
if (emop->emo_reconfigure != NULL) { | |||||
if ((rc = emop->emo_reconfigure(enp)) != 0) | if ((rc = emop->emo_reconfigure(enp)) != 0) | ||||
goto fail4; | goto fail4; | ||||
} | |||||
emp->em_emop = emop; | emp->em_emop = emop; | ||||
return (0); | return (0); | ||||
fail4: | fail4: | ||||
EFSYS_PROBE(fail5); | EFSYS_PROBE(fail5); | ||||
if (emop->emo_reset != NULL) | |||||
(void) emop->emo_reset(enp); | (void) emop->emo_reset(enp); | ||||
fail3: | fail3: | ||||
EFSYS_PROBE(fail4); | EFSYS_PROBE(fail4); | ||||
fail2: | fail2: | ||||
EFSYS_PROBE(fail3); | EFSYS_PROBE(fail3); | ||||
emp->em_type = EFX_MON_INVALID; | emp->em_type = EFX_MON_INVALID; | ||||
enp->en_mod_flags &= ~EFX_MOD_MON; | enp->en_mod_flags &= ~EFX_MOD_MON; | ||||
fail1: | fail1: | ||||
EFSYS_PROBE1(fail1, int, rc); | EFSYS_PROBE1(fail1, int, rc); | ||||
return (rc); | return (rc); | ||||
} | } | ||||
#if EFSYS_OPT_MON_STATS | #if EFSYS_OPT_MON_STATS | ||||
#if EFSYS_OPT_NAMES | #if EFSYS_OPT_NAMES | ||||
/* START MKCONFIG GENERATED MonitorStatNamesBlock 89ff37f1d74ad8b3 */ | /* START MKCONFIG GENERATED MonitorStatNamesBlock b9328f15438c4d01 */ | ||||
static const char __cs * __cs __mon_stat_name[] = { | static const char *__mon_stat_name[] = { | ||||
"value_2_5v", | "value_2_5v", | ||||
"value_vccp1", | "value_vccp1", | ||||
"value_vcc", | "value_vcc", | ||||
"value_5v", | "value_5v", | ||||
"value_12v", | "value_12v", | ||||
"value_vccp2", | "value_vccp2", | ||||
"value_ext_temp", | "value_ext_temp", | ||||
"value_int_temp", | "value_int_temp", | ||||
Show All 14 Lines | static const char *__mon_stat_name[] = { | ||||
"fan0", | "fan0", | ||||
"fan1", | "fan1", | ||||
"fan2", | "fan2", | ||||
"fan3", | "fan3", | ||||
"fan4", | "fan4", | ||||
"vaoe_in", | "vaoe_in", | ||||
"iaoe", | "iaoe", | ||||
"iaoe_in", | "iaoe_in", | ||||
"nic_power", | |||||
"0_9v", | |||||
"i0_9v", | |||||
"i1_2v", | |||||
"0_9v_adc", | |||||
"controller_temperature2", | |||||
"vreg_temperature", | |||||
"vreg_0_9v_temperature", | |||||
"vreg_1_2v_temperature", | |||||
"int_vptat", | |||||
"controller_internal_adc_temperature", | |||||
"ext_vptat", | |||||
"controller_external_adc_temperature", | |||||
"ambient_temperature", | |||||
"airflow", | |||||
"vdd08d_vss08d_csr", | |||||
"vdd08d_vss08d_csr_extadc", | |||||
"hotpoint_temperature", | |||||
"phy_power_switch_port0", | |||||
"phy_power_switch_port1", | |||||
"mum_vcc", | |||||
"0v9_a", | |||||
"i0v9_a", | |||||
"0v9_a_temp", | |||||
"0v9_b", | |||||
"i0v9_b", | |||||
"0v9_b_temp", | |||||
"ccom_avreg_1v2_supply", | |||||
"ccom_avreg_1v2_supply_ext_adc", | |||||
"ccom_avreg_1v8_supply", | |||||
"ccom_avreg_1v8_supply_ext_adc", | |||||
"controller_master_vptat", | |||||
"controller_master_internal_temp", | |||||
"controller_master_vptat_ext_adc", | |||||
"controller_master_internal_temp_ext_adc", | |||||
"controller_slave_vptat", | |||||
"controller_slave_internal_temp", | |||||
"controller_slave_vptat_ext_adc", | |||||
"controller_slave_internal_temp_ext_adc", | |||||
}; | }; | ||||
/* END MKCONFIG GENERATED MonitorStatNamesBlock */ | /* END MKCONFIG GENERATED MonitorStatNamesBlock */ | ||||
extern const char __cs * | extern const char * | ||||
efx_mon_stat_name( | efx_mon_stat_name( | ||||
__in efx_nic_t *enp, | __in efx_nic_t *enp, | ||||
__in efx_mon_stat_t id) | __in efx_mon_stat_t id) | ||||
{ | { | ||||
_NOTE(ARGUNUSED(enp)) | _NOTE(ARGUNUSED(enp)) | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS); | EFSYS_ASSERT3U(id, <, EFX_MON_NSTATS); | ||||
Show All 28 Lines | efx_mon_fini( | ||||
int rc; | int rc; | ||||
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); | ||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE); | ||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON); | EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_MON); | ||||
emp->em_emop = NULL; | emp->em_emop = NULL; | ||||
if (emop->emo_reset != NULL) { | |||||
rc = emop->emo_reset(enp); | rc = emop->emo_reset(enp); | ||||
if (rc != 0) | if (rc != 0) | ||||
EFSYS_PROBE1(fail1, int, rc); | EFSYS_PROBE1(fail1, int, rc); | ||||
} | |||||
emp->em_type = EFX_MON_INVALID; | emp->em_type = EFX_MON_INVALID; | ||||
enp->en_mod_flags &= ~EFX_MOD_MON; | enp->en_mod_flags &= ~EFX_MOD_MON; | ||||
} | } |