• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  *
32  * $Id$
33  */
34 
35 #ifndef SCSI_SRP_H
36 #define SCSI_SRP_H
37 
38 /*
39  * Structures and constants for the SCSI RDMA Protocol (SRP) as
40  * defined by the INCITS T10 committee.  This file was written using
41  * draft Revision 16a of the SRP standard.
42  */
43 
44 #include <linux/types.h>
45 #include <scsi/scsi.h>
46 
47 enum {
48 	SRP_LOGIN_REQ	= 0x00,
49 	SRP_TSK_MGMT	= 0x01,
50 	SRP_CMD		= 0x02,
51 	SRP_I_LOGOUT	= 0x03,
52 	SRP_LOGIN_RSP	= 0xc0,
53 	SRP_RSP		= 0xc1,
54 	SRP_LOGIN_REJ	= 0xc2,
55 	SRP_T_LOGOUT	= 0x80,
56 	SRP_CRED_REQ	= 0x81,
57 	SRP_AER_REQ	= 0x82,
58 	SRP_CRED_RSP	= 0x41,
59 	SRP_AER_RSP	= 0x42
60 };
61 
62 enum {
63 	SRP_BUF_FORMAT_DIRECT	= 1 << 1,
64 	SRP_BUF_FORMAT_INDIRECT	= 1 << 2
65 };
66 
67 enum {
68 	SRP_NO_DATA_DESC	= 0,
69 	SRP_DATA_DESC_DIRECT	= 1,
70 	SRP_DATA_DESC_INDIRECT	= 2,
71 	SRP_DATA_DESC_IMM	= 3,	/* new in SRP2 */
72 };
73 
74 enum {
75 	SRP_TSK_ABORT_TASK	= 0x01,
76 	SRP_TSK_ABORT_TASK_SET	= 0x02,
77 	SRP_TSK_CLEAR_TASK_SET	= 0x04,
78 	SRP_TSK_LUN_RESET	= 0x08,
79 	SRP_TSK_CLEAR_ACA	= 0x40
80 };
81 
82 enum srp_login_rej_reason {
83 	SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL		= 0x00010000,
84 	SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES		= 0x00010001,
85 	SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE	= 0x00010002,
86 	SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL		= 0x00010003,
87 	SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT	= 0x00010004,
88 	SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED		= 0x00010005,
89 	SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED		= 0x00010006
90 };
91 
92 enum {
93 	SRP_REV10_IB_IO_CLASS	= 0xff00,
94 	SRP_REV16A_IB_IO_CLASS	= 0x0100
95 };
96 
97 struct srp_direct_buf {
98 	__be64	va;
99 	__be32	key;
100 	__be32  len;
101 };
102 
103 /*
104  * We need the packed attribute because the SRP spec puts the list of
105  * descriptors at an offset of 20, which is not aligned to the size of
106  * struct srp_direct_buf.  The whole structure must be packed to avoid
107  * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
108  */
109 struct srp_indirect_buf {
110 	struct srp_direct_buf	table_desc;
111 	__be32			len;
112 	struct srp_direct_buf	desc_list[];
113 } __attribute__((packed));
114 
115 /* Immediate data buffer descriptor as defined in SRP2. */
116 struct srp_imm_buf {
117 	__be32	len;
118 };
119 
120 /* srp_login_req.flags */
121 enum {
122 	SRP_MULTICHAN_SINGLE = 0,
123 	SRP_MULTICHAN_MULTI  = 1,
124 	SRP_IMMED_REQUESTED  = 0x80,	/* new in SRP2 */
125 };
126 
127 struct srp_login_req {
128 	u8	opcode;
129 	u8	reserved1[7];
130 	u64	tag;
131 	__be32	req_it_iu_len;
132 	u8	reserved2[4];
133 	__be16	req_buf_fmt;
134 	u8	req_flags;
135 	u8	reserved3[1];
136 	__be16	imm_data_offset;	/* new in SRP2 */
137 	u8	reserved4[2];
138 	u8	initiator_port_id[16];
139 	u8	target_port_id[16];
140 };
141 
142 /**
143  * struct srp_login_req_rdma - RDMA/CM login parameters.
144  *
145  * RDMA/CM over InfiniBand can only carry 92 - 36 = 56 bytes of private
146  * data. The %srp_login_req_rdma structure contains the same information as
147  * %srp_login_req but with the reserved data removed.
148  */
149 struct srp_login_req_rdma {
150 	u64	tag;
151 	__be16	req_buf_fmt;
152 	u8	req_flags;
153 	u8	opcode;
154 	__be32	req_it_iu_len;
155 	u8	initiator_port_id[16];
156 	u8	target_port_id[16];
157 	__be16	imm_data_offset;
158 	u8	reserved[6];
159 };
160 
161 /* srp_login_rsp.rsp_flags */
162 enum {
163 	SRP_LOGIN_RSP_MULTICHAN_NO_CHAN	   = 0x0,
164 	SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,
165 	SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
166 	SRP_LOGIN_RSP_IMMED_SUPP	   = 0x80, /* new in SRP2 */
167 };
168 
169 /*
170  * The SRP spec defines the size of the LOGIN_RSP structure to be 52
171  * bytes, so it needs to be packed to avoid having it padded to 56
172  * bytes on 64-bit architectures.
173  */
174 struct srp_login_rsp {
175 	u8	opcode;
176 	u8	reserved1[3];
177 	__be32	req_lim_delta;
178 	u64	tag;
179 	__be32	max_it_iu_len;
180 	__be32	max_ti_iu_len;
181 	__be16	buf_fmt;
182 	u8	rsp_flags;
183 	u8	reserved2[25];
184 } __attribute__((packed));
185 
186 struct srp_login_rej {
187 	u8	opcode;
188 	u8	reserved1[3];
189 	__be32	reason;
190 	u64	tag;
191 	u8	reserved2[8];
192 	__be16	buf_fmt;
193 	u8	reserved3[6];
194 };
195 
196 struct srp_i_logout {
197 	u8	opcode;
198 	u8	reserved[7];
199 	u64	tag;
200 };
201 
202 struct srp_t_logout {
203 	u8	opcode;
204 	u8	sol_not;
205 	u8	reserved[2];
206 	__be32	reason;
207 	u64	tag;
208 };
209 
210 /*
211  * We need the packed attribute because the SRP spec only aligns the
212  * 8-byte LUN field to 4 bytes.
213  */
214 struct srp_tsk_mgmt {
215 	u8	opcode;
216 	u8	sol_not;
217 	u8	reserved1[6];
218 	u64	tag;
219 	u8	reserved2[4];
220 	struct scsi_lun	lun;
221 	u8	reserved3[2];
222 	u8	tsk_mgmt_func;
223 	u8	reserved4;
224 	u64	task_tag;
225 	u8	reserved5[8];
226 };
227 
228 /*
229  * We need the packed attribute because the SRP spec only aligns the
230  * 8-byte LUN field to 4 bytes.
231  */
232 struct srp_cmd {
233 	u8	opcode;
234 	u8	sol_not;
235 	u8	reserved1[3];
236 	u8	buf_fmt;
237 	u8	data_out_desc_cnt;
238 	u8	data_in_desc_cnt;
239 	u64	tag;
240 	u8	reserved2[4];
241 	struct scsi_lun	lun;
242 	u8	reserved3;
243 	u8	task_attr;
244 	u8	reserved4;
245 	u8	add_cdb_len;
246 	u8	cdb[16];
247 	u8	add_data[];
248 };
249 
250 enum {
251 	SRP_RSP_FLAG_RSPVALID = 1 << 0,
252 	SRP_RSP_FLAG_SNSVALID = 1 << 1,
253 	SRP_RSP_FLAG_DOOVER   = 1 << 2,
254 	SRP_RSP_FLAG_DOUNDER  = 1 << 3,
255 	SRP_RSP_FLAG_DIOVER   = 1 << 4,
256 	SRP_RSP_FLAG_DIUNDER  = 1 << 5
257 };
258 
259 /*
260  * The SRP spec defines the size of the RSP structure to be 36 bytes,
261  * so it needs to be packed to avoid having it padded to 40 bytes on
262  * 64-bit architectures.
263  */
264 struct srp_rsp {
265 	u8	opcode;
266 	u8	sol_not;
267 	u8	reserved1[2];
268 	__be32	req_lim_delta;
269 	u64	tag;
270 	u8	reserved2[2];
271 	u8	flags;
272 	u8	status;
273 	__be32	data_out_res_cnt;
274 	__be32	data_in_res_cnt;
275 	__be32	sense_data_len;
276 	__be32	resp_data_len;
277 	u8	data[];
278 } __attribute__((packed));
279 
280 struct srp_cred_req {
281 	u8	opcode;
282 	u8	sol_not;
283 	u8	reserved[2];
284 	__be32	req_lim_delta;
285 	u64	tag;
286 };
287 
288 struct srp_cred_rsp {
289 	u8	opcode;
290 	u8	reserved[7];
291 	u64	tag;
292 };
293 
294 /*
295  * The SRP spec defines the fixed portion of the AER_REQ structure to be
296  * 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes
297  * on 64-bit architectures.
298  */
299 struct srp_aer_req {
300 	u8	opcode;
301 	u8	sol_not;
302 	u8	reserved[2];
303 	__be32	req_lim_delta;
304 	u64	tag;
305 	u32	reserved2;
306 	struct scsi_lun	lun;
307 	__be32	sense_data_len;
308 	u32	reserved3;
309 	u8	sense_data[];
310 } __attribute__((packed));
311 
312 struct srp_aer_rsp {
313 	u8	opcode;
314 	u8	reserved[7];
315 	u64	tag;
316 };
317 
318 #endif /* SCSI_SRP_H */
319