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 142ECA0C45; Sat, 4 Sep 2021 05:25:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 431B2410D8; Sat, 4 Sep 2021 05:25:48 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 82FB04112E for ; Sat, 4 Sep 2021 05:25:46 +0200 (CEST) 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 SMTP id 183KnkEM013313; Fri, 3 Sep 2021 20:25:45 -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=HgmS2v34FCMR5LeZaJG9NvlgrfUAcYKA/Ko254C7Z+k=; b=C2DS3hadOI/dB+TihRXRlSP8C9Es+Fx+gEGw8iuyVERvfNko6kj4xuhwa52bqY3uqOCi Aq5mB2VYewPEK0sHu4C908WBWXdlwmFqaXLkGPlolbx7TNb64TENKzzCedPZevimTLNt Ghnlj3r9YfGwr5jLOpwD87Zon3PSEDrFCrxKh8ieLMEivFrAaYO8fQVf//6wvqKAq/9A LzlrHwTm7AMvkGfjP0KK3WrM0QqtzWW93CBLbEi/lNhojqfZLxgud/tw5/Iq9qUtRzkZ F/DDRFT2m5Cx92W5pfkScTZAe6MVMJXVR6XhXWgVMOB5PfJBg8u4b0dYtAHSnlpkguZG bw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 3aufr8bedp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 03 Sep 2021 20:25:45 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 3 Sep 2021 20:25:43 -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.18 via Frontend Transport; Fri, 3 Sep 2021 20:25:43 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 974EF3F7060; Fri, 3 Sep 2021 20:25:40 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , , , , , , , Gowrishankar Muthukrishnan Date: Sat, 4 Sep 2021 08:55:21 +0530 Message-ID: <086e443645a6b926a20cc29fd3fa91502fd76175.1630725752.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: AV5x2sZpt0B0sUGgoZIlt-fLoSsMiB2o X-Proofpoint-GUID: AV5x2sZpt0B0sUGgoZIlt-fLoSsMiB2o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-04_01,2021-09-03_01,2020-04-07_01 Subject: [dpdk-dev] [v6, 4/4] net/cnxk: add telemetry endpoing to ethdev 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 Sender: "dev" Add telemetry endpoint to ethdev. Signed-off-by: Gowrishankar Muthukrishnan --- drivers/net/cnxk/cnxk_ethdev_telemetry.c | 148 +++++++++++++++++++++++ drivers/net/cnxk/meson.build | 1 + 2 files changed, 149 insertions(+) create mode 100644 drivers/net/cnxk/cnxk_ethdev_telemetry.c diff --git a/drivers/net/cnxk/cnxk_ethdev_telemetry.c b/drivers/net/cnxk/cnxk_ethdev_telemetry.c new file mode 100644 index 0000000000..4d89151a90 --- /dev/null +++ b/drivers/net/cnxk/cnxk_ethdev_telemetry.c @@ -0,0 +1,148 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2021 Marvell International Ltd. + */ + +#include + +#include "cnxk_ethdev.h" + +/* Macro to count no of words in eth_info_s size */ +#define ETH_INFO_SZ \ + (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \ + sizeof(uint64_t)) +#define MACADDR_LEN 18 + +static int +ethdev_tel_handle_info(const char *cmd __rte_unused, + const char *params __rte_unused, struct rte_tel_data *d) +{ + struct rte_eth_dev *eth_dev; + struct cnxk_eth_dev *dev; + union eth_info_u { + struct eth_info_s { + /** PF/VF information */ + uint16_t pf_func; + /** No of rx queues */ + uint16_t rx_queues; + /** No of tx queues */ + uint16_t tx_queues; + /** Port ID */ + uint16_t port_id; + /** MAC entries */ + char mac_addr[MACADDR_LEN]; + uint8_t max_mac_entries; + bool dmac_filter_ena; + uint8_t dmac_filter_count; + uint16_t flags; + uint8_t ptype_disable; + bool scalar_ena; + bool ptp_ena; + /* Offload capabilities */ + uint64_t rx_offload_capa; + uint64_t tx_offload_capa; + uint32_t speed_capa; + /* Configured offloads */ + uint64_t rx_offloads; + uint64_t tx_offloads; + /* Platform specific offload flags */ + uint16_t rx_offload_flags; + uint16_t tx_offload_flags; + /* ETHDEV RSS HF bitmask */ + uint64_t ethdev_rss_hf; + } info; + uint64_t val[ETH_INFO_SZ]; + }; + union eth_info_u *eth_info; + struct eth_info_s *info; + int n_ports, rc = 0; + int i, j = 0; + + n_ports = rte_eth_dev_count_avail(); + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_int(d, "n_ports", n_ports); + + if (!n_ports) { + plt_err("No active ethernet ports found."); + goto exit; + } + + /* Allocate memory for hw info structure */ + eth_info = malloc(sizeof(struct eth_info_s) * n_ports); + if (!eth_info) { + plt_err("No space for HW info"); + rc = -ENOMEM; + goto exit; + } + + for (i = 0; i < RTE_MAX_ETHPORTS; i++) { + /* Skip if port is unused */ + if (!rte_eth_dev_is_valid_port(i)) + continue; + + eth_dev = &rte_eth_devices[i]; + info = ð_info[j].info; + + if (eth_dev) { + dev = cnxk_eth_pmd_priv(eth_dev); + if (dev) { + info->pf_func = roc_nix_get_pf_func(&dev->nix); + memset(info->mac_addr, 0, MACADDR_LEN); + snprintf(info->mac_addr, MACADDR_LEN, + "%02x:%02x:%02x:%02x:%02x:%02x", + dev->mac_addr[0], dev->mac_addr[1], + dev->mac_addr[2], dev->mac_addr[3], + dev->mac_addr[4], dev->mac_addr[5]); + info->max_mac_entries = dev->max_mac_entries; + info->dmac_filter_ena = dev->dmac_filter_enable; + info->dmac_filter_count = + dev->dmac_filter_count; + info->flags = dev->flags; + info->ptype_disable = dev->ptype_disable; + info->scalar_ena = dev->scalar_ena; + info->ptp_ena = dev->ptp_en; + info->rx_offload_capa = dev->rx_offload_capa; + info->tx_offload_capa = dev->tx_offload_capa; + info->rx_offloads = dev->rx_offloads; + info->tx_offloads = dev->tx_offloads; + info->rx_offload_flags = dev->rx_offload_flags; + info->tx_offload_flags = dev->tx_offload_flags; + info->ethdev_rss_hf = dev->ethdev_rss_hf; + } + + if (eth_dev->data) { + info->rx_queues = eth_dev->data->nb_rx_queues; + info->tx_queues = eth_dev->data->nb_tx_queues; + info->port_id = eth_dev->data->port_id; + } + + j++; + } + } + + /* Validating available count */ + if (n_ports != j) { + rc = -EINVAL; + plt_err("Invalid available port count"); + goto free; + } + + struct rte_tel_data *i_data = rte_tel_data_alloc(); + rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL); + for (i = 0; i < rte_eth_dev_count_avail(); i++) { + for (j = 0; j < (int)ETH_INFO_SZ; j++) + rte_tel_data_add_array_u64(i_data, eth_info[i].val[j]); + } + rte_tel_data_add_dict_container(d, "info", i_data, 0); + +free: + free(eth_info); +exit: + return rc; +} + +RTE_INIT(cnxk_ethdev_init_telemetry) +{ + rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info, + "Returns ethdev device information"); +} diff --git a/drivers/net/cnxk/meson.build b/drivers/net/cnxk/meson.build index d1d4b4e15e..5b3b8422fb 100644 --- a/drivers/net/cnxk/meson.build +++ b/drivers/net/cnxk/meson.build @@ -13,6 +13,7 @@ sources = files( 'cnxk_ethdev_devargs.c', 'cnxk_ethdev_ops.c', 'cnxk_ethdev_sec.c', + 'cnxk_ethdev_telemetry.c', 'cnxk_link.c', 'cnxk_lookup.c', 'cnxk_ptp.c', -- 2.25.1