From patchwork Thu Jan 20 16:53:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akhil Goyal X-Patchwork-Id: 106147 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EF006A034E; Thu, 20 Jan 2022 17:53:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 39B074272A; Thu, 20 Jan 2022 17:53:40 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id A375942721 for ; Thu, 20 Jan 2022 17:53:38 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 20KAALbo026477; Thu, 20 Jan 2022 08:53:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=lHbk3JwbjR9Lf956kM4PYtz4ziphhCg2xiY3R8evW6U=; b=NFDbAsAbiw6cY+TTt+Ax2ysAF8dhcQgBm2Tzw+XwOfyjFTbxdnMaJOQmwgvCqe2CGv2w MtFyvbkSRNEFhBfTO8A5edK7BJpqkShe51shOEmFb9BRD+zP3PqTNWWzv9/HMKGVw+LE ZOiMbbINAwX3bJQZhUqGOVYU9Ug6nxN6/ekhbycDg2OOx40qiRFSbeI2KcEaMp0/kwP1 /25yLPiuojvKGmEljb6W7BgdYHQp/4AhbseK5rltv8WRtecSWo4+rUSrNZvYbQ8ERlcj 3M9pWxbwYFts3N3BTH9rw9U/EhxRpkSXGVCR1B9cuIFrV0qxoN63tv1xX+u6OjchTA6J VQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3dq5re1gm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 20 Jan 2022 08:53:37 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 20 Jan 2022 08:53:36 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 20 Jan 2022 08:53:36 -0800 Received: from localhost.localdomain (unknown [10.28.48.55]) by maili.marvell.com (Postfix) with ESMTP id B61813F704A; Thu, 20 Jan 2022 08:53:32 -0800 (PST) From: Akhil Goyal To: CC: , , , , , , , , , Nithin Dabilpuram Subject: [PATCH v2 4/4] net/cnxk: add option to override outbound inline sa iv Date: Thu, 20 Jan 2022 22:23:10 +0530 Message-ID: <20220120165310.4165567-5-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220120165310.4165567-1-gakhil@marvell.com> References: <20220103160149.1715058-1-gakhil@marvell.com> <20220120165310.4165567-1-gakhil@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: i1qsKCk9Nq7A5XeL0cugftsQqWxRljmD X-Proofpoint-ORIG-GUID: i1qsKCk9Nq7A5XeL0cugftsQqWxRljmD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-20_06,2022-01-20_01,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Nithin Dabilpuram 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 --- 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;