chip_subr.c (f2dbfd32) chip_subr.c (d0caeb89)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 9 unchanged lines hidden (view full) ---

18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2019, Joyent, Inc.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 9 unchanged lines hidden (view full) ---

18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2019, Joyent, Inc.
26 * Copyright 2020 Oxide Computer Company
26 */
27
28/*
29 * Support function for the i86pc chip enumerator
30 */
31
32#include <sys/types.h>
33#include <stdarg.h>

--- 826 unchanged lines hidden (view full) ---

860 ret = FMD_OBJ_STATE_REPLACED;
861 }
862
863out:
864 nvlist_free(rsrc);
865 return (set_retnvl(mod, out, TOPO_METH_REPLACED_RET, ret));
866}
867
27 */
28
29/*
30 * Support function for the i86pc chip enumerator
31 */
32
33#include <sys/types.h>
34#include <stdarg.h>

--- 826 unchanged lines hidden (view full) ---

861 ret = FMD_OBJ_STATE_REPLACED;
862 }
863
864out:
865 nvlist_free(rsrc);
866 return (set_retnvl(mod, out, TOPO_METH_REPLACED_RET, ret));
867}
868
868const char *
869get_chip_brand(topo_mod_t *mod, kstat_ctl_t *kc, int32_t chipid)
869void
870get_chip_kstat_strs(topo_mod_t *mod, kstat_ctl_t *kc, int32_t chipid,
871 char **brandp, char **sktp)
870{
871 kstat_t *ksp;
872 kstat_named_t *ks;
872{
873 kstat_t *ksp;
874 kstat_named_t *ks;
875 uint_t i;
873
876
874 if ((ksp = kstat_lookup(kc, "cpu_info", chipid, NULL)) == NULL ||
875 kstat_read(kc, ksp, NULL) == -1 ||
876 (ks = kstat_data_lookup(ksp, "brand")) == NULL) {
877 topo_mod_dprintf(mod, "failed to read stat cpu_info:%d:brand",
878 chipid);
879 return (NULL);
877 for (i = 0, ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next, i++) {
878 if (strcmp(ksp->ks_module, "cpu_info") != 0)
879 continue;
880
881 if (kstat_read(kc, ksp, NULL) == -1) {
882 topo_mod_dprintf(mod, "failed to read stat cpu_info:%u",
883 i);
884 continue;
885 }
886
887 if ((ks = kstat_data_lookup(ksp, "chip_id")) == NULL ||
888 chipid != ks->value.i32) {
889 continue;
890 }
891
892 if ((ks = kstat_data_lookup(ksp, "brand")) != NULL) {
893 *brandp = topo_mod_strdup(mod, ks->value.str.addr.ptr);
894
895 }
896
897 if ((ks = kstat_data_lookup(ksp, "socket_type")) != NULL) {
898 if (strcmp(ks->value.str.addr.ptr, "Unknown") != 0) {
899 *sktp = topo_mod_strdup(mod,
900 ks->value.str.addr.ptr);
901 }
902 }
903
904 return;
880 }
905 }
881 return (topo_mod_strdup(mod, ks->value.str.addr.ptr));
882}
906}