20 #define DAC960_DriverVersion "2.5.49"
21 #define DAC960_DriverDate "21 Aug 2007"
24 #include <linux/module.h>
25 #include <linux/types.h>
38 #include <linux/slab.h>
42 #include <linux/reboot.h>
45 #include <linux/pci.h>
48 #include <linux/random.h>
51 #include <asm/uaccess.h>
54 #define DAC960_GAM_MINOR 252
59 static int DAC960_ControllerCount;
62 static long disk_size(DAC960_Controller_T *
p,
int drive_nr)
64 if (p->FirmwareType == DAC960_V1_Controller) {
65 if (drive_nr >= p->LogicalDriveCount)
67 return p->V1.LogicalDriveInformation[drive_nr].
71 p->V2.LogicalDeviceInformation[drive_nr];
74 return i->ConfigurableDeviceSize;
80 struct gendisk *disk = bdev->
bd_disk;
81 DAC960_Controller_T *p = disk->queue->queuedata;
82 int drive_nr = (
long)disk->private_data;
86 if (p->FirmwareType == DAC960_V1_Controller) {
87 if (p->V1.LogicalDriveInformation[drive_nr].
92 p->V2.LogicalDeviceInformation[drive_nr];
99 if (!get_capacity(p->disks[drive_nr]))
109 struct gendisk *disk = bdev->
bd_disk;
110 DAC960_Controller_T *p = disk->queue->queuedata;
111 int drive_nr = (
long)disk->private_data;
113 if (p->FirmwareType == DAC960_V1_Controller) {
114 geo->
heads = p->V1.GeometryTranslationHeads;
115 geo->
sectors = p->V1.GeometryTranslationSectors;
116 geo->
cylinders = p->V1.LogicalDriveInformation[drive_nr].
120 p->V2.LogicalDeviceInformation[drive_nr];
121 switch (i->DriveGeometry) {
122 case DAC960_V2_Geometry_128_32:
126 case DAC960_V2_Geometry_255_63:
131 DAC960_Error(
"Illegal Logical Device Geometry %d\n",
132 p, i->DriveGeometry);
136 geo->
cylinders = i->ConfigurableDeviceSize /
143 static unsigned int DAC960_check_events(
struct gendisk *disk,
144 unsigned int clearing)
146 DAC960_Controller_T *p = disk->queue->queuedata;
147 int drive_nr = (
long)disk->private_data;
149 if (!p->LogicalDriveInitiallyAccessible[drive_nr])
150 return DISK_EVENT_MEDIA_CHANGE;
154 static int DAC960_revalidate_disk(
struct gendisk *disk)
156 DAC960_Controller_T *p = disk->queue->queuedata;
157 int unit = (
long)disk->private_data;
159 set_capacity(disk, disk_size(p, unit));
163 static const struct block_device_operations DAC960_BlockDeviceOperations = {
166 .getgeo = DAC960_getgeo,
167 .check_events = DAC960_check_events,
168 .revalidate_disk = DAC960_revalidate_disk,
177 static void DAC960_AnnounceDriver(DAC960_Controller_T *
Controller)
179 DAC960_Announce(
"***** DAC960 RAID Driver Version "
182 DAC960_Announce(
"Copyright 1998-2001 by Leonard N. Zubkoff "
191 static bool DAC960_Failure(DAC960_Controller_T *
Controller,
192 unsigned char *ErrorMessage)
194 DAC960_Error(
"While configuring DAC960 PCI RAID Controller at\n",
196 if (Controller->IO_Address == 0)
197 DAC960_Error(
"PCI Bus %d Device %d Function %d I/O Address N/A "
198 "PCI Address 0x%X\n", Controller,
199 Controller->Bus, Controller->Device,
200 Controller->Function, Controller->PCI_Address);
201 else DAC960_Error(
"PCI Bus %d Device %d Function %d I/O Address "
202 "0x%X PCI Address 0x%X\n", Controller,
203 Controller->Bus, Controller->Device,
204 Controller->Function, Controller->IO_Address,
205 Controller->PCI_Address);
206 DAC960_Error(
"%s FAILED - DETACHING\n", Controller, ErrorMessage);
227 if (cpu_addr ==
NULL)
237 static void *slice_dma_loaf(
struct dma_loaf *loaf,
size_t len,
240 void *cpu_end = loaf->
cpu_free + len;
250 static void free_dma_loaf(
struct pci_dev *dev,
struct dma_loaf *loaf_handle)
264 static bool DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
266 int CommandAllocationLength, CommandAllocationGroupSize;
268 void *AllocationPointer =
NULL;
269 void *ScatterGatherCPU =
NULL;
271 struct pci_pool *ScatterGatherPool;
272 void *RequestSenseCPU =
NULL;
274 struct pci_pool *RequestSensePool =
NULL;
276 if (Controller->FirmwareType == DAC960_V1_Controller)
278 CommandAllocationLength =
offsetof(DAC960_Command_T,
V1.EndMarker);
279 CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
280 ScatterGatherPool = pci_pool_create(
"DAC960_V1_ScatterGather",
281 Controller->PCIDevice,
284 if (ScatterGatherPool ==
NULL)
285 return DAC960_Failure(Controller,
286 "AUXILIARY STRUCTURE CREATION (SG)");
287 Controller->ScatterGatherPool = ScatterGatherPool;
291 CommandAllocationLength =
offsetof(DAC960_Command_T,
V2.EndMarker);
292 CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
293 ScatterGatherPool = pci_pool_create(
"DAC960_V2_ScatterGather",
294 Controller->PCIDevice,
297 if (ScatterGatherPool ==
NULL)
298 return DAC960_Failure(Controller,
299 "AUXILIARY STRUCTURE CREATION (SG)");
300 RequestSensePool = pci_pool_create(
"DAC960_V2_RequestSense",
303 if (RequestSensePool ==
NULL) {
304 pci_pool_destroy(ScatterGatherPool);
305 return DAC960_Failure(Controller,
306 "AUXILIARY STRUCTURE CREATION (SG)");
308 Controller->ScatterGatherPool = ScatterGatherPool;
309 Controller->V2.RequestSensePool = RequestSensePool;
311 Controller->CommandAllocationGroupSize = CommandAllocationGroupSize;
312 Controller->FreeCommands =
NULL;
318 if (--CommandsRemaining <= 0)
322 if (CommandsRemaining > CommandAllocationGroupSize)
323 CommandsRemaining = CommandAllocationGroupSize;
324 CommandGroupByteCount =
325 CommandsRemaining * CommandAllocationLength;
326 AllocationPointer = kzalloc(CommandGroupByteCount,
GFP_ATOMIC);
327 if (AllocationPointer ==
NULL)
328 return DAC960_Failure(Controller,
329 "AUXILIARY STRUCTURE CREATION");
331 Command = (DAC960_Command_T *) AllocationPointer;
332 AllocationPointer += CommandAllocationLength;
335 Command->Next = Controller->FreeCommands;
336 Controller->FreeCommands =
Command;
338 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool,
GFP_ATOMIC,
340 if (ScatterGatherCPU ==
NULL)
341 return DAC960_Failure(Controller,
"AUXILIARY STRUCTURE CREATION");
343 if (RequestSensePool !=
NULL) {
344 RequestSenseCPU = pci_pool_alloc(RequestSensePool,
GFP_ATOMIC,
346 if (RequestSenseCPU ==
NULL) {
347 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
349 return DAC960_Failure(Controller,
350 "AUXILIARY STRUCTURE CREATION");
353 if (Controller->FirmwareType == DAC960_V1_Controller) {
354 Command->cmd_sglist = Command->V1.ScatterList;
355 Command->V1.ScatterGatherList =
357 Command->V1.ScatterGatherListDMA = ScatterGatherDMA;
358 sg_init_table(Command->cmd_sglist, DAC960_V1_ScatterGatherLimit);
360 Command->cmd_sglist = Command->V2.ScatterList;
361 Command->V2.ScatterGatherList =
363 Command->V2.ScatterGatherListDMA = ScatterGatherDMA;
364 Command->V2.RequestSense =
366 Command->V2.RequestSenseDMA = RequestSenseDMA;
367 sg_init_table(Command->cmd_sglist, DAC960_V2_ScatterGatherLimit);
379 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
382 struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
383 struct pci_pool *RequestSensePool =
NULL;
384 void *ScatterGatherCPU;
386 void *RequestSenseCPU;
388 DAC960_Command_T *CommandGroup =
NULL;
391 if (Controller->FirmwareType == DAC960_V2_Controller)
392 RequestSensePool = Controller->V2.RequestSensePool;
394 Controller->FreeCommands =
NULL;
395 for (i = 0; i < Controller->DriverQueueDepth; i++)
397 DAC960_Command_T *Command = Controller->Commands[
i];
402 if (Controller->FirmwareType == DAC960_V1_Controller) {
403 ScatterGatherCPU = (
void *)Command->V1.ScatterGatherList;
404 ScatterGatherDMA = Command->V1.ScatterGatherListDMA;
405 RequestSenseCPU =
NULL;
408 ScatterGatherCPU = (
void *)Command->V2.ScatterGatherList;
409 ScatterGatherDMA = Command->V2.ScatterGatherListDMA;
410 RequestSenseCPU = (
void *)Command->V2.RequestSense;
411 RequestSenseDMA = Command->V2.RequestSenseDMA;
413 if (ScatterGatherCPU !=
NULL)
414 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA);
415 if (RequestSenseCPU !=
NULL)
416 pci_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA);
418 if ((Command->CommandIdentifier
419 % Controller->CommandAllocationGroupSize) == 1) {
429 Controller->Commands[
i] =
NULL;
433 if (Controller->CombinedStatusBuffer !=
NULL)
435 kfree(Controller->CombinedStatusBuffer);
436 Controller->CombinedStatusBuffer =
NULL;
437 Controller->CurrentStatusBuffer =
NULL;
440 if (ScatterGatherPool !=
NULL)
441 pci_pool_destroy(ScatterGatherPool);
442 if (Controller->FirmwareType == DAC960_V1_Controller)
445 if (RequestSensePool !=
NULL)
446 pci_pool_destroy(RequestSensePool);
449 kfree(Controller->V2.LogicalDeviceInformation[i]);
450 Controller->V2.LogicalDeviceInformation[
i] =
NULL;
455 kfree(Controller->V2.PhysicalDeviceInformation[i]);
456 Controller->V2.PhysicalDeviceInformation[
i] =
NULL;
457 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
458 Controller->V2.InquiryUnitSerialNumber[
i] =
NULL;
468 static inline void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
472 Command->V1.CommandStatus = 0;
481 static inline void DAC960_V2_ClearCommand(DAC960_Command_T *Command)
485 Command->V2.CommandStatus = 0;
496 static inline DAC960_Command_T *DAC960_AllocateCommand(DAC960_Controller_T
499 DAC960_Command_T *Command = Controller->FreeCommands;
501 Controller->FreeCommands = Command->Next;
502 Command->Next =
NULL;
512 static inline void DAC960_DeallocateCommand(DAC960_Command_T *Command)
514 DAC960_Controller_T *Controller = Command->Controller;
516 Command->Request =
NULL;
517 Command->Next = Controller->FreeCommands;
518 Controller->FreeCommands =
Command;
526 static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
528 spin_unlock_irq(&Controller->queue_lock);
529 __wait_event(Controller->CommandWaitQueue, Controller->FreeCommands);
530 spin_lock_irq(&Controller->queue_lock);
537 static void DAC960_GEM_QueueCommand(DAC960_Command_T *Command)
539 DAC960_Controller_T *Controller = Command->Controller;
540 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
543 Controller->V2.NextCommandMailbox;
545 CommandMailbox->
Common.CommandIdentifier = Command->CommandIdentifier;
546 DAC960_GEM_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
548 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
549 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
550 DAC960_GEM_MemoryMailboxNewCommand(ControllerBaseAddress);
552 Controller->V2.PreviousCommandMailbox2 =
553 Controller->V2.PreviousCommandMailbox1;
554 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
556 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
557 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
559 Controller->V2.NextCommandMailbox = NextCommandMailbox;
566 static void DAC960_BA_QueueCommand(DAC960_Command_T *Command)
568 DAC960_Controller_T *Controller = Command->Controller;
569 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
572 Controller->V2.NextCommandMailbox;
573 CommandMailbox->
Common.CommandIdentifier = Command->CommandIdentifier;
574 DAC960_BA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
575 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
576 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
577 DAC960_BA_MemoryMailboxNewCommand(ControllerBaseAddress);
578 Controller->V2.PreviousCommandMailbox2 =
579 Controller->V2.PreviousCommandMailbox1;
580 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
581 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
582 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
583 Controller->V2.NextCommandMailbox = NextCommandMailbox;
591 static void DAC960_LP_QueueCommand(DAC960_Command_T *Command)
593 DAC960_Controller_T *Controller = Command->Controller;
594 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
597 Controller->V2.NextCommandMailbox;
598 CommandMailbox->
Common.CommandIdentifier = Command->CommandIdentifier;
599 DAC960_LP_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
600 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
601 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
602 DAC960_LP_MemoryMailboxNewCommand(ControllerBaseAddress);
603 Controller->V2.PreviousCommandMailbox2 =
604 Controller->V2.PreviousCommandMailbox1;
605 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
606 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
607 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
608 Controller->V2.NextCommandMailbox = NextCommandMailbox;
617 static void DAC960_LA_QueueCommandDualMode(DAC960_Command_T *Command)
619 DAC960_Controller_T *Controller = Command->Controller;
620 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
623 Controller->V1.NextCommandMailbox;
625 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
626 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
627 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
628 DAC960_LA_MemoryMailboxNewCommand(ControllerBaseAddress);
629 Controller->V1.PreviousCommandMailbox2 =
630 Controller->V1.PreviousCommandMailbox1;
631 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
632 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
633 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
634 Controller->V1.NextCommandMailbox = NextCommandMailbox;
643 static void DAC960_LA_QueueCommandSingleMode(DAC960_Command_T *Command)
645 DAC960_Controller_T *Controller = Command->Controller;
646 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
649 Controller->V1.NextCommandMailbox;
651 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
652 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
653 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
654 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
655 Controller->V1.PreviousCommandMailbox2 =
656 Controller->V1.PreviousCommandMailbox1;
657 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
658 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
659 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
660 Controller->V1.NextCommandMailbox = NextCommandMailbox;
669 static void DAC960_PG_QueueCommandDualMode(DAC960_Command_T *Command)
671 DAC960_Controller_T *Controller = Command->Controller;
672 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
675 Controller->V1.NextCommandMailbox;
677 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
678 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
679 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
680 DAC960_PG_MemoryMailboxNewCommand(ControllerBaseAddress);
681 Controller->V1.PreviousCommandMailbox2 =
682 Controller->V1.PreviousCommandMailbox1;
683 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
684 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
685 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
686 Controller->V1.NextCommandMailbox = NextCommandMailbox;
695 static void DAC960_PG_QueueCommandSingleMode(DAC960_Command_T *Command)
697 DAC960_Controller_T *Controller = Command->Controller;
698 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
701 Controller->V1.NextCommandMailbox;
703 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
704 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
705 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
706 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
707 Controller->V1.PreviousCommandMailbox2 =
708 Controller->V1.PreviousCommandMailbox1;
709 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
710 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
711 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
712 Controller->V1.NextCommandMailbox = NextCommandMailbox;
720 static void DAC960_PD_QueueCommand(DAC960_Command_T *Command)
722 DAC960_Controller_T *Controller = Command->Controller;
723 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
726 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
728 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
729 DAC960_PD_NewCommand(ControllerBaseAddress);
737 static void DAC960_P_QueueCommand(DAC960_Command_T *Command)
739 DAC960_Controller_T *Controller = Command->Controller;
740 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
753 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
757 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
762 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
767 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
772 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
774 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
775 DAC960_PD_NewCommand(ControllerBaseAddress);
783 static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
785 DAC960_Controller_T *Controller = Command->Controller;
788 Command->Completion = &Completion;
791 DAC960_QueueCommand(Command);
792 spin_unlock_irqrestore(&Controller->queue_lock, flags);
806 static bool DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
810 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
813 DAC960_V1_ClearCommand(Command);
814 Command->CommandType = DAC960_ImmediateCommand;
817 DAC960_ExecuteCommand(Command);
818 CommandStatus = Command->V1.CommandStatus;
819 DAC960_DeallocateCommand(Command);
830 static bool DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
831 DAC960_V1_CommandOpcode_T CommandOpcode,
835 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
838 DAC960_V1_ClearCommand(Command);
839 Command->CommandType = DAC960_ImmediateCommand;
843 DAC960_ExecuteCommand(Command);
844 CommandStatus = Command->V1.CommandStatus;
845 DAC960_DeallocateCommand(Command);
856 static bool DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
857 DAC960_V1_CommandOpcode_T CommandOpcode,
862 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
865 DAC960_V1_ClearCommand(Command);
866 Command->CommandType = DAC960_ImmediateCommand;
871 DAC960_ExecuteCommand(Command);
872 CommandStatus = Command->V1.CommandStatus;
873 DAC960_DeallocateCommand(Command);
886 static bool DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
888 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
891 DAC960_V2_ClearCommand(Command);
892 Command->CommandType = DAC960_ImmediateCommand;
894 CommandMailbox->
Common.CommandControlBits
895 .DataTransferControllerToHost =
true;
896 CommandMailbox->
Common.CommandControlBits
897 .NoAutoRequestSense =
true;
900 CommandMailbox->
Common.DataTransferMemoryAddress
901 .ScatterGatherSegments[0]
902 .SegmentDataPointer =
903 Controller->V2.HealthStatusBufferDMA;
904 CommandMailbox->
Common.DataTransferMemoryAddress
905 .ScatterGatherSegments[0]
907 CommandMailbox->
Common.DataTransferSize;
908 DAC960_ExecuteCommand(Command);
909 CommandStatus = Command->V2.CommandStatus;
910 DAC960_DeallocateCommand(Command);
924 static bool DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
926 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
929 DAC960_V2_ClearCommand(Command);
930 Command->CommandType = DAC960_ImmediateCommand;
933 .DataTransferControllerToHost =
true;
935 .NoAutoRequestSense =
true;
940 .ScatterGatherSegments[0]
941 .SegmentDataPointer =
942 Controller->V2.NewControllerInformationDMA;
944 .ScatterGatherSegments[0]
947 DAC960_ExecuteCommand(Command);
948 CommandStatus = Command->V2.CommandStatus;
949 DAC960_DeallocateCommand(Command);
962 static bool DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
965 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
969 DAC960_V2_ClearCommand(Command);
970 Command->CommandType = DAC960_ImmediateCommand;
974 .DataTransferControllerToHost =
true;
976 .NoAutoRequestSense =
true;
983 .ScatterGatherSegments[0]
984 .SegmentDataPointer =
985 Controller->V2.NewLogicalDeviceInformationDMA;
987 .ScatterGatherSegments[0]
990 DAC960_ExecuteCommand(Command);
991 CommandStatus = Command->V2.CommandStatus;
992 DAC960_DeallocateCommand(Command);
1013 static bool DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
1014 unsigned char Channel,
1015 unsigned char TargetID,
1018 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
1022 DAC960_V2_ClearCommand(Command);
1023 Command->CommandType = DAC960_ImmediateCommand;
1026 .DataTransferControllerToHost =
true;
1028 .NoAutoRequestSense =
true;
1037 .ScatterGatherSegments[0]
1038 .SegmentDataPointer =
1039 Controller->V2.NewPhysicalDeviceInformationDMA;
1041 .ScatterGatherSegments[0]
1044 DAC960_ExecuteCommand(Command);
1045 CommandStatus = Command->V2.CommandStatus;
1046 DAC960_DeallocateCommand(Command);
1051 static void DAC960_V2_ConstructNewUnitSerialNumber(
1052 DAC960_Controller_T *Controller,
1057 CommandMailbox->
SCSI_10.CommandControlBits
1058 .DataTransferControllerToHost =
true;
1059 CommandMailbox->
SCSI_10.CommandControlBits
1060 .NoAutoRequestSense =
true;
1061 CommandMailbox->
SCSI_10.DataTransferSize =
1066 CommandMailbox->
SCSI_10.CDBLength = 6;
1067 CommandMailbox->
SCSI_10.SCSI_CDB[0] = 0x12;
1068 CommandMailbox->
SCSI_10.SCSI_CDB[1] = 1;
1069 CommandMailbox->
SCSI_10.SCSI_CDB[2] = 0x80;
1070 CommandMailbox->
SCSI_10.SCSI_CDB[3] = 0;
1071 CommandMailbox->
SCSI_10.SCSI_CDB[4] =
1073 CommandMailbox->
SCSI_10.SCSI_CDB[5] = 0;
1074 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
1075 .ScatterGatherSegments[0]
1076 .SegmentDataPointer =
1077 Controller->V2.NewInquiryUnitSerialNumberDMA;
1078 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
1079 .ScatterGatherSegments[0]
1081 CommandMailbox->
SCSI_10.DataTransferSize;
1098 static bool DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
1099 int Channel,
int TargetID,
int LogicalUnit)
1105 Command = DAC960_AllocateCommand(Controller);
1106 CommandMailbox = &Command->V2.CommandMailbox;
1107 DAC960_V2_ClearCommand(Command);
1108 Command->CommandType = DAC960_ImmediateCommand;
1110 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
1111 Channel, TargetID, LogicalUnit);
1113 DAC960_ExecuteCommand(Command);
1114 CommandStatus = Command->V2.CommandStatus;
1115 DAC960_DeallocateCommand(Command);
1126 static bool DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1127 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
1128 DAC960_V2_OperationDevice_T
1131 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
1134 DAC960_V2_ClearCommand(Command);
1135 Command->CommandType = DAC960_ImmediateCommand;
1138 .DataTransferControllerToHost =
true;
1140 .NoAutoRequestSense =
true;
1143 DAC960_ExecuteCommand(Command);
1144 CommandStatus = Command->V2.CommandStatus;
1145 DAC960_DeallocateCommand(Command);
1158 static bool DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1161 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
1162 DAC960_HardwareType_T
hw_type = Controller->HardwareType;
1163 struct pci_dev *PCI_Device = Controller->PCIDevice;
1164 struct dma_loaf *DmaPages = &Controller->DmaPages;
1165 size_t DmaPagesSize;
1166 size_t CommandMailboxesSize;
1167 size_t StatusMailboxesSize;
1172 DAC960_V1_StatusMailbox_T *StatusMailboxesMemory;
1182 if (pci_set_dma_mask(Controller->PCIDevice,
DMA_BIT_MASK(32)))
1183 return DAC960_Failure(Controller,
"DMA mask out of range");
1186 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller)) {
1187 CommandMailboxesSize = 0;
1188 StatusMailboxesSize = 0;
1191 StatusMailboxesSize = DAC960_V1_StatusMailboxCount *
sizeof(DAC960_V1_StatusMailbox_T);
1193 DmaPagesSize = CommandMailboxesSize + StatusMailboxesSize +
1202 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize))
1206 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1207 goto skip_mailboxes;
1209 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1210 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1213 Controller->V1.FirstCommandMailbox = CommandMailboxesMemory;
1214 Controller->V1.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1216 CommandMailboxesMemory += DAC960_V1_CommandMailboxCount - 1;
1217 Controller->V1.LastCommandMailbox = CommandMailboxesMemory;
1218 Controller->V1.NextCommandMailbox = Controller->V1.FirstCommandMailbox;
1219 Controller->V1.PreviousCommandMailbox1 = Controller->V1.LastCommandMailbox;
1220 Controller->V1.PreviousCommandMailbox2 =
1221 Controller->V1.LastCommandMailbox - 1;
1224 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1225 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1227 Controller->V1.FirstStatusMailbox = StatusMailboxesMemory;
1228 Controller->V1.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1229 StatusMailboxesMemory += DAC960_V1_StatusMailboxCount - 1;
1230 Controller->V1.LastStatusMailbox = StatusMailboxesMemory;
1231 Controller->V1.NextStatusMailbox = Controller->V1.FirstStatusMailbox;
1234 Controller->V1.MonitoringDCDB = slice_dma_loaf(DmaPages,
1236 &Controller->V1.MonitoringDCDB_DMA);
1238 Controller->V1.NewEnquiry = slice_dma_loaf(DmaPages,
1239 sizeof(DAC960_V1_Enquiry_T),
1240 &Controller->V1.NewEnquiryDMA);
1242 Controller->V1.NewErrorTable = slice_dma_loaf(DmaPages,
1244 &Controller->V1.NewErrorTableDMA);
1246 Controller->V1.EventLogEntry = slice_dma_loaf(DmaPages,
1248 &Controller->V1.EventLogEntryDMA);
1250 Controller->V1.RebuildProgress = slice_dma_loaf(DmaPages,
1252 &Controller->V1.RebuildProgressDMA);
1254 Controller->V1.NewLogicalDriveInformation = slice_dma_loaf(DmaPages,
1256 &Controller->V1.NewLogicalDriveInformationDMA);
1258 Controller->V1.BackgroundInitializationStatus = slice_dma_loaf(DmaPages,
1260 &Controller->V1.BackgroundInitializationStatusDMA);
1262 Controller->V1.NewDeviceState = slice_dma_loaf(DmaPages,
1264 &Controller->V1.NewDeviceStateDMA);
1266 Controller->V1.NewInquiryStandardData = slice_dma_loaf(DmaPages,
1268 &Controller->V1.NewInquiryStandardDataDMA);
1270 Controller->V1.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1272 &Controller->V1.NewInquiryUnitSerialNumberDMA);
1274 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1278 Controller->V1.DualModeMemoryMailboxInterface =
true;
1283 Controller->V1.FirstCommandMailboxDMA;
1285 Controller->V1.FirstStatusMailboxDMA;
1286 #define TIMEOUT_COUNT 1000000
1288 for (i = 0; i < 2; i++)
1289 switch (Controller->HardwareType)
1291 case DAC960_LA_Controller:
1293 while (--TimeoutCounter >= 0)
1295 if (!DAC960_LA_HardwareMailboxFullP(ControllerBaseAddress))
1299 if (TimeoutCounter < 0)
return false;
1300 DAC960_LA_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1301 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
1303 while (--TimeoutCounter >= 0)
1305 if (DAC960_LA_HardwareMailboxStatusAvailableP(
1306 ControllerBaseAddress))
1310 if (TimeoutCounter < 0)
return false;
1311 CommandStatus = DAC960_LA_ReadStatusRegister(ControllerBaseAddress);
1312 DAC960_LA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1313 DAC960_LA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1315 Controller->V1.DualModeMemoryMailboxInterface =
false;
1318 case DAC960_PG_Controller:
1320 while (--TimeoutCounter >= 0)
1322 if (!DAC960_PG_HardwareMailboxFullP(ControllerBaseAddress))
1326 if (TimeoutCounter < 0)
return false;
1327 DAC960_PG_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1328 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
1331 while (--TimeoutCounter >= 0)
1333 if (DAC960_PG_HardwareMailboxStatusAvailableP(
1334 ControllerBaseAddress))
1338 if (TimeoutCounter < 0)
return false;
1339 CommandStatus = DAC960_PG_ReadStatusRegister(ControllerBaseAddress);
1340 DAC960_PG_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1341 DAC960_PG_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1343 Controller->V1.DualModeMemoryMailboxInterface =
false;
1347 DAC960_Failure(Controller,
"Unknown Controller Type\n");
1365 static bool DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1368 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
1369 struct pci_dev *PCI_Device = Controller->PCIDevice;
1370 struct dma_loaf *DmaPages = &Controller->DmaPages;
1371 size_t DmaPagesSize;
1372 size_t CommandMailboxesSize;
1373 size_t StatusMailboxesSize;
1378 DAC960_V2_StatusMailbox_T *StatusMailboxesMemory;
1385 if (!pci_set_dma_mask(Controller->PCIDevice,
DMA_BIT_MASK(64)))
1387 else if (!pci_set_dma_mask(Controller->PCIDevice,
DMA_BIT_MASK(32)))
1390 return DAC960_Failure(Controller,
"DMA mask out of range");
1395 if (CommandMailbox ==
NULL)
1399 StatusMailboxesSize = DAC960_V2_StatusMailboxCount *
sizeof(DAC960_V2_StatusMailbox_T);
1401 CommandMailboxesSize + StatusMailboxesSize +
1410 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize)) {
1412 CommandMailbox, CommandMailboxDMA);
1416 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1417 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1420 Controller->V2.FirstCommandMailbox = CommandMailboxesMemory;
1421 Controller->V2.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1423 CommandMailboxesMemory += DAC960_V2_CommandMailboxCount - 1;
1424 Controller->V2.LastCommandMailbox = CommandMailboxesMemory;
1425 Controller->V2.NextCommandMailbox = Controller->V2.FirstCommandMailbox;
1426 Controller->V2.PreviousCommandMailbox1 = Controller->V2.LastCommandMailbox;
1427 Controller->V2.PreviousCommandMailbox2 =
1428 Controller->V2.LastCommandMailbox - 1;
1431 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1432 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1434 Controller->V2.FirstStatusMailbox = StatusMailboxesMemory;
1435 Controller->V2.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1436 StatusMailboxesMemory += DAC960_V2_StatusMailboxCount - 1;
1437 Controller->V2.LastStatusMailbox = StatusMailboxesMemory;
1438 Controller->V2.NextStatusMailbox = Controller->V2.FirstStatusMailbox;
1440 Controller->V2.HealthStatusBuffer = slice_dma_loaf(DmaPages,
1442 &Controller->V2.HealthStatusBufferDMA);
1444 Controller->V2.NewControllerInformation = slice_dma_loaf(DmaPages,
1446 &Controller->V2.NewControllerInformationDMA);
1448 Controller->V2.NewLogicalDeviceInformation = slice_dma_loaf(DmaPages,
1450 &Controller->V2.NewLogicalDeviceInformationDMA);
1452 Controller->V2.NewPhysicalDeviceInformation = slice_dma_loaf(DmaPages,
1454 &Controller->V2.NewPhysicalDeviceInformationDMA);
1456 Controller->V2.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1458 &Controller->V2.NewInquiryUnitSerialNumberDMA);
1460 Controller->V2.Event = slice_dma_loaf(DmaPages,
1462 &Controller->V2.EventDMA);
1464 Controller->V2.PhysicalToLogicalDevice = slice_dma_loaf(DmaPages,
1466 &Controller->V2.PhysicalToLogicalDeviceDMA);
1478 CommandMailbox->
SetMemoryMailbox.CommandControlBits.NoAutoRequestSense =
true;
1482 (DAC960_V2_StatusMailboxCount *
sizeof(DAC960_V2_StatusMailbox_T)) >> 10;
1489 Controller->V2.HealthStatusBufferDMA;
1491 Controller->V2.FirstCommandMailboxDMA;
1493 Controller->V2.FirstStatusMailboxDMA;
1494 switch (Controller->HardwareType)
1496 case DAC960_GEM_Controller:
1497 while (DAC960_GEM_HardwareMailboxFullP(ControllerBaseAddress))
1499 DAC960_GEM_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1500 DAC960_GEM_HardwareMailboxNewCommand(ControllerBaseAddress);
1501 while (!DAC960_GEM_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1503 CommandStatus = DAC960_GEM_ReadCommandStatus(ControllerBaseAddress);
1504 DAC960_GEM_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1505 DAC960_GEM_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1507 case DAC960_BA_Controller:
1508 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1510 DAC960_BA_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1511 DAC960_BA_HardwareMailboxNewCommand(ControllerBaseAddress);
1512 while (!DAC960_BA_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1514 CommandStatus = DAC960_BA_ReadCommandStatus(ControllerBaseAddress);
1515 DAC960_BA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1516 DAC960_BA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1518 case DAC960_LP_Controller:
1519 while (DAC960_LP_HardwareMailboxFullP(ControllerBaseAddress))
1521 DAC960_LP_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1522 DAC960_LP_HardwareMailboxNewCommand(ControllerBaseAddress);
1523 while (!DAC960_LP_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1525 CommandStatus = DAC960_LP_ReadCommandStatus(ControllerBaseAddress);
1526 DAC960_LP_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1527 DAC960_LP_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1530 DAC960_Failure(Controller,
"Unknown Controller Type\n");
1535 CommandMailbox, CommandMailboxDMA);
1545 static bool DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1555 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1557 return DAC960_Failure(Controller,
"LOGICAL DEVICE ALLOCATION");
1563 Controller->V1.NewEnquiryDMA)) {
1564 free_dma_loaf(Controller->PCIDevice, &local_dma);
1565 return DAC960_Failure(Controller,
"ENQUIRY");
1567 memcpy(&Controller->V1.Enquiry, Controller->V1.NewEnquiry,
1568 sizeof(DAC960_V1_Enquiry_T));
1571 free_dma_loaf(Controller->PCIDevice, &local_dma);
1572 return DAC960_Failure(Controller,
"ENQUIRY2");
1576 free_dma_loaf(Controller->PCIDevice, &local_dma);
1577 return DAC960_Failure(Controller,
"READ CONFIG2");
1581 Controller->V1.NewLogicalDriveInformationDMA)) {
1582 free_dma_loaf(Controller->PCIDevice, &local_dma);
1583 return DAC960_Failure(Controller,
"GET LOGICAL DRIVE INFORMATION");
1585 memcpy(&Controller->V1.LogicalDriveInformation,
1586 Controller->V1.NewLogicalDriveInformation,
1590 for (TargetID = 0; TargetID < Enquiry2->
MaxTargets; TargetID++) {
1593 Controller->V1.NewDeviceStateDMA)) {
1594 free_dma_loaf(Controller->PCIDevice, &local_dma);
1595 return DAC960_Failure(Controller,
"GET DEVICE STATE");
1597 memcpy(&Controller->V1.DeviceState[Channel][TargetID],
1607 strcpy(Controller->ModelName,
"DAC960PU");
1608 else strcpy(Controller->ModelName,
"DAC960PD");
1611 strcpy(Controller->ModelName,
"DAC960PL");
1614 strcpy(Controller->ModelName,
"DAC960PG");
1617 strcpy(Controller->ModelName,
"DAC960PJ");
1620 strcpy(Controller->ModelName,
"DAC960PR");
1623 strcpy(Controller->ModelName,
"DAC960PT");
1626 strcpy(Controller->ModelName,
"DAC960PTL0");
1629 strcpy(Controller->ModelName,
"DAC960PRL");
1632 strcpy(Controller->ModelName,
"DAC960PTL1");
1635 strcpy(Controller->ModelName,
"DAC1164P");
1638 free_dma_loaf(Controller->PCIDevice, &local_dma);
1639 return DAC960_Failure(Controller,
"MODEL VERIFICATION");
1641 strcpy(Controller->FullModelName,
"Mylex ");
1642 strcat(Controller->FullModelName, Controller->ModelName);
1652 #if defined(CONFIG_ALPHA)
1667 # define FIRMWARE_27X "2.70"
1669 # define FIRMWARE_27X "2.73"
1675 Controller->V1.Enquiry.MajorFirmwareVersion;
1677 Controller->V1.Enquiry.MinorFirmwareVersion;
1681 sprintf(Controller->FirmwareVersion,
"%d.%02d-%c-%02d",
1684 if (!((Controller->FirmwareVersion[0] ==
'5' &&
1685 strcmp(Controller->FirmwareVersion,
"5.06") >= 0) ||
1686 (Controller->FirmwareVersion[0] ==
'4' &&
1687 strcmp(Controller->FirmwareVersion,
"4.06") >= 0) ||
1688 (Controller->FirmwareVersion[0] ==
'3' &&
1689 strcmp(Controller->FirmwareVersion,
"3.51") >= 0) ||
1690 (Controller->FirmwareVersion[0] ==
'2' &&
1691 strcmp(Controller->FirmwareVersion, FIRMWARE_27X) >= 0)))
1693 DAC960_Failure(Controller,
"FIRMWARE VERSION VERIFICATION");
1694 DAC960_Error(
"Firmware Version = '%s'\n", Controller,
1695 Controller->FirmwareVersion);
1696 free_dma_loaf(Controller->PCIDevice, &local_dma);
1705 Controller->MemorySize = Enquiry2->
MemorySize >> 20;
1706 Controller->V1.SAFTE_EnclosureManagementEnabled =
1715 Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands;
1716 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1717 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1718 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1719 Controller->LogicalDriveCount =
1720 Controller->V1.Enquiry.NumberOfLogicalDrives;
1723 Controller->DriverScatterGatherLimit =
1724 Controller->ControllerScatterGatherLimit;
1725 if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit)
1726 Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit;
1731 >> (10 - DAC960_BlockSizeBits);
1733 >> (10 - DAC960_BlockSizeBits);
1734 switch (Config2->DriveGeometry)
1736 case DAC960_V1_Geometry_128_32:
1737 Controller->V1.GeometryTranslationHeads = 128;
1738 Controller->V1.GeometryTranslationSectors = 32;
1740 case DAC960_V1_Geometry_255_63:
1741 Controller->V1.GeometryTranslationHeads = 255;
1742 Controller->V1.GeometryTranslationSectors = 63;
1745 free_dma_loaf(Controller->PCIDevice, &local_dma);
1746 return DAC960_Failure(Controller,
"CONFIG2 DRIVE GEOMETRY");
1751 if ((Controller->FirmwareVersion[0] ==
'4' &&
1752 strcmp(Controller->FirmwareVersion,
"4.08") >= 0) ||
1753 (Controller->FirmwareVersion[0] ==
'5' &&
1754 strcmp(Controller->FirmwareVersion,
"5.08") >= 0))
1756 Controller->V1.BackgroundInitializationStatusSupported =
true;
1757 DAC960_V1_ExecuteType3B(Controller,
1760 V1.BackgroundInitializationStatusDMA);
1761 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
1762 Controller->V1.BackgroundInitializationStatus,
1768 for (LogicalDriveNumber = 0;
1769 LogicalDriveNumber < Controller->LogicalDriveCount;
1770 LogicalDriveNumber++)
1771 if (Controller->V1.LogicalDriveInformation
1772 [LogicalDriveNumber].LogicalDriveState !=
1776 free_dma_loaf(Controller->PCIDevice, &local_dma);
1786 static bool DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1790 &Controller->V2.ControllerInformation;
1791 unsigned short LogicalDeviceNumber = 0;
1792 int ModelNameLength;
1795 if (!DAC960_V2_NewControllerInfo(Controller))
1796 return DAC960_Failure(Controller,
"GET CONTROLLER INFO");
1797 memcpy(ControllerInfo, Controller->V2.NewControllerInformation,
1801 if (!DAC960_V2_GeneralInfo(Controller))
1802 return DAC960_Failure(Controller,
"GET HEALTH STATUS");
1808 if (ModelNameLength >
sizeof(Controller->ModelName)-1)
1809 ModelNameLength =
sizeof(Controller->ModelName)-1;
1813 while (Controller->ModelName[ModelNameLength] ==
' ' ||
1814 Controller->ModelName[ModelNameLength] ==
'\0')
1816 Controller->ModelName[++ModelNameLength] =
'\0';
1817 strcpy(Controller->FullModelName,
"Mylex ");
1818 strcat(Controller->FullModelName, Controller->ModelName);
1822 sprintf(Controller->FirmwareVersion,
"%d.%02d-%02d",
1830 DAC960_Info(
"FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n",
1831 Controller, Controller->FirmwareVersion);
1832 DAC960_Info(
"STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n",
1834 DAC960_Info(
"PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n",
1841 Controller->Targets =
1853 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1854 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1855 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1857 Controller->MaxBlocksPerCommand =
1859 Controller->ControllerScatterGatherLimit =
1861 Controller->DriverScatterGatherLimit =
1862 Controller->ControllerScatterGatherLimit;
1863 if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit)
1864 Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit;
1871 Controller->V2.NewLogicalDeviceInformation;
1873 DAC960_V2_PhysicalDevice_T PhysicalDevice;
1875 if (!DAC960_V2_NewLogicalDeviceInfo(Controller, LogicalDeviceNumber))
1878 if (LogicalDeviceNumber >= DAC960_MaxLogicalDrives) {
1879 DAC960_Error(
"DAC960: Logical Drive Number %d not supported\n",
1880 Controller, LogicalDeviceNumber);
1883 if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize) {
1884 DAC960_Error(
"DAC960: Logical Drive Block Size %d not supported\n",
1885 Controller, NewLogicalDeviceInfo->DeviceBlockSizeInBytes);
1886 LogicalDeviceNumber++;
1889 PhysicalDevice.Controller = 0;
1890 PhysicalDevice.Channel = NewLogicalDeviceInfo->
Channel;
1891 PhysicalDevice.TargetID = NewLogicalDeviceInfo->
TargetID;
1892 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->
LogicalUnit;
1900 if (LogicalDeviceInfo ==
NULL)
1901 return DAC960_Failure(Controller,
"LOGICAL DEVICE ALLOCATION");
1904 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
1906 LogicalDeviceNumber++;
1917 static bool DAC960_ReportControllerConfiguration(DAC960_Controller_T
1920 DAC960_Info(
"Configuring Mylex %s PCI RAID Controller\n",
1921 Controller, Controller->ModelName);
1922 DAC960_Info(
" Firmware Version: %s, Channels: %d, Memory Size: %dMB\n",
1923 Controller, Controller->FirmwareVersion,
1924 Controller->Channels, Controller->MemorySize);
1925 DAC960_Info(
" PCI Bus: %d, Device: %d, Function: %d, I/O Address: ",
1926 Controller, Controller->Bus,
1927 Controller->Device, Controller->Function);
1928 if (Controller->IO_Address == 0)
1929 DAC960_Info(
"Unassigned\n", Controller);
1930 else DAC960_Info(
"0x%X\n", Controller, Controller->IO_Address);
1931 DAC960_Info(
" PCI Address: 0x%X mapped at 0x%lX, IRQ Channel: %d\n",
1932 Controller, Controller->PCI_Address,
1933 (
unsigned long) Controller->BaseAddress,
1934 Controller->IRQ_Channel);
1935 DAC960_Info(
" Controller Queue Depth: %d, "
1936 "Maximum Blocks per Command: %d\n",
1937 Controller, Controller->ControllerQueueDepth,
1938 Controller->MaxBlocksPerCommand);
1939 DAC960_Info(
" Driver Queue Depth: %d, "
1940 "Scatter/Gather Limit: %d of %d Segments\n",
1941 Controller, Controller->DriverQueueDepth,
1942 Controller->DriverScatterGatherLimit,
1943 Controller->ControllerScatterGatherLimit);
1944 if (Controller->FirmwareType == DAC960_V1_Controller)
1946 DAC960_Info(
" Stripe Size: %dKB, Segment Size: %dKB, "
1947 "BIOS Geometry: %d/%d\n", Controller,
1948 Controller->V1.StripeSize,
1949 Controller->V1.SegmentSize,
1950 Controller->V1.GeometryTranslationHeads,
1951 Controller->V1.GeometryTranslationSectors);
1952 if (Controller->V1.SAFTE_EnclosureManagementEnabled)
1953 DAC960_Info(
" SAF-TE Enclosure Management Enabled\n", Controller);
1966 static bool DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
1981 unsigned long flags;
1984 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1988 return DAC960_Failure(Controller,
1989 "DMA ALLOCATION FAILED IN ReadDeviceConfiguration");
1991 for (Channel = 0; Channel < Controller->Channels; Channel++) {
1992 DCDBs_cpu[
Channel] = slice_dma_loaf(&local_dma,
1994 SCSI_Inquiry_cpu[
Channel] = slice_dma_loaf(&local_dma,
1996 SCSI_Inquiry_dma + Channel);
1997 SCSI_NewInquiryUnitSerialNumberCPU[
Channel] = slice_dma_loaf(&local_dma,
1999 SCSI_NewInquiryUnitSerialNumberDMA + Channel);
2002 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
2010 for (Channel = 0; Channel < Controller->Channels; Channel++)
2015 DAC960_Command_T *Command = Controller->Commands[
Channel];
2018 init_completion(Completion);
2019 DAC960_V1_ClearCommand(Command);
2020 Command->CommandType = DAC960_ImmediateCommand;
2021 Command->Completion = Completion;
2023 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_dma;
2026 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
2027 DCDB->EarlyStatus =
false;
2028 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
2029 DCDB->NoAutomaticRequestSense =
false;
2030 DCDB->DisconnectPermitted =
true;
2032 DCDB->BusAddress = NewInquiryStandardDataDMA;
2033 DCDB->CDBLength = 6;
2034 DCDB->TransferLengthHigh4 = 0;
2035 DCDB->SenseLength =
sizeof(DCDB->SenseData);
2036 DCDB->CDB[0] = 0x12;
2044 DAC960_QueueCommand(Command);
2045 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2052 for (Channel = 0; Channel < Controller->Channels; Channel++)
2058 SCSI_NewInquiryUnitSerialNumberDMA[
Channel];
2060 SCSI_NewInquiryUnitSerialNumberCPU[
Channel];
2063 DAC960_Command_T *Command = Controller->Commands[
Channel];
2077 Command->Completion = Completion;
2079 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
2080 DCDB->SenseLength =
sizeof(DCDB->SenseData);
2081 DCDB->CDB[0] = 0x12;
2083 DCDB->CDB[2] = 0x80;
2089 DAC960_QueueCommand(Command);
2090 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2094 memset(InquiryUnitSerialNumber, 0,
2098 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2102 free_dma_loaf(Controller->PCIDevice, &local_dma);
2114 static bool DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
2117 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
2118 unsigned short PhysicalDeviceIndex = 0;
2123 Controller->V2.NewPhysicalDeviceInformation;
2126 Controller->V2.NewInquiryUnitSerialNumber;
2129 if (!DAC960_V2_NewPhysicalDeviceInfo(Controller, Channel, TargetID, LogicalUnit))
2134 if (PhysicalDeviceInfo ==
NULL)
2135 return DAC960_Failure(Controller,
"PHYSICAL DEVICE ALLOCATION");
2136 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] =
2138 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
2141 InquiryUnitSerialNumber =
kmalloc(
2143 if (InquiryUnitSerialNumber ==
NULL) {
2144 kfree(PhysicalDeviceInfo);
2145 return DAC960_Failure(Controller,
"SERIAL NUMBER ALLOCATION");
2147 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex] =
2148 InquiryUnitSerialNumber;
2150 Channel = NewPhysicalDeviceInfo->
Channel;
2151 TargetID = NewPhysicalDeviceInfo->
TargetID;
2160 if (!DAC960_V2_NewInquiryUnitSerialNumber(Controller, Channel, TargetID, LogicalUnit)) {
2161 memset(InquiryUnitSerialNumber, 0,
2165 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2168 PhysicalDeviceIndex++;
2182 *InquiryStandardData,
2184 *InquiryUnitSerialNumber,
2185 unsigned char *Vendor,
2186 unsigned char *Model,
2188 unsigned char *SerialNumber)
2190 int SerialNumberLength,
i;
2194 unsigned char VendorCharacter =
2196 Vendor[
i] = (VendorCharacter >=
' ' && VendorCharacter <=
'~'
2197 ? VendorCharacter :
' ');
2202 unsigned char ModelCharacter =
2204 Model[
i] = (ModelCharacter >=
' ' && ModelCharacter <=
'~'
2205 ? ModelCharacter :
' ');
2210 unsigned char RevisionCharacter =
2212 Revision[
i] = (RevisionCharacter >=
' ' && RevisionCharacter <=
'~'
2213 ? RevisionCharacter :
' ');
2217 SerialNumberLength = InquiryUnitSerialNumber->
PageLength;
2218 if (SerialNumberLength >
2221 for (i = 0; i < SerialNumberLength; i++)
2223 unsigned char SerialNumberCharacter =
2226 (SerialNumberCharacter >=
' ' && SerialNumberCharacter <=
'~'
2227 ? SerialNumberCharacter :
' ');
2229 SerialNumber[SerialNumberLength] =
'\0';
2238 static bool DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2242 DAC960_Info(
" Physical Devices:\n", Controller);
2243 for (Channel = 0; Channel < Controller->Channels; Channel++)
2244 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
2257 char SerialNumber[1+
sizeof(InquiryUnitSerialNumber
2260 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2261 Vendor, Model, Revision, SerialNumber);
2262 DAC960_Info(
" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2263 Controller, Channel, TargetID, (TargetID < 10 ?
" " :
""),
2264 Vendor, Model, Revision);
2266 DAC960_Info(
" Serial Number: %s\n", Controller, SerialNumber);
2270 if (Controller->V1.DeviceResetCount[Channel][TargetID] > 0)
2271 DAC960_Info(
" Disk Status: %s, %u blocks, %d resets\n",
2275 : DeviceState->DeviceState
2278 : DeviceState->DeviceState
2280 ?
"Online" :
"Standby"),
2281 DeviceState->DiskSize,
2282 Controller->V1.DeviceResetCount[Channel][TargetID]);
2284 DAC960_Info(
" Disk Status: %s, %u blocks\n", Controller,
2287 : DeviceState->DeviceState
2290 : DeviceState->DeviceState
2292 ?
"Online" :
"Standby"),
2293 DeviceState->DiskSize);
2299 DAC960_Info(
" Errors - Parity: %d, Soft: %d, "
2300 "Hard: %d, Misc: %d\n", Controller,
2306 DAC960_Info(
" Logical Drives:\n", Controller);
2307 for (LogicalDriveNumber = 0;
2308 LogicalDriveNumber < Controller->LogicalDriveCount;
2309 LogicalDriveNumber++)
2313 DAC960_Info(
" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks, %s\n",
2314 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2321 ?
"Critical" :
"Offline"),
2324 ?
"Write Back" :
"Write Thru"));
2335 static bool DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2339 DAC960_Info(
" Physical Devices:\n", Controller);
2340 for (PhysicalDeviceIndex = 0;
2342 PhysicalDeviceIndex++)
2345 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
2349 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
2354 if (PhysicalDeviceInfo ==
NULL)
break;
2355 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2356 Vendor, Model, Revision, SerialNumber);
2357 DAC960_Info(
" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2361 (PhysicalDeviceInfo->
TargetID < 10 ?
" " :
""),
2362 Vendor, Model, Revision);
2364 DAC960_Info(
" %sAsynchronous\n", Controller,
2368 DAC960_Info(
" %sSynchronous at %d MB/sec\n", Controller,
2374 DAC960_Info(
" Serial Number: %s\n", Controller, SerialNumber);
2378 DAC960_Info(
" Disk Status: %s, %u blocks\n", Controller,
2399 ?
"Commanded-Offline"
2402 ?
"Standby" :
"Unknown"),
2409 PhysicalDeviceInfo->
Retries == 0 &&
2410 PhysicalDeviceInfo->
Aborts == 0 &&
2413 DAC960_Info(
" Errors - Parity: %d, Soft: %d, "
2414 "Hard: %d, Misc: %d\n", Controller,
2419 DAC960_Info(
" Timeouts: %d, Retries: %d, "
2420 "Aborts: %d, Predicted: %d\n", Controller,
2423 PhysicalDeviceInfo->
Aborts,
2426 DAC960_Info(
" Logical Drives:\n", Controller);
2427 for (LogicalDriveNumber = 0;
2429 LogicalDriveNumber++)
2433 unsigned char *ReadCacheStatus[] = {
"Read Cache Disabled",
2434 "Read Cache Enabled",
2435 "Read Ahead Enabled",
2436 "Intelligent Read Ahead Enabled",
2437 "-",
"-",
"-",
"-" };
2438 unsigned char *WriteCacheStatus[] = {
"Write Cache Disabled",
2439 "Logical Device Read Only",
2440 "Write Cache Enabled",
2441 "Intelligent Write Cache Enabled",
2442 "-",
"-",
"-",
"-" };
2443 unsigned char *GeometryTranslation;
2444 if (LogicalDeviceInfo ==
NULL)
continue;
2445 switch (LogicalDeviceInfo->DriveGeometry)
2447 case DAC960_V2_Geometry_128_32:
2448 GeometryTranslation =
"128/32";
2450 case DAC960_V2_Geometry_255_63:
2451 GeometryTranslation =
"255/63";
2454 GeometryTranslation =
"Invalid";
2455 DAC960_Error(
"Illegal Logical Device Geometry %d\n",
2456 Controller, LogicalDeviceInfo->DriveGeometry);
2459 DAC960_Info(
" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks\n",
2460 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2467 ?
"Critical" :
"Offline"),
2468 LogicalDeviceInfo->ConfigurableDeviceSize);
2469 DAC960_Info(
" Logical Device %s, BIOS Geometry: %s\n",
2472 .LogicalDeviceInitialized
2473 ?
"Initialized" :
"Uninitialized"),
2474 GeometryTranslation);
2478 DAC960_Info(
" Stripe Size: N/A, "
2479 "Segment Size: N/A\n", Controller);
2481 DAC960_Info(
" Stripe Size: N/A, "
2482 "Segment Size: %dKB\n", Controller,
2488 DAC960_Info(
" Stripe Size: %dKB, "
2489 "Segment Size: N/A\n", Controller,
2492 DAC960_Info(
" Stripe Size: %dKB, "
2493 "Segment Size: %dKB\n", Controller,
2497 DAC960_Info(
" %s, %s\n", Controller,
2502 if (LogicalDeviceInfo->SoftErrors > 0 ||
2503 LogicalDeviceInfo->CommandsFailed > 0 ||
2504 LogicalDeviceInfo->DeferredWriteErrors)
2505 DAC960_Info(
" Errors - Soft: %d, Failed: %d, "
2506 "Deferred Write: %d\n", Controller,
2507 LogicalDeviceInfo->SoftErrors,
2508 LogicalDeviceInfo->CommandsFailed,
2509 LogicalDeviceInfo->DeferredWriteErrors);
2520 static bool DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2522 int MajorNumber =
DAC960_MAJOR + Controller->ControllerNumber;
2532 struct gendisk *disk = Controller->disks[
n];
2536 RequestQueue =
blk_init_queue(DAC960_RequestFunction,&Controller->queue_lock);
2537 if (!RequestQueue) {
2538 printk(
"DAC960: failure to allocate request queue\n");
2541 Controller->RequestQueue[
n] = RequestQueue;
2546 disk->queue = RequestQueue;
2547 sprintf(disk->disk_name,
"rd/c%dd%d", Controller->ControllerNumber, n);
2548 disk->major = MajorNumber;
2549 disk->first_minor = n << DAC960_MaxPartitionsBits;
2550 disk->fops = &DAC960_BlockDeviceOperations;
2564 static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
2566 int MajorNumber =
DAC960_MAJOR + Controller->ControllerNumber;
2573 Controller->RequestQueue[disk] =
NULL;
2587 static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
2591 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
2600 static bool DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
2601 unsigned char ErrorStatus,
2602 unsigned char Parameter0,
2603 unsigned char Parameter1)
2605 switch (ErrorStatus)
2608 DAC960_Notice(
"Physical Device %d:%d Not Responding\n",
2609 Controller, Parameter1, Parameter0);
2612 if (Controller->DriveSpinUpMessageDisplayed)
break;
2613 DAC960_Notice(
"Spinning Up Drives\n", Controller);
2614 Controller->DriveSpinUpMessageDisplayed =
true;
2617 DAC960_Notice(
"Configuration Checksum Error\n", Controller);
2620 DAC960_Notice(
"Mirror Race Recovery Failed\n", Controller);
2623 DAC960_Notice(
"Mirror Race Recovery In Progress\n", Controller);
2626 DAC960_Notice(
"Physical Device %d:%d COD Mismatch\n",
2627 Controller, Parameter1, Parameter0);
2630 DAC960_Notice(
"Logical Drive Installation Aborted\n", Controller);
2633 DAC960_Notice(
"Mirror Race On A Critical Logical Drive\n", Controller);
2636 DAC960_Notice(
"New Controller Configuration Found\n", Controller);
2639 DAC960_Error(
"Fatal Memory Parity Error for Controller at\n", Controller);
2642 DAC960_Error(
"Unknown Initialization Error %02X for Controller at\n",
2643 Controller, ErrorStatus);
2659 static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2664 free_dma_loaf(Controller->PCIDevice, &Controller->DmaPages);
2665 if (Controller->MemoryMappedAddress) {
2666 switch(Controller->HardwareType)
2668 case DAC960_GEM_Controller:
2669 DAC960_GEM_DisableInterrupts(Controller->BaseAddress);
2671 case DAC960_BA_Controller:
2672 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2674 case DAC960_LP_Controller:
2675 DAC960_LP_DisableInterrupts(Controller->BaseAddress);
2677 case DAC960_LA_Controller:
2678 DAC960_LA_DisableInterrupts(Controller->BaseAddress);
2680 case DAC960_PG_Controller:
2681 DAC960_PG_DisableInterrupts(Controller->BaseAddress);
2683 case DAC960_PD_Controller:
2684 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2686 case DAC960_P_Controller:
2687 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2690 iounmap(Controller->MemoryMappedAddress);
2692 if (Controller->IRQ_Channel)
2693 free_irq(Controller->IRQ_Channel, Controller);
2694 if (Controller->IO_Address)
2699 DAC960_Controllers[Controller->ControllerNumber] =
NULL;
2710 static DAC960_Controller_T *
2711 DAC960_DetectController(
struct pci_dev *PCI_Device,
2714 struct DAC960_privdata *privdata =
2716 irq_handler_t InterruptHandler = privdata->InterruptHandler;
2717 unsigned int MemoryWindowSize = privdata->MemoryWindowSize;
2718 DAC960_Controller_T *Controller =
NULL;
2719 unsigned char DeviceFunction = PCI_Device->
devfn;
2720 unsigned char ErrorStatus, Parameter0, Parameter1;
2721 unsigned int IRQ_Channel;
2725 Controller = kzalloc(
sizeof(DAC960_Controller_T),
GFP_ATOMIC);
2726 if (Controller ==
NULL) {
2727 DAC960_Error(
"Unable to allocate Controller structure for "
2728 "Controller at\n",
NULL);
2731 Controller->ControllerNumber = DAC960_ControllerCount;
2732 DAC960_Controllers[DAC960_ControllerCount++] =
Controller;
2733 Controller->Bus = PCI_Device->
bus->number;
2734 Controller->FirmwareType = privdata->FirmwareType;
2735 Controller->HardwareType = privdata->HardwareType;
2736 Controller->Device = DeviceFunction >> 3;
2737 Controller->Function = DeviceFunction & 0x7;
2738 Controller->PCIDevice = PCI_Device;
2739 strcpy(Controller->FullModelName,
"DAC960");
2744 switch (Controller->HardwareType)
2746 case DAC960_GEM_Controller:
2749 case DAC960_BA_Controller:
2752 case DAC960_LP_Controller:
2755 case DAC960_LA_Controller:
2758 case DAC960_PG_Controller:
2761 case DAC960_PD_Controller:
2765 case DAC960_P_Controller:
2771 pci_set_drvdata(PCI_Device, (
void *)((
long)Controller->ControllerNumber));
2773 Controller->disks[
i] =
alloc_disk(1<<DAC960_MaxPartitionsBits);
2774 if (!Controller->disks[i])
2776 Controller->disks[
i]->private_data = (
void *)((
long)
i);
2781 DAC960_AnnounceDriver(Controller);
2787 Controller->MemoryMappedAddress =
2789 Controller->BaseAddress =
2790 Controller->MemoryMappedAddress + (Controller->PCI_Address & ~
PAGE_MASK);
2791 if (Controller->MemoryMappedAddress ==
NULL)
2793 DAC960_Error(
"Unable to map Controller Register Window for "
2794 "Controller at\n", Controller);
2797 BaseAddress = Controller->BaseAddress;
2798 switch (Controller->HardwareType)
2800 case DAC960_GEM_Controller:
2801 DAC960_GEM_DisableInterrupts(BaseAddress);
2802 DAC960_GEM_AcknowledgeHardwareMailboxStatus(BaseAddress);
2804 while (DAC960_GEM_InitializationInProgressP(BaseAddress))
2806 if (DAC960_GEM_ReadErrorStatus(BaseAddress, &ErrorStatus,
2807 &Parameter0, &Parameter1) &&
2808 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2809 Parameter0, Parameter1))
2813 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2815 DAC960_Error(
"Unable to Enable Memory Mailbox Interface "
2816 "for Controller at\n", Controller);
2819 DAC960_GEM_EnableInterrupts(BaseAddress);
2820 Controller->QueueCommand = DAC960_GEM_QueueCommand;
2821 Controller->ReadControllerConfiguration =
2822 DAC960_V2_ReadControllerConfiguration;
2823 Controller->ReadDeviceConfiguration =
2824 DAC960_V2_ReadDeviceConfiguration;
2825 Controller->ReportDeviceConfiguration =
2826 DAC960_V2_ReportDeviceConfiguration;
2827 Controller->QueueReadWriteCommand =
2828 DAC960_V2_QueueReadWriteCommand;
2830 case DAC960_BA_Controller:
2831 DAC960_BA_DisableInterrupts(BaseAddress);
2832 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2834 while (DAC960_BA_InitializationInProgressP(BaseAddress))
2836 if (DAC960_BA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2837 &Parameter0, &Parameter1) &&
2838 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2839 Parameter0, Parameter1))
2843 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2845 DAC960_Error(
"Unable to Enable Memory Mailbox Interface "
2846 "for Controller at\n", Controller);
2849 DAC960_BA_EnableInterrupts(BaseAddress);
2850 Controller->QueueCommand = DAC960_BA_QueueCommand;
2851 Controller->ReadControllerConfiguration =
2852 DAC960_V2_ReadControllerConfiguration;
2853 Controller->ReadDeviceConfiguration =
2854 DAC960_V2_ReadDeviceConfiguration;
2855 Controller->ReportDeviceConfiguration =
2856 DAC960_V2_ReportDeviceConfiguration;
2857 Controller->QueueReadWriteCommand =
2858 DAC960_V2_QueueReadWriteCommand;
2860 case DAC960_LP_Controller:
2861 DAC960_LP_DisableInterrupts(BaseAddress);
2862 DAC960_LP_AcknowledgeHardwareMailboxStatus(BaseAddress);
2864 while (DAC960_LP_InitializationInProgressP(BaseAddress))
2866 if (DAC960_LP_ReadErrorStatus(BaseAddress, &ErrorStatus,
2867 &Parameter0, &Parameter1) &&
2868 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2869 Parameter0, Parameter1))
2873 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2875 DAC960_Error(
"Unable to Enable Memory Mailbox Interface "
2876 "for Controller at\n", Controller);
2879 DAC960_LP_EnableInterrupts(BaseAddress);
2880 Controller->QueueCommand = DAC960_LP_QueueCommand;
2881 Controller->ReadControllerConfiguration =
2882 DAC960_V2_ReadControllerConfiguration;
2883 Controller->ReadDeviceConfiguration =
2884 DAC960_V2_ReadDeviceConfiguration;
2885 Controller->ReportDeviceConfiguration =
2886 DAC960_V2_ReportDeviceConfiguration;
2887 Controller->QueueReadWriteCommand =
2888 DAC960_V2_QueueReadWriteCommand;
2890 case DAC960_LA_Controller:
2891 DAC960_LA_DisableInterrupts(BaseAddress);
2892 DAC960_LA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2894 while (DAC960_LA_InitializationInProgressP(BaseAddress))
2896 if (DAC960_LA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2897 &Parameter0, &Parameter1) &&
2898 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2899 Parameter0, Parameter1))
2903 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2905 DAC960_Error(
"Unable to Enable Memory Mailbox Interface "
2906 "for Controller at\n", Controller);
2909 DAC960_LA_EnableInterrupts(BaseAddress);
2910 if (Controller->V1.DualModeMemoryMailboxInterface)
2911 Controller->QueueCommand = DAC960_LA_QueueCommandDualMode;
2912 else Controller->QueueCommand = DAC960_LA_QueueCommandSingleMode;
2913 Controller->ReadControllerConfiguration =
2914 DAC960_V1_ReadControllerConfiguration;
2915 Controller->ReadDeviceConfiguration =
2916 DAC960_V1_ReadDeviceConfiguration;
2917 Controller->ReportDeviceConfiguration =
2918 DAC960_V1_ReportDeviceConfiguration;
2919 Controller->QueueReadWriteCommand =
2920 DAC960_V1_QueueReadWriteCommand;
2922 case DAC960_PG_Controller:
2923 DAC960_PG_DisableInterrupts(BaseAddress);
2924 DAC960_PG_AcknowledgeHardwareMailboxStatus(BaseAddress);
2926 while (DAC960_PG_InitializationInProgressP(BaseAddress))
2928 if (DAC960_PG_ReadErrorStatus(BaseAddress, &ErrorStatus,
2929 &Parameter0, &Parameter1) &&
2930 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2931 Parameter0, Parameter1))
2935 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2937 DAC960_Error(
"Unable to Enable Memory Mailbox Interface "
2938 "for Controller at\n", Controller);
2941 DAC960_PG_EnableInterrupts(BaseAddress);
2942 if (Controller->V1.DualModeMemoryMailboxInterface)
2943 Controller->QueueCommand = DAC960_PG_QueueCommandDualMode;
2944 else Controller->QueueCommand = DAC960_PG_QueueCommandSingleMode;
2945 Controller->ReadControllerConfiguration =
2946 DAC960_V1_ReadControllerConfiguration;
2947 Controller->ReadDeviceConfiguration =
2948 DAC960_V1_ReadDeviceConfiguration;
2949 Controller->ReportDeviceConfiguration =
2950 DAC960_V1_ReportDeviceConfiguration;
2951 Controller->QueueReadWriteCommand =
2952 DAC960_V1_QueueReadWriteCommand;
2954 case DAC960_PD_Controller:
2956 Controller->FullModelName)) {
2957 DAC960_Error(
"IO port 0x%d busy for Controller at\n",
2958 Controller, Controller->IO_Address);
2961 DAC960_PD_DisableInterrupts(BaseAddress);
2962 DAC960_PD_AcknowledgeStatus(BaseAddress);
2964 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2966 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2967 &Parameter0, &Parameter1) &&
2968 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2969 Parameter0, Parameter1))
2973 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2975 DAC960_Error(
"Unable to allocate DMA mapped memory "
2976 "for Controller at\n", Controller);
2979 DAC960_PD_EnableInterrupts(BaseAddress);
2980 Controller->QueueCommand = DAC960_PD_QueueCommand;
2981 Controller->ReadControllerConfiguration =
2982 DAC960_V1_ReadControllerConfiguration;
2983 Controller->ReadDeviceConfiguration =
2984 DAC960_V1_ReadDeviceConfiguration;
2985 Controller->ReportDeviceConfiguration =
2986 DAC960_V1_ReportDeviceConfiguration;
2987 Controller->QueueReadWriteCommand =
2988 DAC960_V1_QueueReadWriteCommand;
2990 case DAC960_P_Controller:
2992 Controller->FullModelName)){
2993 DAC960_Error(
"IO port 0x%d busy for Controller at\n",
2994 Controller, Controller->IO_Address);
2997 DAC960_PD_DisableInterrupts(BaseAddress);
2998 DAC960_PD_AcknowledgeStatus(BaseAddress);
3000 while (DAC960_PD_InitializationInProgressP(BaseAddress))
3002 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
3003 &Parameter0, &Parameter1) &&
3004 DAC960_ReportErrorStatus(Controller, ErrorStatus,
3005 Parameter0, Parameter1))
3009 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
3011 DAC960_Error(
"Unable to allocate DMA mapped memory"
3012 "for Controller at\n", Controller);
3015 DAC960_PD_EnableInterrupts(BaseAddress);
3016 Controller->QueueCommand = DAC960_P_QueueCommand;
3017 Controller->ReadControllerConfiguration =
3018 DAC960_V1_ReadControllerConfiguration;
3019 Controller->ReadDeviceConfiguration =
3020 DAC960_V1_ReadDeviceConfiguration;
3021 Controller->ReportDeviceConfiguration =
3022 DAC960_V1_ReportDeviceConfiguration;
3023 Controller->QueueReadWriteCommand =
3024 DAC960_V1_QueueReadWriteCommand;
3030 IRQ_Channel = PCI_Device->
irq;
3032 Controller->FullModelName, Controller) < 0)
3034 DAC960_Error(
"Unable to acquire IRQ Channel %d for Controller at\n",
3035 Controller, Controller->IRQ_Channel);
3038 Controller->IRQ_Channel = IRQ_Channel;
3039 Controller->InitialCommand.CommandIdentifier = 1;
3040 Controller->InitialCommand.Controller =
Controller;
3041 Controller->Commands[0] = &Controller->InitialCommand;
3042 Controller->FreeCommands = &Controller->InitialCommand;
3046 if (Controller->IO_Address == 0)
3047 DAC960_Error(
"PCI Bus %d Device %d Function %d I/O Address N/A "
3048 "PCI Address 0x%X\n", Controller,
3049 Controller->Bus, Controller->Device,
3050 Controller->Function, Controller->PCI_Address);
3052 DAC960_Error(
"PCI Bus %d Device %d Function %d I/O Address "
3053 "0x%X PCI Address 0x%X\n", Controller,
3054 Controller->Bus, Controller->Device,
3055 Controller->Function, Controller->IO_Address,
3056 Controller->PCI_Address);
3057 DAC960_DetectCleanup(Controller);
3058 DAC960_ControllerCount--;
3067 DAC960_InitializeController(DAC960_Controller_T *Controller)
3069 if (DAC960_ReadControllerConfiguration(Controller) &&
3070 DAC960_ReportControllerConfiguration(Controller) &&
3071 DAC960_CreateAuxiliaryStructures(Controller) &&
3072 DAC960_ReadDeviceConfiguration(Controller) &&
3073 DAC960_ReportDeviceConfiguration(Controller) &&
3074 DAC960_RegisterBlockDevice(Controller))
3080 Controller->MonitoringTimer.expires =
3081 jiffies + DAC960_MonitoringTimerInterval;
3082 Controller->MonitoringTimer.data = (
unsigned long) Controller;
3083 Controller->MonitoringTimer.function = DAC960_MonitoringTimerFunction;
3084 add_timer(&Controller->MonitoringTimer);
3085 Controller->ControllerInitialized =
true;
3096 static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
3098 if (Controller->ControllerInitialized)
3100 unsigned long flags;
3120 Controller->ShutdownMonitoringTimer = 1;
3121 spin_unlock_irqrestore(&Controller->queue_lock, flags);
3124 if (Controller->FirmwareType == DAC960_V1_Controller)
3126 DAC960_Notice(
"Flushing Cache...", Controller);
3128 DAC960_Notice(
"done\n", Controller);
3130 if (Controller->HardwareType == DAC960_PD_Controller)
3135 DAC960_Notice(
"Flushing Cache...", Controller);
3138 DAC960_Notice(
"done\n", Controller);
3141 DAC960_UnregisterBlockDevice(Controller);
3142 DAC960_DestroyAuxiliaryStructures(Controller);
3143 DAC960_DestroyProcEntries(Controller);
3144 DAC960_DetectCleanup(Controller);
3161 DAC960_Error(
"More than %d DAC960 Controllers detected - "
3162 "ignoring from Controller at\n",
3167 Controller = DAC960_DetectController(dev, entry);
3171 if (!DAC960_InitializeController(Controller)) {
3172 DAC960_FinalizeController(Controller);
3177 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
3180 DAC960_CreateProcEntries(Controller);
3189 static void DAC960_Remove(
struct pci_dev *PCI_Device)
3191 int Controller_Number = (
long)pci_get_drvdata(PCI_Device);
3192 DAC960_Controller_T *Controller = DAC960_Controllers[Controller_Number];
3193 if (Controller !=
NULL)
3194 DAC960_FinalizeController(Controller);
3203 static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *Command)
3205 DAC960_Controller_T *Controller = Command->Controller;
3208 Command->V1.ScatterGatherList;
3209 struct scatterlist *ScatterList = Command->V1.ScatterList;
3211 DAC960_V1_ClearCommand(Command);
3213 if (Command->SegmentCount == 1)
3238 CommandMailbox->Type5.
BusAddress = Command->V1.ScatterGatherListDMA;
3242 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3249 DAC960_QueueCommand(Command);
3258 static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *Command)
3260 DAC960_Controller_T *Controller = Command->Controller;
3262 struct scatterlist *ScatterList = Command->V2.ScatterList;
3264 DAC960_V2_ClearCommand(Command);
3267 CommandMailbox->
SCSI_10.CommandControlBits.DataTransferControllerToHost =
3269 CommandMailbox->
SCSI_10.DataTransferSize =
3270 Command->BlockCount << DAC960_BlockSizeBits;
3271 CommandMailbox->
SCSI_10.RequestSenseBusAddress = Command->V2.RequestSenseDMA;
3272 CommandMailbox->
SCSI_10.PhysicalDevice =
3273 Controller->V2.LogicalDriveToVirtualDevice[Command->LogicalDriveNumber];
3275 CommandMailbox->
SCSI_10.CDBLength = 10;
3276 CommandMailbox->
SCSI_10.SCSI_CDB[0] =
3278 CommandMailbox->
SCSI_10.SCSI_CDB[2] = Command->BlockNumber >> 24;
3279 CommandMailbox->
SCSI_10.SCSI_CDB[3] = Command->BlockNumber >> 16;
3280 CommandMailbox->
SCSI_10.SCSI_CDB[4] = Command->BlockNumber >> 8;
3281 CommandMailbox->
SCSI_10.SCSI_CDB[5] = Command->BlockNumber;
3282 CommandMailbox->
SCSI_10.SCSI_CDB[7] = Command->BlockCount >> 8;
3283 CommandMailbox->
SCSI_10.SCSI_CDB[8] = Command->BlockCount;
3285 if (Command->SegmentCount == 1)
3287 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
3288 .ScatterGatherSegments[0]
3289 .SegmentDataPointer =
3291 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
3292 .ScatterGatherSegments[0]
3294 CommandMailbox->
SCSI_10.DataTransferSize;
3301 if (Command->SegmentCount > 2)
3303 ScatterGatherList = Command->V2.ScatterGatherList;
3304 CommandMailbox->
SCSI_10.CommandControlBits
3305 .AdditionalScatterGatherListMemory =
true;
3306 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
3307 .ExtendedScatterGather.ScatterGatherList0Length = Command->SegmentCount;
3308 CommandMailbox->
SCSI_10.DataTransferMemoryAddress
3309 .ExtendedScatterGather.ScatterGatherList0Address =
3310 Command->V2.ScatterGatherListDMA;
3313 ScatterGatherList = CommandMailbox->
SCSI_10.DataTransferMemoryAddress
3314 .ScatterGatherSegments;
3316 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3323 DAC960_QueueCommand(Command);
3327 static int DAC960_process_queue(DAC960_Controller_T *Controller,
struct request_queue *req_q)
3337 Command = DAC960_AllocateCommand(Controller);
3338 if (Command ==
NULL)
3341 if (rq_data_dir(Request) ==
READ) {
3343 Command->CommandType = DAC960_ReadCommand;
3346 Command->CommandType = DAC960_WriteCommand;
3348 Command->Completion = Request->end_io_data;
3349 Command->LogicalDriveNumber = (
long)Request->rq_disk->private_data;
3350 Command->BlockNumber = blk_rq_pos(Request);
3351 Command->BlockCount = blk_rq_sectors(Request);
3355 Command->Request, Command->cmd_sglist);
3357 Command->SegmentCount = pci_map_sg(Controller->PCIDevice, Command->cmd_sglist,
3358 Command->SegmentCount, Command->DmaDirection);
3360 DAC960_QueueReadWriteCommand(Command);
3370 static void DAC960_ProcessRequest(DAC960_Controller_T *
controller)
3374 if (!controller->ControllerInitialized)
3378 for (i = controller->req_q_index; i < DAC960_MaxLogicalDrives; i++) {
3384 if (!DAC960_process_queue(controller, req_q)) {
3385 controller->req_q_index =
i;
3390 if (controller->req_q_index == 0)
3393 for (i = 0; i < controller->req_q_index; i++) {
3399 if (!DAC960_process_queue(controller, req_q)) {
3400 controller->req_q_index =
i;
3416 static void DAC960_queue_partial_rw(DAC960_Command_T *Command)
3418 DAC960_Controller_T *Controller = Command->Controller;
3419 struct request *Request = Command->Request;
3420 struct request_queue *req_q = Controller->RequestQueue[Command->LogicalDriveNumber];
3423 Command->CommandType = DAC960_ReadRetryCommand;
3425 Command->CommandType = DAC960_WriteRetryCommand;
3435 (
void)pci_map_sg(Controller->PCIDevice, Command->cmd_sglist, 1, Command->DmaDirection);
3442 Command->SegmentCount = 1;
3443 Command->BlockNumber = blk_rq_pos(Request);
3444 Command->BlockCount = 1;
3445 DAC960_QueueReadWriteCommand(Command);
3453 static void DAC960_RequestFunction(
struct request_queue *RequestQueue)
3455 DAC960_ProcessRequest(RequestQueue->queuedata);
3463 static inline bool DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3466 struct request *Request = Command->Request;
3467 int Error = SuccessfulIO ? 0 : -
EIO;
3469 pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist,
3470 Command->SegmentCount, Command->DmaDirection);
3473 if (Command->Completion) {
3475 Command->Completion =
NULL;
3487 static void DAC960_V1_ReadWriteError(DAC960_Command_T *Command)
3489 DAC960_Controller_T *Controller = Command->Controller;
3490 unsigned char *CommandName =
"UNKNOWN";
3491 switch (Command->CommandType)
3493 case DAC960_ReadCommand:
3494 case DAC960_ReadRetryCommand:
3495 CommandName =
"READ";
3497 case DAC960_WriteCommand:
3498 case DAC960_WriteRetryCommand:
3499 CommandName =
"WRITE";
3501 case DAC960_MonitoringCommand:
3502 case DAC960_ImmediateCommand:
3503 case DAC960_QueuedCommand:
3506 switch (Command->V1.CommandStatus)
3509 DAC960_Error(
"Irrecoverable Data Error on %s:\n",
3510 Controller, CommandName);
3513 DAC960_Error(
"Logical Drive Nonexistent or Offline on %s:\n",
3514 Controller, CommandName);
3517 DAC960_Error(
"Attempt to Access Beyond End of Logical Drive "
3518 "on %s:\n", Controller, CommandName);
3521 DAC960_Error(
"Bad Data Encountered on %s:\n", Controller, CommandName);
3524 DAC960_Error(
"Unexpected Error Status %04X on %s:\n",
3525 Controller, Command->V1.CommandStatus, CommandName);
3528 DAC960_Error(
" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
3529 Controller, Controller->ControllerNumber,
3530 Command->LogicalDriveNumber, Command->BlockNumber,
3531 Command->BlockNumber + Command->BlockCount - 1);
3540 static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
3542 DAC960_Controller_T *Controller = Command->Controller;
3543 DAC960_CommandType_T CommandType = Command->CommandType;
3544 DAC960_V1_CommandOpcode_T CommandOpcode =
3545 Command->V1.CommandMailbox.Common.CommandOpcode;
3548 if (CommandType == DAC960_ReadCommand ||
3549 CommandType == DAC960_WriteCommand)
3552 #ifdef FORCE_RETRY_DEBUG
3558 if (!DAC960_ProcessCompletedRequest(Command,
true))
3568 DAC960_queue_partial_rw(Command);
3574 DAC960_V1_ReadWriteError(Command);
3576 if (!DAC960_ProcessCompletedRequest(Command,
false))
3580 else if (CommandType == DAC960_ReadRetryCommand ||
3581 CommandType == DAC960_WriteRetryCommand)
3583 bool normal_completion;
3584 #ifdef FORCE_RETRY_FAILURE_DEBUG
3591 normal_completion =
true;
3593 normal_completion =
false;
3595 DAC960_V1_ReadWriteError(Command);
3598 #ifdef FORCE_RETRY_FAILURE_DEBUG
3599 if (!(++retry_count % 10000)) {
3600 printk(
"V1 error retry failure test\n");
3601 normal_completion =
false;
3602 DAC960_V1_ReadWriteError(Command);
3606 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
3607 DAC960_queue_partial_rw(Command);
3612 else if (CommandType == DAC960_MonitoringCommand)
3614 if (Controller->ShutdownMonitoringTimer)
3618 DAC960_V1_Enquiry_T *OldEnquiry = &Controller->V1.Enquiry;
3619 DAC960_V1_Enquiry_T *NewEnquiry = Controller->V1.NewEnquiry;
3620 unsigned int OldCriticalLogicalDriveCount =
3621 OldEnquiry->CriticalLogicalDriveCount;
3622 unsigned int NewCriticalLogicalDriveCount =
3623 NewEnquiry->CriticalLogicalDriveCount;
3624 if (NewEnquiry->NumberOfLogicalDrives > Controller->LogicalDriveCount)
3626 int LogicalDriveNumber = Controller->LogicalDriveCount - 1;
3628 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
3629 "Now Exists\n", Controller,
3631 Controller->ControllerNumber,
3632 LogicalDriveNumber);
3633 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3634 DAC960_ComputeGenericDiskInfo(Controller);
3636 if (NewEnquiry->NumberOfLogicalDrives < Controller->LogicalDriveCount)
3638 int LogicalDriveNumber = NewEnquiry->NumberOfLogicalDrives - 1;
3639 while (++LogicalDriveNumber < Controller->LogicalDriveCount)
3640 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
3641 "No Longer Exists\n", Controller,
3643 Controller->ControllerNumber,
3644 LogicalDriveNumber);
3645 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3646 DAC960_ComputeGenericDiskInfo(Controller);
3648 if (NewEnquiry->StatusFlags.DeferredWriteError !=
3649 OldEnquiry->StatusFlags.DeferredWriteError)
3650 DAC960_Critical(
"Deferred Write Error Flag is now %s\n", Controller,
3651 (NewEnquiry->StatusFlags.DeferredWriteError
3652 ?
"TRUE" :
"FALSE"));
3653 if ((NewCriticalLogicalDriveCount > 0 ||
3654 NewCriticalLogicalDriveCount != OldCriticalLogicalDriveCount) ||
3655 (NewEnquiry->OfflineLogicalDriveCount > 0 ||
3656 NewEnquiry->OfflineLogicalDriveCount !=
3657 OldEnquiry->OfflineLogicalDriveCount) ||
3658 (NewEnquiry->DeadDriveCount > 0 ||
3659 NewEnquiry->DeadDriveCount !=
3660 OldEnquiry->DeadDriveCount) ||
3661 (NewEnquiry->EventLogSequenceNumber !=
3662 OldEnquiry->EventLogSequenceNumber) ||
3663 Controller->MonitoringTimerCount == 0 ||
3665 + DAC960_SecondaryMonitoringInterval))
3667 Controller->V1.NeedLogicalDriveInformation =
true;
3668 Controller->V1.NewEventLogSequenceNumber =
3669 NewEnquiry->EventLogSequenceNumber;
3670 Controller->V1.NeedErrorTableInformation =
true;
3671 Controller->V1.NeedDeviceStateInformation =
true;
3672 Controller->V1.StartDeviceStateScan =
true;
3673 Controller->V1.NeedBackgroundInitializationStatus =
3674 Controller->V1.BackgroundInitializationStatusSupported;
3675 Controller->SecondaryMonitoringTime =
jiffies;
3678 NewEnquiry->RebuildFlag
3683 Controller->V1.NeedRebuildProgress =
true;
3684 Controller->V1.RebuildProgressFirst =
3685 (NewEnquiry->CriticalLogicalDriveCount <
3686 OldEnquiry->CriticalLogicalDriveCount);
3689 switch (NewEnquiry->RebuildFlag)
3692 DAC960_Progress(
"Consistency Check Completed Successfully\n",
3699 Controller->V1.NeedConsistencyCheckProgress =
true;
3702 DAC960_Progress(
"Consistency Check Completed with Error\n",
3706 DAC960_Progress(
"Consistency Check Failed - "
3707 "Physical Device Failed\n", Controller);
3710 DAC960_Progress(
"Consistency Check Failed - "
3711 "Logical Drive Failed\n", Controller);
3714 DAC960_Progress(
"Consistency Check Failed - Other Causes\n",
3718 DAC960_Progress(
"Consistency Check Successfully Terminated\n",
3722 else if (NewEnquiry->RebuildFlag
3724 Controller->V1.NeedConsistencyCheckProgress =
true;
3725 Controller->MonitoringAlertMode =
3726 (NewEnquiry->CriticalLogicalDriveCount > 0 ||
3727 NewEnquiry->OfflineLogicalDriveCount > 0 ||
3728 NewEnquiry->DeadDriveCount > 0);
3731 Controller->V1.PendingRebuildFlag = NewEnquiry->RebuildFlag;
3732 Controller->V1.RebuildFlagPending =
true;
3734 memcpy(&Controller->V1.Enquiry, &Controller->V1.NewEnquiry,
3735 sizeof(DAC960_V1_Enquiry_T));
3740 *DAC960_EventMessages[] =
3741 {
"killed because write recovery failed",
3742 "killed because of SCSI bus reset failure",
3743 "killed because of double check condition",
3744 "killed because it was removed",
3745 "killed because of gross error on SCSI chip",
3746 "killed because of bad tag returned from drive",
3747 "killed because of timeout on SCSI command",
3748 "killed because of reset SCSI command issued from system",
3749 "killed because busy or parity error count exceeded limit",
3750 "killed because of 'kill drive' command from system",
3751 "killed because of selection timeout",
3752 "killed due to SCSI phase sequence error",
3753 "killed due to unknown status" };
3755 Controller->V1.EventLogEntry;
3757 Controller->V1.OldEventLogSequenceNumber)
3759 unsigned char SenseKey = EventLogEntry->
SenseKey;
3765 AdditionalSenseCode == 0x80 &&
3766 AdditionalSenseCodeQualifier <
3768 DAC960_Critical(
"Physical Device %d:%d %s\n", Controller,
3771 DAC960_EventMessages[
3772 AdditionalSenseCodeQualifier]);
3774 AdditionalSenseCode == 0x29)
3776 if (Controller->MonitoringTimerCount > 0)
3777 Controller->V1.DeviceResetCount[EventLogEntry->
Channel]
3782 AdditionalSenseCode == 0x04 &&
3783 (AdditionalSenseCodeQualifier == 0x01 ||
3784 AdditionalSenseCodeQualifier == 0x02))))
3786 DAC960_Critical(
"Physical Device %d:%d Error Log: "
3787 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
3792 AdditionalSenseCode,
3793 AdditionalSenseCodeQualifier);
3794 DAC960_Critical(
"Physical Device %d:%d Error Log: "
3795 "Information = %02X%02X%02X%02X "
3796 "%02X%02X%02X%02X\n",
3810 Controller->V1.OldEventLogSequenceNumber++;
3817 for (Channel = 0; Channel < Controller->Channels; Channel++)
3818 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
3832 DAC960_Critical(
"Physical Device %d:%d Errors: "
3833 "Parity = %d, Soft = %d, "
3834 "Hard = %d, Misc = %d\n",
3835 Controller, Channel, TargetID,
3841 memcpy(&Controller->V1.ErrorTable, Controller->V1.NewErrorTable,
3847 &Controller->V1.DeviceState[Controller->V1.DeviceStateChannel]
3848 [Controller->V1.DeviceStateTargetID];
3850 Controller->V1.NewDeviceState;
3851 if (NewDeviceState->DeviceState != OldDeviceState->DeviceState)
3852 DAC960_Critical(
"Physical Device %d:%d is now %s\n", Controller,
3853 Controller->V1.DeviceStateChannel,
3854 Controller->V1.DeviceStateTargetID,
3855 (NewDeviceState->DeviceState
3858 : NewDeviceState->DeviceState
3861 : NewDeviceState->DeviceState
3863 ?
"ONLINE" :
"STANDBY"));
3867 Controller->V1.NeedDeviceInquiryInformation =
true;
3868 Controller->V1.NeedDeviceSerialNumberInformation =
true;
3869 Controller->V1.DeviceResetCount
3870 [Controller->V1.DeviceStateChannel]
3871 [Controller->V1.DeviceStateTargetID] = 0;
3873 memcpy(OldDeviceState, NewDeviceState,
3879 for (LogicalDriveNumber = 0;
3880 LogicalDriveNumber < Controller->LogicalDriveCount;
3881 LogicalDriveNumber++)
3886 &(*Controller->V1.NewLogicalDriveInformation)[LogicalDriveNumber];
3889 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
3890 "is now %s\n", Controller,
3892 Controller->ControllerNumber,
3899 ?
"CRITICAL" :
"OFFLINE"));
3900 if (NewLogicalDriveInformation->
WriteBack !=
3902 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
3903 "is now %s\n", Controller,
3905 Controller->ControllerNumber,
3908 ?
"WRITE BACK" :
"WRITE THRU"));
3910 memcpy(&Controller->V1.LogicalDriveInformation,
3911 Controller->V1.NewLogicalDriveInformation,
3916 unsigned int LogicalDriveNumber =
3917 Controller->V1.RebuildProgress->LogicalDriveNumber;
3918 unsigned int LogicalDriveSize =
3919 Controller->V1.RebuildProgress->LogicalDriveSize;
3920 unsigned int BlocksCompleted =
3921 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3925 switch (CommandStatus)
3928 Controller->EphemeralProgressMessage =
true;
3929 DAC960_Progress(
"Rebuild in Progress: "
3930 "Logical Drive %d (/dev/rd/c%dd%d) "
3932 Controller, LogicalDriveNumber,
3933 Controller->ControllerNumber,
3935 (100 * (BlocksCompleted >> 7))
3936 / (LogicalDriveSize >> 7));
3937 Controller->EphemeralProgressMessage =
false;
3940 DAC960_Progress(
"Rebuild Failed due to "
3941 "Logical Drive Failure\n", Controller);
3944 DAC960_Progress(
"Rebuild Failed due to "
3945 "Bad Blocks on Other Drives\n", Controller);
3948 DAC960_Progress(
"Rebuild Failed due to "
3949 "Failure of Drive Being Rebuilt\n", Controller);
3954 DAC960_Progress(
"Rebuild Completed Successfully\n", Controller);
3957 DAC960_Progress(
"Rebuild Successfully Terminated\n", Controller);
3961 if (CommandType != DAC960_MonitoringCommand &&
3962 Controller->V1.RebuildStatusPending)
3964 Command->V1.CommandStatus = Controller->V1.PendingRebuildStatus;
3965 Controller->V1.RebuildStatusPending =
false;
3967 else if (CommandType == DAC960_MonitoringCommand &&
3972 Controller->V1.RebuildStatusPending =
true;
3977 unsigned int LogicalDriveNumber =
3978 Controller->V1.RebuildProgress->LogicalDriveNumber;
3979 unsigned int LogicalDriveSize =
3980 Controller->V1.RebuildProgress->LogicalDriveSize;
3981 unsigned int BlocksCompleted =
3982 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3985 Controller->EphemeralProgressMessage =
true;
3986 DAC960_Progress(
"Consistency Check in Progress: "
3987 "Logical Drive %d (/dev/rd/c%dd%d) "
3989 Controller, LogicalDriveNumber,
3990 Controller->ControllerNumber,
3992 (100 * (BlocksCompleted >> 7))
3993 / (LogicalDriveSize >> 7));
3994 Controller->EphemeralProgressMessage =
false;
3999 unsigned int LogicalDriveNumber =
4000 Controller->V1.BackgroundInitializationStatus->LogicalDriveNumber;
4001 unsigned int LogicalDriveSize =
4002 Controller->V1.BackgroundInitializationStatus->LogicalDriveSize;
4003 unsigned int BlocksCompleted =
4004 Controller->V1.BackgroundInitializationStatus->BlocksCompleted;
4005 switch (CommandStatus)
4008 switch (Controller->V1.BackgroundInitializationStatus->Status)
4013 DAC960_Progress(
"Background Initialization Started\n",
4017 if (BlocksCompleted ==
4018 Controller->V1.LastBackgroundInitializationStatus.
4020 LogicalDriveNumber ==
4021 Controller->V1.LastBackgroundInitializationStatus.
4024 Controller->EphemeralProgressMessage =
true;
4025 DAC960_Progress(
"Background Initialization in Progress: "
4026 "Logical Drive %d (/dev/rd/c%dd%d) "
4028 Controller, LogicalDriveNumber,
4029 Controller->ControllerNumber,
4031 (100 * (BlocksCompleted >> 7))
4032 / (LogicalDriveSize >> 7));
4033 Controller->EphemeralProgressMessage =
false;
4036 DAC960_Progress(
"Background Initialization Suspended\n",
4040 DAC960_Progress(
"Background Initialization Cancelled\n",
4044 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
4045 Controller->V1.BackgroundInitializationStatus,
4049 if (Controller->V1.BackgroundInitializationStatus->Status ==
4051 DAC960_Progress(
"Background Initialization "
4052 "Completed Successfully\n", Controller);
4053 Controller->V1.BackgroundInitializationStatus->Status =
4057 if (Controller->V1.BackgroundInitializationStatus->Status ==
4059 DAC960_Progress(
"Background Initialization Aborted\n",
4061 Controller->V1.BackgroundInitializationStatus->Status =
4083 if (Controller->V1.NeedDeviceInquiryInformation)
4086 &Controller->V1.InquiryStandardData
4087 [Controller->V1.DeviceStateChannel]
4088 [Controller->V1.DeviceStateTargetID];
4091 memset(InquiryStandardData, 0,
4096 memcpy(InquiryStandardData,
4097 Controller->V1.NewInquiryStandardData,
4099 Controller->V1.NeedDeviceInquiryInformation =
false;
4101 else if (Controller->V1.NeedDeviceSerialNumberInformation)
4104 &Controller->V1.InquiryUnitSerialNumber
4105 [Controller->V1.DeviceStateChannel]
4106 [Controller->V1.DeviceStateTargetID];
4109 memset(InquiryUnitSerialNumber, 0,
4114 memcpy(InquiryUnitSerialNumber,
4115 Controller->V1.NewInquiryUnitSerialNumber,
4117 Controller->V1.NeedDeviceSerialNumberInformation =
false;
4123 if (Controller->V1.NewEventLogSequenceNumber
4124 - Controller->V1.OldEventLogSequenceNumber > 0)
4126 Command->V1.CommandMailbox.Type3E.CommandOpcode =
4128 Command->V1.CommandMailbox.Type3E.OperationType =
4130 Command->V1.CommandMailbox.Type3E.OperationQualifier = 1;
4131 Command->V1.CommandMailbox.Type3E.SequenceNumber =
4132 Controller->V1.OldEventLogSequenceNumber;
4133 Command->V1.CommandMailbox.Type3E.BusAddress =
4134 Controller->V1.EventLogEntryDMA;
4135 DAC960_QueueCommand(Command);
4138 if (Controller->V1.NeedErrorTableInformation)
4140 Controller->V1.NeedErrorTableInformation =
false;
4141 Command->V1.CommandMailbox.Type3.CommandOpcode =
4143 Command->V1.CommandMailbox.Type3.BusAddress =
4144 Controller->V1.NewErrorTableDMA;
4145 DAC960_QueueCommand(Command);
4148 if (Controller->V1.NeedRebuildProgress &&
4149 Controller->V1.RebuildProgressFirst)
4151 Controller->V1.NeedRebuildProgress =
false;
4152 Command->V1.CommandMailbox.Type3.CommandOpcode =
4154 Command->V1.CommandMailbox.Type3.BusAddress =
4155 Controller->V1.RebuildProgressDMA;
4156 DAC960_QueueCommand(Command);
4159 if (Controller->V1.NeedDeviceStateInformation)
4161 if (Controller->V1.NeedDeviceInquiryInformation)
4164 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4167 Controller->V1.NewInquiryStandardDataDMA;
4170 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4171 DCDB->
Channel = Controller->V1.DeviceStateChannel;
4172 DCDB->
TargetID = Controller->V1.DeviceStateTargetID;
4173 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4174 DCDB->EarlyStatus =
false;
4175 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4176 DCDB->NoAutomaticRequestSense =
false;
4177 DCDB->DisconnectPermitted =
true;
4179 DCDB->BusAddress = NewInquiryStandardDataDMA;
4180 DCDB->CDBLength = 6;
4181 DCDB->TransferLengthHigh4 = 0;
4182 DCDB->SenseLength =
sizeof(DCDB->SenseData);
4183 DCDB->CDB[0] = 0x12;
4189 DAC960_QueueCommand(Command);
4192 if (Controller->V1.NeedDeviceSerialNumberInformation)
4195 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4197 Controller->V1.NewInquiryUnitSerialNumberDMA;
4200 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4201 DCDB->
Channel = Controller->V1.DeviceStateChannel;
4202 DCDB->
TargetID = Controller->V1.DeviceStateTargetID;
4203 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4204 DCDB->EarlyStatus =
false;
4205 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4206 DCDB->NoAutomaticRequestSense =
false;
4207 DCDB->DisconnectPermitted =
true;
4208 DCDB->TransferLength =
4210 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
4211 DCDB->CDBLength = 6;
4212 DCDB->TransferLengthHigh4 = 0;
4213 DCDB->SenseLength =
sizeof(DCDB->SenseData);
4214 DCDB->CDB[0] = 0x12;
4216 DCDB->CDB[2] = 0x80;
4220 DAC960_QueueCommand(Command);
4223 if (Controller->V1.StartDeviceStateScan)
4225 Controller->V1.DeviceStateChannel = 0;
4226 Controller->V1.DeviceStateTargetID = 0;
4227 Controller->V1.StartDeviceStateScan =
false;
4229 else if (++Controller->V1.DeviceStateTargetID == Controller->Targets)
4231 Controller->V1.DeviceStateChannel++;
4232 Controller->V1.DeviceStateTargetID = 0;
4234 if (Controller->V1.DeviceStateChannel < Controller->Channels)
4236 Controller->V1.NewDeviceState->DeviceState =
4238 Command->V1.CommandMailbox.Type3D.CommandOpcode =
4240 Command->V1.CommandMailbox.Type3D.Channel =
4241 Controller->V1.DeviceStateChannel;
4242 Command->V1.CommandMailbox.Type3D.TargetID =
4243 Controller->V1.DeviceStateTargetID;
4244 Command->V1.CommandMailbox.Type3D.BusAddress =
4245 Controller->V1.NewDeviceStateDMA;
4246 DAC960_QueueCommand(Command);
4249 Controller->V1.NeedDeviceStateInformation =
false;
4251 if (Controller->V1.NeedLogicalDriveInformation)
4253 Controller->V1.NeedLogicalDriveInformation =
false;
4254 Command->V1.CommandMailbox.Type3.CommandOpcode =
4256 Command->V1.CommandMailbox.Type3.BusAddress =
4257 Controller->V1.NewLogicalDriveInformationDMA;
4258 DAC960_QueueCommand(Command);
4261 if (Controller->V1.NeedRebuildProgress)
4263 Controller->V1.NeedRebuildProgress =
false;
4264 Command->V1.CommandMailbox.Type3.CommandOpcode =
4266 Command->V1.CommandMailbox.Type3.BusAddress =
4267 Controller->V1.RebuildProgressDMA;
4268 DAC960_QueueCommand(Command);
4271 if (Controller->V1.NeedConsistencyCheckProgress)
4273 Controller->V1.NeedConsistencyCheckProgress =
false;
4274 Command->V1.CommandMailbox.Type3.CommandOpcode =
4276 Command->V1.CommandMailbox.Type3.BusAddress =
4277 Controller->V1.RebuildProgressDMA;
4278 DAC960_QueueCommand(Command);
4281 if (Controller->V1.NeedBackgroundInitializationStatus)
4283 Controller->V1.NeedBackgroundInitializationStatus =
false;
4284 Command->V1.CommandMailbox.Type3B.CommandOpcode =
4286 Command->V1.CommandMailbox.Type3B.CommandOpcode2 = 0x20;
4287 Command->V1.CommandMailbox.Type3B.BusAddress =
4288 Controller->V1.BackgroundInitializationStatusDMA;
4289 DAC960_QueueCommand(Command);
4292 Controller->MonitoringTimerCount++;
4293 Controller->MonitoringTimer.expires =
4294 jiffies + DAC960_MonitoringTimerInterval;
4295 add_timer(&Controller->MonitoringTimer);
4297 if (CommandType == DAC960_ImmediateCommand)
4300 Command->Completion =
NULL;
4303 if (CommandType == DAC960_QueuedCommand)
4307 Command->V1.KernelCommand =
NULL;
4309 Controller->V1.DirectCommandActive[KernelCommand->
DCDB->
Channel]
4312 DAC960_DeallocateCommand(Command);
4321 if (Controller->MonitoringCommandDeferred)
4323 Controller->MonitoringCommandDeferred =
false;
4324 DAC960_V1_QueueMonitoringCommand(Command);
4330 DAC960_DeallocateCommand(Command);
4334 wake_up(&Controller->CommandWaitQueue);
4343 static void DAC960_V2_ReadWriteError(DAC960_Command_T *Command)
4345 DAC960_Controller_T *Controller = Command->Controller;
4346 unsigned char *SenseErrors[] = {
"NO SENSE",
"RECOVERED ERROR",
4347 "NOT READY",
"MEDIUM ERROR",
4348 "HARDWARE ERROR",
"ILLEGAL REQUEST",
4349 "UNIT ATTENTION",
"DATA PROTECT",
4350 "BLANK CHECK",
"VENDOR-SPECIFIC",
4351 "COPY ABORTED",
"ABORTED COMMAND",
4352 "EQUAL",
"VOLUME OVERFLOW",
4353 "MISCOMPARE",
"RESERVED" };
4354 unsigned char *CommandName =
"UNKNOWN";
4355 switch (Command->CommandType)
4357 case DAC960_ReadCommand:
4358 case DAC960_ReadRetryCommand:
4359 CommandName =
"READ";
4361 case DAC960_WriteCommand:
4362 case DAC960_WriteRetryCommand:
4363 CommandName =
"WRITE";
4365 case DAC960_MonitoringCommand:
4366 case DAC960_ImmediateCommand:
4367 case DAC960_QueuedCommand:
4370 DAC960_Error(
"Error Condition %s on %s:\n", Controller,
4371 SenseErrors[Command->V2.RequestSense->SenseKey], CommandName);
4372 DAC960_Error(
" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
4373 Controller, Controller->ControllerNumber,
4374 Command->LogicalDriveNumber, Command->BlockNumber,
4375 Command->BlockNumber + Command->BlockCount - 1);
4384 static void DAC960_V2_ReportEvent(DAC960_Controller_T *Controller,
4389 unsigned char MessageBuffer[DAC960_LineBufferSize];
4390 static struct {
int EventCode;
unsigned char *EventMessage; } EventList[] =
4392 { 0x0001,
"P Online" },
4393 { 0x0002,
"P Standby" },
4394 { 0x0005,
"P Automatic Rebuild Started" },
4395 { 0x0006,
"P Manual Rebuild Started" },
4396 { 0x0007,
"P Rebuild Completed" },
4397 { 0x0008,
"P Rebuild Cancelled" },
4398 { 0x0009,
"P Rebuild Failed for Unknown Reasons" },
4399 { 0x000A,
"P Rebuild Failed due to New Physical Device" },
4400 { 0x000B,
"P Rebuild Failed due to Logical Drive Failure" },
4401 { 0x000C,
"S Offline" },
4402 { 0x000D,
"P Found" },
4403 { 0x000E,
"P Removed" },
4404 { 0x000F,
"P Unconfigured" },
4405 { 0x0010,
"P Expand Capacity Started" },
4406 { 0x0011,
"P Expand Capacity Completed" },
4407 { 0x0012,
"P Expand Capacity Failed" },
4408 { 0x0013,
"P Command Timed Out" },
4409 { 0x0014,
"P Command Aborted" },
4410 { 0x0015,
"P Command Retried" },
4411 { 0x0016,
"P Parity Error" },
4412 { 0x0017,
"P Soft Error" },
4413 { 0x0018,
"P Miscellaneous Error" },
4414 { 0x0019,
"P Reset" },
4415 { 0x001A,
"P Active Spare Found" },
4416 { 0x001B,
"P Warm Spare Found" },
4417 { 0x001C,
"S Sense Data Received" },
4418 { 0x001D,
"P Initialization Started" },
4419 { 0x001E,
"P Initialization Completed" },
4420 { 0x001F,
"P Initialization Failed" },
4421 { 0x0020,
"P Initialization Cancelled" },
4422 { 0x0021,
"P Failed because Write Recovery Failed" },
4423 { 0x0022,
"P Failed because SCSI Bus Reset Failed" },
4424 { 0x0023,
"P Failed because of Double Check Condition" },
4425 { 0x0024,
"P Failed because Device Cannot Be Accessed" },
4426 { 0x0025,
"P Failed because of Gross Error on SCSI Processor" },
4427 { 0x0026,
"P Failed because of Bad Tag from Device" },
4428 { 0x0027,
"P Failed because of Command Timeout" },
4429 { 0x0028,
"P Failed because of System Reset" },
4430 { 0x0029,
"P Failed because of Busy Status or Parity Error" },
4431 { 0x002A,
"P Failed because Host Set Device to Failed State" },
4432 { 0x002B,
"P Failed because of Selection Timeout" },
4433 { 0x002C,
"P Failed because of SCSI Bus Phase Error" },
4434 { 0x002D,
"P Failed because Device Returned Unknown Status" },
4435 { 0x002E,
"P Failed because Device Not Ready" },
4436 { 0x002F,
"P Failed because Device Not Found at Startup" },
4437 { 0x0030,
"P Failed because COD Write Operation Failed" },
4438 { 0x0031,
"P Failed because BDT Write Operation Failed" },
4439 { 0x0039,
"P Missing at Startup" },
4440 { 0x003A,
"P Start Rebuild Failed due to Physical Drive Too Small" },
4441 { 0x003C,
"P Temporarily Offline Device Automatically Made Online" },
4442 { 0x003D,
"P Standby Rebuild Started" },
4444 { 0x0080,
"M Consistency Check Started" },
4445 { 0x0081,
"M Consistency Check Completed" },
4446 { 0x0082,
"M Consistency Check Cancelled" },
4447 { 0x0083,
"M Consistency Check Completed With Errors" },
4448 { 0x0084,
"M Consistency Check Failed due to Logical Drive Failure" },
4449 { 0x0085,
"M Consistency Check Failed due to Physical Device Failure" },
4450 { 0x0086,
"L Offline" },
4451 { 0x0087,
"L Critical" },
4452 { 0x0088,
"L Online" },
4453 { 0x0089,
"M Automatic Rebuild Started" },
4454 { 0x008A,
"M Manual Rebuild Started" },
4455 { 0x008B,
"M Rebuild Completed" },
4456 { 0x008C,
"M Rebuild Cancelled" },
4457 { 0x008D,
"M Rebuild Failed for Unknown Reasons" },
4458 { 0x008E,
"M Rebuild Failed due to New Physical Device" },
4459 { 0x008F,
"M Rebuild Failed due to Logical Drive Failure" },
4460 { 0x0090,
"M Initialization Started" },
4461 { 0x0091,
"M Initialization Completed" },
4462 { 0x0092,
"M Initialization Cancelled" },
4463 { 0x0093,
"M Initialization Failed" },
4464 { 0x0094,
"L Found" },
4465 { 0x0095,
"L Deleted" },
4466 { 0x0096,
"M Expand Capacity Started" },
4467 { 0x0097,
"M Expand Capacity Completed" },
4468 { 0x0098,
"M Expand Capacity Failed" },
4469 { 0x0099,
"L Bad Block Found" },
4470 { 0x009A,
"L Size Changed" },
4471 { 0x009B,
"L Type Changed" },
4472 { 0x009C,
"L Bad Data Block Found" },
4473 { 0x009E,
"L Read of Data Block in BDT" },
4474 { 0x009F,
"L Write Back Data for Disk Block Lost" },
4475 { 0x00A0,
"L Temporarily Offline RAID-5/3 Drive Made Online" },
4476 { 0x00A1,
"L Temporarily Offline RAID-6/1/0/7 Drive Made Online" },
4477 { 0x00A2,
"L Standby Rebuild Started" },
4479 { 0x0140,
"E Fan %d Failed" },
4480 { 0x0141,
"E Fan %d OK" },
4481 { 0x0142,
"E Fan %d Not Present" },
4482 { 0x0143,
"E Power Supply %d Failed" },
4483 { 0x0144,
"E Power Supply %d OK" },
4484 { 0x0145,
"E Power Supply %d Not Present" },
4485 { 0x0146,
"E Temperature Sensor %d Temperature Exceeds Safe Limit" },
4486 { 0x0147,
"E Temperature Sensor %d Temperature Exceeds Working Limit" },
4487 { 0x0148,
"E Temperature Sensor %d Temperature Normal" },
4488 { 0x0149,
"E Temperature Sensor %d Not Present" },
4489 { 0x014A,
"E Enclosure Management Unit %d Access Critical" },
4490 { 0x014B,
"E Enclosure Management Unit %d Access OK" },
4491 { 0x014C,
"E Enclosure Management Unit %d Access Offline" },
4493 { 0x0181,
"C Cache Write Back Error" },
4494 { 0x0188,
"C Battery Backup Unit Found" },
4495 { 0x0189,
"C Battery Backup Unit Charge Level Low" },
4496 { 0x018A,
"C Battery Backup Unit Charge Level OK" },
4497 { 0x0193,
"C Installation Aborted" },
4498 { 0x0195,
"C Battery Backup Unit Physically Removed" },
4499 { 0x0196,
"C Memory Error During Warm Boot" },
4500 { 0x019E,
"C Memory Soft ECC Error Corrected" },
4501 { 0x019F,
"C Memory Hard ECC Error Corrected" },
4502 { 0x01A2,
"C Battery Backup Unit Failed" },
4503 { 0x01AB,
"C Mirror Race Recovery Failed" },
4504 { 0x01AC,
"C Mirror Race on Critical Drive" },
4506 { 0x0380,
"C Internal Controller Hung" },
4507 { 0x0381,
"C Internal Controller Firmware Breakpoint" },
4508 { 0x0390,
"C Internal Controller i960 Processor Specific Error" },
4509 { 0x03A0,
"C Internal Controller StrongARM Processor Specific Error" },
4511 int EventListIndex = 0, EventCode;
4512 unsigned char EventType, *EventMessage;
4513 if (Event->EventCode == 0x1C &&
4515 (RequestSense->AdditionalSenseCode == 0x80 ||
4516 RequestSense->AdditionalSenseCode == 0x81))
4517 Event->EventCode = ((RequestSense->AdditionalSenseCode - 0x80) << 8) |
4518 RequestSense->AdditionalSenseCodeQualifier;
4521 EventCode = EventList[EventListIndex].EventCode;
4522 if (EventCode == Event->EventCode || EventCode == 0)
break;
4525 EventType = EventList[EventListIndex].EventMessage[0];
4526 EventMessage = &EventList[EventListIndex].EventMessage[2];
4529 DAC960_Critical(
"Unknown Controller Event Code %04X\n",
4530 Controller, Event->EventCode);
4536 DAC960_Critical(
"Physical Device %d:%d %s\n", Controller,
4537 Event->Channel, Event->TargetID, EventMessage);
4540 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4541 Event->LogicalUnit, Controller->ControllerNumber,
4542 Event->LogicalUnit, EventMessage);
4545 DAC960_Progress(
"Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4546 Event->LogicalUnit, Controller->ControllerNumber,
4547 Event->LogicalUnit, EventMessage);
4552 RequestSense->AdditionalSenseCode == 0x04 &&
4553 (RequestSense->AdditionalSenseCodeQualifier == 0x01 ||
4554 RequestSense->AdditionalSenseCodeQualifier == 0x02)))
4556 DAC960_Critical(
"Physical Device %d:%d %s\n", Controller,
4557 Event->Channel, Event->TargetID, EventMessage);
4558 DAC960_Critical(
"Physical Device %d:%d Request Sense: "
4559 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
4563 RequestSense->SenseKey,
4564 RequestSense->AdditionalSenseCode,
4565 RequestSense->AdditionalSenseCodeQualifier);
4566 DAC960_Critical(
"Physical Device %d:%d Request Sense: "
4567 "Information = %02X%02X%02X%02X "
4568 "%02X%02X%02X%02X\n",
4572 RequestSense->Information[0],
4573 RequestSense->Information[1],
4574 RequestSense->Information[2],
4575 RequestSense->Information[3],
4576 RequestSense->CommandSpecificInformation[0],
4577 RequestSense->CommandSpecificInformation[1],
4578 RequestSense->CommandSpecificInformation[2],
4579 RequestSense->CommandSpecificInformation[3]);
4582 if (Controller->SuppressEnclosureMessages)
break;
4583 sprintf(MessageBuffer, EventMessage, Event->LogicalUnit);
4584 DAC960_Critical(
"Enclosure %d %s\n", Controller,
4585 Event->TargetID, MessageBuffer);
4588 DAC960_Critical(
"Controller %s\n", Controller, EventMessage);
4591 DAC960_Critical(
"Unknown Controller Event Code %04X\n",
4592 Controller, Event->EventCode);
4603 static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller,
4604 unsigned char *MessageString,
4605 unsigned int LogicalDeviceNumber,
4606 unsigned long BlocksCompleted,
4607 unsigned long LogicalDeviceSize)
4609 Controller->EphemeralProgressMessage =
true;
4610 DAC960_Progress(
"%s in Progress: Logical Drive %d (/dev/rd/c%dd%d) "
4611 "%d%% completed\n", Controller,
4613 LogicalDeviceNumber,
4614 Controller->ControllerNumber,
4615 LogicalDeviceNumber,
4616 (100 * (BlocksCompleted >> 7)) / (LogicalDeviceSize >> 7));
4617 Controller->EphemeralProgressMessage =
false;
4626 static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4628 DAC960_Controller_T *Controller = Command->Controller;
4629 DAC960_CommandType_T CommandType = Command->CommandType;
4631 DAC960_V2_IOCTL_Opcode_T IOCTLOpcode = CommandMailbox->
Common.IOCTL_Opcode;
4632 DAC960_V2_CommandOpcode_T CommandOpcode = CommandMailbox->
SCSI_10.CommandOpcode;
4635 if (CommandType == DAC960_ReadCommand ||
4636 CommandType == DAC960_WriteCommand)
4639 #ifdef FORCE_RETRY_DEBUG
4646 if (!DAC960_ProcessCompletedRequest(Command,
true))
4655 DAC960_queue_partial_rw(Command);
4661 DAC960_V2_ReadWriteError(Command);
4665 (
void)DAC960_ProcessCompletedRequest(Command,
false);
4668 else if (CommandType == DAC960_ReadRetryCommand ||
4669 CommandType == DAC960_WriteRetryCommand)
4671 bool normal_completion;
4673 #ifdef FORCE_RETRY_FAILURE_DEBUG
4674 static int retry_count = 1;
4680 normal_completion =
true;
4682 normal_completion =
false;
4684 DAC960_V2_ReadWriteError(Command);
4687 #ifdef FORCE_RETRY_FAILURE_DEBUG
4688 if (!(++retry_count % 10000)) {
4689 printk(
"V2 error retry failure test\n");
4690 normal_completion =
false;
4691 DAC960_V2_ReadWriteError(Command);
4695 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
4696 DAC960_queue_partial_rw(Command);
4700 else if (CommandType == DAC960_MonitoringCommand)
4702 if (Controller->ShutdownMonitoringTimer)
4707 Controller->V2.NewControllerInformation;
4709 &Controller->V2.ControllerInformation;
4710 Controller->LogicalDriveCount =
4712 Controller->V2.NeedLogicalDeviceInformation =
true;
4713 Controller->V2.NeedPhysicalDeviceInformation =
true;
4714 Controller->V2.StartLogicalDeviceInformationScan =
true;
4715 Controller->V2.StartPhysicalDeviceInformationScan =
true;
4716 Controller->MonitoringAlertMode =
4721 memcpy(ControllerInfo, NewControllerInfo,
4727 DAC960_V2_ReportEvent(Controller, Controller->V2.Event);
4729 Controller->V2.NextEventSequenceNumber++;
4735 Controller->V2.NewPhysicalDeviceInformation;
4736 unsigned int PhysicalDeviceIndex = Controller->V2.PhysicalDeviceIndex;
4738 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4740 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4741 unsigned int DeviceIndex;
4742 while (PhysicalDeviceInfo !=
NULL &&
4743 (NewPhysicalDeviceInfo->
Channel >
4744 PhysicalDeviceInfo->
Channel ||
4745 (NewPhysicalDeviceInfo->
Channel ==
4746 PhysicalDeviceInfo->
Channel &&
4749 (NewPhysicalDeviceInfo->
TargetID ==
4754 DAC960_Critical(
"Physical Device %d:%d No Longer Exists\n",
4758 Controller->V2.PhysicalDeviceInformation
4759 [PhysicalDeviceIndex] =
NULL;
4760 Controller->V2.InquiryUnitSerialNumber
4761 [PhysicalDeviceIndex] =
NULL;
4762 kfree(PhysicalDeviceInfo);
4763 kfree(InquiryUnitSerialNumber);
4764 for (DeviceIndex = PhysicalDeviceIndex;
4765 DeviceIndex < DAC960_V2_MaxPhysicalDevices - 1;
4768 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4769 Controller->V2.PhysicalDeviceInformation[DeviceIndex+1];
4770 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4771 Controller->V2.InquiryUnitSerialNumber[DeviceIndex+1];
4773 Controller->V2.PhysicalDeviceInformation
4774 [DAC960_V2_MaxPhysicalDevices-1] =
NULL;
4775 Controller->V2.InquiryUnitSerialNumber
4776 [DAC960_V2_MaxPhysicalDevices-1] =
NULL;
4777 PhysicalDeviceInfo =
4778 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4779 InquiryUnitSerialNumber =
4780 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4782 if (PhysicalDeviceInfo ==
NULL ||
4783 (NewPhysicalDeviceInfo->
Channel !=
4784 PhysicalDeviceInfo->
Channel) ||
4785 (NewPhysicalDeviceInfo->
TargetID !=
4790 PhysicalDeviceInfo =
4792 InquiryUnitSerialNumber =
4795 if (InquiryUnitSerialNumber ==
NULL ||
4796 PhysicalDeviceInfo ==
NULL)
4798 kfree(InquiryUnitSerialNumber);
4799 InquiryUnitSerialNumber =
NULL;
4800 kfree(PhysicalDeviceInfo);
4801 PhysicalDeviceInfo =
NULL;
4803 DAC960_Critical(
"Physical Device %d:%d Now Exists%s\n",
4805 NewPhysicalDeviceInfo->
Channel,
4807 (PhysicalDeviceInfo !=
NULL
4808 ?
"" :
" - Allocation Failed"));
4809 if (PhysicalDeviceInfo !=
NULL)
4811 memset(PhysicalDeviceInfo, 0,
4815 memset(InquiryUnitSerialNumber, 0,
4818 for (DeviceIndex = DAC960_V2_MaxPhysicalDevices - 1;
4819 DeviceIndex > PhysicalDeviceIndex;
4822 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4823 Controller->V2.PhysicalDeviceInformation[DeviceIndex-1];
4824 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4825 Controller->V2.InquiryUnitSerialNumber[DeviceIndex-1];
4827 Controller->V2.PhysicalDeviceInformation
4828 [PhysicalDeviceIndex] =
4830 Controller->V2.InquiryUnitSerialNumber
4831 [PhysicalDeviceIndex] =
4832 InquiryUnitSerialNumber;
4833 Controller->V2.NeedDeviceSerialNumberInformation =
true;
4836 if (PhysicalDeviceInfo !=
NULL)
4841 "Physical Device %d:%d is now %s\n", Controller,
4842 NewPhysicalDeviceInfo->
Channel,
4864 ?
"COMMANDED-OFFLINE"
4867 ?
"STANDBY" :
"UNKNOWN"));
4878 (NewPhysicalDeviceInfo->
Retries !=
4879 PhysicalDeviceInfo->
Retries) ||
4880 (NewPhysicalDeviceInfo->
Aborts !=
4881 PhysicalDeviceInfo->
Aborts) ||
4885 DAC960_Critical(
"Physical Device %d:%d Errors: "
4886 "Parity = %d, Soft = %d, "
4887 "Hard = %d, Misc = %d\n",
4889 NewPhysicalDeviceInfo->
Channel,
4895 DAC960_Critical(
"Physical Device %d:%d Errors: "
4896 "Timeouts = %d, Retries = %d, "
4897 "Aborts = %d, Predicted = %d\n",
4899 NewPhysicalDeviceInfo->
Channel,
4902 NewPhysicalDeviceInfo->
Retries,
4903 NewPhysicalDeviceInfo->
Aborts,
4904 NewPhysicalDeviceInfo
4913 Controller->V2.NeedDeviceSerialNumberInformation =
true;
4914 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
4918 Controller->V2.PhysicalDeviceIndex++;
4922 unsigned int DeviceIndex;
4923 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex;
4924 DeviceIndex < DAC960_V2_MaxPhysicalDevices;
4928 Controller->V2.PhysicalDeviceInformation[DeviceIndex];
4930 Controller->V2.InquiryUnitSerialNumber[DeviceIndex];
4931 if (PhysicalDeviceInfo ==
NULL)
break;
4932 DAC960_Critical(
"Physical Device %d:%d No Longer Exists\n",
4936 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
NULL;
4937 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
NULL;
4938 kfree(PhysicalDeviceInfo);
4939 kfree(InquiryUnitSerialNumber);
4941 Controller->V2.NeedPhysicalDeviceInformation =
false;
4947 Controller->V2.NewLogicalDeviceInformation;
4948 unsigned short LogicalDeviceNumber =
4952 if (LogicalDeviceInfo ==
NULL)
4954 DAC960_V2_PhysicalDevice_T PhysicalDevice;
4955 PhysicalDevice.Controller = 0;
4957 PhysicalDevice.TargetID = NewLogicalDeviceInfo->
TargetID;
4958 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->
LogicalUnit;
4965 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
4966 "Now Exists%s\n", Controller,
4967 LogicalDeviceNumber,
4968 Controller->ControllerNumber,
4969 LogicalDeviceNumber,
4970 (LogicalDeviceInfo !=
NULL
4971 ?
"" :
" - Allocation Failed"));
4972 if (LogicalDeviceInfo !=
NULL)
4974 memset(LogicalDeviceInfo, 0,
4976 DAC960_ComputeGenericDiskInfo(Controller);
4979 if (LogicalDeviceInfo !=
NULL)
4981 unsigned long LogicalDeviceSize =
4982 NewLogicalDeviceInfo->ConfigurableDeviceSize;
4985 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
4986 "is now %s\n", Controller,
4987 LogicalDeviceNumber,
4988 Controller->ControllerNumber,
4989 LogicalDeviceNumber,
4995 ?
"CRITICAL" :
"OFFLINE"));
4996 if ((NewLogicalDeviceInfo->SoftErrors !=
4997 LogicalDeviceInfo->SoftErrors) ||
4998 (NewLogicalDeviceInfo->CommandsFailed !=
4999 LogicalDeviceInfo->CommandsFailed) ||
5000 (NewLogicalDeviceInfo->DeferredWriteErrors !=
5001 LogicalDeviceInfo->DeferredWriteErrors))
5002 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) Errors: "
5003 "Soft = %d, Failed = %d, Deferred Write = %d\n",
5004 Controller, LogicalDeviceNumber,
5005 Controller->ControllerNumber,
5006 LogicalDeviceNumber,
5007 NewLogicalDeviceInfo->SoftErrors,
5008 NewLogicalDeviceInfo->CommandsFailed,
5009 NewLogicalDeviceInfo->DeferredWriteErrors);
5011 DAC960_V2_ReportProgress(Controller,
5012 "Consistency Check",
5013 LogicalDeviceNumber,
5014 NewLogicalDeviceInfo
5015 ->ConsistencyCheckBlockNumber,
5018 DAC960_V2_ReportProgress(Controller,
5020 LogicalDeviceNumber,
5021 NewLogicalDeviceInfo
5022 ->RebuildBlockNumber,
5025 DAC960_V2_ReportProgress(Controller,
5026 "Background Initialization",
5027 LogicalDeviceNumber,
5028 NewLogicalDeviceInfo
5029 ->BackgroundInitializationBlockNumber,
5032 DAC960_V2_ReportProgress(Controller,
5033 "Foreground Initialization",
5034 LogicalDeviceNumber,
5035 NewLogicalDeviceInfo
5036 ->ForegroundInitializationBlockNumber,
5039 DAC960_V2_ReportProgress(Controller,
5041 LogicalDeviceNumber,
5042 NewLogicalDeviceInfo
5043 ->DataMigrationBlockNumber,
5046 DAC960_V2_ReportProgress(Controller,
5048 LogicalDeviceNumber,
5049 NewLogicalDeviceInfo
5050 ->PatrolOperationBlockNumber,
5054 DAC960_Progress(
"Logical Drive %d (/dev/rd/c%dd%d) "
5055 "Background Initialization %s\n",
5057 LogicalDeviceNumber,
5058 Controller->ControllerNumber,
5059 LogicalDeviceNumber,
5061 .LogicalDeviceInitialized
5062 ?
"Completed" :
"Failed"));
5063 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
5066 Controller->V2.LogicalDriveFoundDuringScan
5073 for (LogicalDriveNumber = 0;
5075 LogicalDriveNumber++)
5079 if (LogicalDeviceInfo ==
NULL ||
5080 Controller->V2.LogicalDriveFoundDuringScan
5081 [LogicalDriveNumber])
5083 DAC960_Critical(
"Logical Drive %d (/dev/rd/c%dd%d) "
5084 "No Longer Exists\n", Controller,
5086 Controller->ControllerNumber,
5087 LogicalDriveNumber);
5088 Controller->V2.LogicalDeviceInformation
5090 kfree(LogicalDeviceInfo);
5091 Controller->LogicalDriveInitiallyAccessible
5093 DAC960_ComputeGenericDiskInfo(Controller);
5095 Controller->V2.NeedLogicalDeviceInformation =
false;
5100 Controller->V2.InquiryUnitSerialNumber[Controller->V2.PhysicalDeviceIndex - 1];
5103 memset(InquiryUnitSerialNumber,
5107 memcpy(InquiryUnitSerialNumber,
5108 Controller->V2.NewInquiryUnitSerialNumber,
5111 Controller->V2.NeedDeviceSerialNumberInformation =
false;
5114 if (Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5115 - Controller->V2.NextEventSequenceNumber > 0)
5119 CommandMailbox->
GetEvent.EventSequenceNumberHigh16 =
5120 Controller->V2.NextEventSequenceNumber >> 16;
5121 CommandMailbox->
GetEvent.ControllerNumber = 0;
5122 CommandMailbox->
GetEvent.IOCTL_Opcode =
5124 CommandMailbox->
GetEvent.EventSequenceNumberLow16 =
5125 Controller->V2.NextEventSequenceNumber & 0xFFFF;
5126 CommandMailbox->
GetEvent.DataTransferMemoryAddress
5127 .ScatterGatherSegments[0]
5128 .SegmentDataPointer =
5129 Controller->V2.EventDMA;
5130 CommandMailbox->
GetEvent.DataTransferMemoryAddress
5131 .ScatterGatherSegments[0]
5133 CommandMailbox->
GetEvent.DataTransferSize;
5134 DAC960_QueueCommand(Command);
5137 if (Controller->V2.NeedPhysicalDeviceInformation)
5139 if (Controller->V2.NeedDeviceSerialNumberInformation)
5142 Controller->V2.NewInquiryUnitSerialNumber;
5145 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
5146 Controller->V2.NewPhysicalDeviceInformation->Channel,
5147 Controller->V2.NewPhysicalDeviceInformation->TargetID,
5148 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit - 1);
5151 DAC960_QueueCommand(Command);
5154 if (Controller->V2.StartPhysicalDeviceInformationScan)
5156 Controller->V2.PhysicalDeviceIndex = 0;
5157 Controller->V2.NewPhysicalDeviceInformation->Channel = 0;
5158 Controller->V2.NewPhysicalDeviceInformation->TargetID = 0;
5159 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit = 0;
5160 Controller->V2.StartPhysicalDeviceInformationScan =
false;
5166 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit;
5168 Controller->V2.NewPhysicalDeviceInformation->TargetID;
5170 Controller->V2.NewPhysicalDeviceInformation->Channel;
5174 .ScatterGatherSegments[0]
5175 .SegmentDataPointer =
5176 Controller->V2.NewPhysicalDeviceInformationDMA;
5178 .ScatterGatherSegments[0]
5181 DAC960_QueueCommand(Command);
5184 if (Controller->V2.NeedLogicalDeviceInformation)
5186 if (Controller->V2.StartLogicalDeviceInformationScan)
5189 for (LogicalDriveNumber = 0;
5191 LogicalDriveNumber++)
5192 Controller->V2.LogicalDriveFoundDuringScan
5193 [LogicalDriveNumber] =
false;
5194 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber = 0;
5195 Controller->V2.StartLogicalDeviceInformationScan =
false;
5201 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber;
5205 .ScatterGatherSegments[0]
5206 .SegmentDataPointer =
5207 Controller->V2.NewLogicalDeviceInformationDMA;
5209 .ScatterGatherSegments[0]
5212 DAC960_QueueCommand(Command);
5215 Controller->MonitoringTimerCount++;
5216 Controller->MonitoringTimer.expires =
5217 jiffies + DAC960_HealthStatusMonitoringInterval;
5218 add_timer(&Controller->MonitoringTimer);
5220 if (CommandType == DAC960_ImmediateCommand)
5223 Command->Completion =
NULL;
5226 if (CommandType == DAC960_QueuedCommand)
5232 Command->V2.KernelCommand =
NULL;
5233 DAC960_DeallocateCommand(Command);
5242 if (Controller->MonitoringCommandDeferred)
5244 Controller->MonitoringCommandDeferred =
false;
5245 DAC960_V2_QueueMonitoringCommand(Command);
5251 DAC960_DeallocateCommand(Command);
5255 wake_up(&Controller->CommandWaitQueue);
5263 static irqreturn_t DAC960_GEM_InterruptHandler(
int IRQ_Channel,
5264 void *DeviceIdentifier)
5266 DAC960_Controller_T *Controller = DeviceIdentifier;
5267 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5268 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5269 unsigned long flags;
5272 DAC960_GEM_AcknowledgeInterrupt(ControllerBaseAddress);
5273 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5274 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5277 NextStatusMailbox->Fields.CommandIdentifier;
5278 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5279 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5280 Command->V2.RequestSenseLength =
5281 NextStatusMailbox->Fields.RequestSenseLength;
5282 Command->V2.DataTransferResidue =
5283 NextStatusMailbox->Fields.DataTransferResidue;
5284 NextStatusMailbox->Words[0] = 0;
5285 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5286 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5287 DAC960_V2_ProcessCompletedCommand(Command);
5289 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5294 DAC960_ProcessRequest(Controller);
5295 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5304 static irqreturn_t DAC960_BA_InterruptHandler(
int IRQ_Channel,
5305 void *DeviceIdentifier)
5307 DAC960_Controller_T *Controller = DeviceIdentifier;
5308 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5309 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5310 unsigned long flags;
5313 DAC960_BA_AcknowledgeInterrupt(ControllerBaseAddress);
5314 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5315 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5318 NextStatusMailbox->Fields.CommandIdentifier;
5319 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5320 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5321 Command->V2.RequestSenseLength =
5322 NextStatusMailbox->Fields.RequestSenseLength;
5323 Command->V2.DataTransferResidue =
5324 NextStatusMailbox->Fields.DataTransferResidue;
5325 NextStatusMailbox->Words[0] = 0;
5326 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5327 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5328 DAC960_V2_ProcessCompletedCommand(Command);
5330 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5335 DAC960_ProcessRequest(Controller);
5336 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5346 static irqreturn_t DAC960_LP_InterruptHandler(
int IRQ_Channel,
5347 void *DeviceIdentifier)
5349 DAC960_Controller_T *Controller = DeviceIdentifier;
5350 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5351 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5352 unsigned long flags;
5355 DAC960_LP_AcknowledgeInterrupt(ControllerBaseAddress);
5356 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5357 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5360 NextStatusMailbox->Fields.CommandIdentifier;
5361 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5362 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5363 Command->V2.RequestSenseLength =
5364 NextStatusMailbox->Fields.RequestSenseLength;
5365 Command->V2.DataTransferResidue =
5366 NextStatusMailbox->Fields.DataTransferResidue;
5367 NextStatusMailbox->Words[0] = 0;
5368 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5369 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5370 DAC960_V2_ProcessCompletedCommand(Command);
5372 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5377 DAC960_ProcessRequest(Controller);
5378 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5388 static irqreturn_t DAC960_LA_InterruptHandler(
int IRQ_Channel,
5389 void *DeviceIdentifier)
5391 DAC960_Controller_T *Controller = DeviceIdentifier;
5392 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5393 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5394 unsigned long flags;
5397 DAC960_LA_AcknowledgeInterrupt(ControllerBaseAddress);
5398 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5399 while (NextStatusMailbox->Fields.Valid)
5402 NextStatusMailbox->Fields.CommandIdentifier;
5403 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5404 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5405 NextStatusMailbox->Word = 0;
5406 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5407 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5408 DAC960_V1_ProcessCompletedCommand(Command);
5410 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5415 DAC960_ProcessRequest(Controller);
5416 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5426 static irqreturn_t DAC960_PG_InterruptHandler(
int IRQ_Channel,
5427 void *DeviceIdentifier)
5429 DAC960_Controller_T *Controller = DeviceIdentifier;
5430 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5431 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5432 unsigned long flags;
5435 DAC960_PG_AcknowledgeInterrupt(ControllerBaseAddress);
5436 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5437 while (NextStatusMailbox->Fields.Valid)
5440 NextStatusMailbox->Fields.CommandIdentifier;
5441 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5442 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5443 NextStatusMailbox->Word = 0;
5444 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5445 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5446 DAC960_V1_ProcessCompletedCommand(Command);
5448 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5453 DAC960_ProcessRequest(Controller);
5454 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5464 static irqreturn_t DAC960_PD_InterruptHandler(
int IRQ_Channel,
5465 void *DeviceIdentifier)
5467 DAC960_Controller_T *Controller = DeviceIdentifier;
5468 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5469 unsigned long flags;
5472 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5475 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5476 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5477 Command->V1.CommandStatus =
5478 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5479 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5480 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5481 DAC960_V1_ProcessCompletedCommand(Command);
5487 DAC960_ProcessRequest(Controller);
5488 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5502 static irqreturn_t DAC960_P_InterruptHandler(
int IRQ_Channel,
5503 void *DeviceIdentifier)
5505 DAC960_Controller_T *Controller = DeviceIdentifier;
5506 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5507 unsigned long flags;
5510 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5513 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5514 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5516 DAC960_V1_CommandOpcode_T CommandOpcode =
5518 Command->V1.CommandStatus =
5519 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5520 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5521 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5522 switch (CommandOpcode)
5526 DAC960_P_To_PD_TranslateEnquiry(Controller->V1.NewEnquiry);
5529 Command->V1.CommandMailbox.Common.CommandOpcode =
5531 DAC960_P_To_PD_TranslateDeviceState(Controller->V1.NewDeviceState);
5534 Command->V1.CommandMailbox.Common.CommandOpcode =
DAC960_V1_Read;
5535 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5539 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5542 Command->V1.CommandMailbox.Common.CommandOpcode =
5544 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5547 Command->V1.CommandMailbox.Common.CommandOpcode =
5549 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5554 DAC960_V1_ProcessCompletedCommand(Command);
5560 DAC960_ProcessRequest(Controller);
5561 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5571 static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *Command)
5573 DAC960_Controller_T *Controller = Command->Controller;
5575 DAC960_V1_ClearCommand(Command);
5576 Command->CommandType = DAC960_MonitoringCommand;
5578 CommandMailbox->Type3.
BusAddress = Controller->V1.NewEnquiryDMA;
5579 DAC960_QueueCommand(Command);
5588 static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *Command)
5590 DAC960_Controller_T *Controller = Command->Controller;
5592 DAC960_V2_ClearCommand(Command);
5593 Command->CommandType = DAC960_MonitoringCommand;
5596 .DataTransferControllerToHost =
true;
5598 .NoAutoRequestSense =
true;
5604 .ScatterGatherSegments[0]
5605 .SegmentDataPointer =
5606 Controller->V2.NewControllerInformationDMA;
5608 .ScatterGatherSegments[0]
5611 DAC960_QueueCommand(Command);
5620 static void DAC960_MonitoringTimerFunction(
unsigned long TimerData)
5622 DAC960_Controller_T *Controller = (DAC960_Controller_T *) TimerData;
5624 unsigned long flags;
5626 if (Controller->FirmwareType == DAC960_V1_Controller)
5632 Command = DAC960_AllocateCommand(Controller);
5633 if (Command !=
NULL)
5634 DAC960_V1_QueueMonitoringCommand(Command);
5635 else Controller->MonitoringCommandDeferred =
true;
5636 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5641 &Controller->V2.ControllerInformation;
5642 unsigned int StatusChangeCounter =
5643 Controller->V2.HealthStatusBuffer->StatusChangeCounter;
5644 bool ForceMonitoringCommand =
false;
5645 if (
time_after(jiffies, Controller->SecondaryMonitoringTime
5646 + DAC960_SecondaryMonitoringInterval))
5649 for (LogicalDriveNumber = 0;
5651 LogicalDriveNumber++)
5655 if (LogicalDeviceInfo ==
NULL)
continue;
5657 .LogicalDeviceInitialized)
5659 ForceMonitoringCommand =
true;
5663 Controller->SecondaryMonitoringTime =
jiffies;
5665 if (StatusChangeCounter == Controller->V2.StatusChangeCounter &&
5666 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5667 == Controller->V2.NextEventSequenceNumber &&
5674 time_before(jiffies, Controller->PrimaryMonitoringTime
5675 + DAC960_MonitoringTimerInterval)) &&
5676 !ForceMonitoringCommand)
5678 Controller->MonitoringTimer.expires =
5679 jiffies + DAC960_HealthStatusMonitoringInterval;
5680 add_timer(&Controller->MonitoringTimer);
5683 Controller->V2.StatusChangeCounter = StatusChangeCounter;
5684 Controller->PrimaryMonitoringTime =
jiffies;
5690 Command = DAC960_AllocateCommand(Controller);
5691 if (Command !=
NULL)
5692 DAC960_V2_QueueMonitoringCommand(Command);
5693 else Controller->MonitoringCommandDeferred =
true;
5694 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5698 wake_up(&Controller->HealthStatusWaitQueue);
5708 static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
5711 unsigned char *NewStatusBuffer;
5712 if (Controller->InitialStatusLength + 1 +
5713 Controller->CurrentStatusLength + ByteCount + 1 <=
5714 Controller->CombinedStatusBufferLength)
5716 if (Controller->CombinedStatusBufferLength == 0)
5718 unsigned int NewStatusBufferLength = DAC960_InitialStatusBufferSize;
5719 while (NewStatusBufferLength < ByteCount)
5720 NewStatusBufferLength *= 2;
5721 Controller->CombinedStatusBuffer =
kmalloc(NewStatusBufferLength,
5723 if (Controller->CombinedStatusBuffer ==
NULL)
return false;
5724 Controller->CombinedStatusBufferLength = NewStatusBufferLength;
5727 NewStatusBuffer =
kmalloc(2 * Controller->CombinedStatusBufferLength,
5729 if (NewStatusBuffer ==
NULL)
5731 DAC960_Warning(
"Unable to expand Combined Status Buffer - Truncating\n",
5735 memcpy(NewStatusBuffer, Controller->CombinedStatusBuffer,
5736 Controller->CombinedStatusBufferLength);
5737 kfree(Controller->CombinedStatusBuffer);
5738 Controller->CombinedStatusBuffer = NewStatusBuffer;
5739 Controller->CombinedStatusBufferLength *= 2;
5740 Controller->CurrentStatusBuffer =
5741 &NewStatusBuffer[Controller->InitialStatusLength + 1];
5750 static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
5752 DAC960_Controller_T *Controller,
5755 static unsigned char Buffer[DAC960_LineBufferSize];
5756 static bool BeginningOfLine =
true;
5760 Length =
vsprintf(Buffer, Format, Arguments);
5762 if (Controller ==
NULL)
5763 printk(
"%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5764 DAC960_ControllerCount, Buffer);
5765 else if (MessageLevel == DAC960_AnnounceLevel ||
5766 MessageLevel == DAC960_InfoLevel)
5768 if (!Controller->ControllerInitialized)
5770 if (DAC960_CheckStatusBuffer(Controller, Length))
5772 strcpy(&Controller->CombinedStatusBuffer
5773 [Controller->InitialStatusLength],
5775 Controller->InitialStatusLength +=
Length;
5776 Controller->CurrentStatusBuffer =
5777 &Controller->CombinedStatusBuffer
5778 [Controller->InitialStatusLength + 1];
5780 if (MessageLevel == DAC960_AnnounceLevel)
5782 static int AnnouncementLines = 0;
5783 if (++AnnouncementLines <= 2)
5784 printk(
"%sDAC960: %s", DAC960_MessageLevelMap[MessageLevel],
5789 if (BeginningOfLine)
5791 if (Buffer[0] !=
'\n' || Length > 1)
5792 printk(
"%sDAC960#%d: %s",
5793 DAC960_MessageLevelMap[MessageLevel],
5794 Controller->ControllerNumber, Buffer);
5796 else printk(
"%s", Buffer);
5799 else if (DAC960_CheckStatusBuffer(Controller, Length))
5801 strcpy(&Controller->CurrentStatusBuffer[
5802 Controller->CurrentStatusLength], Buffer);
5803 Controller->CurrentStatusLength +=
Length;
5806 else if (MessageLevel == DAC960_ProgressLevel)
5808 strcpy(Controller->ProgressBuffer, Buffer);
5809 Controller->ProgressBufferLength =
Length;
5810 if (Controller->EphemeralProgressMessage)
5812 if (
time_after_eq(jiffies, Controller->LastProgressReportTime
5813 + DAC960_ProgressReportingInterval))
5815 printk(
"%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5816 Controller->ControllerNumber, Buffer);
5817 Controller->LastProgressReportTime =
jiffies;
5820 else printk(
"%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5821 Controller->ControllerNumber, Buffer);
5823 else if (MessageLevel == DAC960_UserCriticalLevel)
5825 strcpy(&Controller->UserStatusBuffer[Controller->UserStatusLength],
5827 Controller->UserStatusLength +=
Length;
5828 if (Buffer[0] !=
'\n' || Length > 1)
5829 printk(
"%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5830 Controller->ControllerNumber, Buffer);
5834 if (BeginningOfLine)
5835 printk(
"%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5836 Controller->ControllerNumber, Buffer);
5837 else printk(
"%s", Buffer);
5839 BeginningOfLine = (Buffer[Length-1] ==
'\n');
5849 static bool DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
5850 char *UserCommandString,
5851 unsigned char *Channel,
5852 unsigned char *TargetID)
5854 char *NewUserCommandString = UserCommandString;
5855 unsigned long XChannel, XTargetID;
5856 while (*UserCommandString ==
' ') UserCommandString++;
5857 if (UserCommandString == NewUserCommandString)
5859 XChannel =
simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5860 if (NewUserCommandString == UserCommandString ||
5861 *NewUserCommandString !=
':' ||
5862 XChannel >= Controller->Channels)
5864 UserCommandString = ++NewUserCommandString;
5865 XTargetID =
simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5866 if (NewUserCommandString == UserCommandString ||
5867 *NewUserCommandString !=
'\0' ||
5868 XTargetID >= Controller->Targets)
5870 *Channel = XChannel;
5871 *TargetID = XTargetID;
5882 static bool DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
5883 char *UserCommandString,
5884 unsigned char *LogicalDriveNumber)
5886 char *NewUserCommandString = UserCommandString;
5887 unsigned long XLogicalDriveNumber;
5888 while (*UserCommandString ==
' ') UserCommandString++;
5889 if (UserCommandString == NewUserCommandString)
5891 XLogicalDriveNumber =
5893 if (NewUserCommandString == UserCommandString ||
5894 *NewUserCommandString !=
'\0' ||
5895 XLogicalDriveNumber > DAC960_MaxLogicalDrives - 1)
5897 *LogicalDriveNumber = XLogicalDriveNumber;
5907 static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
5908 DAC960_Command_T *Command,
5909 unsigned char Channel,
5910 unsigned char TargetID,
5911 DAC960_V1_PhysicalDeviceState_T
5913 const unsigned char *DeviceStateString)
5920 CommandMailbox->Type3D.
Modifier = 0;
5921 DAC960_ExecuteCommand(Command);
5922 switch (Command->V1.CommandStatus)
5925 DAC960_UserCritical(
"%s of Physical Device %d:%d Succeeded\n", Controller,
5926 DeviceStateString, Channel, TargetID);
5929 DAC960_UserCritical(
"%s of Physical Device %d:%d Failed - "
5930 "Unable to Start Device\n", Controller,
5931 DeviceStateString, Channel, TargetID);
5934 DAC960_UserCritical(
"%s of Physical Device %d:%d Failed - "
5935 "No Device at Address\n", Controller,
5936 DeviceStateString, Channel, TargetID);
5939 DAC960_UserCritical(
"%s of Physical Device %d:%d Failed - "
5940 "Invalid Channel or Target or Modifier\n",
5941 Controller, DeviceStateString, Channel, TargetID);
5944 DAC960_UserCritical(
"%s of Physical Device %d:%d Failed - "
5945 "Channel Busy\n", Controller,
5946 DeviceStateString, Channel, TargetID);
5949 DAC960_UserCritical(
"%s of Physical Device %d:%d Failed - "
5950 "Unexpected Status %04X\n", Controller,
5951 DeviceStateString, Channel, TargetID,
5952 Command->V1.CommandStatus);
5963 static bool DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
5964 unsigned char *UserCommand)
5968 unsigned long flags;
5972 while ((Command = DAC960_AllocateCommand(Controller)) ==
NULL)
5973 DAC960_WaitForCommand(Controller);
5974 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5975 Controller->UserStatusLength = 0;
5976 DAC960_V1_ClearCommand(Command);
5977 Command->CommandType = DAC960_ImmediateCommand;
5978 CommandMailbox = &Command->V1.CommandMailbox;
5979 if (
strcmp(UserCommand,
"flush-cache") == 0)
5982 DAC960_ExecuteCommand(Command);
5983 DAC960_UserCritical(
"Cache Flush Completed\n", Controller);
5985 else if (
strncmp(UserCommand,
"kill", 4) == 0 &&
5986 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
5987 &Channel, &TargetID))
5994 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5996 else DAC960_UserCritical(
"Kill of Physical Device %d:%d Illegal\n",
5997 Controller, Channel, TargetID);
5999 else if (
strncmp(UserCommand,
"make-online", 11) == 0 &&
6000 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6001 &Channel, &TargetID))
6008 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
6010 else DAC960_UserCritical(
"Make Online of Physical Device %d:%d Illegal\n",
6011 Controller, Channel, TargetID);
6014 else if (
strncmp(UserCommand,
"make-standby", 12) == 0 &&
6015 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6016 &Channel, &TargetID))
6023 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
6025 else DAC960_UserCritical(
"Make Standby of Physical "
6026 "Device %d:%d Illegal\n",
6027 Controller, Channel, TargetID);
6029 else if (
strncmp(UserCommand,
"rebuild", 7) == 0 &&
6030 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6031 &Channel, &TargetID))
6036 DAC960_ExecuteCommand(Command);
6037 switch (Command->V1.CommandStatus)
6040 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Initiated\n",
6041 Controller, Channel, TargetID);
6044 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Failed - "
6045 "Attempt to Rebuild Online or "
6046 "Unresponsive Drive\n",
6047 Controller, Channel, TargetID);
6050 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Failed - "
6051 "New Disk Failed During Rebuild\n",
6052 Controller, Channel, TargetID);
6055 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Failed - "
6056 "Invalid Device Address\n",
6057 Controller, Channel, TargetID);
6060 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Failed - "
6061 "Rebuild or Consistency Check Already "
6062 "in Progress\n", Controller, Channel, TargetID);
6065 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d Failed - "
6066 "Unexpected Status %04X\n", Controller,
6067 Channel, TargetID, Command->V1.CommandStatus);
6071 else if (
strncmp(UserCommand,
"check-consistency", 17) == 0 &&
6072 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6073 &LogicalDriveNumber))
6078 DAC960_ExecuteCommand(Command);
6079 switch (Command->V1.CommandStatus)
6082 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6083 "(/dev/rd/c%dd%d) Initiated\n",
6084 Controller, LogicalDriveNumber,
6085 Controller->ControllerNumber,
6086 LogicalDriveNumber);
6089 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6090 "(/dev/rd/c%dd%d) Failed - "
6091 "Dependent Physical Device is DEAD\n",
6092 Controller, LogicalDriveNumber,
6093 Controller->ControllerNumber,
6094 LogicalDriveNumber);
6097 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6098 "(/dev/rd/c%dd%d) Failed - "
6099 "Invalid or Nonredundant Logical Drive\n",
6100 Controller, LogicalDriveNumber,
6101 Controller->ControllerNumber,
6102 LogicalDriveNumber);
6105 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6106 "(/dev/rd/c%dd%d) Failed - Rebuild or "
6107 "Consistency Check Already in Progress\n",
6108 Controller, LogicalDriveNumber,
6109 Controller->ControllerNumber,
6110 LogicalDriveNumber);
6113 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6114 "(/dev/rd/c%dd%d) Failed - "
6115 "Unexpected Status %04X\n",
6116 Controller, LogicalDriveNumber,
6117 Controller->ControllerNumber,
6118 LogicalDriveNumber, Command->V1.CommandStatus);
6122 else if (
strcmp(UserCommand,
"cancel-rebuild") == 0 ||
6123 strcmp(UserCommand,
"cancel-consistency-check") == 0)
6129 unsigned char *OldRebuildRateConstant;
6133 sizeof(
char), &OldRebuildRateConstantDMA);
6134 if (OldRebuildRateConstant ==
NULL) {
6135 DAC960_UserCritical(
"Cancellation of Rebuild or "
6136 "Consistency Check Failed - "
6143 CommandMailbox->Type3R.
BusAddress = OldRebuildRateConstantDMA;
6144 DAC960_ExecuteCommand(Command);
6145 switch (Command->V1.CommandStatus)
6148 DAC960_UserCritical(
"Rebuild or Consistency Check Cancelled\n",
6152 DAC960_UserCritical(
"Cancellation of Rebuild or "
6153 "Consistency Check Failed - "
6154 "Unexpected Status %04X\n",
6155 Controller, Command->V1.CommandStatus);
6160 OldRebuildRateConstant, OldRebuildRateConstantDMA);
6162 else DAC960_UserCritical(
"Illegal User Command: '%s'\n",
6163 Controller, UserCommand);
6166 DAC960_DeallocateCommand(Command);
6167 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6178 static bool DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6179 unsigned char Channel,
6180 unsigned char TargetID,
6182 *LogicalDeviceNumber)
6185 DAC960_Controller_T *Controller = Command->Controller;
6187 CommandMailbox = &Command->V2.CommandMailbox;
6188 memcpy(&SavedCommandMailbox, CommandMailbox,
6193 .DataTransferControllerToHost =
true;
6195 .NoAutoRequestSense =
true;
6202 CommandMailbox->
Common.DataTransferMemoryAddress
6203 .ScatterGatherSegments[0]
6204 .SegmentDataPointer =
6205 Controller->V2.PhysicalToLogicalDeviceDMA;
6206 CommandMailbox->
Common.DataTransferMemoryAddress
6207 .ScatterGatherSegments[0]
6209 CommandMailbox->
Common.DataTransferSize;
6211 DAC960_ExecuteCommand(Command);
6212 *LogicalDeviceNumber = Controller->V2.PhysicalToLogicalDevice->LogicalDeviceNumber;
6214 memcpy(CommandMailbox, &SavedCommandMailbox,
6225 static bool DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
6226 unsigned char *UserCommand)
6230 unsigned long flags;
6235 while ((Command = DAC960_AllocateCommand(Controller)) ==
NULL)
6236 DAC960_WaitForCommand(Controller);
6237 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6238 Controller->UserStatusLength = 0;
6239 DAC960_V2_ClearCommand(Command);
6240 Command->CommandType = DAC960_ImmediateCommand;
6241 CommandMailbox = &Command->V2.CommandMailbox;
6243 CommandMailbox->
Common.CommandControlBits.DataTransferControllerToHost =
true;
6244 CommandMailbox->
Common.CommandControlBits.NoAutoRequestSense =
true;
6245 if (
strcmp(UserCommand,
"flush-cache") == 0)
6250 DAC960_ExecuteCommand(Command);
6251 DAC960_UserCritical(
"Cache Flush Completed\n", Controller);
6253 else if (
strncmp(UserCommand,
"kill", 4) == 0 &&
6254 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
6255 &Channel, &TargetID) &&
6256 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6257 &LogicalDeviceNumber))
6259 CommandMailbox->
SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6265 DAC960_ExecuteCommand(Command);
6266 DAC960_UserCritical(
"Kill of Physical Device %d:%d %s\n",
6267 Controller, Channel, TargetID,
6268 (Command->V2.CommandStatus
6270 ?
"Succeeded" :
"Failed"));
6272 else if (
strncmp(UserCommand,
"make-online", 11) == 0 &&
6273 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6274 &Channel, &TargetID) &&
6275 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6276 &LogicalDeviceNumber))
6278 CommandMailbox->
SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6284 DAC960_ExecuteCommand(Command);
6285 DAC960_UserCritical(
"Make Online of Physical Device %d:%d %s\n",
6286 Controller, Channel, TargetID,
6287 (Command->V2.CommandStatus
6289 ?
"Succeeded" :
"Failed"));
6291 else if (
strncmp(UserCommand,
"make-standby", 12) == 0 &&
6292 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6293 &Channel, &TargetID) &&
6294 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6295 &LogicalDeviceNumber))
6297 CommandMailbox->
SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6303 DAC960_ExecuteCommand(Command);
6304 DAC960_UserCritical(
"Make Standby of Physical Device %d:%d %s\n",
6305 Controller, Channel, TargetID,
6306 (Command->V2.CommandStatus
6308 ?
"Succeeded" :
"Failed"));
6310 else if (
strncmp(UserCommand,
"rebuild", 7) == 0 &&
6311 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6312 &Channel, &TargetID) &&
6313 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6314 &LogicalDeviceNumber))
6320 DAC960_ExecuteCommand(Command);
6321 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d %s\n",
6322 Controller, Channel, TargetID,
6323 (Command->V2.CommandStatus
6325 ?
"Initiated" :
"Not Initiated"));
6327 else if (
strncmp(UserCommand,
"cancel-rebuild", 14) == 0 &&
6328 DAC960_ParsePhysicalDevice(Controller, &UserCommand[14],
6329 &Channel, &TargetID) &&
6330 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6331 &LogicalDeviceNumber))
6337 DAC960_ExecuteCommand(Command);
6338 DAC960_UserCritical(
"Rebuild of Physical Device %d:%d %s\n",
6339 Controller, Channel, TargetID,
6340 (Command->V2.CommandStatus
6342 ?
"Cancelled" :
"Not Cancelled"));
6344 else if (
strncmp(UserCommand,
"check-consistency", 17) == 0 &&
6345 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6346 &LogicalDriveNumber))
6354 DAC960_ExecuteCommand(Command);
6355 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6356 "(/dev/rd/c%dd%d) %s\n",
6357 Controller, LogicalDriveNumber,
6358 Controller->ControllerNumber,
6360 (Command->V2.CommandStatus
6362 ?
"Initiated" :
"Not Initiated"));
6364 else if (
strncmp(UserCommand,
"cancel-consistency-check", 24) == 0 &&
6365 DAC960_ParseLogicalDrive(Controller, &UserCommand[24],
6366 &LogicalDriveNumber))
6372 DAC960_ExecuteCommand(Command);
6373 DAC960_UserCritical(
"Consistency Check of Logical Drive %d "
6374 "(/dev/rd/c%dd%d) %s\n",
6375 Controller, LogicalDriveNumber,
6376 Controller->ControllerNumber,
6378 (Command->V2.CommandStatus
6380 ?
"Cancelled" :
"Not Cancelled"));
6382 else if (
strcmp(UserCommand,
"perform-discovery") == 0)
6385 DAC960_ExecuteCommand(Command);
6386 DAC960_UserCritical(
"Discovery %s\n", Controller,
6387 (Command->V2.CommandStatus
6389 ?
"Initiated" :
"Not Initiated"));
6394 .DataTransferControllerToHost =
true;
6396 .NoAutoRequestSense =
true;
6407 .ScatterGatherSegments[0]
6408 .SegmentDataPointer =
6409 Controller->V2.NewControllerInformationDMA;
6411 .ScatterGatherSegments[0]
6414 DAC960_ExecuteCommand(Command);
6415 while (Controller->V2.NewControllerInformation->PhysicalScanActive)
6417 DAC960_ExecuteCommand(Command);
6420 DAC960_UserCritical(
"Discovery Completed\n", Controller);
6423 else if (
strcmp(UserCommand,
"suppress-enclosure-messages") == 0)
6424 Controller->SuppressEnclosureMessages =
true;
6425 else DAC960_UserCritical(
"Illegal User Command: '%s'\n",
6426 Controller, UserCommand);
6429 DAC960_DeallocateCommand(Command);
6430 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6434 static int dac960_proc_show(
struct seq_file *
m,
void *
v)
6436 unsigned char *StatusMessage =
"OK\n";
6437 int ControllerNumber;
6438 for (ControllerNumber = 0;
6439 ControllerNumber < DAC960_ControllerCount;
6442 DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
6443 if (Controller ==
NULL)
continue;
6444 if (Controller->MonitoringAlertMode)
6446 StatusMessage =
"ALERT\n";
6461 .open = dac960_proc_open,
6467 static int dac960_initial_status_proc_show(
struct seq_file *m,
void *v)
6469 DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->
private;
6470 seq_printf(m,
"%.*s", Controller->InitialStatusLength, Controller->CombinedStatusBuffer);
6476 return single_open(file, dac960_initial_status_proc_show, PDE(inode)->
data);
6479 static const struct file_operations dac960_initial_status_proc_fops = {
6481 .open = dac960_initial_status_proc_open,
6487 static int dac960_current_status_proc_show(
struct seq_file *m,
void *v)
6489 DAC960_Controller_T *Controller = (DAC960_Controller_T *) m->
private;
6490 unsigned char *StatusMessage =
6491 "No Rebuild or Consistency Check in Progress\n";
6492 int ProgressMessageLength =
strlen(StatusMessage);
6493 if (jiffies != Controller->LastCurrentStatusTime)
6495 Controller->CurrentStatusLength = 0;
6496 DAC960_AnnounceDriver(Controller);
6497 DAC960_ReportControllerConfiguration(Controller);
6498 DAC960_ReportDeviceConfiguration(Controller);
6499 if (Controller->ProgressBufferLength > 0)
6500 ProgressMessageLength = Controller->ProgressBufferLength;
6501 if (DAC960_CheckStatusBuffer(Controller, 2 + ProgressMessageLength))
6503 unsigned char *CurrentStatusBuffer = Controller->CurrentStatusBuffer;
6504 CurrentStatusBuffer[Controller->CurrentStatusLength++] =
' ';
6505 CurrentStatusBuffer[Controller->CurrentStatusLength++] =
' ';
6506 if (Controller->ProgressBufferLength > 0)
6507 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6508 Controller->ProgressBuffer);
6510 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6512 Controller->CurrentStatusLength += ProgressMessageLength;
6514 Controller->LastCurrentStatusTime =
jiffies;
6516 seq_printf(m,
"%.*s", Controller->CurrentStatusLength, Controller->CurrentStatusBuffer);
6520 static int dac960_current_status_proc_open(
struct inode *inode,
struct file *file)
6522 return single_open(file, dac960_current_status_proc_show, PDE(inode)->
data);
6525 static const struct file_operations dac960_current_status_proc_fops = {
6527 .open = dac960_current_status_proc_open,
6533 static int dac960_user_command_proc_show(
struct seq_file *m,
void *v)
6535 DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->
private;
6537 seq_printf(m,
"%.*s", Controller->UserStatusLength, Controller->UserStatusBuffer);
6541 static int dac960_user_command_proc_open(
struct inode *inode,
struct file *file)
6543 return single_open(file, dac960_user_command_proc_show, PDE(inode)->
data);
6546 static ssize_t dac960_user_command_proc_write(
struct file *file,
6547 const char __user *Buffer,
6550 DAC960_Controller_T *Controller = (DAC960_Controller_T *) PDE(file->
f_path.dentry->d_inode)->data;
6551 unsigned char CommandBuffer[80];
6553 if (Count >
sizeof(CommandBuffer)-1)
return -
EINVAL;
6555 CommandBuffer[
Count] =
'\0';
6556 Length =
strlen(CommandBuffer);
6557 if (Length > 0 && CommandBuffer[Length-1] ==
'\n')
6558 CommandBuffer[--
Length] =
'\0';
6559 if (Controller->FirmwareType == DAC960_V1_Controller)
6560 return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)
6563 return (DAC960_V2_ExecuteUserCommand(Controller, CommandBuffer)
6569 .open = dac960_user_command_proc_open,
6573 .write = dac960_user_command_proc_write,
6581 static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller)
6585 if (DAC960_ProcDirectoryEntry ==
NULL) {
6587 proc_create(
"status", 0, DAC960_ProcDirectoryEntry,
6591 sprintf(Controller->ControllerName,
"c%d", Controller->ControllerNumber);
6592 ControllerProcEntry =
proc_mkdir(Controller->ControllerName,
6593 DAC960_ProcDirectoryEntry);
6594 proc_create_data(
"initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller);
6595 proc_create_data(
"current_status", 0, ControllerProcEntry, &dac960_current_status_proc_fops, Controller);
6597 Controller->ControllerProcEntry = ControllerProcEntry;
6606 static void DAC960_DestroyProcEntries(DAC960_Controller_T *Controller)
6608 if (Controller->ControllerProcEntry ==
NULL)
6614 Controller->ControllerProcEntry =
NULL;
6617 #ifdef DAC960_GAM_MINOR
6623 static long DAC960_gam_ioctl(
struct file *file,
unsigned int Request,
6624 unsigned long Argument)
6633 ErrorCode = DAC960_ControllerCount;
6641 int ControllerNumber;
6642 if (UserSpaceControllerInfo ==
NULL)
6644 else ErrorCode =
get_user(ControllerNumber,
6645 &UserSpaceControllerInfo->ControllerNumber);
6649 if (ControllerNumber < 0 ||
6650 ControllerNumber > DAC960_ControllerCount - 1) {
6653 Controller = DAC960_Controllers[ControllerNumber];
6654 if (Controller ==
NULL)
6658 ControllerInfo.
FirmwareType = Controller->FirmwareType;
6659 ControllerInfo.
Channels = Controller->Channels;
6660 ControllerInfo.
Targets = Controller->Targets;
6661 ControllerInfo.
PCI_Bus = Controller->Bus;
6662 ControllerInfo.
PCI_Device = Controller->Device;
6664 ControllerInfo.
IRQ_Channel = Controller->IRQ_Channel;
6665 ControllerInfo.
PCI_Address = Controller->PCI_Address;
6668 ErrorCode = (
copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
6678 DAC960_Command_T *Command =
NULL;
6684 unsigned long flags;
6685 int ControllerNumber, DataTransferLength;
6686 unsigned char *DataTransferBuffer =
NULL;
6688 if (UserSpaceUserCommand ==
NULL) {
6699 if (ControllerNumber < 0 ||
6700 ControllerNumber > DAC960_ControllerCount - 1)
6702 Controller = DAC960_Controllers[ControllerNumber];
6703 if (Controller ==
NULL)
6706 if (Controller->FirmwareType != DAC960_V1_Controller)
6710 if (CommandOpcode & 0x80)
6721 if (!((DataTransferLength == 0 &&
6723 == DAC960_V1_DCDB_NoDataTransfer) ||
6724 (DataTransferLength > 0 &&
6726 == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
6727 (DataTransferLength < 0 &&
6729 == DAC960_V1_DCDB_DataTransferSystemToDevice)))
6731 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
6732 !=
abs(DataTransferLength))
6736 if (DCDB_IOBUF ==
NULL) {
6742 if (DataTransferLength > 0)
6745 DataTransferLength, &DataTransferBufferDMA);
6746 if (DataTransferBuffer ==
NULL)
6748 memset(DataTransferBuffer, 0, DataTransferLength);
6750 else if (DataTransferLength < 0)
6753 -DataTransferLength, &DataTransferBufferDMA);
6754 if (DataTransferBuffer ==
NULL)
6758 -DataTransferLength)) {
6766 while ((Command = DAC960_AllocateCommand(Controller)) ==
NULL)
6767 DAC960_WaitForCommand(Controller);
6768 while (Controller->V1.DirectCommandActive[DCDB.
Channel]
6771 spin_unlock_irq(&Controller->queue_lock);
6773 !Controller->V1.DirectCommandActive
6775 spin_lock_irq(&Controller->queue_lock);
6777 Controller->V1.DirectCommandActive[DCDB.
Channel]
6779 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6780 DAC960_V1_ClearCommand(Command);
6781 Command->CommandType = DAC960_ImmediateCommand;
6784 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
6785 DCDB.BusAddress = DataTransferBufferDMA;
6791 while ((Command = DAC960_AllocateCommand(Controller)) ==
NULL)
6792 DAC960_WaitForCommand(Controller);
6793 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6794 DAC960_V1_ClearCommand(Command);
6795 Command->CommandType = DAC960_ImmediateCommand;
6798 if (DataTransferBuffer !=
NULL)
6799 Command->V1.CommandMailbox.Type3.BusAddress =
6800 DataTransferBufferDMA;
6802 DAC960_ExecuteCommand(Command);
6803 CommandStatus = Command->V1.CommandStatus;
6805 DAC960_DeallocateCommand(Command);
6806 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6807 if (DataTransferLength > 0)
6810 DataTransferBuffer, DataTransferLength)) {
6821 Controller->V1.DirectCommandActive[DCDB.
Channel]
6831 if (DataTransferBuffer !=
NULL)
6833 DataTransferBuffer, DataTransferBufferDMA);
6834 if (DCDB_IOBUF !=
NULL)
6836 DCDB_IOBUF, DCDB_IOBUFDMA);
6845 DAC960_Command_T *Command =
NULL;
6848 unsigned long flags;
6849 int ControllerNumber, DataTransferLength;
6850 int DataTransferResidue, RequestSenseLength;
6851 unsigned char *DataTransferBuffer =
NULL;
6853 unsigned char *RequestSenseBuffer =
NULL;
6857 if (UserSpaceUserCommand ==
NULL)
6866 if (ControllerNumber < 0 ||
6867 ControllerNumber > DAC960_ControllerCount - 1)
6869 Controller = DAC960_Controllers[ControllerNumber];
6870 if (Controller ==
NULL)
6872 if (Controller->FirmwareType != DAC960_V2_Controller){
6878 if (DataTransferLength > 0)
6881 DataTransferLength, &DataTransferBufferDMA);
6882 if (DataTransferBuffer ==
NULL)
6884 memset(DataTransferBuffer, 0, DataTransferLength);
6886 else if (DataTransferLength < 0)
6889 -DataTransferLength, &DataTransferBufferDMA);
6890 if (DataTransferBuffer ==
NULL)
6894 -DataTransferLength)) {
6900 if (RequestSenseLength > 0)
6903 RequestSenseLength, &RequestSenseBufferDMA);
6904 if (RequestSenseBuffer ==
NULL)
6909 memset(RequestSenseBuffer, 0, RequestSenseLength);
6912 while ((Command = DAC960_AllocateCommand(Controller)) ==
NULL)
6913 DAC960_WaitForCommand(Controller);
6914 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6915 DAC960_V2_ClearCommand(Command);
6916 Command->CommandType = DAC960_ImmediateCommand;
6917 CommandMailbox = &Command->V2.CommandMailbox;
6920 CommandMailbox->
Common.CommandControlBits
6921 .AdditionalScatterGatherListMemory =
false;
6922 CommandMailbox->
Common.CommandControlBits
6923 .NoAutoRequestSense =
true;
6924 CommandMailbox->
Common.DataTransferSize = 0;
6925 CommandMailbox->
Common.DataTransferPageNumber = 0;
6926 memset(&CommandMailbox->
Common.DataTransferMemoryAddress, 0,
6928 if (DataTransferLength != 0)
6930 if (DataTransferLength > 0)
6932 CommandMailbox->
Common.CommandControlBits
6933 .DataTransferControllerToHost =
true;
6934 CommandMailbox->
Common.DataTransferSize = DataTransferLength;
6938 CommandMailbox->
Common.CommandControlBits
6939 .DataTransferControllerToHost =
false;
6940 CommandMailbox->
Common.DataTransferSize = -DataTransferLength;
6942 CommandMailbox->
Common.DataTransferMemoryAddress
6943 .ScatterGatherSegments[0]
6944 .SegmentDataPointer = DataTransferBufferDMA;
6945 CommandMailbox->
Common.DataTransferMemoryAddress
6946 .ScatterGatherSegments[0]
6948 CommandMailbox->
Common.DataTransferSize;
6950 if (RequestSenseLength > 0)
6952 CommandMailbox->
Common.CommandControlBits
6953 .NoAutoRequestSense =
false;
6954 CommandMailbox->
Common.RequestSenseSize = RequestSenseLength;
6955 CommandMailbox->
Common.RequestSenseBusAddress =
6956 RequestSenseBufferDMA;
6958 DAC960_ExecuteCommand(Command);
6959 CommandStatus = Command->V2.CommandStatus;
6960 RequestSenseLength = Command->V2.RequestSenseLength;
6961 DataTransferResidue = Command->V2.DataTransferResidue;
6963 DAC960_DeallocateCommand(Command);
6964 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6967 if (
copy_to_user(&UserSpaceUserCommand->DataTransferLength,
6968 &DataTransferResidue,
6969 sizeof(DataTransferResidue))) {
6973 if (
copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
6974 &RequestSenseLength,
sizeof(RequestSenseLength))) {
6978 if (DataTransferLength > 0)
6981 DataTransferBuffer, DataTransferLength)) {
6986 if (RequestSenseLength > 0)
6989 RequestSenseBuffer, RequestSenseLength)) {
6997 DataTransferBuffer, DataTransferBufferDMA);
6998 if (RequestSenseBuffer !=
NULL)
7000 RequestSenseBuffer, RequestSenseBufferDMA);
7010 int ControllerNumber;
7011 if (UserSpaceGetHealthStatus ==
NULL) {
7022 if (ControllerNumber < 0 ||
7023 ControllerNumber > DAC960_ControllerCount - 1)
7025 Controller = DAC960_Controllers[ControllerNumber];
7026 if (Controller ==
NULL)
7028 if (Controller->FirmwareType != DAC960_V2_Controller) {
7038 while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
7040 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
7044 DAC960_MonitoringTimerInterval);
7045 if (signal_pending(
current)) {
7051 Controller->V2.HealthStatusBuffer,
7066 .unlocked_ioctl = DAC960_gam_ioctl,
7076 static int DAC960_gam_init(
void)
7086 static void DAC960_gam_cleanup(
void)
7093 static struct DAC960_privdata DAC960_GEM_privdata = {
7094 .HardwareType = DAC960_GEM_Controller,
7095 .FirmwareType = DAC960_V2_Controller,
7096 .InterruptHandler = DAC960_GEM_InterruptHandler,
7097 .MemoryWindowSize = DAC960_GEM_RegisterWindowSize,
7101 static struct DAC960_privdata DAC960_BA_privdata = {
7102 .HardwareType = DAC960_BA_Controller,
7103 .FirmwareType = DAC960_V2_Controller,
7104 .InterruptHandler = DAC960_BA_InterruptHandler,
7105 .MemoryWindowSize = DAC960_BA_RegisterWindowSize,
7108 static struct DAC960_privdata DAC960_LP_privdata = {
7109 .HardwareType = DAC960_LP_Controller,
7110 .FirmwareType = DAC960_V2_Controller,
7111 .InterruptHandler = DAC960_LP_InterruptHandler,
7112 .MemoryWindowSize = DAC960_LP_RegisterWindowSize,
7115 static struct DAC960_privdata DAC960_LA_privdata = {
7116 .HardwareType = DAC960_LA_Controller,
7117 .FirmwareType = DAC960_V1_Controller,
7118 .InterruptHandler = DAC960_LA_InterruptHandler,
7119 .MemoryWindowSize = DAC960_LA_RegisterWindowSize,
7122 static struct DAC960_privdata DAC960_PG_privdata = {
7123 .HardwareType = DAC960_PG_Controller,
7124 .FirmwareType = DAC960_V1_Controller,
7125 .InterruptHandler = DAC960_PG_InterruptHandler,
7126 .MemoryWindowSize = DAC960_PG_RegisterWindowSize,
7129 static struct DAC960_privdata DAC960_PD_privdata = {
7130 .HardwareType = DAC960_PD_Controller,
7131 .FirmwareType = DAC960_V1_Controller,
7132 .InterruptHandler = DAC960_PD_InterruptHandler,
7133 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7136 static struct DAC960_privdata DAC960_P_privdata = {
7137 .HardwareType = DAC960_P_Controller,
7138 .FirmwareType = DAC960_V1_Controller,
7139 .InterruptHandler = DAC960_P_InterruptHandler,
7140 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7149 .driver_data = (
unsigned long) &DAC960_GEM_privdata,
7156 .driver_data = (
unsigned long) &DAC960_BA_privdata,
7163 .driver_data = (
unsigned long) &DAC960_LP_privdata,
7170 .driver_data = (
unsigned long) &DAC960_LA_privdata,
7177 .driver_data = (
unsigned long) &DAC960_PG_privdata,
7184 .driver_data = (
unsigned long) &DAC960_PD_privdata,
7191 .driver_data = (
unsigned long) &DAC960_P_privdata,
7198 static struct pci_driver DAC960_pci_driver = {
7200 .id_table = DAC960_id_table,
7201 .probe = DAC960_Probe,
7202 .remove = DAC960_Remove,
7205 static int __init DAC960_init_module(
void)
7209 ret = pci_register_driver(&DAC960_pci_driver);
7210 #ifdef DAC960_GAM_MINOR
7217 static void __exit DAC960_cleanup_module(
void)
7221 #ifdef DAC960_GAM_MINOR
7222 DAC960_gam_cleanup();
7225 for (i = 0; i < DAC960_ControllerCount; i++) {
7226 DAC960_Controller_T *Controller = DAC960_Controllers[
i];
7227 if (Controller ==
NULL)
7229 DAC960_FinalizeController(Controller);
7231 if (DAC960_ProcDirectoryEntry !=
NULL) {
7235 DAC960_ControllerCount = 0;