Lines Matching refs:handle

124 static void qat_uclo_wr_sram_by_words(struct icp_qat_fw_loader_handle *handle,
133 SRAM_WRITE(handle, addr, outval);
140 static void qat_uclo_wr_umem_by_words(struct icp_qat_fw_loader_handle *handle,
152 qat_hal_wr_umem(handle, ae, addr++, 1, &outval);
158 static void qat_uclo_batch_wr_umem(struct icp_qat_fw_loader_handle *handle,
175 qat_uclo_wr_umem_by_words(handle, ae, addr, value, size);
181 qat_uclo_cleanup_batch_init_list(struct icp_qat_fw_loader_handle *handle,
217 static int qat_uclo_fetch_initmem_ae(struct icp_qat_fw_loader_handle *handle,
221 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
249 *handle, struct icp_qat_uof_initmem
307 static int qat_uclo_init_lmem_seg(struct icp_qat_fw_loader_handle *handle,
310 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
313 if (qat_uclo_fetch_initmem_ae(handle, init_mem,
314 handle->chip_info->lm_size, &ae))
316 if (qat_uclo_create_batch_init_list(handle, init_mem, ae,
322 static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,
325 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
330 if (qat_uclo_fetch_initmem_ae(handle, init_mem, ustore_size, &ae))
332 if (qat_uclo_create_batch_init_list(handle, init_mem, ae,
345 static int qat_uclo_init_ae_memory(struct icp_qat_fw_loader_handle *handle,
350 if (qat_uclo_init_lmem_seg(handle, init_mem))
354 if (qat_uclo_init_umem_seg(handle, init_mem))
365 static int qat_uclo_init_ustore(struct icp_qat_fw_loader_handle *handle,
374 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
375 unsigned long ae_mask = handle->hal_handle->ae_mask;
376 unsigned long cfg_ae_mask = handle->cfg_ae_mask;
389 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
401 qat_hal_wr_uwords(handle, (unsigned char)ae, 0,
403 qat_hal_wr_uwords(handle, (unsigned char)ae, patt_pos,
411 static int qat_uclo_init_memory(struct icp_qat_fw_loader_handle *handle)
414 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
416 unsigned long ae_mask = handle->hal_handle->ae_mask;
420 if (qat_uclo_init_ae_memory(handle, initmem))
430 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
431 if (qat_hal_batch_wr_lm(handle, ae,
436 qat_uclo_cleanup_batch_init_list(handle,
438 qat_uclo_batch_wr_umem(handle, ae,
440 qat_uclo_cleanup_batch_init_list(handle,
656 static int qat_uclo_map_ae(struct icp_qat_fw_loader_handle *handle, int max_ae)
660 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
661 unsigned long ae_mask = handle->hal_handle->ae_mask;
662 unsigned long cfg_ae_mask = handle->cfg_ae_mask;
724 qat_uclo_get_dev_type(struct icp_qat_fw_loader_handle *handle)
726 switch (handle->pci_dev->device) {
740 handle->pci_dev->device);
764 static int qat_uclo_init_reg(struct icp_qat_fw_loader_handle *handle,
776 return qat_hal_init_gpr(handle, ae, ctx_mask, reg_type,
788 return qat_hal_init_rd_xfer(handle, ae, ctx_mask, reg_type,
796 return qat_hal_init_wr_xfer(handle, ae, ctx_mask, reg_type,
799 return qat_hal_init_nn(handle, ae, ctx_mask, reg_addr, value);
807 static int qat_uclo_init_reg_sym(struct icp_qat_fw_loader_handle *handle,
828 qat_uclo_init_reg(handle, ae, ctx_mask,
841 qat_uclo_init_reg(handle, ae,
862 static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle)
864 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
865 unsigned long ae_mask = handle->hal_handle->ae_mask;
872 if (qat_uclo_init_memory(handle)) {
878 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
883 if (qat_uclo_init_reg_sym(handle, ae, aed->ae_slices[s].encap_image))
891 static int qat_hal_set_modes(struct icp_qat_fw_loader_handle *handle,
900 ret = qat_hal_set_ae_ctx_mode(handle, ae, mode);
905 if (handle->chip_info->nn) {
907 ret = qat_hal_set_ae_nn_mode(handle, ae, mode);
914 ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM0, mode);
920 ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM1, mode);
925 if (handle->chip_info->lm2lm3) {
927 ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM2, mode);
933 ret = qat_hal_set_ae_lm_mode(handle, ae, ICP_LMEM3, mode);
939 qat_hal_set_ae_tindex_mode(handle, ae, mode);
944 static int qat_uclo_set_ae_mode(struct icp_qat_fw_loader_handle *handle)
948 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
949 unsigned long ae_mask = handle->hal_handle->ae_mask;
950 unsigned long cfg_ae_mask = handle->cfg_ae_mask;
954 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
964 error = qat_hal_set_modes(handle, obj_handle, ae,
973 static void qat_uclo_init_uword_num(struct icp_qat_fw_loader_handle *handle)
975 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
986 static int qat_uclo_parse_uof_obj(struct icp_qat_fw_loader_handle *handle)
988 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
995 obj_handle->prod_type = qat_uclo_get_dev_type(handle);
997 (PID_MINOR_REV & handle->hal_handle->revision_id);
1018 if (qat_uclo_map_ae(handle, handle->hal_handle->ae_max_num)) {
1022 qat_uclo_init_uword_num(handle);
1025 if (qat_uclo_set_ae_mode(handle))
1036 static int qat_uclo_map_suof_file_hdr(struct icp_qat_fw_loader_handle *handle,
1042 struct icp_qat_suof_handle *suof_handle = handle->sobj_handle;
1062 static void qat_uclo_map_simg(struct icp_qat_fw_loader_handle *handle,
1066 struct icp_qat_suof_handle *suof_handle = handle->sobj_handle;
1081 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) +
1082 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle);
1084 ICP_QAT_CSS_SIGNATURE_LEN(handle);
1108 static int qat_uclo_check_simg_compat(struct icp_qat_fw_loader_handle *handle,
1114 prod_type = qat_uclo_get_dev_type(handle);
1117 (PID_MINOR_REV & handle->hal_handle->revision_id);
1132 static void qat_uclo_del_suof(struct icp_qat_fw_loader_handle *handle)
1134 struct icp_qat_suof_handle *sobj_handle = handle->sobj_handle;
1138 kfree(handle->sobj_handle);
1139 handle->sobj_handle = NULL;
1157 static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle,
1161 struct icp_qat_suof_handle *suof_handle = handle->sobj_handle;
1174 ret = qat_uclo_map_suof_file_hdr(handle, suof_ptr, suof_size);
1192 qat_uclo_map_simg(handle, &suof_img_hdr[i],
1194 ret = qat_uclo_check_simg_compat(handle,
1198 suof_img_hdr[i].ae_mask &= handle->cfg_ae_mask;
1203 if (!handle->chip_info->tgroup_share_ustore) {
1214 static int qat_uclo_auth_fw(struct icp_qat_fw_loader_handle *handle,
1225 fcu_ctl_csr = handle->chip_info->fcu_ctl_csr;
1226 fcu_sts_csr = handle->chip_info->fcu_sts_csr;
1227 fcu_dram_hi_csr = handle->chip_info->fcu_dram_addr_hi;
1228 fcu_dram_lo_csr = handle->chip_info->fcu_dram_addr_lo;
1230 SET_CAP_CSR(handle, fcu_dram_hi_csr, (bus_addr >> BITS_IN_DWORD));
1231 SET_CAP_CSR(handle, fcu_dram_lo_csr, bus_addr);
1232 SET_CAP_CSR(handle, fcu_ctl_csr, FCU_CTRL_CMD_AUTH);
1236 fcu_sts = GET_CAP_CSR(handle, fcu_sts_csr);
1249 static bool qat_uclo_is_broadcast(struct icp_qat_fw_loader_handle *handle,
1254 if (!handle->chip_info->tgroup_share_ustore)
1257 sobj_handle = (struct icp_qat_suof_handle *)handle->sobj_handle;
1258 if (handle->hal_handle->admin_ae_mask &
1265 static int qat_uclo_broadcast_load_fw(struct icp_qat_fw_loader_handle *handle,
1268 unsigned long ae_mask = handle->hal_handle->ae_mask;
1275 if (handle->chip_info->tgroup_share_ustore) {
1276 fcu_ctl_csr = handle->chip_info->fcu_ctl_csr;
1277 fcu_sts_csr = handle->chip_info->fcu_sts_csr;
1278 fcu_loaded_csr = handle->chip_info->fcu_loaded_ae_csr;
1281 handle->pci_dev->device);
1285 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
1286 if (qat_hal_check_ae_active(handle, (unsigned char)ae)) {
1296 SET_CAP_CSR(handle, FCU_ME_BROADCAST_MASK_TYPE,
1299 SET_CAP_CSR(handle, fcu_ctl_csr, FCU_CTRL_CMD_LOAD);
1303 fcu_sts = GET_CAP_CSR(handle, fcu_sts_csr);
1310 ae_loaded = GET_CAP_CSR(handle, fcu_loaded_csr);
1311 ae_loaded >>= handle->chip_info->fcu_loaded_ae_pos;
1326 static int qat_uclo_simg_alloc(struct icp_qat_fw_loader_handle *handle,
1333 vptr = dma_alloc_coherent(&handle->pci_dev->dev,
1343 static void qat_uclo_simg_free(struct icp_qat_fw_loader_handle *handle,
1346 if (handle && dram_desc && dram_desc->dram_base_addr_v) {
1347 dma_free_coherent(&handle->pci_dev->dev,
1357 static void qat_uclo_ummap_auth_fw(struct icp_qat_fw_loader_handle *handle,
1368 qat_uclo_simg_free(handle, &dram_desc);
1372 static int qat_uclo_check_image(struct icp_qat_fw_loader_handle *handle,
1379 if (handle->chip_info->fw_auth) {
1381 unsigned int header_len = ICP_QAT_AE_IMG_OFFSET(handle);
1414 static int qat_uclo_map_auth_fw(struct icp_qat_fw_loader_handle *handle,
1426 if (size > (ICP_QAT_AE_IMG_OFFSET(handle) + ICP_QAT_CSS_RSA4K_MAX_IMAGE_LEN)) {
1431 ICP_QAT_CSS_AE_SIMG_LEN(handle) + simg_offset :
1432 size + ICP_QAT_CSS_FWSK_PAD_LEN(handle) + simg_offset;
1433 if (qat_uclo_simg_alloc(handle, &img_desc, length)) {
1459 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle));
1461 memset((void *)(uintptr_t)(virt_addr + ICP_QAT_CSS_FWSK_MODULUS_LEN(handle)),
1462 0, ICP_QAT_CSS_FWSK_PAD_LEN(handle));
1465 memcpy((void *)(uintptr_t)(virt_addr + ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) +
1466 ICP_QAT_CSS_FWSK_PAD_LEN(handle)),
1468 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle)),
1474 ICP_QAT_CSS_FWSK_PUB_LEN(handle);
1475 virt_addr = virt_addr + ICP_QAT_CSS_FWSK_PUB_LEN(handle);
1481 ICP_QAT_CSS_FWSK_MODULUS_LEN(handle) +
1482 ICP_QAT_CSS_FWSK_EXPONENT_LEN(handle)),
1483 ICP_QAT_CSS_SIGNATURE_LEN(handle));
1487 ICP_QAT_CSS_SIGNATURE_LEN(handle);
1488 virt_addr += ICP_QAT_CSS_SIGNATURE_LEN(handle);
1492 auth_desc->img_len = size - ICP_QAT_AE_IMG_OFFSET(handle);
1494 (void *)(image + ICP_QAT_AE_IMG_OFFSET(handle)),
1514 virt_addr += ICP_QAT_CSS_FWSK_PUB_LEN(handle);
1515 virt_addr += ICP_QAT_CSS_SIGNATURE_LEN(handle);
1517 auth_desc->ae_mask = simg_ae_mode->ae_mask & handle->cfg_ae_mask;
1526 static int qat_uclo_load_fw(struct icp_qat_fw_loader_handle *handle,
1529 unsigned long ae_mask = handle->hal_handle->ae_mask;
1535 fcu_ctl_csr = handle->chip_info->fcu_ctl_csr;
1536 fcu_sts_csr = handle->chip_info->fcu_sts_csr;
1537 loaded_csr = handle->chip_info->fcu_loaded_ae_csr;
1539 for_each_set_bit(i, &ae_mask, handle->hal_handle->ae_max_num) {
1544 if (qat_hal_check_ae_active(handle, i)) {
1548 SET_CAP_CSR(handle, fcu_ctl_csr,
1555 fcu_sts = GET_CAP_CSR(handle, fcu_sts_csr);
1558 loaded_aes = GET_CAP_CSR(handle, loaded_csr);
1559 loaded_aes >>= handle->chip_info->fcu_loaded_ae_pos;
1572 static int qat_uclo_map_suof_obj(struct icp_qat_fw_loader_handle *handle,
1580 handle->sobj_handle = suof_handle;
1581 if (qat_uclo_map_suof(handle, addr_ptr, mem_size)) {
1582 qat_uclo_del_suof(handle);
1589 int qat_uclo_wr_mimage(struct icp_qat_fw_loader_handle *handle,
1596 ret = qat_uclo_check_image(handle, addr_ptr, mem_size, CSS_MMP_FIRMWARE);
1600 if (handle->chip_info->fw_auth) {
1601 status = qat_uclo_map_auth_fw(handle, addr_ptr, mem_size, &desc);
1603 status = qat_uclo_auth_fw(handle, desc);
1604 qat_uclo_ummap_auth_fw(handle, &desc);
1606 if (handle->chip_info->mmp_sram_size < mem_size) {
1610 qat_uclo_wr_sram_by_words(handle, 0, addr_ptr, mem_size);
1615 static int qat_uclo_map_uof_obj(struct icp_qat_fw_loader_handle *handle,
1636 handle->obj_handle = objhdl;
1637 if (qat_uclo_parse_uof_obj(handle))
1642 handle->obj_handle = NULL;
1651 static int qat_uclo_map_mof_file_hdr(struct icp_qat_fw_loader_handle *handle,
1655 struct icp_qat_mof_handle *mobj_handle = handle->mobj_handle;
1678 static void qat_uclo_del_mof(struct icp_qat_fw_loader_handle *handle)
1680 struct icp_qat_mof_handle *mobj_handle = handle->mobj_handle;
1684 kfree(handle->mobj_handle);
1685 handle->mobj_handle = NULL;
1839 static int qat_uclo_map_mof_obj(struct icp_qat_fw_loader_handle *handle,
1865 handle->mobj_handle = mobj_handle;
1866 ret = qat_uclo_map_mof_file_hdr(handle, mof_ptr, mof_size);
1891 int qat_uclo_map_obj(struct icp_qat_fw_loader_handle *handle,
1899 (sizeof(handle->hal_handle->ae_mask) * 8));
1901 if (!handle || !addr_ptr || mem_size < 24)
1905 ret = qat_uclo_map_mof_obj(handle, addr_ptr, mem_size, obj_name,
1914 return (handle->chip_info->fw_auth) ?
1915 qat_uclo_map_suof_obj(handle, obj_addr, obj_size) :
1916 qat_uclo_map_uof_obj(handle, obj_addr, obj_size);
1919 void qat_uclo_del_obj(struct icp_qat_fw_loader_handle *handle)
1921 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
1924 if (handle->mobj_handle)
1925 qat_uclo_del_mof(handle);
1926 if (handle->sobj_handle)
1927 qat_uclo_del_suof(handle);
1935 for (a = 0; a < handle->hal_handle->ae_max_num; a++)
1941 handle->obj_handle = NULL;
1974 static void qat_uclo_wr_uimage_raw_page(struct icp_qat_fw_loader_handle *handle,
1979 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
2000 qat_hal_wr_uwords(handle, (unsigned char)ae,
2010 static void qat_uclo_wr_uimage_page(struct icp_qat_fw_loader_handle *handle,
2013 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
2014 unsigned long ae_mask = handle->hal_handle->ae_mask;
2015 unsigned long cfg_ae_mask = handle->cfg_ae_mask;
2029 for_each_set_bit(ae, &ae_mask, handle->hal_handle->ae_max_num) {
2048 qat_uclo_wr_uimage_raw_page(handle, page->encap_page, ae);
2054 qat_hal_set_live_ctx(handle, (unsigned char)ae,
2056 qat_hal_set_pc(handle, (unsigned char)ae, image->ctx_assigned,
2061 static int qat_uclo_wr_suof_img(struct icp_qat_fw_loader_handle *handle)
2065 struct icp_qat_suof_handle *sobj_handle = handle->sobj_handle;
2070 ret = qat_uclo_check_image(handle, simg_hdr[i].simg_buf,
2076 if (qat_uclo_map_auth_fw(handle,
2082 if (qat_uclo_auth_fw(handle, desc))
2084 if (qat_uclo_is_broadcast(handle, i)) {
2085 if (qat_uclo_broadcast_load_fw(handle, desc))
2088 if (qat_uclo_load_fw(handle, desc))
2091 qat_uclo_ummap_auth_fw(handle, &desc);
2095 qat_uclo_ummap_auth_fw(handle, &desc);
2099 static int qat_uclo_wr_uof_img(struct icp_qat_fw_loader_handle *handle)
2101 struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
2104 if (qat_uclo_init_globals(handle))
2109 if (qat_uclo_init_ustore(handle, &obj_handle->ae_uimage[i]))
2111 qat_uclo_wr_uimage_page(handle,
2117 int qat_uclo_wr_all_uimage(struct icp_qat_fw_loader_handle *handle)
2119 return (handle->chip_info->fw_auth) ? qat_uclo_wr_suof_img(handle) :
2120 qat_uclo_wr_uof_img(handle);
2123 int qat_uclo_set_cfg_ae_mask(struct icp_qat_fw_loader_handle *handle,
2129 handle->cfg_ae_mask = cfg_ae_mask;