xref: /titanic_41/usr/src/uts/common/sys/fibre-channel/fc_types.h (revision b59b3655028aeb11832ad679eb5c2577c2b75235)
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 2014 Garrett D'Amore <garrett@damore.org>
23  *
24  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_FC_TYPES_H
29 #define	_FC_TYPES_H
30 
31 
32 
33 /*
34  * Types for FC Transport subsystems.
35  *
36  * This file picks up specific as well as generic type
37  * defines, and also serves as a wrapper for many common
38  * includes.
39  */
40 
41 #include <sys/types.h>
42 #include <sys/param.h>
43 
44 #ifdef	__cplusplus
45 extern "C" {
46 #endif
47 
48 #if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
49 #error	One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
50 #endif	/* _BIT_FIELDS_LTOH */
51 
52 #ifdef	_KERNEL
53 #include <sys/systm.h>
54 #include <sys/cmn_err.h>
55 #include <sys/debug.h>
56 #include <sys/devops.h>
57 #include <sys/callb.h>
58 #include <sys/disp.h>
59 #include <sys/taskq.h>
60 #endif	/* _KERNEL */
61 
62 #ifndef	_SYS_SCSI_SCSI_TYPES_H
63 
64 
65 typedef void *opaque_t;
66 
67 #endif /* _SYS_SCSI_SCSI_TYPES_H */
68 
69 /* Sysevent defs */
70 #define	EC_SUNFC		"EC_sunfc"
71 #define	ESC_SUNFC_PORT_ATTACH	"ESC_sunfc_port_attach"
72 #define	ESC_SUNFC_PORT_DETACH	"ESC_sunfc_port_detach"
73 #define	ESC_SUNFC_PORT_ONLINE	"ESC_sunfc_port_online"
74 #define	ESC_SUNFC_PORT_OFFLINE	"ESC_sunfc_port_offline"
75 #define	ESC_SUNFC_PORT_RSCN	"ESC_sunfc_port_rscn"
76 #define	ESC_SUNFC_TARGET_ADD	"ESC_sunfc_target_add"
77 #define	ESC_SUNFC_TARGET_REMOVE	"ESC_sunfc_target_remove"
78 #define	ESC_SUNFC_DEVICE_ONLINE	"ESC_sunfc_device_online"
79 #define	ESC_SUNFC_DEVICE_OFFLINE	"ESC_sunfc_device_offline"
80 
81 /* T11 FC-HBA state change tracking */
82 typedef uint64_t    fc_hba_state_change_t;
83 
84 typedef struct port_id {
85 #if	defined(_BIT_FIELDS_LTOH)
86 	uint32_t	port_id : 24,		/* Port Identifier */
87 			priv_lilp_posit : 8;	/* LILP map position */
88 #else
89 	uint32_t	priv_lilp_posit : 8,	/* LILP map position */
90 			port_id : 24;		/* Port Identifier */
91 #endif	/* _BIT_FIELDS_LTOH */
92 } fc_portid_t;
93 
94 typedef struct hard_addr {
95 #if	defined(_BIT_FIELDS_LTOH)
96 	uint32_t	hard_addr : 24,		/* hard address */
97 			rsvd : 8;		/* reserved */
98 #else
99 	uint32_t	rsvd : 8,
100 			hard_addr : 24;		/* hard address */
101 #endif	/* _BIT_FIELDS_LTOH */
102 } fc_hardaddr_t;
103 
104 typedef struct port_type {
105 #if defined(_BIT_FIELDS_LTOH)
106 	uint32_t	rsvd   		: 24,
107 			port_type	: 8;
108 #else
109 	uint32_t	port_type   	: 8,
110 			rsvd		: 24;
111 #endif	/* _BIT_FIELDS_LTOH */
112 } fc_porttype_t;
113 
114 /*
115  * FCA post reset behavior
116  */
117 typedef enum fc_reset_action {
118 	FC_RESET_RETURN_NONE,		/* Can't return any */
119 	FC_RESET_RETURN_ALL,		/* Return all commands reached here */
120 	FC_RESET_RETURN_OUTSTANDING	/* Return ones that haven't gone out */
121 } fc_reset_action_t;
122 
123 /*
124  * FCA DMA behavior on Unaligned buffers
125  */
126 typedef enum fc_dma_behavior {
127 	FC_ALLOW_STREAMING,		/* Streaming mode for all xfers */
128 	FC_NO_STREAMING			/* Disable Streaming on unaligned */
129 					/* buffer or byte counts */
130 } fc_dma_behavior_t;
131 
132 
133 /*
134  * FCA FCP command and response allocation in DVMA space
135  */
136 typedef enum fc_fcp_dma {
137 	FC_DVMA_SPACE,			/* allocation should be in DVMA mem */
138 	FC_NO_DVMA_SPACE		/* allocation shouldn't be DVMA mem */
139 } fc_fcp_dma_t;
140 
141 
142 /*
143  * struct to track rscn info both within the transport layer
144  * and between the ULPs and transport.
145  */
146 typedef	struct		fc_ulp_rscn_info {
147 	uint32_t	ulp_rscn_count;
148 } fc_ulp_rscn_info_t;
149 
150 /*
151  * Define a value for ulp_rscn_count to indicate that the contents
152  * of the fc_ulp_rscn_info_t struct are invalid. Note that some parts of the
153  * code assume that this value is zero, i.e., they use kmem_zalloc().
154  */
155 #define	FC_INVALID_RSCN_COUNT		((uint32_t)0)
156 
157 /*
158  * FC Transport exported header files to all Consumers
159  */
160 
161 #ifdef	_KERNEL
162 #include <sys/fibre-channel/impl/fcph.h>
163 #include <sys/fibre-channel/fc_appif.h>
164 #include <sys/fibre-channel/impl/fc_linkapp.h>
165 #include <sys/fibre-channel/impl/fcgs2.h>
166 #include <sys/fibre-channel/impl/fc_fla.h>
167 #include <sys/fibre-channel/impl/fcal.h>
168 #include <sys/fibre-channel/impl/fctl.h>
169 #include <sys/fibre-channel/impl/fc_error.h>
170 #include <sys/fibre-channel/fcio.h>
171 #include <sys/fibre-channel/ulp/fcp.h>
172 #include <sys/fibre-channel/ulp/fcp_util.h>
173 
174 /*
175  * For drivers which do not include these - must be last
176  */
177 #include <sys/ddi.h>
178 #include <sys/sunddi.h>
179 #include <sys/stat.h>
180 #include <sys/sunndi.h>
181 #include <sys/devctl.h>
182 #endif	/* _KERNEL */
183 
184 #ifdef	__cplusplus
185 }
186 #endif
187 
188 #endif	/* _FC_TYPES_H */
189