2019-05-19 13:51:48 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-05-01 21:50:04 +00:00
|
|
|
/*
|
|
|
|
* Target driver for EMC CLARiiON AX/CX-series hardware.
|
|
|
|
* Based on code from Lars Marowsky-Bree <lmb@suse.de>
|
|
|
|
* and Ed Goggin <egoggin@emc.com>.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Red Hat, Inc. All rights reserved.
|
|
|
|
* Copyright (C) 2006 Mike Christie
|
|
|
|
*/
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2011-05-27 13:47:43 +00:00
|
|
|
#include <linux/module.h>
|
2008-05-01 21:50:04 +00:00
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_eh.h>
|
|
|
|
#include <scsi/scsi_dh.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
#define CLARIION_NAME "emc"
|
2008-05-01 21:50:04 +00:00
|
|
|
|
|
|
|
#define CLARIION_TRESPASS_PAGE 0x22
|
2008-07-17 23:53:03 +00:00
|
|
|
#define CLARIION_BUFFER_SIZE 0xFC
|
2008-05-01 21:50:04 +00:00
|
|
|
#define CLARIION_TIMEOUT (60 * HZ)
|
|
|
|
#define CLARIION_RETRIES 3
|
|
|
|
#define CLARIION_UNBOUND_LU -1
|
2008-07-17 23:53:03 +00:00
|
|
|
#define CLARIION_SP_A 0
|
|
|
|
#define CLARIION_SP_B 1
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
/* Flags */
|
|
|
|
#define CLARIION_SHORT_TRESPASS 1
|
|
|
|
#define CLARIION_HONOR_RESERVATIONS 2
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
/* LUN states */
|
|
|
|
#define CLARIION_LUN_UNINITIALIZED -1
|
|
|
|
#define CLARIION_LUN_UNBOUND 0
|
|
|
|
#define CLARIION_LUN_BOUND 1
|
|
|
|
#define CLARIION_LUN_OWNED 2
|
|
|
|
|
|
|
|
static unsigned char long_trespass[] = {
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
2008-05-01 21:50:04 +00:00
|
|
|
CLARIION_TRESPASS_PAGE, /* Page code */
|
|
|
|
0x09, /* Page length - 2 */
|
2008-07-17 23:53:03 +00:00
|
|
|
0x01, /* Trespass code */
|
2008-05-01 21:50:04 +00:00
|
|
|
0xff, 0xff, /* Trespass target */
|
|
|
|
0, 0, 0, 0, 0, 0 /* Reserved bytes / unknown */
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char short_trespass[] = {
|
|
|
|
0, 0, 0, 0,
|
|
|
|
CLARIION_TRESPASS_PAGE, /* Page code */
|
|
|
|
0x02, /* Page length - 2 */
|
2008-07-17 23:53:03 +00:00
|
|
|
0x01, /* Trespass code */
|
2008-05-01 21:50:04 +00:00
|
|
|
0xff, /* Trespass target */
|
|
|
|
};
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
static const char * lun_state[] =
|
|
|
|
{
|
|
|
|
"not bound",
|
|
|
|
"bound",
|
|
|
|
"owned",
|
2008-05-01 21:50:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct clariion_dh_data {
|
|
|
|
/*
|
2008-07-17 23:53:03 +00:00
|
|
|
* Flags:
|
|
|
|
* CLARIION_SHORT_TRESPASS
|
2008-05-01 21:50:04 +00:00
|
|
|
* Use short trespass command (FC-series) or the long version
|
|
|
|
* (default for AX/CX CLARiiON arrays).
|
2008-07-17 23:53:03 +00:00
|
|
|
*
|
|
|
|
* CLARIION_HONOR_RESERVATIONS
|
2008-05-01 21:50:04 +00:00
|
|
|
* Whether or not (default) to honor SCSI reservations when
|
|
|
|
* initiating a switch-over.
|
|
|
|
*/
|
2008-07-17 23:53:03 +00:00
|
|
|
unsigned flags;
|
|
|
|
/*
|
|
|
|
* I/O buffer for both MODE_SELECT and INQUIRY commands.
|
|
|
|
*/
|
2008-09-23 14:58:59 +00:00
|
|
|
unsigned char buffer[CLARIION_BUFFER_SIZE];
|
2008-07-17 23:53:03 +00:00
|
|
|
/*
|
|
|
|
* LUN state
|
|
|
|
*/
|
|
|
|
int lun_state;
|
|
|
|
/*
|
|
|
|
* SP Port number
|
|
|
|
*/
|
|
|
|
int port;
|
|
|
|
/*
|
|
|
|
* which SP (A=0,B=1,UNBOUND=-1) is the default SP for this
|
|
|
|
* path's mapped LUN
|
|
|
|
*/
|
2008-05-01 21:50:04 +00:00
|
|
|
int default_sp;
|
2008-07-17 23:53:03 +00:00
|
|
|
/*
|
|
|
|
* which SP (A=0,B=1,UNBOUND=-1) is the active SP for this
|
|
|
|
* path's mapped LUN
|
|
|
|
*/
|
2008-05-01 21:50:04 +00:00
|
|
|
int current_sp;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse MODE_SELECT cmd reply.
|
|
|
|
*/
|
2016-11-03 13:20:22 +00:00
|
|
|
static int trespass_endio(struct scsi_device *sdev,
|
|
|
|
struct scsi_sense_hdr *sshdr)
|
2008-05-01 21:50:04 +00:00
|
|
|
{
|
2008-07-17 23:53:03 +00:00
|
|
|
int err = SCSI_DH_IO;
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2016-11-03 13:20:22 +00:00
|
|
|
sdev_printk(KERN_ERR, sdev, "%s: Found valid sense data 0x%2x, "
|
|
|
|
"0x%2x, 0x%2x while sending CLARiiON trespass "
|
|
|
|
"command.\n", CLARIION_NAME, sshdr->sense_key,
|
|
|
|
sshdr->asc, sshdr->ascq);
|
|
|
|
|
|
|
|
if (sshdr->sense_key == 0x05 && sshdr->asc == 0x04 &&
|
|
|
|
sshdr->ascq == 0x00) {
|
|
|
|
/*
|
|
|
|
* Array based copy in progress -- do not send
|
|
|
|
* mode_select or copy will be aborted mid-stream.
|
|
|
|
*/
|
|
|
|
sdev_printk(KERN_INFO, sdev, "%s: Array Based Copy in "
|
|
|
|
"progress while sending CLARiiON trespass "
|
|
|
|
"command.\n", CLARIION_NAME);
|
|
|
|
err = SCSI_DH_DEV_TEMP_BUSY;
|
|
|
|
} else if (sshdr->sense_key == 0x02 && sshdr->asc == 0x04 &&
|
|
|
|
sshdr->ascq == 0x03) {
|
|
|
|
/*
|
|
|
|
* LUN Not Ready - Manual Intervention Required
|
|
|
|
* indicates in-progress ucode upgrade (NDU).
|
|
|
|
*/
|
|
|
|
sdev_printk(KERN_INFO, sdev, "%s: Detected in-progress "
|
|
|
|
"ucode upgrade NDU operation while sending "
|
|
|
|
"CLARiiON trespass command.\n", CLARIION_NAME);
|
|
|
|
err = SCSI_DH_DEV_TEMP_BUSY;
|
|
|
|
} else
|
|
|
|
err = SCSI_DH_DEV_FAILED;
|
2008-05-01 21:50:04 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
static int parse_sp_info_reply(struct scsi_device *sdev,
|
|
|
|
struct clariion_dh_data *csdev)
|
2008-05-01 21:50:04 +00:00
|
|
|
{
|
|
|
|
int err = SCSI_DH_OK;
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
/* check for in-progress ucode upgrade (NDU) */
|
|
|
|
if (csdev->buffer[48] != 0) {
|
|
|
|
sdev_printk(KERN_NOTICE, sdev, "%s: Detected in-progress "
|
|
|
|
"ucode upgrade NDU operation while finding "
|
|
|
|
"current active SP.", CLARIION_NAME);
|
|
|
|
err = SCSI_DH_DEV_TEMP_BUSY;
|
|
|
|
goto out;
|
|
|
|
}
|
2008-09-23 14:58:59 +00:00
|
|
|
if (csdev->buffer[4] > 2) {
|
2008-07-17 23:53:03 +00:00
|
|
|
/* Invalid buffer format */
|
|
|
|
sdev_printk(KERN_NOTICE, sdev,
|
|
|
|
"%s: invalid VPD page 0xC0 format\n",
|
|
|
|
CLARIION_NAME);
|
|
|
|
err = SCSI_DH_NOSYS;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
switch (csdev->buffer[28] & 0x0f) {
|
|
|
|
case 6:
|
|
|
|
sdev_printk(KERN_NOTICE, sdev,
|
|
|
|
"%s: ALUA failover mode detected\n",
|
|
|
|
CLARIION_NAME);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
/* Linux failover */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: Invalid failover mode %d\n",
|
|
|
|
CLARIION_NAME, csdev->buffer[28] & 0x0f);
|
|
|
|
err = SCSI_DH_NOSYS;
|
|
|
|
goto out;
|
2008-05-01 21:50:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
csdev->default_sp = csdev->buffer[5];
|
|
|
|
csdev->lun_state = csdev->buffer[4];
|
|
|
|
csdev->current_sp = csdev->buffer[8];
|
|
|
|
csdev->port = csdev->buffer[7];
|
2016-03-03 06:54:11 +00:00
|
|
|
if (csdev->lun_state == CLARIION_LUN_OWNED)
|
|
|
|
sdev->access_state = SCSI_ACCESS_STATE_OPTIMAL;
|
|
|
|
else
|
|
|
|
sdev->access_state = SCSI_ACCESS_STATE_STANDBY;
|
|
|
|
if (csdev->default_sp == csdev->current_sp)
|
|
|
|
sdev->access_state |= SCSI_ACCESS_STATE_PREFERRED;
|
2008-07-17 23:53:03 +00:00
|
|
|
out:
|
2008-05-01 21:50:04 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
#define emc_default_str "FC (Legacy)"
|
|
|
|
|
|
|
|
static char * parse_sp_model(struct scsi_device *sdev, unsigned char *buffer)
|
2008-05-01 21:50:04 +00:00
|
|
|
{
|
2008-07-17 23:53:03 +00:00
|
|
|
unsigned char len = buffer[4] + 5;
|
|
|
|
char *sp_model = NULL;
|
|
|
|
unsigned char sp_len, serial_len;
|
|
|
|
|
|
|
|
if (len < 160) {
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: Invalid information section length %d\n",
|
|
|
|
CLARIION_NAME, len);
|
|
|
|
/* Check for old FC arrays */
|
|
|
|
if (!strncmp(buffer + 8, "DGC", 3)) {
|
|
|
|
/* Old FC array, not supporting extended information */
|
|
|
|
sp_model = emc_default_str;
|
|
|
|
}
|
|
|
|
goto out;
|
|
|
|
}
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
/*
|
|
|
|
* Parse extended information for SP model number
|
|
|
|
*/
|
|
|
|
serial_len = buffer[160];
|
|
|
|
if (serial_len == 0 || serial_len + 161 > len) {
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: Invalid array serial number length %d\n",
|
|
|
|
CLARIION_NAME, serial_len);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
sp_len = buffer[99];
|
|
|
|
if (sp_len == 0 || serial_len + sp_len + 161 > len) {
|
|
|
|
sdev_printk(KERN_WARNING, sdev,
|
|
|
|
"%s: Invalid model number length %d\n",
|
|
|
|
CLARIION_NAME, sp_len);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
sp_model = &buffer[serial_len + 161];
|
|
|
|
/* Strip whitespace at the end */
|
|
|
|
while (sp_len > 1 && sp_model[sp_len - 1] == ' ')
|
|
|
|
sp_len--;
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
sp_model[sp_len] = '\0';
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
out:
|
|
|
|
return sp_model;
|
2008-05-01 21:50:04 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
static int send_trespass_cmd(struct scsi_device *sdev,
|
|
|
|
struct clariion_dh_data *csdev)
|
2008-05-01 21:50:04 +00:00
|
|
|
{
|
2008-07-17 23:53:03 +00:00
|
|
|
unsigned char *page22;
|
2018-03-09 22:32:11 +00:00
|
|
|
unsigned char cdb[MAX_COMMAND_SIZE];
|
2016-11-03 13:20:22 +00:00
|
|
|
int err, res = SCSI_DH_OK, len;
|
|
|
|
struct scsi_sense_hdr sshdr;
|
|
|
|
u64 req_flags = REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
|
|
|
|
REQ_FAILFAST_DRIVER;
|
2008-07-17 23:53:03 +00:00
|
|
|
|
|
|
|
if (csdev->flags & CLARIION_SHORT_TRESPASS) {
|
|
|
|
page22 = short_trespass;
|
|
|
|
if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
|
|
|
|
/* Set Honor Reservations bit */
|
|
|
|
page22[6] |= 0x80;
|
|
|
|
len = sizeof(short_trespass);
|
2016-11-03 13:20:22 +00:00
|
|
|
cdb[0] = MODE_SELECT;
|
|
|
|
cdb[1] = 0x10;
|
|
|
|
cdb[4] = len;
|
2008-07-17 23:53:03 +00:00
|
|
|
} else {
|
|
|
|
page22 = long_trespass;
|
|
|
|
if (!(csdev->flags & CLARIION_HONOR_RESERVATIONS))
|
|
|
|
/* Set Honor Reservations bit */
|
|
|
|
page22[10] |= 0x80;
|
|
|
|
len = sizeof(long_trespass);
|
2016-11-03 13:20:22 +00:00
|
|
|
cdb[0] = MODE_SELECT_10;
|
|
|
|
cdb[8] = len;
|
2008-07-17 23:53:03 +00:00
|
|
|
}
|
|
|
|
BUG_ON((len > CLARIION_BUFFER_SIZE));
|
|
|
|
memcpy(csdev->buffer, page22, len);
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2017-02-23 15:02:37 +00:00
|
|
|
err = scsi_execute(sdev, cdb, DMA_TO_DEVICE, csdev->buffer, len, NULL,
|
|
|
|
&sshdr, CLARIION_TIMEOUT * HZ, CLARIION_RETRIES,
|
|
|
|
req_flags, 0, NULL);
|
2016-11-03 13:20:22 +00:00
|
|
|
if (err) {
|
|
|
|
if (scsi_sense_valid(&sshdr))
|
|
|
|
res = trespass_endio(sdev, &sshdr);
|
|
|
|
else {
|
2008-07-17 23:53:03 +00:00
|
|
|
sdev_printk(KERN_INFO, sdev,
|
|
|
|
"%s: failed to send MODE SELECT: %x\n",
|
2016-11-03 13:20:22 +00:00
|
|
|
CLARIION_NAME, err);
|
|
|
|
res = SCSI_DH_IO;
|
2008-07-17 23:53:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-03 13:20:22 +00:00
|
|
|
return res;
|
2008-05-01 21:50:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int clariion_check_sense(struct scsi_device *sdev,
|
|
|
|
struct scsi_sense_hdr *sense_hdr)
|
|
|
|
{
|
|
|
|
switch (sense_hdr->sense_key) {
|
|
|
|
case NOT_READY:
|
|
|
|
if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x03)
|
|
|
|
/*
|
|
|
|
* LUN Not Ready - Manual Intervention Required
|
|
|
|
* indicates this is a passive path.
|
|
|
|
*
|
|
|
|
* FIXME: However, if this is seen and EVPD C0
|
|
|
|
* indicates that this is due to a NDU in
|
|
|
|
* progress, we should set FAIL_PATH too.
|
|
|
|
* This indicates we might have to do a SCSI
|
|
|
|
* inquiry in the end_io path. Ugh.
|
|
|
|
*
|
|
|
|
* Can return FAILED only when we want the error
|
|
|
|
* recovery process to kick in.
|
|
|
|
*/
|
|
|
|
return SUCCESS;
|
|
|
|
break;
|
|
|
|
case ILLEGAL_REQUEST:
|
|
|
|
if (sense_hdr->asc == 0x25 && sense_hdr->ascq == 0x01)
|
|
|
|
/*
|
|
|
|
* An array based copy is in progress. Do not
|
|
|
|
* fail the path, do not bypass to another PG,
|
|
|
|
* do not retry. Fail the IO immediately.
|
|
|
|
* (Actually this is the same conclusion as in
|
|
|
|
* the default handler, but lets make sure.)
|
|
|
|
*
|
|
|
|
* Can return FAILED only when we want the error
|
|
|
|
* recovery process to kick in.
|
|
|
|
*/
|
|
|
|
return SUCCESS;
|
|
|
|
break;
|
|
|
|
case UNIT_ATTENTION:
|
|
|
|
if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
|
|
|
|
/*
|
|
|
|
* Unit Attention Code. This is the first IO
|
|
|
|
* to the new path, so just retry.
|
|
|
|
*/
|
2008-08-12 19:11:57 +00:00
|
|
|
return ADD_TO_MLQUEUE;
|
2008-05-01 21:50:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
return SCSI_RETURN_NOT_HANDLED;
|
|
|
|
}
|
|
|
|
|
2018-11-09 13:42:40 +00:00
|
|
|
static blk_status_t clariion_prep_fn(struct scsi_device *sdev,
|
|
|
|
struct request *req)
|
2008-07-17 23:53:03 +00:00
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
struct clariion_dh_data *h = sdev->handler_data;
|
2008-07-17 23:53:03 +00:00
|
|
|
|
|
|
|
if (h->lun_state != CLARIION_LUN_OWNED) {
|
2016-10-20 13:12:13 +00:00
|
|
|
req->rq_flags |= RQF_QUIET;
|
2018-11-09 13:42:40 +00:00
|
|
|
return BLK_STS_IOERR;
|
2008-07-17 23:53:03 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 13:42:40 +00:00
|
|
|
return BLK_STS_OK;
|
2008-07-17 23:53:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int clariion_std_inquiry(struct scsi_device *sdev,
|
|
|
|
struct clariion_dh_data *csdev)
|
|
|
|
{
|
2017-02-21 18:46:37 +00:00
|
|
|
int err = SCSI_DH_OK;
|
2008-07-17 23:53:03 +00:00
|
|
|
char *sp_model;
|
|
|
|
|
2016-11-03 13:20:22 +00:00
|
|
|
sp_model = parse_sp_model(sdev, sdev->inquiry);
|
2008-07-17 23:53:03 +00:00
|
|
|
if (!sp_model) {
|
|
|
|
err = SCSI_DH_DEV_UNSUPP;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FC Series arrays do not support long trespass
|
|
|
|
*/
|
|
|
|
if (!strlen(sp_model) || !strncmp(sp_model, "FC",2))
|
|
|
|
csdev->flags |= CLARIION_SHORT_TRESPASS;
|
|
|
|
|
|
|
|
sdev_printk(KERN_INFO, sdev,
|
|
|
|
"%s: detected Clariion %s, flags %x\n",
|
|
|
|
CLARIION_NAME, sp_model, csdev->flags);
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clariion_send_inquiry(struct scsi_device *sdev,
|
|
|
|
struct clariion_dh_data *csdev)
|
|
|
|
{
|
2016-11-03 13:20:22 +00:00
|
|
|
int err = SCSI_DH_IO;
|
|
|
|
|
|
|
|
if (!scsi_get_vpd_page(sdev, 0xC0, csdev->buffer,
|
|
|
|
CLARIION_BUFFER_SIZE))
|
2008-07-17 23:53:03 +00:00
|
|
|
err = parse_sp_info_reply(sdev, csdev);
|
2016-11-03 13:20:22 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-10-21 16:22:46 +00:00
|
|
|
static int clariion_activate(struct scsi_device *sdev,
|
|
|
|
activate_complete fn, void *data)
|
2008-07-17 23:53:03 +00:00
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
struct clariion_dh_data *csdev = sdev->handler_data;
|
2008-07-17 23:53:03 +00:00
|
|
|
int result;
|
|
|
|
|
|
|
|
result = clariion_send_inquiry(sdev, csdev);
|
|
|
|
if (result != SCSI_DH_OK)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
if (csdev->lun_state == CLARIION_LUN_OWNED)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
result = send_trespass_cmd(sdev, csdev);
|
|
|
|
if (result != SCSI_DH_OK)
|
|
|
|
goto done;
|
|
|
|
sdev_printk(KERN_INFO, sdev,"%s: %s trespass command sent\n",
|
|
|
|
CLARIION_NAME,
|
|
|
|
csdev->flags&CLARIION_SHORT_TRESPASS?"short":"long" );
|
|
|
|
|
|
|
|
/* Update status */
|
|
|
|
result = clariion_send_inquiry(sdev, csdev);
|
|
|
|
if (result != SCSI_DH_OK)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
done:
|
|
|
|
sdev_printk(KERN_INFO, sdev,
|
|
|
|
"%s: at SP %c Port %d (%s, default SP %c)\n",
|
|
|
|
CLARIION_NAME, csdev->current_sp + 'A',
|
|
|
|
csdev->port, lun_state[csdev->lun_state],
|
|
|
|
csdev->default_sp + 'A');
|
|
|
|
|
2009-10-21 16:22:46 +00:00
|
|
|
if (fn)
|
|
|
|
fn(data, result);
|
|
|
|
return 0;
|
2008-05-01 21:50:04 +00:00
|
|
|
}
|
2009-08-03 19:42:39 +00:00
|
|
|
/*
|
|
|
|
* params - parameters in the following format
|
|
|
|
* "no_of_params\0param1\0param2\0param3\0...\0"
|
|
|
|
* for example, string for 2 parameters with value 10 and 21
|
|
|
|
* is specified as "2\010\021\0".
|
|
|
|
*/
|
|
|
|
static int clariion_set_params(struct scsi_device *sdev, const char *params)
|
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
struct clariion_dh_data *csdev = sdev->handler_data;
|
2009-08-03 19:42:39 +00:00
|
|
|
unsigned int hr = 0, st = 0, argc;
|
|
|
|
const char *p = params;
|
|
|
|
int result = SCSI_DH_OK;
|
|
|
|
|
|
|
|
if ((sscanf(params, "%u", &argc) != 1) || (argc != 2))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
while (*p++)
|
|
|
|
;
|
|
|
|
if ((sscanf(p, "%u", &st) != 1) || (st > 1))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
while (*p++)
|
|
|
|
;
|
|
|
|
if ((sscanf(p, "%u", &hr) != 1) || (hr > 1))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (st)
|
|
|
|
csdev->flags |= CLARIION_SHORT_TRESPASS;
|
|
|
|
else
|
|
|
|
csdev->flags &= ~CLARIION_SHORT_TRESPASS;
|
|
|
|
|
|
|
|
if (hr)
|
|
|
|
csdev->flags |= CLARIION_HONOR_RESERVATIONS;
|
|
|
|
else
|
|
|
|
csdev->flags &= ~CLARIION_HONOR_RESERVATIONS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this path is owned, we have to send a trespass command
|
|
|
|
* with the new parameters. If not, simply return. Next trespass
|
|
|
|
* command would use the parameters.
|
|
|
|
*/
|
|
|
|
if (csdev->lun_state != CLARIION_LUN_OWNED)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
csdev->lun_state = CLARIION_LUN_UNINITIALIZED;
|
|
|
|
result = send_trespass_cmd(sdev, csdev);
|
|
|
|
if (result != SCSI_DH_OK)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
/* Update status */
|
|
|
|
result = clariion_send_inquiry(sdev, csdev);
|
|
|
|
|
|
|
|
done:
|
|
|
|
return result;
|
|
|
|
}
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2015-08-27 12:16:59 +00:00
|
|
|
static int clariion_bus_attach(struct scsi_device *sdev)
|
2008-05-01 21:50:04 +00:00
|
|
|
{
|
|
|
|
struct clariion_dh_data *h;
|
2008-07-17 23:53:03 +00:00
|
|
|
int err;
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2014-09-14 02:59:51 +00:00
|
|
|
h = kzalloc(sizeof(*h) , GFP_KERNEL);
|
2014-09-14 18:08:21 +00:00
|
|
|
if (!h)
|
2017-09-20 07:18:51 +00:00
|
|
|
return SCSI_DH_NOMEM;
|
2008-07-17 23:53:03 +00:00
|
|
|
h->lun_state = CLARIION_LUN_UNINITIALIZED;
|
2008-07-17 23:52:51 +00:00
|
|
|
h->default_sp = CLARIION_UNBOUND_LU;
|
|
|
|
h->current_sp = CLARIION_UNBOUND_LU;
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:53:03 +00:00
|
|
|
err = clariion_std_inquiry(sdev, h);
|
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
err = clariion_send_inquiry(sdev, h);
|
|
|
|
if (err != SCSI_DH_OK)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
sdev_printk(KERN_INFO, sdev,
|
|
|
|
"%s: connected to SP %c Port %d (%s, default SP %c)\n",
|
|
|
|
CLARIION_NAME, h->current_sp + 'A',
|
|
|
|
h->port, lun_state[h->lun_state],
|
|
|
|
h->default_sp + 'A');
|
2015-08-27 12:16:59 +00:00
|
|
|
|
|
|
|
sdev->handler_data = h;
|
2017-09-20 07:18:51 +00:00
|
|
|
return SCSI_DH_OK;
|
2008-07-17 23:53:03 +00:00
|
|
|
|
|
|
|
failed:
|
2014-09-14 02:59:51 +00:00
|
|
|
kfree(h);
|
2017-09-20 07:18:51 +00:00
|
|
|
return err;
|
2008-07-17 23:52:51 +00:00
|
|
|
}
|
2008-05-01 21:50:04 +00:00
|
|
|
|
2008-07-17 23:52:51 +00:00
|
|
|
static void clariion_bus_detach(struct scsi_device *sdev)
|
|
|
|
{
|
2015-08-27 12:16:59 +00:00
|
|
|
kfree(sdev->handler_data);
|
|
|
|
sdev->handler_data = NULL;
|
2008-05-01 21:50:04 +00:00
|
|
|
}
|
|
|
|
|
2014-09-14 18:08:21 +00:00
|
|
|
static struct scsi_device_handler clariion_dh = {
|
|
|
|
.name = CLARIION_NAME,
|
|
|
|
.module = THIS_MODULE,
|
|
|
|
.attach = clariion_bus_attach,
|
|
|
|
.detach = clariion_bus_detach,
|
|
|
|
.check_sense = clariion_check_sense,
|
|
|
|
.activate = clariion_activate,
|
|
|
|
.prep_fn = clariion_prep_fn,
|
|
|
|
.set_params = clariion_set_params,
|
|
|
|
};
|
|
|
|
|
2008-05-01 21:50:04 +00:00
|
|
|
static int __init clariion_init(void)
|
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = scsi_register_device_handler(&clariion_dh);
|
|
|
|
if (r != 0)
|
2008-07-17 23:53:03 +00:00
|
|
|
printk(KERN_ERR "%s: Failed to register scsi device handler.",
|
|
|
|
CLARIION_NAME);
|
2008-05-01 21:50:04 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit clariion_exit(void)
|
|
|
|
{
|
|
|
|
scsi_unregister_device_handler(&clariion_dh);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(clariion_init);
|
|
|
|
module_exit(clariion_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("EMC CX/AX/FC-family driver");
|
|
|
|
MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, Chandra Seetharaman <sekharan@us.ibm.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|