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 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/*
28 * Enumerate a DIMM node
29 */
30#include <sys/types.h>
31#include <strings.h>
32#include <sys/fm/protocol.h>
33#include <fm/topo_mod.h>
34#include <fm/topo_hc.h>
35#include "pi_impl.h"
36
37#define	_ENUM_NAME	"enum_mem"
38
39int
40pi_enum_mem(topo_mod_t *mod, md_t *mdp, mde_cookie_t mde_node,
41    topo_instance_t inst, tnode_t *t_parent, const char *hc_name,
42    tnode_t **t_node)
43{
44	int		result;
45	int		err;
46	nvlist_t	*rsrc = NULL;
47
48	*t_node = NULL;
49
50	/*
51	 * Create the basic topology node for the DIMM using the generic
52	 * enumerator.  The dimm serial is added to the resource so
53	 * the retire agent can retire correct page whether the dimm
54	 * has been moved or not.
55	 */
56	result = pi_enum_generic_impl(mod, mdp, mde_node, inst, t_parent,
57	    t_parent, hc_name, _ENUM_NAME, t_node, SUN4VPI_ENUM_ADD_SERIAL);
58	if (result != 0) {
59		/* Error messages are printed by the generic routine */
60		return (result);
61	}
62
63	/*
64	 * Set ASRU compute method, using resource as argument.
65	 */
66	result = topo_node_resource(*t_node, &rsrc, &err);
67	if (result != 0) {
68		topo_mod_dprintf(mod,
69		    "%s node_0x%llx failed to get resource: %s\n",
70		    _ENUM_NAME, (uint64_t)mde_node, topo_strerror(err));
71		return (-1);
72	}
73
74	/* Set the ASRU on the node with COMPUTE flag */
75	result = topo_node_asru_set(*t_node, rsrc, TOPO_ASRU_COMPUTE, &err);
76	nvlist_free(rsrc);
77	if (result != 0) {
78		topo_mod_dprintf(mod,
79		    "%s node_0x%llx failed to set ASRU: %s\n", _ENUM_NAME,
80		    (uint64_t)mde_node, topo_strerror(err));
81		return (-1);
82	}
83
84	return (0);
85}
86