xref: /onnv-gate/usr/src/uts/sun4v/sys/ds.h (revision 7697:ef43d2dd0b19)
11991Sheppo /*
21991Sheppo  * CDDL HEADER START
31991Sheppo  *
41991Sheppo  * The contents of this file are subject to the terms of the
51991Sheppo  * Common Development and Distribution License (the "License").
61991Sheppo  * You may not use this file except in compliance with the License.
71991Sheppo  *
81991Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91991Sheppo  * or http://www.opensolaris.org/os/licensing.
101991Sheppo  * See the License for the specific language governing permissions
111991Sheppo  * and limitations under the License.
121991Sheppo  *
131991Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141991Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151991Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161991Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171991Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181991Sheppo  *
191991Sheppo  * CDDL HEADER END
201991Sheppo  */
211991Sheppo 
221991Sheppo /*
23*7697SMichael.Christensen@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
241991Sheppo  * Use is subject to license terms.
251991Sheppo  */
261991Sheppo 
271991Sheppo #ifndef _DS_H
281991Sheppo #define	_DS_H
291991Sheppo 
301991Sheppo 
311991Sheppo /*
321991Sheppo  * Domain Services Client Interface
331991Sheppo  */
341991Sheppo 
351991Sheppo #ifdef __cplusplus
361991Sheppo extern "C" {
371991Sheppo #endif
381991Sheppo 
391991Sheppo typedef uint64_t	ds_svc_hdl_t;	/* opaque service handle */
401991Sheppo typedef void		*ds_cb_arg_t;	/* client specified callback arg */
411991Sheppo 
421991Sheppo #define	DS_INVALID_HDL	(0)		/* a ds handle cannot be zero */
431991Sheppo 
441991Sheppo /*
451991Sheppo  * Domain Services Versioning
461991Sheppo  */
471991Sheppo typedef struct ds_ver {
481991Sheppo 	uint16_t	major;
491991Sheppo 	uint16_t	minor;
501991Sheppo } ds_ver_t;
511991Sheppo 
521991Sheppo /*
531991Sheppo  * Domain Services Capability
541991Sheppo  *
551991Sheppo  * A DS capability is exported by a client using a unique service
561991Sheppo  * identifier string. Along with this identifier is the list of
571991Sheppo  * versions of the capability that the client supports.
581991Sheppo  */
591991Sheppo typedef struct ds_capability {
601991Sheppo 	char		*svc_id;	/* service identifier */
611991Sheppo 	ds_ver_t	*vers;		/* list of supported versions */
621991Sheppo 	int		nvers;		/* number of supported versions */
631991Sheppo } ds_capability_t;
641991Sheppo 
651991Sheppo /*
661991Sheppo  * Domain Services Client Event Callbacks
671991Sheppo  *
681991Sheppo  * A client implementing a DS capability provides a set of callbacks
691991Sheppo  * when it registers with the DS framework. The use of these callbacks
701991Sheppo  * is described below:
711991Sheppo  *
721991Sheppo  *    ds_reg_cb(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl)
731991Sheppo  *
741991Sheppo  *	    The ds_reg_cb() callback is invoked when the DS framework
751991Sheppo  *	    has successfully completed version negotiation with the
761991Sheppo  *	    remote endpoint for the capability. It provides the client
771991Sheppo  *	    with the negotiated version and a handle to use when sending
781991Sheppo  *	    data.
791991Sheppo  *
801991Sheppo  *    ds_unreg_cb(ds_cb_arg_t arg)
811991Sheppo  *
821991Sheppo  *	    The ds_unreg_cb() callback is invoked when the DS framework
831991Sheppo  *	    detects an event that causes the registered capability to
841991Sheppo  *	    become unavailable. This includes an explicit unregister
851991Sheppo  *	    message, a failure in the underlying communication transport,
861991Sheppo  *	    etc. Any such event invalidates the service handle that was
871991Sheppo  *	    received from the register callback.
881991Sheppo  *
891991Sheppo  *    ds_data_cb(ds_cb_arg_t arg, void *buf, size_t buflen)
901991Sheppo  *
911991Sheppo  *	    The ds_data_cb() callback is invoked whenever there is an
921991Sheppo  *	    incoming data message for the client to process. It provides
931991Sheppo  *	    the contents of the message along with the message length.
941991Sheppo  */
951991Sheppo typedef struct ds_clnt_ops {
961991Sheppo 	void (*ds_reg_cb)(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl);
971991Sheppo 	void (*ds_unreg_cb)(ds_cb_arg_t arg);
981991Sheppo 	void (*ds_data_cb)(ds_cb_arg_t arg, void *buf, size_t buflen);
991991Sheppo 	ds_cb_arg_t cb_arg;
1001991Sheppo } ds_clnt_ops_t;
1011991Sheppo 
1021991Sheppo /*
1031991Sheppo  * Domain Services Capability Interface
1041991Sheppo  */
1051991Sheppo extern int ds_cap_init(ds_capability_t *cap, ds_clnt_ops_t *ops);
1061991Sheppo extern int ds_cap_fini(ds_capability_t *cap);
1071991Sheppo extern int ds_cap_send(ds_svc_hdl_t hdl, void *buf, size_t buflen);
1081991Sheppo 
1091991Sheppo #ifdef __cplusplus
1101991Sheppo }
1111991Sheppo #endif
1121991Sheppo 
1131991Sheppo #endif /* _DS_H */
114