示例#1
0
文件: e_qat.c 项目: i10a/QAT_Engine
CpaInstanceHandle get_next_inst(void)
{
    CpaInstanceHandle instance_handle = NULL;
    ENGINE* e = NULL;

    if (1 == enable_instance_for_thread) {
        instance_handle = pthread_getspecific(qatInstanceForThread);
        /* If no thread specific data is found then return NULL
           as there should be as the flag is set */
        if (instance_handle == NULL) {
            WARN("No thread specific instance is available\n");
            return instance_handle;
        }
    }

    e = ENGINE_by_id(engine_qat_id);
    if(e == NULL) {
        WARN("Function ENGINE_by_id returned NULL\n");
        instance_handle = NULL;
        return instance_handle;
    }

    if(!qat_engine_init(e)){
        WARN("Failure in qat_engine_init function\n");
        instance_handle = NULL;
        ENGINE_free(e);
        return instance_handle;
    }

    ENGINE_free(e);

    /* Each call to get_next_inst will iterate through the array of instances
       if an instance was not retrieved already from thread specific data. */
    if (instance_handle == NULL)
    {
        if (qat_instance_handles) {
            instance_handle = qat_instance_handles[curr_inst];
            incr_curr_inst();
        } else {
            WARN("No instances are available\n");
            instance_handle = NULL;
        }
    }
    return instance_handle;
}
示例#2
0
文件: e_qat.c 项目: Muffo/QAT_Engine
/******************************************************************************
* function:
*         get_next_inst(void)
*
* description:
*   Return the next instance handle to use for an operation.
*
******************************************************************************/
CpaInstanceHandle get_next_inst(void)
{
    CpaInstanceHandle instanceHandle = NULL;
    CpaStatus status = CPA_STATUS_SUCCESS;
    ENGINE* e = NULL;

    if (1 == enable_instance_for_thread) {
        instanceHandle = pthread_getspecific(qatInstanceForThread);
        /* If no thread specific data is found then return NULL
           as there should be as the flag is set */
        if (instanceHandle == NULL)
            return instanceHandle;
    }

    e = ENGINE_by_id(engine_qat_id);
    if(e == NULL) {
        instanceHandle = NULL;
        return instanceHandle;
    }

    if(!qat_engine_init(e)){
        instanceHandle = NULL;
        return instanceHandle;
    }

    /* Anytime we use external polling then we want to loop
       through the instances. Any time we are using internal polling
       then we also want to loop through the instances assuming
       one was not retrieved from thread specific data. */
    if (1 == enable_external_polling || instanceHandle == NULL)
    {
        if (qatInstanceHandles) {
            instanceHandle = qatInstanceHandles[currInst];
            incr_curr_inst();
        } else {
            instanceHandle = NULL;
        }
    }
    return instanceHandle;
}