xref: /titanic_44/usr/src/uts/sun4v/sys/ds.h (revision c651b32e568cbf9b715a127805fe1cba321be5b0)
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 #ifndef _DS_H
28 #define	_DS_H
29 
30 
31 /*
32  * Domain Services Client Interface
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 typedef uint64_t	ds_svc_hdl_t;	/* opaque service handle */
40 typedef void		*ds_cb_arg_t;	/* client specified callback arg */
41 
42 #define	DS_INVALID_HDL	(0)		/* a ds handle cannot be zero */
43 
44 /*
45  * Domain Services Versioning
46  */
47 typedef struct ds_ver {
48 	uint16_t	major;
49 	uint16_t	minor;
50 } ds_ver_t;
51 
52 /*
53  * Domain Services Capability
54  *
55  * A DS capability is exported by a client using a unique service
56  * identifier string. Along with this identifier is the list of
57  * versions of the capability that the client supports.
58  */
59 typedef struct ds_capability {
60 	char		*svc_id;	/* service identifier */
61 	ds_ver_t	*vers;		/* list of supported versions */
62 	int		nvers;		/* number of supported versions */
63 } ds_capability_t;
64 
65 /*
66  * Domain Services Client Event Callbacks
67  *
68  * A client implementing a DS capability provides a set of callbacks
69  * when it registers with the DS framework. The use of these callbacks
70  * is described below:
71  *
72  *    ds_reg_cb(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl)
73  *
74  *	    The ds_reg_cb() callback is invoked when the DS framework
75  *	    has successfully completed version negotiation with the
76  *	    remote endpoint for the capability. It provides the client
77  *	    with the negotiated version and a handle to use when sending
78  *	    data.
79  *
80  *    ds_unreg_cb(ds_cb_arg_t arg)
81  *
82  *	    The ds_unreg_cb() callback is invoked when the DS framework
83  *	    detects an event that causes the registered capability to
84  *	    become unavailable. This includes an explicit unregister
85  *	    message, a failure in the underlying communication transport,
86  *	    etc. Any such event invalidates the service handle that was
87  *	    received from the register callback.
88  *
89  *    ds_data_cb(ds_cb_arg_t arg, void *buf, size_t buflen)
90  *
91  *	    The ds_data_cb() callback is invoked whenever there is an
92  *	    incoming data message for the client to process. It provides
93  *	    the contents of the message along with the message length.
94  */
95 typedef struct ds_clnt_ops {
96 	void (*ds_reg_cb)(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl);
97 	void (*ds_unreg_cb)(ds_cb_arg_t arg);
98 	void (*ds_data_cb)(ds_cb_arg_t arg, void *buf, size_t buflen);
99 	ds_cb_arg_t cb_arg;
100 } ds_clnt_ops_t;
101 
102 /*
103  * Domain Services Capability Interface
104  */
105 extern int ds_cap_init(ds_capability_t *cap, ds_clnt_ops_t *ops);
106 extern int ds_cap_fini(ds_capability_t *cap);
107 extern int ds_cap_send(ds_svc_hdl_t hdl, void *buf, size_t buflen);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _DS_H */
114