1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell International Ltd.
5 #include <rte_telemetry.h>
7 #include "cnxk_ethdev.h"
9 /* Macro to count no of words in eth_info_s size */
11 (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) / \
13 #define MACADDR_LEN 18
16 ethdev_tel_handle_info(const char *cmd __rte_unused,
17 const char *params __rte_unused, struct rte_tel_data *d)
19 struct rte_eth_dev *eth_dev;
20 struct rte_tel_data *i_data;
21 struct cnxk_eth_dev *dev;
24 /** PF/VF information */
26 uint8_t max_mac_entries;
28 uint8_t dmac_filter_count;
29 uint8_t ptype_disable;
32 /* Platform specific offload flags */
33 uint16_t rx_offload_flags;
34 uint16_t tx_offload_flags;
36 uint64_t val[ETH_INFO_SZ];
38 struct eth_info_s *info;
39 unsigned int i, j = 0;
42 n_ports = rte_eth_dev_count_avail();
44 plt_err("No active ethernet ports found.");
48 rte_tel_data_start_dict(d);
49 rte_tel_data_add_dict_int(d, "n_ports", n_ports);
51 i_data = rte_tel_data_alloc();
52 rte_tel_data_start_array(i_data, RTE_TEL_U64_VAL);
54 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
55 /* Skip if port is unused */
56 if (!rte_eth_dev_is_valid_port(i))
59 eth_dev = &rte_eth_devices[i];
61 memset(ð_info, 0, sizeof(eth_info));
62 info = ð_info.info;
63 dev = cnxk_eth_pmd_priv(eth_dev);
65 info->pf_func = roc_nix_get_pf_func(&dev->nix);
66 info->max_mac_entries = dev->max_mac_entries;
67 info->dmac_filter_ena = dev->dmac_filter_enable;
68 info->dmac_filter_count =
69 dev->dmac_filter_count;
70 info->ptype_disable = dev->ptype_disable;
71 info->scalar_ena = dev->scalar_ena;
72 info->ptp_ena = dev->ptp_en;
73 info->rx_offload_flags = dev->rx_offload_flags;
74 info->tx_offload_flags = dev->tx_offload_flags;
77 for (j = 0; j < ETH_INFO_SZ; j++)
78 rte_tel_data_add_array_u64(i_data,
85 rte_tel_data_add_dict_container(d, "info", i_data, 0);
89 RTE_INIT(cnxk_ethdev_init_telemetry)
91 rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
92 "Returns ethdev device information");