xref: /titanic_52/usr/src/cmd/fm/modules/sun4v/etm/etm_iosvc.h (revision 25351652d920ae27c5a56c199da581033ce763f6)
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  * etm_iosvc.h
29  *
30  * Header file of the support for io service ldom
31  *
32  */
33 
34 #ifndef _ETM_IO_SVC_H
35 #define	_ETM_IO_SVC_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * ------------------------------ includes -----------------------------------
43  */
44 
45 #include <sys/fm/protocol.h>
46 #include <sys/libds.h>
47 #include <sys/fm/ldom.h>
48 #include <fm/fmd_api.h>
49 #include "etm_xport_api.h"
50 #include "etm_etm_proto.h"
51 
52 #include <libnvpair.h>
53 
54 #include <pthread.h>
55 
56 #define	FORWARDING_FAULTS_TO_CONTROL 0	/* not to forward faults to control */
57 #define	ASYNC_EVENT_Q_SIZE 	100	/* size of the async event q */
58 #define	NUM_OF_ROOT_DOMAINS 	8	/* size of iosvc_list structure array */
59 #define	MAXLEN 			0x6000	/* max size of an FMA event */
60 #define	FMD_EVN_TTL		"__ttl"	/* name-value pair for ev_ttl */
61 
62 typedef enum {
63 
64 	ETM_ASYNC_EVENT_TOO_LOW = 0,	/* range check place holder */
65 	ETM_ASYNC_EVENT_LDOM_BIND,	/* async event type: ldom event */
66 	ETM_ASYNC_EVENT_LDOM_UNBIND,	/* async event type: ldom event */
67 	ETM_ASYNC_EVENT_LDOM_ADD,	/* async event type: ldom event */
68 	ETM_ASYNC_EVENT_LDOM_REMOVE,	/* async event type: ldom event */
69 	ETM_ASYNC_EVENT_DS_REG_CB,	/* async event type: DS reg callback */
70 	ETM_ASYNC_EVENT_DS_UNREG_CB,	/* async event type: DS unreg cllback */
71 	ETM_ASYNC_EVENT_TOO_BIG		/* range check place holder */
72 
73 } etm_async_event_type_t;		/* async etm event type */
74 
75 
76 typedef enum {
77 
78 	SP_MSG = 0,			/* msg for ereports from SP */
79 	FMD_XPRT_OTHER_MSG,		/* fmd all other xprt msg */
80 	FMD_XPRT_RUN_MSG		/* fmd xprt run msg */
81 
82 } etm_pack_msg_type_t;			/* msg type for etm_pack_ds_msg() */
83 
84 typedef struct etm_iosvc_q_ele {
85 
86 	char			*msg;		/* ptr to ETM io svc msg */
87 	size_t			msg_size;	/* sizeof ETM io svc msg */
88 	uint_t			ckpt_flag;	/* checkpoint flags */
89 
90 	struct etm_iosvc_q_ele	*msg_nextp;	/* PRIVATE - next ele ptr */
91 
92 } etm_iosvc_q_ele_t;			/* out-going etm msg queue element */
93 
94 
95 
96 typedef struct etm_iosvc {
97 	char 		ldom_name[MAX_LDOM_NAME];	/* ldom_name */
98 	pthread_cond_t	msg_q_cv;	/* nudges send msg func more to send  */
99 	pthread_mutex_t	msg_q_lock;	/* protects iosvc msg Q */
100 	etm_iosvc_q_ele_t
101 			*msg_q_head;
102 					/* ptr to cur head of the msg Q */
103 	etm_iosvc_q_ele_t
104 			*msg_q_tail;
105 					/* ptr to cur tail of the msg Q */
106 	uint32_t	msg_q_cur_len;
107 					/* cur len of the msg Q */
108 	uint32_t	msg_q_max_len;
109 					/* max len of the msg Q */
110 	uint32_t	cur_send_xid;	/* current trnsaction id for io svc q */
111 	uint32_t	xid_posted_ev;	/* xid of last event posted ok to fmd */
112 	ds_hdl_t	ds_hdl;		/* the ds hdl for this io svc ldom */
113 	fmd_xprt_t	*fmd_xprt;	/* fmd transport layer handle */
114 	pthread_t	send_tid;	/* tid of sending msgs 2 remote iosvc */
115 	pthread_t	recv_tid;	/* tid of recving msgs frm rmte iosvc */
116 	pthread_cond_t	msg_ack_cv;	/* ready 2 send nxt or resend cur one */
117 	pthread_mutex_t	msg_ack_lock;	/* protects msg_ack_cv */
118 	int		thr_is_dying;	/* flag to exit the thread */
119 	uint32_t	start_sending_Q;	/* flag to strt sending msg Q */
120 	uint32_t	ack_ok;		/* indicate if the ACK has come  */
121 } etm_iosvc_t;		/* structure to support io service ldom */
122 
123 
124 typedef struct etm_async_event_ele {
125 
126 	etm_async_event_type_t	event_type;	/* async event type */
127 	ds_hdl_t		ds_hdl;		/* ds handle */
128 	char 			ldom_name[MAX_LDOM_NAME];	/* ldom name */
129 	ds_domain_hdl_t		dhdl;		/* ldom handle */
130 
131 	struct etm_async_event_ele	*async_event_nextp;
132 						/* next ele ptr */
133 
134 } etm_async_event_ele_t;	/* etm async event queue element */
135 
136 
137 /*
138  * This function
139  */
140 extern etm_iosvc_t *etm_iosvc_lookup(fmd_hdl_t *fmd_hdl, char *ldom_name,
141     ds_hdl_t ds_hdl, boolean_t iosvc_create);
142 
143 
144 /*
145  * extern etm_iosvc_t *etm_lookup_iosvc(char *ldom_name);
146  */
147 extern int etm_pack_ds_msg(fmd_hdl_t *fmd_hdl, etm_iosvc_t *iosvc,
148     etm_proto_v1_ev_hdr_t *ev_hdrp, size_t hdr_sz, nvlist_t *evp,
149     etm_pack_msg_type_t msg_type, uint_t ckpt_opt);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif /* _ETM_IO_SVC_H */
156