summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Johnston <rob.johnston@joyent.com>2018-08-30 02:33:29 +0000
committerGordon Ross <gwr@nexenta.com>2019-05-15 12:25:02 -0400
commitc26bf377e2245534feb1f92b43f6d4ed32513c41 (patch)
tree13a3d8480e62d422a06fa4d15b6cb1cfa87ea4c1
parenta1e3874e014aca455b61f88dadd7b0f0145893e8 (diff)
downloadillumos-joyent-c26bf377e2245534feb1f92b43f6d4ed32513c41.tar.gz
10954 expose processor model name on chip topo nodes
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Gordon Ross <gwr@nexenta.com>
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/Makefile2
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/chip.c25
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/chip.h6
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c16
4 files changed, 43 insertions, 6 deletions
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/Makefile b/usr/src/lib/fm/topo/modules/i86pc/chip/Makefile
index bbe1aa06d6..3da69e6ce2 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/Makefile
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/Makefile
@@ -31,7 +31,7 @@ MODULESRCS = chip.c chip_label.c chip_subr.c chip_amd.c chip_intel.c\
chip_serial.c chip_smbios.c
include ../../Makefile.plugin
-LDLIBS += -lipmi -lfmd_agent -lumem -lsmbios
+LDLIBS += -lipmi -lfmd_agent -lumem -lsmbios -lkstat
# not linted
SMATCH=off
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
index dd18ca5e33..cdd799cc0b 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c
@@ -469,13 +469,13 @@ create_core(topo_mod_t *mod, tnode_t *pnode, nvlist_t *cpu,
static int
create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min,
topo_instance_t max, nvlist_t *cpu, nvlist_t *auth,
- int mc_offchip)
+ int mc_offchip, kstat_ctl_t *kc)
{
tnode_t *chip;
nvlist_t *fmri = NULL;
int err, perr, nerr = 0;
int32_t chipid, procnodeid, procnodes_per_pkg;
- const char *vendor;
+ const char *vendor, *brand;
int32_t family, model;
boolean_t create_mc = B_FALSE;
uint16_t smbios_id;
@@ -541,6 +541,18 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min,
nerr -= add_nvlist_longprops(mod, chip, cpu, PGNAME(CHIP),
NULL, CHIP_FAMILY, CHIP_MODEL, CHIP_STEPPING, NULL);
+ /*
+ * Attempt to lookup the processor brand string in kstats.
+ * and add it as a prop, if found.
+ */
+ brand = get_chip_brand(mod, kc, chipid);
+ if (brand != NULL && topo_prop_set_string(chip, PGNAME(CHIP),
+ CHIP_BRAND, TOPO_PROP_IMMUTABLE, brand, &perr) != 0) {
+ whinge(mod, &nerr, "failed to set prop %s/%s",
+ PGNAME(CHIP), CHIP_BRAND);
+ }
+ topo_mod_strfree(mod, (char *)brand);
+
if (FM_AWARE_SMBIOS(mod)) {
int fru = 0;
char *serial = NULL;
@@ -685,6 +697,7 @@ create_chips(topo_mod_t *mod, tnode_t *pnode, const char *name,
nvlist_t **cpus;
int nerr = 0;
uint_t i, ncpu;
+ kstat_ctl_t *kc;
if (strcmp(name, CHIP_NODE_NAME) != 0)
return (0);
@@ -699,11 +712,17 @@ create_chips(topo_mod_t *mod, tnode_t *pnode, const char *name,
}
fmd_agent_close(hdl);
+ if ((kc = kstat_open()) == NULL) {
+ whinge(mod, NULL, "kstat_open() failed");
+ return (topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM));
+ }
+
for (i = 0; i < ncpu; i++) {
nerr -= create_chip(mod, pnode, min, max, cpus[i], auth,
- mc_offchip);
+ mc_offchip, kc);
nvlist_free(cpus[i]);
}
+ (void) kstat_close(kc);
umem_free(cpus, sizeof (nvlist_t *) * ncpu);
if (nerr == 0) {
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h
index a07b92380d..8b5ad3b88f 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h
@@ -70,11 +70,12 @@ extern "C" {
/*
* chip-properties
*/
-#define CHIP_VENDOR_ID "vendor_id"
+#define CHIP_BRAND "brand"
#define CHIP_FAMILY "family"
#define CHIP_MODEL "model"
-#define CHIP_STEPPING "stepping"
#define CHIP_NCORE "ncore_per_chip"
+#define CHIP_STEPPING "stepping"
+#define CHIP_VENDOR_ID "vendor_id"
/*
* memory-controller-properties
@@ -157,6 +158,7 @@ extern int mkrsrc(topo_mod_t *, tnode_t *, const char *, int,
nvlist_t *, nvlist_t **);
extern nvlist_t *cpu_fmri_create(topo_mod_t *, uint32_t, char *, uint8_t);
extern boolean_t is_xpv();
+extern const char *get_chip_brand(topo_mod_t *, kstat_ctl_t *, int32_t);
/*
* topo methods
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c b/usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c
index 93c308a281..a83f31dbb4 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c
@@ -864,3 +864,19 @@ out:
nvlist_free(rsrc);
return (set_retnvl(mod, out, TOPO_METH_REPLACED_RET, ret));
}
+
+const char *
+get_chip_brand(topo_mod_t *mod, kstat_ctl_t *kc, int32_t chipid)
+{
+ kstat_t *ksp;
+ kstat_named_t *ks;
+
+ if ((ksp = kstat_lookup(kc, "cpu_info", chipid, NULL)) == NULL ||
+ kstat_read(kc, ksp, NULL) == -1 ||
+ (ks = kstat_data_lookup(ksp, "brand")) == NULL) {
+ topo_mod_dprintf(mod, "failed to read stat cpu_info:%d:brand",
+ chipid);
+ return (NULL);
+ }
+ return (topo_mod_strdup(mod, ks->value.str.addr.ptr));
+}