Browse Source

Code in place to use a hypothetical SCSI interface.

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
edd1b173a7
2 changed files with 28 additions and 8 deletions
  1. 5
    0
      src/include/gpxe/iscsi.h
  2. 23
    8
      src/net/tcp/iscsi.c

+ 5
- 0
src/include/gpxe/iscsi.h View File

@@ -589,6 +589,11 @@ struct iscsi_session {
589 589
 	 * Set to NULL when command is complete.
590 590
 	 */
591 591
 	struct scsi_command *command;
592
+	/** SCSI command return code
593
+	 *
594
+	 * Set to -EINPROGRESS while command is processing.
595
+	 */
596
+	int rc;
592 597
 	/** Instant return code
593 598
 	 *
594 599
 	 * Set to a non-zero value if all requests should return

+ 23
- 8
src/net/tcp/iscsi.c View File

@@ -165,11 +165,8 @@ static void iscsi_scsi_done ( struct iscsi_session *iscsi, int rc ) {
165 165
 
166 166
 	assert ( iscsi->tx_state == ISCSI_TX_IDLE );
167 167
 
168
-	/* Clear current SCSI command */
169 168
 	iscsi->command = NULL;
170
-
171
-	/* Mark asynchronous operation as complete */
172
-	async_done ( &iscsi->async, rc );
169
+	iscsi->rc = rc;
173 170
 }
174 171
 
175 172
 /****************************************************************************
@@ -1281,20 +1278,32 @@ static int iscsi_scsi_issue ( struct scsi_interface *scsi,
1281 1278
 		container_of ( scsi, struct iscsi_session, scsi );
1282 1279
 	int rc;
1283 1280
 
1281
+	/* Record SCSI command */
1282
+	iscsi->command = command;
1284 1283
 
1285 1284
 	/* Abort immediately if we have a recorded permanent failure */
1286
-	if ( iscsi->instant_rc )
1287
-		return iscsi->instant_rc;
1285
+	if ( iscsi->instant_rc ) {
1286
+		rc = iscsi->instant_rc;
1287
+		goto done;
1288
+	}
1288 1289
 
1289 1290
 	/* Issue command or open connection as appropriate */
1290 1291
 	if ( iscsi->status ) {
1291 1292
 		iscsi_start_command ( iscsi );
1292 1293
 	} else {
1293 1294
 		if ( ( rc = iscsi_open_connection ( iscsi ) ) != 0 )
1294
-			return rc;
1295
+			goto done;
1295 1296
 	}
1296 1297
 
1297
-	return 0;
1298
+	/* Wait for command to complete */
1299
+	iscsi->rc = -EINPROGRESS;
1300
+	while ( iscsi->rc == -EINPROGRESS )
1301
+		step();
1302
+	rc = iscsi->rc;
1303
+
1304
+ done:
1305
+	iscsi->command = NULL;
1306
+	return rc;
1298 1307
 }
1299 1308
 
1300 1309
 /**
@@ -1311,6 +1320,12 @@ static void iscsi_scsi_detach ( struct scsi_interface *scsi, int rc ) {
1311 1320
 	process_del ( &iscsi->process );
1312 1321
 }
1313 1322
 
1323
+/** iSCSI SCSI operations */
1324
+struct scsi_operations iscsi_scsi_operations = {
1325
+	.detach		= iscsi_scsi_detach,
1326
+	.issue		= iscsi_scsi_issue,
1327
+};
1328
+
1314 1329
 /****************************************************************************
1315 1330
  *
1316 1331
  * Instantiator

Loading…
Cancel
Save