diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2007-12-13 13:43:23 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 19:28:23 -0500 |
commit | 004d6530f83bee43a55b51bb5960db96e7ae0ffa (patch) | |
tree | a7bb6ffb3e6e89ca6ee9b164d5f19899a0c100dd /include | |
parent | 7207fea452cfdd2d4e2f4419e2c31f570edbade3 (diff) |
[SCSI] iscsi_tcp, libiscsi: initial AHS Support
at libiscsi generic code
- currently code assumes a storage space of pdu header is allocated
at llds ctask and is pointed to by iscsi_cmd_task->hdr. Here I add
a hdr_max field pertaining to that storage, and an hdr_len that
accumulates the current use of the pdu-header.
- Add an iscsi_next_hdr() inline which returns the next free space
to write new Header at. Also iscsi_next_hdr() is used to retrieve
the address at which to write the header-digest.
- Add iscsi_add_hdr(length). What the user do is calls iscsi_next_hdr()
for address of the new header, than calls iscsi_add_hdr(length) with
the size of the new header. iscsi_add_hdr() will check if space is
available and update to the new size. length must be padded according
to standard.
- Add 2 padding inline helpers thanks to Olaf. Current patch does not
use them but Following patches will.
Also moved definition of ISCSI_PAD_LEN to iscsi_proto.h which had
PAD_WORD_LEN that was never used anywhere.
- Let iscsi_prep_scsi_cmd_pdu() signal an Error return since now it is
possible that it will fail.
- I was tired of yet again writing a "this is a digest" comment next to
sizeof(__u32) so I defined a new ISCSI_DIGEST_SIZE. Now I don't need
any comments. Changed all places that used sizeof(__u32) or "4" in
connection to a digest.
iscsi_tcp specific code
- At struct iscsi_tcp_cmd_task allocate maximum space allowed in
standard for all headers following the iscsi_cmd header. and mark
it so in iscsi_tcp_session_create()
- At iscsi_send_cmd_hdr() retrieve the correct headers size and
write header digest at iscsi_next_hdr().
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Olaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/scsi/iscsi_proto.h | 10 | ||||
-rw-r--r-- | include/scsi/libiscsi.h | 33 |
2 files changed, 40 insertions, 3 deletions
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h index 751c81eaa7f3..6947082eee6d 100644 --- a/include/scsi/iscsi_proto.h +++ b/include/scsi/iscsi_proto.h | |||
@@ -27,7 +27,7 @@ | |||
27 | #define ISCSI_LISTEN_PORT 3260 | 27 | #define ISCSI_LISTEN_PORT 3260 |
28 | 28 | ||
29 | /* Padding word length */ | 29 | /* Padding word length */ |
30 | #define PAD_WORD_LEN 4 | 30 | #define ISCSI_PAD_LEN 4 |
31 | 31 | ||
32 | /* | 32 | /* |
33 | * useful common(control and data pathes) macro | 33 | * useful common(control and data pathes) macro |
@@ -147,6 +147,14 @@ struct iscsi_rlength_ahdr { | |||
147 | __be32 read_length; | 147 | __be32 read_length; |
148 | }; | 148 | }; |
149 | 149 | ||
150 | /* Extended CDB AHS */ | ||
151 | struct iscsi_ecdb_ahdr { | ||
152 | __be16 ahslength; /* CDB length - 15, including reserved byte */ | ||
153 | uint8_t ahstype; | ||
154 | uint8_t reserved; | ||
155 | uint8_t ecdb[260 - 16]; /* 4-byte aligned extended CDB spillover */ | ||
156 | }; | ||
157 | |||
150 | /* SCSI Response Header */ | 158 | /* SCSI Response Header */ |
151 | struct iscsi_cmd_rsp { | 159 | struct iscsi_cmd_rsp { |
152 | uint8_t opcode; | 160 | uint8_t opcode; |
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h index e1fb3d0927b0..a9a9e869188d 100644 --- a/include/scsi/libiscsi.h +++ b/include/scsi/libiscsi.h | |||
@@ -78,6 +78,9 @@ enum { | |||
78 | #define ISCSI_ADDRESS_BUF_LEN 64 | 78 | #define ISCSI_ADDRESS_BUF_LEN 64 |
79 | 79 | ||
80 | enum { | 80 | enum { |
81 | /* this is the maximum possible storage for AHSs */ | ||
82 | ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) + | ||
83 | sizeof(struct iscsi_rlength_ahdr), | ||
81 | ISCSI_DIGEST_SIZE = sizeof(__u32), | 84 | ISCSI_DIGEST_SIZE = sizeof(__u32), |
82 | }; | 85 | }; |
83 | 86 | ||
@@ -102,10 +105,13 @@ enum { | |||
102 | 105 | ||
103 | struct iscsi_cmd_task { | 106 | struct iscsi_cmd_task { |
104 | /* | 107 | /* |
105 | * Becuae LLDs allocate their hdr differently, this is a pointer to | 108 | * Because LLDs allocate their hdr differently, this is a pointer |
106 | * that storage. It must be setup at session creation time. | 109 | * and length to that storage. It must be setup at session |
110 | * creation time. | ||
107 | */ | 111 | */ |
108 | struct iscsi_cmd *hdr; | 112 | struct iscsi_cmd *hdr; |
113 | unsigned short hdr_max; | ||
114 | unsigned short hdr_len; /* accumulated size of hdr used */ | ||
109 | int itt; /* this ITT */ | 115 | int itt; /* this ITT */ |
110 | 116 | ||
111 | uint32_t unsol_datasn; | 117 | uint32_t unsol_datasn; |
@@ -124,6 +130,11 @@ struct iscsi_cmd_task { | |||
124 | void *dd_data; /* driver/transport data */ | 130 | void *dd_data; /* driver/transport data */ |
125 | }; | 131 | }; |
126 | 132 | ||
133 | static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask) | ||
134 | { | ||
135 | return (void*)ctask->hdr + ctask->hdr_len; | ||
136 | } | ||
137 | |||
127 | struct iscsi_conn { | 138 | struct iscsi_conn { |
128 | struct iscsi_cls_conn *cls_conn; /* ptr to class connection */ | 139 | struct iscsi_cls_conn *cls_conn; /* ptr to class connection */ |
129 | void *dd_data; /* iscsi_transport data */ | 140 | void *dd_data; /* iscsi_transport data */ |
@@ -342,4 +353,22 @@ extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask); | |||
342 | extern void iscsi_pool_free(struct iscsi_queue *, void **); | 353 | extern void iscsi_pool_free(struct iscsi_queue *, void **); |
343 | extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int); | 354 | extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int); |
344 | 355 | ||
356 | /* | ||
357 | * inline functions to deal with padding. | ||
358 | */ | ||
359 | static inline unsigned int | ||
360 | iscsi_padded(unsigned int len) | ||
361 | { | ||
362 | return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1); | ||
363 | } | ||
364 | |||
365 | static inline unsigned int | ||
366 | iscsi_padding(unsigned int len) | ||
367 | { | ||
368 | len &= (ISCSI_PAD_LEN - 1); | ||
369 | if (len) | ||
370 | len = ISCSI_PAD_LEN - len; | ||
371 | return len; | ||
372 | } | ||
373 | |||
345 | #endif | 374 | #endif |