xref: /titanic_51/usr/src/uts/common/sys/dktp/controller.h (revision a31148363f598def767ac48c5d82e1572e44b935)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 struct	ctl_ext {
37 	opaque_t	c_type_cookie;	/* controller info 		*/
38 	dev_info_t	*c_ctldip;	/* dip to controller driver	*/
39 	dev_info_t	*c_devdip;	/* dip to target device driver	*/
40 	int		c_targ;		/* device target number		*/
41 	int		c_blksz;	/* device unit size (secsz)	*/
42 };
43 
44 struct	ctl_obj {
45 	opaque_t		c_data;
46 	struct ctl_objops	*c_ops;
47 	struct ctl_ext		*c_ext;
48 	struct ctl_ext		c_extblk;	/* extended blk defined	*/
49 						/* for easy of alloc	*/
50 };
51 
52 struct	ctl_objops {
53 	struct 	cmpkt *(*c_pktalloc)(opaque_t, int (*)(caddr_t), caddr_t);
54 	void	(*c_pktfree)(opaque_t, struct cmpkt *);
55 	struct 	cmpkt *(*c_memsetup)(opaque_t, struct cmpkt *, struct buf *,
56 	    int (*)(caddr_t), caddr_t);
57 	void	(*c_memfree)(opaque_t, struct cmpkt *);
58 	struct 	cmpkt *(*c_iosetup)(opaque_t, struct cmpkt *);
59 	int	(*c_transport)(opaque_t, struct cmpkt *);
60 	int	(*c_reset)(opaque_t, int);
61 	int	(*c_abort)(opaque_t, struct cmpkt *);
62 	int	(*c_getcap)(opaque_t, char *, int);
63 	int	(*c_setcap)(opaque_t, char *, int);
64 	int	(*c_ioctl)(opaque_t, int, intptr_t, int);
65 	void 	*c_resv[2];
66 };
67 
68 #define	CTL_DIP_CTL(X) (((struct ctl_obj *)(X))->c_ext->c_ctldip)
69 #define	CTL_DIP_DEV(X) (((struct ctl_obj *)(X))->c_ext->c_devdip)
70 #define	CTL_GET_TYPE(X) (((struct ctl_obj *)(X))->c_ext->c_type_cookie)
71 #define	CTL_GET_LKARG(X) (((struct ctl_obj *)(X))->c_ext->c_lkarg)
72 #define	CTL_GET_TARG(X) (((struct ctl_obj *)(X))->c_ext->c_targ)
73 #define	CTL_GET_BLKSZ(X) (((struct ctl_obj *)(X))->c_ext->c_blksz)
74 
75 #define	CTL_PKTALLOC(X, callback, arg) \
76 	(*((struct ctl_obj *)(X))->c_ops->c_pktalloc) \
77 	(((struct ctl_obj *)(X))->c_data, (callback), (arg))
78 #define	CTL_PKTFREE(X, pktp) \
79 	(*((struct ctl_obj *)(X))->c_ops->c_pktfree) \
80 	(((struct ctl_obj *)(X))->c_data, (pktp))
81 #define	CTL_MEMSETUP(X, pktp, bp, callback, arg) \
82 	(*((struct ctl_obj *)(X))->c_ops->c_memsetup) \
83 	(((struct ctl_obj *)(X))->c_data, (pktp), (bp), (callback), (arg))
84 #define	CTL_MEMFREE(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_memfree) \
85 	(((struct ctl_obj *)(X))->c_data, (pktp))
86 #define	CTL_IOSETUP(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_iosetup) \
87 	(((struct ctl_obj *)(X))->c_data, (pktp))
88 #define	CTL_TRANSPORT(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_transport) \
89 	(((struct ctl_obj *)(X))->c_data, (pktp))
90 #define	CTL_ABORT(X, pktp) (*((struct ctl_obj *)(X))->c_ops->c_abort) \
91 	(((struct ctl_obj *)(X))->c_data, (pktp))
92 #define	CTL_RESET(X, level) (*((struct ctl_obj *)(X))->c_ops->c_reset) \
93 	(((struct ctl_obj *)(X))->c_data, (level))
94 #define	CTL_IOCTL(X, cmd, arg, flag) \
95 	(*((struct ctl_obj *)(X))->c_ops->c_ioctl) \
96 	(((struct ctl_obj *)(X))->c_data, (cmd), (arg), (flag))
97 
98 /*	transport return code						*/
99 #define	CTL_SEND_SUCCESS	0
100 #define	CTL_SEND_FAILURE	1
101 #define	CTL_SEND_BUSY		2
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _SYS_DKTP_CONTROLLER_H */
108