process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa,
struct cpt_inst_s *inst)
{
- const unsigned int hdr_len = sizeof(struct roc_ie_on_outb_hdr);
+ const unsigned int hdr_len = sa->custom_hdr_len;
struct rte_crypto_sym_op *sym_op = cop->sym;
struct rte_mbuf *m_src = sym_op->m_src;
- uint32_t dlen, rlen, extend_tail;
struct roc_ie_on_outb_sa *out_sa;
struct roc_ie_on_outb_hdr *hdr;
+ uint32_t dlen, rlen;
+ int32_t extend_tail;
out_sa = &sa->out_sa;
extend_tail = rlen - dlen;
if (unlikely(extend_tail > rte_pktmbuf_tailroom(m_src))) {
- plt_dp_err("Not enough tail room");
+ plt_dp_err("Not enough tail room (required: %d, available: %d",
+ extend_tail, rte_pktmbuf_tailroom(m_src));
return -ENOMEM;
}
return -ENOMEM;
}
- memcpy(&hdr->iv[0],
- rte_crypto_op_ctod_offset(cop, uint8_t *, sa->cipher_iv_off),
- sa->cipher_iv_len);
+#ifdef LA_IPSEC_DEBUG
+ if (sa->inst.w4 & ROC_IE_ON_PER_PKT_IV) {
+ memcpy(&hdr->iv[0],
+ rte_crypto_op_ctod_offset(cop, uint8_t *,
+ sa->cipher_iv_off),
+ sa->cipher_iv_len);
+ }
+#endif
+
hdr->seq = rte_cpu_to_be_32(sa->seq_lo);
hdr->ip_id = rte_cpu_to_be_32(sa->ip_id);
if (sa->replay_win_sz) {
ret = ipsec_antireplay_check(sa, sa->replay_win_sz, m_src);
if (unlikely(ret)) {
- plt_dp_err("Anti replay check failed");
- return ret;
+ /* Use PASSTHROUGH op for failed antireplay packet */
+ inst->w4.u64 = 0;
+ inst->w4.s.opcode_major = ROC_SE_MAJOR_OP_MISC;
+ inst->w4.s.opcode_minor =
+ ROC_SE_MISC_MINOR_OP_PASSTHROUGH;
+ inst->w4.s.param1 = 1;
+ /* Send out completion code only */
+ inst->w4.s.param2 =
+ (ROC_IE_ON_SWCC_ANTI_REPLAY << 8) | 0x1;
+ inst->w4.s.dlen = 1;
+ inst->dptr = rte_pktmbuf_iova(m_src);
+ inst->rptr = inst->dptr;
+ inst->w7.u64 = sa->inst.w7;
+ return 0;
}
}