DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>,
	Declan Doherty <declan.doherty@intel.com>,
	Fan Zhang <roy.fan.zhang@intel.com>,
	"Konstantin Ananyev" <konstantin.ananyev@intel.com>
Cc: Tejasree Kondoj <ktejasree@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>,
	 Archana Muniganti <marchana@marvell.com>,
	Hemant Agrawal <hemant.agrawal@nxp.com>,
	Radu Nicolau <radu.nicolau@intel.com>,
	Ciara Power <ciara.power@intel.com>, <dev@dpdk.org>,
	Anoob Joseph <anoobj@marvell.com>
Subject: [dpdk-dev] [PATCH 2/3] crypto/cnxk: add IV in SA in lookaside IPsec debug mode
Date: Mon, 16 Aug 2021 11:29:49 +0530	[thread overview]
Message-ID: <1629093590-115-3-git-send-email-anoobj@marvell.com> (raw)
In-Reply-To: <1629093590-115-1-git-send-email-anoobj@marvell.com>

From: Tejasree Kondoj <ktejasree@marvell.com>

Adding IV in SA in lookaside IPsec debug mode. It helps
to verify lookaside PMD using known outbound vectors in
lookaside autotest.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Tejasree Kondoj <ktejasree@marvell.com>
---
 drivers/crypto/cnxk/cn10k_ipsec.c                 | 16 +++++++++++++++
 drivers/crypto/cnxk/cn10k_ipsec.h                 |  2 ++
 drivers/crypto/cnxk/cn10k_ipsec_la_ops.h          | 24 +++++++++++++++++++++++
 drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 16 ++++++++++++++-
 drivers/crypto/cnxk/meson.build                   |  6 ++++++
 5 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/drivers/crypto/cnxk/cn10k_ipsec.c b/drivers/crypto/cnxk/cn10k_ipsec.c
index 1d567bf..3ce25f2 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.c
+++ b/drivers/crypto/cnxk/cn10k_ipsec.c
@@ -110,6 +110,22 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt,
 
 	sa->inst.w7 = ipsec_cpt_inst_w7_get(roc_cpt, sa);
 
+#ifdef LA_IPSEC_DEBUG
+	/* Use IV from application in debug mode */
+	if (ipsec_xfrm->options.iv_gen_disable == 1) {
+		out_sa->w2.s.iv_src = ROC_IE_OT_SA_IV_SRC_FROM_SA;
+		if (crypto_xfrm->type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+			sa->iv_offset = crypto_xfrm->aead.iv.offset;
+			sa->iv_length = crypto_xfrm->aead.iv.length;
+		}
+	}
+#else
+	if (ipsec_xfrm->options.iv_gen_disable != 0) {
+		plt_err("Application provided IV not supported");
+		return -ENOTSUP;
+	}
+#endif
+
 	/* Get Rlen calculation data */
 	ret = cnxk_ipsec_outb_rlens_get(&rlens, ipsec_xfrm, crypto_xfrm);
 	if (ret)
diff --git a/drivers/crypto/cnxk/cn10k_ipsec.h b/drivers/crypto/cnxk/cn10k_ipsec.h
index 668282f..25fc2ee 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec.h
@@ -20,6 +20,8 @@ struct cn10k_ipsec_sa {
 	};
 	/** Pre-populated CPT inst words */
 	struct cnxk_cpt_inst_tmpl inst;
+	uint16_t iv_offset;
+	uint8_t iv_length;
 	uint8_t partial_len;
 	uint8_t roundup_len;
 	uint8_t roundup_byte;
diff --git a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
index 1e9ebb5..1c142d2 100644
--- a/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
+++ b/drivers/crypto/cnxk/cn10k_ipsec_la_ops.h
@@ -23,6 +23,25 @@ ipsec_po_out_rlen_get(struct cn10k_ipsec_sa *sess, uint32_t plen)
 	return sess->partial_len + enc_payload_len;
 }
 
+static inline void
+ipsec_po_sa_iv_set(struct cn10k_ipsec_sa *sess, struct rte_crypto_op *cop)
+{
+	uint8_t *iv = &sess->out_sa.iv.s.iv_dbg1[0];
+	uint32_t *tmp_iv;
+
+	memcpy(iv, rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset),
+	       4);
+	tmp_iv = (uint32_t *)iv;
+	*tmp_iv = rte_be_to_cpu_32(*tmp_iv);
+
+	iv = &sess->out_sa.iv.s.iv_dbg2[0];
+	memcpy(iv,
+	       rte_crypto_op_ctod_offset(cop, uint8_t *, sess->iv_offset + 4),
+	       4);
+	tmp_iv = (uint32_t *)iv;
+	*tmp_iv = rte_be_to_cpu_32(*tmp_iv);
+}
+
 static __rte_always_inline int
 process_outb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sess,
 		struct cpt_inst_s *inst)
@@ -43,6 +62,11 @@ process_outb_sa(struct rte_crypto_op *cop, struct cn10k_ipsec_sa *sess,
 		return -ENOMEM;
 	}
 
+#ifdef LA_IPSEC_DEBUG
+	if (sess->out_sa.w2.s.iv_src == ROC_IE_OT_SA_IV_SRC_FROM_SA)
+		ipsec_po_sa_iv_set(sess, cop);
+#endif
+
 	/* Prepare CPT instruction */
 	inst->w4.u64 = sess->inst.w4;
 	inst->w4.s.dlen = dlen;
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
index ab37f9c..8ec1e9d 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
+++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c
@@ -776,7 +776,21 @@ static const struct rte_security_capability sec_caps_templ[] = {
 			.proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
 			.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
 			.direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
-			.options = { 0 }
+			.options = {
+				.esn = 0,
+				.udp_encap = 0,
+				.copy_dscp = 0,
+				.copy_flabel = 0,
+				.copy_df = 0,
+				.dec_ttl = 0,
+				.ecn = 0,
+				.stats = 0,
+#ifdef LA_IPSEC_DEBUG
+				.iv_gen_disable = 1,
+#else
+				.iv_gen_disable = 0,
+#endif
+			}
 		},
 		.crypto_capabilities = NULL,
 		.ol_flags = RTE_SECURITY_TX_OLOAD_NEED_MDATA
diff --git a/drivers/crypto/cnxk/meson.build b/drivers/crypto/cnxk/meson.build
index c56d6cf..1694e05 100644
--- a/drivers/crypto/cnxk/meson.build
+++ b/drivers/crypto/cnxk/meson.build
@@ -23,3 +23,9 @@ sources = files(
 deps += ['bus_pci', 'common_cnxk', 'security']
 
 includes += include_directories('../../../lib/net')
+
+if get_option('buildtype').contains('debug')
+    cflags += [ '-DLA_IPSEC_DEBUG' ]
+else
+    cflags += [ '-ULA_IPSEC_DEBUG' ]
+endif
-- 
2.7.4


  parent reply	other threads:[~2021-08-16  6:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  5:59 [dpdk-dev] [PATCH 0/3] Add user specified IV with lookaside IPsec Anoob Joseph
2021-08-16  5:59 ` [dpdk-dev] [PATCH 1/3] security: support user specified IV Anoob Joseph
2021-08-16  5:59 ` Anoob Joseph [this message]
2021-08-16  5:59 ` [dpdk-dev] [PATCH 3/3] test/crypto: add outbound known vector tests Anoob Joseph
2021-09-06 14:58 ` [dpdk-dev] [PATCH v2 0/3] Add user specified IV with lookaside IPsec Anoob Joseph
2021-09-06 14:58   ` [dpdk-dev] [PATCH v2 1/3] security: support user specified IV Anoob Joseph
2021-09-06 19:07     ` Akhil Goyal
2021-09-06 14:58   ` [dpdk-dev] [PATCH v2 2/3] crypto/cnxk: add IV in SA in lookaside IPsec debug mode Anoob Joseph
2021-09-06 19:08     ` Akhil Goyal
2021-09-06 14:58   ` [dpdk-dev] [PATCH v2 3/3] test/crypto: add outbound known vector tests Anoob Joseph
2021-09-06 19:09     ` Akhil Goyal
2021-09-07 16:17   ` [dpdk-dev] [PATCH v3 0/3] Add user specified IV with lookaside IPsec Anoob Joseph
2021-09-07 16:17     ` [dpdk-dev] [PATCH v3 1/3] security: support user specified IV Anoob Joseph
2021-09-16 11:14       ` Ananyev, Konstantin
2021-09-07 16:17     ` [dpdk-dev] [PATCH v3 2/3] crypto/cnxk: add IV in SA in lookaside IPsec debug mode Anoob Joseph
2021-09-07 16:17     ` [dpdk-dev] [PATCH v3 3/3] test/crypto: add outbound known vector tests Anoob Joseph
2021-09-28  8:32     ` [dpdk-dev] [PATCH v3 0/3] Add user specified IV with lookaside IPsec Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1629093590-115-3-git-send-email-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=ciara.power@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=ktejasree@marvell.com \
    --cc=marchana@marvell.com \
    --cc=radu.nicolau@intel.com \
    --cc=roy.fan.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).