1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2022 Intel Corporation
8 #include <cryptodev_pmd.h>
9 #include <rte_crypto_asym.h>
10 #include "icp_qat_fw_pke.h"
11 #include "qat_device.h"
12 #include "qat_crypto.h"
13 #include "icp_qat_fw.h"
15 /** Intel(R) QAT Asymmetric Crypto PMD driver name */
16 #define CRYPTODEV_NAME_QAT_ASYM_PMD crypto_qat_asym
18 typedef uint64_t large_int_ptr;
19 #define MAX_PKE_PARAMS 8
20 #define QAT_PKE_MAX_LN_SIZE 512
21 #define _PKE_ALIGN_ __rte_aligned(8)
23 #define QAT_ASYM_MAX_PARAMS 8
24 #define QAT_ASYM_MODINV_NUM_IN_PARAMS 2
25 #define QAT_ASYM_MODINV_NUM_OUT_PARAMS 1
26 #define QAT_ASYM_MODEXP_NUM_IN_PARAMS 3
27 #define QAT_ASYM_MODEXP_NUM_OUT_PARAMS 1
28 #define QAT_ASYM_RSA_NUM_IN_PARAMS 3
29 #define QAT_ASYM_RSA_NUM_OUT_PARAMS 1
30 #define QAT_ASYM_RSA_QT_NUM_IN_PARAMS 6
33 * helper function to add an asym capability
34 * <name> <op type> <modlen (min, max, increment)>
36 #define QAT_ASYM_CAP(n, o, l, r, i) \
38 .op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC, \
41 .xform_type = RTE_CRYPTO_ASYM_XFORM_##n,\
54 struct qat_asym_op_cookie {
57 rte_iova_t input_addr;
58 rte_iova_t output_addr;
59 large_int_ptr input_params_ptrs[MAX_PKE_PARAMS] _PKE_ALIGN_;
60 large_int_ptr output_params_ptrs[MAX_PKE_PARAMS] _PKE_ALIGN_;
62 uint8_t input_array[MAX_PKE_PARAMS][QAT_PKE_MAX_LN_SIZE];
63 uint8_t input_buffer[MAX_PKE_PARAMS * QAT_PKE_MAX_LN_SIZE];
65 uint8_t output_array[MAX_PKE_PARAMS][QAT_PKE_MAX_LN_SIZE] _PKE_ALIGN_;
68 struct qat_asym_session {
69 struct icp_qat_fw_pke_request req_tmpl;
70 struct rte_crypto_asym_xform *xform;
74 qat_fill_req_tmpl(struct icp_qat_fw_pke_request *qat_req)
76 memset(qat_req, 0, sizeof(*qat_req));
77 qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE;
79 qat_req->pke_hdr.hdr_flags =
80 ICP_QAT_FW_COMN_HDR_FLAGS_BUILD
81 (ICP_QAT_FW_COMN_REQ_FLAG_SET);
85 qat_asym_build_req_tmpl(void *sess_private_data)
87 struct icp_qat_fw_pke_request *qat_req;
88 struct qat_asym_session *session = sess_private_data;
90 qat_req = &session->req_tmpl;
91 qat_fill_req_tmpl(qat_req);
95 qat_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
96 struct rte_crypto_asym_xform *xform,
97 struct rte_cryptodev_asym_session *sess);
100 qat_asym_session_get_private_size(struct rte_cryptodev *dev);
103 qat_asym_session_clear(struct rte_cryptodev *dev,
104 struct rte_cryptodev_asym_session *sess);
107 * Process PKE response received from outgoing queue of QAT
109 * @param op a ptr to the rte_crypto_op referred to by
110 * the response message is returned in this param
111 * @param resp icp_qat_fw_pke_resp message received from
112 * outgoing fw message queue
113 * @param op_cookie Cookie pointer that holds private metadata
117 qat_asym_process_response(void **op, uint8_t *resp,
118 void *op_cookie, __rte_unused uint64_t *dequeue_err_count);
121 qat_asym_init_op_cookie(void *cookie);
123 #endif /* _QAT_ASYM_H_ */