diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 14:44:25 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-02-11 14:44:25 -0500 |
commit | 5f0b1437e0708772b6fecae5900c01c3b5f9b512 (patch) | |
tree | bcd923e305345178bc162ed8560d56a3af197224 /drivers/scsi/aacraid/aachba.c | |
parent | 574009c1a895aeeb85eaab29c235d75852b09eb8 (diff) | |
parent | 81b7bbd1932a04869d4c8635a75222dfc6089f96 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (97 commits)
[SCSI] zfcp: removed wrong comment
[SCSI] zfcp: use of uninitialized variable
[SCSI] zfcp: Invalid locking order
[SCSI] aic79xx: use dma_get_required_mask()
[SCSI] aic79xx: fix bracket mismatch in unused macro
[SCSI] BusLogic: Replace 'boolean' by 'bool'
[SCSI] advansys: clean up warnings
[SCSI] 53c7xx: brackets fix in uncompiled code
[SCSI] nsp_cs: remove old scsi code
[SCSI] aic79xx: make ahd_match_scb() static
[SCSI] DAC960: kmalloc->kzalloc/Casting cleanups
[SCSI] scsi_kmap_atomic_sg(): check that local irqs are disabled
[SCSI] Buslogic: local_irq_disable() is redundant after local_irq_save()
[SCSI] aic94xx: update for v28 firmware
[SCSI] scsi_error: Fix lost EH commands
[SCSI] aic94xx: Add default bus reset handler
[SCSI] aic94xx: Remove TMF result code munging
[SCSI] libsas: Add an LU reset mechanism to the error handler
[SCSI] libsas: Don't BUG when connecting two expanders via wide port
[SCSI] st: fix Tape dies if wrong block size used, bug 7919
...
Diffstat (limited to 'drivers/scsi/aacraid/aachba.c')
-rw-r--r-- | drivers/scsi/aacraid/aachba.c | 602 |
1 files changed, 328 insertions, 274 deletions
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 426cd6f49f5d..ddb33b06e0ef 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -170,9 +170,9 @@ int acbsize = -1; | |||
170 | module_param(acbsize, int, S_IRUGO|S_IWUSR); | 170 | module_param(acbsize, int, S_IRUGO|S_IWUSR); |
171 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware."); | 171 | MODULE_PARM_DESC(acbsize, "Request a specific adapter control block (FIB) size. Valid values are 512, 2048, 4096 and 8192. Default is to use suggestion from Firmware."); |
172 | 172 | ||
173 | int expose_physicals = 0; | 173 | int expose_physicals = -1; |
174 | module_param(expose_physicals, int, S_IRUGO|S_IWUSR); | 174 | module_param(expose_physicals, int, S_IRUGO|S_IWUSR); |
175 | MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. 0=off, 1=on"); | 175 | MODULE_PARM_DESC(expose_physicals, "Expose physical components of the arrays. -1=protect 0=off, 1=on"); |
176 | /** | 176 | /** |
177 | * aac_get_config_status - check the adapter configuration | 177 | * aac_get_config_status - check the adapter configuration |
178 | * @common: adapter to query | 178 | * @common: adapter to query |
@@ -706,6 +706,309 @@ static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code, | |||
706 | } | 706 | } |
707 | } | 707 | } |
708 | 708 | ||
709 | static int aac_bounds_32(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) | ||
710 | { | ||
711 | if (lba & 0xffffffff00000000LL) { | ||
712 | int cid = scmd_id(cmd); | ||
713 | dprintk((KERN_DEBUG "aacraid: Illegal lba\n")); | ||
714 | cmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | ||
715 | SAM_STAT_CHECK_CONDITION; | ||
716 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | ||
717 | HARDWARE_ERROR, | ||
718 | SENCODE_INTERNAL_TARGET_FAILURE, | ||
719 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
720 | 0, 0); | ||
721 | memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | ||
722 | (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(cmd->sense_buffer)) | ||
723 | ? sizeof(cmd->sense_buffer) | ||
724 | : sizeof(dev->fsa_dev[cid].sense_data)); | ||
725 | cmd->scsi_done(cmd); | ||
726 | return 1; | ||
727 | } | ||
728 | return 0; | ||
729 | } | ||
730 | |||
731 | static int aac_bounds_64(struct aac_dev * dev, struct scsi_cmnd * cmd, u64 lba) | ||
732 | { | ||
733 | return 0; | ||
734 | } | ||
735 | |||
736 | static void io_callback(void *context, struct fib * fibptr); | ||
737 | |||
738 | static int aac_read_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
739 | { | ||
740 | u16 fibsize; | ||
741 | struct aac_raw_io *readcmd; | ||
742 | aac_fib_init(fib); | ||
743 | readcmd = (struct aac_raw_io *) fib_data(fib); | ||
744 | readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); | ||
745 | readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); | ||
746 | readcmd->count = cpu_to_le32(count<<9); | ||
747 | readcmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
748 | readcmd->flags = cpu_to_le16(1); | ||
749 | readcmd->bpTotal = 0; | ||
750 | readcmd->bpComplete = 0; | ||
751 | |||
752 | aac_build_sgraw(cmd, &readcmd->sg); | ||
753 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); | ||
754 | BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); | ||
755 | /* | ||
756 | * Now send the Fib to the adapter | ||
757 | */ | ||
758 | return aac_fib_send(ContainerRawIo, | ||
759 | fib, | ||
760 | fibsize, | ||
761 | FsaNormal, | ||
762 | 0, 1, | ||
763 | (fib_callback) io_callback, | ||
764 | (void *) cmd); | ||
765 | } | ||
766 | |||
767 | static int aac_read_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
768 | { | ||
769 | u16 fibsize; | ||
770 | struct aac_read64 *readcmd; | ||
771 | aac_fib_init(fib); | ||
772 | readcmd = (struct aac_read64 *) fib_data(fib); | ||
773 | readcmd->command = cpu_to_le32(VM_CtHostRead64); | ||
774 | readcmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
775 | readcmd->sector_count = cpu_to_le16(count); | ||
776 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
777 | readcmd->pad = 0; | ||
778 | readcmd->flags = 0; | ||
779 | |||
780 | aac_build_sg64(cmd, &readcmd->sg); | ||
781 | fibsize = sizeof(struct aac_read64) + | ||
782 | ((le32_to_cpu(readcmd->sg.count) - 1) * | ||
783 | sizeof (struct sgentry64)); | ||
784 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
785 | sizeof(struct aac_fibhdr))); | ||
786 | /* | ||
787 | * Now send the Fib to the adapter | ||
788 | */ | ||
789 | return aac_fib_send(ContainerCommand64, | ||
790 | fib, | ||
791 | fibsize, | ||
792 | FsaNormal, | ||
793 | 0, 1, | ||
794 | (fib_callback) io_callback, | ||
795 | (void *) cmd); | ||
796 | } | ||
797 | |||
798 | static int aac_read_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
799 | { | ||
800 | u16 fibsize; | ||
801 | struct aac_read *readcmd; | ||
802 | aac_fib_init(fib); | ||
803 | readcmd = (struct aac_read *) fib_data(fib); | ||
804 | readcmd->command = cpu_to_le32(VM_CtBlockRead); | ||
805 | readcmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
806 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
807 | readcmd->count = cpu_to_le32(count * 512); | ||
808 | |||
809 | aac_build_sg(cmd, &readcmd->sg); | ||
810 | fibsize = sizeof(struct aac_read) + | ||
811 | ((le32_to_cpu(readcmd->sg.count) - 1) * | ||
812 | sizeof (struct sgentry)); | ||
813 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
814 | sizeof(struct aac_fibhdr))); | ||
815 | /* | ||
816 | * Now send the Fib to the adapter | ||
817 | */ | ||
818 | return aac_fib_send(ContainerCommand, | ||
819 | fib, | ||
820 | fibsize, | ||
821 | FsaNormal, | ||
822 | 0, 1, | ||
823 | (fib_callback) io_callback, | ||
824 | (void *) cmd); | ||
825 | } | ||
826 | |||
827 | static int aac_write_raw_io(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
828 | { | ||
829 | u16 fibsize; | ||
830 | struct aac_raw_io *writecmd; | ||
831 | aac_fib_init(fib); | ||
832 | writecmd = (struct aac_raw_io *) fib_data(fib); | ||
833 | writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); | ||
834 | writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); | ||
835 | writecmd->count = cpu_to_le32(count<<9); | ||
836 | writecmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
837 | writecmd->flags = 0; | ||
838 | writecmd->bpTotal = 0; | ||
839 | writecmd->bpComplete = 0; | ||
840 | |||
841 | aac_build_sgraw(cmd, &writecmd->sg); | ||
842 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); | ||
843 | BUG_ON(fibsize > (fib->dev->max_fib_size - sizeof(struct aac_fibhdr))); | ||
844 | /* | ||
845 | * Now send the Fib to the adapter | ||
846 | */ | ||
847 | return aac_fib_send(ContainerRawIo, | ||
848 | fib, | ||
849 | fibsize, | ||
850 | FsaNormal, | ||
851 | 0, 1, | ||
852 | (fib_callback) io_callback, | ||
853 | (void *) cmd); | ||
854 | } | ||
855 | |||
856 | static int aac_write_block64(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
857 | { | ||
858 | u16 fibsize; | ||
859 | struct aac_write64 *writecmd; | ||
860 | aac_fib_init(fib); | ||
861 | writecmd = (struct aac_write64 *) fib_data(fib); | ||
862 | writecmd->command = cpu_to_le32(VM_CtHostWrite64); | ||
863 | writecmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
864 | writecmd->sector_count = cpu_to_le16(count); | ||
865 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
866 | writecmd->pad = 0; | ||
867 | writecmd->flags = 0; | ||
868 | |||
869 | aac_build_sg64(cmd, &writecmd->sg); | ||
870 | fibsize = sizeof(struct aac_write64) + | ||
871 | ((le32_to_cpu(writecmd->sg.count) - 1) * | ||
872 | sizeof (struct sgentry64)); | ||
873 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
874 | sizeof(struct aac_fibhdr))); | ||
875 | /* | ||
876 | * Now send the Fib to the adapter | ||
877 | */ | ||
878 | return aac_fib_send(ContainerCommand64, | ||
879 | fib, | ||
880 | fibsize, | ||
881 | FsaNormal, | ||
882 | 0, 1, | ||
883 | (fib_callback) io_callback, | ||
884 | (void *) cmd); | ||
885 | } | ||
886 | |||
887 | static int aac_write_block(struct fib * fib, struct scsi_cmnd * cmd, u64 lba, u32 count) | ||
888 | { | ||
889 | u16 fibsize; | ||
890 | struct aac_write *writecmd; | ||
891 | aac_fib_init(fib); | ||
892 | writecmd = (struct aac_write *) fib_data(fib); | ||
893 | writecmd->command = cpu_to_le32(VM_CtBlockWrite); | ||
894 | writecmd->cid = cpu_to_le16(scmd_id(cmd)); | ||
895 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
896 | writecmd->count = cpu_to_le32(count * 512); | ||
897 | writecmd->sg.count = cpu_to_le32(1); | ||
898 | /* ->stable is not used - it did mean which type of write */ | ||
899 | |||
900 | aac_build_sg(cmd, &writecmd->sg); | ||
901 | fibsize = sizeof(struct aac_write) + | ||
902 | ((le32_to_cpu(writecmd->sg.count) - 1) * | ||
903 | sizeof (struct sgentry)); | ||
904 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
905 | sizeof(struct aac_fibhdr))); | ||
906 | /* | ||
907 | * Now send the Fib to the adapter | ||
908 | */ | ||
909 | return aac_fib_send(ContainerCommand, | ||
910 | fib, | ||
911 | fibsize, | ||
912 | FsaNormal, | ||
913 | 0, 1, | ||
914 | (fib_callback) io_callback, | ||
915 | (void *) cmd); | ||
916 | } | ||
917 | |||
918 | static struct aac_srb * aac_scsi_common(struct fib * fib, struct scsi_cmnd * cmd) | ||
919 | { | ||
920 | struct aac_srb * srbcmd; | ||
921 | u32 flag; | ||
922 | u32 timeout; | ||
923 | |||
924 | aac_fib_init(fib); | ||
925 | switch(cmd->sc_data_direction){ | ||
926 | case DMA_TO_DEVICE: | ||
927 | flag = SRB_DataOut; | ||
928 | break; | ||
929 | case DMA_BIDIRECTIONAL: | ||
930 | flag = SRB_DataIn | SRB_DataOut; | ||
931 | break; | ||
932 | case DMA_FROM_DEVICE: | ||
933 | flag = SRB_DataIn; | ||
934 | break; | ||
935 | case DMA_NONE: | ||
936 | default: /* shuts up some versions of gcc */ | ||
937 | flag = SRB_NoDataXfer; | ||
938 | break; | ||
939 | } | ||
940 | |||
941 | srbcmd = (struct aac_srb*) fib_data(fib); | ||
942 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); | ||
943 | srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scmd_channel(cmd))); | ||
944 | srbcmd->id = cpu_to_le32(scmd_id(cmd)); | ||
945 | srbcmd->lun = cpu_to_le32(cmd->device->lun); | ||
946 | srbcmd->flags = cpu_to_le32(flag); | ||
947 | timeout = cmd->timeout_per_command/HZ; | ||
948 | if (timeout == 0) | ||
949 | timeout = 1; | ||
950 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds | ||
951 | srbcmd->retry_limit = 0; /* Obsolete parameter */ | ||
952 | srbcmd->cdb_size = cpu_to_le32(cmd->cmd_len); | ||
953 | return srbcmd; | ||
954 | } | ||
955 | |||
956 | static void aac_srb_callback(void *context, struct fib * fibptr); | ||
957 | |||
958 | static int aac_scsi_64(struct fib * fib, struct scsi_cmnd * cmd) | ||
959 | { | ||
960 | u16 fibsize; | ||
961 | struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); | ||
962 | |||
963 | aac_build_sg64(cmd, (struct sgmap64*) &srbcmd->sg); | ||
964 | srbcmd->count = cpu_to_le32(cmd->request_bufflen); | ||
965 | |||
966 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); | ||
967 | memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); | ||
968 | /* | ||
969 | * Build Scatter/Gather list | ||
970 | */ | ||
971 | fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + | ||
972 | ((le32_to_cpu(srbcmd->sg.count) & 0xff) * | ||
973 | sizeof (struct sgentry64)); | ||
974 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
975 | sizeof(struct aac_fibhdr))); | ||
976 | |||
977 | /* | ||
978 | * Now send the Fib to the adapter | ||
979 | */ | ||
980 | return aac_fib_send(ScsiPortCommand64, fib, | ||
981 | fibsize, FsaNormal, 0, 1, | ||
982 | (fib_callback) aac_srb_callback, | ||
983 | (void *) cmd); | ||
984 | } | ||
985 | |||
986 | static int aac_scsi_32(struct fib * fib, struct scsi_cmnd * cmd) | ||
987 | { | ||
988 | u16 fibsize; | ||
989 | struct aac_srb * srbcmd = aac_scsi_common(fib, cmd); | ||
990 | |||
991 | aac_build_sg(cmd, (struct sgmap*)&srbcmd->sg); | ||
992 | srbcmd->count = cpu_to_le32(cmd->request_bufflen); | ||
993 | |||
994 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); | ||
995 | memcpy(srbcmd->cdb, cmd->cmnd, cmd->cmd_len); | ||
996 | /* | ||
997 | * Build Scatter/Gather list | ||
998 | */ | ||
999 | fibsize = sizeof (struct aac_srb) + | ||
1000 | (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * | ||
1001 | sizeof (struct sgentry)); | ||
1002 | BUG_ON (fibsize > (fib->dev->max_fib_size - | ||
1003 | sizeof(struct aac_fibhdr))); | ||
1004 | |||
1005 | /* | ||
1006 | * Now send the Fib to the adapter | ||
1007 | */ | ||
1008 | return aac_fib_send(ScsiPortCommand, fib, fibsize, FsaNormal, 0, 1, | ||
1009 | (fib_callback) aac_srb_callback, (void *) cmd); | ||
1010 | } | ||
1011 | |||
709 | int aac_get_adapter_info(struct aac_dev* dev) | 1012 | int aac_get_adapter_info(struct aac_dev* dev) |
710 | { | 1013 | { |
711 | struct fib* fibptr; | 1014 | struct fib* fibptr; |
@@ -874,14 +1177,27 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
874 | } | 1177 | } |
875 | } | 1178 | } |
876 | /* | 1179 | /* |
877 | * 57 scatter gather elements | 1180 | * Deal with configuring for the individualized limits of each packet |
1181 | * interface. | ||
878 | */ | 1182 | */ |
879 | if (!(dev->raw_io_interface)) { | 1183 | dev->a_ops.adapter_scsi = (dev->dac_support) |
1184 | ? aac_scsi_64 | ||
1185 | : aac_scsi_32; | ||
1186 | if (dev->raw_io_interface) { | ||
1187 | dev->a_ops.adapter_bounds = (dev->raw_io_64) | ||
1188 | ? aac_bounds_64 | ||
1189 | : aac_bounds_32; | ||
1190 | dev->a_ops.adapter_read = aac_read_raw_io; | ||
1191 | dev->a_ops.adapter_write = aac_write_raw_io; | ||
1192 | } else { | ||
1193 | dev->a_ops.adapter_bounds = aac_bounds_32; | ||
880 | dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - | 1194 | dev->scsi_host_ptr->sg_tablesize = (dev->max_fib_size - |
881 | sizeof(struct aac_fibhdr) - | 1195 | sizeof(struct aac_fibhdr) - |
882 | sizeof(struct aac_write) + sizeof(struct sgentry)) / | 1196 | sizeof(struct aac_write) + sizeof(struct sgentry)) / |
883 | sizeof(struct sgentry); | 1197 | sizeof(struct sgentry); |
884 | if (dev->dac_support) { | 1198 | if (dev->dac_support) { |
1199 | dev->a_ops.adapter_read = aac_read_block64; | ||
1200 | dev->a_ops.adapter_write = aac_write_block64; | ||
885 | /* | 1201 | /* |
886 | * 38 scatter gather elements | 1202 | * 38 scatter gather elements |
887 | */ | 1203 | */ |
@@ -891,6 +1207,9 @@ int aac_get_adapter_info(struct aac_dev* dev) | |||
891 | sizeof(struct aac_write64) + | 1207 | sizeof(struct aac_write64) + |
892 | sizeof(struct sgentry64)) / | 1208 | sizeof(struct sgentry64)) / |
893 | sizeof(struct sgentry64); | 1209 | sizeof(struct sgentry64); |
1210 | } else { | ||
1211 | dev->a_ops.adapter_read = aac_read_block; | ||
1212 | dev->a_ops.adapter_write = aac_write_block; | ||
894 | } | 1213 | } |
895 | dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; | 1214 | dev->scsi_host_ptr->max_sectors = AAC_MAX_32BIT_SGBCOUNT; |
896 | if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { | 1215 | if(!(dev->adapter_info.options & AAC_OPT_NEW_COMM)) { |
@@ -1004,8 +1323,6 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) | |||
1004 | u64 lba; | 1323 | u64 lba; |
1005 | u32 count; | 1324 | u32 count; |
1006 | int status; | 1325 | int status; |
1007 | |||
1008 | u16 fibsize; | ||
1009 | struct aac_dev *dev; | 1326 | struct aac_dev *dev; |
1010 | struct fib * cmd_fibcontext; | 1327 | struct fib * cmd_fibcontext; |
1011 | 1328 | ||
@@ -1059,23 +1376,8 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) | |||
1059 | } | 1376 | } |
1060 | dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n", | 1377 | dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n", |
1061 | smp_processor_id(), (unsigned long long)lba, jiffies)); | 1378 | smp_processor_id(), (unsigned long long)lba, jiffies)); |
1062 | if ((!(dev->raw_io_interface) || !(dev->raw_io_64)) && | 1379 | if (aac_adapter_bounds(dev,scsicmd,lba)) |
1063 | (lba & 0xffffffff00000000LL)) { | ||
1064 | dprintk((KERN_DEBUG "aac_read: Illegal lba\n")); | ||
1065 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | | ||
1066 | SAM_STAT_CHECK_CONDITION; | ||
1067 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | ||
1068 | HARDWARE_ERROR, | ||
1069 | SENCODE_INTERNAL_TARGET_FAILURE, | ||
1070 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
1071 | 0, 0); | ||
1072 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | ||
1073 | (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer)) | ||
1074 | ? sizeof(scsicmd->sense_buffer) | ||
1075 | : sizeof(dev->fsa_dev[cid].sense_data)); | ||
1076 | scsicmd->scsi_done(scsicmd); | ||
1077 | return 0; | 1380 | return 0; |
1078 | } | ||
1079 | /* | 1381 | /* |
1080 | * Alocate and initialize a Fib | 1382 | * Alocate and initialize a Fib |
1081 | */ | 1383 | */ |
@@ -1083,85 +1385,7 @@ static int aac_read(struct scsi_cmnd * scsicmd, int cid) | |||
1083 | return -1; | 1385 | return -1; |
1084 | } | 1386 | } |
1085 | 1387 | ||
1086 | aac_fib_init(cmd_fibcontext); | 1388 | status = aac_adapter_read(cmd_fibcontext, scsicmd, lba, count); |
1087 | |||
1088 | if (dev->raw_io_interface) { | ||
1089 | struct aac_raw_io *readcmd; | ||
1090 | readcmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); | ||
1091 | readcmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1092 | readcmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); | ||
1093 | readcmd->count = cpu_to_le32(count<<9); | ||
1094 | readcmd->cid = cpu_to_le16(cid); | ||
1095 | readcmd->flags = cpu_to_le16(1); | ||
1096 | readcmd->bpTotal = 0; | ||
1097 | readcmd->bpComplete = 0; | ||
1098 | |||
1099 | aac_build_sgraw(scsicmd, &readcmd->sg); | ||
1100 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(readcmd->sg.count) - 1) * sizeof (struct sgentryraw)); | ||
1101 | BUG_ON(fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))); | ||
1102 | /* | ||
1103 | * Now send the Fib to the adapter | ||
1104 | */ | ||
1105 | status = aac_fib_send(ContainerRawIo, | ||
1106 | cmd_fibcontext, | ||
1107 | fibsize, | ||
1108 | FsaNormal, | ||
1109 | 0, 1, | ||
1110 | (fib_callback) io_callback, | ||
1111 | (void *) scsicmd); | ||
1112 | } else if (dev->dac_support == 1) { | ||
1113 | struct aac_read64 *readcmd; | ||
1114 | readcmd = (struct aac_read64 *) fib_data(cmd_fibcontext); | ||
1115 | readcmd->command = cpu_to_le32(VM_CtHostRead64); | ||
1116 | readcmd->cid = cpu_to_le16(cid); | ||
1117 | readcmd->sector_count = cpu_to_le16(count); | ||
1118 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1119 | readcmd->pad = 0; | ||
1120 | readcmd->flags = 0; | ||
1121 | |||
1122 | aac_build_sg64(scsicmd, &readcmd->sg); | ||
1123 | fibsize = sizeof(struct aac_read64) + | ||
1124 | ((le32_to_cpu(readcmd->sg.count) - 1) * | ||
1125 | sizeof (struct sgentry64)); | ||
1126 | BUG_ON (fibsize > (dev->max_fib_size - | ||
1127 | sizeof(struct aac_fibhdr))); | ||
1128 | /* | ||
1129 | * Now send the Fib to the adapter | ||
1130 | */ | ||
1131 | status = aac_fib_send(ContainerCommand64, | ||
1132 | cmd_fibcontext, | ||
1133 | fibsize, | ||
1134 | FsaNormal, | ||
1135 | 0, 1, | ||
1136 | (fib_callback) io_callback, | ||
1137 | (void *) scsicmd); | ||
1138 | } else { | ||
1139 | struct aac_read *readcmd; | ||
1140 | readcmd = (struct aac_read *) fib_data(cmd_fibcontext); | ||
1141 | readcmd->command = cpu_to_le32(VM_CtBlockRead); | ||
1142 | readcmd->cid = cpu_to_le32(cid); | ||
1143 | readcmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1144 | readcmd->count = cpu_to_le32(count * 512); | ||
1145 | |||
1146 | aac_build_sg(scsicmd, &readcmd->sg); | ||
1147 | fibsize = sizeof(struct aac_read) + | ||
1148 | ((le32_to_cpu(readcmd->sg.count) - 1) * | ||
1149 | sizeof (struct sgentry)); | ||
1150 | BUG_ON (fibsize > (dev->max_fib_size - | ||
1151 | sizeof(struct aac_fibhdr))); | ||
1152 | /* | ||
1153 | * Now send the Fib to the adapter | ||
1154 | */ | ||
1155 | status = aac_fib_send(ContainerCommand, | ||
1156 | cmd_fibcontext, | ||
1157 | fibsize, | ||
1158 | FsaNormal, | ||
1159 | 0, 1, | ||
1160 | (fib_callback) io_callback, | ||
1161 | (void *) scsicmd); | ||
1162 | } | ||
1163 | |||
1164 | |||
1165 | 1389 | ||
1166 | /* | 1390 | /* |
1167 | * Check that the command queued to the controller | 1391 | * Check that the command queued to the controller |
@@ -1187,7 +1411,6 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) | |||
1187 | u64 lba; | 1411 | u64 lba; |
1188 | u32 count; | 1412 | u32 count; |
1189 | int status; | 1413 | int status; |
1190 | u16 fibsize; | ||
1191 | struct aac_dev *dev; | 1414 | struct aac_dev *dev; |
1192 | struct fib * cmd_fibcontext; | 1415 | struct fib * cmd_fibcontext; |
1193 | 1416 | ||
@@ -1227,22 +1450,8 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) | |||
1227 | } | 1450 | } |
1228 | dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n", | 1451 | dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n", |
1229 | smp_processor_id(), (unsigned long long)lba, jiffies)); | 1452 | smp_processor_id(), (unsigned long long)lba, jiffies)); |
1230 | if ((!(dev->raw_io_interface) || !(dev->raw_io_64)) | 1453 | if (aac_adapter_bounds(dev,scsicmd,lba)) |
1231 | && (lba & 0xffffffff00000000LL)) { | ||
1232 | dprintk((KERN_DEBUG "aac_write: Illegal lba\n")); | ||
1233 | scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION; | ||
1234 | set_sense((u8 *) &dev->fsa_dev[cid].sense_data, | ||
1235 | HARDWARE_ERROR, | ||
1236 | SENCODE_INTERNAL_TARGET_FAILURE, | ||
1237 | ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0, | ||
1238 | 0, 0); | ||
1239 | memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data, | ||
1240 | (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer)) | ||
1241 | ? sizeof(scsicmd->sense_buffer) | ||
1242 | : sizeof(dev->fsa_dev[cid].sense_data)); | ||
1243 | scsicmd->scsi_done(scsicmd); | ||
1244 | return 0; | 1454 | return 0; |
1245 | } | ||
1246 | /* | 1455 | /* |
1247 | * Allocate and initialize a Fib then setup a BlockWrite command | 1456 | * Allocate and initialize a Fib then setup a BlockWrite command |
1248 | */ | 1457 | */ |
@@ -1251,85 +1460,8 @@ static int aac_write(struct scsi_cmnd * scsicmd, int cid) | |||
1251 | scsicmd->scsi_done(scsicmd); | 1460 | scsicmd->scsi_done(scsicmd); |
1252 | return 0; | 1461 | return 0; |
1253 | } | 1462 | } |
1254 | aac_fib_init(cmd_fibcontext); | ||
1255 | 1463 | ||
1256 | if (dev->raw_io_interface) { | 1464 | status = aac_adapter_write(cmd_fibcontext, scsicmd, lba, count); |
1257 | struct aac_raw_io *writecmd; | ||
1258 | writecmd = (struct aac_raw_io *) fib_data(cmd_fibcontext); | ||
1259 | writecmd->block[0] = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1260 | writecmd->block[1] = cpu_to_le32((u32)((lba&0xffffffff00000000LL)>>32)); | ||
1261 | writecmd->count = cpu_to_le32(count<<9); | ||
1262 | writecmd->cid = cpu_to_le16(cid); | ||
1263 | writecmd->flags = 0; | ||
1264 | writecmd->bpTotal = 0; | ||
1265 | writecmd->bpComplete = 0; | ||
1266 | |||
1267 | aac_build_sgraw(scsicmd, &writecmd->sg); | ||
1268 | fibsize = sizeof(struct aac_raw_io) + ((le32_to_cpu(writecmd->sg.count) - 1) * sizeof (struct sgentryraw)); | ||
1269 | BUG_ON(fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))); | ||
1270 | /* | ||
1271 | * Now send the Fib to the adapter | ||
1272 | */ | ||
1273 | status = aac_fib_send(ContainerRawIo, | ||
1274 | cmd_fibcontext, | ||
1275 | fibsize, | ||
1276 | FsaNormal, | ||
1277 | 0, 1, | ||
1278 | (fib_callback) io_callback, | ||
1279 | (void *) scsicmd); | ||
1280 | } else if (dev->dac_support == 1) { | ||
1281 | struct aac_write64 *writecmd; | ||
1282 | writecmd = (struct aac_write64 *) fib_data(cmd_fibcontext); | ||
1283 | writecmd->command = cpu_to_le32(VM_CtHostWrite64); | ||
1284 | writecmd->cid = cpu_to_le16(cid); | ||
1285 | writecmd->sector_count = cpu_to_le16(count); | ||
1286 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1287 | writecmd->pad = 0; | ||
1288 | writecmd->flags = 0; | ||
1289 | |||
1290 | aac_build_sg64(scsicmd, &writecmd->sg); | ||
1291 | fibsize = sizeof(struct aac_write64) + | ||
1292 | ((le32_to_cpu(writecmd->sg.count) - 1) * | ||
1293 | sizeof (struct sgentry64)); | ||
1294 | BUG_ON (fibsize > (dev->max_fib_size - | ||
1295 | sizeof(struct aac_fibhdr))); | ||
1296 | /* | ||
1297 | * Now send the Fib to the adapter | ||
1298 | */ | ||
1299 | status = aac_fib_send(ContainerCommand64, | ||
1300 | cmd_fibcontext, | ||
1301 | fibsize, | ||
1302 | FsaNormal, | ||
1303 | 0, 1, | ||
1304 | (fib_callback) io_callback, | ||
1305 | (void *) scsicmd); | ||
1306 | } else { | ||
1307 | struct aac_write *writecmd; | ||
1308 | writecmd = (struct aac_write *) fib_data(cmd_fibcontext); | ||
1309 | writecmd->command = cpu_to_le32(VM_CtBlockWrite); | ||
1310 | writecmd->cid = cpu_to_le32(cid); | ||
1311 | writecmd->block = cpu_to_le32((u32)(lba&0xffffffff)); | ||
1312 | writecmd->count = cpu_to_le32(count * 512); | ||
1313 | writecmd->sg.count = cpu_to_le32(1); | ||
1314 | /* ->stable is not used - it did mean which type of write */ | ||
1315 | |||
1316 | aac_build_sg(scsicmd, &writecmd->sg); | ||
1317 | fibsize = sizeof(struct aac_write) + | ||
1318 | ((le32_to_cpu(writecmd->sg.count) - 1) * | ||
1319 | sizeof (struct sgentry)); | ||
1320 | BUG_ON (fibsize > (dev->max_fib_size - | ||
1321 | sizeof(struct aac_fibhdr))); | ||
1322 | /* | ||
1323 | * Now send the Fib to the adapter | ||
1324 | */ | ||
1325 | status = aac_fib_send(ContainerCommand, | ||
1326 | cmd_fibcontext, | ||
1327 | fibsize, | ||
1328 | FsaNormal, | ||
1329 | 0, 1, | ||
1330 | (fib_callback) io_callback, | ||
1331 | (void *) scsicmd); | ||
1332 | } | ||
1333 | 1465 | ||
1334 | /* | 1466 | /* |
1335 | * Check that the command queued to the controller | 1467 | * Check that the command queued to the controller |
@@ -2099,10 +2231,6 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) | |||
2099 | struct fib* cmd_fibcontext; | 2231 | struct fib* cmd_fibcontext; |
2100 | struct aac_dev* dev; | 2232 | struct aac_dev* dev; |
2101 | int status; | 2233 | int status; |
2102 | struct aac_srb *srbcmd; | ||
2103 | u16 fibsize; | ||
2104 | u32 flag; | ||
2105 | u32 timeout; | ||
2106 | 2234 | ||
2107 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; | 2235 | dev = (struct aac_dev *)scsicmd->device->host->hostdata; |
2108 | if (scmd_id(scsicmd) >= dev->maximum_num_physicals || | 2236 | if (scmd_id(scsicmd) >= dev->maximum_num_physicals || |
@@ -2112,88 +2240,14 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) | |||
2112 | return 0; | 2240 | return 0; |
2113 | } | 2241 | } |
2114 | 2242 | ||
2115 | switch(scsicmd->sc_data_direction){ | ||
2116 | case DMA_TO_DEVICE: | ||
2117 | flag = SRB_DataOut; | ||
2118 | break; | ||
2119 | case DMA_BIDIRECTIONAL: | ||
2120 | flag = SRB_DataIn | SRB_DataOut; | ||
2121 | break; | ||
2122 | case DMA_FROM_DEVICE: | ||
2123 | flag = SRB_DataIn; | ||
2124 | break; | ||
2125 | case DMA_NONE: | ||
2126 | default: /* shuts up some versions of gcc */ | ||
2127 | flag = SRB_NoDataXfer; | ||
2128 | break; | ||
2129 | } | ||
2130 | |||
2131 | |||
2132 | /* | 2243 | /* |
2133 | * Allocate and initialize a Fib then setup a BlockWrite command | 2244 | * Allocate and initialize a Fib then setup a BlockWrite command |
2134 | */ | 2245 | */ |
2135 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) { | 2246 | if (!(cmd_fibcontext = aac_fib_alloc(dev))) { |
2136 | return -1; | 2247 | return -1; |
2137 | } | 2248 | } |
2138 | aac_fib_init(cmd_fibcontext); | 2249 | status = aac_adapter_scsi(cmd_fibcontext, scsicmd); |
2139 | |||
2140 | srbcmd = (struct aac_srb*) fib_data(cmd_fibcontext); | ||
2141 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); | ||
2142 | srbcmd->channel = cpu_to_le32(aac_logical_to_phys(scmd_channel(scsicmd))); | ||
2143 | srbcmd->id = cpu_to_le32(scmd_id(scsicmd)); | ||
2144 | srbcmd->lun = cpu_to_le32(scsicmd->device->lun); | ||
2145 | srbcmd->flags = cpu_to_le32(flag); | ||
2146 | timeout = scsicmd->timeout_per_command/HZ; | ||
2147 | if(timeout == 0){ | ||
2148 | timeout = 1; | ||
2149 | } | ||
2150 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds | ||
2151 | srbcmd->retry_limit = 0; /* Obsolete parameter */ | ||
2152 | srbcmd->cdb_size = cpu_to_le32(scsicmd->cmd_len); | ||
2153 | |||
2154 | if( dev->dac_support == 1 ) { | ||
2155 | aac_build_sg64(scsicmd, (struct sgmap64*) &srbcmd->sg); | ||
2156 | srbcmd->count = cpu_to_le32(scsicmd->request_bufflen); | ||
2157 | |||
2158 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); | ||
2159 | memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len); | ||
2160 | /* | ||
2161 | * Build Scatter/Gather list | ||
2162 | */ | ||
2163 | fibsize = sizeof (struct aac_srb) - sizeof (struct sgentry) + | ||
2164 | ((le32_to_cpu(srbcmd->sg.count) & 0xff) * | ||
2165 | sizeof (struct sgentry64)); | ||
2166 | BUG_ON (fibsize > (dev->max_fib_size - | ||
2167 | sizeof(struct aac_fibhdr))); | ||
2168 | 2250 | ||
2169 | /* | ||
2170 | * Now send the Fib to the adapter | ||
2171 | */ | ||
2172 | status = aac_fib_send(ScsiPortCommand64, cmd_fibcontext, | ||
2173 | fibsize, FsaNormal, 0, 1, | ||
2174 | (fib_callback) aac_srb_callback, | ||
2175 | (void *) scsicmd); | ||
2176 | } else { | ||
2177 | aac_build_sg(scsicmd, (struct sgmap*)&srbcmd->sg); | ||
2178 | srbcmd->count = cpu_to_le32(scsicmd->request_bufflen); | ||
2179 | |||
2180 | memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); | ||
2181 | memcpy(srbcmd->cdb, scsicmd->cmnd, scsicmd->cmd_len); | ||
2182 | /* | ||
2183 | * Build Scatter/Gather list | ||
2184 | */ | ||
2185 | fibsize = sizeof (struct aac_srb) + | ||
2186 | (((le32_to_cpu(srbcmd->sg.count) & 0xff) - 1) * | ||
2187 | sizeof (struct sgentry)); | ||
2188 | BUG_ON (fibsize > (dev->max_fib_size - | ||
2189 | sizeof(struct aac_fibhdr))); | ||
2190 | |||
2191 | /* | ||
2192 | * Now send the Fib to the adapter | ||
2193 | */ | ||
2194 | status = aac_fib_send(ScsiPortCommand, cmd_fibcontext, fibsize, FsaNormal, 0, 1, | ||
2195 | (fib_callback) aac_srb_callback, (void *) scsicmd); | ||
2196 | } | ||
2197 | /* | 2251 | /* |
2198 | * Check that the command queued to the controller | 2252 | * Check that the command queued to the controller |
2199 | */ | 2253 | */ |