mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-06 22:04:22 +08:00
crypto: qat - refactor qat_crypto_dev_config()
Refactor function qat_crypto_dev_config() to propagate errors to the caller. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
533179ce37
commit
54e3d7538f
@ -115,88 +115,103 @@ struct qat_crypto_instance *qat_crypto_get_instance_node(int node)
|
||||
*/
|
||||
int qat_crypto_dev_config(struct adf_accel_dev *accel_dev)
|
||||
{
|
||||
int cpus = num_online_cpus();
|
||||
int banks = GET_MAX_BANKS(accel_dev);
|
||||
char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES];
|
||||
int i;
|
||||
int banks = GET_MAX_BANKS(accel_dev);
|
||||
int cpus = num_online_cpus();
|
||||
unsigned long val;
|
||||
int instances;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
if (adf_hw_dev_has_crypto(accel_dev))
|
||||
instances = min(cpus, banks);
|
||||
else
|
||||
instances = 0;
|
||||
|
||||
if (adf_cfg_section_add(accel_dev, ADF_KERNEL_SEC))
|
||||
ret = adf_cfg_section_add(accel_dev, ADF_KERNEL_SEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
if (adf_cfg_section_add(accel_dev, "Accelerator0"))
|
||||
|
||||
ret = adf_cfg_section_add(accel_dev, "Accelerator0");
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < instances; i++) {
|
||||
val = i;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_BANK_NUM, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_ETRMGR_CORE_AFFINITY,
|
||||
i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_SIZE, i);
|
||||
val = 128;
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = 512;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_SIZE, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = 0;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_TX, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = 2;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_TX, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = 8;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_ASYM_RX, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = 10;
|
||||
snprintf(key, sizeof(key), ADF_CY "%d" ADF_RING_SYM_RX, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
val = ADF_COALESCING_DEF_TIME;
|
||||
snprintf(key, sizeof(key), ADF_ETRMGR_COALESCE_TIMER_FORMAT, i);
|
||||
if (adf_cfg_add_key_value_param(accel_dev, "Accelerator0",
|
||||
key, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, "Accelerator0",
|
||||
key, &val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
val = i;
|
||||
if (adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC,
|
||||
ADF_NUM_CY, &val, ADF_DEC))
|
||||
ret = adf_cfg_add_key_value_param(accel_dev, ADF_KERNEL_SEC, ADF_NUM_CY,
|
||||
&val, ADF_DEC);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
set_bit(ADF_STATUS_CONFIGURED, &accel_dev->status);
|
||||
return 0;
|
||||
err:
|
||||
dev_err(&GET_DEV(accel_dev), "Failed to start QAT accel dev\n");
|
||||
return -EINVAL;
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(qat_crypto_dev_config);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user