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