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 6A84A42CA8; Tue, 13 Jun 2023 12:22:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6364242D9B; Tue, 13 Jun 2023 12:21:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 193A842D8E for ; Tue, 13 Jun 2023 12:21:01 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35D5riwM007661; Tue, 13 Jun 2023 03:21:00 -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=C1L8gg+zHBHBH2u/vQyCGUYW7sSZRy/smjvnMyhEaJ0=; b=a8XtRJtuJYijPVB7ghAkv8r1wVT35CqHB+c8aw/sJ3Vi+gRv4ZA+1xTeDowpzZ/Dxm7O UeMc/fuEq69Y3PjCzJKrxPfRoy6tXIt+dIkioKkRD9tLIlqaV11DEo9+1KnbxDwNj954 46b61T1TGsJZj3PSLo26WGI+Rd1aLrwInIvExgbHBOAFsQfAi28YmdSnqroBC7bBOxls cnn3qZ/3JL6mPGt3fhw7f5jUAxZcHfws5BfMj1ZoKpW5P/F8Z5K80rXWy/qY2gJmj3Hy Yk0ThQKFsWjlQtIbpqTV1PLfhRkP039/CL/IHrbI8MFomdiaUGl0kGNQuR3ZHLcA9cTN PQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3r4rpkfpvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 13 Jun 2023 03:21:00 -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.48; Tue, 13 Jun 2023 03:20:58 -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.48 via Frontend Transport; Tue, 13 Jun 2023 03:20:58 -0700 Received: from localhost.localdomain (unknown [10.28.36.102]) by maili.marvell.com (Postfix) with ESMTP id EBE0D3F7092; Tue, 13 Jun 2023 03:20:55 -0700 (PDT) From: Akhil Goyal To: CC: , , , , , , Akhil Goyal Subject: [PATCH v4 15/15] net/cnxk: add MACsec stats Date: Tue, 13 Jun 2023 15:50:09 +0530 Message-ID: <20230613102009.2390568-16-gakhil@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230613102009.2390568-1-gakhil@marvell.com> References: <20230613071614.2259604-1-gakhil@marvell.com> <20230613102009.2390568-1-gakhil@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: LwnKlDUiaoxf9OQpWpYtKTq8CAwrB7Xv X-Proofpoint-GUID: LwnKlDUiaoxf9OQpWpYtKTq8CAwrB7Xv 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-13_04,2023-06-12_02,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 --- doc/guides/rel_notes/release_23_07.rst | 5 ++ drivers/net/cnxk/cn10k_ethdev_sec.c | 11 +++-- drivers/net/cnxk/cnxk_ethdev_mcs.c | 64 ++++++++++++++++++++++++++ drivers/net/cnxk/cnxk_ethdev_mcs.h | 9 ++++ 4 files changed, 86 insertions(+), 3 deletions(-) diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst index 915c37529a..f126be1435 100644 --- a/doc/guides/rel_notes/release_23_07.rst +++ b/doc/guides/rel_notes/release_23_07.rst @@ -139,6 +139,11 @@ New Features for new capability registers, large passthrough BAR and some performance enhancements for UPT. +* **Updated Marvell cnxk ethdev driver.** + + Added support for Inline MACsec processing using rte_security framework + for CN103 platform. + * **Added new algorithms to cryptodev.** * Added asymmetric algorithm ShangMi 2 (SM2) along with prime field curve support. 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 87bfcb8b4e..5264774394 100644 --- a/drivers/net/cnxk/cnxk_ethdev_mcs.c +++ b/drivers/net/cnxk/cnxk_ethdev_mcs.c @@ -521,6 +521,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%" PRIx64 "\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%" PRIx64 "\n", port_stats.tcam_miss_cnt); + plt_nix_dbg("RX parser_err_cnt: 0x%" PRIx64 "\n", port_stats.parser_err_cnt); + plt_nix_dbg("RX preempt_err_cnt: 0x%" PRIx64 "\n", port_stats.preempt_err_cnt); + plt_nix_dbg("RX sectag_insert_err_cnt: 0x%" PRIx64 "\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