1*25cf1a30Sjl /*
2*25cf1a30Sjl  * CDDL HEADER START
3*25cf1a30Sjl  *
4*25cf1a30Sjl  * The contents of this file are subject to the terms of the
5*25cf1a30Sjl  * Common Development and Distribution License (the "License").
6*25cf1a30Sjl  * You may not use this file except in compliance with the License.
7*25cf1a30Sjl  *
8*25cf1a30Sjl  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*25cf1a30Sjl  * or http://www.opensolaris.org/os/licensing.
10*25cf1a30Sjl  * See the License for the specific language governing permissions
11*25cf1a30Sjl  * and limitations under the License.
12*25cf1a30Sjl  *
13*25cf1a30Sjl  * When distributing Covered Code, include this CDDL HEADER in each
14*25cf1a30Sjl  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*25cf1a30Sjl  * If applicable, add the following below this CDDL HEADER, with the
16*25cf1a30Sjl  * fields enclosed by brackets "[]" replaced with your own identifying
17*25cf1a30Sjl  * information: Portions Copyright [yyyy] [name of copyright owner]
18*25cf1a30Sjl  *
19*25cf1a30Sjl  * CDDL HEADER END
20*25cf1a30Sjl  */
21*25cf1a30Sjl /*
22*25cf1a30Sjl  * All Rights Reserved, Copyright (c) FUJITSU LIMITED 2005
23*25cf1a30Sjl  */
24*25cf1a30Sjl 
25*25cf1a30Sjl #ifndef _SCFDSCPIF_H
26*25cf1a30Sjl #define	_SCFDSCPIF_H
27*25cf1a30Sjl 
28*25cf1a30Sjl #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*25cf1a30Sjl 
30*25cf1a30Sjl #ifdef __cplusplus
31*25cf1a30Sjl extern "C" {
32*25cf1a30Sjl #endif
33*25cf1a30Sjl 
34*25cf1a30Sjl typedef uint32_t mkey_t;	/* Data type for mailbox key */
35*25cf1a30Sjl typedef uint32_t target_id_t;	/* Target ID specifying the peer */
36*25cf1a30Sjl 
37*25cf1a30Sjl /*
38*25cf1a30Sjl  * Mailbox event types are defined as below.
39*25cf1a30Sjl  */
40*25cf1a30Sjl typedef enum {
41*25cf1a30Sjl 	SCF_MB_CONN_OK,		/* Connection OK event */
42*25cf1a30Sjl 	SCF_MB_MSG_DATA,	/* A new message has received */
43*25cf1a30Sjl 	SCF_MB_SPACE,		/* Mailbox has space */
44*25cf1a30Sjl 	SCF_MB_DISC_ERROR	/* Disconnect error */
45*25cf1a30Sjl } scf_event_t;
46*25cf1a30Sjl 
47*25cf1a30Sjl #define	SCF_EVENT_PRI	DDI_SOFTINT_LOW	/* Event handler priority */
48*25cf1a30Sjl 
49*25cf1a30Sjl /*
50*25cf1a30Sjl  * A scatter/gather data structure used for sending/receiving mailbox
51*25cf1a30Sjl  * messages.
52*25cf1a30Sjl  */
53*25cf1a30Sjl typedef struct mscat_gath {
54*25cf1a30Sjl 	caddr_t		msc_dptr; /* pointer to the data buffer */
55*25cf1a30Sjl 	uint32_t	msc_len;  /* Length of data in the data buffer */
56*25cf1a30Sjl } mscat_gath_t;
57*25cf1a30Sjl 
58*25cf1a30Sjl 
59*25cf1a30Sjl /*
60*25cf1a30Sjl  * Mailbox Flush types.
61*25cf1a30Sjl  */
62*25cf1a30Sjl typedef enum {
63*25cf1a30Sjl 	MB_FLUSH_SEND = 0x01,	/* Flush all messages on the send side */
64*25cf1a30Sjl 	MB_FLUSH_RECEIVE,	/* Flush all messages on the recieve side */
65*25cf1a30Sjl 	MB_FLUSH_ALL		/* Flush messages on the both sides */
66*25cf1a30Sjl } mflush_type_t;
67*25cf1a30Sjl 
68*25cf1a30Sjl int scf_mb_init(target_id_t target_id, mkey_t mkey,
69*25cf1a30Sjl     void (*event_handler)(scf_event_t mevent, void *arg), void *arg);
70*25cf1a30Sjl 
71*25cf1a30Sjl int scf_mb_fini(target_id_t target_id, mkey_t mkey);
72*25cf1a30Sjl 
73*25cf1a30Sjl int scf_mb_putmsg(target_id_t target_id, mkey_t mkey, uint32_t data_len,
74*25cf1a30Sjl     uint32_t num_sg, mscat_gath_t *sgp, clock_t timeout);
75*25cf1a30Sjl 
76*25cf1a30Sjl int scf_mb_canget(target_id_t target_id, mkey_t mkey, uint32_t *data_lenp);
77*25cf1a30Sjl 
78*25cf1a30Sjl int scf_mb_getmsg(target_id_t target_id, mkey_t mkey, uint32_t data_len,
79*25cf1a30Sjl     uint32_t num_sg, mscat_gath_t *sgp, clock_t timeout);
80*25cf1a30Sjl 
81*25cf1a30Sjl int scf_mb_flush(target_id_t target_id, uint32_t key, mflush_type_t flush_type);
82*25cf1a30Sjl 
83*25cf1a30Sjl int scf_mb_ctrl(target_id_t target_id, uint32_t key, uint32_t op, void *arg);
84*25cf1a30Sjl 
85*25cf1a30Sjl 
86*25cf1a30Sjl /*
87*25cf1a30Sjl  * The following are the operations defined for scf_mb_ctrl().
88*25cf1a30Sjl  */
89*25cf1a30Sjl 
90*25cf1a30Sjl /*
91*25cf1a30Sjl  * Return the maximum message length which could be received/transmitted
92*25cf1a30Sjl  * on the specified mailbox. The value is returned via the argument(arg),
93*25cf1a30Sjl  * which will be treated as a pointer to an uint32_t.
94*25cf1a30Sjl  */
95*25cf1a30Sjl #define	SCF_MBOP_MAXMSGSIZE 0x00000001
96*25cf1a30Sjl 
97*25cf1a30Sjl #define	DSCP_KEY	('D' << 24 | 'S' << 16 | 'C' << 8 | 'P')
98*25cf1a30Sjl #define	DKMD_KEY	('D' << 24 | 'K' << 16 | 'M' << 8 | 'D')
99*25cf1a30Sjl 
100*25cf1a30Sjl #ifdef	__cplusplus
101*25cf1a30Sjl }
102*25cf1a30Sjl #endif
103*25cf1a30Sjl 
104*25cf1a30Sjl #endif	/* _SCFDSCPIF_H */
105