Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * commctrl.c |
| 26 | * |
| 27 | * Abstract: Contains all routines for control of the AFA comm layer |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <linux/kernel.h> |
| 32 | #include <linux/init.h> |
| 33 | #include <linux/types.h> |
| 34 | #include <linux/sched.h> |
| 35 | #include <linux/pci.h> |
| 36 | #include <linux/spinlock.h> |
| 37 | #include <linux/slab.h> |
| 38 | #include <linux/completion.h> |
| 39 | #include <linux/dma-mapping.h> |
| 40 | #include <linux/blkdev.h> |
| 41 | #include <asm/semaphore.h> |
| 42 | #include <asm/uaccess.h> |
| 43 | |
| 44 | #include "aacraid.h" |
| 45 | |
| 46 | /** |
| 47 | * ioctl_send_fib - send a FIB from userspace |
| 48 | * @dev: adapter is being processed |
| 49 | * @arg: arguments to the ioctl call |
| 50 | * |
| 51 | * This routine sends a fib to the adapter on behalf of a user level |
| 52 | * program. |
| 53 | */ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 54 | # define AAC_DEBUG_PREAMBLE KERN_INFO |
| 55 | # define AAC_DEBUG_POSTAMBLE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | static int ioctl_send_fib(struct aac_dev * dev, void __user *arg) |
| 58 | { |
| 59 | struct hw_fib * kfib; |
| 60 | struct fib *fibptr; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 61 | struct hw_fib * hw_fib = (struct hw_fib *)0; |
| 62 | dma_addr_t hw_fib_pa = (dma_addr_t)0LL; |
| 63 | unsigned size; |
| 64 | int retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 66 | fibptr = aac_fib_alloc(dev); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 67 | if(fibptr == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | return -ENOMEM; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 69 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | |
| 71 | kfib = fibptr->hw_fib; |
| 72 | /* |
| 73 | * First copy in the header so that we can check the size field. |
| 74 | */ |
| 75 | if (copy_from_user((void *)kfib, arg, sizeof(struct aac_fibhdr))) { |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 76 | aac_fib_free(fibptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | return -EFAULT; |
| 78 | } |
| 79 | /* |
| 80 | * Since we copy based on the fib header size, make sure that we |
| 81 | * will not overrun the buffer when we copy the memory. Return |
| 82 | * an error if we would. |
| 83 | */ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 84 | size = le16_to_cpu(kfib->header.Size) + sizeof(struct aac_fibhdr); |
| 85 | if (size < le16_to_cpu(kfib->header.SenderSize)) |
| 86 | size = le16_to_cpu(kfib->header.SenderSize); |
| 87 | if (size > dev->max_fib_size) { |
Mark Haverkamp | 6e289a9 | 2006-01-11 09:28:07 -0800 | [diff] [blame] | 88 | if (size > 2048) { |
| 89 | retval = -EINVAL; |
| 90 | goto cleanup; |
| 91 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 92 | /* Highjack the hw_fib */ |
| 93 | hw_fib = fibptr->hw_fib; |
| 94 | hw_fib_pa = fibptr->hw_fib_pa; |
| 95 | fibptr->hw_fib = kfib = pci_alloc_consistent(dev->pdev, size, &fibptr->hw_fib_pa); |
| 96 | memset(((char *)kfib) + dev->max_fib_size, 0, size - dev->max_fib_size); |
| 97 | memcpy(kfib, hw_fib, dev->max_fib_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 100 | if (copy_from_user(kfib, arg, size)) { |
| 101 | retval = -EFAULT; |
| 102 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 105 | if (kfib->header.Command == cpu_to_le16(TakeABreakPt)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | aac_adapter_interrupt(dev); |
| 107 | /* |
| 108 | * Since we didn't really send a fib, zero out the state to allow |
| 109 | * cleanup code not to assert. |
| 110 | */ |
| 111 | kfib->header.XferState = 0; |
| 112 | } else { |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 113 | retval = aac_fib_send(le16_to_cpu(kfib->header.Command), fibptr, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | le16_to_cpu(kfib->header.Size) , FsaNormal, |
| 115 | 1, 1, NULL, NULL); |
| 116 | if (retval) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 117 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 119 | if (aac_fib_complete(fibptr) != 0) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 120 | retval = -EINVAL; |
| 121 | goto cleanup; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | /* |
| 125 | * Make sure that the size returned by the adapter (which includes |
| 126 | * the header) is less than or equal to the size of a fib, so we |
| 127 | * don't corrupt application data. Then copy that size to the user |
| 128 | * buffer. (Don't try to add the header information again, since it |
| 129 | * was already included by the adapter.) |
| 130 | */ |
| 131 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 132 | retval = 0; |
| 133 | if (copy_to_user(arg, (void *)kfib, size)) |
| 134 | retval = -EFAULT; |
| 135 | cleanup: |
| 136 | if (hw_fib) { |
| 137 | pci_free_consistent(dev->pdev, size, kfib, fibptr->hw_fib_pa); |
| 138 | fibptr->hw_fib_pa = hw_fib_pa; |
| 139 | fibptr->hw_fib = hw_fib; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 141 | aac_fib_free(fibptr); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 142 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /** |
| 146 | * open_getadapter_fib - Get the next fib |
| 147 | * |
| 148 | * This routine will get the next Fib, if available, from the AdapterFibContext |
| 149 | * passed in from the user. |
| 150 | */ |
| 151 | |
| 152 | static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) |
| 153 | { |
| 154 | struct aac_fib_context * fibctx; |
| 155 | int status; |
| 156 | |
| 157 | fibctx = kmalloc(sizeof(struct aac_fib_context), GFP_KERNEL); |
| 158 | if (fibctx == NULL) { |
| 159 | status = -ENOMEM; |
| 160 | } else { |
| 161 | unsigned long flags; |
| 162 | struct list_head * entry; |
| 163 | struct aac_fib_context * context; |
| 164 | |
| 165 | fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT; |
| 166 | fibctx->size = sizeof(struct aac_fib_context); |
| 167 | /* |
| 168 | * Yes yes, I know this could be an index, but we have a |
| 169 | * better guarantee of uniqueness for the locked loop below. |
| 170 | * Without the aid of a persistent history, this also helps |
| 171 | * reduce the chance that the opaque context would be reused. |
| 172 | */ |
| 173 | fibctx->unique = (u32)((ulong)fibctx & 0xFFFFFFFF); |
| 174 | /* |
| 175 | * Initialize the mutex used to wait for the next AIF. |
| 176 | */ |
| 177 | init_MUTEX_LOCKED(&fibctx->wait_sem); |
| 178 | fibctx->wait = 0; |
| 179 | /* |
| 180 | * Initialize the fibs and set the count of fibs on |
| 181 | * the list to 0. |
| 182 | */ |
| 183 | fibctx->count = 0; |
| 184 | INIT_LIST_HEAD(&fibctx->fib_list); |
| 185 | fibctx->jiffies = jiffies/HZ; |
| 186 | /* |
| 187 | * Now add this context onto the adapter's |
| 188 | * AdapterFibContext list. |
| 189 | */ |
| 190 | spin_lock_irqsave(&dev->fib_lock, flags); |
| 191 | /* Ensure that we have a unique identifier */ |
| 192 | entry = dev->fib_list.next; |
| 193 | while (entry != &dev->fib_list) { |
| 194 | context = list_entry(entry, struct aac_fib_context, next); |
| 195 | if (context->unique == fibctx->unique) { |
| 196 | /* Not unique (32 bits) */ |
| 197 | fibctx->unique++; |
| 198 | entry = dev->fib_list.next; |
| 199 | } else { |
| 200 | entry = entry->next; |
| 201 | } |
| 202 | } |
| 203 | list_add_tail(&fibctx->next, &dev->fib_list); |
| 204 | spin_unlock_irqrestore(&dev->fib_lock, flags); |
| 205 | if (copy_to_user(arg, &fibctx->unique, |
| 206 | sizeof(fibctx->unique))) { |
| 207 | status = -EFAULT; |
| 208 | } else { |
| 209 | status = 0; |
| 210 | } |
| 211 | } |
| 212 | return status; |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * next_getadapter_fib - get the next fib |
| 217 | * @dev: adapter to use |
| 218 | * @arg: ioctl argument |
| 219 | * |
| 220 | * This routine will get the next Fib, if available, from the AdapterFibContext |
| 221 | * passed in from the user. |
| 222 | */ |
| 223 | |
| 224 | static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) |
| 225 | { |
| 226 | struct fib_ioctl f; |
| 227 | struct fib *fib; |
| 228 | struct aac_fib_context *fibctx; |
| 229 | int status; |
| 230 | struct list_head * entry; |
| 231 | unsigned long flags; |
| 232 | |
| 233 | if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl))) |
| 234 | return -EFAULT; |
| 235 | /* |
| 236 | * Verify that the HANDLE passed in was a valid AdapterFibContext |
| 237 | * |
| 238 | * Search the list of AdapterFibContext addresses on the adapter |
| 239 | * to be sure this is a valid address |
| 240 | */ |
| 241 | entry = dev->fib_list.next; |
| 242 | fibctx = NULL; |
| 243 | |
| 244 | while (entry != &dev->fib_list) { |
| 245 | fibctx = list_entry(entry, struct aac_fib_context, next); |
| 246 | /* |
| 247 | * Extract the AdapterFibContext from the Input parameters. |
| 248 | */ |
| 249 | if (fibctx->unique == f.fibctx) { /* We found a winner */ |
| 250 | break; |
| 251 | } |
| 252 | entry = entry->next; |
| 253 | fibctx = NULL; |
| 254 | } |
| 255 | if (!fibctx) { |
| 256 | dprintk ((KERN_INFO "Fib Context not found\n")); |
| 257 | return -EINVAL; |
| 258 | } |
| 259 | |
| 260 | if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || |
| 261 | (fibctx->size != sizeof(struct aac_fib_context))) { |
| 262 | dprintk ((KERN_INFO "Fib Context corrupt?\n")); |
| 263 | return -EINVAL; |
| 264 | } |
| 265 | status = 0; |
| 266 | spin_lock_irqsave(&dev->fib_lock, flags); |
| 267 | /* |
| 268 | * If there are no fibs to send back, then either wait or return |
| 269 | * -EAGAIN |
| 270 | */ |
| 271 | return_fib: |
| 272 | if (!list_empty(&fibctx->fib_list)) { |
| 273 | struct list_head * entry; |
| 274 | /* |
| 275 | * Pull the next fib from the fibs |
| 276 | */ |
| 277 | entry = fibctx->fib_list.next; |
| 278 | list_del(entry); |
| 279 | |
| 280 | fib = list_entry(entry, struct fib, fiblink); |
| 281 | fibctx->count--; |
| 282 | spin_unlock_irqrestore(&dev->fib_lock, flags); |
| 283 | if (copy_to_user(f.fib, fib->hw_fib, sizeof(struct hw_fib))) { |
| 284 | kfree(fib->hw_fib); |
| 285 | kfree(fib); |
| 286 | return -EFAULT; |
| 287 | } |
| 288 | /* |
| 289 | * Free the space occupied by this copy of the fib. |
| 290 | */ |
| 291 | kfree(fib->hw_fib); |
| 292 | kfree(fib); |
| 293 | status = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | } else { |
| 295 | spin_unlock_irqrestore(&dev->fib_lock, flags); |
| 296 | if (f.wait) { |
| 297 | if(down_interruptible(&fibctx->wait_sem) < 0) { |
| 298 | status = -EINTR; |
| 299 | } else { |
| 300 | /* Lock again and retry */ |
| 301 | spin_lock_irqsave(&dev->fib_lock, flags); |
| 302 | goto return_fib; |
| 303 | } |
| 304 | } else { |
| 305 | status = -EAGAIN; |
| 306 | } |
| 307 | } |
Mark Haverkamp | 12a26d0 | 2005-08-03 15:39:25 -0700 | [diff] [blame] | 308 | fibctx->jiffies = jiffies/HZ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | return status; |
| 310 | } |
| 311 | |
| 312 | int aac_close_fib_context(struct aac_dev * dev, struct aac_fib_context * fibctx) |
| 313 | { |
| 314 | struct fib *fib; |
| 315 | |
| 316 | /* |
| 317 | * First free any FIBs that have not been consumed. |
| 318 | */ |
| 319 | while (!list_empty(&fibctx->fib_list)) { |
| 320 | struct list_head * entry; |
| 321 | /* |
| 322 | * Pull the next fib from the fibs |
| 323 | */ |
| 324 | entry = fibctx->fib_list.next; |
| 325 | list_del(entry); |
| 326 | fib = list_entry(entry, struct fib, fiblink); |
| 327 | fibctx->count--; |
| 328 | /* |
| 329 | * Free the space occupied by this copy of the fib. |
| 330 | */ |
| 331 | kfree(fib->hw_fib); |
| 332 | kfree(fib); |
| 333 | } |
| 334 | /* |
| 335 | * Remove the Context from the AdapterFibContext List |
| 336 | */ |
| 337 | list_del(&fibctx->next); |
| 338 | /* |
| 339 | * Invalidate context |
| 340 | */ |
| 341 | fibctx->type = 0; |
| 342 | /* |
| 343 | * Free the space occupied by the Context |
| 344 | */ |
| 345 | kfree(fibctx); |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * close_getadapter_fib - close down user fib context |
| 351 | * @dev: adapter |
| 352 | * @arg: ioctl arguments |
| 353 | * |
| 354 | * This routine will close down the fibctx passed in from the user. |
| 355 | */ |
| 356 | |
| 357 | static int close_getadapter_fib(struct aac_dev * dev, void __user *arg) |
| 358 | { |
| 359 | struct aac_fib_context *fibctx; |
| 360 | int status; |
| 361 | unsigned long flags; |
| 362 | struct list_head * entry; |
| 363 | |
| 364 | /* |
| 365 | * Verify that the HANDLE passed in was a valid AdapterFibContext |
| 366 | * |
| 367 | * Search the list of AdapterFibContext addresses on the adapter |
| 368 | * to be sure this is a valid address |
| 369 | */ |
| 370 | |
| 371 | entry = dev->fib_list.next; |
| 372 | fibctx = NULL; |
| 373 | |
| 374 | while(entry != &dev->fib_list) { |
| 375 | fibctx = list_entry(entry, struct aac_fib_context, next); |
| 376 | /* |
| 377 | * Extract the fibctx from the input parameters |
| 378 | */ |
| 379 | if (fibctx->unique == (u32)(unsigned long)arg) { |
| 380 | /* We found a winner */ |
| 381 | break; |
| 382 | } |
| 383 | entry = entry->next; |
| 384 | fibctx = NULL; |
| 385 | } |
| 386 | |
| 387 | if (!fibctx) |
| 388 | return 0; /* Already gone */ |
| 389 | |
| 390 | if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) || |
| 391 | (fibctx->size != sizeof(struct aac_fib_context))) |
| 392 | return -EINVAL; |
| 393 | spin_lock_irqsave(&dev->fib_lock, flags); |
| 394 | status = aac_close_fib_context(dev, fibctx); |
| 395 | spin_unlock_irqrestore(&dev->fib_lock, flags); |
| 396 | return status; |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * check_revision - close down user fib context |
| 401 | * @dev: adapter |
| 402 | * @arg: ioctl arguments |
| 403 | * |
| 404 | * This routine returns the driver version. |
| 405 | * Under Linux, there have been no version incompatibilities, so this is |
| 406 | * simple! |
| 407 | */ |
| 408 | |
| 409 | static int check_revision(struct aac_dev *dev, void __user *arg) |
| 410 | { |
| 411 | struct revision response; |
Mark Haverkamp | c7f4760 | 2005-08-03 15:38:55 -0700 | [diff] [blame] | 412 | char *driver_version = aac_driver_version; |
| 413 | u32 version; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | |
Mark Haverkamp | 9f30a32 | 2005-10-24 10:52:02 -0700 | [diff] [blame] | 415 | response.compat = 1; |
Mark Haverkamp | c7f4760 | 2005-08-03 15:38:55 -0700 | [diff] [blame] | 416 | version = (simple_strtol(driver_version, |
| 417 | &driver_version, 10) << 24) | 0x00000400; |
| 418 | version += simple_strtol(driver_version + 1, &driver_version, 10) << 16; |
| 419 | version += simple_strtol(driver_version + 1, NULL, 10); |
| 420 | response.version = cpu_to_le32(version); |
| 421 | # if (defined(AAC_DRIVER_BUILD)) |
| 422 | response.build = cpu_to_le32(AAC_DRIVER_BUILD); |
| 423 | # else |
| 424 | response.build = cpu_to_le32(9999); |
| 425 | # endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | |
| 427 | if (copy_to_user(arg, &response, sizeof(response))) |
| 428 | return -EFAULT; |
| 429 | return 0; |
| 430 | } |
| 431 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 432 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | /** |
| 434 | * |
| 435 | * aac_send_raw_scb |
| 436 | * |
| 437 | */ |
| 438 | |
Adrian Bunk | 4833869 | 2005-04-25 19:45:58 -0700 | [diff] [blame] | 439 | static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 440 | { |
| 441 | struct fib* srbfib; |
| 442 | int status; |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 443 | struct aac_srb *srbcmd = NULL; |
| 444 | struct user_aac_srb *user_srbcmd = NULL; |
| 445 | struct user_aac_srb __user *user_srb = arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | struct aac_srb_reply __user *user_reply; |
| 447 | struct aac_srb_reply* reply; |
| 448 | u32 fibsize = 0; |
| 449 | u32 flags = 0; |
| 450 | s32 rcode = 0; |
| 451 | u32 data_dir; |
| 452 | void __user *sg_user[32]; |
| 453 | void *sg_list[32]; |
| 454 | u32 sg_indx = 0; |
| 455 | u32 byte_count = 0; |
| 456 | u32 actual_fibsize = 0; |
| 457 | int i; |
| 458 | |
| 459 | |
| 460 | if (!capable(CAP_SYS_ADMIN)){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 461 | dprintk((KERN_DEBUG"aacraid: No permission to send raw srb\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | return -EPERM; |
| 463 | } |
| 464 | /* |
| 465 | * Allocate and initialize a Fib then setup a BlockWrite command |
| 466 | */ |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 467 | if (!(srbfib = aac_fib_alloc(dev))) { |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 468 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 470 | aac_fib_init(srbfib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | |
| 472 | srbcmd = (struct aac_srb*) fib_data(srbfib); |
| 473 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 474 | memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 476 | dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | rcode = -EFAULT; |
| 478 | goto cleanup; |
| 479 | } |
| 480 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 481 | if (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | rcode = -EINVAL; |
| 483 | goto cleanup; |
| 484 | } |
| 485 | |
Dave Jones | 4645df1 | 2005-07-12 13:58:08 -0700 | [diff] [blame] | 486 | user_srbcmd = kmalloc(fibsize, GFP_KERNEL); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 487 | if (!user_srbcmd) { |
| 488 | dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n")); |
| 489 | rcode = -ENOMEM; |
| 490 | goto cleanup; |
| 491 | } |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 492 | if(copy_from_user(user_srbcmd, user_srb,fibsize)){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 493 | dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | rcode = -EFAULT; |
| 495 | goto cleanup; |
| 496 | } |
| 497 | |
| 498 | user_reply = arg+fibsize; |
| 499 | |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 500 | flags = user_srbcmd->flags; /* from user in cpu order */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | // Fix up srb for endian and force some values |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); // Force this |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 504 | srbcmd->channel = cpu_to_le32(user_srbcmd->channel); |
| 505 | srbcmd->id = cpu_to_le32(user_srbcmd->id); |
| 506 | srbcmd->lun = cpu_to_le32(user_srbcmd->lun); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 507 | srbcmd->timeout = cpu_to_le32(user_srbcmd->timeout); |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 508 | srbcmd->flags = cpu_to_le32(flags); |
| 509 | srbcmd->retry_limit = 0; // Obsolete parameter |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 510 | srbcmd->cdb_size = cpu_to_le32(user_srbcmd->cdb_size); |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 511 | memcpy(srbcmd->cdb, user_srbcmd->cdb, sizeof(srbcmd->cdb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 513 | switch (flags & (SRB_DataIn | SRB_DataOut)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | case SRB_DataOut: |
| 515 | data_dir = DMA_TO_DEVICE; |
| 516 | break; |
| 517 | case (SRB_DataIn | SRB_DataOut): |
| 518 | data_dir = DMA_BIDIRECTIONAL; |
| 519 | break; |
| 520 | case SRB_DataIn: |
| 521 | data_dir = DMA_FROM_DEVICE; |
| 522 | break; |
| 523 | default: |
| 524 | data_dir = DMA_NONE; |
| 525 | } |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 526 | if (user_srbcmd->sg.count > (sizeof(sg_list)/sizeof(sg_list[0]))) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 527 | dprintk((KERN_DEBUG"aacraid: too many sg entries %d\n", |
| 528 | le32_to_cpu(srbcmd->sg.count))); |
| 529 | rcode = -EINVAL; |
| 530 | goto cleanup; |
| 531 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | if (dev->dac_support == 1) { |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 533 | struct user_sgmap64* upsg = (struct user_sgmap64*)&user_srbcmd->sg; |
Mark Haverkamp | 84e2930 | 2005-07-07 13:40:00 -0700 | [diff] [blame] | 534 | struct sgmap64* psg = (struct sgmap64*)&srbcmd->sg; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 535 | struct user_sgmap* usg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | byte_count = 0; |
| 537 | |
| 538 | /* |
| 539 | * This should also catch if user used the 32 bit sgmap |
| 540 | */ |
| 541 | actual_fibsize = sizeof(struct aac_srb) - |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 542 | sizeof(struct sgentry) + |
| 543 | ((upsg->count & 0xff) * |
| 544 | sizeof(struct sgentry)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | if(actual_fibsize != fibsize){ // User made a mistake - should not continue |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 546 | dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 547 | rcode = -EINVAL; |
| 548 | goto cleanup; |
| 549 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 550 | usg = kmalloc(actual_fibsize - sizeof(struct aac_srb) |
| 551 | + sizeof(struct sgmap), GFP_KERNEL); |
| 552 | if (!usg) { |
| 553 | dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n")); |
| 554 | rcode = -ENOMEM; |
| 555 | goto cleanup; |
| 556 | } |
| 557 | memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb) |
| 558 | + sizeof(struct sgmap)); |
| 559 | actual_fibsize = sizeof(struct aac_srb) - |
| 560 | sizeof(struct sgentry) + ((usg->count & 0xff) * |
| 561 | sizeof(struct sgentry64)); |
| 562 | if ((data_dir == DMA_NONE) && upsg->count) { |
| 563 | kfree (usg); |
| 564 | dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | rcode = -EINVAL; |
| 566 | goto cleanup; |
| 567 | } |
| 568 | |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 569 | for (i = 0; i < usg->count; i++) { |
| 570 | u64 addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | void* p; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 572 | /* Does this really need to be GFP_DMA? */ |
| 573 | p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | if(p == 0) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 575 | kfree (usg); |
| 576 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
| 577 | usg->sg[i].count,i,usg->count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | rcode = -ENOMEM; |
| 579 | goto cleanup; |
| 580 | } |
Mark Haverkamp | e75d517 | 2005-10-24 10:52:11 -0700 | [diff] [blame] | 581 | sg_user[i] = (void __user *)(long)usg->sg[i].addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | sg_list[i] = p; // save so we can clean up later |
| 583 | sg_indx = i; |
| 584 | |
| 585 | if( flags & SRB_DataOut ){ |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 586 | if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 587 | kfree (usg); |
| 588 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | rcode = -EFAULT; |
| 590 | goto cleanup; |
| 591 | } |
| 592 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 593 | addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 595 | psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 596 | psg->sg[i].addr[1] = cpu_to_le32(addr>>32); |
| 597 | psg->sg[i].count = cpu_to_le32(usg->sg[i].count); |
| 598 | byte_count += usg->sg[i].count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 600 | kfree (usg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | |
| 602 | srbcmd->count = cpu_to_le32(byte_count); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 603 | psg->count = cpu_to_le32(sg_indx+1); |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 604 | status = aac_fib_send(ScsiPortCommand64, srbfib, actual_fibsize, FsaNormal, 1, 1,NULL,NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | } else { |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 606 | struct user_sgmap* upsg = &user_srbcmd->sg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | struct sgmap* psg = &srbcmd->sg; |
| 608 | byte_count = 0; |
| 609 | |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 610 | actual_fibsize = sizeof (struct aac_srb) + (((user_srbcmd->sg.count & 0xff) - 1) * sizeof (struct sgentry)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | if(actual_fibsize != fibsize){ // User made a mistake - should not continue |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 612 | dprintk((KERN_DEBUG"aacraid: Bad Size specified in Raw SRB command\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | rcode = -EINVAL; |
| 614 | goto cleanup; |
| 615 | } |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 616 | if ((data_dir == DMA_NONE) && upsg->count) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 617 | dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | rcode = -EINVAL; |
| 619 | goto cleanup; |
| 620 | } |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 621 | for (i = 0; i < upsg->count; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | dma_addr_t addr; |
| 623 | void* p; |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 624 | p = kmalloc(upsg->sg[i].count, GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 625 | if(p == 0) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 626 | dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n", |
| 627 | upsg->sg[i].count, i, upsg->count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | rcode = -ENOMEM; |
| 629 | goto cleanup; |
| 630 | } |
Mark Haverkamp | e75d517 | 2005-10-24 10:52:11 -0700 | [diff] [blame] | 631 | sg_user[i] = (void __user *)(long)upsg->sg[i].addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | sg_list[i] = p; // save so we can clean up later |
| 633 | sg_indx = i; |
| 634 | |
| 635 | if( flags & SRB_DataOut ){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 636 | if(copy_from_user(p, sg_user[i], |
| 637 | upsg->sg[i].count)) { |
| 638 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | rcode = -EFAULT; |
| 640 | goto cleanup; |
| 641 | } |
| 642 | } |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 643 | addr = pci_map_single(dev->pdev, p, |
| 644 | upsg->sg[i].count, data_dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
| 646 | psg->sg[i].addr = cpu_to_le32(addr); |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 647 | psg->sg[i].count = cpu_to_le32(upsg->sg[i].count); |
| 648 | byte_count += upsg->sg[i].count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | } |
| 650 | srbcmd->count = cpu_to_le32(byte_count); |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 651 | psg->count = cpu_to_le32(sg_indx+1); |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 652 | status = aac_fib_send(ScsiPortCommand, srbfib, actual_fibsize, FsaNormal, 1, 1, NULL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | if (status != 0){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 656 | dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n")); |
Mark Haverkamp | 5d497ce | 2005-06-17 13:38:04 -0700 | [diff] [blame] | 657 | rcode = -ENXIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | goto cleanup; |
| 659 | } |
| 660 | |
| 661 | if( flags & SRB_DataIn ) { |
| 662 | for(i = 0 ; i <= sg_indx; i++){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 663 | byte_count = le32_to_cpu((dev->dac_support == 1) |
| 664 | ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count |
| 665 | : srbcmd->sg.sg[i].count); |
| 666 | if(copy_to_user(sg_user[i], sg_list[i], byte_count)){ |
| 667 | dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | rcode = -EFAULT; |
| 669 | goto cleanup; |
| 670 | |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | reply = (struct aac_srb_reply *) fib_data(srbfib); |
| 676 | if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){ |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 677 | dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | rcode = -EFAULT; |
| 679 | goto cleanup; |
| 680 | } |
| 681 | |
| 682 | cleanup: |
Mark Haverkamp | 56b5871 | 2005-04-27 06:05:51 -0700 | [diff] [blame] | 683 | kfree(user_srbcmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | for(i=0; i <= sg_indx; i++){ |
| 685 | kfree(sg_list[i]); |
| 686 | } |
Mark Haverkamp | bfb35aa8 | 2006-02-01 09:30:55 -0800 | [diff] [blame] | 687 | aac_fib_complete(srbfib); |
| 688 | aac_fib_free(srbfib); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | |
| 690 | return rcode; |
| 691 | } |
| 692 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | struct aac_pci_info { |
| 694 | u32 bus; |
| 695 | u32 slot; |
| 696 | }; |
| 697 | |
| 698 | |
Adrian Bunk | 4833869 | 2005-04-25 19:45:58 -0700 | [diff] [blame] | 699 | static int aac_get_pci_info(struct aac_dev* dev, void __user *arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | { |
| 701 | struct aac_pci_info pci_info; |
| 702 | |
| 703 | pci_info.bus = dev->pdev->bus->number; |
| 704 | pci_info.slot = PCI_SLOT(dev->pdev->devfn); |
| 705 | |
| 706 | if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) { |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 707 | dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | return -EFAULT; |
| 709 | } |
| 710 | return 0; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 711 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | |
| 713 | |
| 714 | int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg) |
| 715 | { |
| 716 | int status; |
| 717 | |
| 718 | /* |
| 719 | * HBA gets first crack |
| 720 | */ |
| 721 | |
| 722 | status = aac_dev_ioctl(dev, cmd, arg); |
| 723 | if(status != -ENOTTY) |
| 724 | return status; |
| 725 | |
| 726 | switch (cmd) { |
| 727 | case FSACTL_MINIPORT_REV_CHECK: |
| 728 | status = check_revision(dev, arg); |
| 729 | break; |
Mark Haverkamp | 7c00ffa | 2005-05-16 18:28:42 -0700 | [diff] [blame] | 730 | case FSACTL_SEND_LARGE_FIB: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | case FSACTL_SENDFIB: |
| 732 | status = ioctl_send_fib(dev, arg); |
| 733 | break; |
| 734 | case FSACTL_OPEN_GET_ADAPTER_FIB: |
| 735 | status = open_getadapter_fib(dev, arg); |
| 736 | break; |
| 737 | case FSACTL_GET_NEXT_ADAPTER_FIB: |
| 738 | status = next_getadapter_fib(dev, arg); |
| 739 | break; |
| 740 | case FSACTL_CLOSE_GET_ADAPTER_FIB: |
| 741 | status = close_getadapter_fib(dev, arg); |
| 742 | break; |
| 743 | case FSACTL_SEND_RAW_SRB: |
| 744 | status = aac_send_raw_srb(dev,arg); |
| 745 | break; |
| 746 | case FSACTL_GET_PCI_INFO: |
| 747 | status = aac_get_pci_info(dev,arg); |
| 748 | break; |
| 749 | default: |
| 750 | status = -ENOTTY; |
| 751 | break; |
| 752 | } |
| 753 | return status; |
| 754 | } |
| 755 | |