All of lore.kernel.org
 help / color / mirror / Atom feed
From: mengcong <mc@linux.vnet.ibm.com>
To: target-devel@vger.kernel.org
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
	meng cong <mc@linux.vnet.ibm.com>
Subject: [PATCH] target: Handle ATA_PASS_THROUGH_16 passthrough
Date: Wed, 16 May 2012 13:33:29 +0800	[thread overview]
Message-ID: <1337146409.18429.11.camel@mengcong> (raw)

The cdrecord uses ATA_PASS_THROUGH_16 command while burning CDs
with a SATA CD-ROM. This patch adds support to it so that PSCSI 
CD-ROM passthrough works with the cdrecord.

Signed-off-by: Cong Meng <mc@linux.vnet.ibm.com>
---
 drivers/target/target_core_transport.c |   30 ++++++++++++++++++++++++++++++
 include/scsi/scsi.h                    |    1 +
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 2d75c29..41439b3 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -2926,6 +2926,36 @@ static int transport_generic_cmd_sequencer(
 		size = (cdb[7] << 8) | cdb[8];
 		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
 		break;
+	case ATA_PASS_THROUGH_16:
+		// T_LENGTH
+		switch (cdb[2] & 0x3) {
+		case 0x0:
+			sectors = 0;
+			break;
+		case 0x1:
+			sectors = (((cdb[1] & 0x1) ? cdb[3] : 0) << 8) | cdb[4];
+			break;
+		case 0x2:
+			sectors = (((cdb[1] & 0x1) ? cdb[5] : 0) << 8) | cdb[6];
+			break;
+		case 0x3:
+			pr_err("T_LENGTH=0x3 not supported\n");
+			goto out_invalid_cdb_field;
+			break;
+		}
+		
+		// BYTE_BLOCK
+		if (cdb[2] & 0x4) {
+			// BLOCK
+			// T_TYPE: 512 or sector
+			size = sectors * ((cdb[2] & 0x10) ? 
+				dev->se_sub_dev->se_dev_attrib.block_size : 512);
+		} else {
+			// BYTE
+			size = sectors;
+		}
+		cmd->se_cmd_flags |= SCF_SCSI_CONTROL_SG_IO_CDB;
+		break;
 	default:
 		pr_warn("TARGET_CORE[%s]: Unsupported SCSI Opcode"
 			" 0x%02x, sending CHECK_CONDITION.\n",
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index f34a5a8..f6dcd25 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -116,6 +116,7 @@ struct scsi_cmnd;
 #define PERSISTENT_RESERVE_IN 0x5e
 #define PERSISTENT_RESERVE_OUT 0x5f
 #define VARIABLE_LENGTH_CMD   0x7f
+#define ATA_PASS_THROUGH_16   0x85
 #define REPORT_LUNS           0xa0
 #define SECURITY_PROTOCOL_IN  0xa2
 #define MAINTENANCE_IN        0xa3
-- 
1.7.7



             reply	other threads:[~2012-05-16  6:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-16  5:33 mengcong [this message]
2012-05-16  7:38 ` [PATCH] target: Handle ATA_PASS_THROUGH_16 passthrough James Bottomley
2012-05-17  3:14   ` [PATCH] V2: " mengcong
2012-05-17  6:13     ` Nicholas A. Bellinger
2012-05-17  6:32       ` mengcong
2012-05-16 23:41 ` [PATCH] " Nicholas A. Bellinger
2012-05-17  6:22   ` mengcong

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=1337146409.18429.11.camel@mengcong \
    --to=mc@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=stefanha@linux.vnet.ibm.com \
    --cc=target-devel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.