2cb5535af222653abf2eba5c180ded4a7b85d8b6robj/*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * CDDL HEADER START
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * The contents of this file are subject to the terms of the
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Common Development and Distribution License (the "License").
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * You may not use this file except in compliance with the License.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * or http://www.opensolaris.org/os/licensing.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * See the License for the specific language governing permissions
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * and limitations under the License.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * When distributing Covered Code, include this CDDL HEADER in each
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * If applicable, add the following below this CDDL HEADER, with the
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * fields enclosed by brackets "[]" replaced with your own identifying
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * information: Portions Copyright [yyyy] [name of copyright owner]
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * CDDL HEADER END
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj/*
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Use is subject to license terms.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <stdio.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <stdlib.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <stdarg.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <string.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <strings.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <libnvpair.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <sys/types.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <libipmi.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <fm/topo_mod.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include <ctype.h>
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#include "chip.h"
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj#define BUFSZ 128
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston#define JEDEC_TBL_SZ 5
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj/*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * The following table maps DIMM manufacturer names to a JEDEC ID as sourced
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * from JEDEC publication JEP106W. This is (obviously) a sparse table which
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * only contains entries for manufacturers whose DIMM's have been qualified
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * for use on Sun platforms.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robjstatic const char *jedec_tbl[JEDEC_TBL_SZ][2] =
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj{
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston { "HYUNDAI ELECTRONICS", "00AD" },
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj { "INFINEON", "00C1" },
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj { "MICRON TECHNOLOGY", "002C" },
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj { "QIMONDA", "7F51" },
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj { "SAMSUNG", "00CE" },
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj};
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robjstatic int
2cb5535af222653abf2eba5c180ded4a7b85d8b6robjipmi_serial_lookup(topo_mod_t *mod, char *ipmi_tag, char *buf)
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj{
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj char *fru_data;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj int i, found_id = 0, serial_len;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_handle_t *hdl;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_sdr_fru_locator_t *fru_loc;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_fru_prod_info_t prod_info;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "ipmi_serial_lookup() called\n");
0b1b4412cfd6c4ac5467dbe6f4088dcec4f55fe8Eric Schrock if ((hdl = topo_mod_ipmi_hold(mod)) == NULL) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Failed to get IPMI handle\n");
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (topo_mod_seterrno(mod, EMOD_UNKNOWN));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Looking up FRU data for %s ...\n", ipmi_tag);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if ((fru_loc = ipmi_sdr_lookup_fru(hdl, (const char *)ipmi_tag))
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj == NULL) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Failed to lookup %s (%s)\n", ipmi_tag,
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_errmsg(hdl));
0b1b4412cfd6c4ac5467dbe6f4088dcec4f55fe8Eric Schrock topo_mod_ipmi_rele(mod);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Reading FRU data ...\n");
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (ipmi_fru_read(hdl, fru_loc, &fru_data) < 0) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Failed to read FRU data (%s)\n",
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_errmsg(hdl));
0b1b4412cfd6c4ac5467dbe6f4088dcec4f55fe8Eric Schrock topo_mod_ipmi_rele(mod);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Parsing product info area ...\n");
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (ipmi_fru_parse_product(hdl, fru_data, &prod_info) < 0) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Failed to read FRU product info (%s)\n",
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj ipmi_errmsg(hdl));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj free(fru_data);
0b1b4412cfd6c4ac5467dbe6f4088dcec4f55fe8Eric Schrock topo_mod_ipmi_rele(mod);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj free(fru_data);
0b1b4412cfd6c4ac5467dbe6f4088dcec4f55fe8Eric Schrock topo_mod_ipmi_rele(mod);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "FRU Product Serial: %s\n",
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj prod_info.ifpi_product_serial);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Manufacturer Name: \"%s\"\n",
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj prod_info.ifpi_manuf_name);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj serial_len = strnlen(prod_info.ifpi_product_serial, FRU_INFO_MAXLEN);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Newer ILOM software that has the fix for CR 6607996 will have
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * an 18-character serial number that has been synthesized using
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * the recipe from the Sun SPD JEDEC DIMM specification. If we
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * find an 18-character then we'll simply use it, as-is, and
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * return.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (serial_len == 18) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj (void) memcpy(buf, prod_info.ifpi_product_serial, 18);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *(buf+18) = '\0';
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (0);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Older ILOM software that DOESN'T have the fix for CR 6607996 will
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * only provide the 8 character manufacturer serial number.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * However, if for some reason the product info area doesn't have the
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * serial information or if the serial isn't 8 characters (we may
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * encounter SP's that don't populate the serial field or are buggy and
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * populate it with garbage), then we'll stop right now and just set the
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * buf to an empty string.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (serial_len != 8) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *buf = '\0';
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (0);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * What follows is a very crude adaptation of the recipe from the
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Sun SPD JEDEC DIMM specification for synthesizing globally unique
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * serial numbers from the 8 character manufacturer serial number.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * The Sun serial number takes the following form:
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * jjjjllyywwssssssss
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * The components are:
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * yyyy: JEDEC ID in hex (2 byte manufacture ID, 2 byte continuation
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * code).
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * ll: The memory module's manufacturing location.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * yyww: The module's manufacturing date (2-digit year/2-digit week)
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * ssssssss: The 8 character maufacturer serial number
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * First we need to normalize the manufacturer name we pulled out of
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * the FRU product info area. Our normalization algorithm is fairly
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * simple:
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * - convert all alpha chars to uppercase
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * - convert non-alphanumeric characters to a single space
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * We use the normalized name to lookup the JEDEC ID from a static
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * table. If the FRU area didn't have a manufacturer name or if the ID
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * lookup fails we'll set jjjj to 0000.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj for (i = 0; prod_info.ifpi_manuf_name[i]; i++) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj prod_info.ifpi_manuf_name[i] =
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj toupper(prod_info.ifpi_manuf_name[i]);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (!isalpha(prod_info.ifpi_manuf_name[i]) &&
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj !isdigit(prod_info.ifpi_manuf_name[i]))
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj prod_info.ifpi_manuf_name[i] = (char)0x20;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj topo_mod_dprintf(mod, "Normalized Manufacturer Name \"%s\"\n",
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj prod_info.ifpi_manuf_name);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj for (i = 0; i < JEDEC_TBL_SZ; i++)
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (strcmp(prod_info.ifpi_manuf_name, jedec_tbl[i][0]) == 0) {
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj found_id = 1;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj break;
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj if (found_id)
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj (void) memcpy(buf, jedec_tbl[i][1], 4);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj else
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj (void) memcpy(buf, (char *)("0000"), 4);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * The manufacturing location and date is not available via IPMI on
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Sun platforms, so we simply set these six digits to zeros.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj (void) memcpy((buf+4), (char *)("000000"), 6);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj /*
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * Finally, we just copy the 8 character product serial straight over
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj * and then NULL terminate the string.
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj (void) memcpy((buf+10), prod_info.ifpi_product_serial, 8);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj *(buf+18) = '\0';
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (0);
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj}
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj/* ARGSUSED */
2cb5535af222653abf2eba5c180ded4a7b85d8b6robjint
2cb5535af222653abf2eba5c180ded4a7b85d8b6robjget_dimm_serial(topo_mod_t *mod, tnode_t *node, topo_version_t vers,
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj nvlist_t *in, nvlist_t **out)
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj{
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston char **entity_refs, fru_serial[FRU_INFO_MAXLEN];
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston int err, rv = 0, i;
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston uint_t nelems;
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston boolean_t found_serial = B_FALSE;
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston if (topo_prop_get_string_array(node, TOPO_PGROUP_IPMI, "entity_ref",
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston &entity_refs, &nelems, &err) != 0) {
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston topo_mod_dprintf(mod, "%s: Failed to lookup entity_ref property"
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston " (%s)", __func__, topo_strerror(err));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj return (topo_mod_seterrno(mod, EMOD_NVL_INVAL));
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj }
2cb5535af222653abf2eba5c180ded4a7b85d8b6robj
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston for (i = 0; i < nelems; i++) {
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston if (ipmi_serial_lookup(mod, entity_refs[i], fru_serial) == 0) {
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston found_serial = B_TRUE;
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston break;
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston } else
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston topo_mod_dprintf(mod, "Failed to lookup serial for "
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston "%s\n", entity_refs[i]);
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan }
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston if (! found_serial)
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan (void) strcpy(fru_serial, "");
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan if (store_prop_val(mod, fru_serial, "serial", out) != 0) {
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan topo_mod_dprintf(mod, "Failed to set serial\n");
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan /* topo errno already set */
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston rv = -1;
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan }
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston for (i = 0; i < nelems; i++)
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston topo_mod_strfree(mod, entity_refs[i]);
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston topo_mod_free(mod, entity_refs, (nelems * sizeof (char *)));
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston
88045cff0aae4ed8823cd0989168e8f56927f83eRobert Johnston return (rv);
c3c82186300a3bf11cfdda43b1cca3cd6b333629Srihari Venkatesan}