xref: /titanic_41/usr/src/lib/fm/topo/modules/sun4v/sun4vpi/pi_impl.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _PI_IMPL_H
27 #define	_PI_IMPL_H
28 
29 /*
30  * SUN4V Platform Independent Enumerator private interfaces
31  */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <sys/types.h>
38 #include <pthread.h>
39 #include <libuutil.h>
40 #include <sys/mdesc.h>
41 #include <sys/fm/ldom.h>
42 #include <fm/topo_mod.h>
43 #include <fm/topo_hc.h>
44 
45 /* Definitions used when registering the enumerator with libtopo */
46 #define	SUN4VPI_DESC		"SUN4V Platform independent topology enumerator"
47 #define	SUN4VPI_SCHEME		"hc"
48 #define	SUN4VPI_VERSION		TOPO_VERSION
49 
50 /* Flags used by pi_enum_generic_impl */
51 #define	SUN4VPI_ENUM_ADD_SERIAL	1	/* Add serial to resource */
52 
53 /* Definitions used when working with PRI machine description nodes */
54 #define	MD_STR_BACK		"back"
55 #define	MD_STR_CFG_HANDLE	"cfg-handle"		/* FWARC/2008/300 */
56 #define	MD_STR_CHIP		"chip"
57 #define	MD_STR_COMPONENT	"component"		/* FWARC/2006/700 */
58 #define	MD_STR_CHASSIS		"chassis"
59 #define	MD_STR_COMPONENTS	"components"		/* FWARC/2006/700 */
60 #define	MD_STR_DASH_NUMBER	"dash_number"		/* FWARC/2006/700 */
61 #define	MD_STR_FRU		"fru"			/* FWARC/2006/700 */
62 #define	MD_STR_FWD		"fwd"
63 #define	MD_STR_ID		"id"			/* FWARC/2008/300 */
64 #define	MD_STR_NAC		"nac"			/* FWARC/2008/300 */
65 #define	MD_STR_NAME		"name"
66 #define	MD_STR_PART_NUMBER	"part_number"		/* FWARC/2008/300 */
67 #define	MD_STR_PATH		"path"
68 #define	MD_STR_PHY_NUMBER	"phy_number"		/* FWARC/2010/185 */
69 #define	MD_STR_PLATFORM		"platform"
70 #define	MD_STR_PRODUCT		"product"		/* FWARC/2009/390 */
71 #define	MD_STR_REVISION_NUMBER	"rev_number"		/* FWARC/2008/300 */
72 #define	MD_STR_SERIAL_NUMBER	"serial_number"		/* FWARC/2008/300 */
73 #define	MD_STR_TOPO_HC_NAME	"topo-hc-name"		/* FWARC/2008/300 */
74 #define	MD_STR_TOPO_SKIP	"topo-skip"		/* FWARC/2008/300 */
75 #define	MD_STR_TYPE		"type"
76 
77 
78 /*
79  * The enumerator needs to pass some state in to the function that walks
80  * the PRI graph.  This structure contains the necessary information.
81  */
82 struct pi_enum_s {
83 	topo_mod_t	*mod;		/* Topo module handle		*/
84 
85 	ldom_hdl_t	*ldomp;		/* LDOM connection handle	*/
86 	uint64_t	*ldom_bufp;	/* LDOM connection data		*/
87 	ssize_t		ldom_bufsize;	/* LDOM connection data size	*/
88 
89 	md_t		*mdp;		/* Machine Description handle	*/
90 	int		md_nodes;	/* Number of md nodes		*/
91 
92 	void		*wp;		/* Walker private data		*/
93 };
94 typedef struct pi_enum_s pi_enum_t;
95 
96 
97 /*
98  * Some node types require custom functions to create their topology nodes.
99  * This function prototype defines the interface to these functions.
100  */
101 typedef int pi_enum_fn_t(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t,
102     tnode_t *, const char *, tnode_t **);
103 
104 pi_enum_fn_t	pi_enum_cpu;		/* Enumerate a CHIP/CORE/CPU node */
105 pi_enum_fn_t	pi_enum_mem;		/* Enumerate a DIMM node */
106 pi_enum_fn_t	pi_enum_generic;	/* Enumerate a generic PRI node */
107 pi_enum_fn_t	pi_enum_niu;		/* Enumerate an NIU node */
108 pi_enum_fn_t	pi_enum_hostbridge;	/* Enumerate a hostbridge node */
109 pi_enum_fn_t	pi_enum_pciexrc;	/* Enumerate a PCIEX root complex */
110 pi_enum_fn_t	pi_enum_bay;		/* Enumerate a bay PRI node */
111 pi_enum_fn_t	pi_enum_top;		/* Enumerate a top-level PRI node */
112 
113 int pi_enum_generic_impl(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t,
114     tnode_t *, tnode_t *, const char *, const char *, tnode_t **, int flag);
115 
116 
117 /*
118  * Some enumeration functions may need to defer execution until after the
119  * entire PRI graph has been walked for some nodes.  This interface is
120  * provided to allow for the registration of routines to execute after the
121  * entire graph has been walked (for example, to execute sub-enumerators).
122  */
123 typedef int pi_deferenum_fn_t(topo_mod_t *, md_t *, mde_cookie_t,
124     topo_instance_t, tnode_t *, const char *, tnode_t *, void *);
125 
126 int pi_defer_add(topo_mod_t *, mde_cookie_t, tnode_t *, tnode_t *,
127     pi_deferenum_fn_t, void *);
128 int pi_defer_exec(topo_mod_t *, md_t *);
129 
130 /* Decorate a PCI-E node. */
131 int pi_enum_update(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *, tnode_t *,
132     const char *);
133 
134 /* Functions to handle LDOM PRI sessions */
135 int  pi_ldompri_open(topo_mod_t *, pi_enum_t *);
136 void pi_ldompri_close(topo_mod_t *, pi_enum_t *);
137 
138 
139 /* Walk the PRI and create a topology starting at a particular PRI node */
140 int  pi_walker(pi_enum_t *, tnode_t *, const char *, mde_cookie_t,
141     mde_str_cookie_t, mde_str_cookie_t);
142 int  pi_walker_init(topo_mod_t *);
143 void pi_walker_fini(topo_mod_t *);
144 
145 /* PRI machine description node data access routines */
146 int	pi_find_mdenodes(topo_mod_t *, md_t *, mde_cookie_t, char *, char *,
147     mde_cookie_t **, size_t *);
148 int	pi_skip_node(topo_mod_t *, md_t *, mde_cookie_t);
149 char   *pi_get_dipath(topo_mod_t *, di_node_t);
150 char   *pi_get_productsn(topo_mod_t *, md_t *, mde_cookie_t);
151 char   *pi_get_chassisid(topo_mod_t *, md_t *, mde_cookie_t);
152 int	pi_get_fru(topo_mod_t *, md_t *, mde_cookie_t, int *);
153 int	pi_get_instance(topo_mod_t *, md_t *, mde_cookie_t, topo_instance_t *);
154 char   *pi_get_label(topo_mod_t *, md_t *, mde_cookie_t);
155 int	pi_get_lun(topo_mod_t *, di_node_t);
156 char   *pi_get_part(topo_mod_t *, md_t *, mde_cookie_t);
157 char   *pi_get_path(topo_mod_t *, md_t *, mde_cookie_t);
158 char   *pi_get_productid(topo_mod_t *, md_t *);
159 int	pi_get_priphy(topo_mod_t *, md_t *, mde_cookie_t, uint8_t *);
160 int	pi_get_phynum(topo_mod_t *, di_node_t);
161 char   *pi_get_revision(topo_mod_t *, md_t *, mde_cookie_t);
162 char   *pi_get_serial(topo_mod_t *, md_t *, mde_cookie_t);
163 char   *pi_get_serverid(topo_mod_t *);
164 char   *pi_get_target_port(topo_mod_t *, di_node_t);
165 char   *pi_get_topo_hc_name(topo_mod_t *, md_t *, mde_cookie_t);
166 
167 int	pi_set_auth(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *, tnode_t *);
168 int	pi_set_frufmri(topo_mod_t *, md_t *, mde_cookie_t, const char *,
169     topo_instance_t, tnode_t *, tnode_t *);
170 int	pi_set_label(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *);
171 int	pi_set_system(topo_mod_t *, tnode_t *);
172 
173 tnode_t *pi_node_bind(topo_mod_t *, md_t *, mde_cookie_t, tnode_t *,
174     const char *, topo_instance_t, nvlist_t *);
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif /* _PI_IMPL_H */
181