27 #include <linux/kernel.h>
29 #include <linux/types.h>
30 #include <linux/pci.h>
32 #include <linux/slab.h>
35 #include <asm/uaccess.h>
37 #include <linux/module.h>
39 #include <scsi/scsi.h>
47 #define INQD_PDT_DA 0x00
48 #define INQD_PDT_PROC 0x03
49 #define INQD_PDT_CHNGR 0x08
50 #define INQD_PDT_COMM 0x09
51 #define INQD_PDT_NOLUN2 0x1f
52 #define INQD_PDT_NOLUN 0x7f
54 #define INQD_PDT_DMASK 0x1F
55 #define INQD_PDT_QMASK 0xE0
61 #define SENCODE_NO_SENSE 0x00
62 #define SENCODE_END_OF_DATA 0x00
63 #define SENCODE_BECOMING_READY 0x04
64 #define SENCODE_INIT_CMD_REQUIRED 0x04
65 #define SENCODE_PARAM_LIST_LENGTH_ERROR 0x1A
66 #define SENCODE_INVALID_COMMAND 0x20
67 #define SENCODE_LBA_OUT_OF_RANGE 0x21
68 #define SENCODE_INVALID_CDB_FIELD 0x24
69 #define SENCODE_LUN_NOT_SUPPORTED 0x25
70 #define SENCODE_INVALID_PARAM_FIELD 0x26
71 #define SENCODE_PARAM_NOT_SUPPORTED 0x26
72 #define SENCODE_PARAM_VALUE_INVALID 0x26
73 #define SENCODE_RESET_OCCURRED 0x29
74 #define SENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x3E
75 #define SENCODE_INQUIRY_DATA_CHANGED 0x3F
76 #define SENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x39
77 #define SENCODE_DIAGNOSTIC_FAILURE 0x40
78 #define SENCODE_INTERNAL_TARGET_FAILURE 0x44
79 #define SENCODE_INVALID_MESSAGE_ERROR 0x49
80 #define SENCODE_LUN_FAILED_SELF_CONFIG 0x4c
81 #define SENCODE_OVERLAPPED_COMMAND 0x4E
87 #define ASENCODE_NO_SENSE 0x00
88 #define ASENCODE_END_OF_DATA 0x05
89 #define ASENCODE_BECOMING_READY 0x01
90 #define ASENCODE_INIT_CMD_REQUIRED 0x02
91 #define ASENCODE_PARAM_LIST_LENGTH_ERROR 0x00
92 #define ASENCODE_INVALID_COMMAND 0x00
93 #define ASENCODE_LBA_OUT_OF_RANGE 0x00
94 #define ASENCODE_INVALID_CDB_FIELD 0x00
95 #define ASENCODE_LUN_NOT_SUPPORTED 0x00
96 #define ASENCODE_INVALID_PARAM_FIELD 0x00
97 #define ASENCODE_PARAM_NOT_SUPPORTED 0x01
98 #define ASENCODE_PARAM_VALUE_INVALID 0x02
99 #define ASENCODE_RESET_OCCURRED 0x00
100 #define ASENCODE_LUN_NOT_SELF_CONFIGURED_YET 0x00
101 #define ASENCODE_INQUIRY_DATA_CHANGED 0x03
102 #define ASENCODE_SAVING_PARAMS_NOT_SUPPORTED 0x00
103 #define ASENCODE_DIAGNOSTIC_FAILURE 0x80
104 #define ASENCODE_INTERNAL_TARGET_FAILURE 0x00
105 #define ASENCODE_INVALID_MESSAGE_ERROR 0x00
106 #define ASENCODE_LUN_FAILED_SELF_CONFIG 0x00
107 #define ASENCODE_OVERLAPPED_COMMAND 0x00
109 #define BYTE0(x) (unsigned char)(x)
110 #define BYTE1(x) (unsigned char)((x) >> 8)
111 #define BYTE2(x) (unsigned char)((x) >> 16)
112 #define BYTE3(x) (unsigned char)((x) >> 24)
136 static unsigned long aac_build_sg64(
struct scsi_cmnd* scsicmd,
struct sgmap64* psg);
137 static unsigned long aac_build_sgraw(
struct scsi_cmnd* scsicmd,
struct sgmapraw* psg);
138 static unsigned long aac_build_sgraw2(
struct scsi_cmnd *scsicmd,
struct aac_raw_io2 *rio2,
int sg_max);
139 static int aac_convert_sgraw2(
struct aac_raw_io2 *rio2,
int pages,
int nseg,
int nseg_new);
140 static int aac_send_srb_fib(
struct scsi_cmnd* scsicmd);
141 #ifdef AAC_DETAILED_STATUS_INFO
142 static char *aac_get_status_string(
u32 status);
149 static int nondasd = -1;
150 static int aac_cache = 2;
151 static int dacmode = -1;
170 "\tbit 0 - Disable FUA in WRITE SCSI commands\n"
171 "\tbit 1 - Disable SYNCHRONIZE_CACHE SCSI command\n"
172 "\tbit 2 - Disable only if Battery is protecting Cache");
174 MODULE_PARM_DESC(dacmode,
"Control whether dma addressing is using 64 bit DAC."
178 " adapter for foreign arrays.\n"
179 "This is typically needed in systems that do not have a BIOS."
183 " 0=PIC(default), 1=MSI, 2=MSI-X(unsupported, uses MSI)");
186 " adapter to have it's kernel up and\n"
187 "running. This is typically adjusted for large systems that do not"
191 " applications to pick up AIFs before\n"
192 "deregistering them. This is typically adjusted for heavily burdened"
198 " blocks (FIB) allocated. Valid values are 512 and down. Default is"
199 " to use suggestion from Firmware.");
204 " size. Valid values are 512, 2048, 4096 and 8192. Default is to use"
205 " suggestion from Firmware.");
210 " updates issued to adapter.");
214 MODULE_PARM_DESC(check_interval,
"Interval in seconds between adapter health"
220 " adapter. a value of -1 forces the reset to adapters programmed to"
226 " -1=protect 0=off, 1=on");
236 "\t1 - Array Meta Data Signature (default)\n"
237 "\t2 - Adapter Serial Number");
240 static inline int aac_valid_context(
struct scsi_cmnd *scsicmd,
241 struct fib *fibptr) {
252 if (
unlikely(!device || !scsi_device_online(device))) {
297 "aac_get_config_status: response=%d status=%d action=%d\n",
304 printk(
KERN_WARNING "aac_get_config_status: Will not issue the Commit Configuration\n");
334 "aac_get_config_status: Foreign device configurations are being ignored\n");
343 static void aac_expose_phy_device(
struct scsi_cmnd *scsicmd)
346 scsi_sg_copy_to_buffer(scsicmd, &inq_data,
sizeof(inq_data));
347 if ((inq_data & 0x20) && (inq_data & 0x1f) ==
TYPE_DISK) {
349 scsi_sg_copy_from_buffer(scsicmd, &inq_data,
sizeof(inq_data));
394 fsa_dev_ptr = kzalloc(
sizeof(*fsa_dev_ptr) * maximum_num_containers,
415 if (++index >= status)
421 static void get_container_name_callback(
void *
context,
struct fib * fibptr)
428 if (!aac_valid_context(scsicmd, fibptr))
437 && (get_name_reply->
data[0] !=
'\0')) {
438 char *
sp = get_name_reply->
data;
448 *dp++ = (*sp) ? *
sp++ :
' ';
449 }
while (--count > 0);
451 scsi_sg_copy_to_buffer(scsicmd, &inq,
sizeof(inq));
453 scsi_sg_copy_from_buffer(scsicmd, &inq,
sizeof(inq));
467 static int aac_get_container_name(
struct scsi_cmnd * scsicmd)
471 struct fib * cmd_fibcontext;
503 printk(
KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n", status);
509 static int aac_probe_container_callback2(
struct scsi_cmnd * scsicmd)
521 static void _aac_probe_container2(
void * context,
struct fib * fibptr)
528 if (!aac_valid_context(scsicmd, fibptr))
531 scsicmd->
SCp.Status = 0;
532 fsa_dev_ptr = fibptr->
dev->fsa_dev;
535 fsa_dev_ptr +=
scmd_id(scsicmd);
540 fsa_dev_ptr->
valid = 1;
552 if ((fsa_dev_ptr->
valid & 1) == 0)
553 fsa_dev_ptr->
valid = 0;
560 (*callback)(scsicmd);
564 static void _aac_probe_container1(
void * context,
struct fib * fibptr)
572 dresp->
mnt[0].capacityhigh = 0;
575 _aac_probe_container2(context, fibptr);
580 if (!aac_valid_context(scsicmd, fibptr))
596 _aac_probe_container2,
603 else if (status < 0) {
606 _aac_probe_container2(context, fibptr);
632 _aac_probe_container1,
650 fsa_dev_ptr +=
scmd_id(scsicmd);
651 if ((fsa_dev_ptr->
valid & 1) == 0) {
652 fsa_dev_ptr->
valid = 0;
668 static int aac_probe_container_callback1(
struct scsi_cmnd * scsicmd)
680 if (!scsicmd || !scsidev) {
688 scsicmd->
device = scsidev;
693 if (_aac_probe_container(scsicmd, aac_probe_container_callback1) == 0)
694 while (scsicmd->
device == scsidev)
697 status = scsicmd->
SCp.Status;
718 static void inqstrcpy(
char *
a,
char *
b)
721 while (*a != (
char)0)
725 static char *container_types[] = {
753 return container_types[tindex];
765 static void setinqstr(
struct aac_dev *dev,
void *
data,
int tindex)
770 memset(str,
' ',
sizeof(*str));
775 if ((cp[0] ==
'A') && (cp[1] ==
'O') && (cp[2] ==
'C'))
776 inqstrcpy(
"SMC", str->
vid);
778 c =
sizeof(str->
vid);
779 while (*cp && *cp !=
' ' && --c)
786 while (*cp && *cp !=
' ')
794 c = cp[
sizeof(str->
pid)];
795 cp[
sizeof(str->
pid)] =
'\0';
797 inqstrcpy (cp, str->
pid);
799 cp[
sizeof(str->
pid)] = c;
809 char *findit = str->
pid;
811 for ( ; *findit !=
' '; findit++);
813 if (
memcmp(findit-4,
"RAID", 4) == 0)
814 *(findit -= 4) =
' ';
815 if (((findit - str->
pid) +
strlen(container_types[tindex]))
816 < (
sizeof(str->
pid) +
sizeof(str->
prl)))
817 inqstrcpy (container_types[tindex], findit + 1);
819 inqstrcpy (
"V1.0", str->
prl);
822 static void get_container_serial_callback(
void *context,
struct fib * fibptr)
830 if (!aac_valid_context(scsicmd, fibptr))
839 sp[1] = scsicmd->
cmnd[2];
841 sp[3] =
snprintf(sp+4,
sizeof(sp)-4,
"%08X",
843 scsi_sg_copy_from_buffer(scsicmd, sp,
sizeof(sp));
856 static int aac_get_container_serial(
struct scsi_cmnd * scsicmd)
860 struct fib * cmd_fibcontext;
891 printk(
KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status);
908 static int setinqserial(
struct aac_dev *dev,
void *data,
int cid)
918 u8 sense_code,
u8 a_sense_code,
u8 bit_pointer,
u16 field_pointer)
920 u8 *sense_buf = (
u8 *)sense_data;
927 sense_buf[12] = sense_code;
928 sense_buf[13] = a_sense_code;
933 sense_buf[15] = bit_pointer;
936 sense_buf[15] |= 0xc0;
938 sense_buf[16] = field_pointer >> 8;
939 sense_buf[17] = field_pointer;
946 if (lba & 0xffffffff00000000LL) {
951 set_sense(&dev->
fsa_dev[cid].sense_data,
968 static void io_callback(
void *context,
struct fib * fibptr);
985 aac_build_sgraw2(cmd, readcmd2, dev->
scsi_host_ptr->sg_tablesize);
999 aac_build_sgraw(cmd, &readcmd->
sg);
1018 static int aac_read_block64(
struct fib * fib,
struct scsi_cmnd * cmd,
u64 lba,
u32 count)
1031 aac_build_sg64(cmd, &readcmd->
sg);
1035 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1049 static int aac_read_block(
struct fib * fib,
struct scsi_cmnd * cmd,
u64 lba,
u32 count)
1060 aac_build_sg(cmd, &readcmd->
sg);
1061 fibsize =
sizeof(
struct aac_read) +
1064 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1078 static int aac_write_raw_io(
struct fib * fib,
struct scsi_cmnd * cmd,
u64 lba,
u32 count,
int fua)
1092 writecmd2->
flags = (fua && ((aac_cache & 5) != 1) &&
1093 (((aac_cache & 5) != 5) || !fib->
dev->cache_protected)) ?
1096 aac_build_sgraw2(cmd, writecmd2, dev->
scsi_host_ptr->sg_tablesize);
1107 writecmd->
flags = (fua && ((aac_cache & 5) != 1) &&
1108 (((aac_cache & 5) != 5) || !fib->
dev->cache_protected)) ?
1113 aac_build_sgraw(cmd, &writecmd->
sg);
1132 static int aac_write_block64(
struct fib * fib,
struct scsi_cmnd * cmd,
u64 lba,
u32 count,
int fua)
1143 writecmd->
flags = 0;
1145 aac_build_sg64(cmd, &writecmd->
sg);
1149 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1163 static int aac_write_block(
struct fib * fib,
struct scsi_cmnd * cmd,
u64 lba,
u32 count,
int fua)
1176 aac_build_sg(cmd, &writecmd->
sg);
1180 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1194 static struct aac_srb * aac_scsi_common(
struct fib * fib,
struct scsi_cmnd * cmd)
1232 static void aac_srb_callback(
void *context,
struct fib * fibptr);
1234 static int aac_scsi_64(
struct fib * fib,
struct scsi_cmnd * cmd)
1237 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1239 aac_build_sg64(cmd, (
struct sgmap64*) &srbcmd->
sg);
1250 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1262 static int aac_scsi_32(
struct fib * fib,
struct scsi_cmnd * cmd)
1265 struct aac_srb * srbcmd = aac_scsi_common(fib, cmd);
1267 aac_build_sg(cmd, (
struct sgmap*)&srbcmd->
sg);
1275 fibsize =
sizeof (
struct aac_srb) +
1278 BUG_ON (fibsize > (fib->
dev->max_fib_size -
1288 static int aac_scsi_32_64(
struct fib * fib,
struct scsi_cmnd * cmd)
1293 return aac_scsi_32(fib, cmd);
1310 memset(info,0,
sizeof(*info));
1338 memset(sinfo,0,
sizeof(*sinfo));
1367 memset(bus_info, 0,
sizeof(*bus_info));
1405 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
1410 tmp>>24,(tmp>>16)&0xff,tmp&0xff,
1416 dev->
name, dev->
id, buffer);
1517 dev->
a_ops.adapter_read = aac_read_raw_io;
1518 dev->
a_ops.adapter_write = aac_write_raw_io;
1520 dev->
a_ops.adapter_bounds = aac_bounds_32;
1523 sizeof(struct aac_write) + sizeof(struct sgentry)) /
1524 sizeof(struct sgentry);
1526 dev->
a_ops.adapter_read = aac_read_block64;
1527 dev->
a_ops.adapter_write = aac_write_block64;
1534 sizeof(struct aac_write64) +
1535 sizeof(struct sgentry64)) /
1536 sizeof(struct sgentry64);
1538 dev->
a_ops.adapter_read = aac_read_block;
1539 dev->
a_ops.adapter_write = aac_write_block;
1566 static void io_callback(
void *context,
struct fib * fibptr)
1575 if (!aac_valid_context(scsicmd, fibptr))
1583 switch (scsicmd->
cmnd[0]) {
1586 lba = ((scsicmd->
cmnd[1] & 0x1F) << 16) |
1587 (scsicmd->
cmnd[2] << 8) | scsicmd->
cmnd[3];
1591 lba = ((
u64)scsicmd->
cmnd[2] << 56) |
1592 ((
u64)scsicmd->
cmnd[3] << 48) |
1593 ((
u64)scsicmd->
cmnd[4] << 40) |
1594 ((
u64)scsicmd->
cmnd[5] << 32) |
1595 ((
u64)scsicmd->
cmnd[6] << 24) |
1596 (scsicmd->
cmnd[7] << 16) |
1597 (scsicmd->
cmnd[8] << 8) | scsicmd->
cmnd[9];
1601 lba = ((
u64)scsicmd->
cmnd[2] << 24) |
1602 (scsicmd->
cmnd[3] << 16) |
1603 (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1606 lba = ((
u64)scsicmd->
cmnd[2] << 24) |
1607 (scsicmd->
cmnd[3] << 16) |
1608 (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1612 "io_callback[cpu %d]: lba = %llu, t = %ld.\n",
1637 #ifdef AAC_DETAILED_STATUS_INFO
1643 set_sense(&dev->
fsa_dev[cid].sense_data,
1663 struct fib * cmd_fibcontext;
1670 switch (scsicmd->
cmnd[0]) {
1674 lba = ((scsicmd->
cmnd[1] & 0x1F) << 16) |
1675 (scsicmd->
cmnd[2] << 8) | scsicmd->
cmnd[3];
1676 count = scsicmd->
cmnd[4];
1684 lba = ((
u64)scsicmd->
cmnd[2] << 56) |
1685 ((
u64)scsicmd->
cmnd[3] << 48) |
1686 ((
u64)scsicmd->
cmnd[4] << 40) |
1687 ((
u64)scsicmd->
cmnd[5] << 32) |
1688 ((
u64)scsicmd->
cmnd[6] << 24) |
1689 (scsicmd->
cmnd[7] << 16) |
1690 (scsicmd->
cmnd[8] << 8) | scsicmd->
cmnd[9];
1691 count = (scsicmd->
cmnd[10] << 24) |
1692 (scsicmd->
cmnd[11] << 16) |
1693 (scsicmd->
cmnd[12] << 8) | scsicmd->
cmnd[13];
1698 lba = ((
u64)scsicmd->
cmnd[2] << 24) |
1699 (scsicmd->
cmnd[3] << 16) |
1700 (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1701 count = (scsicmd->
cmnd[6] << 24) |
1702 (scsicmd->
cmnd[7] << 16) |
1703 (scsicmd->
cmnd[8] << 8) | scsicmd->
cmnd[9];
1708 lba = ((
u64)scsicmd->
cmnd[2] << 24) |
1709 (scsicmd->
cmnd[3] << 16) |
1710 (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1711 count = (scsicmd->
cmnd[7] << 8) | scsicmd->
cmnd[8];
1720 set_sense(&dev->
fsa_dev[cid].sense_data,
1770 struct fib * cmd_fibcontext;
1779 lba = ((scsicmd->
cmnd[1] & 0x1F) << 16) | (scsicmd->
cmnd[2] << 8) | scsicmd->
cmnd[3];
1780 count = scsicmd->
cmnd[4];
1787 lba = ((
u64)scsicmd->
cmnd[2] << 56) |
1788 ((
u64)scsicmd->
cmnd[3] << 48) |
1789 ((
u64)scsicmd->
cmnd[4] << 40) |
1790 ((
u64)scsicmd->
cmnd[5] << 32) |
1791 ((
u64)scsicmd->
cmnd[6] << 24) |
1792 (scsicmd->
cmnd[7] << 16) |
1793 (scsicmd->
cmnd[8] << 8) | scsicmd->
cmnd[9];
1794 count = (scsicmd->
cmnd[10] << 24) | (scsicmd->
cmnd[11] << 16) |
1795 (scsicmd->
cmnd[12] << 8) | scsicmd->
cmnd[13];
1796 fua = scsicmd->
cmnd[1] & 0x8;
1800 lba = ((
u64)scsicmd->
cmnd[2] << 24) | (scsicmd->
cmnd[3] << 16)
1801 | (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1802 count = (scsicmd->
cmnd[6] << 24) | (scsicmd->
cmnd[7] << 16)
1803 | (scsicmd->
cmnd[8] << 8) | scsicmd->
cmnd[9];
1804 fua = scsicmd->
cmnd[1] & 0x8;
1807 lba = ((
u64)scsicmd->
cmnd[2] << 24) | (scsicmd->
cmnd[3] << 16) | (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1808 count = (scsicmd->
cmnd[7] << 8) | scsicmd->
cmnd[8];
1809 fua = scsicmd->
cmnd[1] & 0x8;
1817 set_sense(&dev->
fsa_dev[cid].sense_data,
1867 static void synchronize_callback(
void *context,
struct fib *fibptr)
1874 if (!aac_valid_context(cmd, fibptr))
1882 synchronizereply =
fib_data(fibptr);
1889 u32 cid = sdev_id(sdev);
1891 "synchronize_callback: synchronize failed, status = %d\n",
1895 set_sense(&dev->
fsa_dev[cid].sense_data,
1911 struct fib *cmd_fibcontext;
1917 u64 lba = ((
u64)scsicmd->
cmnd[2] << 24) | (scsicmd->
cmnd[3] << 16) |
1918 (scsicmd->
cmnd[4] << 8) | scsicmd->
cmnd[5];
1919 u32 count = (scsicmd->
cmnd[7] << 8) | scsicmd->
cmnd[8];
1920 unsigned long flags;
1933 cmnd_lba = ((cmd->
cmnd[1] & 0x1F) << 16) |
1934 (cmd->
cmnd[2] << 8) |
1936 cmnd_count = cmd->
cmnd[4];
1937 if (cmnd_count == 0)
1940 cmnd_lba = ((
u64)cmd->
cmnd[2] << 56) |
1945 (cmd->
cmnd[7] << 16) |
1946 (cmd->
cmnd[8] << 8) |
1948 cmnd_count = (cmd->
cmnd[10] << 24) |
1949 (cmd->
cmnd[11] << 16) |
1950 (cmd->
cmnd[12] << 8) |
1953 cmnd_lba = ((
u64)cmd->
cmnd[2] << 24) |
1954 (cmd->
cmnd[3] << 16) |
1955 (cmd->
cmnd[4] << 8) |
1957 cmnd_count = (cmd->
cmnd[6] << 24) |
1958 (cmd->
cmnd[7] << 16) |
1959 (cmd->
cmnd[8] << 8) |
1962 cmnd_lba = ((
u64)cmd->
cmnd[2] << 24) |
1963 (cmd->
cmnd[3] << 16) |
1964 (cmd->
cmnd[4] << 8) |
1966 cmnd_count = (cmd->
cmnd[7] << 8) |
1970 if (((cmnd_lba + cmnd_count) <
lba) ||
1971 (count && ((lba + count) < cmnd_lba)))
1997 synchronizecmd =
fib_data(cmd_fibcontext);
2001 synchronizecmd->
count =
2024 "aac_synchronize: aac_fib_send failed with status: %d.\n", status);
2030 static void aac_start_stop_callback(
void *context,
struct fib *fibptr)
2034 if (!aac_valid_context(scsicmd, fibptr))
2046 static int aac_start_stop(
struct scsi_cmnd *scsicmd)
2049 struct fib *cmd_fibcontext;
2069 if (!cmd_fibcontext)
2078 pmcmd->
sub = (scsicmd->
cmnd[4] & 1) ?
2081 pmcmd->
parm = (scsicmd->
cmnd[1] & 1) ?
2134 (scsicmd->
device->lun != 0)) {
2144 if (((fsa_dev_ptr[cid].
valid & 1) == 0) ||
2145 (fsa_dev_ptr[cid].sense_data.
sense_key ==
2147 switch (scsicmd->
cmnd[0]) {
2158 return _aac_probe_container(scsicmd,
2159 aac_probe_container_callback2);
2169 return aac_send_srb_fib(scsicmd);
2183 dprintk((
KERN_WARNING "Only INQUIRY & TUR command supported for controller, rcvd = 0x%x.\n", scsicmd->
cmnd[0]));
2185 set_sense(&dev->
fsa_dev[cid].sense_data,
2197 switch (scsicmd->
cmnd[0]) {
2206 char *arr = (
char *)&inq_data;
2211 if (scsicmd->
cmnd[2] == 0) {
2216 arr[1] = scsicmd->
cmnd[2];
2217 scsi_sg_copy_from_buffer(scsicmd, &inq_data,
2221 }
else if (scsicmd->
cmnd[2] == 0x80) {
2223 arr[3] = setinqserial(dev, &arr[4],
2225 arr[1] = scsicmd->
cmnd[2];
2226 scsi_sg_copy_from_buffer(scsicmd, &inq_data,
2229 return aac_get_container_serial(
2239 set_sense(&dev->
fsa_dev[cid].sense_data,
2243 &dev->
fsa_dev[cid].sense_data,
2245 sizeof(dev->
fsa_dev[cid].sense_data),
2263 scsi_sg_copy_from_buffer(scsicmd, &inq_data,
2271 setinqstr(dev, (
void *) (inq_data.
inqd_vid), fsa_dev_ptr[cid].
type);
2273 scsi_sg_copy_from_buffer(scsicmd, &inq_data,
sizeof(inq_data));
2274 return aac_get_container_name(scsicmd);
2284 unsigned int alloc_len;
2287 capacity = fsa_dev_ptr[
cid].
size - 1;
2288 cp[0] = (capacity >> 56) & 0xff;
2289 cp[1] = (capacity >> 48) & 0xff;
2290 cp[2] = (capacity >> 40) & 0xff;
2291 cp[3] = (capacity >> 32) & 0xff;
2292 cp[4] = (capacity >> 24) & 0xff;
2293 cp[5] = (capacity >> 16) & 0xff;
2294 cp[6] = (capacity >> 8) & 0xff;
2295 cp[7] = (capacity >> 0) & 0xff;
2302 alloc_len = ((scsicmd->
cmnd[10] << 24)
2303 + (scsicmd->
cmnd[11] << 16)
2304 + (scsicmd->
cmnd[12] << 8) + scsicmd->
cmnd[13]);
2306 alloc_len =
min_t(
size_t, alloc_len,
sizeof(cp));
2307 scsi_sg_copy_from_buffer(scsicmd, cp, alloc_len);
2308 if (alloc_len < scsi_bufflen(scsicmd))
2309 scsi_set_resid(scsicmd,
2310 scsi_bufflen(scsicmd) - alloc_len);
2313 scsicmd->
device->removable = 1;
2327 if (fsa_dev_ptr[cid].
size <= 0x100000000ULL)
2328 capacity = fsa_dev_ptr[
cid].
size - 1;
2332 cp[0] = (capacity >> 24) & 0xff;
2333 cp[1] = (capacity >> 16) & 0xff;
2334 cp[2] = (capacity >> 8) & 0xff;
2335 cp[3] = (capacity >> 0) & 0xff;
2340 scsi_sg_copy_from_buffer(scsicmd, cp,
sizeof(cp));
2342 scsicmd->
device->removable = 1;
2353 int mode_buf_length = 4;
2364 if (((scsicmd->
cmnd[2] & 0x3f) == 8) ||
2365 ((scsicmd->
cmnd[2] & 0x3f) == 0x3f)) {
2369 mode_buf[6] = ((aac_cache & 6) == 2)
2371 mode_buf_length = 7;
2372 if (mode_buf_length > scsicmd->
cmnd[4])
2373 mode_buf_length = scsicmd->
cmnd[4];
2375 scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length);
2384 int mode_buf_length = 8;
2399 if (((scsicmd->
cmnd[2] & 0x3f) == 8) ||
2400 ((scsicmd->
cmnd[2] & 0x3f) == 0x3f)) {
2404 mode_buf[10] = ((aac_cache & 6) == 2)
2406 mode_buf_length = 11;
2407 if (mode_buf_length > scsicmd->
cmnd[8])
2408 mode_buf_length = scsicmd->
cmnd[8];
2410 scsi_sg_copy_from_buffer(scsicmd, mode_buf, mode_buf_length);
2427 if (scsicmd->
cmnd[4])
2442 set_sense(&dev->
fsa_dev[cid].sense_data,
2446 &dev->
fsa_dev[cid].sense_data,
2448 sizeof(dev->
fsa_dev[cid].sense_data),
2464 return aac_start_stop(scsicmd);
2467 switch (scsicmd->
cmnd[0])
2481 if (scsicmd->
request->rq_disk)
2482 strlcpy(fsa_dev_ptr[cid].devname,
2483 scsicmd->
request->rq_disk->disk_name,
2484 min(
sizeof(fsa_dev_ptr[cid].devname),
2485 sizeof(scsicmd->
request->rq_disk->disk_name) + 1));
2505 if ((aac_cache & 6) != 2)
2514 set_sense(&dev->
fsa_dev[cid].sense_data,
2519 sizeof(dev->
fsa_dev[cid].sense_data),
2526 static int query_disk(
struct aac_dev *dev,
void __user *
arg)
2538 else if ((qd.bus == -1) && (qd.id == -1) && (qd.lun == -1))
2549 qd.valid = fsa_dev_ptr[qd.cnum].
valid != 0;
2550 qd.locked = fsa_dev_ptr[qd.cnum].
locked;
2551 qd.deleted = fsa_dev_ptr[qd.cnum].
deleted;
2553 if (fsa_dev_ptr[qd.cnum].
devname[0] ==
'\0')
2559 min(
sizeof(qd.name),
sizeof(fsa_dev_ptr[qd.cnum].
devname) + 1));
2566 static int force_delete_disk(
struct aac_dev *dev,
void __user *arg)
2587 fsa_dev_ptr[
dd.cnum].
valid = 0;
2591 static int delete_disk(
struct aac_dev *dev,
void __user *arg)
2614 fsa_dev_ptr[
dd.cnum].
valid = 0;
2624 return query_disk(dev, arg);
2626 return delete_disk(dev, arg);
2628 return force_delete_disk(dev, arg);
2646 static void aac_srb_callback(
void *context,
struct fib * fibptr)
2654 if (!aac_valid_context(scsicmd, fibptr))
2673 scsi_set_resid(scsicmd, scsi_bufflen(scsicmd)
2682 aac_expose_phy_device(scsicmd);
2707 switch(scsicmd->
cmnd[0]){
2781 #ifdef AAC_DETAILED_STATUS_INFO
2782 printk(
"aacraid: SRB ERROR(%u) %s scsi cmd 0x%x - scsi status 0x%x\n",
2784 aac_get_status_string(
2791 if (scsicmd->
cmnd[2] & (0x01 << 5)) {
2811 #ifdef AAC_DETAILED_STATUS_INFO
2836 static int aac_send_srb_fib(
struct scsi_cmnd* scsicmd)
2838 struct fib* cmd_fibcontext;
2844 scsicmd->
device->lun > 7) {
2873 static unsigned long aac_build_sg(
struct scsi_cmnd* scsicmd,
struct sgmap* psg)
2876 unsigned long byte_count = 0;
2882 psg->
sg[0].addr = 0;
2883 psg->
sg[0].count = 0;
2899 if (byte_count > scsi_bufflen(scsicmd)) {
2901 (byte_count - scsi_bufflen(scsicmd));
2903 byte_count = scsi_bufflen(scsicmd);
2906 if(scsicmd->
underflow && (byte_count < scsicmd->underflow)){
2915 static unsigned long aac_build_sg64(
struct scsi_cmnd* scsicmd,
struct sgmap64* psg)
2918 unsigned long byte_count = 0;
2925 psg->
sg[0].addr[0] = 0;
2926 psg->
sg[0].addr[1] = 0;
2927 psg->
sg[0].count = 0;
2941 byte_count +=
count;
2945 if (byte_count > scsi_bufflen(scsicmd)) {
2947 (byte_count - scsi_bufflen(scsicmd));
2949 byte_count = scsi_bufflen(scsicmd);
2952 if(scsicmd->
underflow && (byte_count < scsicmd->underflow)){
2960 static unsigned long aac_build_sgraw(
struct scsi_cmnd* scsicmd,
struct sgmapraw* psg)
2962 unsigned long byte_count = 0;
2967 psg->
sg[0].next = 0;
2968 psg->
sg[0].prev = 0;
2969 psg->
sg[0].addr[0] = 0;
2970 psg->
sg[0].addr[1] = 0;
2971 psg->
sg[0].count = 0;
2972 psg->
sg[0].flags = 0;
2983 psg->
sg[
i].next = 0;
2984 psg->
sg[
i].prev = 0;
2988 psg->
sg[
i].flags = 0;
2989 byte_count +=
count;
2993 if (byte_count > scsi_bufflen(scsicmd)) {
2995 (byte_count - scsi_bufflen(scsicmd));
2997 byte_count = scsi_bufflen(scsicmd);
3000 if(scsicmd->
underflow && (byte_count < scsicmd->underflow)){
3008 static unsigned long aac_build_sgraw2(
struct scsi_cmnd *scsicmd,
struct aac_raw_io2 *rio2,
int sg_max)
3010 unsigned long byte_count = 0;
3017 int i, conformable = 0;
3028 rio2->
sge[
i].length = cur_size;
3029 rio2->
sge[
i].flags = 0;
3033 }
else if (i == 1) {
3035 min_size = cur_size;
3038 if (cur_size < min_size)
3039 min_size = cur_size;
3041 byte_count +=
count;
3045 if (byte_count > scsi_bufflen(scsicmd)) {
3047 (byte_count - scsi_bufflen(scsicmd));
3049 byte_count = scsi_bufflen(scsicmd);
3056 int j, nseg_new = nseg, err_found;
3057 for (i = min_size /
PAGE_SIZE; i >= 1; --
i) {
3060 for (j = 1; j < nseg - 1; ++
j) {
3070 if (i > 0 && nseg_new <= sg_max)
3071 aac_convert_sgraw2(rio2, i, nseg, nseg_new);
3076 if (scsicmd->
underflow && (byte_count < scsicmd->underflow)) {
3085 static int aac_convert_sgraw2(
struct aac_raw_io2 *rio2,
int pages,
int nseg,
int nseg_new)
3098 for (i = 1, pos = 1; i < nseg-1; ++
i) {
3099 for (j = 0; j < rio2->
sge[
i].length / (pages *
PAGE_SIZE); ++
j) {
3103 if (addr_low < rio2->sge[i].
addrLow)
3110 sge[
pos] = rio2->
sge[nseg-1];
3120 #ifdef AAC_DETAILED_STATUS_INFO
3122 struct aac_srb_status_info {
3128 static struct aac_srb_status_info srb_status_info[] = {
3160 { 0xff,
"Unknown Error"}
3163 char *aac_get_status_string(
u32 status)
3167 for (i = 0; i <
ARRAY_SIZE(srb_status_info); i++)
3168 if (srb_status_info[i].status == status)
3169 return srb_status_info[
i].str;
3171 return "Bad Status Code";