diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c index e1ea0e8a0b1f..5f0ef287aa65 100644 --- a/sys/dev/aac/aac.c +++ b/sys/dev/aac/aac.c @@ -66,6 +66,8 @@ devclass_t aac_devclass; static void aac_startup(void *arg); +static void aac_add_container(struct aac_softc *sc, + struct aac_mntinforesponse *mir, int f); /* Command Processing */ static void aac_startio(struct aac_softc *sc); @@ -103,8 +105,7 @@ static int aac_sync_fib(struct aac_softc *sc, u_int32_t command, static int aac_enqueue_fib(struct aac_softc *sc, int queue, struct aac_command *cm); static int aac_dequeue_fib(struct aac_softc *sc, int queue, - u_int32_t *fib_size, - struct aac_fib **fib_addr); + u_int32_t *fib_size, struct aac_fib **fib_addr); static int aac_enqueue_response(struct aac_softc *sc, int queue, struct aac_fib *fib); @@ -120,16 +121,16 @@ static int aac_sa_get_mailboxstatus(struct aac_softc *sc); static void aac_sa_set_interrupts(struct aac_softc *sc, int enable); struct aac_interface aac_sa_interface = { - aac_sa_get_fwstatus, - aac_sa_qnotify, - aac_sa_get_istatus, - aac_sa_clear_istatus, - aac_sa_set_mailbox, - aac_sa_get_mailboxstatus, - aac_sa_set_interrupts + aac_sa_get_fwstatus, + aac_sa_qnotify, + aac_sa_get_istatus, + aac_sa_clear_istatus, + aac_sa_set_mailbox, + aac_sa_get_mailboxstatus, + aac_sa_set_interrupts }; -/* i960Rx interface */ +/* i960Rx interface */ static int aac_rx_get_fwstatus(struct aac_softc *sc); static void aac_rx_qnotify(struct aac_softc *sc, int qbit); static int aac_rx_get_istatus(struct aac_softc *sc); @@ -141,13 +142,13 @@ static int aac_rx_get_mailboxstatus(struct aac_softc *sc); static void aac_rx_set_interrupts(struct aac_softc *sc, int enable); struct aac_interface aac_rx_interface = { - aac_rx_get_fwstatus, - aac_rx_qnotify, - aac_rx_get_istatus, - aac_rx_clear_istatus, - aac_rx_set_mailbox, - aac_rx_get_mailboxstatus, - aac_rx_set_interrupts + aac_rx_get_fwstatus, + aac_rx_qnotify, + aac_rx_get_istatus, + aac_rx_clear_istatus, + aac_rx_set_mailbox, + aac_rx_get_mailboxstatus, + aac_rx_set_interrupts }; /* Debugging and Diagnostics */ @@ -161,7 +162,7 @@ static d_close_t aac_close; static d_ioctl_t aac_ioctl; static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib); static void aac_handle_aif(struct aac_softc *sc, - struct aac_fib *fib); + struct aac_fib *fib); static int aac_rev_check(struct aac_softc *sc, caddr_t udata); static int aac_getnext_aif(struct aac_softc *sc, caddr_t arg); static int aac_return_aif(struct aac_softc *sc, caddr_t uptr); @@ -170,21 +171,21 @@ static int aac_query_disk(struct aac_softc *sc, caddr_t uptr); #define AAC_CDEV_MAJOR 150 static struct cdevsw aac_cdevsw = { - aac_open, /* open */ - aac_close, /* close */ - noread, /* read */ - nowrite, /* write */ - aac_ioctl, /* ioctl */ - nopoll, /* poll */ - nommap, /* mmap */ - nostrategy, /* strategy */ - "aac", /* name */ - AAC_CDEV_MAJOR, /* major */ - nodump, /* dump */ - nopsize, /* psize */ - 0, /* flags */ + aac_open, /* open */ + aac_close, /* close */ + noread, /* read */ + nowrite, /* write */ + aac_ioctl, /* ioctl */ + nopoll, /* poll */ + nommap, /* mmap */ + nostrategy, /* strategy */ + "aac", /* name */ + AAC_CDEV_MAJOR, /* major */ + nodump, /* dump */ + nopsize, /* psize */ + 0, /* flags */ #if __FreeBSD_version < 500005 - -1, /* bmaj */ + -1, /* bmaj */ #endif }; @@ -193,184 +194,199 @@ MALLOC_DEFINE(M_AACBUF, "aacbuf", "Buffers for the AAC driver"); /* sysctl node */ SYSCTL_NODE(_hw, OID_AUTO, aac, CTLFLAG_RD, 0, "AAC driver parameters"); -/****************************************************************************** - ****************************************************************************** - Device Interface - ****************************************************************************** - ******************************************************************************/ +/* + * Device Interface + */ -/****************************************************************************** +/* * Initialise the controller and softc */ int aac_attach(struct aac_softc *sc) { - int error, unit; + int error, unit; - debug_called(1); + debug_called(1); - /* - * Initialise per-controller queues. - */ - aac_initq_free(sc); - aac_initq_ready(sc); - aac_initq_busy(sc); - aac_initq_complete(sc); - aac_initq_bio(sc); + /* + * Initialise per-controller queues. + */ + aac_initq_free(sc); + aac_initq_ready(sc); + aac_initq_busy(sc); + aac_initq_complete(sc); + aac_initq_bio(sc); #if __FreeBSD_version >= 500005 - /* - * Initialise command-completion task. - */ - TASK_INIT(&sc->aac_task_complete, 0, aac_complete, sc); + /* + * Initialise command-completion task. + */ + TASK_INIT(&sc->aac_task_complete, 0, aac_complete, sc); #endif - /* disable interrupts before we enable anything */ - AAC_MASK_INTERRUPTS(sc); + /* disable interrupts before we enable anything */ + AAC_MASK_INTERRUPTS(sc); - /* mark controller as suspended until we get ourselves organised */ - sc->aac_state |= AAC_STATE_SUSPEND; + /* mark controller as suspended until we get ourselves organised */ + sc->aac_state |= AAC_STATE_SUSPEND; - /* - * Allocate command structures. - */ - if ((error = aac_alloc_commands(sc)) != 0) - return(error); + /* + * Allocate command structures. + */ + if ((error = aac_alloc_commands(sc)) != 0) + return(error); - /* - * Initialise the adapter. - */ - if ((error = aac_init(sc)) != 0) - return(error); + /* + * Initialise the adapter. + */ + if ((error = aac_init(sc)) != 0) + return(error); - /* - * Print a little information about the controller. - */ - aac_describe_controller(sc); + /* + * Print a little information about the controller. + */ + aac_describe_controller(sc); - /* - * Register to probe our containers later. - */ - TAILQ_INIT(&sc->aac_container_tqh); - AAC_LOCK_INIT(&sc->aac_container_lock); + /* + * Register to probe our containers later. + */ + TAILQ_INIT(&sc->aac_container_tqh); + AAC_LOCK_INIT(&sc->aac_container_lock); - sc->aac_ich.ich_func = aac_startup; - sc->aac_ich.ich_arg = sc; - if (config_intrhook_establish(&sc->aac_ich) != 0) { - device_printf(sc->aac_dev, "can't establish configuration hook\n"); - return(ENXIO); - } + sc->aac_ich.ich_func = aac_startup; + sc->aac_ich.ich_arg = sc; + if (config_intrhook_establish(&sc->aac_ich) != 0) { + device_printf(sc->aac_dev, + "can't establish configuration hook\n"); + return(ENXIO); + } - /* - * Make the control device. - */ - unit = device_get_unit(sc->aac_dev); - sc->aac_dev_t = make_dev(&aac_cdevsw, unit, UID_ROOT, GID_WHEEL, 0644, - "aac%d", unit); + /* + * Make the control device. + */ + unit = device_get_unit(sc->aac_dev); + sc->aac_dev_t = make_dev(&aac_cdevsw, unit, UID_ROOT, GID_WHEEL, 0644, + "aac%d", unit); #if __FreeBSD_version > 500005 - (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit); - (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit); + (void)make_dev_alias(sc->aac_dev_t, "afa%d", unit); + (void)make_dev_alias(sc->aac_dev_t, "hpn%d", unit); #endif - sc->aac_dev_t->si_drv1 = sc; + sc->aac_dev_t->si_drv1 = sc; - /* Create the AIF thread */ + /* Create the AIF thread */ #if __FreeBSD_version > 500005 - if (kthread_create((void(*)(void *))aac_host_command, sc, &sc->aifthread, - 0, "aac%daif", unit)) + if (kthread_create((void(*)(void *))aac_host_command, sc, + &sc->aifthread, 0, "aac%daif", unit)) #else - if (kthread_create((void(*)(void *))aac_host_command, sc, &sc->aifthread, - "aac%daif", unit)) + if (kthread_create((void(*)(void *))aac_host_command, sc, + &sc->aifthread, "aac%daif", unit)) #endif - panic("Could not create AIF thread\n"); + panic("Could not create AIF thread\n"); - /* Register the shutdown method to only be called post-dump */ - if ((EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown, sc->aac_dev, - SHUTDOWN_PRI_DEFAULT)) == NULL) + /* Register the shutdown method to only be called post-dump */ + if ((EVENTHANDLER_REGISTER(shutdown_final, aac_shutdown, sc->aac_dev, + SHUTDOWN_PRI_DEFAULT)) == NULL) device_printf(sc->aac_dev, "shutdown event registration failed\n"); - return(0); + return(0); } -/****************************************************************************** +/* * Probe for containers, create disks. */ static void aac_startup(void *arg) { - struct aac_softc *sc = (struct aac_softc *)arg; - struct aac_mntinfo mi; - struct aac_mntinforesponse mir; - struct aac_container *co; - device_t child; - u_int16_t rsize; - int i = 0; + struct aac_softc *sc; + struct aac_mntinfo mi; + struct aac_mntinforesponse mir; + u_int16_t rsize; + int i = 0; - debug_called(1); + debug_called(1); - /* disconnect ourselves from the intrhook chain */ - config_intrhook_disestablish(&sc->aac_ich); + sc = (struct aac_softc *)arg; - /* loop over possible containers */ - mi.Command = VM_NameServe; - mi.MntType = FT_FILESYS; - do { - /* request information on this container */ - mi.MntCount = i; - rsize = sizeof(mir); - if (aac_sync_fib(sc, ContainerCommand, 0, &mi, - sizeof(struct aac_mntinfo), &mir, &rsize)) { - debug(2, "error probing container %d", i); - continue; - } - /* check response size */ - if (rsize != sizeof(mir)) { - debug(2, "container info response wrong size (%d should be %d)", - rsize, sizeof(mir)); - continue; - } - /* - * Check container volume type for validity. Note that many of the - * possible types may never show up. - */ - if ((mir.Status == ST_OK) && (mir.MntTable[0].VolType != CT_NONE)) { - MALLOC(co, struct aac_container *, sizeof *co, M_AACBUF, M_NOWAIT); - if (co == NULL) - panic("Out of memory?!\n"); - debug(1, "%d: id %x name '%.16s' size %u type %d", - i, mir.MntTable[0].ObjectId, - mir.MntTable[0].FileSystemName, mir.MntTable[0].Capacity, - mir.MntTable[0].VolType); + /* disconnect ourselves from the intrhook chain */ + config_intrhook_disestablish(&sc->aac_ich); - if ((child = device_add_child(sc->aac_dev, NULL, -1)) == NULL) { - device_printf(sc->aac_dev, "device_add_child failed\n"); - } else { - device_set_ivars(child, co); - } - device_set_desc(child, aac_describe_code(aac_container_types, - mir.MntTable[0].VolType)); - co->co_disk = child; - co->co_found = 0; - bcopy(&mir.MntTable[0], &co->co_mntobj, sizeof(struct aac_mntobj)); - TAILQ_INSERT_TAIL(&sc->aac_container_tqh, co, co_link); - } - i++; - } while ((i < mir.MntRespCount) && (i < AAC_MAX_CONTAINERS)); + /* loop over possible containers */ + mi.Command = VM_NameServe; + mi.MntType = FT_FILESYS; + do { + /* request information on this container */ + mi.MntCount = i; + rsize = sizeof(mir); + if (aac_sync_fib(sc, ContainerCommand, 0, &mi, + sizeof(struct aac_mntinfo), &mir, &rsize)) { + debug(2, "error probing container %d", i); + continue; + } + /* check response size */ + if (rsize != sizeof(mir)) { + debug(2, "container info response wrong size " + "(%d should be %d)", rsize, sizeof(mir)); + continue; + } - /* poke the bus to actually attach the child devices */ - if (bus_generic_attach(sc->aac_dev)) - device_printf(sc->aac_dev, "bus_generic_attach failed\n"); + aac_add_container(sc, &mir, 0); + i++; + } while ((i < mir.MntRespCount) && (i < AAC_MAX_CONTAINERS)); - /* mark the controller up */ - sc->aac_state &= ~AAC_STATE_SUSPEND; + /* poke the bus to actually attach the child devices */ + if (bus_generic_attach(sc->aac_dev)) + device_printf(sc->aac_dev, "bus_generic_attach failed\n"); - /* enable interrupts now */ - AAC_UNMASK_INTERRUPTS(sc); + /* mark the controller up */ + sc->aac_state &= ~AAC_STATE_SUSPEND; - /* enable the timeout watchdog */ - timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); + /* enable interrupts now */ + AAC_UNMASK_INTERRUPTS(sc); + + /* enable the timeout watchdog */ + timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); } -/****************************************************************************** +/* + * Create a device to respresent a new container + */ +static void +aac_add_container(struct aac_softc *sc, struct aac_mntinforesponse *mir, int f) +{ + struct aac_container *co; + device_t child; + + /* + * Check container volume type for validity. Note that many of + * the possible types may never show up. + */ + if ((mir->Status == ST_OK) && (mir->MntTable[0].VolType != CT_NONE)) { + MALLOC(co, struct aac_container *, sizeof *co, M_AACBUF, + M_NOWAIT); + if (co == NULL) + panic("Out of memory?!\n"); + debug(1, "id %x name '%.16s' size %u type %d", + mir->MntTable[0].ObjectId, + mir->MntTable[0].FileSystemName, + mir->MntTable[0].Capacity, mir->MntTable[0].VolType); + + if ((child = device_add_child(sc->aac_dev, NULL, -1)) == NULL) + device_printf(sc->aac_dev, "device_add_child failed\n"); + else + device_set_ivars(child, co); + device_set_desc(child, aac_describe_code(aac_container_types, + mir->MntTable[0].VolType)); + co->co_disk = child; + co->co_found = f; + bcopy(&mir->MntTable[0], &co->co_mntobj, + sizeof(struct aac_mntobj)); + AAC_LOCK_AQUIRE(&sc->aac_container_lock); + TAILQ_INSERT_TAIL(&sc->aac_container_tqh, co, co_link); + AAC_LOCK_RELEASE(&sc->aac_container_lock); + } +} + +/* * Free all of the resources associated with (sc) * * Should not be called if the controller is active. @@ -378,86 +394,88 @@ aac_startup(void *arg) void aac_free(struct aac_softc *sc) { - debug_called(1); + debug_called(1); - /* remove the control device */ - if (sc->aac_dev_t != NULL) - destroy_dev(sc->aac_dev_t); + /* remove the control device */ + if (sc->aac_dev_t != NULL) + destroy_dev(sc->aac_dev_t); - /* throw away any FIB buffers, discard the FIB DMA tag */ - if (sc->aac_fibs != NULL) - aac_free_commands(sc); - if (sc->aac_fib_dmat) - bus_dma_tag_destroy(sc->aac_fib_dmat); + /* throw away any FIB buffers, discard the FIB DMA tag */ + if (sc->aac_fibs != NULL) + aac_free_commands(sc); + if (sc->aac_fib_dmat) + bus_dma_tag_destroy(sc->aac_fib_dmat); - /* destroy the common area */ - if (sc->aac_common) { - bus_dmamap_unload(sc->aac_common_dmat, sc->aac_common_dmamap); - bus_dmamem_free(sc->aac_common_dmat, sc->aac_common, - sc->aac_common_dmamap); - } - if (sc->aac_common_dmat) - bus_dma_tag_destroy(sc->aac_common_dmat); + /* destroy the common area */ + if (sc->aac_common) { + bus_dmamap_unload(sc->aac_common_dmat, sc->aac_common_dmamap); + bus_dmamem_free(sc->aac_common_dmat, sc->aac_common, + sc->aac_common_dmamap); + } + if (sc->aac_common_dmat) + bus_dma_tag_destroy(sc->aac_common_dmat); - /* disconnect the interrupt handler */ - if (sc->aac_intr) - bus_teardown_intr(sc->aac_dev, sc->aac_irq, sc->aac_intr); - if (sc->aac_irq != NULL) - bus_release_resource(sc->aac_dev, SYS_RES_IRQ, sc->aac_irq_rid, - sc->aac_irq); + /* disconnect the interrupt handler */ + if (sc->aac_intr) + bus_teardown_intr(sc->aac_dev, sc->aac_irq, sc->aac_intr); + if (sc->aac_irq != NULL) + bus_release_resource(sc->aac_dev, SYS_RES_IRQ, sc->aac_irq_rid, + sc->aac_irq); - /* destroy data-transfer DMA tag */ - if (sc->aac_buffer_dmat) - bus_dma_tag_destroy(sc->aac_buffer_dmat); + /* destroy data-transfer DMA tag */ + if (sc->aac_buffer_dmat) + bus_dma_tag_destroy(sc->aac_buffer_dmat); - /* destroy the parent DMA tag */ - if (sc->aac_parent_dmat) - bus_dma_tag_destroy(sc->aac_parent_dmat); + /* destroy the parent DMA tag */ + if (sc->aac_parent_dmat) + bus_dma_tag_destroy(sc->aac_parent_dmat); - /* release the register window mapping */ - if (sc->aac_regs_resource != NULL) - bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, sc->aac_regs_rid, - sc->aac_regs_resource); + /* release the register window mapping */ + if (sc->aac_regs_resource != NULL) + bus_release_resource(sc->aac_dev, SYS_RES_MEMORY, + sc->aac_regs_rid, sc->aac_regs_resource); } -/****************************************************************************** +/* * Disconnect from the controller completely, in preparation for unload. */ int aac_detach(device_t dev) { - struct aac_softc *sc = device_get_softc(dev); + struct aac_softc *sc; #if AAC_BROKEN - int error; + int error; #endif - debug_called(1); + debug_called(1); - if (sc->aac_state & AAC_STATE_OPEN) + sc = device_get_softc(dev); + + if (sc->aac_state & AAC_STATE_OPEN) return(EBUSY); #if AAC_BROKEN - if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { - sc->aifflags |= AAC_AIFFLAGS_EXIT; - wakeup(sc->aifthread); - tsleep(sc->aac_dev, PUSER | PCATCH, "aacdch", 30 * hz); - } + if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { + sc->aifflags |= AAC_AIFFLAGS_EXIT; + wakeup(sc->aifthread); + tsleep(sc->aac_dev, PUSER | PCATCH, "aacdch", 30 * hz); + } - if (sc->aifflags & AAC_AIFFLAGS_RUNNING) - panic("Cannot shutdown AIF thread\n"); + if (sc->aifflags & AAC_AIFFLAGS_RUNNING) + panic("Cannot shutdown AIF thread\n"); - if ((error = aac_shutdown(dev))) - return(error); + if ((error = aac_shutdown(dev))) + return(error); - aac_free(sc); + aac_free(sc); - return(0); + return(0); #else - return (EBUSY); + return (EBUSY); #endif } -/****************************************************************************** +/* * Bring the controller down to a dormant state and detach all child devices. * * This function is called before detach or system shutdown. @@ -468,965 +486,1009 @@ aac_detach(device_t dev) int aac_shutdown(device_t dev) { - struct aac_softc *sc = device_get_softc(dev); - struct aac_close_command cc; - int s, i; + struct aac_softc *sc; + struct aac_close_command cc; + int s, i; - debug_called(1); + debug_called(1); - s = splbio(); + sc = device_get_softc(dev); - sc->aac_state |= AAC_STATE_SUSPEND; + s = splbio(); - /* - * Send a Container shutdown followed by a HostShutdown FIB to the - * controller to convince it that we don't want to talk to it anymore. - * We've been closed and all I/O completed already - */ - device_printf(sc->aac_dev, "shutting down controller..."); + sc->aac_state |= AAC_STATE_SUSPEND; - cc.Command = VM_CloseAll; - cc.ContainerId = 0xffffffff; - if (aac_sync_fib(sc, ContainerCommand, 0, &cc, sizeof(cc), NULL, NULL)) { - printf("FAILED.\n"); - } else { - i = 0; - /* - * XXX Issuing this command to the controller makes it shut down, - * but also keeps it from coming back up without a reset of the - * PCI bus. This is not desirable if you are just unloading the - * driver module with the intent to reload it later. + /* + * Send a Container shutdown followed by a HostShutdown FIB to the + * controller to convince it that we don't want to talk to it anymore. + * We've been closed and all I/O completed already */ - if (aac_sync_fib(sc, FsaHostShutdown, AAC_FIBSTATE_SHUTDOWN, &i, - sizeof(i), NULL, NULL)) { - printf("FAILED.\n"); - } else { - printf("done.\n"); + device_printf(sc->aac_dev, "shutting down controller..."); + + cc.Command = VM_CloseAll; + cc.ContainerId = 0xffffffff; + if (aac_sync_fib(sc, ContainerCommand, 0, &cc, sizeof(cc), NULL, NULL)) + printf("FAILED.\n"); + else { + i = 0; + /* + * XXX Issuing this command to the controller makes it shut down + * but also keeps it from coming back up without a reset of the + * PCI bus. This is not desirable if you are just unloading the + * driver module with the intent to reload it later. + */ + if (aac_sync_fib(sc, FsaHostShutdown, AAC_FIBSTATE_SHUTDOWN, &i, + sizeof(i), NULL, NULL)) { + printf("FAILED.\n"); + } else { + printf("done.\n"); + } } - } - AAC_MASK_INTERRUPTS(sc); + AAC_MASK_INTERRUPTS(sc); - splx(s); - return(0); + splx(s); + return(0); } -/****************************************************************************** +/* * Bring the controller to a quiescent state, ready for system suspend. */ int aac_suspend(device_t dev) { - struct aac_softc *sc = device_get_softc(dev); - int s; + struct aac_softc *sc; + int s; - debug_called(1); - s = splbio(); + debug_called(1); - sc->aac_state |= AAC_STATE_SUSPEND; - - AAC_MASK_INTERRUPTS(sc); - splx(s); - return(0); + sc = device_get_softc(dev); + + s = splbio(); + + sc->aac_state |= AAC_STATE_SUSPEND; + + AAC_MASK_INTERRUPTS(sc); + splx(s); + return(0); } -/****************************************************************************** +/* * Bring the controller back to a state ready for operation. */ int aac_resume(device_t dev) { - struct aac_softc *sc = device_get_softc(dev); + struct aac_softc *sc; - debug_called(1); - sc->aac_state &= ~AAC_STATE_SUSPEND; - AAC_UNMASK_INTERRUPTS(sc); - return(0); + debug_called(1); + + sc = device_get_softc(dev); + + sc->aac_state &= ~AAC_STATE_SUSPEND; + AAC_UNMASK_INTERRUPTS(sc); + return(0); } -/******************************************************************************* +/* * Take an interrupt. */ void aac_intr(void *arg) { - struct aac_softc *sc = (struct aac_softc *)arg; - u_int16_t reason; + struct aac_softc *sc; + u_int16_t reason; - debug_called(2); + debug_called(2); - reason = AAC_GET_ISTATUS(sc); + sc = (struct aac_softc *)arg; - /* controller wants to talk to the log? Defer it to the AIF thread */ - if (reason & AAC_DB_PRINTF) { - AAC_CLEAR_ISTATUS(sc, AAC_DB_PRINTF); - if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { - sc->aifflags |= AAC_AIFFLAGS_PENDING; - wakeup(sc->aifthread); - } else - aac_print_printf(sc); - } + reason = AAC_GET_ISTATUS(sc); - /* controller has a message for us? */ - if (reason & AAC_DB_COMMAND_READY) { - AAC_CLEAR_ISTATUS(sc, AAC_DB_COMMAND_READY); - /* XXX What happens if the thread is already awake? */ - if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { - sc->aifflags |= AAC_AIFFLAGS_PENDING; - wakeup(sc->aifthread); + /* controller wants to talk to the log? Defer it to the AIF thread */ + if (reason & AAC_DB_PRINTF) { + AAC_CLEAR_ISTATUS(sc, AAC_DB_PRINTF); + if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { + sc->aifflags |= AAC_AIFFLAGS_PENDING; + wakeup(sc->aifthread); + } else + aac_print_printf(sc); } - } - - /* controller has a response for us? */ - if (reason & AAC_DB_RESPONSE_READY) { - AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY); - aac_host_response(sc); - } - /* - * spurious interrupts that we don't use - reset the mask and clear the - * interrupts - */ - if (reason & (AAC_DB_COMMAND_NOT_FULL | AAC_DB_RESPONSE_NOT_FULL)) { - AAC_UNMASK_INTERRUPTS(sc); - AAC_CLEAR_ISTATUS(sc, AAC_DB_COMMAND_NOT_FULL | - AAC_DB_RESPONSE_NOT_FULL); - } + /* controller has a message for us? */ + if (reason & AAC_DB_COMMAND_READY) { + AAC_CLEAR_ISTATUS(sc, AAC_DB_COMMAND_READY); + /* XXX What happens if the thread is already awake? */ + if (sc->aifflags & AAC_AIFFLAGS_RUNNING) { + sc->aifflags |= AAC_AIFFLAGS_PENDING; + wakeup(sc->aifthread); + } + } + + /* controller has a response for us? */ + if (reason & AAC_DB_RESPONSE_READY) { + AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY); + aac_host_response(sc); + } + + /* + * spurious interrupts that we don't use - reset the mask and clear the + * interrupts + */ + if (reason & (AAC_DB_COMMAND_NOT_FULL | AAC_DB_RESPONSE_NOT_FULL)) { + AAC_UNMASK_INTERRUPTS(sc); + AAC_CLEAR_ISTATUS(sc, AAC_DB_COMMAND_NOT_FULL | + AAC_DB_RESPONSE_NOT_FULL); + } }; -/****************************************************************************** - ****************************************************************************** - Command Processing - ****************************************************************************** - ******************************************************************************/ +/* + * Command Processing + */ -/****************************************************************************** +/* * Start as much queued I/O as possible on the controller */ static void aac_startio(struct aac_softc *sc) { - struct aac_command *cm; + struct aac_command *cm; - debug_called(2); + debug_called(2); - for(;;) { - /* try to get a command that's been put off for lack of resources */ - cm = aac_dequeue_ready(sc); + for (;;) { + /* + * Try to get a command that's been put off for lack of + * resources + */ + cm = aac_dequeue_ready(sc); - /* try to build a command off the bio queue (ignore error return) */ - if (cm == NULL) - aac_bio_command(sc, &cm); + /* + * Try to build a command off the bio queue (ignore error + * return) + */ + if (cm == NULL) + aac_bio_command(sc, &cm); - /* nothing to do? */ - if (cm == NULL) - break; + /* nothing to do? */ + if (cm == NULL) + break; - /* try to give the command to the controller */ - if (aac_start(cm) == EBUSY) { - /* put it on the ready queue for later */ - aac_requeue_ready(cm); - break; + /* try to give the command to the controller */ + if (aac_start(cm) == EBUSY) { + /* put it on the ready queue for later */ + aac_requeue_ready(cm); + break; + } } - } } -/****************************************************************************** +/* * Deliver a command to the controller; allocate controller resources at the * last moment when possible. */ static int aac_start(struct aac_command *cm) { - struct aac_softc *sc = cm->cm_sc; - int error; + struct aac_softc *sc; + int error; - debug_called(2); + debug_called(2); - /* get the command mapped */ - aac_map_command(cm); + sc = cm->cm_sc; - /* fix up the address values in the FIB */ - cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib; - cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys; + /* get the command mapped */ + aac_map_command(cm); - /* save a pointer to the command for speedy reverse-lookup */ - cm->cm_fib->Header.SenderData = (u_int32_t)cm; /* XXX 64-bit physical + /* fix up the address values in the FIB */ + cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib; + cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys; + + /* save a pointer to the command for speedy reverse-lookup */ + cm->cm_fib->Header.SenderData = (u_int32_t)cm; /* XXX 64-bit physical * address issue */ - /* put the FIB on the outbound queue */ - error = aac_enqueue_fib(sc, cm->cm_queue, cm); - return(error); + /* put the FIB on the outbound queue */ + error = aac_enqueue_fib(sc, cm->cm_queue, cm); + return(error); } -/****************************************************************************** +/* * Handle notification of one or more FIBs coming from the controller. */ static void aac_host_command(struct aac_softc *sc) { - struct aac_fib *fib; - u_int32_t fib_size; - int size; + struct aac_fib *fib; + u_int32_t fib_size; + int size; - debug_called(2); + debug_called(2); - sc->aifflags |= AAC_AIFFLAGS_RUNNING; + sc->aifflags |= AAC_AIFFLAGS_RUNNING; - while(!(sc->aifflags & AAC_AIFFLAGS_EXIT)) { - if (!(sc->aifflags & AAC_AIFFLAGS_PENDING)) - tsleep(sc->aifthread, PRIBIO, "aifthd", 15 * hz); + while (!(sc->aifflags & AAC_AIFFLAGS_EXIT)) { + if (!(sc->aifflags & AAC_AIFFLAGS_PENDING)) + tsleep(sc->aifthread, PRIBIO, "aifthd", 15 * hz); - sc->aifflags &= ~AAC_AIFFLAGS_PENDING; - for (;;) { - if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE, &fib_size, &fib)) - break; /* nothing to do */ + sc->aifflags &= ~AAC_AIFFLAGS_PENDING; + for (;;) { + if (aac_dequeue_fib(sc, AAC_HOST_NORM_CMD_QUEUE, + &fib_size, &fib)) + break; /* nothing to do */ + + AAC_PRINT_FIB(sc, fib); + + switch (fib->Header.Command) { + case AifRequest: + aac_handle_aif(sc, fib); + break; + default: + device_printf(sc->aac_dev, "unknown command " + "from controller\n"); + break; + } - AAC_PRINT_FIB(sc, fib); + /* Return the AIF to the controller. */ + if ((fib->Header.XferState == 0) || + (fib->Header.StructType != AAC_FIBTYPE_TFIB)) + break; - switch(fib->Header.Command) { - case AifRequest: - aac_handle_aif(sc, fib); - break; - default: - device_printf(sc->aac_dev, "unknown command from controller\n"); - break; - } + if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) { + fib->Header.XferState |= AAC_FIBSTATE_DONEHOST; + *(AAC_FSAStatus*)fib->data = ST_OK; - /* Return the AIF to the controller. */ - if ((fib->Header.XferState == 0) || - (fib->Header.StructType != AAC_FIBTYPE_TFIB)) - break; - - if (fib->Header.XferState & AAC_FIBSTATE_FROMADAP) { - if (!(fib->Header.XferState & AAC_FIBSTATE_NORM)) { - /* - * XXX How to recover from this? If anything goes on - * the high priority queue, the controller will panic. - * Since it came on the normal priority queue, just - * punt and return it there. - */ - device_printf(sc->aac_dev, "Error: Attempted to return " - "an AIF not at normal priority\n"); + /* XXX Compute the Size field? */ + size = fib->Header.Size; + if (size > sizeof(struct aac_fib)) { + size = sizeof(struct aac_fib); + fib->Header.Size = size; + } + /* + * Since we did not generate this command, it + * cannot go through the normal + * enqueue->startio chain. + */ + aac_enqueue_response(sc, + AAC_ADAP_NORM_RESP_QUEUE, + fib); + } } - fib->Header.XferState |= AAC_FIBSTATE_DONEHOST; - *(AAC_FSAStatus*)fib->data = ST_OK; + aac_print_printf(sc); - /* XXX Compute the Size field? */ - size = fib->Header.Size; - if (size > sizeof(struct aac_fib)) { - size = sizeof(struct aac_fib); - fib->Header.Size = size; - } - /* - * Since we did not generate this command, it cannot go - * through the normal enqueue->startio chain. - */ - aac_enqueue_response(sc, AAC_ADAP_NORM_RESP_QUEUE, fib); - } } - aac_print_printf(sc); - - } - sc->aifflags &= ~AAC_AIFFLAGS_RUNNING; - wakeup(sc->aac_dev); + sc->aifflags &= ~AAC_AIFFLAGS_RUNNING; + wakeup(sc->aac_dev); #if __FreeBSD_version > 500005 - mtx_lock(&Giant); + mtx_lock(&Giant); #endif - kthread_exit(0); + kthread_exit(0); } -/****************************************************************************** +/* * Handle notification of one or more FIBs completed by the controller */ static void aac_host_response(struct aac_softc *sc) { - struct aac_command *cm; - struct aac_fib *fib; - u_int32_t fib_size; + struct aac_command *cm; + struct aac_fib *fib; + u_int32_t fib_size; - debug_called(2); + debug_called(2); - for (;;) { - /* look for completed FIBs on our queue */ - if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, &fib_size, &fib)) - break; /* nothing to do */ + for (;;) { + /* look for completed FIBs on our queue */ + if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, &fib_size, + &fib)) + break; /* nothing to do */ - /* get the command, unmap and queue for later processing */ - cm = (struct aac_command *)fib->Header.SenderData; - if (cm == NULL) { - AAC_PRINT_FIB(sc, fib); - } else { - aac_remove_busy(cm); - aac_unmap_command(cm); /* XXX defer? */ - aac_enqueue_complete(cm); + /* get the command, unmap and queue for later processing */ + cm = (struct aac_command *)fib->Header.SenderData; + if (cm == NULL) { + AAC_PRINT_FIB(sc, fib); + } else { + aac_remove_busy(cm); + aac_unmap_command(cm); /* XXX defer? */ + aac_enqueue_complete(cm); + } } - } - /* handle completion processing */ + /* handle completion processing */ #if __FreeBSD_version >= 500005 - taskqueue_enqueue(taskqueue_swi, &sc->aac_task_complete); + taskqueue_enqueue(taskqueue_swi, &sc->aac_task_complete); #else - aac_complete(sc, 0); + aac_complete(sc, 0); #endif } -/****************************************************************************** +/* * Process completed commands. */ static void aac_complete(void *context, int pending) { - struct aac_softc *sc = (struct aac_softc *)context; - struct aac_command *cm; - - debug_called(2); + struct aac_softc *sc; + struct aac_command *cm; + + debug_called(2); - /* pull completed commands off the queue */ - for (;;) { - cm = aac_dequeue_complete(sc); - if (cm == NULL) - break; - cm->cm_flags |= AAC_CMD_COMPLETED; + sc = (struct aac_softc *)context; - /* is there a completion handler? */ - if (cm->cm_complete != NULL) { - cm->cm_complete(cm); - } else { - /* assume that someone is sleeping on this command */ - wakeup(cm); + /* pull completed commands off the queue */ + for (;;) { + cm = aac_dequeue_complete(sc); + if (cm == NULL) + break; + cm->cm_flags |= AAC_CMD_COMPLETED; + + /* is there a completion handler? */ + if (cm->cm_complete != NULL) { + cm->cm_complete(cm); + } else { + /* assume that someone is sleeping on this command */ + wakeup(cm); + } } - } - /* see if we can start some more I/O */ - aac_startio(sc); + /* see if we can start some more I/O */ + aac_startio(sc); } -/****************************************************************************** +/* * Handle a bio submitted from a disk device. */ void aac_submit_bio(struct bio *bp) { - struct aac_disk *ad = (struct aac_disk *)bp->bio_dev->si_drv1; - struct aac_softc *sc = ad->ad_controller; + struct aac_disk *ad; + struct aac_softc *sc; - debug_called(2); + debug_called(2); - /* queue the BIO and try to get some work done */ - aac_enqueue_bio(sc, bp); - aac_startio(sc); + ad = (struct aac_disk *)bp->bio_dev->si_drv1; + sc = ad->ad_controller; + + /* queue the BIO and try to get some work done */ + aac_enqueue_bio(sc, bp); + aac_startio(sc); } -/****************************************************************************** +/* * Get a bio and build a command to go with it. */ static int aac_bio_command(struct aac_softc *sc, struct aac_command **cmp) { - struct aac_command *cm; - struct aac_fib *fib; - struct aac_blockread *br; - struct aac_blockwrite *bw; - struct aac_disk *ad; - struct bio *bp; + struct aac_command *cm; + struct aac_fib *fib; + struct aac_blockread *br; + struct aac_blockwrite *bw; + struct aac_disk *ad; + struct bio *bp; - debug_called(2); + debug_called(2); - /* get the resources we will need */ - cm = NULL; - if ((bp = aac_dequeue_bio(sc)) == NULL) - goto fail; - if (aac_alloc_command(sc, &cm)) /* get a command */ - goto fail; + /* get the resources we will need */ + cm = NULL; + if ((bp = aac_dequeue_bio(sc)) == NULL) + goto fail; + if (aac_alloc_command(sc, &cm)) /* get a command */ + goto fail; - /* fill out the command */ - cm->cm_data = (void *)bp->bio_data; - cm->cm_datalen = bp->bio_bcount; - cm->cm_complete = aac_bio_complete; - cm->cm_private = bp; - cm->cm_timestamp = time_second; - cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; + /* fill out the command */ + cm->cm_data = (void *)bp->bio_data; + cm->cm_datalen = bp->bio_bcount; + cm->cm_complete = aac_bio_complete; + cm->cm_private = bp; + cm->cm_timestamp = time_second; + cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; - /* build the FIB */ - fib = cm->cm_fib; - fib->Header.XferState = + /* build the FIB */ + fib = cm->cm_fib; + fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED | AAC_FIBSTATE_INITIALISED | - AAC_FIBSTATE_FROMHOST | + AAC_FIBSTATE_FROMHOST | AAC_FIBSTATE_REXPECTED | AAC_FIBSTATE_NORM; - fib->Header.Command = ContainerCommand; - fib->Header.Size = sizeof(struct aac_fib_header); + fib->Header.Command = ContainerCommand; + fib->Header.Size = sizeof(struct aac_fib_header); - /* build the read/write request */ - ad = (struct aac_disk *)bp->bio_dev->si_drv1; - if (BIO_IS_READ(bp)) { - br = (struct aac_blockread *)&fib->data[0]; - br->Command = VM_CtBlockRead; - br->ContainerId = ad->ad_container->co_mntobj.ObjectId; - br->BlockNumber = bp->bio_pblkno; - br->ByteCount = bp->bio_bcount; - fib->Header.Size += sizeof(struct aac_blockread); - cm->cm_sgtable = &br->SgMap; - cm->cm_flags |= AAC_CMD_DATAIN; - } else { - bw = (struct aac_blockwrite *)&fib->data[0]; - bw->Command = VM_CtBlockWrite; - bw->ContainerId = ad->ad_container->co_mntobj.ObjectId; - bw->BlockNumber = bp->bio_pblkno; - bw->ByteCount = bp->bio_bcount; - bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */ - fib->Header.Size += sizeof(struct aac_blockwrite); - cm->cm_flags |= AAC_CMD_DATAOUT; - cm->cm_sgtable = &bw->SgMap; - } + /* build the read/write request */ + ad = (struct aac_disk *)bp->bio_dev->si_drv1; + if (BIO_IS_READ(bp)) { + br = (struct aac_blockread *)&fib->data[0]; + br->Command = VM_CtBlockRead; + br->ContainerId = ad->ad_container->co_mntobj.ObjectId; + br->BlockNumber = bp->bio_pblkno; + br->ByteCount = bp->bio_bcount; + fib->Header.Size += sizeof(struct aac_blockread); + cm->cm_sgtable = &br->SgMap; + cm->cm_flags |= AAC_CMD_DATAIN; + } else { + bw = (struct aac_blockwrite *)&fib->data[0]; + bw->Command = VM_CtBlockWrite; + bw->ContainerId = ad->ad_container->co_mntobj.ObjectId; + bw->BlockNumber = bp->bio_pblkno; + bw->ByteCount = bp->bio_bcount; + bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */ + fib->Header.Size += sizeof(struct aac_blockwrite); + cm->cm_flags |= AAC_CMD_DATAOUT; + cm->cm_sgtable = &bw->SgMap; + } - *cmp = cm; - return(0); + *cmp = cm; + return(0); fail: - if (bp != NULL) - aac_enqueue_bio(sc, bp); - if (cm != NULL) - aac_release_command(cm); - return(ENOMEM); + if (bp != NULL) + aac_enqueue_bio(sc, bp); + if (cm != NULL) + aac_release_command(cm); + return(ENOMEM); } -/****************************************************************************** +/* * Handle a bio-instigated command that has been completed. */ static void aac_bio_complete(struct aac_command *cm) { - struct aac_blockread_response *brr; - struct aac_blockwrite_response *bwr; - struct bio *bp; - AAC_FSAStatus status; + struct aac_blockread_response *brr; + struct aac_blockwrite_response *bwr; + struct bio *bp; + AAC_FSAStatus status; - /* fetch relevant status and then release the command */ - bp = (struct bio *)cm->cm_private; - if (BIO_IS_READ(bp)) { - brr = (struct aac_blockread_response *)&cm->cm_fib->data[0]; - status = brr->Status; - } else { - bwr = (struct aac_blockwrite_response *)&cm->cm_fib->data[0]; - status = bwr->Status; - } - aac_release_command(cm); + /* fetch relevant status and then release the command */ + bp = (struct bio *)cm->cm_private; + if (BIO_IS_READ(bp)) { + brr = (struct aac_blockread_response *)&cm->cm_fib->data[0]; + status = brr->Status; + } else { + bwr = (struct aac_blockwrite_response *)&cm->cm_fib->data[0]; + status = bwr->Status; + } + aac_release_command(cm); - /* fix up the bio based on status */ - if (status == ST_OK) { - bp->bio_resid = 0; - } else { - bp->bio_error = EIO; - bp->bio_flags |= BIO_ERROR; - /* pass an error string out to the disk layer */ - bp->bio_driver1 = aac_describe_code(aac_command_status_table, status); - } - aac_biodone(bp); + /* fix up the bio based on status */ + if (status == ST_OK) { + bp->bio_resid = 0; + } else { + bp->bio_error = EIO; + bp->bio_flags |= BIO_ERROR; + /* pass an error string out to the disk layer */ + bp->bio_driver1 = aac_describe_code(aac_command_status_table, + status); + } + aac_biodone(bp); } -/****************************************************************************** +/* * Dump a block of data to the controller. If the queue is full, tell the - * caller to hold off and wait for the queue to drain + * caller to hold off and wait for the queue to drain. */ int aac_dump_enqueue(struct aac_disk *ad, u_int32_t lba, void *data, int dumppages) { - struct aac_softc *sc = ad->ad_controller; - struct aac_command *cm = NULL; - struct aac_fib *fib; - struct aac_blockwrite *bw; + struct aac_softc *sc; + struct aac_command *cm; + struct aac_fib *fib; + struct aac_blockwrite *bw; - if (aac_alloc_command(sc, &cm)) - return (EBUSY); + sc = ad->ad_controller; + cm = NULL; - /* fill out the command */ - cm->cm_data = data; - cm->cm_datalen = dumppages * PAGE_SIZE; - cm->cm_complete = NULL; - cm->cm_private = NULL; - cm->cm_timestamp = time_second; - cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; + if (aac_alloc_command(sc, &cm)) + return (EBUSY); - /* build the FIB */ - fib = cm->cm_fib; - fib->Header.XferState = + /* fill out the command */ + cm->cm_data = data; + cm->cm_datalen = dumppages * PAGE_SIZE; + cm->cm_complete = NULL; + cm->cm_private = NULL; + cm->cm_timestamp = time_second; + cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; + + /* build the FIB */ + fib = cm->cm_fib; + fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED | AAC_FIBSTATE_INITIALISED | - AAC_FIBSTATE_FROMHOST | + AAC_FIBSTATE_FROMHOST | AAC_FIBSTATE_REXPECTED | AAC_FIBSTATE_NORM; - fib->Header.Command = ContainerCommand; - fib->Header.Size = sizeof(struct aac_fib_header); + fib->Header.Command = ContainerCommand; + fib->Header.Size = sizeof(struct aac_fib_header); - bw = (struct aac_blockwrite *)&fib->data[0]; - bw->Command = VM_CtBlockWrite; - bw->ContainerId = ad->ad_container->co_mntobj.ObjectId; - bw->BlockNumber = lba; - bw->ByteCount = dumppages * PAGE_SIZE; - bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */ - fib->Header.Size += sizeof(struct aac_blockwrite); - cm->cm_flags |= AAC_CMD_DATAOUT; - cm->cm_sgtable = &bw->SgMap; + bw = (struct aac_blockwrite *)&fib->data[0]; + bw->Command = VM_CtBlockWrite; + bw->ContainerId = ad->ad_container->co_mntobj.ObjectId; + bw->BlockNumber = lba; + bw->ByteCount = dumppages * PAGE_SIZE; + bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */ + fib->Header.Size += sizeof(struct aac_blockwrite); + cm->cm_flags |= AAC_CMD_DATAOUT; + cm->cm_sgtable = &bw->SgMap; - return (aac_start(cm)); + return (aac_start(cm)); } -/****************************************************************************** +/* * Wait for the card's queue to drain when dumping. Also check for monitor * printf's */ void aac_dump_complete(struct aac_softc *sc) { - struct aac_fib *fib; - struct aac_command *cm; - u_int16_t reason; - u_int32_t pi, ci, fib_size; + struct aac_fib *fib; + struct aac_command *cm; + u_int16_t reason; + u_int32_t pi, ci, fib_size; - do { - reason = AAC_GET_ISTATUS(sc); - if (reason & AAC_DB_RESPONSE_READY) { - AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY); - for (;;) { - if (aac_dequeue_fib(sc, AAC_HOST_NORM_RESP_QUEUE, - &fib_size, &fib)) - break; - cm = (struct aac_command *)fib->Header.SenderData; - if (cm == NULL) { - AAC_PRINT_FIB(sc, fib); - } else { - aac_remove_busy(cm); - aac_unmap_command(cm); - aac_enqueue_complete(cm); - aac_release_command(cm); + do { + reason = AAC_GET_ISTATUS(sc); + if (reason & AAC_DB_RESPONSE_READY) { + AAC_CLEAR_ISTATUS(sc, AAC_DB_RESPONSE_READY); + for (;;) { + if (aac_dequeue_fib(sc, + AAC_HOST_NORM_RESP_QUEUE, + &fib_size, &fib)) + break; + cm = (struct aac_command *) + fib->Header.SenderData; + if (cm == NULL) + AAC_PRINT_FIB(sc, fib); + else { + aac_remove_busy(cm); + aac_unmap_command(cm); + aac_enqueue_complete(cm); + aac_release_command(cm); + } + } } - } - } - if (reason & AAC_DB_PRINTF) { - AAC_CLEAR_ISTATUS(sc, AAC_DB_PRINTF); - aac_print_printf(sc); - } - pi = sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX]; - ci = sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX]; - } while (ci != pi); + if (reason & AAC_DB_PRINTF) { + AAC_CLEAR_ISTATUS(sc, AAC_DB_PRINTF); + aac_print_printf(sc); + } + pi = sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][ + AAC_PRODUCER_INDEX]; + ci = sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][ + AAC_CONSUMER_INDEX]; + } while (ci != pi); - return; + return; } -/****************************************************************************** +/* * Submit a command to the controller, return when it completes. */ static int aac_wait_command(struct aac_command *cm, int timeout) { - int s, error = 0; + int s, error = 0; - debug_called(2); + debug_called(2); - /* Put the command on the ready queue and get things going */ - cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; - aac_enqueue_ready(cm); - aac_startio(cm->cm_sc); - s = splbio(); - while(!(cm->cm_flags & AAC_CMD_COMPLETED) && (error != EWOULDBLOCK)) { - error = tsleep(cm, PRIBIO | PCATCH, "aacwait", 0); - if ((error == ERESTART) || (error == EINTR)) - break; - } - splx(s); - return(error); + /* Put the command on the ready queue and get things going */ + cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE; + aac_enqueue_ready(cm); + aac_startio(cm->cm_sc); + s = splbio(); + while (!(cm->cm_flags & AAC_CMD_COMPLETED) && (error != EWOULDBLOCK)) { + error = tsleep(cm, PRIBIO | PCATCH, "aacwait", 0); + if ((error == ERESTART) || (error == EINTR)) + break; + } + splx(s); + return(error); } -/****************************************************************************** - ****************************************************************************** - Command Buffer Management - ****************************************************************************** - ******************************************************************************/ +/* + *Command Buffer Management + */ -/****************************************************************************** +/* * Allocate a command. */ static int aac_alloc_command(struct aac_softc *sc, struct aac_command **cmp) { - struct aac_command *cm; + struct aac_command *cm; - debug_called(3); + debug_called(3); - if ((cm = aac_dequeue_free(sc)) == NULL) - return(ENOMEM); + if ((cm = aac_dequeue_free(sc)) == NULL) + return(ENOMEM); - *cmp = cm; - return(0); + *cmp = cm; + return(0); } -/****************************************************************************** +/* * Release a command back to the freelist. */ static void aac_release_command(struct aac_command *cm) { - debug_called(3); + debug_called(3); - /* (re)initialise the command/FIB */ - cm->cm_sgtable = NULL; - cm->cm_flags = 0; - cm->cm_complete = NULL; - cm->cm_private = NULL; - cm->cm_fib->Header.XferState = AAC_FIBSTATE_EMPTY; - cm->cm_fib->Header.StructType = AAC_FIBTYPE_TFIB; - cm->cm_fib->Header.Flags = 0; - cm->cm_fib->Header.SenderSize = sizeof(struct aac_fib); + /* (re)initialise the command/FIB */ + cm->cm_sgtable = NULL; + cm->cm_flags = 0; + cm->cm_complete = NULL; + cm->cm_private = NULL; + cm->cm_fib->Header.XferState = AAC_FIBSTATE_EMPTY; + cm->cm_fib->Header.StructType = AAC_FIBTYPE_TFIB; + cm->cm_fib->Header.Flags = 0; + cm->cm_fib->Header.SenderSize = sizeof(struct aac_fib); - /* - * These are duplicated in aac_start to cover the case where an - * intermediate stage may have destroyed them. They're left - * initialised here for debugging purposes only. - */ - cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib; - cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys; + /* + * These are duplicated in aac_start to cover the case where an + * intermediate stage may have destroyed them. They're left + * initialised here for debugging purposes only. + */ + cm->cm_fib->Header.SenderFibAddress = (u_int32_t)cm->cm_fib; + cm->cm_fib->Header.ReceiverFibAddress = cm->cm_fibphys; - aac_enqueue_free(cm); + aac_enqueue_free(cm); } -/****************************************************************************** +/* * Map helper for command/FIB allocation. */ static void aac_map_command_helper(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - struct aac_softc *sc = (struct aac_softc *)arg; + struct aac_softc *sc; - debug_called(3); + sc = (struct aac_softc *)arg; - sc->aac_fibphys = segs[0].ds_addr; + debug_called(3); + + sc->aac_fibphys = segs[0].ds_addr; } -/****************************************************************************** +/* * Allocate and initialise commands/FIBs for this adapter. */ static int aac_alloc_commands(struct aac_softc *sc) { - struct aac_command *cm; - int i; + struct aac_command *cm; + int i; - debug_called(1); + debug_called(1); - /* allocate the FIBs in DMAable memory and load them */ - if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&sc->aac_fibs, + /* allocate the FIBs in DMAable memory and load them */ + if (bus_dmamem_alloc(sc->aac_fib_dmat, (void **)&sc->aac_fibs, BUS_DMA_NOWAIT, &sc->aac_fibmap)) { - return(ENOMEM); - } - bus_dmamap_load(sc->aac_fib_dmat, sc->aac_fibmap, sc->aac_fibs, - AAC_FIB_COUNT * sizeof(struct aac_fib), - aac_map_command_helper, sc, 0); + return(ENOMEM); + } + bus_dmamap_load(sc->aac_fib_dmat, sc->aac_fibmap, sc->aac_fibs, + AAC_FIB_COUNT * sizeof(struct aac_fib), + aac_map_command_helper, sc, 0); - /* initialise constant fields in the command structure */ - for (i = 0; i < AAC_FIB_COUNT; i++) { - cm = &sc->aac_command[i]; - cm->cm_sc = sc; - cm->cm_fib = sc->aac_fibs + i; - cm->cm_fibphys = sc->aac_fibphys + (i * sizeof(struct aac_fib)); + /* initialise constant fields in the command structure */ + for (i = 0; i < AAC_FIB_COUNT; i++) { + cm = &sc->aac_command[i]; + cm->cm_sc = sc; + cm->cm_fib = sc->aac_fibs + i; + cm->cm_fibphys = sc->aac_fibphys + (i * sizeof(struct aac_fib)); - if (!bus_dmamap_create(sc->aac_buffer_dmat, 0, &cm->cm_datamap)) - aac_release_command(cm); - } - return(0); + if (!bus_dmamap_create(sc->aac_buffer_dmat, 0, &cm->cm_datamap)) + aac_release_command(cm); + } + return(0); } -/****************************************************************************** +/* * Free FIBs owned by this adapter. */ static void aac_free_commands(struct aac_softc *sc) { - int i; + int i; - debug_called(1); + debug_called(1); - for (i = 0; i < AAC_FIB_COUNT; i++) - bus_dmamap_destroy(sc->aac_buffer_dmat, sc->aac_command[i].cm_datamap); - bus_dmamap_unload(sc->aac_fib_dmat, sc->aac_fibmap); - bus_dmamem_free(sc->aac_fib_dmat, sc->aac_fibs, sc->aac_fibmap); + for (i = 0; i < AAC_FIB_COUNT; i++) + bus_dmamap_destroy(sc->aac_buffer_dmat, + sc->aac_command[i].cm_datamap); + + bus_dmamap_unload(sc->aac_fib_dmat, sc->aac_fibmap); + bus_dmamem_free(sc->aac_fib_dmat, sc->aac_fibs, sc->aac_fibmap); } -/****************************************************************************** +/* * Command-mapping helper function - populate this command's s/g table. */ static void aac_map_command_sg(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - struct aac_command *cm = (struct aac_command *)arg; - struct aac_fib *fib = cm->cm_fib; - struct aac_sg_table *sg; - int i; + struct aac_command *cm; + struct aac_fib *fib; + struct aac_sg_table *sg; + int i; - debug_called(3); + debug_called(3); - /* find the s/g table */ - sg = cm->cm_sgtable; + cm = (struct aac_command *)arg; + fib = cm->cm_fib; - /* copy into the FIB */ - if (sg != NULL) { - sg->SgCount = nseg; - for (i = 0; i < nseg; i++) { - sg->SgEntry[i].SgAddress = segs[i].ds_addr; - sg->SgEntry[i].SgByteCount = segs[i].ds_len; + /* find the s/g table */ + sg = cm->cm_sgtable; + + /* copy into the FIB */ + if (sg != NULL) { + sg->SgCount = nseg; + for (i = 0; i < nseg; i++) { + sg->SgEntry[i].SgAddress = segs[i].ds_addr; + sg->SgEntry[i].SgByteCount = segs[i].ds_len; + } + /* update the FIB size for the s/g count */ + fib->Header.Size += nseg * sizeof(struct aac_sg_entry); } - /* update the FIB size for the s/g count */ - fib->Header.Size += nseg * sizeof(struct aac_sg_entry); - } } -/****************************************************************************** +/* * Map a command into controller-visible space. */ static void aac_map_command(struct aac_command *cm) { - struct aac_softc *sc = cm->cm_sc; + struct aac_softc *sc; - debug_called(2); + debug_called(2); - /* don't map more than once */ - if (cm->cm_flags & AAC_CMD_MAPPED) - return; + sc = cm->cm_sc; - if (cm->cm_datalen != 0) { - bus_dmamap_load(sc->aac_buffer_dmat, cm->cm_datamap, cm->cm_data, - cm->cm_datalen, aac_map_command_sg, cm, 0); + /* don't map more than once */ + if (cm->cm_flags & AAC_CMD_MAPPED) + return; + + if (cm->cm_datalen != 0) { + bus_dmamap_load(sc->aac_buffer_dmat, cm->cm_datamap, + cm->cm_data, cm->cm_datalen, + aac_map_command_sg, cm, 0); if (cm->cm_flags & AAC_CMD_DATAIN) - bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, - BUS_DMASYNC_PREREAD); + bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, + BUS_DMASYNC_PREREAD); if (cm->cm_flags & AAC_CMD_DATAOUT) - bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, - BUS_DMASYNC_PREWRITE); - } - cm->cm_flags |= AAC_CMD_MAPPED; + bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, + BUS_DMASYNC_PREWRITE); + } + cm->cm_flags |= AAC_CMD_MAPPED; } -/****************************************************************************** +/* * Unmap a command from controller-visible space. */ static void aac_unmap_command(struct aac_command *cm) { - struct aac_softc *sc = cm->cm_sc; + struct aac_softc *sc; - debug_called(2); + debug_called(2); - if (!(cm->cm_flags & AAC_CMD_MAPPED)) - return; + sc = cm->cm_sc; - if (cm->cm_datalen != 0) { - if (cm->cm_flags & AAC_CMD_DATAIN) - bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, - BUS_DMASYNC_POSTREAD); - if (cm->cm_flags & AAC_CMD_DATAOUT) - bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, - BUS_DMASYNC_POSTWRITE); + if (!(cm->cm_flags & AAC_CMD_MAPPED)) + return; - bus_dmamap_unload(sc->aac_buffer_dmat, cm->cm_datamap); - } - cm->cm_flags &= ~AAC_CMD_MAPPED; + if (cm->cm_datalen != 0) { + if (cm->cm_flags & AAC_CMD_DATAIN) + bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, + BUS_DMASYNC_POSTREAD); + if (cm->cm_flags & AAC_CMD_DATAOUT) + bus_dmamap_sync(sc->aac_buffer_dmat, cm->cm_datamap, + BUS_DMASYNC_POSTWRITE); + + bus_dmamap_unload(sc->aac_buffer_dmat, cm->cm_datamap); + } + cm->cm_flags &= ~AAC_CMD_MAPPED; } -/****************************************************************************** - ****************************************************************************** - Hardware Interface - ****************************************************************************** - ******************************************************************************/ +/* + * Hardware Interface + */ -/****************************************************************************** +/* * Initialise the adapter. */ static void aac_common_map(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - struct aac_softc *sc = (struct aac_softc *)arg; + struct aac_softc *sc; - debug_called(1); + debug_called(1); - sc->aac_common_busaddr = segs[0].ds_addr; + sc = (struct aac_softc *)arg; + + sc->aac_common_busaddr = segs[0].ds_addr; } static int aac_init(struct aac_softc *sc) { - struct aac_adapter_init *ip; - time_t then; - u_int32_t code; - u_int8_t *qaddr; + struct aac_adapter_init *ip; + time_t then; + u_int32_t code; + u_int8_t *qaddr; - debug_called(1); + debug_called(1); - /* - * First wait for the adapter to come ready. - */ - then = time_second; - do { - code = AAC_GET_FWSTATUS(sc); - if (code & AAC_SELF_TEST_FAILED) { - device_printf(sc->aac_dev, "FATAL: selftest failed\n"); - return(ENXIO); + /* + * First wait for the adapter to come ready. + */ + then = time_second; + do { + code = AAC_GET_FWSTATUS(sc); + if (code & AAC_SELF_TEST_FAILED) { + device_printf(sc->aac_dev, "FATAL: selftest failed\n"); + return(ENXIO); + } + if (code & AAC_KERNEL_PANIC) { + device_printf(sc->aac_dev, + "FATAL: controller kernel panic\n"); + return(ENXIO); + } + if (time_second > (then + AAC_BOOT_TIMEOUT)) { + device_printf(sc->aac_dev, + "FATAL: controller not coming ready, " + "status %x\n", code); + return(ENXIO); + } + } while (!(code & AAC_UP_AND_RUNNING)); + + /* + * Create DMA tag for the common structure and allocate it. + */ + if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ + 1, 0, /* algnmnt, boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + sizeof(struct aac_common), /* maxsize */ + 1, /* nsegments */ + BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ + 0, /* flags */ + &sc->aac_common_dmat)) { + device_printf(sc->aac_dev, + "can't allocate common structure DMA tag\n"); + return(ENOMEM); } - if (code & AAC_KERNEL_PANIC) { - device_printf(sc->aac_dev, "FATAL: controller kernel panic\n"); - return(ENXIO); + if (bus_dmamem_alloc(sc->aac_common_dmat, (void **)&sc->aac_common, + BUS_DMA_NOWAIT, &sc->aac_common_dmamap)) { + device_printf(sc->aac_dev, "can't allocate common structure\n"); + return(ENOMEM); } - if (time_second > (then + AAC_BOOT_TIMEOUT)) { - device_printf(sc->aac_dev, "FATAL: controller not coming ready, " - "status %x\n", code); - return(ENXIO); - } - } while (!(code & AAC_UP_AND_RUNNING)); + bus_dmamap_load(sc->aac_common_dmat, sc->aac_common_dmamap, + sc->aac_common, sizeof(*sc->aac_common), aac_common_map, + sc, 0); + bzero(sc->aac_common, sizeof(*sc->aac_common)); + + /* + * Fill in the init structure. This tells the adapter about the + * physical location of various important shared data structures. + */ + ip = &sc->aac_common->ac_init; + ip->InitStructRevision = AAC_INIT_STRUCT_REVISION; - /* - * Create DMA tag for the common structure and allocate it. - */ - if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - sizeof(struct aac_common), 1,/* maxsize, nsegments */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ - 0, /* flags */ - &sc->aac_common_dmat)) { - device_printf(sc->aac_dev, "can't allocate common structure DMA tag\n"); - return(ENOMEM); - } - if (bus_dmamem_alloc(sc->aac_common_dmat, (void **)&sc->aac_common, - BUS_DMA_NOWAIT, &sc->aac_common_dmamap)) { - device_printf(sc->aac_dev, "can't allocate common structure\n"); - return(ENOMEM); - } - bus_dmamap_load(sc->aac_common_dmat, sc->aac_common_dmamap, sc->aac_common, - sizeof(*sc->aac_common), aac_common_map, sc, 0); - bzero(sc->aac_common, sizeof(*sc->aac_common)); - - /* - * Fill in the init structure. This tells the adapter about the physical - * location of various important shared data structures. - */ - ip = &sc->aac_common->ac_init; - ip->InitStructRevision = AAC_INIT_STRUCT_REVISION; + ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr + + offsetof(struct aac_common, ac_fibs); + ip->AdapterFibsVirtualAddress = &sc->aac_common->ac_fibs[0]; + ip->AdapterFibsSize = AAC_ADAPTER_FIBS * sizeof(struct aac_fib); + ip->AdapterFibAlign = sizeof(struct aac_fib); - ip->AdapterFibsPhysicalAddress = sc->aac_common_busaddr + - offsetof(struct aac_common, ac_fibs); - ip->AdapterFibsVirtualAddress = &sc->aac_common->ac_fibs[0]; - ip->AdapterFibsSize = AAC_ADAPTER_FIBS * sizeof(struct aac_fib); - ip->AdapterFibAlign = sizeof(struct aac_fib); + ip->PrintfBufferAddress = sc->aac_common_busaddr + + offsetof(struct aac_common, ac_printf); + ip->PrintfBufferSize = AAC_PRINTF_BUFSIZE; - ip->PrintfBufferAddress = sc->aac_common_busaddr + - offsetof(struct aac_common, ac_printf); - ip->PrintfBufferSize = AAC_PRINTF_BUFSIZE; + ip->HostPhysMemPages = 0; /* not used? */ + ip->HostElapsedSeconds = time_second; /* reset later if invalid */ - ip->HostPhysMemPages = 0; /* not used? */ - ip->HostElapsedSeconds = time_second; /* reset later if invalid */ + /* + * Initialise FIB queues. Note that it appears that the layout of the + * indexes and the segmentation of the entries may be mandated by the + * adapter, which is only told about the base of the queue index fields. + * + * The initial values of the indices are assumed to inform the adapter + * of the sizes of the respective queues, and theoretically it could + * work out the entire layout of the queue structures from this. We + * take the easy route and just lay this area out like everyone else + * does. + * + * The Linux driver uses a much more complex scheme whereby several + * header records are kept for each queue. We use a couple of generic + * list manipulation functions which 'know' the size of each list by + * virtue of a table. + */ + qaddr = &sc->aac_common->ac_qbuf[0] + AAC_QUEUE_ALIGN; + qaddr -= (u_int32_t)qaddr % AAC_QUEUE_ALIGN; + sc->aac_queues = (struct aac_queue_table *)qaddr; + ip->CommHeaderAddress = sc->aac_common_busaddr + + ((u_int32_t)sc->aac_queues - + (u_int32_t)sc->aac_common); + bzero(sc->aac_queues, sizeof(struct aac_queue_table)); - /* - * Initialise FIB queues. Note that it appears that the layout of the - * indexes and the segmentation of the entries may be mandated by the - * adapter, which is only told about the base of the queue index fields. - * - * The initial values of the indices are assumed to inform the adapter - * of the sizes of the respective queues, and theoretically it could work - * out the entire layout of the queue structures from this. We take the - * easy route and just lay this area out like everyone else does. - * - * The Linux driver uses a much more complex scheme whereby several header - * records are kept for each queue. We use a couple of generic list - * manipulation functions which 'know' the size of each list by virtue of a - * table. - */ - qaddr = &sc->aac_common->ac_qbuf[0] + AAC_QUEUE_ALIGN; - qaddr -= (u_int32_t)qaddr % AAC_QUEUE_ALIGN; - sc->aac_queues = (struct aac_queue_table *)qaddr; - ip->CommHeaderAddress = sc->aac_common_busaddr + ((u_int32_t)sc->aac_queues - - (u_int32_t)sc->aac_common); - bzero(sc->aac_queues, sizeof(struct aac_queue_table)); - - sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX] = AAC_HOST_NORM_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX] = AAC_HOST_NORM_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX] = AAC_HOST_HIGH_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX] = AAC_HOST_HIGH_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX] = AAC_ADAP_NORM_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX] = AAC_ADAP_NORM_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX] = AAC_ADAP_HIGH_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX] = AAC_ADAP_HIGH_CMD_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX]= AAC_HOST_NORM_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX]= AAC_HOST_NORM_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX]= AAC_HOST_HIGH_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX]= AAC_HOST_HIGH_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX]= AAC_ADAP_NORM_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX]= AAC_ADAP_NORM_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX]= AAC_ADAP_HIGH_RESP_ENTRIES; - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX] = + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX]= AAC_ADAP_HIGH_RESP_ENTRIES; - sc->aac_qentries[AAC_HOST_NORM_CMD_QUEUE] = + sc->aac_qentries[AAC_HOST_NORM_CMD_QUEUE] = &sc->aac_queues->qt_HostNormCmdQueue[0]; - sc->aac_qentries[AAC_HOST_HIGH_CMD_QUEUE] = + sc->aac_qentries[AAC_HOST_HIGH_CMD_QUEUE] = &sc->aac_queues->qt_HostHighCmdQueue[0]; - sc->aac_qentries[AAC_ADAP_NORM_CMD_QUEUE] = + sc->aac_qentries[AAC_ADAP_NORM_CMD_QUEUE] = &sc->aac_queues->qt_AdapNormCmdQueue[0]; - sc->aac_qentries[AAC_ADAP_HIGH_CMD_QUEUE] = + sc->aac_qentries[AAC_ADAP_HIGH_CMD_QUEUE] = &sc->aac_queues->qt_AdapHighCmdQueue[0]; - sc->aac_qentries[AAC_HOST_NORM_RESP_QUEUE] = + sc->aac_qentries[AAC_HOST_NORM_RESP_QUEUE] = &sc->aac_queues->qt_HostNormRespQueue[0]; - sc->aac_qentries[AAC_HOST_HIGH_RESP_QUEUE] = + sc->aac_qentries[AAC_HOST_HIGH_RESP_QUEUE] = &sc->aac_queues->qt_HostHighRespQueue[0]; - sc->aac_qentries[AAC_ADAP_NORM_RESP_QUEUE] = + sc->aac_qentries[AAC_ADAP_NORM_RESP_QUEUE] = &sc->aac_queues->qt_AdapNormRespQueue[0]; - sc->aac_qentries[AAC_ADAP_HIGH_RESP_QUEUE] = + sc->aac_qentries[AAC_ADAP_HIGH_RESP_QUEUE] = &sc->aac_queues->qt_AdapHighRespQueue[0]; - /* - * Do controller-type-specific initialisation - */ - switch (sc->aac_hwif) { - case AAC_HWIF_I960RX: - AAC_SETREG4(sc, AAC_RX_ODBR, ~0); - break; - } + /* + * Do controller-type-specific initialisation + */ + switch (sc->aac_hwif) { + case AAC_HWIF_I960RX: + AAC_SETREG4(sc, AAC_RX_ODBR, ~0); + break; + } - /* - * Give the init structure to the controller. - */ - if (aac_sync_command(sc, AAC_MONKER_INITSTRUCT, - sc->aac_common_busaddr + offsetof(struct aac_common, - ac_init), 0, 0, 0, NULL)) { - device_printf(sc->aac_dev, "error establishing init structure\n"); - return(EIO); - } + /* + * Give the init structure to the controller. + */ + if (aac_sync_command(sc, AAC_MONKER_INITSTRUCT, + sc->aac_common_busaddr + + offsetof(struct aac_common, ac_init), 0, 0, 0, + NULL)) { + device_printf(sc->aac_dev, + "error establishing init structure\n"); + return(EIO); + } - return(0); + return(0); } -/****************************************************************************** +/* * Send a synchronous command to the controller and wait for a result. */ static int @@ -1434,120 +1496,125 @@ aac_sync_command(struct aac_softc *sc, u_int32_t command, u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3, u_int32_t *sp) { - time_t then; - u_int32_t status; + time_t then; + u_int32_t status; - debug_called(3); + debug_called(3); - /* populate the mailbox */ - AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3); + /* populate the mailbox */ + AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3); - /* ensure the sync command doorbell flag is cleared */ - AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND); + /* ensure the sync command doorbell flag is cleared */ + AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND); - /* then set it to signal the adapter */ - AAC_QNOTIFY(sc, AAC_DB_SYNC_COMMAND); + /* then set it to signal the adapter */ + AAC_QNOTIFY(sc, AAC_DB_SYNC_COMMAND); - /* spin waiting for the command to complete */ - then = time_second; - do { - if (time_second > (then + AAC_IMMEDIATE_TIMEOUT)) { - debug(2, "timed out"); - return(EIO); - } - } while (!(AAC_GET_ISTATUS(sc) & AAC_DB_SYNC_COMMAND)); + /* spin waiting for the command to complete */ + then = time_second; + do { + if (time_second > (then + AAC_IMMEDIATE_TIMEOUT)) { + debug(2, "timed out"); + return(EIO); + } + } while (!(AAC_GET_ISTATUS(sc) & AAC_DB_SYNC_COMMAND)); - /* clear the completion flag */ - AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND); + /* clear the completion flag */ + AAC_CLEAR_ISTATUS(sc, AAC_DB_SYNC_COMMAND); - /* get the command status */ - status = AAC_GET_MAILBOXSTATUS(sc); - if (sp != NULL) - *sp = status; - return(0); + /* get the command status */ + status = AAC_GET_MAILBOXSTATUS(sc); + if (sp != NULL) + *sp = status; + return(0); } -/****************************************************************************** +/* * Send a synchronous FIB to the controller and wait for a result. */ static int aac_sync_fib(struct aac_softc *sc, u_int32_t command, u_int32_t xferstate, - void *data, u_int16_t datasize, - void *result, u_int16_t *resultsize) + void *data, u_int16_t datasize, + void *result, u_int16_t *resultsize) { - struct aac_fib *fib = &sc->aac_common->ac_sync_fib; + struct aac_fib *fib; - debug_called(3); + debug_called(3); - if (datasize > AAC_FIB_DATASIZE) - return(EINVAL); + fib = &sc->aac_common->ac_sync_fib; - /* - * Set up the sync FIB - */ - fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED | AAC_FIBSTATE_INITIALISED | - AAC_FIBSTATE_EMPTY; - fib->Header.XferState |= xferstate; - fib->Header.Command = command; - fib->Header.StructType = AAC_FIBTYPE_TFIB; - fib->Header.Size = sizeof(struct aac_fib) + datasize; - fib->Header.SenderSize = sizeof(struct aac_fib); - fib->Header.SenderFibAddress = (u_int32_t)fib; - fib->Header.ReceiverFibAddress = sc->aac_common_busaddr + - offsetof(struct aac_common, ac_sync_fib); + if (datasize > AAC_FIB_DATASIZE) + return(EINVAL); - /* - * Copy in data. - */ - if (data != NULL) { - KASSERT(datasize <= sizeof(fib->data), - ("aac_sync_fib: datasize to large")); - bcopy(data, fib->data, datasize); - fib->Header.XferState |= AAC_FIBSTATE_FROMHOST | AAC_FIBSTATE_NORM; - } + /* + * Set up the sync FIB + */ + fib->Header.XferState = AAC_FIBSTATE_HOSTOWNED | + AAC_FIBSTATE_INITIALISED | + AAC_FIBSTATE_EMPTY; + fib->Header.XferState |= xferstate; + fib->Header.Command = command; + fib->Header.StructType = AAC_FIBTYPE_TFIB; + fib->Header.Size = sizeof(struct aac_fib) + datasize; + fib->Header.SenderSize = sizeof(struct aac_fib); + fib->Header.SenderFibAddress = (u_int32_t)fib; + fib->Header.ReceiverFibAddress = sc->aac_common_busaddr + + offsetof(struct aac_common, + ac_sync_fib); - /* - * Give the FIB to the controller, wait for a response. - */ - if (aac_sync_command(sc, AAC_MONKER_SYNCFIB, fib->Header.ReceiverFibAddress, - 0, 0, 0, NULL)) { - debug(2, "IO error"); - return(EIO); - } + /* + * Copy in data. + */ + if (data != NULL) { + KASSERT(datasize <= sizeof(fib->data), + ("aac_sync_fib: datasize to large")); + bcopy(data, fib->data, datasize); + fib->Header.XferState |= AAC_FIBSTATE_FROMHOST | + AAC_FIBSTATE_NORM; + } - /* - * Copy out the result - */ - if (result != NULL) { - u_int copysize; + /* + * Give the FIB to the controller, wait for a response. + */ + if (aac_sync_command(sc, AAC_MONKER_SYNCFIB, + fib->Header.ReceiverFibAddress, 0, 0, 0, NULL)) { + debug(2, "IO error"); + return(EIO); + } - copysize = fib->Header.Size - sizeof(struct aac_fib_header); - if (copysize > *resultsize) - copysize = *resultsize; - *resultsize = fib->Header.Size - sizeof(struct aac_fib_header); - bcopy(fib->data, result, copysize); - } - return(0); + /* + * Copy out the result + */ + if (result != NULL) { + u_int copysize; + + copysize = fib->Header.Size - sizeof(struct aac_fib_header); + if (copysize > *resultsize) + copysize = *resultsize; + *resultsize = fib->Header.Size - sizeof(struct aac_fib_header); + bcopy(fib->data, result, copysize); + } + return(0); } -/****************************************************************************** +/* * Adapter-space FIB queue manipulation * * Note that the queue implementation here is a little funky; neither the PI or * CI will ever be zero. This behaviour is a controller feature. */ static struct { - int size; - int notify; + int size; + int notify; } aac_qinfo[] = { - {AAC_HOST_NORM_CMD_ENTRIES, AAC_DB_COMMAND_NOT_FULL}, - {AAC_HOST_HIGH_CMD_ENTRIES, 0}, - {AAC_ADAP_NORM_CMD_ENTRIES, AAC_DB_COMMAND_READY}, - {AAC_ADAP_HIGH_CMD_ENTRIES, 0}, - {AAC_HOST_NORM_RESP_ENTRIES, AAC_DB_RESPONSE_NOT_FULL}, - {AAC_HOST_HIGH_RESP_ENTRIES, 0}, - {AAC_ADAP_NORM_RESP_ENTRIES, AAC_DB_RESPONSE_READY}, - {AAC_ADAP_HIGH_RESP_ENTRIES, 0} + {AAC_HOST_NORM_CMD_ENTRIES, AAC_DB_COMMAND_NOT_FULL}, + {AAC_HOST_HIGH_CMD_ENTRIES, 0}, + {AAC_ADAP_NORM_CMD_ENTRIES, AAC_DB_COMMAND_READY}, + {AAC_ADAP_HIGH_CMD_ENTRIES, 0}, + {AAC_HOST_NORM_RESP_ENTRIES, AAC_DB_RESPONSE_NOT_FULL}, + {AAC_HOST_HIGH_RESP_ENTRIES, 0}, + {AAC_ADAP_NORM_RESP_ENTRIES, AAC_DB_RESPONSE_READY}, + {AAC_ADAP_HIGH_RESP_ENTRIES, 0} }; /* @@ -1555,60 +1622,61 @@ static struct { * EBUSY if the queue is full. * * Note: it would be more efficient to defer notifying the controller in - * the case where we may be inserting several entries in rapid succession, * but implementing this usefully may be difficult (it would involve a - * separate queue/notify interface). + * the case where we may be inserting several entries in rapid succession, + * but implementing this usefully may be difficult (it would involve a + * separate queue/notify interface). */ static int aac_enqueue_fib(struct aac_softc *sc, int queue, struct aac_command *cm) { - u_int32_t pi, ci; - int s, error; - u_int32_t fib_size; - u_int32_t fib_addr; + u_int32_t pi, ci; + int s, error; + u_int32_t fib_size; + u_int32_t fib_addr; - debug_called(3); + debug_called(3); - fib_size = cm->cm_fib->Header.Size; - fib_addr = cm->cm_fib->Header.ReceiverFibAddress; + fib_size = cm->cm_fib->Header.Size; + fib_addr = cm->cm_fib->Header.ReceiverFibAddress; - s = splbio(); + s = splbio(); - /* get the producer/consumer indices */ - pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; - ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; + /* get the producer/consumer indices */ + pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; + ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; - /* wrap the queue? */ - if (pi >= aac_qinfo[queue].size) - pi = 0; + /* wrap the queue? */ + if (pi >= aac_qinfo[queue].size) + pi = 0; - /* check for queue full */ - if ((pi + 1) == ci) { - error = EBUSY; - goto out; - } + /* check for queue full */ + if ((pi + 1) == ci) { + error = EBUSY; + goto out; + } - /* populate queue entry */ - (sc->aac_qentries[queue] + pi)->aq_fib_size = fib_size; - (sc->aac_qentries[queue] + pi)->aq_fib_addr = fib_addr; + /* populate queue entry */ + (sc->aac_qentries[queue] + pi)->aq_fib_size = fib_size; + (sc->aac_qentries[queue] + pi)->aq_fib_addr = fib_addr; - /* update producer index */ - sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX] = pi + 1; + /* update producer index */ + sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX] = pi + 1; - /* - * To avoid a race with its completion interrupt, place this command on the - * busy queue prior to advertising it to the controller. - */ - aac_enqueue_busy(cm); + /* + * To avoid a race with its completion interrupt, place this command on + * the busy queue prior to advertising it to the controller. + */ + aac_enqueue_busy(cm); - /* notify the adapter if we know how */ - if (aac_qinfo[queue].notify != 0) - AAC_QNOTIFY(sc, aac_qinfo[queue].notify); + /* notify the adapter if we know how */ + if (aac_qinfo[queue].notify != 0) + AAC_QNOTIFY(sc, aac_qinfo[queue].notify); - error = 0; + error = 0; out: - splx(s); - return(error); + splx(s); + return(error); } /* @@ -1619,711 +1687,721 @@ static int aac_dequeue_fib(struct aac_softc *sc, int queue, u_int32_t *fib_size, struct aac_fib **fib_addr) { - u_int32_t pi, ci; - int s, error; - int notify; + u_int32_t pi, ci; + int s, error; + int notify; - debug_called(3); + debug_called(3); - s = splbio(); + s = splbio(); - /* get the producer/consumer indices */ - pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; - ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; + /* get the producer/consumer indices */ + pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; + ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; - /* check for queue empty */ - if (ci == pi) { - error = ENOENT; - goto out; - } - - notify = 0; - if (ci == pi + 1) - notify++; + /* check for queue empty */ + if (ci == pi) { + error = ENOENT; + goto out; + } + + notify = 0; + if (ci == pi + 1) + notify++; - /* wrap the queue? */ - if (ci >= aac_qinfo[queue].size) - ci = 0; + /* wrap the queue? */ + if (ci >= aac_qinfo[queue].size) + ci = 0; - /* fetch the entry */ - *fib_size = (sc->aac_qentries[queue] + ci)->aq_fib_size; - *fib_addr = (struct aac_fib *)(sc->aac_qentries[queue] + ci)->aq_fib_addr; + /* fetch the entry */ + *fib_size = (sc->aac_qentries[queue] + ci)->aq_fib_size; + *fib_addr = (struct aac_fib *)(sc->aac_qentries[queue] + + ci)->aq_fib_addr; - /* update consumer index */ - sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX] = ci + 1; + /* update consumer index */ + sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX] = ci + 1; - /* if we have made the queue un-full, notify the adapter */ - if (notify && (aac_qinfo[queue].notify != 0)) - AAC_QNOTIFY(sc, aac_qinfo[queue].notify); - error = 0; + /* if we have made the queue un-full, notify the adapter */ + if (notify && (aac_qinfo[queue].notify != 0)) + AAC_QNOTIFY(sc, aac_qinfo[queue].notify); + error = 0; out: - splx(s); - return(error); + splx(s); + return(error); } -/****************************************************************************** +/* * Put our response to an Adapter Initialed Fib on the response queue */ static int aac_enqueue_response(struct aac_softc *sc, int queue, struct aac_fib *fib) { - u_int32_t pi, ci; - int s, error; - u_int32_t fib_size; - u_int32_t fib_addr; + u_int32_t pi, ci; + int s, error; + u_int32_t fib_size; + u_int32_t fib_addr; - debug_called(1); + debug_called(1); - /* Tell the adapter where the FIB is */ - fib_size = fib->Header.Size; - fib_addr = fib->Header.SenderFibAddress; - fib->Header.ReceiverFibAddress = fib_addr; + /* Tell the adapter where the FIB is */ + fib_size = fib->Header.Size; + fib_addr = fib->Header.SenderFibAddress; + fib->Header.ReceiverFibAddress = fib_addr; - s = splbio(); + s = splbio(); - /* get the producer/consumer indices */ - pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; - ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; + /* get the producer/consumer indices */ + pi = sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX]; + ci = sc->aac_queues->qt_qindex[queue][AAC_CONSUMER_INDEX]; - /* wrap the queue? */ - if (pi >= aac_qinfo[queue].size) - pi = 0; + /* wrap the queue? */ + if (pi >= aac_qinfo[queue].size) + pi = 0; - /* check for queue full */ - if ((pi + 1) == ci) { - error = EBUSY; - goto out; - } + /* check for queue full */ + if ((pi + 1) == ci) { + error = EBUSY; + goto out; + } - /* populate queue entry */ - (sc->aac_qentries[queue] + pi)->aq_fib_size = fib_size; - (sc->aac_qentries[queue] + pi)->aq_fib_addr = fib_addr; + /* populate queue entry */ + (sc->aac_qentries[queue] + pi)->aq_fib_size = fib_size; + (sc->aac_qentries[queue] + pi)->aq_fib_addr = fib_addr; - /* update producer index */ - sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX] = pi + 1; + /* update producer index */ + sc->aac_queues->qt_qindex[queue][AAC_PRODUCER_INDEX] = pi + 1; - /* notify the adapter if we know how */ - if (aac_qinfo[queue].notify != 0) - AAC_QNOTIFY(sc, aac_qinfo[queue].notify); + /* notify the adapter if we know how */ + if (aac_qinfo[queue].notify != 0) + AAC_QNOTIFY(sc, aac_qinfo[queue].notify); - error = 0; + error = 0; out: - splx(s); - return(error); + splx(s); + return(error); } -/****************************************************************************** +/* * Check for commands that have been outstanding for a suspiciously long time, * and complain about them. */ static void aac_timeout(struct aac_softc *sc) { - int s; - struct aac_command *cm; - time_t deadline; + int s; + struct aac_command *cm; + time_t deadline; #if 0 - /* simulate an interrupt to handle possibly-missed interrupts */ - /* - * XXX This was done to work around another bug which has since been - * fixed. It is dangerous anyways because you don't want multiple - * threads in the interrupt handler at the same time! If calling - * is deamed neccesary in the future, proper mutexes must be used. - */ - s = splbio(); - aac_intr(sc); - splx(s); + /* simulate an interrupt to handle possibly-missed interrupts */ + /* + * XXX This was done to work around another bug which has since been + * fixed. It is dangerous anyways because you don't want multiple + * threads in the interrupt handler at the same time! If calling + * is deamed neccesary in the future, proper mutexes must be used. + */ + s = splbio(); + aac_intr(sc); + splx(s); - /* kick the I/O queue to restart it in the case of deadlock */ - aac_startio(sc); + /* kick the I/O queue to restart it in the case of deadlock */ + aac_startio(sc); #endif - /* traverse the busy command list, bitch about late commands once only */ - deadline = time_second - AAC_CMD_TIMEOUT; - s = splbio(); - TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) { - if ((cm->cm_timestamp < deadline) - /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) { - cm->cm_flags |= AAC_CMD_TIMEDOUT; - device_printf(sc->aac_dev, "COMMAND %p TIMEOUT AFTER %d SECONDS\n", - cm, (int)(time_second - cm->cm_timestamp)); - AAC_PRINT_FIB(sc, cm->cm_fib); + /* + * traverse the busy command list, bitch about late commands once + * only. + */ + deadline = time_second - AAC_CMD_TIMEOUT; + s = splbio(); + TAILQ_FOREACH(cm, &sc->aac_busy, cm_link) { + if ((cm->cm_timestamp < deadline) + /* && !(cm->cm_flags & AAC_CMD_TIMEDOUT) */) { + cm->cm_flags |= AAC_CMD_TIMEDOUT; + device_printf(sc->aac_dev, + "COMMAND %p TIMEOUT AFTER %d SECONDS\n", + cm, (int)(time_second-cm->cm_timestamp)); + AAC_PRINT_FIB(sc, cm->cm_fib); + } } - } - splx(s); + splx(s); - /* reset the timer for next time */ - timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); - return; + /* reset the timer for next time */ + timeout((timeout_t*)aac_timeout, sc, AAC_PERIODIC_INTERVAL * hz); + return; } -/****************************************************************************** - ****************************************************************************** - Interface Function Vectors - ****************************************************************************** - ******************************************************************************/ +/* + * Interface Function Vectors + */ -/****************************************************************************** +/* * Read the current firmware status word. */ static int aac_sa_get_fwstatus(struct aac_softc *sc) { - debug_called(3); + debug_called(3); - return(AAC_GETREG4(sc, AAC_SA_FWSTATUS)); + return(AAC_GETREG4(sc, AAC_SA_FWSTATUS)); } static int aac_rx_get_fwstatus(struct aac_softc *sc) { - debug_called(3); + debug_called(3); - return(AAC_GETREG4(sc, AAC_RX_FWSTATUS)); + return(AAC_GETREG4(sc, AAC_RX_FWSTATUS)); } -/****************************************************************************** +/* * Notify the controller of a change in a given queue */ static void aac_sa_qnotify(struct aac_softc *sc, int qbit) { - debug_called(3); + debug_called(3); - AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); + AAC_SETREG2(sc, AAC_SA_DOORBELL1_SET, qbit); } static void aac_rx_qnotify(struct aac_softc *sc, int qbit) { - debug_called(3); + debug_called(3); - AAC_SETREG4(sc, AAC_RX_IDBR, qbit); + AAC_SETREG4(sc, AAC_RX_IDBR, qbit); } -/****************************************************************************** +/* * Get the interrupt reason bits */ static int aac_sa_get_istatus(struct aac_softc *sc) { - debug_called(3); + debug_called(3); - return(AAC_GETREG2(sc, AAC_SA_DOORBELL0)); + return(AAC_GETREG2(sc, AAC_SA_DOORBELL0)); } static int aac_rx_get_istatus(struct aac_softc *sc) { - debug_called(3); + debug_called(3); - return(AAC_GETREG4(sc, AAC_RX_ODBR)); + return(AAC_GETREG4(sc, AAC_RX_ODBR)); } -/****************************************************************************** +/* * Clear some interrupt reason bits */ static void aac_sa_clear_istatus(struct aac_softc *sc, int mask) { - debug_called(3); + debug_called(3); - AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); + AAC_SETREG2(sc, AAC_SA_DOORBELL0_CLEAR, mask); } static void aac_rx_clear_istatus(struct aac_softc *sc, int mask) { - debug_called(3); + debug_called(3); - AAC_SETREG4(sc, AAC_RX_ODBR, mask); + AAC_SETREG4(sc, AAC_RX_ODBR, mask); } -/****************************************************************************** +/* * Populate the mailbox and set the command word */ static void aac_sa_set_mailbox(struct aac_softc *sc, u_int32_t command, u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3) { - debug_called(4); + debug_called(4); - AAC_SETREG4(sc, AAC_SA_MAILBOX, command); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); + AAC_SETREG4(sc, AAC_SA_MAILBOX, command); + AAC_SETREG4(sc, AAC_SA_MAILBOX + 4, arg0); + AAC_SETREG4(sc, AAC_SA_MAILBOX + 8, arg1); + AAC_SETREG4(sc, AAC_SA_MAILBOX + 12, arg2); + AAC_SETREG4(sc, AAC_SA_MAILBOX + 16, arg3); } static void aac_rx_set_mailbox(struct aac_softc *sc, u_int32_t command, u_int32_t arg0, u_int32_t arg1, u_int32_t arg2, u_int32_t arg3) { - debug_called(4); + debug_called(4); - AAC_SETREG4(sc, AAC_RX_MAILBOX, command); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); - AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); + AAC_SETREG4(sc, AAC_RX_MAILBOX, command); + AAC_SETREG4(sc, AAC_RX_MAILBOX + 4, arg0); + AAC_SETREG4(sc, AAC_RX_MAILBOX + 8, arg1); + AAC_SETREG4(sc, AAC_RX_MAILBOX + 12, arg2); + AAC_SETREG4(sc, AAC_RX_MAILBOX + 16, arg3); } -/****************************************************************************** +/* * Fetch the immediate command status word */ static int aac_sa_get_mailboxstatus(struct aac_softc *sc) { - debug_called(4); + debug_called(4); - return(AAC_GETREG4(sc, AAC_SA_MAILBOX)); + return(AAC_GETREG4(sc, AAC_SA_MAILBOX)); } static int aac_rx_get_mailboxstatus(struct aac_softc *sc) { - debug_called(4); + debug_called(4); - return(AAC_GETREG4(sc, AAC_RX_MAILBOX)); + return(AAC_GETREG4(sc, AAC_RX_MAILBOX)); } -/****************************************************************************** +/* * Set/clear interrupt masks */ static void aac_sa_set_interrupts(struct aac_softc *sc, int enable) { - debug(2, "%sable interrupts", enable ? "en" : "dis"); + debug(2, "%sable interrupts", enable ? "en" : "dis"); - if (enable) { - AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); - } else { - AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0); - } + if (enable) { + AAC_SETREG2((sc), AAC_SA_MASK0_CLEAR, AAC_DB_INTERRUPTS); + } else { + AAC_SETREG2((sc), AAC_SA_MASK0_SET, ~0); + } } static void aac_rx_set_interrupts(struct aac_softc *sc, int enable) { - debug(2, "%sable interrupts", enable ? "en" : "dis"); + debug(2, "%sable interrupts", enable ? "en" : "dis"); - if (enable) { - AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); - } else { - AAC_SETREG4(sc, AAC_RX_OIMR, ~0); - } + if (enable) { + AAC_SETREG4(sc, AAC_RX_OIMR, ~AAC_DB_INTERRUPTS); + } else { + AAC_SETREG4(sc, AAC_RX_OIMR, ~0); + } } -/****************************************************************************** - ****************************************************************************** - Debugging and Diagnostics - ****************************************************************************** - ******************************************************************************/ +/* + * Debugging and Diagnostics + */ -/****************************************************************************** +/* * Print some information about the controller. */ static void aac_describe_controller(struct aac_softc *sc) { - u_int8_t buf[AAC_FIB_DATASIZE]; /* XXX really a bit big - * for the stack */ - u_int16_t bufsize; - struct aac_adapter_info *info; - u_int8_t arg; + u_int8_t buf[AAC_FIB_DATASIZE]; /* XXX really a bit big + * for the stack */ + u_int16_t bufsize; + struct aac_adapter_info *info; + u_int8_t arg; - debug_called(2); + debug_called(2); - arg = 0; - bufsize = sizeof(buf); - if (aac_sync_fib(sc, RequestAdapterInfo, 0, &arg, sizeof(arg), &buf, - &bufsize)) { - device_printf(sc->aac_dev, "RequestAdapterInfo failed\n"); - return; - } - if (bufsize != sizeof(*info)) { - device_printf(sc->aac_dev, "RequestAdapterInfo returned wrong data " - "size (%d != %d)\n", bufsize, sizeof(*info)); - /*return;*/ - } - info = (struct aac_adapter_info *)&buf[0]; + arg = 0; + bufsize = sizeof(buf); + if (aac_sync_fib(sc, RequestAdapterInfo, 0, &arg, sizeof(arg), &buf, + &bufsize)) { + device_printf(sc->aac_dev, "RequestAdapterInfo failed\n"); + return; + } + if (bufsize != sizeof(*info)) { + device_printf(sc->aac_dev, + "RequestAdapterInfo returned wrong data size " + "(%d != %d)\n", bufsize, sizeof(*info)); + /*return;*/ + } + info = (struct aac_adapter_info *)&buf[0]; - device_printf(sc->aac_dev, "%s %dMHz, %dMB cache memory, %s\n", - aac_describe_code(aac_cpu_variant, info->CpuVariant), - info->ClockSpeed, info->BufferMem / (1024 * 1024), - aac_describe_code(aac_battery_platform, info->batteryPlatform)); + device_printf(sc->aac_dev, "%s %dMHz, %dMB cache memory, %s\n", + aac_describe_code(aac_cpu_variant, info->CpuVariant), + info->ClockSpeed, info->BufferMem / (1024 * 1024), + aac_describe_code(aac_battery_platform, + info->batteryPlatform)); - /* save the kernel revision structure for later use */ - sc->aac_revision = info->KernelRevision; - device_printf(sc->aac_dev, "Kernel %d.%d-%d, Build %d, S/N %6X\n", - info->KernelRevision.external.comp.major, - info->KernelRevision.external.comp.minor, - info->KernelRevision.external.comp.dash, - info->KernelRevision.buildNumber, - (u_int32_t)(info->SerialNumber & 0xffffff)); + /* save the kernel revision structure for later use */ + sc->aac_revision = info->KernelRevision; + device_printf(sc->aac_dev, "Kernel %d.%d-%d, Build %d, S/N %6X\n", + info->KernelRevision.external.comp.major, + info->KernelRevision.external.comp.minor, + info->KernelRevision.external.comp.dash, + info->KernelRevision.buildNumber, + (u_int32_t)(info->SerialNumber & 0xffffff)); } -/****************************************************************************** +/* * Look up a text description of a numeric error code and return a pointer to * same. */ static char * aac_describe_code(struct aac_code_lookup *table, u_int32_t code) { - int i; + int i; - for (i = 0; table[i].string != NULL; i++) - if (table[i].code == code) - return(table[i].string); - return(table[i + 1].string); + for (i = 0; table[i].string != NULL; i++) + if (table[i].code == code) + return(table[i].string); + return(table[i + 1].string); } -/***************************************************************************** - ***************************************************************************** - Management Interface - ***************************************************************************** - *****************************************************************************/ +/* + * Management Interface + */ static int aac_open(dev_t dev, int flags, int fmt, struct proc *p) { - struct aac_softc *sc = dev->si_drv1; + struct aac_softc *sc; - debug_called(2); + debug_called(2); - /* Check to make sure the device isn't already open */ - if (sc->aac_state & AAC_STATE_OPEN) { - return EBUSY; - } - sc->aac_state |= AAC_STATE_OPEN; + sc = dev->si_drv1; - return 0; + /* Check to make sure the device isn't already open */ + if (sc->aac_state & AAC_STATE_OPEN) { + return EBUSY; + } + sc->aac_state |= AAC_STATE_OPEN; + + return 0; } static int aac_close(dev_t dev, int flags, int fmt, struct proc *p) { - struct aac_softc *sc = dev->si_drv1; + struct aac_softc *sc; - debug_called(2); + debug_called(2); - /* Mark this unit as no longer open */ - sc->aac_state &= ~AAC_STATE_OPEN; + sc = dev->si_drv1; - return 0; + /* Mark this unit as no longer open */ + sc->aac_state &= ~AAC_STATE_OPEN; + + return 0; } static int aac_ioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p) { - union aac_statrequest *as = (union aac_statrequest *)arg; - struct aac_softc *sc = dev->si_drv1; - int error = 0; - int i; + union aac_statrequest *as; + struct aac_softc *sc; + int error = 0; + int i; - debug_called(2); + debug_called(2); - switch (cmd) { - case AACIO_STATS: - switch (as->as_item) { - case AACQ_FREE: - case AACQ_BIO: - case AACQ_READY: - case AACQ_BUSY: - case AACQ_COMPLETE: - bcopy(&sc->aac_qstat[as->as_item], &as->as_qstat, - sizeof(struct aac_qstat)); - break; - default: - error = ENOENT; - break; - } + as = (union aac_statrequest *)arg; + sc = dev->si_drv1; + + switch (cmd) { + case AACIO_STATS: + switch (as->as_item) { + case AACQ_FREE: + case AACQ_BIO: + case AACQ_READY: + case AACQ_BUSY: + case AACQ_COMPLETE: + bcopy(&sc->aac_qstat[as->as_item], &as->as_qstat, + sizeof(struct aac_qstat)); + break; + default: + error = ENOENT; + break; + } break; - case FSACTL_SENDFIB: - arg = *(caddr_t*)arg; - case FSACTL_LNX_SENDFIB: - debug(1, "FSACTL_SENDFIB"); - error = aac_ioctl_sendfib(sc, arg); - break; - case FSACTL_AIF_THREAD: - case FSACTL_LNX_AIF_THREAD: - debug(1, "FSACTL_AIF_THREAD"); - error = EINVAL; - break; - case FSACTL_OPEN_GET_ADAPTER_FIB: - 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. - */ - i = (int)sc->aifthread; - error = copyout(&i, arg, sizeof(i)); - break; - case FSACTL_GET_NEXT_ADAPTER_FIB: - arg = *(caddr_t*)arg; - case FSACTL_LNX_GET_NEXT_ADAPTER_FIB: - debug(1, "FSACTL_GET_NEXT_ADAPTER_FIB"); - error = aac_getnext_aif(sc, arg); - break; - case FSACTL_CLOSE_GET_ADAPTER_FIB: - case FSACTL_LNX_CLOSE_GET_ADAPTER_FIB: - debug(1, "FSACTL_CLOSE_GET_ADAPTER_FIB"); - /* don't do anything here */ - break; - case FSACTL_MINIPORT_REV_CHECK: - arg = *(caddr_t*)arg; - case FSACTL_LNX_MINIPORT_REV_CHECK: - debug(1, "FSACTL_MINIPORT_REV_CHECK"); - error = aac_rev_check(sc, arg); - break; - case FSACTL_QUERY_DISK: - arg = *(caddr_t*)arg; - case FSACTL_LNX_QUERY_DISK: - debug(1, "FSACTL_QUERY_DISK"); - error = aac_query_disk(sc, arg); - break; - case FSACTL_DELETE_DISK: - case FSACTL_LNX_DELETE_DISK: - error = 0; - break; - default: - device_printf(sc->aac_dev, "unsupported cmd 0x%lx\n", cmd); - error = EINVAL; - break; - } - return(error); + case FSACTL_SENDFIB: + arg = *(caddr_t*)arg; + case FSACTL_LNX_SENDFIB: + debug(1, "FSACTL_SENDFIB"); + error = aac_ioctl_sendfib(sc, arg); + break; + case FSACTL_AIF_THREAD: + case FSACTL_LNX_AIF_THREAD: + debug(1, "FSACTL_AIF_THREAD"); + error = EINVAL; + break; + case FSACTL_OPEN_GET_ADAPTER_FIB: + 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. + */ + i = (int)sc->aifthread; + error = copyout(&i, arg, sizeof(i)); + break; + case FSACTL_GET_NEXT_ADAPTER_FIB: + arg = *(caddr_t*)arg; + case FSACTL_LNX_GET_NEXT_ADAPTER_FIB: + debug(1, "FSACTL_GET_NEXT_ADAPTER_FIB"); + error = aac_getnext_aif(sc, arg); + break; + case FSACTL_CLOSE_GET_ADAPTER_FIB: + case FSACTL_LNX_CLOSE_GET_ADAPTER_FIB: + debug(1, "FSACTL_CLOSE_GET_ADAPTER_FIB"); + /* don't do anything here */ + break; + case FSACTL_MINIPORT_REV_CHECK: + arg = *(caddr_t*)arg; + case FSACTL_LNX_MINIPORT_REV_CHECK: + debug(1, "FSACTL_MINIPORT_REV_CHECK"); + error = aac_rev_check(sc, arg); + break; + case FSACTL_QUERY_DISK: + arg = *(caddr_t*)arg; + case FSACTL_LNX_QUERY_DISK: + debug(1, "FSACTL_QUERY_DISK"); + error = aac_query_disk(sc, arg); + break; + case FSACTL_DELETE_DISK: + case FSACTL_LNX_DELETE_DISK: + /* + * We don't trust the underland to tell us when to delete a + * container, rather we rely on an AIF coming from the + * controller + */ + error = 0; + break; + default: + device_printf(sc->aac_dev, "unsupported cmd 0x%lx\n", cmd); + error = EINVAL; + break; + } + return(error); } -/****************************************************************************** +/* * Send a FIB supplied from userspace */ static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib) { - struct aac_command *cm; - int size, error; + struct aac_command *cm; + int size, error; - debug_called(2); + debug_called(2); - cm = NULL; + cm = NULL; - /* - * Get a command - */ - if (aac_alloc_command(sc, &cm)) { - error = EBUSY; - goto out; - } + /* + * Get a command + */ + if (aac_alloc_command(sc, &cm)) { + error = EBUSY; + goto out; + } - /* - * Fetch the FIB header, then re-copy to get data as well. - */ - if ((error = copyin(ufib, cm->cm_fib, sizeof(struct aac_fib_header))) != 0) - goto out; - size = cm->cm_fib->Header.Size + sizeof(struct aac_fib_header); - if (size > sizeof(struct aac_fib)) { - device_printf(sc->aac_dev, "incoming FIB oversized (%d > %d)\n", size, - sizeof(struct aac_fib)); - size = sizeof(struct aac_fib); - } - if ((error = copyin(ufib, cm->cm_fib, size)) != 0) - goto out; - cm->cm_fib->Header.Size = size; - cm->cm_timestamp = time_second; + /* + * Fetch the FIB header, then re-copy to get data as well. + */ + if ((error = copyin(ufib, cm->cm_fib, + sizeof(struct aac_fib_header))) != 0) + goto out; + size = cm->cm_fib->Header.Size + sizeof(struct aac_fib_header); + if (size > sizeof(struct aac_fib)) { + device_printf(sc->aac_dev, "incoming FIB oversized (%d > %d)\n", + size, sizeof(struct aac_fib)); + size = sizeof(struct aac_fib); + } + if ((error = copyin(ufib, cm->cm_fib, size)) != 0) + goto out; + cm->cm_fib->Header.Size = size; + cm->cm_timestamp = time_second; - /* - * Pass the FIB to the controller, wait for it to complete. - */ - if ((error = aac_wait_command(cm, 30)) != 0) /* XXX user timeout? */ - goto out; + /* + * Pass the FIB to the controller, wait for it to complete. + */ + if ((error = aac_wait_command(cm, 30)) != 0) /* XXX user timeout? */ + goto out; - /* - * Copy the FIB and data back out to the caller. - */ - size = cm->cm_fib->Header.Size; - if (size > sizeof(struct aac_fib)) { - device_printf(sc->aac_dev, "outbound FIB oversized (%d > %d)\n", size, - sizeof(struct aac_fib)); - size = sizeof(struct aac_fib); - } - error = copyout(cm->cm_fib, ufib, size); + /* + * Copy the FIB and data back out to the caller. + */ + size = cm->cm_fib->Header.Size; + if (size > sizeof(struct aac_fib)) { + device_printf(sc->aac_dev, "outbound FIB oversized (%d > %d)\n", + size, sizeof(struct aac_fib)); + size = sizeof(struct aac_fib); + } + error = copyout(cm->cm_fib, ufib, size); out: - if (cm != NULL) { - aac_release_command(cm); - } - return(error); + if (cm != NULL) { + aac_release_command(cm); + } + return(error); } -/****************************************************************************** +/* * Handle an AIF sent to us by the controller; queue it for later reference. * If the queue fills up, then drop the older entries. */ static void aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib) { - device_t child; - struct aac_aif_command *aif; - struct aac_container *co, *co_next; - struct aac_mntinfo mi; - struct aac_mntinforesponse mir; - u_int16_t rsize; - int next, s, found; - int added = 0, i = 0; + struct aac_aif_command *aif; + struct aac_container *co, *co_next; + struct aac_mntinfo mi; + struct aac_mntinforesponse mir; + u_int16_t rsize; + int next, s, found; + int added = 0, i = 0; - debug_called(2); + debug_called(2); - aif = (struct aac_aif_command*)&fib->data[0]; - aac_print_aif(sc, aif); + aif = (struct aac_aif_command*)&fib->data[0]; + aac_print_aif(sc, aif); - /* Is it an event that we should care about? */ - switch (aif->command) { - case AifCmdEventNotify: - switch (aif->data.EN.type) { - case AifEnAddContainer: - case AifEnDeleteContainer: - /* - * A container was added or deleted, but the message doesn't tell us - * anything else! Re-enumerate the containers and sort things out. - */ - mi.Command = VM_NameServe; - mi.MntType = FT_FILESYS; - do { - /* - * Ask the controller for its containers one at a time. - * XXX What if the controller's list changes midway through - * this enumaration? - * XXX This should be done async. - */ - mi.MntCount = i; - rsize = sizeof(mir); - if (aac_sync_fib(sc, ContainerCommand, 0, &mi, sizeof(mi), - &mir, &rsize)) { - debug(2, "Error probing container %d\n", i); - continue; - } - if (rsize != sizeof(mir)) { - debug(2, "Container response size too large\n"); - continue; - } - /* - * Check the container against our list. co->co_found - * was already set to 0 in a previous run. - */ - if ((mir.Status == ST_OK) && (mir.MntTable[0].VolType != - CT_NONE)) { - found = 0; - TAILQ_FOREACH(co, &sc->aac_container_tqh, co_link) { - if (co->co_mntobj.ObjectId == - mir.MntTable[0].ObjectId) { - co->co_found = 1; - found = 1; - break; + /* Is it an event that we should care about? */ + switch (aif->command) { + case AifCmdEventNotify: + switch (aif->data.EN.type) { + case AifEnAddContainer: + case AifEnDeleteContainer: + /* + * A container was added or deleted, but the message + * doesn't tell us anything else! Re-enumerate the + * containers and sort things out. + */ + mi.Command = VM_NameServe; + mi.MntType = FT_FILESYS; + do { + /* + * Ask the controller for its containers one at + * a time. + * XXX What if the controller's list changes + * midway through this enumaration? + * XXX This should be done async. + */ + mi.MntCount = i; + rsize = sizeof(mir); + if (aac_sync_fib(sc, ContainerCommand, 0, &mi, + sizeof(mi), &mir, &rsize)) { + debug(2, "Error probing container %d\n", + i); + continue; + } + if (rsize != sizeof(mir)) { + debug(2, "Container response size too " + "large\n"); + continue; + } + /* + * Check the container against our list. + * co->co_found was already set to 0 in a + * previous run. + */ + if ((mir.Status == ST_OK) && + (mir.MntTable[0].VolType != CT_NONE)) { + found = 0; + TAILQ_FOREACH(co, + &sc->aac_container_tqh, + co_link) { + if (co->co_mntobj.ObjectId == + mir.MntTable[0].ObjectId) { + co->co_found = 1; + found = 1; + break; + } + } + /* + * If the container matched, continue + * in the list. + */ + if (found) { + i++; + continue; + } + + /* + * This is a new container. Do all the + * appropriate things to set it up. */ + aac_add_container(sc, &mir, 1); + added = 1; + } + i++; + } while ((i < mir.MntRespCount) && + (i < AAC_MAX_CONTAINERS)); + + /* + * Go through our list of containers and see which ones + * were not marked 'found'. Since the controller didn't + * list them they must have been deleted. Do the + * appropriate steps to destroy the device. Also reset + * the co->co_found field. + */ + co = TAILQ_FIRST(&sc->aac_container_tqh); + while (co != NULL) { + if (co->co_found == 0) { + device_delete_child(sc->aac_dev, + co->co_disk); + co_next = TAILQ_NEXT(co, co_link); + AAC_LOCK_AQUIRE(&sc-> + aac_container_lock); + TAILQ_REMOVE(&sc->aac_container_tqh, co, + co_link); + AAC_LOCK_RELEASE(&sc-> + aac_container_lock); + FREE(co, M_AACBUF); + co = co_next; + } else { + co->co_found = 0; + co = TAILQ_NEXT(co, co_link); + } } - } - /* If the container matched, continue on in the list */ - if (found) { - i++; - continue; - } - /* - * This is a new container. Do all the appropriate things - * to set it up. - */ - MALLOC(co, struct aac_container *, sizeof *co, M_AACBUF, - M_WAITOK); - if ((child = device_add_child(sc->aac_dev, NULL, -1)) == - NULL) { - device_printf(sc->aac_dev, "device_add_child failed\n"); - } else { - device_set_ivars(child, co); - } - device_set_desc(child, - aac_describe_code(aac_container_types, - mir.MntTable[0].VolType)); - co->co_disk = child; - co->co_found = 1; - bcopy(&mir.MntTable[0], &co->co_mntobj, - sizeof(struct aac_mntobj)); - AAC_LOCK_AQUIRE(&sc->aac_container_lock); - TAILQ_INSERT_HEAD(&sc->aac_container_tqh, co, co_link); - AAC_LOCK_RELEASE(&sc->aac_container_lock); - added = 1; + /* Attach the newly created containers */ + if (added) + bus_generic_attach(sc->aac_dev); + + break; + + default: + break; } - i++; - } while ((i < mir.MntRespCount) && (i < AAC_MAX_CONTAINERS)); - - /* - * Go through our list of containers and see which ones were - * not marked 'found'. Since the controller didn't list them - * they must have been deleted. Do the appropriate steps to - * destroy the device. Also reset the co->co_found field. - */ - co = TAILQ_FIRST(&sc->aac_container_tqh); - while (co != NULL) { - if (co->co_found == 0) { - device_delete_child(sc->aac_dev, co->co_disk); - co_next = TAILQ_NEXT(co, co_link); - AAC_LOCK_AQUIRE(&sc->aac_container_lock); - TAILQ_REMOVE(&sc->aac_container_tqh, co, co_link); - AAC_LOCK_RELEASE(&sc->aac_container_lock); - FREE(co, M_AACBUF); - co = co_next; - } else { - co->co_found = 0; - co = TAILQ_NEXT(co, co_link); - } - } - - /* Attach the newly created containers */ - if (added) - bus_generic_attach(sc->aac_dev); - - break; default: - break; + break; } - default: - break; - } - - /* Copy the AIF data to the AIF queue for ioctl retrieval */ - s = splbio(); - 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)); + /* Copy the AIF data to the AIF queue for ioctl retrieval */ + s = splbio(); + 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; if (sc->aac_state & AAC_STATE_AIF_SLEEPER) - wakeup(sc->aac_aifq); - } - splx(s); + wakeup(sc->aac_aifq); + } + splx(s); - return; + return; } -/****************************************************************************** - ****************************************************************************** - Linux Management Interface - ****************************************************************************** - ******************************************************************************/ +/* + * Linux Management Interface + * This is soon to be removed! + */ #ifdef AAC_COMPAT_LINUX @@ -2332,6 +2410,7 @@ aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib) #include #include +/* There are multiple ioctl number ranges that need to be handled */ #define AAC_LINUX_IOCTL_MIN 0x0000 #define AAC_LINUX_IOCTL_MAX 0x21ff @@ -2350,19 +2429,23 @@ MODULE_DEPEND(aac, linux, 1, 1, 1); static int aac_linux_ioctl(struct proc *p, struct linux_ioctl_args *args) { - struct file *fp = p->p_fd->fd_ofiles[args->fd]; - u_long cmd = args->cmd; + struct file *fp; + u_long cmd; - debug_called(2); - /* - * Pass the ioctl off to our standard handler. - */ - return(fo_ioctl(fp, cmd, (caddr_t)args->arg, p)); + debug_called(2); + + fp = p->p_fd->fd_ofiles[args->fd]; + cmd = args->cmd; + + /* + * Pass the ioctl off to our standard handler. + */ + return(fo_ioctl(fp, cmd, (caddr_t)args->arg, p)); } #endif -/****************************************************************************** +/* * Return the Revision of the driver to userspace and check to see if the * userspace app is possibly compatible. This is extremely bogus since * our driver doesn't follow Adaptec's versioning system. Cheat by just @@ -2371,97 +2454,103 @@ aac_linux_ioctl(struct proc *p, struct linux_ioctl_args *args) static int aac_rev_check(struct aac_softc *sc, caddr_t udata) { - struct aac_rev_check rev_check; - struct aac_rev_check_resp rev_check_resp; - int error = 0; + struct aac_rev_check rev_check; + struct aac_rev_check_resp rev_check_resp; + int error = 0; - debug_called(2); + debug_called(2); - /* - * Copyin the revision struct from userspace - */ - if ((error = copyin(udata, (caddr_t)&rev_check, + /* + * Copyin the revision struct from userspace + */ + if ((error = copyin(udata, (caddr_t)&rev_check, sizeof(struct aac_rev_check))) != 0) { - return error; - } + return error; + } - debug(2, "Userland revision= %d\n", rev_check.callingRevision.buildNumber); + debug(2, "Userland revision= %d\n", + rev_check.callingRevision.buildNumber); - /* - * Doctor up the response struct. - */ - rev_check_resp.possiblyCompatible = 1; - rev_check_resp.adapterSWRevision.external.ul = sc->aac_revision.external.ul; - rev_check_resp.adapterSWRevision.buildNumber = sc->aac_revision.buildNumber; + /* + * Doctor up the response struct. + */ + rev_check_resp.possiblyCompatible = 1; + rev_check_resp.adapterSWRevision.external.ul = + sc->aac_revision.external.ul; + rev_check_resp.adapterSWRevision.buildNumber = + sc->aac_revision.buildNumber; - return(copyout((caddr_t)&rev_check_resp, udata, - sizeof(struct aac_rev_check_resp))); + return(copyout((caddr_t)&rev_check_resp, udata, + sizeof(struct aac_rev_check_resp))); } -/****************************************************************************** +/* * 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; - int error, s; + struct get_adapter_fib_ioctl agf; + int error, s; - debug_called(2); + debug_called(2); - if ((error = copyin(arg, &agf, sizeof(agf))) == 0) { + if ((error = copyin(arg, &agf, sizeof(agf))) == 0) { - /* - * Check the magic number that we gave the caller. - */ - if (agf.AdapterFibContext != (int)sc->aifthread) { - error = EFAULT; - } else { - - s = splbio(); - error = aac_return_aif(sc, agf.AifFib); - - if ((error == EAGAIN) && (agf.Wait)) { - sc->aac_state |= AAC_STATE_AIF_SLEEPER; - while (error == EAGAIN) { - error = tsleep(sc->aac_aifq, PRIBIO | PCATCH, "aacaif", 0); - if (error == 0) + /* + * Check the magic number that we gave the caller. + */ + if (agf.AdapterFibContext != (int)sc->aifthread) { + error = EFAULT; + } else { + + s = splbio(); error = aac_return_aif(sc, agf.AifFib); + + if ((error == EAGAIN) && (agf.Wait)) { + 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); + } + sc->aac_state &= ~AAC_STATE_AIF_SLEEPER; + } + splx(s); } - sc->aac_state &= ~AAC_STATE_AIF_SLEEPER; - } - splx(s); } - } - return(error); + return(error); } -/****************************************************************************** +/* * 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) { - int error, s; + int error, s; - debug_called(2); + debug_called(2); - s = splbio(); - if (sc->aac_aifq_tail == sc->aac_aifq_head) { - error = EAGAIN; - } else { - error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, - sizeof(struct aac_aif_command)); - if (error) - printf("aac_return_aif: copyout returned %d\n", error); - if (!error) - sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % AAC_AIFQ_LENGTH; - } - splx(s); - return(error); + s = splbio(); + if (sc->aac_aifq_tail == sc->aac_aifq_head) { + error = EAGAIN; + } else { + error = copyout(&sc->aac_aifq[sc->aac_aifq_tail], uptr, + sizeof(struct aac_aif_command)); + if (error) + printf("aac_return_aif: copyout returned %d\n", error); + if (!error) + sc->aac_aifq_tail = (sc->aac_aifq_tail + 1) % + AAC_AIFQ_LENGTH; + } + splx(s); + return(error); } -/****************************************************************************** +/* * Give the userland some information about the container. The AAC arch * expects the driver to be a SCSI passthrough type driver, so it expects * the containers to have b:t:l numbers. Fake it. @@ -2469,46 +2558,52 @@ aac_return_aif(struct aac_softc *sc, caddr_t uptr) static int aac_query_disk(struct aac_softc *sc, caddr_t uptr) { - struct aac_query_disk query_disk; - struct aac_container *co; - struct aac_disk *disk = NULL; - int error, id; + struct aac_query_disk query_disk; + struct aac_container *co; + struct aac_disk *disk; + int error, id; - debug_called(2); + debug_called(2); + + disk = NULL; + + error = copyin(uptr, (caddr_t)&query_disk, + sizeof(struct aac_query_disk)); + if (error) + return (error); + + id = query_disk.ContainerNumber; + if (id == -1) + return (EINVAL); + + AAC_LOCK_AQUIRE(&sc->aac_container_lock); + TAILQ_FOREACH(co, &sc->aac_container_tqh, co_link) { + if (co->co_mntobj.ObjectId == id) + break; + } + + if (co == NULL) { + query_disk.Valid = 0; + query_disk.Locked = 0; + query_disk.Deleted = 1; /* XXX is this right? */ + } else { + disk = device_get_softc(co->co_disk); + query_disk.Valid = 1; + query_disk.Locked = + (disk->ad_flags & AAC_DISK_OPEN) ? 1 : 0; + query_disk.Deleted = 0; + query_disk.Bus = 0; + query_disk.Target = disk->unit; + query_disk.Lun = 0; + query_disk.UnMapped = 0; + bcopy(disk->ad_dev_t->si_name, + &query_disk.diskDeviceName[0], 10); + } + AAC_LOCK_RELEASE(&sc->aac_container_lock); + + error = copyout((caddr_t)&query_disk, uptr, + sizeof(struct aac_query_disk)); - error = copyin(uptr, (caddr_t)&query_disk, sizeof(struct aac_query_disk)); - if (error) return (error); - - id = query_disk.ContainerNumber; - if (id == -1) - return (EINVAL); - - AAC_LOCK_AQUIRE(&sc->aac_container_lock); - TAILQ_FOREACH(co, &sc->aac_container_tqh, co_link) { - if (co->co_mntobj.ObjectId == id) - break; - } - - if (co == NULL) { - query_disk.Valid = 0; - query_disk.Locked = 0; - query_disk.Deleted = 1; /* XXX is this right? */ - } else { - disk = device_get_softc(co->co_disk); - query_disk.Valid = 1; - query_disk.Locked = (disk->ad_flags & AAC_DISK_OPEN) ? 1 : 0; - query_disk.Deleted = 0; - query_disk.Bus = 0; - query_disk.Target = disk->unit; - query_disk.Lun = 0; - query_disk.UnMapped = 0; - bcopy(disk->ad_dev_t->si_name, &query_disk.diskDeviceName[0], 10); - } - AAC_LOCK_RELEASE(&sc->aac_container_lock); - - error = copyout((caddr_t)&query_disk, uptr, sizeof(struct aac_query_disk)); - - return (error); } diff --git a/sys/dev/aac/aac_compat.h b/sys/dev/aac/aac_compat.h index 5c3ab8bc0915..ef61c0a36503 100644 --- a/sys/dev/aac/aac_compat.h +++ b/sys/dev/aac/aac_compat.h @@ -35,30 +35,30 @@ */ #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) +#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) +#include +#define BIO_IS_READ(x) ((x)->bio_cmd == BIO_READ) #endif diff --git a/sys/dev/aac/aac_debug.c b/sys/dev/aac/aac_debug.c index 1db2d50e5706..71c5bdcf095c 100644 --- a/sys/dev/aac/aac_debug.c +++ b/sys/dev/aac/aac_debug.c @@ -51,443 +51,497 @@ #include #ifdef AAC_DEBUG -void aac_printstate0(void); -void aac_intr0(void); +void aac_printstate0(void); +void aac_intr0(void); -/****************************************************************************** +/* * Dump the command queue indices */ void aac_print_queues(struct aac_softc *sc) { - device_printf(sc->aac_dev, "FIB queue header at %p queues at %p\n", - &sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][0], - &sc->aac_queues->qt_HostNormCmdQueue[0]); - device_printf(sc->aac_dev, "HOST_NORM_CMD %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX], - AAC_HOST_NORM_CMD_ENTRIES); - device_printf(sc->aac_dev, "HOST_HIGH_CMD %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX], - AAC_HOST_HIGH_CMD_ENTRIES); - device_printf(sc->aac_dev, "ADAP_NORM_CMD %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][AAC_CONSUMER_INDEX], - AAC_ADAP_NORM_CMD_ENTRIES); - device_printf(sc->aac_dev, "ADAP_HIGH_CMD %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][AAC_CONSUMER_INDEX], - AAC_ADAP_HIGH_CMD_ENTRIES); - device_printf(sc->aac_dev, "HOST_NORM_RESP %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX], - AAC_HOST_NORM_RESP_ENTRIES); - device_printf(sc->aac_dev, "HOST_HIGH_RESP %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX], - AAC_HOST_HIGH_RESP_ENTRIES); - device_printf(sc->aac_dev, "ADAP_NORM_RESP %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][AAC_CONSUMER_INDEX], - AAC_ADAP_NORM_RESP_ENTRIES); - device_printf(sc->aac_dev, "ADAP_HIGH_RESP %d/%d (%d)\n", - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_PRODUCER_INDEX], - sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][AAC_CONSUMER_INDEX], - AAC_ADAP_HIGH_RESP_ENTRIES); - device_printf(sc->aac_dev, "AACQ_FREE %d/%d\n", - sc->aac_qstat[AACQ_FREE].q_length, sc->aac_qstat[AACQ_FREE].q_max); - device_printf(sc->aac_dev, "AACQ_BIO %d/%d\n", - sc->aac_qstat[AACQ_BIO].q_length, sc->aac_qstat[AACQ_BIO].q_max); - device_printf(sc->aac_dev, "AACQ_READY %d/%d\n", - sc->aac_qstat[AACQ_READY].q_length, sc->aac_qstat[AACQ_READY].q_max); - device_printf(sc->aac_dev, "AACQ_BUSY %d/%d\n", - sc->aac_qstat[AACQ_BUSY].q_length, sc->aac_qstat[AACQ_BUSY].q_max); - device_printf(sc->aac_dev, "AACQ_COMPLETE %d/%d\n", - sc->aac_qstat[AACQ_COMPLETE].q_length, - sc->aac_qstat[AACQ_COMPLETE].q_max); + device_printf(sc->aac_dev, "FIB queue header at %p queues at %p\n", + &sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][0], + &sc->aac_queues->qt_HostNormCmdQueue[0]); + device_printf(sc->aac_dev, "HOST_NORM_CMD %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_HOST_NORM_CMD_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_HOST_NORM_CMD_ENTRIES); + device_printf(sc->aac_dev, "HOST_HIGH_CMD %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_CMD_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_HOST_HIGH_CMD_ENTRIES); + device_printf(sc->aac_dev, "ADAP_NORM_CMD %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_CMD_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_ADAP_NORM_CMD_ENTRIES); + device_printf(sc->aac_dev, "ADAP_HIGH_CMD %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_CMD_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_ADAP_HIGH_CMD_ENTRIES); + device_printf(sc->aac_dev, "HOST_NORM_RESP %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_HOST_NORM_RESP_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_HOST_NORM_RESP_ENTRIES); + device_printf(sc->aac_dev, "HOST_HIGH_RESP %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_HOST_HIGH_RESP_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_HOST_HIGH_RESP_ENTRIES); + device_printf(sc->aac_dev, "ADAP_NORM_RESP %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_ADAP_NORM_RESP_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_ADAP_NORM_RESP_ENTRIES); + device_printf(sc->aac_dev, "ADAP_HIGH_RESP %d/%d (%d)\n", + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][ + AAC_PRODUCER_INDEX], + sc->aac_queues->qt_qindex[AAC_ADAP_HIGH_RESP_QUEUE][ + AAC_CONSUMER_INDEX], + AAC_ADAP_HIGH_RESP_ENTRIES); + device_printf(sc->aac_dev, "AACQ_FREE %d/%d\n", + sc->aac_qstat[AACQ_FREE].q_length, sc->aac_qstat[AACQ_FREE].q_max); + device_printf(sc->aac_dev, "AACQ_BIO %d/%d\n", + sc->aac_qstat[AACQ_BIO].q_length, sc->aac_qstat[AACQ_BIO].q_max); + device_printf(sc->aac_dev, "AACQ_READY %d/%d\n", + sc->aac_qstat[AACQ_READY].q_length, + sc->aac_qstat[AACQ_READY].q_max); + device_printf(sc->aac_dev, "AACQ_BUSY %d/%d\n", + sc->aac_qstat[AACQ_BUSY].q_length, sc->aac_qstat[AACQ_BUSY].q_max); + device_printf(sc->aac_dev, "AACQ_COMPLETE %d/%d\n", + sc->aac_qstat[AACQ_COMPLETE].q_length, + sc->aac_qstat[AACQ_COMPLETE].q_max); } -/****************************************************************************** +/* * Print the command queue states for controller 0 (callable from DDB) */ void aac_printstate0(void) { - struct aac_softc *sc = devclass_get_softc(aac_devclass, 0); + struct aac_softc *sc; - aac_print_queues(sc); - switch (sc->aac_hwif) { - case AAC_HWIF_I960RX: - device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x IISR 0x%08x\n", - AAC_GETREG4(sc, AAC_RX_IDBR), AAC_GETREG4(sc, AAC_RX_IIMR), - AAC_GETREG4(sc, AAC_RX_IISR)); - device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x OISR 0x%08x\n", - AAC_GETREG4(sc, AAC_RX_ODBR), AAC_GETREG4(sc, AAC_RX_OIMR), - AAC_GETREG4(sc, AAC_RX_OISR)); - AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | - AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/); - device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x OISR 0x%08x\n", - AAC_GETREG4(sc, AAC_RX_ODBR), AAC_GETREG4(sc, AAC_RX_OIMR), - AAC_GETREG4(sc, AAC_RX_OISR)); - break; - case AAC_HWIF_STRONGARM: - /* XXX implement */ - } + sc = devclass_get_softc(aac_devclass, 0); + + aac_print_queues(sc); + switch (sc->aac_hwif) { + case AAC_HWIF_I960RX: + device_printf(sc->aac_dev, "IDBR 0x%08x IIMR 0x%08x " + "IISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_IDBR), + AAC_GETREG4(sc, AAC_RX_IIMR), AAC_GETREG4(sc, AAC_RX_IISR)); + device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " + "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), + AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); + AAC_SETREG4(sc, AAC_RX_OIMR, 0/*~(AAC_DB_COMMAND_READY | + AAC_DB_RESPONSE_READY | AAC_DB_PRINTF)*/); + device_printf(sc->aac_dev, "ODBR 0x%08x OIMR 0x%08x " + "OISR 0x%08x\n", AAC_GETREG4(sc, AAC_RX_ODBR), + AAC_GETREG4(sc, AAC_RX_OIMR), AAC_GETREG4(sc, AAC_RX_OISR)); + break; + case AAC_HWIF_STRONGARM: + /* XXX implement */ + } } -/****************************************************************************** +/* * simulate an interrupt for controller 0 */ void aac_intr0(void) { - struct aac_softc *sc = devclass_get_softc(aac_devclass, 0); + struct aac_softc *sc; - aac_intr(sc); + sc = devclass_get_softc(aac_devclass, 0); + + aac_intr(sc); } -/****************************************************************************** +/* * Panic in a slightly informative fashion */ void aac_panic(struct aac_softc *sc, char *reason) { - aac_print_queues(sc); - panic(reason); + aac_print_queues(sc); + panic(reason); } -/****************************************************************************** +/* * Print a FIB */ void aac_print_fib(struct aac_softc *sc, struct aac_fib *fib, char *caller) { - device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib); - device_printf(sc->aac_dev, " XferState %b\n", fib->Header.XferState, "\20" - "\1HOSTOWNED" - "\2ADAPTEROWNED" - "\3INITIALISED" - "\4EMPTY" - "\5FROMPOOL" - "\6FROMHOST" - "\7FROMADAP" - "\10REXPECTED" - "\11RNOTEXPECTED" - "\12DONEADAP" - "\13DONEHOST" - "\14HIGH" - "\15NORM" - "\16ASYNC" - "\17PAGEFILEIO" - "\20SHUTDOWN" - "\21LAZYWRITE" - "\22ADAPMICROFIB" - "\23BIOSFIB" - "\24FAST_RESPONSE" - "\25APIFIB\n"); - device_printf(sc->aac_dev, " Command %d\n", fib->Header.Command); - device_printf(sc->aac_dev, " StructType %d\n", - fib->Header.StructType); - device_printf(sc->aac_dev, " Flags 0x%x\n", fib->Header.Flags); - device_printf(sc->aac_dev, " Size %d\n", fib->Header.Size); - device_printf(sc->aac_dev, " SenderSize %d\n", - fib->Header.SenderSize); - device_printf(sc->aac_dev, " SenderAddress 0x%x\n", - fib->Header.SenderFibAddress); - device_printf(sc->aac_dev, " ReceiverAddress 0x%x\n", - fib->Header.ReceiverFibAddress); - device_printf(sc->aac_dev, " SenderData 0x%x\n", - fib->Header.SenderData); - switch(fib->Header.Command) { - case ContainerCommand: - { - struct aac_blockread *br = (struct aac_blockread *)fib->data; - struct aac_blockwrite *bw = (struct aac_blockwrite *)fib->data; - struct aac_sg_table *sg = NULL; - int i; - if (br->Command == VM_CtBlockRead) { - device_printf(sc->aac_dev, " BlockRead: container %d 0x%x/%d\n", - br->ContainerId, br->BlockNumber, br->ByteCount); - sg = &br->SgMap; + device_printf(sc->aac_dev, "%s: FIB @ %p\n", caller, fib); + device_printf(sc->aac_dev, " XferState %b\n", fib->Header.XferState, + "\20" + "\1HOSTOWNED" + "\2ADAPTEROWNED" + "\3INITIALISED" + "\4EMPTY" + "\5FROMPOOL" + "\6FROMHOST" + "\7FROMADAP" + "\10REXPECTED" + "\11RNOTEXPECTED" + "\12DONEADAP" + "\13DONEHOST" + "\14HIGH" + "\15NORM" + "\16ASYNC" + "\17PAGEFILEIO" + "\20SHUTDOWN" + "\21LAZYWRITE" + "\22ADAPMICROFIB" + "\23BIOSFIB" + "\24FAST_RESPONSE" + "\25APIFIB\n"); + device_printf(sc->aac_dev, " Command %d\n", fib->Header.Command); + device_printf(sc->aac_dev, " StructType %d\n", + fib->Header.StructType); + device_printf(sc->aac_dev, " Flags 0x%x\n", fib->Header.Flags); + device_printf(sc->aac_dev, " Size %d\n", fib->Header.Size); + device_printf(sc->aac_dev, " SenderSize %d\n",xi + fib->Header.SenderSize); + device_printf(sc->aac_dev, " SenderAddress 0x%x\n", + fib->Header.SenderFibAddress); + device_printf(sc->aac_dev, " RcvrAddress 0x%x\n", + fib->Header.ReceiverFibAddress); + device_printf(sc->aac_dev, " SenderData 0x%x\n", + fib->Header.SenderData); + switch(fib->Header.Command) { + case ContainerCommand: + { + struct aac_blockread *br; + struct aac_blockwrite *br; + struct aac_sg_table *sg; + int i; + + br = (struct aac_blockread*)fib->data; + bw = (struct aac_blockwrite*)fib->data; + sg = NULL; + + if (br->Command == VM_CtBlockRead) { + device_printf(sc->aac_dev, + " BlockRead: container %d 0x%x/%d\n", + br->ContainerId, br->BlockNumber, + br->ByteCount); + sg = &br->SgMap; + } + if (bw->Command == VM_CtBlockWrite) { + device_printf(sc->aac_dev, + " BlockWrite: container %d 0x%x/%d " + "(%s)\n", bw->ContainerId, + bw->BlockNumber, bw->ByteCount, + bw->Stable == CSTABLE ? "stable" : + "unstable"); + sg = &bw->SgMap; + } + if (sg != NULL) { + device_printf(sc->aac_dev, + " %d s/g entries\n", sg->SgCount); + for (i = 0; i < sg->SgCount; i++) + device_printf(sc->aac_dev, " 0x%08x/%d\n", + sg->SgEntry[i].SgAddress, + sg->SgEntry[i].SgByteCount); + } + break; } - if (bw->Command == VM_CtBlockWrite) { - device_printf(sc->aac_dev, " BlockWrite: container %d 0x%x/%d " - "(%s)\n", bw->ContainerId, bw->BlockNumber, - bw->ByteCount, bw->Stable == CSTABLE ? "stable" : - "unstable"); - sg = &bw->SgMap; + default: + device_printf(sc->aac_dev, " %16D\n", fib->data, " "); + device_printf(sc->aac_dev, " %16D\n", fib->data + 16, " "); + break; } - if (sg != NULL) { - device_printf(sc->aac_dev, " %d s/g entries\n", sg->SgCount); - for (i = 0; i < sg->SgCount; i++) - device_printf(sc->aac_dev, " 0x%08x/%d\n", - sg->SgEntry[i].SgAddress, - sg->SgEntry[i].SgByteCount); - } - break; - } - default: - device_printf(sc->aac_dev, " %16D\n", fib->data, " "); - device_printf(sc->aac_dev, " %16D\n", fib->data + 16, " "); - break; - } } -/****************************************************************************** +/* * Describe an AIF we have received. */ void aac_print_aif(struct aac_softc *sc, struct aac_aif_command *aif) { - switch(aif->command) { - case AifCmdEventNotify: - device_printf(sc->aac_dev, "EventNotify (%d)\n", aif->seqNumber); - switch(aif->data.EN.type) { - case AifEnGeneric: /* Generic notification */ - device_printf(sc->aac_dev, "(Generic) %.*s\n", - (int)sizeof(aif->data.EN.data.EG), - aif->data.EN.data.EG.text); - break; - case AifEnTaskComplete: /* Task has completed */ - device_printf(sc->aac_dev, "(TaskComplete)\n"); - break; - case AifEnConfigChange: /* Adapter configuration change + switch(aif->command) { + case AifCmdEventNotify: + device_printf(sc->aac_dev, "EventNotify(%d)\n", aif->seqNumber); + switch(aif->data.EN.type) { + case AifEnGeneric: /* Generic notification */ + device_printf(sc->aac_dev, "(Generic) %.*s\n", + (int)sizeof(aif->data.EN.data.EG), + aif->data.EN.data.EG.text); + break; + case AifEnTaskComplete: /* Task has completed */ + device_printf(sc->aac_dev, "(TaskComplete)\n"); + break; + case AifEnConfigChange: /* Adapter configuration change * occurred */ - device_printf(sc->aac_dev, "(ConfigChange)\n"); - break; - case AifEnContainerChange: /* Adapter specific container + device_printf(sc->aac_dev, "(ConfigChange)\n"); + break; + case AifEnContainerChange: /* Adapter specific container * configuration change */ - device_printf(sc->aac_dev, "(ContainerChange) container %d,%d\n", - aif->data.EN.data.ECC.container[0], - aif->data.EN.data.ECC.container[1]); - break; - case AifEnDeviceFailure: /* SCSI device failed */ - device_printf(sc->aac_dev, "(DeviceFailure) handle %d\n", - aif->data.EN.data.EDF.deviceHandle); /* XXX - * interpret */ - break; - case AifEnMirrorFailover: /* Mirror failover started */ - device_printf(sc->aac_dev, "(MirrorFailover) container %d failed, " - "migrating from slice %d to %d\n", - aif->data.EN.data.EMF.container, - aif->data.EN.data.EMF.failedSlice, - aif->data.EN.data.EMF.creatingSlice); - break; - case AifEnContainerEvent: /* Significant container + device_printf(sc->aac_dev, "(ContainerChange) " + "container %d,%d\n", + aif->data.EN.data.ECC.container[0], + aif->data.EN.data.ECC.container[1]); + break; + case AifEnDeviceFailure: /* SCSI device failed */ + device_printf(sc->aac_dev, "(DeviceFailure) " + "handle %d\n", + aif->data.EN.data.EDF.deviceHandle); + break; + case AifEnMirrorFailover: /* Mirror failover started */ + device_printf(sc->aac_dev, "(MirrorFailover) " + "container %d failed, " + "migrating from slice %d to %d\n", + aif->data.EN.data.EMF.container, + aif->data.EN.data.EMF.failedSlice, + aif->data.EN.data.EMF.creatingSlice); + break; + case AifEnContainerEvent: /* Significant container * event */ - device_printf(sc->aac_dev, "(ContainerEvent) container %d event " - "%d\n", aif->data.EN.data.ECE.container, - aif->data.EN.data.ECE.eventType); /* XXX - * interpret? */ - break; - case AifEnFileSystemChange: /* File system changed */ - device_printf(sc->aac_dev, "(FileSystemChange)\n"); - break; - case AifEnConfigPause: /* Container pause event */ - device_printf(sc->aac_dev, "(ConfigPause)\n"); - break; - case AifEnConfigResume: /* Container resume event */ - device_printf(sc->aac_dev, "(ConfigResume)\n"); - break; - case AifEnFailoverChange: /* Failover space assignment + device_printf(sc->aac_dev, "(ContainerEvent) " + "container %d event " + "%d\n", aif->data.EN.data.ECE.container, + aif->data.EN.data.ECE.eventType); + break; + case AifEnFileSystemChange: /* File system changed */ + device_printf(sc->aac_dev, "(FileSystemChange)\n"); + break; + case AifEnConfigPause: /* Container pause event */ + device_printf(sc->aac_dev, "(ConfigPause)\n"); + break; + case AifEnConfigResume: /* Container resume event */ + device_printf(sc->aac_dev, "(ConfigResume)\n"); + break; + case AifEnFailoverChange: /* Failover space assignment * changed */ - device_printf(sc->aac_dev, "(FailoverChange)\n"); - break; - case AifEnRAID5RebuildDone: /* RAID5 rebuild finished */ - device_printf(sc->aac_dev, "(RAID5RebuildDone)\n"); - break; - case AifEnEnclosureManagement: /* Enclosure management event */ - device_printf(sc->aac_dev, "(EnclosureManagement) EMPID %d unit %d " - "event %d\n", aif->data.EN.data.EEE.empID, - aif->data.EN.data.EEE.unitID, - aif->data.EN.data.EEE.eventType); - break; - case AifEnBatteryEvent: /* Significant NV battery + device_printf(sc->aac_dev, "(FailoverChange)\n"); + break; + case AifEnRAID5RebuildDone: /* RAID5 rebuild finished */ + device_printf(sc->aac_dev, "(RAID5RebuildDone)\n"); + break; + case AifEnEnclosureManagement: /* Enclosure management event */ + device_printf(sc->aac_dev, "(EnclosureManagement) " + "EMPID %d unit %d " + "event %d\n", aif->data.EN.data.EEE.empID, + aif->data.EN.data.EEE.unitID, + aif->data.EN.data.EEE.eventType); + break; + case AifEnBatteryEvent: /* Significant NV battery * event */ - device_printf(sc->aac_dev, "(BatteryEvent) %d (state was %d, " - "is %d\n", aif->data.EN.data.EBE.transition_type, - aif->data.EN.data.EBE.current_state, /* XXX */ - aif->data.EN.data.EBE.prior_state); /* interpret? */ - break; - case AifEnAddContainer: /* A new container was + device_printf(sc->aac_dev, "(BatteryEvent) %d " + "(state was %d, is %d\n", + aif->data.EN.data.EBE.transition_type, + aif->data.EN.data.EBE.current_state, + aif->data.EN.data.EBE.prior_state); + break; + case AifEnAddContainer: /* A new container was * created. */ - device_printf(sc->aac_dev, "(AddContainer)\n"); - break; - case AifEnDeleteContainer: /* A container was deleted. */ - device_printf(sc->aac_dev, "(DeleteContainer)\n"); - break; - case AifEnBatteryNeedsRecond: /* The battery needs + device_printf(sc->aac_dev, "(AddContainer)\n"); + break; + case AifEnDeleteContainer: /* A container was deleted. */ + device_printf(sc->aac_dev, "(DeleteContainer)\n"); + break; + case AifEnBatteryNeedsRecond: /* The battery needs * reconditioning */ - device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n"); - break; - case AifEnClusterEvent: /* Some cluster event */ - device_printf(sc->aac_dev, "(ClusterEvent) event %d\n", - aif->data.EN.data.ECLE.eventType); - break; - case AifEnDiskSetEvent: /* A disk set event occured. */ - device_printf(sc->aac_dev, "(DiskSetEvent) event %d diskset %lld " - "creator %lld\n", aif->data.EN.data.EDS.eventType, - aif->data.EN.data.EDS.DsNum, - aif->data.EN.data.EDS.CreatorId); - break; - case AifDenMorphComplete: /* A morph operation + device_printf(sc->aac_dev, "(BatteryNeedsRecond)\n"); + break; + case AifEnClusterEvent: /* Some cluster event */ + device_printf(sc->aac_dev, "(ClusterEvent) event %d\n", + aif->data.EN.data.ECLE.eventType); + break; + case AifEnDiskSetEvent: /* A disk set event occured. */ + device_printf(sc->aac_dev, "(DiskSetEvent) event %d " + "diskset %lld creator %lld\n", + aif->data.EN.data.EDS.eventType, + aif->data.EN.data.EDS.DsNum, + aif->data.EN.data.EDS.CreatorId); + break; + case AifDenMorphComplete: /* A morph operation * completed */ - device_printf(sc->aac_dev, "(MorphComplete)\n"); - break; - case AifDenVolumeExtendComplete: /* A volume expand operation - * completed */ - device_printf(sc->aac_dev, "(VolumeExtendComplete)\n"); - break; - default: - device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type); - break; - } - break; - case AifCmdJobProgress: - { - char *status; - switch(aif->data.PR[0].status) { - case AifJobStsSuccess: - status = "success"; break; - case AifJobStsFinished: - status = "finished"; break; - case AifJobStsAborted: - status = "aborted"; break; - case AifJobStsFailed: - status = "failed"; break; - case AifJobStsSuspended: - status = "suspended"; break; - case AifJobStsRunning: - status = "running"; break; - default: - status = "unknown status"; break; - } + device_printf(sc->aac_dev, "(MorphComplete)\n"); + break; + case AifDenVolumeExtendComplete: /* A volume expand operation + * completed */ + device_printf(sc->aac_dev, "(VolumeExtendComplete)\n"); + break; + default: + device_printf(sc->aac_dev, "(%d)\n", aif->data.EN.type); + break; + } + break; + case AifCmdJobProgress: + { + char *status; + switch(aif->data.PR[0].status) { + case AifJobStsSuccess: + status = "success"; break; + case AifJobStsFinished: + status = "finished"; break; + case AifJobStsAborted: + status = "aborted"; break; + case AifJobStsFailed: + status = "failed"; break; + case AifJobStsSuspended: + status = "suspended"; break; + case AifJobStsRunning: + status = "running"; break; + default: + status = "unknown status"; break; + } - device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n", - aif->seqNumber, status, aif->data.PR[0].currentTick, - aif->data.PR[0].finalTick); - switch(aif->data.PR[0].jd.type) { - case AifJobScsiZero: /* SCSI dev clear operation */ - device_printf(sc->aac_dev, "(ScsiZero) handle %d\n", - aif->data.PR[0].jd.client.scsi_dh); - break; - case AifJobScsiVerify: /* SCSI device Verify operation + device_printf(sc->aac_dev, "JobProgress (%d) - %s (%d, %d)\n", + aif->seqNumber, status, + aif->data.PR[0].currentTick, + aif->data.PR[0].finalTick); + switch(aif->data.PR[0].jd.type) { + case AifJobScsiZero: /* SCSI dev clear operation */ + device_printf(sc->aac_dev, "(ScsiZero) handle %d\n", + aif->data.PR[0].jd.client.scsi_dh); + break; + case AifJobScsiVerify: /* SCSI device Verify operation * NO REPAIR */ - device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n", - aif->data.PR[0].jd.client.scsi_dh); - break; - case AifJobScsiExercise: /* SCSI device Exercise + device_printf(sc->aac_dev, "(ScsiVerify) handle %d\n", + aif->data.PR[0].jd.client.scsi_dh); + break; + case AifJobScsiExercise: /* SCSI device Exercise * operation */ - device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n", - aif->data.PR[0].jd.client.scsi_dh); - break; - case AifJobScsiVerifyRepair: /* SCSI device Verify operation + device_printf(sc->aac_dev, "(ScsiExercise) handle %d\n", + aif->data.PR[0].jd.client.scsi_dh); + break; + case AifJobScsiVerifyRepair: /* SCSI device Verify operation * WITH repair */ - device_printf(sc->aac_dev, "(ScsiVerifyRepair) handle %d\n", - aif->data.PR[0].jd.client.scsi_dh); - break; - case AifJobCtrZero: /* Container clear operation */ - device_printf(sc->aac_dev, "(ConatainerZero) container %d\n", - aif->data.PR[0].jd.client.container.src); - break; - case AifJobCtrCopy: /* Container copy operation */ - device_printf(sc->aac_dev, "(ConatainerCopy) container %d to %d\n", - aif->data.PR[0].jd.client.container.src, - aif->data.PR[0].jd.client.container.dst); - break; - case AifJobCtrCreateMirror: /* Container Create Mirror + device_printf(sc->aac_dev, + "(ScsiVerifyRepair) handle %d\n", + aif->data.PR[0].jd.client.scsi_dh); + break; + case AifJobCtrZero: /* Container clear operation */ + device_printf(sc->aac_dev, + "(ConatainerZero) container %d\n", + aif->data.PR[0].jd.client.container.src); + break; + case AifJobCtrCopy: /* Container copy operation */ + device_printf(sc->aac_dev, + "(ConatainerCopy) container %d to %d\n", + aif->data.PR[0].jd.client.container.src, + aif->data.PR[0].jd.client.container.dst); + break; + case AifJobCtrCreateMirror: /* Container Create Mirror * operation */ - device_printf(sc->aac_dev, "(ConatainerCreateMirror) container " - "%d\n", aif->data.PR[0].jd.client.container.src); - /* XXX two containers? */ - break; - case AifJobCtrMergeMirror: /* Container Merge Mirror + device_printf(sc->aac_dev, + "(ConatainerCreateMirror) container %d\n", + aif->data.PR[0].jd.client.container.src); + /* XXX two containers? */ + break; + case AifJobCtrMergeMirror: /* Container Merge Mirror * operation */ - device_printf(sc->aac_dev, "(ConatainerMergeMirror) container %d\n", - aif->data.PR[0].jd.client.container.src); - /* XXX two containers? */ - break; - case AifJobCtrScrubMirror: /* Container Scrub Mirror + device_printf(sc->aac_dev, + "(ConatainerMergeMirror) container %d\n", + aif->data.PR[0].jd.client.container.src); + /* XXX two containers? */ + break; + case AifJobCtrScrubMirror: /* Container Scrub Mirror * operation */ - device_printf(sc->aac_dev, "(ConatainerScrubMirror) container %d\n", - aif->data.PR[0].jd.client.container.src); - break; - case AifJobCtrRebuildRaid5: /* Container Rebuild Raid5 + device_printf(sc->aac_dev, + "(ConatainerScrubMirror) container %d\n", + aif->data.PR[0].jd.client.container.src); + break; + case AifJobCtrRebuildRaid5: /* Container Rebuild Raid5 * operation */ - device_printf(sc->aac_dev, "(ConatainerRebuildRaid5) container " - "%d\n", aif->data.PR[0].jd.client.container.src); - break; - case AifJobCtrScrubRaid5: /* Container Scrub Raid5 + device_printf(sc->aac_dev, + "(ConatainerRebuildRaid5) container %d\n", + aif->data.PR[0].jd.client.container.src); + break; + case AifJobCtrScrubRaid5: /* Container Scrub Raid5 * operation */ - device_printf(sc->aac_dev, "(ConatainerScrubRaid5) container %d\n", - aif->data.PR[0].jd.client.container.src); - break; - case AifJobCtrMorph: /* Container morph operation */ - device_printf(sc->aac_dev, "(ConatainerMorph) container %d\n", - aif->data.PR[0].jd.client.container.src); - /* XXX two containers? */ - break; - case AifJobCtrPartCopy: /* Container Partition copy + device_printf(sc->aac_dev, + "(ConatainerScrubRaid5) container %d\n", + aif->data.PR[0].jd.client.container.src); + break; + case AifJobCtrMorph: /* Container morph operation */ + device_printf(sc->aac_dev, + "(ConatainerMorph) container %d\n", + aif->data.PR[0].jd.client.container.src); + /* XXX two containers? */ + break; + case AifJobCtrPartCopy: /* Container Partition copy * operation */ - device_printf(sc->aac_dev, "(ConatainerPartCopy) container %d to " - "%d\n", aif->data.PR[0].jd.client.container.src, - aif->data.PR[0].jd.client.container.dst); - break; - case AifJobCtrRebuildMirror: /* Container Rebuild Mirror + device_printf(sc->aac_dev, + "(ConatainerPartCopy) container %d to " + "%d\n", + aif->data.PR[0].jd.client.container.src, + aif->data.PR[0].jd.client.container.dst); + break; + case AifJobCtrRebuildMirror: /* Container Rebuild Mirror * operation */ - device_printf(sc->aac_dev, "(ConatainerRebuildMirror) container " - "%d\n", aif->data.PR[0].jd.client.container.src); - break; - case AifJobCtrCrazyCache: /* crazy cache */ - device_printf(sc->aac_dev, "(ConatainerCrazyCache) container %d\n", - aif->data.PR[0].jd.client.container.src); - /* XXX two containers? */ - break; - case AifJobFsCreate: /* File System Create + device_printf(sc->aac_dev, + "(ConatainerRebuildMirror) container " + "%d\n", + aif->data.PR[0].jd.client.container.src); + break; + case AifJobCtrCrazyCache: /* crazy cache */ + device_printf(sc->aac_dev, + "(ConatainerCrazyCache) container %d\n", + aif->data.PR[0].jd.client.container.src); + /* XXX two containers? */ + break; + case AifJobFsCreate: /* File System Create * operation */ - device_printf(sc->aac_dev, "(FsCreate)\n"); - break; - case AifJobFsVerify: /* File System Verify + device_printf(sc->aac_dev, "(FsCreate)\n"); + break; + case AifJobFsVerify: /* File System Verify * operation */ - device_printf(sc->aac_dev, "(FsVerivy)\n"); - break; - case AifJobFsExtend: /* File System Extend + device_printf(sc->aac_dev, "(FsVerivy)\n"); + break; + case AifJobFsExtend: /* File System Extend * operation */ - device_printf(sc->aac_dev, "(FsExtend)\n"); - break; - case AifJobApiFormatNTFS: /* Format a drive to NTFS */ - device_printf(sc->aac_dev, "(FormatNTFS)\n"); - break; - case AifJobApiFormatFAT: /* Format a drive to FAT */ - device_printf(sc->aac_dev, "(FormatFAT)\n"); - break; - case AifJobApiUpdateSnapshot: /* update the read/write half + device_printf(sc->aac_dev, "(FsExtend)\n"); + break; + case AifJobApiFormatNTFS: /* Format a drive to NTFS */ + device_printf(sc->aac_dev, "(FormatNTFS)\n"); + break; + case AifJobApiFormatFAT: /* Format a drive to FAT */ + device_printf(sc->aac_dev, "(FormatFAT)\n"); + break; + case AifJobApiUpdateSnapshot: /* update the read/write half * of a snapshot */ - device_printf(sc->aac_dev, "(UpdateSnapshot)\n"); - break; - case AifJobApiFormatFAT32: /* Format a drive to FAT32 */ - device_printf(sc->aac_dev, "(FormatFAT32)\n"); - break; - case AifJobCtlContinuousCtrVerify: /* Adapter operation */ - device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n"); - break; - default: - device_printf(sc->aac_dev, "(%d)\n", aif->data.PR[0].jd.type); - break; + device_printf(sc->aac_dev, "(UpdateSnapshot)\n"); + break; + case AifJobApiFormatFAT32: /* Format a drive to FAT32 */ + device_printf(sc->aac_dev, "(FormatFAT32)\n"); + break; + case AifJobCtlContinuousCtrVerify: /* Adapter operation */ + device_printf(sc->aac_dev, "(ContinuousCtrVerify)\n"); + break; + default: + device_printf(sc->aac_dev, "(%d)\n", + aif->data.PR[0].jd.type); + break; + } + break; + } + case AifCmdAPIReport: + device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber); + break; + case AifCmdDriverNotify: + device_printf(sc->aac_dev, "DriverNotify (%d)\n", + aif->seqNumber); + break; + default: + device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command, + aif->seqNumber); + break; } - break; - } - case AifCmdAPIReport: - device_printf(sc->aac_dev, "APIReport (%d)\n", aif->seqNumber); - break; - case AifCmdDriverNotify: - device_printf(sc->aac_dev, "DriverNotify (%d)\n", aif->seqNumber); - break; - default: - device_printf(sc->aac_dev, "AIF %d (%d)\n", aif->command, - aif->seqNumber); - break; - } } #endif /* AAC_DEBUG */ diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c index a5a70da2451c..3917fa19a4c4 100644 --- a/sys/dev/aac/aac_disk.c +++ b/sys/dev/aac/aac_disk.c @@ -71,21 +71,21 @@ static d_dump_t aac_disk_dump; #define AAC_DISK_CDEV_MAJOR 151 static struct cdevsw aac_disk_cdevsw = { - /* open */ aac_disk_open, - /* close */ aac_disk_close, - /* read */ physread, - /* write */ physwrite, - /* ioctl */ noioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ aac_disk_strategy, - /* name */ "aacd", - /* maj */ AAC_DISK_CDEV_MAJOR, - /* dump */ aac_disk_dump, - /* psize */ nopsize, - /* flags */ D_DISK, + /* open */ aac_disk_open, + /* close */ aac_disk_close, + /* read */ physread, + /* write */ physwrite, + /* ioctl */ noioctl, + /* poll */ nopoll, + /* mmap */ nommap, + /* strategy */ aac_disk_strategy, + /* name */ "aacd", + /* maj */ AAC_DISK_CDEV_MAJOR, + /* dump */ aac_disk_dump, + /* psize */ nopsize, + /* flags */ D_DISK, #if __FreeBSD_version < 500005 - /* bmaj */ -1 + /* bmaj */ -1 #endif }; @@ -96,16 +96,16 @@ static int disks_registered = 0; #endif static device_method_t aac_disk_methods[] = { - DEVMETHOD(device_probe, aac_disk_probe), - DEVMETHOD(device_attach, aac_disk_attach), - DEVMETHOD(device_detach, aac_disk_detach), - { 0, 0 } + DEVMETHOD(device_probe, aac_disk_probe), + DEVMETHOD(device_attach, aac_disk_attach), + DEVMETHOD(device_detach, aac_disk_detach), + { 0, 0 } }; static driver_t aac_disk_driver = { - "aacd", - aac_disk_methods, - sizeof(struct aac_disk) + "aacd", + aac_disk_methods, + sizeof(struct aac_disk) }; DRIVER_MODULE(aacd, aac, aac_disk_driver, aac_disk_devclass, 0, 0); @@ -120,7 +120,7 @@ SYSCTL_UINT(_hw_aac, OID_AUTO, iosize_max, CTLFLAG_RD, &aac_iosize_max, 0, #define AAC_MAXIO 65536 -/****************************************************************************** +/* * Handle open from generic layer. * * This is called by the diskslice code on first open in order to get the @@ -129,84 +129,90 @@ SYSCTL_UINT(_hw_aac, OID_AUTO, iosize_max, CTLFLAG_RD, &aac_iosize_max, 0, static int aac_disk_open(dev_t dev, int flags, int fmt, struct proc *p) { - struct aac_disk *sc = (struct aac_disk *)dev->si_drv1; - struct disklabel *label; + struct aac_disk *sc; + struct disklabel *label; - debug_called(4); + debug_called(4); + + sc = (struct aac_disk *)dev->si_drv1; - if (sc == NULL) - return (ENXIO); + if (sc == NULL) + return (ENXIO); - /* check that the controller is up and running */ - if (sc->ad_controller->aac_state & AAC_STATE_SUSPEND) - return(ENXIO); + /* check that the controller is up and running */ + if (sc->ad_controller->aac_state & AAC_STATE_SUSPEND) + return(ENXIO); - /* build synthetic label */ - label = &sc->ad_disk.d_label; - bzero(label, sizeof(*label)); - label->d_type = DTYPE_ESDI; - label->d_secsize = AAC_BLOCK_SIZE; - label->d_nsectors = sc->ad_sectors; - label->d_ntracks = sc->ad_heads; - label->d_ncylinders = sc->ad_cylinders; - label->d_secpercyl = sc->ad_sectors * sc->ad_heads; - label->d_secperunit = sc->ad_size; + /* build synthetic label */ + label = &sc->ad_disk.d_label; + bzero(label, sizeof(*label)); + label->d_type = DTYPE_ESDI; + label->d_secsize = AAC_BLOCK_SIZE; + label->d_nsectors = sc->ad_sectors; + label->d_ntracks = sc->ad_heads; + label->d_ncylinders = sc->ad_cylinders; + label->d_secpercyl = sc->ad_sectors * sc->ad_heads; + label->d_secperunit = sc->ad_size; - sc->ad_flags |= AAC_DISK_OPEN; - return (0); + sc->ad_flags |= AAC_DISK_OPEN; + return (0); } -/****************************************************************************** +/* * Handle last close of the disk device. */ static int aac_disk_close(dev_t dev, int flags, int fmt, struct proc *p) { - struct aac_disk *sc = (struct aac_disk *)dev->si_drv1; + struct aac_disk *sc; - debug_called(4); + debug_called(4); + + sc = (struct aac_disk *)dev->si_drv1; - if (sc == NULL) - return (ENXIO); + if (sc == NULL) + return (ENXIO); - sc->ad_flags &= ~AAC_DISK_OPEN; - return (0); + sc->ad_flags &= ~AAC_DISK_OPEN; + return (0); } -/****************************************************************************** +/* * Handle an I/O request. */ static void aac_disk_strategy(struct bio *bp) { - struct aac_disk *sc = (struct aac_disk *)bp->bio_dev->si_drv1; + struct aac_disk *sc; - debug_called(4); + debug_called(4); - /* bogus disk? */ - if (sc == NULL) { - bp->bio_flags |= BIO_ERROR; - bp->bio_error = EINVAL; - biodone(bp); + sc = (struct aac_disk *)bp->bio_dev->si_drv1; + + /* bogus disk? */ + if (sc == NULL) { + bp->bio_flags |= BIO_ERROR; + bp->bio_error = EINVAL; + biodone(bp); + return; + } + + /* do-nothing operation? */ + if (bp->bio_bcount == 0) { + bp->bio_resid = bp->bio_bcount; + biodone(bp); + return; + } + + /* perform accounting */ + devstat_start_transaction(&sc->ad_stats); + + /* pass the bio to the controller - it can work out who we are */ + aac_submit_bio(bp); return; - } - - /* do-nothing operation? */ - if (bp->bio_bcount == 0) { - bp->bio_resid = bp->bio_bcount; - biodone(bp); - return; - } - - /* perform accounting */ - devstat_start_transaction(&sc->ad_stats); - - /* pass the bio to the controller - it can work out who we are */ - aac_submit_bio(bp); - return; } -/****************************************************************************** +/* * Dump memory out to an array * * This queues blocks of memory of size AAC_MAXIO to the controller and waits @@ -215,186 +221,193 @@ aac_disk_strategy(struct bio *bp) static int aac_disk_dump(dev_t dev) { - struct aac_disk *ad = dev->si_drv1; - struct aac_softc *sc; - vm_offset_t addr = 0; - long blkcnt; - unsigned int count, blkno, secsize; - int dumppages = AAC_MAXIO / PAGE_SIZE; - int i, error; + struct aac_disk *ad; + struct aac_softc *sc; + vm_offset_t addr; + long blkcnt; + unsigned int count, blkno, secsize; + int dumppages; + int i, error; - if ((error = disk_dumpcheck(dev, &count, &blkno, &secsize))) - return (error); + ad = dev->si_drv1; + addr = 0; + dumppages = AAC_MAXIO / PAGE_SIZE; - if (ad == NULL) - return (ENXIO); + if ((error = disk_dumpcheck(dev, &count, &blkno, &secsize))) + return (error); - sc= ad->ad_controller; + if (ad == NULL) + return (ENXIO); - blkcnt = howmany(PAGE_SIZE, secsize); + sc= ad->ad_controller; - while (count > 0) { - caddr_t va = NULL; + blkcnt = howmany(PAGE_SIZE, secsize); - if ((count / blkcnt) < dumppages) - dumppages = count / blkcnt; + while (count > 0) { + caddr_t va = NULL; - for (i = 0; i < dumppages; ++i) { - vm_offset_t a = addr + (i * PAGE_SIZE); - if (is_physical_memory(a)) { - va = pmap_kenter_temporary(trunc_page(a), i); - } else { - va = pmap_kenter_temporary(trunc_page(0), i); - } - } + if ((count / blkcnt) < dumppages) + dumppages = count / blkcnt; + + for (i = 0; i < dumppages; ++i) { + vm_offset_t a = addr + (i * PAGE_SIZE); + if (is_physical_memory(a)) { + va = pmap_kenter_temporary(trunc_page(a), i); + } else { + va = pmap_kenter_temporary(trunc_page(0), i); + } + } retry: - /* - * Queue the block to the controller. If the queue is full, EBUSY - * will be returned. - */ - error = aac_dump_enqueue(ad, blkno, va, dumppages); - if (error && (error != EBUSY)) - return (error); + /* + * Queue the block to the controller. If the queue is full, + * EBUSY will be returned. + */ + error = aac_dump_enqueue(ad, blkno, va, dumppages); + if (error && (error != EBUSY)) + return (error); - if (!error) { - if (dumpstatus(addr, (long)(count * DEV_BSIZE)) < 0) - return (EINTR); + if (!error) { + if (dumpstatus(addr, (long)(count * DEV_BSIZE)) < 0) + return (EINTR); - blkno += blkcnt * dumppages; - count -= blkcnt * dumppages; - addr += PAGE_SIZE * dumppages; - if (count > 0) - continue; + blkno += blkcnt * dumppages; + count -= blkcnt * dumppages; + addr += PAGE_SIZE * dumppages; + if (count > 0) + continue; + } + + /* + * Either the queue was full on the last attemp, or we have no + * more data to dump. Let the queue drain out and retry the + * block if the queue was full. + */ + aac_dump_complete(sc); + + if (error == EBUSY) + goto retry; } - /* - * Either the queue was full on the last attemp, or we have no more - * data to dump. Let the queue drain out and retry the block if - * the queue was full. - */ - aac_dump_complete(sc); - - if (error == EBUSY) - goto retry; - } - - return (0); + return (0); } -/****************************************************************************** +/* * Handle completion of an I/O request. */ void aac_biodone(struct bio *bp) { - struct aac_disk *sc = (struct aac_disk *)bp->bio_dev->si_drv1; + struct aac_disk *sc; + int blkno; - debug_called(4); + debug_called(4); - devstat_end_transaction_bio(&sc->ad_stats, bp); - if (bp->bio_flags & BIO_ERROR) { - /* - * XXX For some reason, the disklabel seems to get zero'd out. This - * will cause diskerr to panic unless we pass in -1 as the blkno. - */ - int blkno = (sc->ad_label.d_nsectors) ? 0 : -1; + sc = (struct aac_disk *)bp->bio_dev->si_drv1; + + devstat_end_transaction_bio(&sc->ad_stats, bp); + if (bp->bio_flags & BIO_ERROR) { + blkno = (sc->ad_label.d_nsectors) ? 0 : -1; #if __FreeBSD_version > 500005 - diskerr(bp, (char *)bp->bio_driver1, blkno, &sc->ad_label); + diskerr(bp, (char *)bp->bio_driver1, blkno, &sc->ad_label); #else - diskerr(bp, (char *)bp->bio_driver1, 0, blkno, &sc->ad_label); + diskerr(bp, (char *)bp->bio_driver1, 0, blkno, &sc->ad_label); #endif - } - biodone(bp); + } + biodone(bp); } -/****************************************************************************** +/* * Stub only. */ static int aac_disk_probe(device_t dev) { - debug_called(2); + debug_called(2); - return (0); + return (0); } -/****************************************************************************** +/* * Attach a unit to the controller. */ static int aac_disk_attach(device_t dev) { - struct aac_disk *sc = (struct aac_disk *)device_get_softc(dev); - - debug_called(1); + struct aac_disk *sc; + + debug_called(1); - /* initialise our softc */ - sc->ad_controller = - (struct aac_softc *)device_get_softc(device_get_parent(dev)); - sc->ad_container = device_get_ivars(dev); - sc->ad_dev = dev; + sc = (struct aac_disk *)device_get_softc(dev); - /* - * require that extended translation be enabled - other drivers read the - * disk! - */ - sc->ad_size = sc->ad_container->co_mntobj.Capacity; - if (sc->ad_size >= (2 * 1024 * 1024)) { /* 2GB */ - sc->ad_heads = 255; - sc->ad_sectors = 63; - } else if (sc->ad_size >= (1 * 1024 * 1024)) { /* 1GB */ - sc->ad_heads = 128; - sc->ad_sectors = 32; - } else { - sc->ad_heads = 64; - sc->ad_sectors = 32; - } - sc->ad_cylinders = (sc->ad_size / (sc->ad_heads * sc->ad_sectors)); + /* initialise our softc */ + sc->ad_controller = + (struct aac_softc *)device_get_softc(device_get_parent(dev)); + sc->ad_container = device_get_ivars(dev); + sc->ad_dev = dev; - device_printf(dev, "%uMB (%u sectors)\n", - sc->ad_size / ((1024 * 1024) / AAC_BLOCK_SIZE), sc->ad_size); + /* + * require that extended translation be enabled - other drivers read the + * disk! + */ + sc->ad_size = sc->ad_container->co_mntobj.Capacity; + if (sc->ad_size >= (2 * 1024 * 1024)) { /* 2GB */ + sc->ad_heads = 255; + sc->ad_sectors = 63; + } else if (sc->ad_size >= (1 * 1024 * 1024)) { /* 1GB */ + sc->ad_heads = 128; + sc->ad_sectors = 32; + } else { + sc->ad_heads = 64; + sc->ad_sectors = 32; + } + sc->ad_cylinders = (sc->ad_size / (sc->ad_heads * sc->ad_sectors)); - devstat_add_entry(&sc->ad_stats, "aacd", device_get_unit(dev), - AAC_BLOCK_SIZE, DEVSTAT_NO_ORDERED_TAGS, - DEVSTAT_TYPE_STORARRAY | DEVSTAT_TYPE_IF_OTHER, - DEVSTAT_PRIORITY_ARRAY); + device_printf(dev, "%uMB (%u sectors)\n", + sc->ad_size / ((1024 * 1024) / AAC_BLOCK_SIZE), + sc->ad_size); - /* attach a generic disk device to ourselves */ - sc->ad_dev_t = disk_create(device_get_unit(dev), &sc->ad_disk, 0, - &aac_disk_cdevsw, &aac_disk_disk_cdevsw); - sc->ad_dev_t->si_drv1 = sc; + devstat_add_entry(&sc->ad_stats, "aacd", device_get_unit(dev), + AAC_BLOCK_SIZE, DEVSTAT_NO_ORDERED_TAGS, + DEVSTAT_TYPE_STORARRAY | DEVSTAT_TYPE_IF_OTHER, + DEVSTAT_PRIORITY_ARRAY); + + /* attach a generic disk device to ourselves */ + sc->ad_dev_t = disk_create(device_get_unit(dev), &sc->ad_disk, 0, + &aac_disk_cdevsw, &aac_disk_disk_cdevsw); + sc->ad_dev_t->si_drv1 = sc; #ifdef FREEBSD_4 - disks_registered++; + disks_registered++; #endif - sc->ad_dev_t->si_iosize_max = aac_iosize_max; - sc->unit = device_get_unit(dev); + sc->ad_dev_t->si_iosize_max = aac_iosize_max; + sc->unit = device_get_unit(dev); - return (0); + return (0); } -/****************************************************************************** +/* * Disconnect ourselves from the system. */ static int aac_disk_detach(device_t dev) { - struct aac_disk *sc = (struct aac_disk *)device_get_softc(dev); + struct aac_disk *sc; - debug_called(2); + debug_called(2); - if (sc->ad_flags & AAC_DISK_OPEN) - return(EBUSY); + sc = (struct aac_disk *)device_get_softc(dev); - devstat_remove_entry(&sc->ad_stats); - disk_destroy(sc->ad_dev_t); + if (sc->ad_flags & AAC_DISK_OPEN) + return(EBUSY); + + devstat_remove_entry(&sc->ad_stats); + disk_destroy(sc->ad_dev_t); #ifdef FREEBSD_4 - if (--disks_registered == 0) - cdevsw_remove(&aac_disk_cdevsw); + if (--disks_registered == 0) + cdevsw_remove(&aac_disk_cdevsw); #endif - return(0); + return(0); } - diff --git a/sys/dev/aac/aac_ioctl.h b/sys/dev/aac/aac_ioctl.h index fda2afd100e5..1b798ebd8238 100644 --- a/sys/dev/aac/aac_ioctl.h +++ b/sys/dev/aac/aac_ioctl.h @@ -39,16 +39,16 @@ #define AACQ_COUNT 5 /* total number of queues */ struct aac_qstat { - u_int32_t q_length; - u_int32_t q_max; + 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; + u_int32_t as_item; + struct aac_qstat as_qstat; }; #define AACIO_STATS _IOWR('T', 101, union aac_statrequest) @@ -147,33 +147,33 @@ union aac_statrequest { * Support for faking the "miniport" version. */ struct aac_rev_check { - RevComponent callingComponent; - struct FsaRevision callingRevision; + RevComponent callingComponent; + struct FsaRevision callingRevision; }; struct aac_rev_check_resp { - int possiblyCompatible; - struct FsaRevision adapterSWRevision; + 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; + 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; + 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; }; diff --git a/sys/dev/aac/aac_pci.c b/sys/dev/aac/aac_pci.c index 4b362c95dd4e..5150735ff092 100644 --- a/sys/dev/aac/aac_pci.c +++ b/sys/dev/aac/aac_pci.c @@ -57,20 +57,20 @@ #include #include -static int aac_pci_probe(device_t dev); -static int aac_pci_attach(device_t dev); +static int aac_pci_probe(device_t dev); +static int aac_pci_attach(device_t dev); static device_method_t aac_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, aac_pci_probe), - DEVMETHOD(device_attach, aac_pci_attach), - DEVMETHOD(device_detach, aac_detach), - DEVMETHOD(device_suspend, aac_suspend), - DEVMETHOD(device_resume, aac_resume), + /* Device interface */ + DEVMETHOD(device_probe, aac_pci_probe), + DEVMETHOD(device_attach, aac_pci_attach), + DEVMETHOD(device_detach, aac_detach), + DEVMETHOD(device_suspend, aac_suspend), + DEVMETHOD(device_resume, aac_resume), - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - { 0, 0 } + DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + { 0, 0 } }; static driver_t aac_pci_driver = { @@ -83,147 +83,154 @@ DRIVER_MODULE(aac, pci, aac_pci_driver, aac_devclass, 0, 0); struct aac_ident { - u_int16_t vendor; - u_int16_t device; - u_int16_t subvendor; - u_int16_t subdevice; - int hwif; - char *desc; + u_int16_t vendor; + u_int16_t device; + u_int16_t subvendor; + u_int16_t subdevice; + int hwif; + char *desc; } aac_identifiers[] = { - {0x1028, 0x0001, 0x1028, 0x0001, AAC_HWIF_I960RX, "Dell PERC 2/Si"}, - {0x1028, 0x0002, 0x1028, 0x0002, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, - {0x1028, 0x0003, 0x1028, 0x0003, AAC_HWIF_I960RX, "Dell PERC 3/Si"}, - {0x1028, 0x0004, 0x1028, 0x00d0, AAC_HWIF_I960RX, "Dell PERC 3/Si"}, - {0x1028, 0x0002, 0x1028, 0x00d1, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, - {0x1028, 0x0002, 0x1028, 0x00d9, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, - {0x1028, 0x0008, 0x1028, 0x00cf, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, - {0x1028, 0x000a, 0x1028, 0x0106, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, - {0x1011, 0x0046, 0x9005, 0x0364, AAC_HWIF_STRONGARM, "Adaptec AAC-364"}, - {0x1011, 0x0046, 0x9005, 0x0365, AAC_HWIF_STRONGARM, - "Adaptec SCSI RAID 5400S"}, - {0x1011, 0x0046, 0x9005, 0x1364, AAC_HWIF_STRONGARM, "Dell PERC 2/QC"}, - {0x1011, 0x0046, 0x103c, 0x10c2, AAC_HWIF_STRONGARM, "HP NetRaid-4M"}, - {0, 0, 0, 0, 0, 0} + {0x1028, 0x0001, 0x1028, 0x0001, AAC_HWIF_I960RX, "Dell PERC 2/Si"}, + {0x1028, 0x0002, 0x1028, 0x0002, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, + {0x1028, 0x0003, 0x1028, 0x0003, AAC_HWIF_I960RX, "Dell PERC 3/Si"}, + {0x1028, 0x0004, 0x1028, 0x00d0, AAC_HWIF_I960RX, "Dell PERC 3/Si"}, + {0x1028, 0x0002, 0x1028, 0x00d1, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, + {0x1028, 0x0002, 0x1028, 0x00d9, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, + {0x1028, 0x0008, 0x1028, 0x00cf, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, + {0x1028, 0x000a, 0x1028, 0x0106, AAC_HWIF_I960RX, "Dell PERC 3/Di"}, + {0x1011, 0x0046, 0x9005, 0x0364, AAC_HWIF_STRONGARM, "Adaptec AAC-364"}, + {0x1011, 0x0046, 0x9005, 0x0365, AAC_HWIF_STRONGARM, + "Adaptec SCSI RAID 5400S"}, + {0x1011, 0x0046, 0x9005, 0x1364, AAC_HWIF_STRONGARM, "Dell PERC 2/QC"}, + {0x1011, 0x0046, 0x103c, 0x10c2, AAC_HWIF_STRONGARM, "HP NetRaid-4M"}, + {0, 0, 0, 0, 0, 0} }; -/****************************************************************************** +/* * Determine whether this is one of our supported adapters. */ static int aac_pci_probe(device_t dev) { - struct aac_ident *m; + struct aac_ident *m; - debug_called(1); + debug_called(1); - for (m = aac_identifiers; m->vendor != 0; m++) { - if ((m->vendor == pci_get_vendor(dev)) && - (m->device == pci_get_device(dev)) && - ((m->subvendor == 0) || (m->subvendor == pci_get_subvendor(dev))) && - ((m->subdevice == 0) || ((m->subdevice == pci_get_subdevice(dev))))) { - - device_set_desc(dev, m->desc); - return(-10); /* allow room to be overridden */ + for (m = aac_identifiers; m->vendor != 0; m++) { + if ((m->vendor == pci_get_vendor(dev)) && + (m->device == pci_get_device(dev)) && + ((m->subvendor == 0) || (m->subvendor == + pci_get_subvendor(dev))) && + ((m->subdevice == 0) || ((m->subdevice == + pci_get_subdevice(dev))))) { + + device_set_desc(dev, m->desc); + return(-10); /* allow room to be overridden */ + } } - } - return(ENXIO); + return(ENXIO); } -/****************************************************************************** +/* * Allocate resources for our device, set up the bus interface. */ static int aac_pci_attach(device_t dev) { - struct aac_softc *sc; - int i, error; - u_int32_t command; + struct aac_softc *sc; + int i, error; + u_int32_t command; - debug_called(1); + debug_called(1); - /* - * Initialise softc. - */ - sc = device_get_softc(dev); - bzero(sc, sizeof(*sc)); - sc->aac_dev = dev; + /* + * Initialise softc. + */ + sc = device_get_softc(dev); + bzero(sc, sizeof(*sc)); + sc->aac_dev = dev; - /* assume failure is 'not configured' */ - error = ENXIO; + /* assume failure is 'not configured' */ + error = ENXIO; - /* - * Verify that the adapter is correctly set up in PCI space. - */ - command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); - command |= PCIM_CMD_BUSMASTEREN; - pci_write_config(dev, PCIR_COMMAND, command, 2); - command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); - if (!(command & PCIM_CMD_BUSMASTEREN)) { - device_printf(sc->aac_dev, "can't enable bus-master feature\n"); - goto out; - } - if ((command & PCIM_CMD_MEMEN) == 0) { - device_printf(sc->aac_dev, "memory window not available\n"); - goto out; - } + /* + * Verify that the adapter is correctly set up in PCI space. + */ + command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); + command |= PCIM_CMD_BUSMASTEREN; + pci_write_config(dev, PCIR_COMMAND, command, 2); + command = pci_read_config(sc->aac_dev, PCIR_COMMAND, 2); + if (!(command & PCIM_CMD_BUSMASTEREN)) { + device_printf(sc->aac_dev, "can't enable bus-master feature\n"); + goto out; + } + if ((command & PCIM_CMD_MEMEN) == 0) { + device_printf(sc->aac_dev, "memory window not available\n"); + goto out; + } - /* - * Allocate the PCI register window. - */ - sc->aac_regs_rid = 0x10; /* first base address register */ - if ((sc->aac_regs_resource = bus_alloc_resource(sc->aac_dev, SYS_RES_MEMORY, - &sc->aac_regs_rid, 0, ~0, 1, - RF_ACTIVE)) == NULL) { - device_printf(sc->aac_dev, "couldn't allocate register window\n"); - goto out; - } - sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); - sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); + /* + * Allocate the PCI register window. + */ + sc->aac_regs_rid = 0x10; /* first base address register */ + if ((sc->aac_regs_resource = bus_alloc_resource(sc->aac_dev, + SYS_RES_MEMORY, + &sc->aac_regs_rid, + 0, ~0, 1, + RF_ACTIVE)) == NULL) { + device_printf(sc->aac_dev, + "couldn't allocate register window\n"); + goto out; + } + sc->aac_btag = rman_get_bustag(sc->aac_regs_resource); + sc->aac_bhandle = rman_get_bushandle(sc->aac_regs_resource); - /* - * Allocate and connect our interrupt. - */ - sc->aac_irq_rid = 0; - if ((sc->aac_irq = bus_alloc_resource(sc->aac_dev, SYS_RES_IRQ, - &sc->aac_irq_rid, 0, ~0, 1, - RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(sc->aac_dev, "can't allocate interrupt\n"); - goto out; - } + /* + * Allocate and connect our interrupt. + */ + sc->aac_irq_rid = 0; + if ((sc->aac_irq = bus_alloc_resource(sc->aac_dev, SYS_RES_IRQ, + &sc->aac_irq_rid, 0, ~0, 1, + RF_SHAREABLE | + RF_ACTIVE)) == NULL) { + device_printf(sc->aac_dev, "can't allocate interrupt\n"); + goto out; + } #if __FreeBSD_version < 500005 #define INTR_ENTROPY 0 #endif - if (bus_setup_intr(sc->aac_dev, sc->aac_irq, INTR_TYPE_BIO|INTR_ENTROPY, - aac_intr, sc, &sc->aac_intr)) { - device_printf(sc->aac_dev, "can't set up interrupt\n"); - goto out; - } + if (bus_setup_intr(sc->aac_dev, sc->aac_irq, INTR_TYPE_BIO|INTR_ENTROPY, + aac_intr, sc, &sc->aac_intr)) { + device_printf(sc->aac_dev, "can't set up interrupt\n"); + goto out; + } - /* assume failure is 'out of memory' */ - error = ENOMEM; + /* assume failure is 'out of memory' */ + error = ENOMEM; - /* - * Allocate the parent bus DMA tag appropriate for our PCI interface. - * - * Note that some of these controllers are 64-bit capable. - */ - if (bus_dma_tag_create(NULL, /* parent */ - 1, 0, /* algnmnt, boundary */ - BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ - BUS_SPACE_MAXADDR, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MAXBSIZE, AAC_MAXSGENTRIES, /* maxsize, nsegments */ - BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - &sc->aac_parent_dmat)) { - device_printf(sc->aac_dev, "can't allocate parent DMA tag\n"); - goto out; - } + /* + * Allocate the parent bus DMA tag appropriate for our PCI interface. + * + * Note that some of these controllers are 64-bit capable. + */ + if (bus_dma_tag_create(NULL, /* parent */ + 1, 0, /* algnmnt, boundary */ + BUS_SPACE_MAXADDR_32BIT, /* lowaddr */ + BUS_SPACE_MAXADDR, /* highaddr */ + NULL, NULL, /* filter, filterarg */ + MAXBSIZE, /* maxsize */ + AAC_MAXSGENTRIES, /* nsegments */ + BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ + BUS_DMA_ALLOCNOW, /* flags */ + &sc->aac_parent_dmat)) { + device_printf(sc->aac_dev, "can't allocate parent DMA tag\n"); + goto out; + } - /* - * Create DMA tag for mapping buffers into controller-addressable space. - */ - if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ + /* + * Create DMA tag for mapping buffers into controller-addressable space. + */ + if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ 1, 0, /* algnmnt, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ @@ -232,14 +239,14 @@ aac_pci_attach(device_t dev) BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ &sc->aac_buffer_dmat)) { - device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n"); - goto out; - } + device_printf(sc->aac_dev, "can't allocate buffer DMA tag\n"); + goto out; + } - /* - * Create DMA tag for mapping FIBs into controller-addressable space.. - */ - if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ + /* + * Create DMA tag for mapping FIBs into controller-addressable space.. + */ + if (bus_dma_tag_create(sc->aac_parent_dmat, /* parent */ 1, 0, /* algnmnt, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ @@ -249,46 +256,46 @@ aac_pci_attach(device_t dev) BUS_SPACE_MAXSIZE_32BIT, /* maxsegsize */ 0, /* flags */ &sc->aac_fib_dmat)) { - device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n"); - goto out; - } - - /* - * Detect the hardware interface version, set up the bus interface - * indirection. - */ - sc->aac_hwif = AAC_HWIF_UNKNOWN; - for (i = 0; aac_identifiers[i].vendor != 0; i++) { - if ((aac_identifiers[i].vendor == pci_get_vendor(dev)) && - (aac_identifiers[i].device == pci_get_device(dev))) { - sc->aac_hwif = aac_identifiers[i].hwif; - switch(sc->aac_hwif) { - case AAC_HWIF_I960RX: - debug(2, "set hardware up for i960Rx"); - sc->aac_if = aac_rx_interface; - break; - - case AAC_HWIF_STRONGARM: - debug(2, "set hardware up for StrongARM"); - sc->aac_if = aac_sa_interface; - break; - } - break; + device_printf(sc->aac_dev, "can't allocate FIB DMA tag\n"); + goto out; } - } - if (sc->aac_hwif == AAC_HWIF_UNKNOWN) { - device_printf(sc->aac_dev, "unknown hardware type\n"); - error = ENXIO; - goto out; - } - /* - * Do bus-independent initialisation. - */ - error = aac_attach(sc); - + /* + * Detect the hardware interface version, set up the bus interface + * indirection. + */ + sc->aac_hwif = AAC_HWIF_UNKNOWN; + for (i = 0; aac_identifiers[i].vendor != 0; i++) { + if ((aac_identifiers[i].vendor == pci_get_vendor(dev)) && + (aac_identifiers[i].device == pci_get_device(dev))) { + sc->aac_hwif = aac_identifiers[i].hwif; + switch(sc->aac_hwif) { + case AAC_HWIF_I960RX: + debug(2, "set hardware up for i960Rx"); + sc->aac_if = aac_rx_interface; + break; + + case AAC_HWIF_STRONGARM: + debug(2, "set hardware up for StrongARM"); + sc->aac_if = aac_sa_interface; + break; + } + break; + } + } + if (sc->aac_hwif == AAC_HWIF_UNKNOWN) { + device_printf(sc->aac_dev, "unknown hardware type\n"); + error = ENXIO; + goto out; + } + + /* + * Do bus-independent initialisation. + */ + error = aac_attach(sc); + out: - if (error) - aac_free(sc); - return(error); + if (error) + aac_free(sc); + return(error); } diff --git a/sys/dev/aac/aac_tables.h b/sys/dev/aac/aac_tables.h index d994ae622181..b1343d41b828 100644 --- a/sys/dev/aac/aac_tables.h +++ b/sys/dev/aac/aac_tables.h @@ -34,84 +34,84 @@ * relevant only to FSA operations. */ static struct aac_code_lookup aac_command_status_table[] = { - {"OK", 0}, - {"operation not permitted", 1}, - {"not found", 2}, - {"I/O error", 5}, - {"device not configured", 6}, - {"too big", 7}, - {"permission denoed", 13}, - {"file exists", 17}, - {"cross-device link", 18}, - {"operation not supported by device", 19}, - {"not a directory", 20}, - {"is a directory", 21}, - {"invalid argument", 22}, - {"file too large", 27}, - {"no space on device", 28}, - {"readonly filesystem", 30}, - {"too many links", 31}, - {"operation would block", 35}, - {"file name too long", 63}, - {"directory not empty", 66}, - {"quota exceeded", 69}, - {"stale file handle", 70}, - {"too many levels of remote in path", 71}, - {"bad file handle", 10001}, - {"not sync", 10002}, - {"bad cookie", 10003}, - {"operation not supported", 10004}, - {"too small", 10005}, - {"server fault", 10006}, - {"bad type", 10007}, - {"jukebox", 10008}, - {"not mounted", 10009}, - {"in maintenace mode", 10010}, - {"stale ACL", 10011}, - {NULL, 0}, - {"unknown command status", 0} + {"OK", 0}, + {"operation not permitted", 1}, + {"not found", 2}, + {"I/O error", 5}, + {"device not configured", 6}, + {"too big", 7}, + {"permission denoed", 13}, + {"file exists", 17}, + {"cross-device link", 18}, + {"operation not supported by device", 19}, + {"not a directory", 20}, + {"is a directory", 21}, + {"invalid argument", 22}, + {"file too large", 27}, + {"no space on device", 28}, + {"readonly filesystem", 30}, + {"too many links", 31}, + {"operation would block", 35}, + {"file name too long", 63}, + {"directory not empty", 66}, + {"quota exceeded", 69}, + {"stale file handle", 70}, + {"too many levels of remote in path", 71}, + {"bad file handle", 10001}, + {"not sync", 10002}, + {"bad cookie", 10003}, + {"operation not supported", 10004}, + {"too small", 10005}, + {"server fault", 10006}, + {"bad type", 10007}, + {"jukebox", 10008}, + {"not mounted", 10009}, + {"in maintenace mode", 10010}, + {"stale ACL", 10011}, + {NULL, 0}, + {"unknown command status", 0} }; #define AAC_COMMAND_STATUS(x) aac_describe_code(aac_command_status_table, x) static struct aac_code_lookup aac_cpu_variant[] = { - {"i960JX", CPUI960_JX}, - {"i960CX", CPUI960_CX}, - {"i960HX", CPUI960_HX}, - {"i960RX", CPUI960_RX}, - {"StrongARM SA110", CPUARM_SA110}, - {"PowerPC 603e", CPUPPC_603e}, - {"Unknown StrongARM", CPUARM_xxx}, - {"Unknown PowerPC", CPUPPC_xxx}, - {NULL, 0}, - {"Unknown processor", 0} + {"i960JX", CPUI960_JX}, + {"i960CX", CPUI960_CX}, + {"i960HX", CPUI960_HX}, + {"i960RX", CPUI960_RX}, + {"StrongARM SA110", CPUARM_SA110}, + {"PowerPC 603e", CPUPPC_603e}, + {"Unknown StrongARM", CPUARM_xxx}, + {"Unknown PowerPC", CPUPPC_xxx}, + {NULL, 0}, + {"Unknown processor", 0} }; static struct aac_code_lookup aac_battery_platform[] = { - {"required battery present", PLATFORM_BAT_REQ_PRESENT}, - {"REQUIRED BATTERY NOT PRESENT", PLATFORM_BAT_REQ_NOTPRESENT}, - {"optional battery present", PLATFORM_BAT_OPT_PRESENT}, - {"optional battery not installed", PLATFORM_BAT_OPT_NOTPRESENT}, - {"no battery support", PLATFORM_BAT_NOT_SUPPORTED}, - {NULL, 0}, - {"unknown battery platform", 0} + {"required battery present", PLATFORM_BAT_REQ_PRESENT}, + {"REQUIRED BATTERY NOT PRESENT", PLATFORM_BAT_REQ_NOTPRESENT}, + {"optional battery present", PLATFORM_BAT_OPT_PRESENT}, + {"optional battery not installed", PLATFORM_BAT_OPT_NOTPRESENT}, + {"no battery support", PLATFORM_BAT_NOT_SUPPORTED}, + {NULL, 0}, + {"unknown battery platform", 0} }; static struct aac_code_lookup aac_container_types[] = { - {"Volume", CT_VOLUME}, - {"RAID 1 (Mirror)", CT_MIRROR}, - {"RAID 0 (Stripe)", CT_STRIPE}, - {"RAID 5", CT_RAID5}, - {"SSRW", CT_SSRW}, - {"SSRO", CT_SSRO}, - {"Morph", CT_MORPH}, - {"Passthrough", CT_PASSTHRU}, - {"RAID 4", CT_RAID4}, - {"RAID 10", CT_RAID10}, - {"RAID 00", CT_RAID00}, - {"Volume of Mirrors", CT_VOLUME_OF_MIRRORS}, - {"Pseudo RAID 3", CT_PSEUDO_RAID3}, - {NULL, 0}, - {"unknown", 0} + {"Volume", CT_VOLUME}, + {"RAID 1 (Mirror)", CT_MIRROR}, + {"RAID 0 (Stripe)", CT_STRIPE}, + {"RAID 5", CT_RAID5}, + {"SSRW", CT_SSRW}, + {"SSRO", CT_SSRO}, + {"Morph", CT_MORPH}, + {"Passthrough", CT_PASSTHRU}, + {"RAID 4", CT_RAID4}, + {"RAID 10", CT_RAID10}, + {"RAID 00", CT_RAID00}, + {"Volume of Mirrors", CT_VOLUME_OF_MIRRORS}, + {"Pseudo RAID 3", CT_PSEUDO_RAID3}, + {NULL, 0}, + {"unknown", 0} }; diff --git a/sys/dev/aac/aacreg.h b/sys/dev/aac/aacreg.h index e349a9183f18..735ccd6763f1 100644 --- a/sys/dev/aac/aacreg.h +++ b/sys/dev/aac/aacreg.h @@ -36,13 +36,13 @@ * two slightly easier. */ -/****************************************************************************** +/* * Misc. magic numbers. */ #define AAC_MAX_CONTAINERS 64 #define AAC_BLOCK_SIZE 512 -/****************************************************************************** +/* * Communications interface. * * Where datastructure layouts are closely parallel to the Adaptec sample code, @@ -82,8 +82,8 @@ #define AAC_QUEUE_ALIGN 16 struct aac_queue_entry { - u_int32_t aq_fib_size; /* FIB size in bytes */ - u_int32_t aq_fib_addr; /* receiver-space address of the FIB */ + u_int32_t aq_fib_size; /* FIB size in bytes */ + u_int32_t aq_fib_addr; /* receiver-space address of the FIB */ } __attribute__ ((packed)); #define AAC_PRODUCER_INDEX 0 @@ -94,18 +94,18 @@ struct aac_queue_entry { * controller. This structure must be aligned to AAC_QUEUE_ALIGN */ struct aac_queue_table { - /* queue consumer/producer indexes (layout mandated by adapter) */ - u_int32_t qt_qindex[AAC_QUEUE_COUNT][2]; + /* queue consumer/producer indexes (layout mandated by adapter) */ + u_int32_t qt_qindex[AAC_QUEUE_COUNT][2]; - /* queue entry structures (layout mandated by adapter) */ - struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES]; - struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES]; - struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES]; - struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES]; - struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES]; - struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES]; - struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES]; - struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES]; + /* queue entry structures (layout mandated by adapter) */ + struct aac_queue_entry qt_HostNormCmdQueue [AAC_HOST_NORM_CMD_ENTRIES]; + struct aac_queue_entry qt_HostHighCmdQueue [AAC_HOST_HIGH_CMD_ENTRIES]; + struct aac_queue_entry qt_AdapNormCmdQueue [AAC_ADAP_NORM_CMD_ENTRIES]; + struct aac_queue_entry qt_AdapHighCmdQueue [AAC_ADAP_HIGH_CMD_ENTRIES]; + struct aac_queue_entry qt_HostNormRespQueue[AAC_HOST_NORM_RESP_ENTRIES]; + struct aac_queue_entry qt_HostHighRespQueue[AAC_HOST_HIGH_RESP_ENTRIES]; + struct aac_queue_entry qt_AdapNormRespQueue[AAC_ADAP_NORM_RESP_ENTRIES]; + struct aac_queue_entry qt_AdapHighRespQueue[AAC_ADAP_HIGH_RESP_ENTRIES]; } __attribute__ ((packed)); /* @@ -128,8 +128,8 @@ struct aac_queue_table { * our private command structure and don't touch these) */ struct aac_fib_list_entry { - struct fib_list_entry *Flink; - struct fib_list_entry *Blink; + struct fib_list_entry *Flink; + struct fib_list_entry *Blink; } __attribute__ ((packed)); /* @@ -137,84 +137,84 @@ struct aac_fib_list_entry { * and adapter. */ struct aac_fib_header { - u_int32_t XferState; - u_int16_t Command; - u_int8_t StructType; - u_int8_t Flags; - u_int16_t Size; - u_int16_t SenderSize; - u_int32_t SenderFibAddress; - u_int32_t ReceiverFibAddress; - u_int32_t SenderData; - union { - struct { - u_int32_t ReceiverTimeStart; - u_int32_t ReceiverTimeDone; - } _s; - struct aac_fib_list_entry FibLinks; - } _u; + u_int32_t XferState; + u_int16_t Command; + u_int8_t StructType; + u_int8_t Flags; + u_int16_t Size; + u_int16_t SenderSize; + u_int32_t SenderFibAddress; + u_int32_t ReceiverFibAddress; + u_int32_t SenderData; + union { + struct { + u_int32_t ReceiverTimeStart; + u_int32_t ReceiverTimeDone; + } _s; + struct aac_fib_list_entry FibLinks; + } _u; } __attribute__ ((packed)); #define AAC_FIB_DATASIZE (512 - sizeof(struct aac_fib_header)) struct aac_fib { - struct aac_fib_header Header; - u_int8_t data[AAC_FIB_DATASIZE]; + struct aac_fib_header Header; + u_int8_t data[AAC_FIB_DATASIZE]; } __attribute__ ((packed)); /* * FIB commands */ typedef enum { - TestCommandResponse = 1, - TestAdapterCommand = 2, + TestCommandResponse = 1, + TestAdapterCommand = 2, - /* lowlevel and comm commands */ - LastTestCommand = 100, - ReinitHostNormCommandQueue = 101, - ReinitHostHighCommandQueue = 102, - ReinitHostHighRespQueue = 103, - ReinitHostNormRespQueue = 104, - ReinitAdapNormCommandQueue = 105, - ReinitAdapHighCommandQueue = 107, - ReinitAdapHighRespQueue = 108, - ReinitAdapNormRespQueue = 109, - InterfaceShutdown = 110, - DmaCommandFib = 120, - StartProfile = 121, - TermProfile = 122, - SpeedTest = 123, - TakeABreakPt = 124, - RequestPerfData = 125, - SetInterruptDefTimer= 126, - SetInterruptDefCount= 127, - GetInterruptDefStatus= 128, - LastCommCommand = 129, + /* lowlevel and comm commands */ + LastTestCommand = 100, + ReinitHostNormCommandQueue = 101, + ReinitHostHighCommandQueue = 102, + ReinitHostHighRespQueue = 103, + ReinitHostNormRespQueue = 104, + ReinitAdapNormCommandQueue = 105, + ReinitAdapHighCommandQueue = 107, + ReinitAdapHighRespQueue = 108, + ReinitAdapNormRespQueue = 109, + InterfaceShutdown = 110, + DmaCommandFib = 120, + StartProfile = 121, + TermProfile = 122, + SpeedTest = 123, + TakeABreakPt = 124, + RequestPerfData = 125, + SetInterruptDefTimer= 126, + SetInterruptDefCount= 127, + GetInterruptDefStatus= 128, + LastCommCommand = 129, - /* filesystem commands */ - NuFileSystem = 300, - UFS = 301, - HostFileSystem = 302, - LastFileSystemCommand = 303, + /* filesystem commands */ + NuFileSystem = 300, + UFS = 301, + HostFileSystem = 302, + LastFileSystemCommand = 303, - /* Container Commands */ - ContainerCommand = 500, - ContainerCommand64 = 501, + /* Container Commands */ + ContainerCommand = 500, + ContainerCommand64 = 501, - /* Cluster Commands */ - ClusterCommand = 550, + /* Cluster Commands */ + ClusterCommand = 550, - /* Scsi Port commands (scsi passthrough) */ - ScsiPortCommand = 600, + /* Scsi Port commands (scsi passthrough) */ + ScsiPortCommand = 600, - /* misc house keeping and generic adapter initiated commands */ - AifRequest = 700, - CheckRevision = 701, - FsaHostShutdown = 702, - RequestAdapterInfo = 703, - IsAdapterPaused = 704, - SendHostTime = 705, - LastMiscCommand = 706 + /* misc house keeping and generic adapter initiated commands */ + AifRequest = 700, + CheckRevision = 701, + FsaHostShutdown = 702, + RequestAdapterInfo = 703, + IsAdapterPaused = 704, + SendHostTime = 705, + LastMiscCommand = 706 } AAC_FibCommands; /* @@ -268,198 +268,198 @@ typedef enum { * AAC_MONKER_INITSTRUCT command to point it at our control structures. */ struct aac_adapter_init { - u_int32_t InitStructRevision; + u_int32_t InitStructRevision; #define AAC_INIT_STRUCT_REVISION 3 - u_int32_t MiniPortRevision; - u_int32_t FilesystemRevision; - u_int32_t CommHeaderAddress; - u_int32_t FastIoCommAreaAddress; - u_int32_t AdapterFibsPhysicalAddress; - void *AdapterFibsVirtualAddress; - u_int32_t AdapterFibsSize; - u_int32_t AdapterFibAlign; - u_int32_t PrintfBufferAddress; - u_int32_t PrintfBufferSize; - u_int32_t HostPhysMemPages; - u_int32_t HostElapsedSeconds; + u_int32_t MiniPortRevision; + u_int32_t FilesystemRevision; + u_int32_t CommHeaderAddress; + u_int32_t FastIoCommAreaAddress; + u_int32_t AdapterFibsPhysicalAddress; + void *AdapterFibsVirtualAddress; + u_int32_t AdapterFibsSize; + u_int32_t AdapterFibAlign; + u_int32_t PrintfBufferAddress; + u_int32_t PrintfBufferSize; + u_int32_t HostPhysMemPages; + u_int32_t HostElapsedSeconds; } __attribute__ ((packed)); -/****************************************************************************** +/* * Shared data types */ /* * Container types */ typedef enum { - CT_NONE = 0, - CT_VOLUME, - CT_MIRROR, - CT_STRIPE, - CT_RAID5, - CT_SSRW, - CT_SSRO, - CT_MORPH, - CT_PASSTHRU, - CT_RAID4, - CT_RAID10, /* stripe of mirror */ - CT_RAID00, /* stripe of stripe */ - CT_VOLUME_OF_MIRRORS, /* volume of mirror */ - CT_PSEUDO_RAID3, /* really raid4 */ + CT_NONE = 0, + CT_VOLUME, + CT_MIRROR, + CT_STRIPE, + CT_RAID5, + CT_SSRW, + CT_SSRO, + CT_MORPH, + CT_PASSTHRU, + CT_RAID4, + CT_RAID10, /* stripe of mirror */ + CT_RAID00, /* stripe of stripe */ + CT_VOLUME_OF_MIRRORS, /* volume of mirror */ + CT_PSEUDO_RAID3, /* really raid4 */ } AAC_FSAVolType; /* * Host-addressable object types */ typedef enum { - FT_REG = 1, /* regular file */ - FT_DIR, /* directory */ - FT_BLK, /* "block" device - reserved */ - FT_CHR, /* "character special" device - reserved */ - FT_LNK, /* symbolic link */ - FT_SOCK, /* socket */ - FT_FIFO, /* fifo */ - FT_FILESYS, /* ADAPTEC's "FSA"(tm) filesystem */ - FT_DRIVE, /* physical disk - addressable in scsi by bus/target/lun */ - FT_SLICE, /* virtual disk - raw volume - slice */ - FT_PARTITION, /* FSA partition - carved out of a slice - building block - * for containers */ - FT_VOLUME, /* Container - Volume Set */ - FT_STRIPE, /* Container - Stripe Set */ - FT_MIRROR, /* Container - Mirror Set */ - FT_RAID5, /* Container - Raid 5 Set */ - FT_DATABASE /* Storage object with "foreign" content manager */ + FT_REG = 1, /* regular file */ + FT_DIR, /* directory */ + FT_BLK, /* "block" device - reserved */ + FT_CHR, /* "character special" device - reserved */ + FT_LNK, /* symbolic link */ + FT_SOCK, /* socket */ + FT_FIFO, /* fifo */ + FT_FILESYS, /* ADAPTEC's "FSA"(tm) filesystem */ + FT_DRIVE, /* physical disk - addressable in scsi by b/t/l */ + FT_SLICE, /* virtual disk - raw volume - slice */ + FT_PARTITION, /* FSA partition - carved out of a slice - building + * block for containers */ + FT_VOLUME, /* Container - Volume Set */ + FT_STRIPE, /* Container - Stripe Set */ + FT_MIRROR, /* Container - Mirror Set */ + FT_RAID5, /* Container - Raid 5 Set */ + FT_DATABASE /* Storage object with "foreign" content manager */ } AAC_FType; /* * Host-side scatter/gather list for 32-bit commands. */ struct aac_sg_entry { - u_int32_t SgAddress; - u_int32_t SgByteCount; + u_int32_t SgAddress; + u_int32_t SgByteCount; } __attribute__ ((packed)); struct aac_sg_table { - u_int32_t SgCount; - struct aac_sg_entry SgEntry[0]; + u_int32_t SgCount; + struct aac_sg_entry SgEntry[0]; } __attribute__ ((packed)); /* * Host-side scatter/gather list for 64-bit commands. */ struct aac_sg_table64 { - u_int8_t SgCount; - u_int8_t SgSectorsPerPage; - u_int16_t SgByteOffset; - u_int64_t SgEntry[0]; + u_int8_t SgCount; + u_int8_t SgSectorsPerPage; + u_int16_t SgByteOffset; + u_int64_t SgEntry[0]; } __attribute__ ((packed)); /* * Container creation data */ struct aac_container_creation { - u_int8_t ViaBuildNumber; - u_int8_t MicroSecond; - u_int8_t Via; /* 1 = FSU, 2 = API, etc. */ - u_int8_t YearsSince1900; - u_int32_t Month:4; /* 1-12 */ - u_int32_t Day:6; /* 1-32 */ - u_int32_t Hour:6; /* 0-23 */ - u_int32_t Minute:6; /* 0-59 */ - u_int32_t Second:6; /* 0-59 */ - u_int64_t ViaAdapterSerialNumber; + u_int8_t ViaBuildNumber; + u_int8_t MicroSecond; + u_int8_t Via; /* 1 = FSU, 2 = API, etc. */ + u_int8_t YearsSince1900; + u_int32_t Month:4; /* 1-12 */ + u_int32_t Day:6; /* 1-32 */ + u_int32_t Hour:6; /* 0-23 */ + u_int32_t Minute:6; /* 0-59 */ + u_int32_t Second:6; /* 0-59 */ + u_int64_t ViaAdapterSerialNumber; } __attribute__ ((packed)); -/****************************************************************************** +/* * Revision number handling */ typedef enum { - RevApplication = 1, - RevDkiCli, - RevNetService, - RevApi, - RevFileSysDriver, - RevMiniportDriver, - RevAdapterSW, - RevMonitor, - RevRemoteApi + RevApplication = 1, + RevDkiCli, + RevNetService, + RevApi, + RevFileSysDriver, + RevMiniportDriver, + RevAdapterSW, + RevMonitor, + RevRemoteApi } RevComponent; struct FsaRevision { - union { - struct { - u_int8_t dash; - u_int8_t type; - u_int8_t minor; - u_int8_t major; - } comp; - u_int32_t ul; - } external; - u_int32_t buildNumber; + union { + struct { + u_int8_t dash; + u_int8_t type; + u_int8_t minor; + u_int8_t major; + } comp; + u_int32_t ul; + } external; + u_int32_t buildNumber; } __attribute__ ((packed)); -/****************************************************************************** +/* * Adapter Information */ typedef enum { - CPU_NTSIM = 1, - CPU_I960, - CPU_ARM, - CPU_SPARC, - CPU_POWERPC, - CPU_ALPHA, - CPU_P7, - CPU_I960_RX, - CPU__last + CPU_NTSIM = 1, + CPU_I960, + CPU_ARM, + CPU_SPARC, + CPU_POWERPC, + CPU_ALPHA, + CPU_P7, + CPU_I960_RX, + CPU__last } AAC_CpuType; typedef enum { - CPUI960_JX = 1, - CPUI960_CX, - CPUI960_HX, - CPUI960_RX, - CPUARM_SA110, - CPUARM_xxx, - CPUPPC_603e, - CPUPPC_xxx, - CPUSUBTYPE__last + CPUI960_JX = 1, + CPUI960_CX, + CPUI960_HX, + CPUI960_RX, + CPUARM_SA110, + CPUARM_xxx, + CPUPPC_603e, + CPUPPC_xxx, + CPUSUBTYPE__last } AAC_CpuSubType; typedef enum { - PLAT_NTSIM = 1, - PLAT_V3ADU, - PLAT_CYCLONE, - PLAT_CYCLONE_HD, - PLAT_BATBOARD, - PLAT_BATBOARD_HD, - PLAT_YOLO, - PLAT_COBRA, - PLAT_ANAHEIM, - PLAT_JALAPENO, - PLAT_QUEENS, - PLAT_JALAPENO_DELL, - PLAT_POBLANO, - PLAT_POBLANO_OPAL, - PLAT_POBLANO_SL0, - PLAT_POBLANO_SL1, - PLAT_POBLANO_SL2, - PLAT_POBLANO_XXX, - PLAT_JALAPENO_P2, - PLAT_HABANERO, - PLAT__last + PLAT_NTSIM = 1, + PLAT_V3ADU, + PLAT_CYCLONE, + PLAT_CYCLONE_HD, + PLAT_BATBOARD, + PLAT_BATBOARD_HD, + PLAT_YOLO, + PLAT_COBRA, + PLAT_ANAHEIM, + PLAT_JALAPENO, + PLAT_QUEENS, + PLAT_JALAPENO_DELL, + PLAT_POBLANO, + PLAT_POBLANO_OPAL, + PLAT_POBLANO_SL0, + PLAT_POBLANO_SL1, + PLAT_POBLANO_SL2, + PLAT_POBLANO_XXX, + PLAT_JALAPENO_P2, + PLAT_HABANERO, + PLAT__last } AAC_Platform; typedef enum { - OEM_FLAVOR_ADAPTEC = 1, - OEM_FLAVOR_DELL, - OEM_FLAVOR_HP, - OEM_FLAVOR_IBM, - OEM_FLAVOR_CPQ, - OEM_FLAVOR_BRAND_X, - OEM_FLAVOR_BRAND_Y, - OEM_FLAVOR_BRAND_Z, - OEM_FLAVOR__last + OEM_FLAVOR_ADAPTEC = 1, + OEM_FLAVOR_DELL, + OEM_FLAVOR_HP, + OEM_FLAVOR_IBM, + OEM_FLAVOR_CPQ, + OEM_FLAVOR_BRAND_X, + OEM_FLAVOR_BRAND_Y, + OEM_FLAVOR_BRAND_Z, + OEM_FLAVOR__last } AAC_OemFlavor; /* @@ -467,11 +467,11 @@ typedef enum { */ typedef enum { - PLATFORM_BAT_REQ_PRESENT = 1, /* BATTERY REQUIRED AND PRESENT */ - PLATFORM_BAT_REQ_NOTPRESENT, /* BATTERY REQUIRED AND NOT PRESENT */ - PLATFORM_BAT_OPT_PRESENT, /* BATTERY OPTIONAL AND PRESENT */ - PLATFORM_BAT_OPT_NOTPRESENT, /* BATTERY OPTIONAL AND NOT PRESENT */ - PLATFORM_BAT_NOT_SUPPORTED /* BATTERY NOT SUPPORTED */ + PLATFORM_BAT_REQ_PRESENT = 1, /* BATTERY REQUIRED AND PRESENT */ + PLATFORM_BAT_REQ_NOTPRESENT, /* BATTERY REQUIRED AND NOT PRESENT */ + PLATFORM_BAT_OPT_PRESENT, /* BATTERY OPTIONAL AND PRESENT */ + PLATFORM_BAT_OPT_NOTPRESENT, /* BATTERY OPTIONAL AND NOT PRESENT */ + PLATFORM_BAT_NOT_SUPPORTED /* BATTERY NOT SUPPORTED */ } AAC_BatteryPlatform; /* @@ -490,28 +490,30 @@ typedef enum * Structure used to respond to a RequestAdapterInfo fib. */ struct aac_adapter_info { - AAC_Platform PlatformBase; /* adapter type */ - AAC_CpuType CpuArchitecture; /* adapter CPU type */ - AAC_CpuSubType CpuVariant; /* adapter CPU subtype */ - u_int32_t ClockSpeed; /* adapter CPU clockspeed */ - u_int32_t ExecutionMem; /* adapter Execution Memory size */ - u_int32_t BufferMem; /* adapter Data Memory */ - u_int32_t TotalMem; /* adapter Total Memory */ - struct FsaRevision KernelRevision; /* adapter Kernel Software Revision */ - struct FsaRevision MonitorRevision; /* adapter Monitor/Diagnostic - * Software Revision */ - struct FsaRevision HardwareRevision;/* TBD */ - struct FsaRevision BIOSRevision; /* adapter BIOS Revision */ - u_int32_t ClusteringEnabled; - u_int32_t ClusterChannelMask; - u_int64_t SerialNumber; - AAC_BatteryPlatform batteryPlatform; - u_int32_t SupportedOptions; /* supported features of this - * controller */ - AAC_OemFlavor OemVariant; + AAC_Platform PlatformBase; /* adapter type */ + AAC_CpuType CpuArchitecture; /* adapter CPU type */ + AAC_CpuSubType CpuVariant; /* adapter CPU subtype */ + u_int32_t ClockSpeed; /* adapter CPU clockspeed */ + u_int32_t ExecutionMem; /* adapter Execution Memory + * size */ + u_int32_t BufferMem; /* adapter Data Memory */ + u_int32_t TotalMem; /* adapter Total Memory */ + struct FsaRevision KernelRevision; /* adapter Kernel Software + * Revision */ + struct FsaRevision MonitorRevision; /* adapter Monitor/Diagnostic + * Software Revision */ + struct FsaRevision HardwareRevision;/* TBD */ + struct FsaRevision BIOSRevision; /* adapter BIOS Revision */ + u_int32_t ClusteringEnabled; + u_int32_t ClusterChannelMask; + u_int64_t SerialNumber; + AAC_BatteryPlatform batteryPlatform; + u_int32_t SupportedOptions; /* supported features of this + * controller */ + AAC_OemFlavor OemVariant; } __attribute__ ((packed)); -/****************************************************************************** +/* * Monitor/Kernel interface. */ @@ -537,7 +539,7 @@ struct aac_adapter_info { #define AAC_UP_AND_RUNNING 0x00000080 #define AAC_KERNEL_PANIC 0x00000100 -/****************************************************************************** +/* * Data types relating to control and monitoring of the NVRAM/WriteCache * subsystem. */ @@ -548,13 +550,12 @@ struct aac_adapter_info { * NVRAM/Write Cache subsystem states */ typedef enum { - NVSTATUS_DISABLED = 0, /* present, clean, not being used */ - NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */ - NVSTATUS_ERROR, /* present, dirty, contains dirty data */ - /* for bad/missing device */ - NVSTATUS_BATTERY, /* present, bad or low battery, may contain dirty data */ - /* for bad/missing device */ - NVSTATUS_UNKNOWN + NVSTATUS_DISABLED = 0, /* present, clean, not being used */ + NVSTATUS_ENABLED, /* present, possibly dirty, ready for use */ + NVSTATUS_ERROR, /* present, dirty, contains dirty data */ + NVSTATUS_BATTERY, /* present, bad or low battery, may contain + * dirty data */ + NVSTATUS_UNKNOWN /* for bad/missing device */ } AAC_NVSTATUS; /* @@ -562,52 +563,58 @@ typedef enum { * */ typedef enum { - NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */ - NVBATTSTATUS_LOW, /* battery is low on power */ - NVBATTSTATUS_OK, /* battery is okay - normal operation possible only in this state */ - NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning in process */ + NVBATTSTATUS_NONE = 0, /* battery has no power or is not present */ + NVBATTSTATUS_LOW, /* battery is low on power */ + NVBATTSTATUS_OK, /* battery is okay - normal operation possible + * only in this state */ + NVBATTSTATUS_RECONDITIONING /* no battery present - reconditioning + * in process */ } AAC_NVBATTSTATUS; /* * Battery transition type */ typedef enum { - NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not present */ - NVBATT_TRANSITION_LOW, /* battery is now low on power */ - NVBATT_TRANSITION_OK /* battery is now okay - normal operation possible only in this state */ + NVBATT_TRANSITION_NONE = 0, /* battery now has no power or is not + * present */ + NVBATT_TRANSITION_LOW, /* battery is now low on power */ + NVBATT_TRANSITION_OK /* battery is now okay - normal + * operation possible only in this + * state */ } AAC_NVBATT_TRANSITION; /* * NVRAM Info structure returned for NVRAM_GetInfo call */ struct aac_nvramdevinfo { - u_int32_t NV_Enabled; /* write caching enabled */ - u_int32_t NV_Error; /* device in error state */ - u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */ - u_int32_t NV_NActive; /* count of NVRAM buffers being written */ + u_int32_t NV_Enabled; /* write caching enabled */ + u_int32_t NV_Error; /* device in error state */ + u_int32_t NV_NDirty; /* count of dirty NVRAM buffers */ + u_int32_t NV_NActive; /* count of NVRAM buffers being + * written */ } __attribute__ ((packed)); struct aac_nvraminfo { - AAC_NVSTATUS NV_Status; /* nvram subsystem status */ - AAC_NVBATTSTATUS NV_BattStatus; /* battery status */ - u_int32_t NV_Size; /* size of WriteCache NVRAM in + AAC_NVSTATUS NV_Status; /* nvram subsystem status */ + AAC_NVBATTSTATUS NV_BattStatus; /* battery status */ + u_int32_t NV_Size; /* size of WriteCache NVRAM in * bytes */ - u_int32_t NV_BufSize; /* size of NVRAM buffers in + u_int32_t NV_BufSize; /* size of NVRAM buffers in * bytes */ - u_int32_t NV_NBufs; /* number of NVRAM buffers */ - u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */ - u_int32_t NV_NClean; /* Num clean NVRAM buffers */ - u_int32_t NV_NActive; /* Num NVRAM buffers being + u_int32_t NV_NBufs; /* number of NVRAM buffers */ + u_int32_t NV_NDirty; /* Num dirty NVRAM buffers */ + u_int32_t NV_NClean; /* Num clean NVRAM buffers */ + u_int32_t NV_NActive; /* Num NVRAM buffers being * written */ - u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */ - struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device + u_int32_t NV_NBrokered; /* Num brokered NVRAM buffers */ + struct aac_nvramdevinfo NV_DevInfo[AAC_NFILESYS]; /* per device * info */ - u_int32_t NV_BattNeedsReconditioning; /* boolean */ - u_int32_t NV_TotalSize; /* size of all non-volatile + u_int32_t NV_BattNeedsReconditioning; /* boolean */ + u_int32_t NV_TotalSize; /* size of all non-volatile * memories in bytes */ } __attribute__ ((packed)); -/****************************************************************************** +/* * Data types relating to adapter-initiated FIBs * * Based on types and structures in @@ -617,183 +624,185 @@ struct aac_nvraminfo { * Progress Reports */ typedef enum { - AifJobStsSuccess = 1, - AifJobStsFinished, - AifJobStsAborted, - AifJobStsFailed, - AifJobStsLastReportMarker = 100, /* All before mean last report */ - AifJobStsSuspended, - AifJobStsRunning + AifJobStsSuccess = 1, + AifJobStsFinished, + AifJobStsAborted, + AifJobStsFailed, + AifJobStsLastReportMarker = 100, /* All prior mean last report */ + AifJobStsSuspended, + AifJobStsRunning } AAC_AifJobStatus; typedef enum { - AifJobScsiMin = 1, /* Minimum value for Scsi operation */ - AifJobScsiZero, /* SCSI device clear operation */ - AifJobScsiVerify, /* SCSI device Verify operation NO + AifJobScsiMin = 1, /* Minimum value for Scsi operation */ + AifJobScsiZero, /* SCSI device clear operation */ + AifJobScsiVerify, /* SCSI device Verify operation NO * REPAIR */ - AifJobScsiExercise, /* SCSI device Exercise operation */ - AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH + AifJobScsiExercise, /* SCSI device Exercise operation */ + AifJobScsiVerifyRepair, /* SCSI device Verify operation WITH * repair */ - AifJobScsiMax = 99, /* Max Scsi value */ - AifJobCtrMin, /* Min Ctr op value */ - AifJobCtrZero, /* Container clear operation */ - AifJobCtrCopy, /* Container copy operation */ - AifJobCtrCreateMirror, /* Container Create Mirror operation */ - AifJobCtrMergeMirror, /* Container Merge Mirror operation */ - AifJobCtrScrubMirror, /* Container Scrub Mirror operation */ - AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */ - AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */ - AifJobCtrMorph, /* Container morph operation */ - AifJobCtrPartCopy, /* Container Partition copy operation */ - AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */ - AifJobCtrCrazyCache, /* crazy cache */ - AifJobCtrMax = 199, /* Max Ctr type operation */ - AifJobFsMin, /* Min Fs type operation */ - AifJobFsCreate, /* File System Create operation */ - AifJobFsVerify, /* File System Verify operation */ - AifJobFsExtend, /* File System Extend operation */ - AifJobFsMax = 299, /* Max Fs type operation */ - AifJobApiFormatNTFS, /* Format a drive to NTFS */ - AifJobApiFormatFAT, /* Format a drive to FAT */ - AifJobApiUpdateSnapshot, /* update the read/write half of a + AifJobScsiMax = 99, /* Max Scsi value */ + AifJobCtrMin, /* Min Ctr op value */ + AifJobCtrZero, /* Container clear operation */ + AifJobCtrCopy, /* Container copy operation */ + AifJobCtrCreateMirror, /* Container Create Mirror operation */ + AifJobCtrMergeMirror, /* Container Merge Mirror operation */ + AifJobCtrScrubMirror, /* Container Scrub Mirror operation */ + AifJobCtrRebuildRaid5, /* Container Rebuild Raid5 operation */ + AifJobCtrScrubRaid5, /* Container Scrub Raid5 operation */ + AifJobCtrMorph, /* Container morph operation */ + AifJobCtrPartCopy, /* Container Partition copy operation */ + AifJobCtrRebuildMirror, /* Container Rebuild Mirror operation */ + AifJobCtrCrazyCache, /* crazy cache */ + AifJobCtrMax = 199, /* Max Ctr type operation */ + AifJobFsMin, /* Min Fs type operation */ + AifJobFsCreate, /* File System Create operation */ + AifJobFsVerify, /* File System Verify operation */ + AifJobFsExtend, /* File System Extend operation */ + AifJobFsMax = 299, /* Max Fs type operation */ + AifJobApiFormatNTFS, /* Format a drive to NTFS */ + AifJobApiFormatFAT, /* Format a drive to FAT */ + AifJobApiUpdateSnapshot, /* update the read/write half of a * snapshot */ - AifJobApiFormatFAT32, /* Format a drive to FAT32 */ - AifJobApiMax = 399, /* Max API type operation */ - AifJobCtlContinuousCtrVerify, /* Adapter operation */ - AifJobCtlMax = 499 /* Max Adapter type operation */ + AifJobApiFormatFAT32, /* Format a drive to FAT32 */ + AifJobApiMax = 399, /* Max API type operation */ + AifJobCtlContinuousCtrVerify, /* Adapter operation */ + AifJobCtlMax = 499 /* Max Adapter type operation */ } AAC_AifJobType; struct aac_AifContainers { - u_int32_t src; /* from/master */ - u_int32_t dst; /* to/slave */ + u_int32_t src; /* from/master */ + u_int32_t dst; /* to/slave */ } __attribute__ ((packed)); union aac_AifJobClient { - struct aac_AifContainers container; /* For Container and file - * system progress ops; */ - int32_t scsi_dh; /* For SCSI progress ops */ + struct aac_AifContainers container; /* For Container and + * file system progress + * ops; */ + int32_t scsi_dh; /* For SCSI progress + * ops */ }; struct aac_AifJobDesc { - u_int32_t jobID; /* DO NOT FILL IN! Will be + u_int32_t jobID; /* DO NOT FILL IN! Will be * filled in by AIF */ - AAC_AifJobType type; /* Operation that is being + AAC_AifJobType type; /* Operation that is being * performed */ - union aac_AifJobClient client; /* Details */ + union aac_AifJobClient client; /* Details */ } __attribute__ ((packed)); struct aac_AifJobProgressReport { - struct aac_AifJobDesc jd; - AAC_AifJobStatus status; - u_int32_t finalTick; - u_int32_t currentTick; - u_int32_t jobSpecificData1; - u_int32_t jobSpecificData2; + struct aac_AifJobDesc jd; + AAC_AifJobStatus status; + u_int32_t finalTick; + u_int32_t currentTick; + u_int32_t jobSpecificData1; + u_int32_t jobSpecificData2; } __attribute__ ((packed)); /* * Event Notification */ typedef enum { - /* General application notifies start here */ - AifEnGeneric = 1, /* Generic notification */ - AifEnTaskComplete, /* Task has completed */ - AifEnConfigChange, /* Adapter config change occurred */ - AifEnContainerChange, /* Adapter specific container + /* General application notifies start here */ + AifEnGeneric = 1, /* Generic notification */ + AifEnTaskComplete, /* Task has completed */ + AifEnConfigChange, /* Adapter config change occurred */ + AifEnContainerChange, /* Adapter specific container * configuration change */ - AifEnDeviceFailure, /* SCSI device failed */ - AifEnMirrorFailover, /* Mirror failover started */ - AifEnContainerEvent, /* Significant container event */ - AifEnFileSystemChange, /* File system changed */ - AifEnConfigPause, /* Container pause event */ - AifEnConfigResume, /* Container resume event */ - AifEnFailoverChange, /* Failover space assignment changed */ - AifEnRAID5RebuildDone, /* RAID5 rebuild finished */ - AifEnEnclosureManagement, /* Enclosure management event */ - AifEnBatteryEvent, /* Significant NV battery event */ - AifEnAddContainer, /* A new container was created. */ - AifEnDeleteContainer, /* A container was deleted. */ - AifEnSMARTEvent, /* SMART Event */ - AifEnBatteryNeedsRecond, /* The battery needs reconditioning */ - AifEnClusterEvent, /* Some cluster event */ - AifEnDiskSetEvent, /* A disk set event occured. */ - AifDriverNotifyStart=199, /* Notifies for host driver go here */ - /* Host driver notifications start here */ - AifDenMorphComplete, /* A morph operation completed */ - AifDenVolumeExtendComplete /* A volume expand operation completed */ + AifEnDeviceFailure, /* SCSI device failed */ + AifEnMirrorFailover, /* Mirror failover started */ + AifEnContainerEvent, /* Significant container event */ + AifEnFileSystemChange, /* File system changed */ + AifEnConfigPause, /* Container pause event */ + AifEnConfigResume, /* Container resume event */ + AifEnFailoverChange, /* Failover space assignment changed */ + AifEnRAID5RebuildDone, /* RAID5 rebuild finished */ + AifEnEnclosureManagement, /* Enclosure management event */ + AifEnBatteryEvent, /* Significant NV battery event */ + AifEnAddContainer, /* A new container was created. */ + AifEnDeleteContainer, /* A container was deleted. */ + AifEnSMARTEvent, /* SMART Event */ + AifEnBatteryNeedsRecond, /* The battery needs reconditioning */ + AifEnClusterEvent, /* Some cluster event */ + AifEnDiskSetEvent, /* A disk set event occured. */ + AifDriverNotifyStart=199, /* Notifies for host driver go here */ + /* Host driver notifications start here */ + AifDenMorphComplete, /* A morph operation completed */ + AifDenVolumeExtendComplete /* Volume expand operation completed */ } AAC_AifEventNotifyType; struct aac_AifEnsGeneric { - char text[132]; /* Generic text */ + char text[132]; /* Generic text */ } __attribute__ ((packed)); struct aac_AifEnsDeviceFailure { - u_int32_t deviceHandle; /* SCSI device handle */ + u_int32_t deviceHandle; /* SCSI device handle */ } __attribute__ ((packed)); struct aac_AifEnsMirrorFailover { - u_int32_t container; /* Container with failed element */ - u_int32_t failedSlice; /* Old slice which failed */ - u_int32_t creatingSlice; /* New slice used for auto-create */ + u_int32_t container; /* Container with failed element */ + u_int32_t failedSlice; /* Old slice which failed */ + u_int32_t creatingSlice; /* New slice used for auto-create */ } __attribute__ ((packed)); struct aac_AifEnsContainerChange { - u_int32_t container[2]; /* container that changed, -1 if no + u_int32_t container[2]; /* container that changed, -1 if no * container */ } __attribute__ ((packed)); struct aac_AifEnsContainerEvent { - u_int32_t container; /* container number */ - u_int32_t eventType; /* event type */ + u_int32_t container; /* container number */ + u_int32_t eventType; /* event type */ } __attribute__ ((packed)); struct aac_AifEnsEnclosureEvent { - u_int32_t empID; /* enclosure management proc number */ - u_int32_t unitID; /* unitId, fan id, power supply id, + u_int32_t empID; /* enclosure management proc number */ + u_int32_t unitID; /* unitId, fan id, power supply id, * slot id, tempsensor id. */ - u_int32_t eventType; /* event type */ + u_int32_t eventType; /* event type */ } __attribute__ ((packed)); struct aac_AifEnsBatteryEvent { - AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */ - AAC_NVBATTSTATUS current_state; /* current batt state */ - AAC_NVBATTSTATUS prior_state; /* prev batt state */ + AAC_NVBATT_TRANSITION transition_type; /* eg from low to ok */ + AAC_NVBATTSTATUS current_state; /* current batt state */ + AAC_NVBATTSTATUS prior_state; /* prev batt state */ } __attribute__ ((packed)); struct aac_AifEnsDiskSetEvent { - u_int32_t eventType; - u_int64_t DsNum; - u_int64_t CreatorId; + u_int32_t eventType; + u_int64_t DsNum; + u_int64_t CreatorId; } __attribute__ ((packed)); typedef enum { - CLUSTER_NULL_EVENT = 0, - CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or + CLUSTER_NULL_EVENT = 0, + CLUSTER_PARTNER_NAME_EVENT, /* change in partner hostname or * adaptername from NULL to non-NULL */ - /* (partner's agent may be up) */ - CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or + /* (partner's agent may be up) */ + CLUSTER_PARTNER_NULL_NAME_EVENT /* change in partner hostname or * adaptername from non-null to NULL */ - /* (partner has rebooted) */ + /* (partner has rebooted) */ } AAC_ClusterAifEvent; struct aac_AifEnsClusterEvent { - AAC_ClusterAifEvent eventType; + AAC_ClusterAifEvent eventType; } __attribute__ ((packed)); struct aac_AifEventNotify { - AAC_AifEventNotifyType type; - union { - struct aac_AifEnsGeneric EG; - struct aac_AifEnsDeviceFailure EDF; - struct aac_AifEnsMirrorFailover EMF; - struct aac_AifEnsContainerChange ECC; - struct aac_AifEnsContainerEvent ECE; - struct aac_AifEnsEnclosureEvent EEE; - struct aac_AifEnsBatteryEvent EBE; - struct aac_AifEnsDiskSetEvent EDS; -/* struct aac_AifEnsSMARTEvent ES;*/ - struct aac_AifEnsClusterEvent ECLE; - } data; + AAC_AifEventNotifyType type; + union { + struct aac_AifEnsGeneric EG; + struct aac_AifEnsDeviceFailure EDF; + struct aac_AifEnsMirrorFailover EMF; + struct aac_AifEnsContainerChange ECC; + struct aac_AifEnsContainerEvent ECE; + struct aac_AifEnsEnclosureEvent EEE; + struct aac_AifEnsBatteryEvent EBE; + struct aac_AifEnsDiskSetEvent EDS; +/* struct aac_AifEnsSMARTEvent ES;*/ + struct aac_AifEnsClusterEvent ECLE; + } data; } __attribute__ ((packed)); /* @@ -804,36 +813,36 @@ struct aac_AifEventNotify { #define AAC_AIF_REPORT_MAX_SIZE 64 typedef enum { - AifCmdEventNotify = 1, /* Notify of event */ - AifCmdJobProgress, /* Progress report */ - AifCmdAPIReport, /* Report from other user of API */ - AifCmdDriverNotify, /* Notify host driver of event */ - AifReqJobList = 100, /* Gets back complete job list */ - AifReqJobsForCtr, /* Gets back jobs for specific container */ - AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */ - AifReqJobReport, /* Gets back a specific job report or list */ - AifReqTerminateJob, /* Terminates job */ - AifReqSuspendJob, /* Suspends a job */ - AifReqResumeJob, /* Resumes a job */ - AifReqSendAPIReport, /* API generic report requests */ - AifReqAPIJobStart, /* Start a job from the API */ - AifReqAPIJobUpdate, /* Update a job report from the API */ - AifReqAPIJobFinish /* Finish a job from the API */ + AifCmdEventNotify = 1, /* Notify of event */ + AifCmdJobProgress, /* Progress report */ + AifCmdAPIReport, /* Report from other user of API */ + AifCmdDriverNotify, /* Notify host driver of event */ + AifReqJobList = 100, /* Gets back complete job list */ + AifReqJobsForCtr, /* Gets back jobs for specific container */ + AifReqJobsForScsi, /* Gets back jobs for specific SCSI device */ + AifReqJobReport, /* Gets back a specific job report or list */ + AifReqTerminateJob, /* Terminates job */ + AifReqSuspendJob, /* Suspends a job */ + AifReqResumeJob, /* Resumes a job */ + AifReqSendAPIReport, /* API generic report requests */ + AifReqAPIJobStart, /* Start a job from the API */ + AifReqAPIJobUpdate, /* Update a job report from the API */ + AifReqAPIJobFinish /* Finish a job from the API */ } AAC_AifCommand; struct aac_aif_command { - AAC_AifCommand command; /* Tell host what type of - * notify this is */ - u_int32_t seqNumber; /* To allow ordering of - * reports (if necessary) */ - union { + AAC_AifCommand command; /* Tell host what type of + * notify this is */ + u_int32_t seqNumber; /* To allow ordering of + * reports (if necessary) */ + union { struct aac_AifEventNotify EN; /* Event notify structure */ struct aac_AifJobProgressReport PR[1]; /* Progress report */ u_int8_t AR[AAC_AIF_REPORT_MAX_SIZE]; - } data; + } data; } __attribute__ ((packed)); -/****************************************************************************** +/* * Filesystem commands/data * * The adapter has a very complex filesystem interface, most of which we ignore. @@ -845,168 +854,168 @@ struct aac_aif_command { * (not used?) */ typedef enum { - Null = 0, - GetAttributes, - SetAttributes, - Lookup, - ReadLink, - Read, - Write, - Create, - MakeDirectory, - SymbolicLink, - MakeNode, - Removex, - RemoveDirectory, - Rename, - Link, - ReadDirectory, - ReadDirectoryPlus, - FileSystemStatus, - FileSystemInfo, - PathConfigure, - Commit, - Mount, - UnMount, - Newfs, - FsCheck, - FsSync, - SimReadWrite, - SetFileSystemStatus, - BlockRead, - BlockWrite, - NvramIoctl, - FsSyncWait, - ClearArchiveBit, - SetAcl, - GetAcl, - AssignAcl, - FaultInsertion, - CrazyCache + Null = 0, + GetAttributes, + SetAttributes, + Lookup, + ReadLink, + Read, + Write, + Create, + MakeDirectory, + SymbolicLink, + MakeNode, + Removex, + RemoveDirectory, + Rename, + Link, + ReadDirectory, + ReadDirectoryPlus, + FileSystemStatus, + FileSystemInfo, + PathConfigure, + Commit, + Mount, + UnMount, + Newfs, + FsCheck, + FsSync, + SimReadWrite, + SetFileSystemStatus, + BlockRead, + BlockWrite, + NvramIoctl, + FsSyncWait, + ClearArchiveBit, + SetAcl, + GetAcl, + AssignAcl, + FaultInsertion, + CrazyCache } AAC_FSACommand; /* * Command status values */ typedef enum { - ST_OK = 0, - ST_PERM = 1, - ST_NOENT = 2, - ST_IO = 5, - ST_NXIO = 6, - ST_E2BIG = 7, - ST_ACCES = 13, - ST_EXIST = 17, - ST_XDEV = 18, - ST_NODEV = 19, - ST_NOTDIR = 20, - ST_ISDIR = 21, - ST_INVAL = 22, - ST_FBIG = 27, - ST_NOSPC = 28, - ST_ROFS = 30, - ST_MLINK = 31, - ST_WOULDBLOCK = 35, - ST_NAMETOOLONG = 63, - ST_NOTEMPTY = 66, - ST_DQUOT = 69, - ST_STALE = 70, - ST_REMOTE = 71, - ST_BADHANDLE = 10001, - ST_NOT_SYNC = 10002, - ST_BAD_COOKIE = 10003, - ST_NOTSUPP = 10004, - ST_TOOSMALL = 10005, - ST_SERVERFAULT = 10006, - ST_BADTYPE = 10007, - ST_JUKEBOX = 10008, - ST_NOTMOUNTED = 10009, - ST_MAINTMODE = 10010, - ST_STALEACL = 10011 + ST_OK = 0, + ST_PERM = 1, + ST_NOENT = 2, + ST_IO = 5, + ST_NXIO = 6, + ST_E2BIG = 7, + ST_ACCES = 13, + ST_EXIST = 17, + ST_XDEV = 18, + ST_NODEV = 19, + ST_NOTDIR = 20, + ST_ISDIR = 21, + ST_INVAL = 22, + ST_FBIG = 27, + ST_NOSPC = 28, + ST_ROFS = 30, + ST_MLINK = 31, + ST_WOULDBLOCK = 35, + ST_NAMETOOLONG = 63, + ST_NOTEMPTY = 66, + ST_DQUOT = 69, + ST_STALE = 70, + ST_REMOTE = 71, + ST_BADHANDLE = 10001, + ST_NOT_SYNC = 10002, + ST_BAD_COOKIE = 10003, + ST_NOTSUPP = 10004, + ST_TOOSMALL = 10005, + ST_SERVERFAULT = 10006, + ST_BADTYPE = 10007, + ST_JUKEBOX = 10008, + ST_NOTMOUNTED = 10009, + ST_MAINTMODE = 10010, + ST_STALEACL = 10011 } AAC_FSAStatus; /* * Volume manager commands */ typedef enum _VM_COMMANDS { - VM_Null = 0, - VM_NameServe, - VM_ContainerConfig, - VM_Ioctl, - VM_FilesystemIoctl, - VM_CloseAll, - VM_CtBlockRead, - VM_CtBlockWrite, - VM_SliceBlockRead, /* raw access to configured "storage objects" */ - VM_SliceBlockWrite, - VM_DriveBlockRead, /* raw access to physical devices */ - VM_DriveBlockWrite, - VM_EnclosureMgt, /* enclosure management */ - VM_Unused, /* used to be diskset management */ - VM_CtBlockVerify, - VM_CtPerf, /* performance test */ - VM_CtBlockRead64, - VM_CtBlockWrite64, - VM_CtBlockVerify64, + VM_Null = 0, + VM_NameServe, + VM_ContainerConfig, + VM_Ioctl, + VM_FilesystemIoctl, + VM_CloseAll, + VM_CtBlockRead, + VM_CtBlockWrite, + VM_SliceBlockRead, /* raw access to configured storage objects */ + VM_SliceBlockWrite, + VM_DriveBlockRead, /* raw access to physical devices */ + VM_DriveBlockWrite, + VM_EnclosureMgt, /* enclosure management */ + VM_Unused, /* used to be diskset management */ + VM_CtBlockVerify, + VM_CtPerf, /* performance test */ + VM_CtBlockRead64, + VM_CtBlockWrite64, + VM_CtBlockVerify64, } AAC_VMCommand; /* * "mountable object" */ struct aac_mntobj { - u_int32_t ObjectId; - char FileSystemName[16]; - struct aac_container_creation CreateInfo; - u_int32_t Capacity; - AAC_FSAVolType VolType; - AAC_FType ObjType; - u_int32_t ContentState; + u_int32_t ObjectId; + char FileSystemName[16]; + struct aac_container_creation CreateInfo; + u_int32_t Capacity; + AAC_FSAVolType VolType; + AAC_FType ObjType; + u_int32_t ContentState; #define FSCS_READONLY 0x0002 /* XXX need more information * than this */ - union { - u_int32_t pad[8]; - } ObjExtension; - u_int32_t AlterEgoId; + union { + u_int32_t pad[8]; + } ObjExtension; + u_int32_t AlterEgoId; } __attribute__ ((packed)); struct aac_mntinfo { - AAC_VMCommand Command; - AAC_FType MntType; - u_int32_t MntCount; + AAC_VMCommand Command; + AAC_FType MntType; + u_int32_t MntCount; } __attribute__ ((packed)); struct aac_mntinforesponse { - AAC_FSAStatus Status; - AAC_FType MntType; - u_int32_t MntRespCount; - struct aac_mntobj MntTable[1]; + AAC_FSAStatus Status; + AAC_FType MntType; + u_int32_t MntRespCount; + struct aac_mntobj MntTable[1]; } __attribute__ ((packed)); /* * Container shutdown command. */ struct aac_closecommand { - u_int32_t Command; - u_int32_t ContainerId; + u_int32_t Command; + u_int32_t ContainerId; } __attribute__ ((packed)); /* * Write 'stability' options. */ typedef enum { - CSTABLE = 1, - CUNSTABLE + CSTABLE = 1, + CUNSTABLE } AAC_CacheLevel; /* * Commit level response for a write request. */ typedef enum { - CMFILE_SYNC_NVRAM = 1, - CMDATA_SYNC_NVRAM, - CMFILE_SYNC, - CMDATA_SYNC, - CMUNSTABLE + CMFILE_SYNC_NVRAM = 1, + CMDATA_SYNC_NVRAM, + CMFILE_SYNC, + CMDATA_SYNC, + CMUNSTABLE } AAC_CommitLevel; /* @@ -1015,42 +1024,42 @@ typedef enum { */ struct aac_blockread { - AAC_VMCommand Command; /* not FSACommand! */ - u_int32_t ContainerId; - u_int32_t BlockNumber; - u_int32_t ByteCount; - struct aac_sg_table SgMap; /* variable size */ + AAC_VMCommand Command; /* not FSACommand! */ + u_int32_t ContainerId; + u_int32_t BlockNumber; + u_int32_t ByteCount; + struct aac_sg_table SgMap; /* variable size */ } __attribute__ ((packed)); struct aac_blockread_response { - AAC_FSAStatus Status; - u_int32_t ByteCount; + AAC_FSAStatus Status; + u_int32_t ByteCount; } __attribute__ ((packed)); struct aac_blockwrite { - AAC_VMCommand Command; /* not FSACommand! */ - u_int32_t ContainerId; - u_int32_t BlockNumber; - u_int32_t ByteCount; - AAC_CacheLevel Stable; - struct aac_sg_table SgMap; /* variable size */ + AAC_VMCommand Command; /* not FSACommand! */ + u_int32_t ContainerId; + u_int32_t BlockNumber; + u_int32_t ByteCount; + AAC_CacheLevel Stable; + struct aac_sg_table SgMap; /* variable size */ } __attribute__ ((packed)); struct aac_blockwrite_response { - AAC_FSAStatus Status; - u_int32_t ByteCount; - AAC_CommitLevel Committed; + AAC_FSAStatus Status; + u_int32_t ByteCount; + AAC_CommitLevel Committed; } __attribute__ ((packed)); /* * Container shutdown command. */ struct aac_close_command { - AAC_VMCommand Command; - u_int32_t ContainerId; + AAC_VMCommand Command; + u_int32_t ContainerId; }; -/****************************************************************************** +/* * Register definitions for the Adaptec AAC-364 'Jalapeno I/II' adapters, based * on the SA110 'StrongArm'. */ @@ -1069,7 +1078,7 @@ struct aac_close_command { #define AAC_SA_MAILBOX 0xa8 /* mailbox (20 bytes) */ #define AAC_SA_FWSTATUS 0xc4 -/****************************************************************************** +/* * Register definitions for the Adaptec 'Pablano' adapters, based on the i960Rx, * and other related adapters. */ @@ -1084,7 +1093,7 @@ struct aac_close_command { #define AAC_RX_MAILBOX 0x50 /* mailbox (20 bytes) */ #define AAC_RX_FWSTATUS 0x6c -/****************************************************************************** +/* * Common bit definitions for the doorbell registers. */ @@ -1110,4 +1119,6 @@ struct aac_close_command { * Mask containing the interrupt bits we care about. We don't anticipate (or * want) interrupts not in this mask. */ -#define AAC_DB_INTERRUPTS (AAC_DB_COMMAND_READY | AAC_DB_RESPONSE_READY | AAC_DB_PRINTF) +#define AAC_DB_INTERRUPTS (AAC_DB_COMMAND_READY | \ + AAC_DB_RESPONSE_READY | \ + AAC_DB_PRINTF) diff --git a/sys/dev/aac/aacvar.h b/sys/dev/aac/aacvar.h index 2ed9221de7da..9395f2537ae2 100644 --- a/sys/dev/aac/aacvar.h +++ b/sys/dev/aac/aacvar.h @@ -29,11 +29,9 @@ * $FreeBSD$ */ -/****************************************************************************** - ****************************************************************************** - Driver Parameter Definitions - ****************************************************************************** - ******************************************************************************/ +/* + * Driver Parameter Definitions + */ /* * The firmware interface allows for a 16-bit s/g list length. We limit @@ -92,11 +90,9 @@ */ #define AAC_DISK_MAJOR 200 -/****************************************************************************** - ****************************************************************************** - Driver Variable Definitions - ****************************************************************************** - ******************************************************************************/ +/* + * Driver Variable Definitions + */ #if __FreeBSD_version >= 500005 # include @@ -107,10 +103,10 @@ */ struct aac_container { - struct aac_mntobj co_mntobj; - device_t co_disk; - int co_found; - TAILQ_ENTRY(aac_container) co_link; + struct aac_mntobj co_mntobj; + device_t co_disk; + int co_found; + TAILQ_ENTRY(aac_container) co_link; }; /* @@ -118,20 +114,20 @@ struct aac_container */ struct aac_disk { - device_t ad_dev; - dev_t ad_dev_t; - struct aac_softc *ad_controller; - struct aac_container *ad_container; - struct disk ad_disk; - struct devstat ad_stats; - struct disklabel ad_label; - int ad_flags; + device_t ad_dev; + dev_t ad_dev_t; + struct aac_softc *ad_controller; + struct aac_container *ad_container; + struct disk ad_disk; + struct devstat ad_stats; + struct disklabel ad_label; + int ad_flags; #define AAC_DISK_OPEN (1<<0) - int ad_cylinders; - int ad_heads; - int ad_sectors; - u_int32_t ad_size; - int unit; + int ad_cylinders; + int ad_heads; + int ad_sectors; + u_int32_t ad_size; + int unit; }; /* @@ -139,21 +135,20 @@ struct aac_disk */ struct aac_command { - TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ + TAILQ_ENTRY(aac_command) cm_link; /* list linkage */ - struct aac_softc *cm_sc; /* controller that owns us */ + struct aac_softc *cm_sc; /* controller that owns us */ - struct aac_fib *cm_fib; /* FIB associated with this + struct aac_fib *cm_fib; /* FIB associated with this * command */ - u_int32_t cm_fibphys; /* bus address of the FIB */ - struct bio *cm_data; /* pointer to data in kernel + u_int32_t cm_fibphys; /* bus address of the FIB */ + struct bio *cm_data; /* pointer to data in kernel * space */ - u_int32_t cm_datalen; /* data length */ - bus_dmamap_t cm_datamap; /* DMA map for bio data */ - struct aac_sg_table *cm_sgtable; /* pointer to s/g table in + u_int32_t cm_datalen; /* data length */ + bus_dmamap_t cm_datamap; /* DMA map for bio data */ + struct aac_sg_table *cm_sgtable; /* pointer to s/g table in * command */ - - int cm_flags; + int cm_flags; #define AAC_CMD_MAPPED (1<<0) /* command has had its data * mapped */ #define AAC_CMD_DATAIN (1<<1) /* command involves data moving @@ -168,10 +163,10 @@ struct aac_command #define AAC_ON_AACQ_COMPLETE (1<<8) #define AAC_ON_AACQ_MASK ((1<<5)|(1<<6)|(1<<7)|(1<<8)) - void (* cm_complete)(struct aac_command *cm); - void *cm_private; - time_t cm_timestamp; /* command creation time */ - int cm_queue; + void (* cm_complete)(struct aac_command *cm); + void *cm_private; + time_t cm_timestamp; /* command creation time */ + int cm_queue; }; /* @@ -188,21 +183,21 @@ struct aac_command * Sync Fib */ struct aac_common { - /* fibs for the controller to send us messages */ - struct aac_fib ac_fibs[AAC_ADAPTER_FIBS]; + /* fibs for the controller to send us messages */ + struct aac_fib ac_fibs[AAC_ADAPTER_FIBS]; - /* the init structure */ - struct aac_adapter_init ac_init; + /* the init structure */ + struct aac_adapter_init ac_init; - /* arena within which the queue structures are kept */ - u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + - AAC_QUEUE_ALIGN]; + /* arena within which the queue structures are kept */ + u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + + AAC_QUEUE_ALIGN]; - /* buffer for text messages from the controller */ - char ac_printf[AAC_PRINTF_BUFSIZE]; - - /* fib for synchronous commands */ - struct aac_fib ac_sync_fib; + /* buffer for text messages from the controller */ + char ac_printf[AAC_PRINTF_BUFSIZE]; + + /* fib for synchronous commands */ + struct aac_fib ac_sync_fib; }; /* @@ -210,15 +205,15 @@ struct aac_common { */ struct aac_interface { - int (* aif_get_fwstatus)(struct aac_softc *sc); - void (* aif_qnotify)(struct aac_softc *sc, int qbit); - int (* aif_get_istatus)(struct aac_softc *sc); - void (* aif_set_istatus)(struct aac_softc *sc, int mask); - void (* aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, - u_int32_t arg0, u_int32_t arg1, - u_int32_t arg2, u_int32_t arg3); - int (* aif_get_mailboxstatus)(struct aac_softc *sc); - void (* aif_set_interrupts)(struct aac_softc *sc, int enable); + int (*aif_get_fwstatus)(struct aac_softc *sc); + void (*aif_qnotify)(struct aac_softc *sc, int qbit); + int (*aif_get_istatus)(struct aac_softc *sc); + void (*aif_set_istatus)(struct aac_softc *sc, int mask); + void (*aif_set_mailbox)(struct aac_softc *sc, u_int32_t command, + u_int32_t arg0, u_int32_t arg1, + u_int32_t arg2, u_int32_t arg3); + int (*aif_get_mailboxstatus)(struct aac_softc *sc); + void (*aif_set_interrupts)(struct aac_softc *sc, int enable); }; extern struct aac_interface aac_rx_interface; extern struct aac_interface aac_sa_interface; @@ -231,9 +226,12 @@ extern struct aac_interface aac_sa_interface; #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \ ((sc)->aac_if.aif_set_mailbox((sc), (command), (arg0), (arg1), (arg2), \ (arg3))) -#define AAC_GET_MAILBOXSTATUS(sc) ((sc)->aac_if.aif_get_mailboxstatus((sc))) -#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), 0)) -#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), 1)) +#define AAC_GET_MAILBOXSTATUS(sc) ((sc)->aac_if.aif_get_mailboxstatus( \ + (sc))) +#define AAC_MASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ + 0)) +#define AAC_UNMASK_INTERRUPTS(sc) ((sc)->aac_if.aif_set_interrupts((sc), \ + 1)) #define AAC_SETREG4(sc, reg, val) bus_space_write_4(sc->aac_btag, \ sc->aac_bhandle, reg, val) @@ -270,80 +268,80 @@ typedef struct simplelock aac_lock_t; */ struct aac_softc { - /* bus connections */ - device_t aac_dev; - struct resource *aac_regs_resource; /* register interface + /* bus connections */ + device_t aac_dev; + struct resource *aac_regs_resource; /* register interface * window */ - int aac_regs_rid; /* resource ID */ - bus_space_handle_t aac_bhandle; /* bus space handle */ - bus_space_tag_t aac_btag; /* bus space tag */ - bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ - bus_dma_tag_t aac_buffer_dmat; /* data buffer/command + int aac_regs_rid; /* resource ID */ + bus_space_handle_t aac_bhandle; /* bus space handle */ + bus_space_tag_t aac_btag; /* bus space tag */ + bus_dma_tag_t aac_parent_dmat; /* parent DMA tag */ + bus_dma_tag_t aac_buffer_dmat; /* data buffer/command * DMA tag */ - struct resource *aac_irq; /* interrupt */ - int aac_irq_rid; - void *aac_intr; /* interrupt handle */ + struct resource *aac_irq; /* interrupt */ + int aac_irq_rid; + void *aac_intr; /* interrupt handle */ - /* controller features, limits and status */ - int aac_state; + /* controller features, limits and status */ + int aac_state; #define AAC_STATE_SUSPEND (1<<0) #define AAC_STATE_OPEN (1<<1) #define AAC_STATE_INTERRUPTS_ON (1<<2) #define AAC_STATE_AIF_SLEEPER (1<<3) - struct FsaRevision aac_revision; + struct FsaRevision aac_revision; - /* controller hardware interface */ - int aac_hwif; + /* controller hardware interface */ + int aac_hwif; #define AAC_HWIF_I960RX 0 #define AAC_HWIF_STRONGARM 1 #define AAC_HWIF_UNKNOWN -1 - bus_dma_tag_t aac_common_dmat; /* common structure + bus_dma_tag_t aac_common_dmat; /* common structure * DMA tag */ - bus_dmamap_t aac_common_dmamap; /* common structure + bus_dmamap_t aac_common_dmamap; /* common structure * DMA map */ - struct aac_common *aac_common; - u_int32_t aac_common_busaddr; - struct aac_interface aac_if; + struct aac_common *aac_common; + u_int32_t aac_common_busaddr; + struct aac_interface aac_if; - /* command/fib resources */ - bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */ - struct aac_fib *aac_fibs; - bus_dmamap_t aac_fibmap; - u_int32_t aac_fibphys; - struct aac_command aac_command[AAC_FIB_COUNT]; + /* command/fib resources */ + bus_dma_tag_t aac_fib_dmat; /* DMA tag for allocing FIBs */ + struct aac_fib *aac_fibs; + bus_dmamap_t aac_fibmap; + u_int32_t aac_fibphys; + struct aac_command aac_command[AAC_FIB_COUNT]; - /* command management */ - TAILQ_HEAD(,aac_command) aac_free; /* command structures + /* command management */ + TAILQ_HEAD(,aac_command) aac_free; /* command structures * available for reuse */ - TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for + TAILQ_HEAD(,aac_command) aac_ready; /* commands on hold for * controller resources */ - TAILQ_HEAD(,aac_command) aac_busy; - TAILQ_HEAD(,aac_command) aac_complete; /* commands which have been + TAILQ_HEAD(,aac_command) aac_busy; + TAILQ_HEAD(,aac_command) aac_complete; /* commands which have been * returned by the controller */ - struct bio_queue_head aac_bioq; - struct aac_queue_table *aac_queues; - struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; + struct bio_queue_head aac_bioq; + struct aac_queue_table *aac_queues; + struct aac_queue_entry *aac_qentries[AAC_QUEUE_COUNT]; - struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ + struct aac_qstat aac_qstat[AACQ_COUNT]; /* queue statistics */ - /* connected containters */ - struct aac_container_tq aac_container_tqh; - aac_lock_t aac_container_lock; + /* connected containters */ + struct aac_container_tq aac_container_tqh; + aac_lock_t aac_container_lock; - /* delayed activity infrastructure */ + /* delayed activity infrastructure */ #if __FreeBSD_version >= 500005 - struct task aac_task_complete; /* deferred-completion + struct task aac_task_complete; /* deferred-completion * task */ #endif - struct intr_config_hook aac_ich; + struct intr_config_hook aac_ich; - /* management interface */ - dev_t aac_dev_t; - struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH]; - int aac_aifq_head; - int aac_aifq_tail; - struct proc *aifthread; - int aifflags; + /* management interface */ + dev_t aac_dev_t; + struct aac_aif_command aac_aifq[AAC_AIFQ_LENGTH]; + int aac_aifq_head; + int aac_aifq_tail; + struct proc *aifthread; + int aifflags; #define AAC_AIFFLAGS_RUNNING (1 << 0) #define AAC_AIFFLAGS_PENDING (1 << 1) #define AAC_AIFFLAGS_EXIT (1 << 2) @@ -376,13 +374,13 @@ extern void aac_dump_complete(struct aac_softc *sc); */ #ifdef AAC_DEBUG # define debug(level, fmt, args...) \ - do { \ + do { \ if (level <=AAC_DEBUG) printf("%s: " fmt "\n", __FUNCTION__ , ##args); \ - } while(0) + } while (0) # define debug_called(level) \ - do { \ + do { \ if (level <= AAC_DEBUG) printf(__FUNCTION__ ": called\n"); \ - } while(0) + } while (0) extern void aac_print_queues(struct aac_softc *sc); extern void aac_panic(struct aac_softc *sc, char *reason); @@ -405,104 +403,108 @@ extern void aac_print_aif(struct aac_softc *sc, #endif struct aac_code_lookup { - char *string; - u_int32_t code; + char *string; + u_int32_t code; }; -/****************************************************************************** +/* * Queue primitives for driver queues. */ #define AACQ_ADD(sc, qname) \ do { \ - struct aac_qstat *qs = &(sc)->aac_qstat[qname]; \ + struct aac_qstat *qs; \ \ - qs->q_length++; \ - if (qs->q_length > qs->q_max) \ - qs->q_max = qs->q_length; \ - } while(0) + qs = &(sc)->aac_qstat[qname]; \ + \ + qs->q_length++; \ + if (qs->q_length > qs->q_max) \ + qs->q_max = qs->q_length; \ + } while (0) #define AACQ_REMOVE(sc, qname) (sc)->aac_qstat[qname].q_length-- -#define AACQ_INIT(sc, qname) \ - do { \ - sc->aac_qstat[qname].q_length = 0; \ - sc->aac_qstat[qname].q_max = 0; \ - } while(0) +#define AACQ_INIT(sc, qname) \ + do { \ + sc->aac_qstat[qname].q_length = 0; \ + sc->aac_qstat[qname].q_max = 0; \ + } while (0) #define AACQ_COMMAND_QUEUE(name, index) \ static __inline void \ aac_initq_ ## name (struct aac_softc *sc) \ { \ - TAILQ_INIT(&sc->aac_ ## name); \ - AACQ_INIT(sc, index); \ + TAILQ_INIT(&sc->aac_ ## name); \ + AACQ_INIT(sc, index); \ } \ static __inline void \ aac_enqueue_ ## name (struct aac_command *cm) \ { \ - int s; \ + int s; \ \ - s = splbio(); \ - if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ - printf("command %p is on another queue, flags = %#x\n", \ - cm, cm->cm_flags); \ - panic("command is on another queue"); \ - } \ - TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \ - cm->cm_flags |= AAC_ON_ ## index; \ - AACQ_ADD(cm->cm_sc, index); \ - splx(s); \ + s = splbio(); \ + if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ + printf("command %p is on another queue, flags = %#x\n", \ + cm, cm->cm_flags); \ + panic("command is on another queue"); \ + } \ + TAILQ_INSERT_TAIL(&cm->cm_sc->aac_ ## name, cm, cm_link); \ + cm->cm_flags |= AAC_ON_ ## index; \ + AACQ_ADD(cm->cm_sc, index); \ + splx(s); \ } \ static __inline void \ aac_requeue_ ## name (struct aac_command *cm) \ { \ - int s; \ + int s; \ \ - s = splbio(); \ - if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ - printf("command %p is on another queue, flags = %#x\n", \ - cm, cm->cm_flags); \ - panic("command is on another queue"); \ - } \ - TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \ - cm->cm_flags |= AAC_ON_ ## index; \ - AACQ_ADD(cm->cm_sc, index); \ - splx(s); \ + s = splbio(); \ + if ((cm->cm_flags & AAC_ON_AACQ_MASK) != 0) { \ + printf("command %p is on another queue, flags = %#x\n", \ + cm, cm->cm_flags); \ + panic("command is on another queue"); \ + } \ + TAILQ_INSERT_HEAD(&cm->cm_sc->aac_ ## name, cm, cm_link); \ + cm->cm_flags |= AAC_ON_ ## index; \ + AACQ_ADD(cm->cm_sc, index); \ + splx(s); \ } \ static __inline struct aac_command * \ aac_dequeue_ ## name (struct aac_softc *sc) \ { \ - struct aac_command *cm; \ - int s; \ + struct aac_command *cm; \ + int s; \ \ - s = splbio(); \ - if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \ - if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ - printf("command %p not in queue, flags = %#x, bit = %#x\n",\ - cm, cm->cm_flags, AAC_ON_ ## index); \ - panic("command not in queue"); \ + s = splbio(); \ + if ((cm = TAILQ_FIRST(&sc->aac_ ## name)) != NULL) { \ + if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ + printf("command %p not in queue, flags = %#x, " \ + "bit = %#x\n", cm, cm->cm_flags, \ + AAC_ON_ ## index); \ + panic("command not in queue"); \ + } \ + TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \ + cm->cm_flags &= ~AAC_ON_ ## index; \ + AACQ_REMOVE(sc, index); \ } \ - TAILQ_REMOVE(&sc->aac_ ## name, cm, cm_link); \ - cm->cm_flags &= ~AAC_ON_ ## index; \ - AACQ_REMOVE(sc, index); \ - } \ - splx(s); \ - return(cm); \ + splx(s); \ + return(cm); \ } \ static __inline void \ aac_remove_ ## name (struct aac_command *cm) \ { \ - int s; \ + int s; \ \ - s = splbio(); \ - if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ - printf("command %p not in queue, flags = %#x, bit = %#x\n", \ - cm, cm->cm_flags, AAC_ON_ ## index); \ - panic("command not in queue"); \ - } \ - TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \ - cm->cm_flags &= ~AAC_ON_ ## index; \ - AACQ_REMOVE(cm->cm_sc, index); \ - splx(s); \ + s = splbio(); \ + if ((cm->cm_flags & AAC_ON_ ## index) == 0) { \ + printf("command %p not in queue, flags = %#x, " \ + "bit = %#x\n", cm, cm->cm_flags, \ + AAC_ON_ ## index); \ + panic("command not in queue"); \ + } \ + TAILQ_REMOVE(&cm->cm_sc->aac_ ## name, cm, cm_link); \ + cm->cm_flags &= ~AAC_ON_ ## index; \ + AACQ_REMOVE(cm->cm_sc, index); \ + splx(s); \ } \ struct hack @@ -517,43 +519,43 @@ AACQ_COMMAND_QUEUE(complete, AACQ_COMPLETE); static __inline void aac_initq_bio(struct aac_softc *sc) { - bioq_init(&sc->aac_bioq); - AACQ_INIT(sc, AACQ_BIO); + bioq_init(&sc->aac_bioq); + AACQ_INIT(sc, AACQ_BIO); } static __inline void aac_enqueue_bio(struct aac_softc *sc, struct bio *bp) { - int s; + int s; - s = splbio(); - bioq_insert_tail(&sc->aac_bioq, bp); - AACQ_ADD(sc, AACQ_BIO); - splx(s); + s = splbio(); + bioq_insert_tail(&sc->aac_bioq, bp); + AACQ_ADD(sc, AACQ_BIO); + splx(s); } static __inline struct bio * aac_dequeue_bio(struct aac_softc *sc) { - int s; - struct bio *bp; + int s; + struct bio *bp; - s = splbio(); - if ((bp = bioq_first(&sc->aac_bioq)) != NULL) { + s = splbio(); + if ((bp = bioq_first(&sc->aac_bioq)) != NULL) { bioq_remove(&sc->aac_bioq, bp); AACQ_REMOVE(sc, AACQ_BIO); - } - splx(s); - return(bp); + } + splx(s); + return(bp); } static __inline void aac_print_printf(struct aac_softc *sc) { - if (sc->aac_common->ac_printf[0]) { + if (sc->aac_common->ac_printf[0]) { device_printf(sc->aac_dev, "**Monitor** %.*s", AAC_PRINTF_BUFSIZE, sc->aac_common->ac_printf); sc->aac_common->ac_printf[0] = 0; AAC_QNOTIFY(sc, AAC_DB_PRINTF); - } + } } diff --git a/sys/sys/aac_ioctl.h b/sys/sys/aac_ioctl.h index fda2afd100e5..1b798ebd8238 100644 --- a/sys/sys/aac_ioctl.h +++ b/sys/sys/aac_ioctl.h @@ -39,16 +39,16 @@ #define AACQ_COUNT 5 /* total number of queues */ struct aac_qstat { - u_int32_t q_length; - u_int32_t q_max; + 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; + u_int32_t as_item; + struct aac_qstat as_qstat; }; #define AACIO_STATS _IOWR('T', 101, union aac_statrequest) @@ -147,33 +147,33 @@ union aac_statrequest { * Support for faking the "miniport" version. */ struct aac_rev_check { - RevComponent callingComponent; - struct FsaRevision callingRevision; + RevComponent callingComponent; + struct FsaRevision callingRevision; }; struct aac_rev_check_resp { - int possiblyCompatible; - struct FsaRevision adapterSWRevision; + 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; + 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; + 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; };