2 * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <gpxe/scsi.h>
26 #include <gpxe/process.h>
27 #include <gpxe/uaccess.h>
28 #include <gpxe/iscsi.h>
36 static void iscsi_start_tx ( struct iscsi_session *iscsi );
37 static void iscsi_start_data_out ( struct iscsi_session *iscsi,
38 unsigned int datasn );
40 /****************************************************************************
42 * iSCSI SCSI command issuing
47 * Build iSCSI SCSI command BHS
49 * @v iscsi iSCSI session
51 * We don't currently support bidirectional commands (i.e. with both
52 * Data-In and Data-Out segments); these would require providing code
53 * to generate an AHS, and there doesn't seem to be any need for it at
56 static void iscsi_start_command ( struct iscsi_session *iscsi ) {
57 struct iscsi_bhs_scsi_command *command = &iscsi->tx_bhs.scsi_command;
59 assert ( ! ( iscsi->command->data_in && iscsi->command->data_out ) );
61 /* Construct BHS and initiate transmission */
62 iscsi_start_tx ( iscsi );
63 command->opcode = ISCSI_OPCODE_SCSI_COMMAND;
64 command->flags = ( ISCSI_FLAG_FINAL |
65 ISCSI_COMMAND_ATTR_SIMPLE );
66 if ( iscsi->command->data_in )
67 command->flags |= ISCSI_COMMAND_FLAG_READ;
68 if ( iscsi->command->data_out )
69 command->flags |= ISCSI_COMMAND_FLAG_WRITE;
70 /* lengths left as zero */
71 command->lun = iscsi->lun;
72 command->itt = htonl ( ++iscsi->itt );
73 command->exp_len = htonl ( iscsi->command->data_in_len |
74 iscsi->command->data_out_len );
75 command->cmdsn = htonl ( iscsi->cmdsn );
76 command->expstatsn = htonl ( iscsi->statsn + 1 );
77 memcpy ( &command->cdb, &iscsi->command->cdb, sizeof ( command->cdb ));
81 * Receive data segment of an iSCSI SCSI response PDU
83 * @v iscsi iSCSI session
84 * @v data Received data
85 * @v len Length of received data
86 * @v remaining Data remaining after this data
89 static void iscsi_rx_scsi_response ( struct iscsi_session *iscsi, void *data,
90 size_t len, size_t remaining ) {
91 struct iscsi_bhs_scsi_response *response
92 = &iscsi->rx_bhs.scsi_response;
95 /* Capture the sense response code as it floats past, if present */
96 sense_offset = ISCSI_SENSE_RESPONSE_CODE_OFFSET - iscsi->rx_offset;
97 if ( ( sense_offset >= 0 ) && len ) {
98 iscsi->command->sense_response =
99 * ( ( char * ) data + sense_offset );
102 /* Wait for whole SCSI response to arrive */
106 /* Record SCSI status code */
107 iscsi->command->status = response->status;
109 /* Mark as completed, with error if applicable */
110 iscsi->status |= ISCSI_STATUS_DONE;
111 if ( response->response != ISCSI_RESPONSE_COMMAND_COMPLETE )
112 iscsi->status |= ISCSI_STATUS_ERR;
116 * Receive data segment of an iSCSI data-in PDU
118 * @v iscsi iSCSI session
119 * @v data Received data
120 * @v len Length of received data
121 * @v remaining Data remaining after this data
124 static void iscsi_rx_data_in ( struct iscsi_session *iscsi, void *data,
125 size_t len, size_t remaining __unused ) {
126 struct iscsi_bhs_data_in *data_in = &iscsi->rx_bhs.data_in;
127 unsigned long offset;
129 /* Copy data to data-in buffer */
130 offset = ntohl ( data_in->offset ) + iscsi->rx_offset;
131 assert ( iscsi->command != NULL );
132 assert ( iscsi->command->data_in != NULL );
133 assert ( ( offset + len ) <= iscsi->command->data_in_len );
134 copy_to_user ( iscsi->command->data_in, offset, data, len );
136 /* Record SCSI status, if present */
137 if ( data_in->flags & ISCSI_DATA_FLAG_STATUS )
138 iscsi->command->status = data_in->status;
140 /* If this is the end, flag as complete */
141 if ( ( offset + len ) == iscsi->command->data_in_len ) {
142 assert ( data_in->flags & ISCSI_FLAG_FINAL );
143 assert ( remaining == 0 );
144 iscsi->status |= ISCSI_STATUS_DONE;
149 * Receive data segment of an iSCSI R2T PDU
151 * @v iscsi iSCSI session
152 * @v data Received data
153 * @v len Length of received data
154 * @v remaining Data remaining after this data
157 static void iscsi_rx_r2t ( struct iscsi_session *iscsi, void *data __unused,
158 size_t len __unused, size_t remaining __unused ) {
159 struct iscsi_bhs_r2t *r2t = &iscsi->rx_bhs.r2t;
161 /* Record transfer parameters and trigger first data-out */
162 iscsi->ttt = ntohl ( r2t->ttt );
163 iscsi->transfer_offset = ntohl ( r2t->offset );
164 iscsi->transfer_len = ntohl ( r2t->len );
165 iscsi_start_data_out ( iscsi, 0 );
169 * Build iSCSI data-out BHS
171 * @v iscsi iSCSI session
172 * @v datasn Data sequence number within the transfer
175 static void iscsi_start_data_out ( struct iscsi_session *iscsi,
176 unsigned int datasn ) {
177 struct iscsi_bhs_data_out *data_out = &iscsi->tx_bhs.data_out;
178 unsigned long offset;
179 unsigned long remaining;
182 /* We always send 512-byte Data-Out PDUs; this removes the
183 * need to worry about the target's MaxRecvDataSegmentLength.
185 offset = datasn * 512;
186 remaining = iscsi->transfer_len - offset;
191 /* Construct BHS and initiate transmission */
192 iscsi_start_tx ( iscsi );
193 data_out->opcode = ISCSI_OPCODE_DATA_OUT;
194 if ( len == remaining )
195 data_out->flags = ( ISCSI_FLAG_FINAL );
196 ISCSI_SET_LENGTHS ( data_out->lengths, 0, len );
197 data_out->lun = iscsi->lun;
198 data_out->itt = htonl ( iscsi->itt );
199 data_out->ttt = htonl ( iscsi->ttt );
200 data_out->expstatsn = htonl ( iscsi->statsn + 1 );
201 data_out->datasn = htonl ( datasn );
202 data_out->offset = htonl ( iscsi->transfer_offset + offset );
206 * Complete iSCSI data-out PDU transmission
208 * @v iscsi iSCSI session
211 static void iscsi_data_out_done ( struct iscsi_session *iscsi ) {
212 struct iscsi_bhs_data_out *data_out = &iscsi->tx_bhs.data_out;
214 /* If we haven't reached the end of the sequence, start
215 * sending the next data-out PDU.
217 if ( ! ( data_out->flags & ISCSI_FLAG_FINAL ) )
218 iscsi_start_data_out ( iscsi, ntohl ( data_out->datasn ) + 1 );
222 * Send iSCSI data-out data segment
224 * @v iscsi iSCSI session
225 * @v buf Temporary data buffer
226 * @v len Length of temporary data buffer
228 static void iscsi_tx_data_out ( struct iscsi_session *iscsi,
229 void *buf, size_t len ) {
230 struct iscsi_bhs_data_out *data_out = &iscsi->tx_bhs.data_out;
231 unsigned long offset;
232 unsigned long remaining;
234 offset = ( iscsi->transfer_offset + ntohl ( data_out->offset ) +
236 remaining = ( ISCSI_DATA_LEN ( data_out->lengths ) - iscsi->tx_offset);
237 assert ( iscsi->command != NULL );
238 assert ( iscsi->command->data_out != NULL );
239 assert ( ( offset + len ) <= iscsi->command->data_out_len );
241 if ( remaining < len )
243 copy_from_user ( buf, iscsi->command->data_out, offset, len );
245 tcp_send ( &iscsi->tcp, buf, len );
248 /****************************************************************************
255 * Build iSCSI login request strings
257 * @v iscsi iSCSI session
259 * These are the initial set of strings sent in the first login
260 * request PDU. We want the following settings:
264 * MaxConnections is irrelevant; we make only one connection anyway
266 * ImmediateData is irrelevant; we never send immediate data
267 * MaxRecvDataSegmentLength=8192 (default; we don't care)
268 * MaxBurstLength=262144 (default; we don't care)
269 * FirstBurstLength=262144 (default; we don't care)
270 * DefaultTime2Wait=0 [2]
271 * DefaultTime2Retain=0 [2]
272 * MaxOutstandingR2T=1
274 * DataSequenceInOrder=Yes
275 * ErrorRecoveryLevel=0
277 * [1] InitialR2T has an OR resolution function, so the target may
278 * force us to use it. We therefore simplify our logic by always
281 * [2] These ensure that we can safely start a new task once we have
282 * reconnected after a failure, without having to manually tidy up
285 static int iscsi_build_login_request_strings ( struct iscsi_session *iscsi,
286 void *data, size_t len ) {
287 return snprintf ( data, len,
290 "SessionType=Normal%c"
291 "HeaderDigest=None%c"
294 "DefaultTime2Wait=0%c"
295 "DefaultTime2Retain=0%c"
296 "MaxOutstandingR2T=1%c"
297 "DataPDUInOrder=Yes%c"
298 "DataSequenceInOrder=Yes%c"
299 "ErrorRecoveryLevel=0%c",
300 iscsi->initiator, 0, iscsi->target, 0,
301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
305 * Build iSCSI login request BHS
307 * @v iscsi iSCSI session
308 * @v first Login request is the first in a sequence
310 static void iscsi_start_login ( struct iscsi_session *iscsi, int first ) {
311 struct iscsi_bhs_login_request *request = &iscsi->tx_bhs.login_request;
314 /* Construct BHS and initiate transmission */
315 iscsi_start_tx ( iscsi );
316 request->opcode = ( ISCSI_OPCODE_LOGIN_REQUEST |
317 ISCSI_FLAG_IMMEDIATE );
318 request->flags = ( ISCSI_LOGIN_FLAG_TRANSITION |
319 ISCSI_LOGIN_CSG_OPERATIONAL_NEGOTIATION |
320 ISCSI_LOGIN_NSG_FULL_FEATURE_PHASE );
321 /* version_max and version_min left as zero */
323 len = iscsi_build_login_request_strings ( iscsi, NULL, 0 );
324 ISCSI_SET_LENGTHS ( request->lengths, 0, len );
326 request->isid_iana_en = htonl ( ISCSI_ISID_IANA |
327 IANA_EN_FEN_SYSTEMS );
328 /* isid_iana_qual left as zero */
329 request->tsih = htons ( iscsi->tsih );
332 request->itt = htonl ( iscsi->itt );
333 /* cid left as zero */
334 request->cmdsn = htonl ( iscsi->cmdsn );
335 request->expstatsn = htonl ( iscsi->statsn + 1 );
339 * Transmit data segment of an iSCSI login request PDU
341 * @v iscsi iSCSI session
342 * @v buf Temporary data buffer
343 * @v len Length of temporary data buffer
345 * For login requests, the data segment consists of the login strings.
347 static void iscsi_tx_login_request ( struct iscsi_session *iscsi,
348 void *buf, size_t len ) {
349 len = iscsi_build_login_request_strings ( iscsi, buf, len );
350 tcp_send ( &iscsi->tcp, buf + iscsi->tx_offset,
351 len - iscsi->tx_offset );
355 * Receive data segment of an iSCSI login response PDU
357 * @v iscsi iSCSI session
358 * @v data Received data
359 * @v len Length of received data
360 * @v remaining Data remaining after this data
363 static void iscsi_rx_login_response ( struct iscsi_session *iscsi,
366 size_t remaining __unused ) {
367 struct iscsi_bhs_login_response *response
368 = &iscsi->rx_bhs.login_response;
370 /* Check for fatal errors */
371 if ( response->status_class != 0 ) {
372 printf ( "iSCSI login failure: class %02x detail %02x\n",
373 response->status_class, response->status_detail );
374 iscsi->status |= ( ISCSI_STATUS_DONE | ISCSI_STATUS_ERR );
375 tcp_close ( &iscsi->tcp );
379 /* If server did not transition, send back another login
380 * request without any login strings.
382 if ( ! ( response->flags & ISCSI_LOGIN_FLAG_TRANSITION ) ) {
383 iscsi_start_login ( iscsi, 0 );
387 /* Record TSIH for future reference */
388 iscsi->tsih = ntohl ( response->tsih );
390 /* Send the SCSI command */
391 iscsi_start_command ( iscsi );
394 /****************************************************************************
396 * iSCSI to TCP interface
400 static inline struct iscsi_session *
401 tcp_to_iscsi ( struct tcp_connection *conn ) {
402 return container_of ( conn, struct iscsi_session, tcp );
406 * Start up a new TX PDU
408 * @v iscsi iSCSI session
410 * This initiates the process of sending a new PDU. Only one PDU may
411 * be in transit at any one time.
413 static void iscsi_start_tx ( struct iscsi_session *iscsi ) {
414 assert ( iscsi->tx_state == ISCSI_TX_IDLE );
416 /* Initialise TX BHS */
417 memset ( &iscsi->tx_bhs, 0, sizeof ( iscsi->tx_bhs ) );
419 /* Flag TX engine to start transmitting */
420 iscsi->tx_state = ISCSI_TX_BHS;
421 iscsi->tx_offset = 0;
425 * Transmit data segment of an iSCSI PDU
427 * @v iscsi iSCSI session
428 * @v buf Temporary data buffer
429 * @v len Length of temporary data buffer
431 * Handle transmission of part of a PDU data segment. iscsi::tx_bhs
432 * will be valid when this is called.
434 static void iscsi_tx_data ( struct iscsi_session *iscsi,
435 void *buf, size_t len ) {
436 struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
438 switch ( common->opcode & ISCSI_OPCODE_MASK ) {
439 case ISCSI_OPCODE_DATA_OUT:
440 iscsi_tx_data_out ( iscsi, buf, len );
442 case ISCSI_OPCODE_LOGIN_REQUEST:
443 iscsi_tx_login_request ( iscsi, buf, len );
452 * Complete iSCSI PDU transmission
454 * @v iscsi iSCSI session
456 * Called when a PDU has been completely transmitted and the TX state
457 * machine is about to enter the idle state. iscsi::tx_bhs will be
458 * valid for the just-completed PDU when this is called.
460 static void iscsi_tx_done ( struct iscsi_session *iscsi ) {
461 struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
463 switch ( common->opcode & ISCSI_OPCODE_MASK ) {
464 case ISCSI_OPCODE_DATA_OUT:
465 iscsi_data_out_done ( iscsi );
475 * @v iscsi iSCSI session
477 * Updates iscsi->tx_offset and, if applicable, transitions to the
480 static void iscsi_acked ( struct tcp_connection *conn, size_t len ) {
481 struct iscsi_session *iscsi = tcp_to_iscsi ( conn );
482 struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
483 size_t max_tx_offset;
484 enum iscsi_tx_state next_state;
486 iscsi->tx_offset += len;
488 switch ( iscsi->tx_state ) {
490 max_tx_offset = sizeof ( iscsi->tx_bhs );
491 next_state = ISCSI_TX_AHS;
494 max_tx_offset = 4 * ISCSI_AHS_LEN ( common->lengths );
495 next_state = ISCSI_TX_DATA;
498 max_tx_offset = ISCSI_DATA_LEN ( common->lengths );
499 next_state = ISCSI_TX_DATA_PADDING;
501 case ISCSI_TX_DATA_PADDING:
502 max_tx_offset = ISCSI_DATA_PAD_LEN ( common->lengths );
503 next_state = ISCSI_TX_IDLE;
511 assert ( iscsi->tx_offset <= max_tx_offset );
513 /* If the whole of the current portion has not yet
514 * been acked, stay in this state for now.
516 if ( iscsi->tx_offset != max_tx_offset )
519 /* Move to next state. Call iscsi_tx_done() when PDU
520 * transmission is complete.
522 iscsi->tx_state = next_state;
523 iscsi->tx_offset = 0;
524 if ( next_state == ISCSI_TX_IDLE )
525 iscsi_tx_done ( iscsi );
532 * @v iscsi iSCSI session
533 * @v buf Temporary data buffer
534 * @v len Length of temporary data buffer
536 * Constructs data to be sent for the current TX state
538 static void iscsi_senddata ( struct tcp_connection *conn,
539 void *buf, size_t len ) {
540 struct iscsi_session *iscsi = tcp_to_iscsi ( conn );
541 struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
542 static const char pad[] = { '\0', '\0', '\0' };
544 switch ( iscsi->tx_state ) {
546 /* Nothing to send */
549 tcp_send ( conn, &iscsi->tx_bhs.bytes[iscsi->tx_offset],
550 ( sizeof ( iscsi->tx_bhs ) - iscsi->tx_offset ) );
553 /* We don't yet have an AHS transmission mechanism */
557 iscsi_tx_data ( iscsi, buf, len );
559 case ISCSI_TX_DATA_PADDING:
560 tcp_send ( conn, pad, ( ISCSI_DATA_PAD_LEN ( common->lengths )
561 - iscsi->tx_offset ) );
570 * Receive data segment of an iSCSI PDU
572 * @v iscsi iSCSI session
573 * @v data Received data
574 * @v len Length of received data
575 * @v remaining Data remaining after this data
577 * Handle processing of part of a PDU data segment. iscsi::rx_bhs
578 * will be valid when this is called.
580 static void iscsi_rx_data ( struct iscsi_session *iscsi, void *data,
581 size_t len, size_t remaining ) {
582 struct iscsi_bhs_common_response *response
583 = &iscsi->rx_bhs.common_response;
585 /* Update cmdsn and statsn */
586 iscsi->cmdsn = ntohl ( response->expcmdsn );
587 iscsi->statsn = ntohl ( response->statsn );
589 switch ( response->opcode & ISCSI_OPCODE_MASK ) {
590 case ISCSI_OPCODE_LOGIN_RESPONSE:
591 iscsi_rx_login_response ( iscsi, data, len, remaining );
593 case ISCSI_OPCODE_SCSI_RESPONSE:
594 iscsi_rx_scsi_response ( iscsi, data, len, remaining );
596 case ISCSI_OPCODE_DATA_IN:
597 iscsi_rx_data_in ( iscsi, data, len, remaining );
599 case ISCSI_OPCODE_R2T:
600 iscsi_rx_r2t ( iscsi, data, len, remaining );
603 printf ( "Unknown iSCSI opcode %02x\n", response->opcode );
604 iscsi->status |= ( ISCSI_STATUS_DONE | ISCSI_STATUS_ERR );
610 * Discard portion of an iSCSI PDU.
612 * @v iscsi iSCSI session
613 * @v data Received data
614 * @v len Length of received data
615 * @v remaining Data remaining after this data
617 * This discards data from a portion of a received PDU.
619 static void iscsi_rx_discard ( struct iscsi_session *iscsi __unused,
620 void *data __unused, size_t len __unused,
621 size_t remaining __unused ) {
626 * Receive basic header segment of an iSCSI PDU
628 * @v iscsi iSCSI session
629 * @v data Received data
630 * @v len Length of received data
631 * @v remaining Data remaining after this data
633 * This fills in iscsi::rx_bhs with the data from the BHS portion of
636 static void iscsi_rx_bhs ( struct iscsi_session *iscsi, void *data,
637 size_t len, size_t remaining __unused ) {
638 memcpy ( &iscsi->rx_bhs.bytes[iscsi->rx_offset], data, len );
644 * @v tcp TCP connection
645 * @v data Received data
646 * @v len Length of received data
648 * This handles received PDUs. The receive strategy is to fill in
649 * iscsi::rx_bhs with the contents of the BHS portion of the PDU,
650 * throw away any AHS portion, and then process each part of the data
651 * portion as it arrives. The data processing routine therefore
652 * always has a full copy of the BHS available, even for portions of
653 * the data in different packets to the BHS.
655 static void iscsi_newdata ( struct tcp_connection *conn, void *data,
657 struct iscsi_session *iscsi = tcp_to_iscsi ( conn );
658 struct iscsi_bhs_common *common = &iscsi->rx_bhs.common;
659 void ( *process ) ( struct iscsi_session *iscsi, void *data,
660 size_t len, size_t remaining );
661 size_t max_rx_offset;
662 enum iscsi_rx_state next_state;
667 switch ( iscsi->rx_state ) {
669 process = iscsi_rx_bhs;
670 max_rx_offset = sizeof ( iscsi->rx_bhs );
671 next_state = ISCSI_RX_AHS;
674 process = iscsi_rx_discard;
675 max_rx_offset = 4 * ISCSI_AHS_LEN ( common->lengths );
676 next_state = ISCSI_RX_DATA;
679 process = iscsi_rx_data;
680 max_rx_offset = ISCSI_DATA_LEN ( common->lengths );
681 next_state = ISCSI_RX_DATA_PADDING;
683 case ISCSI_RX_DATA_PADDING:
684 process = iscsi_rx_discard;
685 max_rx_offset = ISCSI_DATA_PAD_LEN ( common->lengths );
686 next_state = ISCSI_RX_BHS;
693 frag_len = max_rx_offset - iscsi->rx_offset;
694 if ( frag_len > len )
696 remaining = max_rx_offset - iscsi->rx_offset - frag_len;
697 process ( iscsi, data, frag_len, remaining );
699 iscsi->rx_offset += frag_len;
703 /* If all the data for this state has not yet been
704 * received, stay in this state for now.
706 if ( iscsi->rx_offset != max_rx_offset )
709 iscsi->rx_state = next_state;
710 iscsi->rx_offset = 0;
715 * Handle TCP connection closure
717 * @v conn TCP connection
718 * @v status Error code, if any
721 static void iscsi_closed ( struct tcp_connection *conn, int status __unused ) {
722 struct iscsi_session *iscsi = tcp_to_iscsi ( conn );
724 /* Clear connected flag */
725 iscsi->status &= ~ISCSI_STATUS_CONNECTED;
727 /* Retry connection if within the retry limit, otherwise fail */
728 if ( ++iscsi->retry_count <= ISCSI_MAX_RETRIES ) {
729 tcp_connect ( conn );
731 printf ( "iSCSI retry count exceeded\n" );
732 iscsi->status |= ( ISCSI_STATUS_DONE | ISCSI_STATUS_ERR );
737 * Handle TCP connection opening
739 * @v conn TCP connection
742 static void iscsi_connected ( struct tcp_connection *conn ) {
743 struct iscsi_session *iscsi = tcp_to_iscsi ( conn );
745 /* Set connected flag and reset retry count */
746 iscsi->status |= ISCSI_STATUS_CONNECTED;
747 iscsi->retry_count = 0;
749 /* Prepare to receive PDUs. */
750 iscsi->rx_state = ISCSI_RX_BHS;
751 iscsi->rx_offset = 0;
753 /* Start logging in */
754 iscsi_start_login ( iscsi, 1 );
757 /** iSCSI TCP operations */
758 static struct tcp_operations iscsi_tcp_operations = {
759 .closed = iscsi_closed,
760 .connected = iscsi_connected,
761 .acked = iscsi_acked,
762 .newdata = iscsi_newdata,
763 .senddata = iscsi_senddata,
767 * Issue SCSI command via iSCSI session
769 * @v iscsi iSCSI session
770 * @v command SCSI command
771 * @ret rc Return status code
773 int iscsi_issue ( struct iscsi_session *iscsi,
774 struct scsi_command *command ) {
775 iscsi->command = command;
776 iscsi->status &= ~( ISCSI_STATUS_DONE | ISCSI_STATUS_ERR );
778 if ( iscsi->status & ISCSI_STATUS_CONNECTED ) {
779 iscsi_start_command ( iscsi );
780 tcp_kick ( &iscsi->tcp );
782 iscsi->tcp.tcp_op = &iscsi_tcp_operations;
783 tcp_connect ( &iscsi->tcp );
786 while ( ! ( iscsi->status & ISCSI_STATUS_DONE ) ) {
790 iscsi->command = NULL;
792 return ( ( iscsi->status & ISCSI_STATUS_ERR ) ? -EIO : 0 );