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