crypto/cnxk: use rlen from CPT result with lookaside
[dpdk.git] / drivers / crypto / cnxk / cn10k_ipsec_la_ops.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef __CN10K_IPSEC_LA_OPS_H__
6 #define __CN10K_IPSEC_LA_OPS_H__
7
8 #include <rte_crypto_sym.h>
9 #include <rte_security.h>
10
11 #include "cn10k_cryptodev.h"
12 #include "cn10k_ipsec.h"
13 #include "cnxk_cryptodev.h"
14
15 static __rte_always_inline int
16 process_outb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sess,
17                 struct cpt_inst_s *inst)
18 {
19         struct rte_crypto_sym_op *sym_op = cop->sym;
20         struct rte_mbuf *m_src = sym_op->m_src;
21
22         if (unlikely(rte_pktmbuf_tailroom(m_src) < sess->max_extended_len)) {
23                 plt_dp_err("Not enough tail room");
24                 return -ENOMEM;
25         }
26
27         /* Prepare CPT instruction */
28         inst->w4.u64 = sess->inst.w4;
29         inst->w4.s.dlen = rte_pktmbuf_pkt_len(m_src);
30         inst->dptr = rte_pktmbuf_iova(m_src);
31         inst->rptr = inst->dptr;
32
33         return 0;
34 }
35
36 static __rte_always_inline int
37 process_inb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sa,
38                struct cpt_inst_s *inst)
39 {
40         struct rte_crypto_sym_op *sym_op = cop->sym;
41         struct rte_mbuf *m_src = sym_op->m_src;
42
43         /* Prepare CPT instruction */
44         inst->w4.u64 = sa->inst.w4;
45         inst->w4.s.dlen = rte_pktmbuf_pkt_len(m_src);
46         inst->dptr = rte_pktmbuf_iova(m_src);
47         inst->rptr = inst->dptr;
48
49         return 0;
50 }
51
52 #endif /* __CN10K_IPSEC_LA_OPS_H__ */