]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - include/scsi/iscsi_proto.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157
[mirror_ubuntu-hirsute-kernel.git] / include / scsi / iscsi_proto.h
CommitLineData
c942fddf 1/* SPDX-License-Identifier: GPL-2.0-or-later */
39e84790
AA
2/*
3 * RFC 3720 (iSCSI) protocol data types
4 *
5 * Copyright (C) 2005 Dmitry Yusupov
6 * Copyright (C) 2005 Alex Aizman
7 * maintained by open-iscsi@googlegroups.com
8 *
39e84790
AA
9 * See the file COPYING included with this distribution for more details.
10 */
11
12#ifndef ISCSI_PROTO_H
13#define ISCSI_PROTO_H
14
26974789 15#include <linux/types.h>
30e9ba9f 16#include <scsi/scsi.h>
26974789 17
39e84790
AA
18#define ISCSI_DRAFT20_VERSION 0x00
19
20/* default iSCSI listen port for incoming connections */
21#define ISCSI_LISTEN_PORT 3260
22
8304bbce
NB
23/* iSCSI header length */
24#define ISCSI_HDR_LEN 48
25
26/* iSCSI CRC32C length */
27#define ISCSI_CRC_LEN 4
28
39e84790 29/* Padding word length */
004d6530 30#define ISCSI_PAD_LEN 4
39e84790 31
8304bbce
NB
32/*
33 * Serial Number Arithmetic, 32 bits, RFC1982
34 */
35
36static inline int iscsi_sna_lt(u32 n1, u32 n2)
37{
38 return (s32)(n1 - n2) < 0;
39}
40
41static inline int iscsi_sna_lte(u32 n1, u32 n2)
42{
43 return (s32)(n1 - n2) <= 0;
44}
45
46static inline int iscsi_sna_gt(u32 n1, u32 n2)
47{
48 return (s32)(n1 - n2) > 0;
49}
50
51static inline int iscsi_sna_gte(u32 n1, u32 n2)
52{
53 return (s32)(n1 - n2) >= 0;
54}
55
39e84790
AA
56/*
57 * useful common(control and data pathes) macro
58 */
59#define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2]))
60#define hton24(p, v) { \
61 p[0] = (((v) >> 16) & 0xFF); \
62 p[1] = (((v) >> 8) & 0xFF); \
63 p[2] = ((v) & 0xFF); \
64}
65#define zero_data(p) {p[0]=0;p[1]=0;p[2]=0;}
66
b4377356 67/* initiator tags; opaque for target */
9efeccac 68typedef uint32_t __bitwise itt_t;
b4377356 69/* below makes sense only for initiator that created this tag */
8b1d0343
MC
70#define build_itt(itt, age) ((__force itt_t)\
71 ((itt) | ((age) << ISCSI_AGE_SHIFT)))
b4377356
AV
72#define get_itt(itt) ((__force uint32_t)(itt_t)(itt) & ISCSI_ITT_MASK)
73#define RESERVED_ITT ((__force itt_t)0xffffffff)
74
39e84790
AA
75/*
76 * iSCSI Template Message Header
77 */
78struct iscsi_hdr {
79 uint8_t opcode;
80 uint8_t flags; /* Final bit */
81 uint8_t rsvd2[2];
82 uint8_t hlength; /* AHSs total length */
83 uint8_t dlength[3]; /* Data length */
55bdabdf 84 struct scsi_lun lun;
b4377356 85 itt_t itt; /* Initiator Task Tag, opaque for target */
39e84790
AA
86 __be32 ttt; /* Target Task Tag */
87 __be32 statsn;
88 __be32 exp_statsn;
baebc497
MC
89 __be32 max_statsn;
90 uint8_t other[12];
39e84790
AA
91};
92
93/************************* RFC 3720 Begin *****************************/
94
95#define ISCSI_RESERVED_TAG 0xffffffff
96
97/* Opcode encoding bits */
98#define ISCSI_OP_RETRY 0x80
99#define ISCSI_OP_IMMEDIATE 0x40
100#define ISCSI_OPCODE_MASK 0x3F
101
102/* Initiator Opcode values */
103#define ISCSI_OP_NOOP_OUT 0x00
104#define ISCSI_OP_SCSI_CMD 0x01
105#define ISCSI_OP_SCSI_TMFUNC 0x02
106#define ISCSI_OP_LOGIN 0x03
107#define ISCSI_OP_TEXT 0x04
108#define ISCSI_OP_SCSI_DATA_OUT 0x05
109#define ISCSI_OP_LOGOUT 0x06
110#define ISCSI_OP_SNACK 0x10
111
baebc497
MC
112#define ISCSI_OP_VENDOR1_CMD 0x1c
113#define ISCSI_OP_VENDOR2_CMD 0x1d
114#define ISCSI_OP_VENDOR3_CMD 0x1e
115#define ISCSI_OP_VENDOR4_CMD 0x1f
116
39e84790
AA
117/* Target Opcode values */
118#define ISCSI_OP_NOOP_IN 0x20
119#define ISCSI_OP_SCSI_CMD_RSP 0x21
120#define ISCSI_OP_SCSI_TMFUNC_RSP 0x22
121#define ISCSI_OP_LOGIN_RSP 0x23
122#define ISCSI_OP_TEXT_RSP 0x24
123#define ISCSI_OP_SCSI_DATA_IN 0x25
124#define ISCSI_OP_LOGOUT_RSP 0x26
125#define ISCSI_OP_R2T 0x31
126#define ISCSI_OP_ASYNC_EVENT 0x32
127#define ISCSI_OP_REJECT 0x3f
128
baebc497
MC
129struct iscsi_ahs_hdr {
130 __be16 ahslength;
131 uint8_t ahstype;
132 uint8_t ahspec[5];
133};
134
135#define ISCSI_AHSTYPE_CDB 1
136#define ISCSI_AHSTYPE_RLENGTH 2
38d1c069 137#define ISCSI_CDB_SIZE 16
baebc497 138
39e84790 139/* iSCSI PDU Header */
12352183 140struct iscsi_scsi_req {
39e84790
AA
141 uint8_t opcode;
142 uint8_t flags;
baebc497 143 __be16 rsvd2;
39e84790
AA
144 uint8_t hlength;
145 uint8_t dlength[3];
55bdabdf 146 struct scsi_lun lun;
b4377356 147 itt_t itt; /* Initiator Task Tag */
39e84790
AA
148 __be32 data_length;
149 __be32 cmdsn;
150 __be32 exp_statsn;
38d1c069 151 uint8_t cdb[ISCSI_CDB_SIZE]; /* SCSI Command Block */
39e84790
AA
152 /* Additional Data (Command Dependent) */
153};
154
155/* Command PDU flags */
156#define ISCSI_FLAG_CMD_FINAL 0x80
157#define ISCSI_FLAG_CMD_READ 0x40
158#define ISCSI_FLAG_CMD_WRITE 0x20
159#define ISCSI_FLAG_CMD_ATTR_MASK 0x07 /* 3 bits */
160
161/* SCSI Command Attribute values */
162#define ISCSI_ATTR_UNTAGGED 0
163#define ISCSI_ATTR_SIMPLE 1
164#define ISCSI_ATTR_ORDERED 2
165#define ISCSI_ATTR_HEAD_OF_QUEUE 3
166#define ISCSI_ATTR_ACA 4
167
baebc497
MC
168struct iscsi_rlength_ahdr {
169 __be16 ahslength;
170 uint8_t ahstype;
171 uint8_t reserved;
172 __be32 read_length;
173};
174
004d6530
BH
175/* Extended CDB AHS */
176struct iscsi_ecdb_ahdr {
177 __be16 ahslength; /* CDB length - 15, including reserved byte */
178 uint8_t ahstype;
179 uint8_t reserved;
38d1c069 180 /* 4-byte aligned extended CDB spillover */
30e9ba9f 181 uint8_t ecdb[SCSI_MAX_VARLEN_CDB_SIZE - ISCSI_CDB_SIZE];
004d6530
BH
182};
183
39e84790 184/* SCSI Response Header */
12352183 185struct iscsi_scsi_rsp {
39e84790
AA
186 uint8_t opcode;
187 uint8_t flags;
188 uint8_t response;
189 uint8_t cmd_status;
190 uint8_t hlength;
191 uint8_t dlength[3];
192 uint8_t rsvd[8];
b4377356 193 itt_t itt; /* Initiator Task Tag */
39e84790
AA
194 __be32 rsvd1;
195 __be32 statsn;
196 __be32 exp_cmdsn;
197 __be32 max_cmdsn;
198 __be32 exp_datasn;
199 __be32 bi_residual_count;
200 __be32 residual_count;
201 /* Response or Sense Data (optional) */
202};
203
204/* Command Response PDU flags */
205#define ISCSI_FLAG_CMD_BIDI_OVERFLOW 0x10
206#define ISCSI_FLAG_CMD_BIDI_UNDERFLOW 0x08
207#define ISCSI_FLAG_CMD_OVERFLOW 0x04
208#define ISCSI_FLAG_CMD_UNDERFLOW 0x02
209
210/* iSCSI Status values. Valid if Rsp Selector bit is not set */
211#define ISCSI_STATUS_CMD_COMPLETED 0
212#define ISCSI_STATUS_TARGET_FAILURE 1
213#define ISCSI_STATUS_SUBSYS_FAILURE 2
214
215/* Asynchronous Event Header */
216struct iscsi_async {
217 uint8_t opcode;
218 uint8_t flags;
219 uint8_t rsvd2[2];
220 uint8_t rsvd3;
221 uint8_t dlength[3];
55bdabdf 222 struct scsi_lun lun;
39e84790
AA
223 uint8_t rsvd4[8];
224 __be32 statsn;
225 __be32 exp_cmdsn;
226 __be32 max_cmdsn;
227 uint8_t async_event;
228 uint8_t async_vcode;
229 __be16 param1;
230 __be16 param2;
231 __be16 param3;
232 uint8_t rsvd5[4];
233};
234
235/* iSCSI Event Codes */
236#define ISCSI_ASYNC_MSG_SCSI_EVENT 0
237#define ISCSI_ASYNC_MSG_REQUEST_LOGOUT 1
238#define ISCSI_ASYNC_MSG_DROPPING_CONNECTION 2
239#define ISCSI_ASYNC_MSG_DROPPING_ALL_CONNECTIONS 3
240#define ISCSI_ASYNC_MSG_PARAM_NEGOTIATION 4
241#define ISCSI_ASYNC_MSG_VENDOR_SPECIFIC 255
242
243/* NOP-Out Message */
244struct iscsi_nopout {
245 uint8_t opcode;
246 uint8_t flags;
247 __be16 rsvd2;
248 uint8_t rsvd3;
249 uint8_t dlength[3];
55bdabdf 250 struct scsi_lun lun;
b4377356 251 itt_t itt; /* Initiator Task Tag */
39e84790
AA
252 __be32 ttt; /* Target Transfer Tag */
253 __be32 cmdsn;
254 __be32 exp_statsn;
255 uint8_t rsvd4[16];
256};
257
258/* NOP-In Message */
259struct iscsi_nopin {
260 uint8_t opcode;
261 uint8_t flags;
262 __be16 rsvd2;
263 uint8_t rsvd3;
264 uint8_t dlength[3];
55bdabdf 265 struct scsi_lun lun;
b4377356 266 itt_t itt; /* Initiator Task Tag */
39e84790
AA
267 __be32 ttt; /* Target Transfer Tag */
268 __be32 statsn;
269 __be32 exp_cmdsn;
270 __be32 max_cmdsn;
271 uint8_t rsvd4[12];
272};
273
274/* SCSI Task Management Message Header */
275struct iscsi_tm {
276 uint8_t opcode;
277 uint8_t flags;
278 uint8_t rsvd1[2];
279 uint8_t hlength;
280 uint8_t dlength[3];
55bdabdf 281 struct scsi_lun lun;
b4377356
AV
282 itt_t itt; /* Initiator Task Tag */
283 itt_t rtt; /* Reference Task Tag */
39e84790
AA
284 __be32 cmdsn;
285 __be32 exp_statsn;
286 __be32 refcmdsn;
287 __be32 exp_datasn;
288 uint8_t rsvd2[8];
289};
290
baebc497 291#define ISCSI_FLAG_TM_FUNC_MASK 0x7F
39e84790
AA
292
293/* Function values */
294#define ISCSI_TM_FUNC_ABORT_TASK 1
295#define ISCSI_TM_FUNC_ABORT_TASK_SET 2
296#define ISCSI_TM_FUNC_CLEAR_ACA 3
297#define ISCSI_TM_FUNC_CLEAR_TASK_SET 4
298#define ISCSI_TM_FUNC_LOGICAL_UNIT_RESET 5
299#define ISCSI_TM_FUNC_TARGET_WARM_RESET 6
300#define ISCSI_TM_FUNC_TARGET_COLD_RESET 7
301#define ISCSI_TM_FUNC_TASK_REASSIGN 8
302
5d12c05e
MC
303#define ISCSI_TM_FUNC_VALUE(hdr) ((hdr)->flags & ISCSI_FLAG_TM_FUNC_MASK)
304
39e84790
AA
305/* SCSI Task Management Response Header */
306struct iscsi_tm_rsp {
307 uint8_t opcode;
308 uint8_t flags;
309 uint8_t response; /* see Response values below */
310 uint8_t qualifier;
311 uint8_t hlength;
312 uint8_t dlength[3];
313 uint8_t rsvd2[8];
b4377356
AV
314 itt_t itt; /* Initiator Task Tag */
315 itt_t rtt; /* Reference Task Tag */
39e84790
AA
316 __be32 statsn;
317 __be32 exp_cmdsn;
318 __be32 max_cmdsn;
319 uint8_t rsvd3[12];
320};
321
322/* Response values */
baebc497
MC
323#define ISCSI_TMF_RSP_COMPLETE 0x00
324#define ISCSI_TMF_RSP_NO_TASK 0x01
325#define ISCSI_TMF_RSP_NO_LUN 0x02
326#define ISCSI_TMF_RSP_TASK_ALLEGIANT 0x03
327#define ISCSI_TMF_RSP_NO_FAILOVER 0x04
328#define ISCSI_TMF_RSP_NOT_SUPPORTED 0x05
329#define ISCSI_TMF_RSP_AUTH_FAILED 0x06
330#define ISCSI_TMF_RSP_REJECTED 0xff
39e84790
AA
331
332/* Ready To Transfer Header */
333struct iscsi_r2t_rsp {
334 uint8_t opcode;
335 uint8_t flags;
336 uint8_t rsvd2[2];
337 uint8_t hlength;
338 uint8_t dlength[3];
55bdabdf 339 struct scsi_lun lun;
b4377356 340 itt_t itt; /* Initiator Task Tag */
39e84790
AA
341 __be32 ttt; /* Target Transfer Tag */
342 __be32 statsn;
343 __be32 exp_cmdsn;
344 __be32 max_cmdsn;
345 __be32 r2tsn;
346 __be32 data_offset;
347 __be32 data_length;
348};
349
350/* SCSI Data Hdr */
351struct iscsi_data {
352 uint8_t opcode;
353 uint8_t flags;
354 uint8_t rsvd2[2];
355 uint8_t rsvd3;
356 uint8_t dlength[3];
55bdabdf 357 struct scsi_lun lun;
b4377356 358 itt_t itt;
39e84790
AA
359 __be32 ttt;
360 __be32 rsvd4;
361 __be32 exp_statsn;
362 __be32 rsvd5;
363 __be32 datasn;
364 __be32 offset;
365 __be32 rsvd6;
366 /* Payload */
367};
368
369/* SCSI Data Response Hdr */
370struct iscsi_data_rsp {
371 uint8_t opcode;
372 uint8_t flags;
373 uint8_t rsvd2;
374 uint8_t cmd_status;
375 uint8_t hlength;
376 uint8_t dlength[3];
55bdabdf 377 struct scsi_lun lun;
b4377356 378 itt_t itt;
39e84790
AA
379 __be32 ttt;
380 __be32 statsn;
381 __be32 exp_cmdsn;
382 __be32 max_cmdsn;
383 __be32 datasn;
384 __be32 offset;
385 __be32 residual_count;
386};
387
388/* Data Response PDU flags */
389#define ISCSI_FLAG_DATA_ACK 0x40
390#define ISCSI_FLAG_DATA_OVERFLOW 0x04
391#define ISCSI_FLAG_DATA_UNDERFLOW 0x02
392#define ISCSI_FLAG_DATA_STATUS 0x01
393
394/* Text Header */
395struct iscsi_text {
396 uint8_t opcode;
397 uint8_t flags;
398 uint8_t rsvd2[2];
399 uint8_t hlength;
400 uint8_t dlength[3];
401 uint8_t rsvd4[8];
b4377356 402 itt_t itt;
39e84790
AA
403 __be32 ttt;
404 __be32 cmdsn;
405 __be32 exp_statsn;
406 uint8_t rsvd5[16];
407 /* Text - key=value pairs */
408};
409
410#define ISCSI_FLAG_TEXT_CONTINUE 0x40
411
412/* Text Response Header */
413struct iscsi_text_rsp {
414 uint8_t opcode;
415 uint8_t flags;
416 uint8_t rsvd2[2];
417 uint8_t hlength;
418 uint8_t dlength[3];
419 uint8_t rsvd4[8];
b4377356 420 itt_t itt;
39e84790
AA
421 __be32 ttt;
422 __be32 statsn;
423 __be32 exp_cmdsn;
424 __be32 max_cmdsn;
425 uint8_t rsvd5[12];
426 /* Text Response - key:value pairs */
427};
428
429/* Login Header */
12352183 430struct iscsi_login_req {
39e84790
AA
431 uint8_t opcode;
432 uint8_t flags;
433 uint8_t max_version; /* Max. version supported */
434 uint8_t min_version; /* Min. version supported */
435 uint8_t hlength;
436 uint8_t dlength[3];
437 uint8_t isid[6]; /* Initiator Session ID */
438 __be16 tsih; /* Target Session Handle */
b4377356 439 itt_t itt; /* Initiator Task Tag */
39e84790
AA
440 __be16 cid;
441 __be16 rsvd3;
442 __be32 cmdsn;
443 __be32 exp_statsn;
444 uint8_t rsvd5[16];
445};
446
447/* Login PDU flags */
448#define ISCSI_FLAG_LOGIN_TRANSIT 0x80
449#define ISCSI_FLAG_LOGIN_CONTINUE 0x40
450#define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */
12352183
NB
451#define ISCSI_FLAG_LOGIN_CURRENT_STAGE1 0x04
452#define ISCSI_FLAG_LOGIN_CURRENT_STAGE2 0x08
453#define ISCSI_FLAG_LOGIN_CURRENT_STAGE3 0x0C
39e84790 454#define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */
12352183
NB
455#define ISCSI_FLAG_LOGIN_NEXT_STAGE1 0x01
456#define ISCSI_FLAG_LOGIN_NEXT_STAGE2 0x02
457#define ISCSI_FLAG_LOGIN_NEXT_STAGE3 0x03
39e84790
AA
458
459#define ISCSI_LOGIN_CURRENT_STAGE(flags) \
460 ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2)
461#define ISCSI_LOGIN_NEXT_STAGE(flags) \
462 (flags & ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK)
463
464/* Login Response Header */
465struct iscsi_login_rsp {
466 uint8_t opcode;
467 uint8_t flags;
468 uint8_t max_version; /* Max. version supported */
469 uint8_t active_version; /* Active version */
470 uint8_t hlength;
471 uint8_t dlength[3];
472 uint8_t isid[6]; /* Initiator Session ID */
473 __be16 tsih; /* Target Session Handle */
b4377356 474 itt_t itt; /* Initiator Task Tag */
39e84790
AA
475 __be32 rsvd3;
476 __be32 statsn;
477 __be32 exp_cmdsn;
478 __be32 max_cmdsn;
479 uint8_t status_class; /* see Login RSP ststus classes below */
480 uint8_t status_detail; /* see Login RSP Status details below */
481 uint8_t rsvd4[10];
482};
483
484/* Login stage (phase) codes for CSG, NSG */
485#define ISCSI_INITIAL_LOGIN_STAGE -1
486#define ISCSI_SECURITY_NEGOTIATION_STAGE 0
487#define ISCSI_OP_PARMS_NEGOTIATION_STAGE 1
488#define ISCSI_FULL_FEATURE_PHASE 3
489
490/* Login Status response classes */
491#define ISCSI_STATUS_CLS_SUCCESS 0x00
492#define ISCSI_STATUS_CLS_REDIRECT 0x01
493#define ISCSI_STATUS_CLS_INITIATOR_ERR 0x02
494#define ISCSI_STATUS_CLS_TARGET_ERR 0x03
495
496/* Login Status response detail codes */
497/* Class-0 (Success) */
498#define ISCSI_LOGIN_STATUS_ACCEPT 0x00
499
500/* Class-1 (Redirection) */
501#define ISCSI_LOGIN_STATUS_TGT_MOVED_TEMP 0x01
502#define ISCSI_LOGIN_STATUS_TGT_MOVED_PERM 0x02
503
504/* Class-2 (Initiator Error) */
505#define ISCSI_LOGIN_STATUS_INIT_ERR 0x00
506#define ISCSI_LOGIN_STATUS_AUTH_FAILED 0x01
507#define ISCSI_LOGIN_STATUS_TGT_FORBIDDEN 0x02
508#define ISCSI_LOGIN_STATUS_TGT_NOT_FOUND 0x03
509#define ISCSI_LOGIN_STATUS_TGT_REMOVED 0x04
510#define ISCSI_LOGIN_STATUS_NO_VERSION 0x05
511#define ISCSI_LOGIN_STATUS_ISID_ERROR 0x06
512#define ISCSI_LOGIN_STATUS_MISSING_FIELDS 0x07
513#define ISCSI_LOGIN_STATUS_CONN_ADD_FAILED 0x08
514#define ISCSI_LOGIN_STATUS_NO_SESSION_TYPE 0x09
515#define ISCSI_LOGIN_STATUS_NO_SESSION 0x0a
516#define ISCSI_LOGIN_STATUS_INVALID_REQUEST 0x0b
517
518/* Class-3 (Target Error) */
519#define ISCSI_LOGIN_STATUS_TARGET_ERROR 0x00
520#define ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE 0x01
521#define ISCSI_LOGIN_STATUS_NO_RESOURCES 0x02
522
523/* Logout Header */
524struct iscsi_logout {
525 uint8_t opcode;
526 uint8_t flags;
527 uint8_t rsvd1[2];
528 uint8_t hlength;
529 uint8_t dlength[3];
530 uint8_t rsvd2[8];
b4377356 531 itt_t itt; /* Initiator Task Tag */
39e84790
AA
532 __be16 cid;
533 uint8_t rsvd3[2];
534 __be32 cmdsn;
535 __be32 exp_statsn;
536 uint8_t rsvd4[16];
537};
538
539/* Logout PDU flags */
540#define ISCSI_FLAG_LOGOUT_REASON_MASK 0x7F
541
542/* logout reason_code values */
543
544#define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0
545#define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1
546#define ISCSI_LOGOUT_REASON_RECOVERY 2
547#define ISCSI_LOGOUT_REASON_AEN_REQUEST 3
548
549/* Logout Response Header */
550struct iscsi_logout_rsp {
551 uint8_t opcode;
552 uint8_t flags;
553 uint8_t response; /* see Logout response values below */
554 uint8_t rsvd2;
555 uint8_t hlength;
556 uint8_t dlength[3];
557 uint8_t rsvd3[8];
b4377356 558 itt_t itt; /* Initiator Task Tag */
39e84790
AA
559 __be32 rsvd4;
560 __be32 statsn;
561 __be32 exp_cmdsn;
562 __be32 max_cmdsn;
563 __be32 rsvd5;
564 __be16 t2wait;
565 __be16 t2retain;
566 __be32 rsvd6;
567};
568
569/* logout response status values */
570
571#define ISCSI_LOGOUT_SUCCESS 0
572#define ISCSI_LOGOUT_CID_NOT_FOUND 1
573#define ISCSI_LOGOUT_RECOVERY_UNSUPPORTED 2
574#define ISCSI_LOGOUT_CLEANUP_FAILED 3
575
576/* SNACK Header */
577struct iscsi_snack {
578 uint8_t opcode;
579 uint8_t flags;
12352183
NB
580 uint8_t rsvd2[2];
581 uint8_t hlength;
582 uint8_t dlength[3];
583 uint8_t lun[8];
b4377356 584 itt_t itt;
12352183
NB
585 __be32 ttt;
586 uint8_t rsvd3[4];
587 __be32 exp_statsn;
588 uint8_t rsvd4[8];
39e84790
AA
589 __be32 begrun;
590 __be32 runlength;
39e84790
AA
591};
592
593/* SNACK PDU flags */
12352183
NB
594#define ISCSI_FLAG_SNACK_TYPE_DATA 0
595#define ISCSI_FLAG_SNACK_TYPE_R2T 0
596#define ISCSI_FLAG_SNACK_TYPE_STATUS 1
597#define ISCSI_FLAG_SNACK_TYPE_DATA_ACK 2
598#define ISCSI_FLAG_SNACK_TYPE_RDATA 3
39e84790
AA
599#define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */
600
601/* Reject Message Header */
602struct iscsi_reject {
603 uint8_t opcode;
604 uint8_t flags;
605 uint8_t reason;
606 uint8_t rsvd2;
fa0a6957 607 uint8_t hlength;
39e84790 608 uint8_t dlength[3];
fa0a6957
MC
609 uint8_t rsvd3[8];
610 __be32 ffffffff;
611 uint8_t rsvd4[4];
39e84790
AA
612 __be32 statsn;
613 __be32 exp_cmdsn;
614 __be32 max_cmdsn;
615 __be32 datasn;
616 uint8_t rsvd5[8];
617 /* Text - Rejected hdr */
618};
619
620/* Reason for Reject */
fa0a6957
MC
621#define ISCSI_REASON_CMD_BEFORE_LOGIN 1
622#define ISCSI_REASON_DATA_DIGEST_ERROR 2
623#define ISCSI_REASON_DATA_SNACK_REJECT 3
624#define ISCSI_REASON_PROTOCOL_ERROR 4
625#define ISCSI_REASON_CMD_NOT_SUPPORTED 5
626#define ISCSI_REASON_IMM_CMD_REJECT 6
627#define ISCSI_REASON_TASK_IN_PROGRESS 7
628#define ISCSI_REASON_INVALID_SNACK 8
629#define ISCSI_REASON_BOOKMARK_INVALID 9
630#define ISCSI_REASON_BOOKMARK_NO_RESOURCES 10
631#define ISCSI_REASON_NEGOTIATION_RESET 11
39e84790
AA
632
633/* Max. number of Key=Value pairs in a text message */
634#define MAX_KEY_VALUE_PAIRS 8192
635
636/* maximum length for text keys/values */
637#define KEY_MAXLEN 64
638#define VALUE_MAXLEN 255
639#define TARGET_NAME_MAXLEN VALUE_MAXLEN
640
bf32ed33
MC
641#define ISCSI_DEF_MAX_RECV_SEG_LEN 8192
642#define ISCSI_MIN_MAX_RECV_SEG_LEN 512
643#define ISCSI_MAX_MAX_RECV_SEG_LEN 16777215
644
645#define ISCSI_DEF_FIRST_BURST_LEN 65536
646#define ISCSI_MIN_FIRST_BURST_LEN 512
647#define ISCSI_MAX_FIRST_BURST_LEN 16777215
648
649#define ISCSI_DEF_MAX_BURST_LEN 262144
650#define ISCSI_MIN_MAX_BURST_LEN 512
651#define ISCSI_MAX_MAX_BURST_LEN 16777215
39e84790 652
843c0a8a
MC
653#define ISCSI_DEF_TIME2WAIT 2
654
2177199d
JSJ
655#define ISCSI_NAME_LEN 224
656
39e84790
AA
657/************************* RFC 3720 End *****************************/
658
659#endif /* ISCSI_PROTO_H */