summaryrefslogtreecommitdiffstats
path: root/src/drivers/block/scsi.c
diff options
context:
space:
mode:
authorMichael Brown2009-07-13 06:01:54 +0200
committerMichael Brown2009-07-18 00:00:46 +0200
commitacfd7cc6092e467376f950a61f4b4474ff0813e5 (patch)
tree4c4437dbcd121e4f3944979ff9aa0f39523264b0 /src/drivers/block/scsi.c
parent[scsi] Make SCSI command issuing partially asynchronous (diff)
downloadipxe-acfd7cc6092e467376f950a61f4b4474ff0813e5.tar.gz
ipxe-acfd7cc6092e467376f950a61f4b4474ff0813e5.tar.xz
ipxe-acfd7cc6092e467376f950a61f4b4474ff0813e5.zip
[scsi] Improve SCSI debugging
Diffstat (limited to 'src/drivers/block/scsi.c')
-rw-r--r--src/drivers/block/scsi.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/drivers/block/scsi.c b/src/drivers/block/scsi.c
index d6511c97..fe6dcd8c 100644
--- a/src/drivers/block/scsi.c
+++ b/src/drivers/block/scsi.c
@@ -55,6 +55,9 @@ static int scsi_command ( struct scsi_device *scsi,
struct scsi_command *command ) {
int rc;
+ DBGC2 ( scsi, "SCSI %p " SCSI_CDB_FORMAT "\n",
+ scsi, SCSI_CDB_DATA ( command->cdb ) );
+
/* Clear sense response code before issuing command */
command->sense_response = 0;
@@ -64,8 +67,8 @@ static int scsi_command ( struct scsi_device *scsi,
/* Issue SCSI command */
if ( ( rc = scsi->command ( scsi, command ) ) != 0 ) {
/* Something went wrong with the issuing mechanism */
- DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
- scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
+ DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
+ scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
return rc;
}
@@ -74,16 +77,16 @@ static int scsi_command ( struct scsi_device *scsi,
step();
if ( ( rc = command->rc ) != 0 ) {
/* Something went wrong with the command execution */
- DBG ( "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
- scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
+ DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " err %s\n",
+ scsi, SCSI_CDB_DATA ( command->cdb ), strerror ( rc ) );
return rc;
}
/* Check for SCSI errors */
if ( command->status != 0 ) {
- DBG ( "SCSI %p " SCSI_CDB_FORMAT " status %02x sense %02x\n",
- scsi, SCSI_CDB_DATA ( command->cdb ),
- command->status, command->sense_response );
+ DBGC ( scsi, "SCSI %p " SCSI_CDB_FORMAT " status %02x sense "
+ "%02x\n", scsi, SCSI_CDB_DATA ( command->cdb ),
+ command->status, command->sense_response );
return -EIO;
}
@@ -285,12 +288,17 @@ int init_scsidev ( struct scsi_device *scsi ) {
for ( i = 0 ; i < SCSI_MAX_DUMMY_READ_CAP ; i++ ) {
if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) == 0 )
break;
+ DBGC ( scsi, "SCSI %p ignoring start-of-day error (#%d)\n",
+ scsi, ( i + 1 ) );
}
/* Try READ CAPACITY (10), which is a mandatory command, first. */
scsi->blockdev.op = &scsi_operations_10;
- if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) != 0 )
+ if ( ( rc = scsi_read_capacity_10 ( &scsi->blockdev ) ) != 0 ) {
+ DBGC ( scsi, "SCSI %p could not READ CAPACITY (10): %s\n",
+ scsi, strerror ( rc ) );
return rc;
+ }
/* If capacity range was exceeded (i.e. capacity.lba was
* 0xffffffff, meaning that blockdev->blocks is now zero), use
@@ -299,9 +307,18 @@ int init_scsidev ( struct scsi_device *scsi ) {
*/
if ( scsi->blockdev.blocks == 0 ) {
scsi->blockdev.op = &scsi_operations_16;
- if ( ( rc = scsi_read_capacity_16 ( &scsi->blockdev ) ) != 0 )
+ if ( ( rc = scsi_read_capacity_16 ( &scsi->blockdev ) ) != 0 ){
+ DBGC ( scsi, "SCSI %p could not READ CAPACITY (16): "
+ "%s\n", scsi, strerror ( rc ) );
return rc;
+ }
}
+ DBGC ( scsi, "SCSI %p using READ/WRITE (%d) commands\n", scsi,
+ ( ( scsi->blockdev.op == &scsi_operations_10 ) ? 10 : 16 ) );
+ DBGC ( scsi, "SCSI %p capacity is %ld MB (%#llx blocks)\n", scsi,
+ ( ( unsigned long ) ( scsi->blockdev.blocks >> 11 ) ),
+ scsi->blockdev.blocks );
+
return 0;
}