xref: /dpdk/drivers/common/cpt/cpt_pmd_ops_helper.c (revision 25d11a86c56d50947af33d0b79ede622809bd8b9)
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 
15 int32_t
16 cpt_pmd_ops_helper_get_mlen_direct_mode(void)
17 {
18 	uint32_t len = 0;
19 
20 	/* Request structure */
21 	len = sizeof(struct cpt_request_info);
22 
23 	/* CPT HW result structure plus extra as it is aligned */
24 	len += 2*sizeof(cpt_res_s_t);
25 
26 	return len;
27 }
28 
29 int
30 cpt_pmd_ops_helper_get_mlen_sg_mode(void)
31 {
32 	uint32_t len = 0;
33 
34 	len += sizeof(struct cpt_request_info);
35 	len += CPT_OFFSET_CONTROL_BYTES + CPT_MAX_IV_LEN;
36 	len += ROUNDUP8(SG_LIST_HDR_SIZE +
37 			(ROUNDUP4(CPT_MAX_SG_IN_OUT_CNT) >> 2) * SG_ENTRY_SIZE);
38 	len += 2 * COMPLETION_CODE_SIZE;
39 	len += 2 * sizeof(cpt_res_s_t);
40 	return len;
41 }
42