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 /*
23 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #ifndef _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
27 #define _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
28
29 /*
30 * Multiplexed I/O SCSI vHCI global include
31 */
32 #include <sys/note.h>
33 #include <sys/taskq.h>
34 #include <sys/mhd.h>
35 #include <sys/sunmdi.h>
36 #include <sys/mdi_impldefs.h>
37 #include <sys/scsi/adapters/mpapi_impl.h>
38 #include <sys/scsi/adapters/mpapi_scsi_vhci.h>
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
48 #ifdef _KERNEL
49
50 #ifdef UNDEFINED
51 #undef UNDEFINED
52 #endif
53 #define UNDEFINED -1
54
55 #define VHCI_STATE_OPEN 0x00000001
56
57
58 #define VH_SLEEP 0x0
59 #define VH_NOSLEEP 0x1
60
61 /*
62 * HBA interface macros
63 */
64
65 #define TRAN2HBAPRIVATE(tran) ((struct scsi_vhci *)(tran)->tran_hba_private)
66 #define VHCI_INIT_WAIT_TIMEOUT 60000000
67 #define VHCI_FOWATCH_INTERVAL 1000000 /* in usecs */
68 #define VHCI_EXTFO_TIMEOUT 3*60 /* 3 minutes */
69
70 #define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK)
71
72 int vhci_do_scsi_cmd(struct scsi_pkt *);
73 /*PRINTFLIKE3*/
74 void vhci_log(int, dev_info_t *, const char *, ...);
75
76 /*
77 * debugging stuff
78 */
79
80 #ifdef DEBUG
81
82 #ifndef VHCI_DEBUG_DEFAULT_VAL
83 #define VHCI_DEBUG_DEFAULT_VAL 0
84 #endif /* VHCI_DEBUG_DEFAULT_VAL */
85
86 extern int vhci_debug;
87
88 #include <sys/debug.h>
299 * Saved when the command is being retried internally.
300 */
301 struct vhci_pkt *vpkt_org_vpkt;
302 };
303
304 typedef struct scsi_vhci_lun {
305 kmutex_t svl_mutex;
306 kcondvar_t svl_cv;
307
308 /*
309 * following three fields are under svl_mutex protection
310 */
311 int svl_transient;
312
313 /*
314 * to prevent unnecessary failover when a device is
315 * is discovered across a passive path and active path
316 * is still comng up
317 */
318 int svl_waiting_for_activepath;
319 time_t svl_wfa_time;
320
321 /*
322 * to keep the failover status in order to return the
323 * failure status to target driver when targer driver
324 * retries the command which originally triggered the
325 * failover.
326 */
327 int svl_failover_status;
328
329 /*
330 * for RESERVE/RELEASE support
331 */
332 client_lb_t svl_lb_policy_save;
333
334 /*
335 * Failover ops and ops name selected for the lun.
336 */
337 struct scsi_failover_ops *svl_fops;
338 char *svl_fops_name;
339
445
446 /*
447 * following is used to prevent packets completing with the
448 * same error reason from flooding the screen
449 */
450 uchar_t svp_last_pkt_reason;
451
452 /* external failover scsi_watch token */
453 opaque_t svp_sw_token;
454
455 /* any cleanup operations for a newly found path. */
456 int svp_new_path;
457 } scsi_vhci_priv_t;
458
459 /*
460 * argument to scsi_watch callback. Used for processing
461 * externally initiated failovers
462 */
463 typedef struct scsi_vhci_swarg {
464 scsi_vhci_priv_t *svs_svp;
465 time_t svs_tos; /* time of submission */
466 mdi_pathinfo_t *svs_pi; /* pathinfo being "watched" */
467 int svs_release_lun;
468 int svs_done;
469 } scsi_vhci_swarg_t;
470
471 /*
472 * scsi_vhci softstate
473 *
474 * vhci_mutex protects
475 * vhci_state
476 * and vhci_reset_notify list
477 */
478 struct scsi_vhci {
479 kmutex_t vhci_mutex;
480 dev_info_t *vhci_dip;
481 struct scsi_hba_tran *vhci_tran;
482 uint32_t vhci_state;
483 uint32_t vhci_instance;
484 kstat_t vhci_kstat;
485 /*
|
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 /*
23 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 /*
26 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
27 */
28
29 #ifndef _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
30 #define _SYS_SCSI_ADAPTERS_SCSI_VHCI_H
31
32 /*
33 * Multiplexed I/O SCSI vHCI global include
34 */
35 #include <sys/note.h>
36 #include <sys/taskq.h>
37 #include <sys/mhd.h>
38 #include <sys/sunmdi.h>
39 #include <sys/mdi_impldefs.h>
40 #include <sys/scsi/adapters/mpapi_impl.h>
41 #include <sys/scsi/adapters/mpapi_scsi_vhci.h>
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
51 #ifdef _KERNEL
52
53 #ifdef UNDEFINED
54 #undef UNDEFINED
55 #endif
56 #define UNDEFINED -1
57
58 #define VHCI_STATE_OPEN 0x00000001
59
60
61 #define VH_SLEEP 0x0
62 #define VH_NOSLEEP 0x1
63
64 /*
65 * HBA interface macros
66 */
67
68 #define TRAN2HBAPRIVATE(tran) ((struct scsi_vhci *)(tran)->tran_hba_private)
69 #define VHCI_INIT_WAIT_TIMEOUT 60000000
70 #define VHCI_FOWATCH_INTERVAL 1000000 /* in usecs */
71 #define VHCI_EXTFO_TIMEOUT (3 * 60 * NANOSEC) /* 3 minutes in nsec */
72
73 #define SCBP_C(pkt) ((*(pkt)->pkt_scbp) & STATUS_MASK)
74
75 int vhci_do_scsi_cmd(struct scsi_pkt *);
76 /*PRINTFLIKE3*/
77 void vhci_log(int, dev_info_t *, const char *, ...);
78
79 /*
80 * debugging stuff
81 */
82
83 #ifdef DEBUG
84
85 #ifndef VHCI_DEBUG_DEFAULT_VAL
86 #define VHCI_DEBUG_DEFAULT_VAL 0
87 #endif /* VHCI_DEBUG_DEFAULT_VAL */
88
89 extern int vhci_debug;
90
91 #include <sys/debug.h>
302 * Saved when the command is being retried internally.
303 */
304 struct vhci_pkt *vpkt_org_vpkt;
305 };
306
307 typedef struct scsi_vhci_lun {
308 kmutex_t svl_mutex;
309 kcondvar_t svl_cv;
310
311 /*
312 * following three fields are under svl_mutex protection
313 */
314 int svl_transient;
315
316 /*
317 * to prevent unnecessary failover when a device is
318 * is discovered across a passive path and active path
319 * is still comng up
320 */
321 int svl_waiting_for_activepath;
322 hrtime_t svl_wfa_time;
323
324 /*
325 * to keep the failover status in order to return the
326 * failure status to target driver when targer driver
327 * retries the command which originally triggered the
328 * failover.
329 */
330 int svl_failover_status;
331
332 /*
333 * for RESERVE/RELEASE support
334 */
335 client_lb_t svl_lb_policy_save;
336
337 /*
338 * Failover ops and ops name selected for the lun.
339 */
340 struct scsi_failover_ops *svl_fops;
341 char *svl_fops_name;
342
448
449 /*
450 * following is used to prevent packets completing with the
451 * same error reason from flooding the screen
452 */
453 uchar_t svp_last_pkt_reason;
454
455 /* external failover scsi_watch token */
456 opaque_t svp_sw_token;
457
458 /* any cleanup operations for a newly found path. */
459 int svp_new_path;
460 } scsi_vhci_priv_t;
461
462 /*
463 * argument to scsi_watch callback. Used for processing
464 * externally initiated failovers
465 */
466 typedef struct scsi_vhci_swarg {
467 scsi_vhci_priv_t *svs_svp;
468 hrtime_t svs_tos; /* time of submission */
469 mdi_pathinfo_t *svs_pi; /* pathinfo being "watched" */
470 int svs_release_lun;
471 int svs_done;
472 } scsi_vhci_swarg_t;
473
474 /*
475 * scsi_vhci softstate
476 *
477 * vhci_mutex protects
478 * vhci_state
479 * and vhci_reset_notify list
480 */
481 struct scsi_vhci {
482 kmutex_t vhci_mutex;
483 dev_info_t *vhci_dip;
484 struct scsi_hba_tran *vhci_tran;
485 uint32_t vhci_state;
486 uint32_t vhci_instance;
487 kstat_t vhci_kstat;
488 /*
|