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 C7B2CA0547; Wed, 29 Sep 2021 06:25:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4DE204068F; Wed, 29 Sep 2021 06:25:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 4C68C4068E for ; Wed, 29 Sep 2021 06:25:38 +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 18T2SrOd017877; Tue, 28 Sep 2021 21:25:37 -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=FqDF6RipGcgmVf1LeT5TjwucZZkbnhyl6rL4oja8xuE=; b=FZxWe/45O0TV1CBZm4Yakgk1nCU+HYIqiEhpB5e6k+EISIH/8+NpVP6YdwHiz0/tjEfi AOJ4eIihI3aUc8LDpkX9SpC6NMuG/fBzms+Zx24Trtgy01XPoV4aMcebZITvu++zFDwC Z/pHML2f9Ep5/W2SVA20957PB79VbzxMGdA4pzqDtaq5jtBJqNzNWPG0dvDneKRW1HNz cbkn5fktNNsrNAzGUktI1jZWENOtyn1qFK3BZYISHXTQTbjBzgSAyRWfZKBbfOwChmAV kkEHeaM/ovlcQmhDcDxPK3+839fw3vJXSpfceJpfCol2MerKcZQfeK6K1RBhCbuQ4we2 jA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 3bcfd48bjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 28 Sep 2021 21:25:37 -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.18; Tue, 28 Sep 2021 21:25:35 -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; Tue, 28 Sep 2021 21:25:35 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 1A96A3F706D; Tue, 28 Sep 2021 21:25:32 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , , Gowrishankar Muthukrishnan Date: Wed, 29 Sep 2021 09:55:29 +0530 Message-ID: <64d6649a4374f0b5c48d0f27d0d540064afdbe38.1632888548.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <2eaeef2ece0ff3a5a3fc9323f15a47be617a73a4.1632219073.git.gmuthukrishn@marvell.com> References: <2eaeef2ece0ff3a5a3fc9323f15a47be617a73a4.1632219073.git.gmuthukrishn@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: N3NHZJtSd240OrbEAL71G54UcOJxzUAc X-Proofpoint-ORIG-GUID: N3NHZJtSd240OrbEAL71G54UcOJxzUAc 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-29_01,2021-09-28_01,2020-04-07_01 Subject: [dpdk-dev] [v1] ethdev: add telemetry endpoint for device info 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 /ethdev/info for device info. Signed-off-by: Gowrishankar Muthukrishnan Change-Id: I3e6ee2bd1a80675473adf0bd884b194f98e28536 --- lib/ethdev/rte_ethdev.c | 92 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index daf5ca9242..9b7bfa5f63 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6242,6 +6242,96 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused, return 0; } +static int +eth_dev_handle_port_info(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_tel_data *rxq_state, *txq_state; + char mac_addr[RTE_ETHER_ADDR_LEN]; + struct rte_eth_dev *eth_dev; + char *end_param; + int port_id, i; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -1; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring"); + + if (!rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + eth_dev = &rte_eth_devices[port_id]; + if (!eth_dev) + return -EINVAL; + + rxq_state = rte_tel_data_alloc(); + if (!rxq_state) + return -ENOMEM; + + txq_state = rte_tel_data_alloc(); + if (!txq_state) + return -ENOMEM; + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_string(d, "name", eth_dev->data->name); + rte_tel_data_add_dict_int(d, "state", eth_dev->state); + rte_tel_data_add_dict_int(d, "nb_rx_queues", + eth_dev->data->nb_rx_queues); + rte_tel_data_add_dict_int(d, "nb_tx_queues", + eth_dev->data->nb_tx_queues); + rte_tel_data_add_dict_int(d, "port_id", eth_dev->data->port_id); + rte_tel_data_add_dict_int(d, "mtu", eth_dev->data->mtu); + rte_tel_data_add_dict_int(d, "rx_mbuf_size_min", + eth_dev->data->min_rx_buf_size); + rte_tel_data_add_dict_int(d, "rx_mbuf_alloc_fail", + eth_dev->data->rx_mbuf_alloc_failed); + snprintf(mac_addr, RTE_ETHER_ADDR_LEN, "%02x:%02x:%02x:%02x:%02x:%02x", + eth_dev->data->mac_addrs->addr_bytes[0], + eth_dev->data->mac_addrs->addr_bytes[1], + eth_dev->data->mac_addrs->addr_bytes[2], + eth_dev->data->mac_addrs->addr_bytes[3], + eth_dev->data->mac_addrs->addr_bytes[4], + eth_dev->data->mac_addrs->addr_bytes[5]); + rte_tel_data_add_dict_string(d, "mac_addr", mac_addr); + rte_tel_data_add_dict_int(d, "promiscuous", + eth_dev->data->promiscuous); + rte_tel_data_add_dict_int(d, "scattered_rx", + eth_dev->data->scattered_rx); + rte_tel_data_add_dict_int(d, "all_multicast", + eth_dev->data->all_multicast); + rte_tel_data_add_dict_int(d, "dev_started", eth_dev->data->dev_started); + rte_tel_data_add_dict_int(d, "lro", eth_dev->data->lro); + rte_tel_data_add_dict_int(d, "dev_configured", + eth_dev->data->dev_configured); + + rte_tel_data_start_array(rxq_state, RTE_TEL_INT_VAL); + for (i = 0; i < eth_dev->data->nb_rx_queues; i++) + rte_tel_data_add_array_int(rxq_state, + eth_dev->data->rx_queue_state[i]); + + rte_tel_data_start_array(txq_state, RTE_TEL_INT_VAL); + for (i = 0; i < eth_dev->data->nb_tx_queues; i++) + rte_tel_data_add_array_int(txq_state, + eth_dev->data->tx_queue_state[i]); + + rte_tel_data_add_dict_container(d, "rxq_state", rxq_state, 0); + rte_tel_data_add_dict_container(d, "txq_state", txq_state, 0); + rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node); + rte_tel_data_add_dict_int(d, "dev_flags", eth_dev->data->dev_flags); + rte_tel_data_add_dict_int(d, "rx_offloads", + eth_dev->data->dev_conf.rxmode.offloads); + rte_tel_data_add_dict_int(d, "tx_offloads", + eth_dev->data->dev_conf.txmode.offloads); + rte_tel_data_add_dict_int(d, "ethdev_rss_hf", + eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf); + + return 0; +} + int rte_eth_hairpin_queue_peer_update(uint16_t peer_port, uint16_t peer_queue, struct rte_hairpin_peer_info *cur_info, @@ -6323,4 +6413,6 @@ RTE_INIT(ethdev_init_telemetry) rte_telemetry_register_cmd("/ethdev/link_status", eth_dev_handle_port_link_status, "Returns the link status for a port. Parameters: int port_id"); + rte_telemetry_register_cmd("/ethdev/info", eth_dev_handle_port_info, + "Returns the device info for a port. Parameters: int port_id"); } -- 2.25.1