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 D0D18A04FF; Thu, 5 May 2022 14:58:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C075F4286A; Thu, 5 May 2022 14:57:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C89634286A for ; Thu, 5 May 2022 14:57:08 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.16.1.2) with ESMTP id 2457XGqL012012 for ; Thu, 5 May 2022 05:57:08 -0700 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=z9EE7JneJtofFhPm3SzKS+Dxgx4RNc0EgXcaszNREr8=; b=khEZTZrxG1oa8WLoXk+zE+6ncwUVpOabtLF1/TnJAaeAgI0N6aVJ06zDtIVTJS2XY5fU aQr6A1eqBj+tafM8/9KQvAASjhQOat4C+Ya0yuTgf7FSn6zV2N1mjOEJjYnDsGoqDPi3 0oS32y72D8mZJVbDEPf80ioqBo04+mAvQOWrjPZyNdkfMEh65TMmLfpXEAFra8oBYFif uI+95+DMkpyMIcf37ykBe2UvWuyrfeLEzy5jcPx5vN/C2EztxPx5pPXR65xH5N4kFCJH u7Qr42wMLRn+g5/8BJH+YuBS/IC8JOtUE1bzdE69rE2nSOc9aWOnxR2RcCFpGNsVjW/6 aQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3fuscx4yb9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 05 May 2022 05:57:07 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 5 May 2022 05:57:06 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Thu, 5 May 2022 05:57:06 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id D2B6A3F70A8; Thu, 5 May 2022 05:57:03 -0700 (PDT) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: , Akhil Goyal , Vamsi Attunuru Subject: [PATCH v3 23/28] net/cnxk: support security stats Date: Thu, 5 May 2022 18:25:52 +0530 Message-ID: <20220505125557.8828-23-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220505125557.8828-1-ndabilpuram@marvell.com> References: <20220419055921.10566-1-ndabilpuram@marvell.com> <20220505125557.8828-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: dBBhHtARqdHXuesv0fjkJO4KVfcs2t0K X-Proofpoint-ORIG-GUID: dBBhHtARqdHXuesv0fjkJO4KVfcs2t0K X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-05_05,2022-05-05_01,2022-02-23_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: Akhil Goyal Enabled rte_security stats operation based on the configuration of SA options set while creating session. Signed-off-by: Vamsi Attunuru Signed-off-by: Akhil Goyal --- drivers/net/cnxk/cn10k_ethdev_sec.c | 56 ++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c index 7e4941d..7c4988b 100644 --- a/drivers/net/cnxk/cn10k_ethdev_sec.c +++ b/drivers/net/cnxk/cn10k_ethdev_sec.c @@ -270,7 +270,7 @@ static const struct rte_security_capability cn10k_eth_sec_capabilities[] = { .dec_ttl = 1, .ip_csum_enable = 1, .l4_csum_enable = 1, - .stats = 0, + .stats = 1, .esn = 1, }, }, @@ -295,7 +295,7 @@ static const struct rte_security_capability cn10k_eth_sec_capabilities[] = { .dec_ttl = 1, .ip_csum_enable = 1, .l4_csum_enable = 1, - .stats = 0, + .stats = 1, .esn = 1, }, }, @@ -319,7 +319,7 @@ static const struct rte_security_capability cn10k_eth_sec_capabilities[] = { .dec_ttl = 1, .ip_csum_enable = 1, .l4_csum_enable = 1, - .stats = 0, + .stats = 1, .esn = 1, }, }, @@ -342,7 +342,7 @@ static const struct rte_security_capability cn10k_eth_sec_capabilities[] = { .dec_ttl = 1, .ip_csum_enable = 1, .l4_csum_enable = 1, - .stats = 0, + .stats = 1, .esn = 1, }, }, @@ -679,6 +679,11 @@ cn10k_eth_sec_session_create(void *device, inb_sa_dptr->w1.s.cookie = rte_cpu_to_be_32(ipsec->spi & spi_mask); + if (ipsec->options.stats == 1) { + /* Enable mib counters */ + inb_sa_dptr->w0.s.count_mib_bytes = 1; + inb_sa_dptr->w0.s.count_mib_pkts = 1; + } /* Prepare session priv */ sess_priv.inb_sa = 1; sess_priv.sa_idx = ipsec->spi & spi_mask; @@ -761,6 +766,12 @@ cn10k_eth_sec_session_create(void *device, /* Save rlen info */ cnxk_ipsec_outb_rlens_get(rlens, ipsec, crypto); + if (ipsec->options.stats == 1) { + /* Enable mib counters */ + outb_sa_dptr->w0.s.count_mib_bytes = 1; + outb_sa_dptr->w0.s.count_mib_pkts = 1; + } + /* Prepare session priv */ sess_priv.sa_idx = outb_priv->sa_idx; sess_priv.roundup_byte = rlens->roundup_byte; @@ -877,6 +888,42 @@ cn10k_eth_sec_capabilities_get(void *device __rte_unused) return cn10k_eth_sec_capabilities; } +static int +cn10k_eth_sec_session_stats_get(void *device, struct rte_security_session *sess, + struct rte_security_stats *stats) +{ + struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device; + struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct cnxk_eth_sec_sess *eth_sec; + int rc; + + eth_sec = cnxk_eth_sec_sess_get_by_sess(dev, sess); + if (eth_sec == NULL) + return -EINVAL; + + rc = roc_nix_inl_sa_sync(&dev->nix, eth_sec->sa, eth_sec->inb, + ROC_NIX_INL_SA_OP_FLUSH); + if (rc) + return -EINVAL; + rte_delay_ms(1); + + stats->protocol = RTE_SECURITY_PROTOCOL_IPSEC; + + if (eth_sec->inb) { + stats->ipsec.ipackets = + ((struct roc_ot_ipsec_inb_sa *)eth_sec->sa)->ctx.mib_pkts; + stats->ipsec.ibytes = + ((struct roc_ot_ipsec_inb_sa *)eth_sec->sa)->ctx.mib_octs; + } else { + stats->ipsec.opackets = + ((struct roc_ot_ipsec_outb_sa *)eth_sec->sa)->ctx.mib_pkts; + stats->ipsec.obytes = + ((struct roc_ot_ipsec_outb_sa *)eth_sec->sa)->ctx.mib_octs; + } + + return 0; +} + void cn10k_eth_sec_ops_override(void) { @@ -890,4 +937,5 @@ cn10k_eth_sec_ops_override(void) cnxk_eth_sec_ops.session_create = cn10k_eth_sec_session_create; cnxk_eth_sec_ops.session_destroy = cn10k_eth_sec_session_destroy; cnxk_eth_sec_ops.capabilities_get = cn10k_eth_sec_capabilities_get; + cnxk_eth_sec_ops.session_stats_get = cn10k_eth_sec_session_stats_get; } -- 2.8.4