xref: /titanic_41/usr/src/uts/common/sys/fc4/fcp.h (revision 24dd95375a09d43fe4f6b55f6d5188f4bac4f68d)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1995,1997-1998 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SYS_FC4_FCP_H
28 #define	_SYS_FC4_FCP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * Frame format and protocol definitions for transferring
34  * commands and data between a SCSI initiator and target
35  * using an FC4 serial link interface.
36  */
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 
43 /*
44  * FCP Device Data Frame Information Categories
45  */
46 #define	FCP_SCSI_DATA		0x01	/* frame contains SCSI data */
47 #define	FCP_SCSI_CMD		0x02	/* frame contains SCSI command */
48 #define	FCP_SCSI_RSP		0x03	/* frame contains SCSI response */
49 #define	FCP_SCSI_XFER_RDY	0x05	/* frame contains xfer rdy block */
50 
51 
52 /*
53  * FCP SCSI Control structure
54  */
55 typedef struct fcp_cntl {
56 	uchar_t	cntl_reserved_0;		/* reserved */
57 	uchar_t	cntl_reserved_1	: 5,		/* reserved */
58 		cntl_qtype	: 3;		/* tagged queueing type */
59 	uchar_t	cntl_kill_tsk	: 1,		/* terminate task */
60 		cntl_clr_aca	: 1,		/* clear aca */
61 		cntl_reset	: 1,		/* reset */
62 		cntl_reserved_2	: 2,		/* reserved */
63 		cntl_clr_tsk	: 1,		/* clear task set */
64 		cntl_abort_tsk	: 1,		/* abort task set */
65 		cntl_reserved_3	: 1;		/* reserved */
66 	uchar_t	cntl_reserved_4	: 6,		/* reserved */
67 		cntl_read_data	: 1,		/* initiator read */
68 		cntl_write_data	: 1;		/* initiator write */
69 } fcp_cntl_t;
70 
71 /*
72  * FCP SCSI Control Tagged Queueing types - cntl_qtype
73  */
74 #define	FCP_QTYPE_SIMPLE	0		/* simple queueing */
75 #define	FCP_QTYPE_HEAD_OF_Q	1		/* head of queue */
76 #define	FCP_QTYPE_ORDERED	2		/* ordered queueing */
77 #define	FCP_QTYPE_ACA_Q_TAG	4		/* ACA queueing */
78 #define	FCP_QTYPE_UNTAGGED	5		/* Untagged */
79 
80 
81 /*
82  * FCP SCSI Entity Address
83  *
84  * ent_addr_0 is always the first and highest layer of
85  * the hierarchy.  The depth of the hierarchy of addressing,
86  * up to a maximum of four layers, is arbitrary and
87  * device-dependent.
88  */
89 typedef struct fcp_ent_addr {
90 	ushort_t ent_addr_0;		/* entity address 0 */
91 	ushort_t ent_addr_1;		/* entity address 1 */
92 	ushort_t ent_addr_2;		/* entity address 2 */
93 	ushort_t ent_addr_3;		/* entity address 3 */
94 } fcp_ent_addr_t;
95 
96 
97 /*
98  * Maximum size of SCSI cdb in FCP SCSI command
99  */
100 #define	FCP_CDB_SIZE		16
101 #define	FCP_LUN_SIZE		8
102 
103 /*
104  * FCP SCSI command payload
105  */
106 typedef struct fcp_cmd {
107 	fcp_ent_addr_t	fcp_ent_addr;			/* entity address */
108 	fcp_cntl_t	fcp_cntl;			/* SCSI options */
109 	uchar_t		fcp_cdb[FCP_CDB_SIZE];		/* SCSI cdb */
110 	int		fcp_data_len;			/* data length */
111 } fcp_cmd_t;
112 
113 
114 /*
115  * FCP SCSI status
116  */
117 typedef struct fcp_status {
118 	ushort_t reserved_0;			/* reserved */
119 	uchar_t	reserved_1	: 4,		/* reserved */
120 		resid_under	: 1,		/* resid non-zero */
121 		resid_over	: 1,		/* resid non-zero */
122 		sense_len_set	: 1,		/* sense_len non-zero */
123 		rsp_len_set	: 1;		/* response_len non-zero */
124 	uchar_t	scsi_status;			/* status of cmd */
125 } fcp_status_t;
126 
127 #define	resid_len_set	resid_over		/* for pln */
128 
129 
130 /*
131  * FCP SCSI Response Payload
132  */
133 typedef struct fcp_rsp {
134 	uint_t	reserved_0;			/* reserved */
135 	uint_t	reserved_1;			/* reserved */
136 	union {
137 		fcp_status_t	fcp_status;		/* command status */
138 		uint_t		i_fcp_status;
139 	}fcp_u;
140 	uint_t		fcp_resid;		/* resid of operation */
141 	uint_t		fcp_sense_len;		/* sense data length */
142 	uint_t		fcp_response_len;	/* response data length */
143 	/*
144 	 * 'm' bytes of scsi response info follow
145 	 * 'n' bytes of scsi sense info follow
146 	 */
147 } fcp_rsp_t;
148 
149 #define	FCP_MAX_RSP_IU_SIZE	256
150 
151 /*
152  * FCP RSP_INFO field format
153  */
154 
155 struct fcp_rsp_info {
156 	uchar_t		resvd1;
157 	uchar_t		resvd2;
158 	uchar_t		resvd3;
159 	uchar_t		rsp_code;
160 	uchar_t		resvd4;
161 	uchar_t		resvd5;
162 	uchar_t		resvd6;
163 	uchar_t		resvd7;
164 };
165 
166 /*	RSP_CODE definitions */
167 
168 #define		FCP_NO_FAILURE			0x0
169 #define		FCP_DL_LEN_MISMATCH		0x1
170 #define		FCP_CMND_INVALID		0x2
171 #define		FCP_DATA_RO_MISMATCH		0x3
172 #define		FCP_TASK_MGMT_NOT_SUPPTD	0x4
173 #define		FCP_TASK_MGMT_FAILED		0x5
174 
175 
176 /*
177  * FCP SCSI_ XFER_RDY Payload
178  */
179 typedef struct fcp_xfer_rdy {
180 	ulong_t		fcp_seq_offset;		/* relative offset */
181 	ulong_t		fcp_burst_len;		/* buffer space */
182 	ulong_t		reserved;		/* reserved */
183 } fcp_xfer_rdy_t;
184 
185 /*
186  * FCP PRLI Payload
187  */
188 
189 struct fcp_prli {
190 	uchar_t		type;
191 	uchar_t		resvd1;
192 	uint_t		orig_process_assoc_valid:1;
193 	uint_t		resp_process_assoc_valid:1;
194 	uint_t		establish_image_pair:1;
195 	uint_t		resvd2:13;
196 	uint_t		orig_process_associator;
197 	uint_t		resp_process_associator;
198 	uint_t		resvd3:25;
199 	uint_t		data_overlay_allowed:1;
200 	uint_t		initiator_fn:1;
201 	uint_t		target_fn:1;
202 	uint_t		cmd_data_mixed:1;
203 	uint_t		data_resp_mixed:1;
204 	uint_t		read_xfer_rdy_disabled:1;
205 	uint_t		write_xfer_rdy_disabled:1;
206 };
207 
208 /*
209  * FCP PRLI ACC Payload
210  */
211 
212 struct fcp_prli_acc {
213 	uchar_t		type;
214 	uchar_t		resvd1;
215 	uint_t		orig_process_assoc_valid:1;
216 	uint_t		resp_process_assoc_valid:1;
217 	uint_t		image_pair_establsihed:1;
218 	uint_t		resvd2:1;
219 	uint_t		accept_response_code:4;
220 	uint_t		resvd3:8;
221 	uint_t		orig_process_associator;
222 	uint_t		resp_process_associator;
223 	uint_t		resvd4:26;
224 	uint_t		initiator_fn:1;
225 	uint_t		target_fn:1;
226 	uint_t		cmd_data_mixed:1;
227 	uint_t		data_resp_mixed:1;
228 	uint_t		read_xfer_rdy_disabled:1;
229 	uint_t		write_xfer_rdy_disabled:1;
230 };
231 
232 
233 #ifdef	__cplusplus
234 }
235 #endif
236 
237 #endif	/* _SYS_FC4_FCP_H */
238