qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Cong Meng <mc@linux.vnet.ibm.com>
Cc: zwanp@cn.ibm.com, linuxram@us.ibm.com,
	stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] add suport for ATA_PASSTHROUGH_xx scsi command
Date: Wed, 01 Aug 2012 11:42:08 +0200	[thread overview]
Message-ID: <5018F9F0.9020206@redhat.com> (raw)
In-Reply-To: <1343811943-3972-1-git-send-email-mc@linux.vnet.ibm.com>

Il 01/08/2012 11:05, Cong Meng ha scritto:
> +    case ATA_PASSTHROUGH_12:
> +        if (dev->type != TYPE_ROM) {
> +            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;

Hmm, I think you're only handling this partially.

Four bits of buf[2] count; bits 0..1 are T_LENGTH, bit 2 is BYTE_BLOCK,
bit 4 is T_TYPE:

If buf[2] is xxxxxx00, cmd->xfer = 0

else

   if buf[2] is xxxxx0xx, xfer_unit = 1
   else if buf[2] is xxx0x1xx, xfer_unit = 512
   else xfer_unit = dev->blocksize (this is when buf[2] is xxx1x1xx)

   if buf[2] is xxxxxx01, set cmd->xfer to the FEATURES field
   if buf[2] is xxxxxx10, set cmd->xfer to the SECTOR_COUNT

   for ATA_PASSTHROUGH_16, if buf[1] bit 0 is 0, then cmd->xfer &= 255;

   cmd->xfer *= xfer_unit;

Also we cannot support buf[2] is xxxxxx11.  Please add a check to
hw/scsi-generic.c, so that the request is failed in this case.

This is better encapsulated in a separate function, of course.

On top of this, the direction is not necessarily TO_DEV (as in the
current code for scsi_cmd_xfer_mode).  It is TO_DEV if buf[2] bit 3
(T_DIR) is zero; it is FROM_DEV if buf[2] bit 3 is one.

Do you have a copy of the SAT (SCSI/ATA translation) standard?  This is
all in paragraph 12.2.2.2 in my copy.

Paolo

  reply	other threads:[~2012-08-01  9:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01  9:05 [Qemu-devel] [PATCH v2] add suport for ATA_PASSTHROUGH_xx scsi command Cong Meng
2012-08-01  9:42 ` Paolo Bonzini [this message]
2012-08-01 10:08   ` Cong Meng
2012-08-01 10:17     ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5018F9F0.9020206@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=linuxram@us.ibm.com \
    --cc=mc@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=zwanp@cn.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).