diff mbox

add suport for ATA_PASSTHROUGH_xx scsi command

Message ID 1343807602-2229-1-git-send-email-mc@linux.vnet.ibm.com
State New
Headers show

Commit Message

Cong Meng Aug. 1, 2012, 7:53 a.m. UTC
Correct the command names of opcode 0x85 and 0xa1, and calculate
their xfer size from CDB.

Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
---
 hw/scsi-bus.c  |   17 ++++++++++++++---
 hw/scsi-defs.h |    4 ++--
 2 files changed, 16 insertions(+), 5 deletions(-)

Comments

Paolo Bonzini Aug. 1, 2012, 8:20 a.m. UTC | #1
Il 01/08/2012 09:53, Cong Meng ha scritto:
> Correct the command names of opcode 0x85 and 0xa1, and calculate
> their xfer size from CDB.
> 
> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
> ---
>  hw/scsi-bus.c  |   17 ++++++++++++++---
>  hw/scsi-defs.h |    4 ++--
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index e4ec19e..cf9f4fe 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -867,6 +867,16 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
>              cmd->xfer = buf[9] | (buf[8] << 8);
>          }
>          break;
> +    case ATA_PASSTHROUGH_12:

Please make this conditional on the type _not_ being TYPE_ROM.

Paolo

> +        if ((buf[2] & 0x3) == 2) {
> +            cmd->xfer = buf[4] * dev->blocksize;
> +        }
> +        break;
> +    case ATA_PASSTHROUGH_16:
> +        if ((buf[2] & 0x3) == 2) {
> +            cmd->xfer = ((buf[5] << 8) | buf[6]) * dev->blocksize;
> +        }
> +        break;
>      }
>      return 0;
>  }
> @@ -996,7 +1006,8 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
>      case SEND_DVD_STRUCTURE:
>      case PERSISTENT_RESERVE_OUT:
>      case MAINTENANCE_OUT:
> -    case ATA_PASSTHROUGH:
> +    case ATA_PASSTHROUGH_12:
> +    case ATA_PASSTHROUGH_16:
>          cmd->mode = SCSI_XFER_TO_DEV;
>          break;
>      default:
> @@ -1335,7 +1346,7 @@ static const char *scsi_command_name(uint8_t cmd)
>          [ PERSISTENT_RESERVE_OUT   ] = "PERSISTENT_RESERVE_OUT",
>          [ WRITE_FILEMARKS_16       ] = "WRITE_FILEMARKS_16",
>          [ EXTENDED_COPY            ] = "EXTENDED_COPY",
> -        [ ATA_PASSTHROUGH          ] = "ATA_PASSTHROUGH",
> +        [ ATA_PASSTHROUGH_16       ] = "ATA_PASSTHROUGH_16",
>          [ ACCESS_CONTROL_IN        ] = "ACCESS_CONTROL_IN",
>          [ ACCESS_CONTROL_OUT       ] = "ACCESS_CONTROL_OUT",
>          [ READ_16                  ] = "READ_16",
> @@ -1352,7 +1363,7 @@ static const char *scsi_command_name(uint8_t cmd)
>          [ SERVICE_ACTION_IN_16     ] = "SERVICE_ACTION_IN_16",
>          [ WRITE_LONG_16            ] = "WRITE_LONG_16",
>          [ REPORT_LUNS              ] = "REPORT_LUNS",
> -        [ BLANK                    ] = "BLANK",
> +        [ ATA_PASSTHROUGH_12       ] = "ATA_PASSTHROUGH_12",
>          [ MOVE_MEDIUM              ] = "MOVE_MEDIUM",
>          [ EXCHANGE_MEDIUM          ] = "EXCHANGE MEDIUM",
>          [ LOAD_UNLOAD              ] = "LOAD_UNLOAD",
> diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
> index 8a73f74..d7a4019 100644
> --- a/hw/scsi-defs.h
> +++ b/hw/scsi-defs.h
> @@ -100,7 +100,7 @@
>  #define READ_REVERSE_16       0x81
>  #define ALLOW_OVERWRITE       0x82
>  #define EXTENDED_COPY         0x83
> -#define ATA_PASSTHROUGH       0x85
> +#define ATA_PASSTHROUGH_16    0x85
>  #define ACCESS_CONTROL_IN     0x86
>  #define ACCESS_CONTROL_OUT    0x87
>  #define READ_16               0x88
> @@ -117,7 +117,7 @@
>  #define SERVICE_ACTION_IN_16  0x9e
>  #define WRITE_LONG_16         0x9f
>  #define REPORT_LUNS           0xa0
> -#define BLANK                 0xa1
> +#define ATA_PASSTHROUGH_12    0xa1
>  #define MAINTENANCE_IN        0xa3
>  #define MAINTENANCE_OUT       0xa4
>  #define MOVE_MEDIUM           0xa5
>
Cong Meng Aug. 1, 2012, 8:43 a.m. UTC | #2
On Wed 01 Aug 2012 04:20:28 PM CST, Paolo Bonzini wrote:
> Il 01/08/2012 09:53, Cong Meng ha scritto:
>> Correct the command names of opcode 0x85 and 0xa1, and calculate
>> their xfer size from CDB.
>>
>> Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
>> ---
>>   hw/scsi-bus.c  |   17 ++++++++++++++---
>>   hw/scsi-defs.h |    4 ++--
>>   2 files changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
>> index e4ec19e..cf9f4fe 100644
>> --- a/hw/scsi-bus.c
>> +++ b/hw/scsi-bus.c
>> @@ -867,6 +867,16 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
>>               cmd->xfer = buf[9] | (buf[8] << 8);
>>           }
>>           break;
>> +    case ATA_PASSTHROUGH_12:
>
> Please make this conditional on the type _not_ being TYPE_ROM.

May I ask why cdrom device should be an exception?
Thanks.
Cong

>
> Paolo
>
>> +        if ((buf[2] & 0x3) == 2) {
>> +            cmd->xfer = buf[4] * dev->blocksize;
>> +        }
>> +        break;
>> +    case ATA_PASSTHROUGH_16:
>> +        if ((buf[2] & 0x3) == 2) {
>> +            cmd->xfer = ((buf[5] << 8) | buf[6]) * dev->blocksize;
>> +        }
>> +        break;
>>       }
>>       return 0;
>>   }
>> @@ -996,7 +1006,8 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)
>>       case SEND_DVD_STRUCTURE:
>>       case PERSISTENT_RESERVE_OUT:
>>       case MAINTENANCE_OUT:
>> -    case ATA_PASSTHROUGH:
>> +    case ATA_PASSTHROUGH_12:
>> +    case ATA_PASSTHROUGH_16:
>>           cmd->mode = SCSI_XFER_TO_DEV;
>>           break;
>>       default:
>> @@ -1335,7 +1346,7 @@ static const char *scsi_command_name(uint8_t cmd)
>>           [ PERSISTENT_RESERVE_OUT   ] = "PERSISTENT_RESERVE_OUT",
>>           [ WRITE_FILEMARKS_16       ] = "WRITE_FILEMARKS_16",
>>           [ EXTENDED_COPY            ] = "EXTENDED_COPY",
>> -        [ ATA_PASSTHROUGH          ] = "ATA_PASSTHROUGH",
>> +        [ ATA_PASSTHROUGH_16       ] = "ATA_PASSTHROUGH_16",
>>           [ ACCESS_CONTROL_IN        ] = "ACCESS_CONTROL_IN",
>>           [ ACCESS_CONTROL_OUT       ] = "ACCESS_CONTROL_OUT",
>>           [ READ_16                  ] = "READ_16",
>> @@ -1352,7 +1363,7 @@ static const char *scsi_command_name(uint8_t cmd)
>>           [ SERVICE_ACTION_IN_16     ] = "SERVICE_ACTION_IN_16",
>>           [ WRITE_LONG_16            ] = "WRITE_LONG_16",
>>           [ REPORT_LUNS              ] = "REPORT_LUNS",
>> -        [ BLANK                    ] = "BLANK",
>> +        [ ATA_PASSTHROUGH_12       ] = "ATA_PASSTHROUGH_12",
>>           [ MOVE_MEDIUM              ] = "MOVE_MEDIUM",
>>           [ EXCHANGE_MEDIUM          ] = "EXCHANGE MEDIUM",
>>           [ LOAD_UNLOAD              ] = "LOAD_UNLOAD",
>> diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
>> index 8a73f74..d7a4019 100644
>> --- a/hw/scsi-defs.h
>> +++ b/hw/scsi-defs.h
>> @@ -100,7 +100,7 @@
>>   #define READ_REVERSE_16       0x81
>>   #define ALLOW_OVERWRITE       0x82
>>   #define EXTENDED_COPY         0x83
>> -#define ATA_PASSTHROUGH       0x85
>> +#define ATA_PASSTHROUGH_16    0x85
>>   #define ACCESS_CONTROL_IN     0x86
>>   #define ACCESS_CONTROL_OUT    0x87
>>   #define READ_16               0x88
>> @@ -117,7 +117,7 @@
>>   #define SERVICE_ACTION_IN_16  0x9e
>>   #define WRITE_LONG_16         0x9f
>>   #define REPORT_LUNS           0xa0
>> -#define BLANK                 0xa1
>> +#define ATA_PASSTHROUGH_12    0xa1
>>   #define MAINTENANCE_IN        0xa3
>>   #define MAINTENANCE_OUT       0xa4
>>   #define MOVE_MEDIUM           0xa5
>>
>
>
Paolo Bonzini Aug. 1, 2012, 8:45 a.m. UTC | #3
Il 01/08/2012 10:43, Cong Meng ha scritto:
>>
>> Please make this conditional on the type _not_ being TYPE_ROM.
> 
> May I ask why cdrom device should be an exception?

Because CD-ROM devices do not support ATA PASSTHROUGH (the SAT standard
only describes direct access devices---type=0x00).  The 0xa1 command is
"BLANK" for CD-ROMs.

Paolo
ronnie sahlberg Aug. 1, 2012, 8:49 a.m. UTC | #4
Because opcode 0xA1 has a different meaning for CDROM/MMC devices.
On such devices 0xA1 means BLANK, so it would collide if QEMU some day
adds support for
re-writeable mmc device.


On Wed, Aug 1, 2012 at 6:45 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 01/08/2012 10:43, Cong Meng ha scritto:
>>>
>>> Please make this conditional on the type _not_ being TYPE_ROM.
>>
>> May I ask why cdrom device should be an exception?
>
> Because CD-ROM devices do not support ATA PASSTHROUGH (the SAT standard
> only describes direct access devices---type=0x00).  The 0xa1 command is
> "BLANK" for CD-ROMs.
>
> Paolo
>
Cong Meng Aug. 1, 2012, 8:55 a.m. UTC | #5
I see. thank both.

On Wed 01 Aug 2012 04:49:18 PM CST, ronnie sahlberg wrote:
> Because opcode 0xA1 has a different meaning for CDROM/MMC devices.
> On such devices 0xA1 means BLANK, so it would collide if QEMU some day
> adds support for
> re-writeable mmc device.
>
>
> On Wed, Aug 1, 2012 at 6:45 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> Il 01/08/2012 10:43, Cong Meng ha scritto:
>>>>
>>>> Please make this conditional on the type _not_ being TYPE_ROM.
>>>
>>> May I ask why cdrom device should be an exception?
>>
>> Because CD-ROM devices do not support ATA PASSTHROUGH (the SAT standard
>> only describes direct access devices---type=0x00).  The 0xa1 command is
>> "BLANK" for CD-ROMs.
>>
>> Paolo
>>
>
diff mbox

Patch

diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index e4ec19e..cf9f4fe 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -867,6 +867,16 @@  static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
             cmd->xfer = buf[9] | (buf[8] << 8);
         }
         break;
+    case ATA_PASSTHROUGH_12:
+        if ((buf[2] & 0x3) == 2) {
+            cmd->xfer = buf[4] * dev->blocksize;
+        }
+        break;
+    case ATA_PASSTHROUGH_16:
+        if ((buf[2] & 0x3) == 2) {
+            cmd->xfer = ((buf[5] << 8) | buf[6]) * dev->blocksize;
+        }
+        break;
     }
     return 0;
 }
@@ -996,7 +1006,8 @@  static void scsi_cmd_xfer_mode(SCSICommand *cmd)
     case SEND_DVD_STRUCTURE:
     case PERSISTENT_RESERVE_OUT:
     case MAINTENANCE_OUT:
-    case ATA_PASSTHROUGH:
+    case ATA_PASSTHROUGH_12:
+    case ATA_PASSTHROUGH_16:
         cmd->mode = SCSI_XFER_TO_DEV;
         break;
     default:
@@ -1335,7 +1346,7 @@  static const char *scsi_command_name(uint8_t cmd)
         [ PERSISTENT_RESERVE_OUT   ] = "PERSISTENT_RESERVE_OUT",
         [ WRITE_FILEMARKS_16       ] = "WRITE_FILEMARKS_16",
         [ EXTENDED_COPY            ] = "EXTENDED_COPY",
-        [ ATA_PASSTHROUGH          ] = "ATA_PASSTHROUGH",
+        [ ATA_PASSTHROUGH_16       ] = "ATA_PASSTHROUGH_16",
         [ ACCESS_CONTROL_IN        ] = "ACCESS_CONTROL_IN",
         [ ACCESS_CONTROL_OUT       ] = "ACCESS_CONTROL_OUT",
         [ READ_16                  ] = "READ_16",
@@ -1352,7 +1363,7 @@  static const char *scsi_command_name(uint8_t cmd)
         [ SERVICE_ACTION_IN_16     ] = "SERVICE_ACTION_IN_16",
         [ WRITE_LONG_16            ] = "WRITE_LONG_16",
         [ REPORT_LUNS              ] = "REPORT_LUNS",
-        [ BLANK                    ] = "BLANK",
+        [ ATA_PASSTHROUGH_12       ] = "ATA_PASSTHROUGH_12",
         [ MOVE_MEDIUM              ] = "MOVE_MEDIUM",
         [ EXCHANGE_MEDIUM          ] = "EXCHANGE MEDIUM",
         [ LOAD_UNLOAD              ] = "LOAD_UNLOAD",
diff --git a/hw/scsi-defs.h b/hw/scsi-defs.h
index 8a73f74..d7a4019 100644
--- a/hw/scsi-defs.h
+++ b/hw/scsi-defs.h
@@ -100,7 +100,7 @@ 
 #define READ_REVERSE_16       0x81
 #define ALLOW_OVERWRITE       0x82
 #define EXTENDED_COPY         0x83
-#define ATA_PASSTHROUGH       0x85
+#define ATA_PASSTHROUGH_16    0x85
 #define ACCESS_CONTROL_IN     0x86
 #define ACCESS_CONTROL_OUT    0x87
 #define READ_16               0x88
@@ -117,7 +117,7 @@ 
 #define SERVICE_ACTION_IN_16  0x9e
 #define WRITE_LONG_16         0x9f
 #define REPORT_LUNS           0xa0
-#define BLANK                 0xa1
+#define ATA_PASSTHROUGH_12    0xa1
 #define MAINTENANCE_IN        0xa3
 #define MAINTENANCE_OUT       0xa4
 #define MOVE_MEDIUM           0xa5