crypto/cnxk: fix update of number of descriptors
[dpdk.git] / drivers / crypto / cnxk / cn9k_ipsec_la_ops.h
index 2b0261e..df89aac 100644 (file)
@@ -74,7 +74,7 @@ static __rte_always_inline int
 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;
        struct roc_ie_on_outb_sa *out_sa;
@@ -103,9 +103,15 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa,
                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);
 
@@ -134,8 +140,20 @@ process_inb_sa(struct rte_crypto_op *cop, struct cn9k_ipsec_sa *sa,
        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;
                }
        }