DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akhil Goyal <gakhil@marvell.com>
To: <dev@dpdk.org>
Cc: <anoobj@marvell.com>, <hemant.agrawal@nxp.com>,
	<matan@nvidia.com>, <konstantin.ananyev@intel.com>,
	<thomas@monjalon.net>, <ferruh.yigit@intel.com>,
	<andrew.rybchenko@oktetlabs.ru>, <rosen.xu@intel.com>,
	<jerinj@marvell.com>, Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [PATCH v2 4/4] net/cnxk: add option to override outbound inline sa iv
Date: Thu, 20 Jan 2022 22:23:10 +0530	[thread overview]
Message-ID: <20220120165310.4165567-5-gakhil@marvell.com> (raw)
In-Reply-To: <20220120165310.4165567-1-gakhil@marvell.com>

From: Nithin Dabilpuram <ndabilpuram@marvell.com>

Add option to override outbound inline sa iv for debug
purposes via environment variable. User can set env variable as:
export CN10K_ETH_SEC_IV_OVR="0x0, 0x0,..."

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 drivers/net/cnxk/cn10k_ethdev_sec.c | 62 +++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c
index 59c7befb8e..a8788195f4 100644
--- a/drivers/net/cnxk/cn10k_ethdev_sec.c
+++ b/drivers/net/cnxk/cn10k_ethdev_sec.c
@@ -225,6 +225,63 @@ cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args)
 	rte_pktmbuf_free(mbuf);
 }
 
+static void
+outb_dbg_iv_update(struct roc_ot_ipsec_outb_sa *outb_sa, const char *__iv_str)
+{
+	uint8_t *iv_dbg = outb_sa->iv.iv_dbg;
+	char *iv_str = strdup(__iv_str);
+	char *iv_b = NULL, len = 16;
+	char *save;
+	int i;
+
+	if (!iv_str)
+		return;
+
+	if (outb_sa->w2.s.enc_type == ROC_IE_OT_SA_ENC_AES_GCM ||
+	    outb_sa->w2.s.enc_type == ROC_IE_OT_SA_ENC_AES_CTR ||
+	    outb_sa->w2.s.enc_type == ROC_IE_OT_SA_ENC_AES_CCM ||
+	    outb_sa->w2.s.auth_type == ROC_IE_OT_SA_AUTH_AES_GMAC) {
+		memset(outb_sa->iv.s.iv_dbg1, 0, sizeof(outb_sa->iv.s.iv_dbg1));
+		memset(outb_sa->iv.s.iv_dbg2, 0, sizeof(outb_sa->iv.s.iv_dbg2));
+
+		iv_dbg = outb_sa->iv.s.iv_dbg1;
+		for (i = 0; i < 4; i++) {
+			iv_b = strtok_r(i ? NULL : iv_str, ",", &save);
+			if (!iv_b)
+				break;
+			iv_dbg[i] = strtoul(iv_b, NULL, 0);
+		}
+		*(uint32_t *)iv_dbg = rte_be_to_cpu_32(*(uint32_t *)iv_dbg);
+
+		iv_dbg = outb_sa->iv.s.iv_dbg2;
+		for (i = 0; i < 4; i++) {
+			iv_b = strtok_r(NULL, ",", &save);
+			if (!iv_b)
+				break;
+			iv_dbg[i] = strtoul(iv_b, NULL, 0);
+		}
+		*(uint32_t *)iv_dbg = rte_be_to_cpu_32(*(uint32_t *)iv_dbg);
+
+	} else {
+		iv_dbg = outb_sa->iv.iv_dbg;
+		memset(iv_dbg, 0, sizeof(outb_sa->iv.iv_dbg));
+
+		for (i = 0; i < len; i++) {
+			iv_b = strtok_r(i ? NULL : iv_str, ",", &save);
+			if (!iv_b)
+				break;
+			iv_dbg[i] = strtoul(iv_b, NULL, 0);
+		}
+		*(uint64_t *)iv_dbg = rte_be_to_cpu_64(*(uint64_t *)iv_dbg);
+		*(uint64_t *)&iv_dbg[8] =
+			rte_be_to_cpu_64(*(uint64_t *)&iv_dbg[8]);
+	}
+
+	/* Update source of IV */
+	outb_sa->w2.s.iv_src = ROC_IE_OT_SA_IV_SRC_FROM_SA;
+	free(iv_str);
+}
+
 static int
 cn10k_eth_sec_session_create(void *device,
 			     struct rte_security_session_conf *conf,
@@ -370,6 +427,7 @@ cn10k_eth_sec_session_create(void *device,
 		struct cn10k_outb_priv_data *outb_priv;
 		struct cnxk_ipsec_outb_rlens *rlens;
 		uint64_t sa_base = dev->outb.sa_base;
+		const char *iv_str;
 		uint32_t sa_idx;
 
 		PLT_STATIC_ASSERT(sizeof(struct cn10k_outb_priv_data) <
@@ -395,6 +453,10 @@ cn10k_eth_sec_session_create(void *device,
 			goto mempool_put;
 		}
 
+		iv_str = getenv("CN10K_ETH_SEC_IV_OVR");
+		if (iv_str)
+			outb_dbg_iv_update(outb_sa_dptr, iv_str);
+
 		/* Save userdata */
 		outb_priv->userdata = conf->userdata;
 		outb_priv->sa_idx = sa_idx;
-- 
2.25.1


  parent reply	other threads:[~2022-01-20 16:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03 16:01 [PATCH 0/5] net/cnxk: support IP reassembly offload Akhil Goyal
2022-01-03 16:01 ` [PATCH 1/5] common/cnxk: configure reassembly specific params Akhil Goyal
2022-01-03 16:01 ` [PATCH 2/5] net/cnxk: reassembly support Akhil Goyal
2022-01-03 16:01 ` [PATCH 3/5] net/cnxk: support IP reassembly mbuf dynfield Akhil Goyal
2022-01-03 16:01 ` [PATCH 4/5] net/cnxk: add dev args for min-max spi Akhil Goyal
2022-01-03 16:01 ` [PATCH 5/5] net/cnxk: add option to override outbound inline sa iv Akhil Goyal
2022-01-20 16:53 ` [PATCH v2 0/4] net/cnxk: support IP reassembly offload Akhil Goyal
2022-01-20 16:53   ` [PATCH v2 1/4] common/cnxk: configure reassembly specific params Akhil Goyal
2022-01-20 16:53   ` [PATCH v2 2/4] net/cnxk: support IP reassembly Akhil Goyal
2022-01-20 16:53   ` [PATCH v2 3/4] net/cnxk: add dev args for min-max spi Akhil Goyal
2022-01-20 16:53   ` Akhil Goyal [this message]
2022-02-23 12:28   ` [PATCH v3 0/2] net/cnxk: support IP reassembly offload Akhil Goyal
2022-02-23 12:28     ` [PATCH v3 1/2] common/cnxk: configure reassembly specific params Akhil Goyal
2022-02-23 16:51       ` Jerin Jacob
2022-02-23 12:28     ` [PATCH v3 2/2] net/cnxk: support IP reassembly Akhil Goyal
2022-02-23 16:57       ` Jerin Jacob
2022-02-24 17:28     ` [PATCH v4 0/2] net/cnxk: support IP reassembly offload Akhil Goyal
2022-02-24 17:28       ` [PATCH v4 1/2] common/cnxk: configure reassembly specific params Akhil Goyal
2022-02-24 17:28       ` [PATCH v4 2/2] net/cnxk: support IP reassembly Akhil Goyal
2022-02-24 17:41         ` Jerin Jacob
2022-02-24 18:28       ` [PATCH v5 0/2] net/cnxk: support IP reassembly offload Akhil Goyal
2022-02-24 18:29         ` [PATCH v5 1/2] common/cnxk: configure reassembly specific params Akhil Goyal
2022-02-24 18:29         ` [PATCH v5 2/2] net/cnxk: support IP reassembly Akhil Goyal
2022-02-24 20:40         ` [PATCH v5 0/2] net/cnxk: support IP reassembly offload Jerin Jacob

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=20220120165310.4165567-5-gakhil@marvell.com \
    --to=gakhil@marvell.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=matan@nvidia.com \
    --cc=ndabilpuram@marvell.com \
    --cc=rosen.xu@intel.com \
    --cc=thomas@monjalon.net \
    /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).