diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2008-04-30 04:27:26 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-05-02 12:33:25 -0400 |
commit | db4742dd8f0aa9125b74f9b2516336a75f3d9106 (patch) | |
tree | 6820b74e8fbfb13c4eee4c8ef8b59a9132320799 /drivers/scsi | |
parent | 64a87b244b9297667ca80264aab849a36f494884 (diff) |
[SCSI] add support for variable length extended commands
Add support for variable-length, extended, and vendor specific
CDBs to scsi-ml. It is now possible for initiators and ULD's
to issue these types of commands. LLDs need not change much.
All they need is to raise the .max_cmd_len to the longest command
they support (see iscsi patch).
- clean-up some code paths that did not expect commands to be
larger than 16, and change cmd_len members' type to short as
char is not enough.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/constants.c | 10 | ||||
-rw-r--r-- | drivers/scsi/scsi.c | 15 | ||||
-rw-r--r-- | drivers/scsi/scsi_lib.c | 2 |
3 files changed, 8 insertions, 19 deletions
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c index 403a7f2d8f9b..9785d7384199 100644 --- a/drivers/scsi/constants.c +++ b/drivers/scsi/constants.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #define SERVICE_ACTION_OUT_12 0xa9 | 28 | #define SERVICE_ACTION_OUT_12 0xa9 |
29 | #define SERVICE_ACTION_IN_16 0x9e | 29 | #define SERVICE_ACTION_IN_16 0x9e |
30 | #define SERVICE_ACTION_OUT_16 0x9f | 30 | #define SERVICE_ACTION_OUT_16 0x9f |
31 | #define VARIABLE_LENGTH_CMD 0x7f | ||
32 | 31 | ||
33 | 32 | ||
34 | 33 | ||
@@ -210,7 +209,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) | |||
210 | cdb0 = cdbp[0]; | 209 | cdb0 = cdbp[0]; |
211 | switch(cdb0) { | 210 | switch(cdb0) { |
212 | case VARIABLE_LENGTH_CMD: | 211 | case VARIABLE_LENGTH_CMD: |
213 | len = cdbp[7] + 8; | 212 | len = scsi_varlen_cdb_length(cdbp); |
214 | if (len < 10) { | 213 | if (len < 10) { |
215 | printk("short variable length command, " | 214 | printk("short variable length command, " |
216 | "len=%d ext_len=%d", len, cdb_len); | 215 | "len=%d ext_len=%d", len, cdb_len); |
@@ -300,7 +299,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len) | |||
300 | cdb0 = cdbp[0]; | 299 | cdb0 = cdbp[0]; |
301 | switch(cdb0) { | 300 | switch(cdb0) { |
302 | case VARIABLE_LENGTH_CMD: | 301 | case VARIABLE_LENGTH_CMD: |
303 | len = cdbp[7] + 8; | 302 | len = scsi_varlen_cdb_length(cdbp); |
304 | if (len < 10) { | 303 | if (len < 10) { |
305 | printk("short opcode=0x%x command, len=%d " | 304 | printk("short opcode=0x%x command, len=%d " |
306 | "ext_len=%d", cdb0, len, cdb_len); | 305 | "ext_len=%d", cdb0, len, cdb_len); |
@@ -335,10 +334,7 @@ void __scsi_print_command(unsigned char *cdb) | |||
335 | int k, len; | 334 | int k, len; |
336 | 335 | ||
337 | print_opcode_name(cdb, 0); | 336 | print_opcode_name(cdb, 0); |
338 | if (VARIABLE_LENGTH_CMD == cdb[0]) | 337 | len = scsi_command_size(cdb); |
339 | len = cdb[7] + 8; | ||
340 | else | ||
341 | len = COMMAND_SIZE(cdb[0]); | ||
342 | /* print out all bytes in cdb */ | 338 | /* print out all bytes in cdb */ |
343 | for (k = 0; k < len; ++k) | 339 | for (k = 0; k < len; ++k) |
344 | printk(" %02x", cdb[k]); | 340 | printk(" %02x", cdb[k]); |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index 749c9c7fc2e1..110e776d1a07 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -79,15 +79,6 @@ static void scsi_done(struct scsi_cmnd *cmd); | |||
79 | #define MIN_RESET_PERIOD (15*HZ) | 79 | #define MIN_RESET_PERIOD (15*HZ) |
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Macro to determine the size of SCSI command. This macro takes vendor | ||
83 | * unique commands into account. SCSI commands in groups 6 and 7 are | ||
84 | * vendor unique and we will depend upon the command length being | ||
85 | * supplied correctly in cmd_len. | ||
86 | */ | ||
87 | #define CDB_SIZE(cmd) (((((cmd)->cmnd[0] >> 5) & 7) < 6) ? \ | ||
88 | COMMAND_SIZE((cmd)->cmnd[0]) : (cmd)->cmd_len) | ||
89 | |||
90 | /* | ||
91 | * Note - the initial logging level can be set here to log events at boot time. | 82 | * Note - the initial logging level can be set here to log events at boot time. |
92 | * After the system is up, you may enable logging via the /proc interface. | 83 | * After the system is up, you may enable logging via the /proc interface. |
93 | */ | 84 | */ |
@@ -709,9 +700,11 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
709 | * Before we queue this command, check if the command | 700 | * Before we queue this command, check if the command |
710 | * length exceeds what the host adapter can handle. | 701 | * length exceeds what the host adapter can handle. |
711 | */ | 702 | */ |
712 | if (CDB_SIZE(cmd) > cmd->device->host->max_cmd_len) { | 703 | if (cmd->cmd_len > cmd->device->host->max_cmd_len) { |
713 | SCSI_LOG_MLQUEUE(3, | 704 | SCSI_LOG_MLQUEUE(3, |
714 | printk("queuecommand : command too long.\n")); | 705 | printk("queuecommand : command too long. " |
706 | "cdb_size=%d host->max_cmd_len=%d\n", | ||
707 | cmd->cmd_len, cmd->device->host->max_cmd_len)); | ||
715 | cmd->result = (DID_ABORT << 16); | 708 | cmd->result = (DID_ABORT << 16); |
716 | 709 | ||
717 | scsi_done(cmd); | 710 | scsi_done(cmd); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 325270b520e1..ba7e8ad76d04 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -445,7 +445,7 @@ static void scsi_init_cmd_errh(struct scsi_cmnd *cmd) | |||
445 | scsi_set_resid(cmd, 0); | 445 | scsi_set_resid(cmd, 0); |
446 | memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 446 | memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
447 | if (cmd->cmd_len == 0) | 447 | if (cmd->cmd_len == 0) |
448 | cmd->cmd_len = COMMAND_SIZE(cmd->cmnd[0]); | 448 | cmd->cmd_len = scsi_command_size(cmd->cmnd); |
449 | } | 449 | } |
450 | 450 | ||
451 | void scsi_device_unbusy(struct scsi_device *sdev) | 451 | void scsi_device_unbusy(struct scsi_device *sdev) |