]>
Commit | Line | Data |
---|---|---|
12618416 | 1 | /** @file\r |
2 | The header file of IScsi Protocol that defines many specific data structures.\r | |
6a690e23 | 3 | \r |
9cb8724d | 4 | Copyright (c) 2004 - 2008, Intel Corporation\r |
7a444476 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
6a690e23 | 12 | \r |
13 | Module Name:\r | |
14 | \r | |
15 | IScsiProto.h\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
12618416 | 19 | Protocol definitions for IScsi driver, mainly from RFC3720.\r |
6a690e23 | 20 | \r |
12618416 | 21 | **/\r |
6a690e23 | 22 | \r |
23 | #ifndef _ISCSI_PROTO_H_\r | |
24 | #define _ISCSI_PROTO_H_\r | |
25 | \r | |
9cb8724d | 26 | #include <Protocol/ScsiPassThruExt.h>\r |
6a690e23 | 27 | \r |
28 | //\r | |
29 | // RFC 1982 Serial Number Arithmetic, SERIAL_BITS = 32\r | |
30 | //\r | |
31 | #define ISCSI_SEQ_EQ(s1, s2) ((s1) == (s2))\r | |
32 | #define ISCSI_SEQ_LT(s1, s2) \\r | |
33 | ( \\r | |
1c574ee4 | 34 | (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) < ((UINT32) 1 << 31)) || \\r |
35 | (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) > ((UINT32) 1 << 31)) \\r | |
6a690e23 | 36 | )\r |
37 | #define ISCSI_SEQ_GT(s1, s2) \\r | |
38 | ( \\r | |
1c574ee4 | 39 | (((INT32) (s1) < (INT32) (s2)) && (s2 - s1) > ((UINT32) 1 << 31)) || \\r |
40 | (((INT32) (s1) > (INT32) (s2)) && (s1 - s2) < ((UINT32) 1 << 31)) \\r | |
6a690e23 | 41 | )\r |
42 | \r | |
43 | #define ISCSI_WELL_KNOWN_PORT 3260\r | |
44 | #define ISCSI_MAX_CONNS_PER_SESSION 1\r | |
45 | \r | |
46 | #define DEFAULT_MAX_RECV_DATA_SEG_LEN 8192\r | |
47 | #define MAX_RECV_DATA_SEG_LEN_IN_FFP 65536\r | |
48 | #define DEFAULT_MAX_OUTSTANDING_R2T 1\r | |
49 | \r | |
50 | #define ISCSI_VERSION_MAX 0x00\r | |
51 | #define ISCSI_VERSION_MIN 0x00\r | |
52 | \r | |
53 | #define ISID_BYTE_0 0 // OUI format\r | |
54 | #define ISID_BYTE_1 0\r | |
55 | #define ISID_BYTE_2 0xaa\r | |
56 | #define ISID_BYTE_3 0x1\r | |
57 | \r | |
58 | #define ISCSI_KEY_AUTH_METHOD "AuthMethod"\r | |
59 | #define ISCSI_KEY_HEADER_DIGEST "HeaderDigest"\r | |
60 | #define ISCSI_KEY_DATA_DIGEST "DataDigest"\r | |
61 | #define ISCSI_KEY_MAX_CONNECTIONS "MaxConnections"\r | |
62 | #define ISCSI_KEY_TARGET_NAME "TargetName"\r | |
63 | #define ISCSI_KEY_INITIATOR_NAME "InitiatorName"\r | |
64 | #define ISCSI_KEY_TARGET_ALIAS "TargetAlias"\r | |
65 | #define ISCSI_KEY_INITIATOR_ALIAS "InitiatorAlias"\r | |
66 | #define ISCSI_KEY_TARGET_ADDRESS "TargetAddress"\r | |
67 | #define ISCSI_KEY_INITIAL_R2T "InitialR2T"\r | |
68 | #define ISCSI_KEY_IMMEDIATE_DATA "ImmediateData"\r | |
69 | #define ISCSI_KEY_TARGET_PORTAL_GROUP_TAG "TargetPortalGroupTag"\r | |
70 | #define ISCSI_KEY_MAX_BURST_LENGTH "MaxBurstLength"\r | |
71 | #define ISCSI_KEY_FIRST_BURST_LENGTH "FirstBurstLength"\r | |
72 | #define ISCSI_KEY_DEFAULT_TIME2WAIT "DefaultTime2Wait"\r | |
73 | #define ISCSI_KEY_DEFAULT_TIME2RETAIN "DefaultTime2Retain"\r | |
74 | #define ISCSI_KEY_MAX_OUTSTANDING_R2T "MaxOutstandingR2T"\r | |
75 | #define ISCSI_KEY_DATA_PDU_IN_ORDER "DataPDUInOrder"\r | |
76 | #define ISCSI_KEY_DATA_SEQUENCE_IN_ORDER "DataSequenceInOrder"\r | |
77 | #define ISCSI_KEY_ERROR_RECOVERY_LEVEL "ErrorRecoveryLevel"\r | |
78 | #define ISCSI_KEY_SESSION_TYPE "SessionType"\r | |
79 | #define ISCSI_KEY_MAX_RECV_DATA_SEGMENT_LENGTH "MaxRecvDataSegmentLength"\r | |
80 | \r | |
81 | #define ISCSI_KEY_VALUE_NONE "None"\r | |
82 | \r | |
83 | //\r | |
84 | // connection state for initiator\r | |
85 | //\r | |
86 | typedef enum {\r | |
87 | CONN_STATE_FREE,\r | |
88 | CONN_STATE_XPT_WAIT,\r | |
89 | CONN_STATE_IN_LOGIN,\r | |
90 | CONN_STATE_LOGGED_IN,\r | |
91 | CONN_STATE_IN_LOGOUT,\r | |
92 | CONN_STATE_LOGOUT_REQUESTED,\r | |
93 | CONN_STATE_CLEANUP_WAIT,\r | |
94 | CONN_STATE_IN_CLEANUP\r | |
95 | } CONNECTION_STATE;\r | |
96 | \r | |
97 | //\r | |
98 | // session state for initiator\r | |
99 | //\r | |
100 | typedef enum {\r | |
101 | SESSION_STATE_FREE,\r | |
102 | SESSION_STATE_LOGGED_IN,\r | |
103 | SESSION_STATE_FAILED\r | |
104 | } SESSION_STATE;\r | |
105 | \r | |
106 | typedef enum {\r | |
107 | DataIn = 0,\r | |
108 | DataOut = 1,\r | |
109 | DataBi = 2\r | |
110 | } DATA_DIRECTION;\r | |
111 | \r | |
112 | #define ISCSI_RESERVED_TAG 0xffffffff\r | |
113 | \r | |
114 | #define ISCSI_REQ_IMMEDIATE 0x40\r | |
115 | #define ISCSI_OPCODE_MASK 0x3F\r | |
116 | \r | |
117 | #define ISCSI_SET_OPCODE(PduHdr, Op, Flgs) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) = ((Op) | (Flgs)))\r | |
118 | #define ISCSI_GET_OPCODE(PduHdr) ((((ISCSI_BASIC_HEADER *) (PduHdr))->OpCode) & ISCSI_OPCODE_MASK)\r | |
119 | #define ISCSI_CHECK_OPCODE(PduHdr, Op) ((((PduHdr)->OpCode) & ISCSI_OPCODE_MASK) == (Op))\r | |
120 | #define ISCSI_IMMEDIATE_ON(PduHdr) ((PduHdr)->OpCode & ISCSI_REQ_IMMEDIATE)\r | |
69b0882d | 121 | #define ISCSI_SET_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags |= (BOOLEAN)(Flag))\r |
6a690e23 | 122 | #define ISCSI_CLEAR_FLAG(PduHdr, Flag) (((ISCSI_BASIC_HEADER *) (PduHdr))->Flags &= ~(Flag))\r |
93e3992d | 123 | #define ISCSI_FLAG_ON(PduHdr, Flag) ((((ISCSI_BASIC_HEADER *) (PduHdr))->Flags & (Flag)) == (Flag))\r |
69b0882d | 124 | #define ISCSI_SET_STAGES(PduHdr, Cur, Nxt) ((PduHdr)->Flags = (UINT8) ((PduHdr)->Flags | ((Cur) << 2 | (Nxt))))\r |
6a690e23 | 125 | #define ISCSI_GET_CURRENT_STAGE(PduHdr) (((PduHdr)->Flags >> 2) & 0x3)\r |
126 | #define ISCSI_GET_NEXT_STAGE(PduHdr) (((PduHdr)->Flags) & 0x3)\r | |
127 | \r | |
128 | #define ISCSI_GET_PAD_LEN(DataLen) ((~(DataLen) + 1) & 0x3)\r | |
129 | #define ISCSI_ROUNDUP(DataLen) (((DataLen) + 3) &~(0x3))\r | |
130 | \r | |
131 | #define HTON24(Dst, Src) \\r | |
132 | do { \\r | |
69b0882d | 133 | (Dst)[0] = (UINT8) (((Src) >> 16) & 0xFF); \\r |
134 | (Dst)[1] = (UINT8) (((Src) >> 8) & 0xFF); \\r | |
135 | (Dst)[2] = (UINT8) ((Src) & 0xFF); \\r | |
6a690e23 | 136 | } while (0);\r |
137 | \r | |
138 | #define NTOH24(src) (((src)[0] << 16) | ((src)[1] << 8) | ((src)[2]))\r | |
139 | \r | |
140 | #define ISCSI_GET_DATASEG_LEN(PduHdr) NTOH24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength)\r | |
141 | #define ISCSI_SET_DATASEG_LEN(PduHdr, Len) HTON24 (((ISCSI_BASIC_HEADER *) (PduHdr))->DataSegmentLength, (Len))\r | |
142 | \r | |
143 | //\r | |
144 | // initiator opcodes\r | |
145 | //\r | |
146 | #define ISCSI_OPCODE_NOP_OUT 0x00\r | |
147 | #define ISCSI_OPCODE_SCSI_CMD 0x01\r | |
148 | #define ISCSI_OPCODE_SCSI_TMF_REQ 0x02\r | |
149 | #define ISCSI_OPCODE_LOGIN_REQ 0x03\r | |
150 | #define ISCSI_OPCODE_TEXT_REQ 0x04\r | |
151 | #define ISCSI_OPCODE_SCSI_DATA_OUT 0x05\r | |
152 | #define ISCSI_OPCODE_LOGOUT_REQ 0x06\r | |
153 | #define ISCSI_OPCODE_SNACK_REQ 0x10\r | |
154 | #define ISCSI_OPCODE_VENDOR_I0 0x1c\r | |
155 | #define ISCSI_OPCODE_VENDOR_I1 0x1d\r | |
156 | #define ISCSI_OPCODE_VENDOR_I2 0x1e\r | |
157 | \r | |
158 | //\r | |
159 | // target opcodes\r | |
160 | //\r | |
161 | #define ISCSI_OPCODE_NOP_IN 0x20\r | |
162 | #define ISCSI_OPCODE_SCSI_RSP 0x21\r | |
163 | #define ISCSI_OPCODE_SCSI_TMF_RSP 0x22\r | |
164 | #define ISCSI_OPCODE_LOGIN_RSP 0x23\r | |
165 | #define ISCSI_OPCODE_TEXT_RSP 0x24\r | |
166 | #define ISCSI_OPCODE_SCSI_DATA_IN 0x25\r | |
167 | #define ISCSI_OPCODE_LOGOUT_RSP 0x26\r | |
168 | #define ISCSI_OPCODE_R2T 0x31\r | |
169 | #define ISCSI_OPCODE_ASYNC_MSG 0x32\r | |
170 | #define ISCSI_OPCODE_VENDOR_T0 0x3c\r | |
171 | #define ISCSI_OPCODE_VENDOR_T1 0x3d\r | |
172 | #define ISCSI_OPCODE_VENDOR_T2 0x3e\r | |
173 | #define ISCSI_OPCODE_REJECT 0x3f\r | |
174 | \r | |
175 | #define ISCSI_BHS_FLAG_FINAL 0x80\r | |
176 | \r | |
177 | //\r | |
178 | // iSCSI Basic Header Segment\r | |
179 | //\r | |
180 | typedef struct _ISCSI_BASIC_HEADER {\r | |
181 | UINT8 OpCode;\r | |
182 | UINT8 Flags;\r | |
183 | UINT16 OpCodeSpecific1;\r | |
184 | UINT8 TotalAHSLength;\r | |
185 | UINT8 DataSegmentLength[3];\r | |
186 | UINT8 Lun[8];\r | |
187 | UINT32 InitiatorTaskTag;\r | |
188 | UINT32 OpCodeSpecific2[7];\r | |
189 | } ISCSI_BASIC_HEADER;\r | |
190 | \r | |
191 | //\r | |
192 | // Defined AHS types, others are reserved.\r | |
193 | //\r | |
194 | #define ISCSI_AHS_TYPE_EXT_CDB 0x1\r | |
195 | #define ISCSI_AHS_TYPE_BI_EXP_READ_DATA_LEN 0x2\r | |
196 | \r | |
197 | typedef struct _ISCSI_ADDTIONAL_HEADER {\r | |
198 | UINT16 Length;\r | |
199 | UINT8 Type;\r | |
200 | UINT8 TypeSpecific[1];\r | |
201 | } ISCSI_ADDITIONAL_HEADER;\r | |
202 | \r | |
203 | typedef struct _ISCSI_BI_EXP_READ_DATA_LEN_AHS {\r | |
204 | UINT16 Length;\r | |
205 | UINT8 Type;\r | |
206 | UINT8 Reserved;\r | |
207 | UINT32 ExpReadDataLength;\r | |
208 | } ISCSI_BI_EXP_READ_DATA_LEN_AHS;\r | |
209 | \r | |
210 | #define SCSI_CMD_PDU_FLAG_READ 0x40\r | |
211 | #define SCSI_CMD_PDU_FLAG_WRITE 0x20\r | |
212 | \r | |
213 | #define ISCSI_CMD_PDU_TASK_ATTR_MASK 0x07\r | |
214 | \r | |
215 | //\r | |
216 | // task attributes\r | |
217 | //\r | |
218 | #define ISCSI_TASK_ATTR_UNTAGGED 0x00\r | |
219 | #define ISCSI_TASK_ATTR_SIMPLE 0x01\r | |
220 | #define ISCSI_TASK_ATTR_ORDERD 0x02\r | |
221 | #define ISCSI_TASK_ATTR_HOQ 0x03\r | |
222 | #define ISCSI_TASK_ATTR_ACA 0x04\r | |
223 | \r | |
224 | //\r | |
225 | // SCSI Command\r | |
226 | //\r | |
227 | typedef struct _SCSI_COMMAND {\r | |
228 | UINT8 OpCode;\r | |
229 | UINT8 Flags;\r | |
230 | UINT16 Reserved;\r | |
231 | UINT8 TotalAHSLength;\r | |
232 | UINT8 DataSegmentLength[3];\r | |
233 | UINT8 Lun[8];\r | |
234 | UINT32 InitiatorTaskTag;\r | |
235 | UINT32 ExpDataXferLength;\r | |
236 | UINT32 CmdSN;\r | |
237 | UINT32 ExpStatSN;\r | |
238 | UINT8 CDB[16];\r | |
239 | } SCSI_COMMAND;\r | |
240 | \r | |
241 | //\r | |
242 | // flag bit definitions in SCSI response\r | |
243 | //\r | |
244 | #define SCSI_RSP_PDU_FLAG_BI_READ_OVERFLOW 0x10\r | |
245 | #define SCSI_RSP_PDU_FLAG_BI_READ_UNDERFLOW 0x08\r | |
246 | #define SCSI_RSP_PDU_FLAG_OVERFLOW 0x04\r | |
247 | #define SCSI_RSP_PDU_FLAG_UNDERFLOW 0x02\r | |
248 | \r | |
249 | //\r | |
250 | // iSCSI service response codes\r | |
251 | //\r | |
252 | #define ISCSI_SERVICE_RSP_COMMAND_COMPLETE_AT_TARGET 0x00\r | |
253 | #define ISCSI_SERVICE_RSP_TARGET_FAILURE 0x01\r | |
254 | \r | |
255 | //\r | |
256 | // SCSI Response\r | |
257 | //\r | |
258 | typedef struct _SCSI_RESPONSE {\r | |
259 | UINT8 OpCode;\r | |
260 | UINT8 Flags;\r | |
261 | UINT8 Response;\r | |
262 | UINT8 Status;\r | |
263 | UINT8 TotalAHSLength;\r | |
264 | UINT8 DataSegmentLength[3];\r | |
265 | UINT8 Reserved[8];\r | |
266 | UINT32 InitiatorTaskTag;\r | |
267 | UINT32 SNACKTag;\r | |
268 | UINT32 StatSN;\r | |
269 | UINT32 ExpCmdSN;\r | |
270 | UINT32 MaxCmdSN;\r | |
271 | UINT32 ExpDataSN;\r | |
272 | UINT32 BiReadResidualCount;\r | |
273 | UINT32 ResidualCount;\r | |
274 | } SCSI_RESPONSE;\r | |
275 | \r | |
276 | typedef struct _ISCSI_SENSE_DATA {\r | |
277 | UINT16 Length;\r | |
278 | UINT8 Data[2];\r | |
279 | } ISCSI_SENSE_DATA;\r | |
280 | \r | |
281 | //\r | |
282 | // iSCSI Task Managment Function Request\r | |
283 | //\r | |
284 | typedef struct _ISCSI_TMF_REQUEST {\r | |
285 | UINT8 OpCode;\r | |
286 | UINT8 Fuction;\r | |
287 | UINT16 Reserved1;\r | |
288 | UINT8 TotalAHSLength;\r | |
289 | UINT8 DataSegmentLength[3];\r | |
290 | UINT8 Lun[8];\r | |
291 | UINT32 InitiatorTaskTag;\r | |
292 | UINT32 ReferencedTaskTag;\r | |
293 | UINT32 CmdSN;\r | |
294 | UINT32 ExpStatSN;\r | |
295 | UINT32 RefCmdSN;\r | |
296 | UINT32 ExpDataSN;\r | |
297 | UINT32 Reserved2[2];\r | |
298 | } ISCSI_TMF_REQUEST;\r | |
299 | \r | |
300 | #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_COMPLETE 0\r | |
301 | #define ISCSI_TMF_RSP_PDU_RSP_TASK_NOT_EXIST 1\r | |
302 | #define ISCSI_TMF_RSP_PDU_RSP_LUN_NOT_EXIST 2\r | |
303 | #define ISCSI_TMF_RSP_PDU_RSP_TASK_STILL_ALLEGIANT 3\r | |
304 | #define ISCSI_TMF_RSP_PDU_RSP_TASK_REASSGIN_NOT_SUPPORTED 4\r | |
305 | #define ISCSI_TMF_RSP_PDU_RSP_NOT_SUPPORTED 5\r | |
306 | #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_AHTH_FAILED 6\r | |
307 | #define ISCSI_TMF_RSP_PDU_RSP_FUNCTION_REJECTED 255\r | |
308 | \r | |
309 | //\r | |
310 | // iSCSI Task Management Function Response\r | |
311 | //\r | |
312 | typedef struct _ISCSI_TMF_RESPONSE {\r | |
313 | UINT8 OpCode;\r | |
314 | UINT8 Reserved1;\r | |
315 | UINT8 Response;\r | |
316 | UINT8 Reserved2;\r | |
317 | UINT8 TotalAHSLength;\r | |
318 | UINT8 DataSegmentLength[3];\r | |
319 | UINT32 Reserver3[2];\r | |
320 | UINT32 InitiatorTaskTag;\r | |
321 | UINT32 Reserved4;\r | |
322 | UINT32 StatSN;\r | |
323 | UINT32 ExpCmdSN;\r | |
324 | UINT32 MaxCmdSN;\r | |
325 | UINT32 Reserved[3];\r | |
326 | } ISCSI_TMF_RESPONSE;\r | |
327 | \r | |
328 | //\r | |
329 | // SCSI Data-Out\r | |
330 | //\r | |
331 | typedef struct _ISCSI_SCSI_DATA_OUT {\r | |
332 | UINT8 OpCode;\r | |
333 | UINT8 Reserved1[3];\r | |
334 | UINT8 TotalAHSLength;\r | |
335 | UINT8 DataSegmentLength[3];\r | |
336 | UINT8 Lun[8];\r | |
337 | UINT32 InitiatorTaskTag;\r | |
338 | UINT32 TargetTransferTag;\r | |
339 | UINT32 Reserved2;\r | |
340 | UINT32 ExpStatSN;\r | |
341 | UINT32 Reserved3;\r | |
342 | UINT32 DataSN;\r | |
343 | UINT32 BufferOffset;\r | |
344 | UINT32 Reserved4;\r | |
345 | } ISCSI_SCSI_DATA_OUT;\r | |
346 | \r | |
347 | #define SCSI_DATA_IN_PDU_FLAG_ACKKNOWLEDGE 0x40\r | |
348 | #define SCSI_DATA_IN_PDU_FLAG_OVERFLOW SCSI_RSP_PDU_FLAG_OVERFLOW\r | |
349 | #define SCSI_DATA_IN_PDU_FLAG_UNDERFLOW SCSI_RSP_PDU_FLAG_UNDERFLOW\r | |
350 | #define SCSI_DATA_IN_PDU_FLAG_STATUS_VALID 0x01\r | |
351 | //\r | |
352 | // SCSI Data-In\r | |
353 | //\r | |
354 | typedef struct _ISCSI_SCSI_DATA_IN {\r | |
355 | UINT8 OpCode;\r | |
356 | UINT8 Flags;\r | |
357 | UINT8 Reserved1;\r | |
358 | UINT8 Status;\r | |
359 | UINT8 TotalAHSLength;\r | |
360 | UINT8 DataSegmentLength[3];\r | |
361 | UINT8 Lun[8];\r | |
362 | UINT32 InitiatorTaskTag;\r | |
363 | UINT32 TargetTransferTag;\r | |
364 | UINT32 StatSN;\r | |
365 | UINT32 ExpCmdSN;\r | |
366 | UINT32 MaxCmdSN;\r | |
367 | UINT32 DataSN;\r | |
368 | UINT32 BufferOffset;\r | |
369 | UINT32 ResidualCount;\r | |
370 | } ISCSI_SCSI_DATA_IN;\r | |
371 | \r | |
372 | #define ISCSI_GET_BUFFER_OFFSET(PduHdr) NTOHL (((ISCSI_SCSI_DATA_IN *) (PduHdr))->BufferOffset)\r | |
373 | //\r | |
374 | // Ready To Transfer\r | |
375 | //\r | |
376 | typedef struct _ISCSI_READY_TO_TRANSFER {\r | |
377 | UINT8 OpCode;\r | |
378 | UINT8 Reserved1[3];\r | |
379 | UINT8 TotalAHSLength;\r | |
380 | UINT8 DataSegmentLength[3];\r | |
381 | UINT8 Lun[8];\r | |
382 | UINT32 InitiatorTaskTag;\r | |
383 | UINT32 TargetTransferTag;\r | |
384 | UINT32 StatSN;\r | |
385 | UINT32 ExpCmdSN;\r | |
386 | UINT32 MaxCmdSN;\r | |
387 | UINT32 R2TSN;\r | |
388 | UINT32 BufferOffset;\r | |
389 | UINT32 DesiredDataTransferLength;\r | |
390 | } ISCSI_READY_TO_TRANSFER;\r | |
391 | \r | |
392 | typedef struct _ISCSI_ASYNC_MESSAGE {\r | |
393 | UINT8 OpCode;\r | |
394 | UINT8 Reserved1[8];\r | |
395 | UINT8 TotalAHSLength;\r | |
396 | UINT8 DataSegmentLength[3];\r | |
397 | UINT8 Lun[8];\r | |
398 | UINT32 InitiatorTaskTag;\r | |
399 | UINT32 Reserved2;\r | |
400 | UINT32 StatSN;\r | |
401 | UINT32 ExpCmdSN;\r | |
402 | UINT32 MaxCmdSN;\r | |
403 | UINT8 AsyncEvent;\r | |
404 | UINT8 AsyncVCode;\r | |
405 | UINT16 Parameter1;\r | |
406 | UINT16 Parameter2;\r | |
407 | UINT16 Parameter3;\r | |
408 | UINT32 Reserved3;\r | |
409 | } ISCSI_ASYNC_MESSAGE;\r | |
410 | \r | |
411 | #define ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT 0x80\r | |
412 | #define ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE 0x40\r | |
413 | \r | |
414 | //\r | |
415 | // Login Request\r | |
416 | //\r | |
417 | typedef struct _ISCSI_LOGIN_REQUEST {\r | |
418 | UINT8 OpCode;\r | |
419 | UINT8 Flags;\r | |
420 | UINT8 VersionMax;\r | |
421 | UINT8 VersionMin;\r | |
422 | UINT8 TotalAHSLength;\r | |
423 | UINT8 DataSegmentLength[3];\r | |
424 | UINT8 ISID[6];\r | |
425 | UINT16 TSIH;\r | |
426 | UINT32 InitiatorTaskTag;\r | |
427 | UINT16 CID;\r | |
428 | UINT16 Reserved1;\r | |
429 | UINT32 CmdSN;\r | |
430 | UINT32 ExpStatSN;\r | |
431 | UINT32 Reserved2[4];\r | |
432 | } ISCSI_LOGIN_REQUEST;\r | |
433 | \r | |
434 | #define ISCSI_LOGIN_RSP_PDU_FLAG_TRANSIT ISCSI_LOGIN_REQ_PDU_FLAG_TRANSIT\r | |
435 | #define ISCSI_LOGIN_RSP_PDU_FLAG_CONTINUE ISCSI_LOGIN_REQ_PDU_FLAG_CONTINUE\r | |
436 | \r | |
437 | #define ISCSI_LOGIN_STATUS_SUCCESS 0\r | |
438 | #define ISCSI_LOGIN_STATUS_REDIRECTION 1\r | |
439 | #define ISCSI_LOGIN_STATUS_INITIATOR_ERROR 2\r | |
440 | #define ISCSI_LOGIN_STATUS_TARGET_ERROR 3\r | |
441 | \r | |
442 | //\r | |
443 | // Login Response\r | |
444 | //\r | |
445 | typedef struct _ISCSI_LOGIN_RESPONSE {\r | |
446 | UINT8 OpCode;\r | |
447 | UINT8 Flags;\r | |
448 | UINT8 VersionMax;\r | |
449 | UINT8 VersionActive;\r | |
450 | UINT8 TotalAHSLength;\r | |
451 | UINT8 DataSegmentLength[3];\r | |
452 | UINT8 ISID[6];\r | |
453 | UINT16 TSIH;\r | |
454 | UINT32 InitiatorTaskTag;\r | |
455 | UINT32 Reserved1;\r | |
456 | UINT32 StatSN;\r | |
457 | UINT32 ExpCmdSN;\r | |
458 | UINT32 MaxCmdSN;\r | |
459 | UINT8 StatusClass;\r | |
460 | UINT8 StatusDetail;\r | |
461 | UINT8 Reserved2[10];\r | |
462 | } ISCSI_LOGIN_RESPONSE;\r | |
463 | \r | |
464 | #define ISCSI_LOGOUT_REASON_CLOSE_SESSION 0\r | |
465 | #define ISCSI_LOGOUT_REASON_CLOSE_CONNECTION 1\r | |
466 | #define ISCSI_LOGOUT_REASON_REMOVE_CONNECTION_FOR_RECOVERY 2\r | |
467 | \r | |
468 | //\r | |
469 | // Logout Request\r | |
470 | //\r | |
471 | typedef struct _ISCSI_LOGOUT_REQUEST {\r | |
472 | UINT8 OpCode;\r | |
473 | UINT8 ReasonCode;\r | |
474 | UINT16 Reserved1;\r | |
475 | UINT8 TotalAHSLength;\r | |
476 | UINT8 DataSegmentLength[3];\r | |
477 | UINT32 Reserved2[2];\r | |
478 | UINT32 InitiatorTaskTag;\r | |
479 | UINT16 CID;\r | |
480 | UINT16 Reserved3;\r | |
481 | UINT32 CmdSN;\r | |
482 | UINT32 ExpStatSN;\r | |
483 | UINT32 Reserved4[4];\r | |
484 | } ISCSI_LOGOUT_REQUEST;\r | |
485 | \r | |
486 | #define ISCSI_LOGOUT_RESPONSE_SESSION_CLOSED_SUCCESS 0\r | |
487 | #define ISCSI_LOGOUT_RESPONSE_CID_NOT_FOUND 1\r | |
488 | #define ISCSI_LOGOUT_RESPONSE_RECOVERY_NOT_SUPPORTED 2\r | |
489 | #define ISCSI_LOGOUT_RESPONSE_CLEANUP_FAILED 3\r | |
490 | \r | |
491 | //\r | |
492 | // Logout Response\r | |
493 | //\r | |
494 | typedef struct _ISCSI_LOGOUT_RESPONSE {\r | |
495 | UINT8 OpCode;\r | |
496 | UINT8 Reserved1;\r | |
497 | UINT8 Response;\r | |
498 | UINT8 Reserved2;\r | |
499 | UINT8 TotalAHSLength;\r | |
500 | UINT8 DataSegmentLength[3];\r | |
501 | UINT32 Reserved3[2];\r | |
502 | UINT32 InitiatorTaskTag;\r | |
503 | UINT32 Reserved4;\r | |
504 | UINT32 StatSN;\r | |
505 | UINT32 ExpCmdSN;\r | |
506 | UINT32 MaxCmdSN;\r | |
507 | UINT32 Reserved5;\r | |
508 | UINT16 Time2Wait;\r | |
509 | UINT16 Time2Retain;\r | |
510 | UINT32 Reserved6;\r | |
511 | } ISCSI_LOGOUT_RESPONSE;\r | |
512 | \r | |
513 | #define ISCSI_SNACK_REQUEST_TYPE_DATA_OR_R2T 0\r | |
514 | #define ISCSI_SNACK_REQUEST_TYPE_STATUS 1\r | |
515 | #define ISCSI_SNACK_REQUEST_TYPE_DATA_ACK 2\r | |
516 | #define ISCSI_SNACK_REQUEST_TYPE_RDATA 3\r | |
517 | \r | |
518 | //\r | |
519 | // SNACK Request\r | |
520 | //\r | |
521 | typedef struct _ISCSI_SNACK_REQUEST {\r | |
522 | UINT8 OpCode;\r | |
523 | UINT8 Type;\r | |
524 | UINT16 Reserved1;\r | |
525 | UINT8 TotalAHSLength;\r | |
526 | UINT8 DataSegmentLength[3];\r | |
527 | UINT8 Lun[8];\r | |
528 | UINT32 InitiatorTaskTag;\r | |
529 | UINT32 TargetTransferTag;\r | |
530 | UINT32 Reserved2;\r | |
531 | UINT32 ExpStatSN;\r | |
532 | UINT32 Reserved[2];\r | |
533 | UINT32 BegRun;\r | |
534 | UINT32 RunLength;\r | |
535 | } ISCSI_SNACK_REQUEST;\r | |
536 | \r | |
537 | //\r | |
538 | // Reject\r | |
539 | //\r | |
540 | typedef struct _ISCSI_REJECT {\r | |
541 | UINT8 OpCode;\r | |
542 | UINT8 Reserved1;\r | |
543 | UINT8 Reason;\r | |
544 | UINT8 Reserved2;\r | |
545 | UINT8 TotalAHSLength;\r | |
546 | UINT8 DataSegmentLength[3];\r | |
547 | UINT32 Reserved3[2];\r | |
548 | UINT32 InitiatorTaskTag;\r | |
549 | UINT32 Reserved4;\r | |
550 | UINT32 StatSN;\r | |
551 | UINT32 ExpCmdSN;\r | |
552 | UINT32 MaxCmdSN;\r | |
553 | UINT32 DataSN;\r | |
554 | UINT32 Reserved5[2];\r | |
555 | } ISCSI_REJECT;\r | |
556 | \r | |
557 | //\r | |
558 | // NOP-Out\r | |
559 | //\r | |
560 | typedef struct _ISCSI_NOP_OUT {\r | |
561 | UINT8 OpCode;\r | |
562 | UINT8 Reserved1[3];\r | |
563 | UINT8 TotalAHSLength;\r | |
564 | UINT8 DataSegmentLength[3];\r | |
565 | UINT8 Lun[8];\r | |
566 | UINT32 InitiatorTaskTag;\r | |
567 | UINT32 TargetTransferTag;\r | |
568 | UINT32 CmdSN;\r | |
569 | UINT32 ExpStatSN;\r | |
570 | UINT32 Reserved2[4];\r | |
571 | } ISCSI_NOP_OUT;\r | |
572 | \r | |
573 | //\r | |
574 | // NOP-In\r | |
575 | //\r | |
576 | typedef struct _ISCSI_NOP_IN {\r | |
577 | UINT8 OpCode;\r | |
578 | UINT8 Reserved1[3];\r | |
579 | UINT8 TotalAHSLength;\r | |
580 | UINT8 DataSegmentLength[3];\r | |
581 | UINT8 Lun[8];\r | |
582 | UINT32 InitiatorTaskTag;\r | |
583 | UINT32 TargetTransferTag;\r | |
584 | UINT32 StatSN;\r | |
585 | UINT32 ExpCmdSN;\r | |
586 | UINT32 MaxCmdSN;\r | |
587 | UINT32 Reserved2[3];\r | |
588 | } ISCSI_NOP_IN;\r | |
589 | \r | |
590 | #define ISCSI_SECURITY_NEGOTIATION 0\r | |
591 | #define ISCSI_LOGIN_OPERATIONAL_NEGOTIATION 1\r | |
592 | #define ISCSI_FULL_FEATURE_PHASE 3\r | |
593 | \r | |
594 | typedef enum {\r | |
595 | ISCSI_DIGEST_NONE,\r | |
596 | ISCSI_DIGEST_CRC32\r | |
597 | } ISCSI_DIGEST_TYPE;\r | |
598 | \r | |
599 | typedef struct _ISCSI_XFER_CONTEXT {\r | |
600 | UINT32 TargetTransferTag;\r | |
601 | UINT32 Offset;\r | |
602 | UINT32 DesiredLength;\r | |
603 | UINT32 ExpDataSN;\r | |
604 | } ISCSI_XFER_CONTEXT;\r | |
605 | \r | |
606 | typedef struct _ISCSI_IN_BUFFER_CONTEXT {\r | |
607 | UINT8 *InData;\r | |
608 | UINT32 InDataLen;\r | |
609 | } ISCSI_IN_BUFFER_CONTEXT;\r | |
610 | \r | |
611 | typedef struct _ISCSI_TCB {\r | |
e48e37fc | 612 | LIST_ENTRY Link;\r |
6a690e23 | 613 | \r |
614 | BOOLEAN SoFarInOrder;\r | |
615 | UINT32 ExpDataSN;\r | |
616 | BOOLEAN FbitReceived;\r | |
617 | BOOLEAN StatusXferd;\r | |
618 | UINT32 ActiveR2Ts;\r | |
619 | UINT32 Response;\r | |
620 | CHAR8 *Reason;\r | |
621 | UINT32 InitiatorTaskTag;\r | |
622 | UINT32 CmdSN;\r | |
623 | UINT32 SNACKTag;\r | |
624 | \r | |
625 | ISCSI_XFER_CONTEXT XferContext;\r | |
626 | \r | |
627 | ISCSI_CONNECTION *Conn;\r | |
628 | } ISCSI_TCB;\r | |
629 | \r | |
630 | typedef struct _ISCSI_KEY_VALUE_PAIR {\r | |
e48e37fc | 631 | LIST_ENTRY List;\r |
6a690e23 | 632 | \r |
633 | CHAR8 *Key;\r | |
634 | CHAR8 *Value;\r | |
635 | } ISCSI_KEY_VALUE_PAIR;\r | |
636 | \r | |
637 | //\r | |
638 | // function prototypes.\r | |
639 | //\r | |
12618416 | 640 | /**\r |
641 | Attach the iSCSI connection to the iSCSI session. \r | |
642 | \r | |
643 | @param Session[in] The iSCSI session.\r | |
644 | \r | |
645 | @param Conn[in] The iSCSI connection.\r | |
646 | \r | |
647 | @retval None.\r | |
648 | \r | |
649 | **/\r | |
6a690e23 | 650 | VOID\r |
651 | IScsiAttatchConnection (\r | |
652 | IN ISCSI_SESSION *Session,\r | |
653 | IN ISCSI_CONNECTION *Conn\r | |
654 | );\r | |
655 | \r | |
12618416 | 656 | /**\r |
657 | Detach the iSCSI connection from the session it belongs to. \r | |
658 | \r | |
659 | @param Conn[in] The iSCSI connection.\r | |
660 | \r | |
661 | @retval None.\r | |
662 | \r | |
663 | **/\r | |
6a690e23 | 664 | VOID\r |
665 | IScsiDetatchConnection (\r | |
666 | IN ISCSI_CONNECTION *Conn\r | |
667 | );\r | |
668 | \r | |
12618416 | 669 | /**\r |
670 | This function does the iSCSI connection login.\r | |
671 | \r | |
672 | @param Conn[in] The iSCSI connection to login.\r | |
673 | \r | |
674 | @retval EFI_SUCCESS The iSCSI connection is logged into the iSCSI target.\r | |
675 | \r | |
676 | @retval EFI_TIMEOUT Timeout happened during the login procedure.\r | |
677 | \r | |
678 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
679 | \r | |
680 | **/\r | |
6a690e23 | 681 | EFI_STATUS\r |
682 | IScsiConnLogin (\r | |
683 | IN ISCSI_CONNECTION *Conn\r | |
684 | );\r | |
685 | \r | |
12618416 | 686 | /**\r |
687 | Create a TCP connection for the iSCSI session.\r | |
688 | \r | |
689 | @param Private[in] The iSCSI driver data.\r | |
690 | \r | |
691 | @param Session[in] Maximum CmdSN from the target.\r | |
692 | \r | |
693 | @retval The newly created iSCSI connection.\r | |
694 | \r | |
695 | **/\r | |
6a690e23 | 696 | ISCSI_CONNECTION *\r |
697 | IScsiCreateConnection (\r | |
698 | IN ISCSI_DRIVER_DATA *Private,\r | |
699 | IN ISCSI_SESSION *Session\r | |
700 | );\r | |
701 | \r | |
12618416 | 702 | /**\r |
703 | Destroy an iSCSI connection.\r | |
704 | \r | |
705 | @param Conn[in] The connection to destroy.\r | |
706 | \r | |
707 | @retval None.\r | |
708 | \r | |
709 | **/\r | |
6a690e23 | 710 | VOID\r |
711 | IScsiDestroyConnection (\r | |
712 | IN ISCSI_CONNECTION *Conn\r | |
713 | );\r | |
714 | \r | |
12618416 | 715 | /**\r |
716 | Login the iSCSI session.\r | |
717 | \r | |
718 | @param Private[in] The iSCSI driver data.\r | |
719 | \r | |
720 | @retval EFI_SUCCESS The iSCSI session login procedure finished.\r | |
721 | \r | |
722 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
723 | \r | |
724 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
725 | \r | |
726 | **/\r | |
6a690e23 | 727 | EFI_STATUS\r |
728 | IScsiSessionLogin (\r | |
729 | IN ISCSI_DRIVER_DATA *Private\r | |
730 | );\r | |
731 | \r | |
12618416 | 732 | /**\r |
733 | Build and send the iSCSI login request to the iSCSI target according to\r | |
734 | the current login stage.\r | |
735 | \r | |
736 | @param Conn[in] The connection in the iSCSI login phase.\r | |
737 | \r | |
738 | @retval EFI_SUCCESS The iSCSI login request PDU is built and sent on this\r | |
739 | connection.\r | |
740 | \r | |
741 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
742 | \r | |
743 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
744 | \r | |
745 | **/\r | |
6a690e23 | 746 | EFI_STATUS\r |
747 | IScsiSendLoginReq (\r | |
748 | IN ISCSI_CONNECTION *Conn\r | |
749 | );\r | |
750 | \r | |
12618416 | 751 | /**\r |
752 | Receive and process the iSCSI login response.\r | |
753 | \r | |
754 | @param Conn[in] The connection in the iSCSI login phase.\r | |
755 | \r | |
756 | @retval EFI_SUCCESS The iSCSI login response PDU is received and processed.\r | |
757 | \r | |
758 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
759 | \r | |
760 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
761 | \r | |
762 | **/\r | |
6a690e23 | 763 | EFI_STATUS\r |
764 | IScsiReceiveLoginRsp (\r | |
765 | IN ISCSI_CONNECTION *Conn\r | |
766 | );\r | |
767 | \r | |
12618416 | 768 | /**\r |
769 | Add an iSCSI key-value pair as a string into the data segment of the Login Request PDU.\r | |
770 | The DataSegmentLength and the actual size of the net buffer containing this PDU will be\r | |
771 | updated.\r | |
772 | \r | |
773 | @param Pdu[in] The iSCSI PDU whose data segment the key-value pair will\r | |
774 | be added to.\r | |
775 | \r | |
776 | @param Key[in] The key name string.\r | |
777 | \r | |
778 | @param Value[in] The value string.\r | |
779 | \r | |
780 | @retval EFI_SUCCESS The key-valu pair is added to the PDU's datasegment and\r | |
781 | the correspondence length fields are updated.\r | |
782 | \r | |
783 | @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to add the key-value\r | |
784 | pair.\r | |
785 | \r | |
786 | **/\r | |
6a690e23 | 787 | EFI_STATUS\r |
788 | IScsiAddKeyValuePair (\r | |
789 | IN NET_BUF *Pdu,\r | |
790 | IN CHAR8 *Key,\r | |
791 | IN CHAR8 *Value\r | |
792 | );\r | |
793 | \r | |
12618416 | 794 | /**\r |
795 | Prepare the iSCSI login request to be sent according to the current login status.\r | |
796 | \r | |
797 | @param Conn[in] The connection in the iSCSI login phase.\r | |
798 | \r | |
799 | @retval The pointer to the net buffer containing the iSCSI login request built.\r | |
800 | \r | |
801 | **/\r | |
802 | NET_BUF *\r | |
6a690e23 | 803 | IScsiPrepareLoginReq (\r |
804 | IN ISCSI_CONNECTION *Conn\r | |
805 | );\r | |
806 | \r | |
12618416 | 807 | /**\r |
808 | Process the iSCSI Login Response.\r | |
809 | \r | |
810 | @param Conn[in] The connection on which the iSCSI login response is received.\r | |
811 | \r | |
812 | @param Pdu[in] The iSCSI login response PDU.\r | |
813 | \r | |
814 | @retval EFI_SUCCESS The iSCSI login response PDU is processed and all check are passed.\r | |
815 | \r | |
816 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
817 | \r | |
818 | **/\r | |
6a690e23 | 819 | EFI_STATUS\r |
820 | IScsiProcessLoginRsp (\r | |
821 | IN ISCSI_CONNECTION *Conn,\r | |
822 | IN NET_BUF *Pdu\r | |
823 | );\r | |
824 | \r | |
12618416 | 825 | /**\r |
826 | Updated the target information according the data received in the iSCSI\r | |
827 | login response with an target redirection status.\r | |
828 | \r | |
829 | @param Session[in] The iSCSI session.\r | |
830 | \r | |
831 | @param Data[in] The data segment which should contain the\r | |
832 | TargetAddress key-value list.\r | |
833 | \r | |
834 | @param Len[in] Length of the data.\r | |
835 | \r | |
836 | @retval EFI_SUCCESS The target address is updated.\r | |
837 | \r | |
838 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
839 | \r | |
840 | @retval EFI_NOT_FOUND The TargetAddress key is not found.\r | |
841 | \r | |
842 | **/\r | |
6a690e23 | 843 | EFI_STATUS\r |
844 | IScsiUpdateTargetAddress (\r | |
845 | IN ISCSI_SESSION *Session,\r | |
846 | IN CHAR8 *Data,\r | |
847 | IN UINT32 Len\r | |
848 | );\r | |
849 | \r | |
12618416 | 850 | /**\r |
851 | The callback function to free the net buffer list.\r | |
852 | \r | |
853 | @param Arg[in] The opaque parameter.\r | |
854 | \r | |
855 | @retval None.\r | |
856 | \r | |
857 | **/\r | |
6a690e23 | 858 | VOID\r |
859 | IScsiFreeNbufList (\r | |
860 | VOID *Arg\r | |
861 | );\r | |
862 | \r | |
12618416 | 863 | /**\r |
864 | Receive an iSCSI response PDU. An iSCSI response PDU contains an iSCSI PDU header and\r | |
865 | an optional data segment. The two parts will be put into two blocks of buffers in the\r | |
866 | net buffer. The digest check will be conducted in this function if needed and the digests\r | |
867 | will be trimmed from the PDU buffer.\r | |
868 | \r | |
869 | @param Conn[in] The iSCSI connection to receive data from.\r | |
870 | \r | |
871 | @param Pdu[out] The received iSCSI pdu.\r | |
872 | \r | |
873 | @param Context[in] The context used to describe information on the caller provided\r | |
874 | buffer to receive data segment of the iSCSI pdu, it's optional.\r | |
875 | \r | |
876 | @param HeaderDigest[in] Whether there will be header digest received.\r | |
877 | \r | |
878 | @param DataDigest[in] Whether there will be data digest.\r | |
879 | \r | |
880 | @param TimeoutEvent[in] The timeout event, it's optional.\r | |
881 | \r | |
882 | @retval EFI_SUCCESS An iSCSI pdu is received.\r | |
883 | \r | |
884 | @retval EFI_TIMEOUT Timeout happenend.\r | |
885 | \r | |
886 | **/\r | |
6a690e23 | 887 | EFI_STATUS\r |
888 | IScsiReceivePdu (\r | |
889 | IN ISCSI_CONNECTION *Conn,\r | |
890 | OUT NET_BUF **Pdu,\r | |
891 | IN ISCSI_IN_BUFFER_CONTEXT *Context, OPTIONAL\r | |
892 | IN BOOLEAN HeaderDigest,\r | |
893 | IN BOOLEAN DataDigest,\r | |
894 | IN EFI_EVENT TimeoutEvent OPTIONAL\r | |
895 | );\r | |
896 | \r | |
12618416 | 897 | /**\r |
898 | Check and get the result of the prameter negotiation.\r | |
899 | \r | |
900 | @param Conn[in] The connection in iSCSI login.\r | |
901 | \r | |
902 | @param Pdu[in] The iSCSI response PDU containing the parameter list.\r | |
903 | \r | |
904 | @retval EFI_SUCCESS The parmeter check is passed and negotiation is finished.\r | |
905 | \r | |
906 | @retval EFI_PROTOCOL_ERROR Some kind of iSCSI protocol error happened.\r | |
907 | \r | |
908 | **/\r | |
6a690e23 | 909 | EFI_STATUS\r |
910 | IScsiCheckOpParams (\r | |
911 | IN ISCSI_CONNECTION *Conn,\r | |
912 | IN BOOLEAN Transit\r | |
913 | );\r | |
914 | \r | |
12618416 | 915 | /**\r |
916 | Fill the oprational prameters.\r | |
917 | \r | |
918 | @param Conn[in] The connection in iSCSI login.\r | |
919 | \r | |
920 | @param Pdu[in] The iSCSI login request PDU to fill the parameters.\r | |
921 | \r | |
922 | @retval EFI_SUCCESS The parmeters are filled into the iSCSI login request PDU.\r | |
923 | \r | |
924 | @retval EFI_OUT_OF_RESOURCES There is not enough space in the PDU to hold the parameters.\r | |
925 | \r | |
926 | **/\r | |
6a690e23 | 927 | EFI_STATUS\r |
928 | IScsiFillOpParams (\r | |
929 | IN ISCSI_CONNECTION *Conn,\r | |
930 | IN NET_BUF *Pdu\r | |
931 | );\r | |
932 | \r | |
12618416 | 933 | /**\r |
934 | Pad the iSCSI AHS or data segment to an integer number of 4 byte words.\r | |
935 | \r | |
936 | @param Pdu[in] The iSCSI pdu which contains segments to pad.\r | |
937 | \r | |
938 | @param Len[in] The length of the last semgnet in the PDU.\r | |
939 | \r | |
940 | @retval EFI_SUCCESS The segment is padded or no need to pad it.\r | |
941 | \r | |
942 | @retval EFI_OUT_OF_RESOURCES There is not enough remaining free space to add the\r | |
943 | padding bytes.\r | |
944 | \r | |
945 | **/\r | |
6a690e23 | 946 | EFI_STATUS\r |
947 | IScsiPadSegment (\r | |
948 | IN NET_BUF *Pdu,\r | |
949 | IN UINT32 Len\r | |
950 | );\r | |
951 | \r | |
12618416 | 952 | /**\r |
953 | Build a key-value list from the data segment.\r | |
954 | \r | |
955 | @param Data[in] The data segment containing the key-value pairs.\r | |
956 | \r | |
957 | @param Len[in] Length of the data segment.\r | |
958 | \r | |
959 | @retval The key-value list.\r | |
960 | \r | |
961 | **/\r | |
962 | LIST_ENTRY *\r | |
6a690e23 | 963 | IScsiBuildKeyValueList (\r |
964 | IN CHAR8 *Data,\r | |
965 | IN UINT32 Len\r | |
966 | );\r | |
967 | \r | |
12618416 | 968 | /**\r |
969 | Get the value string by the key name from the key-value list. If found,\r | |
970 | the key-value entry will be removed from the list.\r | |
971 | \r | |
972 | @param KeyValueList[in] The key-value list.\r | |
973 | \r | |
974 | @param Key[in] The key name to find.\r | |
975 | \r | |
976 | @retval The value string.\r | |
977 | \r | |
978 | **/\r | |
979 | CHAR8 *\r | |
6a690e23 | 980 | IScsiGetValueByKeyFromList (\r |
e48e37fc | 981 | IN LIST_ENTRY *KeyValueList,\r |
6a690e23 | 982 | IN CHAR8 *Key\r |
983 | );\r | |
984 | \r | |
12618416 | 985 | /**\r |
986 | Free the key-value list.\r | |
987 | \r | |
988 | @param KeyValueList[in] The key-value list.\r | |
989 | \r | |
990 | @retval None.\r | |
991 | \r | |
992 | **/\r | |
6a690e23 | 993 | VOID\r |
994 | IScsiFreeKeyValueList (\r | |
e48e37fc | 995 | IN LIST_ENTRY *KeyValueList\r |
6a690e23 | 996 | );\r |
997 | \r | |
12618416 | 998 | /**\r |
999 | Normalize the iSCSI name according to RFC.\r | |
1000 | \r | |
1001 | @param Name[in] The iSCSI name.\r | |
1002 | \r | |
1003 | @param Len[in] length of the iSCSI name.\r | |
1004 | \r | |
1005 | @retval EFI_SUCCESS The iSCSI name is valid and normalized.\r | |
1006 | \r | |
1007 | @retval EFI_PROTOCOL_ERROR The iSCSI name is mal-formatted or not in the IQN format.\r | |
1008 | \r | |
1009 | **/\r | |
6a690e23 | 1010 | EFI_STATUS\r |
1011 | IScsiNormalizeName (\r | |
1012 | IN CHAR8 *Name,\r | |
1013 | IN UINTN Len\r | |
1014 | );\r | |
1015 | \r | |
12618416 | 1016 | /**\r |
1017 | Execute the SCSI command issued through the EXT SCSI PASS THRU protocol.\r | |
1018 | \r | |
1019 | @param PassThru[in] The EXT SCSI PASS THRU protocol.\r | |
1020 | \r | |
1021 | @param Target[in] The target ID.\r | |
1022 | \r | |
1023 | @param Lun[in] The LUN.\r | |
1024 | \r | |
1025 | @param Packet[in][out] The request packet containing IO request, SCSI command\r | |
1026 | buffer and buffers to read/write.\r | |
1027 | \r | |
1028 | @retval EFI_SUCCES The SCSI command is executed and the result is updated to \r | |
1029 | the Packet.\r | |
1030 | \r | |
1031 | @retval EFI_DEVICE_ERROR Some unexpected error happened.\r | |
1032 | \r | |
1033 | **/\r | |
6a690e23 | 1034 | EFI_STATUS\r |
1035 | IScsiExecuteScsiCommand (\r | |
1036 | IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru,\r | |
1037 | IN UINT8 *Target,\r | |
1038 | IN UINT64 Lun,\r | |
1039 | IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet\r | |
1040 | );\r | |
1041 | \r | |
12618416 | 1042 | /**\r |
1043 | Reinstate the session on some error.\r | |
1044 | \r | |
1045 | @param Private[in] The iSCSI driver data.\r | |
1046 | \r | |
1047 | @retval EFI_SUCCES The session is reinstated from some error.\r | |
1048 | \r | |
1049 | @retval other Reinstatement failed.\r | |
1050 | \r | |
1051 | **/\r | |
6a690e23 | 1052 | EFI_STATUS\r |
1053 | IScsiSessionReinstatement (\r | |
1054 | IN ISCSI_DRIVER_DATA *Private\r | |
1055 | );\r | |
1056 | \r | |
12618416 | 1057 | /**\r |
1058 | Initialize some session parameters before login.\r | |
1059 | \r | |
1060 | @param Session[in] The iSCSI session.\r | |
1061 | \r | |
1062 | @param Recovery[in] Whether the request is from a fresh new start or recovery.\r | |
1063 | \r | |
1064 | @retval None.\r | |
1065 | \r | |
1066 | **/\r | |
6a690e23 | 1067 | VOID\r |
1068 | IScsiSessionInit (\r | |
1069 | IN ISCSI_SESSION *Session,\r | |
1070 | IN BOOLEAN Recovery\r | |
1071 | );\r | |
1072 | \r | |
12618416 | 1073 | /**\r |
1074 | Abort the iSCSI session, that is, reset all the connection and free the\r | |
1075 | resources.\r | |
1076 | \r | |
1077 | @param Session[in] The iSCSI session.\r | |
1078 | \r | |
1079 | @retval EFI_SUCCES The session is aborted.\r | |
1080 | \r | |
1081 | **/\r | |
6a690e23 | 1082 | EFI_STATUS\r |
1083 | IScsiSessionAbort (\r | |
1084 | IN ISCSI_SESSION *Session\r | |
1085 | );\r | |
1086 | \r | |
1087 | #endif\r |