summaryrefslogtreecommitdiff
path: root/gpxe/src/net/tcp/iscsi.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-02 22:41:00 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-02 22:41:00 -0800
commit702c7fbe7342403472e887508716add0c58c385c (patch)
tree639050b522cea25f4475d48da54380d61c7d10f3 /gpxe/src/net/tcp/iscsi.c
parent1e96e9cc1c3549c86dbf4e7caf880477e16e93e0 (diff)
downloadsyslinux-702c7fbe7342403472e887508716add0c58c385c.tar.gz
Update gPXE to version 1.0.0
Diffstat (limited to 'gpxe/src/net/tcp/iscsi.c')
-rw-r--r--gpxe/src/net/tcp/iscsi.c79
1 files changed, 16 insertions, 63 deletions
diff --git a/gpxe/src/net/tcp/iscsi.c b/gpxe/src/net/tcp/iscsi.c
index 45519e66..771384b9 100644
--- a/gpxe/src/net/tcp/iscsi.c
+++ b/gpxe/src/net/tcp/iscsi.c
@@ -16,6 +16,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+FILE_LICENCE ( GPL2_OR_LATER );
+
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
@@ -180,9 +182,10 @@ static void iscsi_close_connection ( struct iscsi_session *iscsi, int rc ) {
static void iscsi_scsi_done ( struct iscsi_session *iscsi, int rc ) {
assert ( iscsi->tx_state == ISCSI_TX_IDLE );
+ assert ( iscsi->command != NULL );
+ iscsi->command->rc = rc;
iscsi->command = NULL;
- iscsi->rc = rc;
}
/****************************************************************************
@@ -1514,7 +1517,7 @@ static int iscsi_vredirect ( struct xfer_interface *socket, int type,
va_end ( tmp );
}
- return xfer_vopen ( socket, type, args );
+ return xfer_vreopen ( socket, type, args );
}
@@ -1548,37 +1551,24 @@ static int iscsi_command ( struct scsi_device *scsi,
container_of ( scsi->backend, struct iscsi_session, refcnt );
int rc;
+ /* Abort immediately if we have a recorded permanent failure */
+ if ( iscsi->instant_rc )
+ return iscsi->instant_rc;
+
/* Record SCSI command */
iscsi->command = command;
- /* Abort immediately if we have a recorded permanent failure */
- if ( iscsi->instant_rc ) {
- rc = iscsi->instant_rc;
- goto done;
- }
-
/* Issue command or open connection as appropriate */
if ( iscsi->status ) {
iscsi_start_command ( iscsi );
} else {
- if ( ( rc = iscsi_open_connection ( iscsi ) ) != 0 )
- goto done;
+ if ( ( rc = iscsi_open_connection ( iscsi ) ) != 0 ) {
+ iscsi->command = NULL;
+ return rc;
+ }
}
- /* Wait for command to complete */
- iscsi->rc = -EINPROGRESS;
- while ( iscsi->rc == -EINPROGRESS )
- step();
- rc = iscsi->rc;
-
- done:
- iscsi->command = NULL;
- return rc;
-}
-
-static int iscsi_detached_command ( struct scsi_device *scsi __unused,
- struct scsi_command *command __unused ) {
- return -ENODEV;
+ return 0;
}
/**
@@ -1593,7 +1583,7 @@ void iscsi_detach ( struct scsi_device *scsi ) {
xfer_nullify ( &iscsi->socket );
iscsi_close_connection ( iscsi, 0 );
process_del ( &iscsi->process );
- scsi->command = iscsi_detached_command;
+ scsi->command = scsi_detached_command;
ref_put ( scsi->backend );
scsi->backend = NULL;
}
@@ -1616,42 +1606,6 @@ enum iscsi_root_path_component {
};
/**
- * Parse iSCSI LUN
- *
- * @v iscsi iSCSI session
- * @v lun_string LUN string representation (as per RFC4173)
- * @ret rc Return status code
- */
-static int iscsi_parse_lun ( struct iscsi_session *iscsi,
- const char *lun_string ) {
- union {
- uint64_t u64;
- uint16_t u16[4];
- } lun;
- char *p;
- int i;
-
- memset ( &lun, 0, sizeof ( lun ) );
- if ( lun_string ) {
- p = ( char * ) lun_string;
-
- for ( i = 0 ; i < 4 ; i++ ) {
- lun.u16[i] = htons ( strtoul ( p, &p, 16 ) );
- if ( *p == '\0' )
- break;
- if ( *p != '-' )
- return -EINVAL;
- p++;
- }
- if ( *p )
- return -EINVAL;
- }
-
- iscsi->lun = lun.u64;
- return 0;
-}
-
-/**
* Parse iSCSI root path
*
* @v iscsi iSCSI session
@@ -1689,7 +1643,7 @@ static int iscsi_parse_root_path ( struct iscsi_session *iscsi,
iscsi->target_port = strtoul ( rp_comp[RP_PORT], NULL, 10 );
if ( ! iscsi->target_port )
iscsi->target_port = ISCSI_PORT;
- if ( ( rc = iscsi_parse_lun ( iscsi, rp_comp[RP_LUN] ) ) != 0 ) {
+ if ( ( rc = scsi_parse_lun ( rp_comp[RP_LUN], &iscsi->lun ) ) != 0 ) {
DBGC ( iscsi, "iSCSI %p invalid LUN \"%s\"\n",
iscsi, rp_comp[RP_LUN] );
return rc;
@@ -1809,7 +1763,6 @@ int iscsi_attach ( struct scsi_device *scsi, const char *root_path ) {
/* Attach parent interface, mortalise self, and return */
scsi->backend = ref_get ( &iscsi->refcnt );
scsi->command = iscsi_command;
- scsi->lun = iscsi->lun;
ref_put ( &iscsi->refcnt );
return 0;