From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36A63A034F; Mon, 7 Feb 2022 08:32:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 234744114F; Mon, 7 Feb 2022 08:30:47 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7C9ED41141 for ; Mon, 7 Feb 2022 08:30:45 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 216MnxOv021550 for ; Sun, 6 Feb 2022 23:30:44 -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-type; s=pfpt0220; bh=RM2MHhMTJPnT9zFYJI5vHoHSUQVxP1OewpNInXVMxRg=; b=QEd+DOjL6QDGbiN16rAyE4V54ME0byF5ZUiOJlDjVB0IQY1AuwC/iZcJFVWN/PuGc+uy rZ/5z8w5qY7RO5Oy5O4AOc4P/i+HF+ThCnLCvutXkIfCOwbiMg2wZx403hRxqnqAqp51 s/igu7lpEgMf1vkz4w1wxH0fvkaQOugpWA175HKkxVyJtCEBEMU7DuUWWtSZAkHDFlS5 JhCB6Pr8N66taL4Ff9VtocjN9DF4/9EhREwOmsiDhePm6rMVecNyb1CZypUTpS1Cx0xC QW0hgbYZmoduIkdmtz8i8pZbyYOpE8vmJ6Pm7Y1AUJWtEFuMhbyM9EqwlD9VFVwUfBln Pw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e1smr4p77-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 06 Feb 2022 23:30:44 -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; Sun, 6 Feb 2022 23:30:42 -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; Sun, 6 Feb 2022 23:30:42 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 5176A3F704F; Sun, 6 Feb 2022 23:30:40 -0800 (PST) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: Subject: [PATCH 20/20] net/cnxk: add option to override outbound inline sa iv Date: Mon, 7 Feb 2022 12:59:32 +0530 Message-ID: <20220207072932.22409-20-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220207072932.22409-1-ndabilpuram@marvell.com> References: <20220207072932.22409-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: Simlx9mXOh1RoiCaSAAL7_mesj-U4ds_ X-Proofpoint-ORIG-GUID: Simlx9mXOh1RoiCaSAAL7_mesj-U4ds_ 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-02-07_02,2022-02-03_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 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 a2a53c1..a514345 100644 --- a/drivers/net/cnxk/cn10k_ethdev_sec.c +++ b/drivers/net/cnxk/cn10k_ethdev_sec.c @@ -252,6 +252,63 @@ cn10k_eth_sec_sso_work_cb(uint64_t *gw, void *args) cnxk_pktmbuf_free_no_cache(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, @@ -390,6 +447,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) < @@ -416,6 +474,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.8.4