This patch usages the anti replay window size to config
the anti replay checking  in decap path for lookaside
IPSEC offload

Signed-off-by: Hemant Agrawal <hemant.agra...@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 21 +++++++++++++++++
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 26 +++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 7364b78e7..d7d95bf80 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2887,6 +2887,27 @@ dpaa2_sec_set_ipsec_session(struct rte_cryptodev *dev,
                                sizeof(struct rte_ipv6_hdr) << 16;
                if (ipsec_xform->options.esn)
                        decap_pdb.options |= PDBOPTS_ESP_ESN;
+
+               if (ipsec_xform->replay_win_sz) {
+                       uint32_t win_sz;
+                       win_sz = rte_align32pow2(ipsec_xform->replay_win_sz);
+
+                       switch (win_sz) {
+                       case 1:
+                       case 2:
+                       case 4:
+                       case 8:
+                       case 16:
+                       case 32:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS32;
+                               break;
+                       case 64:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS64;
+                               break;
+                       default:
+                               decap_pdb.options |= PDBOPTS_ESP_ARS128;
+                       }
+               }
                session->dir = DIR_DEC;
                bufsize = cnstr_shdsc_ipsec_new_decap(priv->flc_desc[0].desc,
                                1, 0, SHR_SERIAL,
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c 
b/drivers/crypto/dpaa_sec/dpaa_sec.c
index a828b23c7..f5f18457a 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2832,6 +2832,32 @@ dpaa_sec_set_ipsec_session(__rte_unused struct 
rte_cryptodev *dev,
                                        sizeof(struct rte_ipv6_hdr) << 16;
                if (ipsec_xform->options.esn)
                        session->decap_pdb.options |= PDBOPTS_ESP_ESN;
+               if (ipsec_xform->replay_win_sz) {
+                       uint32_t win_sz;
+                       win_sz = rte_align32pow2(ipsec_xform->replay_win_sz);
+
+                       switch (win_sz) {
+                       case 1:
+                       case 2:
+                       case 4:
+                       case 8:
+                       case 16:
+                       case 32:
+                               if (ipsec_xform->options.esn)
+                                       session->decap_pdb.options |=
+                                                       PDBOPTS_ESP_ARS64;
+                               else
+                                       session->decap_pdb.options |=
+                                                       PDBOPTS_ESP_ARS32;
+                               break;
+                       case 64:
+                               session->decap_pdb.options |= PDBOPTS_ESP_ARS64;
+                               break;
+                       default:
+                               session->decap_pdb.options |=
+                                                       PDBOPTS_ESP_ARS128;
+                       }
+               }
                session->dir = DIR_DEC;
        } else
                goto out;
-- 
2.17.1

Reply via email to