summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@joyent.com>2019-04-24 03:05:13 +0000
committerRobert Mustacchi <rm@joyent.com>2019-06-03 21:53:28 +0000
commit4726209a730fa4360258bd41e324d6fcd8c00269 (patch)
tree3dae8d9db8c287ca2f3edc42692c0d71184fa2e3 /usr/src/lib
parent36f3bf06b174311a3035c2fd79f71eec859b0849 (diff)
downloadillumos-joyent-4726209a730fa4360258bd41e324d6fcd8c00269.tar.gz
OS-7769 Want Intel PCH temperature sensor
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Mike Zeller <mike.zeller@joyent.com> Approved by: Rob Johnston <rob.johnston@joyent.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/hc.c3
-rw-r--r--usr/src/lib/fm/topo/libtopo/common/topo_hc.h3
-rw-r--r--usr/src/lib/fm/topo/maps/i86pc/i86pc-legacy-hc-topology.xml5
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/Makefile2
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chipset/chipset.c190
5 files changed, 199 insertions, 4 deletions
diff --git a/usr/src/lib/fm/topo/libtopo/common/hc.c b/usr/src/lib/fm/topo/libtopo/common/hc.c
index 9c64077549..15d7b769e9 100644
--- a/usr/src/lib/fm/topo/libtopo/common/hc.c
+++ b/usr/src/lib/fm/topo/libtopo/common/hc.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#include <stdio.h>
@@ -154,6 +154,7 @@ static const hcc_t hc_canon[] = {
{ CENTERPLANE, TOPO_STABILITY_PRIVATE },
{ CHASSIS, TOPO_STABILITY_PRIVATE },
{ CHIP, TOPO_STABILITY_PRIVATE },
+ { CHIPSET, TOPO_STABILITY_PRIVATE },
{ CHIP_SELECT, TOPO_STABILITY_PRIVATE },
{ CORE, TOPO_STABILITY_PRIVATE },
{ CONTROLLER, TOPO_STABILITY_PRIVATE },
diff --git a/usr/src/lib/fm/topo/libtopo/common/topo_hc.h b/usr/src/lib/fm/topo/libtopo/common/topo_hc.h
index a102293f0a..5f90741c1c 100644
--- a/usr/src/lib/fm/topo/libtopo/common/topo_hc.h
+++ b/usr/src/lib/fm/topo/libtopo/common/topo_hc.h
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2019, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
#ifndef _TOPO_HC_H
@@ -42,6 +42,7 @@ extern "C" {
#define CENTERPLANE "centerplane"
#define CHASSIS "chassis"
#define CHIP "chip"
+#define CHIPSET "chipset"
#define CORE "core"
#define STRAND "strand"
#define CHIP_SELECT "chip-select"
diff --git a/usr/src/lib/fm/topo/maps/i86pc/i86pc-legacy-hc-topology.xml b/usr/src/lib/fm/topo/maps/i86pc/i86pc-legacy-hc-topology.xml
index 20ddecbf48..f6b0a39e9e 100644
--- a/usr/src/lib/fm/topo/maps/i86pc/i86pc-legacy-hc-topology.xml
+++ b/usr/src/lib/fm/topo/maps/i86pc/i86pc-legacy-hc-topology.xml
@@ -2,7 +2,7 @@
<!DOCTYPE topology SYSTEM "/usr/share/lib/xml/dtd/topology.dtd.1">
<!--
Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
-Copyright (c) 2018, Joyent, Inc. All rights reserved.
+Copyright 2019 Joyent, Inc.
CDDL HEADER START
@@ -89,6 +89,9 @@ Copyright (c) 2018, Joyent, Inc. All rights reserved.
<range name='usb-mobo' min='0' max='100'>
<enum-method name='usb' version='1' />
</range>
+ <range name='chipset' min='0' max='100'>
+ <enum-method name='chipset' version='1' />
+ </range>
</dependents>
</range>
diff --git a/usr/src/lib/fm/topo/modules/i86pc/Makefile b/usr/src/lib/fm/topo/modules/i86pc/Makefile
index f42af0a306..36c4ea5f95 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/Makefile
+++ b/usr/src/lib/fm/topo/modules/i86pc/Makefile
@@ -24,7 +24,7 @@
# Use is subject to license terms.
#
-SUBDIRS = chip hostbridge pcibus x86pi
+SUBDIRS = chip chipset hostbridge pcibus x86pi
.PARALLEL: $(SUBDIRS)
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chipset/chipset.c b/usr/src/lib/fm/topo/modules/i86pc/chipset/chipset.c
new file mode 100644
index 0000000000..cc306b4b2f
--- /dev/null
+++ b/usr/src/lib/fm/topo/modules/i86pc/chipset/chipset.c
@@ -0,0 +1,190 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
+
+/*
+ * Chipset Enumeration
+ *
+ * Most x86 systems have some form of chipset which are components that exist on
+ * the motherboard that provide additional services that range from I/O such as
+ * memory and PCIe controllers (though as of this writing those mostly are a
+ * part of the CPU now) to additional functionality like Ethernet and USB
+ * controllers. At the moment, this module opts to enumerate a chipset node if
+ * there's something that exists under it that we care about such as:
+ *
+ * o Temperature sensors
+ * o Firmware modules
+ *
+ * If we do not detect anything, then we do not bother enumerating and trying to
+ * determine the different chipsets that are on the system. Currently, the only
+ * method for doing this is the presence of an Intel platform controller hub
+ * (PCH) temperature sensor.
+ */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+
+#include <sys/fm/protocol.h>
+#include <fm/topo_mod.h>
+#include <fm/topo_list.h>
+#include <fm/topo_method.h>
+
+#include <topo_sensor.h>
+
+#define CHIPSET_VERSION 1
+
+/*
+ * This is the path to the temperature sensor that, if present, indicates we
+ * should construct a chipset node.
+ */
+static const char *topo_chipset_temp_sensor =
+ "/dev/sensors/temperature/pch/ts.0";
+
+/*
+ * Attempt to determine if there is enough information for us to enumerate a
+ * chipset node, which usually means that we would enumerate something under it
+ * such as a temperature sensor or provide information about some piece of
+ * firmware that it has. Currently, if there is no temperature sensor, then we
+ * don't consider one to be present and don't do anything else.
+ */
+static boolean_t
+topo_chipset_present(void)
+{
+ struct stat st;
+
+ if (stat(topo_chipset_temp_sensor, &st) == 0 &&
+ S_ISCHR(st.st_mode)) {
+ return (B_TRUE);
+ }
+
+ return (B_FALSE);
+}
+
+static int
+topo_chipset_enum(topo_mod_t *mod, tnode_t *pnode, const char *name,
+ topo_instance_t min, topo_instance_t max, void *modarg, void *data)
+{
+ int ret;
+ nvlist_t *fmri = NULL, *auth = NULL, *presource = NULL;
+ tnode_t *tn = NULL;
+ const topo_instance_t inst = 0;
+
+ topo_mod_dprintf(mod, "chipset_enum: asked to enumerate %s", name);
+
+ if (strcmp(name, CHIPSET) != 0) {
+ topo_mod_dprintf(mod, "chipset_enum: asked to enumerate "
+ "unknown component");
+ return (topo_mod_seterrno(mod, EMOD_UKNOWN_ENUM));
+ }
+
+ if (!topo_chipset_present()) {
+ topo_mod_dprintf(mod, "chipset_enum: no device present", name);
+ return (0);
+ }
+
+ if ((auth = topo_mod_auth(mod, pnode)) == NULL) {
+ topo_mod_dprintf(mod, "chipset_enum: failed to get topo "
+ "auth: %s", topo_mod_errmsg(mod));
+ /* topo_mod_auth() sets the module error */
+ ret = -1;
+ goto err;
+ }
+
+ if ((fmri = topo_mod_hcfmri(mod, pnode, FM_HC_SCHEME_VERSION,
+ CHIPSET, inst, NULL, auth, NULL, NULL, NULL)) == NULL) {
+ topo_mod_dprintf(mod, "chipset_enum: failed to get FMRI: %s",
+ topo_mod_errmsg(mod));
+ /* topo_mod_hcfmri() sets the module error */
+ ret = -1;
+ goto err;
+ }
+
+ if ((tn = topo_node_bind(mod, pnode, CHIPSET, inst, fmri)) == NULL) {
+ topo_mod_dprintf(mod, "chipset_enum: failed to bind node: %s",
+ topo_mod_errmsg(mod));
+ ret = -1;
+ goto err;
+ }
+
+ if (topo_node_resource(pnode, &presource, &ret) != 0) {
+ topo_mod_dprintf(mod, "chipset_enum: failed to get parent "
+ "resource %s\n", topo_strerror(ret));
+ ret = topo_mod_seterrno(mod, ret);
+ goto err;
+ }
+
+ if (topo_node_fru_set(tn, presource, 0, &ret) != 0) {
+ topo_mod_dprintf(mod, "chipset_enum: failed to set FRU: %s",
+ topo_strerror(ret));
+ ret = topo_mod_seterrno(mod, ret);
+ goto err;
+ }
+
+ /*
+ * Finally, create the temperature sensor.
+ */
+ if ((ret = topo_sensor_create_temp_sensor(mod, tn,
+ topo_chipset_temp_sensor, "temp")) != 0) {
+ topo_mod_dprintf(mod, "failed to create chipset temperature "
+ "sensor");
+ goto err;
+ }
+
+ nvlist_free(auth);
+ nvlist_free(fmri);
+ nvlist_free(presource);
+ return (0);
+err:
+ nvlist_free(auth);
+ nvlist_free(fmri);
+ nvlist_free(presource);
+ topo_node_unbind(tn);
+ return (ret);
+}
+
+static const topo_modops_t chipset_ops = {
+ topo_chipset_enum, NULL
+};
+
+static topo_modinfo_t chipset_mod = {
+ CHIPSET, FM_FMRI_SCHEME_HC, CHIPSET_VERSION, &chipset_ops
+};
+
+int
+_topo_init(topo_mod_t *mod, topo_version_t version)
+{
+ if (getenv("TOPOCHIPSETDEBUG") != NULL) {
+ topo_mod_setdebug(mod);
+ }
+
+ topo_mod_dprintf(mod, "_mod_init: initializing %s enumerator\n",
+ CHIPSET);
+
+ if (version != -1) {
+
+ }
+
+ if (topo_mod_register(mod, &chipset_mod, TOPO_VERSION) != 0) {
+ return (-1);
+ }
+
+ return (0);
+}
+
+void
+_topo_fini(topo_mod_t *mod)
+{
+}