1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef __CN10K_IPSEC_LA_OPS_H__
6 #define __CN10K_IPSEC_LA_OPS_H__
8 #include <rte_crypto_sym.h>
9 #include <rte_security.h>
11 #include "cn10k_cryptodev.h"
12 #include "cn10k_ipsec.h"
13 #include "cnxk_cryptodev.h"
15 static __rte_always_inline int32_t
16 ipsec_po_out_rlen_get(struct cn10k_ipsec_sa *sess, uint32_t plen)
18 uint32_t enc_payload_len;
21 RTE_ALIGN_CEIL(plen + sess->roundup_len, sess->roundup_byte);
23 return sess->partial_len + enc_payload_len;
26 static __rte_always_inline int
27 process_outb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sess,
28 struct cpt_inst_s *inst)
30 struct rte_crypto_sym_op *sym_op = cop->sym;
31 struct rte_mbuf *m_src = sym_op->m_src;
32 uint32_t dlen, rlen, extend_tail;
35 dlen = rte_pktmbuf_pkt_len(m_src);
36 rlen = ipsec_po_out_rlen_get(sess, dlen);
38 extend_tail = rlen - dlen;
40 mdata = rte_pktmbuf_append(m_src, extend_tail);
41 if (unlikely(mdata == NULL)) {
42 plt_dp_err("Not enough tail room");
46 /* Prepare CPT instruction */
47 inst->w4.u64 = sess->inst.w4;
48 inst->w4.s.dlen = dlen;
49 inst->dptr = rte_pktmbuf_iova(m_src);
50 inst->rptr = inst->dptr;
55 static __rte_always_inline int
56 process_inb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sa,
57 struct cpt_inst_s *inst)
59 struct rte_crypto_sym_op *sym_op = cop->sym;
60 struct rte_mbuf *m_src = sym_op->m_src;
63 dlen = rte_pktmbuf_pkt_len(m_src);
65 /* Prepare CPT instruction */
66 inst->w4.u64 = sa->inst.w4;
67 inst->w4.s.dlen = dlen;
68 inst->dptr = rte_pktmbuf_iova(m_src);
69 inst->rptr = inst->dptr;
74 #endif /* __CN10K_IPSEC_LA_OPS_H__ */