blob: 637f77eccf0c77d491a6c6a4e7d6b54ed115f645 [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>
45
46enum {
47 SRP_LOGIN_REQ = 0x00,
48 SRP_TSK_MGMT = 0x01,
49 SRP_CMD = 0x02,
50 SRP_I_LOGOUT = 0x03,
51 SRP_LOGIN_RSP = 0xc0,
52 SRP_RSP = 0xc1,
53 SRP_LOGIN_REJ = 0xc2,
54 SRP_T_LOGOUT = 0x80,
55 SRP_CRED_REQ = 0x81,
56 SRP_AER_REQ = 0x82,
57 SRP_CRED_RSP = 0x41,
58 SRP_AER_RSP = 0x42
59};
60
61enum {
62 SRP_BUF_FORMAT_DIRECT = 1 << 1,
63 SRP_BUF_FORMAT_INDIRECT = 1 << 2
64};
65
66enum {
67 SRP_NO_DATA_DESC = 0,
68 SRP_DATA_DESC_DIRECT = 1,
69 SRP_DATA_DESC_INDIRECT = 2
70};
71
72enum {
73 SRP_TSK_ABORT_TASK = 0x01,
74 SRP_TSK_ABORT_TASK_SET = 0x02,
75 SRP_TSK_CLEAR_TASK_SET = 0x04,
76 SRP_TSK_LUN_RESET = 0x08,
77 SRP_TSK_CLEAR_ACA = 0x40
78};
79
80enum srp_login_rej_reason {
81 SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
82 SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
83 SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
84 SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
85 SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
86 SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
87 SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
88};
89
90struct srp_direct_buf {
91 __be64 va;
92 __be32 key;
93 __be32 len;
94};
95
96/*
97 * We need the packed attribute because the SRP spec puts the list of
Roland Dreierec448a02006-04-18 09:05:39 -070098 * descriptors at an offset of 20, which is not aligned to the size of
99 * struct srp_direct_buf. The whole structure must be packed to avoid
100 * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
Roland Dreieraef9ec32005-11-02 14:07:13 -0800101 */
102struct srp_indirect_buf {
103 struct srp_direct_buf table_desc;
104 __be32 len;
Roland Dreierec448a02006-04-18 09:05:39 -0700105 struct srp_direct_buf desc_list[0];
106} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800107
108enum {
109 SRP_MULTICHAN_SINGLE = 0,
110 SRP_MULTICHAN_MULTI = 1
111};
112
113struct srp_login_req {
114 u8 opcode;
115 u8 reserved1[7];
116 u64 tag;
117 __be32 req_it_iu_len;
118 u8 reserved2[4];
119 __be16 req_buf_fmt;
120 u8 req_flags;
121 u8 reserved3[5];
122 u8 initiator_port_id[16];
123 u8 target_port_id[16];
124};
125
Roland Dreierec448a02006-04-18 09:05:39 -0700126/*
127 * The SRP spec defines the size of the LOGIN_RSP structure to be 52
128 * bytes, so it needs to be packed to avoid having it padded to 56
129 * bytes on 64-bit architectures.
130 */
Roland Dreieraef9ec32005-11-02 14:07:13 -0800131struct srp_login_rsp {
132 u8 opcode;
133 u8 reserved1[3];
134 __be32 req_lim_delta;
135 u64 tag;
136 __be32 max_it_iu_len;
137 __be32 max_ti_iu_len;
138 __be16 buf_fmt;
139 u8 rsp_flags;
140 u8 reserved2[25];
Roland Dreierec448a02006-04-18 09:05:39 -0700141} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800142
143struct srp_login_rej {
144 u8 opcode;
145 u8 reserved1[3];
146 __be32 reason;
147 u64 tag;
148 u8 reserved2[8];
149 __be16 buf_fmt;
150 u8 reserved3[6];
151};
152
153struct srp_i_logout {
154 u8 opcode;
155 u8 reserved[7];
156 u64 tag;
157};
158
159struct srp_t_logout {
160 u8 opcode;
161 u8 sol_not;
162 u8 reserved[2];
163 __be32 reason;
164 u64 tag;
165};
166
167/*
168 * We need the packed attribute because the SRP spec only aligns the
169 * 8-byte LUN field to 4 bytes.
170 */
171struct srp_tsk_mgmt {
172 u8 opcode;
173 u8 sol_not;
174 u8 reserved1[6];
175 u64 tag;
176 u8 reserved2[4];
177 __be64 lun __attribute__((packed));
178 u8 reserved3[2];
179 u8 tsk_mgmt_func;
180 u8 reserved4;
181 u64 task_tag;
182 u8 reserved5[8];
183};
184
185/*
186 * We need the packed attribute because the SRP spec only aligns the
187 * 8-byte LUN field to 4 bytes.
188 */
189struct srp_cmd {
190 u8 opcode;
191 u8 sol_not;
192 u8 reserved1[3];
193 u8 buf_fmt;
194 u8 data_out_desc_cnt;
195 u8 data_in_desc_cnt;
196 u64 tag;
197 u8 reserved2[4];
198 __be64 lun __attribute__((packed));
199 u8 reserved3;
200 u8 task_attr;
201 u8 reserved4;
202 u8 add_cdb_len;
203 u8 cdb[16];
204 u8 add_data[0];
205};
206
207enum {
208 SRP_RSP_FLAG_RSPVALID = 1 << 0,
209 SRP_RSP_FLAG_SNSVALID = 1 << 1,
210 SRP_RSP_FLAG_DOOVER = 1 << 2,
211 SRP_RSP_FLAG_DOUNDER = 1 << 3,
212 SRP_RSP_FLAG_DIOVER = 1 << 4,
213 SRP_RSP_FLAG_DIUNDER = 1 << 5
214};
215
Roland Dreierec448a02006-04-18 09:05:39 -0700216/*
217 * The SRP spec defines the size of the RSP structure to be 36 bytes,
218 * so it needs to be packed to avoid having it padded to 40 bytes on
219 * 64-bit architectures.
220 */
Roland Dreieraef9ec32005-11-02 14:07:13 -0800221struct srp_rsp {
222 u8 opcode;
223 u8 sol_not;
224 u8 reserved1[2];
225 __be32 req_lim_delta;
226 u64 tag;
227 u8 reserved2[2];
228 u8 flags;
229 u8 status;
230 __be32 data_out_res_cnt;
231 __be32 data_in_res_cnt;
232 __be32 sense_data_len;
233 __be32 resp_data_len;
234 u8 data[0];
Roland Dreierec448a02006-04-18 09:05:39 -0700235} __attribute__((packed));
Roland Dreieraef9ec32005-11-02 14:07:13 -0800236
237#endif /* SCSI_SRP_H */