LCOV - code coverage report
Current view: top level - drivers/net/hns3 - hns3_dump.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 338 0.0 %
Date: 2024-04-01 19:00:53 Functions: 0 30 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 244 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2022 HiSilicon Limited
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <rte_malloc.h>
       6                 :            : 
       7                 :            : #include "hns3_common.h"
       8                 :            : #include "hns3_logs.h"
       9                 :            : #include "hns3_regs.h"
      10                 :            : #include "hns3_rxtx.h"
      11                 :            : #include "hns3_dump.h"
      12                 :            : 
      13                 :            : #define HNS3_BD_DW_NUM 8
      14                 :            : #define HNS3_BD_ADDRESS_LAST_DW 2
      15                 :            : 
      16                 :            : static const char *
      17                 :          0 : hns3_get_adapter_state_name(enum hns3_adapter_state state)
      18                 :            : {
      19                 :            :         const struct {
      20                 :            :                 enum hns3_adapter_state state;
      21                 :            :                 const char *name;
      22                 :          0 :         } adapter_state_name[] = {
      23                 :            :                 {HNS3_NIC_UNINITIALIZED, "UNINITIALIZED"},
      24                 :            :                 {HNS3_NIC_INITIALIZED, "INITIALIZED"},
      25                 :            :                 {HNS3_NIC_CONFIGURING, "CONFIGURING"},
      26                 :            :                 {HNS3_NIC_CONFIGURED, "CONFIGURED"},
      27                 :            :                 {HNS3_NIC_STARTING, "STARTING"},
      28                 :            :                 {HNS3_NIC_STARTED, "STARTED"},
      29                 :            :                 {HNS3_NIC_STOPPING, "STOPPING"},
      30                 :            :                 {HNS3_NIC_CLOSING, "CLOSING"},
      31                 :            :                 {HNS3_NIC_CLOSED, "CLOSED"},
      32                 :            :                 {HNS3_NIC_REMOVED, "REMOVED"},
      33                 :            :                 {HNS3_NIC_NSTATES, "NSTATES"},
      34                 :            :         };
      35                 :            :         uint32_t i;
      36                 :            : 
      37         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(adapter_state_name); i++)
      38         [ #  # ]:          0 :                 if (state == adapter_state_name[i].state)
      39                 :          0 :                         return adapter_state_name[i].name;
      40                 :            : 
      41                 :            :         return "Unknown";
      42                 :            : }
      43                 :            : 
      44                 :            : static const char *
      45                 :            : hns3_get_io_func_hint_name(uint32_t hint)
      46                 :            : {
      47                 :          0 :         switch (hint) {
      48                 :            :         case HNS3_IO_FUNC_HINT_NONE:
      49                 :            :                 return "none";
      50                 :          0 :         case HNS3_IO_FUNC_HINT_VEC:
      51                 :          0 :                 return "vec";
      52                 :          0 :         case HNS3_IO_FUNC_HINT_SVE:
      53                 :          0 :                 return "sve";
      54                 :          0 :         case HNS3_IO_FUNC_HINT_SIMPLE:
      55                 :          0 :                 return "simple";
      56                 :          0 :         case HNS3_IO_FUNC_HINT_COMMON:
      57                 :          0 :                 return "common";
      58                 :          0 :         default:
      59                 :          0 :                 return "unknown";
      60                 :            :         }
      61                 :            : }
      62                 :            : 
      63                 :            : static void
      64                 :          0 : hns3_get_dev_mac_info(FILE *file, struct hns3_adapter *hns)
      65                 :            : {
      66                 :            :         struct hns3_hw *hw = &hns->hw;
      67                 :            :         struct hns3_pf *pf = &hns->pf;
      68                 :            : 
      69                 :            :         fprintf(file, "  - MAC Info:\n");
      70                 :          0 :         fprintf(file,
      71                 :            :                 "\t  -- media_type=%s\n"
      72                 :            :                 "\t  -- query_type=%u\n"
      73                 :            :                 "\t  -- supported_speed=0x%x\n"
      74                 :            :                 "\t  -- advertising=0x%x\n"
      75                 :            :                 "\t  -- lp_advertising=0x%x\n"
      76                 :            :                 "\t  -- support_autoneg=%s\n"
      77                 :            :                 "\t  -- support_fc_autoneg=%s\n",
      78                 :          0 :                 hns3_get_media_type_name(hw->mac.media_type),
      79                 :          0 :                 hw->mac.query_type,
      80                 :            :                 hw->mac.supported_speed,
      81                 :            :                 hw->mac.advertising,
      82                 :            :                 hw->mac.lp_advertising,
      83         [ #  # ]:          0 :                 hw->mac.support_autoneg != 0 ? "Yes" : "No",
      84         [ #  # ]:          0 :                 pf->support_fc_autoneg ? "Yes" : "No");
      85                 :          0 : }
      86                 :            : 
      87                 :            : static void
      88                 :          0 : hns3_get_dev_feature_capability(FILE *file, struct hns3_hw *hw)
      89                 :            : {
      90                 :            :         const struct {
      91                 :            :                 enum hns3_dev_cap cap;
      92                 :            :                 const char *name;
      93                 :          0 :         } caps_name[] = {
      94                 :            :                 {HNS3_DEV_SUPPORT_DCB_B, "DCB"},
      95                 :            :                 {HNS3_DEV_SUPPORT_COPPER_B, "COPPER"},
      96                 :            :                 {HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, "FD QUEUE REGION"},
      97                 :            :                 {HNS3_DEV_SUPPORT_PTP_B, "PTP"},
      98                 :            :                 {HNS3_DEV_SUPPORT_TX_PUSH_B, "TX PUSH"},
      99                 :            :                 {HNS3_DEV_SUPPORT_INDEP_TXRX_B, "INDEP TXRX"},
     100                 :            :                 {HNS3_DEV_SUPPORT_STASH_B, "STASH"},
     101                 :            :                 {HNS3_DEV_SUPPORT_SIMPLE_BD_B, "SIMPLE BD"},
     102                 :            :                 {HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, "RXD Advanced Layout"},
     103                 :            :                 {HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, "OUTER UDP CKSUM"},
     104                 :            :                 {HNS3_DEV_SUPPORT_RAS_IMP_B, "RAS IMP"},
     105                 :            :                 {HNS3_DEV_SUPPORT_TM_B, "TM"},
     106                 :            :                 {HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, "VF VLAN FILTER MOD"},
     107                 :            :                 {HNS3_DEV_SUPPORT_FC_AUTO_B, "FC AUTO"},
     108                 :            :                 {HNS3_DEV_SUPPORT_GRO_B, "GRO"}
     109                 :            :         };
     110                 :            :         uint32_t i;
     111                 :            : 
     112                 :            :         fprintf(file, "  - Dev Capability:\n");
     113         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(caps_name); i++)
     114                 :          0 :                 fprintf(file, "\t  -- support %s: %s\n", caps_name[i].name,
     115         [ #  # ]:          0 :                         hns3_get_bit(hw->capability, caps_name[i].cap) ? "Yes" :
     116                 :            :                                                                          "No");
     117                 :          0 : }
     118                 :            : 
     119                 :            : static const char *
     120                 :          0 : hns3_get_fdir_tuple_name(uint32_t index)
     121                 :            : {
     122                 :          0 :         const char * const tuple_name[] = {
     123                 :            :                 "outer_dst_mac",
     124                 :            :                 "outer_src_mac",
     125                 :            :                 "outer_vlan_1st_tag",
     126                 :            :                 "outer_vlan_2nd_tag",
     127                 :            :                 "outer_eth_type",
     128                 :            :                 "outer_l2_rsv",
     129                 :            :                 "outer_ip_tos",
     130                 :            :                 "outer_ip_proto",
     131                 :            :                 "outer_src_ip",
     132                 :            :                 "outer_dst_ip",
     133                 :            :                 "outer_l3_rsv",
     134                 :            :                 "outer_src_port",
     135                 :            :                 "outer_dst_port",
     136                 :            :                 "outer_l4_rsv",
     137                 :            :                 "outer_tun_vni",
     138                 :            :                 "outer_tun_flow_id",
     139                 :            :                 "inner_dst_mac",
     140                 :            :                 "inner_src_mac",
     141                 :            :                 "inner_vlan_tag1",
     142                 :            :                 "inner_vlan_tag2",
     143                 :            :                 "inner_eth_type",
     144                 :            :                 "inner_l2_rsv",
     145                 :            :                 "inner_ip_tos",
     146                 :            :                 "inner_ip_proto",
     147                 :            :                 "inner_src_ip",
     148                 :            :                 "inner_dst_ip",
     149                 :            :                 "inner_l3_rsv",
     150                 :            :                 "inner_src_port",
     151                 :            :                 "inner_dst_port",
     152                 :            :                 "inner_sctp_tag",
     153                 :            :         };
     154         [ #  # ]:          0 :         if (index < RTE_DIM(tuple_name))
     155                 :          0 :                 return tuple_name[index];
     156                 :            :         else
     157                 :            :                 return "unknown";
     158                 :            : }
     159                 :            : 
     160                 :            : static void
     161                 :          0 : hns3_get_fdir_basic_info(FILE *file, struct hns3_pf *pf)
     162                 :            : {
     163                 :            : #define HNS3_PERLINE_TUPLE_NAME_LEN     4
     164                 :            :         struct hns3_fd_cfg *fdcfg = &pf->fdir.fd_cfg;
     165                 :            :         uint32_t i, count = 0;
     166                 :            : 
     167                 :            :         fprintf(file, "  - Fdir Info:\n");
     168                 :          0 :         fprintf(file,
     169                 :            :                 "\t  -- mode=%u max_key_len=%u rule_num:%u cnt_num:%u\n"
     170                 :            :                 "\t  -- key_sel=%u tuple_active=0x%x meta_data_active=0x%x\n"
     171                 :            :                 "\t  -- ipv6_word_en: in_s=%u in_d=%u out_s=%u out_d=%u\n"
     172                 :            :                 "\t  -- active_tuples:\n",
     173                 :          0 :                 fdcfg->fd_mode, fdcfg->max_key_length,
     174                 :            :                 fdcfg->rule_num[HNS3_FD_STAGE_1],
     175                 :          0 :                 fdcfg->cnt_num[HNS3_FD_STAGE_1],
     176                 :          0 :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].key_sel,
     177                 :            :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active,
     178                 :            :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].meta_data_active,
     179                 :          0 :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_sipv6_word_en,
     180                 :          0 :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].inner_dipv6_word_en,
     181                 :          0 :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_sipv6_word_en,
     182                 :          0 :                 fdcfg->key_cfg[HNS3_FD_STAGE_1].outer_dipv6_word_en);
     183                 :            : 
     184         [ #  # ]:          0 :         for (i = 0; i < MAX_TUPLE; i++) {
     185         [ #  # ]:          0 :                 if (!(fdcfg->key_cfg[HNS3_FD_STAGE_1].tuple_active & BIT(i)))
     186                 :          0 :                         continue;
     187         [ #  # ]:          0 :                 if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
     188                 :            :                         fprintf(file, "\t      ");
     189                 :          0 :                 fprintf(file, " %s", hns3_get_fdir_tuple_name(i));
     190                 :          0 :                 count++;
     191         [ #  # ]:          0 :                 if (count % HNS3_PERLINE_TUPLE_NAME_LEN == 0)
     192                 :            :                         fprintf(file, "\n");
     193                 :            :         }
     194         [ #  # ]:          0 :         if (count % HNS3_PERLINE_TUPLE_NAME_LEN)
     195                 :            :                 fprintf(file, "\n");
     196                 :          0 : }
     197                 :            : 
     198                 :            : static void
     199                 :          0 : hns3_get_device_basic_info(FILE *file, struct rte_eth_dev *dev)
     200                 :            : {
     201                 :          0 :         struct hns3_adapter *hns = dev->data->dev_private;
     202                 :            :         struct hns3_hw *hw = &hns->hw;
     203                 :            : 
     204   [ #  #  #  #  :          0 :         fprintf(file,
                   #  # ]
     205                 :            :                 "  - Device Base Info:\n"
     206                 :            :                 "\t  -- name: %s\n"
     207                 :            :                 "\t  -- adapter_state=%s\n"
     208                 :            :                 "\t  -- nb_rx_queues=%u nb_tx_queues=%u\n"
     209                 :            :                 "\t  -- total_tqps_num=%u tqps_num=%u intr_tqps_num=%u\n"
     210                 :            :                 "\t  -- rss_size_max=%u alloc_rss_size=%u tx_qnum_per_tc=%u\n"
     211                 :            :                 "\t  -- min_tx_pkt_len=%u intr_mapping_mode=%u vlan_mode=%u\n"
     212                 :            :                 "\t  -- tso_mode=%u max_non_tso_bd_num=%u\n"
     213                 :            :                 "\t  -- max_tm_rate=%u Mbps\n"
     214                 :            :                 "\t  -- set link down: %s\n"
     215                 :            :                 "\t  -- rx_func_hint=%s tx_func_hint=%s\n"
     216                 :            :                 "\t  -- dev_flags: lsc=%d\n"
     217                 :            :                 "\t  -- intr_conf: lsc=%u rxq=%u\n",
     218                 :          0 :                 dev->data->name,
     219                 :            :                 hns3_get_adapter_state_name(hw->adapter_state),
     220                 :          0 :                 dev->data->nb_rx_queues, dev->data->nb_tx_queues,
     221                 :          0 :                 hw->total_tqps_num, hw->tqps_num, hw->intr_tqps_num,
     222                 :          0 :                 hw->rss_size_max, hw->alloc_rss_size, hw->tx_qnum_per_tc,
     223                 :          0 :                 hw->min_tx_pkt_len, hw->intr.mapping_mode, hw->vlan_mode,
     224                 :          0 :                 hw->tso_mode, hw->max_non_tso_bd_num,
     225                 :            :                 hw->max_tm_rate,
     226         [ #  # ]:          0 :                 hw->set_link_down ? "Yes" : "No",
     227                 :            :                 hns3_get_io_func_hint_name(hns->rx_func_hint),
     228                 :            :                 hns3_get_io_func_hint_name(hns->tx_func_hint),
     229                 :          0 :                 !!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC),
     230                 :          0 :                 dev->data->dev_conf.intr_conf.lsc,
     231   [ #  #  #  #  :          0 :                 dev->data->dev_conf.intr_conf.rxq);
                   #  # ]
     232                 :          0 : }
     233                 :            : 
     234                 :            : static struct hns3_rx_queue *
     235                 :          0 : hns3_get_rx_queue(struct rte_eth_dev *dev)
     236                 :            : {
     237                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     238                 :            :         struct hns3_rx_queue *rxq;
     239                 :            :         uint32_t queue_id;
     240                 :            :         void **rx_queues;
     241                 :            : 
     242         [ #  # ]:          0 :         for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
     243                 :          0 :                 rx_queues = dev->data->rx_queues;
     244   [ #  #  #  # ]:          0 :                 if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
     245                 :          0 :                         hns3_err(hw, "detect rx_queues is NULL!\n");
     246                 :          0 :                         return NULL;
     247                 :            :                 }
     248                 :            : 
     249                 :            :                 rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
     250         [ #  # ]:          0 :                 if (rxq->rx_deferred_start)
     251                 :            :                         continue;
     252                 :            : 
     253                 :            :                 return rx_queues[queue_id];
     254                 :            :         }
     255                 :            : 
     256                 :            :         return NULL;
     257                 :            : }
     258                 :            : 
     259                 :            : static struct hns3_tx_queue *
     260                 :          0 : hns3_get_tx_queue(struct rte_eth_dev *dev)
     261                 :            : {
     262                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     263                 :            :         struct hns3_tx_queue *txq;
     264                 :            :         uint32_t queue_id;
     265                 :            :         void **tx_queues;
     266                 :            : 
     267         [ #  # ]:          0 :         for (queue_id = 0; queue_id < dev->data->nb_tx_queues; queue_id++) {
     268                 :          0 :                 tx_queues = dev->data->tx_queues;
     269   [ #  #  #  # ]:          0 :                 if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
     270                 :          0 :                         hns3_err(hw, "detect tx_queues is NULL!\n");
     271                 :          0 :                         return NULL;
     272                 :            :                 }
     273                 :            : 
     274                 :            :                 txq = (struct hns3_tx_queue *)tx_queues[queue_id];
     275         [ #  # ]:          0 :                 if (txq->tx_deferred_start)
     276                 :            :                         continue;
     277                 :            : 
     278                 :            :                 return tx_queues[queue_id];
     279                 :            :         }
     280                 :            : 
     281                 :            :         return NULL;
     282                 :            : }
     283                 :            : 
     284                 :            : static void
     285                 :          0 : hns3_get_rxtx_fake_queue_info(FILE *file, struct rte_eth_dev *dev)
     286                 :            : {
     287                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     288                 :            :         struct hns3_rx_queue *rxq;
     289                 :            :         struct hns3_tx_queue *txq;
     290                 :            :         uint32_t queue_id = 0;
     291                 :            :         void **rx_queues;
     292                 :            :         void **tx_queues;
     293                 :            : 
     294         [ #  # ]:          0 :         if (hns3_dev_get_support(hw, INDEP_TXRX))
     295                 :            :                 return;
     296                 :            : 
     297         [ #  # ]:          0 :         if (dev->data->nb_rx_queues < dev->data->nb_tx_queues) {
     298                 :          0 :                 rx_queues = hw->fkq_data.rx_queues;
     299   [ #  #  #  # ]:          0 :                 if (rx_queues == NULL || rx_queues[queue_id] == NULL) {
     300                 :          0 :                         hns3_err(hw, "detect rx_queues is NULL!\n");
     301                 :          0 :                         return;
     302                 :            :                 }
     303                 :            :                 rxq = (struct hns3_rx_queue *)rx_queues[queue_id];
     304                 :            : 
     305                 :          0 :                 fprintf(file,
     306                 :            :                         "\t  -- first fake_queue info:\n"
     307                 :            :                         "\t       Rx: port=%u nb_desc=%u free_thresh=%u\n",
     308                 :          0 :                         rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh);
     309         [ #  # ]:          0 :         } else if (dev->data->nb_rx_queues > dev->data->nb_tx_queues) {
     310                 :          0 :                 tx_queues = hw->fkq_data.tx_queues;
     311                 :            :                 queue_id = 0;
     312                 :            : 
     313   [ #  #  #  # ]:          0 :                 if (tx_queues == NULL || tx_queues[queue_id] == NULL) {
     314                 :          0 :                         hns3_err(hw, "detect tx_queues is NULL!\n");
     315                 :          0 :                         return;
     316                 :            :                 }
     317                 :            :                 txq = (struct hns3_tx_queue *)tx_queues[queue_id];
     318                 :            : 
     319                 :          0 :                 fprintf(file,
     320                 :            :                         "\t  -- first fake_queue info:\n"
     321                 :            :                         "\t          Tx: port=%u nb_desc=%u\n",
     322                 :          0 :                         txq->port_id, txq->nb_tx_desc);
     323                 :            :         }
     324                 :            : }
     325                 :            : 
     326                 :            : static void
     327                 :          0 : hns3_get_queue_enable_state(struct hns3_hw *hw, uint32_t *queue_state,
     328                 :            :                             uint32_t nb_queues, bool is_rxq)
     329                 :            : {
     330                 :            : #define HNS3_QUEUE_NUM_PER_STATS (sizeof(*queue_state) * HNS3_UINT8_BIT)
     331                 :            :         uint32_t queue_en_reg;
     332                 :            :         uint32_t reg_offset;
     333                 :            :         uint32_t state;
     334                 :            :         uint32_t i;
     335                 :            : 
     336         [ #  # ]:          0 :         queue_en_reg = is_rxq ? HNS3_RING_RX_EN_REG : HNS3_RING_TX_EN_REG;
     337         [ #  # ]:          0 :         for (i = 0; i < nb_queues; i++) {
     338                 :          0 :                 reg_offset = hns3_get_tqp_reg_offset(i);
     339                 :          0 :                 state = hns3_read_dev(hw, reg_offset + HNS3_RING_EN_REG);
     340         [ #  # ]:          0 :                 if (hns3_dev_get_support(hw, INDEP_TXRX))
     341   [ #  #  #  # ]:          0 :                         state = state && hns3_read_dev(hw, reg_offset +
     342                 :            :                                                        queue_en_reg);
     343                 :          0 :                 hns3_set_bit(queue_state[i / HNS3_QUEUE_NUM_PER_STATS],
     344                 :            :                                 i % HNS3_QUEUE_NUM_PER_STATS, state);
     345                 :            :         }
     346                 :          0 : }
     347                 :            : 
     348                 :            : static void
     349                 :          0 : hns3_print_queue_state_perline(FILE *file, const uint32_t *queue_state,
     350                 :            :                                uint32_t nb_queues, uint32_t line_num)
     351                 :            : {
     352                 :            : #define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
     353                 :          0 :         uint32_t id = line_num * HNS3_NUM_QUEUE_PER_LINE;
     354                 :            :         uint32_t i;
     355                 :            : 
     356         [ #  # ]:          0 :         for (i = 0; i < HNS3_NUM_QUEUE_PER_LINE; i++) {
     357                 :          0 :                 fprintf(file, "%1lx", hns3_get_bit(queue_state[line_num], i));
     358                 :            : 
     359         [ #  # ]:          0 :                 if (id % HNS3_UINT8_BIT == HNS3_UINT8_BIT - 1) {
     360         [ #  # ]:          0 :                         fprintf(file, "%s",
     361                 :            :                                 i == HNS3_NUM_QUEUE_PER_LINE - 1 ? "\n" : ":");
     362                 :            :                 }
     363                 :          0 :                 id++;
     364         [ #  # ]:          0 :                 if (id >= nb_queues) {
     365                 :            :                         fprintf(file, "\n");
     366                 :            :                         break;
     367                 :            :                 }
     368                 :            :         }
     369                 :          0 : }
     370                 :            : 
     371                 :            : static void
     372                 :          0 : hns3_display_queue_enable_state(FILE *file, const uint32_t *queue_state,
     373                 :            :                                 uint32_t nb_queues, bool is_rxq)
     374                 :            : {
     375                 :            : #define HNS3_NUM_QUEUE_PER_LINE (sizeof(uint32_t) * HNS3_UINT8_BIT)
     376                 :            :         uint32_t i;
     377                 :            : 
     378         [ #  # ]:          0 :         fprintf(file, "\t       %s queue id | enable state bitMap\n",
     379                 :            :                         is_rxq ? "Rx" : "Tx");
     380                 :            : 
     381         [ #  # ]:          0 :         for (i = 0; i < (nb_queues - 1) / HNS3_NUM_QUEUE_PER_LINE + 1; i++) {
     382                 :          0 :                 uint32_t line_end = (i + 1) * HNS3_NUM_QUEUE_PER_LINE - 1;
     383                 :          0 :                 uint32_t line_start = i * HNS3_NUM_QUEUE_PER_LINE;
     384                 :          0 :                 fprintf(file, "\t       %04u - %04u | ", line_start,
     385                 :            :                         nb_queues - 1 > line_end ? line_end : nb_queues - 1);
     386                 :            : 
     387                 :          0 :                 hns3_print_queue_state_perline(file, queue_state, nb_queues, i);
     388                 :            :         }
     389                 :          0 : }
     390                 :            : 
     391                 :            : static void
     392                 :          0 : hns3_get_rxtx_queue_enable_state(FILE *file, struct rte_eth_dev *dev)
     393                 :            : {
     394                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     395                 :            :         uint32_t *rx_queue_state;
     396                 :            :         uint32_t *tx_queue_state;
     397                 :            :         uint32_t nb_rx_queues;
     398                 :            :         uint32_t nb_tx_queues;
     399                 :            :         uint32_t bitmap_size;
     400                 :            : 
     401                 :          0 :         nb_rx_queues = dev->data->nb_rx_queues;
     402                 :          0 :         nb_tx_queues = dev->data->nb_tx_queues;
     403         [ #  # ]:          0 :         if (nb_rx_queues == 0) {
     404                 :            :                 fprintf(file, "\t  -- Rx queue number is 0\n");
     405                 :          0 :                 return;
     406                 :            :         }
     407         [ #  # ]:          0 :         if (nb_tx_queues == 0) {
     408                 :            :                 fprintf(file, "\t  -- Tx queue number is 0\n");
     409                 :          0 :                 return;
     410                 :            :         }
     411                 :            : 
     412                 :          0 :         bitmap_size = (hw->tqps_num * sizeof(uint32_t) + HNS3_UINT32_BIT) /
     413                 :            :                         HNS3_UINT32_BIT;
     414                 :          0 :         rx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
     415         [ #  # ]:          0 :         if (rx_queue_state == NULL) {
     416                 :          0 :                 hns3_err(hw, "Failed to allocate memory for rx queue state!");
     417                 :          0 :                 return;
     418                 :            :         }
     419                 :            : 
     420                 :          0 :         tx_queue_state = (uint32_t *)rte_zmalloc(NULL, bitmap_size, 0);
     421         [ #  # ]:          0 :         if (tx_queue_state == NULL) {
     422                 :          0 :                 hns3_err(hw, "Failed to allocate memory for tx queue state!");
     423                 :          0 :                 rte_free(rx_queue_state);
     424                 :          0 :                 return;
     425                 :            :         }
     426                 :            : 
     427                 :            :         fprintf(file, "\t  -- enable state:\n");
     428                 :          0 :         hns3_get_queue_enable_state(hw, rx_queue_state, nb_rx_queues, true);
     429                 :          0 :         hns3_display_queue_enable_state(file, rx_queue_state, nb_rx_queues,
     430                 :            :                                          true);
     431                 :            : 
     432                 :          0 :         hns3_get_queue_enable_state(hw, tx_queue_state, nb_tx_queues, false);
     433                 :          0 :         hns3_display_queue_enable_state(file, tx_queue_state, nb_tx_queues,
     434                 :            :                                          false);
     435                 :          0 :         rte_free(rx_queue_state);
     436                 :          0 :         rte_free(tx_queue_state);
     437                 :            : }
     438                 :            : 
     439                 :            : static void
     440                 :          0 : hns3_get_rxtx_queue_info(FILE *file, struct rte_eth_dev *dev)
     441                 :            : {
     442                 :            :         struct hns3_rx_queue *rxq;
     443                 :            :         struct hns3_tx_queue *txq;
     444                 :            : 
     445                 :          0 :         rxq = hns3_get_rx_queue(dev);
     446         [ #  # ]:          0 :         if (rxq == NULL)
     447                 :            :                 return;
     448                 :          0 :         txq = hns3_get_tx_queue(dev);
     449         [ #  # ]:          0 :         if (txq == NULL)
     450                 :            :                 return;
     451                 :            :         fprintf(file, "  - Rx/Tx Queue Info:\n");
     452                 :          0 :         fprintf(file,
     453                 :            :                 "\t  -- first queue rxtx info:\n"
     454                 :            :                 "\t       Rx: port=%u nb_desc=%u free_thresh=%u\n"
     455                 :            :                 "\t       Tx: port=%u nb_desc=%u\n"
     456                 :            :                 "\t  -- tx push: %s\n",
     457                 :          0 :                 rxq->port_id, rxq->nb_rx_desc, rxq->rx_free_thresh,
     458                 :          0 :                 txq->port_id, txq->nb_tx_desc,
     459         [ #  # ]:          0 :                 txq->tx_push_enable ? "enabled" : "disabled");
     460                 :            : 
     461                 :          0 :         hns3_get_rxtx_fake_queue_info(file, dev);
     462                 :          0 :         hns3_get_rxtx_queue_enable_state(file, dev);
     463                 :            : }
     464                 :            : 
     465                 :            : static int
     466                 :          0 : hns3_get_vlan_filter_cfg(FILE *file, struct hns3_hw *hw)
     467                 :            : {
     468                 :            : #define HNS3_FILTER_TYPE_VF             0
     469                 :            : #define HNS3_FILTER_TYPE_PORT           1
     470                 :            : #define HNS3_FILTER_FE_NIC_INGRESS_B    BIT(0)
     471                 :            : #define HNS3_FILTER_FE_NIC_EGRESS_B     BIT(1)
     472                 :            :         struct hns3_vlan_filter_ctrl_cmd *req;
     473                 :            :         struct hns3_cmd_desc desc;
     474                 :            :         uint8_t i;
     475                 :            :         int ret;
     476                 :            : 
     477                 :            :         static const uint32_t vlan_filter_type[] = {
     478                 :            :                 HNS3_FILTER_TYPE_PORT,
     479                 :            :                 HNS3_FILTER_TYPE_VF
     480                 :            :         };
     481                 :            : 
     482         [ #  # ]:          0 :         for (i = 0; i < RTE_DIM(vlan_filter_type); i++) {
     483                 :          0 :                 hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_FILTER_CTRL,
     484                 :            :                                                 true);
     485                 :            :                 req = (struct hns3_vlan_filter_ctrl_cmd *)desc.data;
     486                 :          0 :                 req->vlan_type = vlan_filter_type[i];
     487                 :          0 :                 req->vf_id = HNS3_PF_FUNC_ID;
     488                 :          0 :                 ret = hns3_cmd_send(hw, &desc, 1);
     489         [ #  # ]:          0 :                 if (ret != 0) {
     490                 :          0 :                         hns3_err(hw,
     491                 :            :                                 "NIC IMP exec ret=%d desc_num=%d optcode=0x%x!",
     492                 :            :                                 ret, 1, rte_le_to_cpu_16(desc.opcode));
     493                 :          0 :                         return ret;
     494                 :            :                 }
     495         [ #  # ]:          0 :                 fprintf(file,
     496                 :            :                         "\t  -- %s VLAN filter configuration\n"
     497                 :            :                         "\t       nic_ingress           :%s\n"
     498                 :            :                         "\t       nic_egress            :%s\n",
     499         [ #  # ]:          0 :                         req->vlan_type == HNS3_FILTER_TYPE_PORT ?
     500                 :            :                         "Port" : "VF",
     501                 :            :                         req->vlan_fe & HNS3_FILTER_FE_NIC_INGRESS_B ?
     502                 :            :                         "Enable" : "Disable",
     503         [ #  # ]:          0 :                         req->vlan_fe & HNS3_FILTER_FE_NIC_EGRESS_B ?
     504                 :            :                         "Enable" : "Disable");
     505                 :            :         }
     506                 :            : 
     507                 :            :         return 0;
     508                 :            : }
     509                 :            : 
     510                 :            : static int
     511                 :          0 : hns3_get_vlan_rx_offload_cfg(FILE *file, struct hns3_hw *hw)
     512                 :            : {
     513                 :            :         struct hns3_vport_vtag_rx_cfg_cmd *req;
     514                 :            :         struct hns3_cmd_desc desc;
     515                 :            :         uint16_t vport_id;
     516                 :            :         uint8_t bitmap;
     517                 :            :         int ret;
     518                 :            : 
     519                 :          0 :         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_RX_CFG, true);
     520                 :            :         req = (struct hns3_vport_vtag_rx_cfg_cmd *)desc.data;
     521                 :            :         vport_id = HNS3_PF_FUNC_ID;
     522                 :          0 :         req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
     523                 :            :         bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
     524                 :          0 :         req->vf_bitmap[req->vf_offset] = bitmap;
     525                 :            : 
     526                 :            :         /*
     527                 :            :          * current version VF is not supported when PF is driven by DPDK driver,
     528                 :            :          * just need to configure rx parameters for PF vport.
     529                 :            :          */
     530                 :          0 :         ret = hns3_cmd_send(hw, &desc, 1);
     531         [ #  # ]:          0 :         if (ret != 0) {
     532                 :          0 :                 hns3_err(hw,
     533                 :            :                          "NIC firmware exec ret=%d optcode=0x%x!", ret,
     534                 :            :                          rte_le_to_cpu_16(desc.opcode));
     535                 :          0 :                 return ret;
     536                 :            :         }
     537                 :            : 
     538   [ #  #  #  #  :          0 :         fprintf(file,
          #  #  #  #  #  
                      # ]
     539                 :            :                 "\t  -- RX VLAN configuration\n"
     540                 :            :                 "\t       vlan1_strip_en        :%s\n"
     541                 :            :                 "\t       vlan2_strip_en        :%s\n"
     542                 :            :                 "\t       vlan1_vlan_prionly    :%s\n"
     543                 :            :                 "\t       vlan2_vlan_prionly    :%s\n"
     544                 :            :                 "\t       vlan1_strip_discard   :%s\n"
     545                 :            :                 "\t       vlan2_strip_discard   :%s\n",
     546                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     547                 :            :                         HNS3_REM_TAG1_EN_B) ? "Enable" : "Disable",
     548                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     549                 :            :                         HNS3_REM_TAG2_EN_B) ? "Enable" : "Disable",
     550                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     551                 :            :                         HNS3_SHOW_TAG1_EN_B) ? "Enable" : "Disable",
     552                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     553                 :            :                         HNS3_SHOW_TAG2_EN_B) ? "Enable" : "Disable",
     554                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     555                 :            :                         HNS3_DISCARD_TAG1_EN_B) ? "Enable" : "Disable",
     556         [ #  # ]:          0 :                 hns3_get_bit(req->vport_vlan_cfg,
     557                 :            :                         HNS3_DISCARD_TAG2_EN_B) ? "Enable" : "Disable");
     558                 :            : 
     559                 :          0 :         return 0;
     560                 :            : }
     561                 :            : 
     562                 :            : static void
     563                 :          0 : hns3_parse_tx_vlan_cfg(FILE *file, struct hns3_vport_vtag_tx_cfg_cmd *req)
     564                 :            : {
     565                 :            : #define VLAN_VID_MASK 0x0fff
     566                 :            : #define VLAN_PRIO_SHIFT 13
     567                 :            : 
     568   [ #  #  #  #  :          0 :         fprintf(file,
             #  #  #  # ]
     569                 :            :                 "\t  -- TX VLAN configuration\n"
     570                 :            :                 "\t       accept_tag1           :%s\n"
     571                 :            :                 "\t       accept_untag1         :%s\n"
     572                 :            :                 "\t       insert_tag1_en        :%s\n"
     573                 :            :                 "\t       default_vlan_tag1 = %d, qos = %d\n"
     574                 :            :                 "\t       accept_tag2           :%s\n"
     575                 :            :                 "\t       accept_untag2         :%s\n"
     576                 :            :                 "\t       insert_tag2_en        :%s\n"
     577                 :            :                 "\t       default_vlan_tag2 = %d, qos = %d\n"
     578                 :            :                 "\t       vlan_shift_mode       :%s\n",
     579                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     580                 :            :                         HNS3_ACCEPT_TAG1_B) ? "Enable" : "Disable",
     581                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     582                 :            :                         HNS3_ACCEPT_UNTAG1_B) ? "Enable" : "Disable",
     583                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     584                 :            :                         HNS3_PORT_INS_TAG1_EN_B) ? "Enable" : "Disable",
     585                 :            :                 req->def_vlan_tag1 & VLAN_VID_MASK,
     586         [ #  # ]:          0 :                 req->def_vlan_tag1 >> VLAN_PRIO_SHIFT,
     587                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     588                 :            :                         HNS3_ACCEPT_TAG2_B) ? "Enable" : "Disable",
     589                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     590                 :            :                         HNS3_ACCEPT_UNTAG2_B) ? "Enable" : "Disable",
     591                 :            :                 hns3_get_bit(req->vport_vlan_cfg,
     592                 :            :                         HNS3_PORT_INS_TAG2_EN_B) ? "Enable" : "Disable",
     593                 :            :                 req->def_vlan_tag2 & VLAN_VID_MASK,
     594         [ #  # ]:          0 :                 req->def_vlan_tag2 >> VLAN_PRIO_SHIFT,
     595                 :          0 :                 hns3_get_bit(req->vport_vlan_cfg,
     596         [ #  # ]:          0 :                         HNS3_TAG_SHIFT_MODE_EN_B) ? "Enable" :
     597                 :            :                         "Disable");
     598                 :          0 : }
     599                 :            : 
     600                 :            : static int
     601                 :          0 : hns3_get_vlan_tx_offload_cfg(FILE *file, struct hns3_hw *hw)
     602                 :            : {
     603                 :            :         struct hns3_vport_vtag_tx_cfg_cmd *req;
     604                 :            :         struct hns3_cmd_desc desc;
     605                 :            :         uint16_t vport_id;
     606                 :            :         uint8_t bitmap;
     607                 :            :         int ret;
     608                 :            : 
     609                 :          0 :         hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_VLAN_PORT_TX_CFG, true);
     610                 :            :         req = (struct hns3_vport_vtag_tx_cfg_cmd *)desc.data;
     611                 :            :         vport_id = HNS3_PF_FUNC_ID;
     612                 :          0 :         req->vf_offset = vport_id / HNS3_VF_NUM_PER_CMD;
     613                 :            :         bitmap = 1 << (vport_id % HNS3_VF_NUM_PER_BYTE);
     614                 :          0 :         req->vf_bitmap[req->vf_offset] = bitmap;
     615                 :            :         /*
     616                 :            :          * current version VF is not supported when PF is driven by DPDK driver,
     617                 :            :          * just need to configure tx parameters for PF vport.
     618                 :            :          */
     619                 :          0 :         ret = hns3_cmd_send(hw, &desc, 1);
     620         [ #  # ]:          0 :         if (ret != 0) {
     621                 :          0 :                 hns3_err(hw,
     622                 :            :                         "NIC firmware exec ret=%d desc_num=%d optcode=0x%x!",
     623                 :            :                         ret, 1, rte_le_to_cpu_16(desc.opcode));
     624                 :          0 :                 return ret;
     625                 :            :         }
     626                 :            : 
     627                 :          0 :         hns3_parse_tx_vlan_cfg(file, req);
     628                 :            : 
     629                 :          0 :         return 0;
     630                 :            : }
     631                 :            : 
     632                 :            : static void
     633                 :            : hns3_get_port_pvid_info(FILE *file, struct hns3_hw *hw)
     634                 :            : {
     635                 :          0 :         fprintf(file, "  - pvid status: %s\n",
     636         [ #  # ]:          0 :                 hw->port_base_vlan_cfg.state ? "On" : "Off");
     637                 :            : }
     638                 :            : 
     639                 :            : static void
     640                 :          0 : hns3_get_vlan_config_info(FILE *file, struct hns3_hw *hw)
     641                 :            : {
     642                 :            :         int ret;
     643                 :            : 
     644                 :            :         fprintf(file, "  - VLAN Config Info:\n");
     645                 :          0 :         ret = hns3_get_vlan_filter_cfg(file, hw);
     646         [ #  # ]:          0 :         if (ret < 0)
     647                 :            :                 return;
     648                 :            : 
     649                 :          0 :         ret = hns3_get_vlan_rx_offload_cfg(file, hw);
     650         [ #  # ]:          0 :         if (ret < 0)
     651                 :            :                 return;
     652                 :            : 
     653                 :          0 :         ret = hns3_get_vlan_tx_offload_cfg(file, hw);
     654                 :            :         if (ret < 0)
     655                 :            :                 return;
     656                 :            : }
     657                 :            : 
     658                 :            : static void
     659                 :          0 : hns3_get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf)
     660                 :            : {
     661                 :            :         struct hns3_shaper_profile_list *shaper_profile_list =
     662                 :            :                 &conf->shaper_profile_list;
     663                 :            :         struct hns3_tm_shaper_profile *shaper_profile;
     664                 :            : 
     665         [ #  # ]:          0 :         if (conf->nb_shaper_profile == 0)
     666                 :            :                 return;
     667                 :            : 
     668                 :            :         fprintf(file, "\t  -- shaper_profile:\n");
     669         [ #  # ]:          0 :         TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
     670                 :          0 :                 fprintf(file,
     671                 :            :                         "\t       id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n",
     672                 :            :                         shaper_profile->shaper_profile_id,
     673                 :            :                         shaper_profile->reference_count,
     674                 :            :                         shaper_profile->profile.peak.rate);
     675                 :            :         }
     676                 :            : }
     677                 :            : 
     678                 :            : static void
     679                 :          0 : hns3_get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf)
     680                 :            : {
     681         [ #  # ]:          0 :         if (conf->root == NULL)
     682                 :            :                 return;
     683                 :            : 
     684                 :          0 :         fprintf(file,
     685                 :            :                 "\t  -- port_node:\n"
     686                 :            :                 "\t       node_id=%u reference_count=%u shaper_profile_id=%d\n",
     687                 :            :                 conf->root->id, conf->root->reference_count,
     688         [ #  # ]:          0 :                 conf->root->shaper_profile ?
     689                 :          0 :                 (int)conf->root->shaper_profile->shaper_profile_id : -1);
     690                 :            : }
     691                 :            : 
     692                 :            : static void
     693                 :          0 : hns3_get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf)
     694                 :            : {
     695                 :            :         struct hns3_tm_node_list *tc_list = &conf->tc_list;
     696                 :            :         struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM];
     697                 :            :         struct hns3_tm_node *tm_node;
     698                 :            :         uint32_t tidx;
     699                 :            : 
     700         [ #  # ]:          0 :         if (conf->nb_tc_node == 0)
     701                 :          0 :                 return;
     702                 :            : 
     703                 :            :         fprintf(file, "\t  -- tc_node:\n");
     704                 :            :         memset(tc_node, 0, sizeof(tc_node));
     705         [ #  # ]:          0 :         TAILQ_FOREACH(tm_node, tc_list, node) {
     706         [ #  # ]:          0 :                 tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id);
     707         [ #  # ]:          0 :                 if (tidx < HNS3_MAX_TC_NUM)
     708                 :          0 :                         tc_node[tidx] = tm_node;
     709                 :            :         }
     710                 :            : 
     711         [ #  # ]:          0 :         for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) {
     712                 :          0 :                 tm_node = tc_node[tidx];
     713         [ #  # ]:          0 :                 if (tm_node == NULL)
     714                 :          0 :                         continue;
     715                 :          0 :                 fprintf(file,
     716                 :            :                         "\t       id=%u TC%u reference_count=%u parent_id=%d "
     717                 :            :                         "shaper_profile_id=%d\n",
     718         [ #  # ]:          0 :                         tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id),
     719                 :            :                         tm_node->reference_count,
     720         [ #  # ]:          0 :                         tm_node->parent ? (int)tm_node->parent->id : -1,
     721         [ #  # ]:          0 :                         tm_node->shaper_profile ?
     722                 :          0 :                         (int)tm_node->shaper_profile->shaper_profile_id : -1);
     723                 :            :         }
     724                 :            : }
     725                 :            : 
     726                 :            : static void
     727                 :          0 : hns3_get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node,
     728                 :            :                                    uint32_t *queue_node_tc,
     729                 :            :                                    uint32_t nb_tx_queues)
     730                 :            : {
     731                 :            : #define HNS3_PERLINE_QUEUES     32
     732                 :            : #define HNS3_PERLINE_STRIDE     8
     733                 :            :         uint32_t i, j, line_num, start_queue_id, end_queue_id;
     734                 :            : 
     735                 :          0 :         line_num = (nb_tx_queues + HNS3_PERLINE_QUEUES - 1) /
     736                 :            :                 HNS3_PERLINE_QUEUES;
     737         [ #  # ]:          0 :         for (i = 0; i < line_num; i++) {
     738                 :          0 :                 start_queue_id = i * HNS3_PERLINE_QUEUES;
     739                 :          0 :                 end_queue_id = (i + 1) * HNS3_PERLINE_QUEUES - 1;
     740                 :          0 :                 if (end_queue_id > nb_tx_queues - 1)
     741                 :            :                         end_queue_id = nb_tx_queues - 1;
     742                 :            :                 fprintf(file, "\t       %04u - %04u | ", start_queue_id,
     743                 :            :                         end_queue_id);
     744         [ #  # ]:          0 :                 for (j = start_queue_id; j < nb_tx_queues; j++) {
     745         [ #  # ]:          0 :                         if (j >= end_queue_id + 1)
     746                 :            :                                 break;
     747   [ #  #  #  # ]:          0 :                         if (j > start_queue_id && j % HNS3_PERLINE_STRIDE == 0)
     748                 :            :                                 fprintf(file, ":");
     749                 :          0 :                         fprintf(file, "%u",
     750         [ #  # ]:          0 :                                 queue_node[j] ? queue_node_tc[j] :
     751                 :            :                                 HNS3_MAX_TC_NUM);
     752                 :            :                 }
     753                 :            :                 fprintf(file, "\n");
     754                 :            :         }
     755                 :          0 : }
     756                 :            : 
     757                 :            : static void
     758                 :          0 : hns3_get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf,
     759                 :            :                                  uint32_t nb_tx_queues)
     760                 :          0 : {
     761                 :            :         struct hns3_tm_node_list *queue_list = &conf->queue_list;
     762                 :          0 :         uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1;
     763                 :          0 :         struct hns3_tm_node *queue_node[nb_queue_node];
     764                 :          0 :         uint32_t queue_node_tc[nb_queue_node];
     765                 :            :         struct hns3_tm_node *tm_node;
     766                 :            : 
     767         [ #  # ]:          0 :         if (conf->nb_queue_node == 0)
     768                 :          0 :                 return;
     769                 :            : 
     770                 :            :         fprintf(file,
     771                 :            :                 "\t  -- queue_node:\n"
     772                 :            :                 "\t       tx queue id | mapped tc (8 mean node not exist)\n");
     773                 :            : 
     774                 :            :         memset(queue_node, 0, sizeof(queue_node));
     775                 :            :         memset(queue_node_tc, 0, sizeof(queue_node_tc));
     776                 :          0 :         nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node);
     777         [ #  # ]:          0 :         TAILQ_FOREACH(tm_node, queue_list, node) {
     778         [ #  # ]:          0 :                 if (tm_node->id >= nb_queue_node)
     779                 :          0 :                         continue;
     780                 :          0 :                 queue_node[tm_node->id] = tm_node;
     781                 :          0 :                 queue_node_tc[tm_node->id] = tm_node->parent ?
     782   [ #  #  #  # ]:          0 :                         hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0;
     783                 :          0 :                 nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1);
     784                 :            :         }
     785                 :            : 
     786                 :          0 :         hns3_get_tm_conf_queue_format_info(file, queue_node, queue_node_tc,
     787                 :            :                                       nb_tx_queues);
     788                 :            : }
     789                 :            : 
     790                 :            : static void
     791                 :          0 : hns3_get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
     792                 :            : {
     793                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     794                 :            :         struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private);
     795                 :          0 :         struct hns3_tm_conf *conf = &pf->tm_conf;
     796                 :            : 
     797         [ #  # ]:          0 :         if (!hns3_dev_get_support(hw, TM))
     798                 :            :                 return;
     799                 :            : 
     800                 :            :         fprintf(file, "  - TM config info:\n");
     801                 :          0 :         fprintf(file,
     802                 :            :                 "\t  -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n"
     803                 :            :                 "\t  -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n"
     804                 :            :                 "\t  -- committed=%u\n",
     805                 :            :                 conf->nb_leaf_nodes_max, conf->nb_nodes_max,
     806                 :            :                 conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node,
     807                 :          0 :                 conf->committed);
     808                 :            : 
     809                 :          0 :         hns3_get_tm_conf_shaper_info(file, conf);
     810                 :          0 :         hns3_get_tm_conf_port_node_info(file, conf);
     811                 :          0 :         hns3_get_tm_conf_tc_node_info(file, conf);
     812                 :          0 :         hns3_get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
     813                 :            : }
     814                 :            : 
     815                 :            : static void
     816                 :            : hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause,
     817                 :            :                            bool *tx_pause)
     818                 :            : {
     819                 :            :         switch (fc_mode) {
     820                 :            :         case HNS3_FC_NONE:
     821                 :            :                 *tx_pause = false;
     822                 :            :                 *rx_pause = false;
     823                 :            :                 break;
     824                 :            :         case HNS3_FC_RX_PAUSE:
     825                 :            :                 *rx_pause = true;
     826                 :            :                 *tx_pause = false;
     827                 :            :                 break;
     828                 :            :         case HNS3_FC_TX_PAUSE:
     829                 :            :                 *rx_pause = false;
     830                 :            :                 *tx_pause = true;
     831                 :            :                 break;
     832                 :            :         case HNS3_FC_FULL:
     833                 :            :                 *rx_pause = true;
     834                 :            :                 *tx_pause = true;
     835                 :            :                 break;
     836                 :            :         default:
     837                 :            :                 *rx_pause = false;
     838                 :            :                 *tx_pause = false;
     839                 :            :                 break;
     840                 :            :         }
     841                 :            : }
     842                 :            : 
     843                 :            : static bool
     844                 :            : hns3_is_link_fc_mode(struct hns3_adapter *hns)
     845                 :            : {
     846                 :            :         struct hns3_hw *hw = &hns->hw;
     847                 :            :         struct hns3_pf *pf = &hns->pf;
     848                 :            : 
     849                 :          0 :         if (hw->current_fc_status == HNS3_FC_STATUS_PFC)
     850                 :            :                 return false;
     851                 :            : 
     852   [ #  #  #  # ]:          0 :         if (hw->num_tc > 1 && !pf->support_multi_tc_pause)
     853                 :            :                 return false;
     854                 :            : 
     855                 :            :         return true;
     856                 :            : }
     857                 :            : 
     858                 :            : static void
     859                 :          0 : hns3_get_link_fc_info(FILE *file, struct rte_eth_dev *dev)
     860                 :            : {
     861         [ #  # ]:          0 :         struct hns3_adapter *hns = dev->data->dev_private;
     862                 :            :         struct hns3_hw *hw = &hns->hw;
     863                 :            :         struct rte_eth_fc_conf cur_fc_conf;
     864                 :            :         bool rx_pause1;
     865                 :            :         bool tx_pause1;
     866                 :            :         bool rx_pause2;
     867                 :            :         bool tx_pause2;
     868                 :            :         int ret;
     869                 :            : 
     870                 :            :         if (!hns3_is_link_fc_mode(hns))
     871                 :          0 :                 return;
     872                 :            : 
     873                 :          0 :         ret = hns3_flow_ctrl_get(dev, &cur_fc_conf);
     874         [ #  # ]:          0 :         if (ret)  {
     875                 :            :                 fprintf(file, "get device flow control info fail!\n");
     876                 :          0 :                 return;
     877                 :            :         }
     878                 :            : 
     879         [ #  # ]:          0 :         hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode,
     880                 :            :                                    &rx_pause1, &tx_pause1);
     881         [ #  # ]:          0 :         hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)cur_fc_conf.mode,
     882                 :            :                                    &rx_pause2, &tx_pause2);
     883                 :            : 
     884   [ #  #  #  #  :          0 :         fprintf(file,
             #  #  #  # ]
     885                 :            :                 "\t  -- link_fc_info:\n"
     886                 :            :                 "\t       Requested fc:\n"
     887                 :            :                 "\t         Rx:    %s\n"
     888                 :            :                 "\t         Tx:    %s\n"
     889                 :            :                 "\t       Current fc:\n"
     890                 :            :                 "\t         Rx:    %s\n"
     891                 :            :                 "\t         Tx:    %s\n"
     892                 :            :                 "\t       Autonegotiate: %s\n"
     893                 :            :                 "\t       Pause time:      0x%x\n",
     894                 :            :                 rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off",
     895                 :            :                 rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off",
     896                 :          0 :                 cur_fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off",
     897         [ #  # ]:          0 :                 cur_fc_conf.pause_time);
     898                 :            : }
     899                 :            : 
     900                 :            : static void
     901                 :          0 : hns3_get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev)
     902                 :            : {
     903                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     904                 :            : 
     905                 :            :         fprintf(file, "  - Flow Ctrl Info:\n");
     906                 :            :         fprintf(file,
     907                 :            :                 "\t  -- fc_common_info:\n"
     908                 :            :                 "\t       current_fc_status=%u\n"
     909                 :            :                 "\t       requested_fc_mode=%u\n",
     910                 :          0 :                 hw->current_fc_status,
     911                 :          0 :                 hw->requested_fc_mode);
     912                 :            : 
     913                 :          0 :         hns3_get_link_fc_info(file, dev);
     914                 :          0 : }
     915                 :            : 
     916                 :            : int
     917                 :          0 : hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
     918                 :            : {
     919                 :          0 :         struct hns3_adapter *hns = dev->data->dev_private;
     920                 :          0 :         struct hns3_hw *hw = &hns->hw;
     921                 :            : 
     922                 :          0 :         rte_spinlock_lock(&hw->lock);
     923                 :            : 
     924                 :          0 :         hns3_get_device_basic_info(file, dev);
     925                 :          0 :         hns3_get_dev_feature_capability(file, hw);
     926                 :          0 :         hns3_get_rxtx_queue_info(file, dev);
     927                 :            :         hns3_get_port_pvid_info(file, hw);
     928                 :            : 
     929                 :            :         /*
     930                 :            :          * VF only supports dumping basic info, feature capability and queue
     931                 :            :          * info.
     932                 :            :          */
     933         [ #  # ]:          0 :         if (hns->is_vf) {
     934                 :            :                 rte_spinlock_unlock(&hw->lock);
     935                 :          0 :                 return 0;
     936                 :            :         }
     937                 :            : 
     938                 :          0 :         hns3_get_dev_mac_info(file, hns);
     939                 :          0 :         hns3_get_vlan_config_info(file, hw);
     940                 :          0 :         hns3_get_fdir_basic_info(file, &hns->pf);
     941                 :          0 :         hns3_get_tm_conf_info(file, dev);
     942                 :          0 :         hns3_get_flow_ctrl_info(file, dev);
     943                 :            : 
     944                 :            :         rte_spinlock_unlock(&hw->lock);
     945                 :            : 
     946                 :          0 :         return 0;
     947                 :            : }
     948                 :            : 
     949                 :            : int
     950                 :          0 : hns3_rx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
     951                 :            :                         uint16_t offset, uint16_t num, FILE *file)
     952                 :            : {
     953                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     954                 :          0 :         struct hns3_rx_queue *rxq = dev->data->rx_queues[queue_id];
     955                 :            :         uint32_t *bd_data;
     956                 :            :         uint16_t count = 0;
     957                 :            :         uint16_t desc_id;
     958                 :            :         int i;
     959                 :            : 
     960         [ #  # ]:          0 :         if (offset >= rxq->nb_rx_desc)
     961                 :            :                 return -EINVAL;
     962                 :            : 
     963         [ #  # ]:          0 :         if (num > rxq->nb_rx_desc) {
     964                 :          0 :                 hns3_err(hw, "Invalid BD num=%u\n", num);
     965                 :          0 :                 return -EINVAL;
     966                 :            :         }
     967                 :            : 
     968         [ #  # ]:          0 :         while (count < num) {
     969                 :          0 :                 desc_id = (rxq->next_to_use + offset + count) % rxq->nb_rx_desc;
     970                 :          0 :                 bd_data = (uint32_t *)(&rxq->rx_ring[desc_id]);
     971                 :          0 :                 fprintf(file, "Rx queue id:%u BD id:%u\n", queue_id, desc_id);
     972         [ #  # ]:          0 :                 for (i = 0; i < HNS3_BD_DW_NUM; i++) {
     973                 :            :                         /*
     974                 :            :                          * For the sake of security, first 8 bytes of BD which
     975                 :            :                          * stands for physical address of packet should not be
     976                 :            :                          * shown.
     977                 :            :                          */
     978         [ #  # ]:          0 :                         if (i < HNS3_BD_ADDRESS_LAST_DW) {
     979                 :            :                                 fprintf(file, "RX BD WORD[%d]:0x%08x\n", i, 0);
     980                 :          0 :                                 continue;
     981                 :            :                         }
     982                 :          0 :                         fprintf(file, "RX BD WORD[%d]:0x%08x\n", i,
     983                 :          0 :                                 *(bd_data + i));
     984                 :            :                 }
     985                 :          0 :                 count++;
     986                 :            :         }
     987                 :            : 
     988                 :            :         return 0;
     989                 :            : }
     990                 :            : 
     991                 :            : int
     992                 :          0 : hns3_tx_descriptor_dump(const struct rte_eth_dev *dev, uint16_t queue_id,
     993                 :            :                         uint16_t offset, uint16_t num, FILE *file)
     994                 :            : {
     995                 :          0 :         struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     996                 :          0 :         struct hns3_tx_queue *txq = dev->data->tx_queues[queue_id];
     997                 :            :         uint32_t *bd_data;
     998                 :            :         uint16_t count = 0;
     999                 :            :         uint16_t desc_id;
    1000                 :            :         int i;
    1001                 :            : 
    1002         [ #  # ]:          0 :         if (offset >= txq->nb_tx_desc)
    1003                 :            :                 return -EINVAL;
    1004                 :            : 
    1005         [ #  # ]:          0 :         if (num > txq->nb_tx_desc) {
    1006                 :          0 :                 hns3_err(hw, "Invalid BD num=%u\n", num);
    1007                 :          0 :                 return -EINVAL;
    1008                 :            :         }
    1009                 :            : 
    1010         [ #  # ]:          0 :         while (count < num) {
    1011                 :          0 :                 desc_id = (txq->next_to_use + offset + count) % txq->nb_tx_desc;
    1012                 :          0 :                 bd_data = (uint32_t *)(&txq->tx_ring[desc_id]);
    1013                 :          0 :                 fprintf(file, "Tx queue id:%u BD id:%u\n", queue_id, desc_id);
    1014         [ #  # ]:          0 :                 for (i = 0; i < HNS3_BD_DW_NUM; i++) {
    1015                 :            :                         /*
    1016                 :            :                          * For the sake of security, first 8 bytes of BD which
    1017                 :            :                          * stands for physical address of packet should not be
    1018                 :            :                          * shown.
    1019                 :            :                          */
    1020         [ #  # ]:          0 :                         if (i < HNS3_BD_ADDRESS_LAST_DW) {
    1021                 :            :                                 fprintf(file, "TX BD WORD[%d]:0x%08x\n", i, 0);
    1022                 :          0 :                                 continue;
    1023                 :            :                         }
    1024                 :            : 
    1025                 :          0 :                         fprintf(file, "Tx BD WORD[%d]:0x%08x\n", i,
    1026                 :          0 :                                 *(bd_data + i));
    1027                 :            :                 }
    1028                 :          0 :                 count++;
    1029                 :            :         }
    1030                 :            : 
    1031                 :            :         return 0;
    1032                 :            : }

Generated by: LCOV version 1.14