xref: /onnv-gate/usr/src/lib/fm/libldom/sparc/ldmsvcs_utils.h (revision 2072:a94b3dbc5bcb)
1*2072Svn83148 /*
2*2072Svn83148  * CDDL HEADER START
3*2072Svn83148  *
4*2072Svn83148  * The contents of this file are subject to the terms of the
5*2072Svn83148  * Common Development and Distribution License (the "License").
6*2072Svn83148  * You may not use this file except in compliance with the License.
7*2072Svn83148  *
8*2072Svn83148  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*2072Svn83148  * or http://www.opensolaris.org/os/licensing.
10*2072Svn83148  * See the License for the specific language governing permissions
11*2072Svn83148  * and limitations under the License.
12*2072Svn83148  *
13*2072Svn83148  * When distributing Covered Code, include this CDDL HEADER in each
14*2072Svn83148  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*2072Svn83148  * If applicable, add the following below this CDDL HEADER, with the
16*2072Svn83148  * fields enclosed by brackets "[]" replaced with your own identifying
17*2072Svn83148  * information: Portions Copyright [yyyy] [name of copyright owner]
18*2072Svn83148  *
19*2072Svn83148  * CDDL HEADER END
20*2072Svn83148  */
21*2072Svn83148 /*
22*2072Svn83148  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*2072Svn83148  * Use is subject to license terms.
24*2072Svn83148  */
25*2072Svn83148 
26*2072Svn83148 #ifndef	_LDMSVCS_UTILS_H
27*2072Svn83148 #define	_LDMSVCS_UTILS_H
28*2072Svn83148 
29*2072Svn83148 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*2072Svn83148 
31*2072Svn83148 #include <stdlib.h>
32*2072Svn83148 #include <sys/types.h>
33*2072Svn83148 #include <sys/ldc.h>
34*2072Svn83148 #include <sys/vldc.h>
35*2072Svn83148 #include <sys/ds.h>
36*2072Svn83148 #include <sys/ds_impl.h>
37*2072Svn83148 
38*2072Svn83148 #ifdef	__cplusplus
39*2072Svn83148 extern "C" {
40*2072Svn83148 #endif
41*2072Svn83148 
42*2072Svn83148 /*
43*2072Svn83148  * Service Information
44*2072Svn83148  */
45*2072Svn83148 typedef struct fds_svc {
46*2072Svn83148 	ds_svc_hdl_t hdl;	/* handle assigned by DS */
47*2072Svn83148 	ds_svc_state_t state;	/* current service state */
48*2072Svn83148 	ds_ver_t ver;		/* svc protocol version in use */
49*2072Svn83148 	char *name;
50*2072Svn83148 } fds_svc_t;
51*2072Svn83148 
52*2072Svn83148 /*
53*2072Svn83148  * table of registered services
54*2072Svn83148  */
55*2072Svn83148 typedef struct fds_reg_svcs {
56*2072Svn83148 	pthread_mutex_t mt;
57*2072Svn83148 	pthread_cond_t cv;
58*2072Svn83148 	fds_svc_t **tbl;		/* the table itself */
59*2072Svn83148 	uint_t nsvcs;		/* current number of items */
60*2072Svn83148 } fds_reg_svcs_t;
61*2072Svn83148 
62*2072Svn83148 
63*2072Svn83148 typedef enum {
64*2072Svn83148 	CHANNEL_UNINITIALIZED,	/* status of channel unknown */
65*2072Svn83148 	CHANNEL_CLOSED,		/* port structure not in use */
66*2072Svn83148 	CHANNEL_OPEN,		/* open but not initialized/reset */
67*2072Svn83148 	CHANNEL_READY,		/* init/reset done */
68*2072Svn83148 	CHANNEL_UNUSABLE,	/* cannot be used (possibly busy) */
69*2072Svn83148 	CHANNEL_EXIT		/* normal exit */
70*2072Svn83148 } fds_chan_state_t;
71*2072Svn83148 
72*2072Svn83148 typedef struct fds_channel {
73*2072Svn83148 	int fd;			/* FD for this channel */
74*2072Svn83148 	fds_chan_state_t state; /* state of the port */
75*2072Svn83148 	ds_ver_t ver;		/* DS protocol version in use */
76*2072Svn83148 } fds_channel_t;
77*2072Svn83148 
78*2072Svn83148 
79*2072Svn83148 /*
80*2072Svn83148  * FMA services
81*2072Svn83148  */
82*2072Svn83148 typedef struct {
83*2072Svn83148 	uint64_t req_num;
84*2072Svn83148 } fma_req_pri_t;
85*2072Svn83148 
86*2072Svn83148 /*
87*2072Svn83148  * definition of fma_pri_resp_t is not shown here.  for more details,
88*2072Svn83148  * see ldmsvcs_utils.c:ldmsvcs_get_core_md().
89*2072Svn83148  */
90*2072Svn83148 
91*2072Svn83148 #define	FMA_CPU_REQ_STATUS	0
92*2072Svn83148 #define	FMA_CPU_REQ_OFFLINE	1
93*2072Svn83148 #define	FMA_CPU_REQ_ONLINE	2
94*2072Svn83148 
95*2072Svn83148 #define	FMA_CPU_RESP_OK		0
96*2072Svn83148 #define	FMA_CPU_RESP_FAILURE	1
97*2072Svn83148 
98*2072Svn83148 #define	FMA_CPU_STAT_ONLINE	0
99*2072Svn83148 #define	FMA_CPU_STAT_OFFLINE	1
100*2072Svn83148 #define	FMA_CPU_STAT_ILLEGAL	2
101*2072Svn83148 
102*2072Svn83148 typedef struct {
103*2072Svn83148 	uint64_t req_num;
104*2072Svn83148 	uint32_t msg_type;
105*2072Svn83148 	uint32_t cpu_id;
106*2072Svn83148 } fma_cpu_service_req_t;
107*2072Svn83148 
108*2072Svn83148 typedef struct {
109*2072Svn83148 	uint64_t req_num;
110*2072Svn83148 	uint32_t result;
111*2072Svn83148 	uint32_t status;
112*2072Svn83148 } fma_cpu_resp_t;
113*2072Svn83148 
114*2072Svn83148 #define	FMA_MEM_REQ_STATUS	0
115*2072Svn83148 #define	FMA_MEM_REQ_RETIRE	1
116*2072Svn83148 #define	FMA_MEM_REQ_RESURRECT	2
117*2072Svn83148 
118*2072Svn83148 #define	FMA_MEM_RESP_OK		0
119*2072Svn83148 #define	FMA_MEM_RESP_FAILURE	1
120*2072Svn83148 
121*2072Svn83148 #define	FMA_MEM_STAT_NOTRETIRED	0
122*2072Svn83148 #define	FMA_MEM_STAT_RETIRED	1
123*2072Svn83148 #define	FMA_MEM_STAT_ILLEGAL	2
124*2072Svn83148 
125*2072Svn83148 typedef struct {
126*2072Svn83148 	uint64_t req_num;
127*2072Svn83148 	uint32_t msg_type;
128*2072Svn83148 	uint32_t _resvd;
129*2072Svn83148 	uint64_t real_addr;
130*2072Svn83148 	uint64_t length;
131*2072Svn83148 } fma_mem_service_req_t;
132*2072Svn83148 
133*2072Svn83148 typedef struct {
134*2072Svn83148 	uint64_t req_num;
135*2072Svn83148 	uint32_t result;
136*2072Svn83148 	uint32_t status;
137*2072Svn83148 	uint64_t res_addr;
138*2072Svn83148 	uint64_t res_length;
139*2072Svn83148 } fma_mem_resp_t;
140*2072Svn83148 
141*2072Svn83148 
142*2072Svn83148 struct ldom_hdl {
143*2072Svn83148 	int major_version;
144*2072Svn83148 	int service_ldom;
145*2072Svn83148 	void *(*allocp)(size_t size);
146*2072Svn83148 	void (*freep)(void *addr, size_t size);
147*2072Svn83148 	struct ldmsvcs_info *lsinfo;
148*2072Svn83148 };
149*2072Svn83148 
150*2072Svn83148 
151*2072Svn83148 extern int ldmsvcs_check_channel(void);
152*2072Svn83148 
153*2072Svn83148 extern void ldmsvcs_init(struct ldom_hdl *lhp);
154*2072Svn83148 
155*2072Svn83148 extern void ldmsvcs_fini(struct ldom_hdl *lhp);
156*2072Svn83148 
157*2072Svn83148 extern ssize_t ldmsvcs_get_core_md(struct ldom_hdl *lhp, uint64_t **buf);
158*2072Svn83148 
159*2072Svn83148 extern int ldmsvcs_cpu_req_status(struct ldom_hdl *lhp, uint32_t cpuid);
160*2072Svn83148 
161*2072Svn83148 extern int ldmsvcs_mem_req_status(struct ldom_hdl *lhp, uint64_t pa);
162*2072Svn83148 
163*2072Svn83148 extern int ldmsvcs_cpu_req_offline(struct ldom_hdl *lhp, uint32_t cpuid);
164*2072Svn83148 
165*2072Svn83148 extern int ldmsvcs_mem_req_retire(struct ldom_hdl *lhp, uint64_t pa);
166*2072Svn83148 
167*2072Svn83148 #ifdef	__cplusplus
168*2072Svn83148 }
169*2072Svn83148 #endif
170*2072Svn83148 
171*2072Svn83148 #endif	/* _LDMSVCS_UTILS_H */
172