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 AF696A050C; Sun, 8 May 2022 09:51:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A2A0142840; Sun, 8 May 2022 09:49:51 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D83B44289A for ; Sun, 8 May 2022 09:49:49 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2485QDrd023654 for ; Sun, 8 May 2022 00:49:49 -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=fxG5UQM6Ri0J6ed7j7qi8uw5lMaX0alO9lnivvtn0pc=; b=dkDIhE/42xfl3LdAOw2pVTFF34NzU2L/f4d0RzO5CX0+cRUwnrTBL2VwcrYRepkMSkli EiUHmrfvWuGu8zQigHXeBX1p3bLKSN1yPmbVyckJBC+ia+9WoQCWQNSOaRkcVquvzT0r 7uifRouQt5lWafNGEe6UYVIvHm6kZ4xLNIP3EsVQoWkZSQTqWkrSO/suv7qEZQnW5rCM ZBsn+NN3wuBgA4a87+eyWm1yeYAVhzi+4zMpouVgdIeQQqoPJeh+MII+kvOm2DQVVgL4 SBbFqeh2WotNsYQ/SKPSxyKy3+TDr9O/9LIjTddV9o/vdb0I0nWtCl8vhcX0LFfjFn6A 7w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3fwy5j13st-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 08 May 2022 00:49:49 -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; Sun, 8 May 2022 00:49:47 -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; Sun, 8 May 2022 00:49:47 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id C02645B6929; Sun, 8 May 2022 00:49:44 -0700 (PDT) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao CC: , Akhil Goyal , Vamsi Attunuru Subject: [PATCH v5 23/28] net/cnxk: support security stats Date: Sun, 8 May 2022 13:18:34 +0530 Message-ID: <20220508074839.6965-23-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220508074839.6965-1-ndabilpuram@marvell.com> References: <20220419055921.10566-1-ndabilpuram@marvell.com> <20220508074839.6965-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: T9ltjkT_M0EFXz33aHw1UuMD_onsz5P_ X-Proofpoint-GUID: T9ltjkT_M0EFXz33aHw1UuMD_onsz5P_ 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-08_02,2022-05-06_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 b535bda..3795b0c 100644 --- a/drivers/net/cnxk/cn10k_ethdev_sec.c +++ b/drivers/net/cnxk/cn10k_ethdev_sec.c @@ -291,7 +291,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, }, }, @@ -316,7 +316,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, }, }, @@ -340,7 +340,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, }, }, @@ -363,7 +363,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, }, }, @@ -700,6 +700,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; @@ -782,6 +787,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; @@ -1001,6 +1012,42 @@ rte_pmd_cnxk_hw_sa_write(void *device, struct rte_security_session *sess, return 0; } +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) { @@ -1015,4 +1062,5 @@ cn10k_eth_sec_ops_override(void) 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_update = cn10k_eth_sec_session_update; + cnxk_eth_sec_ops.session_stats_get = cn10k_eth_sec_session_stats_get; } -- 2.8.4