diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac.c sas/aac.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac.c Mon Jan 30 12:56:06 2006 +++ sas/aac.c Fri Feb 23 22:18:28 2007 @@ -28,13 +28,16 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac.c,v 1.109.2.5 2006/01/30 17:56:06 scottl Exp $"); /* * Driver for the Adaptec 'FSA' family of PCI/SCSI RAID adapters. */ -#define AAC_DRIVER_VERSION 0x02000000 -#define AAC_DRIVERNAME "aac" +#define AAC_DRIVER_MAJOR_VERSION 2 +#define AAC_DRIVER_MINOR_VERSION 0 +#define AAC_DRIVER_BUGFIX_LEVEL 11 + +#define AAC_DRIVERNAME "aacu" #include "opt_aac.h" @@ -216,8 +219,11 @@ static void aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib); static int aac_rev_check(struct aac_softc *sc, caddr_t udata); +static int aac_open_aif(struct aac_softc *sc, caddr_t arg); +static int aac_close_aif(struct aac_softc *sc, caddr_t arg); static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg); -static int aac_return_aif(struct aac_softc *sc, caddr_t uptr); +static int aac_return_aif(struct aac_softc *sc, + struct aac_fib_context *ctx, caddr_t uptr); static int aac_query_disk(struct aac_softc *sc, caddr_t uptr); static int aac_get_pci_info(struct aac_softc *sc, caddr_t uptr); static void aac_ioctl_event(struct aac_softc *sc, @@ -230,7 +236,7 @@ .d_close = aac_close, .d_ioctl = aac_ioctl, .d_poll = aac_poll, - .d_name = "aac", + .d_name = "aacu", }; MALLOC_DEFINE(M_AACBUF, "aacbuf", "Buffers for the AAC driver"); @@ -283,9 +289,6 @@ TAILQ_INIT(&sc->aac_container_tqh); TAILQ_INIT(&sc->aac_ev_cmfree); - /* Initialize the local AIF queue pointers */ - sc->aac_aifq_head = sc->aac_aifq_tail = AAC_AIFQ_LENGTH; - /* * Initialise the adapter. */ @@ -469,7 +472,7 @@ mir->MntTable[0].FileSystemName, mir->MntTable[0].Capacity, mir->MntTable[0].VolType); - if ((child = device_add_child(sc->aac_dev, "aacd", -1)) == NULL) + if ((child = device_add_child(sc->aac_dev, "aacdu", -1)) == NULL) device_printf(sc->aac_dev, "device_add_child failed\n"); else device_set_ivars(child, co); @@ -1366,7 +1369,6 @@ aac_map_command_helper, &fibphys, 0); /* initialise constant fields in the command structure */ - mtx_lock(&sc->aac_io_lock); bzero(fm->aac_fibs, sc->aac_max_fibs_alloc * sc->aac_max_fib_size); for (i = 0; i < sc->aac_max_fibs_alloc; i++) { cm = sc->aac_commands + sc->total_fibs; @@ -1378,21 +1380,22 @@ cm->cm_index = sc->total_fibs; if ((error = bus_dmamap_create(sc->aac_buffer_dmat, 0, - &cm->cm_datamap)) == 0) - aac_release_command(cm); - else + &cm->cm_datamap)) != 0) break; + mtx_lock(&sc->aac_io_lock); + aac_release_command(cm); sc->total_fibs++; + mtx_unlock(&sc->aac_io_lock); } if (i > 0) { + mtx_lock(&sc->aac_io_lock); TAILQ_INSERT_TAIL(&sc->aac_fibmap_tqh, fm, fm_link); debug(1, "total_fibs= %d\n", sc->total_fibs); mtx_unlock(&sc->aac_io_lock); return (0); } - mtx_unlock(&sc->aac_io_lock); bus_dmamap_unload(sc->aac_fib_dmat, fm->aac_fibmap); bus_dmamem_free(sc->aac_fib_dmat, fm->aac_fibs, fm->aac_fibmap); free(fm, M_AACBUF); @@ -1668,14 +1671,12 @@ sc->aac_max_sectors = 128; /* 64KB */ if (sc->flags & AAC_FLAGS_SG_64BIT) sc->aac_sg_tablesize = (AAC_FIB_DATASIZE - - sizeof(struct aac_blockwrite64) - + sizeof(struct aac_sg_table64)) - / sizeof(struct aac_sg_table64); + - sizeof(struct aac_blockwrite64)) + / sizeof(struct aac_sg_entry64); else sc->aac_sg_tablesize = (AAC_FIB_DATASIZE - - sizeof(struct aac_blockwrite) - + sizeof(struct aac_sg_table)) - / sizeof(struct aac_sg_table); + - sizeof(struct aac_blockwrite)) + / sizeof(struct aac_sg_entry); if (!aac_sync_command(sc, AAC_MONKER_GETCOMMPREF, 0, 0, 0, 0, NULL)) { options = AAC_GET_MAILBOX(sc, 1); @@ -2744,10 +2745,8 @@ sc->aac_revision = info->KernelRevision; device_printf(sc->aac_dev, "Adaptec Raid Controller %d.%d.%d-%d\n", - AAC_DRIVER_VERSION >> 24, - (AAC_DRIVER_VERSION >> 16) & 0xFF, - AAC_DRIVER_VERSION & 0xFF, - AAC_DRIVER_BUILD); + AAC_DRIVER_MAJOR_VERSION, AAC_DRIVER_MINOR_VERSION, + AAC_DRIVER_BUGFIX_LEVEL, AAC_DRIVER_BUILD); if (bootverbose) { device_printf(sc->aac_dev, "%s %dMHz, %dMB memory " @@ -2821,11 +2820,8 @@ debug_called(2); sc = dev->si_drv1; - - /* Check to make sure the device isn't already open */ - if (sc->aac_state & AAC_STATE_OPEN) { - return EBUSY; - } + sc = dev->si_drv1; + sc->aac_open_cnt++; sc->aac_state |= AAC_STATE_OPEN; return 0; @@ -2839,8 +2835,9 @@ debug_called(2); sc = dev->si_drv1; - + sc->aac_open_cnt--; /* Mark this unit as no longer open */ + if (sc->aac_open_cnt == 0) sc->aac_state &= ~AAC_STATE_OPEN; return 0; @@ -2852,7 +2849,6 @@ union aac_statrequest *as; struct aac_softc *sc; int error = 0; - uint32_t cookie; debug_called(2); @@ -2890,20 +2886,7 @@ arg = *(caddr_t*)arg; case FSACTL_LNX_OPEN_GET_ADAPTER_FIB: debug(1, "FSACTL_OPEN_GET_ADAPTER_FIB"); - /* - * Pass the caller out an AdapterFibContext. - * - * Note that because we only support one opener, we - * basically ignore this. Set the caller's context to a magic - * number just in case. - * - * The Linux code hands the driver a pointer into kernel space, - * and then trusts it when the caller hands it back. Aiee! - * Here, we give it the proc pointer of the per-adapter aif - * thread. It's only used as a sanity check in other calls. - */ - cookie = (uint32_t)(uintptr_t)sc->aifthread; - error = copyout(&cookie, arg, sizeof(cookie)); + error = aac_open_aif(sc, arg); break; case FSACTL_GET_NEXT_ADAPTER_FIB: arg = *(caddr_t*)arg; @@ -2912,9 +2895,10 @@ error = aac_getnext_aif(sc, arg); break; case FSACTL_CLOSE_GET_ADAPTER_FIB: + arg = *(caddr_t*)arg; case FSACTL_LNX_CLOSE_GET_ADAPTER_FIB: debug(1, "FSACTL_CLOSE_GET_ADAPTER_FIB"); - /* don't do anything here */ + error = aac_close_aif(sc, arg); break; case FSACTL_MINIPORT_REV_CHECK: arg = *(caddr_t*)arg; @@ -2962,7 +2946,7 @@ mtx_lock(&sc->aac_aifq_lock); if ((poll_events & (POLLRDNORM | POLLIN)) != 0) { - if (sc->aac_aifq_tail != sc->aac_aifq_head) + if (sc->aifq_idx != 0 || sc->aifq_filled) revents |= poll_events & (POLLIN | POLLRDNORM); } mtx_unlock(&sc->aac_aifq_lock); @@ -3028,6 +3012,7 @@ aac_add_event(sc, event); msleep(&cm, &sc->aac_io_lock, 0, "sendfib", 0); } + mtx_unlock(&sc->aac_io_lock); /* * Fetch the FIB header, then re-copy to get data as well. @@ -3049,11 +3034,13 @@ /* * Pass the FIB to the controller, wait for it to complete. */ + mtx_lock(&sc->aac_io_lock); if ((error = aac_wait_command(cm)) != 0) { device_printf(sc->aac_dev, "aac_wait_command return %d\n", error); goto out; } + mtx_unlock(&sc->aac_io_lock); /* * Copy the FIB and data back out to the caller. @@ -3065,6 +3052,7 @@ size = sizeof(struct aac_fib); } error = copyout(cm->cm_fib, ufib, size); + mtx_lock(&sc->aac_io_lock); out: if (cm != NULL) { @@ -3084,10 +3072,11 @@ { struct aac_aif_command *aif; struct aac_container *co, *co_next; + struct aac_fib_context *ctx; struct aac_mntinfo *mi; struct aac_mntinforesp *mir = NULL; u_int16_t rsize; - int next, found; + int next, current, found; int count = 0, added = 0, i = 0; debug_called(2); @@ -3218,17 +3207,26 @@ /* Copy the AIF data to the AIF queue for ioctl retrieval */ mtx_lock(&sc->aac_aifq_lock); - next = (sc->aac_aifq_head + 1) % AAC_AIFQ_LENGTH; - if (next != sc->aac_aifq_tail) { - bcopy(aif, &sc->aac_aifq[next], sizeof(struct aac_aif_command)); - sc->aac_aifq_head = next; - + current = sc->aifq_idx; + next = (current + 1) % AAC_AIFQ_LENGTH; + if (next == 0) + sc->aifq_filled = 1; + bcopy(fib, &sc->aac_aifq[current], sizeof (struct aac_fib)); + /* modify AIF contexts */ + if (sc->aifq_filled) { + for (ctx = sc->fibctx; ctx; ctx = ctx->next) { + if (next == ctx->ctx_idx) + ctx->ctx_wrap = 1; + else if (current == ctx->ctx_idx && ctx->ctx_wrap) + ctx->ctx_idx = next; + } + } + sc->aifq_idx = next; /* On the off chance that someone is sleeping for an aif... */ if (sc->aac_state & AAC_STATE_AIF_SLEEPER) wakeup(sc->aac_aifq); /* Wakeup any poll()ers */ selwakeuppri(&sc->rcv_select, PRIBIO); - } mtx_unlock(&sc->aac_aifq_lock); return; @@ -3274,38 +3272,113 @@ } /* + * Pass the fib context to the caller + */ +static int +aac_open_aif(struct aac_softc *sc, caddr_t arg) +{ + struct aac_fib_context *fibctx, *ctx; + int error = 0; + + debug_called(2); + + fibctx = malloc(sizeof(struct aac_fib_context), M_AACBUF, M_NOWAIT|M_ZERO); + if (fibctx == NULL) + return (ENOMEM); + + mtx_lock(&sc->aac_aifq_lock); + /* all elements are already 0, add to queue */ + if (sc->fibctx == NULL) + sc->fibctx = fibctx; + else { + for (ctx = sc->fibctx; ctx->next; ctx = ctx->next) + ; + ctx->next = fibctx; + fibctx->prev = ctx; + } + + /* evaluate unique value */ + fibctx->unique = (*(u_int32_t *)&fibctx & 0xffffffff); + ctx = sc->fibctx; + while (ctx != fibctx) { + if (ctx->unique == fibctx->unique) { + fibctx->unique++; + ctx = sc->fibctx; + } else { + ctx = ctx->next; + } + } + mtx_unlock(&sc->aac_aifq_lock); + + error = copyout(&fibctx->unique, (void *)arg, sizeof(u_int32_t)); + if (error) + aac_close_aif(sc, (caddr_t)ctx); + return error; +} + +/* + * Close the caller's fib context + */ +static int +aac_close_aif(struct aac_softc *sc, caddr_t arg) +{ + struct aac_fib_context *ctx; + + debug_called(2); + + mtx_lock(&sc->aac_aifq_lock); + for (ctx = sc->fibctx; ctx; ctx = ctx->next) { + if (ctx->unique == *(uint32_t *)&arg) { + if (ctx == sc->fibctx) + sc->fibctx = NULL; + else { + ctx->prev->next = ctx->next; + if (ctx->next) + ctx->next->prev = ctx->prev; + } + break; + } + } + mtx_unlock(&sc->aac_aifq_lock); + if (ctx) + free(ctx, M_AACBUF); + + return 0; +} + +/* * Pass the caller the next AIF in their queue */ static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg) { struct get_adapter_fib_ioctl agf; + struct aac_fib_context *ctx; int error; debug_called(2); if ((error = copyin(arg, &agf, sizeof(agf))) == 0) { + for (ctx = sc->fibctx; ctx; ctx = ctx->next) { + if (agf.AdapterFibContext == ctx->unique) + break; + } + if (!ctx) + return (EFAULT); - /* - * Check the magic number that we gave the caller. - */ - if (agf.AdapterFibContext != (int)(uintptr_t)sc->aifthread) { - error = EFAULT; - } else { - error = aac_return_aif(sc, agf.AifFib); - if ((error == EAGAIN) && (agf.Wait)) { + error = aac_return_aif(sc, ctx, agf.AifFib); + if (error == EAGAIN && agf.Wait) { + debug(2, "aac_getnext_aif(): waiting for AIF"); sc->aac_state |= AAC_STATE_AIF_SLEEPER; while (error == EAGAIN) { error = tsleep(sc->aac_aifq, PRIBIO | PCATCH, "aacaif", 0); if (error == 0) - error = aac_return_aif(sc, - agf.AifFib); + error = aac_return_aif(sc, ctx, agf.AifFib); } sc->aac_state &= ~AAC_STATE_AIF_SLEEPER; } } - } return(error); } @@ -3313,27 +3386,28 @@ * Hand the next AIF off the top of the queue out to userspace. */ static int -aac_return_aif(struct aac_softc *sc, caddr_t uptr) +aac_return_aif(struct aac_softc *sc, struct aac_fib_context *ctx, caddr_t uptr) { - int next, error; + int current, error; debug_called(2); mtx_lock(&sc->aac_aifq_lock); - if (sc->aac_aifq_tail == sc->aac_aifq_head) { + current = ctx->ctx_idx; + if (current == sc->aifq_idx && !ctx->ctx_wrap) { + /* empty */ mtx_unlock(&sc->aac_aifq_lock); return (EAGAIN); } - - next = (sc->aac_aifq_tail + 1) % AAC_AIFQ_LENGTH; - error = copyout(&sc->aac_aifq[next], uptr, - sizeof(struct aac_aif_command)); + error = + copyout(&sc->aac_aifq[current], (void *)uptr, sizeof(struct aac_fib)); if (error) device_printf(sc->aac_dev, "aac_return_aif: copyout returned %d\n", error); - else - sc->aac_aifq_tail = next; - + else { + ctx->ctx_wrap = 0; + ctx->ctx_idx = (current + 1) % AAC_AIFQ_LENGTH; + } mtx_unlock(&sc->aac_aifq_lock); return(error); } @@ -3503,7 +3577,7 @@ break; }; - child = device_add_child(sc->aac_dev, "aacp", -1); + child = device_add_child(sc->aac_dev, "aacpu", -1); if (child == NULL) { device_printf(sc->aac_dev, "device_add_child failed for passthrough bus %d\n", diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_cam.c sas/aac_cam.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_cam.c Mon Jan 30 12:56:07 2006 +++ sas/aac_cam.c Fri Feb 23 22:18:28 2007 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_cam.c,v 1.20.2.2 2006/01/30 17:56:07 scottl Exp $"); /* * CAM front-end for communicating with non-DASD devices @@ -90,13 +90,13 @@ }; static driver_t aac_pass_driver = { - "aacp", + "aacpu", aac_pass_methods, sizeof(struct aac_cam) }; -DRIVER_MODULE(aacp, aac, aac_pass_driver, aac_pass_devclass, 0, 0); -MODULE_DEPEND(aacp, cam, 1, 1, 1); +DRIVER_MODULE(aacpu, aacu, aac_pass_driver, aac_pass_devclass, 0, 0); +MODULE_DEPEND(aacpu, cam, 1, 1, 1); MALLOC_DEFINE(M_AACCAM, "aaccam", "AAC CAM info"); @@ -109,7 +109,10 @@ case AAC_EVENT_CMFREE: camsc = arg; free(event, M_AACCAM); + mtx_lock(&sc->aac_io_lock); xpt_release_simq(camsc->sim, 1); + sc->sim_freezed = 0; + mtx_unlock(&sc->aac_io_lock); break; default: device_printf(sc->aac_dev, "unknown event %d in aac_cam\n", @@ -170,7 +173,7 @@ if (devq == NULL) return (EIO); - sim = cam_sim_alloc(aac_cam_action, aac_cam_poll, "aacp", camsc, + sim = cam_sim_alloc(aac_cam_action, aac_cam_poll, "aacpu", camsc, device_get_unit(dev), 1, 1, devq); if (sim == NULL) { cam_simq_free(devq); @@ -310,9 +313,14 @@ if (aac_alloc_command(sc, &cm)) { struct aac_event *event; - xpt_freeze_simq(sim, 1); ccb->ccb_h.status = CAM_REQUEUE_REQ; xpt_done(ccb); + if (sc->sim_freezed) { + mtx_unlock(&sc->aac_io_lock); + return; + } + sc->sim_freezed = 1; + xpt_freeze_simq(sim, 1); event = malloc(sizeof(struct aac_event), M_AACCAM, M_NOWAIT | M_ZERO); if (event == NULL) { @@ -371,16 +379,17 @@ bcopy(csio->cdb_io.cdb_bytes, (u_int8_t *)&srb->cdb[0], srb->cdb_len); + /* Set command */ + fib->Header.Command = (sc->flags & AAC_FLAGS_SG_64BIT) ? + ScsiPortCommandU64 : ScsiPortCommand; + /* Map the s/g list. XXX 32bit addresses only! */ if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { if ((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) { srb->data_len = csio->dxfer_len; if (ccb->ccb_h.flags & CAM_DATA_PHYS) { - /* - * XXX This isn't 64-bit clean. - * However, this condition is not - * normally used in CAM. - */ + /* Send a 32bit command */ + fib->Header.Command = ScsiPortCommand; srb->sg_map32.SgCount = 1; srb->sg_map32.SgEntry[0].SgAddress = (uint32_t)(uintptr_t)csio->data_ptr; @@ -414,6 +423,7 @@ } else { ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); + mtx_unlock(&sc->aac_io_lock); return; } default: @@ -437,7 +447,6 @@ AAC_FIBSTATE_FROMHOST | AAC_FIBSTATE_REXPECTED | AAC_FIBSTATE_NORM; - fib->Header.Command = ScsiPortCommand; fib->Header.Size = sizeof(struct aac_fib_header) + sizeof(struct aac_srb32); diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_compat.h sas/aac_compat.h --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_compat.h Wed Dec 31 19:00:00 1969 +++ sas/aac_compat.h Fri Feb 23 22:18:28 2007 @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2000 Michael Smith + * Copyright (c) 2000 BSDi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_compat.h,v 1.3 2001/09/05 20:43:02 scottl Exp $ + */ +/* + * Backwards compatibility support. + */ + +/* + * Handle the new/old bio/buf changeover + */ + +#if __FreeBSD_version < 500003 /* old buf style */ +#include +#define FREEBSD_4 +#define bio buf +#define bioq_init(x) bufq_init(x) +#define bioq_insert_tail(x, y) bufq_insert_tail(x, y) +#define bioq_remove(x, y) bufq_remove(x, y) +#define bioq_first(x) bufq_first(x) +#define bio_queue_head buf_queue_head +#define bio_bcount b_bcount +#define bio_blkno b_blkno +#define bio_caller1 b_caller1 +#define bio_data b_data +#define bio_dev b_dev +#define bio_driver1 b_driver1 +#define bio_driver2 b_driver2 +#define bio_error b_error +#define bio_flags b_flags +#define bio_pblkno b_pblkno +#define bio_resid b_resid +#define BIO_ERROR B_ERROR +#define devstat_end_transaction_bio(x, y) devstat_end_transaction_buf(x, y) +#define BIO_IS_READ(x) ((x)->b_flags & B_READ) + +#else /* new bio style */ +#include +#define BIO_IS_READ(x) ((x)->bio_cmd == BIO_READ) +#endif diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_debug.c sas/aac_debug.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_debug.c Mon Jan 30 12:56:07 2006 +++ sas/aac_debug.c Fri Feb 23 22:18:28 2007 @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_debug.c,v 1.20.2.2 2006/01/30 17:56:07 scottl Exp $"); /* * Debugging support. @@ -128,7 +128,7 @@ { struct aac_softc *sc; - sc = devclass_get_softc(devclass_find("aac"), 0); + sc = devclass_get_softc(devclass_find("aacu"), 0); aac_print_queues(sc); switch (sc->aac_hwif) { diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_disk.c sas/aac_disk.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_disk.c Mon May 2 18:56:52 2005 +++ sas/aac_disk.c Fri Feb 23 22:18:28 2007 @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_disk.c,v 1.43 2005/05/02 22:56:52 scottl Exp $"); #include "opt_aac.h" @@ -78,14 +78,14 @@ }; static driver_t aac_disk_driver = { - "aacd", + "aacdu", aac_disk_methods, sizeof(struct aac_disk) }; #define AAC_MAXIO 65536 -DRIVER_MODULE(aacd, aac, aac_disk_driver, aac_disk_devclass, 0, 0); +DRIVER_MODULE(aacdu, aacu, aac_disk_driver, aac_disk_devclass, 0, 0); /* sysctl tunables */ static unsigned int aac_iosize_max = AAC_MAXIO; /* due to limits of the card */ @@ -366,7 +366,7 @@ sc->unit = device_get_unit(dev); sc->ad_disk = disk_alloc(); sc->ad_disk->d_drv1 = sc; - sc->ad_disk->d_name = "aacd"; + sc->ad_disk->d_name = "aacdu"; sc->ad_disk->d_maxsize = aac_iosize_max; sc->ad_disk->d_open = aac_disk_open; sc->ad_disk->d_close = aac_disk_close; diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_ioctl.h sas/aac_ioctl.h --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_ioctl.h Wed Dec 31 19:00:00 1969 +++ sas/aac_ioctl.h Fri Feb 23 22:18:28 2007 @@ -0,0 +1,179 @@ +/*- + * Copyright (c) 2000 Michael Smith + * Copyright (c) 2000 Scott Long + * Copyright (c) 2000 BSDi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: /repoman/r/ncvs/src/sys/sys/aac_ioctl.h,v 1.11 2004/12/09 22:20:25 scottl Exp $ + */ + +/* + * Command queue statistics + */ +#define AACQ_FREE 0 +#define AACQ_BIO 1 +#define AACQ_READY 2 +#define AACQ_BUSY 3 +#define AACQ_COUNT 4 /* total number of queues */ + +struct aac_qstat { + u_int32_t q_length; + u_int32_t q_max; +}; + +/* + * Statistics request + */ +union aac_statrequest { + u_int32_t as_item; + struct aac_qstat as_qstat; +}; + +#define AACIO_STATS _IOWR('T', 101, union aac_statrequest) + +/* + * Ioctl commands likely to be submitted from a Linux management application. + * These bit encodings are actually descended from Windows NT. Ick. + */ + +#define CTL_CODE(devType, func, meth, acc) (((devType) << 16) | ((acc) << 14) | ((func) << 2) | (meth)) +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 +#define FILE_ANY_ACCESS 0 +#define FILE_READ_ACCESS ( 0x0001 ) +#define FILE_WRITE_ACCESS ( 0x0002 ) +#define FILE_DEVICE_CONTROLLER 0x00000004 + +#define FSACTL_LNX_SENDFIB CTL_CODE(FILE_DEVICE_CONTROLLER, 2050, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_GET_COMM_PERF_DATA CTL_CODE(FILE_DEVICE_CONTROLLER, 2084, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_OPENCLS_COMM_PERF_DATA CTL_CODE(FILE_DEVICE_CONTROLLER, \ + 2085, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_OPEN_GET_ADAPTER_FIB CTL_CODE(FILE_DEVICE_CONTROLLER, 2100, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_GET_NEXT_ADAPTER_FIB CTL_CODE(FILE_DEVICE_CONTROLLER, 2101, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_CLOSE_GET_ADAPTER_FIB CTL_CODE(FILE_DEVICE_CONTROLLER, \ + 2102, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_CLOSE_ADAPTER_CONFIG CTL_CODE(FILE_DEVICE_CONTROLLER, 2104, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_OPEN_ADAPTER_CONFIG CTL_CODE(FILE_DEVICE_CONTROLLER, 2105, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_MINIPORT_REV_CHECK CTL_CODE(FILE_DEVICE_CONTROLLER, 2107, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_QUERY_ADAPTER_CONFIG CTL_CODE(FILE_DEVICE_CONTROLLER, 2113, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_GET_PCI_INFO CTL_CODE(FILE_DEVICE_CONTROLLER, 2119, \ + METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSACTL_LNX_FORCE_DELETE_DISK CTL_CODE(FILE_DEVICE_CONTROLLER, 2120, \ + METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSACTL_LNX_AIF_THREAD CTL_CODE(FILE_DEVICE_CONTROLLER, 2127, \ + METHOD_NEITHER, FILE_ANY_ACCESS) + +/* Why these don't follow the previous convention, I don't know */ +#define FSACTL_LNX_NULL_IO_TEST 0x43 +#define FSACTL_LNX_SIM_IO_TEST 0x53 +#define FSACTL_LNX_DOWNLOAD 0x83 +#define FSACTL_LNX_GET_VAR 0x93 +#define FSACTL_LNX_SET_VAR 0xa3 +#define FSACTL_LNX_GET_FIBTIMES 0xb3 +#define FSACTL_LNX_ZERO_FIBTIMES 0xc3 +#define FSACTL_LNX_DELETE_DISK 0x163 +#define FSACTL_LNX_QUERY_DISK 0x173 + +/* Ok, here it gets really lame */ +#define FSACTL_LNX_PROBE_CONTAINERS 2131 /* Just guessing */ + +/* Do the native version of the ioctls. Since the BSD encoding scheme + * conflicts with the 'standard' AAC encoding scheme, the resulting numbers + * will be different. The '8' comes from the fact that the previous scheme + * used 12 bits for the number, with the the 12th bit being the only set + * bit above bit 8. Thus the value of 8, with the lower 8 bits holding the + * command number. 9 is used for the odd overflow case. + */ +#define FSACTL_SENDFIB _IO('8', 2) +#define FSACTL_GET_COMM_PERF_DATA _IO('8', 36) +#define FSACTL_OPENCLS_COMM_PERF_DATA _IO('8', 37) +#define FSACTL_OPEN_GET_ADAPTER_FIB _IO('8', 52) +#define FSACTL_GET_NEXT_ADAPTER_FIB _IO('8', 53) +#define FSACTL_CLOSE_GET_ADAPTER_FIB _IO('8', 54) +#define FSACTL_CLOSE_ADAPTER_CONFIG _IO('8', 56) +#define FSACTL_OPEN_ADAPTER_CONFIG _IO('8', 57) +#define FSACTL_MINIPORT_REV_CHECK _IO('8', 59) +#define FSACTL_QUERY_ADAPTER_CONFIG _IO('8', 65) +#define FSACTL_GET_PCI_INFO _IO('8', 71) +#define FSACTL_FORCE_DELETE_DISK _IO('8', 72) +#define FSACTL_AIF_THREAD _IO('8', 79) + +#define FSACTL_NULL_IO_TEST _IO('8', 67) +#define FSACTL_SIM_IO_TEST _IO('8', 83) +#define FSACTL_DOWNLOAD _IO('8', 131) +#define FSACTL_GET_VAR _IO('8', 147) +#define FSACTL_SET_VAR _IO('8', 163) +#define FSACTL_GET_FIBTIMES _IO('8', 179) +#define FSACTL_ZERO_FIBTIMES _IO('8', 195) +#define FSACTL_DELETE_DISK _IO('8', 99) +#define FSACTL_QUERY_DISK _IO('9', 115) + +#define FSACTL_PROBE_CONTAINERS _IO('9', 83) /* Just guessing */ + +#ifdef _KERNEL +/* + * Support for faking the "miniport" version. + */ +struct aac_rev_check { + RevComponent callingComponent; + struct FsaRevision callingRevision; +}; + +struct aac_rev_check_resp { + int possiblyCompatible; + struct FsaRevision adapterSWRevision; +}; + +/* + * Context passed in by a consumer looking to collect an AIF. + */ +struct get_adapter_fib_ioctl { + u_int32_t AdapterFibContext; + int Wait; + caddr_t AifFib; +}; + +struct aac_query_disk { + int32_t ContainerNumber; + int32_t Bus; + int32_t Target; + int32_t Lun; + u_int32_t Valid; + u_int32_t Locked; + u_int32_t Deleted; + int32_t Instance; + char diskDeviceName[10]; + u_int32_t UnMapped; +}; +#endif diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_linux.c sas/aac_linux.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_linux.c Sun May 30 16:08:23 2004 +++ sas/aac_linux.c Fri Feb 23 22:18:28 2007 @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_linux.c,v 1.3 2004/05/30 20:08:23 phk Exp $"); /* * Linux ioctl handler for the aac device driver @@ -38,8 +38,13 @@ #include #include #include +#ifdef __amd64__ +#include +#include +#else #include #include +#endif #include /* There are multiple ioctl number ranges that need to be handled */ diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_pci.c sas/aac_pci.c --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_pci.c Mon Jan 30 12:56:07 2006 +++ sas/aac_pci.c Fri Feb 23 22:18:28 2007 @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_pci.c,v 1.54.2.4 2006/01/30 17:56:07 scottl Exp $"); /* * PCI bus interface and resource allocation. @@ -74,14 +74,14 @@ }; static driver_t aac_pci_driver = { - "aac", + "aacu", aac_methods, sizeof(struct aac_softc) }; static devclass_t aac_devclass; -DRIVER_MODULE(aac, pci, aac_pci_driver, aac_devclass, 0, 0); +DRIVER_MODULE(aacu, pci, aac_pci_driver, aac_devclass, 0, 0); struct aac_ident { @@ -166,16 +166,16 @@ "ICP9014RO SATA RAID"}, {0x9005, 0x0285, 0x9005, 0x0294, AAC_HWIF_I960RX, 0, "Adaptec SATA RAID 2026ZCR"}, - {0x9005, 0x0285, 0x103c, 0x3227, AAC_HWIF_I960RX, 0, - "Adaptec SATA RAID 2610SA"}, {0x9005, 0x0285, 0x9005, 0x0296, AAC_HWIF_I960RX, 0, "Adaptec SCSI RAID 2240S"}, {0x9005, 0x0285, 0x9005, 0x0297, AAC_HWIF_I960RX, 0, "Adaptec SAS RAID 4005SAS"}, {0x9005, 0x0285, 0x1014, 0x02f2, AAC_HWIF_I960RX, 0, "IBM ServeRAID 8i"}, + {0x9005, 0x0285, 0x1014, 0x0312, AAC_HWIF_I960RX, 0, + "IBM ServeRAID 8i"}, {0x9005, 0x0285, 0x9005, 0x0298, AAC_HWIF_I960RX, 0, - "Adaptec SAS RAID 4000SAS"}, + "Adaptec RAID 4000"}, {0x9005, 0x0285, 0x9005, 0x0299, AAC_HWIF_I960RX, 0, "Adaptec SAS RAID 4800SAS"}, {0x9005, 0x0285, 0x9005, 0x029a, AAC_HWIF_I960RX, 0, @@ -192,6 +192,52 @@ "ICP9047MA SATA RAID"}, {0x9005, 0x0286, 0x9005, 0x02a1, AAC_HWIF_RKT, 0, "ICP9087MA SATA RAID"}, + {0x9005, 0x0286, 0x9005, 0x02a6, AAC_HWIF_RKT, 0, + "ICP9067MA SATA RAID"}, + {0x9005, 0x0285, 0x9005, 0x02b5, AAC_HWIF_I960RX, 0, + "Adaptec RAID 5445"}, + {0x9005, 0x0285, 0x9005, 0x02b6, AAC_HWIF_I960RX, 0, + "Adaptec RAID 5805"}, + {0x9005, 0x0285, 0x9005, 0x02b7, AAC_HWIF_I960RX, 0, + "Adaptec RAID 5085"}, + {0x9005, 0x0285, 0x9005, 0x02b8, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5445SL"}, + {0x9005, 0x0285, 0x9005, 0x02b9, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5085SL"}, + {0x9005, 0x0285, 0x9005, 0x02ba, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5805SL"}, + {0x9005, 0x0285, 0x9005, 0x02bb, AAC_HWIF_I960RX, 0, + "Adaptec RAID 3405"}, + {0x9005, 0x0285, 0x9005, 0x02bc, AAC_HWIF_I960RX, 0, + "Adaptec RAID 3805"}, + {0x9005, 0x0285, 0x9005, 0x02bd, AAC_HWIF_I960RX, 0, + "Adaptec RAID 31205"}, + {0x9005, 0x0285, 0x9005, 0x02be, AAC_HWIF_I960RX, 0, + "Adaptec RAID 31605"}, + {0x9005, 0x0285, 0x9005, 0x02bf, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5045BL"}, + {0x9005, 0x0285, 0x9005, 0x02c0, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5085BL"}, + {0x9005, 0x0285, 0x9005, 0x02c1, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5125BR"}, + {0x9005, 0x0285, 0x9005, 0x02c2, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5165BR"}, + {0x9005, 0x0285, 0x9005, 0x02c3, AAC_HWIF_I960RX, 0, + "Adaptec RAID 51205"}, + {0x9005, 0x0285, 0x9005, 0x02c4, AAC_HWIF_I960RX, 0, + "Adaptec RAID 51605"}, + {0x9005, 0x0285, 0x9005, 0x02c5, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5125SL"}, + {0x9005, 0x0285, 0x9005, 0x02c6, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5165SL"}, + {0x9005, 0x0285, 0x9005, 0x02c7, AAC_HWIF_I960RX, 0, + "Adaptec RAID 3085"}, + {0x9005, 0x0285, 0x9005, 0x02c8, AAC_HWIF_I960RX, 0, + "ICP RAID ICP5805BL"}, + {0x9005, 0x0286, 0x1014, 0x9580, AAC_HWIF_RKT, 0, + "IBM ServeRAID 8k"}, + {0x9005, 0x0285, 0x1014, 0x034d, AAC_HWIF_I960RX, 0, + "IBM ServeRAID 8s"}, {0, 0, 0, 0, 0, 0, 0} }; @@ -223,7 +269,7 @@ if ((id = aac_find_ident(dev)) != NULL) { device_set_desc(dev, id->desc); - return(BUS_PROBE_DEFAULT); + return(BUS_PROBE_SPECIFIC); } return(ENXIO); } @@ -372,13 +418,13 @@ }; static driver_t aacch_driver = { - "aacch", + "aacchu", aacch_methods, sizeof(struct aacch_softc) }; static devclass_t aacch_devclass; -DRIVER_MODULE(aacch, pci, aacch_driver, aacch_devclass, 0, 0); +DRIVER_MODULE(aacchu, pci, aacch_driver, aacch_devclass, 0, 0); static int aacch_probe(device_t dev) diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aac_tables.h sas/aac_tables.h --- /d2/source/RELENG_6_1/src/sys/dev/aac/aac_tables.h Sun Oct 9 02:39:21 2005 +++ sas/aac_tables.h Fri Feb 23 22:18:28 2007 @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aac_tables.h,v 1.5 2005/06/01 07:11:17 scottl Exp $ */ /* diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aacreg.h sas/aacreg.h --- /d2/source/RELENG_6_1/src/sys/dev/aac/aacreg.h Fri Oct 28 11:48:09 2005 +++ sas/aacreg.h Fri Feb 23 22:18:28 2007 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aacreg.h,v 1.21.2.1.2.1 2005/10/28 16:31:34 scottl Exp $ */ /* Binary files /d2/source/RELENG_6_1/src/sys/dev/aac/aacu.ko and sas/aacu.ko differ diff -Nurw --exclude CVS /d2/source/RELENG_6_1/src/sys/dev/aac/aacvar.h sas/aacvar.h --- /d2/source/RELENG_6_1/src/sys/dev/aac/aacvar.h Sun Oct 9 02:39:21 2005 +++ sas/aacvar.h Fri Feb 23 22:18:28 2007 @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ + * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aac/aacvar.h,v 1.46.8.1 2005/10/09 06:39:21 scottl Exp $ */ #include @@ -272,6 +272,14 @@ #define AAC_GETREG1(sc, reg) bus_space_read_1 (sc->aac_btag, \ sc->aac_bhandle, reg) +/* fib context (IOCTL) */ +struct aac_fib_context { + u_int32_t unique; + int ctx_idx; + int ctx_wrap; + struct aac_fib_context *next, *prev; +}; + /* * Per-controller structure. */ @@ -298,6 +306,7 @@ #define AAC_STATE_OPEN (1<<1) #define AAC_STATE_INTERRUPTS_ON (1<<2) #define AAC_STATE_AIF_SLEEPER (1<<3) + int aac_open_cnt; struct FsaRevision aac_revision; /* controller hardware interface */ @@ -327,10 +336,6 @@ TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for * controller resources */ TAILQ_HEAD(,aac_command) aac_busy; - TAILQ_HEAD(,aac_command) aac_aif; -#if 0 - TAILQ_HEAD(,aac_command) aac_norm; -#endif TAILQ_HEAD(,aac_event) aac_ev_cmfree; struct bio_queue_head aac_bioq; struct aac_queue_table *aac_queues; @@ -356,9 +361,10 @@ /* management interface */ struct cdev *aac_dev_t; struct mtx aac_aifq_lock; - struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH]; - int aac_aifq_head; - int aac_aifq_tail; + struct aac_fib aac_aifq[AAC_AIFQ_LENGTH]; + int aifq_idx; + int aifq_filled; + struct aac_fib_context *fibctx; struct selinfo rcv_select; struct proc *aifthread; int aifflags; @@ -387,6 +393,7 @@ #define AAC_FLAGS_RAW_IO (1 << 12) /* Raw I/O interface */ #define AAC_FLAGS_ARRAY_64BIT (1 << 13) /* 64-bit array size */ + int sim_freezed; /* flag for sim_freeze/release */ u_int32_t supported_options; u_int32_t scsi_method_id; TAILQ_HEAD(,aac_sim) aac_sim_tqh;