Commit ecb917ad authored by Jack Xu's avatar Jack Xu Committed by Herbert Xu

crypto: qat - refactor qat_uclo_set_ae_mode()

Refactor qat_uclo_set_ae_mode() by moving the logic that sets the AE
modes to a separate function, qat_hal_set_modes().
Signed-off-by: default avatarJack Xu <jack.xu@intel.com>
Co-developed-by: default avatarWojciech Ziemba <wojciech.ziemba@intel.com>
Signed-off-by: default avatarWojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 97b98401
...@@ -869,16 +869,52 @@ static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle) ...@@ -869,16 +869,52 @@ static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle)
return 0; return 0;
} }
static int qat_hal_set_modes(struct icp_qat_fw_loader_handle *handle,
struct icp_qat_uclo_objhandle *obj_handle,
unsigned char ae,
struct icp_qat_uof_image *uof_image)
{
unsigned char mode;
int ret;
mode = ICP_QAT_CTX_MODE(uof_image->ae_mode);
ret = qat_hal_set_ae_ctx_mode(handle, ae, mode);
if (ret) {
pr_err("QAT: qat_hal_set_ae_ctx_mode error\n");
return ret;
}
mode = ICP_QAT_NN_MODE(uof_image->ae_mode);
ret = qat_hal_set_ae_nn_mode(handle, ae, mode);
if (ret) {
pr_err("QAT: qat_hal_set_ae_nn_mode error\n");
return ret;
}
mode = ICP_QAT_LOC_MEM0_MODE(uof_image->ae_mode);
ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM0, mode);
if (ret) {
pr_err("QAT: qat_hal_set_ae_lm_mode LMEM0 error\n");
return ret;
}
mode = ICP_QAT_LOC_MEM1_MODE(uof_image->ae_mode);
ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM1, mode);
if (ret) {
pr_err("QAT: qat_hal_set_ae_lm_mode LMEM1 error\n");
return ret;
}
return 0;
}
static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle) static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle)
{ {
unsigned char ae, nn_mode, s;
struct icp_qat_uof_image *uof_image; struct icp_qat_uof_image *uof_image;
struct icp_qat_uclo_aedata *ae_data; struct icp_qat_uclo_aedata *ae_data;
struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
unsigned long ae_mask = handle->hal_handle->ae_mask;
unsigned char ae, s;
int error;
for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) { for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
if (!test_bit(ae, if (!test_bit(ae, &ae_mask))
(unsigned long *)&handle->hal_handle->ae_mask))
continue; continue;
ae_data = &obj_handle->ae_data[ae]; ae_data = &obj_handle->ae_data[ae];
for (s = 0; s < min_t(unsigned int, ae_data->slice_num, for (s = 0; s < min_t(unsigned int, ae_data->slice_num,
...@@ -886,29 +922,10 @@ static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle) ...@@ -886,29 +922,10 @@ static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle)
if (!obj_handle->ae_data[ae].ae_slices[s].encap_image) if (!obj_handle->ae_data[ae].ae_slices[s].encap_image)
continue; continue;
uof_image = ae_data->ae_slices[s].encap_image->img_ptr; uof_image = ae_data->ae_slices[s].encap_image->img_ptr;
if (qat_hal_set_ae_ctx_mode(handle, ae, error = qat_hal_set_modes(handle, obj_handle, ae,
(char)ICP_QAT_CTX_MODE uof_image);
(uof_image->ae_mode))) { if (error)
pr_err("QAT: qat_hal_set_ae_ctx_mode error\n"); return error;
return -EFAULT;
}
nn_mode = ICP_QAT_NN_MODE(uof_image->ae_mode);
if (qat_hal_set_ae_nn_mode(handle, ae, nn_mode)) {
pr_err("QAT: qat_hal_set_ae_nn_mode error\n");
return -EFAULT;
}
if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM0,
(char)ICP_QAT_LOC_MEM0_MODE
(uof_image->ae_mode))) {
pr_err("QAT: qat_hal_set_ae_lm_mode LMEM0 error\n");
return -EFAULT;
}
if (qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM1,
(char)ICP_QAT_LOC_MEM1_MODE
(uof_image->ae_mode))) {
pr_err("QAT: qat_hal_set_ae_lm_mode LMEM1 error\n");
return -EFAULT;
}
} }
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment