1 /***************************************************************************
5 copyright : (C) 2000 by Adaptec
6 email : deanna_bonds@adaptec.com
8 July 30, 2001 First version being submitted
9 for inclusion in the kernel. V2.4
11 See Documentation/scsi/dpti.txt for history, notes, license info
13 ***************************************************************************/
15 /***************************************************************************
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 ***************************************************************************/
27 // On the real kernel ADDR32 should always be zero for 2.4. GFP_HIGH allocates
28 // high pages. Keep the macro around because of the broken unmerged ia64 tree
32 #error Please convert me to Documentation/DMA-mapping.txt
34 #include <linux/version.h>
35 #include <linux/module.h>
37 MODULE_AUTHOR("Deanna Bonds, with _lots_ of help from Mark Salyzyn");
38 MODULE_DESCRIPTION("Adaptec I2O RAID Driver");
40 ////////////////////////////////////////////////////////////////
42 #include <linux/ioctl.h> /* For SCSI-Passthrough */
43 #include <asm/uaccess.h>
45 #include <linux/stat.h>
46 #include <linux/slab.h> /* for kmalloc() */
47 #include <linux/config.h> /* for CONFIG_PCI */
48 #include <linux/pci.h> /* for PCI support */
49 #include <linux/proc_fs.h>
50 #include <linux/blkdev.h>
51 #include <linux/delay.h> /* for udelay */
52 #include <linux/interrupt.h>
53 #include <linux/kernel.h> /* for printk */
54 #include <linux/sched.h>
55 #include <linux/reboot.h>
56 #include <linux/smp_lock.h>
58 #include <linux/timer.h>
59 #include <linux/string.h>
60 #include <linux/ioport.h>
61 #include <linux/stat.h>
63 #include <asm/processor.h> /* for boot_cpu_data */
64 #include <asm/pgtable.h>
65 #include <asm/io.h> /* for virt_to_bus, etc. */
70 #include "dpt/dptsig.h"
73 /*============================================================================
74 * Create a binary signature - this is read by dptsig
75 * Needed for our management apps
76 *============================================================================
78 static dpt_sig_S DPTI_sig = {
79 {'d', 'P', 't', 'S', 'i', 'G'}, SIG_VERSION,
81 PROC_INTEL, PROC_386 | PROC_486 | PROC_PENTIUM | PROC_SEXIUM,
82 #elif defined(__ia64__)
83 PROC_INTEL, PROC_IA64,
84 #elif defined(__sparc__)
86 #elif defined(__alpha__)
91 FT_HBADRVR, 0, OEM_DPT, OS_LINUX, CAP_OVERLAP, DEV_ALL,
92 ADF_ALL_SC5, 0, 0, DPT_VERSION, DPT_REVISION, DPT_SUBREVISION,
93 DPT_MONTH, DPT_DAY, DPT_YEAR, "Adaptec Linux I2O RAID Driver"
99 /*============================================================================
101 *============================================================================
104 DECLARE_MUTEX(adpt_configuration_lock);
106 static struct i2o_sys_tbl *sys_tbl = NULL;
107 static int sys_tbl_ind = 0;
108 static int sys_tbl_len = 0;
110 static adpt_hba* hbas[DPTI_MAX_HBA];
111 static adpt_hba* hba_chain = NULL;
112 static int hba_count = 0;
114 static struct file_operations adpt_fops = {
117 .release = adpt_close
120 #ifdef REBOOT_NOTIFIER
121 static struct notifier_block adpt_reboot_notifier =
129 /* Structures and definitions for synchronous message posting.
130 * See adpt_i2o_post_wait() for description
132 struct adpt_i2o_post_wait_data
136 adpt_wait_queue_head_t *wq;
137 struct adpt_i2o_post_wait_data *next;
140 static struct adpt_i2o_post_wait_data *adpt_post_wait_queue = NULL;
141 static u32 adpt_post_wait_id = 0;
142 static spinlock_t adpt_post_wait_lock = SPIN_LOCK_UNLOCKED;
145 /*============================================================================
147 *============================================================================
150 static u8 adpt_read_blink_led(adpt_hba* host)
152 if(host->FwDebugBLEDflag_P != 0) {
153 if( readb(host->FwDebugBLEDflag_P) == 0xbc ){
154 return readb(host->FwDebugBLEDvalue_P);
160 /*============================================================================
161 * Scsi host template interface functions
162 *============================================================================
165 static struct pci_device_id dptids[] = {
166 { PCI_DPT_VENDOR_ID, PCI_DPT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
167 { PCI_DPT_VENDOR_ID, PCI_DPT_RAPTOR_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
170 MODULE_DEVICE_TABLE(pci,dptids);
172 static int adpt_detect(Scsi_Host_Template* sht)
174 struct pci_dev *pDev = NULL;
179 PINFO("Detecting Adaptec I2O RAID controllers...\n");
181 /* search for all Adatpec I2O RAID cards */
182 while ((pDev = pci_find_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) {
183 if(pDev->device == PCI_DPT_DEVICE_ID ||
184 pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){
185 if(adpt_install_hba(sht, pDev) ){
186 PERROR("Could not Init an I2O RAID device\n");
187 PERROR("Will not try to detect others.\n");
193 /* In INIT state, Activate IOPs */
194 for (pHba = hba_chain; pHba; pHba = pHba->next) {
195 // Activate does get status , init outbound, and get hrt
196 if (adpt_i2o_activate_hba(pHba) < 0) {
197 adpt_i2o_delete_hba(pHba);
202 /* Active IOPs in HOLD state */
205 if (hba_chain == NULL)
209 * If build_sys_table fails, we kill everything and bail
210 * as we can't init the IOPs w/o a system table
212 if (adpt_i2o_build_sys_table() < 0) {
213 adpt_i2o_sys_shutdown();
217 PDEBUG("HBA's in HOLD state\n");
219 /* If IOP don't get online, we need to rebuild the System table */
220 for (pHba = hba_chain; pHba; pHba = pHba->next) {
221 if (adpt_i2o_online_hba(pHba) < 0) {
222 adpt_i2o_delete_hba(pHba);
223 goto rebuild_sys_tab;
227 /* Active IOPs now in OPERATIONAL state */
228 PDEBUG("HBA's in OPERATIONAL state\n");
230 printk(KERN_INFO"dpti: If you have a lot of devices this could take a few minutes.\n");
231 for (pHba = hba_chain; pHba; pHba = pHba->next) {
232 printk(KERN_INFO"%s: Reading the hardware resource table.\n", pHba->name);
233 if (adpt_i2o_lct_get(pHba) < 0){
234 adpt_i2o_delete_hba(pHba);
238 if (adpt_i2o_parse_lct(pHba) < 0){
239 adpt_i2o_delete_hba(pHba);
245 for (pHba = hba_chain; pHba; pHba = pHba->next) {
246 if( adpt_scsi_register(pHba,sht) < 0){
247 adpt_i2o_delete_hba(pHba);
250 pHba->initialized = TRUE;
251 pHba->state &= ~DPTI_STATE_RESET;
254 // Register our control device node
255 // nodes will need to be created in /dev to access this
256 // the nodes can not be created from within the driver
257 if (hba_count && register_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER, &adpt_fops)) {
258 adpt_i2o_sys_shutdown();
266 * scsi_unregister will be called AFTER we return.
268 static int adpt_release(struct Scsi_Host *host)
270 adpt_hba* pHba = (adpt_hba*) host->hostdata[0];
271 // adpt_i2o_quiesce_hba(pHba);
272 adpt_i2o_delete_hba(pHba);
277 static void adpt_inquiry(adpt_hba* pHba)
290 memset(msg, 0, sizeof(msg));
291 buf = (u8*)kmalloc(80,GFP_KERNEL|ADDR32);
293 printk(KERN_ERR"%s: Could not allocate buffer\n",pHba->name);
296 memset((void*)buf, 0, 36);
299 direction = 0x00000000;
300 scsidir =0x40000000; // DATA IN (iop<--dev)
302 reqlen = 14; // SINGLE SGE
303 /* Stick the headers on */
304 msg[0] = reqlen<<16 | SGL_OFFSET_12;
305 msg[1] = (0xff<<24|HOST_TID<<12|ADAPTER_TID);
308 // Adaptec/DPT Private stuff
309 msg[4] = I2O_CMD_SCSI_EXEC|DPT_ORGANIZATION_ID<<16;
310 msg[5] = ADAPTER_TID | 1<<16 /* Interpret*/;
311 /* Direction, disconnect ok | sense data | simple queue , CDBLen */
312 // I2O_SCB_FLAG_ENABLE_DISCONNECT |
313 // I2O_SCB_FLAG_SIMPLE_QUEUE_TAG |
314 // I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE;
315 msg[6] = scsidir|0x20a00000| 6 /* cmd len*/;
319 memset(scb, 0, sizeof(scb));
320 // Write SCSI command into the message - always 16 byte block
327 // Don't care about the rest of scb
329 memcpy(mptr, scb, sizeof(scb));
331 lenptr=mptr++; /* Remember me - fill in when we know */
333 /* Now fill in the SGList and command */
335 *mptr++ = 0xD0000000|direction|len;
336 *mptr++ = virt_to_bus(buf);
338 // Send it on it's way
339 rcode = adpt_i2o_post_wait(pHba, msg, reqlen<<2, 120);
341 sprintf(pHba->detail, "Adaptec I2O RAID");
342 printk(KERN_INFO "%s: Inquiry Error (%d)\n",pHba->name,rcode);
344 memset(pHba->detail, 0, sizeof(pHba->detail));
345 memcpy(&(pHba->detail), "Vendor: Adaptec ", 16);
346 memcpy(&(pHba->detail[16]), " Model: ", 8);
347 memcpy(&(pHba->detail[24]), (u8*) &buf[16], 16);
348 memcpy(&(pHba->detail[40]), " FW: ", 4);
349 memcpy(&(pHba->detail[44]), (u8*) &buf[32], 4);
350 pHba->detail[48] = '\0'; /* precautionary */
353 adpt_i2o_status_get(pHba);
358 static int adpt_slave_configure(Scsi_Device * device)
360 struct Scsi_Host *host = device->host;
363 pHba = (adpt_hba *) host->hostdata[0];
365 if (host->can_queue && device->tagged_supported) {
366 scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
367 host->can_queue - 1);
369 scsi_adjust_queue_depth(device, 0, 1);
374 static int adpt_queue(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
376 adpt_hba* pHba = NULL;
377 struct adpt_device* pDev = NULL; /* dpt per device information */
378 ulong timeout = jiffies + (TMOUT_SCSI*HZ);
380 cmd->scsi_done = done;
382 * SCSI REQUEST_SENSE commands will be executed automatically by the
383 * Host Adapter for any errors, so they should not be executed
384 * explicitly unless the Sense Data is zero indicating that no error
388 if ((cmd->cmnd[0] == REQUEST_SENSE) && (cmd->sense_buffer[0] != 0)) {
389 cmd->result = (DID_OK << 16);
394 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
401 * TODO: I need to block here if I am processing ioctl cmds
402 * but if the outstanding cmds all finish before the ioctl,
403 * the scsi-core will not know to start sending cmds to me again.
404 * I need to a way to restart the scsi-cores queues or should I block
405 * calling scsi_done on the outstanding cmds instead
406 * for now we don't set the IOCTL state
408 if(((pHba->state) & DPTI_STATE_IOCTL) || ((pHba->state) & DPTI_STATE_RESET)) {
409 pHba->host->last_reset = jiffies;
410 pHba->host->resetting = 1;
414 if(cmd->eh_state != SCSI_STATE_QUEUED){
415 // If we are not doing error recovery
416 mod_timer(&cmd->eh_timeout, timeout);
419 // TODO if the cmd->device if offline then I may need to issue a bus rescan
420 // followed by a get_lct to see if the device is there anymore
421 if((pDev = (struct adpt_device*) (cmd->device->hostdata)) == NULL) {
423 * First command request for this device. Set up a pointer
424 * to the device structure. This should be a TEST_UNIT_READY
425 * command from scan_scsis_single.
427 if ((pDev = adpt_find_device(pHba, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun)) == NULL) {
428 // TODO: if any luns are at this bus, scsi id then fake a TEST_UNIT_READY and INQUIRY response
429 // with type 7F (for all luns less than the max for this bus,id) so the lun scan will continue.
430 cmd->result = (DID_NO_CONNECT << 16);
434 (struct adpt_device*)(cmd->device->hostdata) = pDev;
436 pDev->pScsi_dev = cmd->device;
439 * If we are being called from when the device is being reset,
440 * delay processing of the command until later.
442 if (pDev->state & DPTI_DEV_RESET ) {
445 return adpt_scsi_to_i2o(pHba, cmd, pDev);
448 static int adpt_bios_param(struct scsi_device *sdev, struct block_device *dev,
449 sector_t capacity, int geom[])
455 // *** First lets set the default geometry ****
457 // If the capacity is less than ox2000
458 if (capacity < 0x2000 ) { // floppy
462 // else if between 0x2000 and 0x20000
463 else if (capacity < 0x20000) {
467 // else if between 0x20000 and 0x40000
468 else if (capacity < 0x40000) {
472 // else if between 0x4000 and 0x80000
473 else if (capacity < 0x80000) {
477 // else if greater than 0x80000
482 cylinders = capacity / (heads * sectors);
484 // Special case if CDROM
485 if(sdev->type == 5) { // CDROM
495 PDEBUG("adpt_bios_param: exit\n");
500 static const char *adpt_info(struct Scsi_Host *host)
504 pHba = (adpt_hba *) host->hostdata[0];
505 return (char *) (pHba->detail);
508 static int adpt_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
509 int length, int inout)
511 struct adpt_device* d;
523 * The user has done a write and wants us to take the
524 * data in the buffer and do something with it.
525 * proc_scsiwrite calls us with inout = 1
527 * Read data from buffer (writing to us) - NOT SUPPORTED
533 * inout = 0 means the user has done a read and wants information
534 * returned, so we write information about the cards into the buffer
535 * proc_scsiread() calls us with inout = 0
538 // Find HBA (host bus adapter) we are looking for
539 down(&adpt_configuration_lock);
540 for (pHba = hba_chain; pHba; pHba = pHba->next) {
541 if (pHba->host == host) {
542 break; /* found adapter */
545 up(&adpt_configuration_lock);
551 len = sprintf(buffer , "Adaptec I2O RAID Driver Version: %s\n\n", DPT_I2O_VERSION);
552 len += sprintf(buffer+len, "%s\n", pHba->detail);
553 len += sprintf(buffer+len, "SCSI Host=scsi%d Control Node=/dev/%s irq=%d\n",
554 pHba->host->host_no, pHba->name, host->irq);
555 len += sprintf(buffer+len, "\tpost fifo size = %d\n\treply fifo size = %d\n\tsg table size = %d\n\n",
556 host->can_queue, (int) pHba->reply_fifo_size , host->sg_tablesize);
561 if(pos > offset + length) {
566 * If we haven't even written to where we last left
567 * off (the last time we were called), reset the
573 len += sprintf(buffer+len, "Devices:\n");
574 for(chan = 0; chan < MAX_CHANNEL; chan++) {
575 for(id = 0; id < MAX_ID; id++) {
576 d = pHba->channel[chan].device[id];
578 len += sprintf(buffer+len,"\t%-24.24s", d->pScsi_dev->vendor);
579 len += sprintf(buffer+len," Rev: %-8.8s\n", d->pScsi_dev->rev);
584 if(pos > offset + length) {
592 unit = d->pI2o_dev->lct_data.tid;
593 len += sprintf(buffer+len, "\tTID=%d, (Channel=%d, Target=%d, Lun=%d) (%s)\n\n",
594 unit, (int)d->scsi_channel, (int)d->scsi_id, (int)d->scsi_lun,
595 scsi_device_online(d->pScsi_dev)? "online":"offline");
599 if(pos > offset + length) {
613 * begin is where we last checked our position with regards to offset
614 * begin is always less than offset. len is relative to begin. It
615 * is the number of bytes written past begin
619 /* stop the output and calculate the correct length */
620 *(buffer + len) = '\0';
622 *start = buffer + (offset - begin); /* Start of wanted data */
623 len -= (offset - begin);
634 /*===========================================================================
635 * Error Handling routines
636 *===========================================================================
639 static int adpt_abort(Scsi_Cmnd * cmd)
641 adpt_hba* pHba = NULL; /* host bus adapter structure */
642 struct adpt_device* dptdevice; /* dpt per device information */
646 if(cmd->serial_number == 0){
649 pHba = (adpt_hba*) cmd->device->host->hostdata[0];
650 printk(KERN_INFO"%s: Trying to Abort cmd=%ld\n",pHba->name, cmd->serial_number);
651 if ((dptdevice = (void*) (cmd->device->hostdata)) == NULL) {
652 printk(KERN_ERR "%s: Unable to abort: No device in cmnd\n",pHba->name);
656 memset(msg, 0, sizeof(msg));
657 msg[0] = FIVE_WORD_MSG_SIZE|SGL_OFFSET_0;
658 msg[1] = I2O_CMD_SCSI_ABORT<<24|HOST_TID<<12|dptdevice->tid;
662 if( (rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER)) != 0){
663 if(rcode == -EOPNOTSUPP ){
664 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name);
667 printk(KERN_INFO"%s: Abort cmd=%ld failed.\n",pHba->name, cmd->serial_number);
670 printk(KERN_INFO"%s: Abort cmd=%ld complete.\n",pHba->name, cmd->serial_number);
675 #define I2O_DEVICE_RESET 0x27
676 // This is the same for BLK and SCSI devices
677 // NOTE this is wrong in the i2o.h definitions
678 // This is not currently supported by our adapter but we issue it anyway
679 static int adpt_device_reset(Scsi_Cmnd* cmd)
685 struct adpt_device* d = (void*) cmd->device->hostdata;
687 pHba = (void*) cmd->device->host->hostdata[0];
688 printk(KERN_INFO"%s: Trying to reset device\n",pHba->name);
690 printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name);
693 memset(msg, 0, sizeof(msg));
694 msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
695 msg[1] = (I2O_DEVICE_RESET<<24|HOST_TID<<12|d->tid);
699 old_state = d->state;
700 d->state |= DPTI_DEV_RESET;
701 if( (rcode = adpt_i2o_post_wait(pHba, (void*)msg,sizeof(msg), FOREVER)) ){
702 d->state = old_state;
703 if(rcode == -EOPNOTSUPP ){
704 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name);
707 printk(KERN_INFO"%s: Device reset failed\n",pHba->name);
710 d->state = old_state;
711 printk(KERN_INFO"%s: Device reset successful\n",pHba->name);
717 #define I2O_HBA_BUS_RESET 0x87
718 // This version of bus reset is called by the eh_error handler
719 static int adpt_bus_reset(Scsi_Cmnd* cmd)
724 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
725 memset(msg, 0, sizeof(msg));
726 printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid );
727 msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
728 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
731 if(adpt_i2o_post_wait(pHba, (void*)msg,sizeof(msg), FOREVER) ){
732 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name);
735 printk(KERN_WARNING"%s: Bus reset success.\n",pHba->name);
740 // This version of reset is called by the eh_error_handler
741 static int adpt_reset(Scsi_Cmnd* cmd)
745 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
746 printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n",pHba->name,cmd->device->channel,pHba->channel[cmd->device->channel].tid );
747 rcode = adpt_hba_reset(pHba);
749 printk(KERN_WARNING"%s: HBA reset complete\n",pHba->name);
752 printk(KERN_WARNING"%s: HBA reset failed (%x)\n",pHba->name, rcode);
757 // This version of reset is called by the ioctls and indirectly from eh_error_handler via adpt_reset
758 static int adpt_hba_reset(adpt_hba* pHba)
762 pHba->state |= DPTI_STATE_RESET;
764 // Activate does get status , init outbound, and get hrt
765 if ((rcode=adpt_i2o_activate_hba(pHba)) < 0) {
766 printk(KERN_ERR "%s: Could not activate\n", pHba->name);
767 adpt_i2o_delete_hba(pHba);
771 if ((rcode=adpt_i2o_build_sys_table()) < 0) {
772 adpt_i2o_delete_hba(pHba);
775 PDEBUG("%s: in HOLD state\n",pHba->name);
777 if ((rcode=adpt_i2o_online_hba(pHba)) < 0) {
778 adpt_i2o_delete_hba(pHba);
781 PDEBUG("%s: in OPERATIONAL state\n",pHba->name);
783 if ((rcode=adpt_i2o_lct_get(pHba)) < 0){
784 adpt_i2o_delete_hba(pHba);
788 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0){
789 adpt_i2o_delete_hba(pHba);
792 pHba->state &= ~DPTI_STATE_RESET;
794 adpt_fail_posted_scbs(pHba);
795 return 0; /* return success */
798 /*===========================================================================
800 *===========================================================================
804 static void adpt_i2o_sys_shutdown(void)
806 adpt_hba *pHba, *pNext;
807 struct adpt_i2o_post_wait_data *p1, *p2;
809 printk(KERN_INFO"Shutting down Adaptec I2O controllers.\n");
810 printk(KERN_INFO" This could take a few minutes if there are many devices attached\n");
811 /* Delete all IOPs from the controller chain */
812 /* They should have already been released by the
815 for (pHba = hba_chain; pHba; pHba = pNext) {
817 adpt_i2o_delete_hba(pHba);
820 /* Remove any timedout entries from the wait queue. */
822 // spin_lock_irqsave(&adpt_post_wait_lock, flags);
823 /* Nothing should be outstanding at this point so just
826 for(p1 = adpt_post_wait_queue; p1; p2 = p1, p1 = p2->next) {
829 // spin_unlock_irqrestore(&adpt_post_wait_lock, flags);
830 adpt_post_wait_queue = 0;
832 printk(KERN_INFO "Adaptec I2O controllers down.\n");
836 * reboot/shutdown notification.
838 * - Quiesce each IOP in the system
842 #ifdef REBOOT_NOTIFIER
843 static int adpt_reboot_event(struct notifier_block *n, ulong code, void *p)
846 if(code != SYS_RESTART && code != SYS_HALT && code != SYS_POWER_OFF)
849 adpt_i2o_sys_shutdown();
856 static int adpt_install_hba(Scsi_Host_Template* sht, struct pci_dev* pDev)
859 adpt_hba* pHba = NULL;
861 ulong base_addr0_phys = 0;
862 ulong base_addr1_phys = 0;
863 u32 hba_map0_area_size = 0;
864 u32 hba_map1_area_size = 0;
865 ulong base_addr_virt = 0;
866 ulong msg_addr_virt = 0;
868 int raptorFlag = FALSE;
871 if(pci_enable_device(pDev)) {
874 pci_set_master(pDev);
876 base_addr0_phys = pci_resource_start(pDev,0);
877 hba_map0_area_size = pci_resource_len(pDev,0);
879 // Check if standard PCI card or single BAR Raptor
880 if(pDev->device == PCI_DPT_DEVICE_ID){
881 if(pDev->subsystem_device >=0xc032 && pDev->subsystem_device <= 0xc03b){
882 // Raptor card with this device id needs 4M
883 hba_map0_area_size = 0x400000;
884 } else { // Not Raptor - it is a PCI card
885 if(hba_map0_area_size > 0x100000 ){
886 hba_map0_area_size = 0x100000;
889 } else {// Raptor split BAR config
890 // Use BAR1 in this configuration
891 base_addr1_phys = pci_resource_start(pDev,1);
892 hba_map1_area_size = pci_resource_len(pDev,1);
897 base_addr_virt = (ulong)ioremap(base_addr0_phys,hba_map0_area_size);
898 if(base_addr_virt == 0) {
899 PERROR("dpti: adpt_config_hba: io remap failed\n");
903 if(raptorFlag == TRUE) {
904 msg_addr_virt = (ulong)ioremap(base_addr1_phys, hba_map1_area_size );
905 if(msg_addr_virt == 0) {
906 PERROR("dpti: adpt_config_hba: io remap failed on BAR1\n");
907 iounmap((void*)base_addr_virt);
911 msg_addr_virt = base_addr_virt;
914 // Allocate and zero the data structure
915 pHba = kmalloc(sizeof(adpt_hba), GFP_KERNEL);
917 if(msg_addr_virt != base_addr_virt){
918 iounmap((void*)msg_addr_virt);
920 iounmap((void*)base_addr_virt);
923 memset(pHba, 0, sizeof(adpt_hba));
925 down(&adpt_configuration_lock);
926 for(i=0;i<DPTI_MAX_HBA;i++) {
933 if(hba_chain != NULL){
934 for(p = hba_chain; p->next; p = p->next);
940 pHba->unit = hba_count;
941 sprintf(pHba->name, "dpti%d", i);
944 up(&adpt_configuration_lock);
947 pHba->base_addr_phys = base_addr0_phys;
949 // Set up the Virtual Base Address of the I2O Device
950 pHba->base_addr_virt = base_addr_virt;
951 pHba->msg_addr_virt = msg_addr_virt;
952 pHba->irq_mask = (ulong)(base_addr_virt+0x30);
953 pHba->post_port = (ulong)(base_addr_virt+0x40);
954 pHba->reply_port = (ulong)(base_addr_virt+0x44);
959 pHba->status_block = NULL;
960 pHba->post_count = 0;
961 pHba->state = DPTI_STATE_RESET;
963 pHba->devices = NULL;
965 // Initializing the spinlocks
966 spin_lock_init(&pHba->state_lock);
969 printk(KERN_INFO"Adaptec I2O RAID controller %d at %lx size=%x irq=%d\n",
970 hba_count-1, base_addr_virt, hba_map0_area_size, pDev->irq);
972 printk(KERN_INFO"Adaptec I2O RAID controller %d irq=%d\n",hba_count-1, pDev->irq);
973 printk(KERN_INFO" BAR0 %lx - size= %x\n",base_addr_virt,hba_map0_area_size);
974 printk(KERN_INFO" BAR1 %lx - size= %x\n",msg_addr_virt,hba_map1_area_size);
977 if (request_irq (pDev->irq, adpt_isr, SA_SHIRQ, pHba->name, pHba)) {
978 printk(KERN_ERR"%s: Couldn't register IRQ %d\n", pHba->name, pDev->irq);
979 adpt_i2o_delete_hba(pHba);
987 static void adpt_i2o_delete_hba(adpt_hba* pHba)
991 struct i2o_device* d;
992 struct i2o_device* next;
995 struct adpt_device* pDev;
996 struct adpt_device* pNext;
999 down(&adpt_configuration_lock);
1000 // scsi_unregister calls our adpt_release which
1003 free_irq(pHba->host->irq, pHba);
1005 for(i=0;i<DPTI_MAX_HBA;i++) {
1011 for( p1 = hba_chain; p1; p2 = p1,p1=p1->next){
1014 p2->next = p1->next;
1016 hba_chain = p1->next;
1023 up(&adpt_configuration_lock);
1025 iounmap((void*)pHba->base_addr_virt);
1026 if(pHba->msg_addr_virt != pHba->base_addr_virt){
1027 iounmap((void*)pHba->msg_addr_virt);
1035 if(pHba->status_block) {
1036 kfree(pHba->status_block);
1038 if(pHba->reply_pool){
1039 kfree(pHba->reply_pool);
1042 for(d = pHba->devices; d ; d = next){
1046 for(i = 0 ; i < pHba->top_scsi_channel ; i++){
1047 for(j = 0; j < MAX_ID; j++){
1048 if(pHba->channel[i].device[j] != NULL){
1049 for(pDev = pHba->channel[i].device[j]; pDev; pDev = pNext){
1050 pNext = pDev->next_lun;
1059 unregister_chrdev(DPTI_I2O_MAJOR, DPT_DRIVER);
1064 static int adpt_init(void)
1068 printk(KERN_INFO"Loading Adaptec I2O RAID: Version " DPT_I2O_VERSION "\n");
1069 for (i = 0; i < DPTI_MAX_HBA; i++) {
1072 #ifdef REBOOT_NOTIFIER
1073 register_reboot_notifier(&adpt_reboot_notifier);
1080 static struct adpt_device* adpt_find_device(adpt_hba* pHba, u32 chan, u32 id, u32 lun)
1082 struct adpt_device* d;
1084 if(chan < 0 || chan >= MAX_CHANNEL)
1087 if( pHba->channel[chan].device == NULL){
1088 printk(KERN_DEBUG"Adaptec I2O RAID: Trying to find device before they are allocated\n");
1092 d = pHba->channel[chan].device[id];
1093 if(!d || d->tid == 0) {
1097 /* If it is the only lun at that address then this should match*/
1098 if(d->scsi_lun == lun){
1102 /* else we need to look through all the luns */
1103 for(d=d->next_lun ; d ; d = d->next_lun){
1104 if(d->scsi_lun == lun){
1112 static int adpt_i2o_post_wait(adpt_hba* pHba, u32* msg, int len, int timeout)
1114 // I used my own version of the WAIT_QUEUE_HEAD
1115 // to handle some version differences
1116 // When embedded in the kernel this could go back to the vanilla one
1117 ADPT_DECLARE_WAIT_QUEUE_HEAD(adpt_wq_i2o_post);
1120 struct adpt_i2o_post_wait_data *p1, *p2;
1121 struct adpt_i2o_post_wait_data *wait_data =
1122 kmalloc(sizeof(struct adpt_i2o_post_wait_data),GFP_KERNEL);
1123 adpt_wait_queue_t wait;
1129 * The spin locking is needed to keep anyone from playing
1130 * with the queue pointers and id while we do the same
1132 spin_lock_irqsave(&adpt_post_wait_lock, flags);
1133 // TODO we need a MORE unique way of getting ids
1134 // to support async LCT get
1135 wait_data->next = adpt_post_wait_queue;
1136 adpt_post_wait_queue = wait_data;
1137 adpt_post_wait_id++;
1138 adpt_post_wait_id &= 0x7fff;
1139 wait_data->id = adpt_post_wait_id;
1140 spin_unlock_irqrestore(&adpt_post_wait_lock, flags);
1142 wait_data->wq = &adpt_wq_i2o_post;
1143 wait_data->status = -ETIMEDOUT;
1145 // this code is taken from kernel/sched.c:interruptible_sleep_on_timeout
1146 wait.task = current;
1147 init_waitqueue_entry(&wait, current);
1148 spin_lock_irqsave(&adpt_wq_i2o_post.lock, flags);
1149 __add_wait_queue(&adpt_wq_i2o_post, &wait);
1150 spin_unlock(&adpt_wq_i2o_post.lock);
1152 msg[2] |= 0x80000000 | ((u32)wait_data->id);
1154 if((status = adpt_i2o_post_this(pHba, msg, len)) == 0){
1155 set_current_state(TASK_INTERRUPTIBLE);
1156 spin_unlock_irq(pHba->host->host_lock);
1160 schedule_timeout(timeout*HZ);
1161 spin_lock_irq(pHba->host->host_lock);
1163 spin_lock_irq(&adpt_wq_i2o_post.lock);
1164 __remove_wait_queue(&adpt_wq_i2o_post, &wait);
1165 spin_unlock_irqrestore(&adpt_wq_i2o_post.lock, flags);
1167 if(status == -ETIMEDOUT){
1168 printk(KERN_INFO"dpti%d: POST WAIT TIMEOUT\n",pHba->unit);
1169 // We will have to free the wait_data memory during shutdown
1173 /* Remove the entry from the queue. */
1175 spin_lock_irqsave(&adpt_post_wait_lock, flags);
1176 for(p1 = adpt_post_wait_queue; p1; p2 = p1, p1 = p1->next) {
1177 if(p1 == wait_data) {
1178 if(p1->status == I2O_DETAIL_STATUS_UNSUPPORTED_FUNCTION ) {
1179 status = -EOPNOTSUPP;
1182 p2->next = p1->next;
1184 adpt_post_wait_queue = p1->next;
1189 spin_unlock_irqrestore(&adpt_post_wait_lock, flags);
1197 static s32 adpt_i2o_post_this(adpt_hba* pHba, u32* data, int len)
1200 u32 m = EMPTY_QUEUE;
1202 ulong timeout = jiffies + 30*HZ;
1205 m = readl(pHba->post_port);
1206 if (m != EMPTY_QUEUE) {
1209 if(time_after(jiffies,timeout)){
1210 printk(KERN_WARNING"dpti%d: Timeout waiting for message frame!\n", pHba->unit);
1213 } while(m == EMPTY_QUEUE);
1215 msg = (u32*) (pHba->msg_addr_virt + m);
1216 memcpy_toio(msg, data, len);
1220 writel(m, pHba->post_port);
1227 static void adpt_i2o_post_wait_complete(u32 context, int status)
1229 struct adpt_i2o_post_wait_data *p1 = NULL;
1231 * We need to search through the adpt_post_wait
1232 * queue to see if the given message is still
1233 * outstanding. If not, it means that the IOP
1234 * took longer to respond to the message than we
1235 * had allowed and timer has already expired.
1236 * Not much we can do about that except log
1237 * it for debug purposes, increase timeout, and recompile
1239 * Lock needed to keep anyone from moving queue pointers
1240 * around while we're looking through them.
1245 spin_lock(&adpt_post_wait_lock);
1246 for(p1 = adpt_post_wait_queue; p1; p1 = p1->next) {
1247 if(p1->id == context) {
1248 p1->status = status;
1249 spin_unlock(&adpt_post_wait_lock);
1250 wake_up_interruptible(p1->wq);
1254 spin_unlock(&adpt_post_wait_lock);
1255 // If this happens we lose commands that probably really completed
1256 printk(KERN_DEBUG"dpti: Could Not find task %d in wait queue\n",context);
1257 printk(KERN_DEBUG" Tasks in wait queue:\n");
1258 for(p1 = adpt_post_wait_queue; p1; p1 = p1->next) {
1259 printk(KERN_DEBUG" %d\n",p1->id);
1264 static s32 adpt_i2o_reset_hba(adpt_hba* pHba)
1268 u32 m = EMPTY_QUEUE ;
1269 ulong timeout = jiffies + (TMOUT_IOPRESET*HZ);
1271 if(pHba->initialized == FALSE) { // First time reset should be quick
1272 timeout = jiffies + (25*HZ);
1274 adpt_i2o_quiesce_hba(pHba);
1279 m = readl(pHba->post_port);
1280 if (m != EMPTY_QUEUE) {
1283 if(time_after(jiffies,timeout)){
1284 printk(KERN_WARNING"Timeout waiting for message!\n");
1287 } while (m == EMPTY_QUEUE);
1289 status = (u8*)kmalloc(4, GFP_KERNEL|ADDR32);
1290 if(status == NULL) {
1291 adpt_send_nop(pHba, m);
1292 printk(KERN_ERR"IOP reset failed - no free memory.\n");
1297 msg[0]=EIGHT_WORD_MSG_SIZE|SGL_OFFSET_0;
1298 msg[1]=I2O_CMD_ADAPTER_RESET<<24|HOST_TID<<12|ADAPTER_TID;
1303 msg[6]=virt_to_bus(status);
1306 memcpy_toio(pHba->msg_addr_virt+m, msg, sizeof(msg));
1308 writel(m, pHba->post_port);
1311 while(*status == 0){
1312 if(time_after(jiffies,timeout)){
1313 printk(KERN_WARNING"%s: IOP Reset Timeout\n",pHba->name);
1320 if(*status == 0x01 /*I2O_EXEC_IOP_RESET_IN_PROGRESS*/) {
1321 PDEBUG("%s: Reset in progress...\n", pHba->name);
1322 // Here we wait for message frame to become available
1323 // indicated that reset has finished
1326 m = readl(pHba->post_port);
1327 if (m != EMPTY_QUEUE) {
1330 if(time_after(jiffies,timeout)){
1331 printk(KERN_ERR "%s:Timeout waiting for IOP Reset.\n",pHba->name);
1334 } while (m == EMPTY_QUEUE);
1336 adpt_send_nop(pHba, m);
1338 adpt_i2o_status_get(pHba);
1339 if(*status == 0x02 ||
1340 pHba->status_block->iop_state != ADAPTER_STATE_RESET) {
1341 printk(KERN_WARNING"%s: Reset reject, trying to clear\n",
1344 PDEBUG("%s: Reset completed.\n", pHba->name);
1349 // This delay is to allow someone attached to the card through the debug UART to
1350 // set up the dump levels that they want before the rest of the initialization sequence
1357 static int adpt_i2o_parse_lct(adpt_hba* pHba)
1362 struct i2o_device *d;
1363 i2o_lct *lct = pHba->lct;
1367 u32 buf[10]; // larger than 7, or 8 ...
1368 struct adpt_device* pDev;
1371 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name);
1375 max = lct->table_size;
1379 for(i=0;i<max;i++) {
1380 if( lct->lct_entry[i].user_tid != 0xfff){
1382 * If we have hidden devices, we need to inform the upper layers about
1383 * the possible maximum id reference to handle device access when
1384 * an array is disassembled. This code has no other purpose but to
1385 * allow us future access to devices that are currently hidden
1386 * behind arrays, hotspares or have not been configured (JBOD mode).
1388 if( lct->lct_entry[i].class_id != I2O_CLASS_RANDOM_BLOCK_STORAGE &&
1389 lct->lct_entry[i].class_id != I2O_CLASS_SCSI_PERIPHERAL &&
1390 lct->lct_entry[i].class_id != I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){
1393 tid = lct->lct_entry[i].tid;
1394 // I2O_DPT_DEVICE_INFO_GROUP_NO;
1395 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) {
1398 bus_no = buf[0]>>16;
1400 scsi_lun = (buf[2]>>8 )&0xff;
1401 if(bus_no >= MAX_CHANNEL) { // Something wrong skip it
1402 printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no);
1405 if (scsi_id >= MAX_ID){
1406 printk(KERN_WARNING"%s: SCSI ID %d out of range \n", pHba->name, bus_no);
1409 if(bus_no > pHba->top_scsi_channel){
1410 pHba->top_scsi_channel = bus_no;
1412 if(scsi_id > pHba->top_scsi_id){
1413 pHba->top_scsi_id = scsi_id;
1415 if(scsi_lun > pHba->top_scsi_lun){
1416 pHba->top_scsi_lun = scsi_lun;
1420 d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
1423 printk(KERN_CRIT"%s: Out of memory for I2O device data.\n",pHba->name);
1427 d->controller = (void*)pHba;
1430 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
1433 tid = d->lct_data.tid;
1434 adpt_i2o_report_hba_unit(pHba, d);
1435 adpt_i2o_install_device(pHba, d);
1438 for(d = pHba->devices; d ; d = d->next) {
1439 if(d->lct_data.class_id == I2O_CLASS_BUS_ADAPTER_PORT ||
1440 d->lct_data.class_id == I2O_CLASS_FIBRE_CHANNEL_PORT){
1441 tid = d->lct_data.tid;
1442 // TODO get the bus_no from hrt-but for now they are in order
1444 if(bus_no > pHba->top_scsi_channel){
1445 pHba->top_scsi_channel = bus_no;
1447 pHba->channel[bus_no].type = d->lct_data.class_id;
1448 pHba->channel[bus_no].tid = tid;
1449 if(adpt_i2o_query_scalar(pHba, tid, 0x0200, -1, buf, 28)>=0)
1451 pHba->channel[bus_no].scsi_id = buf[1];
1452 PDEBUG("Bus %d - SCSI ID %d.\n", bus_no, buf[1]);
1454 // TODO remove - this is just until we get from hrt
1456 if(bus_no >= MAX_CHANNEL) { // Something wrong skip it
1457 printk(KERN_WARNING"%s: Channel number %d out of range - LCT\n", pHba->name, bus_no);
1463 // Setup adpt_device table
1464 for(d = pHba->devices; d ; d = d->next) {
1465 if(d->lct_data.class_id == I2O_CLASS_RANDOM_BLOCK_STORAGE ||
1466 d->lct_data.class_id == I2O_CLASS_SCSI_PERIPHERAL ||
1467 d->lct_data.class_id == I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){
1469 tid = d->lct_data.tid;
1471 // I2O_DPT_DEVICE_INFO_GROUP_NO;
1472 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)>=0) {
1473 bus_no = buf[0]>>16;
1475 scsi_lun = (buf[2]>>8 )&0xff;
1476 if(bus_no >= MAX_CHANNEL) { // Something wrong skip it
1479 if (scsi_id >= MAX_ID) {
1482 if( pHba->channel[bus_no].device[scsi_id] == NULL){
1483 pDev = kmalloc(sizeof(struct adpt_device),GFP_KERNEL);
1487 pHba->channel[bus_no].device[scsi_id] = pDev;
1488 memset(pDev,0,sizeof(struct adpt_device));
1490 for( pDev = pHba->channel[bus_no].device[scsi_id];
1491 pDev->next_lun; pDev = pDev->next_lun){
1493 pDev->next_lun = kmalloc(sizeof(struct adpt_device),GFP_KERNEL);
1494 if(pDev->next_lun == NULL) {
1497 memset(pDev->next_lun,0,sizeof(struct adpt_device));
1498 pDev = pDev->next_lun;
1501 pDev->scsi_channel = bus_no;
1502 pDev->scsi_id = scsi_id;
1503 pDev->scsi_lun = scsi_lun;
1506 pDev->type = (buf[0])&0xff;
1507 pDev->flags = (buf[0]>>8)&0xff;
1508 if(scsi_id > pHba->top_scsi_id){
1509 pHba->top_scsi_id = scsi_id;
1511 if(scsi_lun > pHba->top_scsi_lun){
1512 pHba->top_scsi_lun = scsi_lun;
1516 printk(KERN_WARNING"Could not find SCSI ID for %s\n",
1517 d->lct_data.identity_tag);
1526 * Each I2O controller has a chain of devices on it - these match
1527 * the useful parts of the LCT of the board.
1530 static int adpt_i2o_install_device(adpt_hba* pHba, struct i2o_device *d)
1532 down(&adpt_configuration_lock);
1535 d->next=pHba->devices;
1537 if (pHba->devices != NULL){
1538 pHba->devices->prev=d;
1543 up(&adpt_configuration_lock);
1547 static int adpt_open(struct inode *inode, struct file *file)
1552 //TODO check for root access
1554 minor = iminor(inode);
1555 if (minor >= hba_count) {
1558 down(&adpt_configuration_lock);
1559 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1560 if (pHba->unit == minor) {
1561 break; /* found adapter */
1565 up(&adpt_configuration_lock);
1569 // if(pHba->in_use){
1570 // up(&adpt_configuration_lock);
1575 up(&adpt_configuration_lock);
1580 static int adpt_close(struct inode *inode, struct file *file)
1585 minor = iminor(inode);
1586 if (minor >= hba_count) {
1589 down(&adpt_configuration_lock);
1590 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1591 if (pHba->unit == minor) {
1592 break; /* found adapter */
1595 up(&adpt_configuration_lock);
1606 static int adpt_i2o_passthru(adpt_hba* pHba, u32* arg)
1608 u32 msg[MAX_MESSAGE_SIZE];
1612 u32* user_msg = (u32*)arg;
1613 u32* user_reply = NULL;
1614 ulong sg_list[pHba->sg_tablesize];
1623 memset(&msg, 0, MAX_MESSAGE_SIZE*4);
1624 // get user msg size in u32s
1625 if(get_user(size, &user_msg[0])){
1630 user_reply = &user_msg[size];
1631 if(size > MAX_MESSAGE_SIZE){
1634 size *= 4; // Convert to bytes
1636 /* Copy in the user's I2O command */
1637 if(copy_from_user((void*)msg, (void*)user_msg, size)) {
1640 get_user(reply_size, &user_reply[0]);
1641 reply_size = reply_size>>16;
1642 if(reply_size > REPLY_FRAME_SIZE){
1643 reply_size = REPLY_FRAME_SIZE;
1646 reply = kmalloc(REPLY_FRAME_SIZE*4, GFP_KERNEL);
1648 printk(KERN_WARNING"%s: Could not allocate reply buffer\n",pHba->name);
1651 memset(reply,0,REPLY_FRAME_SIZE*4);
1652 sg_offset = (msg[0]>>4)&0xf;
1653 msg[2] = 0x40000000; // IOCTL context
1654 msg[3] = (u32)reply;
1655 memset(sg_list,0, sizeof(sg_list[0])*pHba->sg_tablesize);
1658 struct sg_simple_element *sg = (struct sg_simple_element*) (msg+sg_offset);
1659 sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element);
1660 if (sg_count > pHba->sg_tablesize){
1661 printk(KERN_DEBUG"%s:IOCTL SG List too large (%u)\n", pHba->name,sg_count);
1666 for(i = 0; i < sg_count; i++) {
1669 if (!(sg[i].flag_count & 0x10000000 /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT*/)) {
1670 printk(KERN_DEBUG"%s:Bad SG element %d - not simple (%x)\n",pHba->name,i, sg[i].flag_count);
1674 sg_size = sg[i].flag_count & 0xffffff;
1675 /* Allocate memory for the transfer */
1676 p = (ulong)kmalloc(sg_size, GFP_KERNEL|ADDR32);
1678 printk(KERN_DEBUG"%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
1679 pHba->name,sg_size,i,sg_count);
1683 sg_list[sg_index++] = p; // sglist indexed with input frame, not our internal frame.
1684 /* Copy in the user's SG buffer if necessary */
1685 if(sg[i].flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR*/) {
1687 if (copy_from_user((void*)p,(void*)sg[i].addr_bus, sg_size)) {
1688 printk(KERN_DEBUG"%s: Could not copy SG buf %d FROM user\n",pHba->name,i);
1694 sg[i].addr_bus = (u32)virt_to_bus((void*)p);
1699 spin_lock_irqsave(pHba->host->host_lock, flags);
1700 // This state stops any new commands from enterring the
1701 // controller while processing the ioctl
1702 // pHba->state |= DPTI_STATE_IOCTL;
1703 // We can't set this now - The scsi subsystem sets host_blocked and
1704 // the queue empties and stops. We need a way to restart the queue
1705 rcode = adpt_i2o_post_wait(pHba, msg, size, FOREVER);
1706 // pHba->state &= ~DPTI_STATE_IOCTL;
1707 spin_unlock_irqrestore(pHba->host->host_lock, flags);
1708 } while(rcode == -ETIMEDOUT);
1715 /* Copy back the Scatter Gather buffers back to user space */
1718 struct sg_simple_element* sg;
1721 // re-acquire the original message to handle correctly the sg copy operation
1722 memset(&msg, 0, MAX_MESSAGE_SIZE*4);
1723 // get user msg size in u32s
1724 if(get_user(size, &user_msg[0])){
1730 /* Copy in the user's I2O command */
1731 if (copy_from_user ((void*)msg, (void*)user_msg, size)) {
1735 sg_count = (size - sg_offset*4) / sizeof(struct sg_simple_element);
1738 sg = (struct sg_simple_element*)(msg + sg_offset);
1739 for (j = 0; j < sg_count; j++) {
1740 /* Copy out the SG list to user's buffer if necessary */
1741 if(! (sg[j].flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR*/)) {
1742 sg_size = sg[j].flag_count & 0xffffff;
1744 if (copy_to_user((void*)sg[j].addr_bus,(void*)sg_list[j], sg_size)) {
1745 printk(KERN_WARNING"%s: Could not copy %lx TO user %x\n",pHba->name, sg_list[j], sg[j].addr_bus);
1753 /* Copy back the reply to user space */
1755 // we wrote our own values for context - now restore the user supplied ones
1756 if(copy_from_user(reply+2, user_msg+2, sizeof(u32)*2)) {
1757 printk(KERN_WARNING"%s: Could not copy message context FROM user\n",pHba->name);
1760 if(copy_to_user(user_reply, reply, reply_size)) {
1761 printk(KERN_WARNING"%s: Could not copy reply TO user\n",pHba->name);
1770 if(sg_list[--sg_index]) {
1771 kfree((void*)(sg_list[sg_index]));
1779 * This routine returns information about the system. This does not effect
1780 * any logic and if the info is wrong - it doesn't matter.
1783 /* Get all the info we can not get from kernel services */
1784 static int adpt_system_info(void *buffer)
1788 memset(&si, 0, sizeof(si));
1790 si.osType = OS_LINUX;
1791 si.osMajorVersion = (u8) (LINUX_VERSION_CODE >> 16);
1792 si.osMinorVersion = (u8) (LINUX_VERSION_CODE >> 8 & 0x0ff);
1793 si.osRevision = (u8) (LINUX_VERSION_CODE & 0x0ff);
1794 si.busType = SI_PCI_BUS;
1795 si.processorFamily = DPTI_sig.dsProcessorFamily;
1797 #if defined __i386__
1798 adpt_i386_info(&si);
1799 #elif defined (__ia64__)
1800 adpt_ia64_info(&si);
1801 #elif defined(__sparc__)
1802 adpt_sparc_info(&si);
1803 #elif defined (__alpha__)
1804 adpt_alpha_info(&si);
1806 si.processorType = 0xff ;
1808 if(copy_to_user(buffer, &si, sizeof(si))){
1809 printk(KERN_WARNING"dpti: Could not copy buffer TO user\n");
1816 #if defined __ia64__
1817 static void adpt_ia64_info(sysInfo_S* si)
1819 // This is all the info we need for now
1820 // We will add more info as our new
1821 // managmenent utility requires it
1822 si->processorType = PROC_IA64;
1827 #if defined __sparc__
1828 static void adpt_sparc_info(sysInfo_S* si)
1830 // This is all the info we need for now
1831 // We will add more info as our new
1832 // managmenent utility requires it
1833 si->processorType = PROC_ULTRASPARC;
1837 #if defined __alpha__
1838 static void adpt_alpha_info(sysInfo_S* si)
1840 // This is all the info we need for now
1841 // We will add more info as our new
1842 // managmenent utility requires it
1843 si->processorType = PROC_ALPHA;
1847 #if defined __i386__
1849 static void adpt_i386_info(sysInfo_S* si)
1851 // This is all the info we need for now
1852 // We will add more info as our new
1853 // managmenent utility requires it
1854 switch (boot_cpu_data.x86) {
1856 si->processorType = PROC_386;
1859 si->processorType = PROC_486;
1862 si->processorType = PROC_PENTIUM;
1864 default: // Just in case
1865 si->processorType = PROC_PENTIUM;
1873 static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
1881 minor = iminor(inode);
1882 if (minor >= DPTI_MAX_HBA){
1885 down(&adpt_configuration_lock);
1886 for (pHba = hba_chain; pHba; pHba = pHba->next) {
1887 if (pHba->unit == minor) {
1888 break; /* found adapter */
1891 up(&adpt_configuration_lock);
1896 while((volatile u32) pHba->state & DPTI_STATE_RESET ) {
1897 set_task_state(current,TASK_UNINTERRUPTIBLE);
1898 schedule_timeout(2);
1903 // TODO: handle 3 cases
1905 if (copy_to_user((char*)arg, &DPTI_sig, sizeof(DPTI_sig))) {
1910 return adpt_i2o_passthru(pHba,(u32*)arg);
1914 drvrHBAinfo_S HbaInfo;
1916 #define FLG_OSD_PCI_VALID 0x0001
1917 #define FLG_OSD_DMA 0x0002
1918 #define FLG_OSD_I2O 0x0004
1919 memset(&HbaInfo, 0, sizeof(HbaInfo));
1920 HbaInfo.drvrHBAnum = pHba->unit;
1921 HbaInfo.baseAddr = (ulong) pHba->base_addr_phys;
1922 HbaInfo.blinkState = adpt_read_blink_led(pHba);
1923 HbaInfo.pciBusNum = pHba->pDev->bus->number;
1924 HbaInfo.pciDeviceNum=PCI_SLOT(pHba->pDev->devfn);
1925 HbaInfo.Interrupt = pHba->pDev->irq;
1926 HbaInfo.hbaFlags = FLG_OSD_PCI_VALID | FLG_OSD_DMA | FLG_OSD_I2O;
1927 if(copy_to_user((void *) arg, &HbaInfo, sizeof(HbaInfo))){
1928 printk(KERN_WARNING"%s: Could not copy HbaInfo TO user\n",pHba->name);
1934 return adpt_system_info((void*)arg);
1938 value = (u32)adpt_read_blink_led(pHba);
1939 if (copy_to_user((char*)arg, &value, sizeof(value))) {
1945 spin_lock_irqsave(pHba->host->host_lock, flags);
1946 adpt_hba_reset(pHba);
1947 spin_unlock_irqrestore(pHba->host->host_lock, flags);
1960 static void adpt_isr(int irq, void *dev_id, struct pt_regs *regs)
1963 adpt_hba* pHba = dev_id;
1971 printk(KERN_WARNING"adpt_isr: NULL dev_id\n");
1974 spin_lock_irqsave(pHba->host->host_lock, flags);
1975 while( readl(pHba->irq_mask) & I2O_INTERRUPT_PENDING_B) {
1976 m = readl(pHba->reply_port);
1977 if(m == EMPTY_QUEUE){
1978 // Try twice then give up
1980 m = readl(pHba->reply_port);
1981 if(m == EMPTY_QUEUE){
1982 // This really should not happen
1983 printk(KERN_ERR"dpti: Could not get reply frame\n");
1987 reply = (ulong)bus_to_virt(m);
1989 if (readl(reply) & MSG_FAIL) {
1990 u32 old_m = readl(reply+28);
1993 PDEBUG("%s: Failed message\n",pHba->name);
1994 if(old_m >= 0x100000){
1995 printk(KERN_ERR"%s: Bad preserved MFA (%x)- dropping frame\n",pHba->name,old_m);
1996 writel(m,pHba->reply_port);
1999 // Transaction context is 0 in failed reply frame
2000 msg = (ulong)(pHba->msg_addr_virt + old_m);
2001 old_context = readl(msg+12);
2002 writel(old_context, reply+12);
2003 adpt_send_nop(pHba, old_m);
2005 context = readl(reply+8);
2006 if(context & 0x40000000){ // IOCTL
2007 ulong p = (ulong)(readl(reply+12));
2009 memcpy((void*)p, (void*)reply, REPLY_FRAME_SIZE * 4);
2011 // All IOCTLs will also be post wait
2013 if(context & 0x80000000){ // Post wait message
2014 status = readl(reply+16);
2016 status &= 0xffff; /* Get detail status */
2018 status = I2O_POST_WAIT_OK;
2020 if(!(context & 0x40000000)) {
2021 cmd = (Scsi_Cmnd*) readl(reply+12);
2023 printk(KERN_WARNING"%s: Apparent SCSI cmd in Post Wait Context - cmd=%p context=%x\n", pHba->name, cmd, context);
2026 adpt_i2o_post_wait_complete(context, status);
2027 } else { // SCSI message
2028 cmd = (Scsi_Cmnd*) readl(reply+12);
2030 if(cmd->serial_number != 0) { // If not timedout
2031 adpt_i2o_to_scsi(reply, cmd);
2035 writel(m, pHba->reply_port);
2039 out: spin_unlock_irqrestore(pHba->host->host_lock, flags);
2042 static s32 adpt_scsi_to_i2o(adpt_hba* pHba, Scsi_Cmnd* cmd, struct adpt_device* d)
2045 u32 msg[MAX_MESSAGE_SIZE];
2054 memset(msg, 0 , sizeof(msg));
2055 len = cmd->request_bufflen;
2056 direction = 0x00000000;
2058 scsidir = 0x00000000; // DATA NO XFER
2061 * Set SCBFlags to indicate if data is being transferred
2062 * in or out, or no data transfer
2063 * Note: Do not have to verify index is less than 0 since
2064 * cmd->cmnd[0] is an unsigned char
2066 switch(cmd->sc_data_direction){
2067 case SCSI_DATA_READ:
2068 scsidir =0x40000000; // DATA IN (iop<--dev)
2070 case SCSI_DATA_WRITE:
2071 direction=0x04000000; // SGL OUT
2072 scsidir =0x80000000; // DATA OUT (iop-->dev)
2074 case SCSI_DATA_NONE:
2076 case SCSI_DATA_UNKNOWN:
2077 scsidir =0x40000000; // DATA IN (iop<--dev)
2078 // Assume In - and continue;
2081 printk(KERN_WARNING"%s: scsi opcode 0x%x not supported.\n",
2082 pHba->name, cmd->cmnd[0]);
2083 cmd->result = (DID_OK <<16) | (INITIATOR_ERROR << 8);
2084 cmd->scsi_done(cmd);
2088 // msg[0] is set later
2089 // I2O_CMD_SCSI_EXEC
2090 msg[1] = ((0xff<<24)|(HOST_TID<<12)|d->tid);
2092 msg[3] = (u32)cmd; /* We want the SCSI control block back */
2093 // Our cards use the transaction context as the tag for queueing
2094 // Adaptec/DPT Private stuff
2095 msg[4] = I2O_CMD_SCSI_EXEC|(DPT_ORGANIZATION_ID<<16);
2097 /* Direction, disconnect ok | sense data | simple queue , CDBLen */
2098 // I2O_SCB_FLAG_ENABLE_DISCONNECT |
2099 // I2O_SCB_FLAG_SIMPLE_QUEUE_TAG |
2100 // I2O_SCB_FLAG_SENSE_DATA_IN_MESSAGE;
2101 msg[6] = scsidir|0x20a00000|cmd->cmd_len;
2105 // Write SCSI command into the message - always 16 byte block
2106 memset(mptr, 0, 16);
2107 memcpy(mptr, cmd->cmnd, cmd->cmd_len);
2109 lenptr=mptr++; /* Remember me - fill in when we know */
2110 reqlen = 14; // SINGLE SGE
2111 /* Now fill in the SGList and command */
2113 struct scatterlist *sg = (struct scatterlist *)cmd->request_buffer;
2115 for(i = 0 ; i < cmd->use_sg; i++) {
2116 *mptr++ = direction|0x10000000|sg->length;
2118 *mptr++ = virt_to_bus(sg->address);
2121 /* Make this an end of list */
2122 mptr[-2] = direction|0xD0000000|(sg-1)->length;
2123 reqlen = mptr - msg;
2126 if(cmd->underflow && len != cmd->underflow){
2127 printk(KERN_WARNING"Cmd len %08X Cmd underflow %08X\n",
2128 len, cmd->underflow);
2131 *lenptr = len = cmd->request_bufflen;
2135 *mptr++ = 0xD0000000|direction|cmd->request_bufflen;
2136 *mptr++ = virt_to_bus(cmd->request_buffer);
2140 /* Stick the headers on */
2141 msg[0] = reqlen<<16 | ((reqlen > 12) ? SGL_OFFSET_12 : SGL_OFFSET_0);
2143 // Send it on it's way
2144 rcode = adpt_i2o_post_this(pHba, msg, reqlen<<2);
2152 static s32 adpt_scsi_register(adpt_hba* pHba,Scsi_Host_Template * sht)
2154 struct Scsi_Host *host = NULL;
2156 host = scsi_register(sht, sizeof(adpt_hba*));
2158 printk ("%s: scsi_register returned NULL\n",pHba->name);
2161 (adpt_hba*)(host->hostdata[0]) = pHba;
2164 host->irq = pHba->pDev->irq;
2165 /* no IO ports, so don't have to set host->io_port and
2169 host->n_io_port = 0;
2170 /* see comments in hosts.h */
2172 host->max_lun = 256;
2173 host->max_channel = pHba->top_scsi_channel + 1;
2174 host->cmd_per_lun = 1;
2175 host->unique_id = (uint) pHba;
2176 host->sg_tablesize = pHba->sg_tablesize;
2177 host->can_queue = pHba->post_fifo_size;
2183 static s32 adpt_i2o_to_scsi(ulong reply, Scsi_Cmnd* cmd)
2188 u32 reply_flags = readl(reply) & 0xff00; // Leave it shifted up 8 bits
2189 // I know this would look cleaner if I just read bytes
2190 // but the model I have been using for all the rest of the
2191 // io is in 4 byte words - so I keep that model
2192 u16 detailed_status = readl(reply+16) &0xffff;
2193 dev_status = (detailed_status & 0xff);
2194 hba_status = detailed_status >> 8;
2196 // calculate resid for sg
2197 cmd->resid = cmd->request_bufflen - readl(reply+5);
2199 pHba = (adpt_hba*) cmd->device->host->hostdata[0];
2201 cmd->sense_buffer[0] = '\0'; // initialize sense valid flag to false
2203 if(!(reply_flags & MSG_FAIL)) {
2204 switch(detailed_status & I2O_SCSI_DSC_MASK) {
2205 case I2O_SCSI_DSC_SUCCESS:
2206 cmd->result = (DID_OK << 16);
2208 if(readl(reply+5) < cmd->underflow ) {
2209 cmd->result = (DID_ERROR <<16);
2210 printk(KERN_WARNING"%s: SCSI CMD underflow\n",pHba->name);
2213 case I2O_SCSI_DSC_REQUEST_ABORTED:
2214 cmd->result = (DID_ABORT << 16);
2216 case I2O_SCSI_DSC_PATH_INVALID:
2217 case I2O_SCSI_DSC_DEVICE_NOT_PRESENT:
2218 case I2O_SCSI_DSC_SELECTION_TIMEOUT:
2219 case I2O_SCSI_DSC_COMMAND_TIMEOUT:
2220 case I2O_SCSI_DSC_NO_ADAPTER:
2221 case I2O_SCSI_DSC_RESOURCE_UNAVAILABLE:
2222 printk(KERN_WARNING"%s: SCSI Timeout-Device (%d,%d,%d) hba status=0x%x, dev status=0x%x, cmd=0x%x\n",
2223 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun, hba_status, dev_status, cmd->cmnd[0]);
2224 cmd->result = (DID_TIME_OUT << 16);
2226 case I2O_SCSI_DSC_ADAPTER_BUSY:
2227 case I2O_SCSI_DSC_BUS_BUSY:
2228 cmd->result = (DID_BUS_BUSY << 16);
2230 case I2O_SCSI_DSC_SCSI_BUS_RESET:
2231 case I2O_SCSI_DSC_BDR_MESSAGE_SENT:
2232 cmd->result = (DID_RESET << 16);
2234 case I2O_SCSI_DSC_PARITY_ERROR_FAILURE:
2235 printk(KERN_WARNING"%s: SCSI CMD parity error\n",pHba->name);
2236 cmd->result = (DID_PARITY << 16);
2238 case I2O_SCSI_DSC_UNABLE_TO_ABORT:
2239 case I2O_SCSI_DSC_COMPLETE_WITH_ERROR:
2240 case I2O_SCSI_DSC_UNABLE_TO_TERMINATE:
2241 case I2O_SCSI_DSC_MR_MESSAGE_RECEIVED:
2242 case I2O_SCSI_DSC_AUTOSENSE_FAILED:
2243 case I2O_SCSI_DSC_DATA_OVERRUN:
2244 case I2O_SCSI_DSC_UNEXPECTED_BUS_FREE:
2245 case I2O_SCSI_DSC_SEQUENCE_FAILURE:
2246 case I2O_SCSI_DSC_REQUEST_LENGTH_ERROR:
2247 case I2O_SCSI_DSC_PROVIDE_FAILURE:
2248 case I2O_SCSI_DSC_REQUEST_TERMINATED:
2249 case I2O_SCSI_DSC_IDE_MESSAGE_SENT:
2250 case I2O_SCSI_DSC_UNACKNOWLEDGED_EVENT:
2251 case I2O_SCSI_DSC_MESSAGE_RECEIVED:
2252 case I2O_SCSI_DSC_INVALID_CDB:
2253 case I2O_SCSI_DSC_LUN_INVALID:
2254 case I2O_SCSI_DSC_SCSI_TID_INVALID:
2255 case I2O_SCSI_DSC_FUNCTION_UNAVAILABLE:
2256 case I2O_SCSI_DSC_NO_NEXUS:
2257 case I2O_SCSI_DSC_CDB_RECEIVED:
2258 case I2O_SCSI_DSC_LUN_ALREADY_ENABLED:
2259 case I2O_SCSI_DSC_QUEUE_FROZEN:
2260 case I2O_SCSI_DSC_REQUEST_INVALID:
2262 printk(KERN_WARNING"%s: SCSI error %0x-Device(%d,%d,%d) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
2263 pHba->name, detailed_status & I2O_SCSI_DSC_MASK, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun,
2264 hba_status, dev_status, cmd->cmnd[0]);
2265 cmd->result = (DID_ERROR << 16);
2269 // copy over the request sense data if it was a check
2271 if(dev_status == 0x02 /*CHECK_CONDITION*/) {
2272 u32 len = sizeof(cmd->sense_buffer);
2273 len = (len > 40) ? 40 : len;
2274 // Copy over the sense data
2275 memcpy(cmd->sense_buffer, (void*)(reply+28) , len);
2276 if(cmd->sense_buffer[0] == 0x70 /* class 7 */ &&
2277 cmd->sense_buffer[2] == DATA_PROTECT ){
2278 /* This is to handle an array failed */
2279 cmd->result = (DID_TIME_OUT << 16);
2280 printk(KERN_WARNING"%s: SCSI Data Protect-Device (%d,%d,%d) hba_status=0x%x, dev_status=0x%x, cmd=0x%x\n",
2281 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun,
2282 hba_status, dev_status, cmd->cmnd[0]);
2287 /* In this condtion we could not talk to the tid
2288 * the card rejected it. We should signal a retry
2289 * for a limitted number of retries.
2291 cmd->result = (DID_TIME_OUT << 16);
2292 printk(KERN_WARNING"%s: I2O MSG_FAIL - Device (%d,%d,%d) tid=%d, cmd=0x%x\n",
2293 pHba->name, (u32)cmd->device->channel, (u32)cmd->device->id, (u32)cmd->device->lun,
2294 ((struct adpt_device*)(cmd->device->hostdata))->tid, cmd->cmnd[0]);
2297 cmd->result |= (dev_status);
2299 if(cmd->scsi_done != NULL){
2300 cmd->scsi_done(cmd);
2306 static s32 adpt_rescan(adpt_hba* pHba)
2311 spin_lock_irqsave(pHba->host->host_lock, flags);
2312 if ((rcode=adpt_i2o_lct_get(pHba)) < 0)
2314 if ((rcode=adpt_i2o_reparse_lct(pHba)) < 0)
2317 out: spin_unlock_irqrestore(pHba->host->host_lock, flags);
2322 static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
2327 struct i2o_device *d;
2328 i2o_lct *lct = pHba->lct;
2332 u32 buf[10]; // at least 8 u32's
2333 struct adpt_device* pDev = NULL;
2334 struct i2o_device* pI2o_dev = NULL;
2337 printk(KERN_ERR "%s: LCT is empty???\n",pHba->name);
2341 max = lct->table_size;
2345 // Mark each drive as unscanned
2346 for (d = pHba->devices; d; d = d->next) {
2347 pDev =(struct adpt_device*) d->owner;
2351 pDev->state |= DPTI_DEV_UNSCANNED;
2354 printk(KERN_INFO "%s: LCT has %d entries.\n", pHba->name,max);
2356 for(i=0;i<max;i++) {
2357 if( lct->lct_entry[i].user_tid != 0xfff){
2361 if( lct->lct_entry[i].class_id == I2O_CLASS_RANDOM_BLOCK_STORAGE ||
2362 lct->lct_entry[i].class_id == I2O_CLASS_SCSI_PERIPHERAL ||
2363 lct->lct_entry[i].class_id == I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL ){
2364 tid = lct->lct_entry[i].tid;
2365 if(adpt_i2o_query_scalar(pHba, tid, 0x8000, -1, buf, 32)<0) {
2366 printk(KERN_ERR"%s: Could not query device\n",pHba->name);
2369 bus_no = buf[0]>>16;
2371 scsi_lun = (buf[2]>>8 )&0xff;
2372 pDev = pHba->channel[bus_no].device[scsi_id];
2375 if(pDev->scsi_lun == scsi_lun) {
2378 pDev = pDev->next_lun;
2380 if(!pDev ) { // Something new add it
2381 d = (struct i2o_device *)kmalloc(sizeof(struct i2o_device), GFP_KERNEL);
2384 printk(KERN_CRIT "Out of memory for I2O device data.\n");
2388 d->controller = (void*)pHba;
2391 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
2394 adpt_i2o_report_hba_unit(pHba, d);
2395 adpt_i2o_install_device(pHba, d);
2397 if(bus_no >= MAX_CHANNEL) { // Something wrong skip it
2398 printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no);
2401 pDev = pHba->channel[bus_no].device[scsi_id];
2403 pDev = kmalloc(sizeof(struct adpt_device),GFP_KERNEL);
2407 pHba->channel[bus_no].device[scsi_id] = pDev;
2409 while (pDev->next_lun) {
2410 pDev = pDev->next_lun;
2412 pDev = pDev->next_lun = kmalloc(sizeof(struct adpt_device),GFP_KERNEL);
2417 memset(pDev,0,sizeof(struct adpt_device));
2418 pDev->tid = d->lct_data.tid;
2419 pDev->scsi_channel = bus_no;
2420 pDev->scsi_id = scsi_id;
2421 pDev->scsi_lun = scsi_lun;
2424 pDev->type = (buf[0])&0xff;
2425 pDev->flags = (buf[0]>>8)&0xff;
2426 // Too late, SCSI system has made up it's mind, but what the hey ...
2427 if(scsi_id > pHba->top_scsi_id){
2428 pHba->top_scsi_id = scsi_id;
2430 if(scsi_lun > pHba->top_scsi_lun){
2431 pHba->top_scsi_lun = scsi_lun;
2434 } // end of new i2o device
2436 // We found an old device - check it
2438 if(pDev->scsi_lun == scsi_lun) {
2439 if(!scsi_device_online(pDev->pScsi_dev)) {
2440 printk(KERN_WARNING"%s: Setting device (%d,%d,%d) back online\n",
2441 pHba->name,bus_no,scsi_id,scsi_lun);
2442 if (pDev->pScsi_dev) {
2443 scsi_device_set_state(pDev->pScsi_dev, SDEV_RUNNING);
2447 if(d->lct_data.tid != tid) { // something changed
2449 memcpy(&d->lct_data, &lct->lct_entry[i], sizeof(i2o_lct_entry));
2450 if (pDev->pScsi_dev) {
2451 pDev->pScsi_dev->changed = TRUE;
2452 pDev->pScsi_dev->removable = TRUE;
2455 // Found it - mark it scanned
2456 pDev->state = DPTI_DEV_ONLINE;
2459 pDev = pDev->next_lun;
2463 for (pI2o_dev = pHba->devices; pI2o_dev; pI2o_dev = pI2o_dev->next) {
2464 pDev =(struct adpt_device*) pI2o_dev->owner;
2468 // Drive offline drives that previously existed but could not be found
2470 if (pDev->state & DPTI_DEV_UNSCANNED){
2471 pDev->state = DPTI_DEV_OFFLINE;
2472 printk(KERN_WARNING"%s: Device (%d,%d,%d) offline\n",pHba->name,pDev->scsi_channel,pDev->scsi_id,pDev->scsi_lun);
2473 if (pDev->pScsi_dev) {
2474 scsi_device_set_state(pDev->pScsi_dev, SDEV_OFFLINE);
2481 static void adpt_fail_posted_scbs(adpt_hba* pHba)
2483 Scsi_Cmnd* cmd = NULL;
2484 Scsi_Device* d = NULL;
2486 shost_for_each_device(d, pHba->host) {
2487 unsigned long flags;
2488 spin_lock_irqsave(&d->list_lock, flags);
2489 list_for_each_entry(cmd, &d->cmd_list, list) {
2490 if(cmd->serial_number == 0){
2493 cmd->result = (DID_OK << 16) | (QUEUE_FULL <<1);
2494 cmd->scsi_done(cmd);
2496 spin_unlock_irqrestore(&d->list_lock, flags);
2501 /*============================================================================
2502 * Routines from i2o subsystem
2503 *============================================================================
2509 * Bring an I2O controller into HOLD state. See the spec.
2511 static int adpt_i2o_activate_hba(adpt_hba* pHba)
2515 if(pHba->initialized ) {
2516 if (adpt_i2o_status_get(pHba) < 0) {
2517 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){
2518 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name);
2521 if (adpt_i2o_status_get(pHba) < 0) {
2522 printk(KERN_INFO "HBA not responding.\n");
2527 if(pHba->status_block->iop_state == ADAPTER_STATE_FAULTED) {
2528 printk(KERN_CRIT "%s: hardware fault\n", pHba->name);
2532 if (pHba->status_block->iop_state == ADAPTER_STATE_READY ||
2533 pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL ||
2534 pHba->status_block->iop_state == ADAPTER_STATE_HOLD ||
2535 pHba->status_block->iop_state == ADAPTER_STATE_FAILED) {
2536 adpt_i2o_reset_hba(pHba);
2537 if (adpt_i2o_status_get(pHba) < 0 || pHba->status_block->iop_state != ADAPTER_STATE_RESET) {
2538 printk(KERN_ERR "%s: Failed to initialize.\n", pHba->name);
2543 if((rcode = adpt_i2o_reset_hba(pHba)) != 0){
2544 printk(KERN_WARNING"%s: Could NOT reset.\n", pHba->name);
2550 if (adpt_i2o_init_outbound_q(pHba) < 0) {
2556 if (adpt_i2o_hrt_get(pHba) < 0) {
2564 * Bring a controller online into OPERATIONAL state.
2567 static int adpt_i2o_online_hba(adpt_hba* pHba)
2569 if (adpt_i2o_systab_send(pHba) < 0) {
2570 adpt_i2o_delete_hba(pHba);
2573 /* In READY state */
2575 if (adpt_i2o_enable_hba(pHba) < 0) {
2576 adpt_i2o_delete_hba(pHba);
2580 /* In OPERATIONAL state */
2584 static s32 adpt_send_nop(adpt_hba*pHba,u32 m)
2587 ulong timeout = jiffies + 5*HZ;
2589 while(m == EMPTY_QUEUE){
2591 m = readl(pHba->post_port);
2592 if(m != EMPTY_QUEUE){
2595 if(time_after(jiffies,timeout)){
2596 printk(KERN_ERR "%s: Timeout waiting for message frame!\n",pHba->name);
2600 msg = (u32*)(pHba->msg_addr_virt + m);
2601 writel( THREE_WORD_MSG_SIZE | SGL_OFFSET_0,&msg[0]);
2602 writel( I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | 0,&msg[1]);
2606 writel(m, pHba->post_port);
2611 static s32 adpt_i2o_init_outbound_q(adpt_hba* pHba)
2616 ulong timeout = jiffies + TMOUT_INITOUTBOUND*HZ;
2618 u32 outbound_frame; // This had to be a 32 bit address
2623 m = readl(pHba->post_port);
2624 if (m != EMPTY_QUEUE) {
2628 if(time_after(jiffies,timeout)){
2629 printk(KERN_WARNING"%s: Timeout waiting for message frame\n",pHba->name);
2632 } while(m == EMPTY_QUEUE);
2634 msg=(u32 *)(pHba->msg_addr_virt+m);
2636 status = kmalloc(4,GFP_KERNEL|ADDR32);
2638 adpt_send_nop(pHba, m);
2639 printk(KERN_WARNING"%s: IOP reset failed - no free memory.\n",
2643 memset(status, 0, 4);
2645 writel(EIGHT_WORD_MSG_SIZE| SGL_OFFSET_6, &msg[0]);
2646 writel(I2O_CMD_OUTBOUND_INIT<<24 | HOST_TID<<12 | ADAPTER_TID, &msg[1]);
2648 writel(0x0106, &msg[3]); /* Transaction context */
2649 writel(4096, &msg[4]); /* Host page frame size */
2650 writel((REPLY_FRAME_SIZE)<<16|0x80, &msg[5]); /* Outbound msg frame size and Initcode */
2651 writel(0xD0000004, &msg[6]); /* Simple SG LE, EOB */
2652 writel(virt_to_bus(status), &msg[7]);
2654 writel(m, pHba->post_port);
2657 // Wait for the reply status to come back
2660 if (*status != 0x01 /*I2O_EXEC_OUTBOUND_INIT_IN_PROGRESS*/) {
2665 if(time_after(jiffies,timeout)){
2666 printk(KERN_WARNING"%s: Timeout Initializing\n",pHba->name);
2667 kfree((void*)status);
2672 // If the command was successful, fill the fifo with our reply
2674 if(*status != 0x04 /*I2O_EXEC_OUTBOUND_INIT_COMPLETE*/) {
2675 kfree((void*)status);
2678 kfree((void*)status);
2680 if(pHba->reply_pool != NULL){
2681 kfree(pHba->reply_pool);
2684 pHba->reply_pool = (u32*)kmalloc(pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4, GFP_KERNEL|ADDR32);
2685 if(!pHba->reply_pool){
2686 printk(KERN_ERR"%s: Could not allocate reply pool\n",pHba->name);
2689 memset(pHba->reply_pool, 0 , pHba->reply_fifo_size * REPLY_FRAME_SIZE * 4);
2691 ptr = pHba->reply_pool;
2692 for(i = 0; i < pHba->reply_fifo_size; i++) {
2693 outbound_frame = (u32)virt_to_bus(ptr);
2694 writel(outbound_frame, pHba->reply_port);
2696 ptr += REPLY_FRAME_SIZE;
2698 adpt_i2o_status_get(pHba);
2704 * I2O System Table. Contains information about
2705 * all the IOPs in the system. Used to inform IOPs
2706 * about each other's existence.
2708 * sys_tbl_ver is the CurrentChangeIndicator that is
2709 * used by IOPs to track changes.
2714 static s32 adpt_i2o_status_get(adpt_hba* pHba)
2719 u8 *status_block=NULL;
2720 ulong status_block_bus;
2722 if(pHba->status_block == NULL) {
2723 pHba->status_block = (i2o_status_block*)
2724 kmalloc(sizeof(i2o_status_block),GFP_KERNEL|ADDR32);
2725 if(pHba->status_block == NULL) {
2727 "dpti%d: Get Status Block failed; Out of memory. \n",
2732 memset(pHba->status_block, 0, sizeof(i2o_status_block));
2733 status_block = (u8*)(pHba->status_block);
2734 status_block_bus = virt_to_bus(pHba->status_block);
2735 timeout = jiffies+TMOUT_GETSTATUS*HZ;
2738 m = readl(pHba->post_port);
2739 if (m != EMPTY_QUEUE) {
2742 if(time_after(jiffies,timeout)){
2743 printk(KERN_ERR "%s: Timeout waiting for message !\n",
2747 } while(m==EMPTY_QUEUE);
2750 msg=(u32*)(pHba->msg_addr_virt+m);
2752 writel(NINE_WORD_MSG_SIZE|SGL_OFFSET_0, &msg[0]);
2753 writel(I2O_CMD_STATUS_GET<<24|HOST_TID<<12|ADAPTER_TID, &msg[1]);
2758 writel(((u32)status_block_bus)&0xffffffff, &msg[6]);
2760 writel(sizeof(i2o_status_block), &msg[8]); // 88 bytes
2763 writel(m, pHba->post_port);
2766 while(status_block[87]!=0xff){
2767 if(time_after(jiffies,timeout)){
2768 printk(KERN_ERR"dpti%d: Get status timeout.\n",
2775 // Set up our number of outbound and inbound messages
2776 pHba->post_fifo_size = pHba->status_block->max_inbound_frames;
2777 if (pHba->post_fifo_size > MAX_TO_IOP_MESSAGES) {
2778 pHba->post_fifo_size = MAX_TO_IOP_MESSAGES;
2781 pHba->reply_fifo_size = pHba->status_block->max_outbound_frames;
2782 if (pHba->reply_fifo_size > MAX_FROM_IOP_MESSAGES) {
2783 pHba->reply_fifo_size = MAX_FROM_IOP_MESSAGES;
2786 // Calculate the Scatter Gather list size
2787 pHba->sg_tablesize = (pHba->status_block->inbound_frame_size * 4 -40)/ sizeof(struct sg_simple_element);
2788 if (pHba->sg_tablesize > SG_LIST_ELEMENTS) {
2789 pHba->sg_tablesize = SG_LIST_ELEMENTS;
2794 printk("dpti%d: State = ",pHba->unit);
2795 switch(pHba->status_block->iop_state) {
2809 printk("OPERATIONAL\n");
2815 printk("FAULTED\n");
2818 printk("%x (unknown!!)\n",pHba->status_block->iop_state);
2825 * Get the IOP's Logical Configuration Table
2827 static int adpt_i2o_lct_get(adpt_hba* pHba)
2833 if ((pHba->lct_size == 0) || (pHba->lct == NULL)){
2834 pHba->lct_size = pHba->status_block->expected_lct_size;
2837 if (pHba->lct == NULL) {
2838 pHba->lct = kmalloc(pHba->lct_size, GFP_KERNEL|ADDR32);
2839 if(pHba->lct == NULL) {
2840 printk(KERN_CRIT "%s: Lct Get failed. Out of memory.\n",
2845 memset(pHba->lct, 0, pHba->lct_size);
2847 msg[0] = EIGHT_WORD_MSG_SIZE|SGL_OFFSET_6;
2848 msg[1] = I2O_CMD_LCT_NOTIFY<<24 | HOST_TID<<12 | ADAPTER_TID;
2851 msg[4] = 0xFFFFFFFF; /* All devices */
2852 msg[5] = 0x00000000; /* Report now */
2853 msg[6] = 0xD0000000|pHba->lct_size;
2854 msg[7] = virt_to_bus(pHba->lct);
2856 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 360))) {
2857 printk(KERN_ERR "%s: LCT Get failed (status=%#10x.\n",
2859 printk(KERN_ERR"Adaptec: Error Reading Hardware.\n");
2863 if ((pHba->lct->table_size << 2) > pHba->lct_size) {
2864 pHba->lct_size = pHba->lct->table_size << 2;
2868 } while (pHba->lct == NULL);
2870 PDEBUG("%s: Hardware resource table read.\n", pHba->name);
2873 // I2O_DPT_EXEC_IOP_BUFFERS_GROUP_NO;
2874 if(adpt_i2o_query_scalar(pHba, 0 , 0x8000, -1, buf, sizeof(buf))>=0) {
2875 pHba->FwDebugBufferSize = buf[1];
2876 pHba->FwDebugBuffer_P = pHba->base_addr_virt + buf[0];
2877 pHba->FwDebugFlags_P = pHba->FwDebugBuffer_P + FW_DEBUG_FLAGS_OFFSET;
2878 pHba->FwDebugBLEDvalue_P = pHba->FwDebugBuffer_P + FW_DEBUG_BLED_OFFSET;
2879 pHba->FwDebugBLEDflag_P = pHba->FwDebugBLEDvalue_P + 1;
2880 pHba->FwDebugStrLength_P = pHba->FwDebugBuffer_P + FW_DEBUG_STR_LENGTH_OFFSET;
2881 pHba->FwDebugBuffer_P += buf[2];
2882 pHba->FwDebugFlags = 0;
2888 static int adpt_i2o_build_sys_table(void)
2890 adpt_hba* pHba = NULL;
2893 sys_tbl_len = sizeof(struct i2o_sys_tbl) + // Header + IOPs
2894 (hba_count) * sizeof(struct i2o_sys_tbl_entry);
2899 sys_tbl = kmalloc(sys_tbl_len, GFP_KERNEL|ADDR32);
2901 printk(KERN_WARNING "SysTab Set failed. Out of memory.\n");
2904 memset(sys_tbl, 0, sys_tbl_len);
2906 sys_tbl->num_entries = hba_count;
2907 sys_tbl->version = I2OVERSION;
2908 sys_tbl->change_ind = sys_tbl_ind++;
2910 for(pHba = hba_chain; pHba; pHba = pHba->next) {
2911 // Get updated Status Block so we have the latest information
2912 if (adpt_i2o_status_get(pHba)) {
2913 sys_tbl->num_entries--;
2914 continue; // try next one
2917 sys_tbl->iops[count].org_id = pHba->status_block->org_id;
2918 sys_tbl->iops[count].iop_id = pHba->unit + 2;
2919 sys_tbl->iops[count].seg_num = 0;
2920 sys_tbl->iops[count].i2o_version = pHba->status_block->i2o_version;
2921 sys_tbl->iops[count].iop_state = pHba->status_block->iop_state;
2922 sys_tbl->iops[count].msg_type = pHba->status_block->msg_type;
2923 sys_tbl->iops[count].frame_size = pHba->status_block->inbound_frame_size;
2924 sys_tbl->iops[count].last_changed = sys_tbl_ind - 1; // ??
2925 sys_tbl->iops[count].iop_capabilities = pHba->status_block->iop_capabilities;
2926 sys_tbl->iops[count].inbound_low = (u32)virt_to_bus((void*)pHba->post_port);
2927 sys_tbl->iops[count].inbound_high = (u32)((u64)virt_to_bus((void*)pHba->post_port)>>32);
2934 u32 *table = (u32*)sys_tbl;
2935 printk(KERN_DEBUG"sys_tbl_len=%d in 32bit words\n",(sys_tbl_len >>2));
2936 for(count = 0; count < (sys_tbl_len >>2); count++) {
2937 printk(KERN_INFO "sys_tbl[%d] = %0#10x\n",
2938 count, table[count]);
2948 * Dump the information block associated with a given unit (TID)
2951 static void adpt_i2o_report_hba_unit(adpt_hba* pHba, struct i2o_device *d)
2954 int unit = d->lct_data.tid;
2956 printk(KERN_INFO "TID %3.3d ", unit);
2958 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 3, buf, 16)>=0)
2961 printk(" Vendor: %-12.12s", buf);
2963 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 4, buf, 16)>=0)
2966 printk(" Device: %-12.12s", buf);
2968 if(adpt_i2o_query_scalar(pHba, unit, 0xF100, 6, buf, 8)>=0)
2971 printk(" Rev: %-12.12s\n", buf);
2974 printk(KERN_INFO "\tClass: %.21s\n", adpt_i2o_get_class_name(d->lct_data.class_id));
2975 printk(KERN_INFO "\tSubclass: 0x%04X\n", d->lct_data.sub_class);
2976 printk(KERN_INFO "\tFlags: ");
2978 if(d->lct_data.device_flags&(1<<0))
2979 printk("C"); // ConfigDialog requested
2980 if(d->lct_data.device_flags&(1<<1))
2981 printk("U"); // Multi-user capable
2982 if(!(d->lct_data.device_flags&(1<<4)))
2983 printk("P"); // Peer service enabled!
2984 if(!(d->lct_data.device_flags&(1<<5)))
2985 printk("M"); // Mgmt service enabled!
2992 * Do i2o class name lookup
2994 static const char *adpt_i2o_get_class_name(int class)
2997 static char *i2o_class_name[] = {
2999 "Device Driver Module",
3004 "Fibre Channel Port",
3005 "Fibre Channel Device",
3009 "Floppy Controller",
3011 "Secondary Bus Port",
3012 "Peer Transport Agent",
3017 switch(class&0xFFF) {
3018 case I2O_CLASS_EXECUTIVE:
3022 case I2O_CLASS_RANDOM_BLOCK_STORAGE:
3024 case I2O_CLASS_SEQUENTIAL_STORAGE:
3030 case I2O_CLASS_FIBRE_CHANNEL_PORT:
3032 case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
3034 case I2O_CLASS_SCSI_PERIPHERAL:
3036 case I2O_CLASS_ATE_PORT:
3038 case I2O_CLASS_ATE_PERIPHERAL:
3040 case I2O_CLASS_FLOPPY_CONTROLLER:
3042 case I2O_CLASS_FLOPPY_DEVICE:
3044 case I2O_CLASS_BUS_ADAPTER_PORT:
3046 case I2O_CLASS_PEER_TRANSPORT_AGENT:
3048 case I2O_CLASS_PEER_TRANSPORT:
3051 return i2o_class_name[idx];
3056 static s32 adpt_i2o_hrt_get(adpt_hba* pHba)
3059 int ret, size = sizeof(i2o_hrt);
3062 if (pHba->hrt == NULL) {
3063 pHba->hrt=kmalloc(size, GFP_KERNEL|ADDR32);
3064 if (pHba->hrt == NULL) {
3065 printk(KERN_CRIT "%s: Hrt Get failed; Out of memory.\n", pHba->name);
3070 msg[0]= SIX_WORD_MSG_SIZE| SGL_OFFSET_4;
3071 msg[1]= I2O_CMD_HRT_GET<<24 | HOST_TID<<12 | ADAPTER_TID;
3074 msg[4]= (0xD0000000 | size); /* Simple transaction */
3075 msg[5]= virt_to_bus(pHba->hrt); /* Dump it here */
3077 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg),20))) {
3078 printk(KERN_ERR "%s: Unable to get HRT (status=%#10x)\n", pHba->name, ret);
3082 if (pHba->hrt->num_entries * pHba->hrt->entry_len << 2 > size) {
3083 size = pHba->hrt->num_entries * pHba->hrt->entry_len << 2;
3087 } while(pHba->hrt == NULL);
3092 * Query one scalar group value or a whole scalar group.
3094 static int adpt_i2o_query_scalar(adpt_hba* pHba, int tid,
3095 int group, int field, void *buf, int buflen)
3097 u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field };
3098 u8 resblk[8+buflen]; /* 8 bytes for header */
3101 if (field == -1) /* whole group */
3104 size = adpt_i2o_issue_params(I2O_CMD_UTIL_PARAMS_GET, pHba, tid,
3105 opblk, sizeof(opblk), resblk, sizeof(resblk));
3107 memcpy(buf, resblk+8, buflen); /* cut off header */
3116 /* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
3118 * This function can be used for all UtilParamsGet/Set operations.
3119 * The OperationBlock is given in opblk-buffer,
3120 * and results are returned in resblk-buffer.
3121 * Note that the minimum sized resblk is 8 bytes and contains
3122 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
3124 static int adpt_i2o_issue_params(int cmd, adpt_hba* pHba, int tid,
3125 void *opblk, int oplen, void *resblk, int reslen)
3128 u32 *res = (u32 *)resblk;
3131 msg[0] = NINE_WORD_MSG_SIZE | SGL_OFFSET_5;
3132 msg[1] = cmd << 24 | HOST_TID << 12 | tid;
3136 msg[5] = 0x54000000 | oplen; /* OperationBlock */
3137 msg[6] = virt_to_bus(opblk);
3138 msg[7] = 0xD0000000 | reslen; /* ResultBlock */
3139 msg[8] = virt_to_bus(resblk);
3141 if ((wait_status = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 20))) {
3142 return wait_status; /* -DetailedStatus */
3145 if (res[1]&0x00FF0000) { /* BlockStatus != SUCCESS */
3146 printk(KERN_WARNING "%s: %s - Error:\n ErrorInfoSize = 0x%02x, "
3147 "BlockStatus = 0x%02x, BlockSize = 0x%04x\n",
3149 (cmd == I2O_CMD_UTIL_PARAMS_SET) ? "PARAMS_SET"
3151 res[1]>>24, (res[1]>>16)&0xFF, res[1]&0xFFFF);
3152 return -((res[1] >> 16) & 0xFF); /* -BlockStatus */
3155 return 4 + ((res[1] & 0x0000FFFF) << 2); /* bytes used in resblk */
3159 static s32 adpt_i2o_quiesce_hba(adpt_hba* pHba)
3164 adpt_i2o_status_get(pHba);
3166 /* SysQuiesce discarded if IOP not in READY or OPERATIONAL state */
3168 if((pHba->status_block->iop_state != ADAPTER_STATE_READY) &&
3169 (pHba->status_block->iop_state != ADAPTER_STATE_OPERATIONAL)){
3173 msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
3174 msg[1] = I2O_CMD_SYS_QUIESCE<<24|HOST_TID<<12|ADAPTER_TID;
3178 if((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) {
3179 printk(KERN_INFO"dpti%d: Unable to quiesce (status=%#x).\n",
3182 printk(KERN_INFO"dpti%d: Quiesced.\n",pHba->unit);
3185 adpt_i2o_status_get(pHba);
3191 * Enable IOP. Allows the IOP to resume external operations.
3193 static int adpt_i2o_enable_hba(adpt_hba* pHba)
3198 adpt_i2o_status_get(pHba);
3199 if(!pHba->status_block){
3202 /* Enable only allowed on READY state */
3203 if(pHba->status_block->iop_state == ADAPTER_STATE_OPERATIONAL)
3206 if(pHba->status_block->iop_state != ADAPTER_STATE_READY)
3209 msg[0]=FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
3210 msg[1]=I2O_CMD_SYS_ENABLE<<24|HOST_TID<<12|ADAPTER_TID;
3214 if ((ret = adpt_i2o_post_wait(pHba, msg, sizeof(msg), 240))) {
3215 printk(KERN_WARNING"%s: Could not enable (status=%#10x).\n",
3218 PDEBUG("%s: Enabled.\n", pHba->name);
3221 adpt_i2o_status_get(pHba);
3226 static int adpt_i2o_systab_send(adpt_hba* pHba)
3231 msg[0] = I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6;
3232 msg[1] = I2O_CMD_SYS_TAB_SET<<24 | HOST_TID<<12 | ADAPTER_TID;
3235 msg[4] = (0<<16) | ((pHba->unit+2) << 12); /* Host 0 IOP ID (unit + 2) */
3236 msg[5] = 0; /* Segment 0 */
3239 * Provide three SGL-elements:
3240 * System table (SysTab), Private memory space declaration and
3241 * Private i/o space declaration
3243 msg[6] = 0x54000000 | sys_tbl_len;
3244 msg[7] = virt_to_phys(sys_tbl);
3245 msg[8] = 0x54000000 | 0;
3247 msg[10] = 0xD4000000 | 0;
3250 if ((ret=adpt_i2o_post_wait(pHba, msg, sizeof(msg), 120))) {
3251 printk(KERN_INFO "%s: Unable to set SysTab (status=%#10x).\n",
3256 PINFO("%s: SysTab set.\n", pHba->name);
3264 /*============================================================================
3266 *============================================================================
3272 static static void adpt_delay(int millisec)
3275 for (i = 0; i < millisec; i++) {
3276 udelay(1000); /* delay for one millisecond */
3282 static Scsi_Host_Template driver_template = {
3284 .proc_name = "dpt_i2o",
3285 .proc_info = adpt_proc_info,
3286 .detect = adpt_detect,
3287 .release = adpt_release,
3289 .queuecommand = adpt_queue,
3290 .eh_abort_handler = adpt_abort,
3291 .eh_device_reset_handler = adpt_device_reset,
3292 .eh_bus_reset_handler = adpt_bus_reset,
3293 .eh_host_reset_handler = adpt_reset,
3294 .bios_param = adpt_bios_param,
3295 .slave_configure = adpt_slave_configure,
3296 .can_queue = MAX_TO_IOP_MESSAGES,
3299 .use_clustering = ENABLE_CLUSTERING,
3301 #include "scsi_module.c"
3302 MODULE_LICENSE("GPL");