3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
7 This program is free software; you may redistribute and/or modify it under
8 the terms of the GNU General Public License Version 2 as published by the
9 Free Software Foundation.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #define DAC960_DriverVersion "2.5.47"
20 #define DAC960_DriverDate "14 November 2002"
23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/miscdevice.h>
26 #include <linux/blkdev.h>
27 #include <linux/bio.h>
28 #include <linux/completion.h>
29 #include <linux/delay.h>
30 #include <linux/genhd.h>
31 #include <linux/hdreg.h>
32 #include <linux/blkpg.h>
33 #include <linux/interrupt.h>
34 #include <linux/ioport.h>
36 #include <linux/slab.h>
37 #include <linux/proc_fs.h>
38 #include <linux/reboot.h>
39 #include <linux/spinlock.h>
40 #include <linux/timer.h>
41 #include <linux/pci.h>
42 #include <linux/init.h>
44 #include <asm/uaccess.h>
47 #define DAC960_GAM_MINOR 252
50 static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
51 static int DAC960_ControllerCount;
52 static struct proc_dir_entry *DAC960_ProcDirectoryEntry;
54 static long disk_size(DAC960_Controller_T *p, int drive_nr)
56 if (p->FirmwareType == DAC960_V1_Controller) {
57 if (drive_nr >= p->LogicalDriveCount)
59 return p->V1.LogicalDriveInformation[drive_nr].
62 DAC960_V2_LogicalDeviceInfo_T *i =
63 p->V2.LogicalDeviceInformation[drive_nr];
66 return i->ConfigurableDeviceSize;
70 static int DAC960_open(struct inode *inode, struct file *file)
72 struct gendisk *disk = inode->i_bdev->bd_disk;
73 DAC960_Controller_T *p = disk->queue->queuedata;
74 int drive_nr = (long)disk->private_data;
76 if (p->FirmwareType == DAC960_V1_Controller) {
77 if (p->V1.LogicalDriveInformation[drive_nr].
78 LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
81 DAC960_V2_LogicalDeviceInfo_T *i =
82 p->V2.LogicalDeviceInformation[drive_nr];
83 if (!i || i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
87 check_disk_change(inode->i_bdev);
89 if (!get_capacity(p->disks[drive_nr]))
94 static int DAC960_ioctl(struct inode *inode, struct file *file,
95 unsigned int cmd, unsigned long arg)
97 struct gendisk *disk = inode->i_bdev->bd_disk;
98 DAC960_Controller_T *p = disk->queue->queuedata;
99 int drive_nr = (long)disk->private_data;
100 struct hd_geometry g;
101 struct hd_geometry __user *loc = (struct hd_geometry __user *)arg;
103 if (cmd != HDIO_GETGEO || !loc)
106 if (p->FirmwareType == DAC960_V1_Controller) {
107 g.heads = p->V1.GeometryTranslationHeads;
108 g.sectors = p->V1.GeometryTranslationSectors;
109 g.cylinders = p->V1.LogicalDriveInformation[drive_nr].
110 LogicalDriveSize / (g.heads * g.sectors);
112 DAC960_V2_LogicalDeviceInfo_T *i =
113 p->V2.LogicalDeviceInformation[drive_nr];
114 switch (i->DriveGeometry) {
115 case DAC960_V2_Geometry_128_32:
119 case DAC960_V2_Geometry_255_63:
124 DAC960_Error("Illegal Logical Device Geometry %d\n",
125 p, i->DriveGeometry);
129 g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors);
132 g.start = get_start_sect(inode->i_bdev);
134 return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0;
137 static int DAC960_media_changed(struct gendisk *disk)
139 DAC960_Controller_T *p = disk->queue->queuedata;
140 int drive_nr = (long)disk->private_data;
142 if (!p->LogicalDriveInitiallyAccessible[drive_nr])
147 static int DAC960_revalidate_disk(struct gendisk *disk)
149 DAC960_Controller_T *p = disk->queue->queuedata;
150 int unit = (long)disk->private_data;
152 set_capacity(disk, disk_size(p, unit));
156 static struct block_device_operations DAC960_BlockDeviceOperations = {
157 .owner = THIS_MODULE,
159 .ioctl = DAC960_ioctl,
160 .media_changed = DAC960_media_changed,
161 .revalidate_disk = DAC960_revalidate_disk,
166 DAC960_AnnounceDriver announces the Driver Version and Date, Author's Name,
167 Copyright Notice, and Electronic Mail Address.
170 static void DAC960_AnnounceDriver(DAC960_Controller_T *Controller)
172 DAC960_Announce("***** DAC960 RAID Driver Version "
173 DAC960_DriverVersion " of "
174 DAC960_DriverDate " *****\n", Controller);
175 DAC960_Announce("Copyright 1998-2001 by Leonard N. Zubkoff "
176 "<lnz@dandelion.com>\n", Controller);
181 DAC960_Failure prints a standardized error message, and then returns false.
184 static boolean DAC960_Failure(DAC960_Controller_T *Controller,
185 unsigned char *ErrorMessage)
187 DAC960_Error("While configuring DAC960 PCI RAID Controller at\n",
189 if (Controller->IO_Address == 0)
190 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
191 "PCI Address 0x%X\n", Controller,
192 Controller->Bus, Controller->Device,
193 Controller->Function, Controller->PCI_Address);
194 else DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
195 "0x%X PCI Address 0x%X\n", Controller,
196 Controller->Bus, Controller->Device,
197 Controller->Function, Controller->IO_Address,
198 Controller->PCI_Address);
199 DAC960_Error("%s FAILED - DETACHING\n", Controller, ErrorMessage);
204 init_dma_loaf() and slice_dma_loaf() are helper functions for
205 aggregating the dma-mapped memory for a well-known collection of
206 data structures that are of different lengths.
208 These routines don't guarantee any alignment. The caller must
209 include any space needed for alignment in the sizes of the structures
213 static boolean init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
217 dma_addr_t dma_handle;
219 cpu_addr = pci_alloc_consistent(dev, len, &dma_handle);
220 if (cpu_addr == NULL)
223 loaf->cpu_free = loaf->cpu_base = cpu_addr;
224 loaf->dma_free =loaf->dma_base = dma_handle;
226 memset(cpu_addr, 0, len);
230 static void *slice_dma_loaf(struct dma_loaf *loaf, size_t len,
231 dma_addr_t *dma_handle)
233 void *cpu_end = loaf->cpu_free + len;
234 void *cpu_addr = loaf->cpu_free;
236 if (cpu_end > loaf->cpu_base + loaf->length)
238 *dma_handle = loaf->dma_free;
239 loaf->cpu_free = cpu_end;
240 loaf->dma_free += len;
244 static void free_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf_handle)
246 if (loaf_handle->cpu_base != NULL)
247 pci_free_consistent(dev, loaf_handle->length,
248 loaf_handle->cpu_base, loaf_handle->dma_base);
253 DAC960_CreateAuxiliaryStructures allocates and initializes the auxiliary
254 data structures for Controller. It returns true on success and false on
258 static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
260 int CommandAllocationLength, CommandAllocationGroupSize;
261 int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount;
262 void *AllocationPointer = NULL;
263 void *ScatterGatherCPU = NULL;
264 dma_addr_t ScatterGatherDMA;
265 struct pci_pool *ScatterGatherPool;
266 void *RequestSenseCPU = NULL;
267 dma_addr_t RequestSenseDMA;
268 struct pci_pool *RequestSensePool = NULL;
270 if (Controller->FirmwareType == DAC960_V1_Controller)
272 CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker);
273 CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
274 ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather",
275 Controller->PCIDevice,
276 DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T),
277 sizeof(DAC960_V1_ScatterGatherSegment_T), 0);
278 if (ScatterGatherPool == NULL)
279 return DAC960_Failure(Controller,
280 "AUXILIARY STRUCTURE CREATION (SG)");
281 Controller->ScatterGatherPool = ScatterGatherPool;
285 CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker);
286 CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
287 ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather",
288 Controller->PCIDevice,
289 DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
290 sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
291 if (ScatterGatherPool == NULL)
292 return DAC960_Failure(Controller,
293 "AUXILIARY STRUCTURE CREATION (SG)");
294 RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
295 Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
297 if (RequestSensePool == NULL) {
298 pci_pool_destroy(ScatterGatherPool);
299 return DAC960_Failure(Controller,
300 "AUXILIARY STRUCTURE CREATION (SG)");
302 Controller->ScatterGatherPool = ScatterGatherPool;
303 Controller->V2.RequestSensePool = RequestSensePool;
305 Controller->CommandAllocationGroupSize = CommandAllocationGroupSize;
306 Controller->FreeCommands = NULL;
307 for (CommandIdentifier = 1;
308 CommandIdentifier <= Controller->DriverQueueDepth;
311 DAC960_Command_T *Command;
312 if (--CommandsRemaining <= 0)
315 Controller->DriverQueueDepth - CommandIdentifier + 1;
316 if (CommandsRemaining > CommandAllocationGroupSize)
317 CommandsRemaining = CommandAllocationGroupSize;
318 CommandGroupByteCount =
319 CommandsRemaining * CommandAllocationLength;
320 AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC);
321 if (AllocationPointer == NULL)
322 return DAC960_Failure(Controller,
323 "AUXILIARY STRUCTURE CREATION");
324 memset(AllocationPointer, 0, CommandGroupByteCount);
326 Command = (DAC960_Command_T *) AllocationPointer;
327 AllocationPointer += CommandAllocationLength;
328 Command->CommandIdentifier = CommandIdentifier;
329 Command->Controller = Controller;
330 Command->Next = Controller->FreeCommands;
331 Controller->FreeCommands = Command;
332 Controller->Commands[CommandIdentifier-1] = Command;
333 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC,
335 if (ScatterGatherCPU == NULL)
336 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
338 if (RequestSensePool != NULL) {
339 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC,
341 if (RequestSenseCPU == NULL) {
342 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
344 return DAC960_Failure(Controller,
345 "AUXILIARY STRUCTURE CREATION");
348 if (Controller->FirmwareType == DAC960_V1_Controller) {
349 Command->cmd_sglist = Command->V1.ScatterList;
350 Command->V1.ScatterGatherList =
351 (DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU;
352 Command->V1.ScatterGatherListDMA = ScatterGatherDMA;
354 Command->cmd_sglist = Command->V2.ScatterList;
355 Command->V2.ScatterGatherList =
356 (DAC960_V2_ScatterGatherSegment_T *)ScatterGatherCPU;
357 Command->V2.ScatterGatherListDMA = ScatterGatherDMA;
358 Command->V2.RequestSense =
359 (DAC960_SCSI_RequestSense_T *)RequestSenseCPU;
360 Command->V2.RequestSenseDMA = RequestSenseDMA;
368 DAC960_DestroyAuxiliaryStructures deallocates the auxiliary data
369 structures for Controller.
372 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
375 struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
376 struct pci_pool *RequestSensePool = NULL;
377 void *ScatterGatherCPU;
378 dma_addr_t ScatterGatherDMA;
379 void *RequestSenseCPU;
380 dma_addr_t RequestSenseDMA;
381 DAC960_Command_T *CommandGroup = NULL;
384 if (Controller->FirmwareType == DAC960_V2_Controller)
385 RequestSensePool = Controller->V2.RequestSensePool;
387 Controller->FreeCommands = NULL;
388 for (i = 0; i < Controller->DriverQueueDepth; i++)
390 DAC960_Command_T *Command = Controller->Commands[i];
395 if (Controller->FirmwareType == DAC960_V1_Controller) {
396 ScatterGatherCPU = (void *)Command->V1.ScatterGatherList;
397 ScatterGatherDMA = Command->V1.ScatterGatherListDMA;
398 RequestSenseCPU = NULL;
399 RequestSenseDMA = (dma_addr_t)0;
401 ScatterGatherCPU = (void *)Command->V2.ScatterGatherList;
402 ScatterGatherDMA = Command->V2.ScatterGatherListDMA;
403 RequestSenseCPU = (void *)Command->V2.RequestSense;
404 RequestSenseDMA = Command->V2.RequestSenseDMA;
406 if (ScatterGatherCPU != NULL)
407 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA);
408 if (RequestSenseCPU != NULL)
409 pci_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA);
411 if ((Command->CommandIdentifier
412 % Controller->CommandAllocationGroupSize) == 1) {
414 * We can't free the group of commands until all of the
415 * request sense and scatter gather dma structures are free.
416 * Remember the beginning of the group, but don't free it
417 * until we've reached the beginning of the next group.
419 if (CommandGroup != NULL)
421 CommandGroup = Command;
423 Controller->Commands[i] = NULL;
425 if (CommandGroup != NULL)
428 if (Controller->CombinedStatusBuffer != NULL)
430 kfree(Controller->CombinedStatusBuffer);
431 Controller->CombinedStatusBuffer = NULL;
432 Controller->CurrentStatusBuffer = NULL;
435 if (ScatterGatherPool != NULL)
436 pci_pool_destroy(ScatterGatherPool);
437 if (Controller->FirmwareType == DAC960_V1_Controller) return;
439 if (RequestSensePool != NULL)
440 pci_pool_destroy(RequestSensePool);
442 for (i = 0; i < DAC960_MaxLogicalDrives; i++)
443 if (Controller->V2.LogicalDeviceInformation[i] != NULL)
445 kfree(Controller->V2.LogicalDeviceInformation[i]);
446 Controller->V2.LogicalDeviceInformation[i] = NULL;
449 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++)
451 if (Controller->V2.PhysicalDeviceInformation[i] != NULL)
453 kfree(Controller->V2.PhysicalDeviceInformation[i]);
454 Controller->V2.PhysicalDeviceInformation[i] = NULL;
456 if (Controller->V2.InquiryUnitSerialNumber[i] != NULL)
458 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
459 Controller->V2.InquiryUnitSerialNumber[i] = NULL;
466 DAC960_V1_ClearCommand clears critical fields of Command for DAC960 V1
467 Firmware Controllers.
470 static inline void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
472 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
473 memset(CommandMailbox, 0, sizeof(DAC960_V1_CommandMailbox_T));
474 Command->V1.CommandStatus = 0;
479 DAC960_V2_ClearCommand clears critical fields of Command for DAC960 V2
480 Firmware Controllers.
483 static inline void DAC960_V2_ClearCommand(DAC960_Command_T *Command)
485 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
486 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
487 Command->V2.CommandStatus = 0;
492 DAC960_AllocateCommand allocates a Command structure from Controller's
493 free list. During driver initialization, a special initialization command
494 has been placed on the free list to guarantee that command allocation can
498 static inline DAC960_Command_T *DAC960_AllocateCommand(DAC960_Controller_T
501 DAC960_Command_T *Command = Controller->FreeCommands;
502 if (Command == NULL) return NULL;
503 Controller->FreeCommands = Command->Next;
504 Command->Next = NULL;
510 DAC960_DeallocateCommand deallocates Command, returning it to Controller's
514 static inline void DAC960_DeallocateCommand(DAC960_Command_T *Command)
516 DAC960_Controller_T *Controller = Command->Controller;
518 Command->Request = NULL;
519 Command->Next = Controller->FreeCommands;
520 Controller->FreeCommands = Command;
525 DAC960_WaitForCommand waits for a wake_up on Controller's Command Wait Queue.
528 static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
530 spin_unlock_irq(&Controller->queue_lock);
531 __wait_event(Controller->CommandWaitQueue, Controller->FreeCommands);
532 spin_lock_irq(&Controller->queue_lock);
537 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
540 static void DAC960_BA_QueueCommand(DAC960_Command_T *Command)
542 DAC960_Controller_T *Controller = Command->Controller;
543 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
544 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
545 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
546 Controller->V2.NextCommandMailbox;
547 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
548 DAC960_BA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
549 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
550 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
551 DAC960_BA_MemoryMailboxNewCommand(ControllerBaseAddress);
552 Controller->V2.PreviousCommandMailbox2 =
553 Controller->V2.PreviousCommandMailbox1;
554 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
555 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
556 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
557 Controller->V2.NextCommandMailbox = NextCommandMailbox;
562 DAC960_LP_QueueCommand queues Command for DAC960 LP Series Controllers.
565 static void DAC960_LP_QueueCommand(DAC960_Command_T *Command)
567 DAC960_Controller_T *Controller = Command->Controller;
568 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
569 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
570 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
571 Controller->V2.NextCommandMailbox;
572 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
573 DAC960_LP_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
574 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
575 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
576 DAC960_LP_MemoryMailboxNewCommand(ControllerBaseAddress);
577 Controller->V2.PreviousCommandMailbox2 =
578 Controller->V2.PreviousCommandMailbox1;
579 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
580 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
581 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
582 Controller->V2.NextCommandMailbox = NextCommandMailbox;
587 DAC960_LA_QueueCommandDualMode queues Command for DAC960 LA Series
588 Controllers with Dual Mode Firmware.
591 static void DAC960_LA_QueueCommandDualMode(DAC960_Command_T *Command)
593 DAC960_Controller_T *Controller = Command->Controller;
594 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
595 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
596 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
597 Controller->V1.NextCommandMailbox;
598 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
599 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
600 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
601 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
602 DAC960_LA_MemoryMailboxNewCommand(ControllerBaseAddress);
603 Controller->V1.PreviousCommandMailbox2 =
604 Controller->V1.PreviousCommandMailbox1;
605 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
606 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
607 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
608 Controller->V1.NextCommandMailbox = NextCommandMailbox;
613 DAC960_LA_QueueCommandSingleMode queues Command for DAC960 LA Series
614 Controllers with Single Mode Firmware.
617 static void DAC960_LA_QueueCommandSingleMode(DAC960_Command_T *Command)
619 DAC960_Controller_T *Controller = Command->Controller;
620 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
621 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
622 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
623 Controller->V1.NextCommandMailbox;
624 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
625 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
626 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
627 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
628 DAC960_LA_HardwareMailboxNewCommand(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;
639 DAC960_PG_QueueCommandDualMode queues Command for DAC960 PG Series
640 Controllers with Dual Mode Firmware.
643 static void DAC960_PG_QueueCommandDualMode(DAC960_Command_T *Command)
645 DAC960_Controller_T *Controller = Command->Controller;
646 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
647 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
648 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
649 Controller->V1.NextCommandMailbox;
650 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
651 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
652 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
653 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
654 DAC960_PG_MemoryMailboxNewCommand(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;
665 DAC960_PG_QueueCommandSingleMode queues Command for DAC960 PG Series
666 Controllers with Single Mode Firmware.
669 static void DAC960_PG_QueueCommandSingleMode(DAC960_Command_T *Command)
671 DAC960_Controller_T *Controller = Command->Controller;
672 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
673 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
674 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
675 Controller->V1.NextCommandMailbox;
676 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
677 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
678 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
679 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
680 DAC960_PG_HardwareMailboxNewCommand(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;
691 DAC960_PD_QueueCommand queues Command for DAC960 PD Series Controllers.
694 static void DAC960_PD_QueueCommand(DAC960_Command_T *Command)
696 DAC960_Controller_T *Controller = Command->Controller;
697 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
698 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
699 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
700 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
702 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
703 DAC960_PD_NewCommand(ControllerBaseAddress);
708 DAC960_P_QueueCommand queues Command for DAC960 P Series Controllers.
711 static void DAC960_P_QueueCommand(DAC960_Command_T *Command)
713 DAC960_Controller_T *Controller = Command->Controller;
714 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
715 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
716 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
717 switch (CommandMailbox->Common.CommandOpcode)
719 case DAC960_V1_Enquiry:
720 CommandMailbox->Common.CommandOpcode = DAC960_V1_Enquiry_Old;
722 case DAC960_V1_GetDeviceState:
723 CommandMailbox->Common.CommandOpcode = DAC960_V1_GetDeviceState_Old;
726 CommandMailbox->Common.CommandOpcode = DAC960_V1_Read_Old;
727 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
729 case DAC960_V1_Write:
730 CommandMailbox->Common.CommandOpcode = DAC960_V1_Write_Old;
731 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
733 case DAC960_V1_ReadWithScatterGather:
734 CommandMailbox->Common.CommandOpcode =
735 DAC960_V1_ReadWithScatterGather_Old;
736 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
738 case DAC960_V1_WriteWithScatterGather:
739 CommandMailbox->Common.CommandOpcode =
740 DAC960_V1_WriteWithScatterGather_Old;
741 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
746 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
748 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
749 DAC960_PD_NewCommand(ControllerBaseAddress);
754 DAC960_ExecuteCommand executes Command and waits for completion.
757 static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
759 DAC960_Controller_T *Controller = Command->Controller;
760 DECLARE_COMPLETION(Completion);
762 Command->Completion = &Completion;
764 spin_lock_irqsave(&Controller->queue_lock, flags);
765 DAC960_QueueCommand(Command);
766 spin_unlock_irqrestore(&Controller->queue_lock, flags);
770 wait_for_completion(&Completion);
775 DAC960_V1_ExecuteType3 executes a DAC960 V1 Firmware Controller Type 3
776 Command and waits for completion. It returns true on success and false
780 static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
781 DAC960_V1_CommandOpcode_T CommandOpcode,
784 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
785 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
786 DAC960_V1_CommandStatus_T CommandStatus;
787 DAC960_V1_ClearCommand(Command);
788 Command->CommandType = DAC960_ImmediateCommand;
789 CommandMailbox->Type3.CommandOpcode = CommandOpcode;
790 CommandMailbox->Type3.BusAddress = DataDMA;
791 DAC960_ExecuteCommand(Command);
792 CommandStatus = Command->V1.CommandStatus;
793 DAC960_DeallocateCommand(Command);
794 return (CommandStatus == DAC960_V1_NormalCompletion);
799 DAC960_V1_ExecuteTypeB executes a DAC960 V1 Firmware Controller Type 3B
800 Command and waits for completion. It returns true on success and false
804 static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
805 DAC960_V1_CommandOpcode_T CommandOpcode,
806 unsigned char CommandOpcode2,
809 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
810 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
811 DAC960_V1_CommandStatus_T CommandStatus;
812 DAC960_V1_ClearCommand(Command);
813 Command->CommandType = DAC960_ImmediateCommand;
814 CommandMailbox->Type3B.CommandOpcode = CommandOpcode;
815 CommandMailbox->Type3B.CommandOpcode2 = CommandOpcode2;
816 CommandMailbox->Type3B.BusAddress = DataDMA;
817 DAC960_ExecuteCommand(Command);
818 CommandStatus = Command->V1.CommandStatus;
819 DAC960_DeallocateCommand(Command);
820 return (CommandStatus == DAC960_V1_NormalCompletion);
825 DAC960_V1_ExecuteType3D executes a DAC960 V1 Firmware Controller Type 3D
826 Command and waits for completion. It returns true on success and false
830 static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
831 DAC960_V1_CommandOpcode_T CommandOpcode,
832 unsigned char Channel,
833 unsigned char TargetID,
836 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
837 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
838 DAC960_V1_CommandStatus_T CommandStatus;
839 DAC960_V1_ClearCommand(Command);
840 Command->CommandType = DAC960_ImmediateCommand;
841 CommandMailbox->Type3D.CommandOpcode = CommandOpcode;
842 CommandMailbox->Type3D.Channel = Channel;
843 CommandMailbox->Type3D.TargetID = TargetID;
844 CommandMailbox->Type3D.BusAddress = DataDMA;
845 DAC960_ExecuteCommand(Command);
846 CommandStatus = Command->V1.CommandStatus;
847 DAC960_DeallocateCommand(Command);
848 return (CommandStatus == DAC960_V1_NormalCompletion);
853 DAC960_V2_GeneralInfo executes a DAC960 V2 Firmware General Information
854 Reading IOCTL Command and waits for completion. It returns true on success
855 and false on failure.
857 Return data in The controller's HealthStatusBuffer, which is dma-able memory
860 static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
862 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
863 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
864 DAC960_V2_CommandStatus_T CommandStatus;
865 DAC960_V2_ClearCommand(Command);
866 Command->CommandType = DAC960_ImmediateCommand;
867 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
868 CommandMailbox->Common.CommandControlBits
869 .DataTransferControllerToHost = true;
870 CommandMailbox->Common.CommandControlBits
871 .NoAutoRequestSense = true;
872 CommandMailbox->Common.DataTransferSize = sizeof(DAC960_V2_HealthStatusBuffer_T);
873 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_GetHealthStatus;
874 CommandMailbox->Common.DataTransferMemoryAddress
875 .ScatterGatherSegments[0]
876 .SegmentDataPointer =
877 Controller->V2.HealthStatusBufferDMA;
878 CommandMailbox->Common.DataTransferMemoryAddress
879 .ScatterGatherSegments[0]
881 CommandMailbox->Common.DataTransferSize;
882 DAC960_ExecuteCommand(Command);
883 CommandStatus = Command->V2.CommandStatus;
884 DAC960_DeallocateCommand(Command);
885 return (CommandStatus == DAC960_V2_NormalCompletion);
890 DAC960_V2_ControllerInfo executes a DAC960 V2 Firmware Controller
891 Information Reading IOCTL Command and waits for completion. It returns
892 true on success and false on failure.
894 Data is returned in the controller's V2.NewControllerInformation dma-able
898 static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
900 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
901 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
902 DAC960_V2_CommandStatus_T CommandStatus;
903 DAC960_V2_ClearCommand(Command);
904 Command->CommandType = DAC960_ImmediateCommand;
905 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
906 CommandMailbox->ControllerInfo.CommandControlBits
907 .DataTransferControllerToHost = true;
908 CommandMailbox->ControllerInfo.CommandControlBits
909 .NoAutoRequestSense = true;
910 CommandMailbox->ControllerInfo.DataTransferSize = sizeof(DAC960_V2_ControllerInfo_T);
911 CommandMailbox->ControllerInfo.ControllerNumber = 0;
912 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
913 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
914 .ScatterGatherSegments[0]
915 .SegmentDataPointer =
916 Controller->V2.NewControllerInformationDMA;
917 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
918 .ScatterGatherSegments[0]
920 CommandMailbox->ControllerInfo.DataTransferSize;
921 DAC960_ExecuteCommand(Command);
922 CommandStatus = Command->V2.CommandStatus;
923 DAC960_DeallocateCommand(Command);
924 return (CommandStatus == DAC960_V2_NormalCompletion);
929 DAC960_V2_LogicalDeviceInfo executes a DAC960 V2 Firmware Controller Logical
930 Device Information Reading IOCTL Command and waits for completion. It
931 returns true on success and false on failure.
933 Data is returned in the controller's V2.NewLogicalDeviceInformation
936 static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
937 unsigned short LogicalDeviceNumber)
939 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
940 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
941 DAC960_V2_CommandStatus_T CommandStatus;
943 DAC960_V2_ClearCommand(Command);
944 Command->CommandType = DAC960_ImmediateCommand;
945 CommandMailbox->LogicalDeviceInfo.CommandOpcode =
947 CommandMailbox->LogicalDeviceInfo.CommandControlBits
948 .DataTransferControllerToHost = true;
949 CommandMailbox->LogicalDeviceInfo.CommandControlBits
950 .NoAutoRequestSense = true;
951 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
952 sizeof(DAC960_V2_LogicalDeviceInfo_T);
953 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
955 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode = DAC960_V2_GetLogicalDeviceInfoValid;
956 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
957 .ScatterGatherSegments[0]
958 .SegmentDataPointer =
959 Controller->V2.NewLogicalDeviceInformationDMA;
960 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
961 .ScatterGatherSegments[0]
963 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
964 DAC960_ExecuteCommand(Command);
965 CommandStatus = Command->V2.CommandStatus;
966 DAC960_DeallocateCommand(Command);
967 return (CommandStatus == DAC960_V2_NormalCompletion);
972 DAC960_V2_PhysicalDeviceInfo executes a DAC960 V2 Firmware Controller "Read
973 Physical Device Information" IOCTL Command and waits for completion. It
974 returns true on success and false on failure.
976 The Channel, TargetID, LogicalUnit arguments should be 0 the first time
977 this function is called for a given controller. This will return data
978 for the "first" device on that controller. The returned data includes a
979 Channel, TargetID, LogicalUnit that can be passed in to this routine to
980 get data for the NEXT device on that controller.
982 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
987 static boolean DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
988 unsigned char Channel,
989 unsigned char TargetID,
990 unsigned char LogicalUnit)
992 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
993 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
994 DAC960_V2_CommandStatus_T CommandStatus;
996 DAC960_V2_ClearCommand(Command);
997 Command->CommandType = DAC960_ImmediateCommand;
998 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
999 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
1000 .DataTransferControllerToHost = true;
1001 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
1002 .NoAutoRequestSense = true;
1003 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
1004 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
1005 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit = LogicalUnit;
1006 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
1007 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
1008 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
1009 DAC960_V2_GetPhysicalDeviceInfoValid;
1010 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1011 .ScatterGatherSegments[0]
1012 .SegmentDataPointer =
1013 Controller->V2.NewPhysicalDeviceInformationDMA;
1014 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1015 .ScatterGatherSegments[0]
1017 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
1018 DAC960_ExecuteCommand(Command);
1019 CommandStatus = Command->V2.CommandStatus;
1020 DAC960_DeallocateCommand(Command);
1021 return (CommandStatus == DAC960_V2_NormalCompletion);
1025 static void DAC960_V2_ConstructNewUnitSerialNumber(
1026 DAC960_Controller_T *Controller,
1027 DAC960_V2_CommandMailbox_T *CommandMailbox, int Channel, int TargetID,
1030 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10_Passthru;
1031 CommandMailbox->SCSI_10.CommandControlBits
1032 .DataTransferControllerToHost = true;
1033 CommandMailbox->SCSI_10.CommandControlBits
1034 .NoAutoRequestSense = true;
1035 CommandMailbox->SCSI_10.DataTransferSize =
1036 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1037 CommandMailbox->SCSI_10.PhysicalDevice.LogicalUnit = LogicalUnit;
1038 CommandMailbox->SCSI_10.PhysicalDevice.TargetID = TargetID;
1039 CommandMailbox->SCSI_10.PhysicalDevice.Channel = Channel;
1040 CommandMailbox->SCSI_10.CDBLength = 6;
1041 CommandMailbox->SCSI_10.SCSI_CDB[0] = 0x12; /* INQUIRY */
1042 CommandMailbox->SCSI_10.SCSI_CDB[1] = 1; /* EVPD = 1 */
1043 CommandMailbox->SCSI_10.SCSI_CDB[2] = 0x80; /* Page Code */
1044 CommandMailbox->SCSI_10.SCSI_CDB[3] = 0; /* Reserved */
1045 CommandMailbox->SCSI_10.SCSI_CDB[4] =
1046 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1047 CommandMailbox->SCSI_10.SCSI_CDB[5] = 0; /* Control */
1048 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1049 .ScatterGatherSegments[0]
1050 .SegmentDataPointer =
1051 Controller->V2.NewInquiryUnitSerialNumberDMA;
1052 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1053 .ScatterGatherSegments[0]
1055 CommandMailbox->SCSI_10.DataTransferSize;
1060 DAC960_V2_NewUnitSerialNumber executes an SCSI pass-through
1061 Inquiry command to a SCSI device identified by Channel number,
1062 Target id, Logical Unit Number. This function Waits for completion
1065 The return data includes Unit Serial Number information for the
1068 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
1072 static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
1073 int Channel, int TargetID, int LogicalUnit)
1075 DAC960_Command_T *Command;
1076 DAC960_V2_CommandMailbox_T *CommandMailbox;
1077 DAC960_V2_CommandStatus_T CommandStatus;
1079 Command = DAC960_AllocateCommand(Controller);
1080 CommandMailbox = &Command->V2.CommandMailbox;
1081 DAC960_V2_ClearCommand(Command);
1082 Command->CommandType = DAC960_ImmediateCommand;
1084 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
1085 Channel, TargetID, LogicalUnit);
1087 DAC960_ExecuteCommand(Command);
1088 CommandStatus = Command->V2.CommandStatus;
1089 DAC960_DeallocateCommand(Command);
1090 return (CommandStatus == DAC960_V2_NormalCompletion);
1095 DAC960_V2_DeviceOperation executes a DAC960 V2 Firmware Controller Device
1096 Operation IOCTL Command and waits for completion. It returns true on
1097 success and false on failure.
1100 static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1101 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
1102 DAC960_V2_OperationDevice_T
1105 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
1106 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
1107 DAC960_V2_CommandStatus_T CommandStatus;
1108 DAC960_V2_ClearCommand(Command);
1109 Command->CommandType = DAC960_ImmediateCommand;
1110 CommandMailbox->DeviceOperation.CommandOpcode = DAC960_V2_IOCTL;
1111 CommandMailbox->DeviceOperation.CommandControlBits
1112 .DataTransferControllerToHost = true;
1113 CommandMailbox->DeviceOperation.CommandControlBits
1114 .NoAutoRequestSense = true;
1115 CommandMailbox->DeviceOperation.IOCTL_Opcode = IOCTL_Opcode;
1116 CommandMailbox->DeviceOperation.OperationDevice = OperationDevice;
1117 DAC960_ExecuteCommand(Command);
1118 CommandStatus = Command->V2.CommandStatus;
1119 DAC960_DeallocateCommand(Command);
1120 return (CommandStatus == DAC960_V2_NormalCompletion);
1125 DAC960_V1_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1126 for DAC960 V1 Firmware Controllers.
1128 PD and P controller types have no memory mailbox, but still need the
1129 other dma mapped memory.
1132 static boolean DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1135 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
1136 DAC960_HardwareType_T hw_type = Controller->HardwareType;
1137 struct pci_dev *PCI_Device = Controller->PCIDevice;
1138 struct dma_loaf *DmaPages = &Controller->DmaPages;
1139 size_t DmaPagesSize;
1140 size_t CommandMailboxesSize;
1141 size_t StatusMailboxesSize;
1143 DAC960_V1_CommandMailbox_T *CommandMailboxesMemory;
1144 dma_addr_t CommandMailboxesMemoryDMA;
1146 DAC960_V1_StatusMailbox_T *StatusMailboxesMemory;
1147 dma_addr_t StatusMailboxesMemoryDMA;
1149 DAC960_V1_CommandMailbox_T CommandMailbox;
1150 DAC960_V1_CommandStatus_T CommandStatus;
1155 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V1_PciDmaMask))
1156 return DAC960_Failure(Controller, "DMA mask out of range");
1157 Controller->BounceBufferLimit = DAC690_V1_PciDmaMask;
1159 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller)) {
1160 CommandMailboxesSize = 0;
1161 StatusMailboxesSize = 0;
1163 CommandMailboxesSize = DAC960_V1_CommandMailboxCount * sizeof(DAC960_V1_CommandMailbox_T);
1164 StatusMailboxesSize = DAC960_V1_StatusMailboxCount * sizeof(DAC960_V1_StatusMailbox_T);
1166 DmaPagesSize = CommandMailboxesSize + StatusMailboxesSize +
1167 sizeof(DAC960_V1_DCDB_T) + sizeof(DAC960_V1_Enquiry_T) +
1168 sizeof(DAC960_V1_ErrorTable_T) + sizeof(DAC960_V1_EventLogEntry_T) +
1169 sizeof(DAC960_V1_RebuildProgress_T) +
1170 sizeof(DAC960_V1_LogicalDriveInformationArray_T) +
1171 sizeof(DAC960_V1_BackgroundInitializationStatus_T) +
1172 sizeof(DAC960_V1_DeviceState_T) + sizeof(DAC960_SCSI_Inquiry_T) +
1173 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1175 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize))
1179 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1180 goto skip_mailboxes;
1182 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1183 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1185 /* These are the base addresses for the command memory mailbox array */
1186 Controller->V1.FirstCommandMailbox = CommandMailboxesMemory;
1187 Controller->V1.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1189 CommandMailboxesMemory += DAC960_V1_CommandMailboxCount - 1;
1190 Controller->V1.LastCommandMailbox = CommandMailboxesMemory;
1191 Controller->V1.NextCommandMailbox = Controller->V1.FirstCommandMailbox;
1192 Controller->V1.PreviousCommandMailbox1 = Controller->V1.LastCommandMailbox;
1193 Controller->V1.PreviousCommandMailbox2 =
1194 Controller->V1.LastCommandMailbox - 1;
1196 /* These are the base addresses for the status memory mailbox array */
1197 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1198 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1200 Controller->V1.FirstStatusMailbox = StatusMailboxesMemory;
1201 Controller->V1.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1202 StatusMailboxesMemory += DAC960_V1_StatusMailboxCount - 1;
1203 Controller->V1.LastStatusMailbox = StatusMailboxesMemory;
1204 Controller->V1.NextStatusMailbox = Controller->V1.FirstStatusMailbox;
1207 Controller->V1.MonitoringDCDB = slice_dma_loaf(DmaPages,
1208 sizeof(DAC960_V1_DCDB_T),
1209 &Controller->V1.MonitoringDCDB_DMA);
1211 Controller->V1.NewEnquiry = slice_dma_loaf(DmaPages,
1212 sizeof(DAC960_V1_Enquiry_T),
1213 &Controller->V1.NewEnquiryDMA);
1215 Controller->V1.NewErrorTable = slice_dma_loaf(DmaPages,
1216 sizeof(DAC960_V1_ErrorTable_T),
1217 &Controller->V1.NewErrorTableDMA);
1219 Controller->V1.EventLogEntry = slice_dma_loaf(DmaPages,
1220 sizeof(DAC960_V1_EventLogEntry_T),
1221 &Controller->V1.EventLogEntryDMA);
1223 Controller->V1.RebuildProgress = slice_dma_loaf(DmaPages,
1224 sizeof(DAC960_V1_RebuildProgress_T),
1225 &Controller->V1.RebuildProgressDMA);
1227 Controller->V1.NewLogicalDriveInformation = slice_dma_loaf(DmaPages,
1228 sizeof(DAC960_V1_LogicalDriveInformationArray_T),
1229 &Controller->V1.NewLogicalDriveInformationDMA);
1231 Controller->V1.BackgroundInitializationStatus = slice_dma_loaf(DmaPages,
1232 sizeof(DAC960_V1_BackgroundInitializationStatus_T),
1233 &Controller->V1.BackgroundInitializationStatusDMA);
1235 Controller->V1.NewDeviceState = slice_dma_loaf(DmaPages,
1236 sizeof(DAC960_V1_DeviceState_T),
1237 &Controller->V1.NewDeviceStateDMA);
1239 Controller->V1.NewInquiryStandardData = slice_dma_loaf(DmaPages,
1240 sizeof(DAC960_SCSI_Inquiry_T),
1241 &Controller->V1.NewInquiryStandardDataDMA);
1243 Controller->V1.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1244 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1245 &Controller->V1.NewInquiryUnitSerialNumberDMA);
1247 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1250 /* Enable the Memory Mailbox Interface. */
1251 Controller->V1.DualModeMemoryMailboxInterface = true;
1252 CommandMailbox.TypeX.CommandOpcode = 0x2B;
1253 CommandMailbox.TypeX.CommandIdentifier = 0;
1254 CommandMailbox.TypeX.CommandOpcode2 = 0x14;
1255 CommandMailbox.TypeX.CommandMailboxesBusAddress =
1256 Controller->V1.FirstCommandMailboxDMA;
1257 CommandMailbox.TypeX.StatusMailboxesBusAddress =
1258 Controller->V1.FirstStatusMailboxDMA;
1259 #define TIMEOUT_COUNT 1000000
1261 for (i = 0; i < 2; i++)
1262 switch (Controller->HardwareType)
1264 case DAC960_LA_Controller:
1265 TimeoutCounter = TIMEOUT_COUNT;
1266 while (--TimeoutCounter >= 0)
1268 if (!DAC960_LA_HardwareMailboxFullP(ControllerBaseAddress))
1272 if (TimeoutCounter < 0) return false;
1273 DAC960_LA_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1274 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
1275 TimeoutCounter = TIMEOUT_COUNT;
1276 while (--TimeoutCounter >= 0)
1278 if (DAC960_LA_HardwareMailboxStatusAvailableP(
1279 ControllerBaseAddress))
1283 if (TimeoutCounter < 0) return false;
1284 CommandStatus = DAC960_LA_ReadStatusRegister(ControllerBaseAddress);
1285 DAC960_LA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1286 DAC960_LA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1287 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1288 Controller->V1.DualModeMemoryMailboxInterface = false;
1289 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1291 case DAC960_PG_Controller:
1292 TimeoutCounter = TIMEOUT_COUNT;
1293 while (--TimeoutCounter >= 0)
1295 if (!DAC960_PG_HardwareMailboxFullP(ControllerBaseAddress))
1299 if (TimeoutCounter < 0) return false;
1300 DAC960_PG_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1301 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
1303 TimeoutCounter = TIMEOUT_COUNT;
1304 while (--TimeoutCounter >= 0)
1306 if (DAC960_PG_HardwareMailboxStatusAvailableP(
1307 ControllerBaseAddress))
1311 if (TimeoutCounter < 0) return false;
1312 CommandStatus = DAC960_PG_ReadStatusRegister(ControllerBaseAddress);
1313 DAC960_PG_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1314 DAC960_PG_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1315 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1316 Controller->V1.DualModeMemoryMailboxInterface = false;
1317 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1320 DAC960_Failure(Controller, "Unknown Controller Type\n");
1328 DAC960_V2_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1329 for DAC960 V2 Firmware Controllers.
1331 Aggregate the space needed for the controller's memory mailbox and
1332 the other data structures that will be targets of dma transfers with
1333 the controller. Allocate a dma-mapped region of memory to hold these
1334 structures. Then, save CPU pointers and dma_addr_t values to reference
1335 the structures that are contained in that region.
1338 static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1341 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
1342 struct pci_dev *PCI_Device = Controller->PCIDevice;
1343 struct dma_loaf *DmaPages = &Controller->DmaPages;
1344 size_t DmaPagesSize;
1345 size_t CommandMailboxesSize;
1346 size_t StatusMailboxesSize;
1348 DAC960_V2_CommandMailbox_T *CommandMailboxesMemory;
1349 dma_addr_t CommandMailboxesMemoryDMA;
1351 DAC960_V2_StatusMailbox_T *StatusMailboxesMemory;
1352 dma_addr_t StatusMailboxesMemoryDMA;
1354 DAC960_V2_CommandMailbox_T *CommandMailbox;
1355 dma_addr_t CommandMailboxDMA;
1356 DAC960_V2_CommandStatus_T CommandStatus;
1358 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V2_PciDmaMask))
1359 return DAC960_Failure(Controller, "DMA mask out of range");
1360 Controller->BounceBufferLimit = DAC690_V2_PciDmaMask;
1362 /* This is a temporary dma mapping, used only in the scope of this function */
1364 (DAC960_V2_CommandMailbox_T *)pci_alloc_consistent( PCI_Device,
1365 sizeof(DAC960_V2_CommandMailbox_T), &CommandMailboxDMA);
1366 if (CommandMailbox == NULL)
1369 CommandMailboxesSize = DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T);
1370 StatusMailboxesSize = DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T);
1372 CommandMailboxesSize + StatusMailboxesSize +
1373 sizeof(DAC960_V2_HealthStatusBuffer_T) +
1374 sizeof(DAC960_V2_ControllerInfo_T) +
1375 sizeof(DAC960_V2_LogicalDeviceInfo_T) +
1376 sizeof(DAC960_V2_PhysicalDeviceInfo_T) +
1377 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T) +
1378 sizeof(DAC960_V2_Event_T) +
1379 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
1381 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize)) {
1382 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1383 CommandMailbox, CommandMailboxDMA);
1387 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1388 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1390 /* These are the base addresses for the command memory mailbox array */
1391 Controller->V2.FirstCommandMailbox = CommandMailboxesMemory;
1392 Controller->V2.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1394 CommandMailboxesMemory += DAC960_V2_CommandMailboxCount - 1;
1395 Controller->V2.LastCommandMailbox = CommandMailboxesMemory;
1396 Controller->V2.NextCommandMailbox = Controller->V2.FirstCommandMailbox;
1397 Controller->V2.PreviousCommandMailbox1 = Controller->V2.LastCommandMailbox;
1398 Controller->V2.PreviousCommandMailbox2 =
1399 Controller->V2.LastCommandMailbox - 1;
1401 /* These are the base addresses for the status memory mailbox array */
1402 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1403 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1405 Controller->V2.FirstStatusMailbox = StatusMailboxesMemory;
1406 Controller->V2.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1407 StatusMailboxesMemory += DAC960_V2_StatusMailboxCount - 1;
1408 Controller->V2.LastStatusMailbox = StatusMailboxesMemory;
1409 Controller->V2.NextStatusMailbox = Controller->V2.FirstStatusMailbox;
1411 Controller->V2.HealthStatusBuffer = slice_dma_loaf(DmaPages,
1412 sizeof(DAC960_V2_HealthStatusBuffer_T),
1413 &Controller->V2.HealthStatusBufferDMA);
1415 Controller->V2.NewControllerInformation = slice_dma_loaf(DmaPages,
1416 sizeof(DAC960_V2_ControllerInfo_T),
1417 &Controller->V2.NewControllerInformationDMA);
1419 Controller->V2.NewLogicalDeviceInformation = slice_dma_loaf(DmaPages,
1420 sizeof(DAC960_V2_LogicalDeviceInfo_T),
1421 &Controller->V2.NewLogicalDeviceInformationDMA);
1423 Controller->V2.NewPhysicalDeviceInformation = slice_dma_loaf(DmaPages,
1424 sizeof(DAC960_V2_PhysicalDeviceInfo_T),
1425 &Controller->V2.NewPhysicalDeviceInformationDMA);
1427 Controller->V2.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1428 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1429 &Controller->V2.NewInquiryUnitSerialNumberDMA);
1431 Controller->V2.Event = slice_dma_loaf(DmaPages,
1432 sizeof(DAC960_V2_Event_T),
1433 &Controller->V2.EventDMA);
1435 Controller->V2.PhysicalToLogicalDevice = slice_dma_loaf(DmaPages,
1436 sizeof(DAC960_V2_PhysicalToLogicalDevice_T),
1437 &Controller->V2.PhysicalToLogicalDeviceDMA);
1440 Enable the Memory Mailbox Interface.
1442 I don't know why we can't just use one of the memory mailboxes
1443 we just allocated to do this, instead of using this temporary one.
1444 Try this change later.
1446 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
1447 CommandMailbox->SetMemoryMailbox.CommandIdentifier = 1;
1448 CommandMailbox->SetMemoryMailbox.CommandOpcode = DAC960_V2_IOCTL;
1449 CommandMailbox->SetMemoryMailbox.CommandControlBits.NoAutoRequestSense = true;
1450 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxSizeKB =
1451 (DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T)) >> 10;
1452 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxSizeKB =
1453 (DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T)) >> 10;
1454 CommandMailbox->SetMemoryMailbox.SecondCommandMailboxSizeKB = 0;
1455 CommandMailbox->SetMemoryMailbox.SecondStatusMailboxSizeKB = 0;
1456 CommandMailbox->SetMemoryMailbox.RequestSenseSize = 0;
1457 CommandMailbox->SetMemoryMailbox.IOCTL_Opcode = DAC960_V2_SetMemoryMailbox;
1458 CommandMailbox->SetMemoryMailbox.HealthStatusBufferSizeKB = 1;
1459 CommandMailbox->SetMemoryMailbox.HealthStatusBufferBusAddress =
1460 Controller->V2.HealthStatusBufferDMA;
1461 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxBusAddress =
1462 Controller->V2.FirstCommandMailboxDMA;
1463 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxBusAddress =
1464 Controller->V2.FirstStatusMailboxDMA;
1465 switch (Controller->HardwareType)
1467 case DAC960_BA_Controller:
1468 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1470 DAC960_BA_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1471 DAC960_BA_HardwareMailboxNewCommand(ControllerBaseAddress);
1472 while (!DAC960_BA_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1474 CommandStatus = DAC960_BA_ReadCommandStatus(ControllerBaseAddress);
1475 DAC960_BA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1476 DAC960_BA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1478 case DAC960_LP_Controller:
1479 while (DAC960_LP_HardwareMailboxFullP(ControllerBaseAddress))
1481 DAC960_LP_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1482 DAC960_LP_HardwareMailboxNewCommand(ControllerBaseAddress);
1483 while (!DAC960_LP_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1485 CommandStatus = DAC960_LP_ReadCommandStatus(ControllerBaseAddress);
1486 DAC960_LP_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1487 DAC960_LP_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1490 DAC960_Failure(Controller, "Unknown Controller Type\n");
1491 CommandStatus = DAC960_V2_AbormalCompletion;
1494 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1495 CommandMailbox, CommandMailboxDMA);
1496 return (CommandStatus == DAC960_V2_NormalCompletion);
1501 DAC960_V1_ReadControllerConfiguration reads the Configuration Information
1502 from DAC960 V1 Firmware Controllers and initializes the Controller structure.
1505 static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1508 DAC960_V1_Enquiry2_T *Enquiry2;
1509 dma_addr_t Enquiry2DMA;
1510 DAC960_V1_Config2_T *Config2;
1511 dma_addr_t Config2DMA;
1512 int LogicalDriveNumber, Channel, TargetID;
1513 struct dma_loaf local_dma;
1515 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1516 sizeof(DAC960_V1_Enquiry2_T) + sizeof(DAC960_V1_Config2_T)))
1517 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1519 Enquiry2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Enquiry2_T), &Enquiry2DMA);
1520 Config2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Config2_T), &Config2DMA);
1522 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry,
1523 Controller->V1.NewEnquiryDMA)) {
1524 free_dma_loaf(Controller->PCIDevice, &local_dma);
1525 return DAC960_Failure(Controller, "ENQUIRY");
1527 memcpy(&Controller->V1.Enquiry, Controller->V1.NewEnquiry,
1528 sizeof(DAC960_V1_Enquiry_T));
1530 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry2, Enquiry2DMA)) {
1531 free_dma_loaf(Controller->PCIDevice, &local_dma);
1532 return DAC960_Failure(Controller, "ENQUIRY2");
1535 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_ReadConfig2, Config2DMA)) {
1536 free_dma_loaf(Controller->PCIDevice, &local_dma);
1537 return DAC960_Failure(Controller, "READ CONFIG2");
1540 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_GetLogicalDriveInformation,
1541 Controller->V1.NewLogicalDriveInformationDMA)) {
1542 free_dma_loaf(Controller->PCIDevice, &local_dma);
1543 return DAC960_Failure(Controller, "GET LOGICAL DRIVE INFORMATION");
1545 memcpy(&Controller->V1.LogicalDriveInformation,
1546 Controller->V1.NewLogicalDriveInformation,
1547 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
1549 for (Channel = 0; Channel < Enquiry2->ActualChannels; Channel++)
1550 for (TargetID = 0; TargetID < Enquiry2->MaxTargets; TargetID++) {
1551 if (!DAC960_V1_ExecuteType3D(Controller, DAC960_V1_GetDeviceState,
1553 Controller->V1.NewDeviceStateDMA)) {
1554 free_dma_loaf(Controller->PCIDevice, &local_dma);
1555 return DAC960_Failure(Controller, "GET DEVICE STATE");
1557 memcpy(&Controller->V1.DeviceState[Channel][TargetID],
1558 Controller->V1.NewDeviceState, sizeof(DAC960_V1_DeviceState_T));
1561 Initialize the Controller Model Name and Full Model Name fields.
1563 switch (Enquiry2->HardwareID.SubModel)
1565 case DAC960_V1_P_PD_PU:
1566 if (Enquiry2->SCSICapability.BusSpeed == DAC960_V1_Ultra)
1567 strcpy(Controller->ModelName, "DAC960PU");
1568 else strcpy(Controller->ModelName, "DAC960PD");
1571 strcpy(Controller->ModelName, "DAC960PL");
1574 strcpy(Controller->ModelName, "DAC960PG");
1577 strcpy(Controller->ModelName, "DAC960PJ");
1580 strcpy(Controller->ModelName, "DAC960PR");
1583 strcpy(Controller->ModelName, "DAC960PT");
1585 case DAC960_V1_PTL0:
1586 strcpy(Controller->ModelName, "DAC960PTL0");
1589 strcpy(Controller->ModelName, "DAC960PRL");
1591 case DAC960_V1_PTL1:
1592 strcpy(Controller->ModelName, "DAC960PTL1");
1594 case DAC960_V1_1164P:
1595 strcpy(Controller->ModelName, "DAC1164P");
1598 free_dma_loaf(Controller->PCIDevice, &local_dma);
1599 return DAC960_Failure(Controller, "MODEL VERIFICATION");
1601 strcpy(Controller->FullModelName, "Mylex ");
1602 strcat(Controller->FullModelName, Controller->ModelName);
1604 Initialize the Controller Firmware Version field and verify that it
1605 is a supported firmware version. The supported firmware versions are:
1607 DAC1164P 5.06 and above
1608 DAC960PTL/PRL/PJ/PG 4.06 and above
1609 DAC960PU/PD/PL 3.51 and above
1610 DAC960PU/PD/PL/P 2.73 and above
1612 #if defined(CONFIG_ALPHA)
1614 DEC Alpha machines were often equipped with DAC960 cards that were
1615 OEMed from Mylex, and had their own custom firmware. Version 2.70,
1616 the last custom FW revision to be released by DEC for these older
1617 controllers, appears to work quite well with this driver.
1619 Cards tested successfully were several versions each of the PD and
1620 PU, called by DEC the KZPSC and KZPAC, respectively, and having
1621 the Manufacturer Numbers (from Mylex), usually on a sticker on the
1622 back of the board, of:
1624 KZPSC: D040347 (1-channel) or D040348 (2-channel) or D040349 (3-channel)
1625 KZPAC: D040395 (1-channel) or D040396 (2-channel) or D040397 (3-channel)
1627 # define FIRMWARE_27X "2.70"
1629 # define FIRMWARE_27X "2.73"
1632 if (Enquiry2->FirmwareID.MajorVersion == 0)
1634 Enquiry2->FirmwareID.MajorVersion =
1635 Controller->V1.Enquiry.MajorFirmwareVersion;
1636 Enquiry2->FirmwareID.MinorVersion =
1637 Controller->V1.Enquiry.MinorFirmwareVersion;
1638 Enquiry2->FirmwareID.FirmwareType = '0';
1639 Enquiry2->FirmwareID.TurnID = 0;
1641 sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d",
1642 Enquiry2->FirmwareID.MajorVersion, Enquiry2->FirmwareID.MinorVersion,
1643 Enquiry2->FirmwareID.FirmwareType, Enquiry2->FirmwareID.TurnID);
1644 if (!((Controller->FirmwareVersion[0] == '5' &&
1645 strcmp(Controller->FirmwareVersion, "5.06") >= 0) ||
1646 (Controller->FirmwareVersion[0] == '4' &&
1647 strcmp(Controller->FirmwareVersion, "4.06") >= 0) ||
1648 (Controller->FirmwareVersion[0] == '3' &&
1649 strcmp(Controller->FirmwareVersion, "3.51") >= 0) ||
1650 (Controller->FirmwareVersion[0] == '2' &&
1651 strcmp(Controller->FirmwareVersion, FIRMWARE_27X) >= 0)))
1653 DAC960_Failure(Controller, "FIRMWARE VERSION VERIFICATION");
1654 DAC960_Error("Firmware Version = '%s'\n", Controller,
1655 Controller->FirmwareVersion);
1656 free_dma_loaf(Controller->PCIDevice, &local_dma);
1660 Initialize the Controller Channels, Targets, Memory Size, and SAF-TE
1661 Enclosure Management Enabled fields.
1663 Controller->Channels = Enquiry2->ActualChannels;
1664 Controller->Targets = Enquiry2->MaxTargets;
1665 Controller->MemorySize = Enquiry2->MemorySize >> 20;
1666 Controller->V1.SAFTE_EnclosureManagementEnabled =
1667 (Enquiry2->FaultManagementType == DAC960_V1_SAFTE);
1669 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1670 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1671 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1672 less than the Controller Queue Depth to allow for an automatic drive
1675 Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands;
1676 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1677 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1678 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1679 Controller->LogicalDriveCount =
1680 Controller->V1.Enquiry.NumberOfLogicalDrives;
1681 Controller->MaxBlocksPerCommand = Enquiry2->MaxBlocksPerCommand;
1682 Controller->ControllerScatterGatherLimit = Enquiry2->MaxScatterGatherEntries;
1683 Controller->DriverScatterGatherLimit =
1684 Controller->ControllerScatterGatherLimit;
1685 if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit)
1686 Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit;
1688 Initialize the Stripe Size, Segment Size, and Geometry Translation.
1690 Controller->V1.StripeSize = Config2->BlocksPerStripe * Config2->BlockFactor
1691 >> (10 - DAC960_BlockSizeBits);
1692 Controller->V1.SegmentSize = Config2->BlocksPerCacheLine * Config2->BlockFactor
1693 >> (10 - DAC960_BlockSizeBits);
1694 switch (Config2->DriveGeometry)
1696 case DAC960_V1_Geometry_128_32:
1697 Controller->V1.GeometryTranslationHeads = 128;
1698 Controller->V1.GeometryTranslationSectors = 32;
1700 case DAC960_V1_Geometry_255_63:
1701 Controller->V1.GeometryTranslationHeads = 255;
1702 Controller->V1.GeometryTranslationSectors = 63;
1705 free_dma_loaf(Controller->PCIDevice, &local_dma);
1706 return DAC960_Failure(Controller, "CONFIG2 DRIVE GEOMETRY");
1709 Initialize the Background Initialization Status.
1711 if ((Controller->FirmwareVersion[0] == '4' &&
1712 strcmp(Controller->FirmwareVersion, "4.08") >= 0) ||
1713 (Controller->FirmwareVersion[0] == '5' &&
1714 strcmp(Controller->FirmwareVersion, "5.08") >= 0))
1716 Controller->V1.BackgroundInitializationStatusSupported = true;
1717 DAC960_V1_ExecuteType3B(Controller,
1718 DAC960_V1_BackgroundInitializationControl, 0x20,
1720 V1.BackgroundInitializationStatusDMA);
1721 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
1722 Controller->V1.BackgroundInitializationStatus,
1723 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
1726 Initialize the Logical Drive Initially Accessible flag.
1728 for (LogicalDriveNumber = 0;
1729 LogicalDriveNumber < Controller->LogicalDriveCount;
1730 LogicalDriveNumber++)
1731 if (Controller->V1.LogicalDriveInformation
1732 [LogicalDriveNumber].LogicalDriveState !=
1733 DAC960_V1_LogicalDrive_Offline)
1734 Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;
1735 Controller->V1.LastRebuildStatus = DAC960_V1_NoRebuildOrCheckInProgress;
1736 free_dma_loaf(Controller->PCIDevice, &local_dma);
1742 DAC960_V2_ReadControllerConfiguration reads the Configuration Information
1743 from DAC960 V2 Firmware Controllers and initializes the Controller structure.
1746 static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1749 DAC960_V2_ControllerInfo_T *ControllerInfo =
1750 &Controller->V2.ControllerInformation;
1751 unsigned short LogicalDeviceNumber = 0;
1752 int ModelNameLength;
1754 /* Get data into dma-able area, then copy into permanant location */
1755 if (!DAC960_V2_NewControllerInfo(Controller))
1756 return DAC960_Failure(Controller, "GET CONTROLLER INFO");
1757 memcpy(ControllerInfo, Controller->V2.NewControllerInformation,
1758 sizeof(DAC960_V2_ControllerInfo_T));
1761 if (!DAC960_V2_GeneralInfo(Controller))
1762 return DAC960_Failure(Controller, "GET HEALTH STATUS");
1765 Initialize the Controller Model Name and Full Model Name fields.
1767 ModelNameLength = sizeof(ControllerInfo->ControllerName);
1768 if (ModelNameLength > sizeof(Controller->ModelName)-1)
1769 ModelNameLength = sizeof(Controller->ModelName)-1;
1770 memcpy(Controller->ModelName, ControllerInfo->ControllerName,
1773 while (Controller->ModelName[ModelNameLength] == ' ' ||
1774 Controller->ModelName[ModelNameLength] == '\0')
1776 Controller->ModelName[++ModelNameLength] = '\0';
1777 strcpy(Controller->FullModelName, "Mylex ");
1778 strcat(Controller->FullModelName, Controller->ModelName);
1780 Initialize the Controller Firmware Version field.
1782 sprintf(Controller->FirmwareVersion, "%d.%02d-%02d",
1783 ControllerInfo->FirmwareMajorVersion,
1784 ControllerInfo->FirmwareMinorVersion,
1785 ControllerInfo->FirmwareTurnNumber);
1786 if (ControllerInfo->FirmwareMajorVersion == 6 &&
1787 ControllerInfo->FirmwareMinorVersion == 0 &&
1788 ControllerInfo->FirmwareTurnNumber < 1)
1790 DAC960_Info("FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n",
1791 Controller, Controller->FirmwareVersion);
1792 DAC960_Info("STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n",
1794 DAC960_Info("PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n",
1798 Initialize the Controller Channels, Targets, and Memory Size.
1800 Controller->Channels = ControllerInfo->NumberOfPhysicalChannelsPresent;
1801 Controller->Targets =
1802 ControllerInfo->MaximumTargetsPerChannel
1803 [ControllerInfo->NumberOfPhysicalChannelsPresent-1];
1804 Controller->MemorySize = ControllerInfo->MemorySizeMB;
1806 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1807 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1808 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1809 less than the Controller Queue Depth to allow for an automatic drive
1812 Controller->ControllerQueueDepth = ControllerInfo->MaximumParallelCommands;
1813 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1814 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1815 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1816 Controller->LogicalDriveCount = ControllerInfo->LogicalDevicesPresent;
1817 Controller->MaxBlocksPerCommand =
1818 ControllerInfo->MaximumDataTransferSizeInBlocks;
1819 Controller->ControllerScatterGatherLimit =
1820 ControllerInfo->MaximumScatterGatherEntries;
1821 Controller->DriverScatterGatherLimit =
1822 Controller->ControllerScatterGatherLimit;
1823 if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit)
1824 Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit;
1826 Initialize the Logical Device Information.
1830 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
1831 Controller->V2.NewLogicalDeviceInformation;
1832 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo;
1833 DAC960_V2_PhysicalDevice_T PhysicalDevice;
1835 if (!DAC960_V2_NewLogicalDeviceInfo(Controller, LogicalDeviceNumber))
1837 LogicalDeviceNumber = NewLogicalDeviceInfo->LogicalDeviceNumber;
1838 if (LogicalDeviceNumber >= DAC960_MaxLogicalDrives) {
1839 DAC960_Error("DAC960: Logical Drive Number %d not supported\n",
1840 Controller, LogicalDeviceNumber);
1843 if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize) {
1844 DAC960_Error("DAC960: Logical Drive Block Size %d not supported\n",
1845 Controller, NewLogicalDeviceInfo->DeviceBlockSizeInBytes);
1846 LogicalDeviceNumber++;
1849 PhysicalDevice.Controller = 0;
1850 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
1851 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
1852 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
1853 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
1855 if (NewLogicalDeviceInfo->LogicalDeviceState !=
1856 DAC960_V2_LogicalDevice_Offline)
1857 Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;
1858 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
1859 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
1860 if (LogicalDeviceInfo == NULL)
1861 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1862 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
1864 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
1865 sizeof(DAC960_V2_LogicalDeviceInfo_T));
1866 LogicalDeviceNumber++;
1873 DAC960_ReportControllerConfiguration reports the Configuration Information
1877 static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
1880 DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",
1881 Controller, Controller->ModelName);
1882 DAC960_Info(" Firmware Version: %s, Channels: %d, Memory Size: %dMB\n",
1883 Controller, Controller->FirmwareVersion,
1884 Controller->Channels, Controller->MemorySize);
1885 DAC960_Info(" PCI Bus: %d, Device: %d, Function: %d, I/O Address: ",
1886 Controller, Controller->Bus,
1887 Controller->Device, Controller->Function);
1888 if (Controller->IO_Address == 0)
1889 DAC960_Info("Unassigned\n", Controller);
1890 else DAC960_Info("0x%X\n", Controller, Controller->IO_Address);
1891 DAC960_Info(" PCI Address: 0x%X mapped at 0x%lX, IRQ Channel: %d\n",
1892 Controller, Controller->PCI_Address,
1893 (unsigned long) Controller->BaseAddress,
1894 Controller->IRQ_Channel);
1895 DAC960_Info(" Controller Queue Depth: %d, "
1896 "Maximum Blocks per Command: %d\n",
1897 Controller, Controller->ControllerQueueDepth,
1898 Controller->MaxBlocksPerCommand);
1899 DAC960_Info(" Driver Queue Depth: %d, "
1900 "Scatter/Gather Limit: %d of %d Segments\n",
1901 Controller, Controller->DriverQueueDepth,
1902 Controller->DriverScatterGatherLimit,
1903 Controller->ControllerScatterGatherLimit);
1904 if (Controller->FirmwareType == DAC960_V1_Controller)
1906 DAC960_Info(" Stripe Size: %dKB, Segment Size: %dKB, "
1907 "BIOS Geometry: %d/%d\n", Controller,
1908 Controller->V1.StripeSize,
1909 Controller->V1.SegmentSize,
1910 Controller->V1.GeometryTranslationHeads,
1911 Controller->V1.GeometryTranslationSectors);
1912 if (Controller->V1.SAFTE_EnclosureManagementEnabled)
1913 DAC960_Info(" SAF-TE Enclosure Management Enabled\n", Controller);
1920 DAC960_V1_ReadDeviceConfiguration reads the Device Configuration Information
1921 for DAC960 V1 Firmware Controllers by requesting the SCSI Inquiry and SCSI
1922 Inquiry Unit Serial Number information for each device connected to
1926 static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
1929 struct dma_loaf local_dma;
1931 dma_addr_t DCDBs_dma[DAC960_V1_MaxChannels];
1932 DAC960_V1_DCDB_T *DCDBs_cpu[DAC960_V1_MaxChannels];
1934 dma_addr_t SCSI_Inquiry_dma[DAC960_V1_MaxChannels];
1935 DAC960_SCSI_Inquiry_T *SCSI_Inquiry_cpu[DAC960_V1_MaxChannels];
1937 dma_addr_t SCSI_NewInquiryUnitSerialNumberDMA[DAC960_V1_MaxChannels];
1938 DAC960_SCSI_Inquiry_UnitSerialNumber_T *SCSI_NewInquiryUnitSerialNumberCPU[DAC960_V1_MaxChannels];
1940 struct completion Completions[DAC960_V1_MaxChannels];
1941 unsigned long flags;
1942 int Channel, TargetID;
1944 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1945 DAC960_V1_MaxChannels*(sizeof(DAC960_V1_DCDB_T) +
1946 sizeof(DAC960_SCSI_Inquiry_T) +
1947 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T))))
1948 return DAC960_Failure(Controller,
1949 "DMA ALLOCATION FAILED IN ReadDeviceConfiguration");
1951 for (Channel = 0; Channel < Controller->Channels; Channel++) {
1952 DCDBs_cpu[Channel] = slice_dma_loaf(&local_dma,
1953 sizeof(DAC960_V1_DCDB_T), DCDBs_dma + Channel);
1954 SCSI_Inquiry_cpu[Channel] = slice_dma_loaf(&local_dma,
1955 sizeof(DAC960_SCSI_Inquiry_T),
1956 SCSI_Inquiry_dma + Channel);
1957 SCSI_NewInquiryUnitSerialNumberCPU[Channel] = slice_dma_loaf(&local_dma,
1958 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1959 SCSI_NewInquiryUnitSerialNumberDMA + Channel);
1962 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
1965 * For each channel, submit a probe for a device on that channel.
1966 * The timeout interval for a device that is present is 10 seconds.
1967 * With this approach, the timeout periods can elapse in parallel
1970 for (Channel = 0; Channel < Controller->Channels; Channel++)
1972 dma_addr_t NewInquiryStandardDataDMA = SCSI_Inquiry_dma[Channel];
1973 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
1974 dma_addr_t DCDB_dma = DCDBs_dma[Channel];
1975 DAC960_Command_T *Command = Controller->Commands[Channel];
1976 struct completion *Completion = &Completions[Channel];
1978 init_completion(Completion);
1979 DAC960_V1_ClearCommand(Command);
1980 Command->CommandType = DAC960_ImmediateCommand;
1981 Command->Completion = Completion;
1982 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
1983 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_dma;
1984 DCDB->Channel = Channel;
1985 DCDB->TargetID = TargetID;
1986 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
1987 DCDB->EarlyStatus = false;
1988 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
1989 DCDB->NoAutomaticRequestSense = false;
1990 DCDB->DisconnectPermitted = true;
1991 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
1992 DCDB->BusAddress = NewInquiryStandardDataDMA;
1993 DCDB->CDBLength = 6;
1994 DCDB->TransferLengthHigh4 = 0;
1995 DCDB->SenseLength = sizeof(DCDB->SenseData);
1996 DCDB->CDB[0] = 0x12; /* INQUIRY */
1997 DCDB->CDB[1] = 0; /* EVPD = 0 */
1998 DCDB->CDB[2] = 0; /* Page Code */
1999 DCDB->CDB[3] = 0; /* Reserved */
2000 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
2001 DCDB->CDB[5] = 0; /* Control */
2003 spin_lock_irqsave(&Controller->queue_lock, flags);
2004 DAC960_QueueCommand(Command);
2005 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2008 * Wait for the problems submitted in the previous loop
2009 * to complete. On the probes that are successful,
2010 * get the serial number of the device that was found.
2012 for (Channel = 0; Channel < Controller->Channels; Channel++)
2014 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2015 &Controller->V1.InquiryStandardData[Channel][TargetID];
2016 DAC960_SCSI_Inquiry_T *NewInquiryStandardData = SCSI_Inquiry_cpu[Channel];
2017 dma_addr_t NewInquiryUnitSerialNumberDMA =
2018 SCSI_NewInquiryUnitSerialNumberDMA[Channel];
2019 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
2020 SCSI_NewInquiryUnitSerialNumberCPU[Channel];
2021 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2022 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2023 DAC960_Command_T *Command = Controller->Commands[Channel];
2024 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
2025 struct completion *Completion = &Completions[Channel];
2027 wait_for_completion(Completion);
2029 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2030 memset(InquiryStandardData, 0, sizeof(DAC960_SCSI_Inquiry_T));
2031 InquiryStandardData->PeripheralDeviceType = 0x1F;
2034 memcpy(InquiryStandardData, NewInquiryStandardData, sizeof(DAC960_SCSI_Inquiry_T));
2036 /* Preserve Channel and TargetID values from the previous loop */
2037 Command->Completion = Completion;
2038 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2039 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
2040 DCDB->SenseLength = sizeof(DCDB->SenseData);
2041 DCDB->CDB[0] = 0x12; /* INQUIRY */
2042 DCDB->CDB[1] = 1; /* EVPD = 1 */
2043 DCDB->CDB[2] = 0x80; /* Page Code */
2044 DCDB->CDB[3] = 0; /* Reserved */
2045 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2046 DCDB->CDB[5] = 0; /* Control */
2048 spin_lock_irqsave(&Controller->queue_lock, flags);
2049 DAC960_QueueCommand(Command);
2050 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2051 wait_for_completion(Completion);
2053 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2054 memset(InquiryUnitSerialNumber, 0,
2055 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2056 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2058 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2059 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2062 free_dma_loaf(Controller->PCIDevice, &local_dma);
2068 DAC960_V2_ReadDeviceConfiguration reads the Device Configuration Information
2069 for DAC960 V2 Firmware Controllers by requesting the Physical Device
2070 Information and SCSI Inquiry Unit Serial Number information for each
2071 device connected to Controller.
2074 static boolean DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
2077 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
2078 unsigned short PhysicalDeviceIndex = 0;
2082 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
2083 Controller->V2.NewPhysicalDeviceInformation;
2084 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo;
2085 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
2086 Controller->V2.NewInquiryUnitSerialNumber;
2087 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber;
2089 if (!DAC960_V2_NewPhysicalDeviceInfo(Controller, Channel, TargetID, LogicalUnit))
2092 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
2093 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
2094 if (PhysicalDeviceInfo == NULL)
2095 return DAC960_Failure(Controller, "PHYSICAL DEVICE ALLOCATION");
2096 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] =
2098 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
2099 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
2101 InquiryUnitSerialNumber = (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
2102 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
2103 if (InquiryUnitSerialNumber == NULL) {
2104 kfree(PhysicalDeviceInfo);
2105 return DAC960_Failure(Controller, "SERIAL NUMBER ALLOCATION");
2107 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex] =
2108 InquiryUnitSerialNumber;
2110 Channel = NewPhysicalDeviceInfo->Channel;
2111 TargetID = NewPhysicalDeviceInfo->TargetID;
2112 LogicalUnit = NewPhysicalDeviceInfo->LogicalUnit;
2115 Some devices do NOT have Unit Serial Numbers.
2116 This command fails for them. But, we still want to
2117 remember those devices are there. Construct a
2118 UnitSerialNumber structure for the failure case.
2120 if (!DAC960_V2_NewInquiryUnitSerialNumber(Controller, Channel, TargetID, LogicalUnit)) {
2121 memset(InquiryUnitSerialNumber, 0,
2122 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2123 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2125 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2126 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2128 PhysicalDeviceIndex++;
2136 DAC960_SanitizeInquiryData sanitizes the Vendor, Model, Revision, and
2137 Product Serial Number fields of the Inquiry Standard Data and Inquiry
2138 Unit Serial Number structures.
2141 static void DAC960_SanitizeInquiryData(DAC960_SCSI_Inquiry_T
2142 *InquiryStandardData,
2143 DAC960_SCSI_Inquiry_UnitSerialNumber_T
2144 *InquiryUnitSerialNumber,
2145 unsigned char *Vendor,
2146 unsigned char *Model,
2147 unsigned char *Revision,
2148 unsigned char *SerialNumber)
2150 int SerialNumberLength, i;
2151 if (InquiryStandardData->PeripheralDeviceType == 0x1F) return;
2152 for (i = 0; i < sizeof(InquiryStandardData->VendorIdentification); i++)
2154 unsigned char VendorCharacter =
2155 InquiryStandardData->VendorIdentification[i];
2156 Vendor[i] = (VendorCharacter >= ' ' && VendorCharacter <= '~'
2157 ? VendorCharacter : ' ');
2159 Vendor[sizeof(InquiryStandardData->VendorIdentification)] = '\0';
2160 for (i = 0; i < sizeof(InquiryStandardData->ProductIdentification); i++)
2162 unsigned char ModelCharacter =
2163 InquiryStandardData->ProductIdentification[i];
2164 Model[i] = (ModelCharacter >= ' ' && ModelCharacter <= '~'
2165 ? ModelCharacter : ' ');
2167 Model[sizeof(InquiryStandardData->ProductIdentification)] = '\0';
2168 for (i = 0; i < sizeof(InquiryStandardData->ProductRevisionLevel); i++)
2170 unsigned char RevisionCharacter =
2171 InquiryStandardData->ProductRevisionLevel[i];
2172 Revision[i] = (RevisionCharacter >= ' ' && RevisionCharacter <= '~'
2173 ? RevisionCharacter : ' ');
2175 Revision[sizeof(InquiryStandardData->ProductRevisionLevel)] = '\0';
2176 if (InquiryUnitSerialNumber->PeripheralDeviceType == 0x1F) return;
2177 SerialNumberLength = InquiryUnitSerialNumber->PageLength;
2178 if (SerialNumberLength >
2179 sizeof(InquiryUnitSerialNumber->ProductSerialNumber))
2180 SerialNumberLength = sizeof(InquiryUnitSerialNumber->ProductSerialNumber);
2181 for (i = 0; i < SerialNumberLength; i++)
2183 unsigned char SerialNumberCharacter =
2184 InquiryUnitSerialNumber->ProductSerialNumber[i];
2186 (SerialNumberCharacter >= ' ' && SerialNumberCharacter <= '~'
2187 ? SerialNumberCharacter : ' ');
2189 SerialNumber[SerialNumberLength] = '\0';
2194 DAC960_V1_ReportDeviceConfiguration reports the Device Configuration
2195 Information for DAC960 V1 Firmware Controllers.
2198 static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2201 int LogicalDriveNumber, Channel, TargetID;
2202 DAC960_Info(" Physical Devices:\n", Controller);
2203 for (Channel = 0; Channel < Controller->Channels; Channel++)
2204 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
2206 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2207 &Controller->V1.InquiryStandardData[Channel][TargetID];
2208 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2209 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2210 DAC960_V1_DeviceState_T *DeviceState =
2211 &Controller->V1.DeviceState[Channel][TargetID];
2212 DAC960_V1_ErrorTableEntry_T *ErrorEntry =
2213 &Controller->V1.ErrorTable.ErrorTableEntries[Channel][TargetID];
2214 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2215 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2216 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2217 char SerialNumber[1+sizeof(InquiryUnitSerialNumber
2218 ->ProductSerialNumber)];
2219 if (InquiryStandardData->PeripheralDeviceType == 0x1F) continue;
2220 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2221 Vendor, Model, Revision, SerialNumber);
2222 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2223 Controller, Channel, TargetID, (TargetID < 10 ? " " : ""),
2224 Vendor, Model, Revision);
2225 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2226 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2227 if (DeviceState->Present &&
2228 DeviceState->DeviceType == DAC960_V1_DiskType)
2230 if (Controller->V1.DeviceResetCount[Channel][TargetID] > 0)
2231 DAC960_Info(" Disk Status: %s, %u blocks, %d resets\n",
2233 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2235 : DeviceState->DeviceState
2236 == DAC960_V1_Device_WriteOnly
2238 : DeviceState->DeviceState
2239 == DAC960_V1_Device_Online
2240 ? "Online" : "Standby"),
2241 DeviceState->DiskSize,
2242 Controller->V1.DeviceResetCount[Channel][TargetID]);
2244 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2245 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2247 : DeviceState->DeviceState
2248 == DAC960_V1_Device_WriteOnly
2250 : DeviceState->DeviceState
2251 == DAC960_V1_Device_Online
2252 ? "Online" : "Standby"),
2253 DeviceState->DiskSize);
2255 if (ErrorEntry->ParityErrorCount > 0 ||
2256 ErrorEntry->SoftErrorCount > 0 ||
2257 ErrorEntry->HardErrorCount > 0 ||
2258 ErrorEntry->MiscErrorCount > 0)
2259 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2260 "Hard: %d, Misc: %d\n", Controller,
2261 ErrorEntry->ParityErrorCount,
2262 ErrorEntry->SoftErrorCount,
2263 ErrorEntry->HardErrorCount,
2264 ErrorEntry->MiscErrorCount);
2266 DAC960_Info(" Logical Drives:\n", Controller);
2267 for (LogicalDriveNumber = 0;
2268 LogicalDriveNumber < Controller->LogicalDriveCount;
2269 LogicalDriveNumber++)
2271 DAC960_V1_LogicalDriveInformation_T *LogicalDriveInformation =
2272 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
2273 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks, %s\n",
2274 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2275 LogicalDriveInformation->RAIDLevel,
2276 (LogicalDriveInformation->LogicalDriveState
2277 == DAC960_V1_LogicalDrive_Online
2279 : LogicalDriveInformation->LogicalDriveState
2280 == DAC960_V1_LogicalDrive_Critical
2281 ? "Critical" : "Offline"),
2282 LogicalDriveInformation->LogicalDriveSize,
2283 (LogicalDriveInformation->WriteBack
2284 ? "Write Back" : "Write Thru"));
2291 DAC960_V2_ReportDeviceConfiguration reports the Device Configuration
2292 Information for DAC960 V2 Firmware Controllers.
2295 static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2298 int PhysicalDeviceIndex, LogicalDriveNumber;
2299 DAC960_Info(" Physical Devices:\n", Controller);
2300 for (PhysicalDeviceIndex = 0;
2301 PhysicalDeviceIndex < DAC960_V2_MaxPhysicalDevices;
2302 PhysicalDeviceIndex++)
2304 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
2305 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
2306 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2307 (DAC960_SCSI_Inquiry_T *) &PhysicalDeviceInfo->SCSI_InquiryData;
2308 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2309 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
2310 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2311 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2312 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2313 char SerialNumber[1+sizeof(InquiryUnitSerialNumber->ProductSerialNumber)];
2314 if (PhysicalDeviceInfo == NULL) break;
2315 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2316 Vendor, Model, Revision, SerialNumber);
2317 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2319 PhysicalDeviceInfo->Channel,
2320 PhysicalDeviceInfo->TargetID,
2321 (PhysicalDeviceInfo->TargetID < 10 ? " " : ""),
2322 Vendor, Model, Revision);
2323 if (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers == 0)
2324 DAC960_Info(" %sAsynchronous\n", Controller,
2325 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2328 DAC960_Info(" %sSynchronous at %d MB/sec\n", Controller,
2329 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2331 (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers
2332 * PhysicalDeviceInfo->NegotiatedDataWidthBits/8));
2333 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2334 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2335 if (PhysicalDeviceInfo->PhysicalDeviceState ==
2336 DAC960_V2_Device_Unconfigured)
2338 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2339 (PhysicalDeviceInfo->PhysicalDeviceState
2340 == DAC960_V2_Device_Online
2342 : PhysicalDeviceInfo->PhysicalDeviceState
2343 == DAC960_V2_Device_Rebuild
2345 : PhysicalDeviceInfo->PhysicalDeviceState
2346 == DAC960_V2_Device_Missing
2348 : PhysicalDeviceInfo->PhysicalDeviceState
2349 == DAC960_V2_Device_Critical
2351 : PhysicalDeviceInfo->PhysicalDeviceState
2352 == DAC960_V2_Device_Dead
2354 : PhysicalDeviceInfo->PhysicalDeviceState
2355 == DAC960_V2_Device_SuspectedDead
2357 : PhysicalDeviceInfo->PhysicalDeviceState
2358 == DAC960_V2_Device_CommandedOffline
2359 ? "Commanded-Offline"
2360 : PhysicalDeviceInfo->PhysicalDeviceState
2361 == DAC960_V2_Device_Standby
2362 ? "Standby" : "Unknown"),
2363 PhysicalDeviceInfo->ConfigurableDeviceSize);
2364 if (PhysicalDeviceInfo->ParityErrors == 0 &&
2365 PhysicalDeviceInfo->SoftErrors == 0 &&
2366 PhysicalDeviceInfo->HardErrors == 0 &&
2367 PhysicalDeviceInfo->MiscellaneousErrors == 0 &&
2368 PhysicalDeviceInfo->CommandTimeouts == 0 &&
2369 PhysicalDeviceInfo->Retries == 0 &&
2370 PhysicalDeviceInfo->Aborts == 0 &&
2371 PhysicalDeviceInfo->PredictedFailuresDetected == 0)
2373 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2374 "Hard: %d, Misc: %d\n", Controller,
2375 PhysicalDeviceInfo->ParityErrors,
2376 PhysicalDeviceInfo->SoftErrors,
2377 PhysicalDeviceInfo->HardErrors,
2378 PhysicalDeviceInfo->MiscellaneousErrors);
2379 DAC960_Info(" Timeouts: %d, Retries: %d, "
2380 "Aborts: %d, Predicted: %d\n", Controller,
2381 PhysicalDeviceInfo->CommandTimeouts,
2382 PhysicalDeviceInfo->Retries,
2383 PhysicalDeviceInfo->Aborts,
2384 PhysicalDeviceInfo->PredictedFailuresDetected);
2386 DAC960_Info(" Logical Drives:\n", Controller);
2387 for (LogicalDriveNumber = 0;
2388 LogicalDriveNumber < DAC960_MaxLogicalDrives;
2389 LogicalDriveNumber++)
2391 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
2392 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
2393 unsigned char *ReadCacheStatus[] = { "Read Cache Disabled",
2394 "Read Cache Enabled",
2395 "Read Ahead Enabled",
2396 "Intelligent Read Ahead Enabled",
2397 "-", "-", "-", "-" };
2398 unsigned char *WriteCacheStatus[] = { "Write Cache Disabled",
2399 "Logical Device Read Only",
2400 "Write Cache Enabled",
2401 "Intelligent Write Cache Enabled",
2402 "-", "-", "-", "-" };
2403 unsigned char *GeometryTranslation;
2404 if (LogicalDeviceInfo == NULL) continue;
2405 switch (LogicalDeviceInfo->DriveGeometry)
2407 case DAC960_V2_Geometry_128_32:
2408 GeometryTranslation = "128/32";
2410 case DAC960_V2_Geometry_255_63:
2411 GeometryTranslation = "255/63";
2414 GeometryTranslation = "Invalid";
2415 DAC960_Error("Illegal Logical Device Geometry %d\n",
2416 Controller, LogicalDeviceInfo->DriveGeometry);
2419 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks\n",
2420 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2421 LogicalDeviceInfo->RAIDLevel,
2422 (LogicalDeviceInfo->LogicalDeviceState
2423 == DAC960_V2_LogicalDevice_Online
2425 : LogicalDeviceInfo->LogicalDeviceState
2426 == DAC960_V2_LogicalDevice_Critical
2427 ? "Critical" : "Offline"),
2428 LogicalDeviceInfo->ConfigurableDeviceSize);
2429 DAC960_Info(" Logical Device %s, BIOS Geometry: %s\n",
2431 (LogicalDeviceInfo->LogicalDeviceControl
2432 .LogicalDeviceInitialized
2433 ? "Initialized" : "Uninitialized"),
2434 GeometryTranslation);
2435 if (LogicalDeviceInfo->StripeSize == 0)
2437 if (LogicalDeviceInfo->CacheLineSize == 0)
2438 DAC960_Info(" Stripe Size: N/A, "
2439 "Segment Size: N/A\n", Controller);
2441 DAC960_Info(" Stripe Size: N/A, "
2442 "Segment Size: %dKB\n", Controller,
2443 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2447 if (LogicalDeviceInfo->CacheLineSize == 0)
2448 DAC960_Info(" Stripe Size: %dKB, "
2449 "Segment Size: N/A\n", Controller,
2450 1 << (LogicalDeviceInfo->StripeSize - 2));
2452 DAC960_Info(" Stripe Size: %dKB, "
2453 "Segment Size: %dKB\n", Controller,
2454 1 << (LogicalDeviceInfo->StripeSize - 2),
2455 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2457 DAC960_Info(" %s, %s\n", Controller,
2459 LogicalDeviceInfo->LogicalDeviceControl.ReadCache],
2461 LogicalDeviceInfo->LogicalDeviceControl.WriteCache]);
2462 if (LogicalDeviceInfo->SoftErrors > 0 ||
2463 LogicalDeviceInfo->CommandsFailed > 0 ||
2464 LogicalDeviceInfo->DeferredWriteErrors)
2465 DAC960_Info(" Errors - Soft: %d, Failed: %d, "
2466 "Deferred Write: %d\n", Controller,
2467 LogicalDeviceInfo->SoftErrors,
2468 LogicalDeviceInfo->CommandsFailed,
2469 LogicalDeviceInfo->DeferredWriteErrors);
2476 DAC960_RegisterBlockDevice registers the Block Device structures
2477 associated with Controller.
2480 static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2482 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2486 Register the Block Device Major Number for this DAC960 Controller.
2488 if (register_blkdev(MajorNumber, "dac960") < 0)
2491 for (n = 0; n < DAC960_MaxLogicalDrives; n++) {
2492 struct gendisk *disk = Controller->disks[n];
2493 struct request_queue *RequestQueue;
2495 /* for now, let all request queues share controller's lock */
2496 RequestQueue = blk_init_queue(DAC960_RequestFunction,&Controller->queue_lock);
2497 if (!RequestQueue) {
2498 printk("DAC960: failure to allocate request queue\n");
2501 Controller->RequestQueue[n] = RequestQueue;
2502 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
2503 RequestQueue->queuedata = Controller;
2504 blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2505 blk_queue_max_phys_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2506 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2507 disk->queue = RequestQueue;
2508 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2509 sprintf(disk->devfs_name, "rd/host%d/target%d", Controller->ControllerNumber, n);
2510 disk->major = MajorNumber;
2511 disk->first_minor = n << DAC960_MaxPartitionsBits;
2512 disk->fops = &DAC960_BlockDeviceOperations;
2515 Indicate the Block Device Registration completed successfully,
2522 DAC960_UnregisterBlockDevice unregisters the Block Device structures
2523 associated with Controller.
2526 static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
2528 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2531 /* does order matter when deleting gendisk and cleanup in request queue? */
2532 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
2533 del_gendisk(Controller->disks[disk]);
2534 blk_cleanup_queue(Controller->RequestQueue[disk]);
2535 Controller->RequestQueue[disk] = NULL;
2539 Unregister the Block Device Major Number for this DAC960 Controller.
2541 unregister_blkdev(MajorNumber, "dac960");
2545 DAC960_ComputeGenericDiskInfo computes the values for the Generic Disk
2546 Information Partition Sector Counts and Block Sizes.
2549 static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
2552 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
2553 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
2557 DAC960_ReportErrorStatus reports Controller BIOS Messages passed through
2558 the Error Status Register when the driver performs the BIOS handshaking.
2559 It returns true for fatal errors and false otherwise.
2562 static boolean DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
2563 unsigned char ErrorStatus,
2564 unsigned char Parameter0,
2565 unsigned char Parameter1)
2567 switch (ErrorStatus)
2570 DAC960_Notice("Physical Device %d:%d Not Responding\n",
2571 Controller, Parameter1, Parameter0);
2574 if (Controller->DriveSpinUpMessageDisplayed) break;
2575 DAC960_Notice("Spinning Up Drives\n", Controller);
2576 Controller->DriveSpinUpMessageDisplayed = true;
2579 DAC960_Notice("Configuration Checksum Error\n", Controller);
2582 DAC960_Notice("Mirror Race Recovery Failed\n", Controller);
2585 DAC960_Notice("Mirror Race Recovery In Progress\n", Controller);
2588 DAC960_Notice("Physical Device %d:%d COD Mismatch\n",
2589 Controller, Parameter1, Parameter0);
2592 DAC960_Notice("Logical Drive Installation Aborted\n", Controller);
2595 DAC960_Notice("Mirror Race On A Critical Logical Drive\n", Controller);
2598 DAC960_Notice("New Controller Configuration Found\n", Controller);
2601 DAC960_Error("Fatal Memory Parity Error for Controller at\n", Controller);
2604 DAC960_Error("Unknown Initialization Error %02X for Controller at\n",
2605 Controller, ErrorStatus);
2613 * DAC960_DetectCleanup releases the resources that were allocated
2614 * during DAC960_DetectController(). DAC960_DetectController can
2615 * has several internal failure points, so not ALL resources may
2616 * have been allocated. It's important to free only
2617 * resources that HAVE been allocated. The code below always
2618 * tests that the resource has been allocated before attempting to
2621 static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2625 /* Free the memory mailbox, status, and related structures */
2626 free_dma_loaf(Controller->PCIDevice, &Controller->DmaPages);
2627 if (Controller->MemoryMappedAddress) {
2628 switch(Controller->HardwareType)
2630 case DAC960_BA_Controller:
2631 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2633 case DAC960_LP_Controller:
2634 DAC960_LP_DisableInterrupts(Controller->BaseAddress);
2636 case DAC960_LA_Controller:
2637 DAC960_LA_DisableInterrupts(Controller->BaseAddress);
2639 case DAC960_PG_Controller:
2640 DAC960_PG_DisableInterrupts(Controller->BaseAddress);
2642 case DAC960_PD_Controller:
2643 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2645 case DAC960_P_Controller:
2646 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2649 iounmap(Controller->MemoryMappedAddress);
2651 if (Controller->IRQ_Channel)
2652 free_irq(Controller->IRQ_Channel, Controller);
2653 if (Controller->IO_Address)
2654 release_region(Controller->IO_Address, 0x80);
2655 pci_disable_device(Controller->PCIDevice);
2656 for (i = 0; (i < DAC960_MaxLogicalDrives) && Controller->disks[i]; i++)
2657 put_disk(Controller->disks[i]);
2658 DAC960_Controllers[Controller->ControllerNumber] = NULL;
2664 DAC960_DetectController detects Mylex DAC960/AcceleRAID/eXtremeRAID
2665 PCI RAID Controllers by interrogating the PCI Configuration Space for
2669 static DAC960_Controller_T *
2670 DAC960_DetectController(struct pci_dev *PCI_Device,
2671 const struct pci_device_id *entry)
2673 struct DAC960_privdata *privdata =
2674 (struct DAC960_privdata *)entry->driver_data;
2675 irqreturn_t (*InterruptHandler)(int, void *, struct pt_regs *) =
2676 privdata->InterruptHandler;
2677 unsigned int MemoryWindowSize = privdata->MemoryWindowSize;
2678 DAC960_Controller_T *Controller = NULL;
2679 unsigned char DeviceFunction = PCI_Device->devfn;
2680 unsigned char ErrorStatus, Parameter0, Parameter1;
2681 unsigned int IRQ_Channel;
2682 void __iomem *BaseAddress;
2685 Controller = (DAC960_Controller_T *)
2686 kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
2687 if (Controller == NULL) {
2688 DAC960_Error("Unable to allocate Controller structure for "
2689 "Controller at\n", NULL);
2692 memset(Controller, 0, sizeof(DAC960_Controller_T));
2693 Controller->ControllerNumber = DAC960_ControllerCount;
2694 DAC960_Controllers[DAC960_ControllerCount++] = Controller;
2695 Controller->Bus = PCI_Device->bus->number;
2696 Controller->FirmwareType = privdata->FirmwareType;
2697 Controller->HardwareType = privdata->HardwareType;
2698 Controller->Device = DeviceFunction >> 3;
2699 Controller->Function = DeviceFunction & 0x7;
2700 Controller->PCIDevice = PCI_Device;
2701 strcpy(Controller->FullModelName, "DAC960");
2703 if (pci_enable_device(PCI_Device)) {
2708 switch (Controller->HardwareType)
2710 case DAC960_BA_Controller:
2711 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2713 case DAC960_LP_Controller:
2714 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2716 case DAC960_LA_Controller:
2717 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2719 case DAC960_PG_Controller:
2720 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2722 case DAC960_PD_Controller:
2723 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2724 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2726 case DAC960_P_Controller:
2727 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2728 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2732 pci_set_drvdata(PCI_Device, (void *)((long)Controller->ControllerNumber));
2733 for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
2734 Controller->disks[i] = alloc_disk(1<<DAC960_MaxPartitionsBits);
2735 if (!Controller->disks[i])
2737 Controller->disks[i]->private_data = (void *)((long)i);
2739 init_waitqueue_head(&Controller->CommandWaitQueue);
2740 init_waitqueue_head(&Controller->HealthStatusWaitQueue);
2741 spin_lock_init(&Controller->queue_lock);
2742 DAC960_AnnounceDriver(Controller);
2744 Map the Controller Register Window.
2746 if (MemoryWindowSize < PAGE_SIZE)
2747 MemoryWindowSize = PAGE_SIZE;
2748 Controller->MemoryMappedAddress =
2749 ioremap_nocache(Controller->PCI_Address & PAGE_MASK, MemoryWindowSize);
2750 Controller->BaseAddress =
2751 Controller->MemoryMappedAddress + (Controller->PCI_Address & ~PAGE_MASK);
2752 if (Controller->MemoryMappedAddress == NULL)
2754 DAC960_Error("Unable to map Controller Register Window for "
2755 "Controller at\n", Controller);
2758 BaseAddress = Controller->BaseAddress;
2759 switch (Controller->HardwareType)
2761 case DAC960_BA_Controller:
2762 DAC960_BA_DisableInterrupts(BaseAddress);
2763 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2765 while (DAC960_BA_InitializationInProgressP(BaseAddress))
2767 if (DAC960_BA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2768 &Parameter0, &Parameter1) &&
2769 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2770 Parameter0, Parameter1))
2774 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2776 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2777 "for Controller at\n", Controller);
2780 DAC960_BA_EnableInterrupts(BaseAddress);
2781 Controller->QueueCommand = DAC960_BA_QueueCommand;
2782 Controller->ReadControllerConfiguration =
2783 DAC960_V2_ReadControllerConfiguration;
2784 Controller->ReadDeviceConfiguration =
2785 DAC960_V2_ReadDeviceConfiguration;
2786 Controller->ReportDeviceConfiguration =
2787 DAC960_V2_ReportDeviceConfiguration;
2788 Controller->QueueReadWriteCommand =
2789 DAC960_V2_QueueReadWriteCommand;
2791 case DAC960_LP_Controller:
2792 DAC960_LP_DisableInterrupts(BaseAddress);
2793 DAC960_LP_AcknowledgeHardwareMailboxStatus(BaseAddress);
2795 while (DAC960_LP_InitializationInProgressP(BaseAddress))
2797 if (DAC960_LP_ReadErrorStatus(BaseAddress, &ErrorStatus,
2798 &Parameter0, &Parameter1) &&
2799 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2800 Parameter0, Parameter1))
2804 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2806 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2807 "for Controller at\n", Controller);
2810 DAC960_LP_EnableInterrupts(BaseAddress);
2811 Controller->QueueCommand = DAC960_LP_QueueCommand;
2812 Controller->ReadControllerConfiguration =
2813 DAC960_V2_ReadControllerConfiguration;
2814 Controller->ReadDeviceConfiguration =
2815 DAC960_V2_ReadDeviceConfiguration;
2816 Controller->ReportDeviceConfiguration =
2817 DAC960_V2_ReportDeviceConfiguration;
2818 Controller->QueueReadWriteCommand =
2819 DAC960_V2_QueueReadWriteCommand;
2821 case DAC960_LA_Controller:
2822 DAC960_LA_DisableInterrupts(BaseAddress);
2823 DAC960_LA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2825 while (DAC960_LA_InitializationInProgressP(BaseAddress))
2827 if (DAC960_LA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2828 &Parameter0, &Parameter1) &&
2829 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2830 Parameter0, Parameter1))
2834 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2836 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2837 "for Controller at\n", Controller);
2840 DAC960_LA_EnableInterrupts(BaseAddress);
2841 if (Controller->V1.DualModeMemoryMailboxInterface)
2842 Controller->QueueCommand = DAC960_LA_QueueCommandDualMode;
2843 else Controller->QueueCommand = DAC960_LA_QueueCommandSingleMode;
2844 Controller->ReadControllerConfiguration =
2845 DAC960_V1_ReadControllerConfiguration;
2846 Controller->ReadDeviceConfiguration =
2847 DAC960_V1_ReadDeviceConfiguration;
2848 Controller->ReportDeviceConfiguration =
2849 DAC960_V1_ReportDeviceConfiguration;
2850 Controller->QueueReadWriteCommand =
2851 DAC960_V1_QueueReadWriteCommand;
2853 case DAC960_PG_Controller:
2854 DAC960_PG_DisableInterrupts(BaseAddress);
2855 DAC960_PG_AcknowledgeHardwareMailboxStatus(BaseAddress);
2857 while (DAC960_PG_InitializationInProgressP(BaseAddress))
2859 if (DAC960_PG_ReadErrorStatus(BaseAddress, &ErrorStatus,
2860 &Parameter0, &Parameter1) &&
2861 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2862 Parameter0, Parameter1))
2866 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2868 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2869 "for Controller at\n", Controller);
2872 DAC960_PG_EnableInterrupts(BaseAddress);
2873 if (Controller->V1.DualModeMemoryMailboxInterface)
2874 Controller->QueueCommand = DAC960_PG_QueueCommandDualMode;
2875 else Controller->QueueCommand = DAC960_PG_QueueCommandSingleMode;
2876 Controller->ReadControllerConfiguration =
2877 DAC960_V1_ReadControllerConfiguration;
2878 Controller->ReadDeviceConfiguration =
2879 DAC960_V1_ReadDeviceConfiguration;
2880 Controller->ReportDeviceConfiguration =
2881 DAC960_V1_ReportDeviceConfiguration;
2882 Controller->QueueReadWriteCommand =
2883 DAC960_V1_QueueReadWriteCommand;
2885 case DAC960_PD_Controller:
2886 if (!request_region(Controller->IO_Address, 0x80,
2887 Controller->FullModelName)) {
2888 DAC960_Error("IO port 0x%d busy for Controller at\n",
2889 Controller, Controller->IO_Address);
2892 DAC960_PD_DisableInterrupts(BaseAddress);
2893 DAC960_PD_AcknowledgeStatus(BaseAddress);
2895 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2897 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2898 &Parameter0, &Parameter1) &&
2899 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2900 Parameter0, Parameter1))
2904 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2906 DAC960_Error("Unable to allocate DMA mapped memory "
2907 "for Controller at\n", Controller);
2910 DAC960_PD_EnableInterrupts(BaseAddress);
2911 Controller->QueueCommand = DAC960_PD_QueueCommand;
2912 Controller->ReadControllerConfiguration =
2913 DAC960_V1_ReadControllerConfiguration;
2914 Controller->ReadDeviceConfiguration =
2915 DAC960_V1_ReadDeviceConfiguration;
2916 Controller->ReportDeviceConfiguration =
2917 DAC960_V1_ReportDeviceConfiguration;
2918 Controller->QueueReadWriteCommand =
2919 DAC960_V1_QueueReadWriteCommand;
2921 case DAC960_P_Controller:
2922 if (!request_region(Controller->IO_Address, 0x80,
2923 Controller->FullModelName)){
2924 DAC960_Error("IO port 0x%d busy for Controller at\n",
2925 Controller, Controller->IO_Address);
2928 DAC960_PD_DisableInterrupts(BaseAddress);
2929 DAC960_PD_AcknowledgeStatus(BaseAddress);
2931 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2933 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2934 &Parameter0, &Parameter1) &&
2935 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2936 Parameter0, Parameter1))
2940 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2942 DAC960_Error("Unable to allocate DMA mapped memory"
2943 "for Controller at\n", Controller);
2946 DAC960_PD_EnableInterrupts(BaseAddress);
2947 Controller->QueueCommand = DAC960_P_QueueCommand;
2948 Controller->ReadControllerConfiguration =
2949 DAC960_V1_ReadControllerConfiguration;
2950 Controller->ReadDeviceConfiguration =
2951 DAC960_V1_ReadDeviceConfiguration;
2952 Controller->ReportDeviceConfiguration =
2953 DAC960_V1_ReportDeviceConfiguration;
2954 Controller->QueueReadWriteCommand =
2955 DAC960_V1_QueueReadWriteCommand;
2959 Acquire shared access to the IRQ Channel.
2961 IRQ_Channel = PCI_Device->irq;
2962 if (request_irq(IRQ_Channel, InterruptHandler, SA_SHIRQ,
2963 Controller->FullModelName, Controller) < 0)
2965 DAC960_Error("Unable to acquire IRQ Channel %d for Controller at\n",
2966 Controller, Controller->IRQ_Channel);
2969 Controller->IRQ_Channel = IRQ_Channel;
2970 Controller->InitialCommand.CommandIdentifier = 1;
2971 Controller->InitialCommand.Controller = Controller;
2972 Controller->Commands[0] = &Controller->InitialCommand;
2973 Controller->FreeCommands = &Controller->InitialCommand;
2977 if (Controller->IO_Address == 0)
2978 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
2979 "PCI Address 0x%X\n", Controller,
2980 Controller->Bus, Controller->Device,
2981 Controller->Function, Controller->PCI_Address);
2983 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
2984 "0x%X PCI Address 0x%X\n", Controller,
2985 Controller->Bus, Controller->Device,
2986 Controller->Function, Controller->IO_Address,
2987 Controller->PCI_Address);
2988 DAC960_DetectCleanup(Controller);
2989 DAC960_ControllerCount--;
2994 DAC960_InitializeController initializes Controller.
2998 DAC960_InitializeController(DAC960_Controller_T *Controller)
3000 if (DAC960_ReadControllerConfiguration(Controller) &&
3001 DAC960_ReportControllerConfiguration(Controller) &&
3002 DAC960_CreateAuxiliaryStructures(Controller) &&
3003 DAC960_ReadDeviceConfiguration(Controller) &&
3004 DAC960_ReportDeviceConfiguration(Controller) &&
3005 DAC960_RegisterBlockDevice(Controller))
3008 Initialize the Monitoring Timer.
3010 init_timer(&Controller->MonitoringTimer);
3011 Controller->MonitoringTimer.expires =
3012 jiffies + DAC960_MonitoringTimerInterval;
3013 Controller->MonitoringTimer.data = (unsigned long) Controller;
3014 Controller->MonitoringTimer.function = DAC960_MonitoringTimerFunction;
3015 add_timer(&Controller->MonitoringTimer);
3016 Controller->ControllerInitialized = true;
3024 DAC960_FinalizeController finalizes Controller.
3027 static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
3029 if (Controller->ControllerInitialized)
3031 unsigned long flags;
3034 * Acquiring and releasing lock here eliminates
3035 * a very low probability race.
3037 * The code below allocates controller command structures
3038 * from the free list without holding the controller lock.
3039 * This is safe assuming there is no other activity on
3040 * the controller at the time.
3042 * But, there might be a monitoring command still
3043 * in progress. Setting the Shutdown flag while holding
3044 * the lock ensures that there is no monitoring command
3045 * in the interrupt handler currently, and any monitoring
3046 * commands that complete from this time on will NOT return
3047 * their command structure to the free list.
3050 spin_lock_irqsave(&Controller->queue_lock, flags);
3051 Controller->ShutdownMonitoringTimer = 1;
3052 spin_unlock_irqrestore(&Controller->queue_lock, flags);
3054 del_timer_sync(&Controller->MonitoringTimer);
3055 if (Controller->FirmwareType == DAC960_V1_Controller)
3057 DAC960_Notice("Flushing Cache...", Controller);
3058 DAC960_V1_ExecuteType3(Controller, DAC960_V1_Flush, 0);
3059 DAC960_Notice("done\n", Controller);
3061 if (Controller->HardwareType == DAC960_PD_Controller)
3062 release_region(Controller->IO_Address, 0x80);
3066 DAC960_Notice("Flushing Cache...", Controller);
3067 DAC960_V2_DeviceOperation(Controller, DAC960_V2_PauseDevice,
3068 DAC960_V2_RAID_Controller);
3069 DAC960_Notice("done\n", Controller);
3072 DAC960_UnregisterBlockDevice(Controller);
3073 DAC960_DestroyAuxiliaryStructures(Controller);
3074 DAC960_DestroyProcEntries(Controller);
3075 DAC960_DetectCleanup(Controller);
3080 DAC960_Probe verifies controller's existence and
3081 initializes the DAC960 Driver for that controller.
3085 DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry)
3088 DAC960_Controller_T *Controller;
3090 if (DAC960_ControllerCount == DAC960_MaxControllers)
3092 DAC960_Error("More than %d DAC960 Controllers detected - "
3093 "ignoring from Controller at\n",
3094 NULL, DAC960_MaxControllers);
3098 Controller = DAC960_DetectController(dev, entry);
3102 if (!DAC960_InitializeController(Controller)) {
3103 DAC960_FinalizeController(Controller);
3107 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
3108 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
3109 add_disk(Controller->disks[disk]);
3111 DAC960_CreateProcEntries(Controller);
3117 DAC960_Finalize finalizes the DAC960 Driver.
3120 static void DAC960_Remove(struct pci_dev *PCI_Device)
3122 int Controller_Number = (long)pci_get_drvdata(PCI_Device);
3123 DAC960_Controller_T *Controller = DAC960_Controllers[Controller_Number];
3124 if (Controller != NULL)
3125 DAC960_FinalizeController(Controller);
3130 DAC960_V1_QueueReadWriteCommand prepares and queues a Read/Write Command for
3131 DAC960 V1 Firmware Controllers.
3134 static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *Command)
3136 DAC960_Controller_T *Controller = Command->Controller;
3137 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
3138 DAC960_V1_ScatterGatherSegment_T *ScatterGatherList =
3139 Command->V1.ScatterGatherList;
3140 struct scatterlist *ScatterList = Command->V1.ScatterList;
3142 DAC960_V1_ClearCommand(Command);
3144 if (Command->SegmentCount == 1)
3146 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3147 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Read;
3149 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Write;
3151 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3152 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3153 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3154 CommandMailbox->Type5.BusAddress =
3155 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3161 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3162 CommandMailbox->Type5.CommandOpcode = DAC960_V1_ReadWithScatterGather;
3164 CommandMailbox->Type5.CommandOpcode = DAC960_V1_WriteWithScatterGather;
3166 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3167 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3168 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3169 CommandMailbox->Type5.BusAddress = Command->V1.ScatterGatherListDMA;
3171 CommandMailbox->Type5.ScatterGatherCount = Command->SegmentCount;
3173 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3174 ScatterGatherList->SegmentDataPointer =
3175 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3176 ScatterGatherList->SegmentByteCount =
3177 (DAC960_ByteCount32_T)sg_dma_len(ScatterList);
3180 DAC960_QueueCommand(Command);
3185 DAC960_V2_QueueReadWriteCommand prepares and queues a Read/Write Command for
3186 DAC960 V2 Firmware Controllers.
3189 static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *Command)
3191 DAC960_Controller_T *Controller = Command->Controller;
3192 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
3193 struct scatterlist *ScatterList = Command->V2.ScatterList;
3195 DAC960_V2_ClearCommand(Command);
3197 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10;
3198 CommandMailbox->SCSI_10.CommandControlBits.DataTransferControllerToHost =
3199 (Command->DmaDirection == PCI_DMA_FROMDEVICE);
3200 CommandMailbox->SCSI_10.DataTransferSize =
3201 Command->BlockCount << DAC960_BlockSizeBits;
3202 CommandMailbox->SCSI_10.RequestSenseBusAddress = Command->V2.RequestSenseDMA;
3203 CommandMailbox->SCSI_10.PhysicalDevice =
3204 Controller->V2.LogicalDriveToVirtualDevice[Command->LogicalDriveNumber];
3205 CommandMailbox->SCSI_10.RequestSenseSize = sizeof(DAC960_SCSI_RequestSense_T);
3206 CommandMailbox->SCSI_10.CDBLength = 10;
3207 CommandMailbox->SCSI_10.SCSI_CDB[0] =
3208 (Command->DmaDirection == PCI_DMA_FROMDEVICE ? 0x28 : 0x2A);
3209 CommandMailbox->SCSI_10.SCSI_CDB[2] = Command->BlockNumber >> 24;
3210 CommandMailbox->SCSI_10.SCSI_CDB[3] = Command->BlockNumber >> 16;
3211 CommandMailbox->SCSI_10.SCSI_CDB[4] = Command->BlockNumber >> 8;
3212 CommandMailbox->SCSI_10.SCSI_CDB[5] = Command->BlockNumber;
3213 CommandMailbox->SCSI_10.SCSI_CDB[7] = Command->BlockCount >> 8;
3214 CommandMailbox->SCSI_10.SCSI_CDB[8] = Command->BlockCount;
3216 if (Command->SegmentCount == 1)
3218 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3219 .ScatterGatherSegments[0]
3220 .SegmentDataPointer =
3221 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3222 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3223 .ScatterGatherSegments[0]
3225 CommandMailbox->SCSI_10.DataTransferSize;
3229 DAC960_V2_ScatterGatherSegment_T *ScatterGatherList;
3232 if (Command->SegmentCount > 2)
3234 ScatterGatherList = Command->V2.ScatterGatherList;
3235 CommandMailbox->SCSI_10.CommandControlBits
3236 .AdditionalScatterGatherListMemory = true;
3237 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3238 .ExtendedScatterGather.ScatterGatherList0Length = Command->SegmentCount;
3239 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3240 .ExtendedScatterGather.ScatterGatherList0Address =
3241 Command->V2.ScatterGatherListDMA;
3244 ScatterGatherList = CommandMailbox->SCSI_10.DataTransferMemoryAddress
3245 .ScatterGatherSegments;
3247 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3248 ScatterGatherList->SegmentDataPointer =
3249 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3250 ScatterGatherList->SegmentByteCount =
3251 (DAC960_ByteCount64_T)sg_dma_len(ScatterList);
3254 DAC960_QueueCommand(Command);
3258 static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_queue *req_q)
3260 struct request *Request;
3261 DAC960_Command_T *Command;
3264 Request = elv_next_request(req_q);
3268 Command = DAC960_AllocateCommand(Controller);
3269 if (Command == NULL)
3272 if (rq_data_dir(Request) == READ) {
3273 Command->DmaDirection = PCI_DMA_FROMDEVICE;
3274 Command->CommandType = DAC960_ReadCommand;
3276 Command->DmaDirection = PCI_DMA_TODEVICE;
3277 Command->CommandType = DAC960_WriteCommand;
3279 Command->Completion = Request->waiting;
3280 Command->LogicalDriveNumber = (long)Request->rq_disk->private_data;
3281 Command->BlockNumber = Request->sector;
3282 Command->BlockCount = Request->nr_sectors;
3283 Command->Request = Request;
3284 blkdev_dequeue_request(Request);
3285 Command->SegmentCount = blk_rq_map_sg(req_q,
3286 Command->Request, Command->cmd_sglist);
3287 /* pci_map_sg MAY change the value of SegCount */
3288 Command->SegmentCount = pci_map_sg(Controller->PCIDevice, Command->cmd_sglist,
3289 Command->SegmentCount, Command->DmaDirection);
3291 DAC960_QueueReadWriteCommand(Command);
3296 DAC960_ProcessRequest attempts to remove one I/O Request from Controller's
3297 I/O Request Queue and queues it to the Controller. WaitForCommand is true if
3298 this function should wait for a Command to become available if necessary.
3299 This function returns true if an I/O Request was queued and false otherwise.
3301 static void DAC960_ProcessRequest(DAC960_Controller_T *controller)
3305 if (!controller->ControllerInitialized)
3308 /* Do this better later! */
3309 for (i = controller->req_q_index; i < DAC960_MaxLogicalDrives; i++) {
3310 struct request_queue *req_q = controller->RequestQueue[i];
3315 if (!DAC960_process_queue(controller, req_q)) {
3316 controller->req_q_index = i;
3321 if (controller->req_q_index == 0)
3324 for (i = 0; i < controller->req_q_index; i++) {
3325 struct request_queue *req_q = controller->RequestQueue[i];
3330 if (!DAC960_process_queue(controller, req_q)) {
3331 controller->req_q_index = i;
3339 DAC960_queue_partial_rw extracts one bio from the request already
3340 associated with argument command, and construct a new command block to retry I/O
3341 only on that bio. Queue that command to the controller.
3343 This function re-uses a previously-allocated Command,
3344 there is no failure mode from trying to allocate a command.
3347 static void DAC960_queue_partial_rw(DAC960_Command_T *Command)
3349 DAC960_Controller_T *Controller = Command->Controller;
3350 struct request *Request = Command->Request;
3351 struct request_queue *req_q = Controller->RequestQueue[Command->LogicalDriveNumber];
3353 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3354 Command->CommandType = DAC960_ReadRetryCommand;
3356 Command->CommandType = DAC960_WriteRetryCommand;
3359 * We could be more efficient with these mapping requests
3360 * and map only the portions that we need. But since this
3361 * code should almost never be called, just go with a
3364 (void)blk_rq_map_sg(req_q, Command->Request, Command->cmd_sglist);
3366 (void)pci_map_sg(Controller->PCIDevice, Command->cmd_sglist, 1, Command->DmaDirection);
3368 * Resubmitting the request sector at a time is really tedious.
3369 * But, this should almost never happen. So, we're willing to pay
3370 * this price so that in the end, as much of the transfer is completed
3371 * successfully as possible.
3373 Command->SegmentCount = 1;
3374 Command->BlockNumber = Request->sector;
3375 Command->BlockCount = 1;
3376 DAC960_QueueReadWriteCommand(Command);
3381 DAC960_RequestFunction is the I/O Request Function for DAC960 Controllers.
3384 static void DAC960_RequestFunction(struct request_queue *RequestQueue)
3386 DAC960_ProcessRequest(RequestQueue->queuedata);
3390 DAC960_ProcessCompletedBuffer performs completion processing for an
3394 static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3395 boolean SuccessfulIO)
3397 struct request *Request = Command->Request;
3404 pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist,
3405 Command->SegmentCount, Command->DmaDirection);
3407 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
3409 end_that_request_last(Request);
3411 if (Command->Completion) {
3412 complete(Command->Completion);
3413 Command->Completion = NULL;
3421 DAC960_V1_ReadWriteError prints an appropriate error message for Command
3422 when an error occurs on a Read or Write operation.
3425 static void DAC960_V1_ReadWriteError(DAC960_Command_T *Command)
3427 DAC960_Controller_T *Controller = Command->Controller;
3428 unsigned char *CommandName = "UNKNOWN";
3429 switch (Command->CommandType)
3431 case DAC960_ReadCommand:
3432 case DAC960_ReadRetryCommand:
3433 CommandName = "READ";
3435 case DAC960_WriteCommand:
3436 case DAC960_WriteRetryCommand:
3437 CommandName = "WRITE";
3439 case DAC960_MonitoringCommand:
3440 case DAC960_ImmediateCommand:
3441 case DAC960_QueuedCommand:
3444 switch (Command->V1.CommandStatus)
3446 case DAC960_V1_IrrecoverableDataError:
3447 DAC960_Error("Irrecoverable Data Error on %s:\n",
3448 Controller, CommandName);
3450 case DAC960_V1_LogicalDriveNonexistentOrOffline:
3451 DAC960_Error("Logical Drive Nonexistent or Offline on %s:\n",
3452 Controller, CommandName);
3454 case DAC960_V1_AccessBeyondEndOfLogicalDrive:
3455 DAC960_Error("Attempt to Access Beyond End of Logical Drive "
3456 "on %s:\n", Controller, CommandName);
3458 case DAC960_V1_BadDataEncountered:
3459 DAC960_Error("Bad Data Encountered on %s:\n", Controller, CommandName);
3462 DAC960_Error("Unexpected Error Status %04X on %s:\n",
3463 Controller, Command->V1.CommandStatus, CommandName);
3466 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
3467 Controller, Controller->ControllerNumber,
3468 Command->LogicalDriveNumber, Command->BlockNumber,
3469 Command->BlockNumber + Command->BlockCount - 1);
3474 DAC960_V1_ProcessCompletedCommand performs completion processing for Command
3475 for DAC960 V1 Firmware Controllers.
3478 static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
3480 DAC960_Controller_T *Controller = Command->Controller;
3481 DAC960_CommandType_T CommandType = Command->CommandType;
3482 DAC960_V1_CommandOpcode_T CommandOpcode =
3483 Command->V1.CommandMailbox.Common.CommandOpcode;
3484 DAC960_V1_CommandStatus_T CommandStatus = Command->V1.CommandStatus;
3486 if (CommandType == DAC960_ReadCommand ||
3487 CommandType == DAC960_WriteCommand)
3490 #ifdef FORCE_RETRY_DEBUG
3491 CommandStatus = DAC960_V1_IrrecoverableDataError;
3494 if (CommandStatus == DAC960_V1_NormalCompletion) {
3496 if (!DAC960_ProcessCompletedRequest(Command, true))
3499 } else if (CommandStatus == DAC960_V1_IrrecoverableDataError ||
3500 CommandStatus == DAC960_V1_BadDataEncountered)
3503 * break the command down into pieces and resubmit each
3504 * piece, hoping that some of them will succeed.
3506 DAC960_queue_partial_rw(Command);
3511 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3512 DAC960_V1_ReadWriteError(Command);
3514 if (!DAC960_ProcessCompletedRequest(Command, false))
3518 else if (CommandType == DAC960_ReadRetryCommand ||
3519 CommandType == DAC960_WriteRetryCommand)
3521 boolean normal_completion;
3522 #ifdef FORCE_RETRY_FAILURE_DEBUG
3523 static int retry_count = 1;
3526 Perform completion processing for the portion that was
3527 retried, and submit the next portion, if any.
3529 normal_completion = true;
3530 if (CommandStatus != DAC960_V1_NormalCompletion) {
3531 normal_completion = false;
3532 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3533 DAC960_V1_ReadWriteError(Command);
3536 #ifdef FORCE_RETRY_FAILURE_DEBUG
3537 if (!(++retry_count % 10000)) {
3538 printk("V1 error retry failure test\n");
3539 normal_completion = false;
3540 DAC960_V1_ReadWriteError(Command);
3544 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
3545 DAC960_queue_partial_rw(Command);
3550 else if (CommandType == DAC960_MonitoringCommand)
3552 if (Controller->ShutdownMonitoringTimer)
3554 if (CommandOpcode == DAC960_V1_Enquiry)
3556 DAC960_V1_Enquiry_T *OldEnquiry = &Controller->V1.Enquiry;
3557 DAC960_V1_Enquiry_T *NewEnquiry = Controller->V1.NewEnquiry;
3558 unsigned int OldCriticalLogicalDriveCount =
3559 OldEnquiry->CriticalLogicalDriveCount;
3560 unsigned int NewCriticalLogicalDriveCount =
3561 NewEnquiry->CriticalLogicalDriveCount;
3562 if (NewEnquiry->NumberOfLogicalDrives > Controller->LogicalDriveCount)
3564 int LogicalDriveNumber = Controller->LogicalDriveCount - 1;
3565 while (++LogicalDriveNumber < NewEnquiry->NumberOfLogicalDrives)
3566 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3567 "Now Exists\n", Controller,
3569 Controller->ControllerNumber,
3570 LogicalDriveNumber);
3571 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3572 DAC960_ComputeGenericDiskInfo(Controller);
3574 if (NewEnquiry->NumberOfLogicalDrives < Controller->LogicalDriveCount)
3576 int LogicalDriveNumber = NewEnquiry->NumberOfLogicalDrives - 1;
3577 while (++LogicalDriveNumber < Controller->LogicalDriveCount)
3578 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3579 "No Longer Exists\n", Controller,
3581 Controller->ControllerNumber,
3582 LogicalDriveNumber);
3583 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3584 DAC960_ComputeGenericDiskInfo(Controller);
3586 if (NewEnquiry->StatusFlags.DeferredWriteError !=
3587 OldEnquiry->StatusFlags.DeferredWriteError)
3588 DAC960_Critical("Deferred Write Error Flag is now %s\n", Controller,
3589 (NewEnquiry->StatusFlags.DeferredWriteError
3590 ? "TRUE" : "FALSE"));
3591 if ((NewCriticalLogicalDriveCount > 0 ||
3592 NewCriticalLogicalDriveCount != OldCriticalLogicalDriveCount) ||
3593 (NewEnquiry->OfflineLogicalDriveCount > 0 ||
3594 NewEnquiry->OfflineLogicalDriveCount !=
3595 OldEnquiry->OfflineLogicalDriveCount) ||
3596 (NewEnquiry->DeadDriveCount > 0 ||
3597 NewEnquiry->DeadDriveCount !=
3598 OldEnquiry->DeadDriveCount) ||
3599 (NewEnquiry->EventLogSequenceNumber !=
3600 OldEnquiry->EventLogSequenceNumber) ||
3601 Controller->MonitoringTimerCount == 0 ||
3602 (jiffies - Controller->SecondaryMonitoringTime
3603 >= DAC960_SecondaryMonitoringInterval))
3605 Controller->V1.NeedLogicalDriveInformation = true;
3606 Controller->V1.NewEventLogSequenceNumber =
3607 NewEnquiry->EventLogSequenceNumber;
3608 Controller->V1.NeedErrorTableInformation = true;
3609 Controller->V1.NeedDeviceStateInformation = true;
3610 Controller->V1.StartDeviceStateScan = true;
3611 Controller->V1.NeedBackgroundInitializationStatus =
3612 Controller->V1.BackgroundInitializationStatusSupported;
3613 Controller->SecondaryMonitoringTime = jiffies;
3615 if (NewEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3616 NewEnquiry->RebuildFlag
3617 == DAC960_V1_BackgroundRebuildInProgress ||
3618 OldEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3619 OldEnquiry->RebuildFlag == DAC960_V1_BackgroundRebuildInProgress)
3621 Controller->V1.NeedRebuildProgress = true;
3622 Controller->V1.RebuildProgressFirst =
3623 (NewEnquiry->CriticalLogicalDriveCount <
3624 OldEnquiry->CriticalLogicalDriveCount);
3626 if (OldEnquiry->RebuildFlag == DAC960_V1_BackgroundCheckInProgress)
3627 switch (NewEnquiry->RebuildFlag)
3629 case DAC960_V1_NoStandbyRebuildOrCheckInProgress:
3630 DAC960_Progress("Consistency Check Completed Successfully\n",
3633 case DAC960_V1_StandbyRebuildInProgress:
3634 case DAC960_V1_BackgroundRebuildInProgress:
3636 case DAC960_V1_BackgroundCheckInProgress:
3637 Controller->V1.NeedConsistencyCheckProgress = true;
3639 case DAC960_V1_StandbyRebuildCompletedWithError:
3640 DAC960_Progress("Consistency Check Completed with Error\n",
3643 case DAC960_V1_BackgroundRebuildOrCheckFailed_DriveFailed:
3644 DAC960_Progress("Consistency Check Failed - "
3645 "Physical Device Failed\n", Controller);
3647 case DAC960_V1_BackgroundRebuildOrCheckFailed_LogicalDriveFailed:
3648 DAC960_Progress("Consistency Check Failed - "
3649 "Logical Drive Failed\n", Controller);
3651 case DAC960_V1_BackgroundRebuildOrCheckFailed_OtherCauses:
3652 DAC960_Progress("Consistency Check Failed - Other Causes\n",
3655 case DAC960_V1_BackgroundRebuildOrCheckSuccessfullyTerminated:
3656 DAC960_Progress("Consistency Check Successfully Terminated\n",
3660 else if (NewEnquiry->RebuildFlag
3661 == DAC960_V1_BackgroundCheckInProgress)
3662 Controller->V1.NeedConsistencyCheckProgress = true;
3663 Controller->MonitoringAlertMode =
3664 (NewEnquiry->CriticalLogicalDriveCount > 0 ||
3665 NewEnquiry->OfflineLogicalDriveCount > 0 ||
3666 NewEnquiry->DeadDriveCount > 0);
3667 if (NewEnquiry->RebuildFlag > DAC960_V1_BackgroundCheckInProgress)
3669 Controller->V1.PendingRebuildFlag = NewEnquiry->RebuildFlag;
3670 Controller->V1.RebuildFlagPending = true;
3672 memcpy(&Controller->V1.Enquiry, &Controller->V1.NewEnquiry,
3673 sizeof(DAC960_V1_Enquiry_T));
3675 else if (CommandOpcode == DAC960_V1_PerformEventLogOperation)
3678 *DAC960_EventMessages[] =
3679 { "killed because write recovery failed",
3680 "killed because of SCSI bus reset failure",
3681 "killed because of double check condition",
3682 "killed because it was removed",
3683 "killed because of gross error on SCSI chip",
3684 "killed because of bad tag returned from drive",
3685 "killed because of timeout on SCSI command",
3686 "killed because of reset SCSI command issued from system",
3687 "killed because busy or parity error count exceeded limit",
3688 "killed because of 'kill drive' command from system",
3689 "killed because of selection timeout",
3690 "killed due to SCSI phase sequence error",
3691 "killed due to unknown status" };
3692 DAC960_V1_EventLogEntry_T *EventLogEntry =
3693 Controller->V1.EventLogEntry;
3694 if (EventLogEntry->SequenceNumber ==
3695 Controller->V1.OldEventLogSequenceNumber)
3697 unsigned char SenseKey = EventLogEntry->SenseKey;
3698 unsigned char AdditionalSenseCode =
3699 EventLogEntry->AdditionalSenseCode;
3700 unsigned char AdditionalSenseCodeQualifier =
3701 EventLogEntry->AdditionalSenseCodeQualifier;
3702 if (SenseKey == DAC960_SenseKey_VendorSpecific &&
3703 AdditionalSenseCode == 0x80 &&
3704 AdditionalSenseCodeQualifier <
3705 sizeof(DAC960_EventMessages) / sizeof(char *))
3706 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
3707 EventLogEntry->Channel,
3708 EventLogEntry->TargetID,
3709 DAC960_EventMessages[
3710 AdditionalSenseCodeQualifier]);
3711 else if (SenseKey == DAC960_SenseKey_UnitAttention &&
3712 AdditionalSenseCode == 0x29)
3714 if (Controller->MonitoringTimerCount > 0)
3715 Controller->V1.DeviceResetCount[EventLogEntry->Channel]
3716 [EventLogEntry->TargetID]++;
3718 else if (!(SenseKey == DAC960_SenseKey_NoSense ||
3719 (SenseKey == DAC960_SenseKey_NotReady &&
3720 AdditionalSenseCode == 0x04 &&
3721 (AdditionalSenseCodeQualifier == 0x01 ||
3722 AdditionalSenseCodeQualifier == 0x02))))
3724 DAC960_Critical("Physical Device %d:%d Error Log: "
3725 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
3727 EventLogEntry->Channel,
3728 EventLogEntry->TargetID,
3730 AdditionalSenseCode,
3731 AdditionalSenseCodeQualifier);
3732 DAC960_Critical("Physical Device %d:%d Error Log: "
3733 "Information = %02X%02X%02X%02X "
3734 "%02X%02X%02X%02X\n",
3736 EventLogEntry->Channel,
3737 EventLogEntry->TargetID,
3738 EventLogEntry->Information[0],
3739 EventLogEntry->Information[1],
3740 EventLogEntry->Information[2],
3741 EventLogEntry->Information[3],
3742 EventLogEntry->CommandSpecificInformation[0],
3743 EventLogEntry->CommandSpecificInformation[1],
3744 EventLogEntry->CommandSpecificInformation[2],
3745 EventLogEntry->CommandSpecificInformation[3]);
3748 Controller->V1.OldEventLogSequenceNumber++;
3750 else if (CommandOpcode == DAC960_V1_GetErrorTable)
3752 DAC960_V1_ErrorTable_T *OldErrorTable = &Controller->V1.ErrorTable;
3753 DAC960_V1_ErrorTable_T *NewErrorTable = Controller->V1.NewErrorTable;
3754 int Channel, TargetID;
3755 for (Channel = 0; Channel < Controller->Channels; Channel++)
3756 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
3758 DAC960_V1_ErrorTableEntry_T *NewErrorEntry =
3759 &NewErrorTable->ErrorTableEntries[Channel][TargetID];
3760 DAC960_V1_ErrorTableEntry_T *OldErrorEntry =
3761 &OldErrorTable->ErrorTableEntries[Channel][TargetID];
3762 if ((NewErrorEntry->ParityErrorCount !=
3763 OldErrorEntry->ParityErrorCount) ||
3764 (NewErrorEntry->SoftErrorCount !=
3765 OldErrorEntry->SoftErrorCount) ||
3766 (NewErrorEntry->HardErrorCount !=
3767 OldErrorEntry->HardErrorCount) ||
3768 (NewErrorEntry->MiscErrorCount !=
3769 OldErrorEntry->MiscErrorCount))
3770 DAC960_Critical("Physical Device %d:%d Errors: "
3771 "Parity = %d, Soft = %d, "
3772 "Hard = %d, Misc = %d\n",
3773 Controller, Channel, TargetID,
3774 NewErrorEntry->ParityErrorCount,
3775 NewErrorEntry->SoftErrorCount,
3776 NewErrorEntry->HardErrorCount,
3777 NewErrorEntry->MiscErrorCount);
3779 memcpy(&Controller->V1.ErrorTable, Controller->V1.NewErrorTable,
3780 sizeof(DAC960_V1_ErrorTable_T));
3782 else if (CommandOpcode == DAC960_V1_GetDeviceState)
3784 DAC960_V1_DeviceState_T *OldDeviceState =
3785 &Controller->V1.DeviceState[Controller->V1.DeviceStateChannel]
3786 [Controller->V1.DeviceStateTargetID];
3787 DAC960_V1_DeviceState_T *NewDeviceState =
3788 Controller->V1.NewDeviceState;
3789 if (NewDeviceState->DeviceState != OldDeviceState->DeviceState)
3790 DAC960_Critical("Physical Device %d:%d is now %s\n", Controller,
3791 Controller->V1.DeviceStateChannel,
3792 Controller->V1.DeviceStateTargetID,
3793 (NewDeviceState->DeviceState
3794 == DAC960_V1_Device_Dead
3796 : NewDeviceState->DeviceState
3797 == DAC960_V1_Device_WriteOnly
3799 : NewDeviceState->DeviceState
3800 == DAC960_V1_Device_Online
3801 ? "ONLINE" : "STANDBY"));
3802 if (OldDeviceState->DeviceState == DAC960_V1_Device_Dead &&
3803 NewDeviceState->DeviceState != DAC960_V1_Device_Dead)
3805 Controller->V1.NeedDeviceInquiryInformation = true;
3806 Controller->V1.NeedDeviceSerialNumberInformation = true;
3807 Controller->V1.DeviceResetCount
3808 [Controller->V1.DeviceStateChannel]
3809 [Controller->V1.DeviceStateTargetID] = 0;
3811 memcpy(OldDeviceState, NewDeviceState,
3812 sizeof(DAC960_V1_DeviceState_T));
3814 else if (CommandOpcode == DAC960_V1_GetLogicalDriveInformation)
3816 int LogicalDriveNumber;
3817 for (LogicalDriveNumber = 0;
3818 LogicalDriveNumber < Controller->LogicalDriveCount;
3819 LogicalDriveNumber++)
3821 DAC960_V1_LogicalDriveInformation_T *OldLogicalDriveInformation =
3822 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
3823 DAC960_V1_LogicalDriveInformation_T *NewLogicalDriveInformation =
3824 &(*Controller->V1.NewLogicalDriveInformation)[LogicalDriveNumber];
3825 if (NewLogicalDriveInformation->LogicalDriveState !=
3826 OldLogicalDriveInformation->LogicalDriveState)
3827 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3828 "is now %s\n", Controller,
3830 Controller->ControllerNumber,
3832 (NewLogicalDriveInformation->LogicalDriveState
3833 == DAC960_V1_LogicalDrive_Online
3835 : NewLogicalDriveInformation->LogicalDriveState
3836 == DAC960_V1_LogicalDrive_Critical
3837 ? "CRITICAL" : "OFFLINE"));
3838 if (NewLogicalDriveInformation->WriteBack !=
3839 OldLogicalDriveInformation->WriteBack)
3840 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3841 "is now %s\n", Controller,
3843 Controller->ControllerNumber,
3845 (NewLogicalDriveInformation->WriteBack
3846 ? "WRITE BACK" : "WRITE THRU"));
3848 memcpy(&Controller->V1.LogicalDriveInformation,
3849 Controller->V1.NewLogicalDriveInformation,
3850 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
3852 else if (CommandOpcode == DAC960_V1_GetRebuildProgress)
3854 unsigned int LogicalDriveNumber =
3855 Controller->V1.RebuildProgress->LogicalDriveNumber;
3856 unsigned int LogicalDriveSize =
3857 Controller->V1.RebuildProgress->LogicalDriveSize;
3858 unsigned int BlocksCompleted =
3859 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3860 if (CommandStatus == DAC960_V1_NoRebuildOrCheckInProgress &&
3861 Controller->V1.LastRebuildStatus == DAC960_V1_NormalCompletion)
3862 CommandStatus = DAC960_V1_RebuildSuccessful;
3863 switch (CommandStatus)
3865 case DAC960_V1_NormalCompletion:
3866 Controller->EphemeralProgressMessage = true;
3867 DAC960_Progress("Rebuild in Progress: "
3868 "Logical Drive %d (/dev/rd/c%dd%d) "
3870 Controller, LogicalDriveNumber,
3871 Controller->ControllerNumber,
3873 (100 * (BlocksCompleted >> 7))
3874 / (LogicalDriveSize >> 7));
3875 Controller->EphemeralProgressMessage = false;
3877 case DAC960_V1_RebuildFailed_LogicalDriveFailure:
3878 DAC960_Progress("Rebuild Failed due to "
3879 "Logical Drive Failure\n", Controller);
3881 case DAC960_V1_RebuildFailed_BadBlocksOnOther:
3882 DAC960_Progress("Rebuild Failed due to "
3883 "Bad Blocks on Other Drives\n", Controller);
3885 case DAC960_V1_RebuildFailed_NewDriveFailed:
3886 DAC960_Progress("Rebuild Failed due to "
3887 "Failure of Drive Being Rebuilt\n", Controller);
3889 case DAC960_V1_NoRebuildOrCheckInProgress:
3891 case DAC960_V1_RebuildSuccessful:
3892 DAC960_Progress("Rebuild Completed Successfully\n", Controller);
3894 case DAC960_V1_RebuildSuccessfullyTerminated:
3895 DAC960_Progress("Rebuild Successfully Terminated\n", Controller);
3898 Controller->V1.LastRebuildStatus = CommandStatus;
3899 if (CommandType != DAC960_MonitoringCommand &&
3900 Controller->V1.RebuildStatusPending)
3902 Command->V1.CommandStatus = Controller->V1.PendingRebuildStatus;
3903 Controller->V1.RebuildStatusPending = false;
3905 else if (CommandType == DAC960_MonitoringCommand &&
3906 CommandStatus != DAC960_V1_NormalCompletion &&
3907 CommandStatus != DAC960_V1_NoRebuildOrCheckInProgress)
3909 Controller->V1.PendingRebuildStatus = CommandStatus;
3910 Controller->V1.RebuildStatusPending = true;
3913 else if (CommandOpcode == DAC960_V1_RebuildStat)
3915 unsigned int LogicalDriveNumber =
3916 Controller->V1.RebuildProgress->LogicalDriveNumber;
3917 unsigned int LogicalDriveSize =
3918 Controller->V1.RebuildProgress->LogicalDriveSize;
3919 unsigned int BlocksCompleted =
3920 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3921 if (CommandStatus == DAC960_V1_NormalCompletion)
3923 Controller->EphemeralProgressMessage = true;
3924 DAC960_Progress("Consistency Check in Progress: "
3925 "Logical Drive %d (/dev/rd/c%dd%d) "
3927 Controller, LogicalDriveNumber,
3928 Controller->ControllerNumber,
3930 (100 * (BlocksCompleted >> 7))
3931 / (LogicalDriveSize >> 7));
3932 Controller->EphemeralProgressMessage = false;
3935 else if (CommandOpcode == DAC960_V1_BackgroundInitializationControl)
3937 unsigned int LogicalDriveNumber =
3938 Controller->V1.BackgroundInitializationStatus->LogicalDriveNumber;
3939 unsigned int LogicalDriveSize =
3940 Controller->V1.BackgroundInitializationStatus->LogicalDriveSize;
3941 unsigned int BlocksCompleted =
3942 Controller->V1.BackgroundInitializationStatus->BlocksCompleted;
3943 switch (CommandStatus)
3945 case DAC960_V1_NormalCompletion:
3946 switch (Controller->V1.BackgroundInitializationStatus->Status)
3948 case DAC960_V1_BackgroundInitializationInvalid:
3950 case DAC960_V1_BackgroundInitializationStarted:
3951 DAC960_Progress("Background Initialization Started\n",
3954 case DAC960_V1_BackgroundInitializationInProgress:
3955 if (BlocksCompleted ==
3956 Controller->V1.LastBackgroundInitializationStatus.
3958 LogicalDriveNumber ==
3959 Controller->V1.LastBackgroundInitializationStatus.
3962 Controller->EphemeralProgressMessage = true;
3963 DAC960_Progress("Background Initialization in Progress: "
3964 "Logical Drive %d (/dev/rd/c%dd%d) "
3966 Controller, LogicalDriveNumber,
3967 Controller->ControllerNumber,
3969 (100 * (BlocksCompleted >> 7))
3970 / (LogicalDriveSize >> 7));
3971 Controller->EphemeralProgressMessage = false;
3973 case DAC960_V1_BackgroundInitializationSuspended:
3974 DAC960_Progress("Background Initialization Suspended\n",
3977 case DAC960_V1_BackgroundInitializationCancelled:
3978 DAC960_Progress("Background Initialization Cancelled\n",
3982 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
3983 Controller->V1.BackgroundInitializationStatus,
3984 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
3986 case DAC960_V1_BackgroundInitSuccessful:
3987 if (Controller->V1.BackgroundInitializationStatus->Status ==
3988 DAC960_V1_BackgroundInitializationInProgress)
3989 DAC960_Progress("Background Initialization "
3990 "Completed Successfully\n", Controller);
3991 Controller->V1.BackgroundInitializationStatus->Status =
3992 DAC960_V1_BackgroundInitializationInvalid;
3994 case DAC960_V1_BackgroundInitAborted:
3995 if (Controller->V1.BackgroundInitializationStatus->Status ==
3996 DAC960_V1_BackgroundInitializationInProgress)
3997 DAC960_Progress("Background Initialization Aborted\n",
3999 Controller->V1.BackgroundInitializationStatus->Status =
4000 DAC960_V1_BackgroundInitializationInvalid;
4002 case DAC960_V1_NoBackgroundInitInProgress:
4006 else if (CommandOpcode == DAC960_V1_DCDB)
4011 The InquiryStandardData and
4012 the InquiryUntitSerialNumber information
4013 retrieval operations BOTH use the DAC960_V1_DCDB
4014 commands. the test above can't distinguish between
4017 Instead, we rely on the order of code later in this
4018 function to ensure that DeviceInquiryInformation commands
4019 are submitted before DeviceSerialNumber commands.
4021 if (Controller->V1.NeedDeviceInquiryInformation)
4023 DAC960_SCSI_Inquiry_T *InquiryStandardData =
4024 &Controller->V1.InquiryStandardData
4025 [Controller->V1.DeviceStateChannel]
4026 [Controller->V1.DeviceStateTargetID];
4027 if (CommandStatus != DAC960_V1_NormalCompletion)
4029 memset(InquiryStandardData, 0,
4030 sizeof(DAC960_SCSI_Inquiry_T));
4031 InquiryStandardData->PeripheralDeviceType = 0x1F;
4034 memcpy(InquiryStandardData,
4035 Controller->V1.NewInquiryStandardData,
4036 sizeof(DAC960_SCSI_Inquiry_T));
4037 Controller->V1.NeedDeviceInquiryInformation = false;
4039 else if (Controller->V1.NeedDeviceSerialNumberInformation)
4041 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4042 &Controller->V1.InquiryUnitSerialNumber
4043 [Controller->V1.DeviceStateChannel]
4044 [Controller->V1.DeviceStateTargetID];
4045 if (CommandStatus != DAC960_V1_NormalCompletion)
4047 memset(InquiryUnitSerialNumber, 0,
4048 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4049 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4052 memcpy(InquiryUnitSerialNumber,
4053 Controller->V1.NewInquiryUnitSerialNumber,
4054 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4055 Controller->V1.NeedDeviceSerialNumberInformation = false;
4059 Begin submitting new monitoring commands.
4061 if (Controller->V1.NewEventLogSequenceNumber
4062 - Controller->V1.OldEventLogSequenceNumber > 0)
4064 Command->V1.CommandMailbox.Type3E.CommandOpcode =
4065 DAC960_V1_PerformEventLogOperation;
4066 Command->V1.CommandMailbox.Type3E.OperationType =
4067 DAC960_V1_GetEventLogEntry;
4068 Command->V1.CommandMailbox.Type3E.OperationQualifier = 1;
4069 Command->V1.CommandMailbox.Type3E.SequenceNumber =
4070 Controller->V1.OldEventLogSequenceNumber;
4071 Command->V1.CommandMailbox.Type3E.BusAddress =
4072 Controller->V1.EventLogEntryDMA;
4073 DAC960_QueueCommand(Command);
4076 if (Controller->V1.NeedErrorTableInformation)
4078 Controller->V1.NeedErrorTableInformation = false;
4079 Command->V1.CommandMailbox.Type3.CommandOpcode =
4080 DAC960_V1_GetErrorTable;
4081 Command->V1.CommandMailbox.Type3.BusAddress =
4082 Controller->V1.NewErrorTableDMA;
4083 DAC960_QueueCommand(Command);
4086 if (Controller->V1.NeedRebuildProgress &&
4087 Controller->V1.RebuildProgressFirst)
4089 Controller->V1.NeedRebuildProgress = false;
4090 Command->V1.CommandMailbox.Type3.CommandOpcode =
4091 DAC960_V1_GetRebuildProgress;
4092 Command->V1.CommandMailbox.Type3.BusAddress =
4093 Controller->V1.RebuildProgressDMA;
4094 DAC960_QueueCommand(Command);
4097 if (Controller->V1.NeedDeviceStateInformation)
4099 if (Controller->V1.NeedDeviceInquiryInformation)
4101 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4102 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4104 dma_addr_t NewInquiryStandardDataDMA =
4105 Controller->V1.NewInquiryStandardDataDMA;
4107 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4108 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4109 DCDB->Channel = Controller->V1.DeviceStateChannel;
4110 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4111 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4112 DCDB->EarlyStatus = false;
4113 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4114 DCDB->NoAutomaticRequestSense = false;
4115 DCDB->DisconnectPermitted = true;
4116 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
4117 DCDB->BusAddress = NewInquiryStandardDataDMA;
4118 DCDB->CDBLength = 6;
4119 DCDB->TransferLengthHigh4 = 0;
4120 DCDB->SenseLength = sizeof(DCDB->SenseData);
4121 DCDB->CDB[0] = 0x12; /* INQUIRY */
4122 DCDB->CDB[1] = 0; /* EVPD = 0 */
4123 DCDB->CDB[2] = 0; /* Page Code */
4124 DCDB->CDB[3] = 0; /* Reserved */
4125 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
4126 DCDB->CDB[5] = 0; /* Control */
4127 DAC960_QueueCommand(Command);
4130 if (Controller->V1.NeedDeviceSerialNumberInformation)
4132 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4133 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4134 dma_addr_t NewInquiryUnitSerialNumberDMA =
4135 Controller->V1.NewInquiryUnitSerialNumberDMA;
4137 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4138 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4139 DCDB->Channel = Controller->V1.DeviceStateChannel;
4140 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4141 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4142 DCDB->EarlyStatus = false;
4143 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4144 DCDB->NoAutomaticRequestSense = false;
4145 DCDB->DisconnectPermitted = true;
4146 DCDB->TransferLength =
4147 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4148 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
4149 DCDB->CDBLength = 6;
4150 DCDB->TransferLengthHigh4 = 0;
4151 DCDB->SenseLength = sizeof(DCDB->SenseData);
4152 DCDB->CDB[0] = 0x12; /* INQUIRY */
4153 DCDB->CDB[1] = 1; /* EVPD = 1 */
4154 DCDB->CDB[2] = 0x80; /* Page Code */
4155 DCDB->CDB[3] = 0; /* Reserved */
4156 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4157 DCDB->CDB[5] = 0; /* Control */
4158 DAC960_QueueCommand(Command);
4161 if (Controller->V1.StartDeviceStateScan)
4163 Controller->V1.DeviceStateChannel = 0;
4164 Controller->V1.DeviceStateTargetID = 0;
4165 Controller->V1.StartDeviceStateScan = false;
4167 else if (++Controller->V1.DeviceStateTargetID == Controller->Targets)
4169 Controller->V1.DeviceStateChannel++;
4170 Controller->V1.DeviceStateTargetID = 0;
4172 if (Controller->V1.DeviceStateChannel < Controller->Channels)
4174 Controller->V1.NewDeviceState->DeviceState =
4175 DAC960_V1_Device_Dead;
4176 Command->V1.CommandMailbox.Type3D.CommandOpcode =
4177 DAC960_V1_GetDeviceState;
4178 Command->V1.CommandMailbox.Type3D.Channel =
4179 Controller->V1.DeviceStateChannel;
4180 Command->V1.CommandMailbox.Type3D.TargetID =
4181 Controller->V1.DeviceStateTargetID;
4182 Command->V1.CommandMailbox.Type3D.BusAddress =
4183 Controller->V1.NewDeviceStateDMA;
4184 DAC960_QueueCommand(Command);
4187 Controller->V1.NeedDeviceStateInformation = false;
4189 if (Controller->V1.NeedLogicalDriveInformation)
4191 Controller->V1.NeedLogicalDriveInformation = false;
4192 Command->V1.CommandMailbox.Type3.CommandOpcode =
4193 DAC960_V1_GetLogicalDriveInformation;
4194 Command->V1.CommandMailbox.Type3.BusAddress =
4195 Controller->V1.NewLogicalDriveInformationDMA;
4196 DAC960_QueueCommand(Command);
4199 if (Controller->V1.NeedRebuildProgress)
4201 Controller->V1.NeedRebuildProgress = false;
4202 Command->V1.CommandMailbox.Type3.CommandOpcode =
4203 DAC960_V1_GetRebuildProgress;
4204 Command->V1.CommandMailbox.Type3.BusAddress =
4205 Controller->V1.RebuildProgressDMA;
4206 DAC960_QueueCommand(Command);
4209 if (Controller->V1.NeedConsistencyCheckProgress)
4211 Controller->V1.NeedConsistencyCheckProgress = false;
4212 Command->V1.CommandMailbox.Type3.CommandOpcode =
4213 DAC960_V1_RebuildStat;
4214 Command->V1.CommandMailbox.Type3.BusAddress =
4215 Controller->V1.RebuildProgressDMA;
4216 DAC960_QueueCommand(Command);
4219 if (Controller->V1.NeedBackgroundInitializationStatus)
4221 Controller->V1.NeedBackgroundInitializationStatus = false;
4222 Command->V1.CommandMailbox.Type3B.CommandOpcode =
4223 DAC960_V1_BackgroundInitializationControl;
4224 Command->V1.CommandMailbox.Type3B.CommandOpcode2 = 0x20;
4225 Command->V1.CommandMailbox.Type3B.BusAddress =
4226 Controller->V1.BackgroundInitializationStatusDMA;
4227 DAC960_QueueCommand(Command);
4230 Controller->MonitoringTimerCount++;
4231 Controller->MonitoringTimer.expires =
4232 jiffies + DAC960_MonitoringTimerInterval;
4233 add_timer(&Controller->MonitoringTimer);
4235 if (CommandType == DAC960_ImmediateCommand)
4237 complete(Command->Completion);
4238 Command->Completion = NULL;
4241 if (CommandType == DAC960_QueuedCommand)
4243 DAC960_V1_KernelCommand_T *KernelCommand = Command->V1.KernelCommand;
4244 KernelCommand->CommandStatus = Command->V1.CommandStatus;
4245 Command->V1.KernelCommand = NULL;
4246 if (CommandOpcode == DAC960_V1_DCDB)
4247 Controller->V1.DirectCommandActive[KernelCommand->DCDB->Channel]
4248 [KernelCommand->DCDB->TargetID] =
4250 DAC960_DeallocateCommand(Command);
4251 KernelCommand->CompletionFunction(KernelCommand);
4255 Queue a Status Monitoring Command to the Controller using the just
4256 completed Command if one was deferred previously due to lack of a
4257 free Command when the Monitoring Timer Function was called.
4259 if (Controller->MonitoringCommandDeferred)
4261 Controller->MonitoringCommandDeferred = false;
4262 DAC960_V1_QueueMonitoringCommand(Command);
4266 Deallocate the Command.
4268 DAC960_DeallocateCommand(Command);
4270 Wake up any processes waiting on a free Command.
4272 wake_up(&Controller->CommandWaitQueue);
4277 DAC960_V2_ReadWriteError prints an appropriate error message for Command
4278 when an error occurs on a Read or Write operation.
4281 static void DAC960_V2_ReadWriteError(DAC960_Command_T *Command)
4283 DAC960_Controller_T *Controller = Command->Controller;
4284 unsigned char *SenseErrors[] = { "NO SENSE", "RECOVERED ERROR",
4285 "NOT READY", "MEDIUM ERROR",
4286 "HARDWARE ERROR", "ILLEGAL REQUEST",
4287 "UNIT ATTENTION", "DATA PROTECT",
4288 "BLANK CHECK", "VENDOR-SPECIFIC",
4289 "COPY ABORTED", "ABORTED COMMAND",
4290 "EQUAL", "VOLUME OVERFLOW",
4291 "MISCOMPARE", "RESERVED" };
4292 unsigned char *CommandName = "UNKNOWN";
4293 switch (Command->CommandType)
4295 case DAC960_ReadCommand:
4296 case DAC960_ReadRetryCommand:
4297 CommandName = "READ";
4299 case DAC960_WriteCommand:
4300 case DAC960_WriteRetryCommand:
4301 CommandName = "WRITE";
4303 case DAC960_MonitoringCommand:
4304 case DAC960_ImmediateCommand:
4305 case DAC960_QueuedCommand:
4308 DAC960_Error("Error Condition %s on %s:\n", Controller,
4309 SenseErrors[Command->V2.RequestSense->SenseKey], CommandName);
4310 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
4311 Controller, Controller->ControllerNumber,
4312 Command->LogicalDriveNumber, Command->BlockNumber,
4313 Command->BlockNumber + Command->BlockCount - 1);
4318 DAC960_V2_ReportEvent prints an appropriate message when a Controller Event
4322 static void DAC960_V2_ReportEvent(DAC960_Controller_T *Controller,
4323 DAC960_V2_Event_T *Event)
4325 DAC960_SCSI_RequestSense_T *RequestSense =
4326 (DAC960_SCSI_RequestSense_T *) &Event->RequestSenseData;
4327 unsigned char MessageBuffer[DAC960_LineBufferSize];
4328 static struct { int EventCode; unsigned char *EventMessage; } EventList[] =
4329 { /* Physical Device Events (0x0000 - 0x007F) */
4330 { 0x0001, "P Online" },
4331 { 0x0002, "P Standby" },
4332 { 0x0005, "P Automatic Rebuild Started" },
4333 { 0x0006, "P Manual Rebuild Started" },
4334 { 0x0007, "P Rebuild Completed" },
4335 { 0x0008, "P Rebuild Cancelled" },
4336 { 0x0009, "P Rebuild Failed for Unknown Reasons" },
4337 { 0x000A, "P Rebuild Failed due to New Physical Device" },
4338 { 0x000B, "P Rebuild Failed due to Logical Drive Failure" },
4339 { 0x000C, "S Offline" },
4340 { 0x000D, "P Found" },
4341 { 0x000E, "P Removed" },
4342 { 0x000F, "P Unconfigured" },
4343 { 0x0010, "P Expand Capacity Started" },
4344 { 0x0011, "P Expand Capacity Completed" },
4345 { 0x0012, "P Expand Capacity Failed" },
4346 { 0x0013, "P Command Timed Out" },
4347 { 0x0014, "P Command Aborted" },
4348 { 0x0015, "P Command Retried" },
4349 { 0x0016, "P Parity Error" },
4350 { 0x0017, "P Soft Error" },
4351 { 0x0018, "P Miscellaneous Error" },
4352 { 0x0019, "P Reset" },
4353 { 0x001A, "P Active Spare Found" },
4354 { 0x001B, "P Warm Spare Found" },
4355 { 0x001C, "S Sense Data Received" },
4356 { 0x001D, "P Initialization Started" },
4357 { 0x001E, "P Initialization Completed" },
4358 { 0x001F, "P Initialization Failed" },
4359 { 0x0020, "P Initialization Cancelled" },
4360 { 0x0021, "P Failed because Write Recovery Failed" },
4361 { 0x0022, "P Failed because SCSI Bus Reset Failed" },
4362 { 0x0023, "P Failed because of Double Check Condition" },
4363 { 0x0024, "P Failed because Device Cannot Be Accessed" },
4364 { 0x0025, "P Failed because of Gross Error on SCSI Processor" },
4365 { 0x0026, "P Failed because of Bad Tag from Device" },
4366 { 0x0027, "P Failed because of Command Timeout" },
4367 { 0x0028, "P Failed because of System Reset" },
4368 { 0x0029, "P Failed because of Busy Status or Parity Error" },
4369 { 0x002A, "P Failed because Host Set Device to Failed State" },
4370 { 0x002B, "P Failed because of Selection Timeout" },
4371 { 0x002C, "P Failed because of SCSI Bus Phase Error" },
4372 { 0x002D, "P Failed because Device Returned Unknown Status" },
4373 { 0x002E, "P Failed because Device Not Ready" },
4374 { 0x002F, "P Failed because Device Not Found at Startup" },
4375 { 0x0030, "P Failed because COD Write Operation Failed" },
4376 { 0x0031, "P Failed because BDT Write Operation Failed" },
4377 { 0x0039, "P Missing at Startup" },
4378 { 0x003A, "P Start Rebuild Failed due to Physical Drive Too Small" },
4379 { 0x003C, "P Temporarily Offline Device Automatically Made Online" },
4380 { 0x003D, "P Standby Rebuild Started" },
4381 /* Logical Device Events (0x0080 - 0x00FF) */
4382 { 0x0080, "M Consistency Check Started" },
4383 { 0x0081, "M Consistency Check Completed" },
4384 { 0x0082, "M Consistency Check Cancelled" },
4385 { 0x0083, "M Consistency Check Completed With Errors" },
4386 { 0x0084, "M Consistency Check Failed due to Logical Drive Failure" },
4387 { 0x0085, "M Consistency Check Failed due to Physical Device Failure" },
4388 { 0x0086, "L Offline" },
4389 { 0x0087, "L Critical" },
4390 { 0x0088, "L Online" },
4391 { 0x0089, "M Automatic Rebuild Started" },
4392 { 0x008A, "M Manual Rebuild Started" },
4393 { 0x008B, "M Rebuild Completed" },
4394 { 0x008C, "M Rebuild Cancelled" },
4395 { 0x008D, "M Rebuild Failed for Unknown Reasons" },
4396 { 0x008E, "M Rebuild Failed due to New Physical Device" },
4397 { 0x008F, "M Rebuild Failed due to Logical Drive Failure" },
4398 { 0x0090, "M Initialization Started" },
4399 { 0x0091, "M Initialization Completed" },
4400 { 0x0092, "M Initialization Cancelled" },
4401 { 0x0093, "M Initialization Failed" },
4402 { 0x0094, "L Found" },
4403 { 0x0095, "L Deleted" },
4404 { 0x0096, "M Expand Capacity Started" },
4405 { 0x0097, "M Expand Capacity Completed" },
4406 { 0x0098, "M Expand Capacity Failed" },
4407 { 0x0099, "L Bad Block Found" },
4408 { 0x009A, "L Size Changed" },
4409 { 0x009B, "L Type Changed" },
4410 { 0x009C, "L Bad Data Block Found" },
4411 { 0x009E, "L Read of Data Block in BDT" },
4412 { 0x009F, "L Write Back Data for Disk Block Lost" },
4413 { 0x00A0, "L Temporarily Offline RAID-5/3 Drive Made Online" },
4414 { 0x00A1, "L Temporarily Offline RAID-6/1/0/7 Drive Made Online" },
4415 { 0x00A2, "L Standby Rebuild Started" },
4416 /* Fault Management Events (0x0100 - 0x017F) */
4417 { 0x0140, "E Fan %d Failed" },
4418 { 0x0141, "E Fan %d OK" },
4419 { 0x0142, "E Fan %d Not Present" },
4420 { 0x0143, "E Power Supply %d Failed" },
4421 { 0x0144, "E Power Supply %d OK" },
4422 { 0x0145, "E Power Supply %d Not Present" },
4423 { 0x0146, "E Temperature Sensor %d Temperature Exceeds Safe Limit" },
4424 { 0x0147, "E Temperature Sensor %d Temperature Exceeds Working Limit" },
4425 { 0x0148, "E Temperature Sensor %d Temperature Normal" },
4426 { 0x0149, "E Temperature Sensor %d Not Present" },
4427 { 0x014A, "E Enclosure Management Unit %d Access Critical" },
4428 { 0x014B, "E Enclosure Management Unit %d Access OK" },
4429 { 0x014C, "E Enclosure Management Unit %d Access Offline" },
4430 /* Controller Events (0x0180 - 0x01FF) */
4431 { 0x0181, "C Cache Write Back Error" },
4432 { 0x0188, "C Battery Backup Unit Found" },
4433 { 0x0189, "C Battery Backup Unit Charge Level Low" },
4434 { 0x018A, "C Battery Backup Unit Charge Level OK" },
4435 { 0x0193, "C Installation Aborted" },
4436 { 0x0195, "C Battery Backup Unit Physically Removed" },
4437 { 0x0196, "C Memory Error During Warm Boot" },
4438 { 0x019E, "C Memory Soft ECC Error Corrected" },
4439 { 0x019F, "C Memory Hard ECC Error Corrected" },
4440 { 0x01A2, "C Battery Backup Unit Failed" },
4441 { 0x01AB, "C Mirror Race Recovery Failed" },
4442 { 0x01AC, "C Mirror Race on Critical Drive" },
4443 /* Controller Internal Processor Events */
4444 { 0x0380, "C Internal Controller Hung" },
4445 { 0x0381, "C Internal Controller Firmware Breakpoint" },
4446 { 0x0390, "C Internal Controller i960 Processor Specific Error" },
4447 { 0x03A0, "C Internal Controller StrongARM Processor Specific Error" },
4449 int EventListIndex = 0, EventCode;
4450 unsigned char EventType, *EventMessage;
4451 if (Event->EventCode == 0x1C &&
4452 RequestSense->SenseKey == DAC960_SenseKey_VendorSpecific &&
4453 (RequestSense->AdditionalSenseCode == 0x80 ||
4454 RequestSense->AdditionalSenseCode == 0x81))
4455 Event->EventCode = ((RequestSense->AdditionalSenseCode - 0x80) << 8) |
4456 RequestSense->AdditionalSenseCodeQualifier;
4459 EventCode = EventList[EventListIndex].EventCode;
4460 if (EventCode == Event->EventCode || EventCode == 0) break;
4463 EventType = EventList[EventListIndex].EventMessage[0];
4464 EventMessage = &EventList[EventListIndex].EventMessage[2];
4467 DAC960_Critical("Unknown Controller Event Code %04X\n",
4468 Controller, Event->EventCode);
4474 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4475 Event->Channel, Event->TargetID, EventMessage);
4478 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4479 Event->LogicalUnit, Controller->ControllerNumber,
4480 Event->LogicalUnit, EventMessage);
4483 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4484 Event->LogicalUnit, Controller->ControllerNumber,
4485 Event->LogicalUnit, EventMessage);
4488 if (RequestSense->SenseKey == DAC960_SenseKey_NoSense ||
4489 (RequestSense->SenseKey == DAC960_SenseKey_NotReady &&
4490 RequestSense->AdditionalSenseCode == 0x04 &&
4491 (RequestSense->AdditionalSenseCodeQualifier == 0x01 ||
4492 RequestSense->AdditionalSenseCodeQualifier == 0x02)))
4494 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4495 Event->Channel, Event->TargetID, EventMessage);
4496 DAC960_Critical("Physical Device %d:%d Request Sense: "
4497 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
4501 RequestSense->SenseKey,
4502 RequestSense->AdditionalSenseCode,
4503 RequestSense->AdditionalSenseCodeQualifier);
4504 DAC960_Critical("Physical Device %d:%d Request Sense: "
4505 "Information = %02X%02X%02X%02X "
4506 "%02X%02X%02X%02X\n",
4510 RequestSense->Information[0],
4511 RequestSense->Information[1],
4512 RequestSense->Information[2],
4513 RequestSense->Information[3],
4514 RequestSense->CommandSpecificInformation[0],
4515 RequestSense->CommandSpecificInformation[1],
4516 RequestSense->CommandSpecificInformation[2],
4517 RequestSense->CommandSpecificInformation[3]);
4520 if (Controller->SuppressEnclosureMessages) break;
4521 sprintf(MessageBuffer, EventMessage, Event->LogicalUnit);
4522 DAC960_Critical("Enclosure %d %s\n", Controller,
4523 Event->TargetID, MessageBuffer);
4526 DAC960_Critical("Controller %s\n", Controller, EventMessage);
4529 DAC960_Critical("Unknown Controller Event Code %04X\n",
4530 Controller, Event->EventCode);
4537 DAC960_V2_ReportProgress prints an appropriate progress message for
4538 Logical Device Long Operations.
4541 static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller,
4542 unsigned char *MessageString,
4543 unsigned int LogicalDeviceNumber,
4544 unsigned long BlocksCompleted,
4545 unsigned long LogicalDeviceSize)
4547 Controller->EphemeralProgressMessage = true;
4548 DAC960_Progress("%s in Progress: Logical Drive %d (/dev/rd/c%dd%d) "
4549 "%d%% completed\n", Controller,
4551 LogicalDeviceNumber,
4552 Controller->ControllerNumber,
4553 LogicalDeviceNumber,
4554 (100 * (BlocksCompleted >> 7)) / (LogicalDeviceSize >> 7));
4555 Controller->EphemeralProgressMessage = false;
4560 DAC960_V2_ProcessCompletedCommand performs completion processing for Command
4561 for DAC960 V2 Firmware Controllers.
4564 static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4566 DAC960_Controller_T *Controller = Command->Controller;
4567 DAC960_CommandType_T CommandType = Command->CommandType;
4568 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
4569 DAC960_V2_IOCTL_Opcode_T CommandOpcode = CommandMailbox->Common.IOCTL_Opcode;
4570 DAC960_V2_CommandStatus_T CommandStatus = Command->V2.CommandStatus;
4572 if (CommandType == DAC960_ReadCommand ||
4573 CommandType == DAC960_WriteCommand)
4576 #ifdef FORCE_RETRY_DEBUG
4577 CommandStatus = DAC960_V2_AbormalCompletion;
4579 Command->V2.RequestSense->SenseKey = DAC960_SenseKey_MediumError;
4581 if (CommandStatus == DAC960_V2_NormalCompletion) {
4583 if (!DAC960_ProcessCompletedRequest(Command, true))
4586 } else if (Command->V2.RequestSense->SenseKey == DAC960_SenseKey_MediumError)
4589 * break the command down into pieces and resubmit each
4590 * piece, hoping that some of them will succeed.
4592 DAC960_queue_partial_rw(Command);
4597 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4598 DAC960_V2_ReadWriteError(Command);
4600 Perform completion processing for all buffers in this I/O Request.
4602 (void)DAC960_ProcessCompletedRequest(Command, false);
4605 else if (CommandType == DAC960_ReadRetryCommand ||
4606 CommandType == DAC960_WriteRetryCommand)
4608 boolean normal_completion;
4610 #ifdef FORCE_RETRY_FAILURE_DEBUG
4611 static int retry_count = 1;
4614 Perform completion processing for the portion that was
4615 retried, and submit the next portion, if any.
4617 normal_completion = true;
4618 if (CommandStatus != DAC960_V2_NormalCompletion) {
4619 normal_completion = false;
4620 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4621 DAC960_V2_ReadWriteError(Command);
4624 #ifdef FORCE_RETRY_FAILURE_DEBUG
4625 if (!(++retry_count % 10000)) {
4626 printk("V2 error retry failure test\n");
4627 normal_completion = false;
4628 DAC960_V2_ReadWriteError(Command);
4632 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
4633 DAC960_queue_partial_rw(Command);
4637 else if (CommandType == DAC960_MonitoringCommand)
4639 if (Controller->ShutdownMonitoringTimer)
4641 if (CommandOpcode == DAC960_V2_GetControllerInfo)
4643 DAC960_V2_ControllerInfo_T *NewControllerInfo =
4644 Controller->V2.NewControllerInformation;
4645 DAC960_V2_ControllerInfo_T *ControllerInfo =
4646 &Controller->V2.ControllerInformation;
4647 Controller->LogicalDriveCount =
4648 NewControllerInfo->LogicalDevicesPresent;
4649 Controller->V2.NeedLogicalDeviceInformation = true;
4650 Controller->V2.NeedPhysicalDeviceInformation = true;
4651 Controller->V2.StartLogicalDeviceInformationScan = true;
4652 Controller->V2.StartPhysicalDeviceInformationScan = true;
4653 Controller->MonitoringAlertMode =
4654 (NewControllerInfo->LogicalDevicesCritical > 0 ||
4655 NewControllerInfo->LogicalDevicesOffline > 0 ||
4656 NewControllerInfo->PhysicalDisksCritical > 0 ||
4657 NewControllerInfo->PhysicalDisksOffline > 0);
4658 memcpy(ControllerInfo, NewControllerInfo,
4659 sizeof(DAC960_V2_ControllerInfo_T));
4661 else if (CommandOpcode == DAC960_V2_GetEvent)
4663 if (CommandStatus == DAC960_V2_NormalCompletion) {
4664 DAC960_V2_ReportEvent(Controller, Controller->V2.Event);
4666 Controller->V2.NextEventSequenceNumber++;
4668 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid &&
4669 CommandStatus == DAC960_V2_NormalCompletion)
4671 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
4672 Controller->V2.NewPhysicalDeviceInformation;
4673 unsigned int PhysicalDeviceIndex = Controller->V2.PhysicalDeviceIndex;
4674 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4675 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4676 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4677 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4678 unsigned int DeviceIndex;
4679 while (PhysicalDeviceInfo != NULL &&
4680 (NewPhysicalDeviceInfo->Channel >
4681 PhysicalDeviceInfo->Channel ||
4682 (NewPhysicalDeviceInfo->Channel ==
4683 PhysicalDeviceInfo->Channel &&
4684 (NewPhysicalDeviceInfo->TargetID >
4685 PhysicalDeviceInfo->TargetID ||
4686 (NewPhysicalDeviceInfo->TargetID ==
4687 PhysicalDeviceInfo->TargetID &&
4688 NewPhysicalDeviceInfo->LogicalUnit >
4689 PhysicalDeviceInfo->LogicalUnit)))))
4691 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4693 PhysicalDeviceInfo->Channel,
4694 PhysicalDeviceInfo->TargetID);
4695 Controller->V2.PhysicalDeviceInformation
4696 [PhysicalDeviceIndex] = NULL;
4697 Controller->V2.InquiryUnitSerialNumber
4698 [PhysicalDeviceIndex] = NULL;
4699 kfree(PhysicalDeviceInfo);
4700 kfree(InquiryUnitSerialNumber);
4701 for (DeviceIndex = PhysicalDeviceIndex;
4702 DeviceIndex < DAC960_V2_MaxPhysicalDevices - 1;
4705 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4706 Controller->V2.PhysicalDeviceInformation[DeviceIndex+1];
4707 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4708 Controller->V2.InquiryUnitSerialNumber[DeviceIndex+1];
4710 Controller->V2.PhysicalDeviceInformation
4711 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4712 Controller->V2.InquiryUnitSerialNumber
4713 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4714 PhysicalDeviceInfo =
4715 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4716 InquiryUnitSerialNumber =
4717 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4719 if (PhysicalDeviceInfo == NULL ||
4720 (NewPhysicalDeviceInfo->Channel !=
4721 PhysicalDeviceInfo->Channel) ||
4722 (NewPhysicalDeviceInfo->TargetID !=
4723 PhysicalDeviceInfo->TargetID) ||
4724 (NewPhysicalDeviceInfo->LogicalUnit !=
4725 PhysicalDeviceInfo->LogicalUnit))
4727 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
4728 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
4729 InquiryUnitSerialNumber =
4730 (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
4731 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
4733 if (InquiryUnitSerialNumber == NULL &&
4734 PhysicalDeviceInfo != NULL)
4736 kfree(PhysicalDeviceInfo);
4737 PhysicalDeviceInfo = NULL;
4739 DAC960_Critical("Physical Device %d:%d Now Exists%s\n",
4741 NewPhysicalDeviceInfo->Channel,
4742 NewPhysicalDeviceInfo->TargetID,
4743 (PhysicalDeviceInfo != NULL
4744 ? "" : " - Allocation Failed"));
4745 if (PhysicalDeviceInfo != NULL)
4747 memset(PhysicalDeviceInfo, 0,
4748 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4749 PhysicalDeviceInfo->PhysicalDeviceState =
4750 DAC960_V2_Device_InvalidState;
4751 memset(InquiryUnitSerialNumber, 0,
4752 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4753 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4754 for (DeviceIndex = DAC960_V2_MaxPhysicalDevices - 1;
4755 DeviceIndex > PhysicalDeviceIndex;
4758 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4759 Controller->V2.PhysicalDeviceInformation[DeviceIndex-1];
4760 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4761 Controller->V2.InquiryUnitSerialNumber[DeviceIndex-1];
4763 Controller->V2.PhysicalDeviceInformation
4764 [PhysicalDeviceIndex] =
4766 Controller->V2.InquiryUnitSerialNumber
4767 [PhysicalDeviceIndex] =
4768 InquiryUnitSerialNumber;
4769 Controller->V2.NeedDeviceSerialNumberInformation = true;
4772 if (PhysicalDeviceInfo != NULL)
4774 if (NewPhysicalDeviceInfo->PhysicalDeviceState !=
4775 PhysicalDeviceInfo->PhysicalDeviceState)
4777 "Physical Device %d:%d is now %s\n", Controller,
4778 NewPhysicalDeviceInfo->Channel,
4779 NewPhysicalDeviceInfo->TargetID,
4780 (NewPhysicalDeviceInfo->PhysicalDeviceState
4781 == DAC960_V2_Device_Online
4783 : NewPhysicalDeviceInfo->PhysicalDeviceState
4784 == DAC960_V2_Device_Rebuild
4786 : NewPhysicalDeviceInfo->PhysicalDeviceState
4787 == DAC960_V2_Device_Missing
4789 : NewPhysicalDeviceInfo->PhysicalDeviceState
4790 == DAC960_V2_Device_Critical
4792 : NewPhysicalDeviceInfo->PhysicalDeviceState
4793 == DAC960_V2_Device_Dead
4795 : NewPhysicalDeviceInfo->PhysicalDeviceState
4796 == DAC960_V2_Device_SuspectedDead
4798 : NewPhysicalDeviceInfo->PhysicalDeviceState
4799 == DAC960_V2_Device_CommandedOffline
4800 ? "COMMANDED-OFFLINE"
4801 : NewPhysicalDeviceInfo->PhysicalDeviceState
4802 == DAC960_V2_Device_Standby
4803 ? "STANDBY" : "UNKNOWN"));
4804 if ((NewPhysicalDeviceInfo->ParityErrors !=
4805 PhysicalDeviceInfo->ParityErrors) ||
4806 (NewPhysicalDeviceInfo->SoftErrors !=
4807 PhysicalDeviceInfo->SoftErrors) ||
4808 (NewPhysicalDeviceInfo->HardErrors !=
4809 PhysicalDeviceInfo->HardErrors) ||
4810 (NewPhysicalDeviceInfo->MiscellaneousErrors !=
4811 PhysicalDeviceInfo->MiscellaneousErrors) ||
4812 (NewPhysicalDeviceInfo->CommandTimeouts !=
4813 PhysicalDeviceInfo->CommandTimeouts) ||
4814 (NewPhysicalDeviceInfo->Retries !=
4815 PhysicalDeviceInfo->Retries) ||
4816 (NewPhysicalDeviceInfo->Aborts !=
4817 PhysicalDeviceInfo->Aborts) ||
4818 (NewPhysicalDeviceInfo->PredictedFailuresDetected !=
4819 PhysicalDeviceInfo->PredictedFailuresDetected))
4821 DAC960_Critical("Physical Device %d:%d Errors: "
4822 "Parity = %d, Soft = %d, "
4823 "Hard = %d, Misc = %d\n",
4825 NewPhysicalDeviceInfo->Channel,
4826 NewPhysicalDeviceInfo->TargetID,
4827 NewPhysicalDeviceInfo->ParityErrors,
4828 NewPhysicalDeviceInfo->SoftErrors,
4829 NewPhysicalDeviceInfo->HardErrors,
4830 NewPhysicalDeviceInfo->MiscellaneousErrors);
4831 DAC960_Critical("Physical Device %d:%d Errors: "
4832 "Timeouts = %d, Retries = %d, "
4833 "Aborts = %d, Predicted = %d\n",
4835 NewPhysicalDeviceInfo->Channel,
4836 NewPhysicalDeviceInfo->TargetID,
4837 NewPhysicalDeviceInfo->CommandTimeouts,
4838 NewPhysicalDeviceInfo->Retries,
4839 NewPhysicalDeviceInfo->Aborts,
4840 NewPhysicalDeviceInfo
4841 ->PredictedFailuresDetected);
4843 if ((PhysicalDeviceInfo->PhysicalDeviceState
4844 == DAC960_V2_Device_Dead ||
4845 PhysicalDeviceInfo->PhysicalDeviceState
4846 == DAC960_V2_Device_InvalidState) &&
4847 NewPhysicalDeviceInfo->PhysicalDeviceState
4848 != DAC960_V2_Device_Dead)
4849 Controller->V2.NeedDeviceSerialNumberInformation = true;
4850 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
4851 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4853 NewPhysicalDeviceInfo->LogicalUnit++;
4854 Controller->V2.PhysicalDeviceIndex++;
4856 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid)
4858 unsigned int DeviceIndex;
4859 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex;
4860 DeviceIndex < DAC960_V2_MaxPhysicalDevices;
4863 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4864 Controller->V2.PhysicalDeviceInformation[DeviceIndex];
4865 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4866 Controller->V2.InquiryUnitSerialNumber[DeviceIndex];
4867 if (PhysicalDeviceInfo == NULL) break;
4868 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4870 PhysicalDeviceInfo->Channel,
4871 PhysicalDeviceInfo->TargetID);
4872 Controller->V2.PhysicalDeviceInformation[DeviceIndex] = NULL;
4873 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] = NULL;
4874 kfree(PhysicalDeviceInfo);
4875 kfree(InquiryUnitSerialNumber);
4877 Controller->V2.NeedPhysicalDeviceInformation = false;
4879 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid &&
4880 CommandStatus == DAC960_V2_NormalCompletion)
4882 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
4883 Controller->V2.NewLogicalDeviceInformation;
4884 unsigned short LogicalDeviceNumber =
4885 NewLogicalDeviceInfo->LogicalDeviceNumber;
4886 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
4887 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber];
4888 if (LogicalDeviceInfo == NULL)
4890 DAC960_V2_PhysicalDevice_T PhysicalDevice;
4891 PhysicalDevice.Controller = 0;
4892 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
4893 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
4894 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
4895 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
4897 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
4898 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
4899 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
4901 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4902 "Now Exists%s\n", Controller,
4903 LogicalDeviceNumber,
4904 Controller->ControllerNumber,
4905 LogicalDeviceNumber,
4906 (LogicalDeviceInfo != NULL
4907 ? "" : " - Allocation Failed"));
4908 if (LogicalDeviceInfo != NULL)
4910 memset(LogicalDeviceInfo, 0,
4911 sizeof(DAC960_V2_LogicalDeviceInfo_T));
4912 DAC960_ComputeGenericDiskInfo(Controller);
4915 if (LogicalDeviceInfo != NULL)
4917 unsigned long LogicalDeviceSize =
4918 NewLogicalDeviceInfo->ConfigurableDeviceSize;
4919 if (NewLogicalDeviceInfo->LogicalDeviceState !=
4920 LogicalDeviceInfo->LogicalDeviceState)
4921 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4922 "is now %s\n", Controller,
4923 LogicalDeviceNumber,
4924 Controller->ControllerNumber,
4925 LogicalDeviceNumber,
4926 (NewLogicalDeviceInfo->LogicalDeviceState
4927 == DAC960_V2_LogicalDevice_Online
4929 : NewLogicalDeviceInfo->LogicalDeviceState
4930 == DAC960_V2_LogicalDevice_Critical
4931 ? "CRITICAL" : "OFFLINE"));
4932 if ((NewLogicalDeviceInfo->SoftErrors !=
4933 LogicalDeviceInfo->SoftErrors) ||
4934 (NewLogicalDeviceInfo->CommandsFailed !=
4935 LogicalDeviceInfo->CommandsFailed) ||
4936 (NewLogicalDeviceInfo->DeferredWriteErrors !=
4937 LogicalDeviceInfo->DeferredWriteErrors))
4938 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) Errors: "
4939 "Soft = %d, Failed = %d, Deferred Write = %d\n",
4940 Controller, LogicalDeviceNumber,
4941 Controller->ControllerNumber,
4942 LogicalDeviceNumber,
4943 NewLogicalDeviceInfo->SoftErrors,
4944 NewLogicalDeviceInfo->CommandsFailed,
4945 NewLogicalDeviceInfo->DeferredWriteErrors);
4946 if (NewLogicalDeviceInfo->ConsistencyCheckInProgress)
4947 DAC960_V2_ReportProgress(Controller,
4948 "Consistency Check",
4949 LogicalDeviceNumber,
4950 NewLogicalDeviceInfo
4951 ->ConsistencyCheckBlockNumber,
4953 else if (NewLogicalDeviceInfo->RebuildInProgress)
4954 DAC960_V2_ReportProgress(Controller,
4956 LogicalDeviceNumber,
4957 NewLogicalDeviceInfo
4958 ->RebuildBlockNumber,
4960 else if (NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4961 DAC960_V2_ReportProgress(Controller,
4962 "Background Initialization",
4963 LogicalDeviceNumber,
4964 NewLogicalDeviceInfo
4965 ->BackgroundInitializationBlockNumber,
4967 else if (NewLogicalDeviceInfo->ForegroundInitializationInProgress)
4968 DAC960_V2_ReportProgress(Controller,
4969 "Foreground Initialization",
4970 LogicalDeviceNumber,
4971 NewLogicalDeviceInfo
4972 ->ForegroundInitializationBlockNumber,
4974 else if (NewLogicalDeviceInfo->DataMigrationInProgress)
4975 DAC960_V2_ReportProgress(Controller,
4977 LogicalDeviceNumber,
4978 NewLogicalDeviceInfo
4979 ->DataMigrationBlockNumber,
4981 else if (NewLogicalDeviceInfo->PatrolOperationInProgress)
4982 DAC960_V2_ReportProgress(Controller,
4984 LogicalDeviceNumber,
4985 NewLogicalDeviceInfo
4986 ->PatrolOperationBlockNumber,
4988 if (LogicalDeviceInfo->BackgroundInitializationInProgress &&
4989 !NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4990 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) "
4991 "Background Initialization %s\n",
4993 LogicalDeviceNumber,
4994 Controller->ControllerNumber,
4995 LogicalDeviceNumber,
4996 (NewLogicalDeviceInfo->LogicalDeviceControl
4997 .LogicalDeviceInitialized
4998 ? "Completed" : "Failed"));
4999 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
5000 sizeof(DAC960_V2_LogicalDeviceInfo_T));
5002 Controller->V2.LogicalDriveFoundDuringScan
5003 [LogicalDeviceNumber] = true;
5004 NewLogicalDeviceInfo->LogicalDeviceNumber++;
5006 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid)
5008 int LogicalDriveNumber;
5009 for (LogicalDriveNumber = 0;
5010 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5011 LogicalDriveNumber++)
5013 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
5014 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
5015 if (LogicalDeviceInfo == NULL ||
5016 Controller->V2.LogicalDriveFoundDuringScan
5017 [LogicalDriveNumber])
5019 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
5020 "No Longer Exists\n", Controller,
5022 Controller->ControllerNumber,
5023 LogicalDriveNumber);
5024 Controller->V2.LogicalDeviceInformation
5025 [LogicalDriveNumber] = NULL;
5026 kfree(LogicalDeviceInfo);
5027 Controller->LogicalDriveInitiallyAccessible
5028 [LogicalDriveNumber] = false;
5029 DAC960_ComputeGenericDiskInfo(Controller);
5031 Controller->V2.NeedLogicalDeviceInformation = false;
5033 else if (CommandOpcode == DAC960_V2_SCSI_10_Passthru)
5035 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
5036 Controller->V2.InquiryUnitSerialNumber[Controller->V2.PhysicalDeviceIndex - 1];
5038 if (CommandStatus != DAC960_V2_NormalCompletion) {
5039 memset(InquiryUnitSerialNumber,
5040 0, sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5041 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5043 memcpy(InquiryUnitSerialNumber,
5044 Controller->V2.NewInquiryUnitSerialNumber,
5045 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5047 Controller->V2.NeedDeviceSerialNumberInformation = false;
5050 if (Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5051 - Controller->V2.NextEventSequenceNumber > 0)
5053 CommandMailbox->GetEvent.CommandOpcode = DAC960_V2_IOCTL;
5054 CommandMailbox->GetEvent.DataTransferSize = sizeof(DAC960_V2_Event_T);
5055 CommandMailbox->GetEvent.EventSequenceNumberHigh16 =
5056 Controller->V2.NextEventSequenceNumber >> 16;
5057 CommandMailbox->GetEvent.ControllerNumber = 0;
5058 CommandMailbox->GetEvent.IOCTL_Opcode =
5060 CommandMailbox->GetEvent.EventSequenceNumberLow16 =
5061 Controller->V2.NextEventSequenceNumber & 0xFFFF;
5062 CommandMailbox->GetEvent.DataTransferMemoryAddress
5063 .ScatterGatherSegments[0]
5064 .SegmentDataPointer =
5065 Controller->V2.EventDMA;
5066 CommandMailbox->GetEvent.DataTransferMemoryAddress
5067 .ScatterGatherSegments[0]
5069 CommandMailbox->GetEvent.DataTransferSize;
5070 DAC960_QueueCommand(Command);
5073 if (Controller->V2.NeedPhysicalDeviceInformation)
5075 if (Controller->V2.NeedDeviceSerialNumberInformation)
5077 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
5078 Controller->V2.NewInquiryUnitSerialNumber;
5079 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5081 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
5082 Controller->V2.NewPhysicalDeviceInformation->Channel,
5083 Controller->V2.NewPhysicalDeviceInformation->TargetID,
5084 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit - 1);
5087 DAC960_QueueCommand(Command);
5090 if (Controller->V2.StartPhysicalDeviceInformationScan)
5092 Controller->V2.PhysicalDeviceIndex = 0;
5093 Controller->V2.NewPhysicalDeviceInformation->Channel = 0;
5094 Controller->V2.NewPhysicalDeviceInformation->TargetID = 0;
5095 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit = 0;
5096 Controller->V2.StartPhysicalDeviceInformationScan = false;
5098 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5099 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
5100 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
5101 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit =
5102 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit;
5103 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID =
5104 Controller->V2.NewPhysicalDeviceInformation->TargetID;
5105 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel =
5106 Controller->V2.NewPhysicalDeviceInformation->Channel;
5107 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
5108 DAC960_V2_GetPhysicalDeviceInfoValid;
5109 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5110 .ScatterGatherSegments[0]
5111 .SegmentDataPointer =
5112 Controller->V2.NewPhysicalDeviceInformationDMA;
5113 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5114 .ScatterGatherSegments[0]
5116 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
5117 DAC960_QueueCommand(Command);
5120 if (Controller->V2.NeedLogicalDeviceInformation)
5122 if (Controller->V2.StartLogicalDeviceInformationScan)
5124 int LogicalDriveNumber;
5125 for (LogicalDriveNumber = 0;
5126 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5127 LogicalDriveNumber++)
5128 Controller->V2.LogicalDriveFoundDuringScan
5129 [LogicalDriveNumber] = false;
5130 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber = 0;
5131 Controller->V2.StartLogicalDeviceInformationScan = false;
5133 CommandMailbox->LogicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5134 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
5135 sizeof(DAC960_V2_LogicalDeviceInfo_T);
5136 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
5137 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber;
5138 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
5139 DAC960_V2_GetLogicalDeviceInfoValid;
5140 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5141 .ScatterGatherSegments[0]
5142 .SegmentDataPointer =
5143 Controller->V2.NewLogicalDeviceInformationDMA;
5144 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5145 .ScatterGatherSegments[0]
5147 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
5148 DAC960_QueueCommand(Command);
5151 Controller->MonitoringTimerCount++;
5152 Controller->MonitoringTimer.expires =
5153 jiffies + DAC960_HealthStatusMonitoringInterval;
5154 add_timer(&Controller->MonitoringTimer);
5156 if (CommandType == DAC960_ImmediateCommand)
5158 complete(Command->Completion);
5159 Command->Completion = NULL;
5162 if (CommandType == DAC960_QueuedCommand)
5164 DAC960_V2_KernelCommand_T *KernelCommand = Command->V2.KernelCommand;
5165 KernelCommand->CommandStatus = CommandStatus;
5166 KernelCommand->RequestSenseLength = Command->V2.RequestSenseLength;
5167 KernelCommand->DataTransferLength = Command->V2.DataTransferResidue;
5168 Command->V2.KernelCommand = NULL;
5169 DAC960_DeallocateCommand(Command);
5170 KernelCommand->CompletionFunction(KernelCommand);
5174 Queue a Status Monitoring Command to the Controller using the just
5175 completed Command if one was deferred previously due to lack of a
5176 free Command when the Monitoring Timer Function was called.
5178 if (Controller->MonitoringCommandDeferred)
5180 Controller->MonitoringCommandDeferred = false;
5181 DAC960_V2_QueueMonitoringCommand(Command);
5185 Deallocate the Command.
5187 DAC960_DeallocateCommand(Command);
5189 Wake up any processes waiting on a free Command.
5191 wake_up(&Controller->CommandWaitQueue);
5196 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
5200 static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
5201 void *DeviceIdentifier,
5202 struct pt_regs *InterruptRegisters)
5204 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5205 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5206 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5207 unsigned long flags;
5209 spin_lock_irqsave(&Controller->queue_lock, flags);
5210 DAC960_BA_AcknowledgeInterrupt(ControllerBaseAddress);
5211 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5212 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5214 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5215 NextStatusMailbox->Fields.CommandIdentifier;
5216 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5217 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5218 Command->V2.RequestSenseLength =
5219 NextStatusMailbox->Fields.RequestSenseLength;
5220 Command->V2.DataTransferResidue =
5221 NextStatusMailbox->Fields.DataTransferResidue;
5222 NextStatusMailbox->Words[0] = 0;
5223 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5224 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5225 DAC960_V2_ProcessCompletedCommand(Command);
5227 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5229 Attempt to remove additional I/O Requests from the Controller's
5230 I/O Request Queue and queue them to the Controller.
5232 DAC960_ProcessRequest(Controller);
5233 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5239 DAC960_LP_InterruptHandler handles hardware interrupts from DAC960 LP Series
5243 static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
5244 void *DeviceIdentifier,
5245 struct pt_regs *InterruptRegisters)
5247 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5248 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5249 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5250 unsigned long flags;
5252 spin_lock_irqsave(&Controller->queue_lock, flags);
5253 DAC960_LP_AcknowledgeInterrupt(ControllerBaseAddress);
5254 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5255 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5257 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5258 NextStatusMailbox->Fields.CommandIdentifier;
5259 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5260 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5261 Command->V2.RequestSenseLength =
5262 NextStatusMailbox->Fields.RequestSenseLength;
5263 Command->V2.DataTransferResidue =
5264 NextStatusMailbox->Fields.DataTransferResidue;
5265 NextStatusMailbox->Words[0] = 0;
5266 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5267 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5268 DAC960_V2_ProcessCompletedCommand(Command);
5270 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5272 Attempt to remove additional I/O Requests from the Controller's
5273 I/O Request Queue and queue them to the Controller.
5275 DAC960_ProcessRequest(Controller);
5276 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5282 DAC960_LA_InterruptHandler handles hardware interrupts from DAC960 LA Series
5286 static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
5287 void *DeviceIdentifier,
5288 struct pt_regs *InterruptRegisters)
5290 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5291 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5292 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5293 unsigned long flags;
5295 spin_lock_irqsave(&Controller->queue_lock, flags);
5296 DAC960_LA_AcknowledgeInterrupt(ControllerBaseAddress);
5297 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5298 while (NextStatusMailbox->Fields.Valid)
5300 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5301 NextStatusMailbox->Fields.CommandIdentifier;
5302 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5303 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5304 NextStatusMailbox->Word = 0;
5305 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5306 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5307 DAC960_V1_ProcessCompletedCommand(Command);
5309 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5311 Attempt to remove additional I/O Requests from the Controller's
5312 I/O Request Queue and queue them to the Controller.
5314 DAC960_ProcessRequest(Controller);
5315 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5321 DAC960_PG_InterruptHandler handles hardware interrupts from DAC960 PG Series
5325 static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
5326 void *DeviceIdentifier,
5327 struct pt_regs *InterruptRegisters)
5329 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5330 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5331 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5332 unsigned long flags;
5334 spin_lock_irqsave(&Controller->queue_lock, flags);
5335 DAC960_PG_AcknowledgeInterrupt(ControllerBaseAddress);
5336 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5337 while (NextStatusMailbox->Fields.Valid)
5339 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5340 NextStatusMailbox->Fields.CommandIdentifier;
5341 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5342 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5343 NextStatusMailbox->Word = 0;
5344 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5345 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5346 DAC960_V1_ProcessCompletedCommand(Command);
5348 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5350 Attempt to remove additional I/O Requests from the Controller's
5351 I/O Request Queue and queue them to the Controller.
5353 DAC960_ProcessRequest(Controller);
5354 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5360 DAC960_PD_InterruptHandler handles hardware interrupts from DAC960 PD Series
5364 static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
5365 void *DeviceIdentifier,
5366 struct pt_regs *InterruptRegisters)
5368 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5369 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5370 unsigned long flags;
5372 spin_lock_irqsave(&Controller->queue_lock, flags);
5373 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5375 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5376 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5377 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5378 Command->V1.CommandStatus =
5379 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5380 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5381 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5382 DAC960_V1_ProcessCompletedCommand(Command);
5385 Attempt to remove additional I/O Requests from the Controller's
5386 I/O Request Queue and queue them to the Controller.
5388 DAC960_ProcessRequest(Controller);
5389 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5395 DAC960_P_InterruptHandler handles hardware interrupts from DAC960 P Series
5398 Translations of DAC960_V1_Enquiry and DAC960_V1_GetDeviceState rely
5399 on the data having been placed into DAC960_Controller_T, rather than
5400 an arbitrary buffer.
5403 static irqreturn_t DAC960_P_InterruptHandler(int IRQ_Channel,
5404 void *DeviceIdentifier,
5405 struct pt_regs *InterruptRegisters)
5407 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5408 void __iomem *ControllerBaseAddress = Controller->BaseAddress;
5409 unsigned long flags;
5411 spin_lock_irqsave(&Controller->queue_lock, flags);
5412 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5414 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5415 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5416 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5417 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5418 DAC960_V1_CommandOpcode_T CommandOpcode =
5419 CommandMailbox->Common.CommandOpcode;
5420 Command->V1.CommandStatus =
5421 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5422 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5423 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5424 switch (CommandOpcode)
5426 case DAC960_V1_Enquiry_Old:
5427 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Enquiry;
5428 DAC960_P_To_PD_TranslateEnquiry(Controller->V1.NewEnquiry);
5430 case DAC960_V1_GetDeviceState_Old:
5431 Command->V1.CommandMailbox.Common.CommandOpcode =
5432 DAC960_V1_GetDeviceState;
5433 DAC960_P_To_PD_TranslateDeviceState(Controller->V1.NewDeviceState);
5435 case DAC960_V1_Read_Old:
5436 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Read;
5437 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5439 case DAC960_V1_Write_Old:
5440 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Write;
5441 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5443 case DAC960_V1_ReadWithScatterGather_Old:
5444 Command->V1.CommandMailbox.Common.CommandOpcode =
5445 DAC960_V1_ReadWithScatterGather;
5446 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5448 case DAC960_V1_WriteWithScatterGather_Old:
5449 Command->V1.CommandMailbox.Common.CommandOpcode =
5450 DAC960_V1_WriteWithScatterGather;
5451 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5456 DAC960_V1_ProcessCompletedCommand(Command);
5459 Attempt to remove additional I/O Requests from the Controller's
5460 I/O Request Queue and queue them to the Controller.
5462 DAC960_ProcessRequest(Controller);
5463 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5469 DAC960_V1_QueueMonitoringCommand queues a Monitoring Command to DAC960 V1
5470 Firmware Controllers.
5473 static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *Command)
5475 DAC960_Controller_T *Controller = Command->Controller;
5476 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5477 DAC960_V1_ClearCommand(Command);
5478 Command->CommandType = DAC960_MonitoringCommand;
5479 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Enquiry;
5480 CommandMailbox->Type3.BusAddress = Controller->V1.NewEnquiryDMA;
5481 DAC960_QueueCommand(Command);
5486 DAC960_V2_QueueMonitoringCommand queues a Monitoring Command to DAC960 V2
5487 Firmware Controllers.
5490 static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *Command)
5492 DAC960_Controller_T *Controller = Command->Controller;
5493 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
5494 DAC960_V2_ClearCommand(Command);
5495 Command->CommandType = DAC960_MonitoringCommand;
5496 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
5497 CommandMailbox->ControllerInfo.CommandControlBits
5498 .DataTransferControllerToHost = true;
5499 CommandMailbox->ControllerInfo.CommandControlBits
5500 .NoAutoRequestSense = true;
5501 CommandMailbox->ControllerInfo.DataTransferSize =
5502 sizeof(DAC960_V2_ControllerInfo_T);
5503 CommandMailbox->ControllerInfo.ControllerNumber = 0;
5504 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
5505 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5506 .ScatterGatherSegments[0]
5507 .SegmentDataPointer =
5508 Controller->V2.NewControllerInformationDMA;
5509 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5510 .ScatterGatherSegments[0]
5512 CommandMailbox->ControllerInfo.DataTransferSize;
5513 DAC960_QueueCommand(Command);
5518 DAC960_MonitoringTimerFunction is the timer function for monitoring
5519 the status of DAC960 Controllers.
5522 static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
5524 DAC960_Controller_T *Controller = (DAC960_Controller_T *) TimerData;
5525 DAC960_Command_T *Command;
5526 unsigned long flags;
5528 if (Controller->FirmwareType == DAC960_V1_Controller)
5530 spin_lock_irqsave(&Controller->queue_lock, flags);
5532 Queue a Status Monitoring Command to Controller.
5534 Command = DAC960_AllocateCommand(Controller);
5535 if (Command != NULL)
5536 DAC960_V1_QueueMonitoringCommand(Command);
5537 else Controller->MonitoringCommandDeferred = true;
5538 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5542 DAC960_V2_ControllerInfo_T *ControllerInfo =
5543 &Controller->V2.ControllerInformation;
5544 unsigned int StatusChangeCounter =
5545 Controller->V2.HealthStatusBuffer->StatusChangeCounter;
5546 boolean ForceMonitoringCommand = false;
5547 if (jiffies - Controller->SecondaryMonitoringTime
5548 > DAC960_SecondaryMonitoringInterval)
5550 int LogicalDriveNumber;
5551 for (LogicalDriveNumber = 0;
5552 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5553 LogicalDriveNumber++)
5555 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
5556 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
5557 if (LogicalDeviceInfo == NULL) continue;
5558 if (!LogicalDeviceInfo->LogicalDeviceControl
5559 .LogicalDeviceInitialized)
5561 ForceMonitoringCommand = true;
5565 Controller->SecondaryMonitoringTime = jiffies;
5567 if (StatusChangeCounter == Controller->V2.StatusChangeCounter &&
5568 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5569 == Controller->V2.NextEventSequenceNumber &&
5570 (ControllerInfo->BackgroundInitializationsActive +
5571 ControllerInfo->LogicalDeviceInitializationsActive +
5572 ControllerInfo->PhysicalDeviceInitializationsActive +
5573 ControllerInfo->ConsistencyChecksActive +
5574 ControllerInfo->RebuildsActive +
5575 ControllerInfo->OnlineExpansionsActive == 0 ||
5576 jiffies - Controller->PrimaryMonitoringTime
5577 < DAC960_MonitoringTimerInterval) &&
5578 !ForceMonitoringCommand)
5580 Controller->MonitoringTimer.expires =
5581 jiffies + DAC960_HealthStatusMonitoringInterval;
5582 add_timer(&Controller->MonitoringTimer);
5585 Controller->V2.StatusChangeCounter = StatusChangeCounter;
5586 Controller->PrimaryMonitoringTime = jiffies;
5588 spin_lock_irqsave(&Controller->queue_lock, flags);
5590 Queue a Status Monitoring Command to Controller.
5592 Command = DAC960_AllocateCommand(Controller);
5593 if (Command != NULL)
5594 DAC960_V2_QueueMonitoringCommand(Command);
5595 else Controller->MonitoringCommandDeferred = true;
5596 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5598 Wake up any processes waiting on a Health Status Buffer change.
5600 wake_up(&Controller->HealthStatusWaitQueue);
5605 DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
5606 additional bytes in the Combined Status Buffer and grows the buffer if
5607 necessary. It returns true if there is enough room and false otherwise.
5610 static boolean DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
5611 unsigned int ByteCount)
5613 unsigned char *NewStatusBuffer;
5614 if (Controller->InitialStatusLength + 1 +
5615 Controller->CurrentStatusLength + ByteCount + 1 <=
5616 Controller->CombinedStatusBufferLength)
5618 if (Controller->CombinedStatusBufferLength == 0)
5620 unsigned int NewStatusBufferLength = DAC960_InitialStatusBufferSize;
5621 while (NewStatusBufferLength < ByteCount)
5622 NewStatusBufferLength *= 2;
5623 Controller->CombinedStatusBuffer =
5624 (unsigned char *) kmalloc(NewStatusBufferLength, GFP_ATOMIC);
5625 if (Controller->CombinedStatusBuffer == NULL) return false;
5626 Controller->CombinedStatusBufferLength = NewStatusBufferLength;
5629 NewStatusBuffer = (unsigned char *)
5630 kmalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
5631 if (NewStatusBuffer == NULL)
5633 DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
5637 memcpy(NewStatusBuffer, Controller->CombinedStatusBuffer,
5638 Controller->CombinedStatusBufferLength);
5639 kfree(Controller->CombinedStatusBuffer);
5640 Controller->CombinedStatusBuffer = NewStatusBuffer;
5641 Controller->CombinedStatusBufferLength *= 2;
5642 Controller->CurrentStatusBuffer =
5643 &NewStatusBuffer[Controller->InitialStatusLength + 1];
5649 DAC960_Message prints Driver Messages.
5652 static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
5653 unsigned char *Format,
5654 DAC960_Controller_T *Controller,
5657 static unsigned char Buffer[DAC960_LineBufferSize];
5658 static boolean BeginningOfLine = true;
5661 va_start(Arguments, Controller);
5662 Length = vsprintf(Buffer, Format, Arguments);
5664 if (Controller == NULL)
5665 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5666 DAC960_ControllerCount, Buffer);
5667 else if (MessageLevel == DAC960_AnnounceLevel ||
5668 MessageLevel == DAC960_InfoLevel)
5670 if (!Controller->ControllerInitialized)
5672 if (DAC960_CheckStatusBuffer(Controller, Length))
5674 strcpy(&Controller->CombinedStatusBuffer
5675 [Controller->InitialStatusLength],
5677 Controller->InitialStatusLength += Length;
5678 Controller->CurrentStatusBuffer =
5679 &Controller->CombinedStatusBuffer
5680 [Controller->InitialStatusLength + 1];
5682 if (MessageLevel == DAC960_AnnounceLevel)
5684 static int AnnouncementLines = 0;
5685 if (++AnnouncementLines <= 2)
5686 printk("%sDAC960: %s", DAC960_MessageLevelMap[MessageLevel],
5691 if (BeginningOfLine)
5693 if (Buffer[0] != '\n' || Length > 1)
5694 printk("%sDAC960#%d: %s",
5695 DAC960_MessageLevelMap[MessageLevel],
5696 Controller->ControllerNumber, Buffer);
5698 else printk("%s", Buffer);
5701 else if (DAC960_CheckStatusBuffer(Controller, Length))
5703 strcpy(&Controller->CurrentStatusBuffer[
5704 Controller->CurrentStatusLength], Buffer);
5705 Controller->CurrentStatusLength += Length;
5708 else if (MessageLevel == DAC960_ProgressLevel)
5710 strcpy(Controller->ProgressBuffer, Buffer);
5711 Controller->ProgressBufferLength = Length;
5712 if (Controller->EphemeralProgressMessage)
5714 if (jiffies - Controller->LastProgressReportTime
5715 >= DAC960_ProgressReportingInterval)
5717 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5718 Controller->ControllerNumber, Buffer);
5719 Controller->LastProgressReportTime = jiffies;
5722 else printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5723 Controller->ControllerNumber, Buffer);
5725 else if (MessageLevel == DAC960_UserCriticalLevel)
5727 strcpy(&Controller->UserStatusBuffer[Controller->UserStatusLength],
5729 Controller->UserStatusLength += Length;
5730 if (Buffer[0] != '\n' || Length > 1)
5731 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5732 Controller->ControllerNumber, Buffer);
5736 if (BeginningOfLine)
5737 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5738 Controller->ControllerNumber, Buffer);
5739 else printk("%s", Buffer);
5741 BeginningOfLine = (Buffer[Length-1] == '\n');
5746 DAC960_ParsePhysicalDevice parses spaces followed by a Physical Device
5747 Channel:TargetID specification from a User Command string. It updates
5748 Channel and TargetID and returns true on success and false on failure.
5751 static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
5752 char *UserCommandString,
5753 unsigned char *Channel,
5754 unsigned char *TargetID)
5756 char *NewUserCommandString = UserCommandString;
5757 unsigned long XChannel, XTargetID;
5758 while (*UserCommandString == ' ') UserCommandString++;
5759 if (UserCommandString == NewUserCommandString)
5761 XChannel = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5762 if (NewUserCommandString == UserCommandString ||
5763 *NewUserCommandString != ':' ||
5764 XChannel >= Controller->Channels)
5766 UserCommandString = ++NewUserCommandString;
5767 XTargetID = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5768 if (NewUserCommandString == UserCommandString ||
5769 *NewUserCommandString != '\0' ||
5770 XTargetID >= Controller->Targets)
5772 *Channel = XChannel;
5773 *TargetID = XTargetID;
5779 DAC960_ParseLogicalDrive parses spaces followed by a Logical Drive Number
5780 specification from a User Command string. It updates LogicalDriveNumber and
5781 returns true on success and false on failure.
5784 static boolean DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
5785 char *UserCommandString,
5786 unsigned char *LogicalDriveNumber)
5788 char *NewUserCommandString = UserCommandString;
5789 unsigned long XLogicalDriveNumber;
5790 while (*UserCommandString == ' ') UserCommandString++;
5791 if (UserCommandString == NewUserCommandString)
5793 XLogicalDriveNumber =
5794 simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5795 if (NewUserCommandString == UserCommandString ||
5796 *NewUserCommandString != '\0' ||
5797 XLogicalDriveNumber > DAC960_MaxLogicalDrives - 1)
5799 *LogicalDriveNumber = XLogicalDriveNumber;
5805 DAC960_V1_SetDeviceState sets the Device State for a Physical Device for
5806 DAC960 V1 Firmware Controllers.
5809 static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
5810 DAC960_Command_T *Command,
5811 unsigned char Channel,
5812 unsigned char TargetID,
5813 DAC960_V1_PhysicalDeviceState_T
5815 const unsigned char *DeviceStateString)
5817 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5818 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_StartDevice;
5819 CommandMailbox->Type3D.Channel = Channel;
5820 CommandMailbox->Type3D.TargetID = TargetID;
5821 CommandMailbox->Type3D.DeviceState = DeviceState;
5822 CommandMailbox->Type3D.Modifier = 0;
5823 DAC960_ExecuteCommand(Command);
5824 switch (Command->V1.CommandStatus)
5826 case DAC960_V1_NormalCompletion:
5827 DAC960_UserCritical("%s of Physical Device %d:%d Succeeded\n", Controller,
5828 DeviceStateString, Channel, TargetID);
5830 case DAC960_V1_UnableToStartDevice:
5831 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5832 "Unable to Start Device\n", Controller,
5833 DeviceStateString, Channel, TargetID);
5835 case DAC960_V1_NoDeviceAtAddress:
5836 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5837 "No Device at Address\n", Controller,
5838 DeviceStateString, Channel, TargetID);
5840 case DAC960_V1_InvalidChannelOrTargetOrModifier:
5841 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5842 "Invalid Channel or Target or Modifier\n",
5843 Controller, DeviceStateString, Channel, TargetID);
5845 case DAC960_V1_ChannelBusy:
5846 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5847 "Channel Busy\n", Controller,
5848 DeviceStateString, Channel, TargetID);
5851 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5852 "Unexpected Status %04X\n", Controller,
5853 DeviceStateString, Channel, TargetID,
5854 Command->V1.CommandStatus);
5861 DAC960_V1_ExecuteUserCommand executes a User Command for DAC960 V1 Firmware
5865 static boolean DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
5866 unsigned char *UserCommand)
5868 DAC960_Command_T *Command;
5869 DAC960_V1_CommandMailbox_T *CommandMailbox;
5870 unsigned long flags;
5871 unsigned char Channel, TargetID, LogicalDriveNumber;
5873 spin_lock_irqsave(&Controller->queue_lock, flags);
5874 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
5875 DAC960_WaitForCommand(Controller);
5876 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5877 Controller->UserStatusLength = 0;
5878 DAC960_V1_ClearCommand(Command);
5879 Command->CommandType = DAC960_ImmediateCommand;
5880 CommandMailbox = &Command->V1.CommandMailbox;
5881 if (strcmp(UserCommand, "flush-cache") == 0)
5883 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Flush;
5884 DAC960_ExecuteCommand(Command);
5885 DAC960_UserCritical("Cache Flush Completed\n", Controller);
5887 else if (strncmp(UserCommand, "kill", 4) == 0 &&
5888 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
5889 &Channel, &TargetID))
5891 DAC960_V1_DeviceState_T *DeviceState =
5892 &Controller->V1.DeviceState[Channel][TargetID];
5893 if (DeviceState->Present &&
5894 DeviceState->DeviceType == DAC960_V1_DiskType &&
5895 DeviceState->DeviceState != DAC960_V1_Device_Dead)
5896 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5897 DAC960_V1_Device_Dead, "Kill");
5898 else DAC960_UserCritical("Kill of Physical Device %d:%d Illegal\n",
5899 Controller, Channel, TargetID);
5901 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
5902 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
5903 &Channel, &TargetID))
5905 DAC960_V1_DeviceState_T *DeviceState =
5906 &Controller->V1.DeviceState[Channel][TargetID];
5907 if (DeviceState->Present &&
5908 DeviceState->DeviceType == DAC960_V1_DiskType &&
5909 DeviceState->DeviceState == DAC960_V1_Device_Dead)
5910 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5911 DAC960_V1_Device_Online, "Make Online");
5912 else DAC960_UserCritical("Make Online of Physical Device %d:%d Illegal\n",
5913 Controller, Channel, TargetID);
5916 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
5917 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
5918 &Channel, &TargetID))
5920 DAC960_V1_DeviceState_T *DeviceState =
5921 &Controller->V1.DeviceState[Channel][TargetID];
5922 if (DeviceState->Present &&
5923 DeviceState->DeviceType == DAC960_V1_DiskType &&
5924 DeviceState->DeviceState == DAC960_V1_Device_Dead)
5925 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5926 DAC960_V1_Device_Standby, "Make Standby");
5927 else DAC960_UserCritical("Make Standby of Physical "
5928 "Device %d:%d Illegal\n",
5929 Controller, Channel, TargetID);
5931 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
5932 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
5933 &Channel, &TargetID))
5935 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_RebuildAsync;
5936 CommandMailbox->Type3D.Channel = Channel;
5937 CommandMailbox->Type3D.TargetID = TargetID;
5938 DAC960_ExecuteCommand(Command);
5939 switch (Command->V1.CommandStatus)
5941 case DAC960_V1_NormalCompletion:
5942 DAC960_UserCritical("Rebuild of Physical Device %d:%d Initiated\n",
5943 Controller, Channel, TargetID);
5945 case DAC960_V1_AttemptToRebuildOnlineDrive:
5946 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5947 "Attempt to Rebuild Online or "
5948 "Unresponsive Drive\n",
5949 Controller, Channel, TargetID);
5951 case DAC960_V1_NewDiskFailedDuringRebuild:
5952 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5953 "New Disk Failed During Rebuild\n",
5954 Controller, Channel, TargetID);
5956 case DAC960_V1_InvalidDeviceAddress:
5957 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5958 "Invalid Device Address\n",
5959 Controller, Channel, TargetID);
5961 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
5962 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5963 "Rebuild or Consistency Check Already "
5964 "in Progress\n", Controller, Channel, TargetID);
5967 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5968 "Unexpected Status %04X\n", Controller,
5969 Channel, TargetID, Command->V1.CommandStatus);
5973 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
5974 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
5975 &LogicalDriveNumber))
5977 CommandMailbox->Type3C.CommandOpcode = DAC960_V1_CheckConsistencyAsync;
5978 CommandMailbox->Type3C.LogicalDriveNumber = LogicalDriveNumber;
5979 CommandMailbox->Type3C.AutoRestore = true;
5980 DAC960_ExecuteCommand(Command);
5981 switch (Command->V1.CommandStatus)
5983 case DAC960_V1_NormalCompletion:
5984 DAC960_UserCritical("Consistency Check of Logical Drive %d "
5985 "(/dev/rd/c%dd%d) Initiated\n",
5986 Controller, LogicalDriveNumber,
5987 Controller->ControllerNumber,
5988 LogicalDriveNumber);
5990 case DAC960_V1_DependentDiskIsDead:
5991 DAC960_UserCritical("Consistency Check of Logical Drive %d "
5992 "(/dev/rd/c%dd%d) Failed - "
5993 "Dependent Physical Device is DEAD\n",
5994 Controller, LogicalDriveNumber,
5995 Controller->ControllerNumber,
5996 LogicalDriveNumber);
5998 case DAC960_V1_InvalidOrNonredundantLogicalDrive:
5999 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6000 "(/dev/rd/c%dd%d) Failed - "
6001 "Invalid or Nonredundant Logical Drive\n",
6002 Controller, LogicalDriveNumber,
6003 Controller->ControllerNumber,
6004 LogicalDriveNumber);
6006 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
6007 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6008 "(/dev/rd/c%dd%d) Failed - Rebuild or "
6009 "Consistency Check Already in Progress\n",
6010 Controller, LogicalDriveNumber,
6011 Controller->ControllerNumber,
6012 LogicalDriveNumber);
6015 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6016 "(/dev/rd/c%dd%d) Failed - "
6017 "Unexpected Status %04X\n",
6018 Controller, LogicalDriveNumber,
6019 Controller->ControllerNumber,
6020 LogicalDriveNumber, Command->V1.CommandStatus);
6024 else if (strcmp(UserCommand, "cancel-rebuild") == 0 ||
6025 strcmp(UserCommand, "cancel-consistency-check") == 0)
6028 the OldRebuildRateConstant is never actually used
6029 once its value is retrieved from the controller.
6031 unsigned char *OldRebuildRateConstant;
6032 dma_addr_t OldRebuildRateConstantDMA;
6034 OldRebuildRateConstant = pci_alloc_consistent( Controller->PCIDevice,
6035 sizeof(char), &OldRebuildRateConstantDMA);
6036 if (OldRebuildRateConstant == NULL) {
6037 DAC960_UserCritical("Cancellation of Rebuild or "
6038 "Consistency Check Failed - "
6043 CommandMailbox->Type3R.CommandOpcode = DAC960_V1_RebuildControl;
6044 CommandMailbox->Type3R.RebuildRateConstant = 0xFF;
6045 CommandMailbox->Type3R.BusAddress = OldRebuildRateConstantDMA;
6046 DAC960_ExecuteCommand(Command);
6047 switch (Command->V1.CommandStatus)
6049 case DAC960_V1_NormalCompletion:
6050 DAC960_UserCritical("Rebuild or Consistency Check Cancelled\n",
6054 DAC960_UserCritical("Cancellation of Rebuild or "
6055 "Consistency Check Failed - "
6056 "Unexpected Status %04X\n",
6057 Controller, Command->V1.CommandStatus);
6061 pci_free_consistent(Controller->PCIDevice, sizeof(char),
6062 OldRebuildRateConstant, OldRebuildRateConstantDMA);
6064 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6065 Controller, UserCommand);
6067 spin_lock_irqsave(&Controller->queue_lock, flags);
6068 DAC960_DeallocateCommand(Command);
6069 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6075 DAC960_V2_TranslatePhysicalDevice translates a Physical Device Channel and
6076 TargetID into a Logical Device. It returns true on success and false
6080 static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6081 unsigned char Channel,
6082 unsigned char TargetID,
6084 *LogicalDeviceNumber)
6086 DAC960_V2_CommandMailbox_T SavedCommandMailbox, *CommandMailbox;
6087 DAC960_Controller_T *Controller = Command->Controller;
6089 CommandMailbox = &Command->V2.CommandMailbox;
6090 memcpy(&SavedCommandMailbox, CommandMailbox,
6091 sizeof(DAC960_V2_CommandMailbox_T));
6093 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
6094 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6095 .DataTransferControllerToHost = true;
6096 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6097 .NoAutoRequestSense = true;
6098 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
6099 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
6100 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
6101 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
6102 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
6103 DAC960_V2_TranslatePhysicalToLogicalDevice;
6104 CommandMailbox->Common.DataTransferMemoryAddress
6105 .ScatterGatherSegments[0]
6106 .SegmentDataPointer =
6107 Controller->V2.PhysicalToLogicalDeviceDMA;
6108 CommandMailbox->Common.DataTransferMemoryAddress
6109 .ScatterGatherSegments[0]
6111 CommandMailbox->Common.DataTransferSize;
6113 DAC960_ExecuteCommand(Command);
6114 *LogicalDeviceNumber = Controller->V2.PhysicalToLogicalDevice->LogicalDeviceNumber;
6116 memcpy(CommandMailbox, &SavedCommandMailbox,
6117 sizeof(DAC960_V2_CommandMailbox_T));
6118 return (Command->V2.CommandStatus == DAC960_V2_NormalCompletion);
6123 DAC960_V2_ExecuteUserCommand executes a User Command for DAC960 V2 Firmware
6127 static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
6128 unsigned char *UserCommand)
6130 DAC960_Command_T *Command;
6131 DAC960_V2_CommandMailbox_T *CommandMailbox;
6132 unsigned long flags;
6133 unsigned char Channel, TargetID, LogicalDriveNumber;
6134 unsigned short LogicalDeviceNumber;
6136 spin_lock_irqsave(&Controller->queue_lock, flags);
6137 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6138 DAC960_WaitForCommand(Controller);
6139 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6140 Controller->UserStatusLength = 0;
6141 DAC960_V2_ClearCommand(Command);
6142 Command->CommandType = DAC960_ImmediateCommand;
6143 CommandMailbox = &Command->V2.CommandMailbox;
6144 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
6145 CommandMailbox->Common.CommandControlBits.DataTransferControllerToHost = true;
6146 CommandMailbox->Common.CommandControlBits.NoAutoRequestSense = true;
6147 if (strcmp(UserCommand, "flush-cache") == 0)
6149 CommandMailbox->DeviceOperation.IOCTL_Opcode = DAC960_V2_PauseDevice;
6150 CommandMailbox->DeviceOperation.OperationDevice =
6151 DAC960_V2_RAID_Controller;
6152 DAC960_ExecuteCommand(Command);
6153 DAC960_UserCritical("Cache Flush Completed\n", Controller);
6155 else if (strncmp(UserCommand, "kill", 4) == 0 &&
6156 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
6157 &Channel, &TargetID) &&
6158 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6159 &LogicalDeviceNumber))
6161 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6162 LogicalDeviceNumber;
6163 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6164 DAC960_V2_SetDeviceState;
6165 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6166 DAC960_V2_Device_Dead;
6167 DAC960_ExecuteCommand(Command);
6168 DAC960_UserCritical("Kill of Physical Device %d:%d %s\n",
6169 Controller, Channel, TargetID,
6170 (Command->V2.CommandStatus
6171 == DAC960_V2_NormalCompletion
6172 ? "Succeeded" : "Failed"));
6174 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
6175 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6176 &Channel, &TargetID) &&
6177 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6178 &LogicalDeviceNumber))
6180 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6181 LogicalDeviceNumber;
6182 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6183 DAC960_V2_SetDeviceState;
6184 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6185 DAC960_V2_Device_Online;
6186 DAC960_ExecuteCommand(Command);
6187 DAC960_UserCritical("Make Online of Physical Device %d:%d %s\n",
6188 Controller, Channel, TargetID,
6189 (Command->V2.CommandStatus
6190 == DAC960_V2_NormalCompletion
6191 ? "Succeeded" : "Failed"));
6193 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
6194 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6195 &Channel, &TargetID) &&
6196 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6197 &LogicalDeviceNumber))
6199 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6200 LogicalDeviceNumber;
6201 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6202 DAC960_V2_SetDeviceState;
6203 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6204 DAC960_V2_Device_Standby;
6205 DAC960_ExecuteCommand(Command);
6206 DAC960_UserCritical("Make Standby of Physical Device %d:%d %s\n",
6207 Controller, Channel, TargetID,
6208 (Command->V2.CommandStatus
6209 == DAC960_V2_NormalCompletion
6210 ? "Succeeded" : "Failed"));
6212 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
6213 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6214 &Channel, &TargetID) &&
6215 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6216 &LogicalDeviceNumber))
6218 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6219 LogicalDeviceNumber;
6220 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6221 DAC960_V2_RebuildDeviceStart;
6222 DAC960_ExecuteCommand(Command);
6223 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6224 Controller, Channel, TargetID,
6225 (Command->V2.CommandStatus
6226 == DAC960_V2_NormalCompletion
6227 ? "Initiated" : "Not Initiated"));
6229 else if (strncmp(UserCommand, "cancel-rebuild", 14) == 0 &&
6230 DAC960_ParsePhysicalDevice(Controller, &UserCommand[14],
6231 &Channel, &TargetID) &&
6232 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6233 &LogicalDeviceNumber))
6235 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6236 LogicalDeviceNumber;
6237 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6238 DAC960_V2_RebuildDeviceStop;
6239 DAC960_ExecuteCommand(Command);
6240 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6241 Controller, Channel, TargetID,
6242 (Command->V2.CommandStatus
6243 == DAC960_V2_NormalCompletion
6244 ? "Cancelled" : "Not Cancelled"));
6246 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
6247 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6248 &LogicalDriveNumber))
6250 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6252 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6253 DAC960_V2_ConsistencyCheckStart;
6254 CommandMailbox->ConsistencyCheck.RestoreConsistency = true;
6255 CommandMailbox->ConsistencyCheck.InitializedAreaOnly = false;
6256 DAC960_ExecuteCommand(Command);
6257 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6258 "(/dev/rd/c%dd%d) %s\n",
6259 Controller, LogicalDriveNumber,
6260 Controller->ControllerNumber,
6262 (Command->V2.CommandStatus
6263 == DAC960_V2_NormalCompletion
6264 ? "Initiated" : "Not Initiated"));
6266 else if (strncmp(UserCommand, "cancel-consistency-check", 24) == 0 &&
6267 DAC960_ParseLogicalDrive(Controller, &UserCommand[24],
6268 &LogicalDriveNumber))
6270 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6272 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6273 DAC960_V2_ConsistencyCheckStop;
6274 DAC960_ExecuteCommand(Command);
6275 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6276 "(/dev/rd/c%dd%d) %s\n",
6277 Controller, LogicalDriveNumber,
6278 Controller->ControllerNumber,
6280 (Command->V2.CommandStatus
6281 == DAC960_V2_NormalCompletion
6282 ? "Cancelled" : "Not Cancelled"));
6284 else if (strcmp(UserCommand, "perform-discovery") == 0)
6286 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_StartDiscovery;
6287 DAC960_ExecuteCommand(Command);
6288 DAC960_UserCritical("Discovery %s\n", Controller,
6289 (Command->V2.CommandStatus
6290 == DAC960_V2_NormalCompletion
6291 ? "Initiated" : "Not Initiated"));
6292 if (Command->V2.CommandStatus == DAC960_V2_NormalCompletion)
6294 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
6295 CommandMailbox->ControllerInfo.CommandControlBits
6296 .DataTransferControllerToHost = true;
6297 CommandMailbox->ControllerInfo.CommandControlBits
6298 .NoAutoRequestSense = true;
6299 CommandMailbox->ControllerInfo.DataTransferSize =
6300 sizeof(DAC960_V2_ControllerInfo_T);
6301 CommandMailbox->ControllerInfo.ControllerNumber = 0;
6302 CommandMailbox->ControllerInfo.IOCTL_Opcode =
6303 DAC960_V2_GetControllerInfo;
6305 * How does this NOT race with the queued Monitoring
6306 * usage of this structure?
6308 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6309 .ScatterGatherSegments[0]
6310 .SegmentDataPointer =
6311 Controller->V2.NewControllerInformationDMA;
6312 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6313 .ScatterGatherSegments[0]
6315 CommandMailbox->ControllerInfo.DataTransferSize;
6316 DAC960_ExecuteCommand(Command);
6317 while (Controller->V2.NewControllerInformation->PhysicalScanActive)
6319 DAC960_ExecuteCommand(Command);
6320 sleep_on_timeout(&Controller->CommandWaitQueue, HZ);
6322 DAC960_UserCritical("Discovery Completed\n", Controller);
6325 else if (strcmp(UserCommand, "suppress-enclosure-messages") == 0)
6326 Controller->SuppressEnclosureMessages = true;
6327 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6328 Controller, UserCommand);
6330 spin_lock_irqsave(&Controller->queue_lock, flags);
6331 DAC960_DeallocateCommand(Command);
6332 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6338 DAC960_ProcReadStatus implements reading /proc/rd/status.
6341 static int DAC960_ProcReadStatus(char *Page, char **Start, off_t Offset,
6342 int Count, int *EOF, void *Data)
6344 unsigned char *StatusMessage = "OK\n";
6345 int ControllerNumber, BytesAvailable;
6346 for (ControllerNumber = 0;
6347 ControllerNumber < DAC960_ControllerCount;
6350 DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
6351 if (Controller == NULL) continue;
6352 if (Controller->MonitoringAlertMode)
6354 StatusMessage = "ALERT\n";
6358 BytesAvailable = strlen(StatusMessage) - Offset;
6359 if (Count >= BytesAvailable)
6361 Count = BytesAvailable;
6364 if (Count <= 0) return 0;
6366 memcpy(Page, &StatusMessage[Offset], Count);
6372 DAC960_ProcReadInitialStatus implements reading /proc/rd/cN/initial_status.
6375 static int DAC960_ProcReadInitialStatus(char *Page, char **Start, off_t Offset,
6376 int Count, int *EOF, void *Data)
6378 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6379 int BytesAvailable = Controller->InitialStatusLength - Offset;
6380 if (Count >= BytesAvailable)
6382 Count = BytesAvailable;
6385 if (Count <= 0) return 0;
6387 memcpy(Page, &Controller->CombinedStatusBuffer[Offset], Count);
6393 DAC960_ProcReadCurrentStatus implements reading /proc/rd/cN/current_status.
6396 static int DAC960_ProcReadCurrentStatus(char *Page, char **Start, off_t Offset,
6397 int Count, int *EOF, void *Data)
6399 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6400 unsigned char *StatusMessage =
6401 "No Rebuild or Consistency Check in Progress\n";
6402 int ProgressMessageLength = strlen(StatusMessage);
6404 if (jiffies != Controller->LastCurrentStatusTime)
6406 Controller->CurrentStatusLength = 0;
6407 DAC960_AnnounceDriver(Controller);
6408 DAC960_ReportControllerConfiguration(Controller);
6409 DAC960_ReportDeviceConfiguration(Controller);
6410 if (Controller->ProgressBufferLength > 0)
6411 ProgressMessageLength = Controller->ProgressBufferLength;
6412 if (DAC960_CheckStatusBuffer(Controller, 2 + ProgressMessageLength))
6414 unsigned char *CurrentStatusBuffer = Controller->CurrentStatusBuffer;
6415 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6416 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6417 if (Controller->ProgressBufferLength > 0)
6418 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6419 Controller->ProgressBuffer);
6421 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6423 Controller->CurrentStatusLength += ProgressMessageLength;
6425 Controller->LastCurrentStatusTime = jiffies;
6427 BytesAvailable = Controller->CurrentStatusLength - Offset;
6428 if (Count >= BytesAvailable)
6430 Count = BytesAvailable;
6433 if (Count <= 0) return 0;
6435 memcpy(Page, &Controller->CurrentStatusBuffer[Offset], Count);
6441 DAC960_ProcReadUserCommand implements reading /proc/rd/cN/user_command.
6444 static int DAC960_ProcReadUserCommand(char *Page, char **Start, off_t Offset,
6445 int Count, int *EOF, void *Data)
6447 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6448 int BytesAvailable = Controller->UserStatusLength - Offset;
6449 if (Count >= BytesAvailable)
6451 Count = BytesAvailable;
6454 if (Count <= 0) return 0;
6456 memcpy(Page, &Controller->UserStatusBuffer[Offset], Count);
6462 DAC960_ProcWriteUserCommand implements writing /proc/rd/cN/user_command.
6465 static int DAC960_ProcWriteUserCommand(struct file *file,
6466 const char __user *Buffer,
6467 unsigned long Count, void *Data)
6469 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6470 unsigned char CommandBuffer[80];
6472 if (Count > sizeof(CommandBuffer)-1) return -EINVAL;
6473 if (copy_from_user(CommandBuffer, Buffer, Count)) return -EFAULT;
6474 CommandBuffer[Count] = '\0';
6475 Length = strlen(CommandBuffer);
6476 if (CommandBuffer[Length-1] == '\n')
6477 CommandBuffer[--Length] = '\0';
6478 if (Controller->FirmwareType == DAC960_V1_Controller)
6479 return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)
6482 return (DAC960_V2_ExecuteUserCommand(Controller, CommandBuffer)
6488 DAC960_CreateProcEntries creates the /proc/rd/... entries for the
6492 static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller)
6494 struct proc_dir_entry *StatusProcEntry;
6495 struct proc_dir_entry *ControllerProcEntry;
6496 struct proc_dir_entry *UserCommandProcEntry;
6498 if (DAC960_ProcDirectoryEntry == NULL) {
6499 DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL);
6500 StatusProcEntry = create_proc_read_entry("status", 0,
6501 DAC960_ProcDirectoryEntry,
6502 DAC960_ProcReadStatus, NULL);
6505 sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber);
6506 ControllerProcEntry = proc_mkdir(Controller->ControllerName,
6507 DAC960_ProcDirectoryEntry);
6508 create_proc_read_entry("initial_status", 0, ControllerProcEntry,
6509 DAC960_ProcReadInitialStatus, Controller);
6510 create_proc_read_entry("current_status", 0, ControllerProcEntry,
6511 DAC960_ProcReadCurrentStatus, Controller);
6512 UserCommandProcEntry =
6513 create_proc_read_entry("user_command", S_IWUSR | S_IRUSR,
6514 ControllerProcEntry, DAC960_ProcReadUserCommand,
6516 UserCommandProcEntry->write_proc = DAC960_ProcWriteUserCommand;
6517 Controller->ControllerProcEntry = ControllerProcEntry;
6522 DAC960_DestroyProcEntries destroys the /proc/rd/... entries for the
6526 static void DAC960_DestroyProcEntries(DAC960_Controller_T *Controller)
6528 if (Controller->ControllerProcEntry == NULL)
6530 remove_proc_entry("initial_status", Controller->ControllerProcEntry);
6531 remove_proc_entry("current_status", Controller->ControllerProcEntry);
6532 remove_proc_entry("user_command", Controller->ControllerProcEntry);
6533 remove_proc_entry(Controller->ControllerName, DAC960_ProcDirectoryEntry);
6534 Controller->ControllerProcEntry = NULL;
6537 #ifdef DAC960_GAM_MINOR
6540 * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
6543 static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
6544 unsigned int Request, unsigned long Argument)
6547 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
6550 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
6551 return DAC960_ControllerCount;
6552 case DAC960_IOCTL_GET_CONTROLLER_INFO:
6554 DAC960_ControllerInfo_T __user *UserSpaceControllerInfo =
6555 (DAC960_ControllerInfo_T __user *) Argument;
6556 DAC960_ControllerInfo_T ControllerInfo;
6557 DAC960_Controller_T *Controller;
6558 int ControllerNumber;
6559 if (UserSpaceControllerInfo == NULL) return -EINVAL;
6560 ErrorCode = get_user(ControllerNumber,
6561 &UserSpaceControllerInfo->ControllerNumber);
6562 if (ErrorCode != 0) return ErrorCode;
6563 if (ControllerNumber < 0 ||
6564 ControllerNumber > DAC960_ControllerCount - 1)
6566 Controller = DAC960_Controllers[ControllerNumber];
6567 if (Controller == NULL) return -ENXIO;
6568 memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
6569 ControllerInfo.ControllerNumber = ControllerNumber;
6570 ControllerInfo.FirmwareType = Controller->FirmwareType;
6571 ControllerInfo.Channels = Controller->Channels;
6572 ControllerInfo.Targets = Controller->Targets;
6573 ControllerInfo.PCI_Bus = Controller->Bus;
6574 ControllerInfo.PCI_Device = Controller->Device;
6575 ControllerInfo.PCI_Function = Controller->Function;
6576 ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
6577 ControllerInfo.PCI_Address = Controller->PCI_Address;
6578 strcpy(ControllerInfo.ModelName, Controller->ModelName);
6579 strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
6580 return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
6581 sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
6583 case DAC960_IOCTL_V1_EXECUTE_COMMAND:
6585 DAC960_V1_UserCommand_T __user *UserSpaceUserCommand =
6586 (DAC960_V1_UserCommand_T __user *) Argument;
6587 DAC960_V1_UserCommand_T UserCommand;
6588 DAC960_Controller_T *Controller;
6589 DAC960_Command_T *Command = NULL;
6590 DAC960_V1_CommandOpcode_T CommandOpcode;
6591 DAC960_V1_CommandStatus_T CommandStatus;
6592 DAC960_V1_DCDB_T DCDB;
6593 DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
6594 dma_addr_t DCDB_IOBUFDMA;
6595 unsigned long flags;
6596 int ControllerNumber, DataTransferLength;
6597 unsigned char *DataTransferBuffer = NULL;
6598 dma_addr_t DataTransferBufferDMA;
6599 if (UserSpaceUserCommand == NULL) return -EINVAL;
6600 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6601 sizeof(DAC960_V1_UserCommand_T))) {
6602 ErrorCode = -EFAULT;
6605 ControllerNumber = UserCommand.ControllerNumber;
6606 if (ControllerNumber < 0 ||
6607 ControllerNumber > DAC960_ControllerCount - 1)
6609 Controller = DAC960_Controllers[ControllerNumber];
6610 if (Controller == NULL) return -ENXIO;
6611 if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
6612 CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
6613 DataTransferLength = UserCommand.DataTransferLength;
6614 if (CommandOpcode & 0x80) return -EINVAL;
6615 if (CommandOpcode == DAC960_V1_DCDB)
6617 if (copy_from_user(&DCDB, UserCommand.DCDB,
6618 sizeof(DAC960_V1_DCDB_T))) {
6619 ErrorCode = -EFAULT;
6622 if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
6623 if (!((DataTransferLength == 0 &&
6625 == DAC960_V1_DCDB_NoDataTransfer) ||
6626 (DataTransferLength > 0 &&
6628 == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
6629 (DataTransferLength < 0 &&
6631 == DAC960_V1_DCDB_DataTransferSystemToDevice)))
6633 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
6634 != abs(DataTransferLength))
6636 DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
6637 sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
6638 if (DCDB_IOBUF == NULL)
6641 if (DataTransferLength > 0)
6643 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6644 DataTransferLength, &DataTransferBufferDMA);
6645 if (DataTransferBuffer == NULL) {
6646 ErrorCode = -ENOMEM;
6649 memset(DataTransferBuffer, 0, DataTransferLength);
6651 else if (DataTransferLength < 0)
6653 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6654 -DataTransferLength, &DataTransferBufferDMA);
6655 if (DataTransferBuffer == NULL) {
6656 ErrorCode = -ENOMEM;
6659 if (copy_from_user(DataTransferBuffer,
6660 UserCommand.DataTransferBuffer,
6661 -DataTransferLength)) {
6662 ErrorCode = -EFAULT;
6666 if (CommandOpcode == DAC960_V1_DCDB)
6668 spin_lock_irqsave(&Controller->queue_lock, flags);
6669 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6670 DAC960_WaitForCommand(Controller);
6671 while (Controller->V1.DirectCommandActive[DCDB.Channel]
6674 spin_unlock_irq(&Controller->queue_lock);
6675 __wait_event(Controller->CommandWaitQueue,
6676 !Controller->V1.DirectCommandActive
6677 [DCDB.Channel][DCDB.TargetID]);
6678 spin_lock_irq(&Controller->queue_lock);
6680 Controller->V1.DirectCommandActive[DCDB.Channel]
6681 [DCDB.TargetID] = true;
6682 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6683 DAC960_V1_ClearCommand(Command);
6684 Command->CommandType = DAC960_ImmediateCommand;
6685 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
6686 sizeof(DAC960_V1_CommandMailbox_T));
6687 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
6688 DCDB.BusAddress = DataTransferBufferDMA;
6689 memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
6693 spin_lock_irqsave(&Controller->queue_lock, flags);
6694 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6695 DAC960_WaitForCommand(Controller);
6696 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6697 DAC960_V1_ClearCommand(Command);
6698 Command->CommandType = DAC960_ImmediateCommand;
6699 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
6700 sizeof(DAC960_V1_CommandMailbox_T));
6701 if (DataTransferBuffer != NULL)
6702 Command->V1.CommandMailbox.Type3.BusAddress =
6703 DataTransferBufferDMA;
6705 DAC960_ExecuteCommand(Command);
6706 CommandStatus = Command->V1.CommandStatus;
6707 spin_lock_irqsave(&Controller->queue_lock, flags);
6708 DAC960_DeallocateCommand(Command);
6709 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6710 if (DataTransferLength > 0)
6712 if (copy_to_user(UserCommand.DataTransferBuffer,
6713 DataTransferBuffer, DataTransferLength)) {
6714 ErrorCode = -EFAULT;
6718 if (CommandOpcode == DAC960_V1_DCDB)
6721 I don't believe Target or Channel in the DCDB_IOBUF
6722 should be any different from the contents of DCDB.
6724 Controller->V1.DirectCommandActive[DCDB.Channel]
6725 [DCDB.TargetID] = false;
6726 if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
6727 sizeof(DAC960_V1_DCDB_T))) {
6728 ErrorCode = -EFAULT;
6732 ErrorCode = CommandStatus;
6734 if (DataTransferBuffer != NULL)
6735 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
6736 DataTransferBuffer, DataTransferBufferDMA);
6737 if (DCDB_IOBUF != NULL)
6738 pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
6739 DCDB_IOBUF, DCDB_IOBUFDMA);
6743 case DAC960_IOCTL_V2_EXECUTE_COMMAND:
6745 DAC960_V2_UserCommand_T __user *UserSpaceUserCommand =
6746 (DAC960_V2_UserCommand_T __user *) Argument;
6747 DAC960_V2_UserCommand_T UserCommand;
6748 DAC960_Controller_T *Controller;
6749 DAC960_Command_T *Command = NULL;
6750 DAC960_V2_CommandMailbox_T *CommandMailbox;
6751 DAC960_V2_CommandStatus_T CommandStatus;
6752 unsigned long flags;
6753 int ControllerNumber, DataTransferLength;
6754 int DataTransferResidue, RequestSenseLength;
6755 unsigned char *DataTransferBuffer = NULL;
6756 dma_addr_t DataTransferBufferDMA;
6757 unsigned char *RequestSenseBuffer = NULL;
6758 dma_addr_t RequestSenseBufferDMA;
6759 if (UserSpaceUserCommand == NULL) return -EINVAL;
6760 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6761 sizeof(DAC960_V2_UserCommand_T))) {
6762 ErrorCode = -EFAULT;
6765 ControllerNumber = UserCommand.ControllerNumber;
6766 if (ControllerNumber < 0 ||
6767 ControllerNumber > DAC960_ControllerCount - 1)
6769 Controller = DAC960_Controllers[ControllerNumber];
6770 if (Controller == NULL) return -ENXIO;
6771 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
6772 DataTransferLength = UserCommand.DataTransferLength;
6773 if (DataTransferLength > 0)
6775 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6776 DataTransferLength, &DataTransferBufferDMA);
6777 if (DataTransferBuffer == NULL) return -ENOMEM;
6778 memset(DataTransferBuffer, 0, DataTransferLength);
6780 else if (DataTransferLength < 0)
6782 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6783 -DataTransferLength, &DataTransferBufferDMA);
6784 if (DataTransferBuffer == NULL) return -ENOMEM;
6785 if (copy_from_user(DataTransferBuffer,
6786 UserCommand.DataTransferBuffer,
6787 -DataTransferLength)) {
6788 ErrorCode = -EFAULT;
6792 RequestSenseLength = UserCommand.RequestSenseLength;
6793 if (RequestSenseLength > 0)
6795 RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
6796 RequestSenseLength, &RequestSenseBufferDMA);
6797 if (RequestSenseBuffer == NULL)
6799 ErrorCode = -ENOMEM;
6802 memset(RequestSenseBuffer, 0, RequestSenseLength);
6804 spin_lock_irqsave(&Controller->queue_lock, flags);
6805 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6806 DAC960_WaitForCommand(Controller);
6807 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6808 DAC960_V2_ClearCommand(Command);
6809 Command->CommandType = DAC960_ImmediateCommand;
6810 CommandMailbox = &Command->V2.CommandMailbox;
6811 memcpy(CommandMailbox, &UserCommand.CommandMailbox,
6812 sizeof(DAC960_V2_CommandMailbox_T));
6813 CommandMailbox->Common.CommandControlBits
6814 .AdditionalScatterGatherListMemory = false;
6815 CommandMailbox->Common.CommandControlBits
6816 .NoAutoRequestSense = true;
6817 CommandMailbox->Common.DataTransferSize = 0;
6818 CommandMailbox->Common.DataTransferPageNumber = 0;
6819 memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
6820 sizeof(DAC960_V2_DataTransferMemoryAddress_T));
6821 if (DataTransferLength != 0)
6823 if (DataTransferLength > 0)
6825 CommandMailbox->Common.CommandControlBits
6826 .DataTransferControllerToHost = true;
6827 CommandMailbox->Common.DataTransferSize = DataTransferLength;
6831 CommandMailbox->Common.CommandControlBits
6832 .DataTransferControllerToHost = false;
6833 CommandMailbox->Common.DataTransferSize = -DataTransferLength;
6835 CommandMailbox->Common.DataTransferMemoryAddress
6836 .ScatterGatherSegments[0]
6837 .SegmentDataPointer = DataTransferBufferDMA;
6838 CommandMailbox->Common.DataTransferMemoryAddress
6839 .ScatterGatherSegments[0]
6841 CommandMailbox->Common.DataTransferSize;
6843 if (RequestSenseLength > 0)
6845 CommandMailbox->Common.CommandControlBits
6846 .NoAutoRequestSense = false;
6847 CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
6848 CommandMailbox->Common.RequestSenseBusAddress =
6849 RequestSenseBufferDMA;
6851 DAC960_ExecuteCommand(Command);
6852 CommandStatus = Command->V2.CommandStatus;
6853 RequestSenseLength = Command->V2.RequestSenseLength;
6854 DataTransferResidue = Command->V2.DataTransferResidue;
6855 spin_lock_irqsave(&Controller->queue_lock, flags);
6856 DAC960_DeallocateCommand(Command);
6857 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6858 if (RequestSenseLength > UserCommand.RequestSenseLength)
6859 RequestSenseLength = UserCommand.RequestSenseLength;
6860 if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
6861 &DataTransferResidue,
6862 sizeof(DataTransferResidue))) {
6863 ErrorCode = -EFAULT;
6866 if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
6867 &RequestSenseLength, sizeof(RequestSenseLength))) {
6868 ErrorCode = -EFAULT;
6871 if (DataTransferLength > 0)
6873 if (copy_to_user(UserCommand.DataTransferBuffer,
6874 DataTransferBuffer, DataTransferLength)) {
6875 ErrorCode = -EFAULT;
6879 if (RequestSenseLength > 0)
6881 if (copy_to_user(UserCommand.RequestSenseBuffer,
6882 RequestSenseBuffer, RequestSenseLength)) {
6883 ErrorCode = -EFAULT;
6887 ErrorCode = CommandStatus;
6889 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
6890 DataTransferBuffer, DataTransferBufferDMA);
6891 if (RequestSenseBuffer != NULL)
6892 pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
6893 RequestSenseBuffer, RequestSenseBufferDMA);
6897 case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
6899 DAC960_V2_GetHealthStatus_T __user *UserSpaceGetHealthStatus =
6900 (DAC960_V2_GetHealthStatus_T __user *) Argument;
6901 DAC960_V2_GetHealthStatus_T GetHealthStatus;
6902 DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
6903 DAC960_Controller_T *Controller;
6904 int ControllerNumber;
6905 if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
6906 if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
6907 sizeof(DAC960_V2_GetHealthStatus_T)))
6909 ControllerNumber = GetHealthStatus.ControllerNumber;
6910 if (ControllerNumber < 0 ||
6911 ControllerNumber > DAC960_ControllerCount - 1)
6913 Controller = DAC960_Controllers[ControllerNumber];
6914 if (Controller == NULL) return -ENXIO;
6915 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
6916 if (copy_from_user(&HealthStatusBuffer,
6917 GetHealthStatus.HealthStatusBuffer,
6918 sizeof(DAC960_V2_HealthStatusBuffer_T)))
6920 while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
6921 == HealthStatusBuffer.StatusChangeCounter &&
6922 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
6923 == HealthStatusBuffer.NextEventSequenceNumber)
6925 interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
6926 DAC960_MonitoringTimerInterval);
6927 if (signal_pending(current)) return -EINTR;
6929 if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
6930 Controller->V2.HealthStatusBuffer,
6931 sizeof(DAC960_V2_HealthStatusBuffer_T)))
6939 static struct file_operations DAC960_gam_fops = {
6940 .owner = THIS_MODULE,
6941 .ioctl = DAC960_gam_ioctl
6944 static struct miscdevice DAC960_gam_dev = {
6950 static int DAC960_gam_init(void)
6954 ret = misc_register(&DAC960_gam_dev);
6956 printk(KERN_ERR "DAC960_gam: can't misc_register on minor %d\n", DAC960_GAM_MINOR);
6960 static void DAC960_gam_cleanup(void)
6962 misc_deregister(&DAC960_gam_dev);
6965 #endif /* DAC960_GAM_MINOR */
6967 static struct DAC960_privdata DAC960_BA_privdata = {
6968 .HardwareType = DAC960_BA_Controller,
6969 .FirmwareType = DAC960_V2_Controller,
6970 .InterruptHandler = DAC960_BA_InterruptHandler,
6971 .MemoryWindowSize = DAC960_BA_RegisterWindowSize,
6974 static struct DAC960_privdata DAC960_LP_privdata = {
6975 .HardwareType = DAC960_LP_Controller,
6976 .FirmwareType = DAC960_LP_Controller,
6977 .InterruptHandler = DAC960_LP_InterruptHandler,
6978 .MemoryWindowSize = DAC960_LP_RegisterWindowSize,
6981 static struct DAC960_privdata DAC960_LA_privdata = {
6982 .HardwareType = DAC960_LA_Controller,
6983 .FirmwareType = DAC960_V1_Controller,
6984 .InterruptHandler = DAC960_LA_InterruptHandler,
6985 .MemoryWindowSize = DAC960_LA_RegisterWindowSize,
6988 static struct DAC960_privdata DAC960_PG_privdata = {
6989 .HardwareType = DAC960_PG_Controller,
6990 .FirmwareType = DAC960_V1_Controller,
6991 .InterruptHandler = DAC960_PG_InterruptHandler,
6992 .MemoryWindowSize = DAC960_PG_RegisterWindowSize,
6995 static struct DAC960_privdata DAC960_PD_privdata = {
6996 .HardwareType = DAC960_PD_Controller,
6997 .FirmwareType = DAC960_V1_Controller,
6998 .InterruptHandler = DAC960_PD_InterruptHandler,
6999 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7002 static struct DAC960_privdata DAC960_P_privdata = {
7003 .HardwareType = DAC960_P_Controller,
7004 .FirmwareType = DAC960_V1_Controller,
7005 .InterruptHandler = DAC960_P_InterruptHandler,
7006 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7009 static struct pci_device_id DAC960_id_table[] = {
7011 .vendor = PCI_VENDOR_ID_MYLEX,
7012 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA,
7013 .subvendor = PCI_ANY_ID,
7014 .subdevice = PCI_ANY_ID,
7015 .driver_data = (unsigned long) &DAC960_BA_privdata,
7018 .vendor = PCI_VENDOR_ID_MYLEX,
7019 .device = PCI_DEVICE_ID_MYLEX_DAC960_LP,
7020 .subvendor = PCI_ANY_ID,
7021 .subdevice = PCI_ANY_ID,
7022 .driver_data = (unsigned long) &DAC960_LP_privdata,
7025 .vendor = PCI_VENDOR_ID_DEC,
7026 .device = PCI_DEVICE_ID_DEC_21285,
7027 .subvendor = PCI_VENDOR_ID_MYLEX,
7028 .subdevice = PCI_DEVICE_ID_MYLEX_DAC960_LA,
7029 .driver_data = (unsigned long) &DAC960_LA_privdata,
7032 .vendor = PCI_VENDOR_ID_MYLEX,
7033 .device = PCI_DEVICE_ID_MYLEX_DAC960_PG,
7034 .subvendor = PCI_ANY_ID,
7035 .subdevice = PCI_ANY_ID,
7036 .driver_data = (unsigned long) &DAC960_PG_privdata,
7039 .vendor = PCI_VENDOR_ID_MYLEX,
7040 .device = PCI_DEVICE_ID_MYLEX_DAC960_PD,
7041 .subvendor = PCI_ANY_ID,
7042 .subdevice = PCI_ANY_ID,
7043 .driver_data = (unsigned long) &DAC960_PD_privdata,
7046 .vendor = PCI_VENDOR_ID_MYLEX,
7047 .device = PCI_DEVICE_ID_MYLEX_DAC960_P,
7048 .subvendor = PCI_ANY_ID,
7049 .subdevice = PCI_ANY_ID,
7050 .driver_data = (unsigned long) &DAC960_P_privdata,
7055 MODULE_DEVICE_TABLE(pci, DAC960_id_table);
7057 static struct pci_driver DAC960_pci_driver = {
7059 .id_table = DAC960_id_table,
7060 .probe = DAC960_Probe,
7061 .remove = DAC960_Remove,
7064 static int DAC960_init_module(void)
7068 ret = pci_module_init(&DAC960_pci_driver);
7069 #ifdef DAC960_GAM_MINOR
7076 static void DAC960_cleanup_module(void)
7080 #ifdef DAC960_GAM_MINOR
7081 DAC960_gam_cleanup();
7084 for (i = 0; i < DAC960_ControllerCount; i++) {
7085 DAC960_Controller_T *Controller = DAC960_Controllers[i];
7086 if (Controller == NULL)
7088 DAC960_FinalizeController(Controller);
7090 if (DAC960_ProcDirectoryEntry != NULL) {
7091 remove_proc_entry("rd/status", NULL);
7092 remove_proc_entry("rd", NULL);
7094 DAC960_ControllerCount = 0;
7095 pci_unregister_driver(&DAC960_pci_driver);
7098 module_init(DAC960_init_module);
7099 module_exit(DAC960_cleanup_module);
7101 MODULE_LICENSE("GPL");