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/version.h>
24 #include <linux/module.h>
25 #include <linux/types.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>
48 static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
49 static int DAC960_ControllerCount;
50 static struct proc_dir_entry *DAC960_ProcDirectoryEntry;
52 static long disk_size(DAC960_Controller_T *p, int drive_nr)
54 if (p->FirmwareType == DAC960_V1_Controller) {
55 if (drive_nr >= p->LogicalDriveCount)
57 return p->V1.LogicalDriveInformation[drive_nr].
60 DAC960_V2_LogicalDeviceInfo_T *i =
61 p->V2.LogicalDeviceInformation[drive_nr];
64 return i->ConfigurableDeviceSize;
68 static int DAC960_open(struct inode *inode, struct file *file)
70 struct gendisk *disk = inode->i_bdev->bd_disk;
71 DAC960_Controller_T *p = disk->queue->queuedata;
72 int drive_nr = (int)disk->private_data;
74 /* bad hack for the "user" ioctls */
75 if (!p->ControllerNumber && !drive_nr && (file->f_flags & O_NONBLOCK))
78 if (p->FirmwareType == DAC960_V1_Controller) {
79 if (p->V1.LogicalDriveInformation[drive_nr].
80 LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
83 DAC960_V2_LogicalDeviceInfo_T *i =
84 p->V2.LogicalDeviceInformation[drive_nr];
85 if (i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
89 check_disk_change(inode->i_bdev);
91 if (!get_capacity(p->disks[drive_nr]))
96 static int DAC960_ioctl(struct inode *inode, struct file *file,
97 unsigned int cmd, unsigned long arg)
99 struct gendisk *disk = inode->i_bdev->bd_disk;
100 DAC960_Controller_T *p = disk->queue->queuedata;
101 int drive_nr = (int)disk->private_data;
102 struct hd_geometry g, *loc = (struct hd_geometry *)arg;
104 if (file && (file->f_flags & O_NONBLOCK))
105 return DAC960_UserIOCTL(inode, file, cmd, arg);
107 if (cmd != HDIO_GETGEO || !loc)
110 if (p->FirmwareType == DAC960_V1_Controller) {
111 g.heads = p->V1.GeometryTranslationHeads;
112 g.sectors = p->V1.GeometryTranslationSectors;
113 g.cylinders = p->V1.LogicalDriveInformation[drive_nr].
114 LogicalDriveSize / (g.heads * g.sectors);
116 DAC960_V2_LogicalDeviceInfo_T *i =
117 p->V2.LogicalDeviceInformation[drive_nr];
118 switch (i->DriveGeometry) {
119 case DAC960_V2_Geometry_128_32:
123 case DAC960_V2_Geometry_255_63:
128 DAC960_Error("Illegal Logical Device Geometry %d\n",
129 p, i->DriveGeometry);
133 g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors);
136 g.start = get_start_sect(inode->i_bdev);
138 return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0;
141 static int DAC960_media_changed(struct gendisk *disk)
143 DAC960_Controller_T *p = disk->queue->queuedata;
144 int drive_nr = (int)disk->private_data;
146 if (!p->LogicalDriveInitiallyAccessible[drive_nr])
151 static int DAC960_revalidate_disk(struct gendisk *disk)
153 DAC960_Controller_T *p = disk->queue->queuedata;
154 int unit = (int)disk->private_data;
156 set_capacity(disk, disk_size(p, unit));
160 static struct block_device_operations DAC960_BlockDeviceOperations = {
161 .owner = THIS_MODULE,
163 .ioctl = DAC960_ioctl,
164 .media_changed = DAC960_media_changed,
165 .revalidate_disk = DAC960_revalidate_disk,
170 DAC960_AnnounceDriver announces the Driver Version and Date, Author's Name,
171 Copyright Notice, and Electronic Mail Address.
174 static void DAC960_AnnounceDriver(DAC960_Controller_T *Controller)
176 DAC960_Announce("***** DAC960 RAID Driver Version "
177 DAC960_DriverVersion " of "
178 DAC960_DriverDate " *****\n", Controller);
179 DAC960_Announce("Copyright 1998-2001 by Leonard N. Zubkoff "
180 "<lnz@dandelion.com>\n", Controller);
185 DAC960_Failure prints a standardized error message, and then returns false.
188 static boolean DAC960_Failure(DAC960_Controller_T *Controller,
189 unsigned char *ErrorMessage)
191 DAC960_Error("While configuring DAC960 PCI RAID Controller at\n",
193 if (Controller->IO_Address == 0)
194 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
195 "PCI Address 0x%X\n", Controller,
196 Controller->Bus, Controller->Device,
197 Controller->Function, Controller->PCI_Address);
198 else DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
199 "0x%X PCI Address 0x%X\n", Controller,
200 Controller->Bus, Controller->Device,
201 Controller->Function, Controller->IO_Address,
202 Controller->PCI_Address);
203 DAC960_Error("%s FAILED - DETACHING\n", Controller, ErrorMessage);
208 init_dma_loaf() and slice_dma_loaf() are helper functions for
209 aggregating the dma-mapped memory for a well-known collection of
210 data structures that are of different lengths.
212 These routines don't guarantee any alignment. The caller must
213 include any space needed for alignment in the sizes of the structures
217 static boolean init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
221 dma_addr_t dma_handle;
223 cpu_addr = pci_alloc_consistent(dev, len, &dma_handle);
224 if (cpu_addr == NULL)
227 loaf->cpu_free = loaf->cpu_base = cpu_addr;
228 loaf->dma_free =loaf->dma_base = dma_handle;
230 memset(cpu_addr, 0, len);
234 static void *slice_dma_loaf(struct dma_loaf *loaf, size_t len,
235 dma_addr_t *dma_handle)
237 void *cpu_end = loaf->cpu_free + len;
238 void *cpu_addr = loaf->cpu_free;
240 if (cpu_end > loaf->cpu_base + loaf->length)
242 *dma_handle = loaf->dma_free;
243 loaf->cpu_free = cpu_end;
244 loaf->dma_free += len;
248 static void free_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf_handle)
250 if (loaf_handle->cpu_base != NULL)
251 pci_free_consistent(dev, loaf_handle->length,
252 loaf_handle->cpu_base, loaf_handle->dma_base);
257 DAC960_CreateAuxiliaryStructures allocates and initializes the auxiliary
258 data structures for Controller. It returns true on success and false on
262 static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
264 int CommandAllocationLength, CommandAllocationGroupSize;
265 int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount;
266 void *AllocationPointer = NULL;
267 void *ScatterGatherCPU = NULL;
268 dma_addr_t ScatterGatherDMA;
269 struct pci_pool *ScatterGatherPool;
270 void *RequestSenseCPU = NULL;
271 dma_addr_t RequestSenseDMA;
272 struct pci_pool *RequestSensePool = NULL;
274 if (Controller->FirmwareType == DAC960_V1_Controller)
276 CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker);
277 CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
278 ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather",
279 Controller->PCIDevice,
280 DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T),
281 sizeof(DAC960_V1_ScatterGatherSegment_T), 0);
282 if (ScatterGatherPool == NULL)
283 return DAC960_Failure(Controller,
284 "AUXILIARY STRUCTURE CREATION (SG)");
285 Controller->ScatterGatherPool = ScatterGatherPool;
289 CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker);
290 CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
291 ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather",
292 Controller->PCIDevice,
293 DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
294 sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
295 RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
296 Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
298 if (ScatterGatherPool == NULL || RequestSensePool == NULL)
299 return DAC960_Failure(Controller,
300 "AUXILIARY STRUCTURE CREATION (SG)");
301 Controller->ScatterGatherPool = ScatterGatherPool;
302 Controller->V2.RequestSensePool = RequestSensePool;
304 Controller->CommandAllocationGroupSize = CommandAllocationGroupSize;
305 Controller->FreeCommands = NULL;
306 for (CommandIdentifier = 1;
307 CommandIdentifier <= Controller->DriverQueueDepth;
310 DAC960_Command_T *Command;
311 if (--CommandsRemaining <= 0)
314 Controller->DriverQueueDepth - CommandIdentifier + 1;
315 if (CommandsRemaining > CommandAllocationGroupSize)
316 CommandsRemaining = CommandAllocationGroupSize;
317 CommandGroupByteCount =
318 CommandsRemaining * CommandAllocationLength;
319 AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC);
320 if (AllocationPointer == NULL)
321 return DAC960_Failure(Controller,
322 "AUXILIARY STRUCTURE CREATION");
323 memset(AllocationPointer, 0, CommandGroupByteCount);
325 Command = (DAC960_Command_T *) AllocationPointer;
326 AllocationPointer += CommandAllocationLength;
327 Command->CommandIdentifier = CommandIdentifier;
328 Command->Controller = Controller;
329 Command->Next = Controller->FreeCommands;
330 Controller->FreeCommands = Command;
331 Controller->Commands[CommandIdentifier-1] = Command;
332 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC,
334 if (ScatterGatherCPU == NULL)
335 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
337 if (RequestSensePool != NULL) {
338 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC,
340 if (RequestSenseCPU == NULL) {
341 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
343 return DAC960_Failure(Controller,
344 "AUXILIARY STRUCTURE CREATION");
347 if (Controller->FirmwareType == DAC960_V1_Controller) {
348 Command->cmd_sglist = Command->V1.ScatterList;
349 Command->V1.ScatterGatherList =
350 (DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU;
351 Command->V1.ScatterGatherListDMA = ScatterGatherDMA;
353 Command->cmd_sglist = Command->V2.ScatterList;
354 Command->V2.ScatterGatherList =
355 (DAC960_V2_ScatterGatherSegment_T *)ScatterGatherCPU;
356 Command->V2.ScatterGatherListDMA = ScatterGatherDMA;
357 Command->V2.RequestSense =
358 (DAC960_SCSI_RequestSense_T *)RequestSenseCPU;
359 Command->V2.RequestSenseDMA = RequestSenseDMA;
367 DAC960_DestroyAuxiliaryStructures deallocates the auxiliary data
368 structures for Controller.
371 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
374 struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
375 struct pci_pool *RequestSensePool = NULL;
376 void *ScatterGatherCPU;
377 dma_addr_t ScatterGatherDMA;
378 void *RequestSenseCPU;
379 dma_addr_t RequestSenseDMA;
380 DAC960_Command_T *CommandGroup = NULL;
383 if (Controller->FirmwareType == DAC960_V2_Controller)
384 RequestSensePool = Controller->V2.RequestSensePool;
386 Controller->FreeCommands = NULL;
387 for (i = 0; i < Controller->DriverQueueDepth; i++)
389 DAC960_Command_T *Command = Controller->Commands[i];
394 if (Controller->FirmwareType == DAC960_V1_Controller) {
395 ScatterGatherCPU = (void *)Command->V1.ScatterGatherList;
396 ScatterGatherDMA = Command->V1.ScatterGatherListDMA;
397 RequestSenseCPU = NULL;
398 RequestSenseDMA = (dma_addr_t)0;
400 ScatterGatherCPU = (void *)Command->V2.ScatterGatherList;
401 ScatterGatherDMA = Command->V2.ScatterGatherListDMA;
402 RequestSenseCPU = (void *)Command->V2.RequestSense;
403 RequestSenseDMA = Command->V2.RequestSenseDMA;
405 if (ScatterGatherCPU != NULL)
406 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA);
407 if (RequestSenseCPU != NULL)
408 pci_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA);
410 if ((Command->CommandIdentifier
411 % Controller->CommandAllocationGroupSize) == 1) {
413 * We can't free the group of commands until all of the
414 * request sense and scatter gather dma structures are free.
415 * Remember the beginning of the group, but don't free it
416 * until we've reached the beginning of the next group.
418 if (CommandGroup != NULL)
420 CommandGroup = Command;
422 Controller->Commands[i] = NULL;
424 if (CommandGroup != NULL)
427 if (Controller->CombinedStatusBuffer != NULL)
429 kfree(Controller->CombinedStatusBuffer);
430 Controller->CombinedStatusBuffer = NULL;
431 Controller->CurrentStatusBuffer = NULL;
434 if (ScatterGatherPool != NULL)
435 pci_pool_destroy(ScatterGatherPool);
436 if (Controller->FirmwareType == DAC960_V1_Controller) return;
438 if (RequestSensePool != NULL)
439 pci_pool_destroy(RequestSensePool);
441 for (i = 0; i < DAC960_MaxLogicalDrives; i++)
442 if (Controller->V2.LogicalDeviceInformation[i] != NULL)
444 kfree(Controller->V2.LogicalDeviceInformation[i]);
445 Controller->V2.LogicalDeviceInformation[i] = NULL;
448 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++)
450 if (Controller->V2.PhysicalDeviceInformation[i] != NULL)
452 kfree(Controller->V2.PhysicalDeviceInformation[i]);
453 Controller->V2.PhysicalDeviceInformation[i] = NULL;
455 if (Controller->V2.InquiryUnitSerialNumber[i] != NULL)
457 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
458 Controller->V2.InquiryUnitSerialNumber[i] = NULL;
465 DAC960_V1_ClearCommand clears critical fields of Command for DAC960 V1
466 Firmware Controllers.
469 static inline void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
471 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
472 memset(CommandMailbox, 0, sizeof(DAC960_V1_CommandMailbox_T));
473 Command->V1.CommandStatus = 0;
478 DAC960_V2_ClearCommand clears critical fields of Command for DAC960 V2
479 Firmware Controllers.
482 static inline void DAC960_V2_ClearCommand(DAC960_Command_T *Command)
484 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
485 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
486 Command->V2.CommandStatus = 0;
491 DAC960_AllocateCommand allocates a Command structure from Controller's
492 free list. During driver initialization, a special initialization command
493 has been placed on the free list to guarantee that command allocation can
497 static inline DAC960_Command_T *DAC960_AllocateCommand(DAC960_Controller_T
500 DAC960_Command_T *Command = Controller->FreeCommands;
501 if (Command == NULL) return NULL;
502 Controller->FreeCommands = Command->Next;
503 Command->Next = NULL;
509 DAC960_DeallocateCommand deallocates Command, returning it to Controller's
513 static inline void DAC960_DeallocateCommand(DAC960_Command_T *Command)
515 DAC960_Controller_T *Controller = Command->Controller;
517 Command->Request = NULL;
518 Command->Next = Controller->FreeCommands;
519 Controller->FreeCommands = Command;
524 DAC960_WaitForCommand waits for a wake_up on Controller's Command Wait Queue.
527 static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
529 spin_unlock_irq(&Controller->queue_lock);
530 __wait_event(Controller->CommandWaitQueue, Controller->FreeCommands);
531 spin_lock_irq(&Controller->queue_lock);
536 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
539 static void DAC960_BA_QueueCommand(DAC960_Command_T *Command)
541 DAC960_Controller_T *Controller = Command->Controller;
542 void *ControllerBaseAddress = Controller->BaseAddress;
543 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
544 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
545 Controller->V2.NextCommandMailbox;
546 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
547 DAC960_BA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
548 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
549 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
550 DAC960_BA_MemoryMailboxNewCommand(ControllerBaseAddress);
551 Controller->V2.PreviousCommandMailbox2 =
552 Controller->V2.PreviousCommandMailbox1;
553 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
554 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
555 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
556 Controller->V2.NextCommandMailbox = NextCommandMailbox;
561 DAC960_LP_QueueCommand queues Command for DAC960 LP Series Controllers.
564 static void DAC960_LP_QueueCommand(DAC960_Command_T *Command)
566 DAC960_Controller_T *Controller = Command->Controller;
567 void *ControllerBaseAddress = Controller->BaseAddress;
568 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
569 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
570 Controller->V2.NextCommandMailbox;
571 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
572 DAC960_LP_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
573 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
574 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
575 DAC960_LP_MemoryMailboxNewCommand(ControllerBaseAddress);
576 Controller->V2.PreviousCommandMailbox2 =
577 Controller->V2.PreviousCommandMailbox1;
578 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
579 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
580 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
581 Controller->V2.NextCommandMailbox = NextCommandMailbox;
586 DAC960_LA_QueueCommandDualMode queues Command for DAC960 LA Series
587 Controllers with Dual Mode Firmware.
590 static void DAC960_LA_QueueCommandDualMode(DAC960_Command_T *Command)
592 DAC960_Controller_T *Controller = Command->Controller;
593 void *ControllerBaseAddress = Controller->BaseAddress;
594 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
595 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
596 Controller->V1.NextCommandMailbox;
597 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
598 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
599 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
600 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
601 DAC960_LA_MemoryMailboxNewCommand(ControllerBaseAddress);
602 Controller->V1.PreviousCommandMailbox2 =
603 Controller->V1.PreviousCommandMailbox1;
604 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
605 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
606 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
607 Controller->V1.NextCommandMailbox = NextCommandMailbox;
612 DAC960_LA_QueueCommandSingleMode queues Command for DAC960 LA Series
613 Controllers with Single Mode Firmware.
616 static void DAC960_LA_QueueCommandSingleMode(DAC960_Command_T *Command)
618 DAC960_Controller_T *Controller = Command->Controller;
619 void *ControllerBaseAddress = Controller->BaseAddress;
620 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
621 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
622 Controller->V1.NextCommandMailbox;
623 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
624 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
625 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
626 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
627 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
628 Controller->V1.PreviousCommandMailbox2 =
629 Controller->V1.PreviousCommandMailbox1;
630 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
631 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
632 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
633 Controller->V1.NextCommandMailbox = NextCommandMailbox;
638 DAC960_PG_QueueCommandDualMode queues Command for DAC960 PG Series
639 Controllers with Dual Mode Firmware.
642 static void DAC960_PG_QueueCommandDualMode(DAC960_Command_T *Command)
644 DAC960_Controller_T *Controller = Command->Controller;
645 void *ControllerBaseAddress = Controller->BaseAddress;
646 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
647 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
648 Controller->V1.NextCommandMailbox;
649 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
650 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
651 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
652 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
653 DAC960_PG_MemoryMailboxNewCommand(ControllerBaseAddress);
654 Controller->V1.PreviousCommandMailbox2 =
655 Controller->V1.PreviousCommandMailbox1;
656 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
657 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
658 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
659 Controller->V1.NextCommandMailbox = NextCommandMailbox;
664 DAC960_PG_QueueCommandSingleMode queues Command for DAC960 PG Series
665 Controllers with Single Mode Firmware.
668 static void DAC960_PG_QueueCommandSingleMode(DAC960_Command_T *Command)
670 DAC960_Controller_T *Controller = Command->Controller;
671 void *ControllerBaseAddress = Controller->BaseAddress;
672 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
673 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
674 Controller->V1.NextCommandMailbox;
675 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
676 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
677 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
678 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
679 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
680 Controller->V1.PreviousCommandMailbox2 =
681 Controller->V1.PreviousCommandMailbox1;
682 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
683 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
684 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
685 Controller->V1.NextCommandMailbox = NextCommandMailbox;
690 DAC960_PD_QueueCommand queues Command for DAC960 PD Series Controllers.
693 static void DAC960_PD_QueueCommand(DAC960_Command_T *Command)
695 DAC960_Controller_T *Controller = Command->Controller;
696 void *ControllerBaseAddress = Controller->BaseAddress;
697 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
698 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
699 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
701 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
702 DAC960_PD_NewCommand(ControllerBaseAddress);
707 DAC960_P_QueueCommand queues Command for DAC960 P Series Controllers.
710 static void DAC960_P_QueueCommand(DAC960_Command_T *Command)
712 DAC960_Controller_T *Controller = Command->Controller;
713 void *ControllerBaseAddress = Controller->BaseAddress;
714 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
715 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
716 switch (CommandMailbox->Common.CommandOpcode)
718 case DAC960_V1_Enquiry:
719 CommandMailbox->Common.CommandOpcode = DAC960_V1_Enquiry_Old;
721 case DAC960_V1_GetDeviceState:
722 CommandMailbox->Common.CommandOpcode = DAC960_V1_GetDeviceState_Old;
725 CommandMailbox->Common.CommandOpcode = DAC960_V1_Read_Old;
726 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
728 case DAC960_V1_Write:
729 CommandMailbox->Common.CommandOpcode = DAC960_V1_Write_Old;
730 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
732 case DAC960_V1_ReadWithScatterGather:
733 CommandMailbox->Common.CommandOpcode =
734 DAC960_V1_ReadWithScatterGather_Old;
735 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
737 case DAC960_V1_WriteWithScatterGather:
738 CommandMailbox->Common.CommandOpcode =
739 DAC960_V1_WriteWithScatterGather_Old;
740 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
745 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
747 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
748 DAC960_PD_NewCommand(ControllerBaseAddress);
753 DAC960_ExecuteCommand executes Command and waits for completion.
756 static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
758 DAC960_Controller_T *Controller = Command->Controller;
759 DECLARE_COMPLETION(Completion);
761 Command->Completion = &Completion;
763 spin_lock_irqsave(&Controller->queue_lock, flags);
764 DAC960_QueueCommand(Command);
765 spin_unlock_irqrestore(&Controller->queue_lock, flags);
769 wait_for_completion(&Completion);
774 DAC960_V1_ExecuteType3 executes a DAC960 V1 Firmware Controller Type 3
775 Command and waits for completion. It returns true on success and false
779 static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
780 DAC960_V1_CommandOpcode_T CommandOpcode,
783 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
784 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
785 DAC960_V1_CommandStatus_T CommandStatus;
786 DAC960_V1_ClearCommand(Command);
787 Command->CommandType = DAC960_ImmediateCommand;
788 CommandMailbox->Type3.CommandOpcode = CommandOpcode;
789 CommandMailbox->Type3.BusAddress = DataDMA;
790 DAC960_ExecuteCommand(Command);
791 CommandStatus = Command->V1.CommandStatus;
792 DAC960_DeallocateCommand(Command);
793 return (CommandStatus == DAC960_V1_NormalCompletion);
798 DAC960_V1_ExecuteTypeB executes a DAC960 V1 Firmware Controller Type 3B
799 Command and waits for completion. It returns true on success and false
803 static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
804 DAC960_V1_CommandOpcode_T CommandOpcode,
805 unsigned char CommandOpcode2,
808 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
809 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
810 DAC960_V1_CommandStatus_T CommandStatus;
811 DAC960_V1_ClearCommand(Command);
812 Command->CommandType = DAC960_ImmediateCommand;
813 CommandMailbox->Type3B.CommandOpcode = CommandOpcode;
814 CommandMailbox->Type3B.CommandOpcode2 = CommandOpcode2;
815 CommandMailbox->Type3B.BusAddress = DataDMA;
816 DAC960_ExecuteCommand(Command);
817 CommandStatus = Command->V1.CommandStatus;
818 DAC960_DeallocateCommand(Command);
819 return (CommandStatus == DAC960_V1_NormalCompletion);
824 DAC960_V1_ExecuteType3D executes a DAC960 V1 Firmware Controller Type 3D
825 Command and waits for completion. It returns true on success and false
829 static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
830 DAC960_V1_CommandOpcode_T CommandOpcode,
831 unsigned char Channel,
832 unsigned char TargetID,
835 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
836 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
837 DAC960_V1_CommandStatus_T CommandStatus;
838 DAC960_V1_ClearCommand(Command);
839 Command->CommandType = DAC960_ImmediateCommand;
840 CommandMailbox->Type3D.CommandOpcode = CommandOpcode;
841 CommandMailbox->Type3D.Channel = Channel;
842 CommandMailbox->Type3D.TargetID = TargetID;
843 CommandMailbox->Type3D.BusAddress = DataDMA;
844 DAC960_ExecuteCommand(Command);
845 CommandStatus = Command->V1.CommandStatus;
846 DAC960_DeallocateCommand(Command);
847 return (CommandStatus == DAC960_V1_NormalCompletion);
852 DAC960_V2_GeneralInfo executes a DAC960 V2 Firmware General Information
853 Reading IOCTL Command and waits for completion. It returns true on success
854 and false on failure.
856 Return data in The controller's HealthStatusBuffer, which is dma-able memory
859 static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
861 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
862 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
863 DAC960_V2_CommandStatus_T CommandStatus;
864 DAC960_V2_ClearCommand(Command);
865 Command->CommandType = DAC960_ImmediateCommand;
866 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
867 CommandMailbox->Common.CommandControlBits
868 .DataTransferControllerToHost = true;
869 CommandMailbox->Common.CommandControlBits
870 .NoAutoRequestSense = true;
871 CommandMailbox->Common.DataTransferSize = sizeof(DAC960_V2_HealthStatusBuffer_T);
872 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_GetHealthStatus;
873 CommandMailbox->Common.DataTransferMemoryAddress
874 .ScatterGatherSegments[0]
875 .SegmentDataPointer =
876 Controller->V2.HealthStatusBufferDMA;
877 CommandMailbox->Common.DataTransferMemoryAddress
878 .ScatterGatherSegments[0]
880 CommandMailbox->Common.DataTransferSize;
881 DAC960_ExecuteCommand(Command);
882 CommandStatus = Command->V2.CommandStatus;
883 DAC960_DeallocateCommand(Command);
884 return (CommandStatus == DAC960_V2_NormalCompletion);
889 DAC960_V2_ControllerInfo executes a DAC960 V2 Firmware Controller
890 Information Reading IOCTL Command and waits for completion. It returns
891 true on success and false on failure.
893 Data is returned in the controller's V2.NewControllerInformation dma-able
897 static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
899 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
900 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
901 DAC960_V2_CommandStatus_T CommandStatus;
902 DAC960_V2_ClearCommand(Command);
903 Command->CommandType = DAC960_ImmediateCommand;
904 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
905 CommandMailbox->ControllerInfo.CommandControlBits
906 .DataTransferControllerToHost = true;
907 CommandMailbox->ControllerInfo.CommandControlBits
908 .NoAutoRequestSense = true;
909 CommandMailbox->ControllerInfo.DataTransferSize = sizeof(DAC960_V2_ControllerInfo_T);
910 CommandMailbox->ControllerInfo.ControllerNumber = 0;
911 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
912 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
913 .ScatterGatherSegments[0]
914 .SegmentDataPointer =
915 Controller->V2.NewControllerInformationDMA;
916 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
917 .ScatterGatherSegments[0]
919 CommandMailbox->ControllerInfo.DataTransferSize;
920 DAC960_ExecuteCommand(Command);
921 CommandStatus = Command->V2.CommandStatus;
922 DAC960_DeallocateCommand(Command);
923 return (CommandStatus == DAC960_V2_NormalCompletion);
928 DAC960_V2_LogicalDeviceInfo executes a DAC960 V2 Firmware Controller Logical
929 Device Information Reading IOCTL Command and waits for completion. It
930 returns true on success and false on failure.
932 Data is returned in the controller's V2.NewLogicalDeviceInformation
935 static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
936 unsigned short LogicalDeviceNumber)
938 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
939 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
940 DAC960_V2_CommandStatus_T CommandStatus;
942 DAC960_V2_ClearCommand(Command);
943 Command->CommandType = DAC960_ImmediateCommand;
944 CommandMailbox->LogicalDeviceInfo.CommandOpcode =
946 CommandMailbox->LogicalDeviceInfo.CommandControlBits
947 .DataTransferControllerToHost = true;
948 CommandMailbox->LogicalDeviceInfo.CommandControlBits
949 .NoAutoRequestSense = true;
950 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
951 sizeof(DAC960_V2_LogicalDeviceInfo_T);
952 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
954 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode = DAC960_V2_GetLogicalDeviceInfoValid;
955 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
956 .ScatterGatherSegments[0]
957 .SegmentDataPointer =
958 Controller->V2.NewLogicalDeviceInformationDMA;
959 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
960 .ScatterGatherSegments[0]
962 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
963 DAC960_ExecuteCommand(Command);
964 CommandStatus = Command->V2.CommandStatus;
965 DAC960_DeallocateCommand(Command);
966 return (CommandStatus == DAC960_V2_NormalCompletion);
971 DAC960_V2_PhysicalDeviceInfo executes a DAC960 V2 Firmware Controller "Read
972 Physical Device Information" IOCTL Command and waits for completion. It
973 returns true on success and false on failure.
975 The Channel, TargetID, LogicalUnit arguments should be 0 the first time
976 this function is called for a given controller. This will return data
977 for the "first" device on that controller. The returned data includes a
978 Channel, TargetID, LogicalUnit that can be passed in to this routine to
979 get data for the NEXT device on that controller.
981 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
986 static boolean DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
987 unsigned char Channel,
988 unsigned char TargetID,
989 unsigned char LogicalUnit)
991 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
992 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
993 DAC960_V2_CommandStatus_T CommandStatus;
995 DAC960_V2_ClearCommand(Command);
996 Command->CommandType = DAC960_ImmediateCommand;
997 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
998 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
999 .DataTransferControllerToHost = true;
1000 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
1001 .NoAutoRequestSense = true;
1002 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
1003 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
1004 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit = LogicalUnit;
1005 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
1006 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
1007 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
1008 DAC960_V2_GetPhysicalDeviceInfoValid;
1009 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1010 .ScatterGatherSegments[0]
1011 .SegmentDataPointer =
1012 Controller->V2.NewPhysicalDeviceInformationDMA;
1013 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1014 .ScatterGatherSegments[0]
1016 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
1017 DAC960_ExecuteCommand(Command);
1018 CommandStatus = Command->V2.CommandStatus;
1019 DAC960_DeallocateCommand(Command);
1020 return (CommandStatus == DAC960_V2_NormalCompletion);
1024 static void DAC960_V2_ConstructNewUnitSerialNumber(
1025 DAC960_Controller_T *Controller,
1026 DAC960_V2_CommandMailbox_T *CommandMailbox, int Channel, int TargetID,
1029 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10_Passthru;
1030 CommandMailbox->SCSI_10.CommandControlBits
1031 .DataTransferControllerToHost = true;
1032 CommandMailbox->SCSI_10.CommandControlBits
1033 .NoAutoRequestSense = true;
1034 CommandMailbox->SCSI_10.DataTransferSize =
1035 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1036 CommandMailbox->SCSI_10.PhysicalDevice.LogicalUnit = LogicalUnit;
1037 CommandMailbox->SCSI_10.PhysicalDevice.TargetID = TargetID;
1038 CommandMailbox->SCSI_10.PhysicalDevice.Channel = Channel;
1039 CommandMailbox->SCSI_10.CDBLength = 6;
1040 CommandMailbox->SCSI_10.SCSI_CDB[0] = 0x12; /* INQUIRY */
1041 CommandMailbox->SCSI_10.SCSI_CDB[1] = 1; /* EVPD = 1 */
1042 CommandMailbox->SCSI_10.SCSI_CDB[2] = 0x80; /* Page Code */
1043 CommandMailbox->SCSI_10.SCSI_CDB[3] = 0; /* Reserved */
1044 CommandMailbox->SCSI_10.SCSI_CDB[4] =
1045 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1046 CommandMailbox->SCSI_10.SCSI_CDB[5] = 0; /* Control */
1047 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1048 .ScatterGatherSegments[0]
1049 .SegmentDataPointer =
1050 Controller->V2.NewInquiryUnitSerialNumberDMA;
1051 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1052 .ScatterGatherSegments[0]
1054 CommandMailbox->SCSI_10.DataTransferSize;
1059 DAC960_V2_NewUnitSerialNumber executes an SCSI pass-through
1060 Inquiry command to a SCSI device identified by Channel number,
1061 Target id, Logical Unit Number. This function Waits for completion
1064 The return data includes Unit Serial Number information for the
1067 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
1071 static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
1072 int Channel, int TargetID, int LogicalUnit)
1074 DAC960_Command_T *Command;
1075 DAC960_V2_CommandMailbox_T *CommandMailbox;
1076 DAC960_V2_CommandStatus_T CommandStatus;
1078 Command = DAC960_AllocateCommand(Controller);
1079 CommandMailbox = &Command->V2.CommandMailbox;
1080 DAC960_V2_ClearCommand(Command);
1081 Command->CommandType = DAC960_ImmediateCommand;
1083 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
1084 Channel, TargetID, LogicalUnit);
1086 DAC960_ExecuteCommand(Command);
1087 CommandStatus = Command->V2.CommandStatus;
1088 DAC960_DeallocateCommand(Command);
1089 return (CommandStatus == DAC960_V2_NormalCompletion);
1094 DAC960_V2_DeviceOperation executes a DAC960 V2 Firmware Controller Device
1095 Operation IOCTL Command and waits for completion. It returns true on
1096 success and false on failure.
1099 static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1100 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
1101 DAC960_V2_OperationDevice_T
1104 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
1105 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
1106 DAC960_V2_CommandStatus_T CommandStatus;
1107 DAC960_V2_ClearCommand(Command);
1108 Command->CommandType = DAC960_ImmediateCommand;
1109 CommandMailbox->DeviceOperation.CommandOpcode = DAC960_V2_IOCTL;
1110 CommandMailbox->DeviceOperation.CommandControlBits
1111 .DataTransferControllerToHost = true;
1112 CommandMailbox->DeviceOperation.CommandControlBits
1113 .NoAutoRequestSense = true;
1114 CommandMailbox->DeviceOperation.IOCTL_Opcode = IOCTL_Opcode;
1115 CommandMailbox->DeviceOperation.OperationDevice = OperationDevice;
1116 DAC960_ExecuteCommand(Command);
1117 CommandStatus = Command->V2.CommandStatus;
1118 DAC960_DeallocateCommand(Command);
1119 return (CommandStatus == DAC960_V2_NormalCompletion);
1124 DAC960_V1_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1125 for DAC960 V1 Firmware Controllers.
1127 PD and P controller types have no memory mailbox, but still need the
1128 other dma mapped memory.
1131 static boolean DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1134 void *ControllerBaseAddress = Controller->BaseAddress;
1135 DAC960_HardwareType_T hw_type = Controller->HardwareType;
1136 struct pci_dev *PCI_Device = Controller->PCIDevice;
1137 struct dma_loaf *DmaPages = &Controller->DmaPages;
1138 size_t DmaPagesSize;
1139 size_t CommandMailboxesSize;
1140 size_t StatusMailboxesSize;
1142 DAC960_V1_CommandMailbox_T *CommandMailboxesMemory;
1143 dma_addr_t CommandMailboxesMemoryDMA;
1145 DAC960_V1_StatusMailbox_T *StatusMailboxesMemory;
1146 dma_addr_t StatusMailboxesMemoryDMA;
1148 DAC960_V1_CommandMailbox_T CommandMailbox;
1149 DAC960_V1_CommandStatus_T CommandStatus;
1154 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V1_PciDmaMask))
1155 return DAC960_Failure(Controller, "DMA mask out of range");
1156 Controller->BounceBufferLimit = DAC690_V1_PciDmaMask;
1158 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller)) {
1159 CommandMailboxesSize = 0;
1160 StatusMailboxesSize = 0;
1162 CommandMailboxesSize = DAC960_V1_CommandMailboxCount * sizeof(DAC960_V1_CommandMailbox_T);
1163 StatusMailboxesSize = DAC960_V1_StatusMailboxCount * sizeof(DAC960_V1_StatusMailbox_T);
1165 DmaPagesSize = CommandMailboxesSize + StatusMailboxesSize +
1166 sizeof(DAC960_V1_DCDB_T) + sizeof(DAC960_V1_Enquiry_T) +
1167 sizeof(DAC960_V1_ErrorTable_T) + sizeof(DAC960_V1_EventLogEntry_T) +
1168 sizeof(DAC960_V1_RebuildProgress_T) +
1169 sizeof(DAC960_V1_LogicalDriveInformationArray_T) +
1170 sizeof(DAC960_V1_BackgroundInitializationStatus_T) +
1171 sizeof(DAC960_V1_DeviceState_T) + sizeof(DAC960_SCSI_Inquiry_T) +
1172 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1174 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize))
1178 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1179 goto skip_mailboxes;
1181 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1182 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1184 /* These are the base addresses for the command memory mailbox array */
1185 Controller->V1.FirstCommandMailbox = CommandMailboxesMemory;
1186 Controller->V1.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1188 CommandMailboxesMemory += DAC960_V1_CommandMailboxCount - 1;
1189 Controller->V1.LastCommandMailbox = CommandMailboxesMemory;
1190 Controller->V1.NextCommandMailbox = Controller->V1.FirstCommandMailbox;
1191 Controller->V1.PreviousCommandMailbox1 = Controller->V1.LastCommandMailbox;
1192 Controller->V1.PreviousCommandMailbox2 =
1193 Controller->V1.LastCommandMailbox - 1;
1195 /* These are the base addresses for the status memory mailbox array */
1196 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1197 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1199 Controller->V1.FirstStatusMailbox = StatusMailboxesMemory;
1200 Controller->V1.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1201 StatusMailboxesMemory += DAC960_V1_StatusMailboxCount - 1;
1202 Controller->V1.LastStatusMailbox = StatusMailboxesMemory;
1203 Controller->V1.NextStatusMailbox = Controller->V1.FirstStatusMailbox;
1206 Controller->V1.MonitoringDCDB = slice_dma_loaf(DmaPages,
1207 sizeof(DAC960_V1_DCDB_T),
1208 &Controller->V1.MonitoringDCDB_DMA);
1210 Controller->V1.NewEnquiry = slice_dma_loaf(DmaPages,
1211 sizeof(DAC960_V1_Enquiry_T),
1212 &Controller->V1.NewEnquiryDMA);
1214 Controller->V1.NewErrorTable = slice_dma_loaf(DmaPages,
1215 sizeof(DAC960_V1_ErrorTable_T),
1216 &Controller->V1.NewErrorTableDMA);
1218 Controller->V1.EventLogEntry = slice_dma_loaf(DmaPages,
1219 sizeof(DAC960_V1_EventLogEntry_T),
1220 &Controller->V1.EventLogEntryDMA);
1222 Controller->V1.RebuildProgress = slice_dma_loaf(DmaPages,
1223 sizeof(DAC960_V1_RebuildProgress_T),
1224 &Controller->V1.RebuildProgressDMA);
1226 Controller->V1.NewLogicalDriveInformation = slice_dma_loaf(DmaPages,
1227 sizeof(DAC960_V1_LogicalDriveInformationArray_T),
1228 &Controller->V1.NewLogicalDriveInformationDMA);
1230 Controller->V1.BackgroundInitializationStatus = slice_dma_loaf(DmaPages,
1231 sizeof(DAC960_V1_BackgroundInitializationStatus_T),
1232 &Controller->V1.BackgroundInitializationStatusDMA);
1234 Controller->V1.NewDeviceState = slice_dma_loaf(DmaPages,
1235 sizeof(DAC960_V1_DeviceState_T),
1236 &Controller->V1.NewDeviceStateDMA);
1238 Controller->V1.NewInquiryStandardData = slice_dma_loaf(DmaPages,
1239 sizeof(DAC960_SCSI_Inquiry_T),
1240 &Controller->V1.NewInquiryStandardDataDMA);
1242 Controller->V1.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1243 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1244 &Controller->V1.NewInquiryUnitSerialNumberDMA);
1246 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1249 /* Enable the Memory Mailbox Interface. */
1250 Controller->V1.DualModeMemoryMailboxInterface = true;
1251 CommandMailbox.TypeX.CommandOpcode = 0x2B;
1252 CommandMailbox.TypeX.CommandIdentifier = 0;
1253 CommandMailbox.TypeX.CommandOpcode2 = 0x14;
1254 CommandMailbox.TypeX.CommandMailboxesBusAddress =
1255 Controller->V1.FirstCommandMailboxDMA;
1256 CommandMailbox.TypeX.StatusMailboxesBusAddress =
1257 Controller->V1.FirstStatusMailboxDMA;
1258 #define TIMEOUT_COUNT 1000000
1260 for (i = 0; i < 2; i++)
1261 switch (Controller->HardwareType)
1263 case DAC960_LA_Controller:
1264 TimeoutCounter = TIMEOUT_COUNT;
1265 while (--TimeoutCounter >= 0)
1267 if (!DAC960_LA_HardwareMailboxFullP(ControllerBaseAddress))
1271 if (TimeoutCounter < 0) return false;
1272 DAC960_LA_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1273 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
1274 TimeoutCounter = TIMEOUT_COUNT;
1275 while (--TimeoutCounter >= 0)
1277 if (DAC960_LA_HardwareMailboxStatusAvailableP(
1278 ControllerBaseAddress))
1282 if (TimeoutCounter < 0) return false;
1283 CommandStatus = DAC960_LA_ReadStatusRegister(ControllerBaseAddress);
1284 DAC960_LA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1285 DAC960_LA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1286 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1287 Controller->V1.DualModeMemoryMailboxInterface = false;
1288 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1290 case DAC960_PG_Controller:
1291 TimeoutCounter = TIMEOUT_COUNT;
1292 while (--TimeoutCounter >= 0)
1294 if (!DAC960_PG_HardwareMailboxFullP(ControllerBaseAddress))
1298 if (TimeoutCounter < 0) return false;
1299 DAC960_PG_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1300 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
1302 TimeoutCounter = TIMEOUT_COUNT;
1303 while (--TimeoutCounter >= 0)
1305 if (DAC960_PG_HardwareMailboxStatusAvailableP(
1306 ControllerBaseAddress))
1310 if (TimeoutCounter < 0) return false;
1311 CommandStatus = DAC960_PG_ReadStatusRegister(ControllerBaseAddress);
1312 DAC960_PG_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1313 DAC960_PG_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1314 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1315 Controller->V1.DualModeMemoryMailboxInterface = false;
1316 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1319 DAC960_Failure(Controller, "Unknown Controller Type\n");
1327 DAC960_V2_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1328 for DAC960 V2 Firmware Controllers.
1330 Aggregate the space needed for the controller's memory mailbox and
1331 the other data structures that will be targets of dma transfers with
1332 the controller. Allocate a dma-mapped region of memory to hold these
1333 structures. Then, save CPU pointers and dma_addr_t values to reference
1334 the structures that are contained in that region.
1337 static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1340 void *ControllerBaseAddress = Controller->BaseAddress;
1341 struct pci_dev *PCI_Device = Controller->PCIDevice;
1342 struct dma_loaf *DmaPages = &Controller->DmaPages;
1343 size_t DmaPagesSize;
1344 size_t CommandMailboxesSize;
1345 size_t StatusMailboxesSize;
1347 DAC960_V2_CommandMailbox_T *CommandMailboxesMemory;
1348 dma_addr_t CommandMailboxesMemoryDMA;
1350 DAC960_V2_StatusMailbox_T *StatusMailboxesMemory;
1351 dma_addr_t StatusMailboxesMemoryDMA;
1353 DAC960_V2_CommandMailbox_T *CommandMailbox;
1354 dma_addr_t CommandMailboxDMA;
1355 DAC960_V2_CommandStatus_T CommandStatus;
1357 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V2_PciDmaMask))
1358 return DAC960_Failure(Controller, "DMA mask out of range");
1359 Controller->BounceBufferLimit = DAC690_V2_PciDmaMask;
1361 /* This is a temporary dma mapping, used only in the scope of this function */
1363 (DAC960_V2_CommandMailbox_T *)pci_alloc_consistent( PCI_Device,
1364 sizeof(DAC960_V2_CommandMailbox_T), &CommandMailboxDMA);
1365 if (CommandMailbox == NULL)
1368 CommandMailboxesSize = DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T);
1369 StatusMailboxesSize = DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T);
1371 CommandMailboxesSize + StatusMailboxesSize +
1372 sizeof(DAC960_V2_HealthStatusBuffer_T) +
1373 sizeof(DAC960_V2_ControllerInfo_T) +
1374 sizeof(DAC960_V2_LogicalDeviceInfo_T) +
1375 sizeof(DAC960_V2_PhysicalDeviceInfo_T) +
1376 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T) +
1377 sizeof(DAC960_V2_Event_T) +
1378 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
1380 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize)) {
1381 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1382 CommandMailbox, CommandMailboxDMA);
1386 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1387 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1389 /* These are the base addresses for the command memory mailbox array */
1390 Controller->V2.FirstCommandMailbox = CommandMailboxesMemory;
1391 Controller->V2.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1393 CommandMailboxesMemory += DAC960_V2_CommandMailboxCount - 1;
1394 Controller->V2.LastCommandMailbox = CommandMailboxesMemory;
1395 Controller->V2.NextCommandMailbox = Controller->V2.FirstCommandMailbox;
1396 Controller->V2.PreviousCommandMailbox1 = Controller->V2.LastCommandMailbox;
1397 Controller->V2.PreviousCommandMailbox2 =
1398 Controller->V2.LastCommandMailbox - 1;
1400 /* These are the base addresses for the status memory mailbox array */
1401 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1402 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1404 Controller->V2.FirstStatusMailbox = StatusMailboxesMemory;
1405 Controller->V2.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1406 StatusMailboxesMemory += DAC960_V2_StatusMailboxCount - 1;
1407 Controller->V2.LastStatusMailbox = StatusMailboxesMemory;
1408 Controller->V2.NextStatusMailbox = Controller->V2.FirstStatusMailbox;
1410 Controller->V2.HealthStatusBuffer = slice_dma_loaf(DmaPages,
1411 sizeof(DAC960_V2_HealthStatusBuffer_T),
1412 &Controller->V2.HealthStatusBufferDMA);
1414 Controller->V2.NewControllerInformation = slice_dma_loaf(DmaPages,
1415 sizeof(DAC960_V2_ControllerInfo_T),
1416 &Controller->V2.NewControllerInformationDMA);
1418 Controller->V2.NewLogicalDeviceInformation = slice_dma_loaf(DmaPages,
1419 sizeof(DAC960_V2_LogicalDeviceInfo_T),
1420 &Controller->V2.NewLogicalDeviceInformationDMA);
1422 Controller->V2.NewPhysicalDeviceInformation = slice_dma_loaf(DmaPages,
1423 sizeof(DAC960_V2_PhysicalDeviceInfo_T),
1424 &Controller->V2.NewPhysicalDeviceInformationDMA);
1426 Controller->V2.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1427 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1428 &Controller->V2.NewInquiryUnitSerialNumberDMA);
1430 Controller->V2.Event = slice_dma_loaf(DmaPages,
1431 sizeof(DAC960_V2_Event_T),
1432 &Controller->V2.EventDMA);
1434 Controller->V2.PhysicalToLogicalDevice = slice_dma_loaf(DmaPages,
1435 sizeof(DAC960_V2_PhysicalToLogicalDevice_T),
1436 &Controller->V2.PhysicalToLogicalDeviceDMA);
1439 Enable the Memory Mailbox Interface.
1441 I don't know why we can't just use one of the memory mailboxes
1442 we just allocated to do this, instead of using this temporary one.
1443 Try this change later.
1445 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
1446 CommandMailbox->SetMemoryMailbox.CommandIdentifier = 1;
1447 CommandMailbox->SetMemoryMailbox.CommandOpcode = DAC960_V2_IOCTL;
1448 CommandMailbox->SetMemoryMailbox.CommandControlBits.NoAutoRequestSense = true;
1449 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxSizeKB =
1450 (DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T)) >> 10;
1451 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxSizeKB =
1452 (DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T)) >> 10;
1453 CommandMailbox->SetMemoryMailbox.SecondCommandMailboxSizeKB = 0;
1454 CommandMailbox->SetMemoryMailbox.SecondStatusMailboxSizeKB = 0;
1455 CommandMailbox->SetMemoryMailbox.RequestSenseSize = 0;
1456 CommandMailbox->SetMemoryMailbox.IOCTL_Opcode = DAC960_V2_SetMemoryMailbox;
1457 CommandMailbox->SetMemoryMailbox.HealthStatusBufferSizeKB = 1;
1458 CommandMailbox->SetMemoryMailbox.HealthStatusBufferBusAddress =
1459 Controller->V2.HealthStatusBufferDMA;
1460 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxBusAddress =
1461 Controller->V2.FirstCommandMailboxDMA;
1462 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxBusAddress =
1463 Controller->V2.FirstStatusMailboxDMA;
1464 switch (Controller->HardwareType)
1466 case DAC960_BA_Controller:
1467 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1469 DAC960_BA_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1470 DAC960_BA_HardwareMailboxNewCommand(ControllerBaseAddress);
1471 while (!DAC960_BA_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1473 CommandStatus = DAC960_BA_ReadCommandStatus(ControllerBaseAddress);
1474 DAC960_BA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1475 DAC960_BA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1477 case DAC960_LP_Controller:
1478 while (DAC960_LP_HardwareMailboxFullP(ControllerBaseAddress))
1480 DAC960_LP_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1481 DAC960_LP_HardwareMailboxNewCommand(ControllerBaseAddress);
1482 while (!DAC960_LP_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1484 CommandStatus = DAC960_LP_ReadCommandStatus(ControllerBaseAddress);
1485 DAC960_LP_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1486 DAC960_LP_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1489 DAC960_Failure(Controller, "Unknown Controller Type\n");
1490 CommandStatus = DAC960_V2_AbormalCompletion;
1493 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1494 CommandMailbox, CommandMailboxDMA);
1495 return (CommandStatus == DAC960_V2_NormalCompletion);
1500 DAC960_V1_ReadControllerConfiguration reads the Configuration Information
1501 from DAC960 V1 Firmware Controllers and initializes the Controller structure.
1504 static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1507 DAC960_V1_Enquiry2_T *Enquiry2;
1508 dma_addr_t Enquiry2DMA;
1509 DAC960_V1_Config2_T *Config2;
1510 dma_addr_t Config2DMA;
1511 int LogicalDriveNumber, Channel, TargetID;
1512 struct dma_loaf local_dma;
1514 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1515 sizeof(DAC960_V1_Enquiry2_T) + sizeof(DAC960_V1_Config2_T)))
1516 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1518 Enquiry2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Enquiry2_T), &Enquiry2DMA);
1519 Config2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Config2_T), &Config2DMA);
1521 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry,
1522 Controller->V1.NewEnquiryDMA)) {
1523 free_dma_loaf(Controller->PCIDevice, &local_dma);
1524 return DAC960_Failure(Controller, "ENQUIRY");
1526 memcpy(&Controller->V1.Enquiry, Controller->V1.NewEnquiry,
1527 sizeof(DAC960_V1_Enquiry_T));
1529 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry2, Enquiry2DMA)) {
1530 free_dma_loaf(Controller->PCIDevice, &local_dma);
1531 return DAC960_Failure(Controller, "ENQUIRY2");
1534 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_ReadConfig2, Config2DMA)) {
1535 free_dma_loaf(Controller->PCIDevice, &local_dma);
1536 return DAC960_Failure(Controller, "READ CONFIG2");
1539 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_GetLogicalDriveInformation,
1540 Controller->V1.NewLogicalDriveInformationDMA)) {
1541 free_dma_loaf(Controller->PCIDevice, &local_dma);
1542 return DAC960_Failure(Controller, "GET LOGICAL DRIVE INFORMATION");
1544 memcpy(&Controller->V1.LogicalDriveInformation,
1545 Controller->V1.NewLogicalDriveInformation,
1546 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
1548 for (Channel = 0; Channel < Enquiry2->ActualChannels; Channel++)
1549 for (TargetID = 0; TargetID < Enquiry2->MaxTargets; TargetID++) {
1550 if (!DAC960_V1_ExecuteType3D(Controller, DAC960_V1_GetDeviceState,
1552 Controller->V1.NewDeviceStateDMA)) {
1553 free_dma_loaf(Controller->PCIDevice, &local_dma);
1554 return DAC960_Failure(Controller, "GET DEVICE STATE");
1556 memcpy(&Controller->V1.DeviceState[Channel][TargetID],
1557 Controller->V1.NewDeviceState, sizeof(DAC960_V1_DeviceState_T));
1560 Initialize the Controller Model Name and Full Model Name fields.
1562 switch (Enquiry2->HardwareID.SubModel)
1564 case DAC960_V1_P_PD_PU:
1565 if (Enquiry2->SCSICapability.BusSpeed == DAC960_V1_Ultra)
1566 strcpy(Controller->ModelName, "DAC960PU");
1567 else strcpy(Controller->ModelName, "DAC960PD");
1570 strcpy(Controller->ModelName, "DAC960PL");
1573 strcpy(Controller->ModelName, "DAC960PG");
1576 strcpy(Controller->ModelName, "DAC960PJ");
1579 strcpy(Controller->ModelName, "DAC960PR");
1582 strcpy(Controller->ModelName, "DAC960PT");
1584 case DAC960_V1_PTL0:
1585 strcpy(Controller->ModelName, "DAC960PTL0");
1588 strcpy(Controller->ModelName, "DAC960PRL");
1590 case DAC960_V1_PTL1:
1591 strcpy(Controller->ModelName, "DAC960PTL1");
1593 case DAC960_V1_1164P:
1594 strcpy(Controller->ModelName, "DAC1164P");
1597 free_dma_loaf(Controller->PCIDevice, &local_dma);
1598 return DAC960_Failure(Controller, "MODEL VERIFICATION");
1600 strcpy(Controller->FullModelName, "Mylex ");
1601 strcat(Controller->FullModelName, Controller->ModelName);
1603 Initialize the Controller Firmware Version field and verify that it
1604 is a supported firmware version. The supported firmware versions are:
1606 DAC1164P 5.06 and above
1607 DAC960PTL/PRL/PJ/PG 4.06 and above
1608 DAC960PU/PD/PL 3.51 and above
1609 DAC960PU/PD/PL/P 2.73 and above
1611 if (Enquiry2->FirmwareID.MajorVersion == 0)
1613 Enquiry2->FirmwareID.MajorVersion =
1614 Controller->V1.Enquiry.MajorFirmwareVersion;
1615 Enquiry2->FirmwareID.MinorVersion =
1616 Controller->V1.Enquiry.MinorFirmwareVersion;
1617 Enquiry2->FirmwareID.FirmwareType = '0';
1618 Enquiry2->FirmwareID.TurnID = 0;
1620 sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d",
1621 Enquiry2->FirmwareID.MajorVersion, Enquiry2->FirmwareID.MinorVersion,
1622 Enquiry2->FirmwareID.FirmwareType, Enquiry2->FirmwareID.TurnID);
1623 if (!((Controller->FirmwareVersion[0] == '5' &&
1624 strcmp(Controller->FirmwareVersion, "5.06") >= 0) ||
1625 (Controller->FirmwareVersion[0] == '4' &&
1626 strcmp(Controller->FirmwareVersion, "4.06") >= 0) ||
1627 (Controller->FirmwareVersion[0] == '3' &&
1628 strcmp(Controller->FirmwareVersion, "3.51") >= 0) ||
1629 (Controller->FirmwareVersion[0] == '2' &&
1630 strcmp(Controller->FirmwareVersion, "2.73") >= 0)))
1632 DAC960_Failure(Controller, "FIRMWARE VERSION VERIFICATION");
1633 DAC960_Error("Firmware Version = '%s'\n", Controller,
1634 Controller->FirmwareVersion);
1635 free_dma_loaf(Controller->PCIDevice, &local_dma);
1639 Initialize the Controller Channels, Targets, Memory Size, and SAF-TE
1640 Enclosure Management Enabled fields.
1642 Controller->Channels = Enquiry2->ActualChannels;
1643 Controller->Targets = Enquiry2->MaxTargets;
1644 Controller->MemorySize = Enquiry2->MemorySize >> 20;
1645 Controller->V1.SAFTE_EnclosureManagementEnabled =
1646 (Enquiry2->FaultManagementType == DAC960_V1_SAFTE);
1648 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1649 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1650 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1651 less than the Controller Queue Depth to allow for an automatic drive
1654 Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands;
1655 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1656 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1657 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1658 Controller->LogicalDriveCount =
1659 Controller->V1.Enquiry.NumberOfLogicalDrives;
1660 Controller->MaxBlocksPerCommand = Enquiry2->MaxBlocksPerCommand;
1661 Controller->ControllerScatterGatherLimit = Enquiry2->MaxScatterGatherEntries;
1662 Controller->DriverScatterGatherLimit =
1663 Controller->ControllerScatterGatherLimit;
1664 if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit)
1665 Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit;
1667 Initialize the Stripe Size, Segment Size, and Geometry Translation.
1669 Controller->V1.StripeSize = Config2->BlocksPerStripe * Config2->BlockFactor
1670 >> (10 - DAC960_BlockSizeBits);
1671 Controller->V1.SegmentSize = Config2->BlocksPerCacheLine * Config2->BlockFactor
1672 >> (10 - DAC960_BlockSizeBits);
1673 switch (Config2->DriveGeometry)
1675 case DAC960_V1_Geometry_128_32:
1676 Controller->V1.GeometryTranslationHeads = 128;
1677 Controller->V1.GeometryTranslationSectors = 32;
1679 case DAC960_V1_Geometry_255_63:
1680 Controller->V1.GeometryTranslationHeads = 255;
1681 Controller->V1.GeometryTranslationSectors = 63;
1684 free_dma_loaf(Controller->PCIDevice, &local_dma);
1685 return DAC960_Failure(Controller, "CONFIG2 DRIVE GEOMETRY");
1688 Initialize the Background Initialization Status.
1690 if ((Controller->FirmwareVersion[0] == '4' &&
1691 strcmp(Controller->FirmwareVersion, "4.08") >= 0) ||
1692 (Controller->FirmwareVersion[0] == '5' &&
1693 strcmp(Controller->FirmwareVersion, "5.08") >= 0))
1695 Controller->V1.BackgroundInitializationStatusSupported = true;
1696 DAC960_V1_ExecuteType3B(Controller,
1697 DAC960_V1_BackgroundInitializationControl, 0x20,
1699 V1.BackgroundInitializationStatusDMA);
1700 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
1701 Controller->V1.BackgroundInitializationStatus,
1702 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
1705 Initialize the Logical Drive Initially Accessible flag.
1707 for (LogicalDriveNumber = 0;
1708 LogicalDriveNumber < Controller->LogicalDriveCount;
1709 LogicalDriveNumber++)
1710 if (Controller->V1.LogicalDriveInformation
1711 [LogicalDriveNumber].LogicalDriveState !=
1712 DAC960_V1_LogicalDrive_Offline)
1713 Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;
1714 Controller->V1.LastRebuildStatus = DAC960_V1_NoRebuildOrCheckInProgress;
1715 free_dma_loaf(Controller->PCIDevice, &local_dma);
1721 DAC960_V2_ReadControllerConfiguration reads the Configuration Information
1722 from DAC960 V2 Firmware Controllers and initializes the Controller structure.
1725 static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1728 DAC960_V2_ControllerInfo_T *ControllerInfo =
1729 &Controller->V2.ControllerInformation;
1730 unsigned short LogicalDeviceNumber = 0;
1731 int ModelNameLength;
1733 /* Get data into dma-able area, then copy into permanant location */
1734 if (!DAC960_V2_NewControllerInfo(Controller))
1735 return DAC960_Failure(Controller, "GET CONTROLLER INFO");
1736 memcpy(ControllerInfo, Controller->V2.NewControllerInformation,
1737 sizeof(DAC960_V2_ControllerInfo_T));
1740 if (!DAC960_V2_GeneralInfo(Controller))
1741 return DAC960_Failure(Controller, "GET HEALTH STATUS");
1744 Initialize the Controller Model Name and Full Model Name fields.
1746 ModelNameLength = sizeof(ControllerInfo->ControllerName);
1747 if (ModelNameLength > sizeof(Controller->ModelName)-1)
1748 ModelNameLength = sizeof(Controller->ModelName)-1;
1749 memcpy(Controller->ModelName, ControllerInfo->ControllerName,
1752 while (Controller->ModelName[ModelNameLength] == ' ' ||
1753 Controller->ModelName[ModelNameLength] == '\0')
1755 Controller->ModelName[++ModelNameLength] = '\0';
1756 strcpy(Controller->FullModelName, "Mylex ");
1757 strcat(Controller->FullModelName, Controller->ModelName);
1759 Initialize the Controller Firmware Version field.
1761 sprintf(Controller->FirmwareVersion, "%d.%02d-%02d",
1762 ControllerInfo->FirmwareMajorVersion,
1763 ControllerInfo->FirmwareMinorVersion,
1764 ControllerInfo->FirmwareTurnNumber);
1765 if (ControllerInfo->FirmwareMajorVersion == 6 &&
1766 ControllerInfo->FirmwareMinorVersion == 0 &&
1767 ControllerInfo->FirmwareTurnNumber < 1)
1769 DAC960_Info("FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n",
1770 Controller, Controller->FirmwareVersion);
1771 DAC960_Info("STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n",
1773 DAC960_Info("PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n",
1777 Initialize the Controller Channels, Targets, and Memory Size.
1779 Controller->Channels = ControllerInfo->NumberOfPhysicalChannelsPresent;
1780 Controller->Targets =
1781 ControllerInfo->MaximumTargetsPerChannel
1782 [ControllerInfo->NumberOfPhysicalChannelsPresent-1];
1783 Controller->MemorySize = ControllerInfo->MemorySizeMB;
1785 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1786 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1787 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1788 less than the Controller Queue Depth to allow for an automatic drive
1791 Controller->ControllerQueueDepth = ControllerInfo->MaximumParallelCommands;
1792 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1793 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1794 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1795 Controller->LogicalDriveCount = ControllerInfo->LogicalDevicesPresent;
1796 Controller->MaxBlocksPerCommand =
1797 ControllerInfo->MaximumDataTransferSizeInBlocks;
1798 Controller->ControllerScatterGatherLimit =
1799 ControllerInfo->MaximumScatterGatherEntries;
1800 Controller->DriverScatterGatherLimit =
1801 Controller->ControllerScatterGatherLimit;
1802 if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit)
1803 Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit;
1805 Initialize the Logical Device Information.
1809 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
1810 Controller->V2.NewLogicalDeviceInformation;
1811 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo;
1812 DAC960_V2_PhysicalDevice_T PhysicalDevice;
1814 if (!DAC960_V2_NewLogicalDeviceInfo(Controller, LogicalDeviceNumber))
1816 LogicalDeviceNumber = NewLogicalDeviceInfo->LogicalDeviceNumber;
1817 if (LogicalDeviceNumber >= DAC960_MaxLogicalDrives) {
1818 DAC960_Error("DAC960: Logical Drive Number %d not supported\n",
1819 Controller, LogicalDeviceNumber);
1822 if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize) {
1823 DAC960_Error("DAC960: Logical Drive Block Size %d not supported\n",
1824 Controller, NewLogicalDeviceInfo->DeviceBlockSizeInBytes);
1825 LogicalDeviceNumber++;
1828 PhysicalDevice.Controller = 0;
1829 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
1830 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
1831 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
1832 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
1834 if (NewLogicalDeviceInfo->LogicalDeviceState !=
1835 DAC960_V2_LogicalDevice_Offline)
1836 Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;
1837 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
1838 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
1839 if (LogicalDeviceInfo == NULL)
1840 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1841 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
1843 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
1844 sizeof(DAC960_V2_LogicalDeviceInfo_T));
1845 LogicalDeviceNumber++;
1852 DAC960_ReportControllerConfiguration reports the Configuration Information
1856 static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
1859 DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",
1860 Controller, Controller->ModelName);
1861 DAC960_Info(" Firmware Version: %s, Channels: %d, Memory Size: %dMB\n",
1862 Controller, Controller->FirmwareVersion,
1863 Controller->Channels, Controller->MemorySize);
1864 DAC960_Info(" PCI Bus: %d, Device: %d, Function: %d, I/O Address: ",
1865 Controller, Controller->Bus,
1866 Controller->Device, Controller->Function);
1867 if (Controller->IO_Address == 0)
1868 DAC960_Info("Unassigned\n", Controller);
1869 else DAC960_Info("0x%X\n", Controller, Controller->IO_Address);
1870 DAC960_Info(" PCI Address: 0x%X mapped at 0x%lX, IRQ Channel: %d\n",
1871 Controller, Controller->PCI_Address,
1872 (unsigned long) Controller->BaseAddress,
1873 Controller->IRQ_Channel);
1874 DAC960_Info(" Controller Queue Depth: %d, "
1875 "Maximum Blocks per Command: %d\n",
1876 Controller, Controller->ControllerQueueDepth,
1877 Controller->MaxBlocksPerCommand);
1878 DAC960_Info(" Driver Queue Depth: %d, "
1879 "Scatter/Gather Limit: %d of %d Segments\n",
1880 Controller, Controller->DriverQueueDepth,
1881 Controller->DriverScatterGatherLimit,
1882 Controller->ControllerScatterGatherLimit);
1883 if (Controller->FirmwareType == DAC960_V1_Controller)
1885 DAC960_Info(" Stripe Size: %dKB, Segment Size: %dKB, "
1886 "BIOS Geometry: %d/%d\n", Controller,
1887 Controller->V1.StripeSize,
1888 Controller->V1.SegmentSize,
1889 Controller->V1.GeometryTranslationHeads,
1890 Controller->V1.GeometryTranslationSectors);
1891 if (Controller->V1.SAFTE_EnclosureManagementEnabled)
1892 DAC960_Info(" SAF-TE Enclosure Management Enabled\n", Controller);
1899 DAC960_V1_ReadDeviceConfiguration reads the Device Configuration Information
1900 for DAC960 V1 Firmware Controllers by requesting the SCSI Inquiry and SCSI
1901 Inquiry Unit Serial Number information for each device connected to
1905 static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
1908 struct dma_loaf local_dma;
1910 dma_addr_t DCDBs_dma[DAC960_V1_MaxChannels];
1911 DAC960_V1_DCDB_T *DCDBs_cpu[DAC960_V1_MaxChannels];
1913 dma_addr_t SCSI_Inquiry_dma[DAC960_V1_MaxChannels];
1914 DAC960_SCSI_Inquiry_T *SCSI_Inquiry_cpu[DAC960_V1_MaxChannels];
1916 dma_addr_t SCSI_NewInquiryUnitSerialNumberDMA[DAC960_V1_MaxChannels];
1917 DAC960_SCSI_Inquiry_UnitSerialNumber_T *SCSI_NewInquiryUnitSerialNumberCPU[DAC960_V1_MaxChannels];
1919 struct completion Completions[DAC960_V1_MaxChannels];
1920 unsigned long flags;
1921 int Channel, TargetID;
1923 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1924 DAC960_V1_MaxChannels*(sizeof(DAC960_V1_DCDB_T) +
1925 sizeof(DAC960_SCSI_Inquiry_T) +
1926 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T))))
1927 return DAC960_Failure(Controller,
1928 "DMA ALLOCATION FAILED IN ReadDeviceConfiguration");
1930 for (Channel = 0; Channel < Controller->Channels; Channel++) {
1931 DCDBs_cpu[Channel] = slice_dma_loaf(&local_dma,
1932 sizeof(DAC960_V1_DCDB_T), DCDBs_dma + Channel);
1933 SCSI_Inquiry_cpu[Channel] = slice_dma_loaf(&local_dma,
1934 sizeof(DAC960_SCSI_Inquiry_T),
1935 SCSI_Inquiry_dma + Channel);
1936 SCSI_NewInquiryUnitSerialNumberCPU[Channel] = slice_dma_loaf(&local_dma,
1937 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1938 SCSI_NewInquiryUnitSerialNumberDMA + Channel);
1941 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
1944 * For each channel, submit a probe for a device on that channel.
1945 * The timeout interval for a device that is present is 10 seconds.
1946 * With this approach, the timeout periods can elapse in parallel
1949 for (Channel = 0; Channel < Controller->Channels; Channel++)
1951 dma_addr_t NewInquiryStandardDataDMA = SCSI_Inquiry_dma[Channel];
1952 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
1953 dma_addr_t DCDB_dma = DCDBs_dma[Channel];
1954 DAC960_Command_T *Command = Controller->Commands[Channel];
1955 struct completion *Completion = &Completions[Channel];
1957 init_completion(Completion);
1958 DAC960_V1_ClearCommand(Command);
1959 Command->CommandType = DAC960_ImmediateCommand;
1960 Command->Completion = Completion;
1961 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
1962 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_dma;
1963 DCDB->Channel = Channel;
1964 DCDB->TargetID = TargetID;
1965 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
1966 DCDB->EarlyStatus = false;
1967 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
1968 DCDB->NoAutomaticRequestSense = false;
1969 DCDB->DisconnectPermitted = true;
1970 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
1971 DCDB->BusAddress = NewInquiryStandardDataDMA;
1972 DCDB->CDBLength = 6;
1973 DCDB->TransferLengthHigh4 = 0;
1974 DCDB->SenseLength = sizeof(DCDB->SenseData);
1975 DCDB->CDB[0] = 0x12; /* INQUIRY */
1976 DCDB->CDB[1] = 0; /* EVPD = 0 */
1977 DCDB->CDB[2] = 0; /* Page Code */
1978 DCDB->CDB[3] = 0; /* Reserved */
1979 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
1980 DCDB->CDB[5] = 0; /* Control */
1982 spin_lock_irqsave(&Controller->queue_lock, flags);
1983 DAC960_QueueCommand(Command);
1984 spin_unlock_irqrestore(&Controller->queue_lock, flags);
1987 * Wait for the problems submitted in the previous loop
1988 * to complete. On the probes that are successful,
1989 * get the serial number of the device that was found.
1991 for (Channel = 0; Channel < Controller->Channels; Channel++)
1993 DAC960_SCSI_Inquiry_T *InquiryStandardData =
1994 &Controller->V1.InquiryStandardData[Channel][TargetID];
1995 DAC960_SCSI_Inquiry_T *NewInquiryStandardData = SCSI_Inquiry_cpu[Channel];
1996 dma_addr_t NewInquiryUnitSerialNumberDMA =
1997 SCSI_NewInquiryUnitSerialNumberDMA[Channel];
1998 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
1999 SCSI_NewInquiryUnitSerialNumberCPU[Channel];
2000 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2001 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2002 DAC960_Command_T *Command = Controller->Commands[Channel];
2003 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
2004 struct completion *Completion = &Completions[Channel];
2006 wait_for_completion(Completion);
2008 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2009 memset(InquiryStandardData, 0, sizeof(DAC960_SCSI_Inquiry_T));
2010 InquiryStandardData->PeripheralDeviceType = 0x1F;
2013 memcpy(InquiryStandardData, NewInquiryStandardData, sizeof(DAC960_SCSI_Inquiry_T));
2015 /* Preserve Channel and TargetID values from the previous loop */
2016 Command->Completion = Completion;
2017 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2018 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
2019 DCDB->SenseLength = sizeof(DCDB->SenseData);
2020 DCDB->CDB[0] = 0x12; /* INQUIRY */
2021 DCDB->CDB[1] = 1; /* EVPD = 1 */
2022 DCDB->CDB[2] = 0x80; /* Page Code */
2023 DCDB->CDB[3] = 0; /* Reserved */
2024 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2025 DCDB->CDB[5] = 0; /* Control */
2027 spin_lock_irqsave(&Controller->queue_lock, flags);
2028 DAC960_QueueCommand(Command);
2029 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2030 wait_for_completion(Completion);
2032 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2033 memset(InquiryUnitSerialNumber, 0,
2034 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2035 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2037 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2038 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2041 free_dma_loaf(Controller->PCIDevice, &local_dma);
2047 DAC960_V2_ReadDeviceConfiguration reads the Device Configuration Information
2048 for DAC960 V2 Firmware Controllers by requesting the Physical Device
2049 Information and SCSI Inquiry Unit Serial Number information for each
2050 device connected to Controller.
2053 static boolean DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
2056 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
2057 unsigned short PhysicalDeviceIndex = 0;
2061 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
2062 Controller->V2.NewPhysicalDeviceInformation;
2063 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo;
2064 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
2065 Controller->V2.NewInquiryUnitSerialNumber;
2066 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber;
2068 if (!DAC960_V2_NewPhysicalDeviceInfo(Controller, Channel, TargetID, LogicalUnit))
2071 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
2072 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
2073 if (PhysicalDeviceInfo == NULL)
2074 return DAC960_Failure(Controller, "PHYSICAL DEVICE ALLOCATION");
2075 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] =
2077 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
2078 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
2080 InquiryUnitSerialNumber = (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
2081 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
2082 if (InquiryUnitSerialNumber == NULL) {
2083 kfree(PhysicalDeviceInfo);
2084 return DAC960_Failure(Controller, "SERIAL NUMBER ALLOCATION");
2086 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex] =
2087 InquiryUnitSerialNumber;
2089 Channel = NewPhysicalDeviceInfo->Channel;
2090 TargetID = NewPhysicalDeviceInfo->TargetID;
2091 LogicalUnit = NewPhysicalDeviceInfo->LogicalUnit;
2094 Some devices do NOT have Unit Serial Numbers.
2095 This command fails for them. But, we still want to
2096 remember those devices are there. Construct a
2097 UnitSerialNumber structure for the failure case.
2099 if (!DAC960_V2_NewInquiryUnitSerialNumber(Controller, Channel, TargetID, LogicalUnit)) {
2100 memset(InquiryUnitSerialNumber, 0,
2101 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2102 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2104 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2105 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2107 PhysicalDeviceIndex++;
2115 DAC960_SanitizeInquiryData sanitizes the Vendor, Model, Revision, and
2116 Product Serial Number fields of the Inquiry Standard Data and Inquiry
2117 Unit Serial Number structures.
2120 static void DAC960_SanitizeInquiryData(DAC960_SCSI_Inquiry_T
2121 *InquiryStandardData,
2122 DAC960_SCSI_Inquiry_UnitSerialNumber_T
2123 *InquiryUnitSerialNumber,
2124 unsigned char *Vendor,
2125 unsigned char *Model,
2126 unsigned char *Revision,
2127 unsigned char *SerialNumber)
2129 int SerialNumberLength, i;
2130 if (InquiryStandardData->PeripheralDeviceType == 0x1F) return;
2131 for (i = 0; i < sizeof(InquiryStandardData->VendorIdentification); i++)
2133 unsigned char VendorCharacter =
2134 InquiryStandardData->VendorIdentification[i];
2135 Vendor[i] = (VendorCharacter >= ' ' && VendorCharacter <= '~'
2136 ? VendorCharacter : ' ');
2138 Vendor[sizeof(InquiryStandardData->VendorIdentification)] = '\0';
2139 for (i = 0; i < sizeof(InquiryStandardData->ProductIdentification); i++)
2141 unsigned char ModelCharacter =
2142 InquiryStandardData->ProductIdentification[i];
2143 Model[i] = (ModelCharacter >= ' ' && ModelCharacter <= '~'
2144 ? ModelCharacter : ' ');
2146 Model[sizeof(InquiryStandardData->ProductIdentification)] = '\0';
2147 for (i = 0; i < sizeof(InquiryStandardData->ProductRevisionLevel); i++)
2149 unsigned char RevisionCharacter =
2150 InquiryStandardData->ProductRevisionLevel[i];
2151 Revision[i] = (RevisionCharacter >= ' ' && RevisionCharacter <= '~'
2152 ? RevisionCharacter : ' ');
2154 Revision[sizeof(InquiryStandardData->ProductRevisionLevel)] = '\0';
2155 if (InquiryUnitSerialNumber->PeripheralDeviceType == 0x1F) return;
2156 SerialNumberLength = InquiryUnitSerialNumber->PageLength;
2157 if (SerialNumberLength >
2158 sizeof(InquiryUnitSerialNumber->ProductSerialNumber))
2159 SerialNumberLength = sizeof(InquiryUnitSerialNumber->ProductSerialNumber);
2160 for (i = 0; i < SerialNumberLength; i++)
2162 unsigned char SerialNumberCharacter =
2163 InquiryUnitSerialNumber->ProductSerialNumber[i];
2165 (SerialNumberCharacter >= ' ' && SerialNumberCharacter <= '~'
2166 ? SerialNumberCharacter : ' ');
2168 SerialNumber[SerialNumberLength] = '\0';
2173 DAC960_V1_ReportDeviceConfiguration reports the Device Configuration
2174 Information for DAC960 V1 Firmware Controllers.
2177 static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2180 int LogicalDriveNumber, Channel, TargetID;
2181 DAC960_Info(" Physical Devices:\n", Controller);
2182 for (Channel = 0; Channel < Controller->Channels; Channel++)
2183 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
2185 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2186 &Controller->V1.InquiryStandardData[Channel][TargetID];
2187 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2188 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2189 DAC960_V1_DeviceState_T *DeviceState =
2190 &Controller->V1.DeviceState[Channel][TargetID];
2191 DAC960_V1_ErrorTableEntry_T *ErrorEntry =
2192 &Controller->V1.ErrorTable.ErrorTableEntries[Channel][TargetID];
2193 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2194 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2195 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2196 char SerialNumber[1+sizeof(InquiryUnitSerialNumber
2197 ->ProductSerialNumber)];
2198 if (InquiryStandardData->PeripheralDeviceType == 0x1F) continue;
2199 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2200 Vendor, Model, Revision, SerialNumber);
2201 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2202 Controller, Channel, TargetID, (TargetID < 10 ? " " : ""),
2203 Vendor, Model, Revision);
2204 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2205 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2206 if (DeviceState->Present &&
2207 DeviceState->DeviceType == DAC960_V1_DiskType)
2209 if (Controller->V1.DeviceResetCount[Channel][TargetID] > 0)
2210 DAC960_Info(" Disk Status: %s, %u blocks, %d resets\n",
2212 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2214 : DeviceState->DeviceState
2215 == DAC960_V1_Device_WriteOnly
2217 : DeviceState->DeviceState
2218 == DAC960_V1_Device_Online
2219 ? "Online" : "Standby"),
2220 DeviceState->DiskSize,
2221 Controller->V1.DeviceResetCount[Channel][TargetID]);
2223 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2224 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2226 : DeviceState->DeviceState
2227 == DAC960_V1_Device_WriteOnly
2229 : DeviceState->DeviceState
2230 == DAC960_V1_Device_Online
2231 ? "Online" : "Standby"),
2232 DeviceState->DiskSize);
2234 if (ErrorEntry->ParityErrorCount > 0 ||
2235 ErrorEntry->SoftErrorCount > 0 ||
2236 ErrorEntry->HardErrorCount > 0 ||
2237 ErrorEntry->MiscErrorCount > 0)
2238 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2239 "Hard: %d, Misc: %d\n", Controller,
2240 ErrorEntry->ParityErrorCount,
2241 ErrorEntry->SoftErrorCount,
2242 ErrorEntry->HardErrorCount,
2243 ErrorEntry->MiscErrorCount);
2245 DAC960_Info(" Logical Drives:\n", Controller);
2246 for (LogicalDriveNumber = 0;
2247 LogicalDriveNumber < Controller->LogicalDriveCount;
2248 LogicalDriveNumber++)
2250 DAC960_V1_LogicalDriveInformation_T *LogicalDriveInformation =
2251 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
2252 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks, %s\n",
2253 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2254 LogicalDriveInformation->RAIDLevel,
2255 (LogicalDriveInformation->LogicalDriveState
2256 == DAC960_V1_LogicalDrive_Online
2258 : LogicalDriveInformation->LogicalDriveState
2259 == DAC960_V1_LogicalDrive_Critical
2260 ? "Critical" : "Offline"),
2261 LogicalDriveInformation->LogicalDriveSize,
2262 (LogicalDriveInformation->WriteBack
2263 ? "Write Back" : "Write Thru"));
2270 DAC960_V2_ReportDeviceConfiguration reports the Device Configuration
2271 Information for DAC960 V2 Firmware Controllers.
2274 static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2277 int PhysicalDeviceIndex, LogicalDriveNumber;
2278 DAC960_Info(" Physical Devices:\n", Controller);
2279 for (PhysicalDeviceIndex = 0;
2280 PhysicalDeviceIndex < DAC960_V2_MaxPhysicalDevices;
2281 PhysicalDeviceIndex++)
2283 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
2284 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
2285 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2286 (DAC960_SCSI_Inquiry_T *) &PhysicalDeviceInfo->SCSI_InquiryData;
2287 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2288 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
2289 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2290 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2291 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2292 char SerialNumber[1+sizeof(InquiryUnitSerialNumber->ProductSerialNumber)];
2293 if (PhysicalDeviceInfo == NULL) break;
2294 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2295 Vendor, Model, Revision, SerialNumber);
2296 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2298 PhysicalDeviceInfo->Channel,
2299 PhysicalDeviceInfo->TargetID,
2300 (PhysicalDeviceInfo->TargetID < 10 ? " " : ""),
2301 Vendor, Model, Revision);
2302 if (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers == 0)
2303 DAC960_Info(" %sAsynchronous\n", Controller,
2304 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2307 DAC960_Info(" %sSynchronous at %d MB/sec\n", Controller,
2308 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2310 (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers
2311 * PhysicalDeviceInfo->NegotiatedDataWidthBits/8));
2312 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2313 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2314 if (PhysicalDeviceInfo->PhysicalDeviceState ==
2315 DAC960_V2_Device_Unconfigured)
2317 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2318 (PhysicalDeviceInfo->PhysicalDeviceState
2319 == DAC960_V2_Device_Online
2321 : PhysicalDeviceInfo->PhysicalDeviceState
2322 == DAC960_V2_Device_Rebuild
2324 : PhysicalDeviceInfo->PhysicalDeviceState
2325 == DAC960_V2_Device_Missing
2327 : PhysicalDeviceInfo->PhysicalDeviceState
2328 == DAC960_V2_Device_Critical
2330 : PhysicalDeviceInfo->PhysicalDeviceState
2331 == DAC960_V2_Device_Dead
2333 : PhysicalDeviceInfo->PhysicalDeviceState
2334 == DAC960_V2_Device_SuspectedDead
2336 : PhysicalDeviceInfo->PhysicalDeviceState
2337 == DAC960_V2_Device_CommandedOffline
2338 ? "Commanded-Offline"
2339 : PhysicalDeviceInfo->PhysicalDeviceState
2340 == DAC960_V2_Device_Standby
2341 ? "Standby" : "Unknown"),
2342 PhysicalDeviceInfo->ConfigurableDeviceSize);
2343 if (PhysicalDeviceInfo->ParityErrors == 0 &&
2344 PhysicalDeviceInfo->SoftErrors == 0 &&
2345 PhysicalDeviceInfo->HardErrors == 0 &&
2346 PhysicalDeviceInfo->MiscellaneousErrors == 0 &&
2347 PhysicalDeviceInfo->CommandTimeouts == 0 &&
2348 PhysicalDeviceInfo->Retries == 0 &&
2349 PhysicalDeviceInfo->Aborts == 0 &&
2350 PhysicalDeviceInfo->PredictedFailuresDetected == 0)
2352 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2353 "Hard: %d, Misc: %d\n", Controller,
2354 PhysicalDeviceInfo->ParityErrors,
2355 PhysicalDeviceInfo->SoftErrors,
2356 PhysicalDeviceInfo->HardErrors,
2357 PhysicalDeviceInfo->MiscellaneousErrors);
2358 DAC960_Info(" Timeouts: %d, Retries: %d, "
2359 "Aborts: %d, Predicted: %d\n", Controller,
2360 PhysicalDeviceInfo->CommandTimeouts,
2361 PhysicalDeviceInfo->Retries,
2362 PhysicalDeviceInfo->Aborts,
2363 PhysicalDeviceInfo->PredictedFailuresDetected);
2365 DAC960_Info(" Logical Drives:\n", Controller);
2366 for (LogicalDriveNumber = 0;
2367 LogicalDriveNumber < DAC960_MaxLogicalDrives;
2368 LogicalDriveNumber++)
2370 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
2371 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
2372 unsigned char *ReadCacheStatus[] = { "Read Cache Disabled",
2373 "Read Cache Enabled",
2374 "Read Ahead Enabled",
2375 "Intelligent Read Ahead Enabled",
2376 "-", "-", "-", "-" };
2377 unsigned char *WriteCacheStatus[] = { "Write Cache Disabled",
2378 "Logical Device Read Only",
2379 "Write Cache Enabled",
2380 "Intelligent Write Cache Enabled",
2381 "-", "-", "-", "-" };
2382 unsigned char *GeometryTranslation;
2383 if (LogicalDeviceInfo == NULL) continue;
2384 switch (LogicalDeviceInfo->DriveGeometry)
2386 case DAC960_V2_Geometry_128_32:
2387 GeometryTranslation = "128/32";
2389 case DAC960_V2_Geometry_255_63:
2390 GeometryTranslation = "255/63";
2393 GeometryTranslation = "Invalid";
2394 DAC960_Error("Illegal Logical Device Geometry %d\n",
2395 Controller, LogicalDeviceInfo->DriveGeometry);
2398 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks\n",
2399 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2400 LogicalDeviceInfo->RAIDLevel,
2401 (LogicalDeviceInfo->LogicalDeviceState
2402 == DAC960_V2_LogicalDevice_Online
2404 : LogicalDeviceInfo->LogicalDeviceState
2405 == DAC960_V2_LogicalDevice_Critical
2406 ? "Critical" : "Offline"),
2407 LogicalDeviceInfo->ConfigurableDeviceSize);
2408 DAC960_Info(" Logical Device %s, BIOS Geometry: %s\n",
2410 (LogicalDeviceInfo->LogicalDeviceControl
2411 .LogicalDeviceInitialized
2412 ? "Initialized" : "Uninitialized"),
2413 GeometryTranslation);
2414 if (LogicalDeviceInfo->StripeSize == 0)
2416 if (LogicalDeviceInfo->CacheLineSize == 0)
2417 DAC960_Info(" Stripe Size: N/A, "
2418 "Segment Size: N/A\n", Controller);
2420 DAC960_Info(" Stripe Size: N/A, "
2421 "Segment Size: %dKB\n", Controller,
2422 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2426 if (LogicalDeviceInfo->CacheLineSize == 0)
2427 DAC960_Info(" Stripe Size: %dKB, "
2428 "Segment Size: N/A\n", Controller,
2429 1 << (LogicalDeviceInfo->StripeSize - 2));
2431 DAC960_Info(" Stripe Size: %dKB, "
2432 "Segment Size: %dKB\n", Controller,
2433 1 << (LogicalDeviceInfo->StripeSize - 2),
2434 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2436 DAC960_Info(" %s, %s\n", Controller,
2438 LogicalDeviceInfo->LogicalDeviceControl.ReadCache],
2440 LogicalDeviceInfo->LogicalDeviceControl.WriteCache]);
2441 if (LogicalDeviceInfo->SoftErrors > 0 ||
2442 LogicalDeviceInfo->CommandsFailed > 0 ||
2443 LogicalDeviceInfo->DeferredWriteErrors)
2444 DAC960_Info(" Errors - Soft: %d, Failed: %d, "
2445 "Deferred Write: %d\n", Controller,
2446 LogicalDeviceInfo->SoftErrors,
2447 LogicalDeviceInfo->CommandsFailed,
2448 LogicalDeviceInfo->DeferredWriteErrors);
2455 DAC960_RegisterBlockDevice registers the Block Device structures
2456 associated with Controller.
2459 static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2461 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2462 struct request_queue *RequestQueue;
2466 Register the Block Device Major Number for this DAC960 Controller.
2468 if (register_blkdev(MajorNumber, "dac960") < 0)
2472 Initialize the I/O Request Queue.
2474 RequestQueue = blk_init_queue(DAC960_RequestFunction,&Controller->queue_lock);
2475 if (!RequestQueue) {
2476 unregister_blkdev(MajorNumber, "dac960");
2479 Controller->RequestQueue = RequestQueue;
2480 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
2481 RequestQueue->queuedata = Controller;
2482 blk_queue_max_hw_segments(RequestQueue,
2483 Controller->DriverScatterGatherLimit);
2484 blk_queue_max_phys_segments(RequestQueue,
2485 Controller->DriverScatterGatherLimit);
2486 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2488 for (n = 0; n < DAC960_MaxLogicalDrives; n++) {
2489 struct gendisk *disk = Controller->disks[n];
2490 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2491 sprintf(disk->devfs_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2492 disk->major = MajorNumber;
2493 disk->first_minor = n << DAC960_MaxPartitionsBits;
2494 disk->fops = &DAC960_BlockDeviceOperations;
2497 Indicate the Block Device Registration completed successfully,
2504 DAC960_UnregisterBlockDevice unregisters the Block Device structures
2505 associated with Controller.
2508 static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
2510 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2513 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
2514 del_gendisk(Controller->disks[disk]);
2517 Unregister the Block Device Major Number for this DAC960 Controller.
2519 unregister_blkdev(MajorNumber, "dac960");
2521 Remove the I/O Request Queue.
2523 blk_cleanup_queue(Controller->RequestQueue);
2527 DAC960_ComputeGenericDiskInfo computes the values for the Generic Disk
2528 Information Partition Sector Counts and Block Sizes.
2531 static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
2534 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
2535 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
2539 DAC960_ReportErrorStatus reports Controller BIOS Messages passed through
2540 the Error Status Register when the driver performs the BIOS handshaking.
2541 It returns true for fatal errors and false otherwise.
2544 static boolean DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
2545 unsigned char ErrorStatus,
2546 unsigned char Parameter0,
2547 unsigned char Parameter1)
2549 switch (ErrorStatus)
2552 DAC960_Notice("Physical Device %d:%d Not Responding\n",
2553 Controller, Parameter1, Parameter0);
2556 if (Controller->DriveSpinUpMessageDisplayed) break;
2557 DAC960_Notice("Spinning Up Drives\n", Controller);
2558 Controller->DriveSpinUpMessageDisplayed = true;
2561 DAC960_Notice("Configuration Checksum Error\n", Controller);
2564 DAC960_Notice("Mirror Race Recovery Failed\n", Controller);
2567 DAC960_Notice("Mirror Race Recovery In Progress\n", Controller);
2570 DAC960_Notice("Physical Device %d:%d COD Mismatch\n",
2571 Controller, Parameter1, Parameter0);
2574 DAC960_Notice("Logical Drive Installation Aborted\n", Controller);
2577 DAC960_Notice("Mirror Race On A Critical Logical Drive\n", Controller);
2580 DAC960_Notice("New Controller Configuration Found\n", Controller);
2583 DAC960_Error("Fatal Memory Parity Error for Controller at\n", Controller);
2586 DAC960_Error("Unknown Initialization Error %02X for Controller at\n",
2587 Controller, ErrorStatus);
2595 * DAC960_DetectCleanup releases the resources that were allocated
2596 * during DAC960_DetectController(). DAC960_DetectController can
2597 * has several internal failure points, so not ALL resources may
2598 * have been allocated. It's important to free only
2599 * resources that HAVE been allocated. The code below always
2600 * tests that the resource has been allocated before attempting to
2603 static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2607 /* Free the memory mailbox, status, and related structures */
2608 free_dma_loaf(Controller->PCIDevice, &Controller->DmaPages);
2609 if (Controller->MemoryMappedAddress) {
2610 switch(Controller->HardwareType)
2612 case DAC960_BA_Controller:
2613 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2615 case DAC960_LP_Controller:
2616 DAC960_LP_DisableInterrupts(Controller->BaseAddress);
2618 case DAC960_LA_Controller:
2619 DAC960_LA_DisableInterrupts(Controller->BaseAddress);
2621 case DAC960_PG_Controller:
2622 DAC960_PG_DisableInterrupts(Controller->BaseAddress);
2624 case DAC960_PD_Controller:
2625 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2627 case DAC960_P_Controller:
2628 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2631 iounmap(Controller->MemoryMappedAddress);
2633 if (Controller->IRQ_Channel)
2634 free_irq(Controller->IRQ_Channel, Controller);
2635 if (Controller->IO_Address)
2636 release_region(Controller->IO_Address, 0x80);
2637 pci_disable_device(Controller->PCIDevice);
2638 for (i = 0; (i < DAC960_MaxLogicalDrives) && Controller->disks[i]; i++)
2639 put_disk(Controller->disks[i]);
2640 DAC960_Controllers[Controller->ControllerNumber] = NULL;
2646 DAC960_DetectController detects Mylex DAC960/AcceleRAID/eXtremeRAID
2647 PCI RAID Controllers by interrogating the PCI Configuration Space for
2651 static DAC960_Controller_T *
2652 DAC960_DetectController(struct pci_dev *PCI_Device,
2653 const struct pci_device_id *entry)
2655 struct DAC960_privdata *privdata =
2656 (struct DAC960_privdata *)entry->driver_data;
2657 irqreturn_t (*InterruptHandler)(int, void *, struct pt_regs *) =
2658 privdata->InterruptHandler;
2659 unsigned int MemoryWindowSize = privdata->MemoryWindowSize;
2660 DAC960_Controller_T *Controller = NULL;
2661 unsigned char DeviceFunction = PCI_Device->devfn;
2662 unsigned char ErrorStatus, Parameter0, Parameter1;
2663 unsigned int IRQ_Channel = PCI_Device->irq;
2667 Controller = (DAC960_Controller_T *)
2668 kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
2669 if (Controller == NULL) {
2670 DAC960_Error("Unable to allocate Controller structure for "
2671 "Controller at\n", NULL);
2674 memset(Controller, 0, sizeof(DAC960_Controller_T));
2675 Controller->ControllerNumber = DAC960_ControllerCount;
2676 DAC960_Controllers[DAC960_ControllerCount++] = Controller;
2677 Controller->Bus = PCI_Device->bus->number;
2678 Controller->FirmwareType = privdata->FirmwareType;
2679 Controller->HardwareType = privdata->HardwareType;
2680 Controller->Device = DeviceFunction >> 3;
2681 Controller->Function = DeviceFunction & 0x7;
2682 Controller->PCIDevice = PCI_Device;
2683 strcpy(Controller->FullModelName, "DAC960");
2685 if (pci_enable_device(PCI_Device)) {
2690 switch (Controller->HardwareType)
2692 case DAC960_BA_Controller:
2693 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2695 case DAC960_LP_Controller:
2696 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2698 case DAC960_LA_Controller:
2699 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2701 case DAC960_PG_Controller:
2702 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2704 case DAC960_PD_Controller:
2705 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2706 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2708 case DAC960_P_Controller:
2709 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2710 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2714 pci_set_drvdata(PCI_Device, (void *)((int)Controller->ControllerNumber));
2715 for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
2716 Controller->disks[i] = alloc_disk(1<<DAC960_MaxPartitionsBits);
2717 if (!Controller->disks[i])
2719 Controller->disks[i]->private_data = (void *)i;
2720 Controller->disks[i]->queue = Controller->RequestQueue;
2722 init_waitqueue_head(&Controller->CommandWaitQueue);
2723 init_waitqueue_head(&Controller->HealthStatusWaitQueue);
2724 Controller->queue_lock = SPIN_LOCK_UNLOCKED;
2725 DAC960_AnnounceDriver(Controller);
2727 Map the Controller Register Window.
2729 if (MemoryWindowSize < PAGE_SIZE)
2730 MemoryWindowSize = PAGE_SIZE;
2731 Controller->MemoryMappedAddress =
2732 ioremap_nocache(Controller->PCI_Address & PAGE_MASK, MemoryWindowSize);
2733 Controller->BaseAddress =
2734 Controller->MemoryMappedAddress + (Controller->PCI_Address & ~PAGE_MASK);
2735 if (Controller->MemoryMappedAddress == NULL)
2737 DAC960_Error("Unable to map Controller Register Window for "
2738 "Controller at\n", Controller);
2741 BaseAddress = Controller->BaseAddress;
2742 switch (Controller->HardwareType)
2744 case DAC960_BA_Controller:
2745 DAC960_BA_DisableInterrupts(BaseAddress);
2746 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2748 while (DAC960_BA_InitializationInProgressP(BaseAddress))
2750 if (DAC960_BA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2751 &Parameter0, &Parameter1) &&
2752 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2753 Parameter0, Parameter1))
2757 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2759 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2760 "for Controller at\n", Controller);
2763 DAC960_BA_EnableInterrupts(BaseAddress);
2764 Controller->QueueCommand = DAC960_BA_QueueCommand;
2765 Controller->ReadControllerConfiguration =
2766 DAC960_V2_ReadControllerConfiguration;
2767 Controller->ReadDeviceConfiguration =
2768 DAC960_V2_ReadDeviceConfiguration;
2769 Controller->ReportDeviceConfiguration =
2770 DAC960_V2_ReportDeviceConfiguration;
2771 Controller->QueueReadWriteCommand =
2772 DAC960_V2_QueueReadWriteCommand;
2774 case DAC960_LP_Controller:
2775 DAC960_LP_DisableInterrupts(BaseAddress);
2776 DAC960_LP_AcknowledgeHardwareMailboxStatus(BaseAddress);
2778 while (DAC960_LP_InitializationInProgressP(BaseAddress))
2780 if (DAC960_LP_ReadErrorStatus(BaseAddress, &ErrorStatus,
2781 &Parameter0, &Parameter1) &&
2782 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2783 Parameter0, Parameter1))
2787 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2789 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2790 "for Controller at\n", Controller);
2793 DAC960_LP_EnableInterrupts(BaseAddress);
2794 Controller->QueueCommand = DAC960_LP_QueueCommand;
2795 Controller->ReadControllerConfiguration =
2796 DAC960_V2_ReadControllerConfiguration;
2797 Controller->ReadDeviceConfiguration =
2798 DAC960_V2_ReadDeviceConfiguration;
2799 Controller->ReportDeviceConfiguration =
2800 DAC960_V2_ReportDeviceConfiguration;
2801 Controller->QueueReadWriteCommand =
2802 DAC960_V2_QueueReadWriteCommand;
2804 case DAC960_LA_Controller:
2805 DAC960_LA_DisableInterrupts(BaseAddress);
2806 DAC960_LA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2808 while (DAC960_LA_InitializationInProgressP(BaseAddress))
2810 if (DAC960_LA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2811 &Parameter0, &Parameter1) &&
2812 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2813 Parameter0, Parameter1))
2817 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2819 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2820 "for Controller at\n", Controller);
2823 DAC960_LA_EnableInterrupts(BaseAddress);
2824 if (Controller->V1.DualModeMemoryMailboxInterface)
2825 Controller->QueueCommand = DAC960_LA_QueueCommandDualMode;
2826 else Controller->QueueCommand = DAC960_LA_QueueCommandSingleMode;
2827 Controller->ReadControllerConfiguration =
2828 DAC960_V1_ReadControllerConfiguration;
2829 Controller->ReadDeviceConfiguration =
2830 DAC960_V1_ReadDeviceConfiguration;
2831 Controller->ReportDeviceConfiguration =
2832 DAC960_V1_ReportDeviceConfiguration;
2833 Controller->QueueReadWriteCommand =
2834 DAC960_V1_QueueReadWriteCommand;
2836 case DAC960_PG_Controller:
2837 DAC960_PG_DisableInterrupts(BaseAddress);
2838 DAC960_PG_AcknowledgeHardwareMailboxStatus(BaseAddress);
2840 while (DAC960_PG_InitializationInProgressP(BaseAddress))
2842 if (DAC960_PG_ReadErrorStatus(BaseAddress, &ErrorStatus,
2843 &Parameter0, &Parameter1) &&
2844 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2845 Parameter0, Parameter1))
2849 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2851 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2852 "for Controller at\n", Controller);
2855 DAC960_PG_EnableInterrupts(BaseAddress);
2856 if (Controller->V1.DualModeMemoryMailboxInterface)
2857 Controller->QueueCommand = DAC960_PG_QueueCommandDualMode;
2858 else Controller->QueueCommand = DAC960_PG_QueueCommandSingleMode;
2859 Controller->ReadControllerConfiguration =
2860 DAC960_V1_ReadControllerConfiguration;
2861 Controller->ReadDeviceConfiguration =
2862 DAC960_V1_ReadDeviceConfiguration;
2863 Controller->ReportDeviceConfiguration =
2864 DAC960_V1_ReportDeviceConfiguration;
2865 Controller->QueueReadWriteCommand =
2866 DAC960_V1_QueueReadWriteCommand;
2868 case DAC960_PD_Controller:
2869 if (!request_region(Controller->IO_Address, 0x80,
2870 Controller->FullModelName)) {
2871 DAC960_Error("IO port 0x%d busy for Controller at\n",
2872 Controller, Controller->IO_Address);
2875 DAC960_PD_DisableInterrupts(BaseAddress);
2876 DAC960_PD_AcknowledgeStatus(BaseAddress);
2878 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2880 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2881 &Parameter0, &Parameter1) &&
2882 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2883 Parameter0, Parameter1))
2887 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2889 DAC960_Error("Unable to allocate DMA mapped memory "
2890 "for Controller at\n", Controller);
2893 DAC960_PD_EnableInterrupts(BaseAddress);
2894 Controller->QueueCommand = DAC960_PD_QueueCommand;
2895 Controller->ReadControllerConfiguration =
2896 DAC960_V1_ReadControllerConfiguration;
2897 Controller->ReadDeviceConfiguration =
2898 DAC960_V1_ReadDeviceConfiguration;
2899 Controller->ReportDeviceConfiguration =
2900 DAC960_V1_ReportDeviceConfiguration;
2901 Controller->QueueReadWriteCommand =
2902 DAC960_V1_QueueReadWriteCommand;
2904 case DAC960_P_Controller:
2905 if (!request_region(Controller->IO_Address, 0x80,
2906 Controller->FullModelName)){
2907 DAC960_Error("IO port 0x%d busy for Controller at\n",
2908 Controller, Controller->IO_Address);
2911 DAC960_PD_DisableInterrupts(BaseAddress);
2912 DAC960_PD_AcknowledgeStatus(BaseAddress);
2914 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2916 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2917 &Parameter0, &Parameter1) &&
2918 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2919 Parameter0, Parameter1))
2923 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2925 DAC960_Error("Unable to allocate DMA mapped memory"
2926 "for Controller at\n", Controller);
2929 DAC960_PD_EnableInterrupts(BaseAddress);
2930 Controller->QueueCommand = DAC960_P_QueueCommand;
2931 Controller->ReadControllerConfiguration =
2932 DAC960_V1_ReadControllerConfiguration;
2933 Controller->ReadDeviceConfiguration =
2934 DAC960_V1_ReadDeviceConfiguration;
2935 Controller->ReportDeviceConfiguration =
2936 DAC960_V1_ReportDeviceConfiguration;
2937 Controller->QueueReadWriteCommand =
2938 DAC960_V1_QueueReadWriteCommand;
2942 Acquire shared access to the IRQ Channel.
2944 if (request_irq(IRQ_Channel, InterruptHandler, SA_SHIRQ,
2945 Controller->FullModelName, Controller) < 0)
2947 DAC960_Error("Unable to acquire IRQ Channel %d for Controller at\n",
2948 Controller, Controller->IRQ_Channel);
2951 Controller->IRQ_Channel = IRQ_Channel;
2952 Controller->InitialCommand.CommandIdentifier = 1;
2953 Controller->InitialCommand.Controller = Controller;
2954 Controller->Commands[0] = &Controller->InitialCommand;
2955 Controller->FreeCommands = &Controller->InitialCommand;
2959 if (Controller->IO_Address == 0)
2960 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
2961 "PCI Address 0x%X\n", Controller,
2962 Controller->Bus, Controller->Device,
2963 Controller->Function, Controller->PCI_Address);
2965 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
2966 "0x%X PCI Address 0x%X\n", Controller,
2967 Controller->Bus, Controller->Device,
2968 Controller->Function, Controller->IO_Address,
2969 Controller->PCI_Address);
2970 DAC960_DetectCleanup(Controller);
2971 DAC960_ControllerCount--;
2976 DAC960_InitializeController initializes Controller.
2980 DAC960_InitializeController(DAC960_Controller_T *Controller)
2982 if (DAC960_ReadControllerConfiguration(Controller) &&
2983 DAC960_ReportControllerConfiguration(Controller) &&
2984 DAC960_CreateAuxiliaryStructures(Controller) &&
2985 DAC960_ReadDeviceConfiguration(Controller) &&
2986 DAC960_ReportDeviceConfiguration(Controller) &&
2987 DAC960_RegisterBlockDevice(Controller))
2990 Initialize the Monitoring Timer.
2992 init_timer(&Controller->MonitoringTimer);
2993 Controller->MonitoringTimer.expires =
2994 jiffies + DAC960_MonitoringTimerInterval;
2995 Controller->MonitoringTimer.data = (unsigned long) Controller;
2996 Controller->MonitoringTimer.function = DAC960_MonitoringTimerFunction;
2997 add_timer(&Controller->MonitoringTimer);
2998 Controller->ControllerInitialized = true;
3006 DAC960_FinalizeController finalizes Controller.
3009 static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
3011 if (Controller->ControllerInitialized)
3013 unsigned long flags;
3016 * Acquiring and releasing lock here eliminates
3017 * a very low probability race.
3019 * The code below allocates controller command structures
3020 * from the free list without holding the controller lock.
3021 * This is safe assuming there is no other activity on
3022 * the controller at the time.
3024 * But, there might be a monitoring command still
3025 * in progress. Setting the Shutdown flag while holding
3026 * the lock ensures that there is no monitoring command
3027 * in the interrupt handler currently, and any monitoring
3028 * commands that complete from this time on will NOT return
3029 * their command structure to the free list.
3032 spin_lock_irqsave(&Controller->queue_lock, flags);
3033 Controller->ShutdownMonitoringTimer = 1;
3034 spin_unlock_irqrestore(&Controller->queue_lock, flags);
3036 del_timer_sync(&Controller->MonitoringTimer);
3037 if (Controller->FirmwareType == DAC960_V1_Controller)
3039 DAC960_Notice("Flushing Cache...", Controller);
3040 DAC960_V1_ExecuteType3(Controller, DAC960_V1_Flush, 0);
3041 DAC960_Notice("done\n", Controller);
3043 if (Controller->HardwareType == DAC960_PD_Controller)
3044 release_region(Controller->IO_Address, 0x80);
3048 DAC960_Notice("Flushing Cache...", Controller);
3049 DAC960_V2_DeviceOperation(Controller, DAC960_V2_PauseDevice,
3050 DAC960_V2_RAID_Controller);
3051 DAC960_Notice("done\n", Controller);
3054 DAC960_UnregisterBlockDevice(Controller);
3055 DAC960_DestroyAuxiliaryStructures(Controller);
3056 DAC960_DestroyProcEntries(Controller);
3057 DAC960_DetectCleanup(Controller);
3062 DAC960_Probe verifies controller's existence and
3063 initializes the DAC960 Driver for that controller.
3067 DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry)
3070 DAC960_Controller_T *Controller;
3072 if (DAC960_ControllerCount == DAC960_MaxControllers)
3074 DAC960_Error("More than %d DAC960 Controllers detected - "
3075 "ignoring from Controller at\n",
3076 NULL, DAC960_MaxControllers);
3080 Controller = DAC960_DetectController(dev, entry);
3084 if (!DAC960_InitializeController(Controller)) {
3085 DAC960_FinalizeController(Controller);
3089 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
3090 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
3091 add_disk(Controller->disks[disk]);
3093 DAC960_CreateProcEntries(Controller);
3099 DAC960_Finalize finalizes the DAC960 Driver.
3102 static void DAC960_Remove(struct pci_dev *PCI_Device)
3104 int Controller_Number = (int)pci_get_drvdata(PCI_Device);
3105 DAC960_Controller_T *Controller = DAC960_Controllers[Controller_Number];
3106 if (Controller != NULL)
3107 DAC960_FinalizeController(Controller);
3112 DAC960_V1_QueueReadWriteCommand prepares and queues a Read/Write Command for
3113 DAC960 V1 Firmware Controllers.
3116 static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *Command)
3118 DAC960_Controller_T *Controller = Command->Controller;
3119 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
3120 DAC960_V1_ScatterGatherSegment_T *ScatterGatherList =
3121 Command->V1.ScatterGatherList;
3122 struct scatterlist *ScatterList = Command->V1.ScatterList;
3124 DAC960_V1_ClearCommand(Command);
3126 if (Command->SegmentCount == 1)
3128 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3129 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Read;
3131 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Write;
3133 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3134 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3135 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3136 CommandMailbox->Type5.BusAddress =
3137 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3143 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3144 CommandMailbox->Type5.CommandOpcode = DAC960_V1_ReadWithScatterGather;
3146 CommandMailbox->Type5.CommandOpcode = DAC960_V1_WriteWithScatterGather;
3148 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3149 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3150 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3151 CommandMailbox->Type5.BusAddress = Command->V1.ScatterGatherListDMA;
3153 CommandMailbox->Type5.ScatterGatherCount = Command->SegmentCount;
3155 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3156 ScatterGatherList->SegmentDataPointer =
3157 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3158 ScatterGatherList->SegmentByteCount =
3159 (DAC960_ByteCount32_T)sg_dma_len(ScatterList);
3162 DAC960_QueueCommand(Command);
3167 DAC960_V2_QueueReadWriteCommand prepares and queues a Read/Write Command for
3168 DAC960 V2 Firmware Controllers.
3171 static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *Command)
3173 DAC960_Controller_T *Controller = Command->Controller;
3174 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
3175 struct scatterlist *ScatterList = Command->V2.ScatterList;
3177 DAC960_V2_ClearCommand(Command);
3179 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10;
3180 CommandMailbox->SCSI_10.CommandControlBits.DataTransferControllerToHost =
3181 (Command->DmaDirection == PCI_DMA_FROMDEVICE);
3182 CommandMailbox->SCSI_10.DataTransferSize =
3183 Command->BlockCount << DAC960_BlockSizeBits;
3184 CommandMailbox->SCSI_10.RequestSenseBusAddress = Command->V2.RequestSenseDMA;
3185 CommandMailbox->SCSI_10.PhysicalDevice =
3186 Controller->V2.LogicalDriveToVirtualDevice[Command->LogicalDriveNumber];
3187 CommandMailbox->SCSI_10.RequestSenseSize = sizeof(DAC960_SCSI_RequestSense_T);
3188 CommandMailbox->SCSI_10.CDBLength = 10;
3189 CommandMailbox->SCSI_10.SCSI_CDB[0] =
3190 (Command->DmaDirection == PCI_DMA_FROMDEVICE ? 0x28 : 0x2A);
3191 CommandMailbox->SCSI_10.SCSI_CDB[2] = Command->BlockNumber >> 24;
3192 CommandMailbox->SCSI_10.SCSI_CDB[3] = Command->BlockNumber >> 16;
3193 CommandMailbox->SCSI_10.SCSI_CDB[4] = Command->BlockNumber >> 8;
3194 CommandMailbox->SCSI_10.SCSI_CDB[5] = Command->BlockNumber;
3195 CommandMailbox->SCSI_10.SCSI_CDB[7] = Command->BlockCount >> 8;
3196 CommandMailbox->SCSI_10.SCSI_CDB[8] = Command->BlockCount;
3198 if (Command->SegmentCount == 1)
3200 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3201 .ScatterGatherSegments[0]
3202 .SegmentDataPointer =
3203 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3204 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3205 .ScatterGatherSegments[0]
3207 CommandMailbox->SCSI_10.DataTransferSize;
3211 DAC960_V2_ScatterGatherSegment_T *ScatterGatherList;
3214 if (Command->SegmentCount > 2)
3216 ScatterGatherList = Command->V2.ScatterGatherList;
3217 CommandMailbox->SCSI_10.CommandControlBits
3218 .AdditionalScatterGatherListMemory = true;
3219 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3220 .ExtendedScatterGather.ScatterGatherList0Length = Command->SegmentCount;
3221 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3222 .ExtendedScatterGather.ScatterGatherList0Address =
3223 Command->V2.ScatterGatherListDMA;
3226 ScatterGatherList = CommandMailbox->SCSI_10.DataTransferMemoryAddress
3227 .ScatterGatherSegments;
3229 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3230 ScatterGatherList->SegmentDataPointer =
3231 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3232 ScatterGatherList->SegmentByteCount =
3233 (DAC960_ByteCount64_T)sg_dma_len(ScatterList);
3236 DAC960_QueueCommand(Command);
3241 DAC960_ProcessRequest attempts to remove one I/O Request from Controller's
3242 I/O Request Queue and queues it to the Controller. WaitForCommand is true if
3243 this function should wait for a Command to become available if necessary.
3244 This function returns true if an I/O Request was queued and false otherwise.
3247 static boolean DAC960_ProcessRequest(DAC960_Controller_T *Controller,
3248 boolean WaitForCommand)
3250 struct request_queue *RequestQueue = Controller->RequestQueue;
3251 struct request *Request;
3252 DAC960_Command_T *Command;
3254 if (!Controller->ControllerInitialized)
3258 Request = elv_next_request(RequestQueue);
3262 Command = DAC960_AllocateCommand(Controller);
3263 if (Command != NULL)
3266 if (!WaitForCommand)
3269 DAC960_WaitForCommand(Controller);
3271 if (rq_data_dir(Request) == READ) {
3272 Command->DmaDirection = PCI_DMA_FROMDEVICE;
3273 Command->CommandType = DAC960_ReadCommand;
3275 Command->DmaDirection = PCI_DMA_TODEVICE;
3276 Command->CommandType = DAC960_WriteCommand;
3278 Command->Completion = Request->waiting;
3279 Command->LogicalDriveNumber = (int)Request->rq_disk->private_data;
3280 Command->BlockNumber = Request->sector;
3281 Command->BlockCount = Request->nr_sectors;
3282 Command->Request = Request;
3283 blkdev_dequeue_request(Request);
3284 Command->SegmentCount = blk_rq_map_sg(Controller->RequestQueue,
3285 Command->Request, Command->cmd_sglist);
3286 /* pci_map_sg MAY change the value of SegCount */
3287 Command->SegmentCount = pci_map_sg(Command->PciDevice, Command->cmd_sglist,
3288 Command->SegmentCount, Command->DmaDirection);
3290 DAC960_QueueReadWriteCommand(Command);
3296 DAC960_queue_partial_rw extracts one bio from the request already
3297 associated with argument command, and construct a new command block to retry I/O
3298 only on that bio. Queue that command to the controller.
3300 This function re-uses a previously-allocated Command,
3301 there is no failure mode from trying to allocate a command.
3304 static void DAC960_queue_partial_rw(DAC960_Command_T *Command)
3306 DAC960_Controller_T *Controller = Command->Controller;
3307 struct request *Request = Command->Request;
3309 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3310 Command->CommandType = DAC960_ReadRetryCommand;
3312 Command->CommandType = DAC960_WriteRetryCommand;
3315 * We could be more efficient with these mapping requests
3316 * and map only the portions that we need. But since this
3317 * code should almost never be called, just go with a
3320 (void)blk_rq_map_sg(Controller->RequestQueue, Command->Request,
3321 Command->cmd_sglist);
3323 (void)pci_map_sg(Command->PciDevice, Command->cmd_sglist, 1,
3324 Command->DmaDirection);
3326 * Resubmitting the request sector at a time is really tedious.
3327 * But, this should almost never happen. So, we're willing to pay
3328 * this price so that in the end, as much of the transfer is completed
3329 * successfully as possible.
3331 Command->SegmentCount = 1;
3332 Command->BlockNumber = Request->sector;
3333 Command->BlockCount = 1;
3334 DAC960_QueueReadWriteCommand(Command);
3339 DAC960_RequestFunction is the I/O Request Function for DAC960 Controllers.
3342 static void DAC960_RequestFunction(struct request_queue *RequestQueue)
3345 while (DAC960_ProcessRequest(RequestQueue->queuedata, (i++ == 0)))
3350 DAC960_ProcessCompletedBuffer performs completion processing for an
3354 static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3355 boolean SuccessfulIO)
3357 struct request *Request = Command->Request;
3364 pci_unmap_sg(Command->PciDevice, Command->cmd_sglist,
3365 Command->SegmentCount, Command->DmaDirection);
3367 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
3369 end_that_request_last(Request);
3371 if (Command->Completion) {
3372 complete(Command->Completion);
3373 Command->Completion = NULL;
3381 DAC960_V1_ReadWriteError prints an appropriate error message for Command
3382 when an error occurs on a Read or Write operation.
3385 static void DAC960_V1_ReadWriteError(DAC960_Command_T *Command)
3387 DAC960_Controller_T *Controller = Command->Controller;
3388 unsigned char *CommandName = "UNKNOWN";
3389 switch (Command->CommandType)
3391 case DAC960_ReadCommand:
3392 case DAC960_ReadRetryCommand:
3393 CommandName = "READ";
3395 case DAC960_WriteCommand:
3396 case DAC960_WriteRetryCommand:
3397 CommandName = "WRITE";
3399 case DAC960_MonitoringCommand:
3400 case DAC960_ImmediateCommand:
3401 case DAC960_QueuedCommand:
3404 switch (Command->V1.CommandStatus)
3406 case DAC960_V1_IrrecoverableDataError:
3407 DAC960_Error("Irrecoverable Data Error on %s:\n",
3408 Controller, CommandName);
3410 case DAC960_V1_LogicalDriveNonexistentOrOffline:
3411 DAC960_Error("Logical Drive Nonexistent or Offline on %s:\n",
3412 Controller, CommandName);
3414 case DAC960_V1_AccessBeyondEndOfLogicalDrive:
3415 DAC960_Error("Attempt to Access Beyond End of Logical Drive "
3416 "on %s:\n", Controller, CommandName);
3418 case DAC960_V1_BadDataEncountered:
3419 DAC960_Error("Bad Data Encountered on %s:\n", Controller, CommandName);
3422 DAC960_Error("Unexpected Error Status %04X on %s:\n",
3423 Controller, Command->V1.CommandStatus, CommandName);
3426 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
3427 Controller, Controller->ControllerNumber,
3428 Command->LogicalDriveNumber, Command->BlockNumber,
3429 Command->BlockNumber + Command->BlockCount - 1);
3434 DAC960_V1_ProcessCompletedCommand performs completion processing for Command
3435 for DAC960 V1 Firmware Controllers.
3438 static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
3440 DAC960_Controller_T *Controller = Command->Controller;
3441 DAC960_CommandType_T CommandType = Command->CommandType;
3442 DAC960_V1_CommandOpcode_T CommandOpcode =
3443 Command->V1.CommandMailbox.Common.CommandOpcode;
3444 DAC960_V1_CommandStatus_T CommandStatus = Command->V1.CommandStatus;
3446 if (CommandType == DAC960_ReadCommand ||
3447 CommandType == DAC960_WriteCommand)
3450 #ifdef FORCE_RETRY_DEBUG
3451 CommandStatus = DAC960_V1_IrrecoverableDataError;
3454 if (CommandStatus == DAC960_V1_NormalCompletion) {
3456 if (!DAC960_ProcessCompletedRequest(Command, true))
3459 } else if (CommandStatus == DAC960_V1_IrrecoverableDataError ||
3460 CommandStatus == DAC960_V1_BadDataEncountered)
3463 * break the command down into pieces and resubmit each
3464 * piece, hoping that some of them will succeed.
3466 DAC960_queue_partial_rw(Command);
3471 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3472 DAC960_V1_ReadWriteError(Command);
3474 if (!DAC960_ProcessCompletedRequest(Command, false))
3478 else if (CommandType == DAC960_ReadRetryCommand ||
3479 CommandType == DAC960_WriteRetryCommand)
3481 boolean normal_completion;
3482 #ifdef FORCE_RETRY_FAILURE_DEBUG
3483 static int retry_count = 1;
3486 Perform completion processing for the portion that was
3487 retried, and submit the next portion, if any.
3489 normal_completion = true;
3490 if (CommandStatus != DAC960_V1_NormalCompletion) {
3491 normal_completion = false;
3492 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3493 DAC960_V1_ReadWriteError(Command);
3496 #ifdef FORCE_RETRY_FAILURE_DEBUG
3497 if (!(++retry_count % 10000)) {
3498 printk("V1 error retry failure test\n");
3499 normal_completion = false;
3500 DAC960_V1_ReadWriteError(Command);
3504 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
3505 DAC960_queue_partial_rw(Command);
3510 else if (CommandType == DAC960_MonitoringCommand)
3512 if (Controller->ShutdownMonitoringTimer)
3514 if (CommandOpcode == DAC960_V1_Enquiry)
3516 DAC960_V1_Enquiry_T *OldEnquiry = &Controller->V1.Enquiry;
3517 DAC960_V1_Enquiry_T *NewEnquiry = Controller->V1.NewEnquiry;
3518 unsigned int OldCriticalLogicalDriveCount =
3519 OldEnquiry->CriticalLogicalDriveCount;
3520 unsigned int NewCriticalLogicalDriveCount =
3521 NewEnquiry->CriticalLogicalDriveCount;
3522 if (NewEnquiry->NumberOfLogicalDrives > Controller->LogicalDriveCount)
3524 int LogicalDriveNumber = Controller->LogicalDriveCount - 1;
3525 while (++LogicalDriveNumber < NewEnquiry->NumberOfLogicalDrives)
3526 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3527 "Now Exists\n", Controller,
3529 Controller->ControllerNumber,
3530 LogicalDriveNumber);
3531 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3532 DAC960_ComputeGenericDiskInfo(Controller);
3534 if (NewEnquiry->NumberOfLogicalDrives < Controller->LogicalDriveCount)
3536 int LogicalDriveNumber = NewEnquiry->NumberOfLogicalDrives - 1;
3537 while (++LogicalDriveNumber < Controller->LogicalDriveCount)
3538 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3539 "No Longer Exists\n", Controller,
3541 Controller->ControllerNumber,
3542 LogicalDriveNumber);
3543 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3544 DAC960_ComputeGenericDiskInfo(Controller);
3546 if (NewEnquiry->StatusFlags.DeferredWriteError !=
3547 OldEnquiry->StatusFlags.DeferredWriteError)
3548 DAC960_Critical("Deferred Write Error Flag is now %s\n", Controller,
3549 (NewEnquiry->StatusFlags.DeferredWriteError
3550 ? "TRUE" : "FALSE"));
3551 if ((NewCriticalLogicalDriveCount > 0 ||
3552 NewCriticalLogicalDriveCount != OldCriticalLogicalDriveCount) ||
3553 (NewEnquiry->OfflineLogicalDriveCount > 0 ||
3554 NewEnquiry->OfflineLogicalDriveCount !=
3555 OldEnquiry->OfflineLogicalDriveCount) ||
3556 (NewEnquiry->DeadDriveCount > 0 ||
3557 NewEnquiry->DeadDriveCount !=
3558 OldEnquiry->DeadDriveCount) ||
3559 (NewEnquiry->EventLogSequenceNumber !=
3560 OldEnquiry->EventLogSequenceNumber) ||
3561 Controller->MonitoringTimerCount == 0 ||
3562 (jiffies - Controller->SecondaryMonitoringTime
3563 >= DAC960_SecondaryMonitoringInterval))
3565 Controller->V1.NeedLogicalDriveInformation = true;
3566 Controller->V1.NewEventLogSequenceNumber =
3567 NewEnquiry->EventLogSequenceNumber;
3568 Controller->V1.NeedErrorTableInformation = true;
3569 Controller->V1.NeedDeviceStateInformation = true;
3570 Controller->V1.StartDeviceStateScan = true;
3571 Controller->V1.NeedBackgroundInitializationStatus =
3572 Controller->V1.BackgroundInitializationStatusSupported;
3573 Controller->SecondaryMonitoringTime = jiffies;
3575 if (NewEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3576 NewEnquiry->RebuildFlag
3577 == DAC960_V1_BackgroundRebuildInProgress ||
3578 OldEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3579 OldEnquiry->RebuildFlag == DAC960_V1_BackgroundRebuildInProgress)
3581 Controller->V1.NeedRebuildProgress = true;
3582 Controller->V1.RebuildProgressFirst =
3583 (NewEnquiry->CriticalLogicalDriveCount <
3584 OldEnquiry->CriticalLogicalDriveCount);
3586 if (OldEnquiry->RebuildFlag == DAC960_V1_BackgroundCheckInProgress)
3587 switch (NewEnquiry->RebuildFlag)
3589 case DAC960_V1_NoStandbyRebuildOrCheckInProgress:
3590 DAC960_Progress("Consistency Check Completed Successfully\n",
3593 case DAC960_V1_StandbyRebuildInProgress:
3594 case DAC960_V1_BackgroundRebuildInProgress:
3596 case DAC960_V1_BackgroundCheckInProgress:
3597 Controller->V1.NeedConsistencyCheckProgress = true;
3599 case DAC960_V1_StandbyRebuildCompletedWithError:
3600 DAC960_Progress("Consistency Check Completed with Error\n",
3603 case DAC960_V1_BackgroundRebuildOrCheckFailed_DriveFailed:
3604 DAC960_Progress("Consistency Check Failed - "
3605 "Physical Device Failed\n", Controller);
3607 case DAC960_V1_BackgroundRebuildOrCheckFailed_LogicalDriveFailed:
3608 DAC960_Progress("Consistency Check Failed - "
3609 "Logical Drive Failed\n", Controller);
3611 case DAC960_V1_BackgroundRebuildOrCheckFailed_OtherCauses:
3612 DAC960_Progress("Consistency Check Failed - Other Causes\n",
3615 case DAC960_V1_BackgroundRebuildOrCheckSuccessfullyTerminated:
3616 DAC960_Progress("Consistency Check Successfully Terminated\n",
3620 else if (NewEnquiry->RebuildFlag
3621 == DAC960_V1_BackgroundCheckInProgress)
3622 Controller->V1.NeedConsistencyCheckProgress = true;
3623 Controller->MonitoringAlertMode =
3624 (NewEnquiry->CriticalLogicalDriveCount > 0 ||
3625 NewEnquiry->OfflineLogicalDriveCount > 0 ||
3626 NewEnquiry->DeadDriveCount > 0);
3627 if (NewEnquiry->RebuildFlag > DAC960_V1_BackgroundCheckInProgress)
3629 Controller->V1.PendingRebuildFlag = NewEnquiry->RebuildFlag;
3630 Controller->V1.RebuildFlagPending = true;
3632 memcpy(&Controller->V1.Enquiry, &Controller->V1.NewEnquiry,
3633 sizeof(DAC960_V1_Enquiry_T));
3635 else if (CommandOpcode == DAC960_V1_PerformEventLogOperation)
3638 *DAC960_EventMessages[] =
3639 { "killed because write recovery failed",
3640 "killed because of SCSI bus reset failure",
3641 "killed because of double check condition",
3642 "killed because it was removed",
3643 "killed because of gross error on SCSI chip",
3644 "killed because of bad tag returned from drive",
3645 "killed because of timeout on SCSI command",
3646 "killed because of reset SCSI command issued from system",
3647 "killed because busy or parity error count exceeded limit",
3648 "killed because of 'kill drive' command from system",
3649 "killed because of selection timeout",
3650 "killed due to SCSI phase sequence error",
3651 "killed due to unknown status" };
3652 DAC960_V1_EventLogEntry_T *EventLogEntry =
3653 Controller->V1.EventLogEntry;
3654 if (EventLogEntry->SequenceNumber ==
3655 Controller->V1.OldEventLogSequenceNumber)
3657 unsigned char SenseKey = EventLogEntry->SenseKey;
3658 unsigned char AdditionalSenseCode =
3659 EventLogEntry->AdditionalSenseCode;
3660 unsigned char AdditionalSenseCodeQualifier =
3661 EventLogEntry->AdditionalSenseCodeQualifier;
3662 if (SenseKey == DAC960_SenseKey_VendorSpecific &&
3663 AdditionalSenseCode == 0x80 &&
3664 AdditionalSenseCodeQualifier <
3665 sizeof(DAC960_EventMessages) / sizeof(char *))
3666 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
3667 EventLogEntry->Channel,
3668 EventLogEntry->TargetID,
3669 DAC960_EventMessages[
3670 AdditionalSenseCodeQualifier]);
3671 else if (SenseKey == DAC960_SenseKey_UnitAttention &&
3672 AdditionalSenseCode == 0x29)
3674 if (Controller->MonitoringTimerCount > 0)
3675 Controller->V1.DeviceResetCount[EventLogEntry->Channel]
3676 [EventLogEntry->TargetID]++;
3678 else if (!(SenseKey == DAC960_SenseKey_NoSense ||
3679 (SenseKey == DAC960_SenseKey_NotReady &&
3680 AdditionalSenseCode == 0x04 &&
3681 (AdditionalSenseCodeQualifier == 0x01 ||
3682 AdditionalSenseCodeQualifier == 0x02))))
3684 DAC960_Critical("Physical Device %d:%d Error Log: "
3685 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
3687 EventLogEntry->Channel,
3688 EventLogEntry->TargetID,
3690 AdditionalSenseCode,
3691 AdditionalSenseCodeQualifier);
3692 DAC960_Critical("Physical Device %d:%d Error Log: "
3693 "Information = %02X%02X%02X%02X "
3694 "%02X%02X%02X%02X\n",
3696 EventLogEntry->Channel,
3697 EventLogEntry->TargetID,
3698 EventLogEntry->Information[0],
3699 EventLogEntry->Information[1],
3700 EventLogEntry->Information[2],
3701 EventLogEntry->Information[3],
3702 EventLogEntry->CommandSpecificInformation[0],
3703 EventLogEntry->CommandSpecificInformation[1],
3704 EventLogEntry->CommandSpecificInformation[2],
3705 EventLogEntry->CommandSpecificInformation[3]);
3708 Controller->V1.OldEventLogSequenceNumber++;
3710 else if (CommandOpcode == DAC960_V1_GetErrorTable)
3712 DAC960_V1_ErrorTable_T *OldErrorTable = &Controller->V1.ErrorTable;
3713 DAC960_V1_ErrorTable_T *NewErrorTable = Controller->V1.NewErrorTable;
3714 int Channel, TargetID;
3715 for (Channel = 0; Channel < Controller->Channels; Channel++)
3716 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
3718 DAC960_V1_ErrorTableEntry_T *NewErrorEntry =
3719 &NewErrorTable->ErrorTableEntries[Channel][TargetID];
3720 DAC960_V1_ErrorTableEntry_T *OldErrorEntry =
3721 &OldErrorTable->ErrorTableEntries[Channel][TargetID];
3722 if ((NewErrorEntry->ParityErrorCount !=
3723 OldErrorEntry->ParityErrorCount) ||
3724 (NewErrorEntry->SoftErrorCount !=
3725 OldErrorEntry->SoftErrorCount) ||
3726 (NewErrorEntry->HardErrorCount !=
3727 OldErrorEntry->HardErrorCount) ||
3728 (NewErrorEntry->MiscErrorCount !=
3729 OldErrorEntry->MiscErrorCount))
3730 DAC960_Critical("Physical Device %d:%d Errors: "
3731 "Parity = %d, Soft = %d, "
3732 "Hard = %d, Misc = %d\n",
3733 Controller, Channel, TargetID,
3734 NewErrorEntry->ParityErrorCount,
3735 NewErrorEntry->SoftErrorCount,
3736 NewErrorEntry->HardErrorCount,
3737 NewErrorEntry->MiscErrorCount);
3739 memcpy(&Controller->V1.ErrorTable, Controller->V1.NewErrorTable,
3740 sizeof(DAC960_V1_ErrorTable_T));
3742 else if (CommandOpcode == DAC960_V1_GetDeviceState)
3744 DAC960_V1_DeviceState_T *OldDeviceState =
3745 &Controller->V1.DeviceState[Controller->V1.DeviceStateChannel]
3746 [Controller->V1.DeviceStateTargetID];
3747 DAC960_V1_DeviceState_T *NewDeviceState =
3748 Controller->V1.NewDeviceState;
3749 if (NewDeviceState->DeviceState != OldDeviceState->DeviceState)
3750 DAC960_Critical("Physical Device %d:%d is now %s\n", Controller,
3751 Controller->V1.DeviceStateChannel,
3752 Controller->V1.DeviceStateTargetID,
3753 (NewDeviceState->DeviceState
3754 == DAC960_V1_Device_Dead
3756 : NewDeviceState->DeviceState
3757 == DAC960_V1_Device_WriteOnly
3759 : NewDeviceState->DeviceState
3760 == DAC960_V1_Device_Online
3761 ? "ONLINE" : "STANDBY"));
3762 if (OldDeviceState->DeviceState == DAC960_V1_Device_Dead &&
3763 NewDeviceState->DeviceState != DAC960_V1_Device_Dead)
3765 Controller->V1.NeedDeviceInquiryInformation = true;
3766 Controller->V1.NeedDeviceSerialNumberInformation = true;
3767 Controller->V1.DeviceResetCount
3768 [Controller->V1.DeviceStateChannel]
3769 [Controller->V1.DeviceStateTargetID] = 0;
3771 memcpy(OldDeviceState, NewDeviceState,
3772 sizeof(DAC960_V1_DeviceState_T));
3774 else if (CommandOpcode == DAC960_V1_GetLogicalDriveInformation)
3776 int LogicalDriveNumber;
3777 for (LogicalDriveNumber = 0;
3778 LogicalDriveNumber < Controller->LogicalDriveCount;
3779 LogicalDriveNumber++)
3781 DAC960_V1_LogicalDriveInformation_T *OldLogicalDriveInformation =
3782 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
3783 DAC960_V1_LogicalDriveInformation_T *NewLogicalDriveInformation =
3784 &(*Controller->V1.NewLogicalDriveInformation)[LogicalDriveNumber];
3785 if (NewLogicalDriveInformation->LogicalDriveState !=
3786 OldLogicalDriveInformation->LogicalDriveState)
3787 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3788 "is now %s\n", Controller,
3790 Controller->ControllerNumber,
3792 (NewLogicalDriveInformation->LogicalDriveState
3793 == DAC960_V1_LogicalDrive_Online
3795 : NewLogicalDriveInformation->LogicalDriveState
3796 == DAC960_V1_LogicalDrive_Critical
3797 ? "CRITICAL" : "OFFLINE"));
3798 if (NewLogicalDriveInformation->WriteBack !=
3799 OldLogicalDriveInformation->WriteBack)
3800 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3801 "is now %s\n", Controller,
3803 Controller->ControllerNumber,
3805 (NewLogicalDriveInformation->WriteBack
3806 ? "WRITE BACK" : "WRITE THRU"));
3808 memcpy(&Controller->V1.LogicalDriveInformation,
3809 Controller->V1.NewLogicalDriveInformation,
3810 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
3812 else if (CommandOpcode == DAC960_V1_GetRebuildProgress)
3814 unsigned int LogicalDriveNumber =
3815 Controller->V1.RebuildProgress->LogicalDriveNumber;
3816 unsigned int LogicalDriveSize =
3817 Controller->V1.RebuildProgress->LogicalDriveSize;
3818 unsigned int BlocksCompleted =
3819 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3820 if (CommandStatus == DAC960_V1_NoRebuildOrCheckInProgress &&
3821 Controller->V1.LastRebuildStatus == DAC960_V1_NormalCompletion)
3822 CommandStatus = DAC960_V1_RebuildSuccessful;
3823 switch (CommandStatus)
3825 case DAC960_V1_NormalCompletion:
3826 Controller->EphemeralProgressMessage = true;
3827 DAC960_Progress("Rebuild in Progress: "
3828 "Logical Drive %d (/dev/rd/c%dd%d) "
3830 Controller, LogicalDriveNumber,
3831 Controller->ControllerNumber,
3833 (100 * (BlocksCompleted >> 7))
3834 / (LogicalDriveSize >> 7));
3835 Controller->EphemeralProgressMessage = false;
3837 case DAC960_V1_RebuildFailed_LogicalDriveFailure:
3838 DAC960_Progress("Rebuild Failed due to "
3839 "Logical Drive Failure\n", Controller);
3841 case DAC960_V1_RebuildFailed_BadBlocksOnOther:
3842 DAC960_Progress("Rebuild Failed due to "
3843 "Bad Blocks on Other Drives\n", Controller);
3845 case DAC960_V1_RebuildFailed_NewDriveFailed:
3846 DAC960_Progress("Rebuild Failed due to "
3847 "Failure of Drive Being Rebuilt\n", Controller);
3849 case DAC960_V1_NoRebuildOrCheckInProgress:
3851 case DAC960_V1_RebuildSuccessful:
3852 DAC960_Progress("Rebuild Completed Successfully\n", Controller);
3854 case DAC960_V1_RebuildSuccessfullyTerminated:
3855 DAC960_Progress("Rebuild Successfully Terminated\n", Controller);
3858 Controller->V1.LastRebuildStatus = CommandStatus;
3859 if (CommandType != DAC960_MonitoringCommand &&
3860 Controller->V1.RebuildStatusPending)
3862 Command->V1.CommandStatus = Controller->V1.PendingRebuildStatus;
3863 Controller->V1.RebuildStatusPending = false;
3865 else if (CommandType == DAC960_MonitoringCommand &&
3866 CommandStatus != DAC960_V1_NormalCompletion &&
3867 CommandStatus != DAC960_V1_NoRebuildOrCheckInProgress)
3869 Controller->V1.PendingRebuildStatus = CommandStatus;
3870 Controller->V1.RebuildStatusPending = true;
3873 else if (CommandOpcode == DAC960_V1_RebuildStat)
3875 unsigned int LogicalDriveNumber =
3876 Controller->V1.RebuildProgress->LogicalDriveNumber;
3877 unsigned int LogicalDriveSize =
3878 Controller->V1.RebuildProgress->LogicalDriveSize;
3879 unsigned int BlocksCompleted =
3880 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3881 if (CommandStatus == DAC960_V1_NormalCompletion)
3883 Controller->EphemeralProgressMessage = true;
3884 DAC960_Progress("Consistency Check in Progress: "
3885 "Logical Drive %d (/dev/rd/c%dd%d) "
3887 Controller, LogicalDriveNumber,
3888 Controller->ControllerNumber,
3890 (100 * (BlocksCompleted >> 7))
3891 / (LogicalDriveSize >> 7));
3892 Controller->EphemeralProgressMessage = false;
3895 else if (CommandOpcode == DAC960_V1_BackgroundInitializationControl)
3897 unsigned int LogicalDriveNumber =
3898 Controller->V1.BackgroundInitializationStatus->LogicalDriveNumber;
3899 unsigned int LogicalDriveSize =
3900 Controller->V1.BackgroundInitializationStatus->LogicalDriveSize;
3901 unsigned int BlocksCompleted =
3902 Controller->V1.BackgroundInitializationStatus->BlocksCompleted;
3903 switch (CommandStatus)
3905 case DAC960_V1_NormalCompletion:
3906 switch (Controller->V1.BackgroundInitializationStatus->Status)
3908 case DAC960_V1_BackgroundInitializationInvalid:
3910 case DAC960_V1_BackgroundInitializationStarted:
3911 DAC960_Progress("Background Initialization Started\n",
3914 case DAC960_V1_BackgroundInitializationInProgress:
3915 if (BlocksCompleted ==
3916 Controller->V1.LastBackgroundInitializationStatus.
3918 LogicalDriveNumber ==
3919 Controller->V1.LastBackgroundInitializationStatus.
3922 Controller->EphemeralProgressMessage = true;
3923 DAC960_Progress("Background Initialization in Progress: "
3924 "Logical Drive %d (/dev/rd/c%dd%d) "
3926 Controller, LogicalDriveNumber,
3927 Controller->ControllerNumber,
3929 (100 * (BlocksCompleted >> 7))
3930 / (LogicalDriveSize >> 7));
3931 Controller->EphemeralProgressMessage = false;
3933 case DAC960_V1_BackgroundInitializationSuspended:
3934 DAC960_Progress("Background Initialization Suspended\n",
3937 case DAC960_V1_BackgroundInitializationCancelled:
3938 DAC960_Progress("Background Initialization Cancelled\n",
3942 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
3943 Controller->V1.BackgroundInitializationStatus,
3944 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
3946 case DAC960_V1_BackgroundInitSuccessful:
3947 if (Controller->V1.BackgroundInitializationStatus->Status ==
3948 DAC960_V1_BackgroundInitializationInProgress)
3949 DAC960_Progress("Background Initialization "
3950 "Completed Successfully\n", Controller);
3951 Controller->V1.BackgroundInitializationStatus->Status =
3952 DAC960_V1_BackgroundInitializationInvalid;
3954 case DAC960_V1_BackgroundInitAborted:
3955 if (Controller->V1.BackgroundInitializationStatus->Status ==
3956 DAC960_V1_BackgroundInitializationInProgress)
3957 DAC960_Progress("Background Initialization Aborted\n",
3959 Controller->V1.BackgroundInitializationStatus->Status =
3960 DAC960_V1_BackgroundInitializationInvalid;
3962 case DAC960_V1_NoBackgroundInitInProgress:
3966 else if (CommandOpcode == DAC960_V1_DCDB)
3971 The InquiryStandardData and
3972 the InquiryUntitSerialNumber information
3973 retrieval operations BOTH use the DAC960_V1_DCDB
3974 commands. the test above can't distinguish between
3977 Instead, we rely on the order of code later in this
3978 function to ensure that DeviceInquiryInformation commands
3979 are submitted before DeviceSerialNumber commands.
3981 if (Controller->V1.NeedDeviceInquiryInformation)
3983 DAC960_SCSI_Inquiry_T *InquiryStandardData =
3984 &Controller->V1.InquiryStandardData
3985 [Controller->V1.DeviceStateChannel]
3986 [Controller->V1.DeviceStateTargetID];
3987 if (CommandStatus != DAC960_V1_NormalCompletion)
3989 memset(InquiryStandardData, 0,
3990 sizeof(DAC960_SCSI_Inquiry_T));
3991 InquiryStandardData->PeripheralDeviceType = 0x1F;
3994 memcpy(InquiryStandardData,
3995 Controller->V1.NewInquiryStandardData,
3996 sizeof(DAC960_SCSI_Inquiry_T));
3997 Controller->V1.NeedDeviceInquiryInformation = false;
3999 else if (Controller->V1.NeedDeviceSerialNumberInformation)
4001 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4002 &Controller->V1.InquiryUnitSerialNumber
4003 [Controller->V1.DeviceStateChannel]
4004 [Controller->V1.DeviceStateTargetID];
4005 if (CommandStatus != DAC960_V1_NormalCompletion)
4007 memset(InquiryUnitSerialNumber, 0,
4008 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4009 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4012 memcpy(InquiryUnitSerialNumber,
4013 Controller->V1.NewInquiryUnitSerialNumber,
4014 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4015 Controller->V1.NeedDeviceSerialNumberInformation = false;
4019 Begin submitting new monitoring commands.
4021 if (Controller->V1.NewEventLogSequenceNumber
4022 - Controller->V1.OldEventLogSequenceNumber > 0)
4024 Command->V1.CommandMailbox.Type3E.CommandOpcode =
4025 DAC960_V1_PerformEventLogOperation;
4026 Command->V1.CommandMailbox.Type3E.OperationType =
4027 DAC960_V1_GetEventLogEntry;
4028 Command->V1.CommandMailbox.Type3E.OperationQualifier = 1;
4029 Command->V1.CommandMailbox.Type3E.SequenceNumber =
4030 Controller->V1.OldEventLogSequenceNumber;
4031 Command->V1.CommandMailbox.Type3E.BusAddress =
4032 Controller->V1.EventLogEntryDMA;
4033 DAC960_QueueCommand(Command);
4036 if (Controller->V1.NeedErrorTableInformation)
4038 Controller->V1.NeedErrorTableInformation = false;
4039 Command->V1.CommandMailbox.Type3.CommandOpcode =
4040 DAC960_V1_GetErrorTable;
4041 Command->V1.CommandMailbox.Type3.BusAddress =
4042 Controller->V1.NewErrorTableDMA;
4043 DAC960_QueueCommand(Command);
4046 if (Controller->V1.NeedRebuildProgress &&
4047 Controller->V1.RebuildProgressFirst)
4049 Controller->V1.NeedRebuildProgress = false;
4050 Command->V1.CommandMailbox.Type3.CommandOpcode =
4051 DAC960_V1_GetRebuildProgress;
4052 Command->V1.CommandMailbox.Type3.BusAddress =
4053 Controller->V1.RebuildProgressDMA;
4054 DAC960_QueueCommand(Command);
4057 if (Controller->V1.NeedDeviceStateInformation)
4059 if (Controller->V1.NeedDeviceInquiryInformation)
4061 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4062 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4064 dma_addr_t NewInquiryStandardDataDMA =
4065 Controller->V1.NewInquiryStandardDataDMA;
4067 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4068 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4069 DCDB->Channel = Controller->V1.DeviceStateChannel;
4070 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4071 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4072 DCDB->EarlyStatus = false;
4073 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4074 DCDB->NoAutomaticRequestSense = false;
4075 DCDB->DisconnectPermitted = true;
4076 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
4077 DCDB->BusAddress = NewInquiryStandardDataDMA;
4078 DCDB->CDBLength = 6;
4079 DCDB->TransferLengthHigh4 = 0;
4080 DCDB->SenseLength = sizeof(DCDB->SenseData);
4081 DCDB->CDB[0] = 0x12; /* INQUIRY */
4082 DCDB->CDB[1] = 0; /* EVPD = 0 */
4083 DCDB->CDB[2] = 0; /* Page Code */
4084 DCDB->CDB[3] = 0; /* Reserved */
4085 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
4086 DCDB->CDB[5] = 0; /* Control */
4087 DAC960_QueueCommand(Command);
4090 if (Controller->V1.NeedDeviceSerialNumberInformation)
4092 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4093 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4094 dma_addr_t NewInquiryUnitSerialNumberDMA =
4095 Controller->V1.NewInquiryUnitSerialNumberDMA;
4097 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4098 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4099 DCDB->Channel = Controller->V1.DeviceStateChannel;
4100 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4101 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4102 DCDB->EarlyStatus = false;
4103 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4104 DCDB->NoAutomaticRequestSense = false;
4105 DCDB->DisconnectPermitted = true;
4106 DCDB->TransferLength =
4107 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4108 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
4109 DCDB->CDBLength = 6;
4110 DCDB->TransferLengthHigh4 = 0;
4111 DCDB->SenseLength = sizeof(DCDB->SenseData);
4112 DCDB->CDB[0] = 0x12; /* INQUIRY */
4113 DCDB->CDB[1] = 1; /* EVPD = 1 */
4114 DCDB->CDB[2] = 0x80; /* Page Code */
4115 DCDB->CDB[3] = 0; /* Reserved */
4116 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4117 DCDB->CDB[5] = 0; /* Control */
4118 DAC960_QueueCommand(Command);
4121 if (Controller->V1.StartDeviceStateScan)
4123 Controller->V1.DeviceStateChannel = 0;
4124 Controller->V1.DeviceStateTargetID = 0;
4125 Controller->V1.StartDeviceStateScan = false;
4127 else if (++Controller->V1.DeviceStateTargetID == Controller->Targets)
4129 Controller->V1.DeviceStateChannel++;
4130 Controller->V1.DeviceStateTargetID = 0;
4132 if (Controller->V1.DeviceStateChannel < Controller->Channels)
4134 Controller->V1.NewDeviceState->DeviceState =
4135 DAC960_V1_Device_Dead;
4136 Command->V1.CommandMailbox.Type3D.CommandOpcode =
4137 DAC960_V1_GetDeviceState;
4138 Command->V1.CommandMailbox.Type3D.Channel =
4139 Controller->V1.DeviceStateChannel;
4140 Command->V1.CommandMailbox.Type3D.TargetID =
4141 Controller->V1.DeviceStateTargetID;
4142 Command->V1.CommandMailbox.Type3D.BusAddress =
4143 Controller->V1.NewDeviceStateDMA;
4144 DAC960_QueueCommand(Command);
4147 Controller->V1.NeedDeviceStateInformation = false;
4149 if (Controller->V1.NeedLogicalDriveInformation)
4151 Controller->V1.NeedLogicalDriveInformation = false;
4152 Command->V1.CommandMailbox.Type3.CommandOpcode =
4153 DAC960_V1_GetLogicalDriveInformation;
4154 Command->V1.CommandMailbox.Type3.BusAddress =
4155 Controller->V1.NewLogicalDriveInformationDMA;
4156 DAC960_QueueCommand(Command);
4159 if (Controller->V1.NeedRebuildProgress)
4161 Controller->V1.NeedRebuildProgress = false;
4162 Command->V1.CommandMailbox.Type3.CommandOpcode =
4163 DAC960_V1_GetRebuildProgress;
4164 Command->V1.CommandMailbox.Type3.BusAddress =
4165 Controller->V1.RebuildProgressDMA;
4166 DAC960_QueueCommand(Command);
4169 if (Controller->V1.NeedConsistencyCheckProgress)
4171 Controller->V1.NeedConsistencyCheckProgress = false;
4172 Command->V1.CommandMailbox.Type3.CommandOpcode =
4173 DAC960_V1_RebuildStat;
4174 Command->V1.CommandMailbox.Type3.BusAddress =
4175 Controller->V1.RebuildProgressDMA;
4176 DAC960_QueueCommand(Command);
4179 if (Controller->V1.NeedBackgroundInitializationStatus)
4181 Controller->V1.NeedBackgroundInitializationStatus = false;
4182 Command->V1.CommandMailbox.Type3B.CommandOpcode =
4183 DAC960_V1_BackgroundInitializationControl;
4184 Command->V1.CommandMailbox.Type3B.CommandOpcode2 = 0x20;
4185 Command->V1.CommandMailbox.Type3B.BusAddress =
4186 Controller->V1.BackgroundInitializationStatusDMA;
4187 DAC960_QueueCommand(Command);
4190 Controller->MonitoringTimerCount++;
4191 Controller->MonitoringTimer.expires =
4192 jiffies + DAC960_MonitoringTimerInterval;
4193 add_timer(&Controller->MonitoringTimer);
4195 if (CommandType == DAC960_ImmediateCommand)
4197 complete(Command->Completion);
4198 Command->Completion = NULL;
4201 if (CommandType == DAC960_QueuedCommand)
4203 DAC960_V1_KernelCommand_T *KernelCommand = Command->V1.KernelCommand;
4204 KernelCommand->CommandStatus = Command->V1.CommandStatus;
4205 Command->V1.KernelCommand = NULL;
4206 if (CommandOpcode == DAC960_V1_DCDB)
4207 Controller->V1.DirectCommandActive[KernelCommand->DCDB->Channel]
4208 [KernelCommand->DCDB->TargetID] =
4210 DAC960_DeallocateCommand(Command);
4211 KernelCommand->CompletionFunction(KernelCommand);
4215 Queue a Status Monitoring Command to the Controller using the just
4216 completed Command if one was deferred previously due to lack of a
4217 free Command when the Monitoring Timer Function was called.
4219 if (Controller->MonitoringCommandDeferred)
4221 Controller->MonitoringCommandDeferred = false;
4222 DAC960_V1_QueueMonitoringCommand(Command);
4226 Deallocate the Command.
4228 DAC960_DeallocateCommand(Command);
4230 Wake up any processes waiting on a free Command.
4232 wake_up(&Controller->CommandWaitQueue);
4237 DAC960_V2_ReadWriteError prints an appropriate error message for Command
4238 when an error occurs on a Read or Write operation.
4241 static void DAC960_V2_ReadWriteError(DAC960_Command_T *Command)
4243 DAC960_Controller_T *Controller = Command->Controller;
4244 unsigned char *SenseErrors[] = { "NO SENSE", "RECOVERED ERROR",
4245 "NOT READY", "MEDIUM ERROR",
4246 "HARDWARE ERROR", "ILLEGAL REQUEST",
4247 "UNIT ATTENTION", "DATA PROTECT",
4248 "BLANK CHECK", "VENDOR-SPECIFIC",
4249 "COPY ABORTED", "ABORTED COMMAND",
4250 "EQUAL", "VOLUME OVERFLOW",
4251 "MISCOMPARE", "RESERVED" };
4252 unsigned char *CommandName = "UNKNOWN";
4253 switch (Command->CommandType)
4255 case DAC960_ReadCommand:
4256 case DAC960_ReadRetryCommand:
4257 CommandName = "READ";
4259 case DAC960_WriteCommand:
4260 case DAC960_WriteRetryCommand:
4261 CommandName = "WRITE";
4263 case DAC960_MonitoringCommand:
4264 case DAC960_ImmediateCommand:
4265 case DAC960_QueuedCommand:
4268 DAC960_Error("Error Condition %s on %s:\n", Controller,
4269 SenseErrors[Command->V2.RequestSense->SenseKey], CommandName);
4270 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
4271 Controller, Controller->ControllerNumber,
4272 Command->LogicalDriveNumber, Command->BlockNumber,
4273 Command->BlockNumber + Command->BlockCount - 1);
4278 DAC960_V2_ReportEvent prints an appropriate message when a Controller Event
4282 static void DAC960_V2_ReportEvent(DAC960_Controller_T *Controller,
4283 DAC960_V2_Event_T *Event)
4285 DAC960_SCSI_RequestSense_T *RequestSense =
4286 (DAC960_SCSI_RequestSense_T *) &Event->RequestSenseData;
4287 unsigned char MessageBuffer[DAC960_LineBufferSize];
4288 static struct { int EventCode; unsigned char *EventMessage; } EventList[] =
4289 { /* Physical Device Events (0x0000 - 0x007F) */
4290 { 0x0001, "P Online" },
4291 { 0x0002, "P Standby" },
4292 { 0x0005, "P Automatic Rebuild Started" },
4293 { 0x0006, "P Manual Rebuild Started" },
4294 { 0x0007, "P Rebuild Completed" },
4295 { 0x0008, "P Rebuild Cancelled" },
4296 { 0x0009, "P Rebuild Failed for Unknown Reasons" },
4297 { 0x000A, "P Rebuild Failed due to New Physical Device" },
4298 { 0x000B, "P Rebuild Failed due to Logical Drive Failure" },
4299 { 0x000C, "S Offline" },
4300 { 0x000D, "P Found" },
4301 { 0x000E, "P Removed" },
4302 { 0x000F, "P Unconfigured" },
4303 { 0x0010, "P Expand Capacity Started" },
4304 { 0x0011, "P Expand Capacity Completed" },
4305 { 0x0012, "P Expand Capacity Failed" },
4306 { 0x0013, "P Command Timed Out" },
4307 { 0x0014, "P Command Aborted" },
4308 { 0x0015, "P Command Retried" },
4309 { 0x0016, "P Parity Error" },
4310 { 0x0017, "P Soft Error" },
4311 { 0x0018, "P Miscellaneous Error" },
4312 { 0x0019, "P Reset" },
4313 { 0x001A, "P Active Spare Found" },
4314 { 0x001B, "P Warm Spare Found" },
4315 { 0x001C, "S Sense Data Received" },
4316 { 0x001D, "P Initialization Started" },
4317 { 0x001E, "P Initialization Completed" },
4318 { 0x001F, "P Initialization Failed" },
4319 { 0x0020, "P Initialization Cancelled" },
4320 { 0x0021, "P Failed because Write Recovery Failed" },
4321 { 0x0022, "P Failed because SCSI Bus Reset Failed" },
4322 { 0x0023, "P Failed because of Double Check Condition" },
4323 { 0x0024, "P Failed because Device Cannot Be Accessed" },
4324 { 0x0025, "P Failed because of Gross Error on SCSI Processor" },
4325 { 0x0026, "P Failed because of Bad Tag from Device" },
4326 { 0x0027, "P Failed because of Command Timeout" },
4327 { 0x0028, "P Failed because of System Reset" },
4328 { 0x0029, "P Failed because of Busy Status or Parity Error" },
4329 { 0x002A, "P Failed because Host Set Device to Failed State" },
4330 { 0x002B, "P Failed because of Selection Timeout" },
4331 { 0x002C, "P Failed because of SCSI Bus Phase Error" },
4332 { 0x002D, "P Failed because Device Returned Unknown Status" },
4333 { 0x002E, "P Failed because Device Not Ready" },
4334 { 0x002F, "P Failed because Device Not Found at Startup" },
4335 { 0x0030, "P Failed because COD Write Operation Failed" },
4336 { 0x0031, "P Failed because BDT Write Operation Failed" },
4337 { 0x0039, "P Missing at Startup" },
4338 { 0x003A, "P Start Rebuild Failed due to Physical Drive Too Small" },
4339 { 0x003C, "P Temporarily Offline Device Automatically Made Online" },
4340 { 0x003D, "P Standby Rebuild Started" },
4341 /* Logical Device Events (0x0080 - 0x00FF) */
4342 { 0x0080, "M Consistency Check Started" },
4343 { 0x0081, "M Consistency Check Completed" },
4344 { 0x0082, "M Consistency Check Cancelled" },
4345 { 0x0083, "M Consistency Check Completed With Errors" },
4346 { 0x0084, "M Consistency Check Failed due to Logical Drive Failure" },
4347 { 0x0085, "M Consistency Check Failed due to Physical Device Failure" },
4348 { 0x0086, "L Offline" },
4349 { 0x0087, "L Critical" },
4350 { 0x0088, "L Online" },
4351 { 0x0089, "M Automatic Rebuild Started" },
4352 { 0x008A, "M Manual Rebuild Started" },
4353 { 0x008B, "M Rebuild Completed" },
4354 { 0x008C, "M Rebuild Cancelled" },
4355 { 0x008D, "M Rebuild Failed for Unknown Reasons" },
4356 { 0x008E, "M Rebuild Failed due to New Physical Device" },
4357 { 0x008F, "M Rebuild Failed due to Logical Drive Failure" },
4358 { 0x0090, "M Initialization Started" },
4359 { 0x0091, "M Initialization Completed" },
4360 { 0x0092, "M Initialization Cancelled" },
4361 { 0x0093, "M Initialization Failed" },
4362 { 0x0094, "L Found" },
4363 { 0x0095, "L Deleted" },
4364 { 0x0096, "M Expand Capacity Started" },
4365 { 0x0097, "M Expand Capacity Completed" },
4366 { 0x0098, "M Expand Capacity Failed" },
4367 { 0x0099, "L Bad Block Found" },
4368 { 0x009A, "L Size Changed" },
4369 { 0x009B, "L Type Changed" },
4370 { 0x009C, "L Bad Data Block Found" },
4371 { 0x009E, "L Read of Data Block in BDT" },
4372 { 0x009F, "L Write Back Data for Disk Block Lost" },
4373 { 0x00A0, "L Temporarily Offline RAID-5/3 Drive Made Online" },
4374 { 0x00A1, "L Temporarily Offline RAID-6/1/0/7 Drive Made Online" },
4375 { 0x00A2, "L Standby Rebuild Started" },
4376 /* Fault Management Events (0x0100 - 0x017F) */
4377 { 0x0140, "E Fan %d Failed" },
4378 { 0x0141, "E Fan %d OK" },
4379 { 0x0142, "E Fan %d Not Present" },
4380 { 0x0143, "E Power Supply %d Failed" },
4381 { 0x0144, "E Power Supply %d OK" },
4382 { 0x0145, "E Power Supply %d Not Present" },
4383 { 0x0146, "E Temperature Sensor %d Temperature Exceeds Safe Limit" },
4384 { 0x0147, "E Temperature Sensor %d Temperature Exceeds Working Limit" },
4385 { 0x0148, "E Temperature Sensor %d Temperature Normal" },
4386 { 0x0149, "E Temperature Sensor %d Not Present" },
4387 { 0x014A, "E Enclosure Management Unit %d Access Critical" },
4388 { 0x014B, "E Enclosure Management Unit %d Access OK" },
4389 { 0x014C, "E Enclosure Management Unit %d Access Offline" },
4390 /* Controller Events (0x0180 - 0x01FF) */
4391 { 0x0181, "C Cache Write Back Error" },
4392 { 0x0188, "C Battery Backup Unit Found" },
4393 { 0x0189, "C Battery Backup Unit Charge Level Low" },
4394 { 0x018A, "C Battery Backup Unit Charge Level OK" },
4395 { 0x0193, "C Installation Aborted" },
4396 { 0x0195, "C Battery Backup Unit Physically Removed" },
4397 { 0x0196, "C Memory Error During Warm Boot" },
4398 { 0x019E, "C Memory Soft ECC Error Corrected" },
4399 { 0x019F, "C Memory Hard ECC Error Corrected" },
4400 { 0x01A2, "C Battery Backup Unit Failed" },
4401 { 0x01AB, "C Mirror Race Recovery Failed" },
4402 { 0x01AC, "C Mirror Race on Critical Drive" },
4403 /* Controller Internal Processor Events */
4404 { 0x0380, "C Internal Controller Hung" },
4405 { 0x0381, "C Internal Controller Firmware Breakpoint" },
4406 { 0x0390, "C Internal Controller i960 Processor Specific Error" },
4407 { 0x03A0, "C Internal Controller StrongARM Processor Specific Error" },
4409 int EventListIndex = 0, EventCode;
4410 unsigned char EventType, *EventMessage;
4411 if (Event->EventCode == 0x1C &&
4412 RequestSense->SenseKey == DAC960_SenseKey_VendorSpecific &&
4413 (RequestSense->AdditionalSenseCode == 0x80 ||
4414 RequestSense->AdditionalSenseCode == 0x81))
4415 Event->EventCode = ((RequestSense->AdditionalSenseCode - 0x80) << 8) |
4416 RequestSense->AdditionalSenseCodeQualifier;
4419 EventCode = EventList[EventListIndex].EventCode;
4420 if (EventCode == Event->EventCode || EventCode == 0) break;
4423 EventType = EventList[EventListIndex].EventMessage[0];
4424 EventMessage = &EventList[EventListIndex].EventMessage[2];
4427 DAC960_Critical("Unknown Controller Event Code %04X\n",
4428 Controller, Event->EventCode);
4434 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4435 Event->Channel, Event->TargetID, EventMessage);
4438 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4439 Event->LogicalUnit, Controller->ControllerNumber,
4440 Event->LogicalUnit, EventMessage);
4443 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4444 Event->LogicalUnit, Controller->ControllerNumber,
4445 Event->LogicalUnit, EventMessage);
4448 if (RequestSense->SenseKey == DAC960_SenseKey_NoSense ||
4449 (RequestSense->SenseKey == DAC960_SenseKey_NotReady &&
4450 RequestSense->AdditionalSenseCode == 0x04 &&
4451 (RequestSense->AdditionalSenseCodeQualifier == 0x01 ||
4452 RequestSense->AdditionalSenseCodeQualifier == 0x02)))
4454 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4455 Event->Channel, Event->TargetID, EventMessage);
4456 DAC960_Critical("Physical Device %d:%d Request Sense: "
4457 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
4461 RequestSense->SenseKey,
4462 RequestSense->AdditionalSenseCode,
4463 RequestSense->AdditionalSenseCodeQualifier);
4464 DAC960_Critical("Physical Device %d:%d Request Sense: "
4465 "Information = %02X%02X%02X%02X "
4466 "%02X%02X%02X%02X\n",
4470 RequestSense->Information[0],
4471 RequestSense->Information[1],
4472 RequestSense->Information[2],
4473 RequestSense->Information[3],
4474 RequestSense->CommandSpecificInformation[0],
4475 RequestSense->CommandSpecificInformation[1],
4476 RequestSense->CommandSpecificInformation[2],
4477 RequestSense->CommandSpecificInformation[3]);
4480 if (Controller->SuppressEnclosureMessages) break;
4481 sprintf(MessageBuffer, EventMessage, Event->LogicalUnit);
4482 DAC960_Critical("Enclosure %d %s\n", Controller,
4483 Event->TargetID, MessageBuffer);
4486 DAC960_Critical("Controller %s\n", Controller, EventMessage);
4489 DAC960_Critical("Unknown Controller Event Code %04X\n",
4490 Controller, Event->EventCode);
4497 DAC960_V2_ReportProgress prints an appropriate progress message for
4498 Logical Device Long Operations.
4501 static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller,
4502 unsigned char *MessageString,
4503 unsigned int LogicalDeviceNumber,
4504 unsigned long BlocksCompleted,
4505 unsigned long LogicalDeviceSize)
4507 Controller->EphemeralProgressMessage = true;
4508 DAC960_Progress("%s in Progress: Logical Drive %d (/dev/rd/c%dd%d) "
4509 "%d%% completed\n", Controller,
4511 LogicalDeviceNumber,
4512 Controller->ControllerNumber,
4513 LogicalDeviceNumber,
4514 (100 * (BlocksCompleted >> 7)) / (LogicalDeviceSize >> 7));
4515 Controller->EphemeralProgressMessage = false;
4520 DAC960_V2_ProcessCompletedCommand performs completion processing for Command
4521 for DAC960 V2 Firmware Controllers.
4524 static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4526 DAC960_Controller_T *Controller = Command->Controller;
4527 DAC960_CommandType_T CommandType = Command->CommandType;
4528 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
4529 DAC960_V2_IOCTL_Opcode_T CommandOpcode = CommandMailbox->Common.IOCTL_Opcode;
4530 DAC960_V2_CommandStatus_T CommandStatus = Command->V2.CommandStatus;
4532 if (CommandType == DAC960_ReadCommand ||
4533 CommandType == DAC960_WriteCommand)
4536 #ifdef FORCE_RETRY_DEBUG
4537 CommandStatus = DAC960_V2_AbormalCompletion;
4539 Command->V2.RequestSense->SenseKey = DAC960_SenseKey_MediumError;
4541 if (CommandStatus == DAC960_V2_NormalCompletion) {
4543 if (!DAC960_ProcessCompletedRequest(Command, true))
4546 } else if (Command->V2.RequestSense->SenseKey == DAC960_SenseKey_MediumError)
4549 * break the command down into pieces and resubmit each
4550 * piece, hoping that some of them will succeed.
4552 DAC960_queue_partial_rw(Command);
4557 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4558 DAC960_V2_ReadWriteError(Command);
4560 Perform completion processing for all buffers in this I/O Request.
4562 (void)DAC960_ProcessCompletedRequest(Command, false);
4565 else if (CommandType == DAC960_ReadRetryCommand ||
4566 CommandType == DAC960_WriteRetryCommand)
4568 boolean normal_completion;
4570 #ifdef FORCE_RETRY_FAILURE_DEBUG
4571 static int retry_count = 1;
4574 Perform completion processing for the portion that was
4575 retried, and submit the next portion, if any.
4577 normal_completion = true;
4578 if (CommandStatus != DAC960_V2_NormalCompletion) {
4579 normal_completion = false;
4580 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4581 DAC960_V2_ReadWriteError(Command);
4584 #ifdef FORCE_RETRY_FAILURE_DEBUG
4585 if (!(++retry_count % 10000)) {
4586 printk("V2 error retry failure test\n");
4587 normal_completion = false;
4588 DAC960_V2_ReadWriteError(Command);
4592 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
4593 DAC960_queue_partial_rw(Command);
4597 else if (CommandType == DAC960_MonitoringCommand)
4599 if (Controller->ShutdownMonitoringTimer)
4601 if (CommandOpcode == DAC960_V2_GetControllerInfo)
4603 DAC960_V2_ControllerInfo_T *NewControllerInfo =
4604 Controller->V2.NewControllerInformation;
4605 DAC960_V2_ControllerInfo_T *ControllerInfo =
4606 &Controller->V2.ControllerInformation;
4607 Controller->LogicalDriveCount =
4608 NewControllerInfo->LogicalDevicesPresent;
4609 Controller->V2.NeedLogicalDeviceInformation = true;
4610 Controller->V2.NeedPhysicalDeviceInformation = true;
4611 Controller->V2.StartLogicalDeviceInformationScan = true;
4612 Controller->V2.StartPhysicalDeviceInformationScan = true;
4613 Controller->MonitoringAlertMode =
4614 (NewControllerInfo->LogicalDevicesCritical > 0 ||
4615 NewControllerInfo->LogicalDevicesOffline > 0 ||
4616 NewControllerInfo->PhysicalDisksCritical > 0 ||
4617 NewControllerInfo->PhysicalDisksOffline > 0);
4618 memcpy(ControllerInfo, NewControllerInfo,
4619 sizeof(DAC960_V2_ControllerInfo_T));
4621 else if (CommandOpcode == DAC960_V2_GetEvent)
4623 if (CommandStatus == DAC960_V2_NormalCompletion) {
4624 DAC960_V2_ReportEvent(Controller, Controller->V2.Event);
4626 Controller->V2.NextEventSequenceNumber++;
4628 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid &&
4629 CommandStatus == DAC960_V2_NormalCompletion)
4631 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
4632 Controller->V2.NewPhysicalDeviceInformation;
4633 unsigned int PhysicalDeviceIndex = Controller->V2.PhysicalDeviceIndex;
4634 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4635 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4636 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4637 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4638 unsigned int DeviceIndex;
4639 while (PhysicalDeviceInfo != NULL &&
4640 (NewPhysicalDeviceInfo->Channel >
4641 PhysicalDeviceInfo->Channel ||
4642 (NewPhysicalDeviceInfo->Channel ==
4643 PhysicalDeviceInfo->Channel &&
4644 (NewPhysicalDeviceInfo->TargetID >
4645 PhysicalDeviceInfo->TargetID ||
4646 (NewPhysicalDeviceInfo->TargetID ==
4647 PhysicalDeviceInfo->TargetID &&
4648 NewPhysicalDeviceInfo->LogicalUnit >
4649 PhysicalDeviceInfo->LogicalUnit)))))
4651 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4653 PhysicalDeviceInfo->Channel,
4654 PhysicalDeviceInfo->TargetID);
4655 Controller->V2.PhysicalDeviceInformation
4656 [PhysicalDeviceIndex] = NULL;
4657 Controller->V2.InquiryUnitSerialNumber
4658 [PhysicalDeviceIndex] = NULL;
4659 kfree(PhysicalDeviceInfo);
4660 kfree(InquiryUnitSerialNumber);
4661 for (DeviceIndex = PhysicalDeviceIndex;
4662 DeviceIndex < DAC960_V2_MaxPhysicalDevices - 1;
4665 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4666 Controller->V2.PhysicalDeviceInformation[DeviceIndex+1];
4667 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4668 Controller->V2.InquiryUnitSerialNumber[DeviceIndex+1];
4670 Controller->V2.PhysicalDeviceInformation
4671 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4672 Controller->V2.InquiryUnitSerialNumber
4673 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4674 PhysicalDeviceInfo =
4675 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4676 InquiryUnitSerialNumber =
4677 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4679 if (PhysicalDeviceInfo == NULL ||
4680 (NewPhysicalDeviceInfo->Channel !=
4681 PhysicalDeviceInfo->Channel) ||
4682 (NewPhysicalDeviceInfo->TargetID !=
4683 PhysicalDeviceInfo->TargetID) ||
4684 (NewPhysicalDeviceInfo->LogicalUnit !=
4685 PhysicalDeviceInfo->LogicalUnit))
4687 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
4688 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
4689 InquiryUnitSerialNumber =
4690 (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
4691 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
4693 if (InquiryUnitSerialNumber == NULL &&
4694 PhysicalDeviceInfo != NULL)
4696 kfree(PhysicalDeviceInfo);
4697 PhysicalDeviceInfo = NULL;
4699 DAC960_Critical("Physical Device %d:%d Now Exists%s\n",
4701 NewPhysicalDeviceInfo->Channel,
4702 NewPhysicalDeviceInfo->TargetID,
4703 (PhysicalDeviceInfo != NULL
4704 ? "" : " - Allocation Failed"));
4705 if (PhysicalDeviceInfo != NULL)
4707 memset(PhysicalDeviceInfo, 0,
4708 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4709 PhysicalDeviceInfo->PhysicalDeviceState =
4710 DAC960_V2_Device_InvalidState;
4711 memset(InquiryUnitSerialNumber, 0,
4712 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4713 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4714 for (DeviceIndex = DAC960_V2_MaxPhysicalDevices - 1;
4715 DeviceIndex > PhysicalDeviceIndex;
4718 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4719 Controller->V2.PhysicalDeviceInformation[DeviceIndex-1];
4720 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4721 Controller->V2.InquiryUnitSerialNumber[DeviceIndex-1];
4723 Controller->V2.PhysicalDeviceInformation
4724 [PhysicalDeviceIndex] =
4726 Controller->V2.InquiryUnitSerialNumber
4727 [PhysicalDeviceIndex] =
4728 InquiryUnitSerialNumber;
4729 Controller->V2.NeedDeviceSerialNumberInformation = true;
4732 if (PhysicalDeviceInfo != NULL)
4734 if (NewPhysicalDeviceInfo->PhysicalDeviceState !=
4735 PhysicalDeviceInfo->PhysicalDeviceState)
4737 "Physical Device %d:%d is now %s\n", Controller,
4738 NewPhysicalDeviceInfo->Channel,
4739 NewPhysicalDeviceInfo->TargetID,
4740 (NewPhysicalDeviceInfo->PhysicalDeviceState
4741 == DAC960_V2_Device_Online
4743 : NewPhysicalDeviceInfo->PhysicalDeviceState
4744 == DAC960_V2_Device_Rebuild
4746 : NewPhysicalDeviceInfo->PhysicalDeviceState
4747 == DAC960_V2_Device_Missing
4749 : NewPhysicalDeviceInfo->PhysicalDeviceState
4750 == DAC960_V2_Device_Critical
4752 : NewPhysicalDeviceInfo->PhysicalDeviceState
4753 == DAC960_V2_Device_Dead
4755 : NewPhysicalDeviceInfo->PhysicalDeviceState
4756 == DAC960_V2_Device_SuspectedDead
4758 : NewPhysicalDeviceInfo->PhysicalDeviceState
4759 == DAC960_V2_Device_CommandedOffline
4760 ? "COMMANDED-OFFLINE"
4761 : NewPhysicalDeviceInfo->PhysicalDeviceState
4762 == DAC960_V2_Device_Standby
4763 ? "STANDBY" : "UNKNOWN"));
4764 if ((NewPhysicalDeviceInfo->ParityErrors !=
4765 PhysicalDeviceInfo->ParityErrors) ||
4766 (NewPhysicalDeviceInfo->SoftErrors !=
4767 PhysicalDeviceInfo->SoftErrors) ||
4768 (NewPhysicalDeviceInfo->HardErrors !=
4769 PhysicalDeviceInfo->HardErrors) ||
4770 (NewPhysicalDeviceInfo->MiscellaneousErrors !=
4771 PhysicalDeviceInfo->MiscellaneousErrors) ||
4772 (NewPhysicalDeviceInfo->CommandTimeouts !=
4773 PhysicalDeviceInfo->CommandTimeouts) ||
4774 (NewPhysicalDeviceInfo->Retries !=
4775 PhysicalDeviceInfo->Retries) ||
4776 (NewPhysicalDeviceInfo->Aborts !=
4777 PhysicalDeviceInfo->Aborts) ||
4778 (NewPhysicalDeviceInfo->PredictedFailuresDetected !=
4779 PhysicalDeviceInfo->PredictedFailuresDetected))
4781 DAC960_Critical("Physical Device %d:%d Errors: "
4782 "Parity = %d, Soft = %d, "
4783 "Hard = %d, Misc = %d\n",
4785 NewPhysicalDeviceInfo->Channel,
4786 NewPhysicalDeviceInfo->TargetID,
4787 NewPhysicalDeviceInfo->ParityErrors,
4788 NewPhysicalDeviceInfo->SoftErrors,
4789 NewPhysicalDeviceInfo->HardErrors,
4790 NewPhysicalDeviceInfo->MiscellaneousErrors);
4791 DAC960_Critical("Physical Device %d:%d Errors: "
4792 "Timeouts = %d, Retries = %d, "
4793 "Aborts = %d, Predicted = %d\n",
4795 NewPhysicalDeviceInfo->Channel,
4796 NewPhysicalDeviceInfo->TargetID,
4797 NewPhysicalDeviceInfo->CommandTimeouts,
4798 NewPhysicalDeviceInfo->Retries,
4799 NewPhysicalDeviceInfo->Aborts,
4800 NewPhysicalDeviceInfo
4801 ->PredictedFailuresDetected);
4803 if ((PhysicalDeviceInfo->PhysicalDeviceState
4804 == DAC960_V2_Device_Dead ||
4805 PhysicalDeviceInfo->PhysicalDeviceState
4806 == DAC960_V2_Device_InvalidState) &&
4807 NewPhysicalDeviceInfo->PhysicalDeviceState
4808 != DAC960_V2_Device_Dead)
4809 Controller->V2.NeedDeviceSerialNumberInformation = true;
4810 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
4811 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4813 NewPhysicalDeviceInfo->LogicalUnit++;
4814 Controller->V2.PhysicalDeviceIndex++;
4816 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid)
4818 unsigned int DeviceIndex;
4819 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex;
4820 DeviceIndex < DAC960_V2_MaxPhysicalDevices;
4823 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4824 Controller->V2.PhysicalDeviceInformation[DeviceIndex];
4825 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4826 Controller->V2.InquiryUnitSerialNumber[DeviceIndex];
4827 if (PhysicalDeviceInfo == NULL) break;
4828 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4830 PhysicalDeviceInfo->Channel,
4831 PhysicalDeviceInfo->TargetID);
4832 Controller->V2.PhysicalDeviceInformation[DeviceIndex] = NULL;
4833 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] = NULL;
4834 kfree(PhysicalDeviceInfo);
4835 kfree(InquiryUnitSerialNumber);
4837 Controller->V2.NeedPhysicalDeviceInformation = false;
4839 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid &&
4840 CommandStatus == DAC960_V2_NormalCompletion)
4842 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
4843 Controller->V2.NewLogicalDeviceInformation;
4844 unsigned short LogicalDeviceNumber =
4845 NewLogicalDeviceInfo->LogicalDeviceNumber;
4846 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
4847 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber];
4848 if (LogicalDeviceInfo == NULL)
4850 DAC960_V2_PhysicalDevice_T PhysicalDevice;
4851 PhysicalDevice.Controller = 0;
4852 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
4853 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
4854 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
4855 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
4857 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
4858 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
4859 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
4861 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4862 "Now Exists%s\n", Controller,
4863 LogicalDeviceNumber,
4864 Controller->ControllerNumber,
4865 LogicalDeviceNumber,
4866 (LogicalDeviceInfo != NULL
4867 ? "" : " - Allocation Failed"));
4868 if (LogicalDeviceInfo != NULL)
4870 memset(LogicalDeviceInfo, 0,
4871 sizeof(DAC960_V2_LogicalDeviceInfo_T));
4872 DAC960_ComputeGenericDiskInfo(Controller);
4875 if (LogicalDeviceInfo != NULL)
4877 unsigned long LogicalDeviceSize =
4878 NewLogicalDeviceInfo->ConfigurableDeviceSize;
4879 if (NewLogicalDeviceInfo->LogicalDeviceState !=
4880 LogicalDeviceInfo->LogicalDeviceState)
4881 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4882 "is now %s\n", Controller,
4883 LogicalDeviceNumber,
4884 Controller->ControllerNumber,
4885 LogicalDeviceNumber,
4886 (NewLogicalDeviceInfo->LogicalDeviceState
4887 == DAC960_V2_LogicalDevice_Online
4889 : NewLogicalDeviceInfo->LogicalDeviceState
4890 == DAC960_V2_LogicalDevice_Critical
4891 ? "CRITICAL" : "OFFLINE"));
4892 if ((NewLogicalDeviceInfo->SoftErrors !=
4893 LogicalDeviceInfo->SoftErrors) ||
4894 (NewLogicalDeviceInfo->CommandsFailed !=
4895 LogicalDeviceInfo->CommandsFailed) ||
4896 (NewLogicalDeviceInfo->DeferredWriteErrors !=
4897 LogicalDeviceInfo->DeferredWriteErrors))
4898 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) Errors: "
4899 "Soft = %d, Failed = %d, Deferred Write = %d\n",
4900 Controller, LogicalDeviceNumber,
4901 Controller->ControllerNumber,
4902 LogicalDeviceNumber,
4903 NewLogicalDeviceInfo->SoftErrors,
4904 NewLogicalDeviceInfo->CommandsFailed,
4905 NewLogicalDeviceInfo->DeferredWriteErrors);
4906 if (NewLogicalDeviceInfo->ConsistencyCheckInProgress)
4907 DAC960_V2_ReportProgress(Controller,
4908 "Consistency Check",
4909 LogicalDeviceNumber,
4910 NewLogicalDeviceInfo
4911 ->ConsistencyCheckBlockNumber,
4913 else if (NewLogicalDeviceInfo->RebuildInProgress)
4914 DAC960_V2_ReportProgress(Controller,
4916 LogicalDeviceNumber,
4917 NewLogicalDeviceInfo
4918 ->RebuildBlockNumber,
4920 else if (NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4921 DAC960_V2_ReportProgress(Controller,
4922 "Background Initialization",
4923 LogicalDeviceNumber,
4924 NewLogicalDeviceInfo
4925 ->BackgroundInitializationBlockNumber,
4927 else if (NewLogicalDeviceInfo->ForegroundInitializationInProgress)
4928 DAC960_V2_ReportProgress(Controller,
4929 "Foreground Initialization",
4930 LogicalDeviceNumber,
4931 NewLogicalDeviceInfo
4932 ->ForegroundInitializationBlockNumber,
4934 else if (NewLogicalDeviceInfo->DataMigrationInProgress)
4935 DAC960_V2_ReportProgress(Controller,
4937 LogicalDeviceNumber,
4938 NewLogicalDeviceInfo
4939 ->DataMigrationBlockNumber,
4941 else if (NewLogicalDeviceInfo->PatrolOperationInProgress)
4942 DAC960_V2_ReportProgress(Controller,
4944 LogicalDeviceNumber,
4945 NewLogicalDeviceInfo
4946 ->PatrolOperationBlockNumber,
4948 if (LogicalDeviceInfo->BackgroundInitializationInProgress &&
4949 !NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4950 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) "
4951 "Background Initialization %s\n",
4953 LogicalDeviceNumber,
4954 Controller->ControllerNumber,
4955 LogicalDeviceNumber,
4956 (NewLogicalDeviceInfo->LogicalDeviceControl
4957 .LogicalDeviceInitialized
4958 ? "Completed" : "Failed"));
4959 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
4960 sizeof(DAC960_V2_LogicalDeviceInfo_T));
4962 Controller->V2.LogicalDriveFoundDuringScan
4963 [LogicalDeviceNumber] = true;
4964 NewLogicalDeviceInfo->LogicalDeviceNumber++;
4966 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid)
4968 int LogicalDriveNumber;
4969 for (LogicalDriveNumber = 0;
4970 LogicalDriveNumber < DAC960_MaxLogicalDrives;
4971 LogicalDriveNumber++)
4973 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
4974 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
4975 if (LogicalDeviceInfo == NULL ||
4976 Controller->V2.LogicalDriveFoundDuringScan
4977 [LogicalDriveNumber])
4979 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4980 "No Longer Exists\n", Controller,
4982 Controller->ControllerNumber,
4983 LogicalDriveNumber);
4984 Controller->V2.LogicalDeviceInformation
4985 [LogicalDriveNumber] = NULL;
4986 kfree(LogicalDeviceInfo);
4987 Controller->LogicalDriveInitiallyAccessible
4988 [LogicalDriveNumber] = false;
4989 DAC960_ComputeGenericDiskInfo(Controller);
4991 Controller->V2.NeedLogicalDeviceInformation = false;
4993 else if (CommandOpcode == DAC960_V2_SCSI_10_Passthru)
4995 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4996 Controller->V2.InquiryUnitSerialNumber[Controller->V2.PhysicalDeviceIndex - 1];
4998 if (CommandStatus != DAC960_V2_NormalCompletion) {
4999 memset(InquiryUnitSerialNumber,
5000 0, sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5001 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5003 memcpy(InquiryUnitSerialNumber,
5004 Controller->V2.NewInquiryUnitSerialNumber,
5005 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5007 Controller->V2.NeedDeviceSerialNumberInformation = false;
5010 if (Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5011 - Controller->V2.NextEventSequenceNumber > 0)
5013 CommandMailbox->GetEvent.CommandOpcode = DAC960_V2_IOCTL;
5014 CommandMailbox->GetEvent.DataTransferSize = sizeof(DAC960_V2_Event_T);
5015 CommandMailbox->GetEvent.EventSequenceNumberHigh16 =
5016 Controller->V2.NextEventSequenceNumber >> 16;
5017 CommandMailbox->GetEvent.ControllerNumber = 0;
5018 CommandMailbox->GetEvent.IOCTL_Opcode =
5020 CommandMailbox->GetEvent.EventSequenceNumberLow16 =
5021 Controller->V2.NextEventSequenceNumber & 0xFFFF;
5022 CommandMailbox->GetEvent.DataTransferMemoryAddress
5023 .ScatterGatherSegments[0]
5024 .SegmentDataPointer =
5025 Controller->V2.EventDMA;
5026 CommandMailbox->GetEvent.DataTransferMemoryAddress
5027 .ScatterGatherSegments[0]
5029 CommandMailbox->GetEvent.DataTransferSize;
5030 DAC960_QueueCommand(Command);
5033 if (Controller->V2.NeedPhysicalDeviceInformation)
5035 if (Controller->V2.NeedDeviceSerialNumberInformation)
5037 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
5038 Controller->V2.NewInquiryUnitSerialNumber;
5039 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5041 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
5042 Controller->V2.NewPhysicalDeviceInformation->Channel,
5043 Controller->V2.NewPhysicalDeviceInformation->TargetID,
5044 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit - 1);
5047 DAC960_QueueCommand(Command);
5050 if (Controller->V2.StartPhysicalDeviceInformationScan)
5052 Controller->V2.PhysicalDeviceIndex = 0;
5053 Controller->V2.NewPhysicalDeviceInformation->Channel = 0;
5054 Controller->V2.NewPhysicalDeviceInformation->TargetID = 0;
5055 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit = 0;
5056 Controller->V2.StartPhysicalDeviceInformationScan = false;
5058 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5059 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
5060 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
5061 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit =
5062 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit;
5063 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID =
5064 Controller->V2.NewPhysicalDeviceInformation->TargetID;
5065 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel =
5066 Controller->V2.NewPhysicalDeviceInformation->Channel;
5067 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
5068 DAC960_V2_GetPhysicalDeviceInfoValid;
5069 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5070 .ScatterGatherSegments[0]
5071 .SegmentDataPointer =
5072 Controller->V2.NewPhysicalDeviceInformationDMA;
5073 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5074 .ScatterGatherSegments[0]
5076 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
5077 DAC960_QueueCommand(Command);
5080 if (Controller->V2.NeedLogicalDeviceInformation)
5082 if (Controller->V2.StartLogicalDeviceInformationScan)
5084 int LogicalDriveNumber;
5085 for (LogicalDriveNumber = 0;
5086 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5087 LogicalDriveNumber++)
5088 Controller->V2.LogicalDriveFoundDuringScan
5089 [LogicalDriveNumber] = false;
5090 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber = 0;
5091 Controller->V2.StartLogicalDeviceInformationScan = false;
5093 CommandMailbox->LogicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5094 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
5095 sizeof(DAC960_V2_LogicalDeviceInfo_T);
5096 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
5097 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber;
5098 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
5099 DAC960_V2_GetLogicalDeviceInfoValid;
5100 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5101 .ScatterGatherSegments[0]
5102 .SegmentDataPointer =
5103 Controller->V2.NewLogicalDeviceInformationDMA;
5104 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5105 .ScatterGatherSegments[0]
5107 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
5108 DAC960_QueueCommand(Command);
5111 Controller->MonitoringTimerCount++;
5112 Controller->MonitoringTimer.expires =
5113 jiffies + DAC960_HealthStatusMonitoringInterval;
5114 add_timer(&Controller->MonitoringTimer);
5116 if (CommandType == DAC960_ImmediateCommand)
5118 complete(Command->Completion);
5119 Command->Completion = NULL;
5122 if (CommandType == DAC960_QueuedCommand)
5124 DAC960_V2_KernelCommand_T *KernelCommand = Command->V2.KernelCommand;
5125 KernelCommand->CommandStatus = CommandStatus;
5126 KernelCommand->RequestSenseLength = Command->V2.RequestSenseLength;
5127 KernelCommand->DataTransferLength = Command->V2.DataTransferResidue;
5128 Command->V2.KernelCommand = NULL;
5129 DAC960_DeallocateCommand(Command);
5130 KernelCommand->CompletionFunction(KernelCommand);
5134 Queue a Status Monitoring Command to the Controller using the just
5135 completed Command if one was deferred previously due to lack of a
5136 free Command when the Monitoring Timer Function was called.
5138 if (Controller->MonitoringCommandDeferred)
5140 Controller->MonitoringCommandDeferred = false;
5141 DAC960_V2_QueueMonitoringCommand(Command);
5145 Deallocate the Command.
5147 DAC960_DeallocateCommand(Command);
5149 Wake up any processes waiting on a free Command.
5151 wake_up(&Controller->CommandWaitQueue);
5156 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
5160 static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
5161 void *DeviceIdentifier,
5162 struct pt_regs *InterruptRegisters)
5164 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5165 void *ControllerBaseAddress = Controller->BaseAddress;
5166 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5167 unsigned long flags;
5169 spin_lock_irqsave(&Controller->queue_lock, flags);
5170 DAC960_BA_AcknowledgeInterrupt(ControllerBaseAddress);
5171 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5172 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5174 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5175 NextStatusMailbox->Fields.CommandIdentifier;
5176 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5177 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5178 Command->V2.RequestSenseLength =
5179 NextStatusMailbox->Fields.RequestSenseLength;
5180 Command->V2.DataTransferResidue =
5181 NextStatusMailbox->Fields.DataTransferResidue;
5182 NextStatusMailbox->Words[0] = 0;
5183 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5184 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5185 DAC960_V2_ProcessCompletedCommand(Command);
5187 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5189 Attempt to remove additional I/O Requests from the Controller's
5190 I/O Request Queue and queue them to the Controller.
5192 while (DAC960_ProcessRequest(Controller, false))
5194 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5200 DAC960_LP_InterruptHandler handles hardware interrupts from DAC960 LP Series
5204 static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
5205 void *DeviceIdentifier,
5206 struct pt_regs *InterruptRegisters)
5208 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5209 void *ControllerBaseAddress = Controller->BaseAddress;
5210 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5211 unsigned long flags;
5213 spin_lock_irqsave(&Controller->queue_lock, flags);
5214 DAC960_LP_AcknowledgeInterrupt(ControllerBaseAddress);
5215 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5216 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5218 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5219 NextStatusMailbox->Fields.CommandIdentifier;
5220 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5221 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5222 Command->V2.RequestSenseLength =
5223 NextStatusMailbox->Fields.RequestSenseLength;
5224 Command->V2.DataTransferResidue =
5225 NextStatusMailbox->Fields.DataTransferResidue;
5226 NextStatusMailbox->Words[0] = 0;
5227 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5228 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5229 DAC960_V2_ProcessCompletedCommand(Command);
5231 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5233 Attempt to remove additional I/O Requests from the Controller's
5234 I/O Request Queue and queue them to the Controller.
5236 while (DAC960_ProcessRequest(Controller, false))
5238 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5244 DAC960_LA_InterruptHandler handles hardware interrupts from DAC960 LA Series
5248 static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
5249 void *DeviceIdentifier,
5250 struct pt_regs *InterruptRegisters)
5252 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5253 void *ControllerBaseAddress = Controller->BaseAddress;
5254 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5255 unsigned long flags;
5257 spin_lock_irqsave(&Controller->queue_lock, flags);
5258 DAC960_LA_AcknowledgeInterrupt(ControllerBaseAddress);
5259 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5260 while (NextStatusMailbox->Fields.Valid)
5262 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5263 NextStatusMailbox->Fields.CommandIdentifier;
5264 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5265 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5266 NextStatusMailbox->Word = 0;
5267 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5268 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5269 DAC960_V1_ProcessCompletedCommand(Command);
5271 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5273 Attempt to remove additional I/O Requests from the Controller's
5274 I/O Request Queue and queue them to the Controller.
5276 while (DAC960_ProcessRequest(Controller, false))
5278 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5284 DAC960_PG_InterruptHandler handles hardware interrupts from DAC960 PG Series
5288 static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
5289 void *DeviceIdentifier,
5290 struct pt_regs *InterruptRegisters)
5292 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5293 void *ControllerBaseAddress = Controller->BaseAddress;
5294 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5295 unsigned long flags;
5297 spin_lock_irqsave(&Controller->queue_lock, flags);
5298 DAC960_PG_AcknowledgeInterrupt(ControllerBaseAddress);
5299 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5300 while (NextStatusMailbox->Fields.Valid)
5302 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5303 NextStatusMailbox->Fields.CommandIdentifier;
5304 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5305 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5306 NextStatusMailbox->Word = 0;
5307 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5308 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5309 DAC960_V1_ProcessCompletedCommand(Command);
5311 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5313 Attempt to remove additional I/O Requests from the Controller's
5314 I/O Request Queue and queue them to the Controller.
5316 while (DAC960_ProcessRequest(Controller, false))
5318 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5324 DAC960_PD_InterruptHandler handles hardware interrupts from DAC960 PD Series
5328 static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
5329 void *DeviceIdentifier,
5330 struct pt_regs *InterruptRegisters)
5332 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5333 void *ControllerBaseAddress = Controller->BaseAddress;
5334 unsigned long flags;
5336 spin_lock_irqsave(&Controller->queue_lock, flags);
5337 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5339 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5340 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5341 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5342 Command->V1.CommandStatus =
5343 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5344 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5345 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5346 DAC960_V1_ProcessCompletedCommand(Command);
5349 Attempt to remove additional I/O Requests from the Controller's
5350 I/O Request Queue and queue them to the Controller.
5352 while (DAC960_ProcessRequest(Controller, false))
5354 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5360 DAC960_P_InterruptHandler handles hardware interrupts from DAC960 P Series
5363 Translations of DAC960_V1_Enquiry and DAC960_V1_GetDeviceState rely
5364 on the data having been placed into DAC960_Controller_T, rather than
5365 an arbitrary buffer.
5368 static irqreturn_t DAC960_P_InterruptHandler(int IRQ_Channel,
5369 void *DeviceIdentifier,
5370 struct pt_regs *InterruptRegisters)
5372 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5373 void *ControllerBaseAddress = Controller->BaseAddress;
5374 unsigned long flags;
5376 spin_lock_irqsave(&Controller->queue_lock, flags);
5377 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5379 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5380 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5381 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5382 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5383 DAC960_V1_CommandOpcode_T CommandOpcode =
5384 CommandMailbox->Common.CommandOpcode;
5385 Command->V1.CommandStatus =
5386 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5387 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5388 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5389 switch (CommandOpcode)
5391 case DAC960_V1_Enquiry_Old:
5392 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Enquiry;
5393 DAC960_P_To_PD_TranslateEnquiry(Controller->V1.NewEnquiry);
5395 case DAC960_V1_GetDeviceState_Old:
5396 Command->V1.CommandMailbox.Common.CommandOpcode =
5397 DAC960_V1_GetDeviceState;
5398 DAC960_P_To_PD_TranslateDeviceState(Controller->V1.NewDeviceState);
5400 case DAC960_V1_Read_Old:
5401 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Read;
5402 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5404 case DAC960_V1_Write_Old:
5405 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Write;
5406 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5408 case DAC960_V1_ReadWithScatterGather_Old:
5409 Command->V1.CommandMailbox.Common.CommandOpcode =
5410 DAC960_V1_ReadWithScatterGather;
5411 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5413 case DAC960_V1_WriteWithScatterGather_Old:
5414 Command->V1.CommandMailbox.Common.CommandOpcode =
5415 DAC960_V1_WriteWithScatterGather;
5416 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5421 DAC960_V1_ProcessCompletedCommand(Command);
5424 Attempt to remove additional I/O Requests from the Controller's
5425 I/O Request Queue and queue them to the Controller.
5427 while (DAC960_ProcessRequest(Controller, false))
5429 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5435 DAC960_V1_QueueMonitoringCommand queues a Monitoring Command to DAC960 V1
5436 Firmware Controllers.
5439 static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *Command)
5441 DAC960_Controller_T *Controller = Command->Controller;
5442 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5443 DAC960_V1_ClearCommand(Command);
5444 Command->CommandType = DAC960_MonitoringCommand;
5445 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Enquiry;
5446 CommandMailbox->Type3.BusAddress = Controller->V1.NewEnquiryDMA;
5447 DAC960_QueueCommand(Command);
5452 DAC960_V2_QueueMonitoringCommand queues a Monitoring Command to DAC960 V2
5453 Firmware Controllers.
5456 static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *Command)
5458 DAC960_Controller_T *Controller = Command->Controller;
5459 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
5460 DAC960_V2_ClearCommand(Command);
5461 Command->CommandType = DAC960_MonitoringCommand;
5462 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
5463 CommandMailbox->ControllerInfo.CommandControlBits
5464 .DataTransferControllerToHost = true;
5465 CommandMailbox->ControllerInfo.CommandControlBits
5466 .NoAutoRequestSense = true;
5467 CommandMailbox->ControllerInfo.DataTransferSize =
5468 sizeof(DAC960_V2_ControllerInfo_T);
5469 CommandMailbox->ControllerInfo.ControllerNumber = 0;
5470 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
5471 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5472 .ScatterGatherSegments[0]
5473 .SegmentDataPointer =
5474 Controller->V2.NewControllerInformationDMA;
5475 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5476 .ScatterGatherSegments[0]
5478 CommandMailbox->ControllerInfo.DataTransferSize;
5479 DAC960_QueueCommand(Command);
5484 DAC960_MonitoringTimerFunction is the timer function for monitoring
5485 the status of DAC960 Controllers.
5488 static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
5490 DAC960_Controller_T *Controller = (DAC960_Controller_T *) TimerData;
5491 DAC960_Command_T *Command;
5492 unsigned long flags;
5494 if (Controller->FirmwareType == DAC960_V1_Controller)
5496 spin_lock_irqsave(&Controller->queue_lock, flags);
5498 Queue a Status Monitoring Command to Controller.
5500 Command = DAC960_AllocateCommand(Controller);
5501 if (Command != NULL)
5502 DAC960_V1_QueueMonitoringCommand(Command);
5503 else Controller->MonitoringCommandDeferred = true;
5504 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5508 DAC960_V2_ControllerInfo_T *ControllerInfo =
5509 &Controller->V2.ControllerInformation;
5510 unsigned int StatusChangeCounter =
5511 Controller->V2.HealthStatusBuffer->StatusChangeCounter;
5512 boolean ForceMonitoringCommand = false;
5513 if (jiffies - Controller->SecondaryMonitoringTime
5514 > DAC960_SecondaryMonitoringInterval)
5516 int LogicalDriveNumber;
5517 for (LogicalDriveNumber = 0;
5518 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5519 LogicalDriveNumber++)
5521 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
5522 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
5523 if (LogicalDeviceInfo == NULL) continue;
5524 if (!LogicalDeviceInfo->LogicalDeviceControl
5525 .LogicalDeviceInitialized)
5527 ForceMonitoringCommand = true;
5531 Controller->SecondaryMonitoringTime = jiffies;
5533 if (StatusChangeCounter == Controller->V2.StatusChangeCounter &&
5534 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5535 == Controller->V2.NextEventSequenceNumber &&
5536 (ControllerInfo->BackgroundInitializationsActive +
5537 ControllerInfo->LogicalDeviceInitializationsActive +
5538 ControllerInfo->PhysicalDeviceInitializationsActive +
5539 ControllerInfo->ConsistencyChecksActive +
5540 ControllerInfo->RebuildsActive +
5541 ControllerInfo->OnlineExpansionsActive == 0 ||
5542 jiffies - Controller->PrimaryMonitoringTime
5543 < DAC960_MonitoringTimerInterval) &&
5544 !ForceMonitoringCommand)
5546 Controller->MonitoringTimer.expires =
5547 jiffies + DAC960_HealthStatusMonitoringInterval;
5548 add_timer(&Controller->MonitoringTimer);
5551 Controller->V2.StatusChangeCounter = StatusChangeCounter;
5552 Controller->PrimaryMonitoringTime = jiffies;
5554 spin_lock_irqsave(&Controller->queue_lock, flags);
5556 Queue a Status Monitoring Command to Controller.
5558 Command = DAC960_AllocateCommand(Controller);
5559 if (Command != NULL)
5560 DAC960_V2_QueueMonitoringCommand(Command);
5561 else Controller->MonitoringCommandDeferred = true;
5562 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5564 Wake up any processes waiting on a Health Status Buffer change.
5566 wake_up(&Controller->HealthStatusWaitQueue);
5571 DAC960_UserIOCTL is the User IOCTL Function for the DAC960 Driver.
5574 static int DAC960_UserIOCTL(struct inode *inode, struct file *file,
5575 unsigned int Request, unsigned long Argument)
5578 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
5581 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
5582 return DAC960_ControllerCount;
5583 case DAC960_IOCTL_GET_CONTROLLER_INFO:
5585 DAC960_ControllerInfo_T *UserSpaceControllerInfo =
5586 (DAC960_ControllerInfo_T *) Argument;
5587 DAC960_ControllerInfo_T ControllerInfo;
5588 DAC960_Controller_T *Controller;
5589 int ControllerNumber;
5590 if (UserSpaceControllerInfo == NULL) return -EINVAL;
5591 ErrorCode = get_user(ControllerNumber,
5592 &UserSpaceControllerInfo->ControllerNumber);
5593 if (ErrorCode != 0) return ErrorCode;
5594 if (ControllerNumber < 0 ||
5595 ControllerNumber > DAC960_ControllerCount - 1)
5597 Controller = DAC960_Controllers[ControllerNumber];
5598 if (Controller == NULL) return -ENXIO;
5599 memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
5600 ControllerInfo.ControllerNumber = ControllerNumber;
5601 ControllerInfo.FirmwareType = Controller->FirmwareType;
5602 ControllerInfo.Channels = Controller->Channels;
5603 ControllerInfo.Targets = Controller->Targets;
5604 ControllerInfo.PCI_Bus = Controller->Bus;
5605 ControllerInfo.PCI_Device = Controller->Device;
5606 ControllerInfo.PCI_Function = Controller->Function;
5607 ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
5608 ControllerInfo.PCI_Address = Controller->PCI_Address;
5609 strcpy(ControllerInfo.ModelName, Controller->ModelName);
5610 strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
5611 return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
5612 sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
5614 case DAC960_IOCTL_V1_EXECUTE_COMMAND:
5616 DAC960_V1_UserCommand_T *UserSpaceUserCommand =
5617 (DAC960_V1_UserCommand_T *) Argument;
5618 DAC960_V1_UserCommand_T UserCommand;
5619 DAC960_Controller_T *Controller;
5620 DAC960_Command_T *Command = NULL;
5621 DAC960_V1_CommandOpcode_T CommandOpcode;
5622 DAC960_V1_CommandStatus_T CommandStatus;
5623 DAC960_V1_DCDB_T DCDB;
5624 DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
5625 dma_addr_t DCDB_IOBUFDMA;
5626 unsigned long flags;
5627 int ControllerNumber, DataTransferLength;
5628 unsigned char *DataTransferBuffer = NULL;
5629 dma_addr_t DataTransferBufferDMA;
5630 if (UserSpaceUserCommand == NULL) return -EINVAL;
5631 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
5632 sizeof(DAC960_V1_UserCommand_T))) {
5633 ErrorCode = -EFAULT;
5636 ControllerNumber = UserCommand.ControllerNumber;
5637 if (ControllerNumber < 0 ||
5638 ControllerNumber > DAC960_ControllerCount - 1)
5640 Controller = DAC960_Controllers[ControllerNumber];
5641 if (Controller == NULL) return -ENXIO;
5642 if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
5643 CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
5644 DataTransferLength = UserCommand.DataTransferLength;
5645 if (CommandOpcode & 0x80) return -EINVAL;
5646 if (CommandOpcode == DAC960_V1_DCDB)
5648 if (copy_from_user(&DCDB, UserCommand.DCDB,
5649 sizeof(DAC960_V1_DCDB_T))) {
5650 ErrorCode = -EFAULT;
5653 if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
5654 if (!((DataTransferLength == 0 &&
5656 == DAC960_V1_DCDB_NoDataTransfer) ||
5657 (DataTransferLength > 0 &&
5659 == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
5660 (DataTransferLength < 0 &&
5662 == DAC960_V1_DCDB_DataTransferSystemToDevice)))
5664 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
5665 != abs(DataTransferLength))
5667 DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
5668 sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
5669 if (DCDB_IOBUF == NULL)
5672 if (DataTransferLength > 0)
5674 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
5675 DataTransferLength, &DataTransferBufferDMA);
5676 if (DataTransferBuffer == NULL) {
5677 ErrorCode = -ENOMEM;
5680 memset(DataTransferBuffer, 0, DataTransferLength);
5682 else if (DataTransferLength < 0)
5684 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
5685 -DataTransferLength, &DataTransferBufferDMA);
5686 if (DataTransferBuffer == NULL) {
5687 ErrorCode = -ENOMEM;
5690 if (copy_from_user(DataTransferBuffer,
5691 UserCommand.DataTransferBuffer,
5692 -DataTransferLength)) {
5693 ErrorCode = -EFAULT;
5697 if (CommandOpcode == DAC960_V1_DCDB)
5699 spin_lock_irqsave(&Controller->queue_lock, flags);
5700 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
5701 DAC960_WaitForCommand(Controller);
5702 while (Controller->V1.DirectCommandActive[DCDB.Channel]
5705 spin_unlock_irq(&Controller->queue_lock);
5706 __wait_event(Controller->CommandWaitQueue,
5707 !Controller->V1.DirectCommandActive
5708 [DCDB.Channel][DCDB.TargetID]);
5709 spin_lock_irq(&Controller->queue_lock);
5711 Controller->V1.DirectCommandActive[DCDB.Channel]
5712 [DCDB.TargetID] = true;
5713 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5714 DAC960_V1_ClearCommand(Command);
5715 Command->CommandType = DAC960_ImmediateCommand;
5716 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
5717 sizeof(DAC960_V1_CommandMailbox_T));
5718 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
5719 DCDB.BusAddress = DataTransferBufferDMA;
5720 memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
5724 spin_lock_irqsave(&Controller->queue_lock, flags);
5725 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
5726 DAC960_WaitForCommand(Controller);
5727 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5728 DAC960_V1_ClearCommand(Command);
5729 Command->CommandType = DAC960_ImmediateCommand;
5730 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
5731 sizeof(DAC960_V1_CommandMailbox_T));
5732 if (DataTransferBuffer != NULL)
5733 Command->V1.CommandMailbox.Type3.BusAddress =
5734 DataTransferBufferDMA;
5736 DAC960_ExecuteCommand(Command);
5737 CommandStatus = Command->V1.CommandStatus;
5738 spin_lock_irqsave(&Controller->queue_lock, flags);
5739 DAC960_DeallocateCommand(Command);
5740 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5741 if (DataTransferLength > 0)
5743 if (copy_to_user(UserCommand.DataTransferBuffer,
5744 DataTransferBuffer, DataTransferLength)) {
5745 ErrorCode = -EFAULT;
5749 if (CommandOpcode == DAC960_V1_DCDB)
5752 I don't believe Target or Channel in the DCDB_IOBUF
5753 should be any different from the contents of DCDB.
5755 Controller->V1.DirectCommandActive[DCDB.Channel]
5756 [DCDB.TargetID] = false;
5757 if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
5758 sizeof(DAC960_V1_DCDB_T))) {
5759 ErrorCode = -EFAULT;
5763 ErrorCode = CommandStatus;
5765 if (DataTransferBuffer != NULL)
5766 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
5767 DataTransferBuffer, DataTransferBufferDMA);
5768 if (DCDB_IOBUF != NULL)
5769 pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
5770 DCDB_IOBUF, DCDB_IOBUFDMA);
5774 case DAC960_IOCTL_V2_EXECUTE_COMMAND:
5776 DAC960_V2_UserCommand_T *UserSpaceUserCommand =
5777 (DAC960_V2_UserCommand_T *) Argument;
5778 DAC960_V2_UserCommand_T UserCommand;
5779 DAC960_Controller_T *Controller;
5780 DAC960_Command_T *Command = NULL;
5781 DAC960_V2_CommandMailbox_T *CommandMailbox;
5782 DAC960_V2_CommandStatus_T CommandStatus;
5783 unsigned long flags;
5784 int ControllerNumber, DataTransferLength;
5785 int DataTransferResidue, RequestSenseLength;
5786 unsigned char *DataTransferBuffer = NULL;
5787 dma_addr_t DataTransferBufferDMA;
5788 unsigned char *RequestSenseBuffer = NULL;
5789 dma_addr_t RequestSenseBufferDMA;
5790 if (UserSpaceUserCommand == NULL) return -EINVAL;
5791 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
5792 sizeof(DAC960_V2_UserCommand_T))) {
5793 ErrorCode = -EFAULT;
5796 ControllerNumber = UserCommand.ControllerNumber;
5797 if (ControllerNumber < 0 ||
5798 ControllerNumber > DAC960_ControllerCount - 1)
5800 Controller = DAC960_Controllers[ControllerNumber];
5801 if (Controller == NULL) return -ENXIO;
5802 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
5803 DataTransferLength = UserCommand.DataTransferLength;
5804 if (DataTransferLength > 0)
5806 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
5807 DataTransferLength, &DataTransferBufferDMA);
5808 if (DataTransferBuffer == NULL) return -ENOMEM;
5809 memset(DataTransferBuffer, 0, DataTransferLength);
5811 else if (DataTransferLength < 0)
5813 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
5814 -DataTransferLength, &DataTransferBufferDMA);
5815 if (DataTransferBuffer == NULL) return -ENOMEM;
5816 if (copy_from_user(DataTransferBuffer,
5817 UserCommand.DataTransferBuffer,
5818 -DataTransferLength)) {
5819 ErrorCode = -EFAULT;
5823 RequestSenseLength = UserCommand.RequestSenseLength;
5824 if (RequestSenseLength > 0)
5826 RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
5827 RequestSenseLength, &RequestSenseBufferDMA);
5828 if (RequestSenseBuffer == NULL)
5830 ErrorCode = -ENOMEM;
5833 memset(RequestSenseBuffer, 0, RequestSenseLength);
5835 spin_lock_irqsave(&Controller->queue_lock, flags);
5836 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
5837 DAC960_WaitForCommand(Controller);
5838 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5839 DAC960_V2_ClearCommand(Command);
5840 Command->CommandType = DAC960_ImmediateCommand;
5841 CommandMailbox = &Command->V2.CommandMailbox;
5842 memcpy(CommandMailbox, &UserCommand.CommandMailbox,
5843 sizeof(DAC960_V2_CommandMailbox_T));
5844 CommandMailbox->Common.CommandControlBits
5845 .AdditionalScatterGatherListMemory = false;
5846 CommandMailbox->Common.CommandControlBits
5847 .NoAutoRequestSense = true;
5848 CommandMailbox->Common.DataTransferSize = 0;
5849 CommandMailbox->Common.DataTransferPageNumber = 0;
5850 memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
5851 sizeof(DAC960_V2_DataTransferMemoryAddress_T));
5852 if (DataTransferLength != 0)
5854 if (DataTransferLength > 0)
5856 CommandMailbox->Common.CommandControlBits
5857 .DataTransferControllerToHost = true;
5858 CommandMailbox->Common.DataTransferSize = DataTransferLength;
5862 CommandMailbox->Common.CommandControlBits
5863 .DataTransferControllerToHost = false;
5864 CommandMailbox->Common.DataTransferSize = -DataTransferLength;
5866 CommandMailbox->Common.DataTransferMemoryAddress
5867 .ScatterGatherSegments[0]
5868 .SegmentDataPointer = DataTransferBufferDMA;
5869 CommandMailbox->Common.DataTransferMemoryAddress
5870 .ScatterGatherSegments[0]
5872 CommandMailbox->Common.DataTransferSize;
5874 if (RequestSenseLength > 0)
5876 CommandMailbox->Common.CommandControlBits
5877 .NoAutoRequestSense = false;
5878 CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
5879 CommandMailbox->Common.RequestSenseBusAddress =
5880 RequestSenseBufferDMA;
5882 DAC960_ExecuteCommand(Command);
5883 CommandStatus = Command->V2.CommandStatus;
5884 RequestSenseLength = Command->V2.RequestSenseLength;
5885 DataTransferResidue = Command->V2.DataTransferResidue;
5886 spin_lock_irqsave(&Controller->queue_lock, flags);
5887 DAC960_DeallocateCommand(Command);
5888 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5889 if (RequestSenseLength > UserCommand.RequestSenseLength)
5890 RequestSenseLength = UserCommand.RequestSenseLength;
5891 if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
5892 &DataTransferResidue,
5893 sizeof(DataTransferResidue))) {
5894 ErrorCode = -EFAULT;
5897 if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
5898 &RequestSenseLength, sizeof(RequestSenseLength))) {
5899 ErrorCode = -EFAULT;
5902 if (DataTransferLength > 0)
5904 if (copy_to_user(UserCommand.DataTransferBuffer,
5905 DataTransferBuffer, DataTransferLength)) {
5906 ErrorCode = -EFAULT;
5910 if (RequestSenseLength > 0)
5912 if (copy_to_user(UserCommand.RequestSenseBuffer,
5913 RequestSenseBuffer, RequestSenseLength)) {
5914 ErrorCode = -EFAULT;
5918 ErrorCode = CommandStatus;
5920 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
5921 DataTransferBuffer, DataTransferBufferDMA);
5922 if (RequestSenseBuffer != NULL)
5923 pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
5924 RequestSenseBuffer, RequestSenseBufferDMA);
5928 case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
5930 DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
5931 (DAC960_V2_GetHealthStatus_T *) Argument;
5932 DAC960_V2_GetHealthStatus_T GetHealthStatus;
5933 DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
5934 DAC960_Controller_T *Controller;
5935 int ControllerNumber;
5936 if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
5937 if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
5938 sizeof(DAC960_V2_GetHealthStatus_T)))
5940 ControllerNumber = GetHealthStatus.ControllerNumber;
5941 if (ControllerNumber < 0 ||
5942 ControllerNumber > DAC960_ControllerCount - 1)
5944 Controller = DAC960_Controllers[ControllerNumber];
5945 if (Controller == NULL) return -ENXIO;
5946 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
5947 if (copy_from_user(&HealthStatusBuffer,
5948 GetHealthStatus.HealthStatusBuffer,
5949 sizeof(DAC960_V2_HealthStatusBuffer_T)))
5951 while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
5952 == HealthStatusBuffer.StatusChangeCounter &&
5953 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5954 == HealthStatusBuffer.NextEventSequenceNumber)
5956 interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
5957 DAC960_MonitoringTimerInterval);
5958 if (signal_pending(current)) return -EINTR;
5960 if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
5961 Controller->V2.HealthStatusBuffer,
5962 sizeof(DAC960_V2_HealthStatusBuffer_T)))
5972 DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
5973 additional bytes in the Combined Status Buffer and grows the buffer if
5974 necessary. It returns true if there is enough room and false otherwise.
5977 static boolean DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
5978 unsigned int ByteCount)
5980 unsigned char *NewStatusBuffer;
5981 if (Controller->InitialStatusLength + 1 +
5982 Controller->CurrentStatusLength + ByteCount + 1 <=
5983 Controller->CombinedStatusBufferLength)
5985 if (Controller->CombinedStatusBufferLength == 0)
5987 unsigned int NewStatusBufferLength = DAC960_InitialStatusBufferSize;
5988 while (NewStatusBufferLength < ByteCount)
5989 NewStatusBufferLength *= 2;
5990 Controller->CombinedStatusBuffer =
5991 (unsigned char *) kmalloc(NewStatusBufferLength, GFP_ATOMIC);
5992 if (Controller->CombinedStatusBuffer == NULL) return false;
5993 Controller->CombinedStatusBufferLength = NewStatusBufferLength;
5996 NewStatusBuffer = (unsigned char *)
5997 kmalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
5998 if (NewStatusBuffer == NULL)
6000 DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
6004 memcpy(NewStatusBuffer, Controller->CombinedStatusBuffer,
6005 Controller->CombinedStatusBufferLength);
6006 kfree(Controller->CombinedStatusBuffer);
6007 Controller->CombinedStatusBuffer = NewStatusBuffer;
6008 Controller->CombinedStatusBufferLength *= 2;
6009 Controller->CurrentStatusBuffer =
6010 &NewStatusBuffer[Controller->InitialStatusLength + 1];
6016 DAC960_Message prints Driver Messages.
6019 static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
6020 unsigned char *Format,
6021 DAC960_Controller_T *Controller,
6024 static unsigned char Buffer[DAC960_LineBufferSize];
6025 static boolean BeginningOfLine = true;
6028 va_start(Arguments, Controller);
6029 Length = vsprintf(Buffer, Format, Arguments);
6031 if (Controller == NULL)
6032 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
6033 DAC960_ControllerCount, Buffer);
6034 else if (MessageLevel == DAC960_AnnounceLevel ||
6035 MessageLevel == DAC960_InfoLevel)
6037 if (!Controller->ControllerInitialized)
6039 if (DAC960_CheckStatusBuffer(Controller, Length))
6041 strcpy(&Controller->CombinedStatusBuffer
6042 [Controller->InitialStatusLength],
6044 Controller->InitialStatusLength += Length;
6045 Controller->CurrentStatusBuffer =
6046 &Controller->CombinedStatusBuffer
6047 [Controller->InitialStatusLength + 1];
6049 if (MessageLevel == DAC960_AnnounceLevel)
6051 static int AnnouncementLines = 0;
6052 if (++AnnouncementLines <= 2)
6053 printk("%sDAC960: %s", DAC960_MessageLevelMap[MessageLevel],
6058 if (BeginningOfLine)
6060 if (Buffer[0] != '\n' || Length > 1)
6061 printk("%sDAC960#%d: %s",
6062 DAC960_MessageLevelMap[MessageLevel],
6063 Controller->ControllerNumber, Buffer);
6065 else printk("%s", Buffer);
6068 else if (DAC960_CheckStatusBuffer(Controller, Length))
6070 strcpy(&Controller->CurrentStatusBuffer[
6071 Controller->CurrentStatusLength], Buffer);
6072 Controller->CurrentStatusLength += Length;
6075 else if (MessageLevel == DAC960_ProgressLevel)
6077 strcpy(Controller->ProgressBuffer, Buffer);
6078 Controller->ProgressBufferLength = Length;
6079 if (Controller->EphemeralProgressMessage)
6081 if (jiffies - Controller->LastProgressReportTime
6082 >= DAC960_ProgressReportingInterval)
6084 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
6085 Controller->ControllerNumber, Buffer);
6086 Controller->LastProgressReportTime = jiffies;
6089 else printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
6090 Controller->ControllerNumber, Buffer);
6092 else if (MessageLevel == DAC960_UserCriticalLevel)
6094 strcpy(&Controller->UserStatusBuffer[Controller->UserStatusLength],
6096 Controller->UserStatusLength += Length;
6097 if (Buffer[0] != '\n' || Length > 1)
6098 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
6099 Controller->ControllerNumber, Buffer);
6103 if (BeginningOfLine)
6104 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
6105 Controller->ControllerNumber, Buffer);
6106 else printk("%s", Buffer);
6108 BeginningOfLine = (Buffer[Length-1] == '\n');
6113 DAC960_ParsePhysicalDevice parses spaces followed by a Physical Device
6114 Channel:TargetID specification from a User Command string. It updates
6115 Channel and TargetID and returns true on success and false on failure.
6118 static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
6119 char *UserCommandString,
6120 unsigned char *Channel,
6121 unsigned char *TargetID)
6123 char *NewUserCommandString = UserCommandString;
6124 unsigned long XChannel, XTargetID;
6125 while (*UserCommandString == ' ') UserCommandString++;
6126 if (UserCommandString == NewUserCommandString)
6128 XChannel = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
6129 if (NewUserCommandString == UserCommandString ||
6130 *NewUserCommandString != ':' ||
6131 XChannel >= Controller->Channels)
6133 UserCommandString = ++NewUserCommandString;
6134 XTargetID = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
6135 if (NewUserCommandString == UserCommandString ||
6136 *NewUserCommandString != '\0' ||
6137 XTargetID >= Controller->Targets)
6139 *Channel = XChannel;
6140 *TargetID = XTargetID;
6146 DAC960_ParseLogicalDrive parses spaces followed by a Logical Drive Number
6147 specification from a User Command string. It updates LogicalDriveNumber and
6148 returns true on success and false on failure.
6151 static boolean DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
6152 char *UserCommandString,
6153 unsigned char *LogicalDriveNumber)
6155 char *NewUserCommandString = UserCommandString;
6156 unsigned long XLogicalDriveNumber;
6157 while (*UserCommandString == ' ') UserCommandString++;
6158 if (UserCommandString == NewUserCommandString)
6160 XLogicalDriveNumber =
6161 simple_strtoul(UserCommandString, &NewUserCommandString, 10);
6162 if (NewUserCommandString == UserCommandString ||
6163 *NewUserCommandString != '\0' ||
6164 XLogicalDriveNumber > DAC960_MaxLogicalDrives - 1)
6166 *LogicalDriveNumber = XLogicalDriveNumber;
6172 DAC960_V1_SetDeviceState sets the Device State for a Physical Device for
6173 DAC960 V1 Firmware Controllers.
6176 static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
6177 DAC960_Command_T *Command,
6178 unsigned char Channel,
6179 unsigned char TargetID,
6180 DAC960_V1_PhysicalDeviceState_T
6182 const unsigned char *DeviceStateString)
6184 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
6185 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_StartDevice;
6186 CommandMailbox->Type3D.Channel = Channel;
6187 CommandMailbox->Type3D.TargetID = TargetID;
6188 CommandMailbox->Type3D.DeviceState = DeviceState;
6189 CommandMailbox->Type3D.Modifier = 0;
6190 DAC960_ExecuteCommand(Command);
6191 switch (Command->V1.CommandStatus)
6193 case DAC960_V1_NormalCompletion:
6194 DAC960_UserCritical("%s of Physical Device %d:%d Succeeded\n", Controller,
6195 DeviceStateString, Channel, TargetID);
6197 case DAC960_V1_UnableToStartDevice:
6198 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
6199 "Unable to Start Device\n", Controller,
6200 DeviceStateString, Channel, TargetID);
6202 case DAC960_V1_NoDeviceAtAddress:
6203 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
6204 "No Device at Address\n", Controller,
6205 DeviceStateString, Channel, TargetID);
6207 case DAC960_V1_InvalidChannelOrTargetOrModifier:
6208 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
6209 "Invalid Channel or Target or Modifier\n",
6210 Controller, DeviceStateString, Channel, TargetID);
6212 case DAC960_V1_ChannelBusy:
6213 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
6214 "Channel Busy\n", Controller,
6215 DeviceStateString, Channel, TargetID);
6218 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
6219 "Unexpected Status %04X\n", Controller,
6220 DeviceStateString, Channel, TargetID,
6221 Command->V1.CommandStatus);
6228 DAC960_V1_ExecuteUserCommand executes a User Command for DAC960 V1 Firmware
6232 static boolean DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
6233 unsigned char *UserCommand)
6235 DAC960_Command_T *Command;
6236 DAC960_V1_CommandMailbox_T *CommandMailbox;
6237 unsigned long flags;
6238 unsigned char Channel, TargetID, LogicalDriveNumber;
6240 spin_lock_irqsave(&Controller->queue_lock, flags);
6241 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6242 DAC960_WaitForCommand(Controller);
6243 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6244 Controller->UserStatusLength = 0;
6245 DAC960_V1_ClearCommand(Command);
6246 Command->CommandType = DAC960_ImmediateCommand;
6247 CommandMailbox = &Command->V1.CommandMailbox;
6248 if (strcmp(UserCommand, "flush-cache") == 0)
6250 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Flush;
6251 DAC960_ExecuteCommand(Command);
6252 DAC960_UserCritical("Cache Flush Completed\n", Controller);
6254 else if (strncmp(UserCommand, "kill", 4) == 0 &&
6255 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
6256 &Channel, &TargetID))
6258 DAC960_V1_DeviceState_T *DeviceState =
6259 &Controller->V1.DeviceState[Channel][TargetID];
6260 if (DeviceState->Present &&
6261 DeviceState->DeviceType == DAC960_V1_DiskType &&
6262 DeviceState->DeviceState != DAC960_V1_Device_Dead)
6263 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
6264 DAC960_V1_Device_Dead, "Kill");
6265 else DAC960_UserCritical("Kill of Physical Device %d:%d Illegal\n",
6266 Controller, Channel, TargetID);
6268 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
6269 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6270 &Channel, &TargetID))
6272 DAC960_V1_DeviceState_T *DeviceState =
6273 &Controller->V1.DeviceState[Channel][TargetID];
6274 if (DeviceState->Present &&
6275 DeviceState->DeviceType == DAC960_V1_DiskType &&
6276 DeviceState->DeviceState == DAC960_V1_Device_Dead)
6277 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
6278 DAC960_V1_Device_Online, "Make Online");
6279 else DAC960_UserCritical("Make Online of Physical Device %d:%d Illegal\n",
6280 Controller, Channel, TargetID);
6283 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
6284 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6285 &Channel, &TargetID))
6287 DAC960_V1_DeviceState_T *DeviceState =
6288 &Controller->V1.DeviceState[Channel][TargetID];
6289 if (DeviceState->Present &&
6290 DeviceState->DeviceType == DAC960_V1_DiskType &&
6291 DeviceState->DeviceState == DAC960_V1_Device_Dead)
6292 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
6293 DAC960_V1_Device_Standby, "Make Standby");
6294 else DAC960_UserCritical("Make Standby of Physical "
6295 "Device %d:%d Illegal\n",
6296 Controller, Channel, TargetID);
6298 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
6299 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6300 &Channel, &TargetID))
6302 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_RebuildAsync;
6303 CommandMailbox->Type3D.Channel = Channel;
6304 CommandMailbox->Type3D.TargetID = TargetID;
6305 DAC960_ExecuteCommand(Command);
6306 switch (Command->V1.CommandStatus)
6308 case DAC960_V1_NormalCompletion:
6309 DAC960_UserCritical("Rebuild of Physical Device %d:%d Initiated\n",
6310 Controller, Channel, TargetID);
6312 case DAC960_V1_AttemptToRebuildOnlineDrive:
6313 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
6314 "Attempt to Rebuild Online or "
6315 "Unresponsive Drive\n",
6316 Controller, Channel, TargetID);
6318 case DAC960_V1_NewDiskFailedDuringRebuild:
6319 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
6320 "New Disk Failed During Rebuild\n",
6321 Controller, Channel, TargetID);
6323 case DAC960_V1_InvalidDeviceAddress:
6324 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
6325 "Invalid Device Address\n",
6326 Controller, Channel, TargetID);
6328 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
6329 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
6330 "Rebuild or Consistency Check Already "
6331 "in Progress\n", Controller, Channel, TargetID);
6334 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
6335 "Unexpected Status %04X\n", Controller,
6336 Channel, TargetID, Command->V1.CommandStatus);
6340 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
6341 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6342 &LogicalDriveNumber))
6344 CommandMailbox->Type3C.CommandOpcode = DAC960_V1_CheckConsistencyAsync;
6345 CommandMailbox->Type3C.LogicalDriveNumber = LogicalDriveNumber;
6346 CommandMailbox->Type3C.AutoRestore = true;
6347 DAC960_ExecuteCommand(Command);
6348 switch (Command->V1.CommandStatus)
6350 case DAC960_V1_NormalCompletion:
6351 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6352 "(/dev/rd/c%dd%d) Initiated\n",
6353 Controller, LogicalDriveNumber,
6354 Controller->ControllerNumber,
6355 LogicalDriveNumber);
6357 case DAC960_V1_DependentDiskIsDead:
6358 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6359 "(/dev/rd/c%dd%d) Failed - "
6360 "Dependent Physical Device is DEAD\n",
6361 Controller, LogicalDriveNumber,
6362 Controller->ControllerNumber,
6363 LogicalDriveNumber);
6365 case DAC960_V1_InvalidOrNonredundantLogicalDrive:
6366 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6367 "(/dev/rd/c%dd%d) Failed - "
6368 "Invalid or Nonredundant Logical Drive\n",
6369 Controller, LogicalDriveNumber,
6370 Controller->ControllerNumber,
6371 LogicalDriveNumber);
6373 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
6374 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6375 "(/dev/rd/c%dd%d) Failed - Rebuild or "
6376 "Consistency Check Already in Progress\n",
6377 Controller, LogicalDriveNumber,
6378 Controller->ControllerNumber,
6379 LogicalDriveNumber);
6382 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6383 "(/dev/rd/c%dd%d) Failed - "
6384 "Unexpected Status %04X\n",
6385 Controller, LogicalDriveNumber,
6386 Controller->ControllerNumber,
6387 LogicalDriveNumber, Command->V1.CommandStatus);
6391 else if (strcmp(UserCommand, "cancel-rebuild") == 0 ||
6392 strcmp(UserCommand, "cancel-consistency-check") == 0)
6395 the OldRebuildRateConstant is never actually used
6396 once its value is retrieved from the controller.
6398 unsigned char *OldRebuildRateConstant;
6399 dma_addr_t OldRebuildRateConstantDMA;
6401 OldRebuildRateConstant = pci_alloc_consistent( Controller->PCIDevice,
6402 sizeof(char), &OldRebuildRateConstantDMA);
6403 if (OldRebuildRateConstant == NULL) {
6404 DAC960_UserCritical("Cancellation of Rebuild or "
6405 "Consistency Check Failed - "
6410 CommandMailbox->Type3R.CommandOpcode = DAC960_V1_RebuildControl;
6411 CommandMailbox->Type3R.RebuildRateConstant = 0xFF;
6412 CommandMailbox->Type3R.BusAddress = OldRebuildRateConstantDMA;
6413 DAC960_ExecuteCommand(Command);
6414 switch (Command->V1.CommandStatus)
6416 case DAC960_V1_NormalCompletion:
6417 DAC960_UserCritical("Rebuild or Consistency Check Cancelled\n",
6421 DAC960_UserCritical("Cancellation of Rebuild or "
6422 "Consistency Check Failed - "
6423 "Unexpected Status %04X\n",
6424 Controller, Command->V1.CommandStatus);
6428 pci_free_consistent(Controller->PCIDevice, sizeof(char),
6429 OldRebuildRateConstant, OldRebuildRateConstantDMA);
6431 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6432 Controller, UserCommand);
6434 spin_lock_irqsave(&Controller->queue_lock, flags);
6435 DAC960_DeallocateCommand(Command);
6436 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6442 DAC960_V2_TranslatePhysicalDevice translates a Physical Device Channel and
6443 TargetID into a Logical Device. It returns true on success and false
6447 static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6448 unsigned char Channel,
6449 unsigned char TargetID,
6451 *LogicalDeviceNumber)
6453 DAC960_V2_CommandMailbox_T SavedCommandMailbox, *CommandMailbox;
6454 DAC960_Controller_T *Controller = Command->Controller;
6456 CommandMailbox = &Command->V2.CommandMailbox;
6457 memcpy(&SavedCommandMailbox, CommandMailbox,
6458 sizeof(DAC960_V2_CommandMailbox_T));
6460 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
6461 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6462 .DataTransferControllerToHost = true;
6463 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6464 .NoAutoRequestSense = true;
6465 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
6466 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
6467 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
6468 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
6469 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
6470 DAC960_V2_TranslatePhysicalToLogicalDevice;
6471 CommandMailbox->Common.DataTransferMemoryAddress
6472 .ScatterGatherSegments[0]
6473 .SegmentDataPointer =
6474 Controller->V2.PhysicalToLogicalDeviceDMA;
6475 CommandMailbox->Common.DataTransferMemoryAddress
6476 .ScatterGatherSegments[0]
6478 CommandMailbox->Common.DataTransferSize;
6480 DAC960_ExecuteCommand(Command);
6481 *LogicalDeviceNumber = Controller->V2.PhysicalToLogicalDevice->LogicalDeviceNumber;
6483 memcpy(CommandMailbox, &SavedCommandMailbox,
6484 sizeof(DAC960_V2_CommandMailbox_T));
6485 return (Command->V2.CommandStatus == DAC960_V2_NormalCompletion);
6490 DAC960_V2_ExecuteUserCommand executes a User Command for DAC960 V2 Firmware
6494 static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
6495 unsigned char *UserCommand)
6497 DAC960_Command_T *Command;
6498 DAC960_V2_CommandMailbox_T *CommandMailbox;
6499 unsigned long flags;
6500 unsigned char Channel, TargetID, LogicalDriveNumber;
6501 unsigned short LogicalDeviceNumber;
6503 spin_lock_irqsave(&Controller->queue_lock, flags);
6504 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6505 DAC960_WaitForCommand(Controller);
6506 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6507 Controller->UserStatusLength = 0;
6508 DAC960_V2_ClearCommand(Command);
6509 Command->CommandType = DAC960_ImmediateCommand;
6510 CommandMailbox = &Command->V2.CommandMailbox;
6511 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
6512 CommandMailbox->Common.CommandControlBits.DataTransferControllerToHost = true;
6513 CommandMailbox->Common.CommandControlBits.NoAutoRequestSense = true;
6514 if (strcmp(UserCommand, "flush-cache") == 0)
6516 CommandMailbox->DeviceOperation.IOCTL_Opcode = DAC960_V2_PauseDevice;
6517 CommandMailbox->DeviceOperation.OperationDevice =
6518 DAC960_V2_RAID_Controller;
6519 DAC960_ExecuteCommand(Command);
6520 DAC960_UserCritical("Cache Flush Completed\n", Controller);
6522 else if (strncmp(UserCommand, "kill", 4) == 0 &&
6523 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
6524 &Channel, &TargetID) &&
6525 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6526 &LogicalDeviceNumber))
6528 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6529 LogicalDeviceNumber;
6530 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6531 DAC960_V2_SetDeviceState;
6532 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6533 DAC960_V2_Device_Dead;
6534 DAC960_ExecuteCommand(Command);
6535 DAC960_UserCritical("Kill of Physical Device %d:%d %s\n",
6536 Controller, Channel, TargetID,
6537 (Command->V2.CommandStatus
6538 == DAC960_V2_NormalCompletion
6539 ? "Succeeded" : "Failed"));
6541 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
6542 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6543 &Channel, &TargetID) &&
6544 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6545 &LogicalDeviceNumber))
6547 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6548 LogicalDeviceNumber;
6549 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6550 DAC960_V2_SetDeviceState;
6551 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6552 DAC960_V2_Device_Online;
6553 DAC960_ExecuteCommand(Command);
6554 DAC960_UserCritical("Make Online of Physical Device %d:%d %s\n",
6555 Controller, Channel, TargetID,
6556 (Command->V2.CommandStatus
6557 == DAC960_V2_NormalCompletion
6558 ? "Succeeded" : "Failed"));
6560 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
6561 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6562 &Channel, &TargetID) &&
6563 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6564 &LogicalDeviceNumber))
6566 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6567 LogicalDeviceNumber;
6568 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6569 DAC960_V2_SetDeviceState;
6570 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6571 DAC960_V2_Device_Standby;
6572 DAC960_ExecuteCommand(Command);
6573 DAC960_UserCritical("Make Standby of Physical Device %d:%d %s\n",
6574 Controller, Channel, TargetID,
6575 (Command->V2.CommandStatus
6576 == DAC960_V2_NormalCompletion
6577 ? "Succeeded" : "Failed"));
6579 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
6580 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6581 &Channel, &TargetID) &&
6582 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6583 &LogicalDeviceNumber))
6585 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6586 LogicalDeviceNumber;
6587 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6588 DAC960_V2_RebuildDeviceStart;
6589 DAC960_ExecuteCommand(Command);
6590 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6591 Controller, Channel, TargetID,
6592 (Command->V2.CommandStatus
6593 == DAC960_V2_NormalCompletion
6594 ? "Initiated" : "Not Initiated"));
6596 else if (strncmp(UserCommand, "cancel-rebuild", 14) == 0 &&
6597 DAC960_ParsePhysicalDevice(Controller, &UserCommand[14],
6598 &Channel, &TargetID) &&
6599 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6600 &LogicalDeviceNumber))
6602 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6603 LogicalDeviceNumber;
6604 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6605 DAC960_V2_RebuildDeviceStop;
6606 DAC960_ExecuteCommand(Command);
6607 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6608 Controller, Channel, TargetID,
6609 (Command->V2.CommandStatus
6610 == DAC960_V2_NormalCompletion
6611 ? "Cancelled" : "Not Cancelled"));
6613 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
6614 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6615 &LogicalDriveNumber))
6617 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6619 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6620 DAC960_V2_ConsistencyCheckStart;
6621 CommandMailbox->ConsistencyCheck.RestoreConsistency = true;
6622 CommandMailbox->ConsistencyCheck.InitializedAreaOnly = false;
6623 DAC960_ExecuteCommand(Command);
6624 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6625 "(/dev/rd/c%dd%d) %s\n",
6626 Controller, LogicalDriveNumber,
6627 Controller->ControllerNumber,
6629 (Command->V2.CommandStatus
6630 == DAC960_V2_NormalCompletion
6631 ? "Initiated" : "Not Initiated"));
6633 else if (strncmp(UserCommand, "cancel-consistency-check", 24) == 0 &&
6634 DAC960_ParseLogicalDrive(Controller, &UserCommand[24],
6635 &LogicalDriveNumber))
6637 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6639 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6640 DAC960_V2_ConsistencyCheckStop;
6641 DAC960_ExecuteCommand(Command);
6642 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6643 "(/dev/rd/c%dd%d) %s\n",
6644 Controller, LogicalDriveNumber,
6645 Controller->ControllerNumber,
6647 (Command->V2.CommandStatus
6648 == DAC960_V2_NormalCompletion
6649 ? "Cancelled" : "Not Cancelled"));
6651 else if (strcmp(UserCommand, "perform-discovery") == 0)
6653 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_StartDiscovery;
6654 DAC960_ExecuteCommand(Command);
6655 DAC960_UserCritical("Discovery %s\n", Controller,
6656 (Command->V2.CommandStatus
6657 == DAC960_V2_NormalCompletion
6658 ? "Initiated" : "Not Initiated"));
6659 if (Command->V2.CommandStatus == DAC960_V2_NormalCompletion)
6661 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
6662 CommandMailbox->ControllerInfo.CommandControlBits
6663 .DataTransferControllerToHost = true;
6664 CommandMailbox->ControllerInfo.CommandControlBits
6665 .NoAutoRequestSense = true;
6666 CommandMailbox->ControllerInfo.DataTransferSize =
6667 sizeof(DAC960_V2_ControllerInfo_T);
6668 CommandMailbox->ControllerInfo.ControllerNumber = 0;
6669 CommandMailbox->ControllerInfo.IOCTL_Opcode =
6670 DAC960_V2_GetControllerInfo;
6672 * How does this NOT race with the queued Monitoring
6673 * usage of this structure?
6675 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6676 .ScatterGatherSegments[0]
6677 .SegmentDataPointer =
6678 Controller->V2.NewControllerInformationDMA;
6679 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6680 .ScatterGatherSegments[0]
6682 CommandMailbox->ControllerInfo.DataTransferSize;
6683 DAC960_ExecuteCommand(Command);
6684 while (Controller->V2.NewControllerInformation->PhysicalScanActive)
6686 DAC960_ExecuteCommand(Command);
6687 sleep_on_timeout(&Controller->CommandWaitQueue, HZ);
6689 DAC960_UserCritical("Discovery Completed\n", Controller);
6692 else if (strcmp(UserCommand, "suppress-enclosure-messages") == 0)
6693 Controller->SuppressEnclosureMessages = true;
6694 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6695 Controller, UserCommand);
6697 spin_lock_irqsave(&Controller->queue_lock, flags);
6698 DAC960_DeallocateCommand(Command);
6699 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6705 DAC960_ProcReadStatus implements reading /proc/rd/status.
6708 static int DAC960_ProcReadStatus(char *Page, char **Start, off_t Offset,
6709 int Count, int *EOF, void *Data)
6711 unsigned char *StatusMessage = "OK\n";
6712 int ControllerNumber, BytesAvailable;
6713 for (ControllerNumber = 0;
6714 ControllerNumber < DAC960_ControllerCount;
6717 DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
6718 if (Controller == NULL) continue;
6719 if (Controller->MonitoringAlertMode)
6721 StatusMessage = "ALERT\n";
6725 BytesAvailable = strlen(StatusMessage) - Offset;
6726 if (Count >= BytesAvailable)
6728 Count = BytesAvailable;
6731 if (Count <= 0) return 0;
6733 memcpy(Page, &StatusMessage[Offset], Count);
6739 DAC960_ProcReadInitialStatus implements reading /proc/rd/cN/initial_status.
6742 static int DAC960_ProcReadInitialStatus(char *Page, char **Start, off_t Offset,
6743 int Count, int *EOF, void *Data)
6745 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6746 int BytesAvailable = Controller->InitialStatusLength - Offset;
6747 if (Count >= BytesAvailable)
6749 Count = BytesAvailable;
6752 if (Count <= 0) return 0;
6754 memcpy(Page, &Controller->CombinedStatusBuffer[Offset], Count);
6760 DAC960_ProcReadCurrentStatus implements reading /proc/rd/cN/current_status.
6763 static int DAC960_ProcReadCurrentStatus(char *Page, char **Start, off_t Offset,
6764 int Count, int *EOF, void *Data)
6766 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6767 unsigned char *StatusMessage =
6768 "No Rebuild or Consistency Check in Progress\n";
6769 int ProgressMessageLength = strlen(StatusMessage);
6771 if (jiffies != Controller->LastCurrentStatusTime)
6773 Controller->CurrentStatusLength = 0;
6774 DAC960_AnnounceDriver(Controller);
6775 DAC960_ReportControllerConfiguration(Controller);
6776 DAC960_ReportDeviceConfiguration(Controller);
6777 if (Controller->ProgressBufferLength > 0)
6778 ProgressMessageLength = Controller->ProgressBufferLength;
6779 if (DAC960_CheckStatusBuffer(Controller, 2 + ProgressMessageLength))
6781 unsigned char *CurrentStatusBuffer = Controller->CurrentStatusBuffer;
6782 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6783 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6784 if (Controller->ProgressBufferLength > 0)
6785 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6786 Controller->ProgressBuffer);
6788 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6790 Controller->CurrentStatusLength += ProgressMessageLength;
6792 Controller->LastCurrentStatusTime = jiffies;
6794 BytesAvailable = Controller->CurrentStatusLength - Offset;
6795 if (Count >= BytesAvailable)
6797 Count = BytesAvailable;
6800 if (Count <= 0) return 0;
6802 memcpy(Page, &Controller->CurrentStatusBuffer[Offset], Count);
6808 DAC960_ProcReadUserCommand implements reading /proc/rd/cN/user_command.
6811 static int DAC960_ProcReadUserCommand(char *Page, char **Start, off_t Offset,
6812 int Count, int *EOF, void *Data)
6814 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6815 int BytesAvailable = Controller->UserStatusLength - Offset;
6816 if (Count >= BytesAvailable)
6818 Count = BytesAvailable;
6821 if (Count <= 0) return 0;
6823 memcpy(Page, &Controller->UserStatusBuffer[Offset], Count);
6829 DAC960_ProcWriteUserCommand implements writing /proc/rd/cN/user_command.
6832 static int DAC960_ProcWriteUserCommand(struct file *file, const char *Buffer,
6833 unsigned long Count, void *Data)
6835 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6836 unsigned char CommandBuffer[80];
6838 if (Count > sizeof(CommandBuffer)-1) return -EINVAL;
6839 if (copy_from_user(CommandBuffer, Buffer, Count)) return -EFAULT;
6840 CommandBuffer[Count] = '\0';
6841 Length = strlen(CommandBuffer);
6842 if (CommandBuffer[Length-1] == '\n')
6843 CommandBuffer[--Length] = '\0';
6844 if (Controller->FirmwareType == DAC960_V1_Controller)
6845 return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)
6848 return (DAC960_V2_ExecuteUserCommand(Controller, CommandBuffer)
6854 DAC960_CreateProcEntries creates the /proc/rd/... entries for the
6858 static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller)
6860 struct proc_dir_entry *StatusProcEntry;
6861 struct proc_dir_entry *ControllerProcEntry;
6862 struct proc_dir_entry *UserCommandProcEntry;
6864 if (DAC960_ProcDirectoryEntry == NULL) {
6865 DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL);
6866 StatusProcEntry = create_proc_read_entry("status", 0,
6867 DAC960_ProcDirectoryEntry,
6868 DAC960_ProcReadStatus, NULL);
6871 sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber);
6872 ControllerProcEntry = proc_mkdir(Controller->ControllerName,
6873 DAC960_ProcDirectoryEntry);
6874 create_proc_read_entry("initial_status", 0, ControllerProcEntry,
6875 DAC960_ProcReadInitialStatus, Controller);
6876 create_proc_read_entry("current_status", 0, ControllerProcEntry,
6877 DAC960_ProcReadCurrentStatus, Controller);
6878 UserCommandProcEntry =
6879 create_proc_read_entry("user_command", S_IWUSR | S_IRUSR,
6880 ControllerProcEntry, DAC960_ProcReadUserCommand,
6882 UserCommandProcEntry->write_proc = DAC960_ProcWriteUserCommand;
6883 Controller->ControllerProcEntry = ControllerProcEntry;
6888 DAC960_DestroyProcEntries destroys the /proc/rd/... entries for the
6892 static void DAC960_DestroyProcEntries(DAC960_Controller_T *Controller)
6894 if (Controller->ControllerProcEntry == NULL)
6896 remove_proc_entry("initial_status", Controller->ControllerProcEntry);
6897 remove_proc_entry("current_status", Controller->ControllerProcEntry);
6898 remove_proc_entry("user_command", Controller->ControllerProcEntry);
6899 remove_proc_entry(Controller->ControllerName, DAC960_ProcDirectoryEntry);
6900 Controller->ControllerProcEntry = NULL;
6903 static struct DAC960_privdata DAC960_BA_privdata = {
6904 .HardwareType = DAC960_BA_Controller,
6905 .FirmwareType = DAC960_V2_Controller,
6906 .InterruptHandler = DAC960_BA_InterruptHandler,
6907 .MemoryWindowSize = DAC960_BA_RegisterWindowSize,
6910 static struct DAC960_privdata DAC960_LP_privdata = {
6911 .HardwareType = DAC960_LP_Controller,
6912 .FirmwareType = DAC960_LP_Controller,
6913 .InterruptHandler = DAC960_LP_InterruptHandler,
6914 .MemoryWindowSize = DAC960_LP_RegisterWindowSize,
6917 static struct DAC960_privdata DAC960_LA_privdata = {
6918 .HardwareType = DAC960_LA_Controller,
6919 .FirmwareType = DAC960_V1_Controller,
6920 .InterruptHandler = DAC960_LA_InterruptHandler,
6921 .MemoryWindowSize = DAC960_LA_RegisterWindowSize,
6924 static struct DAC960_privdata DAC960_PG_privdata = {
6925 .HardwareType = DAC960_PG_Controller,
6926 .FirmwareType = DAC960_V1_Controller,
6927 .InterruptHandler = DAC960_PG_InterruptHandler,
6928 .MemoryWindowSize = DAC960_PG_RegisterWindowSize,
6931 static struct DAC960_privdata DAC960_PD_privdata = {
6932 .HardwareType = DAC960_PD_Controller,
6933 .FirmwareType = DAC960_V1_Controller,
6934 .InterruptHandler = DAC960_PD_InterruptHandler,
6935 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
6938 static struct DAC960_privdata DAC960_P_privdata = {
6939 .HardwareType = DAC960_P_Controller,
6940 .FirmwareType = DAC960_V1_Controller,
6941 .InterruptHandler = DAC960_P_InterruptHandler,
6942 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
6945 static struct pci_device_id DAC960_id_table[] = {
6947 .vendor = PCI_VENDOR_ID_MYLEX,
6948 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA,
6949 .subvendor = PCI_ANY_ID,
6950 .subdevice = PCI_ANY_ID,
6951 .driver_data = (unsigned long) &DAC960_BA_privdata,
6954 .vendor = PCI_VENDOR_ID_MYLEX,
6955 .device = PCI_DEVICE_ID_MYLEX_DAC960_LP,
6956 .subvendor = PCI_ANY_ID,
6957 .subdevice = PCI_ANY_ID,
6958 .driver_data = (unsigned long) &DAC960_LP_privdata,
6961 .vendor = PCI_VENDOR_ID_DEC,
6962 .device = PCI_DEVICE_ID_DEC_21285,
6963 .subvendor = PCI_VENDOR_ID_MYLEX,
6964 .subdevice = PCI_DEVICE_ID_MYLEX_DAC960_LA,
6965 .driver_data = (unsigned long) &DAC960_LA_privdata,
6968 .vendor = PCI_VENDOR_ID_MYLEX,
6969 .device = PCI_DEVICE_ID_MYLEX_DAC960_PG,
6970 .subvendor = PCI_ANY_ID,
6971 .subdevice = PCI_ANY_ID,
6972 .driver_data = (unsigned long) &DAC960_PG_privdata,
6975 .vendor = PCI_VENDOR_ID_MYLEX,
6976 .device = PCI_DEVICE_ID_MYLEX_DAC960_PD,
6977 .subvendor = PCI_ANY_ID,
6978 .subdevice = PCI_ANY_ID,
6979 .driver_data = (unsigned long) &DAC960_PD_privdata,
6982 .vendor = PCI_VENDOR_ID_MYLEX,
6983 .device = PCI_DEVICE_ID_MYLEX_DAC960_P,
6984 .subvendor = PCI_ANY_ID,
6985 .subdevice = PCI_ANY_ID,
6986 .driver_data = (unsigned long) &DAC960_P_privdata,
6991 MODULE_DEVICE_TABLE(pci, DAC960_id_table);
6993 static struct pci_driver DAC960_pci_driver = {
6995 .id_table = DAC960_id_table,
6996 .probe = DAC960_Probe,
6997 .remove = DAC960_Remove,
7000 static int DAC960_init_module(void)
7002 return pci_module_init(&DAC960_pci_driver);
7005 static void DAC960_cleanup_module(void)
7009 for (i = 0; i < DAC960_ControllerCount; i++) {
7010 DAC960_Controller_T *Controller = DAC960_Controllers[i];
7011 if (Controller == NULL)
7013 DAC960_FinalizeController(Controller);
7015 if (DAC960_ProcDirectoryEntry != NULL) {
7016 remove_proc_entry("rd/status", NULL);
7017 remove_proc_entry("rd", NULL);
7019 DAC960_ControllerCount = 0;
7020 pci_unregister_driver(&DAC960_pci_driver);
7023 module_init(DAC960_init_module);
7024 module_exit(DAC960_cleanup_module);
7026 MODULE_LICENSE("GPL");