diff options
Diffstat (limited to 'include/scsi/iscsi_proto.h')
-rw-r--r-- | include/scsi/iscsi_proto.h | 78 |
1 files changed, 61 insertions, 17 deletions
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h index dd0a52cea95a..988ba06b3ad6 100644 --- a/include/scsi/iscsi_proto.h +++ b/include/scsi/iscsi_proto.h | |||
@@ -29,10 +29,40 @@ | |||
29 | /* default iSCSI listen port for incoming connections */ | 29 | /* default iSCSI listen port for incoming connections */ |
30 | #define ISCSI_LISTEN_PORT 3260 | 30 | #define ISCSI_LISTEN_PORT 3260 |
31 | 31 | ||
32 | /* iSCSI header length */ | ||
33 | #define ISCSI_HDR_LEN 48 | ||
34 | |||
35 | /* iSCSI CRC32C length */ | ||
36 | #define ISCSI_CRC_LEN 4 | ||
37 | |||
32 | /* Padding word length */ | 38 | /* Padding word length */ |
33 | #define ISCSI_PAD_LEN 4 | 39 | #define ISCSI_PAD_LEN 4 |
34 | 40 | ||
35 | /* | 41 | /* |
42 | * Serial Number Arithmetic, 32 bits, RFC1982 | ||
43 | */ | ||
44 | |||
45 | static inline int iscsi_sna_lt(u32 n1, u32 n2) | ||
46 | { | ||
47 | return (s32)(n1 - n2) < 0; | ||
48 | } | ||
49 | |||
50 | static inline int iscsi_sna_lte(u32 n1, u32 n2) | ||
51 | { | ||
52 | return (s32)(n1 - n2) <= 0; | ||
53 | } | ||
54 | |||
55 | static inline int iscsi_sna_gt(u32 n1, u32 n2) | ||
56 | { | ||
57 | return (s32)(n1 - n2) > 0; | ||
58 | } | ||
59 | |||
60 | static inline int iscsi_sna_gte(u32 n1, u32 n2) | ||
61 | { | ||
62 | return (s32)(n1 - n2) >= 0; | ||
63 | } | ||
64 | |||
65 | /* | ||
36 | * useful common(control and data pathes) macro | 66 | * useful common(control and data pathes) macro |
37 | */ | 67 | */ |
38 | #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) | 68 | #define ntoh24(p) (((p)[0] << 16) | ((p)[1] << 8) | ((p)[2])) |
@@ -60,7 +90,7 @@ struct iscsi_hdr { | |||
60 | uint8_t rsvd2[2]; | 90 | uint8_t rsvd2[2]; |
61 | uint8_t hlength; /* AHSs total length */ | 91 | uint8_t hlength; /* AHSs total length */ |
62 | uint8_t dlength[3]; /* Data length */ | 92 | uint8_t dlength[3]; /* Data length */ |
63 | uint8_t lun[8]; | 93 | struct scsi_lun lun; |
64 | itt_t itt; /* Initiator Task Tag, opaque for target */ | 94 | itt_t itt; /* Initiator Task Tag, opaque for target */ |
65 | __be32 ttt; /* Target Task Tag */ | 95 | __be32 ttt; /* Target Task Tag */ |
66 | __be32 statsn; | 96 | __be32 statsn; |
@@ -116,13 +146,13 @@ struct iscsi_ahs_hdr { | |||
116 | #define ISCSI_CDB_SIZE 16 | 146 | #define ISCSI_CDB_SIZE 16 |
117 | 147 | ||
118 | /* iSCSI PDU Header */ | 148 | /* iSCSI PDU Header */ |
119 | struct iscsi_cmd { | 149 | struct iscsi_scsi_req { |
120 | uint8_t opcode; | 150 | uint8_t opcode; |
121 | uint8_t flags; | 151 | uint8_t flags; |
122 | __be16 rsvd2; | 152 | __be16 rsvd2; |
123 | uint8_t hlength; | 153 | uint8_t hlength; |
124 | uint8_t dlength[3]; | 154 | uint8_t dlength[3]; |
125 | uint8_t lun[8]; | 155 | struct scsi_lun lun; |
126 | itt_t itt; /* Initiator Task Tag */ | 156 | itt_t itt; /* Initiator Task Tag */ |
127 | __be32 data_length; | 157 | __be32 data_length; |
128 | __be32 cmdsn; | 158 | __be32 cmdsn; |
@@ -161,7 +191,7 @@ struct iscsi_ecdb_ahdr { | |||
161 | }; | 191 | }; |
162 | 192 | ||
163 | /* SCSI Response Header */ | 193 | /* SCSI Response Header */ |
164 | struct iscsi_cmd_rsp { | 194 | struct iscsi_scsi_rsp { |
165 | uint8_t opcode; | 195 | uint8_t opcode; |
166 | uint8_t flags; | 196 | uint8_t flags; |
167 | uint8_t response; | 197 | uint8_t response; |
@@ -198,7 +228,7 @@ struct iscsi_async { | |||
198 | uint8_t rsvd2[2]; | 228 | uint8_t rsvd2[2]; |
199 | uint8_t rsvd3; | 229 | uint8_t rsvd3; |
200 | uint8_t dlength[3]; | 230 | uint8_t dlength[3]; |
201 | uint8_t lun[8]; | 231 | struct scsi_lun lun; |
202 | uint8_t rsvd4[8]; | 232 | uint8_t rsvd4[8]; |
203 | __be32 statsn; | 233 | __be32 statsn; |
204 | __be32 exp_cmdsn; | 234 | __be32 exp_cmdsn; |
@@ -226,7 +256,7 @@ struct iscsi_nopout { | |||
226 | __be16 rsvd2; | 256 | __be16 rsvd2; |
227 | uint8_t rsvd3; | 257 | uint8_t rsvd3; |
228 | uint8_t dlength[3]; | 258 | uint8_t dlength[3]; |
229 | uint8_t lun[8]; | 259 | struct scsi_lun lun; |
230 | itt_t itt; /* Initiator Task Tag */ | 260 | itt_t itt; /* Initiator Task Tag */ |
231 | __be32 ttt; /* Target Transfer Tag */ | 261 | __be32 ttt; /* Target Transfer Tag */ |
232 | __be32 cmdsn; | 262 | __be32 cmdsn; |
@@ -241,7 +271,7 @@ struct iscsi_nopin { | |||
241 | __be16 rsvd2; | 271 | __be16 rsvd2; |
242 | uint8_t rsvd3; | 272 | uint8_t rsvd3; |
243 | uint8_t dlength[3]; | 273 | uint8_t dlength[3]; |
244 | uint8_t lun[8]; | 274 | struct scsi_lun lun; |
245 | itt_t itt; /* Initiator Task Tag */ | 275 | itt_t itt; /* Initiator Task Tag */ |
246 | __be32 ttt; /* Target Transfer Tag */ | 276 | __be32 ttt; /* Target Transfer Tag */ |
247 | __be32 statsn; | 277 | __be32 statsn; |
@@ -257,7 +287,7 @@ struct iscsi_tm { | |||
257 | uint8_t rsvd1[2]; | 287 | uint8_t rsvd1[2]; |
258 | uint8_t hlength; | 288 | uint8_t hlength; |
259 | uint8_t dlength[3]; | 289 | uint8_t dlength[3]; |
260 | uint8_t lun[8]; | 290 | struct scsi_lun lun; |
261 | itt_t itt; /* Initiator Task Tag */ | 291 | itt_t itt; /* Initiator Task Tag */ |
262 | itt_t rtt; /* Reference Task Tag */ | 292 | itt_t rtt; /* Reference Task Tag */ |
263 | __be32 cmdsn; | 293 | __be32 cmdsn; |
@@ -315,7 +345,7 @@ struct iscsi_r2t_rsp { | |||
315 | uint8_t rsvd2[2]; | 345 | uint8_t rsvd2[2]; |
316 | uint8_t hlength; | 346 | uint8_t hlength; |
317 | uint8_t dlength[3]; | 347 | uint8_t dlength[3]; |
318 | uint8_t lun[8]; | 348 | struct scsi_lun lun; |
319 | itt_t itt; /* Initiator Task Tag */ | 349 | itt_t itt; /* Initiator Task Tag */ |
320 | __be32 ttt; /* Target Transfer Tag */ | 350 | __be32 ttt; /* Target Transfer Tag */ |
321 | __be32 statsn; | 351 | __be32 statsn; |
@@ -333,7 +363,7 @@ struct iscsi_data { | |||
333 | uint8_t rsvd2[2]; | 363 | uint8_t rsvd2[2]; |
334 | uint8_t rsvd3; | 364 | uint8_t rsvd3; |
335 | uint8_t dlength[3]; | 365 | uint8_t dlength[3]; |
336 | uint8_t lun[8]; | 366 | struct scsi_lun lun; |
337 | itt_t itt; | 367 | itt_t itt; |
338 | __be32 ttt; | 368 | __be32 ttt; |
339 | __be32 rsvd4; | 369 | __be32 rsvd4; |
@@ -353,7 +383,7 @@ struct iscsi_data_rsp { | |||
353 | uint8_t cmd_status; | 383 | uint8_t cmd_status; |
354 | uint8_t hlength; | 384 | uint8_t hlength; |
355 | uint8_t dlength[3]; | 385 | uint8_t dlength[3]; |
356 | uint8_t lun[8]; | 386 | struct scsi_lun lun; |
357 | itt_t itt; | 387 | itt_t itt; |
358 | __be32 ttt; | 388 | __be32 ttt; |
359 | __be32 statsn; | 389 | __be32 statsn; |
@@ -406,7 +436,7 @@ struct iscsi_text_rsp { | |||
406 | }; | 436 | }; |
407 | 437 | ||
408 | /* Login Header */ | 438 | /* Login Header */ |
409 | struct iscsi_login { | 439 | struct iscsi_login_req { |
410 | uint8_t opcode; | 440 | uint8_t opcode; |
411 | uint8_t flags; | 441 | uint8_t flags; |
412 | uint8_t max_version; /* Max. version supported */ | 442 | uint8_t max_version; /* Max. version supported */ |
@@ -427,7 +457,13 @@ struct iscsi_login { | |||
427 | #define ISCSI_FLAG_LOGIN_TRANSIT 0x80 | 457 | #define ISCSI_FLAG_LOGIN_TRANSIT 0x80 |
428 | #define ISCSI_FLAG_LOGIN_CONTINUE 0x40 | 458 | #define ISCSI_FLAG_LOGIN_CONTINUE 0x40 |
429 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */ | 459 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK 0x0C /* 2 bits */ |
460 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE1 0x04 | ||
461 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE2 0x08 | ||
462 | #define ISCSI_FLAG_LOGIN_CURRENT_STAGE3 0x0C | ||
430 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */ | 463 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE_MASK 0x03 /* 2 bits */ |
464 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE1 0x01 | ||
465 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE2 0x02 | ||
466 | #define ISCSI_FLAG_LOGIN_NEXT_STAGE3 0x03 | ||
431 | 467 | ||
432 | #define ISCSI_LOGIN_CURRENT_STAGE(flags) \ | 468 | #define ISCSI_LOGIN_CURRENT_STAGE(flags) \ |
433 | ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2) | 469 | ((flags & ISCSI_FLAG_LOGIN_CURRENT_STAGE_MASK) >> 2) |
@@ -550,17 +586,25 @@ struct iscsi_logout_rsp { | |||
550 | struct iscsi_snack { | 586 | struct iscsi_snack { |
551 | uint8_t opcode; | 587 | uint8_t opcode; |
552 | uint8_t flags; | 588 | uint8_t flags; |
553 | uint8_t rsvd2[14]; | 589 | uint8_t rsvd2[2]; |
590 | uint8_t hlength; | ||
591 | uint8_t dlength[3]; | ||
592 | uint8_t lun[8]; | ||
554 | itt_t itt; | 593 | itt_t itt; |
594 | __be32 ttt; | ||
595 | uint8_t rsvd3[4]; | ||
596 | __be32 exp_statsn; | ||
597 | uint8_t rsvd4[8]; | ||
555 | __be32 begrun; | 598 | __be32 begrun; |
556 | __be32 runlength; | 599 | __be32 runlength; |
557 | __be32 exp_statsn; | ||
558 | __be32 rsvd3; | ||
559 | __be32 exp_datasn; | ||
560 | uint8_t rsvd6[8]; | ||
561 | }; | 600 | }; |
562 | 601 | ||
563 | /* SNACK PDU flags */ | 602 | /* SNACK PDU flags */ |
603 | #define ISCSI_FLAG_SNACK_TYPE_DATA 0 | ||
604 | #define ISCSI_FLAG_SNACK_TYPE_R2T 0 | ||
605 | #define ISCSI_FLAG_SNACK_TYPE_STATUS 1 | ||
606 | #define ISCSI_FLAG_SNACK_TYPE_DATA_ACK 2 | ||
607 | #define ISCSI_FLAG_SNACK_TYPE_RDATA 3 | ||
564 | #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */ | 608 | #define ISCSI_FLAG_SNACK_TYPE_MASK 0x0F /* 4 bits */ |
565 | 609 | ||
566 | /* Reject Message Header */ | 610 | /* Reject Message Header */ |