xref: /onnv-gate/usr/src/uts/common/sys/dktp/controller.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SYS_DKTP_CONTROLLER_H
28*0Sstevel@tonic-gate #define	_SYS_DKTP_CONTROLLER_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #ifdef	__cplusplus
33*0Sstevel@tonic-gate extern "C" {
34*0Sstevel@tonic-gate #endif
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate struct	ctl_ext {
37*0Sstevel@tonic-gate 	opaque_t	c_type_cookie;	/* controller info 		*/
38*0Sstevel@tonic-gate 	dev_info_t	*c_ctldip;	/* dip to controller driver	*/
39*0Sstevel@tonic-gate 	dev_info_t	*c_devdip;	/* dip to target device driver	*/
40*0Sstevel@tonic-gate 	int		c_targ;		/* device target number		*/
41*0Sstevel@tonic-gate 	int		c_blksz;	/* device unit size (secsz)	*/
42*0Sstevel@tonic-gate };
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate struct	ctl_obj {
45*0Sstevel@tonic-gate 	opaque_t		c_data;
46*0Sstevel@tonic-gate 	struct ctl_objops	*c_ops;
47*0Sstevel@tonic-gate 	struct ctl_ext		*c_ext;
48*0Sstevel@tonic-gate 	struct ctl_ext		c_extblk;	/* extended blk defined	*/
49*0Sstevel@tonic-gate 						/* for easy of alloc	*/
50*0Sstevel@tonic-gate };
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate struct	ctl_objops {
53*0Sstevel@tonic-gate 	struct 	cmpkt *(*c_pktalloc)(opaque_t, int (*)(caddr_t), caddr_t);
54*0Sstevel@tonic-gate 	void	(*c_pktfree)(opaque_t, struct cmpkt *);
55*0Sstevel@tonic-gate 	struct 	cmpkt *(*c_memsetup)(opaque_t, struct cmpkt *, struct buf *,
56*0Sstevel@tonic-gate 	    int (*)(caddr_t), caddr_t);
57*0Sstevel@tonic-gate 	void	(*c_memfree)(opaque_t, struct cmpkt *);
58*0Sstevel@tonic-gate 	struct 	cmpkt *(*c_iosetup)(opaque_t, struct cmpkt *);
59*0Sstevel@tonic-gate 	int	(*c_transport)(opaque_t, struct cmpkt *);
60*0Sstevel@tonic-gate 	int	(*c_reset)(opaque_t, int);
61*0Sstevel@tonic-gate 	int	(*c_abort)(opaque_t, struct cmpkt *);
62*0Sstevel@tonic-gate 	int	(*c_getcap)(opaque_t, char *, int);
63*0Sstevel@tonic-gate 	int	(*c_setcap)(opaque_t, char *, int);
64*0Sstevel@tonic-gate 	int	(*c_ioctl)(opaque_t, int, intptr_t, int);
65*0Sstevel@tonic-gate 	void 	*c_resv[2];
66*0Sstevel@tonic-gate };
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #define	CTL_DIP_CTL(X) (((struct ctl_obj *)(X))->c_ext->c_ctldip)
69*0Sstevel@tonic-gate #define	CTL_DIP_DEV(X) (((struct ctl_obj *)(X))->c_ext->c_devdip)
70*0Sstevel@tonic-gate #define	CTL_GET_TYPE(X) (((struct ctl_obj *)(X))->c_ext->c_type_cookie)
71*0Sstevel@tonic-gate #define	CTL_GET_LKARG(X) (((struct ctl_obj *)(X))->c_ext->c_lkarg)
72*0Sstevel@tonic-gate #define	CTL_GET_TARG(X) (((struct ctl_obj *)(X))->c_ext->c_targ)
73*0Sstevel@tonic-gate #define	CTL_GET_BLKSZ(X) (((struct ctl_obj *)(X))->c_ext->c_blksz)
74*0Sstevel@tonic-gate 
75*0Sstevel@tonic-gate #define	CTL_PKTALLOC(X, callback, arg) \
76*0Sstevel@tonic-gate 	(*((struct ctl_obj *)(X))->c_ops->c_pktalloc) \
77*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (callback), (arg))
78*0Sstevel@tonic-gate #define	CTL_PKTFREE(X, pktp) \
79*0Sstevel@tonic-gate 	(*((struct ctl_obj *)(X))->c_ops->c_pktfree) \
80*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp))
81*0Sstevel@tonic-gate #define	CTL_MEMSETUP(X, pktp, bp, callback, arg) \
82*0Sstevel@tonic-gate 	(*((struct ctl_obj *)(X))->c_ops->c_memsetup) \
83*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp), (bp), (callback), (arg))
84*0Sstevel@tonic-gate #define	CTL_MEMFREE(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_memfree) \
85*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp))
86*0Sstevel@tonic-gate #define	CTL_IOSETUP(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_iosetup) \
87*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp))
88*0Sstevel@tonic-gate #define	CTL_TRANSPORT(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_transport) \
89*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp))
90*0Sstevel@tonic-gate #define	CTL_ABORT(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_abort) \
91*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (pktp))
92*0Sstevel@tonic-gate #define	CTL_RESET(X, level) (*((struct ctl_obj *)(X))->c_ops->c_reset) \
93*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (level))
94*0Sstevel@tonic-gate #define	CTL_IOCTL(X, cmd, arg, flag) \
95*0Sstevel@tonic-gate 	(*((struct ctl_obj *)(X))->c_ops->c_ioctl) \
96*0Sstevel@tonic-gate 	(((struct ctl_obj *)(X))->c_data, (cmd), (arg), (flag))
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate /*	transport return code						*/
99*0Sstevel@tonic-gate #define	CTL_SEND_SUCCESS	0
100*0Sstevel@tonic-gate #define	CTL_SEND_FAILURE	1
101*0Sstevel@tonic-gate #define	CTL_SEND_BUSY		2
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate #ifdef	__cplusplus
104*0Sstevel@tonic-gate }
105*0Sstevel@tonic-gate #endif
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate #endif	/* _SYS_DKTP_CONTROLLER_H */
108