xref: /dpdk/drivers/common/cpt/cpt_pmd_ops_helper.c (revision 27b549c12df2ef2db6b271795b4df7b14a2d9c2c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Cavium, Inc
3  */
4 
5 #include <rte_common.h>
6 
7 #include "cpt_common.h"
8 #include "cpt_hw_types.h"
9 #include "cpt_mcode_defines.h"
10 #include "cpt_pmd_ops_helper.h"
11 
12 #define CPT_MAX_IV_LEN 16
13 #define CPT_OFFSET_CONTROL_BYTES 8
14 #define CPT_MAX_ASYM_OP_NUM_PARAMS 5
15 #define CPT_MAX_ASYM_OP_MOD_LEN 1024
16 
17 int32_t
18 cpt_pmd_ops_helper_get_mlen_direct_mode(void)
19 {
20 	uint32_t len = 0;
21 
22 	/* Request structure */
23 	len = sizeof(struct cpt_request_info);
24 
25 	/* CPT HW result structure plus extra as it is aligned */
26 	len += 2*sizeof(cpt_res_s_t);
27 
28 	return len;
29 }
30 
31 int
32 cpt_pmd_ops_helper_get_mlen_sg_mode(void)
33 {
34 	uint32_t len = 0;
35 
36 	len += sizeof(struct cpt_request_info);
37 	len += CPT_OFFSET_CONTROL_BYTES + CPT_MAX_IV_LEN;
38 	len += ROUNDUP8(SG_LIST_HDR_SIZE +
39 			(ROUNDUP4(CPT_MAX_SG_IN_OUT_CNT) >> 2) * SG_ENTRY_SIZE);
40 	len += 2 * COMPLETION_CODE_SIZE;
41 	len += 2 * sizeof(cpt_res_s_t);
42 	return len;
43 }
44 
45 int
46 cpt_pmd_ops_helper_asym_get_mlen(void)
47 {
48 	uint32_t len;
49 
50 	/* Get meta len for linear buffer (direct) mode */
51 	len = cpt_pmd_ops_helper_get_mlen_direct_mode();
52 
53 	/* Get meta len for asymmetric operations */
54 	len += CPT_MAX_ASYM_OP_NUM_PARAMS * CPT_MAX_ASYM_OP_MOD_LEN;
55 	return len;
56 }
57