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 DC794A00C2; Thu, 10 Feb 2022 07:54:19 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C7B8841152; Thu, 10 Feb 2022 07:54:19 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6D39C40041 for ; Thu, 10 Feb 2022 07:54:18 +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 21A2Jnx0014380 for ; Wed, 9 Feb 2022 22:54:17 -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=f0n9yk/Ysb2AuD/knQ9yV235WeYzlsw7SZVKvBk7O0M=; b=QzBVXCmHJdzUN7Gu+JZwyN4/SOf2WSgAHTunrs2639UHFFCXFWwDZS1OycGvgJsg0ar8 n0putmXNVwribWzgJzB3rc9zL51jXM3zNIQD4ADEn+TQDzzBRq+APQ0M3Azjp1b1pwlU 6cQbCJQ7Urgk7lzUEiTdGZKfLRSmUWjqGcQRUBnaD2eWVK877HV4EOcitaVbbu/azipN S30V3r9PCEYag1OoQ6gFlM3w/+KhbkYe5+NEFU6b0zh0spFxejS7hhxeNIFU0caVjFyv Psl8Ijid/PDgFMyQj2gdkaOnIlvpAzH/pc+CIwcS68/R+pNr16434yQhGCYuI1K5QjZ6 7g== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e4am951uq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 09 Feb 2022 22:54:17 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 9 Feb 2022 22:54:15 -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; Wed, 9 Feb 2022 22:54:15 -0800 Received: from hyd1349.t110.caveonetworks.com.com (unknown [10.29.45.13]) by maili.marvell.com (Postfix) with ESMTP id 1739E3F7077; Wed, 9 Feb 2022 22:54:12 -0800 (PST) From: Ankur Dwivedi To: CC: , , , , , , , Ankur Dwivedi Subject: [PATCH 1/2] net/cnxk: add telemetry for inline IPsec for cn9k Date: Thu, 10 Feb 2022 12:23:33 +0530 Message-ID: <20220210065334.19942-2-adwivedi@marvell.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20220210065334.19942-1-adwivedi@marvell.com> References: <20220210065334.19942-1-adwivedi@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: bY2Ar8lSGkbTDwOcL5AsclevGi4ReO3j X-Proofpoint-ORIG-GUID: bY2Ar8lSGkbTDwOcL5AsclevGi4ReO3j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-10_02,2022-02-09_01,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 Adds telemetry function to get information about inline outbound and inline inbound sa's. The function takes port id as input. Some fields in the structures roc_onf_ipsec_outb_sa and roc_onf_ipsec_inb_sa are returned as output. Signed-off-by: Ankur Dwivedi Reviewed-by: Jerin Jacob Kollanukkaran --- drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c | 140 +++++++++++++++++++ drivers/net/cnxk/meson.build | 1 + 2 files changed, 141 insertions(+) create mode 100644 drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c diff --git a/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c new file mode 100644 index 0000000000..83015e11e2 --- /dev/null +++ b/drivers/net/cnxk/cnxk_ethdev_sec_telemetry.c @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2022 Marvell. + */ + +#include + +#include + +#include "cnxk_ethdev.h" + +#define STR_MAXLEN 20 +#define W0_MAXLEN 21 + +static int +copy_outb_sa_9k(struct rte_tel_data *d, uint32_t i, void *sa) +{ + struct roc_onf_ipsec_outb_sa *out_sa; + union { + struct roc_ie_onf_sa_ctl ctl; + uint64_t u64; + } w0; + char strw0[W0_MAXLEN]; + char str[STR_MAXLEN]; + + out_sa = (struct roc_onf_ipsec_outb_sa *)sa; + w0.ctl = out_sa->ctl; + + snprintf(str, sizeof(str), "outsa_w0_%u", i); + snprintf(strw0, sizeof(strw0), "%" PRIu64, w0.u64); + rte_tel_data_add_dict_string(d, str, strw0); + + snprintf(str, sizeof(str), "outsa_src_%u", i); + rte_tel_data_add_dict_u64(d, str, out_sa->udp_src); + + snprintf(str, sizeof(str), "outsa_dst_%u", i); + rte_tel_data_add_dict_u64(d, str, out_sa->udp_dst); + + snprintf(str, sizeof(str), "outsa_isrc_%u", i); + rte_tel_data_add_dict_u64(d, str, out_sa->ip_src); + + snprintf(str, sizeof(str), "outsa_idst_%u", i); + rte_tel_data_add_dict_u64(d, str, out_sa->ip_dst); + + return 0; +} + +static int +copy_inb_sa_9k(struct rte_tel_data *d, uint32_t i, void *sa) +{ + struct roc_onf_ipsec_inb_sa *in_sa; + union { + struct roc_ie_onf_sa_ctl ctl; + uint64_t u64; + } w0; + char strw0[W0_MAXLEN]; + char str[STR_MAXLEN]; + + in_sa = (struct roc_onf_ipsec_inb_sa *)sa; + w0.ctl = in_sa->ctl; + + snprintf(str, sizeof(str), "insa_w0_%u", i); + snprintf(strw0, sizeof(strw0), "%" PRIu64, w0.u64); + rte_tel_data_add_dict_string(d, str, strw0); + + snprintf(str, sizeof(str), "insa_esnh_%u", i); + rte_tel_data_add_dict_u64(d, str, in_sa->esn_hi); + + snprintf(str, sizeof(str), "insa_esnl_%u", i); + rte_tel_data_add_dict_u64(d, str, in_sa->esn_low); + + return 0; +} + +static int +ethdev_sec_tel_handle_info(const char *cmd __rte_unused, const char *params, + struct rte_tel_data *d) +{ + struct cnxk_eth_sec_sess *eth_sec, *tvar; + struct rte_eth_dev *eth_dev; + struct cnxk_eth_dev *dev; + uint16_t port_id; + char *end_p; + uint32_t i; + int ret; + + port_id = strtoul(params, &end_p, 0); + if (errno != 0) + return -EINVAL; + + if (*end_p != '\0') + plt_err("Extra parameters passed to telemetry, ignoring it"); + + if (!rte_eth_dev_is_valid_port(port_id)) { + plt_err("Invalid port id %u", port_id); + return -EINVAL; + } + + eth_dev = &rte_eth_devices[port_id]; + if (!eth_dev) { + plt_err("Ethdev not available"); + return -EINVAL; + } + + dev = cnxk_eth_pmd_priv(eth_dev); + + rte_tel_data_start_dict(d); + + rte_tel_data_add_dict_int(d, "nb_outb_sa", dev->outb.nb_sess); + + i = 0; + if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) { + tvar = NULL; + RTE_TAILQ_FOREACH_SAFE(eth_sec, &dev->outb.list, entry, tvar) { + ret = copy_outb_sa_9k(d, i++, eth_sec->sa); + if (ret < 0) + return ret; + } + } + + rte_tel_data_add_dict_int(d, "nb_inb_sa", dev->inb.nb_sess); + + i = 0; + if (dev->rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY) { + tvar = NULL; + RTE_TAILQ_FOREACH_SAFE(eth_sec, &dev->inb.list, entry, tvar) { + ret = copy_inb_sa_9k(d, i++, eth_sec->sa); + if (ret < 0) + return ret; + } + } + + return 0; +} + +RTE_INIT(cnxk_ipsec_init_telemetry) +{ + rte_telemetry_register_cmd("/cnxk/ipsec/info", + ethdev_sec_tel_handle_info, + "Returns ipsec info. Parameters: port id"); +} diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build index cd8c13bd1c..83af1f4d0c 100644 --- a/drivers/net/cnxk/meson.build +++ b/drivers/net/cnxk/meson.build @@ -15,6 +15,7 @@ sources = files( 'cnxk_ethdev_ops.c', 'cnxk_ethdev_sec.c', 'cnxk_ethdev_telemetry.c', + 'cnxk_ethdev_sec_telemetry.c', 'cnxk_link.c', 'cnxk_lookup.c', 'cnxk_ptp.c', -- 2.28.0