From patchwork Tue Dec 7 06:50:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anoob Joseph X-Patchwork-Id: 104968 X-Patchwork-Delegate: gakhil@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 BC463A034F; Tue, 7 Dec 2021 07:52:17 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 994D6426FC; Tue, 7 Dec 2021 07:52:00 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id E2B1041C28 for ; Tue, 7 Dec 2021 07:51:58 +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 1B75a0L2014936 for ; Mon, 6 Dec 2021 22:51:57 -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=s/MGdQ4GwDx4IAf4eeJOvGoNkxjGjsLNmK9Fb0c7eGg=; b=CgdlQejb3tkwRPKBJHJaOYWPV4pmAC6JGOxtIeVF/mjcaAN5fdgml28yoHjU3G16It14 302Wn2cgfmnuCC1Oo9eVJ8tb/OHgrNQveIQOBuC8aYRO6SQI6w8MwuAgkCJLo6KV8Cxg M+bMuULQqjNhkxXCLlXE9KwmMipDa+pQpCitc5fr8YmwNDrhFMV7PnGFuiFO1la7AGzx y3bLIrbmc/nViWm4jFR2L0W+R8t1P3ZUao3zeQeM61xZoJZkre9IqHR7HDEAFiS1jac5 xQ8yykpxrjTcJjHwGFa93Jwko6VbaLWiQAK/MDSPXVjges3uuLnnSOMhX6BDP3rgWqZP 3g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3ct1hyg7f0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 06 Dec 2021 22:51:57 -0800 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; Mon, 6 Dec 2021 22:51:55 -0800 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; Mon, 6 Dec 2021 22:51:55 -0800 Received: from HY-LT1002.marvell.com (HY-LT1002.marvell.com [10.28.176.218]) by maili.marvell.com (Postfix) with ESMTP id 4B9033F7071; Mon, 6 Dec 2021 22:51:53 -0800 (PST) From: Anoob Joseph To: Akhil Goyal , Jerin Jacob CC: Ankur Dwivedi , Archana Muniganti , Tejasree Kondoj , Subject: [PATCH 14/25] crypto/cnxk: add security session stats get Date: Tue, 7 Dec 2021 12:20:47 +0530 Message-ID: <1638859858-734-15-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1638859858-734-1-git-send-email-anoobj@marvell.com> References: <1638859858-734-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 3YTQgKOEZD0SZxRrngiO2vAZyvCGCdDW X-Proofpoint-GUID: 3YTQgKOEZD0SZxRrngiO2vAZyvCGCdDW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-07_02,2021-12-06_02,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: Ankur Dwivedi Adds the security session stats get op for cn10k. Signed-off-by: Ankur Dwivedi --- drivers/crypto/cnxk/cn10k_ipsec.c | 55 +++++++++++++++++++++++ drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c | 1 + drivers/crypto/cnxk/cnxk_cryptodev_sec.c | 1 + 3 files changed, 57 insertions(+) diff --git a/drivers/crypto/cnxk/cn10k_ipsec.c b/drivers/crypto/cnxk/cn10k_ipsec.c index 0832b53..a93c211 100644 --- a/drivers/crypto/cnxk/cn10k_ipsec.c +++ b/drivers/crypto/cnxk/cn10k_ipsec.c @@ -122,6 +122,12 @@ cn10k_ipsec_outb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, sa->inst.w4 = inst_w4.u64; + if (ipsec_xfrm->options.stats == 1) { + /* Enable mib counters */ + sa_dptr->w0.s.count_mib_bytes = 1; + sa_dptr->w0.s.count_mib_pkts = 1; + } + memset(out_sa, 0, sizeof(struct roc_ot_ipsec_outb_sa)); /* Copy word0 from sa_dptr to populate ctx_push_sz ctx_size fields */ @@ -212,6 +218,12 @@ cn10k_ipsec_inb_sa_create(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf, sa->inst.w4 = inst_w4.u64; + if (ipsec_xfrm->options.stats == 1) { + /* Enable mib counters */ + sa_dptr->w0.s.count_mib_bytes = 1; + sa_dptr->w0.s.count_mib_pkts = 1; + } + memset(in_sa, 0, sizeof(struct roc_ot_ipsec_inb_sa)); /* Copy word0 from sa_dptr to populate ctx_push_sz ctx_size fields */ @@ -357,6 +369,48 @@ cn10k_sec_session_get_size(void *device __rte_unused) return sizeof(struct cn10k_sec_session); } +static int +cn10k_sec_session_stats_get(void *device, struct rte_security_session *sess, + struct rte_security_stats *stats) +{ + struct rte_cryptodev *crypto_dev = device; + struct roc_ot_ipsec_outb_sa *out_sa; + struct roc_ot_ipsec_inb_sa *in_sa; + union roc_ot_ipsec_sa_word2 *w2; + struct cn10k_sec_session *priv; + struct cn10k_ipsec_sa *sa; + struct cnxk_cpt_qp *qp; + + priv = get_sec_session_private_data(sess); + if (priv == NULL) + return -EINVAL; + + qp = crypto_dev->data->queue_pairs[0]; + if (qp == NULL) + return -EINVAL; + + sa = &priv->sa; + w2 = (union roc_ot_ipsec_sa_word2 *)&sa->in_sa.w2; + + stats->protocol = RTE_SECURITY_PROTOCOL_IPSEC; + + if (w2->s.dir == ROC_IE_SA_DIR_OUTBOUND) { + out_sa = &sa->out_sa; + roc_cpt_lf_ctx_flush(&qp->lf, out_sa, false); + rte_delay_ms(1); + stats->ipsec.opackets = out_sa->ctx.mib_pkts; + stats->ipsec.obytes = out_sa->ctx.mib_octs; + } else { + in_sa = &sa->in_sa; + roc_cpt_lf_ctx_flush(&qp->lf, in_sa, false); + rte_delay_ms(1); + stats->ipsec.ipackets = in_sa->ctx.mib_pkts; + stats->ipsec.ibytes = in_sa->ctx.mib_octs; + } + + return 0; +} + /* Update platform specific security ops */ void cn10k_sec_ops_override(void) @@ -365,4 +419,5 @@ cn10k_sec_ops_override(void) cnxk_sec_ops.session_create = cn10k_sec_session_create; cnxk_sec_ops.session_destroy = cn10k_sec_session_destroy; cnxk_sec_ops.session_get_size = cn10k_sec_session_get_size; + cnxk_sec_ops.session_stats_get = cn10k_sec_session_stats_get; } diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c index 9a55474..0fdd91a 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c @@ -1073,6 +1073,7 @@ cn10k_sec_caps_update(struct rte_security_capability *sec_cap) } sec_cap->ipsec.options.ip_csum_enable = 1; sec_cap->ipsec.options.l4_csum_enable = 1; + sec_cap->ipsec.options.stats = 1; } static void diff --git a/drivers/crypto/cnxk/cnxk_cryptodev_sec.c b/drivers/crypto/cnxk/cnxk_cryptodev_sec.c index 2021d5c..e5a5d2d 100644 --- a/drivers/crypto/cnxk/cnxk_cryptodev_sec.c +++ b/drivers/crypto/cnxk/cnxk_cryptodev_sec.c @@ -15,6 +15,7 @@ struct rte_security_ops cnxk_sec_ops = { .session_create = NULL, .session_destroy = NULL, .session_get_size = NULL, + .session_stats_get = NULL, .set_pkt_metadata = NULL, .get_userdata = NULL, .capabilities_get = cnxk_crypto_sec_capabilities_get