xref: /titanic_41/usr/src/uts/common/sys/dktp/dadk.h (revision 6185db853e024a486ff8837e6784dd290d866112)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_DKTP_DADK_H
27 #define	_SYS_DKTP_DADK_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/dktp/tgcom.h>
36 
37 struct	dadk {
38 	struct tgdk_ext	*dad_extp;	/* back pointer to ext data	*/
39 	struct scsi_device *dad_sd;	/* back pointer to SCSI_DEVICE 	*/
40 
41 	struct  tgdk_geom dad_logg;	/* logical disk geometry 	*/
42 	struct  tgdk_geom dad_phyg;	/* physical disk geometry 	*/
43 
44 	unsigned dad_rmb : 1;		/* removable device		*/
45 	unsigned dad_rdonly : 1;	/* read only device		*/
46 	unsigned dad_cdrom : 1;		/* cdrom device			*/
47 	unsigned dad_noflush : 1;	/* flush cmd unsupported	*/
48 	unsigned dad_wce : 1;		/* disk write cache enabled	*/
49 	unsigned dad_resv : 3;
50 	unsigned char dad_type;		/* device type			*/
51 	unsigned char dad_ctype;	/* controller type 		*/
52 
53 	short	 dad_secshf;
54 	short	 dad_blkshf;
55 
56 	opaque_t dad_bbhobjp;		/* bbh object ptr		*/
57 	opaque_t dad_flcobjp;		/* flow control object ptr	*/
58 	opaque_t dad_ctlobjp;		/* controller object ptr	*/
59 	struct	tgcom_obj dad_com;	/* com object for flowctrl	*/
60 	enum dkio_state dad_iostate;	/* ejected/inserted		*/
61 	kmutex_t	dad_mutex;	/* protect dad_state		*/
62 	kcondvar_t	dad_state_cv;	/* condition variable for state */
63 	uchar_t		dad_thread_cnt;	/* reference count on removable	*/
64 					/* - disk state watcher thread	*/
65 	kstat_t		*dad_errstats;	/* error stats			*/
66 };
67 
68 #define	DAD_SECSIZ	dad_phyg.g_secsiz
69 
70 /*
71  * Local definitions, for clarity of code
72  */
73 
74 /*
75  * Parameters
76  */
77 #define	DADK_BSY_TIMEOUT	(drv_usectohz(5 * 1000000))
78 #define	DADK_IO_TIME		35
79 #define	DADK_FLUSH_CACHE_TIME	60
80 #define	DADK_RETRY_COUNT	5
81 #define	DADK_SILENT		1
82 
83 #define	PKT2DADK(pktp)	((struct dadk *)(pktp)->cp_dev_private)
84 
85 /*
86  * packet action codes
87  */
88 #define	COMMAND_DONE		0
89 #define	COMMAND_DONE_ERROR	1
90 #define	QUE_COMMAND		2
91 #define	QUE_SENSE		3
92 #define	JUST_RETURN		4
93 
94 typedef	struct	dadk_errstats {
95 	kstat_named_t dadk_softerrs;		/* Collecting Softerrs */
96 	kstat_named_t dadk_harderrs;		/* Collecting harderrs */
97 	kstat_named_t dadk_transerrs;		/* Collecting Transfer errs */
98 	kstat_named_t dadk_model;		/* model # of the disk */
99 	kstat_named_t dadk_revision;		/* The disk revision */
100 	kstat_named_t dadk_serial;		/* The disk serial number */
101 	kstat_named_t dadk_capacity;		/* Capacity of the disk */
102 	kstat_named_t dadk_rq_media_err;	/* Any media err seen */
103 	kstat_named_t dadk_rq_ntrdy_err;	/* Not ready errs */
104 	kstat_named_t dadk_rq_nodev_err;	/* No device errs */
105 	kstat_named_t dadk_rq_recov_err;	/* Recovered errs */
106 	kstat_named_t dadk_rq_illrq_err;	/* Illegal requests */
107 } dadk_errstats_t;
108 
109 int dadk_init(opaque_t objp, opaque_t devp, opaque_t flcobjp,
110     opaque_t queobjp, opaque_t bbhobjp, void *lkarg);
111 int dadk_free(struct tgdk_obj *dkobjp);
112 int dadk_probe(opaque_t objp, int kmsflg);
113 int dadk_attach(opaque_t objp);
114 int dadk_open(opaque_t objp, int flag);
115 int dadk_close(opaque_t objp);
116 int dadk_ioctl(opaque_t objp, dev_t dev, int cmd, intptr_t arg,
117     int flag, cred_t *cred_p, int *rval_p);
118 int dadk_flushdone(struct buf *bp);
119 int dadk_strategy(opaque_t objp, struct buf *bp);
120 int dadk_setgeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
121 int dadk_getgeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
122 struct tgdk_iob *dadk_iob_alloc(opaque_t objp, daddr_t blkno,
123     ssize_t xfer, int kmsflg);
124 int dadk_iob_free(opaque_t objp, struct tgdk_iob *iobp);
125 caddr_t dadk_iob_htoc(opaque_t objp, struct tgdk_iob *iobp);
126 caddr_t dadk_iob_xfer(opaque_t objp, struct tgdk_iob *iobp, int rw);
127 int dadk_dump(opaque_t objp, struct buf *bp);
128 int dadk_getphygeom(opaque_t objp, struct tgdk_geom *dkgeom_p);
129 int dadk_set_bbhobj(opaque_t objp, opaque_t bbhobjp);
130 int dadk_check_media(opaque_t objp, int *state);
131 static void dadk_watch_thread(struct dadk *dadkp);
132 int dadk_inquiry(opaque_t objp, opaque_t *inqpp);
133 void dadk_cleanup(struct tgdk_obj *dkobjp);
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif	/* _SYS_DKTP_DADK_H */
140