aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-27 16:21:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-27 16:21:40 -0400
commit91d41fdf31f74e6e2e5f3cb018eca4200e36e202 (patch)
tree81ef11f06bd8047031a2d93706dc263fa1bacd56 /include/scsi
parentc1095c6da518b0b64e724f629051fa67655cd8d9 (diff)
parent277c5f27a2c86a9a733c0ec0f6a9b1032dfa3e15 (diff)
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: target: Convert to DIV_ROUND_UP_SECTOR_T usage for sectors / dev_max_sectors kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage iscsi-target: Add iSCSI fabric support for target v4.1 iscsi: Add Serial Number Arithmetic LT and GT into iscsi_proto.h iscsi: Use struct scsi_lun in iscsi structs instead of u8[8] iscsi: Resolve iscsi_proto.h naming conflicts with drivers/target/iscsi
Diffstat (limited to 'include/scsi')
-rw-r--r--include/scsi/iscsi_proto.h60
1 files changed, 52 insertions, 8 deletions
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index ea68b3c56dbf..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
45static inline int iscsi_sna_lt(u32 n1, u32 n2)
46{
47 return (s32)(n1 - n2) < 0;
48}
49
50static inline int iscsi_sna_lte(u32 n1, u32 n2)
51{
52 return (s32)(n1 - n2) <= 0;
53}
54
55static inline int iscsi_sna_gt(u32 n1, u32 n2)
56{
57 return (s32)(n1 - n2) > 0;
58}
59
60static 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]))
@@ -116,7 +146,7 @@ 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 */
119struct iscsi_cmd { 149struct 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;
@@ -161,7 +191,7 @@ struct iscsi_ecdb_ahdr {
161}; 191};
162 192
163/* SCSI Response Header */ 193/* SCSI Response Header */
164struct iscsi_cmd_rsp { 194struct 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;
@@ -406,7 +436,7 @@ struct iscsi_text_rsp {
406}; 436};
407 437
408/* Login Header */ 438/* Login Header */
409struct iscsi_login { 439struct 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 {
550struct iscsi_snack { 586struct 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 */