14ea4bb737263733ad80a36b4f73f681c30a6b45sd * CDDL HEADER START
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * The contents of this file are subject to the terms of the
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Common Development and Distribution License (the "License").
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * You may not use this file except in compliance with the License.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * See the License for the specific language governing permissions
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * and limitations under the License.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * When distributing Covered Code, include this CDDL HEADER in each
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * If applicable, add the following below this CDDL HEADER, with the
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * fields enclosed by brackets "[]" replaced with your own identifying
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * information: Portions Copyright [yyyy] [name of copyright owner]
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * CDDL HEADER END
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Use is subject to license terms.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Enumerates the processing chips, or sockets, (as distinct from cores) in a
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * system. For each chip found, the necessary nodes (one or more cores, and
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * possibly a memory controller) are constructed underneath.
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/* Forward declaration */
14ea4bb737263733ad80a36b4f73f681c30a6b45sdstatic int chip_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd topo_instance_t, void *, void *);
dd566498928f08e7c9a79797a40db893c6a4b9fbvn if ((chip = topo_mod_zalloc(mod, sizeof (md_info_t))) == NULL)
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd topo_mod_dprintf(mod, "failed to get cpus from the PRI/MD\n");
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (topo_mod_register(mod, &chip_info, TOPO_VERSION) != 0) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (0);
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye char *prod = NULL, *psn = NULL, *csn = NULL, *server = NULL;
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye if (topo_prop_get_string(parent, FM_FMRI_AUTHORITY,
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye (void) nvlist_add_string(auth, FM_FMRI_AUTH_PRODUCT_SN,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd fmri = topo_mod_hcfmri(mod, parent, FM_HC_SCHEME_VERSION, name, i,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd "Unable to make nvlist for %s bind: %s.\n",
14ea4bb737263733ad80a36b4f73f681c30a6b45sd "topo_node_bind (%s%d/%s%d) failed: %s\n",
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (topo_pgroup_create(ntn, &chip_auth_pgroup, &err) == 0) {
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye (void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* Inherit the Label FRU fields from the parent */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye /* Register retire methods */
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye if (topo_method_register(mod, ntn, pi_cpu_methods) < 0)
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye topo_mod_dprintf(mod, "Unsable to register retire methods "
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye "for %s%d/%s%d: %s\n",
3f1e69bef33050bee99ea1e9992af13fc467281fCheng Sean Ye topo_node_name(parent), topo_node_instance(parent),
14ea4bb737263733ad80a36b4f73f681c30a6b45sdcpu_fmri_create(topo_mod_t *mod, uint32_t cpuid, char *serial, uint8_t cpumask)
14ea4bb737263733ad80a36b4f73f681c30a6b45sd err = nvlist_add_uint8(fmri, FM_VERSION, FM_CPU_SCHEME_VERSION);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd err |= nvlist_add_string(fmri, FM_FMRI_SCHEME, FM_FMRI_SCHEME_CPU);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd err |= nvlist_add_uint8(fmri, FM_FMRI_CPU_MASK, cpumask);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd err |= nvlist_add_string(fmri, FM_FMRI_CPU_SERIAL_ID, serial);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (err != 0) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/*ARGSUSED*/
dd566498928f08e7c9a79797a40db893c6a4b9fbvncpu_create(topo_mod_t *mod, tnode_t *rnode, const char *name, md_info_t *chip,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * find the min/max id of cpus per this cmp and create a cpu range
dd566498928f08e7c9a79797a40db893c6a4b9fbvn for (i = 0, mcmp = chip->cpus; i < chip->ncpus; i++, mcmp++) {
13faa91230bde46da937bf33010b9accc5bdeb59sd topo_mod_dprintf(mod, "Invalid cpu range(%d,%d)\n", min, max);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (topo_node_range_create(mod, rnode, name, 0, max+1) < 0) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd topo_mod_dprintf(mod, "failed to create cpu range[0,%d]: %s\n",
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (-1);
13faa91230bde46da937bf33010b9accc5bdeb59sd * Create the cpu[i] nodes of a given cmp i
dd566498928f08e7c9a79797a40db893c6a4b9fbvn for (i = 0, mcmp = chip->cpus; i < chip->ncpus; i++, mcmp++) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* physical cpuid */
1557e65f9d0c6fde875d807c12fc03ea20f50280vn "failed to create a cpu=%d node: %s\n",
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if ((asru = cpu_fmri_create(mod, pid, sbuf, 0)) != NULL) {
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (0);
70818f5837509317d1f5dac4d82d7b5a2d547c29tsiendimm_instantiate(tnode_t *parent, const char *name, topo_mod_t *mod)
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien "Currently only know how to enumerate %s components.\n",
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (0);
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien "Calling dimm_enum\n");
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (0);
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien if ((rp = topo_mod_load(mp, DIMM, TOPO_VERSION)) == NULL) {
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien "%s enumerator could not load %s enum. (%d: %s)\n",
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien topo_mod_dprintf(mp, "dimm_enum_load(EXIT): %s, rp=%p\n", CHIP, rp);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/*ARGSUSED*/
14ea4bb737263733ad80a36b4f73f681c30a6b45sdchip_create(topo_mod_t *mod, tnode_t *rnode, const char *name,
dd566498928f08e7c9a79797a40db893c6a4b9fbvn topo_instance_t min, topo_instance_t max, md_info_t *chip)
13faa91230bde46da937bf33010b9accc5bdeb59sd topo_mod_dprintf(mod, "Invalid chip range(%d,%d)\n", min, max);
13faa91230bde46da937bf33010b9accc5bdeb59sd return (-1);
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * Create the chip[i] nodes, one for each CMP chip uniquely identified
14ea4bb737263733ad80a36b4f73f681c30a6b45sd * by the serial number.
13faa91230bde46da937bf33010b9accc5bdeb59sd /* Skip the processors with no serial number */
1557e65f9d0c6fde875d807c12fc03ea20f50280vn (void) snprintf(sbuf, sizeof (sbuf), "%llx", procp->serialno);
13faa91230bde46da937bf33010b9accc5bdeb59sd topo_mod_dprintf(mod, "node chip[%d], sn=%s\n", i, sbuf);
13faa91230bde46da937bf33010b9accc5bdeb59sd cnode = chip_tnode_create(mod, rnode, name, (topo_instance_t)i,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd /* Enumerate all cpu strands of this CMP chip */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd if (err != 0) {
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien /* Enumerate all DIMMs belonging to this chip */
70818f5837509317d1f5dac4d82d7b5a2d547c29tsien return (-1);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (0);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/*ARGSUSED*/
14ea4bb737263733ad80a36b4f73f681c30a6b45sdchip_enum(topo_mod_t *mod, tnode_t *rnode, const char *name,
14ea4bb737263733ad80a36b4f73f681c30a6b45sd topo_instance_t min, topo_instance_t max, void *arg, void *notused)
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (0);
14ea4bb737263733ad80a36b4f73f681c30a6b45sd/*ARGSUSED*/
14ea4bb737263733ad80a36b4f73f681c30a6b45sdstatic void