diff options
author | Robert Mustacchi <rm@joyent.com> | 2017-10-04 17:17:43 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2018-05-24 17:13:14 +0000 |
commit | 32ece1f96d76b7ae0165091c2bc2a3cdce36971b (patch) | |
tree | 814c4e4e95e1e9d08298985bf709ae553a1c9a80 | |
parent | fcd69270d3e30d8121da73f26d9d8aec4375ecd4 (diff) | |
download | illumos-joyent-32ece1f96d76b7ae0165091c2bc2a3cdce36971b.tar.gz |
9104 smbios(1M) should display PSU info
9105 smbios(1M) processor table info can be confusing
Reviewed by: Tim Kordas <tim.kordas@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/cmd/smbios/smbios.c | 69 | ||||
-rw-r--r-- | usr/src/common/smbios/mktables.sh | 6 | ||||
-rw-r--r-- | usr/src/common/smbios/smb_info.c | 55 | ||||
-rw-r--r-- | usr/src/lib/libsmbios/common/mapfile-vers | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/smbios.h | 51 | ||||
-rw-r--r-- | usr/src/uts/common/sys/smbios_impl.h | 9 |
6 files changed, 192 insertions, 5 deletions
diff --git a/usr/src/cmd/smbios/smbios.c b/usr/src/cmd/smbios/smbios.c index 45a159d3c5..c7bd5d75c6 100644 --- a/usr/src/cmd/smbios/smbios.c +++ b/usr/src/cmd/smbios/smbios.c @@ -57,6 +57,24 @@ static int opt_x; /*PRINTFLIKE2*/ static void +smbios_warn(smbios_hdl_t *shp, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + (void) vfprintf(stderr, format, ap); + va_end(ap); + + if (shp != NULL) { + (void) fprintf(stderr, ": %s", + smbios_errmsg(smbios_errno(shp))); + } + + (void) fprintf(stderr, "\n"); +} + +/*PRINTFLIKE2*/ +static void oprintf(FILE *fp, const char *format, ...) { va_list ap; @@ -526,9 +544,9 @@ print_processor(smbios_hdl_t *shp, id_t id, FILE *fp) else oprintf(fp, " Current Speed: Unknown\n"); - id_printf(fp, " L1 Cache: ", p.smbp_l1cache); - id_printf(fp, " L2 Cache: ", p.smbp_l2cache); - id_printf(fp, " L3 Cache: ", p.smbp_l3cache); + id_printf(fp, " L1 Cache Handle: ", p.smbp_l1cache); + id_printf(fp, " L2 Cache Handle: ", p.smbp_l2cache); + id_printf(fp, " L3 Cache Handle: ", p.smbp_l3cache); } static void @@ -998,6 +1016,47 @@ print_ipmi(smbios_hdl_t *shp, FILE *fp) } static void +print_powersup(smbios_hdl_t *shp, id_t id, FILE *fp) +{ + smbios_powersup_t p; + + if (smbios_info_powersup(shp, id, &p) != 0) { + smbios_warn(shp, "failed to read power supply information"); + return; + } + + oprintf(fp, " Power Supply Group: %u\n", p.smbps_group); + if (p.smbps_maxout != 0x8000) { + oprintf(fp, " Maximum Output: %llu mW\n", p.smbps_maxout); + } else { + oprintf(fp, " Maximum Output: unknown\n"); + } + + flag_printf(fp, "Characteristics", p.smbps_flags, + sizeof (p.smbps_flags) * NBBY, smbios_powersup_flag_name, + smbios_powersup_flag_desc); + + desc_printf(smbios_powersup_input_desc(p.smbps_ivrs), + fp, " Input Voltage Range Switching: %u", p.smbps_ivrs); + desc_printf(smbios_powersup_status_desc(p.smbps_status), + fp, " Status: %u", p.smbps_status); + desc_printf(smbios_powersup_type_desc(p.smbps_pstype), + fp, " Type: %u", p.smbps_pstype); + + if (p.smbps_vprobe != 0xffff) { + oprintf(fp, " Voltage Probe Handle: %lu\n", p.smbps_vprobe); + } + + if (p.smbps_cooldev != 0xffff) { + oprintf(fp, " Cooling Device Handle: %lu\n", p.smbps_cooldev); + } + + if (p.smbps_iprobe != 0xffff) { + oprintf(fp, " Current Probe Handle: %lu\n", p.smbps_iprobe); + } +} + +static void print_extprocessor(smbios_hdl_t *shp, id_t id, FILE *fp) { int i; @@ -1204,6 +1263,10 @@ print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp) oprintf(fp, "\n"); print_ipmi(shp, fp); break; + case SMB_TYPE_POWERSUP: + oprintf(fp, "\n"); + print_powersup(shp, sp->smbstr_id, fp); + break; case SMB_TYPE_OBDEVEXT: oprintf(fp, "\n"); print_obdevs_ext(shp, sp->smbstr_id, fp); diff --git a/usr/src/common/smbios/mktables.sh b/usr/src/common/smbios/mktables.sh index 0d8f0cf997..7a001c0eb3 100644 --- a/usr/src/common/smbios/mktables.sh +++ b/usr/src/common/smbios/mktables.sh @@ -22,6 +22,7 @@ # # # Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright (c) 2017, Joyent, Inc. # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # @@ -47,6 +48,7 @@ SMB_CAT_ smbios_cache_ctype_name uint_t SMB_CAF_ smbios_cache_flag_name uint_t SMB_EVFL_ smbios_evlog_flag_name uint_t SMB_IPMI_F_ smbios_ipmi_flag_name uint_t +SMB_POWERSUP_F_ smbios_powersup_flag_name uint_t SMB_MDF_ smbios_memdevice_flag_name uint_t SMB_PRC_ smbios_processor_core_flag_name uint_t SMB_TYPE_ smbios_type_name uint_t @@ -76,6 +78,10 @@ SMB_EVM_ smbios_evlog_method_desc uint_t SMB_HWSEC_PS_ smbios_hwsec_desc uint_t SMB_IPMI_F_ smbios_ipmi_flag_desc uint_t SMB_IPMI_T_ smbios_ipmi_type_desc uint_t +SMB_POWERSUP_F_ smbios_powersup_flag_desc uint_t +SMB_POWERSUP_I_ smbios_powersup_input_desc uint_t +SMB_POWERSUP_S_ smbios_powersup_status_desc uint_t +SMB_POWERSUP_T_ smbios_powersup_type_desc uint_t SMB_MAL_ smbios_memarray_loc_desc uint_t SMB_MAU_ smbios_memarray_use_desc uint_t SMB_MAE_ smbios_memarray_ecc_desc uint_t diff --git a/usr/src/common/smbios/smb_info.c b/usr/src/common/smbios/smb_info.c index 69a89e6e13..476ce0b059 100644 --- a/usr/src/common/smbios/smb_info.c +++ b/usr/src/common/smbios/smb_info.c @@ -21,7 +21,7 @@ /* * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1265,3 +1265,56 @@ smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id, return (0); } + +int +smbios_info_powersup(smbios_hdl_t *shp, id_t id, smbios_powersup_t *psup) +{ + const smb_struct_t *stp = smb_lookup_id(shp, id); + smb_powersup_t psu; + + if (stp == NULL) + return (-1); /* errno is set for us */ + + if (stp->smbst_hdr->smbh_type != SMB_TYPE_POWERSUP) + return (smb_set_errno(shp, ESMB_TYPE)); + + /* The minimum length required by the spec is 0x10. */ + if (stp->smbst_hdr->smbh_len < 0x10) + return (smb_set_errno(shp, ESMB_SHORT)); + + bzero(psup, sizeof (*psup)); + smb_info_bcopy(stp->smbst_hdr, &psu, sizeof (psu)); + psup->smbps_group = psu.smbpsup_group; + psup->smbps_maxout = psu.smbpsup_max; + + if (SMB_PSU_CHARS_ISHOT(psu.smbpsup_char)) + psup->smbps_flags |= SMB_POWERSUP_F_HOT; + if (SMB_PSU_CHARS_ISPRES(psu.smbpsup_char)) + psup->smbps_flags |= SMB_POWERSUP_F_PRESENT; + if (SMB_PSU_CHARS_ISUNPLUG(psu.smbpsup_char)) + psup->smbps_flags |= SMB_POWERSUP_F_UNPLUG; + + psup->smbps_ivrs = SMB_PSU_CHARS_IVRS(psu.smbpsup_char); + psup->smbps_status = SMB_PSU_CHARS_STATUS(psu.smbpsup_char); + psup->smbps_pstype = SMB_PSU_CHARS_TYPE(psu.smbpsup_char); + + if (stp->smbst_hdr->smbh_len >= 0x12) { + psup->smbps_vprobe = psu.smbpsup_vprobe; + } else { + psup->smbps_vprobe = 0xffff; + } + + if (stp->smbst_hdr->smbh_len >= 0x14) { + psup->smbps_cooldev = psu.smbpsup_cooldev; + } else { + psup->smbps_cooldev = 0xffff; + } + + if (stp->smbst_hdr->smbh_len >= 0x16) { + psup->smbps_iprobe = psu.smbpsup_iprobe; + } else { + psup->smbps_iprobe = 0xffff; + } + + return (0); +} diff --git a/usr/src/lib/libsmbios/common/mapfile-vers b/usr/src/lib/libsmbios/common/mapfile-vers index be6cac125c..f2e6544050 100644 --- a/usr/src/lib/libsmbios/common/mapfile-vers +++ b/usr/src/lib/libsmbios/common/mapfile-vers @@ -20,6 +20,7 @@ # # # Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright (c) 2017, Joyent, Inc. # Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. # @@ -98,6 +99,7 @@ SYMBOL_VERSION SUNWprivate_1.1 { smbios_info_obdevs_ext; smbios_info_port; smbios_info_extport; + smbios_info_powersup; smbios_info_processor; smbios_info_extprocessor; smbios_info_slot; @@ -124,6 +126,11 @@ SYMBOL_VERSION SUNWprivate_1.1 { smbios_onboard_type_desc; smbios_port_conn_desc; smbios_port_type_desc; + smbios_powersup_flag_desc; + smbios_powersup_flag_name; + smbios_powersup_input_desc; + smbios_powersup_status_desc; + smbios_powersup_type_desc; smbios_processor_family_desc; smbios_processor_status_desc; smbios_processor_type_desc; diff --git a/usr/src/uts/common/sys/smbios.h b/usr/src/uts/common/sys/smbios.h index 858df1a586..094017f1da 100644 --- a/usr/src/uts/common/sys/smbios.h +++ b/usr/src/uts/common/sys/smbios.h @@ -1351,6 +1351,50 @@ typedef struct smbios_ipmi { #define SMB_IPMI_F_INTREDGE 0x08 /* intr is edge triggered (else lvl) */ /* + * SMBIOS System Power Supply Information. See DSP0134 7.40 for more + * information. + */ +typedef struct smbios_powersup { + uint32_t smbps_group; /* group ID */ + uint64_t smbps_maxout; /* max output in milliwatts */ + uint32_t smbps_flags; /* see below */ + uint8_t smbps_ivrs; /* input voltage range switching type */ + uint8_t smbps_status; /* PSU status */ + uint8_t smbps_pstype; /* PSU type */ + id_t smbps_vprobe; /* voltage probe handle */ + id_t smbps_cooldev; /* cooling device handle */ + id_t smbps_iprobe; /* current probe handle */ +} smbios_powersup_t; + +/* smbpfs_flags */ +#define SMB_POWERSUP_F_HOT 0x01 /* PSU is hot-replaceable */ +#define SMB_POWERSUP_F_PRESENT 0x02 /* PSU is present */ +#define SMB_POWERSUP_F_UNPLUG 0x04 /* PSU is unplugged from outlet */ + +/* Values for smbps_ivrs */ +#define SMB_POWERSUP_I_OTHER 0x01 /* other */ +#define SMB_POWERSUP_I_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_I_MANUAL 0x03 /* manual */ +#define SMB_POWERSUP_I_AUTO 0x04 /* auto-switch */ +#define SMB_POWERSUP_I_WIDE 0x05 /* wide range */ +#define SMB_POWERSUP_I_NA 0x06 /* not applicable */ + +#define SMB_POWERSUP_S_OTHER 0x01 /* other */ +#define SMB_POWERSUP_S_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_S_OK 0x03 /* OK */ +#define SMB_POWERSUP_S_NONCRIT 0x04 /* non-critical */ +#define SMB_POWERSUP_S_CRIT 0x05 /* critical; PSU failed */ + +#define SMB_POWERSUP_T_OTHER 0x01 /* other */ +#define SMB_POWERSUP_T_UNKNOWN 0x02 /* unknown */ +#define SMB_POWERSUP_T_LINEAR 0x03 /* linear */ +#define SMB_POWERSUP_T_SWITCH 0x04 /* switching */ +#define SMB_POWERSUP_T_BAT 0x05 /* battery */ +#define SMB_POWERSUP_T_UPS 0x06 /* UPS */ +#define SMB_POWERSUP_T_CONV 0x07 /* converter */ +#define SMB_POWERSUP_T_REGL 0x08 /* regulator */ + +/* * SMBIOS Onboard Devices Extended Information. See DSP0134 Section 7.42 * for more information. */ @@ -1507,6 +1551,7 @@ extern int smbios_info_memdevmap(smbios_hdl_t *, id_t, smbios_memdevmap_t *); extern id_t smbios_info_hwsec(smbios_hdl_t *, smbios_hwsec_t *); extern id_t smbios_info_boot(smbios_hdl_t *, smbios_boot_t *); extern id_t smbios_info_ipmi(smbios_hdl_t *, smbios_ipmi_t *); +extern int smbios_info_powersup(smbios_hdl_t *, id_t, smbios_powersup_t *); extern int smbios_info_pciexrc(smbios_hdl_t *, id_t, smbios_pciexrc_t *); extern const char *smbios_psn(smbios_hdl_t *); @@ -1555,6 +1600,12 @@ extern const char *smbios_ipmi_flag_name(uint_t); extern const char *smbios_ipmi_flag_desc(uint_t); extern const char *smbios_ipmi_type_desc(uint_t); +extern const char *smbios_powersup_flag_name(uint_t); +extern const char *smbios_powersup_flag_desc(uint_t); +extern const char *smbios_powersup_input_desc(uint_t); +extern const char *smbios_powersup_status_desc(uint_t); +extern const char *smbios_powersup_type_desc(uint_t); + extern const char *smbios_hwsec_desc(uint_t); extern const char *smbios_memarray_loc_desc(uint_t); diff --git a/usr/src/uts/common/sys/smbios_impl.h b/usr/src/uts/common/sys/smbios_impl.h index 404be225a3..ea11aea2c1 100644 --- a/usr/src/uts/common/sys/smbios_impl.h +++ b/usr/src/uts/common/sys/smbios_impl.h @@ -21,7 +21,7 @@ /* * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. - * Copyright 2016 Joyent, Inc. + * Copyright (c) 2017, Joyent, Inc. * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -398,6 +398,13 @@ typedef struct smb_powersup { uint16_t smbpsup_iprobe; /* current probe handle */ } smb_powersup_t; +#define SMB_PSU_CHARS_ISHOT(x) ((x) & 0x01) +#define SMB_PSU_CHARS_ISPRES(x) ((x) & 0x02) +#define SMB_PSU_CHARS_ISUNPLUG(x) ((x) & 0x04) +#define SMB_PSU_CHARS_IVRS(x) (((x) >> 3) & 0xf) +#define SMB_PSU_CHARS_STATUS(x) (((x) >> 7) & 0x7) +#define SMB_PSU_CHARS_TYPE(x) (((x) >> 10) & 0xf) + typedef struct smb_obdev_ext { smb_header_t smbobe_hdr; /* structure header */ uint8_t smbobe_name; /* reference designation */ |