blob: 15cb8cf8a604936e55529b4d5917146c403ed2fd [file] [log] [blame]
Roland Dreieraef9ec32005-11-02 14:07:13 -08001/*
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>
Bart Van Assche985aa492015-05-18 13:27:14 +020045#include <scsi/scsi.h>
Roland Dreieraef9ec32005-11-02 14:07:13 -080046
47enum {
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
62enum {
63 SRP_BUF_FORMAT_DIRECT = 1 << 1,
64 SRP_BUF_FORMAT_INDIRECT = 1 << 2
65};
66
67enum {
68 SRP_NO_DATA_DESC = 0,
69 SRP_DATA_DESC_DIRECT = 1,
70 SRP_DATA_DESC_INDIRECT = 2
71};
72
73enum {
74 SRP_TSK_ABORT_TASK = 0x01,
75 SRP_TSK_ABORT_TASK_SET = 0x02,
76 SRP_TSK_CLEAR_TASK_SET = 0x04,
77 SRP_TSK_LUN_RESET = 0x08,
78 SRP_TSK_CLEAR_ACA = 0x40
79};
80
81enum srp_login_rej_reason {
82 SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
83 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
84 SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
85 SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
86 SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
87 SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
88 SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
89};
90
Ramachandra K73c09962006-06-17 20:37:38 -070091enum {
92 SRP_REV10_IB_IO_CLASS = 0xff00,
93 SRP_REV16A_IB_IO_CLASS = 0x0100
94};
95
Roland Dreieraef9ec32005-11-02 14:07:13 -080096struct srp_direct_buf {
97 __be64 va;
98 __be32 key;
99 __be32 len;
100};
101
102/*
103 * We need the packed attribute because the SRP spec puts the list of
Roland Dreierec448a02006-04-18 09:05:39 -0700104 * descriptors at an offset of 20, which is not aligned to the size of
105 * struct srp_direct_buf. The whole structure must be packed to avoid
106 * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
Roland Dreieraef9ec32005-11-02 14:07:13 -0800107 */
108struct srp_indirect_buf {
109 struct srp_direct_buf table_desc;
110 __be32 len;
Roland Dreierec448a02006-04-18 09:05:39 -0700111 struct srp_direct_buf desc_list[0];
112} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800113
114enum {
115 SRP_MULTICHAN_SINGLE = 0,
116 SRP_MULTICHAN_MULTI = 1
117};
118
119struct srp_login_req {
120 u8 opcode;
121 u8 reserved1[7];
122 u64 tag;
123 __be32 req_it_iu_len;
124 u8 reserved2[4];
125 __be16 req_buf_fmt;
126 u8 req_flags;
127 u8 reserved3[5];
128 u8 initiator_port_id[16];
129 u8 target_port_id[16];
130};
131
Bart Van Assche19f31342018-01-22 14:27:12 -0800132/**
133 * struct srp_login_req_rdma - RDMA/CM login parameters.
134 *
135 * RDMA/CM over InfiniBand can only carry 92 - 36 = 56 bytes of private
136 * data. The %srp_login_req_rdma structure contains the same information as
137 * %srp_login_req but with the reserved data removed.
138 */
139struct srp_login_req_rdma {
140 u64 tag;
141 __be16 req_buf_fmt;
142 u8 req_flags;
143 u8 opcode;
144 __be32 req_it_iu_len;
145 u8 initiator_port_id[16];
146 u8 target_port_id[16];
147};
148
Bart Van Asschefeafa202018-12-17 13:20:32 -0800149/* srp_login_rsp.rsp_flags */
150enum {
151 SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0,
152 SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,
153 SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
154};
155
Roland Dreierec448a02006-04-18 09:05:39 -0700156/*
157 * The SRP spec defines the size of the LOGIN_RSP structure to be 52
158 * bytes, so it needs to be packed to avoid having it padded to 56
159 * bytes on 64-bit architectures.
160 */
Roland Dreieraef9ec32005-11-02 14:07:13 -0800161struct srp_login_rsp {
162 u8 opcode;
163 u8 reserved1[3];
164 __be32 req_lim_delta;
165 u64 tag;
166 __be32 max_it_iu_len;
167 __be32 max_ti_iu_len;
168 __be16 buf_fmt;
169 u8 rsp_flags;
170 u8 reserved2[25];
Roland Dreierec448a02006-04-18 09:05:39 -0700171} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800172
173struct srp_login_rej {
174 u8 opcode;
175 u8 reserved1[3];
176 __be32 reason;
177 u64 tag;
178 u8 reserved2[8];
179 __be16 buf_fmt;
180 u8 reserved3[6];
181};
182
183struct srp_i_logout {
184 u8 opcode;
185 u8 reserved[7];
186 u64 tag;
187};
188
189struct srp_t_logout {
190 u8 opcode;
191 u8 sol_not;
192 u8 reserved[2];
193 __be32 reason;
194 u64 tag;
195};
196
197/*
198 * We need the packed attribute because the SRP spec only aligns the
199 * 8-byte LUN field to 4 bytes.
200 */
201struct srp_tsk_mgmt {
202 u8 opcode;
203 u8 sol_not;
204 u8 reserved1[6];
205 u64 tag;
206 u8 reserved2[4];
Bart Van Assche985aa492015-05-18 13:27:14 +0200207 struct scsi_lun lun;
Roland Dreieraef9ec32005-11-02 14:07:13 -0800208 u8 reserved3[2];
209 u8 tsk_mgmt_func;
210 u8 reserved4;
211 u64 task_tag;
212 u8 reserved5[8];
213};
214
215/*
216 * We need the packed attribute because the SRP spec only aligns the
217 * 8-byte LUN field to 4 bytes.
218 */
219struct srp_cmd {
220 u8 opcode;
221 u8 sol_not;
222 u8 reserved1[3];
223 u8 buf_fmt;
224 u8 data_out_desc_cnt;
225 u8 data_in_desc_cnt;
226 u64 tag;
227 u8 reserved2[4];
Bart Van Assche985aa492015-05-18 13:27:14 +0200228 struct scsi_lun lun;
Roland Dreieraef9ec32005-11-02 14:07:13 -0800229 u8 reserved3;
230 u8 task_attr;
231 u8 reserved4;
232 u8 add_cdb_len;
233 u8 cdb[16];
234 u8 add_data[0];
235};
236
237enum {
238 SRP_RSP_FLAG_RSPVALID = 1 << 0,
239 SRP_RSP_FLAG_SNSVALID = 1 << 1,
240 SRP_RSP_FLAG_DOOVER = 1 << 2,
241 SRP_RSP_FLAG_DOUNDER = 1 << 3,
242 SRP_RSP_FLAG_DIOVER = 1 << 4,
243 SRP_RSP_FLAG_DIUNDER = 1 << 5
244};
245
Roland Dreierec448a02006-04-18 09:05:39 -0700246/*
247 * The SRP spec defines the size of the RSP structure to be 36 bytes,
248 * so it needs to be packed to avoid having it padded to 40 bytes on
249 * 64-bit architectures.
250 */
Roland Dreieraef9ec32005-11-02 14:07:13 -0800251struct srp_rsp {
252 u8 opcode;
253 u8 sol_not;
254 u8 reserved1[2];
255 __be32 req_lim_delta;
256 u64 tag;
257 u8 reserved2[2];
258 u8 flags;
259 u8 status;
260 __be32 data_out_res_cnt;
261 __be32 data_in_res_cnt;
262 __be32 sense_data_len;
263 __be32 resp_data_len;
264 u8 data[0];
Roland Dreierec448a02006-04-18 09:05:39 -0700265} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800266
David Dillowbb125882010-10-08 14:40:47 -0400267struct srp_cred_req {
268 u8 opcode;
269 u8 sol_not;
270 u8 reserved[2];
271 __be32 req_lim_delta;
272 u64 tag;
273};
274
275struct srp_cred_rsp {
276 u8 opcode;
277 u8 reserved[7];
278 u64 tag;
279};
280
281/*
282 * The SRP spec defines the fixed portion of the AER_REQ structure to be
283 * 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes
284 * on 64-bit architectures.
285 */
286struct srp_aer_req {
287 u8 opcode;
288 u8 sol_not;
289 u8 reserved[2];
290 __be32 req_lim_delta;
291 u64 tag;
292 u32 reserved2;
Bart Van Assche985aa492015-05-18 13:27:14 +0200293 struct scsi_lun lun;
David Dillowbb125882010-10-08 14:40:47 -0400294 __be32 sense_data_len;
295 u32 reserved3;
296 u8 sense_data[0];
297} __attribute__((packed));
298
299struct srp_aer_rsp {
300 u8 opcode;
301 u8 reserved[7];
302 u64 tag;
303};
304
Roland Dreieraef9ec32005-11-02 14:07:13 -0800305#endif /* SCSI_SRP_H */