Print this page
NEX-6018 Return of the walking dead idm_refcnt_wait_ref comstar threads
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
re #12375 rb4141 Create ALUA Support on NexentaStor; Failover causes loss of storage
re #7936 rb3706 Support for COMSTAR/OEM
re #8002 rb3706 Allow setting iSCSI vendor ID via stmf_sbd.conf
re #11454 rb3750 Fix inconsistent vid/pid in stmf
Re #6790 backspace should perform delete on console
VAAI (XXX ATS support for COMSTAR, YYY Block-copy support for COMSTAR)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/stmf.h
+++ new/usr/src/uts/common/sys/stmf.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
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
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 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
23 25 * Copyright (c) 2013 by Delphix. All rights reserved.
24 26 */
27 +
25 28 #ifndef _STMF_H
26 29 #define _STMF_H
27 30
28 31 #include <sys/stmf_defines.h>
29 32
30 33 #ifdef __cplusplus
31 34 extern "C" {
32 35 #endif
33 36
34 37 typedef enum stmf_struct_id {
35 38 STMF_STRUCT_LU_PROVIDER = 1,
36 39 STMF_STRUCT_PORT_PROVIDER,
37 40 STMF_STRUCT_STMF_LOCAL_PORT,
38 41 STMF_STRUCT_STMF_LU,
39 42 STMF_STRUCT_SCSI_SESSION,
40 43 STMF_STRUCT_SCSI_TASK,
41 44 STMF_STRUCT_DATA_BUF,
42 45 STMF_STRUCT_DBUF_STORE,
43 46 STMF_MAX_STRUCT_IDS
44 47 } stmf_struct_id_t;
45 48
46 49 /*
47 50 * Provider callback commands
48 51 */
49 52 #define STMF_PROVIDER_DATA_UPDATED 0x01
50 53
51 54 /*
52 55 * Provider callback flags
53 56 */
54 57 #define STMF_PCB_STMF_ONLINING 0x0001
55 58 #define STMF_PCB_PREG_COMPLETE 0x0002
56 59
57 60 typedef void *data_seg_handle_t;
58 61 #define STMF_MAX_LU_CACHE_NTASKS 16
59 62
60 63 #define STMF_NO_HANDLE 0xffffffff
61 64
62 65 #define COMPANY_ID_NONE 0xFFFFFFFF
63 66 #define COMPANY_ID_SUN 0x00144F
64 67
65 68 /*
66 69 * The scatter/gather list buffer format is used in 2 different
67 70 * contexts within stmf:
68 71 * 1) supplied by the port provider that the LU provider uses to exchange
69 72 * data with the backing store.
70 73 * 2) supplied by the LU provider that the port provider uses exchange
71 74 * data with the host initiator.
72 75 * The second format is optionally supported by the port provided as
73 76 * indicated by the command task flags.
74 77 */
75 78
76 79 typedef struct stmf_sglist_ent {
77 80 uint32_t seg_length;
78 81 uint8_t *seg_addr;
79 82 } stmf_sglist_ent_t;
80 83
81 84 typedef struct stmf_data_buf {
82 85 void *db_stmf_private;
83 86 void *db_port_private;
84 87 void *db_lu_private;
85 88 uint32_t db_buf_size; /* Total size of this buffer */
86 89 uint32_t db_data_size; /* Intended xfer size of this buffer */
87 90 uint32_t db_relative_offset;
88 91 uint16_t db_sglist_length;
89 92 uint16_t db_flags; /* Direction, auto status etc */
90 93 stmf_status_t db_xfer_status;
91 94 uint8_t db_handle; /* To track parallel buffers */
92 95 hrtime_t db_xfer_start_timestamp;
93 96 stmf_sglist_ent_t db_sglist[1]; /* PP scatter/gather list */
94 97 } stmf_data_buf_t;
95 98
96 99 /*
97 100 * db_flags
98 101 */
99 102 #define DB_DIRECTION_TO_RPORT 0x0001
100 103 #define DB_DIRECTION_FROM_RPORT 0x0002
101 104 #define DB_SEND_STATUS_GOOD 0x0004
102 105 #define DB_STATUS_GOOD_SENT 0x0008
103 106 #define DB_DONT_CACHE 0x0010
104 107 #define DB_DONT_REUSE 0x0020
105 108 #define DB_LU_DATA_BUF 0x0040
106 109 #define DB_LPORT_XFER_ACTIVE 0x8000
107 110
108 111 typedef struct scsi_task {
109 112 void *task_stmf_private;
110 113 void *task_port_private;
111 114
112 115 void *task_lu_private;
113 116 struct stmf_scsi_session *task_session;
114 117 struct stmf_local_port *task_lport;
115 118 struct stmf_lu *task_lu;
116 119 void *task_lu_itl_handle; /* Assigned by LU */
117 120
118 121 /* CMD information from initiator */
119 122 uint8_t task_lun_no[8];
120 123 uint8_t task_flags; /* See def. for task flags */
121 124 uint8_t task_priority; /* As per SAM-3 */
122 125 uint8_t task_mgmt_function; /* If this is a TM request */
123 126 uint8_t task_max_nbufs;
124 127 uint8_t task_cur_nbufs;
125 128 uint8_t task_csn_size; /* cmd seq no size in bits */
126 129 uint16_t task_additional_flags;
127 130 uint32_t task_cmd_seq_no;
128 131 uint32_t task_expected_xfer_length;
129 132 uint32_t task_timeout; /* In seconds */
130 133 uint16_t task_ext_id;
131 134 uint16_t task_cdb_length;
132 135 uint8_t *task_cdb;
133 136
134 137 /* Fields to manage data phase */
135 138 uint32_t task_cmd_xfer_length; /* xfer len based on CDB */
136 139 uint32_t task_nbytes_transferred;
137 140 uint32_t task_max_xfer_len; /* largest xfer allowed */
138 141 uint32_t task_1st_xfer_len; /* 1st xfer hint */
139 142 uint32_t task_copy_threshold; /* copy reduction threshold */
140 143
141 144
142 145 /* Status Phase */
143 146 stmf_status_t task_completion_status;
144 147 uint32_t task_resid;
145 148 uint8_t task_status_ctrl; /* See def. for status ctrl */
146 149 uint8_t task_scsi_status;
147 150 uint16_t task_sense_length;
148 151 uint8_t *task_sense_data;
149 152
150 153 /* Misc. task data */
151 154 void *task_extended_cmd;
152 155
153 156 } scsi_task_t;
154 157
155 158 /*
156 159 * Maximum expected transfer length. Can also be used when the transfer
157 160 * length is unknown when the task is allocated (e.g. SAS)
158 161 */
159 162
160 163 #define TASK_MAX_XFER_LENGTH 0xFFFFFFFF
161 164
162 165 /*
163 166 * task_flags definitions.
164 167 */
165 168 /*
166 169 * If TF_INITIAL_BURST is set, the dbuf passed with new_task() contains
167 170 * data from initial burst. Otherwise its just a buffer which the port
168 171 * passed to the LU.
169 172 */
170 173 #define TF_INITIAL_BURST 0x80
171 174 /* Both READ_DATA and WRITE_DATA can be set for bidirectional xfers */
172 175 #define TF_READ_DATA 0x40
173 176 #define TF_WRITE_DATA 0x20
174 177 #define TF_ATTR_MASK 0x07
175 178 #define TF_ATTR_UNTAGGED 0x0
176 179 #define TF_ATTR_SIMPLE_QUEUE 0x1
177 180 #define TF_ATTR_ORDERED_QUEUE 0x2
178 181 #define TF_ATTR_HEAD_OF_QUEUE 0x3
179 182 #define TF_ATTR_ACA 0x4
180 183
181 184 /*
182 185 * Task Management flags.
183 186 */
184 187 #define TM_NONE 0x00
185 188 #define TM_ABORT_TASK 0x01
186 189 #define TM_ABORT_TASK_SET 0x02
187 190 #define TM_CLEAR_ACA 0x03
188 191 #define TM_CLEAR_TASK_SET 0x04
189 192 #define TM_LUN_RESET 0x05
190 193 #define TM_TARGET_WARM_RESET 0x06
191 194 #define TM_TARGET_COLD_RESET 0x07
192 195 #define TM_TASK_REASSIGN 0x08
193 196 #define TM_TARGET_RESET 0x09
194 197 #define TM_QUERY_TASK 0x0A
195 198
196 199 /*
197 200 * additional flags
|
↓ open down ↓ |
163 lines elided |
↑ open up ↑ |
198 201 */
199 202 #define TASK_AF_ENABLE_COMP_CONF 0x01
200 203 #define TASK_AF_PORT_LOAD_HIGH 0x02
201 204 #define TASK_AF_NO_EXPECTED_XFER_LENGTH 0x04
202 205 /*
203 206 * PP sets this flag if it can process dbufs created by the LU.
204 207 */
205 208 #define TASK_AF_ACCEPT_LU_DBUF 0x08
206 209
207 210 /*
211 + * Indicating a PPPT task
212 + */
213 +#define TASK_AF_PPPT_TASK 0x10
214 +
215 +/*
208 216 * scsi_task_t extension identifiers
209 217 */
210 218 #define STMF_TASK_EXT_NONE 0
211 219
212 220 /*
213 221 * max_nbufs
214 222 */
215 223 #define STMF_BUFS_MAX 255
216 224
217 225 /*
218 226 * Task status ctrl
219 227 */
220 228 #define TASK_SCTRL_OVER 1
221 229 #define TASK_SCTRL_UNDER 2
222 230
223 231 /*
224 232 * The flags used by I/O flow.
225 233 */
226 234 #define STMF_IOF_LU_DONE 0x0001
227 235 #define STMF_IOF_LPORT_DONE 0x0002
228 236 #define STMF_IOF_STATS_ONLY 0x0004
229 237
230 238 /*
231 239 * struct allocation flags
232 240 */
233 241 #define AF_FORCE_NOSLEEP 0x0001
234 242 #define AF_DONTZERO 0x0002
235 243
236 244 typedef struct stmf_state_change_info {
237 245 uint64_t st_rflags; /* Reason behind this change */
238 246 char *st_additional_info;
239 247 } stmf_state_change_info_t;
240 248
241 249 typedef struct stmf_change_status {
242 250 stmf_status_t st_completion_status;
243 251 char *st_additional_info;
244 252 } stmf_change_status_t;
245 253
246 254 /*
247 255 * conditions causing or affecting the change.
248 256 */
249 257 #define STMF_RFLAG_USER_REQUEST 0x0001
250 258 #define STMF_RFLAG_FATAL_ERROR 0x0002
251 259 #define STMF_RFLAG_STAY_OFFLINED 0x0004
252 260 #define STMF_RFLAG_RESET 0x0008
253 261 #define STMF_RFLAG_COLLECT_DEBUG_DUMP 0x0010
254 262 #define STMF_RFLAG_LU_ABORT 0x0020
255 263 #define STMF_RFLAG_LPORT_ABORT 0x0040
256 264
257 265 #define STMF_CHANGE_INFO_LEN 160
258 266
259 267 /*
260 268 * cmds to stmf_abort entry point
261 269 */
262 270 #define STMF_QUEUE_TASK_ABORT 1
263 271 #define STMF_REQUEUE_TASK_ABORT_LPORT 2
264 272 #define STMF_REQUEUE_TASK_ABORT_LU 3
265 273 #define STMF_QUEUE_ABORT_LU 4
266 274
267 275 /*
268 276 * cmds to be used by stmf ctl
269 277 */
270 278 #define STMF_CMD_LU_OP 0x0100
271 279 #define STMF_CMD_LPORT_OP 0x0200
272 280 #define STMF_CMD_MASK 0x00ff
273 281 #define STMF_CMD_ONLINE 0x0001
274 282 #define STMF_CMD_OFFLINE 0x0002
275 283 #define STMF_CMD_GET_STATUS 0x0003
276 284 #define STMF_CMD_ONLINE_COMPLETE 0x0004
277 285 #define STMF_CMD_OFFLINE_COMPLETE 0x0005
278 286 #define STMF_ACK_ONLINE_COMPLETE 0x0006
279 287 #define STMF_ACK_OFFLINE_COMPLETE 0x0007
280 288
281 289 #define STMF_CMD_LU_ONLINE (STMF_CMD_LU_OP | STMF_CMD_ONLINE)
282 290 #define STMF_CMD_LU_OFFLINE (STMF_CMD_LU_OP | STMF_CMD_OFFLINE)
283 291 #define STMF_CMD_LPORT_ONLINE (STMF_CMD_LPORT_OP | STMF_CMD_ONLINE)
284 292 #define STMF_CMD_LPORT_OFFLINE (STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE)
285 293 #define STMF_CMD_GET_LU_STATUS (STMF_CMD_LU_OP | STMF_CMD_GET_STATUS)
286 294 #define STMF_CMD_GET_LPORT_STATUS \
287 295 (STMF_CMD_LPORT_OP | STMF_CMD_GET_STATUS)
288 296 #define STMF_CMD_LU_ONLINE_COMPLETE \
289 297 (STMF_CMD_LU_OP | STMF_CMD_ONLINE_COMPLETE)
290 298 #define STMF_CMD_LPORT_ONLINE_COMPLETE \
291 299 (STMF_CMD_LPORT_OP | STMF_CMD_ONLINE_COMPLETE)
292 300 #define STMF_ACK_LU_ONLINE_COMPLETE \
293 301 (STMF_CMD_LU_OP | STMF_ACK_ONLINE_COMPLETE)
294 302 #define STMF_ACK_LPORT_ONLINE_COMPLETE \
295 303 (STMF_CMD_LPORT_OP | STMF_ACK_ONLINE_COMPLETE)
296 304 #define STMF_CMD_LU_OFFLINE_COMPLETE \
297 305 (STMF_CMD_LU_OP | STMF_CMD_OFFLINE_COMPLETE)
298 306 #define STMF_CMD_LPORT_OFFLINE_COMPLETE \
299 307 (STMF_CMD_LPORT_OP | STMF_CMD_OFFLINE_COMPLETE)
300 308 #define STMF_ACK_LU_OFFLINE_COMPLETE \
301 309 (STMF_CMD_LU_OP | STMF_ACK_OFFLINE_COMPLETE)
302 310 #define STMF_ACK_LPORT_OFFLINE_COMPLETE \
303 311 (STMF_CMD_LPORT_OP | STMF_ACK_OFFLINE_COMPLETE)
304 312 /*
305 313 * For LPORTs and LUs to create their own ctl cmds which dont
306 314 * conflict with stmf ctl cmds.
307 315 */
308 316 #define STMF_LPORT_CTL_CMDS 0x1000
309 317 #define STMF_LU_CTL_CMDS 0x2000
310 318
311 319 /*
312 320 * Commands for various info routines.
313 321 */
314 322 /* Command classifiers */
315 323 #define SI_LPORT 0x1000000
316 324 #define SI_STMF 0x2000000
317 325 #define SI_LU 0x4000000
318 326 #define SI_LPORT_FC 0x0000000
319 327 #define SI_LPORT_ISCSI 0x0010000
320 328 #define SI_LPORT_SAS 0x0020000
321 329 #define SI_STMF_LU 0x0010000
322 330 #define SI_STMF_LPORT 0x0020000
323 331
324 332 #define SI_GET_CLASS(v) ((v) & 0xFF000000)
325 333 #define SI_GET_SUBCLASS(v) ((v) & 0x00FF0000)
326 334
327 335 /* Commands for LPORT info routines */
328 336 /* XXX - Implement these. */
329 337 #if 0
330 338 #define SI_LPORT_FC_PORTINFO (SI_LPORT | SI_LPORT_FC | 1)
331 339 #define SI_RPORT_FC_PORTINFO (SI_LPORT | SI_LPORT_FC | 2)
332 340 #endif
333 341
334 342 /*
335 343 * Events
336 344 */
337 345 #define STMF_EVENT_ALL ((int)-1)
338 346 #define LPORT_EVENT_INITIAL_LUN_MAPPED 0
339 347
340 348 /*
341 349 * This needs to go into common/ddi/sunddi.h
342 350 */
343 351 #define DDI_NT_STMF "ddi_scsi_target:framework"
344 352 #define DDI_NT_STMF_LP "ddi_scsi_target:lu_provider"
345 353 #define DDI_NT_STMF_PP "ddi_scsi_target:port_provider"
346 354
347 355 /*
348 356 * VPD page bits.
349 357 */
350 358 #define STMF_VPD_LU_ID 0x01
351 359 #define STMF_VPD_TARGET_ID 0x02
352 360 #define STMF_VPD_TP_GROUP 0x04
353 361 #define STMF_VPD_RELATIVE_TP_ID 0x08
354 362
355 363 /*
356 364 * Common macros to simplify coding
357 365 */
358 366 #define STMF_SEC2TICK(x_sec) (drv_usectohz((x_sec) * 1000000))
359 367
360 368 void stmf_trace(caddr_t ident, const char *fmt, ...);
361 369 void *stmf_alloc(stmf_struct_id_t sid, int additional_size, int alloc_flags);
362 370 void stmf_free(void *struct_ptr);
363 371 struct scsi_task *stmf_task_alloc(struct stmf_local_port *lport,
364 372 struct stmf_scsi_session *ss, uint8_t *lun, uint16_t cdb_length,
365 373 uint16_t ext_id);
366 374 void stmf_post_task(scsi_task_t *task, stmf_data_buf_t *dbuf);
367 375 stmf_data_buf_t *stmf_alloc_dbuf(scsi_task_t *task, uint32_t size,
368 376 uint32_t *pminsize, uint32_t flags);
369 377 void stmf_free_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
370 378 stmf_status_t stmf_setup_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf,
371 379 uint32_t flags);
|
↓ open down ↓ |
154 lines elided |
↑ open up ↑ |
372 380 void stmf_teardown_dbuf(scsi_task_t *task, stmf_data_buf_t *dbuf);
373 381 stmf_status_t stmf_xfer_data(scsi_task_t *task, stmf_data_buf_t *dbuf,
374 382 uint32_t ioflags);
375 383 stmf_status_t stmf_send_scsi_status(scsi_task_t *task, uint32_t ioflags);
376 384 void stmf_data_xfer_done(scsi_task_t *task, stmf_data_buf_t *dbuf,
377 385 uint32_t iof);
378 386 void stmf_send_status_done(scsi_task_t *task, stmf_status_t s, uint32_t iof);
379 387 void stmf_task_lu_done(scsi_task_t *task);
380 388 void stmf_abort(int abort_cmd, scsi_task_t *task, stmf_status_t s, void *arg);
381 389 void stmf_task_lu_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
382 -void stmf_task_lport_aborted(scsi_task_t *task, stmf_status_t s, uint32_t iof);
390 +void stmf_task_lport_aborted_unlocked(scsi_task_t *task, stmf_status_t s,
391 + uint32_t iof);
383 392 stmf_status_t stmf_task_poll_lu(scsi_task_t *task, uint32_t timeout);
384 393 stmf_status_t stmf_task_poll_lport(scsi_task_t *task, uint32_t timeout);
385 394 stmf_status_t stmf_ctl(int cmd, void *obj, void *arg);
386 395 stmf_status_t stmf_register_itl_handle(struct stmf_lu *lu, uint8_t *lun,
387 396 struct stmf_scsi_session *ss, uint64_t session_id, void *itl_handle);
388 397 stmf_status_t stmf_deregister_all_lu_itl_handles(struct stmf_lu *lu);
389 398 stmf_status_t stmf_get_itl_handle(struct stmf_lu *lu, uint8_t *lun,
390 399 struct stmf_scsi_session *ss, uint64_t session_id, void **itl_handle_retp);
391 400 stmf_data_buf_t *stmf_handle_to_buf(scsi_task_t *task, uint8_t h);
392 401 stmf_status_t stmf_lu_add_event(struct stmf_lu *lu, int eventid);
393 402 stmf_status_t stmf_lu_remove_event(struct stmf_lu *lu, int eventid);
394 403 stmf_status_t stmf_lport_add_event(struct stmf_local_port *lport, int eventid);
395 404 stmf_status_t stmf_lport_remove_event(struct stmf_local_port *lport,
396 405 int eventid);
397 406 void stmf_wwn_to_devid_desc(struct scsi_devid_desc *sdid, uint8_t *wwn,
398 407 uint8_t protocol_id);
399 408 stmf_status_t stmf_scsilib_uniq_lu_id(uint32_t company_id,
400 409 struct scsi_devid_desc *lu_id);
401 410 stmf_status_t stmf_scsilib_uniq_lu_id2(uint32_t company_id, uint32_t host_id,
402 411 struct scsi_devid_desc *lu_id);
403 412 void stmf_scsilib_send_status(scsi_task_t *task, uint8_t st, uint32_t saa);
404 413 uint32_t stmf_scsilib_prepare_vpd_page83(scsi_task_t *task, uint8_t *page,
405 414 uint32_t page_len, uint8_t byte0, uint32_t vpd_mask);
406 415 uint16_t stmf_scsilib_get_lport_rtid(struct scsi_devid_desc *devid);
407 416 struct scsi_devid_desc *stmf_scsilib_get_devid_desc(uint16_t rtpid);
408 417 void stmf_scsilib_handle_report_tpgs(scsi_task_t *task, stmf_data_buf_t *dbuf);
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
409 418 void stmf_scsilib_handle_task_mgmt(scsi_task_t *task);
410 419
411 420 struct stmf_remote_port *stmf_scsilib_devid_to_remote_port(
412 421 struct scsi_devid_desc *);
413 422 boolean_t stmf_scsilib_tptid_validate(struct scsi_transport_id *,
414 423 uint32_t, uint16_t *);
415 424 boolean_t stmf_scsilib_tptid_compare(struct scsi_transport_id *,
416 425 struct scsi_transport_id *);
417 426 struct stmf_remote_port *stmf_remote_port_alloc(uint16_t);
418 427 void stmf_remote_port_free(struct stmf_remote_port *);
428 +struct stmf_lu *stmf_check_and_hold_lu(struct scsi_task *task, uint8_t *guid);
429 +void stmf_release_lu(struct stmf_lu *lu);
430 +int stmf_is_task_being_aborted(struct scsi_task *task);
419 431 #ifdef __cplusplus
420 432 }
421 433 #endif
422 434
423 435 #endif /* _STMF_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX