예제 #1
0
static int
isci_sysctl_coalesce_number(SYSCTL_HANDLER_ARGS)
{
    struct isci_softc *isci = (struct isci_softc *)arg1;
    int error = sysctl_handle_int(oidp, &isci->coalesce_number, 0, req);
    int i;

    if (error)
        return (error);

    for (i = 0; i < isci->controller_count; i++)
        scif_controller_set_interrupt_coalescence(
            isci->controllers[i].scif_controller_handle,
            isci->coalesce_number, isci->coalesce_timeout);

    return (0);
}
예제 #2
0
파일: isci.c 프로젝트: tomtor/freebsd
int
isci_initialize(struct isci_softc *isci)
{
    int error;
    uint32_t status = 0;
    uint32_t library_object_size;
    uint32_t verbosity_mask;
    uint32_t scic_log_object_mask;
    uint32_t scif_log_object_mask;
    uint8_t *header_buffer;

    library_object_size = scif_library_get_object_size(SCI_MAX_CONTROLLERS);

    isci->sci_library_memory =
        malloc(library_object_size, M_ISCI, M_NOWAIT | M_ZERO );

    isci->sci_library_handle = scif_library_construct(
                                   isci->sci_library_memory, SCI_MAX_CONTROLLERS);

    sci_object_set_association( isci->sci_library_handle, (void *)isci);

    verbosity_mask = (1<<SCI_LOG_VERBOSITY_ERROR) |
                     (1<<SCI_LOG_VERBOSITY_WARNING) | (1<<SCI_LOG_VERBOSITY_INFO) |
                     (1<<SCI_LOG_VERBOSITY_TRACE);

    scic_log_object_mask = 0xFFFFFFFF;
    scic_log_object_mask &= ~SCIC_LOG_OBJECT_COMPLETION_QUEUE;
    scic_log_object_mask &= ~SCIC_LOG_OBJECT_SSP_IO_REQUEST;
    scic_log_object_mask &= ~SCIC_LOG_OBJECT_STP_IO_REQUEST;
    scic_log_object_mask &= ~SCIC_LOG_OBJECT_SMP_IO_REQUEST;
    scic_log_object_mask &= ~SCIC_LOG_OBJECT_CONTROLLER;

    scif_log_object_mask = 0xFFFFFFFF;
    scif_log_object_mask &= ~SCIF_LOG_OBJECT_CONTROLLER;
    scif_log_object_mask &= ~SCIF_LOG_OBJECT_IO_REQUEST;

    TUNABLE_INT_FETCH("hw.isci.debug_level", &g_isci_debug_level);

    sci_logger_enable(sci_object_get_logger(isci->sci_library_handle),
                      scif_log_object_mask, verbosity_mask);

    sci_logger_enable(sci_object_get_logger(
                          scif_library_get_scic_handle(isci->sci_library_handle)),
                      scic_log_object_mask, verbosity_mask);

    header_buffer = (uint8_t *)&isci->pci_common_header;
    for (uint8_t i = 0; i < sizeof(isci->pci_common_header); i++)
        header_buffer[i] = pci_read_config(isci->device, i, 1);

    scic_library_set_pci_info(
        scif_library_get_scic_handle(isci->sci_library_handle),
        &isci->pci_common_header);

    isci->oem_parameters_found = FALSE;

    isci_get_oem_parameters(isci);

    /* trigger interrupt if 32 completions occur before timeout expires */
    isci->coalesce_number = 32;

    /* trigger interrupt if 2 microseconds elapse after a completion occurs,
     *  regardless if "coalesce_number" completions have occurred
     */
    isci->coalesce_timeout = 2;

    isci->controller_count = scic_library_get_pci_device_controller_count(
                                 scif_library_get_scic_handle(isci->sci_library_handle));

    for (int index = 0; index < isci->controller_count; index++) {
        struct ISCI_CONTROLLER *controller = &isci->controllers[index];
        SCI_CONTROLLER_HANDLE_T scif_controller_handle;

        controller->index = index;
        isci_controller_construct(controller, isci);

        scif_controller_handle = controller->scif_controller_handle;

        status = isci_controller_initialize(controller);

        if(status != SCI_SUCCESS) {
            isci_log_message(0, "ISCI",
                             "isci_controller_initialize FAILED: %x\n",
                             status);
            return (status);
        }

        error = isci_controller_allocate_memory(controller);

        if (error != 0)
            return (error);

        scif_controller_set_interrupt_coalescence(
            scif_controller_handle, isci->coalesce_number,
            isci->coalesce_timeout);
    }

    /* FreeBSD provides us a hook to ensure we get a chance to start
     *  our controllers and complete initial domain discovery before
     *  it searches for the boot device.  Once we're done, we'll
     *  disestablish the hook, signaling the kernel that is can proceed
     *  with the boot process.
     */
    isci->config_hook.ich_func = &isci_controller_start;
    isci->config_hook.ich_arg = &isci->controllers[0];

    if (config_intrhook_establish(&isci->config_hook) != 0)
        isci_log_message(0, "ISCI",
                         "config_intrhook_establish failed!\n");

    return (status);
}