3 Linux Driver for Mylex DAC960/AcceleRAID/eXtremeRAID PCI RAID Controllers
5 Copyright 1998-2001 by Leonard N. Zubkoff <lnz@dandelion.com>
7 This program is free software; you may redistribute and/or modify it under
8 the terms of the GNU General Public License Version 2 as published by the
9 Free Software Foundation.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #define DAC960_DriverVersion "2.5.47"
20 #define DAC960_DriverDate "14 November 2002"
23 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/miscdevice.h>
26 #include <linux/blkdev.h>
27 #include <linux/bio.h>
28 #include <linux/completion.h>
29 #include <linux/delay.h>
30 #include <linux/genhd.h>
31 #include <linux/hdreg.h>
32 #include <linux/blkpg.h>
33 #include <linux/interrupt.h>
34 #include <linux/ioport.h>
36 #include <linux/slab.h>
37 #include <linux/proc_fs.h>
38 #include <linux/reboot.h>
39 #include <linux/spinlock.h>
40 #include <linux/timer.h>
41 #include <linux/pci.h>
42 #include <linux/init.h>
44 #include <asm/uaccess.h>
47 #define DAC960_GAM_MINOR 252
50 static DAC960_Controller_T *DAC960_Controllers[DAC960_MaxControllers];
51 static int DAC960_ControllerCount;
52 static struct proc_dir_entry *DAC960_ProcDirectoryEntry;
54 static long disk_size(DAC960_Controller_T *p, int drive_nr)
56 if (p->FirmwareType == DAC960_V1_Controller) {
57 if (drive_nr >= p->LogicalDriveCount)
59 return p->V1.LogicalDriveInformation[drive_nr].
62 DAC960_V2_LogicalDeviceInfo_T *i =
63 p->V2.LogicalDeviceInformation[drive_nr];
66 return i->ConfigurableDeviceSize;
70 static int DAC960_open(struct inode *inode, struct file *file)
72 struct gendisk *disk = inode->i_bdev->bd_disk;
73 DAC960_Controller_T *p = disk->queue->queuedata;
74 int drive_nr = (long)disk->private_data;
76 if (p->FirmwareType == DAC960_V1_Controller) {
77 if (p->V1.LogicalDriveInformation[drive_nr].
78 LogicalDriveState == DAC960_V1_LogicalDrive_Offline)
81 DAC960_V2_LogicalDeviceInfo_T *i =
82 p->V2.LogicalDeviceInformation[drive_nr];
83 if (!i || i->LogicalDeviceState == DAC960_V2_LogicalDevice_Offline)
87 check_disk_change(inode->i_bdev);
89 if (!get_capacity(p->disks[drive_nr]))
94 static int DAC960_ioctl(struct inode *inode, struct file *file,
95 unsigned int cmd, unsigned long arg)
97 struct gendisk *disk = inode->i_bdev->bd_disk;
98 DAC960_Controller_T *p = disk->queue->queuedata;
99 int drive_nr = (long)disk->private_data;
100 struct hd_geometry g, *loc = (struct hd_geometry *)arg;
102 if (cmd != HDIO_GETGEO || !loc)
105 if (p->FirmwareType == DAC960_V1_Controller) {
106 g.heads = p->V1.GeometryTranslationHeads;
107 g.sectors = p->V1.GeometryTranslationSectors;
108 g.cylinders = p->V1.LogicalDriveInformation[drive_nr].
109 LogicalDriveSize / (g.heads * g.sectors);
111 DAC960_V2_LogicalDeviceInfo_T *i =
112 p->V2.LogicalDeviceInformation[drive_nr];
113 switch (i->DriveGeometry) {
114 case DAC960_V2_Geometry_128_32:
118 case DAC960_V2_Geometry_255_63:
123 DAC960_Error("Illegal Logical Device Geometry %d\n",
124 p, i->DriveGeometry);
128 g.cylinders = i->ConfigurableDeviceSize / (g.heads * g.sectors);
131 g.start = get_start_sect(inode->i_bdev);
133 return copy_to_user(loc, &g, sizeof g) ? -EFAULT : 0;
136 static int DAC960_media_changed(struct gendisk *disk)
138 DAC960_Controller_T *p = disk->queue->queuedata;
139 int drive_nr = (long)disk->private_data;
141 if (!p->LogicalDriveInitiallyAccessible[drive_nr])
146 static int DAC960_revalidate_disk(struct gendisk *disk)
148 DAC960_Controller_T *p = disk->queue->queuedata;
149 int unit = (long)disk->private_data;
151 set_capacity(disk, disk_size(p, unit));
155 static struct block_device_operations DAC960_BlockDeviceOperations = {
156 .owner = THIS_MODULE,
158 .ioctl = DAC960_ioctl,
159 .media_changed = DAC960_media_changed,
160 .revalidate_disk = DAC960_revalidate_disk,
165 DAC960_AnnounceDriver announces the Driver Version and Date, Author's Name,
166 Copyright Notice, and Electronic Mail Address.
169 static void DAC960_AnnounceDriver(DAC960_Controller_T *Controller)
171 DAC960_Announce("***** DAC960 RAID Driver Version "
172 DAC960_DriverVersion " of "
173 DAC960_DriverDate " *****\n", Controller);
174 DAC960_Announce("Copyright 1998-2001 by Leonard N. Zubkoff "
175 "<lnz@dandelion.com>\n", Controller);
180 DAC960_Failure prints a standardized error message, and then returns false.
183 static boolean DAC960_Failure(DAC960_Controller_T *Controller,
184 unsigned char *ErrorMessage)
186 DAC960_Error("While configuring DAC960 PCI RAID Controller at\n",
188 if (Controller->IO_Address == 0)
189 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
190 "PCI Address 0x%X\n", Controller,
191 Controller->Bus, Controller->Device,
192 Controller->Function, Controller->PCI_Address);
193 else DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
194 "0x%X PCI Address 0x%X\n", Controller,
195 Controller->Bus, Controller->Device,
196 Controller->Function, Controller->IO_Address,
197 Controller->PCI_Address);
198 DAC960_Error("%s FAILED - DETACHING\n", Controller, ErrorMessage);
203 init_dma_loaf() and slice_dma_loaf() are helper functions for
204 aggregating the dma-mapped memory for a well-known collection of
205 data structures that are of different lengths.
207 These routines don't guarantee any alignment. The caller must
208 include any space needed for alignment in the sizes of the structures
212 static boolean init_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf,
216 dma_addr_t dma_handle;
218 cpu_addr = pci_alloc_consistent(dev, len, &dma_handle);
219 if (cpu_addr == NULL)
222 loaf->cpu_free = loaf->cpu_base = cpu_addr;
223 loaf->dma_free =loaf->dma_base = dma_handle;
225 memset(cpu_addr, 0, len);
229 static void *slice_dma_loaf(struct dma_loaf *loaf, size_t len,
230 dma_addr_t *dma_handle)
232 void *cpu_end = loaf->cpu_free + len;
233 void *cpu_addr = loaf->cpu_free;
235 if (cpu_end > loaf->cpu_base + loaf->length)
237 *dma_handle = loaf->dma_free;
238 loaf->cpu_free = cpu_end;
239 loaf->dma_free += len;
243 static void free_dma_loaf(struct pci_dev *dev, struct dma_loaf *loaf_handle)
245 if (loaf_handle->cpu_base != NULL)
246 pci_free_consistent(dev, loaf_handle->length,
247 loaf_handle->cpu_base, loaf_handle->dma_base);
252 DAC960_CreateAuxiliaryStructures allocates and initializes the auxiliary
253 data structures for Controller. It returns true on success and false on
257 static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
259 int CommandAllocationLength, CommandAllocationGroupSize;
260 int CommandsRemaining = 0, CommandIdentifier, CommandGroupByteCount;
261 void *AllocationPointer = NULL;
262 void *ScatterGatherCPU = NULL;
263 dma_addr_t ScatterGatherDMA;
264 struct pci_pool *ScatterGatherPool;
265 void *RequestSenseCPU = NULL;
266 dma_addr_t RequestSenseDMA;
267 struct pci_pool *RequestSensePool = NULL;
269 if (Controller->FirmwareType == DAC960_V1_Controller)
271 CommandAllocationLength = offsetof(DAC960_Command_T, V1.EndMarker);
272 CommandAllocationGroupSize = DAC960_V1_CommandAllocationGroupSize;
273 ScatterGatherPool = pci_pool_create("DAC960_V1_ScatterGather",
274 Controller->PCIDevice,
275 DAC960_V1_ScatterGatherLimit * sizeof(DAC960_V1_ScatterGatherSegment_T),
276 sizeof(DAC960_V1_ScatterGatherSegment_T), 0);
277 if (ScatterGatherPool == NULL)
278 return DAC960_Failure(Controller,
279 "AUXILIARY STRUCTURE CREATION (SG)");
280 Controller->ScatterGatherPool = ScatterGatherPool;
284 CommandAllocationLength = offsetof(DAC960_Command_T, V2.EndMarker);
285 CommandAllocationGroupSize = DAC960_V2_CommandAllocationGroupSize;
286 ScatterGatherPool = pci_pool_create("DAC960_V2_ScatterGather",
287 Controller->PCIDevice,
288 DAC960_V2_ScatterGatherLimit * sizeof(DAC960_V2_ScatterGatherSegment_T),
289 sizeof(DAC960_V2_ScatterGatherSegment_T), 0);
290 RequestSensePool = pci_pool_create("DAC960_V2_RequestSense",
291 Controller->PCIDevice, sizeof(DAC960_SCSI_RequestSense_T),
293 if (ScatterGatherPool == NULL || RequestSensePool == NULL)
294 return DAC960_Failure(Controller,
295 "AUXILIARY STRUCTURE CREATION (SG)");
296 Controller->ScatterGatherPool = ScatterGatherPool;
297 Controller->V2.RequestSensePool = RequestSensePool;
299 Controller->CommandAllocationGroupSize = CommandAllocationGroupSize;
300 Controller->FreeCommands = NULL;
301 for (CommandIdentifier = 1;
302 CommandIdentifier <= Controller->DriverQueueDepth;
305 DAC960_Command_T *Command;
306 if (--CommandsRemaining <= 0)
309 Controller->DriverQueueDepth - CommandIdentifier + 1;
310 if (CommandsRemaining > CommandAllocationGroupSize)
311 CommandsRemaining = CommandAllocationGroupSize;
312 CommandGroupByteCount =
313 CommandsRemaining * CommandAllocationLength;
314 AllocationPointer = kmalloc(CommandGroupByteCount, GFP_ATOMIC);
315 if (AllocationPointer == NULL)
316 return DAC960_Failure(Controller,
317 "AUXILIARY STRUCTURE CREATION");
318 memset(AllocationPointer, 0, CommandGroupByteCount);
320 Command = (DAC960_Command_T *) AllocationPointer;
321 AllocationPointer += CommandAllocationLength;
322 Command->CommandIdentifier = CommandIdentifier;
323 Command->Controller = Controller;
324 Command->Next = Controller->FreeCommands;
325 Controller->FreeCommands = Command;
326 Controller->Commands[CommandIdentifier-1] = Command;
327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC,
329 if (ScatterGatherCPU == NULL)
330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
332 if (RequestSensePool != NULL) {
333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC,
335 if (RequestSenseCPU == NULL) {
336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
338 return DAC960_Failure(Controller,
339 "AUXILIARY STRUCTURE CREATION");
342 if (Controller->FirmwareType == DAC960_V1_Controller) {
343 Command->cmd_sglist = Command->V1.ScatterList;
344 Command->V1.ScatterGatherList =
345 (DAC960_V1_ScatterGatherSegment_T *)ScatterGatherCPU;
346 Command->V1.ScatterGatherListDMA = ScatterGatherDMA;
348 Command->cmd_sglist = Command->V2.ScatterList;
349 Command->V2.ScatterGatherList =
350 (DAC960_V2_ScatterGatherSegment_T *)ScatterGatherCPU;
351 Command->V2.ScatterGatherListDMA = ScatterGatherDMA;
352 Command->V2.RequestSense =
353 (DAC960_SCSI_RequestSense_T *)RequestSenseCPU;
354 Command->V2.RequestSenseDMA = RequestSenseDMA;
362 DAC960_DestroyAuxiliaryStructures deallocates the auxiliary data
363 structures for Controller.
366 static void DAC960_DestroyAuxiliaryStructures(DAC960_Controller_T *Controller)
369 struct pci_pool *ScatterGatherPool = Controller->ScatterGatherPool;
370 struct pci_pool *RequestSensePool = NULL;
371 void *ScatterGatherCPU;
372 dma_addr_t ScatterGatherDMA;
373 void *RequestSenseCPU;
374 dma_addr_t RequestSenseDMA;
375 DAC960_Command_T *CommandGroup = NULL;
378 if (Controller->FirmwareType == DAC960_V2_Controller)
379 RequestSensePool = Controller->V2.RequestSensePool;
381 Controller->FreeCommands = NULL;
382 for (i = 0; i < Controller->DriverQueueDepth; i++)
384 DAC960_Command_T *Command = Controller->Commands[i];
389 if (Controller->FirmwareType == DAC960_V1_Controller) {
390 ScatterGatherCPU = (void *)Command->V1.ScatterGatherList;
391 ScatterGatherDMA = Command->V1.ScatterGatherListDMA;
392 RequestSenseCPU = NULL;
393 RequestSenseDMA = (dma_addr_t)0;
395 ScatterGatherCPU = (void *)Command->V2.ScatterGatherList;
396 ScatterGatherDMA = Command->V2.ScatterGatherListDMA;
397 RequestSenseCPU = (void *)Command->V2.RequestSense;
398 RequestSenseDMA = Command->V2.RequestSenseDMA;
400 if (ScatterGatherCPU != NULL)
401 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, ScatterGatherDMA);
402 if (RequestSenseCPU != NULL)
403 pci_pool_free(RequestSensePool, RequestSenseCPU, RequestSenseDMA);
405 if ((Command->CommandIdentifier
406 % Controller->CommandAllocationGroupSize) == 1) {
408 * We can't free the group of commands until all of the
409 * request sense and scatter gather dma structures are free.
410 * Remember the beginning of the group, but don't free it
411 * until we've reached the beginning of the next group.
413 if (CommandGroup != NULL)
415 CommandGroup = Command;
417 Controller->Commands[i] = NULL;
419 if (CommandGroup != NULL)
422 if (Controller->CombinedStatusBuffer != NULL)
424 kfree(Controller->CombinedStatusBuffer);
425 Controller->CombinedStatusBuffer = NULL;
426 Controller->CurrentStatusBuffer = NULL;
429 if (ScatterGatherPool != NULL)
430 pci_pool_destroy(ScatterGatherPool);
431 if (Controller->FirmwareType == DAC960_V1_Controller) return;
433 if (RequestSensePool != NULL)
434 pci_pool_destroy(RequestSensePool);
436 for (i = 0; i < DAC960_MaxLogicalDrives; i++)
437 if (Controller->V2.LogicalDeviceInformation[i] != NULL)
439 kfree(Controller->V2.LogicalDeviceInformation[i]);
440 Controller->V2.LogicalDeviceInformation[i] = NULL;
443 for (i = 0; i < DAC960_V2_MaxPhysicalDevices; i++)
445 if (Controller->V2.PhysicalDeviceInformation[i] != NULL)
447 kfree(Controller->V2.PhysicalDeviceInformation[i]);
448 Controller->V2.PhysicalDeviceInformation[i] = NULL;
450 if (Controller->V2.InquiryUnitSerialNumber[i] != NULL)
452 kfree(Controller->V2.InquiryUnitSerialNumber[i]);
453 Controller->V2.InquiryUnitSerialNumber[i] = NULL;
460 DAC960_V1_ClearCommand clears critical fields of Command for DAC960 V1
461 Firmware Controllers.
464 static inline void DAC960_V1_ClearCommand(DAC960_Command_T *Command)
466 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
467 memset(CommandMailbox, 0, sizeof(DAC960_V1_CommandMailbox_T));
468 Command->V1.CommandStatus = 0;
473 DAC960_V2_ClearCommand clears critical fields of Command for DAC960 V2
474 Firmware Controllers.
477 static inline void DAC960_V2_ClearCommand(DAC960_Command_T *Command)
479 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
480 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
481 Command->V2.CommandStatus = 0;
486 DAC960_AllocateCommand allocates a Command structure from Controller's
487 free list. During driver initialization, a special initialization command
488 has been placed on the free list to guarantee that command allocation can
492 static inline DAC960_Command_T *DAC960_AllocateCommand(DAC960_Controller_T
495 DAC960_Command_T *Command = Controller->FreeCommands;
496 if (Command == NULL) return NULL;
497 Controller->FreeCommands = Command->Next;
498 Command->Next = NULL;
504 DAC960_DeallocateCommand deallocates Command, returning it to Controller's
508 static inline void DAC960_DeallocateCommand(DAC960_Command_T *Command)
510 DAC960_Controller_T *Controller = Command->Controller;
512 Command->Request = NULL;
513 Command->Next = Controller->FreeCommands;
514 Controller->FreeCommands = Command;
519 DAC960_WaitForCommand waits for a wake_up on Controller's Command Wait Queue.
522 static void DAC960_WaitForCommand(DAC960_Controller_T *Controller)
524 spin_unlock_irq(&Controller->queue_lock);
525 __wait_event(Controller->CommandWaitQueue, Controller->FreeCommands);
526 spin_lock_irq(&Controller->queue_lock);
531 DAC960_BA_QueueCommand queues Command for DAC960 BA Series Controllers.
534 static void DAC960_BA_QueueCommand(DAC960_Command_T *Command)
536 DAC960_Controller_T *Controller = Command->Controller;
537 void *ControllerBaseAddress = Controller->BaseAddress;
538 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
539 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
540 Controller->V2.NextCommandMailbox;
541 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
542 DAC960_BA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
543 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
544 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
545 DAC960_BA_MemoryMailboxNewCommand(ControllerBaseAddress);
546 Controller->V2.PreviousCommandMailbox2 =
547 Controller->V2.PreviousCommandMailbox1;
548 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
549 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
550 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
551 Controller->V2.NextCommandMailbox = NextCommandMailbox;
556 DAC960_LP_QueueCommand queues Command for DAC960 LP Series Controllers.
559 static void DAC960_LP_QueueCommand(DAC960_Command_T *Command)
561 DAC960_Controller_T *Controller = Command->Controller;
562 void *ControllerBaseAddress = Controller->BaseAddress;
563 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
564 DAC960_V2_CommandMailbox_T *NextCommandMailbox =
565 Controller->V2.NextCommandMailbox;
566 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
567 DAC960_LP_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
568 if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 ||
569 Controller->V2.PreviousCommandMailbox2->Words[0] == 0)
570 DAC960_LP_MemoryMailboxNewCommand(ControllerBaseAddress);
571 Controller->V2.PreviousCommandMailbox2 =
572 Controller->V2.PreviousCommandMailbox1;
573 Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox;
574 if (++NextCommandMailbox > Controller->V2.LastCommandMailbox)
575 NextCommandMailbox = Controller->V2.FirstCommandMailbox;
576 Controller->V2.NextCommandMailbox = NextCommandMailbox;
581 DAC960_LA_QueueCommandDualMode queues Command for DAC960 LA Series
582 Controllers with Dual Mode Firmware.
585 static void DAC960_LA_QueueCommandDualMode(DAC960_Command_T *Command)
587 DAC960_Controller_T *Controller = Command->Controller;
588 void *ControllerBaseAddress = Controller->BaseAddress;
589 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
590 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
591 Controller->V1.NextCommandMailbox;
592 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
593 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
594 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
595 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
596 DAC960_LA_MemoryMailboxNewCommand(ControllerBaseAddress);
597 Controller->V1.PreviousCommandMailbox2 =
598 Controller->V1.PreviousCommandMailbox1;
599 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
600 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
601 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
602 Controller->V1.NextCommandMailbox = NextCommandMailbox;
607 DAC960_LA_QueueCommandSingleMode queues Command for DAC960 LA Series
608 Controllers with Single Mode Firmware.
611 static void DAC960_LA_QueueCommandSingleMode(DAC960_Command_T *Command)
613 DAC960_Controller_T *Controller = Command->Controller;
614 void *ControllerBaseAddress = Controller->BaseAddress;
615 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
616 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
617 Controller->V1.NextCommandMailbox;
618 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
619 DAC960_LA_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
620 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
621 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
622 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
623 Controller->V1.PreviousCommandMailbox2 =
624 Controller->V1.PreviousCommandMailbox1;
625 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
626 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
627 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
628 Controller->V1.NextCommandMailbox = NextCommandMailbox;
633 DAC960_PG_QueueCommandDualMode queues Command for DAC960 PG Series
634 Controllers with Dual Mode Firmware.
637 static void DAC960_PG_QueueCommandDualMode(DAC960_Command_T *Command)
639 DAC960_Controller_T *Controller = Command->Controller;
640 void *ControllerBaseAddress = Controller->BaseAddress;
641 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
642 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
643 Controller->V1.NextCommandMailbox;
644 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
645 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
646 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
647 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
648 DAC960_PG_MemoryMailboxNewCommand(ControllerBaseAddress);
649 Controller->V1.PreviousCommandMailbox2 =
650 Controller->V1.PreviousCommandMailbox1;
651 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
652 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
653 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
654 Controller->V1.NextCommandMailbox = NextCommandMailbox;
659 DAC960_PG_QueueCommandSingleMode queues Command for DAC960 PG Series
660 Controllers with Single Mode Firmware.
663 static void DAC960_PG_QueueCommandSingleMode(DAC960_Command_T *Command)
665 DAC960_Controller_T *Controller = Command->Controller;
666 void *ControllerBaseAddress = Controller->BaseAddress;
667 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
668 DAC960_V1_CommandMailbox_T *NextCommandMailbox =
669 Controller->V1.NextCommandMailbox;
670 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
671 DAC960_PG_WriteCommandMailbox(NextCommandMailbox, CommandMailbox);
672 if (Controller->V1.PreviousCommandMailbox1->Words[0] == 0 ||
673 Controller->V1.PreviousCommandMailbox2->Words[0] == 0)
674 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
675 Controller->V1.PreviousCommandMailbox2 =
676 Controller->V1.PreviousCommandMailbox1;
677 Controller->V1.PreviousCommandMailbox1 = NextCommandMailbox;
678 if (++NextCommandMailbox > Controller->V1.LastCommandMailbox)
679 NextCommandMailbox = Controller->V1.FirstCommandMailbox;
680 Controller->V1.NextCommandMailbox = NextCommandMailbox;
685 DAC960_PD_QueueCommand queues Command for DAC960 PD Series Controllers.
688 static void DAC960_PD_QueueCommand(DAC960_Command_T *Command)
690 DAC960_Controller_T *Controller = Command->Controller;
691 void *ControllerBaseAddress = Controller->BaseAddress;
692 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
693 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
694 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
696 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
697 DAC960_PD_NewCommand(ControllerBaseAddress);
702 DAC960_P_QueueCommand queues Command for DAC960 P Series Controllers.
705 static void DAC960_P_QueueCommand(DAC960_Command_T *Command)
707 DAC960_Controller_T *Controller = Command->Controller;
708 void *ControllerBaseAddress = Controller->BaseAddress;
709 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
710 CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier;
711 switch (CommandMailbox->Common.CommandOpcode)
713 case DAC960_V1_Enquiry:
714 CommandMailbox->Common.CommandOpcode = DAC960_V1_Enquiry_Old;
716 case DAC960_V1_GetDeviceState:
717 CommandMailbox->Common.CommandOpcode = DAC960_V1_GetDeviceState_Old;
720 CommandMailbox->Common.CommandOpcode = DAC960_V1_Read_Old;
721 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
723 case DAC960_V1_Write:
724 CommandMailbox->Common.CommandOpcode = DAC960_V1_Write_Old;
725 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
727 case DAC960_V1_ReadWithScatterGather:
728 CommandMailbox->Common.CommandOpcode =
729 DAC960_V1_ReadWithScatterGather_Old;
730 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
732 case DAC960_V1_WriteWithScatterGather:
733 CommandMailbox->Common.CommandOpcode =
734 DAC960_V1_WriteWithScatterGather_Old;
735 DAC960_PD_To_P_TranslateReadWriteCommand(CommandMailbox);
740 while (DAC960_PD_MailboxFullP(ControllerBaseAddress))
742 DAC960_PD_WriteCommandMailbox(ControllerBaseAddress, CommandMailbox);
743 DAC960_PD_NewCommand(ControllerBaseAddress);
748 DAC960_ExecuteCommand executes Command and waits for completion.
751 static void DAC960_ExecuteCommand(DAC960_Command_T *Command)
753 DAC960_Controller_T *Controller = Command->Controller;
754 DECLARE_COMPLETION(Completion);
756 Command->Completion = &Completion;
758 spin_lock_irqsave(&Controller->queue_lock, flags);
759 DAC960_QueueCommand(Command);
760 spin_unlock_irqrestore(&Controller->queue_lock, flags);
764 wait_for_completion(&Completion);
769 DAC960_V1_ExecuteType3 executes a DAC960 V1 Firmware Controller Type 3
770 Command and waits for completion. It returns true on success and false
774 static boolean DAC960_V1_ExecuteType3(DAC960_Controller_T *Controller,
775 DAC960_V1_CommandOpcode_T CommandOpcode,
778 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
779 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
780 DAC960_V1_CommandStatus_T CommandStatus;
781 DAC960_V1_ClearCommand(Command);
782 Command->CommandType = DAC960_ImmediateCommand;
783 CommandMailbox->Type3.CommandOpcode = CommandOpcode;
784 CommandMailbox->Type3.BusAddress = DataDMA;
785 DAC960_ExecuteCommand(Command);
786 CommandStatus = Command->V1.CommandStatus;
787 DAC960_DeallocateCommand(Command);
788 return (CommandStatus == DAC960_V1_NormalCompletion);
793 DAC960_V1_ExecuteTypeB executes a DAC960 V1 Firmware Controller Type 3B
794 Command and waits for completion. It returns true on success and false
798 static boolean DAC960_V1_ExecuteType3B(DAC960_Controller_T *Controller,
799 DAC960_V1_CommandOpcode_T CommandOpcode,
800 unsigned char CommandOpcode2,
803 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
804 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
805 DAC960_V1_CommandStatus_T CommandStatus;
806 DAC960_V1_ClearCommand(Command);
807 Command->CommandType = DAC960_ImmediateCommand;
808 CommandMailbox->Type3B.CommandOpcode = CommandOpcode;
809 CommandMailbox->Type3B.CommandOpcode2 = CommandOpcode2;
810 CommandMailbox->Type3B.BusAddress = DataDMA;
811 DAC960_ExecuteCommand(Command);
812 CommandStatus = Command->V1.CommandStatus;
813 DAC960_DeallocateCommand(Command);
814 return (CommandStatus == DAC960_V1_NormalCompletion);
819 DAC960_V1_ExecuteType3D executes a DAC960 V1 Firmware Controller Type 3D
820 Command and waits for completion. It returns true on success and false
824 static boolean DAC960_V1_ExecuteType3D(DAC960_Controller_T *Controller,
825 DAC960_V1_CommandOpcode_T CommandOpcode,
826 unsigned char Channel,
827 unsigned char TargetID,
830 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
831 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
832 DAC960_V1_CommandStatus_T CommandStatus;
833 DAC960_V1_ClearCommand(Command);
834 Command->CommandType = DAC960_ImmediateCommand;
835 CommandMailbox->Type3D.CommandOpcode = CommandOpcode;
836 CommandMailbox->Type3D.Channel = Channel;
837 CommandMailbox->Type3D.TargetID = TargetID;
838 CommandMailbox->Type3D.BusAddress = DataDMA;
839 DAC960_ExecuteCommand(Command);
840 CommandStatus = Command->V1.CommandStatus;
841 DAC960_DeallocateCommand(Command);
842 return (CommandStatus == DAC960_V1_NormalCompletion);
847 DAC960_V2_GeneralInfo executes a DAC960 V2 Firmware General Information
848 Reading IOCTL Command and waits for completion. It returns true on success
849 and false on failure.
851 Return data in The controller's HealthStatusBuffer, which is dma-able memory
854 static boolean DAC960_V2_GeneralInfo(DAC960_Controller_T *Controller)
856 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
857 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
858 DAC960_V2_CommandStatus_T CommandStatus;
859 DAC960_V2_ClearCommand(Command);
860 Command->CommandType = DAC960_ImmediateCommand;
861 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
862 CommandMailbox->Common.CommandControlBits
863 .DataTransferControllerToHost = true;
864 CommandMailbox->Common.CommandControlBits
865 .NoAutoRequestSense = true;
866 CommandMailbox->Common.DataTransferSize = sizeof(DAC960_V2_HealthStatusBuffer_T);
867 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_GetHealthStatus;
868 CommandMailbox->Common.DataTransferMemoryAddress
869 .ScatterGatherSegments[0]
870 .SegmentDataPointer =
871 Controller->V2.HealthStatusBufferDMA;
872 CommandMailbox->Common.DataTransferMemoryAddress
873 .ScatterGatherSegments[0]
875 CommandMailbox->Common.DataTransferSize;
876 DAC960_ExecuteCommand(Command);
877 CommandStatus = Command->V2.CommandStatus;
878 DAC960_DeallocateCommand(Command);
879 return (CommandStatus == DAC960_V2_NormalCompletion);
884 DAC960_V2_ControllerInfo executes a DAC960 V2 Firmware Controller
885 Information Reading IOCTL Command and waits for completion. It returns
886 true on success and false on failure.
888 Data is returned in the controller's V2.NewControllerInformation dma-able
892 static boolean DAC960_V2_NewControllerInfo(DAC960_Controller_T *Controller)
894 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
895 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
896 DAC960_V2_CommandStatus_T CommandStatus;
897 DAC960_V2_ClearCommand(Command);
898 Command->CommandType = DAC960_ImmediateCommand;
899 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
900 CommandMailbox->ControllerInfo.CommandControlBits
901 .DataTransferControllerToHost = true;
902 CommandMailbox->ControllerInfo.CommandControlBits
903 .NoAutoRequestSense = true;
904 CommandMailbox->ControllerInfo.DataTransferSize = sizeof(DAC960_V2_ControllerInfo_T);
905 CommandMailbox->ControllerInfo.ControllerNumber = 0;
906 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
907 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
908 .ScatterGatherSegments[0]
909 .SegmentDataPointer =
910 Controller->V2.NewControllerInformationDMA;
911 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
912 .ScatterGatherSegments[0]
914 CommandMailbox->ControllerInfo.DataTransferSize;
915 DAC960_ExecuteCommand(Command);
916 CommandStatus = Command->V2.CommandStatus;
917 DAC960_DeallocateCommand(Command);
918 return (CommandStatus == DAC960_V2_NormalCompletion);
923 DAC960_V2_LogicalDeviceInfo executes a DAC960 V2 Firmware Controller Logical
924 Device Information Reading IOCTL Command and waits for completion. It
925 returns true on success and false on failure.
927 Data is returned in the controller's V2.NewLogicalDeviceInformation
930 static boolean DAC960_V2_NewLogicalDeviceInfo(DAC960_Controller_T *Controller,
931 unsigned short LogicalDeviceNumber)
933 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
934 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
935 DAC960_V2_CommandStatus_T CommandStatus;
937 DAC960_V2_ClearCommand(Command);
938 Command->CommandType = DAC960_ImmediateCommand;
939 CommandMailbox->LogicalDeviceInfo.CommandOpcode =
941 CommandMailbox->LogicalDeviceInfo.CommandControlBits
942 .DataTransferControllerToHost = true;
943 CommandMailbox->LogicalDeviceInfo.CommandControlBits
944 .NoAutoRequestSense = true;
945 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
946 sizeof(DAC960_V2_LogicalDeviceInfo_T);
947 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
949 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode = DAC960_V2_GetLogicalDeviceInfoValid;
950 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
951 .ScatterGatherSegments[0]
952 .SegmentDataPointer =
953 Controller->V2.NewLogicalDeviceInformationDMA;
954 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
955 .ScatterGatherSegments[0]
957 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
958 DAC960_ExecuteCommand(Command);
959 CommandStatus = Command->V2.CommandStatus;
960 DAC960_DeallocateCommand(Command);
961 return (CommandStatus == DAC960_V2_NormalCompletion);
966 DAC960_V2_PhysicalDeviceInfo executes a DAC960 V2 Firmware Controller "Read
967 Physical Device Information" IOCTL Command and waits for completion. It
968 returns true on success and false on failure.
970 The Channel, TargetID, LogicalUnit arguments should be 0 the first time
971 this function is called for a given controller. This will return data
972 for the "first" device on that controller. The returned data includes a
973 Channel, TargetID, LogicalUnit that can be passed in to this routine to
974 get data for the NEXT device on that controller.
976 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
981 static boolean DAC960_V2_NewPhysicalDeviceInfo(DAC960_Controller_T *Controller,
982 unsigned char Channel,
983 unsigned char TargetID,
984 unsigned char LogicalUnit)
986 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
987 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
988 DAC960_V2_CommandStatus_T CommandStatus;
990 DAC960_V2_ClearCommand(Command);
991 Command->CommandType = DAC960_ImmediateCommand;
992 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
993 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
994 .DataTransferControllerToHost = true;
995 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
996 .NoAutoRequestSense = true;
997 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
998 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
999 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit = LogicalUnit;
1000 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
1001 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
1002 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
1003 DAC960_V2_GetPhysicalDeviceInfoValid;
1004 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1005 .ScatterGatherSegments[0]
1006 .SegmentDataPointer =
1007 Controller->V2.NewPhysicalDeviceInformationDMA;
1008 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
1009 .ScatterGatherSegments[0]
1011 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
1012 DAC960_ExecuteCommand(Command);
1013 CommandStatus = Command->V2.CommandStatus;
1014 DAC960_DeallocateCommand(Command);
1015 return (CommandStatus == DAC960_V2_NormalCompletion);
1019 static void DAC960_V2_ConstructNewUnitSerialNumber(
1020 DAC960_Controller_T *Controller,
1021 DAC960_V2_CommandMailbox_T *CommandMailbox, int Channel, int TargetID,
1024 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10_Passthru;
1025 CommandMailbox->SCSI_10.CommandControlBits
1026 .DataTransferControllerToHost = true;
1027 CommandMailbox->SCSI_10.CommandControlBits
1028 .NoAutoRequestSense = true;
1029 CommandMailbox->SCSI_10.DataTransferSize =
1030 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1031 CommandMailbox->SCSI_10.PhysicalDevice.LogicalUnit = LogicalUnit;
1032 CommandMailbox->SCSI_10.PhysicalDevice.TargetID = TargetID;
1033 CommandMailbox->SCSI_10.PhysicalDevice.Channel = Channel;
1034 CommandMailbox->SCSI_10.CDBLength = 6;
1035 CommandMailbox->SCSI_10.SCSI_CDB[0] = 0x12; /* INQUIRY */
1036 CommandMailbox->SCSI_10.SCSI_CDB[1] = 1; /* EVPD = 1 */
1037 CommandMailbox->SCSI_10.SCSI_CDB[2] = 0x80; /* Page Code */
1038 CommandMailbox->SCSI_10.SCSI_CDB[3] = 0; /* Reserved */
1039 CommandMailbox->SCSI_10.SCSI_CDB[4] =
1040 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1041 CommandMailbox->SCSI_10.SCSI_CDB[5] = 0; /* Control */
1042 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1043 .ScatterGatherSegments[0]
1044 .SegmentDataPointer =
1045 Controller->V2.NewInquiryUnitSerialNumberDMA;
1046 CommandMailbox->SCSI_10.DataTransferMemoryAddress
1047 .ScatterGatherSegments[0]
1049 CommandMailbox->SCSI_10.DataTransferSize;
1054 DAC960_V2_NewUnitSerialNumber executes an SCSI pass-through
1055 Inquiry command to a SCSI device identified by Channel number,
1056 Target id, Logical Unit Number. This function Waits for completion
1059 The return data includes Unit Serial Number information for the
1062 Data is stored in the controller's V2.NewPhysicalDeviceInfo dma-able
1066 static boolean DAC960_V2_NewInquiryUnitSerialNumber(DAC960_Controller_T *Controller,
1067 int Channel, int TargetID, int LogicalUnit)
1069 DAC960_Command_T *Command;
1070 DAC960_V2_CommandMailbox_T *CommandMailbox;
1071 DAC960_V2_CommandStatus_T CommandStatus;
1073 Command = DAC960_AllocateCommand(Controller);
1074 CommandMailbox = &Command->V2.CommandMailbox;
1075 DAC960_V2_ClearCommand(Command);
1076 Command->CommandType = DAC960_ImmediateCommand;
1078 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
1079 Channel, TargetID, LogicalUnit);
1081 DAC960_ExecuteCommand(Command);
1082 CommandStatus = Command->V2.CommandStatus;
1083 DAC960_DeallocateCommand(Command);
1084 return (CommandStatus == DAC960_V2_NormalCompletion);
1089 DAC960_V2_DeviceOperation executes a DAC960 V2 Firmware Controller Device
1090 Operation IOCTL Command and waits for completion. It returns true on
1091 success and false on failure.
1094 static boolean DAC960_V2_DeviceOperation(DAC960_Controller_T *Controller,
1095 DAC960_V2_IOCTL_Opcode_T IOCTL_Opcode,
1096 DAC960_V2_OperationDevice_T
1099 DAC960_Command_T *Command = DAC960_AllocateCommand(Controller);
1100 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
1101 DAC960_V2_CommandStatus_T CommandStatus;
1102 DAC960_V2_ClearCommand(Command);
1103 Command->CommandType = DAC960_ImmediateCommand;
1104 CommandMailbox->DeviceOperation.CommandOpcode = DAC960_V2_IOCTL;
1105 CommandMailbox->DeviceOperation.CommandControlBits
1106 .DataTransferControllerToHost = true;
1107 CommandMailbox->DeviceOperation.CommandControlBits
1108 .NoAutoRequestSense = true;
1109 CommandMailbox->DeviceOperation.IOCTL_Opcode = IOCTL_Opcode;
1110 CommandMailbox->DeviceOperation.OperationDevice = OperationDevice;
1111 DAC960_ExecuteCommand(Command);
1112 CommandStatus = Command->V2.CommandStatus;
1113 DAC960_DeallocateCommand(Command);
1114 return (CommandStatus == DAC960_V2_NormalCompletion);
1119 DAC960_V1_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1120 for DAC960 V1 Firmware Controllers.
1122 PD and P controller types have no memory mailbox, but still need the
1123 other dma mapped memory.
1126 static boolean DAC960_V1_EnableMemoryMailboxInterface(DAC960_Controller_T
1129 void *ControllerBaseAddress = Controller->BaseAddress;
1130 DAC960_HardwareType_T hw_type = Controller->HardwareType;
1131 struct pci_dev *PCI_Device = Controller->PCIDevice;
1132 struct dma_loaf *DmaPages = &Controller->DmaPages;
1133 size_t DmaPagesSize;
1134 size_t CommandMailboxesSize;
1135 size_t StatusMailboxesSize;
1137 DAC960_V1_CommandMailbox_T *CommandMailboxesMemory;
1138 dma_addr_t CommandMailboxesMemoryDMA;
1140 DAC960_V1_StatusMailbox_T *StatusMailboxesMemory;
1141 dma_addr_t StatusMailboxesMemoryDMA;
1143 DAC960_V1_CommandMailbox_T CommandMailbox;
1144 DAC960_V1_CommandStatus_T CommandStatus;
1149 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V1_PciDmaMask))
1150 return DAC960_Failure(Controller, "DMA mask out of range");
1151 Controller->BounceBufferLimit = DAC690_V1_PciDmaMask;
1153 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller)) {
1154 CommandMailboxesSize = 0;
1155 StatusMailboxesSize = 0;
1157 CommandMailboxesSize = DAC960_V1_CommandMailboxCount * sizeof(DAC960_V1_CommandMailbox_T);
1158 StatusMailboxesSize = DAC960_V1_StatusMailboxCount * sizeof(DAC960_V1_StatusMailbox_T);
1160 DmaPagesSize = CommandMailboxesSize + StatusMailboxesSize +
1161 sizeof(DAC960_V1_DCDB_T) + sizeof(DAC960_V1_Enquiry_T) +
1162 sizeof(DAC960_V1_ErrorTable_T) + sizeof(DAC960_V1_EventLogEntry_T) +
1163 sizeof(DAC960_V1_RebuildProgress_T) +
1164 sizeof(DAC960_V1_LogicalDriveInformationArray_T) +
1165 sizeof(DAC960_V1_BackgroundInitializationStatus_T) +
1166 sizeof(DAC960_V1_DeviceState_T) + sizeof(DAC960_SCSI_Inquiry_T) +
1167 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
1169 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize))
1173 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1174 goto skip_mailboxes;
1176 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1177 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1179 /* These are the base addresses for the command memory mailbox array */
1180 Controller->V1.FirstCommandMailbox = CommandMailboxesMemory;
1181 Controller->V1.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1183 CommandMailboxesMemory += DAC960_V1_CommandMailboxCount - 1;
1184 Controller->V1.LastCommandMailbox = CommandMailboxesMemory;
1185 Controller->V1.NextCommandMailbox = Controller->V1.FirstCommandMailbox;
1186 Controller->V1.PreviousCommandMailbox1 = Controller->V1.LastCommandMailbox;
1187 Controller->V1.PreviousCommandMailbox2 =
1188 Controller->V1.LastCommandMailbox - 1;
1190 /* These are the base addresses for the status memory mailbox array */
1191 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1192 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1194 Controller->V1.FirstStatusMailbox = StatusMailboxesMemory;
1195 Controller->V1.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1196 StatusMailboxesMemory += DAC960_V1_StatusMailboxCount - 1;
1197 Controller->V1.LastStatusMailbox = StatusMailboxesMemory;
1198 Controller->V1.NextStatusMailbox = Controller->V1.FirstStatusMailbox;
1201 Controller->V1.MonitoringDCDB = slice_dma_loaf(DmaPages,
1202 sizeof(DAC960_V1_DCDB_T),
1203 &Controller->V1.MonitoringDCDB_DMA);
1205 Controller->V1.NewEnquiry = slice_dma_loaf(DmaPages,
1206 sizeof(DAC960_V1_Enquiry_T),
1207 &Controller->V1.NewEnquiryDMA);
1209 Controller->V1.NewErrorTable = slice_dma_loaf(DmaPages,
1210 sizeof(DAC960_V1_ErrorTable_T),
1211 &Controller->V1.NewErrorTableDMA);
1213 Controller->V1.EventLogEntry = slice_dma_loaf(DmaPages,
1214 sizeof(DAC960_V1_EventLogEntry_T),
1215 &Controller->V1.EventLogEntryDMA);
1217 Controller->V1.RebuildProgress = slice_dma_loaf(DmaPages,
1218 sizeof(DAC960_V1_RebuildProgress_T),
1219 &Controller->V1.RebuildProgressDMA);
1221 Controller->V1.NewLogicalDriveInformation = slice_dma_loaf(DmaPages,
1222 sizeof(DAC960_V1_LogicalDriveInformationArray_T),
1223 &Controller->V1.NewLogicalDriveInformationDMA);
1225 Controller->V1.BackgroundInitializationStatus = slice_dma_loaf(DmaPages,
1226 sizeof(DAC960_V1_BackgroundInitializationStatus_T),
1227 &Controller->V1.BackgroundInitializationStatusDMA);
1229 Controller->V1.NewDeviceState = slice_dma_loaf(DmaPages,
1230 sizeof(DAC960_V1_DeviceState_T),
1231 &Controller->V1.NewDeviceStateDMA);
1233 Controller->V1.NewInquiryStandardData = slice_dma_loaf(DmaPages,
1234 sizeof(DAC960_SCSI_Inquiry_T),
1235 &Controller->V1.NewInquiryStandardDataDMA);
1237 Controller->V1.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1238 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1239 &Controller->V1.NewInquiryUnitSerialNumberDMA);
1241 if ((hw_type == DAC960_PD_Controller) || (hw_type == DAC960_P_Controller))
1244 /* Enable the Memory Mailbox Interface. */
1245 Controller->V1.DualModeMemoryMailboxInterface = true;
1246 CommandMailbox.TypeX.CommandOpcode = 0x2B;
1247 CommandMailbox.TypeX.CommandIdentifier = 0;
1248 CommandMailbox.TypeX.CommandOpcode2 = 0x14;
1249 CommandMailbox.TypeX.CommandMailboxesBusAddress =
1250 Controller->V1.FirstCommandMailboxDMA;
1251 CommandMailbox.TypeX.StatusMailboxesBusAddress =
1252 Controller->V1.FirstStatusMailboxDMA;
1253 #define TIMEOUT_COUNT 1000000
1255 for (i = 0; i < 2; i++)
1256 switch (Controller->HardwareType)
1258 case DAC960_LA_Controller:
1259 TimeoutCounter = TIMEOUT_COUNT;
1260 while (--TimeoutCounter >= 0)
1262 if (!DAC960_LA_HardwareMailboxFullP(ControllerBaseAddress))
1266 if (TimeoutCounter < 0) return false;
1267 DAC960_LA_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1268 DAC960_LA_HardwareMailboxNewCommand(ControllerBaseAddress);
1269 TimeoutCounter = TIMEOUT_COUNT;
1270 while (--TimeoutCounter >= 0)
1272 if (DAC960_LA_HardwareMailboxStatusAvailableP(
1273 ControllerBaseAddress))
1277 if (TimeoutCounter < 0) return false;
1278 CommandStatus = DAC960_LA_ReadStatusRegister(ControllerBaseAddress);
1279 DAC960_LA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1280 DAC960_LA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1281 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1282 Controller->V1.DualModeMemoryMailboxInterface = false;
1283 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1285 case DAC960_PG_Controller:
1286 TimeoutCounter = TIMEOUT_COUNT;
1287 while (--TimeoutCounter >= 0)
1289 if (!DAC960_PG_HardwareMailboxFullP(ControllerBaseAddress))
1293 if (TimeoutCounter < 0) return false;
1294 DAC960_PG_WriteHardwareMailbox(ControllerBaseAddress, &CommandMailbox);
1295 DAC960_PG_HardwareMailboxNewCommand(ControllerBaseAddress);
1297 TimeoutCounter = TIMEOUT_COUNT;
1298 while (--TimeoutCounter >= 0)
1300 if (DAC960_PG_HardwareMailboxStatusAvailableP(
1301 ControllerBaseAddress))
1305 if (TimeoutCounter < 0) return false;
1306 CommandStatus = DAC960_PG_ReadStatusRegister(ControllerBaseAddress);
1307 DAC960_PG_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1308 DAC960_PG_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1309 if (CommandStatus == DAC960_V1_NormalCompletion) return true;
1310 Controller->V1.DualModeMemoryMailboxInterface = false;
1311 CommandMailbox.TypeX.CommandOpcode2 = 0x10;
1314 DAC960_Failure(Controller, "Unknown Controller Type\n");
1322 DAC960_V2_EnableMemoryMailboxInterface enables the Memory Mailbox Interface
1323 for DAC960 V2 Firmware Controllers.
1325 Aggregate the space needed for the controller's memory mailbox and
1326 the other data structures that will be targets of dma transfers with
1327 the controller. Allocate a dma-mapped region of memory to hold these
1328 structures. Then, save CPU pointers and dma_addr_t values to reference
1329 the structures that are contained in that region.
1332 static boolean DAC960_V2_EnableMemoryMailboxInterface(DAC960_Controller_T
1335 void *ControllerBaseAddress = Controller->BaseAddress;
1336 struct pci_dev *PCI_Device = Controller->PCIDevice;
1337 struct dma_loaf *DmaPages = &Controller->DmaPages;
1338 size_t DmaPagesSize;
1339 size_t CommandMailboxesSize;
1340 size_t StatusMailboxesSize;
1342 DAC960_V2_CommandMailbox_T *CommandMailboxesMemory;
1343 dma_addr_t CommandMailboxesMemoryDMA;
1345 DAC960_V2_StatusMailbox_T *StatusMailboxesMemory;
1346 dma_addr_t StatusMailboxesMemoryDMA;
1348 DAC960_V2_CommandMailbox_T *CommandMailbox;
1349 dma_addr_t CommandMailboxDMA;
1350 DAC960_V2_CommandStatus_T CommandStatus;
1352 if (pci_set_dma_mask(Controller->PCIDevice, DAC690_V2_PciDmaMask))
1353 return DAC960_Failure(Controller, "DMA mask out of range");
1354 Controller->BounceBufferLimit = DAC690_V2_PciDmaMask;
1356 /* This is a temporary dma mapping, used only in the scope of this function */
1358 (DAC960_V2_CommandMailbox_T *)pci_alloc_consistent( PCI_Device,
1359 sizeof(DAC960_V2_CommandMailbox_T), &CommandMailboxDMA);
1360 if (CommandMailbox == NULL)
1363 CommandMailboxesSize = DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T);
1364 StatusMailboxesSize = DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T);
1366 CommandMailboxesSize + StatusMailboxesSize +
1367 sizeof(DAC960_V2_HealthStatusBuffer_T) +
1368 sizeof(DAC960_V2_ControllerInfo_T) +
1369 sizeof(DAC960_V2_LogicalDeviceInfo_T) +
1370 sizeof(DAC960_V2_PhysicalDeviceInfo_T) +
1371 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T) +
1372 sizeof(DAC960_V2_Event_T) +
1373 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
1375 if (!init_dma_loaf(PCI_Device, DmaPages, DmaPagesSize)) {
1376 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1377 CommandMailbox, CommandMailboxDMA);
1381 CommandMailboxesMemory = slice_dma_loaf(DmaPages,
1382 CommandMailboxesSize, &CommandMailboxesMemoryDMA);
1384 /* These are the base addresses for the command memory mailbox array */
1385 Controller->V2.FirstCommandMailbox = CommandMailboxesMemory;
1386 Controller->V2.FirstCommandMailboxDMA = CommandMailboxesMemoryDMA;
1388 CommandMailboxesMemory += DAC960_V2_CommandMailboxCount - 1;
1389 Controller->V2.LastCommandMailbox = CommandMailboxesMemory;
1390 Controller->V2.NextCommandMailbox = Controller->V2.FirstCommandMailbox;
1391 Controller->V2.PreviousCommandMailbox1 = Controller->V2.LastCommandMailbox;
1392 Controller->V2.PreviousCommandMailbox2 =
1393 Controller->V2.LastCommandMailbox - 1;
1395 /* These are the base addresses for the status memory mailbox array */
1396 StatusMailboxesMemory = slice_dma_loaf(DmaPages,
1397 StatusMailboxesSize, &StatusMailboxesMemoryDMA);
1399 Controller->V2.FirstStatusMailbox = StatusMailboxesMemory;
1400 Controller->V2.FirstStatusMailboxDMA = StatusMailboxesMemoryDMA;
1401 StatusMailboxesMemory += DAC960_V2_StatusMailboxCount - 1;
1402 Controller->V2.LastStatusMailbox = StatusMailboxesMemory;
1403 Controller->V2.NextStatusMailbox = Controller->V2.FirstStatusMailbox;
1405 Controller->V2.HealthStatusBuffer = slice_dma_loaf(DmaPages,
1406 sizeof(DAC960_V2_HealthStatusBuffer_T),
1407 &Controller->V2.HealthStatusBufferDMA);
1409 Controller->V2.NewControllerInformation = slice_dma_loaf(DmaPages,
1410 sizeof(DAC960_V2_ControllerInfo_T),
1411 &Controller->V2.NewControllerInformationDMA);
1413 Controller->V2.NewLogicalDeviceInformation = slice_dma_loaf(DmaPages,
1414 sizeof(DAC960_V2_LogicalDeviceInfo_T),
1415 &Controller->V2.NewLogicalDeviceInformationDMA);
1417 Controller->V2.NewPhysicalDeviceInformation = slice_dma_loaf(DmaPages,
1418 sizeof(DAC960_V2_PhysicalDeviceInfo_T),
1419 &Controller->V2.NewPhysicalDeviceInformationDMA);
1421 Controller->V2.NewInquiryUnitSerialNumber = slice_dma_loaf(DmaPages,
1422 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1423 &Controller->V2.NewInquiryUnitSerialNumberDMA);
1425 Controller->V2.Event = slice_dma_loaf(DmaPages,
1426 sizeof(DAC960_V2_Event_T),
1427 &Controller->V2.EventDMA);
1429 Controller->V2.PhysicalToLogicalDevice = slice_dma_loaf(DmaPages,
1430 sizeof(DAC960_V2_PhysicalToLogicalDevice_T),
1431 &Controller->V2.PhysicalToLogicalDeviceDMA);
1434 Enable the Memory Mailbox Interface.
1436 I don't know why we can't just use one of the memory mailboxes
1437 we just allocated to do this, instead of using this temporary one.
1438 Try this change later.
1440 memset(CommandMailbox, 0, sizeof(DAC960_V2_CommandMailbox_T));
1441 CommandMailbox->SetMemoryMailbox.CommandIdentifier = 1;
1442 CommandMailbox->SetMemoryMailbox.CommandOpcode = DAC960_V2_IOCTL;
1443 CommandMailbox->SetMemoryMailbox.CommandControlBits.NoAutoRequestSense = true;
1444 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxSizeKB =
1445 (DAC960_V2_CommandMailboxCount * sizeof(DAC960_V2_CommandMailbox_T)) >> 10;
1446 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxSizeKB =
1447 (DAC960_V2_StatusMailboxCount * sizeof(DAC960_V2_StatusMailbox_T)) >> 10;
1448 CommandMailbox->SetMemoryMailbox.SecondCommandMailboxSizeKB = 0;
1449 CommandMailbox->SetMemoryMailbox.SecondStatusMailboxSizeKB = 0;
1450 CommandMailbox->SetMemoryMailbox.RequestSenseSize = 0;
1451 CommandMailbox->SetMemoryMailbox.IOCTL_Opcode = DAC960_V2_SetMemoryMailbox;
1452 CommandMailbox->SetMemoryMailbox.HealthStatusBufferSizeKB = 1;
1453 CommandMailbox->SetMemoryMailbox.HealthStatusBufferBusAddress =
1454 Controller->V2.HealthStatusBufferDMA;
1455 CommandMailbox->SetMemoryMailbox.FirstCommandMailboxBusAddress =
1456 Controller->V2.FirstCommandMailboxDMA;
1457 CommandMailbox->SetMemoryMailbox.FirstStatusMailboxBusAddress =
1458 Controller->V2.FirstStatusMailboxDMA;
1459 switch (Controller->HardwareType)
1461 case DAC960_BA_Controller:
1462 while (DAC960_BA_HardwareMailboxFullP(ControllerBaseAddress))
1464 DAC960_BA_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1465 DAC960_BA_HardwareMailboxNewCommand(ControllerBaseAddress);
1466 while (!DAC960_BA_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1468 CommandStatus = DAC960_BA_ReadCommandStatus(ControllerBaseAddress);
1469 DAC960_BA_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1470 DAC960_BA_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1472 case DAC960_LP_Controller:
1473 while (DAC960_LP_HardwareMailboxFullP(ControllerBaseAddress))
1475 DAC960_LP_WriteHardwareMailbox(ControllerBaseAddress, CommandMailboxDMA);
1476 DAC960_LP_HardwareMailboxNewCommand(ControllerBaseAddress);
1477 while (!DAC960_LP_HardwareMailboxStatusAvailableP(ControllerBaseAddress))
1479 CommandStatus = DAC960_LP_ReadCommandStatus(ControllerBaseAddress);
1480 DAC960_LP_AcknowledgeHardwareMailboxInterrupt(ControllerBaseAddress);
1481 DAC960_LP_AcknowledgeHardwareMailboxStatus(ControllerBaseAddress);
1484 DAC960_Failure(Controller, "Unknown Controller Type\n");
1485 CommandStatus = DAC960_V2_AbormalCompletion;
1488 pci_free_consistent(PCI_Device, sizeof(DAC960_V2_CommandMailbox_T),
1489 CommandMailbox, CommandMailboxDMA);
1490 return (CommandStatus == DAC960_V2_NormalCompletion);
1495 DAC960_V1_ReadControllerConfiguration reads the Configuration Information
1496 from DAC960 V1 Firmware Controllers and initializes the Controller structure.
1499 static boolean DAC960_V1_ReadControllerConfiguration(DAC960_Controller_T
1502 DAC960_V1_Enquiry2_T *Enquiry2;
1503 dma_addr_t Enquiry2DMA;
1504 DAC960_V1_Config2_T *Config2;
1505 dma_addr_t Config2DMA;
1506 int LogicalDriveNumber, Channel, TargetID;
1507 struct dma_loaf local_dma;
1509 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1510 sizeof(DAC960_V1_Enquiry2_T) + sizeof(DAC960_V1_Config2_T)))
1511 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1513 Enquiry2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Enquiry2_T), &Enquiry2DMA);
1514 Config2 = slice_dma_loaf(&local_dma, sizeof(DAC960_V1_Config2_T), &Config2DMA);
1516 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry,
1517 Controller->V1.NewEnquiryDMA)) {
1518 free_dma_loaf(Controller->PCIDevice, &local_dma);
1519 return DAC960_Failure(Controller, "ENQUIRY");
1521 memcpy(&Controller->V1.Enquiry, Controller->V1.NewEnquiry,
1522 sizeof(DAC960_V1_Enquiry_T));
1524 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_Enquiry2, Enquiry2DMA)) {
1525 free_dma_loaf(Controller->PCIDevice, &local_dma);
1526 return DAC960_Failure(Controller, "ENQUIRY2");
1529 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_ReadConfig2, Config2DMA)) {
1530 free_dma_loaf(Controller->PCIDevice, &local_dma);
1531 return DAC960_Failure(Controller, "READ CONFIG2");
1534 if (!DAC960_V1_ExecuteType3(Controller, DAC960_V1_GetLogicalDriveInformation,
1535 Controller->V1.NewLogicalDriveInformationDMA)) {
1536 free_dma_loaf(Controller->PCIDevice, &local_dma);
1537 return DAC960_Failure(Controller, "GET LOGICAL DRIVE INFORMATION");
1539 memcpy(&Controller->V1.LogicalDriveInformation,
1540 Controller->V1.NewLogicalDriveInformation,
1541 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
1543 for (Channel = 0; Channel < Enquiry2->ActualChannels; Channel++)
1544 for (TargetID = 0; TargetID < Enquiry2->MaxTargets; TargetID++) {
1545 if (!DAC960_V1_ExecuteType3D(Controller, DAC960_V1_GetDeviceState,
1547 Controller->V1.NewDeviceStateDMA)) {
1548 free_dma_loaf(Controller->PCIDevice, &local_dma);
1549 return DAC960_Failure(Controller, "GET DEVICE STATE");
1551 memcpy(&Controller->V1.DeviceState[Channel][TargetID],
1552 Controller->V1.NewDeviceState, sizeof(DAC960_V1_DeviceState_T));
1555 Initialize the Controller Model Name and Full Model Name fields.
1557 switch (Enquiry2->HardwareID.SubModel)
1559 case DAC960_V1_P_PD_PU:
1560 if (Enquiry2->SCSICapability.BusSpeed == DAC960_V1_Ultra)
1561 strcpy(Controller->ModelName, "DAC960PU");
1562 else strcpy(Controller->ModelName, "DAC960PD");
1565 strcpy(Controller->ModelName, "DAC960PL");
1568 strcpy(Controller->ModelName, "DAC960PG");
1571 strcpy(Controller->ModelName, "DAC960PJ");
1574 strcpy(Controller->ModelName, "DAC960PR");
1577 strcpy(Controller->ModelName, "DAC960PT");
1579 case DAC960_V1_PTL0:
1580 strcpy(Controller->ModelName, "DAC960PTL0");
1583 strcpy(Controller->ModelName, "DAC960PRL");
1585 case DAC960_V1_PTL1:
1586 strcpy(Controller->ModelName, "DAC960PTL1");
1588 case DAC960_V1_1164P:
1589 strcpy(Controller->ModelName, "DAC1164P");
1592 free_dma_loaf(Controller->PCIDevice, &local_dma);
1593 return DAC960_Failure(Controller, "MODEL VERIFICATION");
1595 strcpy(Controller->FullModelName, "Mylex ");
1596 strcat(Controller->FullModelName, Controller->ModelName);
1598 Initialize the Controller Firmware Version field and verify that it
1599 is a supported firmware version. The supported firmware versions are:
1601 DAC1164P 5.06 and above
1602 DAC960PTL/PRL/PJ/PG 4.06 and above
1603 DAC960PU/PD/PL 3.51 and above
1604 DAC960PU/PD/PL/P 2.73 and above
1606 #if defined(CONFIG_ALPHA)
1608 DEC Alpha machines were often equipped with DAC960 cards that were
1609 OEMed from Mylex, and had their own custom firmware. Version 2.70,
1610 the last custom FW revision to be released by DEC for these older
1611 controllers, appears to work quite well with this driver.
1613 Cards tested successfully were several versions each of the PD and
1614 PU, called by DEC the KZPSC and KZPAC, respectively, and having
1615 the Manufacturer Numbers (from Mylex), usually on a sticker on the
1616 back of the board, of:
1618 KZPSC: D040347 (1-channel) or D040348 (2-channel) or D040349 (3-channel)
1619 KZPAC: D040395 (1-channel) or D040396 (2-channel) or D040397 (3-channel)
1621 # define FIRMWARE_27X "2.70"
1623 # define FIRMWARE_27X "2.73"
1626 if (Enquiry2->FirmwareID.MajorVersion == 0)
1628 Enquiry2->FirmwareID.MajorVersion =
1629 Controller->V1.Enquiry.MajorFirmwareVersion;
1630 Enquiry2->FirmwareID.MinorVersion =
1631 Controller->V1.Enquiry.MinorFirmwareVersion;
1632 Enquiry2->FirmwareID.FirmwareType = '0';
1633 Enquiry2->FirmwareID.TurnID = 0;
1635 sprintf(Controller->FirmwareVersion, "%d.%02d-%c-%02d",
1636 Enquiry2->FirmwareID.MajorVersion, Enquiry2->FirmwareID.MinorVersion,
1637 Enquiry2->FirmwareID.FirmwareType, Enquiry2->FirmwareID.TurnID);
1638 if (!((Controller->FirmwareVersion[0] == '5' &&
1639 strcmp(Controller->FirmwareVersion, "5.06") >= 0) ||
1640 (Controller->FirmwareVersion[0] == '4' &&
1641 strcmp(Controller->FirmwareVersion, "4.06") >= 0) ||
1642 (Controller->FirmwareVersion[0] == '3' &&
1643 strcmp(Controller->FirmwareVersion, "3.51") >= 0) ||
1644 (Controller->FirmwareVersion[0] == '2' &&
1645 strcmp(Controller->FirmwareVersion, FIRMWARE_27X) >= 0)))
1647 DAC960_Failure(Controller, "FIRMWARE VERSION VERIFICATION");
1648 DAC960_Error("Firmware Version = '%s'\n", Controller,
1649 Controller->FirmwareVersion);
1650 free_dma_loaf(Controller->PCIDevice, &local_dma);
1654 Initialize the Controller Channels, Targets, Memory Size, and SAF-TE
1655 Enclosure Management Enabled fields.
1657 Controller->Channels = Enquiry2->ActualChannels;
1658 Controller->Targets = Enquiry2->MaxTargets;
1659 Controller->MemorySize = Enquiry2->MemorySize >> 20;
1660 Controller->V1.SAFTE_EnclosureManagementEnabled =
1661 (Enquiry2->FaultManagementType == DAC960_V1_SAFTE);
1663 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1664 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1665 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1666 less than the Controller Queue Depth to allow for an automatic drive
1669 Controller->ControllerQueueDepth = Controller->V1.Enquiry.MaxCommands;
1670 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1671 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1672 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1673 Controller->LogicalDriveCount =
1674 Controller->V1.Enquiry.NumberOfLogicalDrives;
1675 Controller->MaxBlocksPerCommand = Enquiry2->MaxBlocksPerCommand;
1676 Controller->ControllerScatterGatherLimit = Enquiry2->MaxScatterGatherEntries;
1677 Controller->DriverScatterGatherLimit =
1678 Controller->ControllerScatterGatherLimit;
1679 if (Controller->DriverScatterGatherLimit > DAC960_V1_ScatterGatherLimit)
1680 Controller->DriverScatterGatherLimit = DAC960_V1_ScatterGatherLimit;
1682 Initialize the Stripe Size, Segment Size, and Geometry Translation.
1684 Controller->V1.StripeSize = Config2->BlocksPerStripe * Config2->BlockFactor
1685 >> (10 - DAC960_BlockSizeBits);
1686 Controller->V1.SegmentSize = Config2->BlocksPerCacheLine * Config2->BlockFactor
1687 >> (10 - DAC960_BlockSizeBits);
1688 switch (Config2->DriveGeometry)
1690 case DAC960_V1_Geometry_128_32:
1691 Controller->V1.GeometryTranslationHeads = 128;
1692 Controller->V1.GeometryTranslationSectors = 32;
1694 case DAC960_V1_Geometry_255_63:
1695 Controller->V1.GeometryTranslationHeads = 255;
1696 Controller->V1.GeometryTranslationSectors = 63;
1699 free_dma_loaf(Controller->PCIDevice, &local_dma);
1700 return DAC960_Failure(Controller, "CONFIG2 DRIVE GEOMETRY");
1703 Initialize the Background Initialization Status.
1705 if ((Controller->FirmwareVersion[0] == '4' &&
1706 strcmp(Controller->FirmwareVersion, "4.08") >= 0) ||
1707 (Controller->FirmwareVersion[0] == '5' &&
1708 strcmp(Controller->FirmwareVersion, "5.08") >= 0))
1710 Controller->V1.BackgroundInitializationStatusSupported = true;
1711 DAC960_V1_ExecuteType3B(Controller,
1712 DAC960_V1_BackgroundInitializationControl, 0x20,
1714 V1.BackgroundInitializationStatusDMA);
1715 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
1716 Controller->V1.BackgroundInitializationStatus,
1717 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
1720 Initialize the Logical Drive Initially Accessible flag.
1722 for (LogicalDriveNumber = 0;
1723 LogicalDriveNumber < Controller->LogicalDriveCount;
1724 LogicalDriveNumber++)
1725 if (Controller->V1.LogicalDriveInformation
1726 [LogicalDriveNumber].LogicalDriveState !=
1727 DAC960_V1_LogicalDrive_Offline)
1728 Controller->LogicalDriveInitiallyAccessible[LogicalDriveNumber] = true;
1729 Controller->V1.LastRebuildStatus = DAC960_V1_NoRebuildOrCheckInProgress;
1730 free_dma_loaf(Controller->PCIDevice, &local_dma);
1736 DAC960_V2_ReadControllerConfiguration reads the Configuration Information
1737 from DAC960 V2 Firmware Controllers and initializes the Controller structure.
1740 static boolean DAC960_V2_ReadControllerConfiguration(DAC960_Controller_T
1743 DAC960_V2_ControllerInfo_T *ControllerInfo =
1744 &Controller->V2.ControllerInformation;
1745 unsigned short LogicalDeviceNumber = 0;
1746 int ModelNameLength;
1748 /* Get data into dma-able area, then copy into permanant location */
1749 if (!DAC960_V2_NewControllerInfo(Controller))
1750 return DAC960_Failure(Controller, "GET CONTROLLER INFO");
1751 memcpy(ControllerInfo, Controller->V2.NewControllerInformation,
1752 sizeof(DAC960_V2_ControllerInfo_T));
1755 if (!DAC960_V2_GeneralInfo(Controller))
1756 return DAC960_Failure(Controller, "GET HEALTH STATUS");
1759 Initialize the Controller Model Name and Full Model Name fields.
1761 ModelNameLength = sizeof(ControllerInfo->ControllerName);
1762 if (ModelNameLength > sizeof(Controller->ModelName)-1)
1763 ModelNameLength = sizeof(Controller->ModelName)-1;
1764 memcpy(Controller->ModelName, ControllerInfo->ControllerName,
1767 while (Controller->ModelName[ModelNameLength] == ' ' ||
1768 Controller->ModelName[ModelNameLength] == '\0')
1770 Controller->ModelName[++ModelNameLength] = '\0';
1771 strcpy(Controller->FullModelName, "Mylex ");
1772 strcat(Controller->FullModelName, Controller->ModelName);
1774 Initialize the Controller Firmware Version field.
1776 sprintf(Controller->FirmwareVersion, "%d.%02d-%02d",
1777 ControllerInfo->FirmwareMajorVersion,
1778 ControllerInfo->FirmwareMinorVersion,
1779 ControllerInfo->FirmwareTurnNumber);
1780 if (ControllerInfo->FirmwareMajorVersion == 6 &&
1781 ControllerInfo->FirmwareMinorVersion == 0 &&
1782 ControllerInfo->FirmwareTurnNumber < 1)
1784 DAC960_Info("FIRMWARE VERSION %s DOES NOT PROVIDE THE CONTROLLER\n",
1785 Controller, Controller->FirmwareVersion);
1786 DAC960_Info("STATUS MONITORING FUNCTIONALITY NEEDED BY THIS DRIVER.\n",
1788 DAC960_Info("PLEASE UPGRADE TO VERSION 6.00-01 OR ABOVE.\n",
1792 Initialize the Controller Channels, Targets, and Memory Size.
1794 Controller->Channels = ControllerInfo->NumberOfPhysicalChannelsPresent;
1795 Controller->Targets =
1796 ControllerInfo->MaximumTargetsPerChannel
1797 [ControllerInfo->NumberOfPhysicalChannelsPresent-1];
1798 Controller->MemorySize = ControllerInfo->MemorySizeMB;
1800 Initialize the Controller Queue Depth, Driver Queue Depth, Logical Drive
1801 Count, Maximum Blocks per Command, Controller Scatter/Gather Limit, and
1802 Driver Scatter/Gather Limit. The Driver Queue Depth must be at most one
1803 less than the Controller Queue Depth to allow for an automatic drive
1806 Controller->ControllerQueueDepth = ControllerInfo->MaximumParallelCommands;
1807 Controller->DriverQueueDepth = Controller->ControllerQueueDepth - 1;
1808 if (Controller->DriverQueueDepth > DAC960_MaxDriverQueueDepth)
1809 Controller->DriverQueueDepth = DAC960_MaxDriverQueueDepth;
1810 Controller->LogicalDriveCount = ControllerInfo->LogicalDevicesPresent;
1811 Controller->MaxBlocksPerCommand =
1812 ControllerInfo->MaximumDataTransferSizeInBlocks;
1813 Controller->ControllerScatterGatherLimit =
1814 ControllerInfo->MaximumScatterGatherEntries;
1815 Controller->DriverScatterGatherLimit =
1816 Controller->ControllerScatterGatherLimit;
1817 if (Controller->DriverScatterGatherLimit > DAC960_V2_ScatterGatherLimit)
1818 Controller->DriverScatterGatherLimit = DAC960_V2_ScatterGatherLimit;
1820 Initialize the Logical Device Information.
1824 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
1825 Controller->V2.NewLogicalDeviceInformation;
1826 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo;
1827 DAC960_V2_PhysicalDevice_T PhysicalDevice;
1829 if (!DAC960_V2_NewLogicalDeviceInfo(Controller, LogicalDeviceNumber))
1831 LogicalDeviceNumber = NewLogicalDeviceInfo->LogicalDeviceNumber;
1832 if (LogicalDeviceNumber >= DAC960_MaxLogicalDrives) {
1833 DAC960_Error("DAC960: Logical Drive Number %d not supported\n",
1834 Controller, LogicalDeviceNumber);
1837 if (NewLogicalDeviceInfo->DeviceBlockSizeInBytes != DAC960_BlockSize) {
1838 DAC960_Error("DAC960: Logical Drive Block Size %d not supported\n",
1839 Controller, NewLogicalDeviceInfo->DeviceBlockSizeInBytes);
1840 LogicalDeviceNumber++;
1843 PhysicalDevice.Controller = 0;
1844 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
1845 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
1846 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
1847 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
1849 if (NewLogicalDeviceInfo->LogicalDeviceState !=
1850 DAC960_V2_LogicalDevice_Offline)
1851 Controller->LogicalDriveInitiallyAccessible[LogicalDeviceNumber] = true;
1852 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
1853 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
1854 if (LogicalDeviceInfo == NULL)
1855 return DAC960_Failure(Controller, "LOGICAL DEVICE ALLOCATION");
1856 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
1858 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
1859 sizeof(DAC960_V2_LogicalDeviceInfo_T));
1860 LogicalDeviceNumber++;
1867 DAC960_ReportControllerConfiguration reports the Configuration Information
1871 static boolean DAC960_ReportControllerConfiguration(DAC960_Controller_T
1874 DAC960_Info("Configuring Mylex %s PCI RAID Controller\n",
1875 Controller, Controller->ModelName);
1876 DAC960_Info(" Firmware Version: %s, Channels: %d, Memory Size: %dMB\n",
1877 Controller, Controller->FirmwareVersion,
1878 Controller->Channels, Controller->MemorySize);
1879 DAC960_Info(" PCI Bus: %d, Device: %d, Function: %d, I/O Address: ",
1880 Controller, Controller->Bus,
1881 Controller->Device, Controller->Function);
1882 if (Controller->IO_Address == 0)
1883 DAC960_Info("Unassigned\n", Controller);
1884 else DAC960_Info("0x%X\n", Controller, Controller->IO_Address);
1885 DAC960_Info(" PCI Address: 0x%X mapped at 0x%lX, IRQ Channel: %d\n",
1886 Controller, Controller->PCI_Address,
1887 (unsigned long) Controller->BaseAddress,
1888 Controller->IRQ_Channel);
1889 DAC960_Info(" Controller Queue Depth: %d, "
1890 "Maximum Blocks per Command: %d\n",
1891 Controller, Controller->ControllerQueueDepth,
1892 Controller->MaxBlocksPerCommand);
1893 DAC960_Info(" Driver Queue Depth: %d, "
1894 "Scatter/Gather Limit: %d of %d Segments\n",
1895 Controller, Controller->DriverQueueDepth,
1896 Controller->DriverScatterGatherLimit,
1897 Controller->ControllerScatterGatherLimit);
1898 if (Controller->FirmwareType == DAC960_V1_Controller)
1900 DAC960_Info(" Stripe Size: %dKB, Segment Size: %dKB, "
1901 "BIOS Geometry: %d/%d\n", Controller,
1902 Controller->V1.StripeSize,
1903 Controller->V1.SegmentSize,
1904 Controller->V1.GeometryTranslationHeads,
1905 Controller->V1.GeometryTranslationSectors);
1906 if (Controller->V1.SAFTE_EnclosureManagementEnabled)
1907 DAC960_Info(" SAF-TE Enclosure Management Enabled\n", Controller);
1914 DAC960_V1_ReadDeviceConfiguration reads the Device Configuration Information
1915 for DAC960 V1 Firmware Controllers by requesting the SCSI Inquiry and SCSI
1916 Inquiry Unit Serial Number information for each device connected to
1920 static boolean DAC960_V1_ReadDeviceConfiguration(DAC960_Controller_T
1923 struct dma_loaf local_dma;
1925 dma_addr_t DCDBs_dma[DAC960_V1_MaxChannels];
1926 DAC960_V1_DCDB_T *DCDBs_cpu[DAC960_V1_MaxChannels];
1928 dma_addr_t SCSI_Inquiry_dma[DAC960_V1_MaxChannels];
1929 DAC960_SCSI_Inquiry_T *SCSI_Inquiry_cpu[DAC960_V1_MaxChannels];
1931 dma_addr_t SCSI_NewInquiryUnitSerialNumberDMA[DAC960_V1_MaxChannels];
1932 DAC960_SCSI_Inquiry_UnitSerialNumber_T *SCSI_NewInquiryUnitSerialNumberCPU[DAC960_V1_MaxChannels];
1934 struct completion Completions[DAC960_V1_MaxChannels];
1935 unsigned long flags;
1936 int Channel, TargetID;
1938 if (!init_dma_loaf(Controller->PCIDevice, &local_dma,
1939 DAC960_V1_MaxChannels*(sizeof(DAC960_V1_DCDB_T) +
1940 sizeof(DAC960_SCSI_Inquiry_T) +
1941 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T))))
1942 return DAC960_Failure(Controller,
1943 "DMA ALLOCATION FAILED IN ReadDeviceConfiguration");
1945 for (Channel = 0; Channel < Controller->Channels; Channel++) {
1946 DCDBs_cpu[Channel] = slice_dma_loaf(&local_dma,
1947 sizeof(DAC960_V1_DCDB_T), DCDBs_dma + Channel);
1948 SCSI_Inquiry_cpu[Channel] = slice_dma_loaf(&local_dma,
1949 sizeof(DAC960_SCSI_Inquiry_T),
1950 SCSI_Inquiry_dma + Channel);
1951 SCSI_NewInquiryUnitSerialNumberCPU[Channel] = slice_dma_loaf(&local_dma,
1952 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
1953 SCSI_NewInquiryUnitSerialNumberDMA + Channel);
1956 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
1959 * For each channel, submit a probe for a device on that channel.
1960 * The timeout interval for a device that is present is 10 seconds.
1961 * With this approach, the timeout periods can elapse in parallel
1964 for (Channel = 0; Channel < Controller->Channels; Channel++)
1966 dma_addr_t NewInquiryStandardDataDMA = SCSI_Inquiry_dma[Channel];
1967 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
1968 dma_addr_t DCDB_dma = DCDBs_dma[Channel];
1969 DAC960_Command_T *Command = Controller->Commands[Channel];
1970 struct completion *Completion = &Completions[Channel];
1972 init_completion(Completion);
1973 DAC960_V1_ClearCommand(Command);
1974 Command->CommandType = DAC960_ImmediateCommand;
1975 Command->Completion = Completion;
1976 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
1977 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_dma;
1978 DCDB->Channel = Channel;
1979 DCDB->TargetID = TargetID;
1980 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
1981 DCDB->EarlyStatus = false;
1982 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
1983 DCDB->NoAutomaticRequestSense = false;
1984 DCDB->DisconnectPermitted = true;
1985 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
1986 DCDB->BusAddress = NewInquiryStandardDataDMA;
1987 DCDB->CDBLength = 6;
1988 DCDB->TransferLengthHigh4 = 0;
1989 DCDB->SenseLength = sizeof(DCDB->SenseData);
1990 DCDB->CDB[0] = 0x12; /* INQUIRY */
1991 DCDB->CDB[1] = 0; /* EVPD = 0 */
1992 DCDB->CDB[2] = 0; /* Page Code */
1993 DCDB->CDB[3] = 0; /* Reserved */
1994 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
1995 DCDB->CDB[5] = 0; /* Control */
1997 spin_lock_irqsave(&Controller->queue_lock, flags);
1998 DAC960_QueueCommand(Command);
1999 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2002 * Wait for the problems submitted in the previous loop
2003 * to complete. On the probes that are successful,
2004 * get the serial number of the device that was found.
2006 for (Channel = 0; Channel < Controller->Channels; Channel++)
2008 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2009 &Controller->V1.InquiryStandardData[Channel][TargetID];
2010 DAC960_SCSI_Inquiry_T *NewInquiryStandardData = SCSI_Inquiry_cpu[Channel];
2011 dma_addr_t NewInquiryUnitSerialNumberDMA =
2012 SCSI_NewInquiryUnitSerialNumberDMA[Channel];
2013 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
2014 SCSI_NewInquiryUnitSerialNumberCPU[Channel];
2015 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2016 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2017 DAC960_Command_T *Command = Controller->Commands[Channel];
2018 DAC960_V1_DCDB_T *DCDB = DCDBs_cpu[Channel];
2019 struct completion *Completion = &Completions[Channel];
2021 wait_for_completion(Completion);
2023 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2024 memset(InquiryStandardData, 0, sizeof(DAC960_SCSI_Inquiry_T));
2025 InquiryStandardData->PeripheralDeviceType = 0x1F;
2028 memcpy(InquiryStandardData, NewInquiryStandardData, sizeof(DAC960_SCSI_Inquiry_T));
2030 /* Preserve Channel and TargetID values from the previous loop */
2031 Command->Completion = Completion;
2032 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2033 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
2034 DCDB->SenseLength = sizeof(DCDB->SenseData);
2035 DCDB->CDB[0] = 0x12; /* INQUIRY */
2036 DCDB->CDB[1] = 1; /* EVPD = 1 */
2037 DCDB->CDB[2] = 0x80; /* Page Code */
2038 DCDB->CDB[3] = 0; /* Reserved */
2039 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
2040 DCDB->CDB[5] = 0; /* Control */
2042 spin_lock_irqsave(&Controller->queue_lock, flags);
2043 DAC960_QueueCommand(Command);
2044 spin_unlock_irqrestore(&Controller->queue_lock, flags);
2045 wait_for_completion(Completion);
2047 if (Command->V1.CommandStatus != DAC960_V1_NormalCompletion) {
2048 memset(InquiryUnitSerialNumber, 0,
2049 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2050 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2052 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2053 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2056 free_dma_loaf(Controller->PCIDevice, &local_dma);
2062 DAC960_V2_ReadDeviceConfiguration reads the Device Configuration Information
2063 for DAC960 V2 Firmware Controllers by requesting the Physical Device
2064 Information and SCSI Inquiry Unit Serial Number information for each
2065 device connected to Controller.
2068 static boolean DAC960_V2_ReadDeviceConfiguration(DAC960_Controller_T
2071 unsigned char Channel = 0, TargetID = 0, LogicalUnit = 0;
2072 unsigned short PhysicalDeviceIndex = 0;
2076 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
2077 Controller->V2.NewPhysicalDeviceInformation;
2078 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo;
2079 DAC960_SCSI_Inquiry_UnitSerialNumber_T *NewInquiryUnitSerialNumber =
2080 Controller->V2.NewInquiryUnitSerialNumber;
2081 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber;
2083 if (!DAC960_V2_NewPhysicalDeviceInfo(Controller, Channel, TargetID, LogicalUnit))
2086 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
2087 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
2088 if (PhysicalDeviceInfo == NULL)
2089 return DAC960_Failure(Controller, "PHYSICAL DEVICE ALLOCATION");
2090 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex] =
2092 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
2093 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
2095 InquiryUnitSerialNumber = (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
2096 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T), GFP_ATOMIC);
2097 if (InquiryUnitSerialNumber == NULL) {
2098 kfree(PhysicalDeviceInfo);
2099 return DAC960_Failure(Controller, "SERIAL NUMBER ALLOCATION");
2101 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex] =
2102 InquiryUnitSerialNumber;
2104 Channel = NewPhysicalDeviceInfo->Channel;
2105 TargetID = NewPhysicalDeviceInfo->TargetID;
2106 LogicalUnit = NewPhysicalDeviceInfo->LogicalUnit;
2109 Some devices do NOT have Unit Serial Numbers.
2110 This command fails for them. But, we still want to
2111 remember those devices are there. Construct a
2112 UnitSerialNumber structure for the failure case.
2114 if (!DAC960_V2_NewInquiryUnitSerialNumber(Controller, Channel, TargetID, LogicalUnit)) {
2115 memset(InquiryUnitSerialNumber, 0,
2116 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2117 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
2119 memcpy(InquiryUnitSerialNumber, NewInquiryUnitSerialNumber,
2120 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
2122 PhysicalDeviceIndex++;
2130 DAC960_SanitizeInquiryData sanitizes the Vendor, Model, Revision, and
2131 Product Serial Number fields of the Inquiry Standard Data and Inquiry
2132 Unit Serial Number structures.
2135 static void DAC960_SanitizeInquiryData(DAC960_SCSI_Inquiry_T
2136 *InquiryStandardData,
2137 DAC960_SCSI_Inquiry_UnitSerialNumber_T
2138 *InquiryUnitSerialNumber,
2139 unsigned char *Vendor,
2140 unsigned char *Model,
2141 unsigned char *Revision,
2142 unsigned char *SerialNumber)
2144 int SerialNumberLength, i;
2145 if (InquiryStandardData->PeripheralDeviceType == 0x1F) return;
2146 for (i = 0; i < sizeof(InquiryStandardData->VendorIdentification); i++)
2148 unsigned char VendorCharacter =
2149 InquiryStandardData->VendorIdentification[i];
2150 Vendor[i] = (VendorCharacter >= ' ' && VendorCharacter <= '~'
2151 ? VendorCharacter : ' ');
2153 Vendor[sizeof(InquiryStandardData->VendorIdentification)] = '\0';
2154 for (i = 0; i < sizeof(InquiryStandardData->ProductIdentification); i++)
2156 unsigned char ModelCharacter =
2157 InquiryStandardData->ProductIdentification[i];
2158 Model[i] = (ModelCharacter >= ' ' && ModelCharacter <= '~'
2159 ? ModelCharacter : ' ');
2161 Model[sizeof(InquiryStandardData->ProductIdentification)] = '\0';
2162 for (i = 0; i < sizeof(InquiryStandardData->ProductRevisionLevel); i++)
2164 unsigned char RevisionCharacter =
2165 InquiryStandardData->ProductRevisionLevel[i];
2166 Revision[i] = (RevisionCharacter >= ' ' && RevisionCharacter <= '~'
2167 ? RevisionCharacter : ' ');
2169 Revision[sizeof(InquiryStandardData->ProductRevisionLevel)] = '\0';
2170 if (InquiryUnitSerialNumber->PeripheralDeviceType == 0x1F) return;
2171 SerialNumberLength = InquiryUnitSerialNumber->PageLength;
2172 if (SerialNumberLength >
2173 sizeof(InquiryUnitSerialNumber->ProductSerialNumber))
2174 SerialNumberLength = sizeof(InquiryUnitSerialNumber->ProductSerialNumber);
2175 for (i = 0; i < SerialNumberLength; i++)
2177 unsigned char SerialNumberCharacter =
2178 InquiryUnitSerialNumber->ProductSerialNumber[i];
2180 (SerialNumberCharacter >= ' ' && SerialNumberCharacter <= '~'
2181 ? SerialNumberCharacter : ' ');
2183 SerialNumber[SerialNumberLength] = '\0';
2188 DAC960_V1_ReportDeviceConfiguration reports the Device Configuration
2189 Information for DAC960 V1 Firmware Controllers.
2192 static boolean DAC960_V1_ReportDeviceConfiguration(DAC960_Controller_T
2195 int LogicalDriveNumber, Channel, TargetID;
2196 DAC960_Info(" Physical Devices:\n", Controller);
2197 for (Channel = 0; Channel < Controller->Channels; Channel++)
2198 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
2200 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2201 &Controller->V1.InquiryStandardData[Channel][TargetID];
2202 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2203 &Controller->V1.InquiryUnitSerialNumber[Channel][TargetID];
2204 DAC960_V1_DeviceState_T *DeviceState =
2205 &Controller->V1.DeviceState[Channel][TargetID];
2206 DAC960_V1_ErrorTableEntry_T *ErrorEntry =
2207 &Controller->V1.ErrorTable.ErrorTableEntries[Channel][TargetID];
2208 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2209 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2210 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2211 char SerialNumber[1+sizeof(InquiryUnitSerialNumber
2212 ->ProductSerialNumber)];
2213 if (InquiryStandardData->PeripheralDeviceType == 0x1F) continue;
2214 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2215 Vendor, Model, Revision, SerialNumber);
2216 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2217 Controller, Channel, TargetID, (TargetID < 10 ? " " : ""),
2218 Vendor, Model, Revision);
2219 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2220 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2221 if (DeviceState->Present &&
2222 DeviceState->DeviceType == DAC960_V1_DiskType)
2224 if (Controller->V1.DeviceResetCount[Channel][TargetID] > 0)
2225 DAC960_Info(" Disk Status: %s, %u blocks, %d resets\n",
2227 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2229 : DeviceState->DeviceState
2230 == DAC960_V1_Device_WriteOnly
2232 : DeviceState->DeviceState
2233 == DAC960_V1_Device_Online
2234 ? "Online" : "Standby"),
2235 DeviceState->DiskSize,
2236 Controller->V1.DeviceResetCount[Channel][TargetID]);
2238 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2239 (DeviceState->DeviceState == DAC960_V1_Device_Dead
2241 : DeviceState->DeviceState
2242 == DAC960_V1_Device_WriteOnly
2244 : DeviceState->DeviceState
2245 == DAC960_V1_Device_Online
2246 ? "Online" : "Standby"),
2247 DeviceState->DiskSize);
2249 if (ErrorEntry->ParityErrorCount > 0 ||
2250 ErrorEntry->SoftErrorCount > 0 ||
2251 ErrorEntry->HardErrorCount > 0 ||
2252 ErrorEntry->MiscErrorCount > 0)
2253 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2254 "Hard: %d, Misc: %d\n", Controller,
2255 ErrorEntry->ParityErrorCount,
2256 ErrorEntry->SoftErrorCount,
2257 ErrorEntry->HardErrorCount,
2258 ErrorEntry->MiscErrorCount);
2260 DAC960_Info(" Logical Drives:\n", Controller);
2261 for (LogicalDriveNumber = 0;
2262 LogicalDriveNumber < Controller->LogicalDriveCount;
2263 LogicalDriveNumber++)
2265 DAC960_V1_LogicalDriveInformation_T *LogicalDriveInformation =
2266 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
2267 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks, %s\n",
2268 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2269 LogicalDriveInformation->RAIDLevel,
2270 (LogicalDriveInformation->LogicalDriveState
2271 == DAC960_V1_LogicalDrive_Online
2273 : LogicalDriveInformation->LogicalDriveState
2274 == DAC960_V1_LogicalDrive_Critical
2275 ? "Critical" : "Offline"),
2276 LogicalDriveInformation->LogicalDriveSize,
2277 (LogicalDriveInformation->WriteBack
2278 ? "Write Back" : "Write Thru"));
2285 DAC960_V2_ReportDeviceConfiguration reports the Device Configuration
2286 Information for DAC960 V2 Firmware Controllers.
2289 static boolean DAC960_V2_ReportDeviceConfiguration(DAC960_Controller_T
2292 int PhysicalDeviceIndex, LogicalDriveNumber;
2293 DAC960_Info(" Physical Devices:\n", Controller);
2294 for (PhysicalDeviceIndex = 0;
2295 PhysicalDeviceIndex < DAC960_V2_MaxPhysicalDevices;
2296 PhysicalDeviceIndex++)
2298 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
2299 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
2300 DAC960_SCSI_Inquiry_T *InquiryStandardData =
2301 (DAC960_SCSI_Inquiry_T *) &PhysicalDeviceInfo->SCSI_InquiryData;
2302 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
2303 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
2304 char Vendor[1+sizeof(InquiryStandardData->VendorIdentification)];
2305 char Model[1+sizeof(InquiryStandardData->ProductIdentification)];
2306 char Revision[1+sizeof(InquiryStandardData->ProductRevisionLevel)];
2307 char SerialNumber[1+sizeof(InquiryUnitSerialNumber->ProductSerialNumber)];
2308 if (PhysicalDeviceInfo == NULL) break;
2309 DAC960_SanitizeInquiryData(InquiryStandardData, InquiryUnitSerialNumber,
2310 Vendor, Model, Revision, SerialNumber);
2311 DAC960_Info(" %d:%d%s Vendor: %s Model: %s Revision: %s\n",
2313 PhysicalDeviceInfo->Channel,
2314 PhysicalDeviceInfo->TargetID,
2315 (PhysicalDeviceInfo->TargetID < 10 ? " " : ""),
2316 Vendor, Model, Revision);
2317 if (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers == 0)
2318 DAC960_Info(" %sAsynchronous\n", Controller,
2319 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2322 DAC960_Info(" %sSynchronous at %d MB/sec\n", Controller,
2323 (PhysicalDeviceInfo->NegotiatedDataWidthBits == 16
2325 (PhysicalDeviceInfo->NegotiatedSynchronousMegaTransfers
2326 * PhysicalDeviceInfo->NegotiatedDataWidthBits/8));
2327 if (InquiryUnitSerialNumber->PeripheralDeviceType != 0x1F)
2328 DAC960_Info(" Serial Number: %s\n", Controller, SerialNumber);
2329 if (PhysicalDeviceInfo->PhysicalDeviceState ==
2330 DAC960_V2_Device_Unconfigured)
2332 DAC960_Info(" Disk Status: %s, %u blocks\n", Controller,
2333 (PhysicalDeviceInfo->PhysicalDeviceState
2334 == DAC960_V2_Device_Online
2336 : PhysicalDeviceInfo->PhysicalDeviceState
2337 == DAC960_V2_Device_Rebuild
2339 : PhysicalDeviceInfo->PhysicalDeviceState
2340 == DAC960_V2_Device_Missing
2342 : PhysicalDeviceInfo->PhysicalDeviceState
2343 == DAC960_V2_Device_Critical
2345 : PhysicalDeviceInfo->PhysicalDeviceState
2346 == DAC960_V2_Device_Dead
2348 : PhysicalDeviceInfo->PhysicalDeviceState
2349 == DAC960_V2_Device_SuspectedDead
2351 : PhysicalDeviceInfo->PhysicalDeviceState
2352 == DAC960_V2_Device_CommandedOffline
2353 ? "Commanded-Offline"
2354 : PhysicalDeviceInfo->PhysicalDeviceState
2355 == DAC960_V2_Device_Standby
2356 ? "Standby" : "Unknown"),
2357 PhysicalDeviceInfo->ConfigurableDeviceSize);
2358 if (PhysicalDeviceInfo->ParityErrors == 0 &&
2359 PhysicalDeviceInfo->SoftErrors == 0 &&
2360 PhysicalDeviceInfo->HardErrors == 0 &&
2361 PhysicalDeviceInfo->MiscellaneousErrors == 0 &&
2362 PhysicalDeviceInfo->CommandTimeouts == 0 &&
2363 PhysicalDeviceInfo->Retries == 0 &&
2364 PhysicalDeviceInfo->Aborts == 0 &&
2365 PhysicalDeviceInfo->PredictedFailuresDetected == 0)
2367 DAC960_Info(" Errors - Parity: %d, Soft: %d, "
2368 "Hard: %d, Misc: %d\n", Controller,
2369 PhysicalDeviceInfo->ParityErrors,
2370 PhysicalDeviceInfo->SoftErrors,
2371 PhysicalDeviceInfo->HardErrors,
2372 PhysicalDeviceInfo->MiscellaneousErrors);
2373 DAC960_Info(" Timeouts: %d, Retries: %d, "
2374 "Aborts: %d, Predicted: %d\n", Controller,
2375 PhysicalDeviceInfo->CommandTimeouts,
2376 PhysicalDeviceInfo->Retries,
2377 PhysicalDeviceInfo->Aborts,
2378 PhysicalDeviceInfo->PredictedFailuresDetected);
2380 DAC960_Info(" Logical Drives:\n", Controller);
2381 for (LogicalDriveNumber = 0;
2382 LogicalDriveNumber < DAC960_MaxLogicalDrives;
2383 LogicalDriveNumber++)
2385 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
2386 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
2387 unsigned char *ReadCacheStatus[] = { "Read Cache Disabled",
2388 "Read Cache Enabled",
2389 "Read Ahead Enabled",
2390 "Intelligent Read Ahead Enabled",
2391 "-", "-", "-", "-" };
2392 unsigned char *WriteCacheStatus[] = { "Write Cache Disabled",
2393 "Logical Device Read Only",
2394 "Write Cache Enabled",
2395 "Intelligent Write Cache Enabled",
2396 "-", "-", "-", "-" };
2397 unsigned char *GeometryTranslation;
2398 if (LogicalDeviceInfo == NULL) continue;
2399 switch (LogicalDeviceInfo->DriveGeometry)
2401 case DAC960_V2_Geometry_128_32:
2402 GeometryTranslation = "128/32";
2404 case DAC960_V2_Geometry_255_63:
2405 GeometryTranslation = "255/63";
2408 GeometryTranslation = "Invalid";
2409 DAC960_Error("Illegal Logical Device Geometry %d\n",
2410 Controller, LogicalDeviceInfo->DriveGeometry);
2413 DAC960_Info(" /dev/rd/c%dd%d: RAID-%d, %s, %u blocks\n",
2414 Controller, Controller->ControllerNumber, LogicalDriveNumber,
2415 LogicalDeviceInfo->RAIDLevel,
2416 (LogicalDeviceInfo->LogicalDeviceState
2417 == DAC960_V2_LogicalDevice_Online
2419 : LogicalDeviceInfo->LogicalDeviceState
2420 == DAC960_V2_LogicalDevice_Critical
2421 ? "Critical" : "Offline"),
2422 LogicalDeviceInfo->ConfigurableDeviceSize);
2423 DAC960_Info(" Logical Device %s, BIOS Geometry: %s\n",
2425 (LogicalDeviceInfo->LogicalDeviceControl
2426 .LogicalDeviceInitialized
2427 ? "Initialized" : "Uninitialized"),
2428 GeometryTranslation);
2429 if (LogicalDeviceInfo->StripeSize == 0)
2431 if (LogicalDeviceInfo->CacheLineSize == 0)
2432 DAC960_Info(" Stripe Size: N/A, "
2433 "Segment Size: N/A\n", Controller);
2435 DAC960_Info(" Stripe Size: N/A, "
2436 "Segment Size: %dKB\n", Controller,
2437 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2441 if (LogicalDeviceInfo->CacheLineSize == 0)
2442 DAC960_Info(" Stripe Size: %dKB, "
2443 "Segment Size: N/A\n", Controller,
2444 1 << (LogicalDeviceInfo->StripeSize - 2));
2446 DAC960_Info(" Stripe Size: %dKB, "
2447 "Segment Size: %dKB\n", Controller,
2448 1 << (LogicalDeviceInfo->StripeSize - 2),
2449 1 << (LogicalDeviceInfo->CacheLineSize - 2));
2451 DAC960_Info(" %s, %s\n", Controller,
2453 LogicalDeviceInfo->LogicalDeviceControl.ReadCache],
2455 LogicalDeviceInfo->LogicalDeviceControl.WriteCache]);
2456 if (LogicalDeviceInfo->SoftErrors > 0 ||
2457 LogicalDeviceInfo->CommandsFailed > 0 ||
2458 LogicalDeviceInfo->DeferredWriteErrors)
2459 DAC960_Info(" Errors - Soft: %d, Failed: %d, "
2460 "Deferred Write: %d\n", Controller,
2461 LogicalDeviceInfo->SoftErrors,
2462 LogicalDeviceInfo->CommandsFailed,
2463 LogicalDeviceInfo->DeferredWriteErrors);
2470 DAC960_RegisterBlockDevice registers the Block Device structures
2471 associated with Controller.
2474 static boolean DAC960_RegisterBlockDevice(DAC960_Controller_T *Controller)
2476 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2480 Register the Block Device Major Number for this DAC960 Controller.
2482 if (register_blkdev(MajorNumber, "dac960") < 0)
2485 for (n = 0; n < DAC960_MaxLogicalDrives; n++) {
2486 struct gendisk *disk = Controller->disks[n];
2487 struct request_queue *RequestQueue;
2489 /* for now, let all request queues share controller's lock */
2490 RequestQueue = blk_init_queue(DAC960_RequestFunction,&Controller->queue_lock);
2491 if (!RequestQueue) {
2492 printk("DAC960: failure to allocate request queue\n");
2495 Controller->RequestQueue[n] = RequestQueue;
2496 blk_queue_bounce_limit(RequestQueue, Controller->BounceBufferLimit);
2497 RequestQueue->queuedata = Controller;
2498 blk_queue_max_hw_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2499 blk_queue_max_phys_segments(RequestQueue, Controller->DriverScatterGatherLimit);
2500 blk_queue_max_sectors(RequestQueue, Controller->MaxBlocksPerCommand);
2501 disk->queue = RequestQueue;
2502 sprintf(disk->disk_name, "rd/c%dd%d", Controller->ControllerNumber, n);
2503 sprintf(disk->devfs_name, "rd/host%d/target%d", Controller->ControllerNumber, n);
2504 disk->major = MajorNumber;
2505 disk->first_minor = n << DAC960_MaxPartitionsBits;
2506 disk->fops = &DAC960_BlockDeviceOperations;
2509 Indicate the Block Device Registration completed successfully,
2516 DAC960_UnregisterBlockDevice unregisters the Block Device structures
2517 associated with Controller.
2520 static void DAC960_UnregisterBlockDevice(DAC960_Controller_T *Controller)
2522 int MajorNumber = DAC960_MAJOR + Controller->ControllerNumber;
2525 /* does order matter when deleting gendisk and cleanup in request queue? */
2526 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
2527 del_gendisk(Controller->disks[disk]);
2528 blk_cleanup_queue(Controller->RequestQueue[disk]);
2529 Controller->RequestQueue[disk] = NULL;
2533 Unregister the Block Device Major Number for this DAC960 Controller.
2535 unregister_blkdev(MajorNumber, "dac960");
2539 DAC960_ComputeGenericDiskInfo computes the values for the Generic Disk
2540 Information Partition Sector Counts and Block Sizes.
2543 static void DAC960_ComputeGenericDiskInfo(DAC960_Controller_T *Controller)
2546 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++)
2547 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
2551 DAC960_ReportErrorStatus reports Controller BIOS Messages passed through
2552 the Error Status Register when the driver performs the BIOS handshaking.
2553 It returns true for fatal errors and false otherwise.
2556 static boolean DAC960_ReportErrorStatus(DAC960_Controller_T *Controller,
2557 unsigned char ErrorStatus,
2558 unsigned char Parameter0,
2559 unsigned char Parameter1)
2561 switch (ErrorStatus)
2564 DAC960_Notice("Physical Device %d:%d Not Responding\n",
2565 Controller, Parameter1, Parameter0);
2568 if (Controller->DriveSpinUpMessageDisplayed) break;
2569 DAC960_Notice("Spinning Up Drives\n", Controller);
2570 Controller->DriveSpinUpMessageDisplayed = true;
2573 DAC960_Notice("Configuration Checksum Error\n", Controller);
2576 DAC960_Notice("Mirror Race Recovery Failed\n", Controller);
2579 DAC960_Notice("Mirror Race Recovery In Progress\n", Controller);
2582 DAC960_Notice("Physical Device %d:%d COD Mismatch\n",
2583 Controller, Parameter1, Parameter0);
2586 DAC960_Notice("Logical Drive Installation Aborted\n", Controller);
2589 DAC960_Notice("Mirror Race On A Critical Logical Drive\n", Controller);
2592 DAC960_Notice("New Controller Configuration Found\n", Controller);
2595 DAC960_Error("Fatal Memory Parity Error for Controller at\n", Controller);
2598 DAC960_Error("Unknown Initialization Error %02X for Controller at\n",
2599 Controller, ErrorStatus);
2607 * DAC960_DetectCleanup releases the resources that were allocated
2608 * during DAC960_DetectController(). DAC960_DetectController can
2609 * has several internal failure points, so not ALL resources may
2610 * have been allocated. It's important to free only
2611 * resources that HAVE been allocated. The code below always
2612 * tests that the resource has been allocated before attempting to
2615 static void DAC960_DetectCleanup(DAC960_Controller_T *Controller)
2619 /* Free the memory mailbox, status, and related structures */
2620 free_dma_loaf(Controller->PCIDevice, &Controller->DmaPages);
2621 if (Controller->MemoryMappedAddress) {
2622 switch(Controller->HardwareType)
2624 case DAC960_BA_Controller:
2625 DAC960_BA_DisableInterrupts(Controller->BaseAddress);
2627 case DAC960_LP_Controller:
2628 DAC960_LP_DisableInterrupts(Controller->BaseAddress);
2630 case DAC960_LA_Controller:
2631 DAC960_LA_DisableInterrupts(Controller->BaseAddress);
2633 case DAC960_PG_Controller:
2634 DAC960_PG_DisableInterrupts(Controller->BaseAddress);
2636 case DAC960_PD_Controller:
2637 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2639 case DAC960_P_Controller:
2640 DAC960_PD_DisableInterrupts(Controller->BaseAddress);
2643 iounmap(Controller->MemoryMappedAddress);
2645 if (Controller->IRQ_Channel)
2646 free_irq(Controller->IRQ_Channel, Controller);
2647 if (Controller->IO_Address)
2648 release_region(Controller->IO_Address, 0x80);
2649 pci_disable_device(Controller->PCIDevice);
2650 for (i = 0; (i < DAC960_MaxLogicalDrives) && Controller->disks[i]; i++)
2651 put_disk(Controller->disks[i]);
2652 DAC960_Controllers[Controller->ControllerNumber] = NULL;
2658 DAC960_DetectController detects Mylex DAC960/AcceleRAID/eXtremeRAID
2659 PCI RAID Controllers by interrogating the PCI Configuration Space for
2663 static DAC960_Controller_T *
2664 DAC960_DetectController(struct pci_dev *PCI_Device,
2665 const struct pci_device_id *entry)
2667 struct DAC960_privdata *privdata =
2668 (struct DAC960_privdata *)entry->driver_data;
2669 irqreturn_t (*InterruptHandler)(int, void *, struct pt_regs *) =
2670 privdata->InterruptHandler;
2671 unsigned int MemoryWindowSize = privdata->MemoryWindowSize;
2672 DAC960_Controller_T *Controller = NULL;
2673 unsigned char DeviceFunction = PCI_Device->devfn;
2674 unsigned char ErrorStatus, Parameter0, Parameter1;
2675 unsigned int IRQ_Channel = PCI_Device->irq;
2679 Controller = (DAC960_Controller_T *)
2680 kmalloc(sizeof(DAC960_Controller_T), GFP_ATOMIC);
2681 if (Controller == NULL) {
2682 DAC960_Error("Unable to allocate Controller structure for "
2683 "Controller at\n", NULL);
2686 memset(Controller, 0, sizeof(DAC960_Controller_T));
2687 Controller->ControllerNumber = DAC960_ControllerCount;
2688 DAC960_Controllers[DAC960_ControllerCount++] = Controller;
2689 Controller->Bus = PCI_Device->bus->number;
2690 Controller->FirmwareType = privdata->FirmwareType;
2691 Controller->HardwareType = privdata->HardwareType;
2692 Controller->Device = DeviceFunction >> 3;
2693 Controller->Function = DeviceFunction & 0x7;
2694 Controller->PCIDevice = PCI_Device;
2695 strcpy(Controller->FullModelName, "DAC960");
2697 if (pci_enable_device(PCI_Device)) {
2702 switch (Controller->HardwareType)
2704 case DAC960_BA_Controller:
2705 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2707 case DAC960_LP_Controller:
2708 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2710 case DAC960_LA_Controller:
2711 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2713 case DAC960_PG_Controller:
2714 Controller->PCI_Address = pci_resource_start(PCI_Device, 0);
2716 case DAC960_PD_Controller:
2717 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2718 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2720 case DAC960_P_Controller:
2721 Controller->IO_Address = pci_resource_start(PCI_Device, 0);
2722 Controller->PCI_Address = pci_resource_start(PCI_Device, 1);
2726 pci_set_drvdata(PCI_Device, (void *)((long)Controller->ControllerNumber));
2727 for (i = 0; i < DAC960_MaxLogicalDrives; i++) {
2728 Controller->disks[i] = alloc_disk(1<<DAC960_MaxPartitionsBits);
2729 if (!Controller->disks[i])
2731 Controller->disks[i]->private_data = (void *)((long)i);
2733 init_waitqueue_head(&Controller->CommandWaitQueue);
2734 init_waitqueue_head(&Controller->HealthStatusWaitQueue);
2735 Controller->queue_lock = SPIN_LOCK_UNLOCKED;
2736 DAC960_AnnounceDriver(Controller);
2738 Map the Controller Register Window.
2740 if (MemoryWindowSize < PAGE_SIZE)
2741 MemoryWindowSize = PAGE_SIZE;
2742 Controller->MemoryMappedAddress =
2743 ioremap_nocache(Controller->PCI_Address & PAGE_MASK, MemoryWindowSize);
2744 Controller->BaseAddress =
2745 Controller->MemoryMappedAddress + (Controller->PCI_Address & ~PAGE_MASK);
2746 if (Controller->MemoryMappedAddress == NULL)
2748 DAC960_Error("Unable to map Controller Register Window for "
2749 "Controller at\n", Controller);
2752 BaseAddress = Controller->BaseAddress;
2753 switch (Controller->HardwareType)
2755 case DAC960_BA_Controller:
2756 DAC960_BA_DisableInterrupts(BaseAddress);
2757 DAC960_BA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2759 while (DAC960_BA_InitializationInProgressP(BaseAddress))
2761 if (DAC960_BA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2762 &Parameter0, &Parameter1) &&
2763 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2764 Parameter0, Parameter1))
2768 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2770 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2771 "for Controller at\n", Controller);
2774 DAC960_BA_EnableInterrupts(BaseAddress);
2775 Controller->QueueCommand = DAC960_BA_QueueCommand;
2776 Controller->ReadControllerConfiguration =
2777 DAC960_V2_ReadControllerConfiguration;
2778 Controller->ReadDeviceConfiguration =
2779 DAC960_V2_ReadDeviceConfiguration;
2780 Controller->ReportDeviceConfiguration =
2781 DAC960_V2_ReportDeviceConfiguration;
2782 Controller->QueueReadWriteCommand =
2783 DAC960_V2_QueueReadWriteCommand;
2785 case DAC960_LP_Controller:
2786 DAC960_LP_DisableInterrupts(BaseAddress);
2787 DAC960_LP_AcknowledgeHardwareMailboxStatus(BaseAddress);
2789 while (DAC960_LP_InitializationInProgressP(BaseAddress))
2791 if (DAC960_LP_ReadErrorStatus(BaseAddress, &ErrorStatus,
2792 &Parameter0, &Parameter1) &&
2793 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2794 Parameter0, Parameter1))
2798 if (!DAC960_V2_EnableMemoryMailboxInterface(Controller))
2800 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2801 "for Controller at\n", Controller);
2804 DAC960_LP_EnableInterrupts(BaseAddress);
2805 Controller->QueueCommand = DAC960_LP_QueueCommand;
2806 Controller->ReadControllerConfiguration =
2807 DAC960_V2_ReadControllerConfiguration;
2808 Controller->ReadDeviceConfiguration =
2809 DAC960_V2_ReadDeviceConfiguration;
2810 Controller->ReportDeviceConfiguration =
2811 DAC960_V2_ReportDeviceConfiguration;
2812 Controller->QueueReadWriteCommand =
2813 DAC960_V2_QueueReadWriteCommand;
2815 case DAC960_LA_Controller:
2816 DAC960_LA_DisableInterrupts(BaseAddress);
2817 DAC960_LA_AcknowledgeHardwareMailboxStatus(BaseAddress);
2819 while (DAC960_LA_InitializationInProgressP(BaseAddress))
2821 if (DAC960_LA_ReadErrorStatus(BaseAddress, &ErrorStatus,
2822 &Parameter0, &Parameter1) &&
2823 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2824 Parameter0, Parameter1))
2828 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2830 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2831 "for Controller at\n", Controller);
2834 DAC960_LA_EnableInterrupts(BaseAddress);
2835 if (Controller->V1.DualModeMemoryMailboxInterface)
2836 Controller->QueueCommand = DAC960_LA_QueueCommandDualMode;
2837 else Controller->QueueCommand = DAC960_LA_QueueCommandSingleMode;
2838 Controller->ReadControllerConfiguration =
2839 DAC960_V1_ReadControllerConfiguration;
2840 Controller->ReadDeviceConfiguration =
2841 DAC960_V1_ReadDeviceConfiguration;
2842 Controller->ReportDeviceConfiguration =
2843 DAC960_V1_ReportDeviceConfiguration;
2844 Controller->QueueReadWriteCommand =
2845 DAC960_V1_QueueReadWriteCommand;
2847 case DAC960_PG_Controller:
2848 DAC960_PG_DisableInterrupts(BaseAddress);
2849 DAC960_PG_AcknowledgeHardwareMailboxStatus(BaseAddress);
2851 while (DAC960_PG_InitializationInProgressP(BaseAddress))
2853 if (DAC960_PG_ReadErrorStatus(BaseAddress, &ErrorStatus,
2854 &Parameter0, &Parameter1) &&
2855 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2856 Parameter0, Parameter1))
2860 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2862 DAC960_Error("Unable to Enable Memory Mailbox Interface "
2863 "for Controller at\n", Controller);
2866 DAC960_PG_EnableInterrupts(BaseAddress);
2867 if (Controller->V1.DualModeMemoryMailboxInterface)
2868 Controller->QueueCommand = DAC960_PG_QueueCommandDualMode;
2869 else Controller->QueueCommand = DAC960_PG_QueueCommandSingleMode;
2870 Controller->ReadControllerConfiguration =
2871 DAC960_V1_ReadControllerConfiguration;
2872 Controller->ReadDeviceConfiguration =
2873 DAC960_V1_ReadDeviceConfiguration;
2874 Controller->ReportDeviceConfiguration =
2875 DAC960_V1_ReportDeviceConfiguration;
2876 Controller->QueueReadWriteCommand =
2877 DAC960_V1_QueueReadWriteCommand;
2879 case DAC960_PD_Controller:
2880 if (!request_region(Controller->IO_Address, 0x80,
2881 Controller->FullModelName)) {
2882 DAC960_Error("IO port 0x%d busy for Controller at\n",
2883 Controller, Controller->IO_Address);
2886 DAC960_PD_DisableInterrupts(BaseAddress);
2887 DAC960_PD_AcknowledgeStatus(BaseAddress);
2889 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2891 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2892 &Parameter0, &Parameter1) &&
2893 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2894 Parameter0, Parameter1))
2898 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2900 DAC960_Error("Unable to allocate DMA mapped memory "
2901 "for Controller at\n", Controller);
2904 DAC960_PD_EnableInterrupts(BaseAddress);
2905 Controller->QueueCommand = DAC960_PD_QueueCommand;
2906 Controller->ReadControllerConfiguration =
2907 DAC960_V1_ReadControllerConfiguration;
2908 Controller->ReadDeviceConfiguration =
2909 DAC960_V1_ReadDeviceConfiguration;
2910 Controller->ReportDeviceConfiguration =
2911 DAC960_V1_ReportDeviceConfiguration;
2912 Controller->QueueReadWriteCommand =
2913 DAC960_V1_QueueReadWriteCommand;
2915 case DAC960_P_Controller:
2916 if (!request_region(Controller->IO_Address, 0x80,
2917 Controller->FullModelName)){
2918 DAC960_Error("IO port 0x%d busy for Controller at\n",
2919 Controller, Controller->IO_Address);
2922 DAC960_PD_DisableInterrupts(BaseAddress);
2923 DAC960_PD_AcknowledgeStatus(BaseAddress);
2925 while (DAC960_PD_InitializationInProgressP(BaseAddress))
2927 if (DAC960_PD_ReadErrorStatus(BaseAddress, &ErrorStatus,
2928 &Parameter0, &Parameter1) &&
2929 DAC960_ReportErrorStatus(Controller, ErrorStatus,
2930 Parameter0, Parameter1))
2934 if (!DAC960_V1_EnableMemoryMailboxInterface(Controller))
2936 DAC960_Error("Unable to allocate DMA mapped memory"
2937 "for Controller at\n", Controller);
2940 DAC960_PD_EnableInterrupts(BaseAddress);
2941 Controller->QueueCommand = DAC960_P_QueueCommand;
2942 Controller->ReadControllerConfiguration =
2943 DAC960_V1_ReadControllerConfiguration;
2944 Controller->ReadDeviceConfiguration =
2945 DAC960_V1_ReadDeviceConfiguration;
2946 Controller->ReportDeviceConfiguration =
2947 DAC960_V1_ReportDeviceConfiguration;
2948 Controller->QueueReadWriteCommand =
2949 DAC960_V1_QueueReadWriteCommand;
2953 Acquire shared access to the IRQ Channel.
2955 if (request_irq(IRQ_Channel, InterruptHandler, SA_SHIRQ,
2956 Controller->FullModelName, Controller) < 0)
2958 DAC960_Error("Unable to acquire IRQ Channel %d for Controller at\n",
2959 Controller, Controller->IRQ_Channel);
2962 Controller->IRQ_Channel = IRQ_Channel;
2963 Controller->InitialCommand.CommandIdentifier = 1;
2964 Controller->InitialCommand.Controller = Controller;
2965 Controller->Commands[0] = &Controller->InitialCommand;
2966 Controller->FreeCommands = &Controller->InitialCommand;
2970 if (Controller->IO_Address == 0)
2971 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address N/A "
2972 "PCI Address 0x%X\n", Controller,
2973 Controller->Bus, Controller->Device,
2974 Controller->Function, Controller->PCI_Address);
2976 DAC960_Error("PCI Bus %d Device %d Function %d I/O Address "
2977 "0x%X PCI Address 0x%X\n", Controller,
2978 Controller->Bus, Controller->Device,
2979 Controller->Function, Controller->IO_Address,
2980 Controller->PCI_Address);
2981 DAC960_DetectCleanup(Controller);
2982 DAC960_ControllerCount--;
2987 DAC960_InitializeController initializes Controller.
2991 DAC960_InitializeController(DAC960_Controller_T *Controller)
2993 if (DAC960_ReadControllerConfiguration(Controller) &&
2994 DAC960_ReportControllerConfiguration(Controller) &&
2995 DAC960_CreateAuxiliaryStructures(Controller) &&
2996 DAC960_ReadDeviceConfiguration(Controller) &&
2997 DAC960_ReportDeviceConfiguration(Controller) &&
2998 DAC960_RegisterBlockDevice(Controller))
3001 Initialize the Monitoring Timer.
3003 init_timer(&Controller->MonitoringTimer);
3004 Controller->MonitoringTimer.expires =
3005 jiffies + DAC960_MonitoringTimerInterval;
3006 Controller->MonitoringTimer.data = (unsigned long) Controller;
3007 Controller->MonitoringTimer.function = DAC960_MonitoringTimerFunction;
3008 add_timer(&Controller->MonitoringTimer);
3009 Controller->ControllerInitialized = true;
3017 DAC960_FinalizeController finalizes Controller.
3020 static void DAC960_FinalizeController(DAC960_Controller_T *Controller)
3022 if (Controller->ControllerInitialized)
3024 unsigned long flags;
3027 * Acquiring and releasing lock here eliminates
3028 * a very low probability race.
3030 * The code below allocates controller command structures
3031 * from the free list without holding the controller lock.
3032 * This is safe assuming there is no other activity on
3033 * the controller at the time.
3035 * But, there might be a monitoring command still
3036 * in progress. Setting the Shutdown flag while holding
3037 * the lock ensures that there is no monitoring command
3038 * in the interrupt handler currently, and any monitoring
3039 * commands that complete from this time on will NOT return
3040 * their command structure to the free list.
3043 spin_lock_irqsave(&Controller->queue_lock, flags);
3044 Controller->ShutdownMonitoringTimer = 1;
3045 spin_unlock_irqrestore(&Controller->queue_lock, flags);
3047 del_timer_sync(&Controller->MonitoringTimer);
3048 if (Controller->FirmwareType == DAC960_V1_Controller)
3050 DAC960_Notice("Flushing Cache...", Controller);
3051 DAC960_V1_ExecuteType3(Controller, DAC960_V1_Flush, 0);
3052 DAC960_Notice("done\n", Controller);
3054 if (Controller->HardwareType == DAC960_PD_Controller)
3055 release_region(Controller->IO_Address, 0x80);
3059 DAC960_Notice("Flushing Cache...", Controller);
3060 DAC960_V2_DeviceOperation(Controller, DAC960_V2_PauseDevice,
3061 DAC960_V2_RAID_Controller);
3062 DAC960_Notice("done\n", Controller);
3065 DAC960_UnregisterBlockDevice(Controller);
3066 DAC960_DestroyAuxiliaryStructures(Controller);
3067 DAC960_DestroyProcEntries(Controller);
3068 DAC960_DetectCleanup(Controller);
3073 DAC960_Probe verifies controller's existence and
3074 initializes the DAC960 Driver for that controller.
3078 DAC960_Probe(struct pci_dev *dev, const struct pci_device_id *entry)
3081 DAC960_Controller_T *Controller;
3083 if (DAC960_ControllerCount == DAC960_MaxControllers)
3085 DAC960_Error("More than %d DAC960 Controllers detected - "
3086 "ignoring from Controller at\n",
3087 NULL, DAC960_MaxControllers);
3091 Controller = DAC960_DetectController(dev, entry);
3095 if (!DAC960_InitializeController(Controller)) {
3096 DAC960_FinalizeController(Controller);
3100 for (disk = 0; disk < DAC960_MaxLogicalDrives; disk++) {
3101 set_capacity(Controller->disks[disk], disk_size(Controller, disk));
3102 add_disk(Controller->disks[disk]);
3104 DAC960_CreateProcEntries(Controller);
3110 DAC960_Finalize finalizes the DAC960 Driver.
3113 static void DAC960_Remove(struct pci_dev *PCI_Device)
3115 int Controller_Number = (long)pci_get_drvdata(PCI_Device);
3116 DAC960_Controller_T *Controller = DAC960_Controllers[Controller_Number];
3117 if (Controller != NULL)
3118 DAC960_FinalizeController(Controller);
3123 DAC960_V1_QueueReadWriteCommand prepares and queues a Read/Write Command for
3124 DAC960 V1 Firmware Controllers.
3127 static void DAC960_V1_QueueReadWriteCommand(DAC960_Command_T *Command)
3129 DAC960_Controller_T *Controller = Command->Controller;
3130 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
3131 DAC960_V1_ScatterGatherSegment_T *ScatterGatherList =
3132 Command->V1.ScatterGatherList;
3133 struct scatterlist *ScatterList = Command->V1.ScatterList;
3135 DAC960_V1_ClearCommand(Command);
3137 if (Command->SegmentCount == 1)
3139 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3140 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Read;
3142 CommandMailbox->Type5.CommandOpcode = DAC960_V1_Write;
3144 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3145 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3146 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3147 CommandMailbox->Type5.BusAddress =
3148 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3154 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3155 CommandMailbox->Type5.CommandOpcode = DAC960_V1_ReadWithScatterGather;
3157 CommandMailbox->Type5.CommandOpcode = DAC960_V1_WriteWithScatterGather;
3159 CommandMailbox->Type5.LD.TransferLength = Command->BlockCount;
3160 CommandMailbox->Type5.LD.LogicalDriveNumber = Command->LogicalDriveNumber;
3161 CommandMailbox->Type5.LogicalBlockAddress = Command->BlockNumber;
3162 CommandMailbox->Type5.BusAddress = Command->V1.ScatterGatherListDMA;
3164 CommandMailbox->Type5.ScatterGatherCount = Command->SegmentCount;
3166 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3167 ScatterGatherList->SegmentDataPointer =
3168 (DAC960_BusAddress32_T)sg_dma_address(ScatterList);
3169 ScatterGatherList->SegmentByteCount =
3170 (DAC960_ByteCount32_T)sg_dma_len(ScatterList);
3173 DAC960_QueueCommand(Command);
3178 DAC960_V2_QueueReadWriteCommand prepares and queues a Read/Write Command for
3179 DAC960 V2 Firmware Controllers.
3182 static void DAC960_V2_QueueReadWriteCommand(DAC960_Command_T *Command)
3184 DAC960_Controller_T *Controller = Command->Controller;
3185 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
3186 struct scatterlist *ScatterList = Command->V2.ScatterList;
3188 DAC960_V2_ClearCommand(Command);
3190 CommandMailbox->SCSI_10.CommandOpcode = DAC960_V2_SCSI_10;
3191 CommandMailbox->SCSI_10.CommandControlBits.DataTransferControllerToHost =
3192 (Command->DmaDirection == PCI_DMA_FROMDEVICE);
3193 CommandMailbox->SCSI_10.DataTransferSize =
3194 Command->BlockCount << DAC960_BlockSizeBits;
3195 CommandMailbox->SCSI_10.RequestSenseBusAddress = Command->V2.RequestSenseDMA;
3196 CommandMailbox->SCSI_10.PhysicalDevice =
3197 Controller->V2.LogicalDriveToVirtualDevice[Command->LogicalDriveNumber];
3198 CommandMailbox->SCSI_10.RequestSenseSize = sizeof(DAC960_SCSI_RequestSense_T);
3199 CommandMailbox->SCSI_10.CDBLength = 10;
3200 CommandMailbox->SCSI_10.SCSI_CDB[0] =
3201 (Command->DmaDirection == PCI_DMA_FROMDEVICE ? 0x28 : 0x2A);
3202 CommandMailbox->SCSI_10.SCSI_CDB[2] = Command->BlockNumber >> 24;
3203 CommandMailbox->SCSI_10.SCSI_CDB[3] = Command->BlockNumber >> 16;
3204 CommandMailbox->SCSI_10.SCSI_CDB[4] = Command->BlockNumber >> 8;
3205 CommandMailbox->SCSI_10.SCSI_CDB[5] = Command->BlockNumber;
3206 CommandMailbox->SCSI_10.SCSI_CDB[7] = Command->BlockCount >> 8;
3207 CommandMailbox->SCSI_10.SCSI_CDB[8] = Command->BlockCount;
3209 if (Command->SegmentCount == 1)
3211 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3212 .ScatterGatherSegments[0]
3213 .SegmentDataPointer =
3214 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3215 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3216 .ScatterGatherSegments[0]
3218 CommandMailbox->SCSI_10.DataTransferSize;
3222 DAC960_V2_ScatterGatherSegment_T *ScatterGatherList;
3225 if (Command->SegmentCount > 2)
3227 ScatterGatherList = Command->V2.ScatterGatherList;
3228 CommandMailbox->SCSI_10.CommandControlBits
3229 .AdditionalScatterGatherListMemory = true;
3230 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3231 .ExtendedScatterGather.ScatterGatherList0Length = Command->SegmentCount;
3232 CommandMailbox->SCSI_10.DataTransferMemoryAddress
3233 .ExtendedScatterGather.ScatterGatherList0Address =
3234 Command->V2.ScatterGatherListDMA;
3237 ScatterGatherList = CommandMailbox->SCSI_10.DataTransferMemoryAddress
3238 .ScatterGatherSegments;
3240 for (i = 0; i < Command->SegmentCount; i++, ScatterList++, ScatterGatherList++) {
3241 ScatterGatherList->SegmentDataPointer =
3242 (DAC960_BusAddress64_T)sg_dma_address(ScatterList);
3243 ScatterGatherList->SegmentByteCount =
3244 (DAC960_ByteCount64_T)sg_dma_len(ScatterList);
3247 DAC960_QueueCommand(Command);
3251 static int DAC960_process_queue(DAC960_Controller_T *Controller, struct request_queue *req_q)
3253 struct request *Request;
3254 DAC960_Command_T *Command;
3257 Request = elv_next_request(req_q);
3261 Command = DAC960_AllocateCommand(Controller);
3262 if (Command == NULL)
3265 if (rq_data_dir(Request) == READ) {
3266 Command->DmaDirection = PCI_DMA_FROMDEVICE;
3267 Command->CommandType = DAC960_ReadCommand;
3269 Command->DmaDirection = PCI_DMA_TODEVICE;
3270 Command->CommandType = DAC960_WriteCommand;
3272 Command->Completion = Request->waiting;
3273 Command->LogicalDriveNumber = (long)Request->rq_disk->private_data;
3274 Command->BlockNumber = Request->sector;
3275 Command->BlockCount = Request->nr_sectors;
3276 Command->Request = Request;
3277 blkdev_dequeue_request(Request);
3278 Command->SegmentCount = blk_rq_map_sg(req_q,
3279 Command->Request, Command->cmd_sglist);
3280 /* pci_map_sg MAY change the value of SegCount */
3281 Command->SegmentCount = pci_map_sg(Controller->PCIDevice, Command->cmd_sglist,
3282 Command->SegmentCount, Command->DmaDirection);
3284 DAC960_QueueReadWriteCommand(Command);
3289 DAC960_ProcessRequest attempts to remove one I/O Request from Controller's
3290 I/O Request Queue and queues it to the Controller. WaitForCommand is true if
3291 this function should wait for a Command to become available if necessary.
3292 This function returns true if an I/O Request was queued and false otherwise.
3294 static void DAC960_ProcessRequest(DAC960_Controller_T *controller)
3298 if (!controller->ControllerInitialized)
3301 /* Do this better later! */
3302 for (i = controller->req_q_index; i < DAC960_MaxLogicalDrives; i++) {
3303 struct request_queue *req_q = controller->RequestQueue[i];
3308 if (!DAC960_process_queue(controller, req_q)) {
3309 controller->req_q_index = i;
3314 if (controller->req_q_index == 0)
3317 for (i = 0; i < controller->req_q_index; i++) {
3318 struct request_queue *req_q = controller->RequestQueue[i];
3323 if (!DAC960_process_queue(controller, req_q)) {
3324 controller->req_q_index = i;
3332 DAC960_queue_partial_rw extracts one bio from the request already
3333 associated with argument command, and construct a new command block to retry I/O
3334 only on that bio. Queue that command to the controller.
3336 This function re-uses a previously-allocated Command,
3337 there is no failure mode from trying to allocate a command.
3340 static void DAC960_queue_partial_rw(DAC960_Command_T *Command)
3342 DAC960_Controller_T *Controller = Command->Controller;
3343 struct request *Request = Command->Request;
3344 struct request_queue *req_q = Controller->RequestQueue[Command->LogicalDriveNumber];
3346 if (Command->DmaDirection == PCI_DMA_FROMDEVICE)
3347 Command->CommandType = DAC960_ReadRetryCommand;
3349 Command->CommandType = DAC960_WriteRetryCommand;
3352 * We could be more efficient with these mapping requests
3353 * and map only the portions that we need. But since this
3354 * code should almost never be called, just go with a
3357 (void)blk_rq_map_sg(req_q, Command->Request, Command->cmd_sglist);
3359 (void)pci_map_sg(Controller->PCIDevice, Command->cmd_sglist, 1, Command->DmaDirection);
3361 * Resubmitting the request sector at a time is really tedious.
3362 * But, this should almost never happen. So, we're willing to pay
3363 * this price so that in the end, as much of the transfer is completed
3364 * successfully as possible.
3366 Command->SegmentCount = 1;
3367 Command->BlockNumber = Request->sector;
3368 Command->BlockCount = 1;
3369 DAC960_QueueReadWriteCommand(Command);
3374 DAC960_RequestFunction is the I/O Request Function for DAC960 Controllers.
3377 static void DAC960_RequestFunction(struct request_queue *RequestQueue)
3379 DAC960_ProcessRequest(RequestQueue->queuedata);
3383 DAC960_ProcessCompletedBuffer performs completion processing for an
3387 static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3388 boolean SuccessfulIO)
3390 struct request *Request = Command->Request;
3397 pci_unmap_sg(Command->Controller->PCIDevice, Command->cmd_sglist,
3398 Command->SegmentCount, Command->DmaDirection);
3400 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
3402 end_that_request_last(Request);
3404 if (Command->Completion) {
3405 complete(Command->Completion);
3406 Command->Completion = NULL;
3414 DAC960_V1_ReadWriteError prints an appropriate error message for Command
3415 when an error occurs on a Read or Write operation.
3418 static void DAC960_V1_ReadWriteError(DAC960_Command_T *Command)
3420 DAC960_Controller_T *Controller = Command->Controller;
3421 unsigned char *CommandName = "UNKNOWN";
3422 switch (Command->CommandType)
3424 case DAC960_ReadCommand:
3425 case DAC960_ReadRetryCommand:
3426 CommandName = "READ";
3428 case DAC960_WriteCommand:
3429 case DAC960_WriteRetryCommand:
3430 CommandName = "WRITE";
3432 case DAC960_MonitoringCommand:
3433 case DAC960_ImmediateCommand:
3434 case DAC960_QueuedCommand:
3437 switch (Command->V1.CommandStatus)
3439 case DAC960_V1_IrrecoverableDataError:
3440 DAC960_Error("Irrecoverable Data Error on %s:\n",
3441 Controller, CommandName);
3443 case DAC960_V1_LogicalDriveNonexistentOrOffline:
3444 DAC960_Error("Logical Drive Nonexistent or Offline on %s:\n",
3445 Controller, CommandName);
3447 case DAC960_V1_AccessBeyondEndOfLogicalDrive:
3448 DAC960_Error("Attempt to Access Beyond End of Logical Drive "
3449 "on %s:\n", Controller, CommandName);
3451 case DAC960_V1_BadDataEncountered:
3452 DAC960_Error("Bad Data Encountered on %s:\n", Controller, CommandName);
3455 DAC960_Error("Unexpected Error Status %04X on %s:\n",
3456 Controller, Command->V1.CommandStatus, CommandName);
3459 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
3460 Controller, Controller->ControllerNumber,
3461 Command->LogicalDriveNumber, Command->BlockNumber,
3462 Command->BlockNumber + Command->BlockCount - 1);
3467 DAC960_V1_ProcessCompletedCommand performs completion processing for Command
3468 for DAC960 V1 Firmware Controllers.
3471 static void DAC960_V1_ProcessCompletedCommand(DAC960_Command_T *Command)
3473 DAC960_Controller_T *Controller = Command->Controller;
3474 DAC960_CommandType_T CommandType = Command->CommandType;
3475 DAC960_V1_CommandOpcode_T CommandOpcode =
3476 Command->V1.CommandMailbox.Common.CommandOpcode;
3477 DAC960_V1_CommandStatus_T CommandStatus = Command->V1.CommandStatus;
3479 if (CommandType == DAC960_ReadCommand ||
3480 CommandType == DAC960_WriteCommand)
3483 #ifdef FORCE_RETRY_DEBUG
3484 CommandStatus = DAC960_V1_IrrecoverableDataError;
3487 if (CommandStatus == DAC960_V1_NormalCompletion) {
3489 if (!DAC960_ProcessCompletedRequest(Command, true))
3492 } else if (CommandStatus == DAC960_V1_IrrecoverableDataError ||
3493 CommandStatus == DAC960_V1_BadDataEncountered)
3496 * break the command down into pieces and resubmit each
3497 * piece, hoping that some of them will succeed.
3499 DAC960_queue_partial_rw(Command);
3504 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3505 DAC960_V1_ReadWriteError(Command);
3507 if (!DAC960_ProcessCompletedRequest(Command, false))
3511 else if (CommandType == DAC960_ReadRetryCommand ||
3512 CommandType == DAC960_WriteRetryCommand)
3514 boolean normal_completion;
3515 #ifdef FORCE_RETRY_FAILURE_DEBUG
3516 static int retry_count = 1;
3519 Perform completion processing for the portion that was
3520 retried, and submit the next portion, if any.
3522 normal_completion = true;
3523 if (CommandStatus != DAC960_V1_NormalCompletion) {
3524 normal_completion = false;
3525 if (CommandStatus != DAC960_V1_LogicalDriveNonexistentOrOffline)
3526 DAC960_V1_ReadWriteError(Command);
3529 #ifdef FORCE_RETRY_FAILURE_DEBUG
3530 if (!(++retry_count % 10000)) {
3531 printk("V1 error retry failure test\n");
3532 normal_completion = false;
3533 DAC960_V1_ReadWriteError(Command);
3537 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
3538 DAC960_queue_partial_rw(Command);
3543 else if (CommandType == DAC960_MonitoringCommand)
3545 if (Controller->ShutdownMonitoringTimer)
3547 if (CommandOpcode == DAC960_V1_Enquiry)
3549 DAC960_V1_Enquiry_T *OldEnquiry = &Controller->V1.Enquiry;
3550 DAC960_V1_Enquiry_T *NewEnquiry = Controller->V1.NewEnquiry;
3551 unsigned int OldCriticalLogicalDriveCount =
3552 OldEnquiry->CriticalLogicalDriveCount;
3553 unsigned int NewCriticalLogicalDriveCount =
3554 NewEnquiry->CriticalLogicalDriveCount;
3555 if (NewEnquiry->NumberOfLogicalDrives > Controller->LogicalDriveCount)
3557 int LogicalDriveNumber = Controller->LogicalDriveCount - 1;
3558 while (++LogicalDriveNumber < NewEnquiry->NumberOfLogicalDrives)
3559 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3560 "Now Exists\n", Controller,
3562 Controller->ControllerNumber,
3563 LogicalDriveNumber);
3564 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3565 DAC960_ComputeGenericDiskInfo(Controller);
3567 if (NewEnquiry->NumberOfLogicalDrives < Controller->LogicalDriveCount)
3569 int LogicalDriveNumber = NewEnquiry->NumberOfLogicalDrives - 1;
3570 while (++LogicalDriveNumber < Controller->LogicalDriveCount)
3571 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3572 "No Longer Exists\n", Controller,
3574 Controller->ControllerNumber,
3575 LogicalDriveNumber);
3576 Controller->LogicalDriveCount = NewEnquiry->NumberOfLogicalDrives;
3577 DAC960_ComputeGenericDiskInfo(Controller);
3579 if (NewEnquiry->StatusFlags.DeferredWriteError !=
3580 OldEnquiry->StatusFlags.DeferredWriteError)
3581 DAC960_Critical("Deferred Write Error Flag is now %s\n", Controller,
3582 (NewEnquiry->StatusFlags.DeferredWriteError
3583 ? "TRUE" : "FALSE"));
3584 if ((NewCriticalLogicalDriveCount > 0 ||
3585 NewCriticalLogicalDriveCount != OldCriticalLogicalDriveCount) ||
3586 (NewEnquiry->OfflineLogicalDriveCount > 0 ||
3587 NewEnquiry->OfflineLogicalDriveCount !=
3588 OldEnquiry->OfflineLogicalDriveCount) ||
3589 (NewEnquiry->DeadDriveCount > 0 ||
3590 NewEnquiry->DeadDriveCount !=
3591 OldEnquiry->DeadDriveCount) ||
3592 (NewEnquiry->EventLogSequenceNumber !=
3593 OldEnquiry->EventLogSequenceNumber) ||
3594 Controller->MonitoringTimerCount == 0 ||
3595 (jiffies - Controller->SecondaryMonitoringTime
3596 >= DAC960_SecondaryMonitoringInterval))
3598 Controller->V1.NeedLogicalDriveInformation = true;
3599 Controller->V1.NewEventLogSequenceNumber =
3600 NewEnquiry->EventLogSequenceNumber;
3601 Controller->V1.NeedErrorTableInformation = true;
3602 Controller->V1.NeedDeviceStateInformation = true;
3603 Controller->V1.StartDeviceStateScan = true;
3604 Controller->V1.NeedBackgroundInitializationStatus =
3605 Controller->V1.BackgroundInitializationStatusSupported;
3606 Controller->SecondaryMonitoringTime = jiffies;
3608 if (NewEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3609 NewEnquiry->RebuildFlag
3610 == DAC960_V1_BackgroundRebuildInProgress ||
3611 OldEnquiry->RebuildFlag == DAC960_V1_StandbyRebuildInProgress ||
3612 OldEnquiry->RebuildFlag == DAC960_V1_BackgroundRebuildInProgress)
3614 Controller->V1.NeedRebuildProgress = true;
3615 Controller->V1.RebuildProgressFirst =
3616 (NewEnquiry->CriticalLogicalDriveCount <
3617 OldEnquiry->CriticalLogicalDriveCount);
3619 if (OldEnquiry->RebuildFlag == DAC960_V1_BackgroundCheckInProgress)
3620 switch (NewEnquiry->RebuildFlag)
3622 case DAC960_V1_NoStandbyRebuildOrCheckInProgress:
3623 DAC960_Progress("Consistency Check Completed Successfully\n",
3626 case DAC960_V1_StandbyRebuildInProgress:
3627 case DAC960_V1_BackgroundRebuildInProgress:
3629 case DAC960_V1_BackgroundCheckInProgress:
3630 Controller->V1.NeedConsistencyCheckProgress = true;
3632 case DAC960_V1_StandbyRebuildCompletedWithError:
3633 DAC960_Progress("Consistency Check Completed with Error\n",
3636 case DAC960_V1_BackgroundRebuildOrCheckFailed_DriveFailed:
3637 DAC960_Progress("Consistency Check Failed - "
3638 "Physical Device Failed\n", Controller);
3640 case DAC960_V1_BackgroundRebuildOrCheckFailed_LogicalDriveFailed:
3641 DAC960_Progress("Consistency Check Failed - "
3642 "Logical Drive Failed\n", Controller);
3644 case DAC960_V1_BackgroundRebuildOrCheckFailed_OtherCauses:
3645 DAC960_Progress("Consistency Check Failed - Other Causes\n",
3648 case DAC960_V1_BackgroundRebuildOrCheckSuccessfullyTerminated:
3649 DAC960_Progress("Consistency Check Successfully Terminated\n",
3653 else if (NewEnquiry->RebuildFlag
3654 == DAC960_V1_BackgroundCheckInProgress)
3655 Controller->V1.NeedConsistencyCheckProgress = true;
3656 Controller->MonitoringAlertMode =
3657 (NewEnquiry->CriticalLogicalDriveCount > 0 ||
3658 NewEnquiry->OfflineLogicalDriveCount > 0 ||
3659 NewEnquiry->DeadDriveCount > 0);
3660 if (NewEnquiry->RebuildFlag > DAC960_V1_BackgroundCheckInProgress)
3662 Controller->V1.PendingRebuildFlag = NewEnquiry->RebuildFlag;
3663 Controller->V1.RebuildFlagPending = true;
3665 memcpy(&Controller->V1.Enquiry, &Controller->V1.NewEnquiry,
3666 sizeof(DAC960_V1_Enquiry_T));
3668 else if (CommandOpcode == DAC960_V1_PerformEventLogOperation)
3671 *DAC960_EventMessages[] =
3672 { "killed because write recovery failed",
3673 "killed because of SCSI bus reset failure",
3674 "killed because of double check condition",
3675 "killed because it was removed",
3676 "killed because of gross error on SCSI chip",
3677 "killed because of bad tag returned from drive",
3678 "killed because of timeout on SCSI command",
3679 "killed because of reset SCSI command issued from system",
3680 "killed because busy or parity error count exceeded limit",
3681 "killed because of 'kill drive' command from system",
3682 "killed because of selection timeout",
3683 "killed due to SCSI phase sequence error",
3684 "killed due to unknown status" };
3685 DAC960_V1_EventLogEntry_T *EventLogEntry =
3686 Controller->V1.EventLogEntry;
3687 if (EventLogEntry->SequenceNumber ==
3688 Controller->V1.OldEventLogSequenceNumber)
3690 unsigned char SenseKey = EventLogEntry->SenseKey;
3691 unsigned char AdditionalSenseCode =
3692 EventLogEntry->AdditionalSenseCode;
3693 unsigned char AdditionalSenseCodeQualifier =
3694 EventLogEntry->AdditionalSenseCodeQualifier;
3695 if (SenseKey == DAC960_SenseKey_VendorSpecific &&
3696 AdditionalSenseCode == 0x80 &&
3697 AdditionalSenseCodeQualifier <
3698 sizeof(DAC960_EventMessages) / sizeof(char *))
3699 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
3700 EventLogEntry->Channel,
3701 EventLogEntry->TargetID,
3702 DAC960_EventMessages[
3703 AdditionalSenseCodeQualifier]);
3704 else if (SenseKey == DAC960_SenseKey_UnitAttention &&
3705 AdditionalSenseCode == 0x29)
3707 if (Controller->MonitoringTimerCount > 0)
3708 Controller->V1.DeviceResetCount[EventLogEntry->Channel]
3709 [EventLogEntry->TargetID]++;
3711 else if (!(SenseKey == DAC960_SenseKey_NoSense ||
3712 (SenseKey == DAC960_SenseKey_NotReady &&
3713 AdditionalSenseCode == 0x04 &&
3714 (AdditionalSenseCodeQualifier == 0x01 ||
3715 AdditionalSenseCodeQualifier == 0x02))))
3717 DAC960_Critical("Physical Device %d:%d Error Log: "
3718 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
3720 EventLogEntry->Channel,
3721 EventLogEntry->TargetID,
3723 AdditionalSenseCode,
3724 AdditionalSenseCodeQualifier);
3725 DAC960_Critical("Physical Device %d:%d Error Log: "
3726 "Information = %02X%02X%02X%02X "
3727 "%02X%02X%02X%02X\n",
3729 EventLogEntry->Channel,
3730 EventLogEntry->TargetID,
3731 EventLogEntry->Information[0],
3732 EventLogEntry->Information[1],
3733 EventLogEntry->Information[2],
3734 EventLogEntry->Information[3],
3735 EventLogEntry->CommandSpecificInformation[0],
3736 EventLogEntry->CommandSpecificInformation[1],
3737 EventLogEntry->CommandSpecificInformation[2],
3738 EventLogEntry->CommandSpecificInformation[3]);
3741 Controller->V1.OldEventLogSequenceNumber++;
3743 else if (CommandOpcode == DAC960_V1_GetErrorTable)
3745 DAC960_V1_ErrorTable_T *OldErrorTable = &Controller->V1.ErrorTable;
3746 DAC960_V1_ErrorTable_T *NewErrorTable = Controller->V1.NewErrorTable;
3747 int Channel, TargetID;
3748 for (Channel = 0; Channel < Controller->Channels; Channel++)
3749 for (TargetID = 0; TargetID < Controller->Targets; TargetID++)
3751 DAC960_V1_ErrorTableEntry_T *NewErrorEntry =
3752 &NewErrorTable->ErrorTableEntries[Channel][TargetID];
3753 DAC960_V1_ErrorTableEntry_T *OldErrorEntry =
3754 &OldErrorTable->ErrorTableEntries[Channel][TargetID];
3755 if ((NewErrorEntry->ParityErrorCount !=
3756 OldErrorEntry->ParityErrorCount) ||
3757 (NewErrorEntry->SoftErrorCount !=
3758 OldErrorEntry->SoftErrorCount) ||
3759 (NewErrorEntry->HardErrorCount !=
3760 OldErrorEntry->HardErrorCount) ||
3761 (NewErrorEntry->MiscErrorCount !=
3762 OldErrorEntry->MiscErrorCount))
3763 DAC960_Critical("Physical Device %d:%d Errors: "
3764 "Parity = %d, Soft = %d, "
3765 "Hard = %d, Misc = %d\n",
3766 Controller, Channel, TargetID,
3767 NewErrorEntry->ParityErrorCount,
3768 NewErrorEntry->SoftErrorCount,
3769 NewErrorEntry->HardErrorCount,
3770 NewErrorEntry->MiscErrorCount);
3772 memcpy(&Controller->V1.ErrorTable, Controller->V1.NewErrorTable,
3773 sizeof(DAC960_V1_ErrorTable_T));
3775 else if (CommandOpcode == DAC960_V1_GetDeviceState)
3777 DAC960_V1_DeviceState_T *OldDeviceState =
3778 &Controller->V1.DeviceState[Controller->V1.DeviceStateChannel]
3779 [Controller->V1.DeviceStateTargetID];
3780 DAC960_V1_DeviceState_T *NewDeviceState =
3781 Controller->V1.NewDeviceState;
3782 if (NewDeviceState->DeviceState != OldDeviceState->DeviceState)
3783 DAC960_Critical("Physical Device %d:%d is now %s\n", Controller,
3784 Controller->V1.DeviceStateChannel,
3785 Controller->V1.DeviceStateTargetID,
3786 (NewDeviceState->DeviceState
3787 == DAC960_V1_Device_Dead
3789 : NewDeviceState->DeviceState
3790 == DAC960_V1_Device_WriteOnly
3792 : NewDeviceState->DeviceState
3793 == DAC960_V1_Device_Online
3794 ? "ONLINE" : "STANDBY"));
3795 if (OldDeviceState->DeviceState == DAC960_V1_Device_Dead &&
3796 NewDeviceState->DeviceState != DAC960_V1_Device_Dead)
3798 Controller->V1.NeedDeviceInquiryInformation = true;
3799 Controller->V1.NeedDeviceSerialNumberInformation = true;
3800 Controller->V1.DeviceResetCount
3801 [Controller->V1.DeviceStateChannel]
3802 [Controller->V1.DeviceStateTargetID] = 0;
3804 memcpy(OldDeviceState, NewDeviceState,
3805 sizeof(DAC960_V1_DeviceState_T));
3807 else if (CommandOpcode == DAC960_V1_GetLogicalDriveInformation)
3809 int LogicalDriveNumber;
3810 for (LogicalDriveNumber = 0;
3811 LogicalDriveNumber < Controller->LogicalDriveCount;
3812 LogicalDriveNumber++)
3814 DAC960_V1_LogicalDriveInformation_T *OldLogicalDriveInformation =
3815 &Controller->V1.LogicalDriveInformation[LogicalDriveNumber];
3816 DAC960_V1_LogicalDriveInformation_T *NewLogicalDriveInformation =
3817 &(*Controller->V1.NewLogicalDriveInformation)[LogicalDriveNumber];
3818 if (NewLogicalDriveInformation->LogicalDriveState !=
3819 OldLogicalDriveInformation->LogicalDriveState)
3820 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3821 "is now %s\n", Controller,
3823 Controller->ControllerNumber,
3825 (NewLogicalDriveInformation->LogicalDriveState
3826 == DAC960_V1_LogicalDrive_Online
3828 : NewLogicalDriveInformation->LogicalDriveState
3829 == DAC960_V1_LogicalDrive_Critical
3830 ? "CRITICAL" : "OFFLINE"));
3831 if (NewLogicalDriveInformation->WriteBack !=
3832 OldLogicalDriveInformation->WriteBack)
3833 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
3834 "is now %s\n", Controller,
3836 Controller->ControllerNumber,
3838 (NewLogicalDriveInformation->WriteBack
3839 ? "WRITE BACK" : "WRITE THRU"));
3841 memcpy(&Controller->V1.LogicalDriveInformation,
3842 Controller->V1.NewLogicalDriveInformation,
3843 sizeof(DAC960_V1_LogicalDriveInformationArray_T));
3845 else if (CommandOpcode == DAC960_V1_GetRebuildProgress)
3847 unsigned int LogicalDriveNumber =
3848 Controller->V1.RebuildProgress->LogicalDriveNumber;
3849 unsigned int LogicalDriveSize =
3850 Controller->V1.RebuildProgress->LogicalDriveSize;
3851 unsigned int BlocksCompleted =
3852 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3853 if (CommandStatus == DAC960_V1_NoRebuildOrCheckInProgress &&
3854 Controller->V1.LastRebuildStatus == DAC960_V1_NormalCompletion)
3855 CommandStatus = DAC960_V1_RebuildSuccessful;
3856 switch (CommandStatus)
3858 case DAC960_V1_NormalCompletion:
3859 Controller->EphemeralProgressMessage = true;
3860 DAC960_Progress("Rebuild in Progress: "
3861 "Logical Drive %d (/dev/rd/c%dd%d) "
3863 Controller, LogicalDriveNumber,
3864 Controller->ControllerNumber,
3866 (100 * (BlocksCompleted >> 7))
3867 / (LogicalDriveSize >> 7));
3868 Controller->EphemeralProgressMessage = false;
3870 case DAC960_V1_RebuildFailed_LogicalDriveFailure:
3871 DAC960_Progress("Rebuild Failed due to "
3872 "Logical Drive Failure\n", Controller);
3874 case DAC960_V1_RebuildFailed_BadBlocksOnOther:
3875 DAC960_Progress("Rebuild Failed due to "
3876 "Bad Blocks on Other Drives\n", Controller);
3878 case DAC960_V1_RebuildFailed_NewDriveFailed:
3879 DAC960_Progress("Rebuild Failed due to "
3880 "Failure of Drive Being Rebuilt\n", Controller);
3882 case DAC960_V1_NoRebuildOrCheckInProgress:
3884 case DAC960_V1_RebuildSuccessful:
3885 DAC960_Progress("Rebuild Completed Successfully\n", Controller);
3887 case DAC960_V1_RebuildSuccessfullyTerminated:
3888 DAC960_Progress("Rebuild Successfully Terminated\n", Controller);
3891 Controller->V1.LastRebuildStatus = CommandStatus;
3892 if (CommandType != DAC960_MonitoringCommand &&
3893 Controller->V1.RebuildStatusPending)
3895 Command->V1.CommandStatus = Controller->V1.PendingRebuildStatus;
3896 Controller->V1.RebuildStatusPending = false;
3898 else if (CommandType == DAC960_MonitoringCommand &&
3899 CommandStatus != DAC960_V1_NormalCompletion &&
3900 CommandStatus != DAC960_V1_NoRebuildOrCheckInProgress)
3902 Controller->V1.PendingRebuildStatus = CommandStatus;
3903 Controller->V1.RebuildStatusPending = true;
3906 else if (CommandOpcode == DAC960_V1_RebuildStat)
3908 unsigned int LogicalDriveNumber =
3909 Controller->V1.RebuildProgress->LogicalDriveNumber;
3910 unsigned int LogicalDriveSize =
3911 Controller->V1.RebuildProgress->LogicalDriveSize;
3912 unsigned int BlocksCompleted =
3913 LogicalDriveSize - Controller->V1.RebuildProgress->RemainingBlocks;
3914 if (CommandStatus == DAC960_V1_NormalCompletion)
3916 Controller->EphemeralProgressMessage = true;
3917 DAC960_Progress("Consistency Check in Progress: "
3918 "Logical Drive %d (/dev/rd/c%dd%d) "
3920 Controller, LogicalDriveNumber,
3921 Controller->ControllerNumber,
3923 (100 * (BlocksCompleted >> 7))
3924 / (LogicalDriveSize >> 7));
3925 Controller->EphemeralProgressMessage = false;
3928 else if (CommandOpcode == DAC960_V1_BackgroundInitializationControl)
3930 unsigned int LogicalDriveNumber =
3931 Controller->V1.BackgroundInitializationStatus->LogicalDriveNumber;
3932 unsigned int LogicalDriveSize =
3933 Controller->V1.BackgroundInitializationStatus->LogicalDriveSize;
3934 unsigned int BlocksCompleted =
3935 Controller->V1.BackgroundInitializationStatus->BlocksCompleted;
3936 switch (CommandStatus)
3938 case DAC960_V1_NormalCompletion:
3939 switch (Controller->V1.BackgroundInitializationStatus->Status)
3941 case DAC960_V1_BackgroundInitializationInvalid:
3943 case DAC960_V1_BackgroundInitializationStarted:
3944 DAC960_Progress("Background Initialization Started\n",
3947 case DAC960_V1_BackgroundInitializationInProgress:
3948 if (BlocksCompleted ==
3949 Controller->V1.LastBackgroundInitializationStatus.
3951 LogicalDriveNumber ==
3952 Controller->V1.LastBackgroundInitializationStatus.
3955 Controller->EphemeralProgressMessage = true;
3956 DAC960_Progress("Background Initialization in Progress: "
3957 "Logical Drive %d (/dev/rd/c%dd%d) "
3959 Controller, LogicalDriveNumber,
3960 Controller->ControllerNumber,
3962 (100 * (BlocksCompleted >> 7))
3963 / (LogicalDriveSize >> 7));
3964 Controller->EphemeralProgressMessage = false;
3966 case DAC960_V1_BackgroundInitializationSuspended:
3967 DAC960_Progress("Background Initialization Suspended\n",
3970 case DAC960_V1_BackgroundInitializationCancelled:
3971 DAC960_Progress("Background Initialization Cancelled\n",
3975 memcpy(&Controller->V1.LastBackgroundInitializationStatus,
3976 Controller->V1.BackgroundInitializationStatus,
3977 sizeof(DAC960_V1_BackgroundInitializationStatus_T));
3979 case DAC960_V1_BackgroundInitSuccessful:
3980 if (Controller->V1.BackgroundInitializationStatus->Status ==
3981 DAC960_V1_BackgroundInitializationInProgress)
3982 DAC960_Progress("Background Initialization "
3983 "Completed Successfully\n", Controller);
3984 Controller->V1.BackgroundInitializationStatus->Status =
3985 DAC960_V1_BackgroundInitializationInvalid;
3987 case DAC960_V1_BackgroundInitAborted:
3988 if (Controller->V1.BackgroundInitializationStatus->Status ==
3989 DAC960_V1_BackgroundInitializationInProgress)
3990 DAC960_Progress("Background Initialization Aborted\n",
3992 Controller->V1.BackgroundInitializationStatus->Status =
3993 DAC960_V1_BackgroundInitializationInvalid;
3995 case DAC960_V1_NoBackgroundInitInProgress:
3999 else if (CommandOpcode == DAC960_V1_DCDB)
4004 The InquiryStandardData and
4005 the InquiryUntitSerialNumber information
4006 retrieval operations BOTH use the DAC960_V1_DCDB
4007 commands. the test above can't distinguish between
4010 Instead, we rely on the order of code later in this
4011 function to ensure that DeviceInquiryInformation commands
4012 are submitted before DeviceSerialNumber commands.
4014 if (Controller->V1.NeedDeviceInquiryInformation)
4016 DAC960_SCSI_Inquiry_T *InquiryStandardData =
4017 &Controller->V1.InquiryStandardData
4018 [Controller->V1.DeviceStateChannel]
4019 [Controller->V1.DeviceStateTargetID];
4020 if (CommandStatus != DAC960_V1_NormalCompletion)
4022 memset(InquiryStandardData, 0,
4023 sizeof(DAC960_SCSI_Inquiry_T));
4024 InquiryStandardData->PeripheralDeviceType = 0x1F;
4027 memcpy(InquiryStandardData,
4028 Controller->V1.NewInquiryStandardData,
4029 sizeof(DAC960_SCSI_Inquiry_T));
4030 Controller->V1.NeedDeviceInquiryInformation = false;
4032 else if (Controller->V1.NeedDeviceSerialNumberInformation)
4034 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4035 &Controller->V1.InquiryUnitSerialNumber
4036 [Controller->V1.DeviceStateChannel]
4037 [Controller->V1.DeviceStateTargetID];
4038 if (CommandStatus != DAC960_V1_NormalCompletion)
4040 memset(InquiryUnitSerialNumber, 0,
4041 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4042 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4045 memcpy(InquiryUnitSerialNumber,
4046 Controller->V1.NewInquiryUnitSerialNumber,
4047 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4048 Controller->V1.NeedDeviceSerialNumberInformation = false;
4052 Begin submitting new monitoring commands.
4054 if (Controller->V1.NewEventLogSequenceNumber
4055 - Controller->V1.OldEventLogSequenceNumber > 0)
4057 Command->V1.CommandMailbox.Type3E.CommandOpcode =
4058 DAC960_V1_PerformEventLogOperation;
4059 Command->V1.CommandMailbox.Type3E.OperationType =
4060 DAC960_V1_GetEventLogEntry;
4061 Command->V1.CommandMailbox.Type3E.OperationQualifier = 1;
4062 Command->V1.CommandMailbox.Type3E.SequenceNumber =
4063 Controller->V1.OldEventLogSequenceNumber;
4064 Command->V1.CommandMailbox.Type3E.BusAddress =
4065 Controller->V1.EventLogEntryDMA;
4066 DAC960_QueueCommand(Command);
4069 if (Controller->V1.NeedErrorTableInformation)
4071 Controller->V1.NeedErrorTableInformation = false;
4072 Command->V1.CommandMailbox.Type3.CommandOpcode =
4073 DAC960_V1_GetErrorTable;
4074 Command->V1.CommandMailbox.Type3.BusAddress =
4075 Controller->V1.NewErrorTableDMA;
4076 DAC960_QueueCommand(Command);
4079 if (Controller->V1.NeedRebuildProgress &&
4080 Controller->V1.RebuildProgressFirst)
4082 Controller->V1.NeedRebuildProgress = false;
4083 Command->V1.CommandMailbox.Type3.CommandOpcode =
4084 DAC960_V1_GetRebuildProgress;
4085 Command->V1.CommandMailbox.Type3.BusAddress =
4086 Controller->V1.RebuildProgressDMA;
4087 DAC960_QueueCommand(Command);
4090 if (Controller->V1.NeedDeviceStateInformation)
4092 if (Controller->V1.NeedDeviceInquiryInformation)
4094 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4095 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4097 dma_addr_t NewInquiryStandardDataDMA =
4098 Controller->V1.NewInquiryStandardDataDMA;
4100 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4101 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4102 DCDB->Channel = Controller->V1.DeviceStateChannel;
4103 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4104 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4105 DCDB->EarlyStatus = false;
4106 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4107 DCDB->NoAutomaticRequestSense = false;
4108 DCDB->DisconnectPermitted = true;
4109 DCDB->TransferLength = sizeof(DAC960_SCSI_Inquiry_T);
4110 DCDB->BusAddress = NewInquiryStandardDataDMA;
4111 DCDB->CDBLength = 6;
4112 DCDB->TransferLengthHigh4 = 0;
4113 DCDB->SenseLength = sizeof(DCDB->SenseData);
4114 DCDB->CDB[0] = 0x12; /* INQUIRY */
4115 DCDB->CDB[1] = 0; /* EVPD = 0 */
4116 DCDB->CDB[2] = 0; /* Page Code */
4117 DCDB->CDB[3] = 0; /* Reserved */
4118 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_T);
4119 DCDB->CDB[5] = 0; /* Control */
4120 DAC960_QueueCommand(Command);
4123 if (Controller->V1.NeedDeviceSerialNumberInformation)
4125 DAC960_V1_DCDB_T *DCDB = Controller->V1.MonitoringDCDB;
4126 dma_addr_t DCDB_DMA = Controller->V1.MonitoringDCDB_DMA;
4127 dma_addr_t NewInquiryUnitSerialNumberDMA =
4128 Controller->V1.NewInquiryUnitSerialNumberDMA;
4130 Command->V1.CommandMailbox.Type3.CommandOpcode = DAC960_V1_DCDB;
4131 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_DMA;
4132 DCDB->Channel = Controller->V1.DeviceStateChannel;
4133 DCDB->TargetID = Controller->V1.DeviceStateTargetID;
4134 DCDB->Direction = DAC960_V1_DCDB_DataTransferDeviceToSystem;
4135 DCDB->EarlyStatus = false;
4136 DCDB->Timeout = DAC960_V1_DCDB_Timeout_10_seconds;
4137 DCDB->NoAutomaticRequestSense = false;
4138 DCDB->DisconnectPermitted = true;
4139 DCDB->TransferLength =
4140 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4141 DCDB->BusAddress = NewInquiryUnitSerialNumberDMA;
4142 DCDB->CDBLength = 6;
4143 DCDB->TransferLengthHigh4 = 0;
4144 DCDB->SenseLength = sizeof(DCDB->SenseData);
4145 DCDB->CDB[0] = 0x12; /* INQUIRY */
4146 DCDB->CDB[1] = 1; /* EVPD = 1 */
4147 DCDB->CDB[2] = 0x80; /* Page Code */
4148 DCDB->CDB[3] = 0; /* Reserved */
4149 DCDB->CDB[4] = sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T);
4150 DCDB->CDB[5] = 0; /* Control */
4151 DAC960_QueueCommand(Command);
4154 if (Controller->V1.StartDeviceStateScan)
4156 Controller->V1.DeviceStateChannel = 0;
4157 Controller->V1.DeviceStateTargetID = 0;
4158 Controller->V1.StartDeviceStateScan = false;
4160 else if (++Controller->V1.DeviceStateTargetID == Controller->Targets)
4162 Controller->V1.DeviceStateChannel++;
4163 Controller->V1.DeviceStateTargetID = 0;
4165 if (Controller->V1.DeviceStateChannel < Controller->Channels)
4167 Controller->V1.NewDeviceState->DeviceState =
4168 DAC960_V1_Device_Dead;
4169 Command->V1.CommandMailbox.Type3D.CommandOpcode =
4170 DAC960_V1_GetDeviceState;
4171 Command->V1.CommandMailbox.Type3D.Channel =
4172 Controller->V1.DeviceStateChannel;
4173 Command->V1.CommandMailbox.Type3D.TargetID =
4174 Controller->V1.DeviceStateTargetID;
4175 Command->V1.CommandMailbox.Type3D.BusAddress =
4176 Controller->V1.NewDeviceStateDMA;
4177 DAC960_QueueCommand(Command);
4180 Controller->V1.NeedDeviceStateInformation = false;
4182 if (Controller->V1.NeedLogicalDriveInformation)
4184 Controller->V1.NeedLogicalDriveInformation = false;
4185 Command->V1.CommandMailbox.Type3.CommandOpcode =
4186 DAC960_V1_GetLogicalDriveInformation;
4187 Command->V1.CommandMailbox.Type3.BusAddress =
4188 Controller->V1.NewLogicalDriveInformationDMA;
4189 DAC960_QueueCommand(Command);
4192 if (Controller->V1.NeedRebuildProgress)
4194 Controller->V1.NeedRebuildProgress = false;
4195 Command->V1.CommandMailbox.Type3.CommandOpcode =
4196 DAC960_V1_GetRebuildProgress;
4197 Command->V1.CommandMailbox.Type3.BusAddress =
4198 Controller->V1.RebuildProgressDMA;
4199 DAC960_QueueCommand(Command);
4202 if (Controller->V1.NeedConsistencyCheckProgress)
4204 Controller->V1.NeedConsistencyCheckProgress = false;
4205 Command->V1.CommandMailbox.Type3.CommandOpcode =
4206 DAC960_V1_RebuildStat;
4207 Command->V1.CommandMailbox.Type3.BusAddress =
4208 Controller->V1.RebuildProgressDMA;
4209 DAC960_QueueCommand(Command);
4212 if (Controller->V1.NeedBackgroundInitializationStatus)
4214 Controller->V1.NeedBackgroundInitializationStatus = false;
4215 Command->V1.CommandMailbox.Type3B.CommandOpcode =
4216 DAC960_V1_BackgroundInitializationControl;
4217 Command->V1.CommandMailbox.Type3B.CommandOpcode2 = 0x20;
4218 Command->V1.CommandMailbox.Type3B.BusAddress =
4219 Controller->V1.BackgroundInitializationStatusDMA;
4220 DAC960_QueueCommand(Command);
4223 Controller->MonitoringTimerCount++;
4224 Controller->MonitoringTimer.expires =
4225 jiffies + DAC960_MonitoringTimerInterval;
4226 add_timer(&Controller->MonitoringTimer);
4228 if (CommandType == DAC960_ImmediateCommand)
4230 complete(Command->Completion);
4231 Command->Completion = NULL;
4234 if (CommandType == DAC960_QueuedCommand)
4236 DAC960_V1_KernelCommand_T *KernelCommand = Command->V1.KernelCommand;
4237 KernelCommand->CommandStatus = Command->V1.CommandStatus;
4238 Command->V1.KernelCommand = NULL;
4239 if (CommandOpcode == DAC960_V1_DCDB)
4240 Controller->V1.DirectCommandActive[KernelCommand->DCDB->Channel]
4241 [KernelCommand->DCDB->TargetID] =
4243 DAC960_DeallocateCommand(Command);
4244 KernelCommand->CompletionFunction(KernelCommand);
4248 Queue a Status Monitoring Command to the Controller using the just
4249 completed Command if one was deferred previously due to lack of a
4250 free Command when the Monitoring Timer Function was called.
4252 if (Controller->MonitoringCommandDeferred)
4254 Controller->MonitoringCommandDeferred = false;
4255 DAC960_V1_QueueMonitoringCommand(Command);
4259 Deallocate the Command.
4261 DAC960_DeallocateCommand(Command);
4263 Wake up any processes waiting on a free Command.
4265 wake_up(&Controller->CommandWaitQueue);
4270 DAC960_V2_ReadWriteError prints an appropriate error message for Command
4271 when an error occurs on a Read or Write operation.
4274 static void DAC960_V2_ReadWriteError(DAC960_Command_T *Command)
4276 DAC960_Controller_T *Controller = Command->Controller;
4277 unsigned char *SenseErrors[] = { "NO SENSE", "RECOVERED ERROR",
4278 "NOT READY", "MEDIUM ERROR",
4279 "HARDWARE ERROR", "ILLEGAL REQUEST",
4280 "UNIT ATTENTION", "DATA PROTECT",
4281 "BLANK CHECK", "VENDOR-SPECIFIC",
4282 "COPY ABORTED", "ABORTED COMMAND",
4283 "EQUAL", "VOLUME OVERFLOW",
4284 "MISCOMPARE", "RESERVED" };
4285 unsigned char *CommandName = "UNKNOWN";
4286 switch (Command->CommandType)
4288 case DAC960_ReadCommand:
4289 case DAC960_ReadRetryCommand:
4290 CommandName = "READ";
4292 case DAC960_WriteCommand:
4293 case DAC960_WriteRetryCommand:
4294 CommandName = "WRITE";
4296 case DAC960_MonitoringCommand:
4297 case DAC960_ImmediateCommand:
4298 case DAC960_QueuedCommand:
4301 DAC960_Error("Error Condition %s on %s:\n", Controller,
4302 SenseErrors[Command->V2.RequestSense->SenseKey], CommandName);
4303 DAC960_Error(" /dev/rd/c%dd%d: absolute blocks %u..%u\n",
4304 Controller, Controller->ControllerNumber,
4305 Command->LogicalDriveNumber, Command->BlockNumber,
4306 Command->BlockNumber + Command->BlockCount - 1);
4311 DAC960_V2_ReportEvent prints an appropriate message when a Controller Event
4315 static void DAC960_V2_ReportEvent(DAC960_Controller_T *Controller,
4316 DAC960_V2_Event_T *Event)
4318 DAC960_SCSI_RequestSense_T *RequestSense =
4319 (DAC960_SCSI_RequestSense_T *) &Event->RequestSenseData;
4320 unsigned char MessageBuffer[DAC960_LineBufferSize];
4321 static struct { int EventCode; unsigned char *EventMessage; } EventList[] =
4322 { /* Physical Device Events (0x0000 - 0x007F) */
4323 { 0x0001, "P Online" },
4324 { 0x0002, "P Standby" },
4325 { 0x0005, "P Automatic Rebuild Started" },
4326 { 0x0006, "P Manual Rebuild Started" },
4327 { 0x0007, "P Rebuild Completed" },
4328 { 0x0008, "P Rebuild Cancelled" },
4329 { 0x0009, "P Rebuild Failed for Unknown Reasons" },
4330 { 0x000A, "P Rebuild Failed due to New Physical Device" },
4331 { 0x000B, "P Rebuild Failed due to Logical Drive Failure" },
4332 { 0x000C, "S Offline" },
4333 { 0x000D, "P Found" },
4334 { 0x000E, "P Removed" },
4335 { 0x000F, "P Unconfigured" },
4336 { 0x0010, "P Expand Capacity Started" },
4337 { 0x0011, "P Expand Capacity Completed" },
4338 { 0x0012, "P Expand Capacity Failed" },
4339 { 0x0013, "P Command Timed Out" },
4340 { 0x0014, "P Command Aborted" },
4341 { 0x0015, "P Command Retried" },
4342 { 0x0016, "P Parity Error" },
4343 { 0x0017, "P Soft Error" },
4344 { 0x0018, "P Miscellaneous Error" },
4345 { 0x0019, "P Reset" },
4346 { 0x001A, "P Active Spare Found" },
4347 { 0x001B, "P Warm Spare Found" },
4348 { 0x001C, "S Sense Data Received" },
4349 { 0x001D, "P Initialization Started" },
4350 { 0x001E, "P Initialization Completed" },
4351 { 0x001F, "P Initialization Failed" },
4352 { 0x0020, "P Initialization Cancelled" },
4353 { 0x0021, "P Failed because Write Recovery Failed" },
4354 { 0x0022, "P Failed because SCSI Bus Reset Failed" },
4355 { 0x0023, "P Failed because of Double Check Condition" },
4356 { 0x0024, "P Failed because Device Cannot Be Accessed" },
4357 { 0x0025, "P Failed because of Gross Error on SCSI Processor" },
4358 { 0x0026, "P Failed because of Bad Tag from Device" },
4359 { 0x0027, "P Failed because of Command Timeout" },
4360 { 0x0028, "P Failed because of System Reset" },
4361 { 0x0029, "P Failed because of Busy Status or Parity Error" },
4362 { 0x002A, "P Failed because Host Set Device to Failed State" },
4363 { 0x002B, "P Failed because of Selection Timeout" },
4364 { 0x002C, "P Failed because of SCSI Bus Phase Error" },
4365 { 0x002D, "P Failed because Device Returned Unknown Status" },
4366 { 0x002E, "P Failed because Device Not Ready" },
4367 { 0x002F, "P Failed because Device Not Found at Startup" },
4368 { 0x0030, "P Failed because COD Write Operation Failed" },
4369 { 0x0031, "P Failed because BDT Write Operation Failed" },
4370 { 0x0039, "P Missing at Startup" },
4371 { 0x003A, "P Start Rebuild Failed due to Physical Drive Too Small" },
4372 { 0x003C, "P Temporarily Offline Device Automatically Made Online" },
4373 { 0x003D, "P Standby Rebuild Started" },
4374 /* Logical Device Events (0x0080 - 0x00FF) */
4375 { 0x0080, "M Consistency Check Started" },
4376 { 0x0081, "M Consistency Check Completed" },
4377 { 0x0082, "M Consistency Check Cancelled" },
4378 { 0x0083, "M Consistency Check Completed With Errors" },
4379 { 0x0084, "M Consistency Check Failed due to Logical Drive Failure" },
4380 { 0x0085, "M Consistency Check Failed due to Physical Device Failure" },
4381 { 0x0086, "L Offline" },
4382 { 0x0087, "L Critical" },
4383 { 0x0088, "L Online" },
4384 { 0x0089, "M Automatic Rebuild Started" },
4385 { 0x008A, "M Manual Rebuild Started" },
4386 { 0x008B, "M Rebuild Completed" },
4387 { 0x008C, "M Rebuild Cancelled" },
4388 { 0x008D, "M Rebuild Failed for Unknown Reasons" },
4389 { 0x008E, "M Rebuild Failed due to New Physical Device" },
4390 { 0x008F, "M Rebuild Failed due to Logical Drive Failure" },
4391 { 0x0090, "M Initialization Started" },
4392 { 0x0091, "M Initialization Completed" },
4393 { 0x0092, "M Initialization Cancelled" },
4394 { 0x0093, "M Initialization Failed" },
4395 { 0x0094, "L Found" },
4396 { 0x0095, "L Deleted" },
4397 { 0x0096, "M Expand Capacity Started" },
4398 { 0x0097, "M Expand Capacity Completed" },
4399 { 0x0098, "M Expand Capacity Failed" },
4400 { 0x0099, "L Bad Block Found" },
4401 { 0x009A, "L Size Changed" },
4402 { 0x009B, "L Type Changed" },
4403 { 0x009C, "L Bad Data Block Found" },
4404 { 0x009E, "L Read of Data Block in BDT" },
4405 { 0x009F, "L Write Back Data for Disk Block Lost" },
4406 { 0x00A0, "L Temporarily Offline RAID-5/3 Drive Made Online" },
4407 { 0x00A1, "L Temporarily Offline RAID-6/1/0/7 Drive Made Online" },
4408 { 0x00A2, "L Standby Rebuild Started" },
4409 /* Fault Management Events (0x0100 - 0x017F) */
4410 { 0x0140, "E Fan %d Failed" },
4411 { 0x0141, "E Fan %d OK" },
4412 { 0x0142, "E Fan %d Not Present" },
4413 { 0x0143, "E Power Supply %d Failed" },
4414 { 0x0144, "E Power Supply %d OK" },
4415 { 0x0145, "E Power Supply %d Not Present" },
4416 { 0x0146, "E Temperature Sensor %d Temperature Exceeds Safe Limit" },
4417 { 0x0147, "E Temperature Sensor %d Temperature Exceeds Working Limit" },
4418 { 0x0148, "E Temperature Sensor %d Temperature Normal" },
4419 { 0x0149, "E Temperature Sensor %d Not Present" },
4420 { 0x014A, "E Enclosure Management Unit %d Access Critical" },
4421 { 0x014B, "E Enclosure Management Unit %d Access OK" },
4422 { 0x014C, "E Enclosure Management Unit %d Access Offline" },
4423 /* Controller Events (0x0180 - 0x01FF) */
4424 { 0x0181, "C Cache Write Back Error" },
4425 { 0x0188, "C Battery Backup Unit Found" },
4426 { 0x0189, "C Battery Backup Unit Charge Level Low" },
4427 { 0x018A, "C Battery Backup Unit Charge Level OK" },
4428 { 0x0193, "C Installation Aborted" },
4429 { 0x0195, "C Battery Backup Unit Physically Removed" },
4430 { 0x0196, "C Memory Error During Warm Boot" },
4431 { 0x019E, "C Memory Soft ECC Error Corrected" },
4432 { 0x019F, "C Memory Hard ECC Error Corrected" },
4433 { 0x01A2, "C Battery Backup Unit Failed" },
4434 { 0x01AB, "C Mirror Race Recovery Failed" },
4435 { 0x01AC, "C Mirror Race on Critical Drive" },
4436 /* Controller Internal Processor Events */
4437 { 0x0380, "C Internal Controller Hung" },
4438 { 0x0381, "C Internal Controller Firmware Breakpoint" },
4439 { 0x0390, "C Internal Controller i960 Processor Specific Error" },
4440 { 0x03A0, "C Internal Controller StrongARM Processor Specific Error" },
4442 int EventListIndex = 0, EventCode;
4443 unsigned char EventType, *EventMessage;
4444 if (Event->EventCode == 0x1C &&
4445 RequestSense->SenseKey == DAC960_SenseKey_VendorSpecific &&
4446 (RequestSense->AdditionalSenseCode == 0x80 ||
4447 RequestSense->AdditionalSenseCode == 0x81))
4448 Event->EventCode = ((RequestSense->AdditionalSenseCode - 0x80) << 8) |
4449 RequestSense->AdditionalSenseCodeQualifier;
4452 EventCode = EventList[EventListIndex].EventCode;
4453 if (EventCode == Event->EventCode || EventCode == 0) break;
4456 EventType = EventList[EventListIndex].EventMessage[0];
4457 EventMessage = &EventList[EventListIndex].EventMessage[2];
4460 DAC960_Critical("Unknown Controller Event Code %04X\n",
4461 Controller, Event->EventCode);
4467 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4468 Event->Channel, Event->TargetID, EventMessage);
4471 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4472 Event->LogicalUnit, Controller->ControllerNumber,
4473 Event->LogicalUnit, EventMessage);
4476 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) %s\n", Controller,
4477 Event->LogicalUnit, Controller->ControllerNumber,
4478 Event->LogicalUnit, EventMessage);
4481 if (RequestSense->SenseKey == DAC960_SenseKey_NoSense ||
4482 (RequestSense->SenseKey == DAC960_SenseKey_NotReady &&
4483 RequestSense->AdditionalSenseCode == 0x04 &&
4484 (RequestSense->AdditionalSenseCodeQualifier == 0x01 ||
4485 RequestSense->AdditionalSenseCodeQualifier == 0x02)))
4487 DAC960_Critical("Physical Device %d:%d %s\n", Controller,
4488 Event->Channel, Event->TargetID, EventMessage);
4489 DAC960_Critical("Physical Device %d:%d Request Sense: "
4490 "Sense Key = %X, ASC = %02X, ASCQ = %02X\n",
4494 RequestSense->SenseKey,
4495 RequestSense->AdditionalSenseCode,
4496 RequestSense->AdditionalSenseCodeQualifier);
4497 DAC960_Critical("Physical Device %d:%d Request Sense: "
4498 "Information = %02X%02X%02X%02X "
4499 "%02X%02X%02X%02X\n",
4503 RequestSense->Information[0],
4504 RequestSense->Information[1],
4505 RequestSense->Information[2],
4506 RequestSense->Information[3],
4507 RequestSense->CommandSpecificInformation[0],
4508 RequestSense->CommandSpecificInformation[1],
4509 RequestSense->CommandSpecificInformation[2],
4510 RequestSense->CommandSpecificInformation[3]);
4513 if (Controller->SuppressEnclosureMessages) break;
4514 sprintf(MessageBuffer, EventMessage, Event->LogicalUnit);
4515 DAC960_Critical("Enclosure %d %s\n", Controller,
4516 Event->TargetID, MessageBuffer);
4519 DAC960_Critical("Controller %s\n", Controller, EventMessage);
4522 DAC960_Critical("Unknown Controller Event Code %04X\n",
4523 Controller, Event->EventCode);
4530 DAC960_V2_ReportProgress prints an appropriate progress message for
4531 Logical Device Long Operations.
4534 static void DAC960_V2_ReportProgress(DAC960_Controller_T *Controller,
4535 unsigned char *MessageString,
4536 unsigned int LogicalDeviceNumber,
4537 unsigned long BlocksCompleted,
4538 unsigned long LogicalDeviceSize)
4540 Controller->EphemeralProgressMessage = true;
4541 DAC960_Progress("%s in Progress: Logical Drive %d (/dev/rd/c%dd%d) "
4542 "%d%% completed\n", Controller,
4544 LogicalDeviceNumber,
4545 Controller->ControllerNumber,
4546 LogicalDeviceNumber,
4547 (100 * (BlocksCompleted >> 7)) / (LogicalDeviceSize >> 7));
4548 Controller->EphemeralProgressMessage = false;
4553 DAC960_V2_ProcessCompletedCommand performs completion processing for Command
4554 for DAC960 V2 Firmware Controllers.
4557 static void DAC960_V2_ProcessCompletedCommand(DAC960_Command_T *Command)
4559 DAC960_Controller_T *Controller = Command->Controller;
4560 DAC960_CommandType_T CommandType = Command->CommandType;
4561 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
4562 DAC960_V2_IOCTL_Opcode_T CommandOpcode = CommandMailbox->Common.IOCTL_Opcode;
4563 DAC960_V2_CommandStatus_T CommandStatus = Command->V2.CommandStatus;
4565 if (CommandType == DAC960_ReadCommand ||
4566 CommandType == DAC960_WriteCommand)
4569 #ifdef FORCE_RETRY_DEBUG
4570 CommandStatus = DAC960_V2_AbormalCompletion;
4572 Command->V2.RequestSense->SenseKey = DAC960_SenseKey_MediumError;
4574 if (CommandStatus == DAC960_V2_NormalCompletion) {
4576 if (!DAC960_ProcessCompletedRequest(Command, true))
4579 } else if (Command->V2.RequestSense->SenseKey == DAC960_SenseKey_MediumError)
4582 * break the command down into pieces and resubmit each
4583 * piece, hoping that some of them will succeed.
4585 DAC960_queue_partial_rw(Command);
4590 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4591 DAC960_V2_ReadWriteError(Command);
4593 Perform completion processing for all buffers in this I/O Request.
4595 (void)DAC960_ProcessCompletedRequest(Command, false);
4598 else if (CommandType == DAC960_ReadRetryCommand ||
4599 CommandType == DAC960_WriteRetryCommand)
4601 boolean normal_completion;
4603 #ifdef FORCE_RETRY_FAILURE_DEBUG
4604 static int retry_count = 1;
4607 Perform completion processing for the portion that was
4608 retried, and submit the next portion, if any.
4610 normal_completion = true;
4611 if (CommandStatus != DAC960_V2_NormalCompletion) {
4612 normal_completion = false;
4613 if (Command->V2.RequestSense->SenseKey != DAC960_SenseKey_NotReady)
4614 DAC960_V2_ReadWriteError(Command);
4617 #ifdef FORCE_RETRY_FAILURE_DEBUG
4618 if (!(++retry_count % 10000)) {
4619 printk("V2 error retry failure test\n");
4620 normal_completion = false;
4621 DAC960_V2_ReadWriteError(Command);
4625 if (!DAC960_ProcessCompletedRequest(Command, normal_completion)) {
4626 DAC960_queue_partial_rw(Command);
4630 else if (CommandType == DAC960_MonitoringCommand)
4632 if (Controller->ShutdownMonitoringTimer)
4634 if (CommandOpcode == DAC960_V2_GetControllerInfo)
4636 DAC960_V2_ControllerInfo_T *NewControllerInfo =
4637 Controller->V2.NewControllerInformation;
4638 DAC960_V2_ControllerInfo_T *ControllerInfo =
4639 &Controller->V2.ControllerInformation;
4640 Controller->LogicalDriveCount =
4641 NewControllerInfo->LogicalDevicesPresent;
4642 Controller->V2.NeedLogicalDeviceInformation = true;
4643 Controller->V2.NeedPhysicalDeviceInformation = true;
4644 Controller->V2.StartLogicalDeviceInformationScan = true;
4645 Controller->V2.StartPhysicalDeviceInformationScan = true;
4646 Controller->MonitoringAlertMode =
4647 (NewControllerInfo->LogicalDevicesCritical > 0 ||
4648 NewControllerInfo->LogicalDevicesOffline > 0 ||
4649 NewControllerInfo->PhysicalDisksCritical > 0 ||
4650 NewControllerInfo->PhysicalDisksOffline > 0);
4651 memcpy(ControllerInfo, NewControllerInfo,
4652 sizeof(DAC960_V2_ControllerInfo_T));
4654 else if (CommandOpcode == DAC960_V2_GetEvent)
4656 if (CommandStatus == DAC960_V2_NormalCompletion) {
4657 DAC960_V2_ReportEvent(Controller, Controller->V2.Event);
4659 Controller->V2.NextEventSequenceNumber++;
4661 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid &&
4662 CommandStatus == DAC960_V2_NormalCompletion)
4664 DAC960_V2_PhysicalDeviceInfo_T *NewPhysicalDeviceInfo =
4665 Controller->V2.NewPhysicalDeviceInformation;
4666 unsigned int PhysicalDeviceIndex = Controller->V2.PhysicalDeviceIndex;
4667 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4668 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4669 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4670 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4671 unsigned int DeviceIndex;
4672 while (PhysicalDeviceInfo != NULL &&
4673 (NewPhysicalDeviceInfo->Channel >
4674 PhysicalDeviceInfo->Channel ||
4675 (NewPhysicalDeviceInfo->Channel ==
4676 PhysicalDeviceInfo->Channel &&
4677 (NewPhysicalDeviceInfo->TargetID >
4678 PhysicalDeviceInfo->TargetID ||
4679 (NewPhysicalDeviceInfo->TargetID ==
4680 PhysicalDeviceInfo->TargetID &&
4681 NewPhysicalDeviceInfo->LogicalUnit >
4682 PhysicalDeviceInfo->LogicalUnit)))))
4684 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4686 PhysicalDeviceInfo->Channel,
4687 PhysicalDeviceInfo->TargetID);
4688 Controller->V2.PhysicalDeviceInformation
4689 [PhysicalDeviceIndex] = NULL;
4690 Controller->V2.InquiryUnitSerialNumber
4691 [PhysicalDeviceIndex] = NULL;
4692 kfree(PhysicalDeviceInfo);
4693 kfree(InquiryUnitSerialNumber);
4694 for (DeviceIndex = PhysicalDeviceIndex;
4695 DeviceIndex < DAC960_V2_MaxPhysicalDevices - 1;
4698 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4699 Controller->V2.PhysicalDeviceInformation[DeviceIndex+1];
4700 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4701 Controller->V2.InquiryUnitSerialNumber[DeviceIndex+1];
4703 Controller->V2.PhysicalDeviceInformation
4704 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4705 Controller->V2.InquiryUnitSerialNumber
4706 [DAC960_V2_MaxPhysicalDevices-1] = NULL;
4707 PhysicalDeviceInfo =
4708 Controller->V2.PhysicalDeviceInformation[PhysicalDeviceIndex];
4709 InquiryUnitSerialNumber =
4710 Controller->V2.InquiryUnitSerialNumber[PhysicalDeviceIndex];
4712 if (PhysicalDeviceInfo == NULL ||
4713 (NewPhysicalDeviceInfo->Channel !=
4714 PhysicalDeviceInfo->Channel) ||
4715 (NewPhysicalDeviceInfo->TargetID !=
4716 PhysicalDeviceInfo->TargetID) ||
4717 (NewPhysicalDeviceInfo->LogicalUnit !=
4718 PhysicalDeviceInfo->LogicalUnit))
4720 PhysicalDeviceInfo = (DAC960_V2_PhysicalDeviceInfo_T *)
4721 kmalloc(sizeof(DAC960_V2_PhysicalDeviceInfo_T), GFP_ATOMIC);
4722 InquiryUnitSerialNumber =
4723 (DAC960_SCSI_Inquiry_UnitSerialNumber_T *)
4724 kmalloc(sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T),
4726 if (InquiryUnitSerialNumber == NULL &&
4727 PhysicalDeviceInfo != NULL)
4729 kfree(PhysicalDeviceInfo);
4730 PhysicalDeviceInfo = NULL;
4732 DAC960_Critical("Physical Device %d:%d Now Exists%s\n",
4734 NewPhysicalDeviceInfo->Channel,
4735 NewPhysicalDeviceInfo->TargetID,
4736 (PhysicalDeviceInfo != NULL
4737 ? "" : " - Allocation Failed"));
4738 if (PhysicalDeviceInfo != NULL)
4740 memset(PhysicalDeviceInfo, 0,
4741 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4742 PhysicalDeviceInfo->PhysicalDeviceState =
4743 DAC960_V2_Device_InvalidState;
4744 memset(InquiryUnitSerialNumber, 0,
4745 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
4746 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
4747 for (DeviceIndex = DAC960_V2_MaxPhysicalDevices - 1;
4748 DeviceIndex > PhysicalDeviceIndex;
4751 Controller->V2.PhysicalDeviceInformation[DeviceIndex] =
4752 Controller->V2.PhysicalDeviceInformation[DeviceIndex-1];
4753 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] =
4754 Controller->V2.InquiryUnitSerialNumber[DeviceIndex-1];
4756 Controller->V2.PhysicalDeviceInformation
4757 [PhysicalDeviceIndex] =
4759 Controller->V2.InquiryUnitSerialNumber
4760 [PhysicalDeviceIndex] =
4761 InquiryUnitSerialNumber;
4762 Controller->V2.NeedDeviceSerialNumberInformation = true;
4765 if (PhysicalDeviceInfo != NULL)
4767 if (NewPhysicalDeviceInfo->PhysicalDeviceState !=
4768 PhysicalDeviceInfo->PhysicalDeviceState)
4770 "Physical Device %d:%d is now %s\n", Controller,
4771 NewPhysicalDeviceInfo->Channel,
4772 NewPhysicalDeviceInfo->TargetID,
4773 (NewPhysicalDeviceInfo->PhysicalDeviceState
4774 == DAC960_V2_Device_Online
4776 : NewPhysicalDeviceInfo->PhysicalDeviceState
4777 == DAC960_V2_Device_Rebuild
4779 : NewPhysicalDeviceInfo->PhysicalDeviceState
4780 == DAC960_V2_Device_Missing
4782 : NewPhysicalDeviceInfo->PhysicalDeviceState
4783 == DAC960_V2_Device_Critical
4785 : NewPhysicalDeviceInfo->PhysicalDeviceState
4786 == DAC960_V2_Device_Dead
4788 : NewPhysicalDeviceInfo->PhysicalDeviceState
4789 == DAC960_V2_Device_SuspectedDead
4791 : NewPhysicalDeviceInfo->PhysicalDeviceState
4792 == DAC960_V2_Device_CommandedOffline
4793 ? "COMMANDED-OFFLINE"
4794 : NewPhysicalDeviceInfo->PhysicalDeviceState
4795 == DAC960_V2_Device_Standby
4796 ? "STANDBY" : "UNKNOWN"));
4797 if ((NewPhysicalDeviceInfo->ParityErrors !=
4798 PhysicalDeviceInfo->ParityErrors) ||
4799 (NewPhysicalDeviceInfo->SoftErrors !=
4800 PhysicalDeviceInfo->SoftErrors) ||
4801 (NewPhysicalDeviceInfo->HardErrors !=
4802 PhysicalDeviceInfo->HardErrors) ||
4803 (NewPhysicalDeviceInfo->MiscellaneousErrors !=
4804 PhysicalDeviceInfo->MiscellaneousErrors) ||
4805 (NewPhysicalDeviceInfo->CommandTimeouts !=
4806 PhysicalDeviceInfo->CommandTimeouts) ||
4807 (NewPhysicalDeviceInfo->Retries !=
4808 PhysicalDeviceInfo->Retries) ||
4809 (NewPhysicalDeviceInfo->Aborts !=
4810 PhysicalDeviceInfo->Aborts) ||
4811 (NewPhysicalDeviceInfo->PredictedFailuresDetected !=
4812 PhysicalDeviceInfo->PredictedFailuresDetected))
4814 DAC960_Critical("Physical Device %d:%d Errors: "
4815 "Parity = %d, Soft = %d, "
4816 "Hard = %d, Misc = %d\n",
4818 NewPhysicalDeviceInfo->Channel,
4819 NewPhysicalDeviceInfo->TargetID,
4820 NewPhysicalDeviceInfo->ParityErrors,
4821 NewPhysicalDeviceInfo->SoftErrors,
4822 NewPhysicalDeviceInfo->HardErrors,
4823 NewPhysicalDeviceInfo->MiscellaneousErrors);
4824 DAC960_Critical("Physical Device %d:%d Errors: "
4825 "Timeouts = %d, Retries = %d, "
4826 "Aborts = %d, Predicted = %d\n",
4828 NewPhysicalDeviceInfo->Channel,
4829 NewPhysicalDeviceInfo->TargetID,
4830 NewPhysicalDeviceInfo->CommandTimeouts,
4831 NewPhysicalDeviceInfo->Retries,
4832 NewPhysicalDeviceInfo->Aborts,
4833 NewPhysicalDeviceInfo
4834 ->PredictedFailuresDetected);
4836 if ((PhysicalDeviceInfo->PhysicalDeviceState
4837 == DAC960_V2_Device_Dead ||
4838 PhysicalDeviceInfo->PhysicalDeviceState
4839 == DAC960_V2_Device_InvalidState) &&
4840 NewPhysicalDeviceInfo->PhysicalDeviceState
4841 != DAC960_V2_Device_Dead)
4842 Controller->V2.NeedDeviceSerialNumberInformation = true;
4843 memcpy(PhysicalDeviceInfo, NewPhysicalDeviceInfo,
4844 sizeof(DAC960_V2_PhysicalDeviceInfo_T));
4846 NewPhysicalDeviceInfo->LogicalUnit++;
4847 Controller->V2.PhysicalDeviceIndex++;
4849 else if (CommandOpcode == DAC960_V2_GetPhysicalDeviceInfoValid)
4851 unsigned int DeviceIndex;
4852 for (DeviceIndex = Controller->V2.PhysicalDeviceIndex;
4853 DeviceIndex < DAC960_V2_MaxPhysicalDevices;
4856 DAC960_V2_PhysicalDeviceInfo_T *PhysicalDeviceInfo =
4857 Controller->V2.PhysicalDeviceInformation[DeviceIndex];
4858 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
4859 Controller->V2.InquiryUnitSerialNumber[DeviceIndex];
4860 if (PhysicalDeviceInfo == NULL) break;
4861 DAC960_Critical("Physical Device %d:%d No Longer Exists\n",
4863 PhysicalDeviceInfo->Channel,
4864 PhysicalDeviceInfo->TargetID);
4865 Controller->V2.PhysicalDeviceInformation[DeviceIndex] = NULL;
4866 Controller->V2.InquiryUnitSerialNumber[DeviceIndex] = NULL;
4867 kfree(PhysicalDeviceInfo);
4868 kfree(InquiryUnitSerialNumber);
4870 Controller->V2.NeedPhysicalDeviceInformation = false;
4872 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid &&
4873 CommandStatus == DAC960_V2_NormalCompletion)
4875 DAC960_V2_LogicalDeviceInfo_T *NewLogicalDeviceInfo =
4876 Controller->V2.NewLogicalDeviceInformation;
4877 unsigned short LogicalDeviceNumber =
4878 NewLogicalDeviceInfo->LogicalDeviceNumber;
4879 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
4880 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber];
4881 if (LogicalDeviceInfo == NULL)
4883 DAC960_V2_PhysicalDevice_T PhysicalDevice;
4884 PhysicalDevice.Controller = 0;
4885 PhysicalDevice.Channel = NewLogicalDeviceInfo->Channel;
4886 PhysicalDevice.TargetID = NewLogicalDeviceInfo->TargetID;
4887 PhysicalDevice.LogicalUnit = NewLogicalDeviceInfo->LogicalUnit;
4888 Controller->V2.LogicalDriveToVirtualDevice[LogicalDeviceNumber] =
4890 LogicalDeviceInfo = (DAC960_V2_LogicalDeviceInfo_T *)
4891 kmalloc(sizeof(DAC960_V2_LogicalDeviceInfo_T), GFP_ATOMIC);
4892 Controller->V2.LogicalDeviceInformation[LogicalDeviceNumber] =
4894 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4895 "Now Exists%s\n", Controller,
4896 LogicalDeviceNumber,
4897 Controller->ControllerNumber,
4898 LogicalDeviceNumber,
4899 (LogicalDeviceInfo != NULL
4900 ? "" : " - Allocation Failed"));
4901 if (LogicalDeviceInfo != NULL)
4903 memset(LogicalDeviceInfo, 0,
4904 sizeof(DAC960_V2_LogicalDeviceInfo_T));
4905 DAC960_ComputeGenericDiskInfo(Controller);
4908 if (LogicalDeviceInfo != NULL)
4910 unsigned long LogicalDeviceSize =
4911 NewLogicalDeviceInfo->ConfigurableDeviceSize;
4912 if (NewLogicalDeviceInfo->LogicalDeviceState !=
4913 LogicalDeviceInfo->LogicalDeviceState)
4914 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
4915 "is now %s\n", Controller,
4916 LogicalDeviceNumber,
4917 Controller->ControllerNumber,
4918 LogicalDeviceNumber,
4919 (NewLogicalDeviceInfo->LogicalDeviceState
4920 == DAC960_V2_LogicalDevice_Online
4922 : NewLogicalDeviceInfo->LogicalDeviceState
4923 == DAC960_V2_LogicalDevice_Critical
4924 ? "CRITICAL" : "OFFLINE"));
4925 if ((NewLogicalDeviceInfo->SoftErrors !=
4926 LogicalDeviceInfo->SoftErrors) ||
4927 (NewLogicalDeviceInfo->CommandsFailed !=
4928 LogicalDeviceInfo->CommandsFailed) ||
4929 (NewLogicalDeviceInfo->DeferredWriteErrors !=
4930 LogicalDeviceInfo->DeferredWriteErrors))
4931 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) Errors: "
4932 "Soft = %d, Failed = %d, Deferred Write = %d\n",
4933 Controller, LogicalDeviceNumber,
4934 Controller->ControllerNumber,
4935 LogicalDeviceNumber,
4936 NewLogicalDeviceInfo->SoftErrors,
4937 NewLogicalDeviceInfo->CommandsFailed,
4938 NewLogicalDeviceInfo->DeferredWriteErrors);
4939 if (NewLogicalDeviceInfo->ConsistencyCheckInProgress)
4940 DAC960_V2_ReportProgress(Controller,
4941 "Consistency Check",
4942 LogicalDeviceNumber,
4943 NewLogicalDeviceInfo
4944 ->ConsistencyCheckBlockNumber,
4946 else if (NewLogicalDeviceInfo->RebuildInProgress)
4947 DAC960_V2_ReportProgress(Controller,
4949 LogicalDeviceNumber,
4950 NewLogicalDeviceInfo
4951 ->RebuildBlockNumber,
4953 else if (NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4954 DAC960_V2_ReportProgress(Controller,
4955 "Background Initialization",
4956 LogicalDeviceNumber,
4957 NewLogicalDeviceInfo
4958 ->BackgroundInitializationBlockNumber,
4960 else if (NewLogicalDeviceInfo->ForegroundInitializationInProgress)
4961 DAC960_V2_ReportProgress(Controller,
4962 "Foreground Initialization",
4963 LogicalDeviceNumber,
4964 NewLogicalDeviceInfo
4965 ->ForegroundInitializationBlockNumber,
4967 else if (NewLogicalDeviceInfo->DataMigrationInProgress)
4968 DAC960_V2_ReportProgress(Controller,
4970 LogicalDeviceNumber,
4971 NewLogicalDeviceInfo
4972 ->DataMigrationBlockNumber,
4974 else if (NewLogicalDeviceInfo->PatrolOperationInProgress)
4975 DAC960_V2_ReportProgress(Controller,
4977 LogicalDeviceNumber,
4978 NewLogicalDeviceInfo
4979 ->PatrolOperationBlockNumber,
4981 if (LogicalDeviceInfo->BackgroundInitializationInProgress &&
4982 !NewLogicalDeviceInfo->BackgroundInitializationInProgress)
4983 DAC960_Progress("Logical Drive %d (/dev/rd/c%dd%d) "
4984 "Background Initialization %s\n",
4986 LogicalDeviceNumber,
4987 Controller->ControllerNumber,
4988 LogicalDeviceNumber,
4989 (NewLogicalDeviceInfo->LogicalDeviceControl
4990 .LogicalDeviceInitialized
4991 ? "Completed" : "Failed"));
4992 memcpy(LogicalDeviceInfo, NewLogicalDeviceInfo,
4993 sizeof(DAC960_V2_LogicalDeviceInfo_T));
4995 Controller->V2.LogicalDriveFoundDuringScan
4996 [LogicalDeviceNumber] = true;
4997 NewLogicalDeviceInfo->LogicalDeviceNumber++;
4999 else if (CommandOpcode == DAC960_V2_GetLogicalDeviceInfoValid)
5001 int LogicalDriveNumber;
5002 for (LogicalDriveNumber = 0;
5003 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5004 LogicalDriveNumber++)
5006 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
5007 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
5008 if (LogicalDeviceInfo == NULL ||
5009 Controller->V2.LogicalDriveFoundDuringScan
5010 [LogicalDriveNumber])
5012 DAC960_Critical("Logical Drive %d (/dev/rd/c%dd%d) "
5013 "No Longer Exists\n", Controller,
5015 Controller->ControllerNumber,
5016 LogicalDriveNumber);
5017 Controller->V2.LogicalDeviceInformation
5018 [LogicalDriveNumber] = NULL;
5019 kfree(LogicalDeviceInfo);
5020 Controller->LogicalDriveInitiallyAccessible
5021 [LogicalDriveNumber] = false;
5022 DAC960_ComputeGenericDiskInfo(Controller);
5024 Controller->V2.NeedLogicalDeviceInformation = false;
5026 else if (CommandOpcode == DAC960_V2_SCSI_10_Passthru)
5028 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
5029 Controller->V2.InquiryUnitSerialNumber[Controller->V2.PhysicalDeviceIndex - 1];
5031 if (CommandStatus != DAC960_V2_NormalCompletion) {
5032 memset(InquiryUnitSerialNumber,
5033 0, sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5034 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5036 memcpy(InquiryUnitSerialNumber,
5037 Controller->V2.NewInquiryUnitSerialNumber,
5038 sizeof(DAC960_SCSI_Inquiry_UnitSerialNumber_T));
5040 Controller->V2.NeedDeviceSerialNumberInformation = false;
5043 if (Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5044 - Controller->V2.NextEventSequenceNumber > 0)
5046 CommandMailbox->GetEvent.CommandOpcode = DAC960_V2_IOCTL;
5047 CommandMailbox->GetEvent.DataTransferSize = sizeof(DAC960_V2_Event_T);
5048 CommandMailbox->GetEvent.EventSequenceNumberHigh16 =
5049 Controller->V2.NextEventSequenceNumber >> 16;
5050 CommandMailbox->GetEvent.ControllerNumber = 0;
5051 CommandMailbox->GetEvent.IOCTL_Opcode =
5053 CommandMailbox->GetEvent.EventSequenceNumberLow16 =
5054 Controller->V2.NextEventSequenceNumber & 0xFFFF;
5055 CommandMailbox->GetEvent.DataTransferMemoryAddress
5056 .ScatterGatherSegments[0]
5057 .SegmentDataPointer =
5058 Controller->V2.EventDMA;
5059 CommandMailbox->GetEvent.DataTransferMemoryAddress
5060 .ScatterGatherSegments[0]
5062 CommandMailbox->GetEvent.DataTransferSize;
5063 DAC960_QueueCommand(Command);
5066 if (Controller->V2.NeedPhysicalDeviceInformation)
5068 if (Controller->V2.NeedDeviceSerialNumberInformation)
5070 DAC960_SCSI_Inquiry_UnitSerialNumber_T *InquiryUnitSerialNumber =
5071 Controller->V2.NewInquiryUnitSerialNumber;
5072 InquiryUnitSerialNumber->PeripheralDeviceType = 0x1F;
5074 DAC960_V2_ConstructNewUnitSerialNumber(Controller, CommandMailbox,
5075 Controller->V2.NewPhysicalDeviceInformation->Channel,
5076 Controller->V2.NewPhysicalDeviceInformation->TargetID,
5077 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit - 1);
5080 DAC960_QueueCommand(Command);
5083 if (Controller->V2.StartPhysicalDeviceInformationScan)
5085 Controller->V2.PhysicalDeviceIndex = 0;
5086 Controller->V2.NewPhysicalDeviceInformation->Channel = 0;
5087 Controller->V2.NewPhysicalDeviceInformation->TargetID = 0;
5088 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit = 0;
5089 Controller->V2.StartPhysicalDeviceInformationScan = false;
5091 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5092 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
5093 sizeof(DAC960_V2_PhysicalDeviceInfo_T);
5094 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.LogicalUnit =
5095 Controller->V2.NewPhysicalDeviceInformation->LogicalUnit;
5096 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID =
5097 Controller->V2.NewPhysicalDeviceInformation->TargetID;
5098 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel =
5099 Controller->V2.NewPhysicalDeviceInformation->Channel;
5100 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
5101 DAC960_V2_GetPhysicalDeviceInfoValid;
5102 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5103 .ScatterGatherSegments[0]
5104 .SegmentDataPointer =
5105 Controller->V2.NewPhysicalDeviceInformationDMA;
5106 CommandMailbox->PhysicalDeviceInfo.DataTransferMemoryAddress
5107 .ScatterGatherSegments[0]
5109 CommandMailbox->PhysicalDeviceInfo.DataTransferSize;
5110 DAC960_QueueCommand(Command);
5113 if (Controller->V2.NeedLogicalDeviceInformation)
5115 if (Controller->V2.StartLogicalDeviceInformationScan)
5117 int LogicalDriveNumber;
5118 for (LogicalDriveNumber = 0;
5119 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5120 LogicalDriveNumber++)
5121 Controller->V2.LogicalDriveFoundDuringScan
5122 [LogicalDriveNumber] = false;
5123 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber = 0;
5124 Controller->V2.StartLogicalDeviceInformationScan = false;
5126 CommandMailbox->LogicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
5127 CommandMailbox->LogicalDeviceInfo.DataTransferSize =
5128 sizeof(DAC960_V2_LogicalDeviceInfo_T);
5129 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
5130 Controller->V2.NewLogicalDeviceInformation->LogicalDeviceNumber;
5131 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
5132 DAC960_V2_GetLogicalDeviceInfoValid;
5133 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5134 .ScatterGatherSegments[0]
5135 .SegmentDataPointer =
5136 Controller->V2.NewLogicalDeviceInformationDMA;
5137 CommandMailbox->LogicalDeviceInfo.DataTransferMemoryAddress
5138 .ScatterGatherSegments[0]
5140 CommandMailbox->LogicalDeviceInfo.DataTransferSize;
5141 DAC960_QueueCommand(Command);
5144 Controller->MonitoringTimerCount++;
5145 Controller->MonitoringTimer.expires =
5146 jiffies + DAC960_HealthStatusMonitoringInterval;
5147 add_timer(&Controller->MonitoringTimer);
5149 if (CommandType == DAC960_ImmediateCommand)
5151 complete(Command->Completion);
5152 Command->Completion = NULL;
5155 if (CommandType == DAC960_QueuedCommand)
5157 DAC960_V2_KernelCommand_T *KernelCommand = Command->V2.KernelCommand;
5158 KernelCommand->CommandStatus = CommandStatus;
5159 KernelCommand->RequestSenseLength = Command->V2.RequestSenseLength;
5160 KernelCommand->DataTransferLength = Command->V2.DataTransferResidue;
5161 Command->V2.KernelCommand = NULL;
5162 DAC960_DeallocateCommand(Command);
5163 KernelCommand->CompletionFunction(KernelCommand);
5167 Queue a Status Monitoring Command to the Controller using the just
5168 completed Command if one was deferred previously due to lack of a
5169 free Command when the Monitoring Timer Function was called.
5171 if (Controller->MonitoringCommandDeferred)
5173 Controller->MonitoringCommandDeferred = false;
5174 DAC960_V2_QueueMonitoringCommand(Command);
5178 Deallocate the Command.
5180 DAC960_DeallocateCommand(Command);
5182 Wake up any processes waiting on a free Command.
5184 wake_up(&Controller->CommandWaitQueue);
5189 DAC960_BA_InterruptHandler handles hardware interrupts from DAC960 BA Series
5193 static irqreturn_t DAC960_BA_InterruptHandler(int IRQ_Channel,
5194 void *DeviceIdentifier,
5195 struct pt_regs *InterruptRegisters)
5197 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5198 void *ControllerBaseAddress = Controller->BaseAddress;
5199 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5200 unsigned long flags;
5202 spin_lock_irqsave(&Controller->queue_lock, flags);
5203 DAC960_BA_AcknowledgeInterrupt(ControllerBaseAddress);
5204 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5205 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5207 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5208 NextStatusMailbox->Fields.CommandIdentifier;
5209 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5210 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5211 Command->V2.RequestSenseLength =
5212 NextStatusMailbox->Fields.RequestSenseLength;
5213 Command->V2.DataTransferResidue =
5214 NextStatusMailbox->Fields.DataTransferResidue;
5215 NextStatusMailbox->Words[0] = 0;
5216 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5217 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5218 DAC960_V2_ProcessCompletedCommand(Command);
5220 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5222 Attempt to remove additional I/O Requests from the Controller's
5223 I/O Request Queue and queue them to the Controller.
5225 DAC960_ProcessRequest(Controller);
5226 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5232 DAC960_LP_InterruptHandler handles hardware interrupts from DAC960 LP Series
5236 static irqreturn_t DAC960_LP_InterruptHandler(int IRQ_Channel,
5237 void *DeviceIdentifier,
5238 struct pt_regs *InterruptRegisters)
5240 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5241 void *ControllerBaseAddress = Controller->BaseAddress;
5242 DAC960_V2_StatusMailbox_T *NextStatusMailbox;
5243 unsigned long flags;
5245 spin_lock_irqsave(&Controller->queue_lock, flags);
5246 DAC960_LP_AcknowledgeInterrupt(ControllerBaseAddress);
5247 NextStatusMailbox = Controller->V2.NextStatusMailbox;
5248 while (NextStatusMailbox->Fields.CommandIdentifier > 0)
5250 DAC960_V2_CommandIdentifier_T CommandIdentifier =
5251 NextStatusMailbox->Fields.CommandIdentifier;
5252 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5253 Command->V2.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5254 Command->V2.RequestSenseLength =
5255 NextStatusMailbox->Fields.RequestSenseLength;
5256 Command->V2.DataTransferResidue =
5257 NextStatusMailbox->Fields.DataTransferResidue;
5258 NextStatusMailbox->Words[0] = 0;
5259 if (++NextStatusMailbox > Controller->V2.LastStatusMailbox)
5260 NextStatusMailbox = Controller->V2.FirstStatusMailbox;
5261 DAC960_V2_ProcessCompletedCommand(Command);
5263 Controller->V2.NextStatusMailbox = NextStatusMailbox;
5265 Attempt to remove additional I/O Requests from the Controller's
5266 I/O Request Queue and queue them to the Controller.
5268 DAC960_ProcessRequest(Controller);
5269 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5275 DAC960_LA_InterruptHandler handles hardware interrupts from DAC960 LA Series
5279 static irqreturn_t DAC960_LA_InterruptHandler(int IRQ_Channel,
5280 void *DeviceIdentifier,
5281 struct pt_regs *InterruptRegisters)
5283 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5284 void *ControllerBaseAddress = Controller->BaseAddress;
5285 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5286 unsigned long flags;
5288 spin_lock_irqsave(&Controller->queue_lock, flags);
5289 DAC960_LA_AcknowledgeInterrupt(ControllerBaseAddress);
5290 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5291 while (NextStatusMailbox->Fields.Valid)
5293 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5294 NextStatusMailbox->Fields.CommandIdentifier;
5295 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5296 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5297 NextStatusMailbox->Word = 0;
5298 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5299 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5300 DAC960_V1_ProcessCompletedCommand(Command);
5302 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5304 Attempt to remove additional I/O Requests from the Controller's
5305 I/O Request Queue and queue them to the Controller.
5307 DAC960_ProcessRequest(Controller);
5308 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5314 DAC960_PG_InterruptHandler handles hardware interrupts from DAC960 PG Series
5318 static irqreturn_t DAC960_PG_InterruptHandler(int IRQ_Channel,
5319 void *DeviceIdentifier,
5320 struct pt_regs *InterruptRegisters)
5322 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5323 void *ControllerBaseAddress = Controller->BaseAddress;
5324 DAC960_V1_StatusMailbox_T *NextStatusMailbox;
5325 unsigned long flags;
5327 spin_lock_irqsave(&Controller->queue_lock, flags);
5328 DAC960_PG_AcknowledgeInterrupt(ControllerBaseAddress);
5329 NextStatusMailbox = Controller->V1.NextStatusMailbox;
5330 while (NextStatusMailbox->Fields.Valid)
5332 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5333 NextStatusMailbox->Fields.CommandIdentifier;
5334 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5335 Command->V1.CommandStatus = NextStatusMailbox->Fields.CommandStatus;
5336 NextStatusMailbox->Word = 0;
5337 if (++NextStatusMailbox > Controller->V1.LastStatusMailbox)
5338 NextStatusMailbox = Controller->V1.FirstStatusMailbox;
5339 DAC960_V1_ProcessCompletedCommand(Command);
5341 Controller->V1.NextStatusMailbox = NextStatusMailbox;
5343 Attempt to remove additional I/O Requests from the Controller's
5344 I/O Request Queue and queue them to the Controller.
5346 DAC960_ProcessRequest(Controller);
5347 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5353 DAC960_PD_InterruptHandler handles hardware interrupts from DAC960 PD Series
5357 static irqreturn_t DAC960_PD_InterruptHandler(int IRQ_Channel,
5358 void *DeviceIdentifier,
5359 struct pt_regs *InterruptRegisters)
5361 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5362 void *ControllerBaseAddress = Controller->BaseAddress;
5363 unsigned long flags;
5365 spin_lock_irqsave(&Controller->queue_lock, flags);
5366 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5368 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5369 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5370 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5371 Command->V1.CommandStatus =
5372 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5373 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5374 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5375 DAC960_V1_ProcessCompletedCommand(Command);
5378 Attempt to remove additional I/O Requests from the Controller's
5379 I/O Request Queue and queue them to the Controller.
5381 DAC960_ProcessRequest(Controller);
5382 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5388 DAC960_P_InterruptHandler handles hardware interrupts from DAC960 P Series
5391 Translations of DAC960_V1_Enquiry and DAC960_V1_GetDeviceState rely
5392 on the data having been placed into DAC960_Controller_T, rather than
5393 an arbitrary buffer.
5396 static irqreturn_t DAC960_P_InterruptHandler(int IRQ_Channel,
5397 void *DeviceIdentifier,
5398 struct pt_regs *InterruptRegisters)
5400 DAC960_Controller_T *Controller = (DAC960_Controller_T *) DeviceIdentifier;
5401 void *ControllerBaseAddress = Controller->BaseAddress;
5402 unsigned long flags;
5404 spin_lock_irqsave(&Controller->queue_lock, flags);
5405 while (DAC960_PD_StatusAvailableP(ControllerBaseAddress))
5407 DAC960_V1_CommandIdentifier_T CommandIdentifier =
5408 DAC960_PD_ReadStatusCommandIdentifier(ControllerBaseAddress);
5409 DAC960_Command_T *Command = Controller->Commands[CommandIdentifier-1];
5410 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5411 DAC960_V1_CommandOpcode_T CommandOpcode =
5412 CommandMailbox->Common.CommandOpcode;
5413 Command->V1.CommandStatus =
5414 DAC960_PD_ReadStatusRegister(ControllerBaseAddress);
5415 DAC960_PD_AcknowledgeInterrupt(ControllerBaseAddress);
5416 DAC960_PD_AcknowledgeStatus(ControllerBaseAddress);
5417 switch (CommandOpcode)
5419 case DAC960_V1_Enquiry_Old:
5420 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Enquiry;
5421 DAC960_P_To_PD_TranslateEnquiry(Controller->V1.NewEnquiry);
5423 case DAC960_V1_GetDeviceState_Old:
5424 Command->V1.CommandMailbox.Common.CommandOpcode =
5425 DAC960_V1_GetDeviceState;
5426 DAC960_P_To_PD_TranslateDeviceState(Controller->V1.NewDeviceState);
5428 case DAC960_V1_Read_Old:
5429 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Read;
5430 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5432 case DAC960_V1_Write_Old:
5433 Command->V1.CommandMailbox.Common.CommandOpcode = DAC960_V1_Write;
5434 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5436 case DAC960_V1_ReadWithScatterGather_Old:
5437 Command->V1.CommandMailbox.Common.CommandOpcode =
5438 DAC960_V1_ReadWithScatterGather;
5439 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5441 case DAC960_V1_WriteWithScatterGather_Old:
5442 Command->V1.CommandMailbox.Common.CommandOpcode =
5443 DAC960_V1_WriteWithScatterGather;
5444 DAC960_P_To_PD_TranslateReadWriteCommand(CommandMailbox);
5449 DAC960_V1_ProcessCompletedCommand(Command);
5452 Attempt to remove additional I/O Requests from the Controller's
5453 I/O Request Queue and queue them to the Controller.
5455 DAC960_ProcessRequest(Controller);
5456 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5462 DAC960_V1_QueueMonitoringCommand queues a Monitoring Command to DAC960 V1
5463 Firmware Controllers.
5466 static void DAC960_V1_QueueMonitoringCommand(DAC960_Command_T *Command)
5468 DAC960_Controller_T *Controller = Command->Controller;
5469 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5470 DAC960_V1_ClearCommand(Command);
5471 Command->CommandType = DAC960_MonitoringCommand;
5472 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Enquiry;
5473 CommandMailbox->Type3.BusAddress = Controller->V1.NewEnquiryDMA;
5474 DAC960_QueueCommand(Command);
5479 DAC960_V2_QueueMonitoringCommand queues a Monitoring Command to DAC960 V2
5480 Firmware Controllers.
5483 static void DAC960_V2_QueueMonitoringCommand(DAC960_Command_T *Command)
5485 DAC960_Controller_T *Controller = Command->Controller;
5486 DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox;
5487 DAC960_V2_ClearCommand(Command);
5488 Command->CommandType = DAC960_MonitoringCommand;
5489 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
5490 CommandMailbox->ControllerInfo.CommandControlBits
5491 .DataTransferControllerToHost = true;
5492 CommandMailbox->ControllerInfo.CommandControlBits
5493 .NoAutoRequestSense = true;
5494 CommandMailbox->ControllerInfo.DataTransferSize =
5495 sizeof(DAC960_V2_ControllerInfo_T);
5496 CommandMailbox->ControllerInfo.ControllerNumber = 0;
5497 CommandMailbox->ControllerInfo.IOCTL_Opcode = DAC960_V2_GetControllerInfo;
5498 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5499 .ScatterGatherSegments[0]
5500 .SegmentDataPointer =
5501 Controller->V2.NewControllerInformationDMA;
5502 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
5503 .ScatterGatherSegments[0]
5505 CommandMailbox->ControllerInfo.DataTransferSize;
5506 DAC960_QueueCommand(Command);
5511 DAC960_MonitoringTimerFunction is the timer function for monitoring
5512 the status of DAC960 Controllers.
5515 static void DAC960_MonitoringTimerFunction(unsigned long TimerData)
5517 DAC960_Controller_T *Controller = (DAC960_Controller_T *) TimerData;
5518 DAC960_Command_T *Command;
5519 unsigned long flags;
5521 if (Controller->FirmwareType == DAC960_V1_Controller)
5523 spin_lock_irqsave(&Controller->queue_lock, flags);
5525 Queue a Status Monitoring Command to Controller.
5527 Command = DAC960_AllocateCommand(Controller);
5528 if (Command != NULL)
5529 DAC960_V1_QueueMonitoringCommand(Command);
5530 else Controller->MonitoringCommandDeferred = true;
5531 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5535 DAC960_V2_ControllerInfo_T *ControllerInfo =
5536 &Controller->V2.ControllerInformation;
5537 unsigned int StatusChangeCounter =
5538 Controller->V2.HealthStatusBuffer->StatusChangeCounter;
5539 boolean ForceMonitoringCommand = false;
5540 if (jiffies - Controller->SecondaryMonitoringTime
5541 > DAC960_SecondaryMonitoringInterval)
5543 int LogicalDriveNumber;
5544 for (LogicalDriveNumber = 0;
5545 LogicalDriveNumber < DAC960_MaxLogicalDrives;
5546 LogicalDriveNumber++)
5548 DAC960_V2_LogicalDeviceInfo_T *LogicalDeviceInfo =
5549 Controller->V2.LogicalDeviceInformation[LogicalDriveNumber];
5550 if (LogicalDeviceInfo == NULL) continue;
5551 if (!LogicalDeviceInfo->LogicalDeviceControl
5552 .LogicalDeviceInitialized)
5554 ForceMonitoringCommand = true;
5558 Controller->SecondaryMonitoringTime = jiffies;
5560 if (StatusChangeCounter == Controller->V2.StatusChangeCounter &&
5561 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
5562 == Controller->V2.NextEventSequenceNumber &&
5563 (ControllerInfo->BackgroundInitializationsActive +
5564 ControllerInfo->LogicalDeviceInitializationsActive +
5565 ControllerInfo->PhysicalDeviceInitializationsActive +
5566 ControllerInfo->ConsistencyChecksActive +
5567 ControllerInfo->RebuildsActive +
5568 ControllerInfo->OnlineExpansionsActive == 0 ||
5569 jiffies - Controller->PrimaryMonitoringTime
5570 < DAC960_MonitoringTimerInterval) &&
5571 !ForceMonitoringCommand)
5573 Controller->MonitoringTimer.expires =
5574 jiffies + DAC960_HealthStatusMonitoringInterval;
5575 add_timer(&Controller->MonitoringTimer);
5578 Controller->V2.StatusChangeCounter = StatusChangeCounter;
5579 Controller->PrimaryMonitoringTime = jiffies;
5581 spin_lock_irqsave(&Controller->queue_lock, flags);
5583 Queue a Status Monitoring Command to Controller.
5585 Command = DAC960_AllocateCommand(Controller);
5586 if (Command != NULL)
5587 DAC960_V2_QueueMonitoringCommand(Command);
5588 else Controller->MonitoringCommandDeferred = true;
5589 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5591 Wake up any processes waiting on a Health Status Buffer change.
5593 wake_up(&Controller->HealthStatusWaitQueue);
5598 DAC960_CheckStatusBuffer verifies that there is room to hold ByteCount
5599 additional bytes in the Combined Status Buffer and grows the buffer if
5600 necessary. It returns true if there is enough room and false otherwise.
5603 static boolean DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
5604 unsigned int ByteCount)
5606 unsigned char *NewStatusBuffer;
5607 if (Controller->InitialStatusLength + 1 +
5608 Controller->CurrentStatusLength + ByteCount + 1 <=
5609 Controller->CombinedStatusBufferLength)
5611 if (Controller->CombinedStatusBufferLength == 0)
5613 unsigned int NewStatusBufferLength = DAC960_InitialStatusBufferSize;
5614 while (NewStatusBufferLength < ByteCount)
5615 NewStatusBufferLength *= 2;
5616 Controller->CombinedStatusBuffer =
5617 (unsigned char *) kmalloc(NewStatusBufferLength, GFP_ATOMIC);
5618 if (Controller->CombinedStatusBuffer == NULL) return false;
5619 Controller->CombinedStatusBufferLength = NewStatusBufferLength;
5622 NewStatusBuffer = (unsigned char *)
5623 kmalloc(2 * Controller->CombinedStatusBufferLength, GFP_ATOMIC);
5624 if (NewStatusBuffer == NULL)
5626 DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
5630 memcpy(NewStatusBuffer, Controller->CombinedStatusBuffer,
5631 Controller->CombinedStatusBufferLength);
5632 kfree(Controller->CombinedStatusBuffer);
5633 Controller->CombinedStatusBuffer = NewStatusBuffer;
5634 Controller->CombinedStatusBufferLength *= 2;
5635 Controller->CurrentStatusBuffer =
5636 &NewStatusBuffer[Controller->InitialStatusLength + 1];
5642 DAC960_Message prints Driver Messages.
5645 static void DAC960_Message(DAC960_MessageLevel_T MessageLevel,
5646 unsigned char *Format,
5647 DAC960_Controller_T *Controller,
5650 static unsigned char Buffer[DAC960_LineBufferSize];
5651 static boolean BeginningOfLine = true;
5654 va_start(Arguments, Controller);
5655 Length = vsprintf(Buffer, Format, Arguments);
5657 if (Controller == NULL)
5658 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5659 DAC960_ControllerCount, Buffer);
5660 else if (MessageLevel == DAC960_AnnounceLevel ||
5661 MessageLevel == DAC960_InfoLevel)
5663 if (!Controller->ControllerInitialized)
5665 if (DAC960_CheckStatusBuffer(Controller, Length))
5667 strcpy(&Controller->CombinedStatusBuffer
5668 [Controller->InitialStatusLength],
5670 Controller->InitialStatusLength += Length;
5671 Controller->CurrentStatusBuffer =
5672 &Controller->CombinedStatusBuffer
5673 [Controller->InitialStatusLength + 1];
5675 if (MessageLevel == DAC960_AnnounceLevel)
5677 static int AnnouncementLines = 0;
5678 if (++AnnouncementLines <= 2)
5679 printk("%sDAC960: %s", DAC960_MessageLevelMap[MessageLevel],
5684 if (BeginningOfLine)
5686 if (Buffer[0] != '\n' || Length > 1)
5687 printk("%sDAC960#%d: %s",
5688 DAC960_MessageLevelMap[MessageLevel],
5689 Controller->ControllerNumber, Buffer);
5691 else printk("%s", Buffer);
5694 else if (DAC960_CheckStatusBuffer(Controller, Length))
5696 strcpy(&Controller->CurrentStatusBuffer[
5697 Controller->CurrentStatusLength], Buffer);
5698 Controller->CurrentStatusLength += Length;
5701 else if (MessageLevel == DAC960_ProgressLevel)
5703 strcpy(Controller->ProgressBuffer, Buffer);
5704 Controller->ProgressBufferLength = Length;
5705 if (Controller->EphemeralProgressMessage)
5707 if (jiffies - Controller->LastProgressReportTime
5708 >= DAC960_ProgressReportingInterval)
5710 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5711 Controller->ControllerNumber, Buffer);
5712 Controller->LastProgressReportTime = jiffies;
5715 else printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5716 Controller->ControllerNumber, Buffer);
5718 else if (MessageLevel == DAC960_UserCriticalLevel)
5720 strcpy(&Controller->UserStatusBuffer[Controller->UserStatusLength],
5722 Controller->UserStatusLength += Length;
5723 if (Buffer[0] != '\n' || Length > 1)
5724 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5725 Controller->ControllerNumber, Buffer);
5729 if (BeginningOfLine)
5730 printk("%sDAC960#%d: %s", DAC960_MessageLevelMap[MessageLevel],
5731 Controller->ControllerNumber, Buffer);
5732 else printk("%s", Buffer);
5734 BeginningOfLine = (Buffer[Length-1] == '\n');
5739 DAC960_ParsePhysicalDevice parses spaces followed by a Physical Device
5740 Channel:TargetID specification from a User Command string. It updates
5741 Channel and TargetID and returns true on success and false on failure.
5744 static boolean DAC960_ParsePhysicalDevice(DAC960_Controller_T *Controller,
5745 char *UserCommandString,
5746 unsigned char *Channel,
5747 unsigned char *TargetID)
5749 char *NewUserCommandString = UserCommandString;
5750 unsigned long XChannel, XTargetID;
5751 while (*UserCommandString == ' ') UserCommandString++;
5752 if (UserCommandString == NewUserCommandString)
5754 XChannel = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5755 if (NewUserCommandString == UserCommandString ||
5756 *NewUserCommandString != ':' ||
5757 XChannel >= Controller->Channels)
5759 UserCommandString = ++NewUserCommandString;
5760 XTargetID = simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5761 if (NewUserCommandString == UserCommandString ||
5762 *NewUserCommandString != '\0' ||
5763 XTargetID >= Controller->Targets)
5765 *Channel = XChannel;
5766 *TargetID = XTargetID;
5772 DAC960_ParseLogicalDrive parses spaces followed by a Logical Drive Number
5773 specification from a User Command string. It updates LogicalDriveNumber and
5774 returns true on success and false on failure.
5777 static boolean DAC960_ParseLogicalDrive(DAC960_Controller_T *Controller,
5778 char *UserCommandString,
5779 unsigned char *LogicalDriveNumber)
5781 char *NewUserCommandString = UserCommandString;
5782 unsigned long XLogicalDriveNumber;
5783 while (*UserCommandString == ' ') UserCommandString++;
5784 if (UserCommandString == NewUserCommandString)
5786 XLogicalDriveNumber =
5787 simple_strtoul(UserCommandString, &NewUserCommandString, 10);
5788 if (NewUserCommandString == UserCommandString ||
5789 *NewUserCommandString != '\0' ||
5790 XLogicalDriveNumber > DAC960_MaxLogicalDrives - 1)
5792 *LogicalDriveNumber = XLogicalDriveNumber;
5798 DAC960_V1_SetDeviceState sets the Device State for a Physical Device for
5799 DAC960 V1 Firmware Controllers.
5802 static void DAC960_V1_SetDeviceState(DAC960_Controller_T *Controller,
5803 DAC960_Command_T *Command,
5804 unsigned char Channel,
5805 unsigned char TargetID,
5806 DAC960_V1_PhysicalDeviceState_T
5808 const unsigned char *DeviceStateString)
5810 DAC960_V1_CommandMailbox_T *CommandMailbox = &Command->V1.CommandMailbox;
5811 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_StartDevice;
5812 CommandMailbox->Type3D.Channel = Channel;
5813 CommandMailbox->Type3D.TargetID = TargetID;
5814 CommandMailbox->Type3D.DeviceState = DeviceState;
5815 CommandMailbox->Type3D.Modifier = 0;
5816 DAC960_ExecuteCommand(Command);
5817 switch (Command->V1.CommandStatus)
5819 case DAC960_V1_NormalCompletion:
5820 DAC960_UserCritical("%s of Physical Device %d:%d Succeeded\n", Controller,
5821 DeviceStateString, Channel, TargetID);
5823 case DAC960_V1_UnableToStartDevice:
5824 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5825 "Unable to Start Device\n", Controller,
5826 DeviceStateString, Channel, TargetID);
5828 case DAC960_V1_NoDeviceAtAddress:
5829 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5830 "No Device at Address\n", Controller,
5831 DeviceStateString, Channel, TargetID);
5833 case DAC960_V1_InvalidChannelOrTargetOrModifier:
5834 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5835 "Invalid Channel or Target or Modifier\n",
5836 Controller, DeviceStateString, Channel, TargetID);
5838 case DAC960_V1_ChannelBusy:
5839 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5840 "Channel Busy\n", Controller,
5841 DeviceStateString, Channel, TargetID);
5844 DAC960_UserCritical("%s of Physical Device %d:%d Failed - "
5845 "Unexpected Status %04X\n", Controller,
5846 DeviceStateString, Channel, TargetID,
5847 Command->V1.CommandStatus);
5854 DAC960_V1_ExecuteUserCommand executes a User Command for DAC960 V1 Firmware
5858 static boolean DAC960_V1_ExecuteUserCommand(DAC960_Controller_T *Controller,
5859 unsigned char *UserCommand)
5861 DAC960_Command_T *Command;
5862 DAC960_V1_CommandMailbox_T *CommandMailbox;
5863 unsigned long flags;
5864 unsigned char Channel, TargetID, LogicalDriveNumber;
5866 spin_lock_irqsave(&Controller->queue_lock, flags);
5867 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
5868 DAC960_WaitForCommand(Controller);
5869 spin_unlock_irqrestore(&Controller->queue_lock, flags);
5870 Controller->UserStatusLength = 0;
5871 DAC960_V1_ClearCommand(Command);
5872 Command->CommandType = DAC960_ImmediateCommand;
5873 CommandMailbox = &Command->V1.CommandMailbox;
5874 if (strcmp(UserCommand, "flush-cache") == 0)
5876 CommandMailbox->Type3.CommandOpcode = DAC960_V1_Flush;
5877 DAC960_ExecuteCommand(Command);
5878 DAC960_UserCritical("Cache Flush Completed\n", Controller);
5880 else if (strncmp(UserCommand, "kill", 4) == 0 &&
5881 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
5882 &Channel, &TargetID))
5884 DAC960_V1_DeviceState_T *DeviceState =
5885 &Controller->V1.DeviceState[Channel][TargetID];
5886 if (DeviceState->Present &&
5887 DeviceState->DeviceType == DAC960_V1_DiskType &&
5888 DeviceState->DeviceState != DAC960_V1_Device_Dead)
5889 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5890 DAC960_V1_Device_Dead, "Kill");
5891 else DAC960_UserCritical("Kill of Physical Device %d:%d Illegal\n",
5892 Controller, Channel, TargetID);
5894 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
5895 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
5896 &Channel, &TargetID))
5898 DAC960_V1_DeviceState_T *DeviceState =
5899 &Controller->V1.DeviceState[Channel][TargetID];
5900 if (DeviceState->Present &&
5901 DeviceState->DeviceType == DAC960_V1_DiskType &&
5902 DeviceState->DeviceState == DAC960_V1_Device_Dead)
5903 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5904 DAC960_V1_Device_Online, "Make Online");
5905 else DAC960_UserCritical("Make Online of Physical Device %d:%d Illegal\n",
5906 Controller, Channel, TargetID);
5909 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
5910 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
5911 &Channel, &TargetID))
5913 DAC960_V1_DeviceState_T *DeviceState =
5914 &Controller->V1.DeviceState[Channel][TargetID];
5915 if (DeviceState->Present &&
5916 DeviceState->DeviceType == DAC960_V1_DiskType &&
5917 DeviceState->DeviceState == DAC960_V1_Device_Dead)
5918 DAC960_V1_SetDeviceState(Controller, Command, Channel, TargetID,
5919 DAC960_V1_Device_Standby, "Make Standby");
5920 else DAC960_UserCritical("Make Standby of Physical "
5921 "Device %d:%d Illegal\n",
5922 Controller, Channel, TargetID);
5924 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
5925 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
5926 &Channel, &TargetID))
5928 CommandMailbox->Type3D.CommandOpcode = DAC960_V1_RebuildAsync;
5929 CommandMailbox->Type3D.Channel = Channel;
5930 CommandMailbox->Type3D.TargetID = TargetID;
5931 DAC960_ExecuteCommand(Command);
5932 switch (Command->V1.CommandStatus)
5934 case DAC960_V1_NormalCompletion:
5935 DAC960_UserCritical("Rebuild of Physical Device %d:%d Initiated\n",
5936 Controller, Channel, TargetID);
5938 case DAC960_V1_AttemptToRebuildOnlineDrive:
5939 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5940 "Attempt to Rebuild Online or "
5941 "Unresponsive Drive\n",
5942 Controller, Channel, TargetID);
5944 case DAC960_V1_NewDiskFailedDuringRebuild:
5945 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5946 "New Disk Failed During Rebuild\n",
5947 Controller, Channel, TargetID);
5949 case DAC960_V1_InvalidDeviceAddress:
5950 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5951 "Invalid Device Address\n",
5952 Controller, Channel, TargetID);
5954 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
5955 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5956 "Rebuild or Consistency Check Already "
5957 "in Progress\n", Controller, Channel, TargetID);
5960 DAC960_UserCritical("Rebuild of Physical Device %d:%d Failed - "
5961 "Unexpected Status %04X\n", Controller,
5962 Channel, TargetID, Command->V1.CommandStatus);
5966 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
5967 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
5968 &LogicalDriveNumber))
5970 CommandMailbox->Type3C.CommandOpcode = DAC960_V1_CheckConsistencyAsync;
5971 CommandMailbox->Type3C.LogicalDriveNumber = LogicalDriveNumber;
5972 CommandMailbox->Type3C.AutoRestore = true;
5973 DAC960_ExecuteCommand(Command);
5974 switch (Command->V1.CommandStatus)
5976 case DAC960_V1_NormalCompletion:
5977 DAC960_UserCritical("Consistency Check of Logical Drive %d "
5978 "(/dev/rd/c%dd%d) Initiated\n",
5979 Controller, LogicalDriveNumber,
5980 Controller->ControllerNumber,
5981 LogicalDriveNumber);
5983 case DAC960_V1_DependentDiskIsDead:
5984 DAC960_UserCritical("Consistency Check of Logical Drive %d "
5985 "(/dev/rd/c%dd%d) Failed - "
5986 "Dependent Physical Device is DEAD\n",
5987 Controller, LogicalDriveNumber,
5988 Controller->ControllerNumber,
5989 LogicalDriveNumber);
5991 case DAC960_V1_InvalidOrNonredundantLogicalDrive:
5992 DAC960_UserCritical("Consistency Check of Logical Drive %d "
5993 "(/dev/rd/c%dd%d) Failed - "
5994 "Invalid or Nonredundant Logical Drive\n",
5995 Controller, LogicalDriveNumber,
5996 Controller->ControllerNumber,
5997 LogicalDriveNumber);
5999 case DAC960_V1_RebuildOrCheckAlreadyInProgress:
6000 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6001 "(/dev/rd/c%dd%d) Failed - Rebuild or "
6002 "Consistency Check Already in Progress\n",
6003 Controller, LogicalDriveNumber,
6004 Controller->ControllerNumber,
6005 LogicalDriveNumber);
6008 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6009 "(/dev/rd/c%dd%d) Failed - "
6010 "Unexpected Status %04X\n",
6011 Controller, LogicalDriveNumber,
6012 Controller->ControllerNumber,
6013 LogicalDriveNumber, Command->V1.CommandStatus);
6017 else if (strcmp(UserCommand, "cancel-rebuild") == 0 ||
6018 strcmp(UserCommand, "cancel-consistency-check") == 0)
6021 the OldRebuildRateConstant is never actually used
6022 once its value is retrieved from the controller.
6024 unsigned char *OldRebuildRateConstant;
6025 dma_addr_t OldRebuildRateConstantDMA;
6027 OldRebuildRateConstant = pci_alloc_consistent( Controller->PCIDevice,
6028 sizeof(char), &OldRebuildRateConstantDMA);
6029 if (OldRebuildRateConstant == NULL) {
6030 DAC960_UserCritical("Cancellation of Rebuild or "
6031 "Consistency Check Failed - "
6036 CommandMailbox->Type3R.CommandOpcode = DAC960_V1_RebuildControl;
6037 CommandMailbox->Type3R.RebuildRateConstant = 0xFF;
6038 CommandMailbox->Type3R.BusAddress = OldRebuildRateConstantDMA;
6039 DAC960_ExecuteCommand(Command);
6040 switch (Command->V1.CommandStatus)
6042 case DAC960_V1_NormalCompletion:
6043 DAC960_UserCritical("Rebuild or Consistency Check Cancelled\n",
6047 DAC960_UserCritical("Cancellation of Rebuild or "
6048 "Consistency Check Failed - "
6049 "Unexpected Status %04X\n",
6050 Controller, Command->V1.CommandStatus);
6054 pci_free_consistent(Controller->PCIDevice, sizeof(char),
6055 OldRebuildRateConstant, OldRebuildRateConstantDMA);
6057 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6058 Controller, UserCommand);
6060 spin_lock_irqsave(&Controller->queue_lock, flags);
6061 DAC960_DeallocateCommand(Command);
6062 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6068 DAC960_V2_TranslatePhysicalDevice translates a Physical Device Channel and
6069 TargetID into a Logical Device. It returns true on success and false
6073 static boolean DAC960_V2_TranslatePhysicalDevice(DAC960_Command_T *Command,
6074 unsigned char Channel,
6075 unsigned char TargetID,
6077 *LogicalDeviceNumber)
6079 DAC960_V2_CommandMailbox_T SavedCommandMailbox, *CommandMailbox;
6080 DAC960_Controller_T *Controller = Command->Controller;
6082 CommandMailbox = &Command->V2.CommandMailbox;
6083 memcpy(&SavedCommandMailbox, CommandMailbox,
6084 sizeof(DAC960_V2_CommandMailbox_T));
6086 CommandMailbox->PhysicalDeviceInfo.CommandOpcode = DAC960_V2_IOCTL;
6087 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6088 .DataTransferControllerToHost = true;
6089 CommandMailbox->PhysicalDeviceInfo.CommandControlBits
6090 .NoAutoRequestSense = true;
6091 CommandMailbox->PhysicalDeviceInfo.DataTransferSize =
6092 sizeof(DAC960_V2_PhysicalToLogicalDevice_T);
6093 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.TargetID = TargetID;
6094 CommandMailbox->PhysicalDeviceInfo.PhysicalDevice.Channel = Channel;
6095 CommandMailbox->PhysicalDeviceInfo.IOCTL_Opcode =
6096 DAC960_V2_TranslatePhysicalToLogicalDevice;
6097 CommandMailbox->Common.DataTransferMemoryAddress
6098 .ScatterGatherSegments[0]
6099 .SegmentDataPointer =
6100 Controller->V2.PhysicalToLogicalDeviceDMA;
6101 CommandMailbox->Common.DataTransferMemoryAddress
6102 .ScatterGatherSegments[0]
6104 CommandMailbox->Common.DataTransferSize;
6106 DAC960_ExecuteCommand(Command);
6107 *LogicalDeviceNumber = Controller->V2.PhysicalToLogicalDevice->LogicalDeviceNumber;
6109 memcpy(CommandMailbox, &SavedCommandMailbox,
6110 sizeof(DAC960_V2_CommandMailbox_T));
6111 return (Command->V2.CommandStatus == DAC960_V2_NormalCompletion);
6116 DAC960_V2_ExecuteUserCommand executes a User Command for DAC960 V2 Firmware
6120 static boolean DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller,
6121 unsigned char *UserCommand)
6123 DAC960_Command_T *Command;
6124 DAC960_V2_CommandMailbox_T *CommandMailbox;
6125 unsigned long flags;
6126 unsigned char Channel, TargetID, LogicalDriveNumber;
6127 unsigned short LogicalDeviceNumber;
6128 wait_queue_t __wait;
6130 init_waitqueue_entry(&__wait, current);
6132 spin_lock_irqsave(&Controller->queue_lock, flags);
6133 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6134 DAC960_WaitForCommand(Controller);
6135 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6136 Controller->UserStatusLength = 0;
6137 DAC960_V2_ClearCommand(Command);
6138 Command->CommandType = DAC960_ImmediateCommand;
6139 CommandMailbox = &Command->V2.CommandMailbox;
6140 CommandMailbox->Common.CommandOpcode = DAC960_V2_IOCTL;
6141 CommandMailbox->Common.CommandControlBits.DataTransferControllerToHost = true;
6142 CommandMailbox->Common.CommandControlBits.NoAutoRequestSense = true;
6143 if (strcmp(UserCommand, "flush-cache") == 0)
6145 CommandMailbox->DeviceOperation.IOCTL_Opcode = DAC960_V2_PauseDevice;
6146 CommandMailbox->DeviceOperation.OperationDevice =
6147 DAC960_V2_RAID_Controller;
6148 DAC960_ExecuteCommand(Command);
6149 DAC960_UserCritical("Cache Flush Completed\n", Controller);
6151 else if (strncmp(UserCommand, "kill", 4) == 0 &&
6152 DAC960_ParsePhysicalDevice(Controller, &UserCommand[4],
6153 &Channel, &TargetID) &&
6154 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6155 &LogicalDeviceNumber))
6157 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6158 LogicalDeviceNumber;
6159 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6160 DAC960_V2_SetDeviceState;
6161 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6162 DAC960_V2_Device_Dead;
6163 DAC960_ExecuteCommand(Command);
6164 DAC960_UserCritical("Kill of Physical Device %d:%d %s\n",
6165 Controller, Channel, TargetID,
6166 (Command->V2.CommandStatus
6167 == DAC960_V2_NormalCompletion
6168 ? "Succeeded" : "Failed"));
6170 else if (strncmp(UserCommand, "make-online", 11) == 0 &&
6171 DAC960_ParsePhysicalDevice(Controller, &UserCommand[11],
6172 &Channel, &TargetID) &&
6173 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6174 &LogicalDeviceNumber))
6176 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6177 LogicalDeviceNumber;
6178 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6179 DAC960_V2_SetDeviceState;
6180 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6181 DAC960_V2_Device_Online;
6182 DAC960_ExecuteCommand(Command);
6183 DAC960_UserCritical("Make Online of Physical Device %d:%d %s\n",
6184 Controller, Channel, TargetID,
6185 (Command->V2.CommandStatus
6186 == DAC960_V2_NormalCompletion
6187 ? "Succeeded" : "Failed"));
6189 else if (strncmp(UserCommand, "make-standby", 12) == 0 &&
6190 DAC960_ParsePhysicalDevice(Controller, &UserCommand[12],
6191 &Channel, &TargetID) &&
6192 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6193 &LogicalDeviceNumber))
6195 CommandMailbox->SetDeviceState.LogicalDevice.LogicalDeviceNumber =
6196 LogicalDeviceNumber;
6197 CommandMailbox->SetDeviceState.IOCTL_Opcode =
6198 DAC960_V2_SetDeviceState;
6199 CommandMailbox->SetDeviceState.DeviceState.PhysicalDeviceState =
6200 DAC960_V2_Device_Standby;
6201 DAC960_ExecuteCommand(Command);
6202 DAC960_UserCritical("Make Standby of Physical Device %d:%d %s\n",
6203 Controller, Channel, TargetID,
6204 (Command->V2.CommandStatus
6205 == DAC960_V2_NormalCompletion
6206 ? "Succeeded" : "Failed"));
6208 else if (strncmp(UserCommand, "rebuild", 7) == 0 &&
6209 DAC960_ParsePhysicalDevice(Controller, &UserCommand[7],
6210 &Channel, &TargetID) &&
6211 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6212 &LogicalDeviceNumber))
6214 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6215 LogicalDeviceNumber;
6216 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6217 DAC960_V2_RebuildDeviceStart;
6218 DAC960_ExecuteCommand(Command);
6219 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6220 Controller, Channel, TargetID,
6221 (Command->V2.CommandStatus
6222 == DAC960_V2_NormalCompletion
6223 ? "Initiated" : "Not Initiated"));
6225 else if (strncmp(UserCommand, "cancel-rebuild", 14) == 0 &&
6226 DAC960_ParsePhysicalDevice(Controller, &UserCommand[14],
6227 &Channel, &TargetID) &&
6228 DAC960_V2_TranslatePhysicalDevice(Command, Channel, TargetID,
6229 &LogicalDeviceNumber))
6231 CommandMailbox->LogicalDeviceInfo.LogicalDevice.LogicalDeviceNumber =
6232 LogicalDeviceNumber;
6233 CommandMailbox->LogicalDeviceInfo.IOCTL_Opcode =
6234 DAC960_V2_RebuildDeviceStop;
6235 DAC960_ExecuteCommand(Command);
6236 DAC960_UserCritical("Rebuild of Physical Device %d:%d %s\n",
6237 Controller, Channel, TargetID,
6238 (Command->V2.CommandStatus
6239 == DAC960_V2_NormalCompletion
6240 ? "Cancelled" : "Not Cancelled"));
6242 else if (strncmp(UserCommand, "check-consistency", 17) == 0 &&
6243 DAC960_ParseLogicalDrive(Controller, &UserCommand[17],
6244 &LogicalDriveNumber))
6246 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6248 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6249 DAC960_V2_ConsistencyCheckStart;
6250 CommandMailbox->ConsistencyCheck.RestoreConsistency = true;
6251 CommandMailbox->ConsistencyCheck.InitializedAreaOnly = false;
6252 DAC960_ExecuteCommand(Command);
6253 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6254 "(/dev/rd/c%dd%d) %s\n",
6255 Controller, LogicalDriveNumber,
6256 Controller->ControllerNumber,
6258 (Command->V2.CommandStatus
6259 == DAC960_V2_NormalCompletion
6260 ? "Initiated" : "Not Initiated"));
6262 else if (strncmp(UserCommand, "cancel-consistency-check", 24) == 0 &&
6263 DAC960_ParseLogicalDrive(Controller, &UserCommand[24],
6264 &LogicalDriveNumber))
6266 CommandMailbox->ConsistencyCheck.LogicalDevice.LogicalDeviceNumber =
6268 CommandMailbox->ConsistencyCheck.IOCTL_Opcode =
6269 DAC960_V2_ConsistencyCheckStop;
6270 DAC960_ExecuteCommand(Command);
6271 DAC960_UserCritical("Consistency Check of Logical Drive %d "
6272 "(/dev/rd/c%dd%d) %s\n",
6273 Controller, LogicalDriveNumber,
6274 Controller->ControllerNumber,
6276 (Command->V2.CommandStatus
6277 == DAC960_V2_NormalCompletion
6278 ? "Cancelled" : "Not Cancelled"));
6280 else if (strcmp(UserCommand, "perform-discovery") == 0)
6282 CommandMailbox->Common.IOCTL_Opcode = DAC960_V2_StartDiscovery;
6283 DAC960_ExecuteCommand(Command);
6284 DAC960_UserCritical("Discovery %s\n", Controller,
6285 (Command->V2.CommandStatus
6286 == DAC960_V2_NormalCompletion
6287 ? "Initiated" : "Not Initiated"));
6288 if (Command->V2.CommandStatus == DAC960_V2_NormalCompletion)
6290 CommandMailbox->ControllerInfo.CommandOpcode = DAC960_V2_IOCTL;
6291 CommandMailbox->ControllerInfo.CommandControlBits
6292 .DataTransferControllerToHost = true;
6293 CommandMailbox->ControllerInfo.CommandControlBits
6294 .NoAutoRequestSense = true;
6295 CommandMailbox->ControllerInfo.DataTransferSize =
6296 sizeof(DAC960_V2_ControllerInfo_T);
6297 CommandMailbox->ControllerInfo.ControllerNumber = 0;
6298 CommandMailbox->ControllerInfo.IOCTL_Opcode =
6299 DAC960_V2_GetControllerInfo;
6301 * How does this NOT race with the queued Monitoring
6302 * usage of this structure?
6304 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6305 .ScatterGatherSegments[0]
6306 .SegmentDataPointer =
6307 Controller->V2.NewControllerInformationDMA;
6308 CommandMailbox->ControllerInfo.DataTransferMemoryAddress
6309 .ScatterGatherSegments[0]
6311 CommandMailbox->ControllerInfo.DataTransferSize;
6312 DAC960_ExecuteCommand(Command);
6313 add_wait_queue(&Controller->CommandWaitQueue, &__wait);
6314 set_current_state(TASK_UNINTERRUPTIBLE);
6316 while (Controller->V2.NewControllerInformation->PhysicalScanActive)
6318 DAC960_ExecuteCommand(Command);
6319 schedule_timeout(HZ);
6320 set_current_state(TASK_UNINTERRUPTIBLE);
6322 current->state = TASK_RUNNING;
6323 remove_wait_queue(&Controller->CommandWaitQueue, &__wait);
6325 DAC960_UserCritical("Discovery Completed\n", Controller);
6328 else if (strcmp(UserCommand, "suppress-enclosure-messages") == 0)
6329 Controller->SuppressEnclosureMessages = true;
6330 else DAC960_UserCritical("Illegal User Command: '%s'\n",
6331 Controller, UserCommand);
6333 spin_lock_irqsave(&Controller->queue_lock, flags);
6334 DAC960_DeallocateCommand(Command);
6335 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6341 DAC960_ProcReadStatus implements reading /proc/rd/status.
6344 static int DAC960_ProcReadStatus(char *Page, char **Start, off_t Offset,
6345 int Count, int *EOF, void *Data)
6347 unsigned char *StatusMessage = "OK\n";
6348 int ControllerNumber, BytesAvailable;
6349 for (ControllerNumber = 0;
6350 ControllerNumber < DAC960_ControllerCount;
6353 DAC960_Controller_T *Controller = DAC960_Controllers[ControllerNumber];
6354 if (Controller == NULL) continue;
6355 if (Controller->MonitoringAlertMode)
6357 StatusMessage = "ALERT\n";
6361 BytesAvailable = strlen(StatusMessage) - Offset;
6362 if (Count >= BytesAvailable)
6364 Count = BytesAvailable;
6367 if (Count <= 0) return 0;
6369 memcpy(Page, &StatusMessage[Offset], Count);
6375 DAC960_ProcReadInitialStatus implements reading /proc/rd/cN/initial_status.
6378 static int DAC960_ProcReadInitialStatus(char *Page, char **Start, off_t Offset,
6379 int Count, int *EOF, void *Data)
6381 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6382 int BytesAvailable = Controller->InitialStatusLength - Offset;
6383 if (Count >= BytesAvailable)
6385 Count = BytesAvailable;
6388 if (Count <= 0) return 0;
6390 memcpy(Page, &Controller->CombinedStatusBuffer[Offset], Count);
6396 DAC960_ProcReadCurrentStatus implements reading /proc/rd/cN/current_status.
6399 static int DAC960_ProcReadCurrentStatus(char *Page, char **Start, off_t Offset,
6400 int Count, int *EOF, void *Data)
6402 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6403 unsigned char *StatusMessage =
6404 "No Rebuild or Consistency Check in Progress\n";
6405 int ProgressMessageLength = strlen(StatusMessage);
6407 if (jiffies != Controller->LastCurrentStatusTime)
6409 Controller->CurrentStatusLength = 0;
6410 DAC960_AnnounceDriver(Controller);
6411 DAC960_ReportControllerConfiguration(Controller);
6412 DAC960_ReportDeviceConfiguration(Controller);
6413 if (Controller->ProgressBufferLength > 0)
6414 ProgressMessageLength = Controller->ProgressBufferLength;
6415 if (DAC960_CheckStatusBuffer(Controller, 2 + ProgressMessageLength))
6417 unsigned char *CurrentStatusBuffer = Controller->CurrentStatusBuffer;
6418 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6419 CurrentStatusBuffer[Controller->CurrentStatusLength++] = ' ';
6420 if (Controller->ProgressBufferLength > 0)
6421 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6422 Controller->ProgressBuffer);
6424 strcpy(&CurrentStatusBuffer[Controller->CurrentStatusLength],
6426 Controller->CurrentStatusLength += ProgressMessageLength;
6428 Controller->LastCurrentStatusTime = jiffies;
6430 BytesAvailable = Controller->CurrentStatusLength - Offset;
6431 if (Count >= BytesAvailable)
6433 Count = BytesAvailable;
6436 if (Count <= 0) return 0;
6438 memcpy(Page, &Controller->CurrentStatusBuffer[Offset], Count);
6444 DAC960_ProcReadUserCommand implements reading /proc/rd/cN/user_command.
6447 static int DAC960_ProcReadUserCommand(char *Page, char **Start, off_t Offset,
6448 int Count, int *EOF, void *Data)
6450 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6451 int BytesAvailable = Controller->UserStatusLength - Offset;
6452 if (Count >= BytesAvailable)
6454 Count = BytesAvailable;
6457 if (Count <= 0) return 0;
6459 memcpy(Page, &Controller->UserStatusBuffer[Offset], Count);
6465 DAC960_ProcWriteUserCommand implements writing /proc/rd/cN/user_command.
6468 static int DAC960_ProcWriteUserCommand(struct file *file, const char *Buffer,
6469 unsigned long Count, void *Data)
6471 DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data;
6472 unsigned char CommandBuffer[80];
6474 if (Count > sizeof(CommandBuffer)-1) return -EINVAL;
6475 if (copy_from_user(CommandBuffer, Buffer, Count)) return -EFAULT;
6476 CommandBuffer[Count] = '\0';
6477 Length = strlen(CommandBuffer);
6478 if (CommandBuffer[Length-1] == '\n')
6479 CommandBuffer[--Length] = '\0';
6480 if (Controller->FirmwareType == DAC960_V1_Controller)
6481 return (DAC960_V1_ExecuteUserCommand(Controller, CommandBuffer)
6484 return (DAC960_V2_ExecuteUserCommand(Controller, CommandBuffer)
6490 DAC960_CreateProcEntries creates the /proc/rd/... entries for the
6494 static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller)
6496 struct proc_dir_entry *StatusProcEntry;
6497 struct proc_dir_entry *ControllerProcEntry;
6498 struct proc_dir_entry *UserCommandProcEntry;
6500 if (DAC960_ProcDirectoryEntry == NULL) {
6501 DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL);
6502 StatusProcEntry = create_proc_read_entry("status", 0,
6503 DAC960_ProcDirectoryEntry,
6504 DAC960_ProcReadStatus, NULL);
6507 sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber);
6508 ControllerProcEntry = proc_mkdir(Controller->ControllerName,
6509 DAC960_ProcDirectoryEntry);
6510 create_proc_read_entry("initial_status", 0, ControllerProcEntry,
6511 DAC960_ProcReadInitialStatus, Controller);
6512 create_proc_read_entry("current_status", 0, ControllerProcEntry,
6513 DAC960_ProcReadCurrentStatus, Controller);
6514 UserCommandProcEntry =
6515 create_proc_read_entry("user_command", S_IWUSR | S_IRUSR,
6516 ControllerProcEntry, DAC960_ProcReadUserCommand,
6518 UserCommandProcEntry->write_proc = DAC960_ProcWriteUserCommand;
6519 Controller->ControllerProcEntry = ControllerProcEntry;
6524 DAC960_DestroyProcEntries destroys the /proc/rd/... entries for the
6528 static void DAC960_DestroyProcEntries(DAC960_Controller_T *Controller)
6530 if (Controller->ControllerProcEntry == NULL)
6532 remove_proc_entry("initial_status", Controller->ControllerProcEntry);
6533 remove_proc_entry("current_status", Controller->ControllerProcEntry);
6534 remove_proc_entry("user_command", Controller->ControllerProcEntry);
6535 remove_proc_entry(Controller->ControllerName, DAC960_ProcDirectoryEntry);
6536 Controller->ControllerProcEntry = NULL;
6539 #ifdef DAC960_GAM_MINOR
6542 * DAC960_gam_ioctl is the ioctl function for performing RAID operations.
6545 static int DAC960_gam_ioctl(struct inode *inode, struct file *file,
6546 unsigned int Request, unsigned long Argument)
6549 if (!capable(CAP_SYS_ADMIN)) return -EACCES;
6552 case DAC960_IOCTL_GET_CONTROLLER_COUNT:
6553 return DAC960_ControllerCount;
6554 case DAC960_IOCTL_GET_CONTROLLER_INFO:
6556 DAC960_ControllerInfo_T *UserSpaceControllerInfo =
6557 (DAC960_ControllerInfo_T *) Argument;
6558 DAC960_ControllerInfo_T ControllerInfo;
6559 DAC960_Controller_T *Controller;
6560 int ControllerNumber;
6561 if (UserSpaceControllerInfo == NULL) return -EINVAL;
6562 ErrorCode = get_user(ControllerNumber,
6563 &UserSpaceControllerInfo->ControllerNumber);
6564 if (ErrorCode != 0) return ErrorCode;
6565 if (ControllerNumber < 0 ||
6566 ControllerNumber > DAC960_ControllerCount - 1)
6568 Controller = DAC960_Controllers[ControllerNumber];
6569 if (Controller == NULL) return -ENXIO;
6570 memset(&ControllerInfo, 0, sizeof(DAC960_ControllerInfo_T));
6571 ControllerInfo.ControllerNumber = ControllerNumber;
6572 ControllerInfo.FirmwareType = Controller->FirmwareType;
6573 ControllerInfo.Channels = Controller->Channels;
6574 ControllerInfo.Targets = Controller->Targets;
6575 ControllerInfo.PCI_Bus = Controller->Bus;
6576 ControllerInfo.PCI_Device = Controller->Device;
6577 ControllerInfo.PCI_Function = Controller->Function;
6578 ControllerInfo.IRQ_Channel = Controller->IRQ_Channel;
6579 ControllerInfo.PCI_Address = Controller->PCI_Address;
6580 strcpy(ControllerInfo.ModelName, Controller->ModelName);
6581 strcpy(ControllerInfo.FirmwareVersion, Controller->FirmwareVersion);
6582 return (copy_to_user(UserSpaceControllerInfo, &ControllerInfo,
6583 sizeof(DAC960_ControllerInfo_T)) ? -EFAULT : 0);
6585 case DAC960_IOCTL_V1_EXECUTE_COMMAND:
6587 DAC960_V1_UserCommand_T *UserSpaceUserCommand =
6588 (DAC960_V1_UserCommand_T *) Argument;
6589 DAC960_V1_UserCommand_T UserCommand;
6590 DAC960_Controller_T *Controller;
6591 DAC960_Command_T *Command = NULL;
6592 DAC960_V1_CommandOpcode_T CommandOpcode;
6593 DAC960_V1_CommandStatus_T CommandStatus;
6594 DAC960_V1_DCDB_T DCDB;
6595 DAC960_V1_DCDB_T *DCDB_IOBUF = NULL;
6596 dma_addr_t DCDB_IOBUFDMA;
6597 unsigned long flags;
6598 int ControllerNumber, DataTransferLength;
6599 unsigned char *DataTransferBuffer = NULL;
6600 dma_addr_t DataTransferBufferDMA;
6601 if (UserSpaceUserCommand == NULL) return -EINVAL;
6602 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6603 sizeof(DAC960_V1_UserCommand_T))) {
6604 ErrorCode = -EFAULT;
6607 ControllerNumber = UserCommand.ControllerNumber;
6608 if (ControllerNumber < 0 ||
6609 ControllerNumber > DAC960_ControllerCount - 1)
6611 Controller = DAC960_Controllers[ControllerNumber];
6612 if (Controller == NULL) return -ENXIO;
6613 if (Controller->FirmwareType != DAC960_V1_Controller) return -EINVAL;
6614 CommandOpcode = UserCommand.CommandMailbox.Common.CommandOpcode;
6615 DataTransferLength = UserCommand.DataTransferLength;
6616 if (CommandOpcode & 0x80) return -EINVAL;
6617 if (CommandOpcode == DAC960_V1_DCDB)
6619 if (copy_from_user(&DCDB, UserCommand.DCDB,
6620 sizeof(DAC960_V1_DCDB_T))) {
6621 ErrorCode = -EFAULT;
6624 if (DCDB.Channel >= DAC960_V1_MaxChannels) return -EINVAL;
6625 if (!((DataTransferLength == 0 &&
6627 == DAC960_V1_DCDB_NoDataTransfer) ||
6628 (DataTransferLength > 0 &&
6630 == DAC960_V1_DCDB_DataTransferDeviceToSystem) ||
6631 (DataTransferLength < 0 &&
6633 == DAC960_V1_DCDB_DataTransferSystemToDevice)))
6635 if (((DCDB.TransferLengthHigh4 << 16) | DCDB.TransferLength)
6636 != abs(DataTransferLength))
6638 DCDB_IOBUF = pci_alloc_consistent(Controller->PCIDevice,
6639 sizeof(DAC960_V1_DCDB_T), &DCDB_IOBUFDMA);
6640 if (DCDB_IOBUF == NULL)
6643 if (DataTransferLength > 0)
6645 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6646 DataTransferLength, &DataTransferBufferDMA);
6647 if (DataTransferBuffer == NULL) {
6648 ErrorCode = -ENOMEM;
6651 memset(DataTransferBuffer, 0, DataTransferLength);
6653 else if (DataTransferLength < 0)
6655 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6656 -DataTransferLength, &DataTransferBufferDMA);
6657 if (DataTransferBuffer == NULL) {
6658 ErrorCode = -ENOMEM;
6661 if (copy_from_user(DataTransferBuffer,
6662 UserCommand.DataTransferBuffer,
6663 -DataTransferLength)) {
6664 ErrorCode = -EFAULT;
6668 if (CommandOpcode == DAC960_V1_DCDB)
6670 spin_lock_irqsave(&Controller->queue_lock, flags);
6671 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6672 DAC960_WaitForCommand(Controller);
6673 while (Controller->V1.DirectCommandActive[DCDB.Channel]
6676 spin_unlock_irq(&Controller->queue_lock);
6677 __wait_event(Controller->CommandWaitQueue,
6678 !Controller->V1.DirectCommandActive
6679 [DCDB.Channel][DCDB.TargetID]);
6680 spin_lock_irq(&Controller->queue_lock);
6682 Controller->V1.DirectCommandActive[DCDB.Channel]
6683 [DCDB.TargetID] = true;
6684 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6685 DAC960_V1_ClearCommand(Command);
6686 Command->CommandType = DAC960_ImmediateCommand;
6687 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
6688 sizeof(DAC960_V1_CommandMailbox_T));
6689 Command->V1.CommandMailbox.Type3.BusAddress = DCDB_IOBUFDMA;
6690 DCDB.BusAddress = DataTransferBufferDMA;
6691 memcpy(DCDB_IOBUF, &DCDB, sizeof(DAC960_V1_DCDB_T));
6695 spin_lock_irqsave(&Controller->queue_lock, flags);
6696 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6697 DAC960_WaitForCommand(Controller);
6698 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6699 DAC960_V1_ClearCommand(Command);
6700 Command->CommandType = DAC960_ImmediateCommand;
6701 memcpy(&Command->V1.CommandMailbox, &UserCommand.CommandMailbox,
6702 sizeof(DAC960_V1_CommandMailbox_T));
6703 if (DataTransferBuffer != NULL)
6704 Command->V1.CommandMailbox.Type3.BusAddress =
6705 DataTransferBufferDMA;
6707 DAC960_ExecuteCommand(Command);
6708 CommandStatus = Command->V1.CommandStatus;
6709 spin_lock_irqsave(&Controller->queue_lock, flags);
6710 DAC960_DeallocateCommand(Command);
6711 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6712 if (DataTransferLength > 0)
6714 if (copy_to_user(UserCommand.DataTransferBuffer,
6715 DataTransferBuffer, DataTransferLength)) {
6716 ErrorCode = -EFAULT;
6720 if (CommandOpcode == DAC960_V1_DCDB)
6723 I don't believe Target or Channel in the DCDB_IOBUF
6724 should be any different from the contents of DCDB.
6726 Controller->V1.DirectCommandActive[DCDB.Channel]
6727 [DCDB.TargetID] = false;
6728 if (copy_to_user(UserCommand.DCDB, DCDB_IOBUF,
6729 sizeof(DAC960_V1_DCDB_T))) {
6730 ErrorCode = -EFAULT;
6734 ErrorCode = CommandStatus;
6736 if (DataTransferBuffer != NULL)
6737 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
6738 DataTransferBuffer, DataTransferBufferDMA);
6739 if (DCDB_IOBUF != NULL)
6740 pci_free_consistent(Controller->PCIDevice, sizeof(DAC960_V1_DCDB_T),
6741 DCDB_IOBUF, DCDB_IOBUFDMA);
6745 case DAC960_IOCTL_V2_EXECUTE_COMMAND:
6747 DAC960_V2_UserCommand_T *UserSpaceUserCommand =
6748 (DAC960_V2_UserCommand_T *) Argument;
6749 DAC960_V2_UserCommand_T UserCommand;
6750 DAC960_Controller_T *Controller;
6751 DAC960_Command_T *Command = NULL;
6752 DAC960_V2_CommandMailbox_T *CommandMailbox;
6753 DAC960_V2_CommandStatus_T CommandStatus;
6754 unsigned long flags;
6755 int ControllerNumber, DataTransferLength;
6756 int DataTransferResidue, RequestSenseLength;
6757 unsigned char *DataTransferBuffer = NULL;
6758 dma_addr_t DataTransferBufferDMA;
6759 unsigned char *RequestSenseBuffer = NULL;
6760 dma_addr_t RequestSenseBufferDMA;
6761 if (UserSpaceUserCommand == NULL) return -EINVAL;
6762 if (copy_from_user(&UserCommand, UserSpaceUserCommand,
6763 sizeof(DAC960_V2_UserCommand_T))) {
6764 ErrorCode = -EFAULT;
6767 ControllerNumber = UserCommand.ControllerNumber;
6768 if (ControllerNumber < 0 ||
6769 ControllerNumber > DAC960_ControllerCount - 1)
6771 Controller = DAC960_Controllers[ControllerNumber];
6772 if (Controller == NULL) return -ENXIO;
6773 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
6774 DataTransferLength = UserCommand.DataTransferLength;
6775 if (DataTransferLength > 0)
6777 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6778 DataTransferLength, &DataTransferBufferDMA);
6779 if (DataTransferBuffer == NULL) return -ENOMEM;
6780 memset(DataTransferBuffer, 0, DataTransferLength);
6782 else if (DataTransferLength < 0)
6784 DataTransferBuffer = pci_alloc_consistent(Controller->PCIDevice,
6785 -DataTransferLength, &DataTransferBufferDMA);
6786 if (DataTransferBuffer == NULL) return -ENOMEM;
6787 if (copy_from_user(DataTransferBuffer,
6788 UserCommand.DataTransferBuffer,
6789 -DataTransferLength)) {
6790 ErrorCode = -EFAULT;
6794 RequestSenseLength = UserCommand.RequestSenseLength;
6795 if (RequestSenseLength > 0)
6797 RequestSenseBuffer = pci_alloc_consistent(Controller->PCIDevice,
6798 RequestSenseLength, &RequestSenseBufferDMA);
6799 if (RequestSenseBuffer == NULL)
6801 ErrorCode = -ENOMEM;
6804 memset(RequestSenseBuffer, 0, RequestSenseLength);
6806 spin_lock_irqsave(&Controller->queue_lock, flags);
6807 while ((Command = DAC960_AllocateCommand(Controller)) == NULL)
6808 DAC960_WaitForCommand(Controller);
6809 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6810 DAC960_V2_ClearCommand(Command);
6811 Command->CommandType = DAC960_ImmediateCommand;
6812 CommandMailbox = &Command->V2.CommandMailbox;
6813 memcpy(CommandMailbox, &UserCommand.CommandMailbox,
6814 sizeof(DAC960_V2_CommandMailbox_T));
6815 CommandMailbox->Common.CommandControlBits
6816 .AdditionalScatterGatherListMemory = false;
6817 CommandMailbox->Common.CommandControlBits
6818 .NoAutoRequestSense = true;
6819 CommandMailbox->Common.DataTransferSize = 0;
6820 CommandMailbox->Common.DataTransferPageNumber = 0;
6821 memset(&CommandMailbox->Common.DataTransferMemoryAddress, 0,
6822 sizeof(DAC960_V2_DataTransferMemoryAddress_T));
6823 if (DataTransferLength != 0)
6825 if (DataTransferLength > 0)
6827 CommandMailbox->Common.CommandControlBits
6828 .DataTransferControllerToHost = true;
6829 CommandMailbox->Common.DataTransferSize = DataTransferLength;
6833 CommandMailbox->Common.CommandControlBits
6834 .DataTransferControllerToHost = false;
6835 CommandMailbox->Common.DataTransferSize = -DataTransferLength;
6837 CommandMailbox->Common.DataTransferMemoryAddress
6838 .ScatterGatherSegments[0]
6839 .SegmentDataPointer = DataTransferBufferDMA;
6840 CommandMailbox->Common.DataTransferMemoryAddress
6841 .ScatterGatherSegments[0]
6843 CommandMailbox->Common.DataTransferSize;
6845 if (RequestSenseLength > 0)
6847 CommandMailbox->Common.CommandControlBits
6848 .NoAutoRequestSense = false;
6849 CommandMailbox->Common.RequestSenseSize = RequestSenseLength;
6850 CommandMailbox->Common.RequestSenseBusAddress =
6851 RequestSenseBufferDMA;
6853 DAC960_ExecuteCommand(Command);
6854 CommandStatus = Command->V2.CommandStatus;
6855 RequestSenseLength = Command->V2.RequestSenseLength;
6856 DataTransferResidue = Command->V2.DataTransferResidue;
6857 spin_lock_irqsave(&Controller->queue_lock, flags);
6858 DAC960_DeallocateCommand(Command);
6859 spin_unlock_irqrestore(&Controller->queue_lock, flags);
6860 if (RequestSenseLength > UserCommand.RequestSenseLength)
6861 RequestSenseLength = UserCommand.RequestSenseLength;
6862 if (copy_to_user(&UserSpaceUserCommand->DataTransferLength,
6863 &DataTransferResidue,
6864 sizeof(DataTransferResidue))) {
6865 ErrorCode = -EFAULT;
6868 if (copy_to_user(&UserSpaceUserCommand->RequestSenseLength,
6869 &RequestSenseLength, sizeof(RequestSenseLength))) {
6870 ErrorCode = -EFAULT;
6873 if (DataTransferLength > 0)
6875 if (copy_to_user(UserCommand.DataTransferBuffer,
6876 DataTransferBuffer, DataTransferLength)) {
6877 ErrorCode = -EFAULT;
6881 if (RequestSenseLength > 0)
6883 if (copy_to_user(UserCommand.RequestSenseBuffer,
6884 RequestSenseBuffer, RequestSenseLength)) {
6885 ErrorCode = -EFAULT;
6889 ErrorCode = CommandStatus;
6891 pci_free_consistent(Controller->PCIDevice, abs(DataTransferLength),
6892 DataTransferBuffer, DataTransferBufferDMA);
6893 if (RequestSenseBuffer != NULL)
6894 pci_free_consistent(Controller->PCIDevice, RequestSenseLength,
6895 RequestSenseBuffer, RequestSenseBufferDMA);
6899 case DAC960_IOCTL_V2_GET_HEALTH_STATUS:
6901 DAC960_V2_GetHealthStatus_T *UserSpaceGetHealthStatus =
6902 (DAC960_V2_GetHealthStatus_T *) Argument;
6903 DAC960_V2_GetHealthStatus_T GetHealthStatus;
6904 DAC960_V2_HealthStatusBuffer_T HealthStatusBuffer;
6905 DAC960_Controller_T *Controller;
6906 int ControllerNumber;
6907 if (UserSpaceGetHealthStatus == NULL) return -EINVAL;
6908 if (copy_from_user(&GetHealthStatus, UserSpaceGetHealthStatus,
6909 sizeof(DAC960_V2_GetHealthStatus_T)))
6911 ControllerNumber = GetHealthStatus.ControllerNumber;
6912 if (ControllerNumber < 0 ||
6913 ControllerNumber > DAC960_ControllerCount - 1)
6915 Controller = DAC960_Controllers[ControllerNumber];
6916 if (Controller == NULL) return -ENXIO;
6917 if (Controller->FirmwareType != DAC960_V2_Controller) return -EINVAL;
6918 if (copy_from_user(&HealthStatusBuffer,
6919 GetHealthStatus.HealthStatusBuffer,
6920 sizeof(DAC960_V2_HealthStatusBuffer_T)))
6922 while (Controller->V2.HealthStatusBuffer->StatusChangeCounter
6923 == HealthStatusBuffer.StatusChangeCounter &&
6924 Controller->V2.HealthStatusBuffer->NextEventSequenceNumber
6925 == HealthStatusBuffer.NextEventSequenceNumber)
6927 interruptible_sleep_on_timeout(&Controller->HealthStatusWaitQueue,
6928 DAC960_MonitoringTimerInterval);
6929 if (signal_pending(current)) return -EINTR;
6931 if (copy_to_user(GetHealthStatus.HealthStatusBuffer,
6932 Controller->V2.HealthStatusBuffer,
6933 sizeof(DAC960_V2_HealthStatusBuffer_T)))
6941 static struct file_operations DAC960_gam_fops = {
6942 .owner = THIS_MODULE,
6943 .ioctl = DAC960_gam_ioctl
6946 static struct miscdevice DAC960_gam_dev = {
6952 static int DAC960_gam_init(void)
6956 ret = misc_register(&DAC960_gam_dev);
6958 printk(KERN_ERR "DAC960_gam: can't misc_register on minor %d\n", DAC960_GAM_MINOR);
6962 static void DAC960_gam_cleanup(void)
6964 misc_deregister(&DAC960_gam_dev);
6967 #endif /* DAC960_GAM_MINOR */
6969 static struct DAC960_privdata DAC960_BA_privdata = {
6970 .HardwareType = DAC960_BA_Controller,
6971 .FirmwareType = DAC960_V2_Controller,
6972 .InterruptHandler = DAC960_BA_InterruptHandler,
6973 .MemoryWindowSize = DAC960_BA_RegisterWindowSize,
6976 static struct DAC960_privdata DAC960_LP_privdata = {
6977 .HardwareType = DAC960_LP_Controller,
6978 .FirmwareType = DAC960_LP_Controller,
6979 .InterruptHandler = DAC960_LP_InterruptHandler,
6980 .MemoryWindowSize = DAC960_LP_RegisterWindowSize,
6983 static struct DAC960_privdata DAC960_LA_privdata = {
6984 .HardwareType = DAC960_LA_Controller,
6985 .FirmwareType = DAC960_V1_Controller,
6986 .InterruptHandler = DAC960_LA_InterruptHandler,
6987 .MemoryWindowSize = DAC960_LA_RegisterWindowSize,
6990 static struct DAC960_privdata DAC960_PG_privdata = {
6991 .HardwareType = DAC960_PG_Controller,
6992 .FirmwareType = DAC960_V1_Controller,
6993 .InterruptHandler = DAC960_PG_InterruptHandler,
6994 .MemoryWindowSize = DAC960_PG_RegisterWindowSize,
6997 static struct DAC960_privdata DAC960_PD_privdata = {
6998 .HardwareType = DAC960_PD_Controller,
6999 .FirmwareType = DAC960_V1_Controller,
7000 .InterruptHandler = DAC960_PD_InterruptHandler,
7001 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7004 static struct DAC960_privdata DAC960_P_privdata = {
7005 .HardwareType = DAC960_P_Controller,
7006 .FirmwareType = DAC960_V1_Controller,
7007 .InterruptHandler = DAC960_P_InterruptHandler,
7008 .MemoryWindowSize = DAC960_PD_RegisterWindowSize,
7011 static struct pci_device_id DAC960_id_table[] = {
7013 .vendor = PCI_VENDOR_ID_MYLEX,
7014 .device = PCI_DEVICE_ID_MYLEX_DAC960_BA,
7015 .subvendor = PCI_ANY_ID,
7016 .subdevice = PCI_ANY_ID,
7017 .driver_data = (unsigned long) &DAC960_BA_privdata,
7020 .vendor = PCI_VENDOR_ID_MYLEX,
7021 .device = PCI_DEVICE_ID_MYLEX_DAC960_LP,
7022 .subvendor = PCI_ANY_ID,
7023 .subdevice = PCI_ANY_ID,
7024 .driver_data = (unsigned long) &DAC960_LP_privdata,
7027 .vendor = PCI_VENDOR_ID_DEC,
7028 .device = PCI_DEVICE_ID_DEC_21285,
7029 .subvendor = PCI_VENDOR_ID_MYLEX,
7030 .subdevice = PCI_DEVICE_ID_MYLEX_DAC960_LA,
7031 .driver_data = (unsigned long) &DAC960_LA_privdata,
7034 .vendor = PCI_VENDOR_ID_MYLEX,
7035 .device = PCI_DEVICE_ID_MYLEX_DAC960_PG,
7036 .subvendor = PCI_ANY_ID,
7037 .subdevice = PCI_ANY_ID,
7038 .driver_data = (unsigned long) &DAC960_PG_privdata,
7041 .vendor = PCI_VENDOR_ID_MYLEX,
7042 .device = PCI_DEVICE_ID_MYLEX_DAC960_PD,
7043 .subvendor = PCI_ANY_ID,
7044 .subdevice = PCI_ANY_ID,
7045 .driver_data = (unsigned long) &DAC960_PD_privdata,
7048 .vendor = PCI_VENDOR_ID_MYLEX,
7049 .device = PCI_DEVICE_ID_MYLEX_DAC960_P,
7050 .subvendor = PCI_ANY_ID,
7051 .subdevice = PCI_ANY_ID,
7052 .driver_data = (unsigned long) &DAC960_P_privdata,
7057 MODULE_DEVICE_TABLE(pci, DAC960_id_table);
7059 static struct pci_driver DAC960_pci_driver = {
7061 .id_table = DAC960_id_table,
7062 .probe = DAC960_Probe,
7063 .remove = DAC960_Remove,
7066 static int DAC960_init_module(void)
7070 ret = pci_module_init(&DAC960_pci_driver);
7071 #ifdef DAC960_GAM_MINOR
7078 static void DAC960_cleanup_module(void)
7082 #ifdef DAC960_GAM_MINOR
7083 DAC960_gam_cleanup();
7086 for (i = 0; i < DAC960_ControllerCount; i++) {
7087 DAC960_Controller_T *Controller = DAC960_Controllers[i];
7088 if (Controller == NULL)
7090 DAC960_FinalizeController(Controller);
7092 if (DAC960_ProcDirectoryEntry != NULL) {
7093 remove_proc_entry("rd/status", NULL);
7094 remove_proc_entry("rd", NULL);
7096 DAC960_ControllerCount = 0;
7097 pci_unregister_driver(&DAC960_pci_driver);
7100 module_init(DAC960_init_module);
7101 module_exit(DAC960_cleanup_module);
7103 MODULE_LICENSE("GPL");