summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Johnston <rob.johnston@joyent.com>2018-09-11 22:37:24 +0000
committerRob Johnston <rob.johnston@joyent.com>2018-09-12 22:54:58 +0000
commit76683f77aeee2619b447d8ea5843399835fbc586 (patch)
tree2f6eb106a8932a1f1b8fc76fbf42e081894f9481
parent2bf1a940afbd1382faff159e7c93c72779ca10f4 (diff)
downloadillumos-joyent-release-20180913.tar.gz
OS-7230 topo_dprintf should evaluate debug mask before forging aheadrelease-20180913
OS-7228 Add percentage unit type to sensor abstraction layer Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Approved by: Patrick Mooney <patrick.mooney@joyent.com>
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/libtopo.h24
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_mod.c6
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_subr.c11
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_subr.h3
4 files changed, 25 insertions, 19 deletions
diff --git a/usr/src/lib/fm/topo/libtopo/common/libtopo.h b/usr/src/lib/fm/topo/libtopo/common/libtopo.h
index 156b04342e..1eefb1434a 100644
--- a/usr/src/lib/fm/topo/libtopo/common/libtopo.h
+++ b/usr/src/lib/fm/topo/libtopo/common/libtopo.h
@@ -448,10 +448,13 @@ void topo_sensor_state_name(uint32_t sensor_type, uint8_t state, char *buf,
/*
* Sensor unit types. We're using the unit types and corresponding
- * codes described in the IPMI 2.0 spec as a reference as it seems to be a
- * reasonably comprehensive list. This also simplifies the IPMI provider code
- * since the unit type codes will map exactly to what libtopo uses (so no
- * conversion necessary).
+ * codes described in section 43.17 of the IPMI 2.0 as a reference as it seems
+ * to be a reasonably comprehensive list. This also simplifies the IPMI
+ * facility provider code since the unit type codes will map exactly to what
+ * libtopo uses (so no conversion necessary). To allow for future growth if
+ * new unit types are added to IPMI in the future, while still allowing unit
+ * types not supported by IPMI to be represented, we include a gap between
+ * the last IPMI unit type and the first non-IPMI unit type.
*/
typedef enum topo_sensor_unit {
TOPO_SENSOR_UNITS_UNSPECIFIED = 0,
@@ -551,7 +554,9 @@ typedef enum topo_sensor_unit {
TOPO_SENSOR_UNITS_CE,
TOPO_SENSOR_UNITS_UE,
TOPO_SENSOR_UNITS_FATAL_ERROR,
- TOPO_SENSOR_UNITS_GRAMS
+ TOPO_SENSOR_UNITS_GRAMS,
+
+ TOPO_SENSOR_UNITS_PERCENT = 512
} topo_sensor_unit_t;
/*
@@ -569,10 +574,11 @@ typedef enum topo_sensor_unit {
* These are used to decode the type and state properties in the facility
* propgroup on facility nodes of type sensor.
*
- * Again we're basically using the same defines as for IPMI as it's serves
- * as a good starting point and simplifies the IPMI provider code. Of course
- * other facility providers will need to convert from their native codes
- * to the topo code when they set the type and state properties.
+ * Again we're basically using the same defines as listed in the IPMI
+ * specification (see section 42) as it's serves as a good starting point and
+ * simplifies the IPMI provider code. Of course other facility providers will
+ * need to convert from their native codes to the topo code when they set the
+ * type and state properties.
*/
#define TOPO_SENSOR_TYPE_RESERVED 0x0000
#define TOPO_SENSOR_TYPE_TEMP 0x0001
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
index 72d40475f8..08d7e0adc2 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_mod.c
@@ -755,14 +755,14 @@ topo_mod_clrdebug(topo_mod_t *mod)
void
topo_mod_dprintf(topo_mod_t *mod, const char *format, ...)
{
+ topo_hdl_t *thp = mod->tm_hdl;
va_list alist;
- if (mod->tm_debug == 0)
+ if (mod->tm_debug == 0 || !(thp->th_debug & TOPO_DBG_MOD))
return;
va_start(alist, format);
- topo_vdprintf(mod->tm_hdl, TOPO_DBG_MOD, (const char *)mod->tm_name,
- format, alist);
+ topo_vdprintf(mod->tm_hdl, (const char *)mod->tm_name, format, alist);
va_end(alist);
}
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_subr.c b/usr/src/lib/fm/topo/libtopo/common/topo_subr.c
index 8d9408dd59..e5c5e4052d 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_subr.c
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_subr.c
@@ -172,16 +172,12 @@ topo_debug_set(topo_hdl_t *thp, const char *dbmode, const char *dout)
}
void
-topo_vdprintf(topo_hdl_t *thp, int mask, const char *mod, const char *format,
- va_list ap)
+topo_vdprintf(topo_hdl_t *thp, const char *mod, const char *format, va_list ap)
{
char *msg;
size_t len;
char c;
- if (!(thp->th_debug & mask))
- return;
-
len = vsnprintf(&c, 1, format, ap);
msg = alloca(len + 2);
(void) vsnprintf(msg, len + 1, format, ap);
@@ -212,8 +208,11 @@ topo_dprintf(topo_hdl_t *thp, int mask, const char *format, ...)
{
va_list ap;
+ if (!(thp->th_debug & mask))
+ return;
+
va_start(ap, format);
- topo_vdprintf(thp, mask, NULL, format, ap);
+ topo_vdprintf(thp, NULL, format, ap);
va_end(ap);
}
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_subr.h b/usr/src/lib/fm/topo/libtopo/common/topo_subr.h
index ecb076b08a..073fd382e5 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_subr.h
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_subr.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, Joyent, Inc.
*/
#ifndef _TOPO_SUBR_H
@@ -124,7 +125,7 @@ extern int topo_version_str2num(const char *, topo_version_t);
extern int topo_version_defined(topo_version_t);
extern void topo_dprintf(topo_hdl_t *, int, const char *, ...);
-extern void topo_vdprintf(topo_hdl_t *, int, const char *, const char *,
+extern void topo_vdprintf(topo_hdl_t *, const char *, const char *,
va_list);
extern tnode_t *topo_hdl_root(topo_hdl_t *, const char *);