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 6945E42C4E; Wed, 7 Jun 2023 17:30:12 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7248242F8C; Wed, 7 Jun 2023 17:29:13 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5C9F442DC2 for ; Wed, 7 Jun 2023 17:29:11 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 357Dvh29028122; Wed, 7 Jun 2023 08:29:10 -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-transfer-encoding : content-type; s=pfpt0220; bh=0GXVzCFcpHFFBKSfhUK5czwOP0QErwvdc5fzKrJ88xA=; b=XVHxaCyw6bmvrOs3IevqUI9saTJJur7Ro0g8GLjXKiz1RsdU9lBxjS7USet4+7Et/4d8 T2hBqbXiXxx/uFvbv3wjzadI0ib6JABMjMdnZVhHqhixqr0wbFESwoshURjGoiN4cFPB Z2hAKWeWCQpAvY8pmW8nLXV27wUDo4NFugYBARyy0ZhSANC5q58fjRS0/G1nZh5Cxwum NgeFscozclWjzrPpSKFc0U1fHY09QOenFsdE7/N9NOgyvj7XvzJPpilnbZmmMZAbKSXS fx8wtV6Jg4ML9T2kj4cCQwl+uWah3Ibf6K+DE/gRpwqTCwwqDrHZBXlU3rY0GoBneynd iw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3r2a7bv80e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 07 Jun 2023 08:29:10 -0700 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.48; Wed, 7 Jun 2023 08:29:08 -0700 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.48 via Frontend Transport; Wed, 7 Jun 2023 08:29:08 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id EF9D33F7084; Wed, 7 Jun 2023 08:29:05 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v2 15/15] net/cnxk: add MACsec stats Date: Wed, 7 Jun 2023 20:58:19 +0530 Message-ID: <20230607152819.226838-16-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230607152819.226838-1-gakhil@marvell.com> References: <20230523200401.1945974-1-gakhil@marvell.com> <20230607152819.226838-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: vh-svGoVyZRKrtflc7ix4uDKdc91IQ0n X-Proofpoint-GUID: vh-svGoVyZRKrtflc7ix4uDKdc91IQ0n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-07_07,2023-06-07_01,2023-05-22_02 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 Added support for MACsec SC/flow/session stats. Signed-off-by: Akhil Goyal --- drivers/net/cnxk/cn10k_ethdev_sec.c | 11 +++-- drivers/net/cnxk/cnxk_ethdev_mcs.c | 64 +++++++++++++++++++++++++++++ drivers/net/cnxk/cnxk_ethdev_mcs.h | 9 ++++ 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/drivers/net/cnxk/cn10k_ethdev_sec.c b/drivers/net/cnxk/cn10k_ethdev_sec.c index f20e573338..b98fc9378e 100644 --- a/drivers/net/cnxk/cn10k_ethdev_sec.c +++ b/drivers/net/cnxk/cn10k_ethdev_sec.c @@ -1058,12 +1058,17 @@ cn10k_eth_sec_session_stats_get(void *device, struct rte_security_session *sess, { struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device; struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); + struct cnxk_macsec_sess *macsec_sess; struct cnxk_eth_sec_sess *eth_sec; int rc; eth_sec = cnxk_eth_sec_sess_get_by_sess(dev, sess); - if (eth_sec == NULL) + if (eth_sec == NULL) { + macsec_sess = cnxk_eth_macsec_sess_get_by_sess(dev, sess); + if (macsec_sess) + return cnxk_eth_macsec_session_stats_get(dev, macsec_sess, stats); return -EINVAL; + } rc = roc_nix_inl_sa_sync(&dev->nix, eth_sec->sa, eth_sec->inb, ROC_NIX_INL_SA_OP_FLUSH); @@ -1107,6 +1112,6 @@ cn10k_eth_sec_ops_override(void) 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; - cnxk_eth_sec_ops.macsec_sc_stats_get = NULL; - cnxk_eth_sec_ops.macsec_sa_stats_get = NULL; + cnxk_eth_sec_ops.macsec_sc_stats_get = cnxk_eth_macsec_sc_stats_get; + cnxk_eth_sec_ops.macsec_sa_stats_get = cnxk_eth_macsec_sa_stats_get; } diff --git a/drivers/net/cnxk/cnxk_ethdev_mcs.c b/drivers/net/cnxk/cnxk_ethdev_mcs.c index b47991e259..851c83ff3f 100644 --- a/drivers/net/cnxk/cnxk_ethdev_mcs.c +++ b/drivers/net/cnxk/cnxk_ethdev_mcs.c @@ -517,6 +517,70 @@ cnxk_mcs_flow_destroy(struct cnxk_eth_dev *dev, void *flow) return ret; } +int +cnxk_eth_macsec_sa_stats_get(void *device, uint16_t sa_id, enum rte_security_macsec_direction dir, + struct rte_security_macsec_sa_stats *stats) +{ + RTE_SET_USED(device); + RTE_SET_USED(sa_id); + RTE_SET_USED(dir); + RTE_SET_USED(stats); + + return 0; +} + +int +cnxk_eth_macsec_sc_stats_get(void *device, uint16_t sc_id, enum rte_security_macsec_direction dir, + struct rte_security_macsec_sc_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_mcs_dev *mcs_dev = dev->mcs_dev; + struct roc_mcs_stats_req req = {0}; + + if (!roc_feature_nix_has_macsec()) + return -ENOTSUP; + + req.id = sc_id; + req.dir = (dir == RTE_SECURITY_MACSEC_DIR_RX) ? MCS_RX : MCS_TX; + + return roc_mcs_sc_stats_get(mcs_dev->mdev, &req, (struct roc_mcs_sc_stats *)stats); +} + +int +cnxk_eth_macsec_session_stats_get(struct cnxk_eth_dev *dev, struct cnxk_macsec_sess *sess, + struct rte_security_stats *stats) +{ + struct cnxk_mcs_dev *mcs_dev = dev->mcs_dev; + struct roc_mcs_flowid_stats flow_stats = {0}; + struct roc_mcs_port_stats port_stats = {0}; + struct roc_mcs_stats_req req = {0}; + + if (!roc_feature_nix_has_macsec()) + return -ENOTSUP; + + req.id = sess->flow_id; + req.dir = sess->dir; + roc_mcs_flowid_stats_get(mcs_dev->mdev, &req, &flow_stats); + plt_nix_dbg("\n******* FLOW_ID IDX[%u] STATS dir: %u********\n", sess->flow_id, sess->dir); + plt_nix_dbg("TX: tcam_hit_cnt: 0x%lx\n", flow_stats.tcam_hit_cnt); + + req.id = mcs_dev->port_id; + req.dir = sess->dir; + roc_mcs_port_stats_get(mcs_dev->mdev, &req, &port_stats); + plt_nix_dbg("\n********** PORT[0] STATS ****************\n"); + plt_nix_dbg("RX tcam_miss_cnt: 0x%lx\n", port_stats.tcam_miss_cnt); + plt_nix_dbg("RX parser_err_cnt: 0x%lx\n", port_stats.parser_err_cnt); + plt_nix_dbg("RX preempt_err_cnt: 0x%lx\n", port_stats.preempt_err_cnt); + plt_nix_dbg("RX sectag_insert_err_cnt: 0x%lx\n", port_stats.sectag_insert_err_cnt); + + req.id = sess->secy_id; + req.dir = sess->dir; + + return roc_mcs_secy_stats_get(mcs_dev->mdev, &req, + (struct roc_mcs_secy_stats *)(&stats->macsec)); +} + static int cnxk_mcs_event_cb(void *userdata, struct roc_mcs_event_desc *desc, void *cb_arg) { diff --git a/drivers/net/cnxk/cnxk_ethdev_mcs.h b/drivers/net/cnxk/cnxk_ethdev_mcs.h index 2b1a6f2c90..4a59dd3df9 100644 --- a/drivers/net/cnxk/cnxk_ethdev_mcs.h +++ b/drivers/net/cnxk/cnxk_ethdev_mcs.h @@ -97,6 +97,15 @@ int cnxk_eth_macsec_sa_destroy(void *device, uint16_t sa_id, int cnxk_eth_macsec_sc_destroy(void *device, uint16_t sc_id, enum rte_security_macsec_direction dir); +int cnxk_eth_macsec_sa_stats_get(void *device, uint16_t sa_id, + enum rte_security_macsec_direction dir, + struct rte_security_macsec_sa_stats *stats); +int cnxk_eth_macsec_sc_stats_get(void *device, uint16_t sa_id, + enum rte_security_macsec_direction dir, + struct rte_security_macsec_sc_stats *stats); +int cnxk_eth_macsec_session_stats_get(struct cnxk_eth_dev *dev, struct cnxk_macsec_sess *sess, + struct rte_security_stats *stats); + int cnxk_eth_macsec_session_create(struct cnxk_eth_dev *dev, struct rte_security_session_conf *conf, struct rte_security_session *sess); int cnxk_eth_macsec_session_destroy(struct cnxk_eth_dev *dev, struct rte_security_session *sess); -- 2.25.1