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