1/* 2 * Adaptec AAC series RAID controller driver 3 * (c) Copyright 2001 Red Hat Inc. <alan@redhat.com> 4 * 5 * based on the old aacraid driver that is.. 6 * Adaptec aacraid device driver for Linux. 7 * 8 * Copyright (c) 2000 Adaptec, Inc. (aacraid@adaptec.com) 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2, or (at your option) 13 * any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; see the file COPYING. If not, write to 22 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 * 24 * Module Name: 25 * linit.c 26 * 27 * Abstract: Linux Driver entry module for Adaptec RAID Array Controller 28 * 29 * Provides the following driver entry points: 30 * aac_detect() 31 * aac_release() 32 * aac_queuecommand() 33 * aac_resetcommand() 34 * aac_biosparm() 35 * 36 */ 37 38#define AAC_DRIVER_VERSION "0.9.9ac6-TEST" 39#define AAC_DRIVER_BUILD_DATE __DATE__ 40 41#include <linux/module.h> 42#include <linux/config.h> 43#include <linux/kernel.h> 44#include <linux/init.h> 45#include <linux/types.h> 46#include <linux/sched.h> 47#include <linux/pci.h> 48#include <linux/spinlock.h> 49#include <linux/slab.h> 50#include <linux/completion.h> 51#include <asm/semaphore.h> 52#include <linux/blk.h> 53#include "scsi.h" 54#include "hosts.h" 55 56#include "aacraid.h" 57#include "sd.h" 58 59#define AAC_DRIVERNAME "aacraid" 60 61MODULE_AUTHOR("Red Hat Inc and Adaptec"); 62MODULE_DESCRIPTION("Supports Dell PERC2, 2/Si, 3/Si, 3/Di, Adaptec 2120S, 2200S, 5400S, and HP NetRAID-4M devices. http://domsch.com/linux/ or http://linux.adaptec.com"); 63MODULE_LICENSE("GPL"); 64MODULE_PARM(nondasd, "i"); 65MODULE_PARM_DESC(nondasd, "Control scanning of hba for nondasd devices. 0=off, 1=on"); 66 67static int nondasd=-1; 68 69struct aac_dev *aac_devices[MAXIMUM_NUM_ADAPTERS]; 70 71static unsigned aac_count = 0; 72static int aac_cfg_major = -1; 73 74/* 75 * Because of the way Linux names scsi devices, the order in this table has 76 * become important. Check for on-board Raid first, add-in cards second. 77 * 78 * dmb - For now we add the number of channels to this structure. 79 * In the future we should add a fib that reports the number of channels 80 * for the card. At that time we can remove the channels from here 81 */ 82 83static struct aac_driver_ident aac_drivers[] = { 84 { 0x1028, 0x0001, 0x1028, 0x0001, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 2/Si */ 85 { 0x1028, 0x0002, 0x1028, 0x0002, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 86 { 0x1028, 0x0003, 0x1028, 0x0003, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Si */ 87 { 0x1028, 0x0004, 0x1028, 0x00d0, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Si */ 88 { 0x1028, 0x0002, 0x1028, 0x00d1, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 89 { 0x1028, 0x0002, 0x1028, 0x00d9, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 90 { 0x1028, 0x000a, 0x1028, 0x0106, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 91 { 0x1028, 0x000a, 0x1028, 0x011b, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 92 { 0x1028, 0x000a, 0x1028, 0x0121, aac_rx_init, "percraid", "DELL ", "PERCRAID ", 2 }, /* PERC 3/Di */ 93 { 0x9005, 0x0283, 0x9005, 0x0283, aac_rx_init, "aacraid", "ADAPTEC ", "catapult ", 2 }, /* catapult*/ 94 { 0x9005, 0x0284, 0x9005, 0x0284, aac_rx_init, "aacraid", "ADAPTEC ", "tomcat ", 2 }, /* tomcat*/ 95 { 0x9005, 0x0285, 0x9005, 0x0286, aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2120S ", 1 }, /* Adaptec 2120S (Crusader)*/ 96 { 0x9005, 0x0285, 0x9005, 0x0285, aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2 }, /* Adaptec 2200S (Vulcan)*/ 97 { 0x9005, 0x0285, 0x9005, 0x0287, aac_rx_init, "aacraid", "ADAPTEC ", "Adaptec 2200S ", 2 }, /* Adaptec 2200S (Vulcan-2m)*/ 98 { 0x1011, 0x0046, 0x9005, 0x0365, aac_sa_init, "aacraid", "ADAPTEC ", "Adaptec 5400S ", 4 }, /* Adaptec 5400S (Mustang)*/ 99 { 0x1011, 0x0046, 0x9005, 0x0364, aac_sa_init, "aacraid", "ADAPTEC ", "AAC-364 ", 4 }, /* Adaptec 5400S (Mustang)*/ 100 { 0x1011, 0x0046, 0x9005, 0x1364, aac_sa_init, "percraid", "DELL ", "PERCRAID ", 4 }, /* Dell PERC2 "Quad Channel" */ 101 { 0x1011, 0x0046, 0x103c, 0x10c2, aac_sa_init, "hpnraid", "HP ", "NetRAID-4M ", 4 } /* HP NetRAID-4M */ 102}; 103 104#define NUM_AACTYPES (sizeof(aac_drivers) / sizeof(struct aac_driver_ident)) 105static int num_aacdrivers = NUM_AACTYPES; 106 107static int aac_cfg_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); 108static int aac_cfg_open(struct inode * inode, struct file * file); 109static int aac_cfg_release(struct inode * inode,struct file * file); 110 111static struct file_operations aac_cfg_fops = { 112 owner: THIS_MODULE, 113 ioctl: aac_cfg_ioctl, 114 open: aac_cfg_open, 115 release: aac_cfg_release 116}; 117 118static int aac_detect(Scsi_Host_Template *); 119static int aac_release(struct Scsi_Host *); 120static int aac_queuecommand(Scsi_Cmnd *, void (*CompletionRoutine)(Scsi_Cmnd *)); 121static int aac_biosparm(Scsi_Disk *, kdev_t, int *); 122static int aac_procinfo(char *, char **, off_t, int, int, int); 123static int aac_ioctl(Scsi_Device *, int, void *); 124static int aac_eh_abort(Scsi_Cmnd * cmd); 125static int aac_eh_device_reset(Scsi_Cmnd* cmd); 126static int aac_eh_bus_reset(Scsi_Cmnd* cmd); 127static int aac_eh_reset(Scsi_Cmnd* cmd); 128 129static void aac_queuedepth(struct Scsi_Host *, Scsi_Device *); 130 131/** 132 * aac_detect - Probe for aacraid cards 133 * @template: SCSI driver template 134 * 135 * Probe for AAC Host Adapters initialize, register, and report the 136 * configuration of each AAC Host Adapter found. 137 * Returns the number of adapters successfully initialized and 138 * registered. 139 * Initializes all data necessary for this particular SCSI driver. 140 * Notes: 141 * The detect routine must not call any of the mid level functions 142 * to queue commands because things are not guaranteed to be set 143 * up yet. The detect routine can send commands to the host adapter 144 * as long as the program control will not be passed to scsi.c in 145 * the processing of the command. Note especially that 146 * scsi_malloc/scsi_free must not be called. 147 * 148 */ 149 150static int aac_detect(Scsi_Host_Template *template) 151{ 152 int index; 153 int container; 154 u16 vendor_id, device_id; 155 struct Scsi_Host *host_ptr; 156 struct pci_dev *dev = NULL; 157 struct aac_dev *aac; 158 struct fsa_scsi_hba *fsa_dev_ptr; 159 char *name = NULL; 160 161 printk(KERN_INFO "Red Hat/Adaptec aacraid driver, %s\n", AAC_DRIVER_BUILD_DATE); 162 163 /* setting up the proc directory structure */ 164 template->proc_name = "aacraid"; 165 166 for( index = 0; index != num_aacdrivers; index++ ) 167 { 168 device_id = aac_drivers[index].device; 169 vendor_id = aac_drivers[index].vendor; 170 name = aac_drivers[index].name; 171 dprintk((KERN_DEBUG "Checking %s %x/%x/%x/%x.\n", 172 name, vendor_id, device_id, 173 aac_drivers[index].subsystem_vendor, 174 aac_drivers[index].subsystem_device)); 175 176 dev = NULL; 177 while((dev = pci_find_device(vendor_id, device_id, dev))) { 178 if (pci_enable_device(dev)) 179 continue; 180 pci_set_master(dev); 181 pci_set_dma_mask(dev, 0xFFFFFFFFULL); 182 183 if((dev->subsystem_vendor != aac_drivers[index].subsystem_vendor) || 184 (dev->subsystem_device != aac_drivers[index].subsystem_device)) 185 continue; 186 187 dprintk((KERN_DEBUG "%s device detected.\n", name)); 188 dprintk((KERN_DEBUG "%x/%x/%x/%x.\n", vendor_id, device_id, 189 aac_drivers[index].subsystem_vendor, aac_drivers[index].subsystem_device)); 190 /* Increment the host adapter count */ 191 aac_count++; 192 /* 193 * scsi_register() allocates memory for a Scsi_Hosts structure and 194 * links it into the linked list of host adapters. This linked list 195 * contains the data for all possible <supported> scsi hosts. 196 * This is similar to the Scsi_Host_Template, except that we have 197 * one entry for each actual physical host adapter on the system, 198 * stored as a linked list. If there are two AAC boards, then we 199 * will need to make two Scsi_Host entries, but there will be only 200 * one Scsi_Host_Template entry. The second argument to scsi_register() 201 * specifies the size of the extra memory we want to hold any device 202 * specific information. 203 */ 204 host_ptr = scsi_register( template, sizeof(struct aac_dev) ); 205 /* 206 * These three parameters can be used to allow for wide SCSI 207 * and for host adapters that support multiple buses. 208 */ 209 host_ptr->max_id = 17; 210 host_ptr->max_lun = 8; 211 host_ptr->max_channel = 1; 212 host_ptr->irq = dev->irq; /* Adapter IRQ number */ 213 /* host_ptr->base = ( char * )(dev->resource[0].start & ~0xff); */ 214 host_ptr->base = dev->resource[0].start; 215 scsi_set_pci_device(host_ptr, dev); 216 dprintk((KERN_DEBUG "Device base address = 0x%lx [0x%lx].\n", host_ptr->base, dev->resource[0].start)); 217 dprintk((KERN_DEBUG "Device irq = 0x%x.\n", dev->irq)); 218 /* 219 * The unique_id field is a unique identifier that must 220 * be assigned so that we have some way of identifying 221 * each host adapter properly and uniquely. For hosts 222 * that do not support more than one card in the 223 * system, this does not need to be set. It is 224 * initialized to zero in scsi_register(). This is the 225 * value returned as aac->id. 226 */ 227 host_ptr->unique_id = aac_count - 1; 228 /* 229 * This function is called after the device list has 230 * been built to find the tagged queueing depth 231 * supported for each device. 232 */ 233 host_ptr->select_queue_depths = aac_queuedepth; 234 aac = (struct aac_dev *)host_ptr->hostdata; 235 /* attach a pointer back to Scsi_Host */ 236 aac->scsi_host_ptr = host_ptr; 237 aac->pdev = dev; 238 aac->cardtype = index; 239 aac->name = aac->scsi_host_ptr->hostt->name; 240 aac->id = aac->scsi_host_ptr->unique_id; 241 /* Initialize the ordinal number of the device to -1 */ 242 fsa_dev_ptr = &(aac->fsa_dev); 243 for( container = 0; container < MAXIMUM_NUM_CONTAINERS; container++ ) 244 fsa_dev_ptr->devno[container] = -1; 245 246 dprintk((KERN_DEBUG "Initializing Hardware...\n")); 247 if((*aac_drivers[index].init)(aac , host_ptr->unique_id) != 0) 248 { 249 /* device initialization failed */ 250 printk(KERN_WARNING "aacraid: device initialization failed.\n"); 251 scsi_unregister(host_ptr); 252 aac_count--; 253 continue; 254 } 255 dprintk((KERN_DEBUG "%s:%d device initialization successful.\n", name, host_ptr->unique_id)); 256 aac_get_adapter_info(aac); 257 if(nondasd != -1) 258 { 259 /* someone told us how to set this on the cmdline */ 260 aac->nondasd_support = (nondasd!=0); 261 } 262 if(aac->nondasd_support != 0){ 263 printk(KERN_INFO "%s%d: Non-DASD support enabled\n", aac->name, aac->id); 264 } 265 dprintk((KERN_DEBUG "%s:%d options flag %04x.\n",name, host_ptr->unique_id,aac->adapter_info.options)); 266 if(aac->nondasd_support == 1) 267 { 268 /* 269 * max channel will be the physical channels plus 1 virtual channel 270 * all containers are on the virtual channel 0 271 * physical channels are address by their actual physical number+1 272 */ 273 host_ptr->max_channel = aac_drivers[index].channels+1; 274 } else { 275 host_ptr->max_channel = 1; 276 } 277 dprintk((KERN_DEBUG "Device has %d logical channels\n", host_ptr->max_channel)); 278 aac_get_containers(aac); 279 aac_devices[aac_count-1] = aac; 280 281 /* 282 * dmb - we may need to move these 3 parms somewhere else once 283 * we get a fib that can report the actual numbers 284 */ 285 host_ptr->max_id = AAC_MAX_TARGET; 286 host_ptr->max_lun = AAC_MAX_LUN; 287 288 /* 289 * If we are PAE capable then our future DMA mappings 290 * (for read/write commands) are 64bit clean and don't 291 * need bouncing. This assumes we do no other 32bit only 292 * allocations (eg fib table expands) after this point. 293 */ 294 295 if(aac->pae_support) 296 pci_set_dma_mask(dev, 0xFFFFFFFFFFFFFFFFUL); 297 } 298 } 299 300 if( aac_count ){ 301 if((aac_cfg_major = register_chrdev( 0, "aac", &aac_cfg_fops))<0) 302 printk(KERN_WARNING "aacraid: unable to register \"aac\" device.\n"); 303 } 304 305 template->present = aac_count; /* # of cards of this type found */ 306 return aac_count; 307} 308 309/** 310 * aac_release - release SCSI host resources 311 * @host_ptr: SCSI host to clean up 312 * 313 * Release all resources previously acquired to support a specific Host 314 * Adapter and unregister the AAC Host Adapter. 315 * 316 * BUGS: Does not wait for the thread it kills to die. 317 */ 318 319static int aac_release(struct Scsi_Host *host_ptr) 320{ 321 struct aac_dev *dev; 322 dprintk((KERN_DEBUG "aac_release.\n")); 323 dev = (struct aac_dev *)host_ptr->hostdata; 324 /* 325 * kill any threads we started 326 */ 327 kill_proc(dev->thread_pid, SIGKILL, 0); 328 wait_for_completion(&dev->aif_completion); 329 /* 330 * Call the comm layer to detach from this adapter 331 */ 332 aac_detach(dev); 333 /* Check free orderings... */ 334 /* remove interrupt binding */ 335 free_irq(host_ptr->irq, dev); 336 iounmap((void * )dev->regs.sa); 337 /* unregister adapter */ 338 scsi_unregister(host_ptr); 339 if( aac_cfg_major >= 0 ) 340 { 341 unregister_chrdev(aac_cfg_major, "aac"); 342 aac_cfg_major = -1; 343 } 344 return 0; 345} 346 347/** 348 * aac_queuecommand - queue a SCSI command 349 * @scsi_cmnd_ptr: SCSI command to queue 350 * @CompletionRoutine: Function to call on command completion 351 * 352 * Queues a command for execution by the associated Host Adapter. 353 */ 354 355static int aac_queuecommand(Scsi_Cmnd *scsi_cmnd_ptr, void (*complete)(Scsi_Cmnd *)) 356{ 357 int ret; 358 359 scsi_cmnd_ptr->scsi_done = complete; 360 /* 361 * aac_scsi_cmd() handles command processing, setting the 362 * result code and calling completion routine. 363 */ 364 if((ret = aac_scsi_cmd(scsi_cmnd_ptr)) != 0) 365 dprintk((KERN_DEBUG "aac_scsi_cmd failed.\n")); 366 return ret; 367} 368 369/** 370 * aac_driverinfo - Returns the host adapter name 371 * @host_ptr: Scsi host to report on 372 * 373 * Returns a static string describing the device in question 374 */ 375 376const char *aac_driverinfo(struct Scsi_Host *host_ptr) 377{ 378 struct aac_dev *dev = (struct aac_dev *)host_ptr->hostdata; 379 return aac_drivers[dev->cardtype].name; 380} 381 382/** 383 * aac_get_driver_ident 384 * @devtype: index into lookup table 385 * 386 * Returns a pointer to the entry in the driver lookup table. 387 */ 388struct aac_driver_ident* aac_get_driver_ident(int devtype) 389{ 390 return &aac_drivers[devtype]; 391} 392 393/** 394 * aac_biosparm - return BIOS parameters for disk 395 * @disk: SCSI disk object to process 396 * @device: kdev_t of the disk in question 397 * @geom: geometry block to fill in 398 * 399 * Return the Heads/Sectors/Cylinders BIOS Disk Parameters for Disk. 400 * The default disk geometry is 64 heads, 32 sectors, and the appropriate 401 * number of cylinders so as not to exceed drive capacity. In order for 402 * disks equal to or larger than 1 GB to be addressable by the BIOS 403 * without exceeding the BIOS limitation of 1024 cylinders, Extended 404 * Translation should be enabled. With Extended Translation enabled, 405 * drives between 1 GB inclusive and 2 GB exclusive are given a disk 406 * geometry of 128 heads and 32 sectors, and drives above 2 GB inclusive 407 * are given a disk geometry of 255 heads and 63 sectors. However, if 408 * the BIOS detects that the Extended Translation setting does not match 409 * the geometry in the partition table, then the translation inferred 410 * from the partition table will be used by the BIOS, and a warning may 411 * be displayed. 412 */ 413 414static int aac_biosparm(Scsi_Disk *disk, kdev_t dev, int *geom) 415{ 416 struct diskparm *param = (struct diskparm *)geom; 417 struct buffer_head * buf; 418 419 dprintk((KERN_DEBUG "aac_biosparm.\n")); 420 421 /* 422 * Assuming extended translation is enabled - #REVISIT# 423 */ 424 if( disk->capacity >= 2 * 1024 * 1024 ) /* 1 GB in 512 byte sectors */ 425 { 426 if( disk->capacity >= 4 * 1024 * 1024 ) /* 2 GB in 512 byte sectors */ 427 { 428 param->heads = 255; 429 param->sectors = 63; 430 } 431 else 432 { 433 param->heads = 128; 434 param->sectors = 32; 435 } 436 } 437 else 438 { 439 param->heads = 64; 440 param->sectors = 32; 441 } 442 443 param->cylinders = disk->capacity/(param->heads * param->sectors); 444 445 /* 446 * Read the first 1024 bytes from the disk device 447 */ 448 449 buf = bread(MKDEV(MAJOR(dev), MINOR(dev)&~0xf), 0, block_size(dev)); 450 if(buf == NULL) 451 return 0; 452 /* 453 * If the boot sector partition table is valid, search for a partition 454 * table entry whose end_head matches one of the standard geometry 455 * translations ( 64/32, 128/32, 255/63 ). 456 */ 457 458 if(*(unsigned short *)(buf->b_data + 0x1fe) == cpu_to_le16(0xaa55)) 459 { 460 struct partition *first = (struct partition * )(buf->b_data + 0x1be); 461 struct partition *entry = first; 462 int saved_cylinders = param->cylinders; 463 int num; 464 unsigned char end_head, end_sec; 465 466 for(num = 0; num < 4; num++) 467 { 468 end_head = entry->end_head; 469 end_sec = entry->end_sector & 0x3f; 470 471 if(end_head == 63) 472 { 473 param->heads = 64; 474 param->sectors = 32; 475 break; 476 } 477 else if(end_head == 127) 478 { 479 param->heads = 128; 480 param->sectors = 32; 481 break; 482 } 483 else if(end_head == 254) 484 { 485 param->heads = 255; 486 param->sectors = 63; 487 break; 488 } 489 entry++; 490 } 491 492 if(num == 4) 493 { 494 end_head = first->end_head; 495 end_sec = first->end_sector & 0x3f; 496 } 497 498 param->cylinders = disk->capacity / (param->heads * param->sectors); 499 500 if(num < 4 && end_sec == param->sectors) 501 { 502 if(param->cylinders != saved_cylinders) 503 dprintk((KERN_DEBUG "Adopting geometry: heads=%d, sectors=%d from partition table %d.\n", 504 param->heads, param->sectors, num)); 505 } 506 else if(end_head > 0 || end_sec > 0) 507 { 508 dprintk((KERN_DEBUG "Strange geometry: heads=%d, sectors=%d in partition table %d.\n", 509 end_head + 1, end_sec, num)); 510 dprintk((KERN_DEBUG "Using geometry: heads=%d, sectors=%d.\n", 511 param->heads, param->sectors)); 512 } 513 } 514 brelse(buf); 515 return 0; 516} 517 518/** 519 * aac_queuedepth - compute queue depths 520 * @host: SCSI host in question 521 * @dev: SCSI device we are considering 522 * 523 * Selects queue depths for each target device based on the host adapter's 524 * total capacity and the queue depth supported by the target device. 525 * A queue depth of one automatically disables tagged queueing. 526 */ 527 528static void aac_queuedepth(struct Scsi_Host * host, Scsi_Device * dev ) 529{ 530 Scsi_Device * dptr; 531 532 dprintk((KERN_DEBUG "aac_queuedepth.\n")); 533 dprintk((KERN_DEBUG "Device # Q Depth Online\n")); 534 dprintk((KERN_DEBUG "---------------------------\n")); 535 for(dptr = dev; dptr != NULL; dptr = dptr->next) 536 { 537 if(dptr->host == host) 538 { 539 dptr->queue_depth = 10; 540 dprintk((KERN_DEBUG " %2d %d %d\n", 541 dptr->id, dptr->queue_depth, dptr->online)); 542 } 543 } 544} 545 546 547/** 548 * aac_eh_abort - Abort command if possible. 549 * @cmd: SCSI command block to abort 550 * 551 * Called when the midlayer wishes to abort a command. We don't support 552 * this facility, and our firmware looks after life for us. We just 553 * report this as failing 554 */ 555 556static int aac_eh_abort(Scsi_Cmnd *cmd) 557{ 558 return FAILED; 559} 560 561/** 562 * aac_eh_device_reset - Reset command handling 563 * @cmd: SCSI command block causing the reset 564 * 565 * Issue a reset of a SCSI device. We are ourselves not truely a SCSI 566 * controller and our firmware will do the work for us anyway. Thus this 567 * is a no-op. We just return FAILED. 568 */ 569 570static int aac_eh_device_reset(Scsi_Cmnd *cmd) 571{ 572 return FAILED; 573} 574 575/** 576 * aac_eh_bus_reset - Reset command handling 577 * @scsi_cmd: SCSI command block causing the reset 578 * 579 * Issue a reset of a SCSI bus. We are ourselves not truely a SCSI 580 * controller and our firmware will do the work for us anyway. Thus this 581 * is a no-op. We just return FAILED. 582 */ 583 584static int aac_eh_bus_reset(Scsi_Cmnd* cmd) 585{ 586 return FAILED; 587} 588 589/** 590 * aac_eh_hba_reset - Reset command handling 591 * @scsi_cmd: SCSI command block causing the reset 592 * 593 * Issue a reset of a SCSI host. If things get this bad then arguably we should 594 * go take a look at what the host adapter is doing and see if something really 595 * broke (as can occur at least on my Dell QC card if a drive keeps failing spinup) 596 */ 597 598static int aac_eh_reset(Scsi_Cmnd* cmd) 599{ 600 printk(KERN_ERR "aacraid: Host adapter reset request. SCSI hang ?\n"); 601 return FAILED; 602} 603 604/** 605 * aac_ioctl - Handle SCSI ioctls 606 * @scsi_dev_ptr: scsi device to operate upon 607 * @cmd: ioctl command to use issue 608 * @arg: ioctl data pointer 609 * 610 * Issue an ioctl on an aacraid device. Returns a standard unix error code or 611 * zero for success 612 */ 613 614static int aac_ioctl(Scsi_Device * scsi_dev_ptr, int cmd, void * arg) 615{ 616 struct aac_dev *dev; 617 dprintk((KERN_DEBUG "aac_ioctl.\n")); 618 dev = (struct aac_dev *)scsi_dev_ptr->host->hostdata; 619 return aac_do_ioctl(dev, cmd, arg); 620} 621 622/** 623 * aac_cfg_open - open a configuration file 624 * @inode: inode being opened 625 * @file: file handle attached 626 * 627 * Called when the configuration device is opened. Does the needed 628 * set up on the handle and then returns 629 * 630 * Bugs: This needs extending to check a given adapter is present 631 * so we can support hot plugging, and to ref count adapters. 632 */ 633 634static int aac_cfg_open(struct inode * inode, struct file * file ) 635{ 636 unsigned minor_number = MINOR(inode->i_rdev); 637 if(minor_number >= aac_count) 638 return -ENODEV; 639 return 0; 640} 641 642/** 643 * aac_cfg_release - close down an AAC config device 644 * @inode: inode of configuration file 645 * @file: file handle of configuration file 646 * 647 * Called when the last close of the configuration file handle 648 * is performed. 649 */ 650 651static int aac_cfg_release(struct inode * inode, struct file * file ) 652{ 653 return 0; 654} 655 656/** 657 * aac_cfg_ioctl - AAC configuration request 658 * @inode: inode of device 659 * @file: file handle 660 * @cmd: ioctl command code 661 * @arg: argument 662 * 663 * Handles a configuration ioctl. Currently this involves wrapping it 664 * up and feeding it into the nasty windowsalike glue layer. 665 * 666 * Bugs: Needs locking against parallel ioctls lower down 667 * Bugs: Needs to handle hot plugging 668 */ 669 670static int aac_cfg_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg ) 671{ 672 struct aac_dev *dev = aac_devices[MINOR(inode->i_rdev)]; 673 return aac_do_ioctl(dev, cmd, (void *)arg); 674} 675 676/* 677 * To use the low level SCSI driver support using the linux kernel loadable 678 * module interface we should initialize the global variable driver_interface 679 * (datatype Scsi_Host_Template) and then include the file scsi_module.c. 680 */ 681 682static Scsi_Host_Template driver_template = { 683 module: THIS_MODULE, 684 name: "AAC", 685 proc_info: aac_procinfo, 686 detect: aac_detect, 687 release: aac_release, 688 info: aac_driverinfo, 689 ioctl: aac_ioctl, 690 queuecommand: aac_queuecommand, 691 bios_param: aac_biosparm, 692 can_queue: AAC_NUM_IO_FIB, 693 this_id: 16, 694 sg_tablesize: 16, 695 max_sectors: 128, 696 cmd_per_lun: AAC_NUM_IO_FIB, 697 eh_abort_handler: aac_eh_abort, 698 eh_device_reset_handler:aac_eh_device_reset, 699 eh_bus_reset_handler: aac_eh_bus_reset, 700 eh_host_reset_handler: aac_eh_reset, 701 use_new_eh_code: 1, 702 703 use_clustering: ENABLE_CLUSTERING, 704}; 705 706#include "scsi_module.c" 707 708/** 709 * aac_procinfo - Implement /proc/scsi/<drivername>/<n> 710 * @proc_buffer: memory buffer for I/O 711 * @start_ptr: pointer to first valid data 712 * @offset: offset into file 713 * @bytes_available: space left 714 * @host_no: scsi host ident 715 * @write: direction of I/O 716 * 717 * Used to export driver statistics and other infos to the world outside 718 * the kernel using the proc file system. Also provides an interface to 719 * feed the driver with information. 720 * 721 * For reads 722 * - if offset > 0 return 0 723 * - if offset == 0 write data to proc_buffer and set the start_ptr to 724 * beginning of proc_buffer, return the number of characters written. 725 * For writes 726 * - writes currently not supported, return 0 727 * 728 * Bugs: Only offset zero is handled 729 */ 730 731static int aac_procinfo(char *proc_buffer, char **start_ptr,off_t offset, 732 int bytes_available, int host_no, int write) 733{ 734 if(write || offset > 0) 735 return 0; 736 *start_ptr = proc_buffer; 737 return sprintf(proc_buffer, "%s %d\n", "Raid Controller, scsi hba number", host_no); 738} 739 740EXPORT_NO_SYMBOLS; 741