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

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2022 NVIDIA Corporation & Affiliates
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "mlx5dr_internal.h"
       6                 :            : 
       7                 :            : const char *mlx5dr_debug_action_type_str[] = {
       8                 :            :         [MLX5DR_ACTION_TYP_LAST] = "LAST",
       9                 :            :         [MLX5DR_ACTION_TYP_REFORMAT_TNL_L2_TO_L2] = "TNL_L2_TO_L2",
      10                 :            :         [MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L2] = "L2_TO_TNL_L2",
      11                 :            :         [MLX5DR_ACTION_TYP_REFORMAT_TNL_L3_TO_L2] = "TNL_L3_TO_L2",
      12                 :            :         [MLX5DR_ACTION_TYP_REFORMAT_L2_TO_TNL_L3] = "L2_TO_TNL_L3",
      13                 :            :         [MLX5DR_ACTION_TYP_DROP] = "DROP",
      14                 :            :         [MLX5DR_ACTION_TYP_TIR] = "TIR",
      15                 :            :         [MLX5DR_ACTION_TYP_TBL] = "TBL",
      16                 :            :         [MLX5DR_ACTION_TYP_CTR] = "CTR",
      17                 :            :         [MLX5DR_ACTION_TYP_TAG] = "TAG",
      18                 :            :         [MLX5DR_ACTION_TYP_MODIFY_HDR] = "MODIFY_HDR",
      19                 :            :         [MLX5DR_ACTION_TYP_VPORT] = "VPORT",
      20                 :            :         [MLX5DR_ACTION_TYP_MISS] = "DEFAULT_MISS",
      21                 :            :         [MLX5DR_ACTION_TYP_POP_VLAN] = "POP_VLAN",
      22                 :            :         [MLX5DR_ACTION_TYP_PUSH_VLAN] = "PUSH_VLAN",
      23                 :            :         [MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER",
      24                 :            :         [MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT",
      25                 :            :         [MLX5DR_ACTION_TYP_DEST_ROOT] = "DEST_ROOT",
      26                 :            :         [MLX5DR_ACTION_TYP_DEST_ARRAY] = "DEST_ARRAY",
      27                 :            :         [MLX5DR_ACTION_TYP_INSERT_HEADER] = "INSERT_HEADER",
      28                 :            :         [MLX5DR_ACTION_TYP_REMOVE_HEADER] = "REMOVE_HEADER",
      29                 :            :         [MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT] = "POP_IPV6_ROUTE_EXT",
      30                 :            :         [MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT] = "PUSH_IPV6_ROUTE_EXT",
      31                 :            :         [MLX5DR_ACTION_TYP_NAT64] = "NAT64",
      32                 :            : };
      33                 :            : 
      34                 :            : static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX,
      35                 :            :               "Missing mlx5dr_debug_action_type_str");
      36                 :            : 
      37                 :          0 : const char *mlx5dr_debug_action_type_to_str(enum mlx5dr_action_type action_type)
      38                 :            : {
      39                 :          0 :         return mlx5dr_debug_action_type_str[action_type];
      40                 :            : }
      41                 :            : 
      42                 :            : static int
      43                 :          0 : mlx5dr_debug_dump_matcher_template_definer(FILE *f,
      44                 :            :                                            void *parent_obj,
      45                 :            :                                            struct mlx5dr_definer *definer,
      46                 :            :                                            enum mlx5dr_debug_res_type type)
      47                 :            : {
      48                 :            :         int i, ret;
      49                 :            : 
      50         [ #  # ]:          0 :         if (!definer)
      51                 :            :                 return 0;
      52                 :            : 
      53                 :          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,",
      54                 :            :                       type,
      55                 :            :                       (uint64_t)(uintptr_t)definer,
      56                 :            :                       (uint64_t)(uintptr_t)parent_obj,
      57                 :          0 :                       definer->obj->id,
      58                 :          0 :                       definer->type);
      59         [ #  # ]:          0 :         if (ret < 0) {
      60                 :          0 :                 rte_errno = EINVAL;
      61                 :          0 :                 return rte_errno;
      62                 :            :         }
      63                 :            : 
      64         [ #  # ]:          0 :         for (i = 0; i < DW_SELECTORS; i++) {
      65         [ #  # ]:          0 :                 ret = fprintf(f, "0x%x%s", definer->dw_selector[i],
      66                 :            :                               (i == DW_SELECTORS - 1) ? "," : "-");
      67         [ #  # ]:          0 :                 if (ret < 0) {
      68                 :          0 :                         rte_errno = EINVAL;
      69                 :          0 :                         return rte_errno;
      70                 :            :                 }
      71                 :            :         }
      72                 :            : 
      73         [ #  # ]:          0 :         for (i = 0; i < BYTE_SELECTORS; i++) {
      74         [ #  # ]:          0 :                 ret = fprintf(f, "0x%x%s", definer->byte_selector[i],
      75                 :            :                               (i == BYTE_SELECTORS - 1) ? "," : "-");
      76         [ #  # ]:          0 :                 if (ret < 0) {
      77                 :          0 :                         rte_errno = EINVAL;
      78                 :          0 :                         return rte_errno;
      79                 :            :                 }
      80                 :            :         }
      81                 :            : 
      82         [ #  # ]:          0 :         for (i = 0; i < MLX5DR_JUMBO_TAG_SZ; i++) {
      83                 :          0 :                 ret = fprintf(f, "%02x", definer->mask.jumbo[i]);
      84         [ #  # ]:          0 :                 if (ret < 0) {
      85                 :          0 :                         rte_errno = EINVAL;
      86                 :          0 :                         return rte_errno;
      87                 :            :                 }
      88                 :            :         }
      89                 :            : 
      90                 :            :         ret = fprintf(f, "\n");
      91         [ #  # ]:          0 :         if (ret < 0) {
      92                 :          0 :                 rte_errno = EINVAL;
      93                 :          0 :                 return rte_errno;
      94                 :            :         }
      95                 :            : 
      96                 :            :         return 0;
      97                 :            : }
      98                 :            : 
      99                 :            : static int
     100                 :          0 : mlx5dr_debug_dump_matcher_match_template(FILE *f, struct mlx5dr_matcher *matcher)
     101                 :            : {
     102                 :          0 :         bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL;
     103                 :            :         bool is_compare = mlx5dr_matcher_is_compare(matcher);
     104                 :            :         enum mlx5dr_debug_res_type type;
     105                 :            :         int i, ret;
     106                 :            : 
     107         [ #  # ]:          0 :         for (i = 0; i < matcher->num_of_mt; i++) {
     108                 :          0 :                 struct mlx5dr_match_template *mt = &matcher->mt[i];
     109                 :            : 
     110         [ #  # ]:          0 :                 ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d\n",
     111                 :            :                               MLX5DR_DEBUG_RES_TYPE_MATCHER_MATCH_TEMPLATE,
     112                 :            :                               (uint64_t)(uintptr_t)mt,
     113                 :            :                               (uint64_t)(uintptr_t)matcher,
     114                 :          0 :                               is_root ? 0 : mt->fc_sz,
     115         [ #  # ]:          0 :                               mt->flags,
     116                 :          0 :                               is_root ? 0 : mt->fcr_sz);
     117         [ #  # ]:          0 :                 if (ret < 0) {
     118                 :          0 :                         rte_errno = EINVAL;
     119                 :          0 :                         return rte_errno;
     120                 :            :                 }
     121                 :            : 
     122         [ #  # ]:          0 :                 type = is_compare ? MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_COMPARE_MATCH_DEFINER :
     123                 :            :                                     MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_MATCH_DEFINER;
     124                 :          0 :                 ret = mlx5dr_debug_dump_matcher_template_definer(f, mt, mt->definer, type);
     125         [ #  # ]:          0 :                 if (ret)
     126                 :          0 :                         return ret;
     127                 :            : 
     128                 :            :                 type = MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_RANGE_DEFINER;
     129                 :          0 :                 ret = mlx5dr_debug_dump_matcher_template_definer(f, mt, mt->range_definer, type);
     130         [ #  # ]:          0 :                 if (ret)
     131                 :          0 :                         return ret;
     132                 :            :         }
     133                 :            : 
     134                 :            :         type = MLX5DR_DEBUG_RES_TYPE_MATCHER_TEMPLATE_HASH_DEFINER;
     135                 :          0 :         ret = mlx5dr_debug_dump_matcher_template_definer(f, matcher, matcher->hash_definer, type);
     136         [ #  # ]:          0 :         if (ret)
     137                 :          0 :                 return ret;
     138                 :            : 
     139                 :            :         return 0;
     140                 :            : }
     141                 :            : 
     142                 :            : static int
     143                 :          0 : mlx5dr_debug_dump_matcher_action_template(FILE *f, struct mlx5dr_matcher *matcher)
     144                 :            : {
     145                 :          0 :         bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL;
     146                 :            :         enum mlx5dr_action_type action_type;
     147                 :            :         int i, j, ret;
     148                 :            : 
     149         [ #  # ]:          0 :         for (i = 0; i < matcher->num_of_at; i++) {
     150                 :          0 :                 struct mlx5dr_action_template *at = &matcher->at[i];
     151                 :            : 
     152                 :          0 :                 ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d",
     153                 :            :                               MLX5DR_DEBUG_RES_TYPE_MATCHER_ACTION_TEMPLATE,
     154                 :            :                               (uint64_t)(uintptr_t)at,
     155                 :            :                               (uint64_t)(uintptr_t)matcher,
     156                 :          0 :                               at->only_term ? 0 : 1,
     157                 :          0 :                               is_root ? 0 : at->num_of_action_stes,
     158         [ #  # ]:          0 :                               at->num_actions);
     159         [ #  # ]:          0 :                 if (ret < 0) {
     160                 :          0 :                         rte_errno = EINVAL;
     161                 :          0 :                         return rte_errno;
     162                 :            :                 }
     163                 :            : 
     164         [ #  # ]:          0 :                 for (j = 0; j < at->num_actions; j++) {
     165                 :          0 :                         action_type = at->action_type_arr[j];
     166                 :          0 :                         ret = fprintf(f, ",%s", mlx5dr_debug_action_type_to_str(action_type));
     167         [ #  # ]:          0 :                         if (ret < 0) {
     168                 :          0 :                                 rte_errno = EINVAL;
     169                 :          0 :                                 return rte_errno;
     170                 :            :                         }
     171                 :            :                 }
     172                 :            : 
     173                 :            :                 fprintf(f, "\n");
     174                 :            :         }
     175                 :            : 
     176                 :            :         return 0;
     177                 :            : }
     178                 :            : 
     179                 :            : static int
     180                 :          0 : mlx5dr_debug_dump_matcher_attr(FILE *f, struct mlx5dr_matcher *matcher)
     181                 :            : {
     182                 :            :         struct mlx5dr_matcher_attr *attr = &matcher->attr;
     183                 :            :         int ret;
     184                 :            : 
     185                 :          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d\n",
     186                 :            :                       MLX5DR_DEBUG_RES_TYPE_MATCHER_ATTR,
     187                 :            :                       (uint64_t)(uintptr_t)matcher,
     188                 :            :                       attr->priority,
     189                 :          0 :                       attr->mode,
     190                 :          0 :                       attr->table.sz_row_log,
     191                 :          0 :                       attr->table.sz_col_log,
     192                 :          0 :                       attr->optimize_using_rule_idx,
     193                 :          0 :                       attr->optimize_flow_src,
     194                 :          0 :                       attr->insert_mode,
     195                 :          0 :                       attr->distribute_mode);
     196         [ #  # ]:          0 :         if (ret < 0) {
     197                 :          0 :                 rte_errno = EINVAL;
     198                 :          0 :                 return rte_errno;
     199                 :            :         }
     200                 :            : 
     201                 :            :         return 0;
     202                 :            : }
     203                 :            : 
     204                 :          0 : static int mlx5dr_debug_dump_matcher(FILE *f, struct mlx5dr_matcher *matcher)
     205                 :            : {
     206         [ #  # ]:          0 :         bool is_shared = mlx5dr_context_shared_gvmi_used(matcher->tbl->ctx);
     207                 :          0 :         bool is_root = matcher->tbl->level == MLX5DR_ROOT_LEVEL;
     208                 :          0 :         enum mlx5dr_table_type tbl_type = matcher->tbl->type;
     209                 :          0 :         struct mlx5dr_cmd_ft_query_attr ft_attr = {0};
     210                 :            :         struct mlx5dr_devx_obj *ste_0, *ste_1 = NULL;
     211                 :            :         struct mlx5dr_pool_chunk *ste;
     212                 :            :         struct mlx5dr_pool *ste_pool;
     213                 :          0 :         uint64_t icm_addr_0 = 0;
     214                 :          0 :         uint64_t icm_addr_1 = 0;
     215                 :            :         int ret;
     216                 :            : 
     217         [ #  # ]:          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,0x%" PRIx64,
     218                 :            :                       MLX5DR_DEBUG_RES_TYPE_MATCHER,
     219                 :            :                       (uint64_t)(uintptr_t)matcher,
     220                 :            :                       (uint64_t)(uintptr_t)matcher->tbl,
     221                 :          0 :                       matcher->num_of_mt,
     222                 :          0 :                       is_root ? 0 : matcher->end_ft->id,
     223         [ #  # ]:          0 :                       matcher->col_matcher ? (uint64_t)(uintptr_t)matcher->col_matcher : 0);
     224         [ #  # ]:          0 :         if (ret < 0)
     225                 :          0 :                 goto out_err;
     226                 :            : 
     227                 :            :         ste = &matcher->match_ste.ste;
     228                 :          0 :         ste_pool = matcher->match_ste.pool;
     229         [ #  # ]:          0 :         if (ste_pool) {
     230                 :            :                 ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste);
     231         [ #  # ]:          0 :                 if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
     232                 :            :                         ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
     233                 :            :         } else {
     234                 :            :                 ste_0 = NULL;
     235                 :            :                 ste_1 = NULL;
     236                 :            :         }
     237                 :            : 
     238   [ #  #  #  # ]:          0 :         ret = fprintf(f, ",%d,%d,%d,%d",
     239         [ #  # ]:          0 :                       matcher->match_ste.rtc_0 ? matcher->match_ste.rtc_0->id : 0,
     240                 :          0 :                       ste_0 ? (int)ste_0->id : -1,
     241         [ #  # ]:          0 :                       matcher->match_ste.rtc_1 ? matcher->match_ste.rtc_1->id : 0,
     242                 :          0 :                       ste_1 ? (int)ste_1->id : -1);
     243         [ #  # ]:          0 :         if (ret < 0)
     244                 :          0 :                 goto out_err;
     245                 :            : 
     246                 :            :         ste = &matcher->action_ste.ste;
     247                 :          0 :         ste_pool = matcher->action_ste.pool;
     248         [ #  # ]:          0 :         if (ste_pool) {
     249                 :            :                 ste_0 = mlx5dr_pool_chunk_get_base_devx_obj(ste_pool, ste);
     250         [ #  # ]:          0 :                 if (tbl_type == MLX5DR_TABLE_TYPE_FDB)
     251                 :            :                         ste_1 = mlx5dr_pool_chunk_get_base_devx_obj_mirror(ste_pool, ste);
     252                 :            :         } else {
     253                 :            :                 ste_0 = NULL;
     254                 :            :                 ste_1 = NULL;
     255                 :            :         }
     256                 :            : 
     257         [ #  # ]:          0 :         if (!is_root) {
     258                 :          0 :                 ft_attr.type = matcher->tbl->fw_ft_type;
     259                 :          0 :                 ret = mlx5dr_cmd_flow_table_query(matcher->end_ft,
     260                 :            :                                                   &ft_attr,
     261                 :            :                                                   &icm_addr_0,
     262                 :            :                                                   &icm_addr_1);
     263         [ #  # ]:          0 :                 if (ret)
     264                 :            :                         return ret;
     265                 :            :         }
     266                 :            : 
     267   [ #  #  #  #  :          0 :         ret = fprintf(f, ",%d,%d,%d,%d,%d,0x%" PRIx64 ",0x%" PRIx64 "\n",
                   #  # ]
     268         [ #  # ]:          0 :                       matcher->action_ste.rtc_0 ? matcher->action_ste.rtc_0->id : 0,
     269                 :          0 :                       ste_0 ? (int)ste_0->id : -1,
     270         [ #  # ]:          0 :                       matcher->action_ste.rtc_1 ? matcher->action_ste.rtc_1->id : 0,
     271                 :          0 :                       ste_1 ? (int)ste_1->id : -1,
     272         [ #  # ]:          0 :                       is_shared && !is_root ?
     273                 :          0 :                       matcher->match_ste.aliased_rtc_0->id : 0,
     274                 :            :                       mlx5dr_debug_icm_to_idx(icm_addr_0),
     275                 :            :                       mlx5dr_debug_icm_to_idx(icm_addr_1));
     276         [ #  # ]:          0 :         if (ret < 0)
     277                 :          0 :                 goto out_err;
     278                 :            : 
     279                 :          0 :         ret = mlx5dr_debug_dump_matcher_attr(f, matcher);
     280         [ #  # ]:          0 :         if (ret)
     281                 :            :                 return ret;
     282                 :            : 
     283                 :          0 :         ret = mlx5dr_debug_dump_matcher_match_template(f, matcher);
     284         [ #  # ]:          0 :         if (ret)
     285                 :            :                 return ret;
     286                 :            : 
     287                 :          0 :         ret = mlx5dr_debug_dump_matcher_action_template(f, matcher);
     288         [ #  # ]:          0 :         if (ret)
     289                 :          0 :                 return ret;
     290                 :            : 
     291                 :            :         return 0;
     292                 :            : 
     293                 :          0 : out_err:
     294                 :          0 :         rte_errno = EINVAL;
     295                 :          0 :         return rte_errno;
     296                 :            : }
     297                 :            : 
     298                 :          0 : static int mlx5dr_debug_dump_table(FILE *f, struct mlx5dr_table *tbl)
     299                 :            : {
     300         [ #  # ]:          0 :         bool is_shared = mlx5dr_context_shared_gvmi_used(tbl->ctx);
     301                 :          0 :         bool is_root = tbl->level == MLX5DR_ROOT_LEVEL;
     302                 :          0 :         struct mlx5dr_cmd_ft_query_attr ft_attr = {0};
     303                 :            :         struct mlx5dr_matcher *matcher;
     304                 :          0 :         uint64_t local_icm_addr_0 = 0;
     305                 :          0 :         uint64_t local_icm_addr_1 = 0;
     306                 :          0 :         uint64_t icm_addr_0 = 0;
     307                 :          0 :         uint64_t icm_addr_1 = 0;
     308                 :            :         int ret;
     309                 :            : 
     310         [ #  # ]:          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",0x%" PRIx64 ",%d,%d,%d,%d,%d",
     311                 :            :                       MLX5DR_DEBUG_RES_TYPE_TABLE,
     312                 :            :                       (uint64_t)(uintptr_t)tbl,
     313                 :            :                       (uint64_t)(uintptr_t)tbl->ctx,
     314                 :          0 :                       is_root ? 0 : tbl->ft->id,
     315         [ #  # ]:          0 :                       tbl->type,
     316                 :            :                       is_root ? 0 : tbl->fw_ft_type,
     317                 :            :                       tbl->level,
     318         [ #  # ]:          0 :                       is_shared && !is_root ? tbl->local_ft->id : 0);
     319         [ #  # ]:          0 :         if (ret < 0)
     320                 :          0 :                 goto out_err;
     321                 :            : 
     322         [ #  # ]:          0 :         if (!is_root) {
     323                 :          0 :                 ft_attr.type = tbl->fw_ft_type;
     324                 :          0 :                 ret = mlx5dr_cmd_flow_table_query(tbl->ft,
     325                 :            :                                                   &ft_attr,
     326                 :            :                                                   &icm_addr_0,
     327                 :            :                                                   &icm_addr_1);
     328         [ #  # ]:          0 :                 if (ret)
     329                 :            :                         return ret;
     330                 :            : 
     331         [ #  # ]:          0 :                 if (is_shared) {
     332                 :          0 :                         ft_attr.type = tbl->fw_ft_type;
     333                 :          0 :                         ret = mlx5dr_cmd_flow_table_query(tbl->local_ft,
     334                 :            :                                                           &ft_attr,
     335                 :            :                                                           &local_icm_addr_0,
     336                 :            :                                                           &local_icm_addr_1);
     337         [ #  # ]:          0 :                         if (ret)
     338                 :            :                                 return ret;
     339                 :            :                 }
     340                 :            :         }
     341                 :            : 
     342                 :          0 :         ret = fprintf(f, ",0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 ",0x%" PRIx64 "\n",
     343                 :            :                       mlx5dr_debug_icm_to_idx(icm_addr_0),
     344                 :            :                       mlx5dr_debug_icm_to_idx(icm_addr_1),
     345                 :            :                       mlx5dr_debug_icm_to_idx(local_icm_addr_0),
     346                 :            :                       mlx5dr_debug_icm_to_idx(local_icm_addr_1),
     347                 :          0 :                       (uint64_t)(uintptr_t)tbl->default_miss.miss_tbl);
     348         [ #  # ]:          0 :         if (ret < 0)
     349                 :          0 :                 goto out_err;
     350                 :            : 
     351         [ #  # ]:          0 :         LIST_FOREACH(matcher, &tbl->head, next) {
     352                 :          0 :                 ret = mlx5dr_debug_dump_matcher(f, matcher);
     353         [ #  # ]:          0 :                 if (ret)
     354                 :          0 :                         return ret;
     355                 :            :         }
     356                 :            : 
     357                 :            :         return 0;
     358                 :            : 
     359                 :          0 : out_err:
     360                 :          0 :         rte_errno = EINVAL;
     361                 :          0 :         return rte_errno;
     362                 :            : }
     363                 :            : 
     364                 :            : static int
     365                 :          0 : mlx5dr_debug_dump_context_send_engine(FILE *f, struct mlx5dr_context *ctx)
     366                 :            : {
     367                 :            :         struct mlx5dr_send_engine *send_queue;
     368                 :            :         int ret, i, j;
     369                 :            : 
     370         [ #  # ]:          0 :         for (i = 0; i < (int)ctx->queues; i++) {
     371                 :          0 :                 send_queue = &ctx->send_queue[i];
     372                 :          0 :                 ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
     373                 :            :                               MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_ENGINE,
     374                 :            :                               (uint64_t)(uintptr_t)ctx,
     375                 :            :                               i,
     376                 :          0 :                               send_queue->used_entries,
     377                 :          0 :                               send_queue->th_entries,
     378                 :          0 :                               send_queue->rings,
     379                 :          0 :                               send_queue->num_entries,
     380                 :          0 :                               send_queue->err,
     381                 :          0 :                               send_queue->completed.ci,
     382                 :          0 :                               send_queue->completed.pi,
     383                 :          0 :                               send_queue->completed.mask);
     384         [ #  # ]:          0 :                 if (ret < 0) {
     385                 :          0 :                         rte_errno = EINVAL;
     386                 :          0 :                         return rte_errno;
     387                 :            :                 }
     388                 :            : 
     389         [ #  # ]:          0 :                 for (j = 0; j < MLX5DR_NUM_SEND_RINGS; j++) {
     390                 :            :                         struct mlx5dr_send_ring *send_ring = &send_queue->send_ring[j];
     391                 :            :                         struct mlx5dr_send_ring_cq *cq = &send_ring->send_cq;
     392                 :            :                         struct mlx5dr_send_ring_sq *sq = &send_ring->send_sq;
     393                 :            : 
     394                 :          0 :                         ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
     395                 :            :                                       MLX5DR_DEBUG_RES_TYPE_CONTEXT_SEND_RING,
     396                 :            :                                       (uint64_t)(uintptr_t)ctx,
     397                 :            :                                       j,
     398                 :            :                                       i,
     399                 :            :                                       cq->cqn,
     400                 :            :                                       cq->cons_index,
     401                 :            :                                       cq->ncqe_mask,
     402                 :            :                                       cq->buf_sz,
     403                 :            :                                       cq->ncqe,
     404                 :            :                                       cq->cqe_log_sz,
     405                 :          0 :                                       cq->poll_wqe,
     406                 :            :                                       cq->cqe_sz,
     407                 :            :                                       sq->sqn,
     408                 :          0 :                                       sq->obj->id,
     409                 :          0 :                                       sq->cur_post,
     410                 :          0 :                                       sq->buf_mask);
     411         [ #  # ]:          0 :                         if (ret < 0) {
     412                 :          0 :                                 rte_errno = EINVAL;
     413                 :          0 :                                 return rte_errno;
     414                 :            :                         }
     415                 :            :                 }
     416                 :            :         }
     417                 :            : 
     418                 :            :         return 0;
     419                 :            : }
     420                 :            : 
     421                 :          0 : static int mlx5dr_debug_dump_context_caps(FILE *f, struct mlx5dr_context *ctx)
     422                 :            : {
     423                 :          0 :         struct mlx5dr_cmd_query_caps *caps = ctx->caps;
     424                 :            :         int ret;
     425                 :            : 
     426                 :          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",%s,%d,%d,%d,%d,",
     427                 :            :                       MLX5DR_DEBUG_RES_TYPE_CONTEXT_CAPS,
     428                 :            :                       (uint64_t)(uintptr_t)ctx,
     429                 :          0 :                       caps->fw_ver,
     430                 :          0 :                       caps->wqe_based_update,
     431                 :          0 :                       caps->ste_format,
     432                 :          0 :                       caps->ste_alloc_log_max,
     433                 :          0 :                       caps->log_header_modify_argument_max_alloc);
     434         [ #  # ]:          0 :         if (ret < 0) {
     435                 :          0 :                 rte_errno = EINVAL;
     436                 :          0 :                 return rte_errno;
     437                 :            :         }
     438                 :            : 
     439                 :          0 :         ret = fprintf(f, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
     440                 :            :                       caps->flex_protocols,
     441                 :          0 :                       caps->rtc_reparse_mode,
     442                 :          0 :                       caps->rtc_index_mode,
     443                 :          0 :                       caps->ste_alloc_log_gran,
     444                 :          0 :                       caps->stc_alloc_log_max,
     445                 :          0 :                       caps->stc_alloc_log_gran,
     446                 :          0 :                       caps->rtc_log_depth_max,
     447                 :          0 :                       caps->format_select_gtpu_dw_0,
     448                 :          0 :                       caps->format_select_gtpu_dw_1,
     449                 :          0 :                       caps->format_select_gtpu_dw_2,
     450                 :          0 :                       caps->format_select_gtpu_ext_dw_0,
     451                 :          0 :                       caps->nic_ft.max_level,
     452                 :          0 :                       caps->nic_ft.reparse,
     453                 :          0 :                       caps->fdb_ft.max_level,
     454                 :          0 :                       caps->fdb_ft.reparse,
     455                 :          0 :                       caps->log_header_modify_argument_granularity);
     456         [ #  # ]:          0 :         if (ret < 0) {
     457                 :          0 :                 rte_errno = EINVAL;
     458                 :          0 :                 return rte_errno;
     459                 :            :         }
     460                 :            : 
     461                 :            :         return 0;
     462                 :            : }
     463                 :            : 
     464         [ #  # ]:          0 : static int mlx5dr_debug_dump_context_attr(FILE *f, struct mlx5dr_context *ctx)
     465                 :            : {
     466                 :            :         int ret;
     467                 :            : 
     468         [ #  # ]:          0 :         ret = fprintf(f, "%u,0x%" PRIx64 ",%d,%zu,%d,%s,%d,%d\n",
     469                 :            :                       MLX5DR_DEBUG_RES_TYPE_CONTEXT_ATTR,
     470                 :            :                       (uint64_t)(uintptr_t)ctx,
     471                 :            :                       ctx->pd_num,
     472                 :            :                       ctx->queues,
     473                 :          0 :                       ctx->send_queue->num_entries,
     474                 :            :                       mlx5dr_context_shared_gvmi_used(ctx) ?
     475                 :          0 :                       mlx5_glue->get_device_name(ctx->ibv_ctx->device) : "None",
     476         [ #  # ]:          0 :                       ctx->caps->vhca_id,
     477                 :            :                       mlx5dr_context_shared_gvmi_used(ctx) ?
     478                 :          0 :                       ctx->caps->shared_vhca_id : 0xffff);
     479         [ #  # ]:          0 :         if (ret < 0) {
     480                 :          0 :                 rte_errno = EINVAL;
     481                 :          0 :                 return rte_errno;
     482                 :            :         }
     483                 :            : 
     484                 :            :         return 0;
     485                 :            : }
     486                 :            : 
     487                 :          0 : static int mlx5dr_debug_dump_context_info(FILE *f, struct mlx5dr_context *ctx)
     488                 :            : {
     489                 :            :         int ret;
     490                 :            : 
     491                 :          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",%d,%s,%s\n",
     492                 :            :                       MLX5DR_DEBUG_RES_TYPE_CONTEXT,
     493                 :            :                       (uint64_t)(uintptr_t)ctx,
     494                 :          0 :                       ctx->flags & MLX5DR_CONTEXT_FLAG_HWS_SUPPORT,
     495         [ #  # ]:          0 :                       mlx5_glue->get_device_name(mlx5dr_context_get_local_ibv(ctx)->device),
     496                 :            :                       DEBUG_VERSION);
     497         [ #  # ]:          0 :         if (ret < 0) {
     498                 :          0 :                 rte_errno = EINVAL;
     499                 :          0 :                 return rte_errno;
     500                 :            :         }
     501                 :            : 
     502                 :          0 :         ret = mlx5dr_debug_dump_context_attr(f, ctx);
     503         [ #  # ]:          0 :         if (ret)
     504                 :            :                 return ret;
     505                 :            : 
     506                 :          0 :         ret = mlx5dr_debug_dump_context_caps(f, ctx);
     507         [ #  # ]:          0 :         if (ret)
     508                 :          0 :                 return ret;
     509                 :            : 
     510                 :            :         return 0;
     511                 :            : }
     512                 :            : 
     513                 :            : static int
     514                 :            : mlx5dr_debug_dump_context_stc_resource(FILE *f,
     515                 :            :                                        struct mlx5dr_context *ctx,
     516                 :            :                                        uint32_t tbl_type,
     517                 :            :                                        struct mlx5dr_pool_resource *resource)
     518                 :            : {
     519                 :            :         int ret;
     520                 :            : 
     521                 :          0 :         ret = fprintf(f, "%d,0x%" PRIx64 ",%u,%u\n",
     522                 :            :                       MLX5DR_DEBUG_RES_TYPE_CONTEXT_STC,
     523                 :            :                       (uint64_t)(uintptr_t)ctx,
     524                 :            :                       tbl_type,
     525                 :            :                       resource->base_id);
     526   [ #  #  #  # ]:          0 :         if (ret < 0) {
     527                 :          0 :                 rte_errno = EINVAL;
     528                 :            :                 return rte_errno;
     529                 :            :         }
     530                 :            : 
     531                 :            :         return 0;
     532                 :            : }
     533                 :            : 
     534                 :          0 : static int mlx5dr_debug_dump_context_stc(FILE *f, struct mlx5dr_context *ctx)
     535                 :            : {
     536                 :            :         struct mlx5dr_pool *stc_pool;
     537                 :            :         int ret;
     538                 :            :         int i;
     539                 :            : 
     540         [ #  # ]:          0 :         for (i = 0; i < MLX5DR_TABLE_TYPE_MAX; i++) {
     541                 :          0 :                 stc_pool = ctx->stc_pool[i];
     542                 :            : 
     543         [ #  # ]:          0 :                 if (!stc_pool)
     544                 :          0 :                         continue;
     545                 :            : 
     546         [ #  # ]:          0 :                 if (stc_pool->resource[0] != NULL) {
     547                 :          0 :                         ret = mlx5dr_debug_dump_context_stc_resource(f, ctx, i,
     548                 :            :                                                                      stc_pool->resource[0]);
     549                 :            :                         if (ret)
     550                 :          0 :                                 return ret;
     551                 :            :                 }
     552                 :            : 
     553   [ #  #  #  # ]:          0 :                 if (i == MLX5DR_TABLE_TYPE_FDB && stc_pool->mirror_resource[0] != NULL) {
     554                 :            :                         ret = mlx5dr_debug_dump_context_stc_resource(f, ctx, i,
     555                 :            :                                                                      stc_pool->mirror_resource[0]);
     556                 :            :                         if (ret)
     557                 :          0 :                                 return ret;
     558                 :            :                 }
     559                 :            :         }
     560                 :            : 
     561                 :            :         return 0;
     562                 :            : }
     563                 :            : 
     564                 :          0 : static int mlx5dr_debug_dump_context(FILE *f, struct mlx5dr_context *ctx)
     565                 :            : {
     566                 :            :         struct mlx5dr_table *tbl;
     567                 :            :         int ret;
     568                 :            : 
     569                 :          0 :         ret = mlx5dr_debug_dump_context_info(f, ctx);
     570         [ #  # ]:          0 :         if (ret)
     571                 :            :                 return ret;
     572                 :            : 
     573                 :          0 :         ret = mlx5dr_debug_dump_context_send_engine(f, ctx);
     574         [ #  # ]:          0 :         if (ret)
     575                 :            :                 return ret;
     576                 :            : 
     577                 :          0 :         ret = mlx5dr_debug_dump_context_stc(f, ctx);
     578         [ #  # ]:          0 :         if (ret)
     579                 :            :                 return ret;
     580                 :            : 
     581         [ #  # ]:          0 :         LIST_FOREACH(tbl, &ctx->head, next) {
     582                 :          0 :                 ret = mlx5dr_debug_dump_table(f, tbl);
     583         [ #  # ]:          0 :                 if (ret)
     584                 :          0 :                         return ret;
     585                 :            :         }
     586                 :            : 
     587                 :            :         return 0;
     588                 :            : }
     589                 :            : 
     590                 :          0 : int mlx5dr_debug_dump(struct mlx5dr_context *ctx, FILE *f)
     591                 :            : {
     592                 :            :         int ret;
     593                 :            : 
     594         [ #  # ]:          0 :         if (!f || !ctx) {
     595                 :          0 :                 rte_errno = EINVAL;
     596                 :          0 :                 return -rte_errno;
     597                 :            :         }
     598                 :            : 
     599                 :          0 :         pthread_spin_lock(&ctx->ctrl_lock);
     600                 :          0 :         ret = mlx5dr_debug_dump_context(f, ctx);
     601                 :          0 :         pthread_spin_unlock(&ctx->ctrl_lock);
     602                 :            : 
     603                 :          0 :         return -ret;
     604                 :            : }

Generated by: LCOV version 1.14