diff options
author | Robert Mustacchi <rm@fingolfin.org> | 2020-09-26 10:14:59 -0700 |
---|---|---|
committer | Robert Mustacchi <rm@fingolfin.org> | 2020-10-09 14:18:40 -0700 |
commit | d0caeb890c33e30d7a9addcbccdda2343401d3e7 (patch) | |
tree | 5aab3545382285ae6cfcf29d12147383c87c5b67 /usr/src/lib/fm | |
parent | a41862fc9ba4a637c7ae5da1e5edd176416f7990 (diff) | |
download | illumos-joyent-d0caeb890c33e30d7a9addcbccdda2343401d3e7.tar.gz |
13200 fmtopo could display CPU socket
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Ryan Zezeski <ryan@zinascii.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src/lib/fm')
-rw-r--r-- | usr/src/lib/fm/topo/modules/i86pc/chip/chip.c | 20 | ||||
-rw-r--r-- | usr/src/lib/fm/topo/modules/i86pc/chip/chip.h | 5 | ||||
-rw-r--r-- | usr/src/lib/fm/topo/modules/i86pc/chip/chip_subr.c | 42 |
3 files changed, 52 insertions, 15 deletions
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 c81f01c3e9..183bace316 100644 --- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c +++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.c @@ -23,6 +23,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2019, Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #include <unistd.h> @@ -482,7 +483,8 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min, nvlist_t *fmri = NULL; int err, perr, nerr = 0; int32_t chipid, procnodeid, procnodes_per_pkg; - const char *vendor, *brand; + const char *vendor; + char *brand, *socket; int32_t family, model; boolean_t create_mc = B_FALSE; uint16_t smbios_id; @@ -549,16 +551,24 @@ create_chip(topo_mod_t *mod, tnode_t *pnode, topo_instance_t min, 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. + * Attempt to lookup the processor brand and socket string in + * kstats and add it as a prop, if found. */ - brand = get_chip_brand(mod, kc, chipid); + brand = socket = NULL; + get_chip_kstat_strs(mod, kc, chipid, &brand, &socket); 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); + topo_mod_strfree(mod, brand); + + if (socket != NULL && topo_prop_set_string(chip, PGNAME(CHIP), + CHIP_SOCKET, TOPO_PROP_IMMUTABLE, socket, &perr) != 0) { + whinge(mod, &nerr, "failed to set prop %s/%s", + PGNAME(CHIP), CHIP_SOCKET); + } + topo_mod_strfree(mod, socket); if (FM_AWARE_SMBIOS(mod)) { int fru = 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 b4fd850996..efabfbc6d9 100644 --- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h +++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h @@ -21,6 +21,7 @@ /* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2019, Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ #ifndef _CHIP_H @@ -74,6 +75,7 @@ extern "C" { #define CHIP_FAMILY "family" #define CHIP_MODEL "model" #define CHIP_NCORE "ncore_per_chip" +#define CHIP_SOCKET "socket" #define CHIP_STEPPING "stepping" #define CHIP_VENDOR_ID "vendor_id" @@ -158,7 +160,8 @@ 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); +extern void get_chip_kstat_strs(topo_mod_t *, kstat_ctl_t *, int32_t, char **, + char **); /* * 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 53fd7852ef..90be5dca92 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 @@ -23,6 +23,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2019, Joyent, Inc. + * Copyright 2020 Oxide Computer Company */ /* @@ -865,18 +866,41 @@ out: 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) +void +get_chip_kstat_strs(topo_mod_t *mod, kstat_ctl_t *kc, int32_t chipid, + char **brandp, char **sktp) { kstat_t *ksp; kstat_named_t *ks; + uint_t i; - 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); + for (i = 0, ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next, i++) { + if (strcmp(ksp->ks_module, "cpu_info") != 0) + continue; + + if (kstat_read(kc, ksp, NULL) == -1) { + topo_mod_dprintf(mod, "failed to read stat cpu_info:%u", + i); + continue; + } + + if ((ks = kstat_data_lookup(ksp, "chip_id")) == NULL || + chipid != ks->value.i32) { + continue; + } + + if ((ks = kstat_data_lookup(ksp, "brand")) != NULL) { + *brandp = topo_mod_strdup(mod, ks->value.str.addr.ptr); + + } + + if ((ks = kstat_data_lookup(ksp, "socket_type")) != NULL) { + if (strcmp(ks->value.str.addr.ptr, "Unknown") != 0) { + *sktp = topo_mod_strdup(mod, + ks->value.str.addr.ptr); + } + } + + return; } - return (topo_mod_strdup(mod, ks->value.str.addr.ptr)); } |