LCOV - code coverage report
Current view: top level - drivers/net/cnxk - cnxk_ethdev_telemetry.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 3 32 9.4 %
Date: 2024-12-01 18:57:19 Functions: 1 2 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell International Ltd.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <rte_telemetry.h>
       6                 :            : 
       7                 :            : #include "cnxk_ethdev.h"
       8                 :            : 
       9                 :            : /* Macro to count no of words in eth_info_s size */
      10                 :            : #define ETH_INFO_SZ                                                            \
      11                 :            :         (RTE_ALIGN_CEIL(sizeof(struct eth_info_s), sizeof(uint64_t)) /         \
      12                 :            :          sizeof(uint64_t))
      13                 :            : #define MACADDR_LEN 18
      14                 :            : 
      15                 :            : static int
      16                 :          0 : ethdev_tel_handle_info(const char *cmd __rte_unused,
      17                 :            :                        const char *params __rte_unused, struct rte_tel_data *d)
      18                 :            : {
      19                 :            :         struct rte_eth_dev *eth_dev;
      20                 :            :         struct rte_tel_data *i_data;
      21                 :            :         struct cnxk_eth_dev *dev;
      22                 :            :         union eth_info_u {
      23                 :            :                 struct eth_info_s {
      24                 :            :                         /** PF/VF information */
      25                 :            :                         uint16_t pf_func;
      26                 :            :                         uint16_t inl_dev_pf_func;
      27                 :            :                         uint8_t max_mac_entries;
      28                 :            :                         bool dmac_filter_ena;
      29                 :            :                         uint8_t dmac_filter_count;
      30                 :            :                         uint8_t ptype_disable;
      31                 :            :                         bool scalar_ena;
      32                 :            :                         bool ptp_ena;
      33                 :            :                         /* Platform specific offload flags */
      34                 :            :                         uint16_t rx_offload_flags;
      35                 :            :                         uint16_t tx_offload_flags;
      36                 :            :                 } info;
      37                 :            :                 uint64_t val[ETH_INFO_SZ];
      38                 :            :         } eth_info;
      39                 :            :         struct eth_info_s *info;
      40                 :            :         unsigned int i, j = 0;
      41                 :            :         int n_ports;
      42                 :            : 
      43                 :          0 :         n_ports = rte_eth_dev_count_avail();
      44         [ #  # ]:          0 :         if (!n_ports) {
      45                 :          0 :                 plt_err("No active ethernet ports found.");
      46                 :          0 :                 return -1;
      47                 :            :         }
      48                 :            : 
      49                 :          0 :         rte_tel_data_start_dict(d);
      50                 :          0 :         rte_tel_data_add_dict_int(d, "n_ports", n_ports);
      51                 :            : 
      52                 :          0 :         i_data = rte_tel_data_alloc();
      53         [ #  # ]:          0 :         if (i_data == NULL)
      54                 :            :                 return -ENOMEM;
      55                 :          0 :         rte_tel_data_start_array(i_data, RTE_TEL_UINT_VAL);
      56                 :            : 
      57         [ #  # ]:          0 :         for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
      58                 :            :                 /* Skip if port is unused */
      59         [ #  # ]:          0 :                 if (!rte_eth_dev_is_valid_port(i))
      60                 :          0 :                         continue;
      61                 :            : 
      62                 :            :                 eth_dev = &rte_eth_devices[i];
      63                 :            :                 if (eth_dev) {
      64                 :            :                         memset(&eth_info, 0, sizeof(eth_info));
      65                 :            :                         info = &eth_info.info;
      66                 :            :                         dev = cnxk_eth_pmd_priv(eth_dev);
      67         [ #  # ]:          0 :                         if (dev) {
      68                 :          0 :                                 info->inl_dev_pf_func = roc_idev_nix_inl_dev_pffunc_get();
      69                 :          0 :                                 info->pf_func = roc_nix_get_pf_func(&dev->nix);
      70                 :          0 :                                 info->max_mac_entries = dev->max_mac_entries;
      71                 :          0 :                                 info->dmac_filter_ena = dev->dmac_filter_enable;
      72                 :          0 :                                 info->dmac_filter_count =
      73                 :          0 :                                         dev->dmac_filter_count;
      74                 :          0 :                                 info->ptype_disable = dev->ptype_disable;
      75                 :          0 :                                 info->scalar_ena = dev->scalar_ena;
      76                 :          0 :                                 info->ptp_ena = dev->ptp_en;
      77                 :          0 :                                 info->rx_offload_flags = dev->rx_offload_flags;
      78                 :          0 :                                 info->tx_offload_flags = dev->tx_offload_flags;
      79                 :            :                         }
      80                 :            : 
      81         [ #  # ]:          0 :                         for (j = 0; j < ETH_INFO_SZ; j++)
      82                 :          0 :                                 rte_tel_data_add_array_uint(i_data,
      83                 :            :                                                             eth_info.val[j]);
      84                 :            : 
      85                 :            :                         j++;
      86                 :            :                 }
      87                 :            :         }
      88                 :            : 
      89                 :          0 :         rte_tel_data_add_dict_container(d, "info", i_data, 0);
      90                 :          0 :         return 0;
      91                 :            : }
      92                 :            : 
      93                 :        251 : RTE_INIT(cnxk_ethdev_init_telemetry)
      94                 :            : {
      95                 :        251 :         rte_telemetry_register_cmd("/cnxk/ethdev/info", ethdev_tel_handle_info,
      96                 :            :                                    "Returns ethdev device information");
      97                 :        251 : }

Generated by: LCOV version 1.14