LCOV - code coverage report
Current view: top level - drivers/common/cnxk - cnxk_telemetry_npa.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 7 148 4.7 %
Date: 2025-03-01 20:23:48 Functions: 1 8 12.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 40 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <ctype.h>
       6                 :            : #include "cnxk_telemetry.h"
       7                 :            : #include "roc_api.h"
       8                 :            : #include "roc_priv.h"
       9                 :            : 
      10                 :            : static int
      11                 :          0 : cnxk_tel_npa(struct plt_tel_data *d)
      12                 :            : {
      13                 :            :         struct npa_lf *lf;
      14                 :            :         int aura_cnt = 0;
      15                 :            :         uint32_t i;
      16                 :            : 
      17                 :          0 :         lf = idev_npa_obj_get();
      18         [ #  # ]:          0 :         if (lf == NULL)
      19                 :            :                 return NPA_ERR_DEVICE_NOT_BOUNDED;
      20                 :            : 
      21         [ #  # ]:          0 :         for (i = 0; i < lf->nr_pools; i++) {
      22         [ #  # ]:          0 :                 if (plt_bitmap_get(lf->npa_bmp, i))
      23                 :          0 :                         continue;
      24                 :          0 :                 aura_cnt++;
      25                 :            :         }
      26                 :            : 
      27                 :          0 :         plt_tel_data_add_dict_ptr(d, "npa", lf);
      28         [ #  # ]:          0 :         plt_tel_data_add_dict_int(d, "pf", dev_get_pf(lf->pf_func));
      29         [ #  # ]:          0 :         plt_tel_data_add_dict_int(d, "vf", dev_get_vf(lf->pf_func));
      30                 :          0 :         plt_tel_data_add_dict_int(d, "aura_cnt", aura_cnt);
      31                 :            : 
      32                 :          0 :         CNXK_TEL_DICT_STR(d, lf->pci_dev, name, pcidev_);
      33                 :          0 :         CNXK_TEL_DICT_PTR(d, lf, npa_bmp);
      34                 :          0 :         CNXK_TEL_DICT_PTR(d, lf, npa_bmp_mem);
      35                 :          0 :         CNXK_TEL_DICT_PTR(d, lf, npa_qint_mem);
      36                 :          0 :         CNXK_TEL_DICT_PTR(d, lf, mbox);
      37                 :          0 :         CNXK_TEL_DICT_PTR(d, lf, base);
      38                 :          0 :         CNXK_TEL_DICT_INT(d, lf, stack_pg_ptrs);
      39                 :          0 :         CNXK_TEL_DICT_INT(d, lf, stack_pg_bytes);
      40                 :          0 :         CNXK_TEL_DICT_INT(d, lf, npa_msixoff);
      41                 :          0 :         CNXK_TEL_DICT_INT(d, lf, nr_pools);
      42                 :          0 :         CNXK_TEL_DICT_INT(d, lf, pf_func);
      43                 :          0 :         CNXK_TEL_DICT_INT(d, lf, aura_sz);
      44                 :          0 :         CNXK_TEL_DICT_INT(d, lf, qints);
      45                 :            : 
      46                 :          0 :         return 0;
      47                 :            : }
      48                 :            : 
      49                 :            : static int
      50                 :          0 : cnxk_tel_npa_aura(int aura_id, struct plt_tel_data *d)
      51                 :            : {
      52                 :            :         __io struct npa_aura_s *aura;
      53                 :            :         struct npa_aq_enq_req *req;
      54                 :            :         struct npa_aq_enq_rsp *rsp;
      55                 :            :         struct npa_lf *lf;
      56                 :            :         int rc;
      57                 :            : 
      58                 :          0 :         lf = idev_npa_obj_get();
      59         [ #  # ]:          0 :         if (lf == NULL)
      60                 :            :                 return NPA_ERR_DEVICE_NOT_BOUNDED;
      61                 :            : 
      62         [ #  # ]:          0 :         if (plt_bitmap_get(lf->npa_bmp, aura_id))
      63                 :            :                 return -1;
      64                 :            : 
      65                 :          0 :         req = mbox_alloc_msg_npa_aq_enq(mbox_get(lf->mbox));
      66         [ #  # ]:          0 :         if (!req) {
      67                 :          0 :                 plt_err("Failed to alloc aq enq for npa");
      68                 :            :                 rc = -1;
      69                 :          0 :                 goto exit;
      70                 :            :         }
      71                 :            : 
      72                 :          0 :         req->aura_id = aura_id;
      73                 :          0 :         req->ctype = NPA_AQ_CTYPE_AURA;
      74                 :          0 :         req->op = NPA_AQ_INSTOP_READ;
      75                 :            : 
      76                 :          0 :         rc = mbox_process_msg(lf->mbox, (void *)&rsp);
      77         [ #  # ]:          0 :         if (rc) {
      78                 :          0 :                 plt_err("Failed to get pool(%d) context", aura_id);
      79                 :          0 :                 goto exit;
      80                 :            :         }
      81                 :            : 
      82                 :          0 :         aura = &rsp->aura;
      83                 :          0 :         CNXK_TEL_DICT_PTR(d, aura, pool_addr, w0_);
      84                 :          0 :         CNXK_TEL_DICT_INT(d, aura, ena, w1_);
      85                 :          0 :         CNXK_TEL_DICT_INT(d, aura, pool_caching, w1_);
      86                 :          0 :         CNXK_TEL_DICT_INT(d, aura, pool_way_mask, w1_);
      87                 :          0 :         CNXK_TEL_DICT_INT(d, aura, avg_con, w1_);
      88                 :          0 :         CNXK_TEL_DICT_INT(d, aura, pool_drop_ena, w1_);
      89                 :          0 :         CNXK_TEL_DICT_INT(d, aura, aura_drop_ena, w1_);
      90                 :          0 :         CNXK_TEL_DICT_INT(d, aura, bp_ena, w1_);
      91                 :          0 :         CNXK_TEL_DICT_INT(d, aura, aura_drop, w1_);
      92                 :          0 :         CNXK_TEL_DICT_INT(d, aura, avg_level, w1_);
      93                 :          0 :         CNXK_TEL_DICT_U64(d, aura, count, w2_);
      94                 :          0 :         CNXK_TEL_DICT_INT(d, aura, nix0_bpid, w2_);
      95                 :          0 :         CNXK_TEL_DICT_INT(d, aura, nix1_bpid, w2_);
      96                 :          0 :         CNXK_TEL_DICT_U64(d, aura, limit, w3_);
      97                 :          0 :         CNXK_TEL_DICT_INT(d, aura, bp, w3_);
      98                 :          0 :         CNXK_TEL_DICT_INT(d, aura, fc_ena, w3_);
      99                 :          0 :         CNXK_TEL_DICT_INT(d, aura, fc_up_crossing, w3_);
     100                 :          0 :         CNXK_TEL_DICT_INT(d, aura, fc_stype, w3_);
     101                 :          0 :         CNXK_TEL_DICT_INT(d, aura, fc_hyst_bits, w3_);
     102                 :          0 :         CNXK_TEL_DICT_INT(d, aura, fc_addr, w4_);
     103                 :          0 :         CNXK_TEL_DICT_INT(d, aura, pool_drop, w5_);
     104                 :          0 :         CNXK_TEL_DICT_INT(d, aura, update_time, w5_);
     105                 :          0 :         CNXK_TEL_DICT_INT(d, aura, err_int, w5_);
     106                 :          0 :         CNXK_TEL_DICT_INT(d, aura, err_int_ena, w5_);
     107                 :          0 :         CNXK_TEL_DICT_INT(d, aura, thresh_int, w5_);
     108                 :          0 :         CNXK_TEL_DICT_INT(d, aura, thresh_int_ena, w5_);
     109                 :          0 :         CNXK_TEL_DICT_INT(d, aura, thresh_up, w5_);
     110                 :          0 :         CNXK_TEL_DICT_INT(d, aura, thresh_qint_idx, w5_);
     111                 :          0 :         CNXK_TEL_DICT_INT(d, aura, err_qint_idx, w5_);
     112                 :          0 :         CNXK_TEL_DICT_U64(d, aura, thresh, w6_);
     113                 :            : 
     114                 :            :         rc = 0;
     115                 :          0 : exit:
     116                 :          0 :         mbox_put(lf->mbox);
     117                 :          0 :         return rc;
     118                 :            : }
     119                 :            : 
     120                 :            : static int
     121                 :          0 : cnxk_tel_npa_pool(int pool_id, struct plt_tel_data *d)
     122                 :            : {
     123                 :            :         __io struct npa_pool_s *pool;
     124                 :            :         struct npa_aq_enq_req *req;
     125                 :            :         struct npa_aq_enq_rsp *rsp;
     126                 :            :         struct npa_lf *lf;
     127                 :            :         int rc;
     128                 :            : 
     129                 :          0 :         lf = idev_npa_obj_get();
     130         [ #  # ]:          0 :         if (lf == NULL)
     131                 :            :                 return NPA_ERR_DEVICE_NOT_BOUNDED;
     132                 :            : 
     133         [ #  # ]:          0 :         if (plt_bitmap_get(lf->npa_bmp, pool_id))
     134                 :            :                 return -1;
     135                 :            : 
     136                 :          0 :         req = mbox_alloc_msg_npa_aq_enq(mbox_get(lf->mbox));
     137         [ #  # ]:          0 :         if (!req) {
     138                 :          0 :                 plt_err("Failed to alloc aq enq for npa");
     139                 :            :                 rc = -1;
     140                 :          0 :                 goto exit;
     141                 :            :         }
     142                 :            : 
     143                 :          0 :         req->aura_id = pool_id;
     144                 :          0 :         req->ctype = NPA_AQ_CTYPE_POOL;
     145                 :          0 :         req->op = NPA_AQ_INSTOP_READ;
     146                 :            : 
     147                 :          0 :         rc = mbox_process_msg(lf->mbox, (void *)&rsp);
     148         [ #  # ]:          0 :         if (rc) {
     149                 :          0 :                 plt_err("Failed to get pool(%d) context", pool_id);
     150                 :          0 :                 goto exit;
     151                 :            :         }
     152                 :            : 
     153                 :          0 :         pool = &rsp->pool;
     154                 :          0 :         CNXK_TEL_DICT_PTR(d, pool, stack_base, w0_);
     155                 :          0 :         CNXK_TEL_DICT_INT(d, pool, ena, w1_);
     156                 :          0 :         CNXK_TEL_DICT_INT(d, pool, nat_align, w1_);
     157                 :          0 :         CNXK_TEL_DICT_INT(d, pool, stack_caching, w1_);
     158                 :          0 :         CNXK_TEL_DICT_INT(d, pool, stack_way_mask, w1_);
     159                 :          0 :         CNXK_TEL_DICT_INT(d, pool, buf_offset, w1_);
     160                 :          0 :         CNXK_TEL_DICT_INT(d, pool, buf_size, w1_);
     161                 :          0 :         CNXK_TEL_DICT_INT(d, pool, stack_max_pages, w2_);
     162                 :          0 :         CNXK_TEL_DICT_INT(d, pool, stack_pages, w2_);
     163                 :          0 :         CNXK_TEL_DICT_INT(d, pool, op_pc, w3_);
     164                 :          0 :         CNXK_TEL_DICT_INT(d, pool, stack_offset, w4_);
     165                 :          0 :         CNXK_TEL_DICT_INT(d, pool, shift, w4_);
     166                 :          0 :         CNXK_TEL_DICT_INT(d, pool, avg_level, w4_);
     167                 :          0 :         CNXK_TEL_DICT_INT(d, pool, avg_con, w4_);
     168                 :          0 :         CNXK_TEL_DICT_INT(d, pool, fc_ena, w4_);
     169                 :          0 :         CNXK_TEL_DICT_INT(d, pool, fc_stype, w4_);
     170                 :          0 :         CNXK_TEL_DICT_INT(d, pool, fc_hyst_bits, w4_);
     171                 :          0 :         CNXK_TEL_DICT_INT(d, pool, fc_up_crossing, w4_);
     172                 :          0 :         CNXK_TEL_DICT_INT(d, pool, update_time, w4_);
     173                 :          0 :         CNXK_TEL_DICT_PTR(d, pool, fc_addr, w5_);
     174                 :          0 :         CNXK_TEL_DICT_PTR(d, pool, ptr_start, w6_);
     175                 :          0 :         CNXK_TEL_DICT_PTR(d, pool, ptr_end, w7_);
     176                 :          0 :         CNXK_TEL_DICT_INT(d, pool, err_int, w8_);
     177                 :          0 :         CNXK_TEL_DICT_INT(d, pool, err_int_ena, w8_);
     178                 :          0 :         CNXK_TEL_DICT_INT(d, pool, thresh_int, w8_);
     179                 :          0 :         CNXK_TEL_DICT_INT(d, pool, thresh_int_ena, w8_);
     180                 :          0 :         CNXK_TEL_DICT_INT(d, pool, thresh_up, w8_);
     181                 :          0 :         CNXK_TEL_DICT_INT(d, pool, thresh_qint_idx, w8_);
     182                 :          0 :         CNXK_TEL_DICT_INT(d, pool, err_qint_idx, w8_);
     183                 :            : 
     184                 :            :         rc = 0;
     185                 :          0 : exit:
     186                 :          0 :         mbox_put(lf->mbox);
     187                 :          0 :         return rc;
     188                 :            : }
     189                 :            : 
     190                 :            : static int
     191                 :          0 : cnxk_npa_tel_handle_info(const char *cmd __plt_unused,
     192                 :            :                          const char *params __plt_unused,
     193                 :            :                          struct plt_tel_data *d)
     194                 :            : {
     195                 :          0 :         plt_tel_data_start_dict(d);
     196                 :          0 :         return cnxk_tel_npa(d);
     197                 :            : }
     198                 :            : 
     199                 :            : static int
     200                 :          0 : cnxk_npa_tel_handle_aura_list(const char *cmd __plt_unused,
     201                 :            :                               const char *params __plt_unused,
     202                 :            :                               struct plt_tel_data *d)
     203                 :            : {
     204                 :            :         struct npa_lf *lf;
     205                 :            :         int i;
     206                 :            : 
     207                 :          0 :         lf = idev_npa_obj_get();
     208         [ #  # ]:          0 :         if (lf == NULL)
     209                 :            :                 return NPA_ERR_DEVICE_NOT_BOUNDED;
     210                 :            : 
     211                 :          0 :         plt_tel_data_start_array(d, PLT_TEL_INT_VAL);
     212                 :            : 
     213         [ #  # ]:          0 :         for (i = 0; i < (int)lf->nr_pools; i++)
     214         [ #  # ]:          0 :                 if (!plt_bitmap_get(lf->npa_bmp, i))
     215                 :          0 :                         rte_tel_data_add_array_int(d, i);
     216                 :            : 
     217                 :            :         return 0;
     218                 :            : }
     219                 :            : 
     220                 :            : static int
     221                 :          0 : cnxk_npa_tel_handle_pool_list(const char *cmd, const char *params,
     222                 :            :                               struct plt_tel_data *d)
     223                 :            : {
     224                 :            :         /* In current implementation, aura and pool ID mapped 1:1 */
     225                 :          0 :         return cnxk_npa_tel_handle_aura_list(cmd, params, d);
     226                 :            : }
     227                 :            : 
     228                 :            : static int
     229                 :          0 : cnxk_npa_tel_handle_info_x(const char *cmd, const char *params,
     230                 :            :                            struct plt_tel_data *d)
     231                 :            : {
     232                 :            :         int id, rc;
     233                 :            : 
     234   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
     235                 :            :                 return -1;
     236                 :            : 
     237                 :          0 :         id = strtol(params, NULL, 10);
     238                 :          0 :         plt_tel_data_start_dict(d);
     239                 :            : 
     240         [ #  # ]:          0 :         if (strstr(cmd, "aura/info"))
     241                 :          0 :                 rc = cnxk_tel_npa_aura(id, d);
     242                 :            :         else
     243                 :          0 :                 rc = cnxk_tel_npa_pool(id, d);
     244                 :            : 
     245                 :            :         return rc;
     246                 :            : }
     247                 :            : 
     248                 :        252 : PLT_INIT(cnxk_telemetry_npa_init)
     249                 :            : {
     250                 :        252 :         plt_telemetry_register_cmd(
     251                 :            :                 "/cnxk/npa/info", cnxk_npa_tel_handle_info,
     252                 :            :                 "Returns npa information. Takes no parameters");
     253                 :            : 
     254                 :        252 :         plt_telemetry_register_cmd(
     255                 :            :                 "/cnxk/npa/aura/list", cnxk_npa_tel_handle_aura_list,
     256                 :            :                 "Returns list of npa aura id. Takes no parameters");
     257                 :            : 
     258                 :        252 :         plt_telemetry_register_cmd(
     259                 :            :                 "/cnxk/npa/aura/info", cnxk_npa_tel_handle_info_x,
     260                 :            :                 "Returns npa aura information. Parameters: aura_id");
     261                 :            : 
     262                 :        252 :         plt_telemetry_register_cmd(
     263                 :            :                 "/cnxk/npa/pool/list", cnxk_npa_tel_handle_pool_list,
     264                 :            :                 "Returns list of npa pool id. Takes no parameters");
     265                 :            : 
     266                 :        252 :         plt_telemetry_register_cmd(
     267                 :            :                 "/cnxk/npa/pool/info", cnxk_npa_tel_handle_info_x,
     268                 :            :                 "Returns npa pool information. Parameters: pool_id");
     269                 :        252 : }

Generated by: LCOV version 1.14