Print this page
XXXX introduce drv_sectohz
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/scsi/targets/sgendef.h
+++ new/usr/src/uts/common/sys/scsi/targets/sgendef.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright Siemens 1999
29 29 * All rights reserved.
30 30 */
31 31
32 32 #ifndef _SYS_SCSI_TARGETS_SGENDEF_H
33 33 #define _SYS_SCSI_TARGETS_SGENDEF_H
34 34
35 35 #pragma ident "%Z%%M% %I% %E% SMI"
36 36
37 37 #include <sys/types.h>
38 38 #include <sys/kstat.h>
39 39 #include <sys/condvar.h>
40 40 #include <sys/mutex.h>
41 41 #include <sys/buf.h>
42 42 #include <sys/scsi/scsi.h>
43 43
44 44 #ifdef __cplusplus
45 45 extern "C" {
46 46 #endif
47 47
48 48 #define SGEN_IOC (('S' << 16) | ('G' << 8))
49 49 #define SGEN_IOC_READY (SGEN_IOC | 0x01)
50 50 #define SGEN_IOC_DIAG (SGEN_IOC | 0x02)
51 51
52 52 #if defined(_KERNEL)
53 53
54 54 #define SGEN_DIAG1 ((1 << 8) | CE_CONT)
55 55 #define SGEN_DIAG2 ((2 << 8) | CE_CONT)
56 56 #define SGEN_DIAG3 ((3 << 8) | CE_CONT)
57 57
58 58 struct sgen_errstats {
59 59 kstat_named_t sgen_trans_err; /* error trying to transport pkt */
60 60 kstat_named_t sgen_restart; /* command restart attempted */
61 61 kstat_named_t sgen_incmp_err; /* command failed to complete */
62 62 kstat_named_t sgen_autosen_rcv; /* autosense occurred */
63 63 kstat_named_t sgen_autosen_bad; /* autosense data looks malformed */
64 64 kstat_named_t sgen_sense_rcv; /* sense fetch occurred */
65 65 kstat_named_t sgen_sense_bad; /* sense data looks malformed */
66 66 kstat_named_t sgen_recov_err; /* sense key is KEY_RECOVERABLE */
67 67 kstat_named_t sgen_nosen_err; /* sense key is KEY_NO_SENSE */
68 68 kstat_named_t sgen_unrecov_err; /* sense key indicates other err */
69 69 };
70 70
71 71 typedef struct sgen_state {
72 72 struct scsi_device *sgen_scsidev; /* pointer to scsi_device */
73 73 struct uscsi_cmd *sgen_ucmd; /* uscsi command struct */
74 74 struct buf *sgen_cmdbuf; /* xfer buffer */
75 75 struct scsi_pkt *sgen_cmdpkt; /* scsi packet for command */
76 76 kcondvar_t sgen_cmdbuf_cv; /* cv for cmdbuf */
77 77 int sgen_flags; /* see SGEN_FL_* */
78 78 struct scsi_pkt *sgen_rqspkt; /* request sense packet */
79 79 struct buf *sgen_rqsbuf; /* request sense xfer buffer */
80 80 char *sgen_rqs_sen; /* sense buffer */
81 81 int sgen_arq_enabled; /* auto request sense enabled */
82 82 int sgen_diag; /* diagnostic output level */
83 83 timeout_id_t sgen_restart_timeid; /* timeout for sgen_restart */
84 84 kstat_t *sgen_kstats; /* for error statistics */
85 85 } sgen_state_t;
86 86
87 87 /*
88 88 * Convenience accessors for sgen_state_t.
89 89 */
90 90 #define sgen_mutex sgen_scsidev->sd_mutex
91 91 #define sgen_devinfo sgen_scsidev->sd_dev
92 92 #define sgen_scsiaddr sgen_scsidev->sd_address
93 93 #define sgen_sense sgen_scsidev->sd_sense
94 94
95 95 /*
96 96 * sgen_flags accessors/mutators
97 97 */
98 98 #define SGEN_FL_OPEN 0x01 /* instance is open */
99 99 #define SGEN_FL_SUSP 0x02 /* instance suspended */
100 100 #define SGEN_FL_BUSY 0x04 /* command buffer busy */
101 101 #define SGEN_FL_EXCL 0x08 /* exclusive open */
102 102
103 103 #define SGEN_SET_OPEN(stp) \
104 104 (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_OPEN)
105 105 #define SGEN_CLR_OPEN(stp) \
106 106 (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_OPEN)
107 107 #define SGEN_IS_OPEN(stp) \
108 108 ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_OPEN) == SGEN_FL_OPEN)
109 109
110 110 #define SGEN_SET_SUSP(stp) \
111 111 (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_SUSP)
112 112 #define SGEN_CLR_SUSP(stp) \
113 113 (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_SUSP)
114 114 #define SGEN_IS_SUSP(stp) \
115 115 ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_SUSP) == SGEN_FL_SUSP)
116 116
117 117 #define SGEN_SET_BUSY(stp) \
118 118 (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_BUSY)
119 119 #define SGEN_CLR_BUSY(stp) \
120 120 (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_BUSY)
121 121 #define SGEN_IS_BUSY(stp) \
122 122 ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_BUSY) == SGEN_FL_BUSY)
123 123
124 124 #define SGEN_SET_EXCL(stp) \
125 125 (((sgen_state_t *)(stp))->sgen_flags |= SGEN_FL_EXCL)
126 126 #define SGEN_CLR_EXCL(stp) \
127 127 (((sgen_state_t *)(stp))->sgen_flags &= ~SGEN_FL_EXCL)
128 128 #define SGEN_IS_EXCL(stp) \
129 129 ((((sgen_state_t *)(stp))->sgen_flags & SGEN_FL_EXCL) == SGEN_FL_EXCL)
130 130
131 131 /*
132 132 * These structures form the driver's database of binding information.
133 133 * Inquiry strings and device types from the inquiry-config-list and
134 134 * device-type-config-list properties are stored.
135 135 */
136 136 typedef struct sgen_inq_node {
137 137 char *node_vendor; /* up to 8 character vendor */
138 138 char *node_product; /* up to 16 character product */
139 139 struct sgen_inq_node *node_next;
140 140 } sgen_inq_node_t;
141 141
142 142 typedef struct sgen_type_node {
143 143 uchar_t node_type; /* SCSI device type */
144 144 struct sgen_type_node *node_next;
145 145 } sgen_type_node_t;
146 146
147 147 struct sgen_binddb {
148 148 int sdb_init; /* has this been initialized? */
↓ open down ↓ |
148 lines elided |
↑ open up ↑ |
149 149 kmutex_t sdb_lock; /* protects this structure */
150 150 sgen_inq_node_t *sdb_inq_nodes; /* inquiry binding nodes */
151 151 sgen_type_node_t *sdb_type_nodes; /* dev-type binding nodes */
152 152 };
153 153
154 154 #define SGEN_ESTIMATED_NUM_DEVS 4 /* for soft-state allocation */
155 155
156 156 /*
157 157 * Time to wait before a retry for commands returning Busy Status
158 158 */
159 -#define SGEN_BSY_TIMEOUT (drv_usectohz(5 * 1000000))
159 +#define SGEN_BSY_TIMEOUT drv_sectohz(5)
160 160 #define SGEN_IO_TIME 60 /* seconds */
161 161
162 162 /*
163 163 * sgen_callback action codes
164 164 */
165 165 #define COMMAND_DONE 0 /* command completed, biodone it */
166 166 #define COMMAND_DONE_ERROR 1 /* command completed, indicate error */
167 167 #define FETCH_SENSE 2 /* CHECK CONDITION, so initiate sense */
168 168 /* fetch */
169 169
170 170 #define SET_BP_ERROR(bp, err) bioerror(bp, err);
171 171
172 172 #endif /* defined(_KERNEL) */
173 173
174 174 #ifdef __cplusplus
175 175 }
176 176 #endif
177 177
178 178 #endif /* _SYS_SCSI_TARGETS_SGENDEF_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX