LCOV - code coverage report
Current view: top level - drivers/net/bnxt/tf_core - tf_tbl.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 256 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 138 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2019-2023 Broadcom
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : /* Truflow Table APIs and supporting code */
       7                 :            : 
       8                 :            : #include <rte_common.h>
       9                 :            : #include "tf_tbl.h"
      10                 :            : #include "tf_common.h"
      11                 :            : #include "tf_rm.h"
      12                 :            : #include "tf_util.h"
      13                 :            : #include "tf_msg.h"
      14                 :            : #include "tfp.h"
      15                 :            : #include "tf_session.h"
      16                 :            : #include "tf_device.h"
      17                 :            : 
      18                 :            : struct tf;
      19                 :            : 
      20                 :            : #define TF_TBL_RM_TO_PTR(new_idx, idx, base, shift) {           \
      21                 :            :                 *(new_idx) = (((idx) + (base)) << (shift));       \
      22                 :            : }
      23                 :            : 
      24                 :            : int
      25                 :          0 : tf_tbl_bind(struct tf *tfp,
      26                 :            :             struct tf_tbl_cfg_parms *parms)
      27                 :            : {
      28                 :            :         int rc, d, i;
      29                 :          0 :         int db_rc[TF_DIR_MAX] = { 0 };
      30                 :          0 :         struct tf_rm_create_db_parms db_cfg = { 0 };
      31                 :            :         struct tbl_rm_db *tbl_db;
      32                 :            :         struct tfp_calloc_parms cparms;
      33                 :            :         struct tf_session *tfs;
      34                 :            : 
      35         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
      36                 :            : 
      37                 :            :         /* Retrieve the session information */
      38                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
      39         [ #  # ]:          0 :         if (rc)
      40                 :            :                 return rc;
      41                 :            : 
      42                 :            :         memset(&db_cfg, 0, sizeof(db_cfg));
      43                 :          0 :         cparms.nitems = 1;
      44                 :          0 :         cparms.size = sizeof(struct tbl_rm_db);
      45                 :          0 :         cparms.alignment = 0;
      46         [ #  # ]:          0 :         if (tfp_calloc(&cparms) != 0) {
      47                 :          0 :                 TFP_DRV_LOG(ERR, "tbl_rm_db alloc error %s\n",
      48                 :            :                             strerror(ENOMEM));
      49                 :          0 :                 return -ENOMEM;
      50                 :            :         }
      51                 :            : 
      52                 :          0 :         tbl_db = cparms.mem_va;
      53         [ #  # ]:          0 :         for (i = 0; i < TF_DIR_MAX; i++)
      54                 :          0 :                 tbl_db->tbl_db[i] = NULL;
      55                 :          0 :         tf_session_set_db(tfp, TF_MODULE_TYPE_TABLE, tbl_db);
      56                 :            : 
      57                 :          0 :         db_cfg.num_elements = parms->num_elements;
      58                 :          0 :         db_cfg.module = TF_MODULE_TYPE_TABLE;
      59                 :            :         db_cfg.num_elements = parms->num_elements;
      60                 :            : 
      61         [ #  # ]:          0 :         for (d = 0; d < TF_DIR_MAX; d++) {
      62                 :          0 :                 db_cfg.dir = d;
      63         [ #  # ]:          0 :                 db_cfg.cfg = &parms->cfg[d ? TF_TBL_TYPE_MAX : 0];
      64                 :          0 :                 db_cfg.alloc_cnt = parms->resources->tbl_cnt[d].cnt;
      65                 :          0 :                 db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
      66   [ #  #  #  # ]:          0 :                 if (tf_session_is_shared_session(tfs) &&
      67                 :            :                         (!tf_session_is_shared_session_creator(tfs)))
      68                 :          0 :                         db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
      69                 :            :                 else
      70                 :          0 :                         db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
      71                 :            :         }
      72                 :            : 
      73                 :            :         /* No db created */
      74   [ #  #  #  # ]:          0 :         if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX]) {
      75                 :          0 :                 TFP_DRV_LOG(ERR,
      76                 :            :                             "%s: No Table DB created\n",
      77                 :            :                             tf_dir_2_str(d));
      78                 :          0 :                 return db_rc[TF_DIR_RX];
      79                 :            :         }
      80                 :            : 
      81                 :          0 :         TFP_DRV_LOG(INFO,
      82                 :            :                     "Table Type - initialized\n");
      83                 :            : 
      84                 :          0 :         return 0;
      85                 :            : }
      86                 :            : 
      87                 :            : int
      88                 :          0 : tf_tbl_unbind(struct tf *tfp)
      89                 :            : {
      90                 :            :         int rc;
      91                 :            :         int i;
      92                 :          0 :         struct tf_rm_free_db_parms fparms = { 0 };
      93                 :            :         struct tbl_rm_db *tbl_db;
      94                 :          0 :         void *tbl_db_ptr = NULL;
      95         [ #  # ]:          0 :         TF_CHECK_PARMS1(tfp);
      96                 :            : 
      97                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
      98         [ #  # ]:          0 :         if (rc)
      99                 :            :                 return 0;
     100                 :            : 
     101                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     102                 :            : 
     103         [ #  # ]:          0 :         for (i = 0; i < TF_DIR_MAX; i++) {
     104         [ #  # ]:          0 :                 if (tbl_db->tbl_db[i] == NULL)
     105                 :          0 :                         continue;
     106                 :          0 :                 fparms.dir = i;
     107                 :          0 :                 fparms.rm_db = tbl_db->tbl_db[i];
     108                 :          0 :                 rc = tf_rm_free_db(tfp, &fparms);
     109         [ #  # ]:          0 :                 if (rc)
     110                 :          0 :                         return rc;
     111                 :            : 
     112                 :          0 :                 tbl_db->tbl_db[i] = NULL;
     113                 :            :         }
     114                 :            : 
     115                 :            :         return 0;
     116                 :            : }
     117                 :            : 
     118                 :            : int
     119                 :          0 : tf_tbl_alloc(struct tf *tfp __rte_unused,
     120                 :            :              struct tf_tbl_alloc_parms *parms)
     121                 :            : {
     122                 :            :         int rc;
     123                 :            :         uint32_t idx;
     124                 :          0 :         struct tf_rm_allocate_parms aparms = { 0 };
     125                 :            :         struct tf_session *tfs;
     126                 :            :         struct tf_dev_info *dev;
     127                 :            :         struct tbl_rm_db *tbl_db;
     128                 :          0 :         void *tbl_db_ptr = NULL;
     129                 :            : 
     130         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     131                 :            : 
     132                 :            :         /* Retrieve the session information */
     133                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     134         [ #  # ]:          0 :         if (rc)
     135                 :            :                 return rc;
     136                 :            : 
     137                 :            :         /* Retrieve the device information */
     138                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     139         [ #  # ]:          0 :         if (rc)
     140                 :            :                 return rc;
     141                 :            : 
     142                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     143         [ #  # ]:          0 :         if (rc) {
     144                 :          0 :                 TFP_DRV_LOG(ERR,
     145                 :            :                             "Failed to get tbl_db from session, rc:%s\n",
     146                 :            :                             strerror(-rc));
     147                 :          0 :                 return rc;
     148                 :            :         }
     149                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     150                 :            : 
     151                 :            :         /* Allocate requested element */
     152                 :          0 :         aparms.rm_db = tbl_db->tbl_db[parms->dir];
     153                 :          0 :         aparms.subtype = parms->type;
     154                 :          0 :         aparms.index = &idx;
     155                 :          0 :         rc = tf_rm_allocate(&aparms);
     156         [ #  # ]:          0 :         if (rc) {
     157                 :          0 :                 TFP_DRV_LOG(ERR,
     158                 :            :                             "%s: Failed allocate, type:%s\n",
     159                 :            :                             tf_dir_2_str(parms->dir),
     160                 :            :                             tf_tbl_type_2_str(parms->type));
     161                 :          0 :                 return rc;
     162                 :            :         }
     163                 :            : 
     164                 :          0 :         *parms->idx = idx;
     165                 :            : 
     166                 :          0 :         return 0;
     167                 :            : }
     168                 :            : 
     169                 :            : int
     170                 :          0 : tf_tbl_free(struct tf *tfp __rte_unused,
     171                 :            :             struct tf_tbl_free_parms *parms)
     172                 :            : {
     173                 :            :         int rc;
     174                 :          0 :         struct tf_rm_is_allocated_parms aparms = { 0 };
     175                 :          0 :         struct tf_rm_free_parms fparms = { 0 };
     176                 :          0 :         int allocated = 0;
     177                 :            :         struct tf_session *tfs;
     178                 :            :         struct tf_dev_info *dev;
     179                 :            :         struct tbl_rm_db *tbl_db;
     180                 :          0 :         void *tbl_db_ptr = NULL;
     181                 :            : 
     182         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     183                 :            : 
     184                 :            :         /* Retrieve the session information */
     185                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     186         [ #  # ]:          0 :         if (rc)
     187                 :            :                 return rc;
     188                 :            : 
     189                 :            :         /* Retrieve the device information */
     190                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     191         [ #  # ]:          0 :         if (rc)
     192                 :            :                 return rc;
     193                 :            : 
     194                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     195         [ #  # ]:          0 :         if (rc) {
     196                 :          0 :                 TFP_DRV_LOG(ERR,
     197                 :            :                             "Failed to get em_ext_db from session, rc:%s\n",
     198                 :            :                             strerror(-rc));
     199                 :          0 :                 return rc;
     200                 :            :         }
     201                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     202                 :            : 
     203                 :            :         /* Check if element is in use */
     204                 :          0 :         aparms.rm_db = tbl_db->tbl_db[parms->dir];
     205                 :          0 :         aparms.subtype = parms->type;
     206                 :          0 :         aparms.index = parms->idx;
     207                 :          0 :         aparms.allocated = &allocated;
     208                 :          0 :         rc = tf_rm_is_allocated(&aparms);
     209         [ #  # ]:          0 :         if (rc)
     210                 :            :                 return rc;
     211                 :            : 
     212         [ #  # ]:          0 :         if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
     213                 :          0 :                 TFP_DRV_LOG(ERR,
     214                 :            :                             "%s: Entry already free, type:%s, index:%d\n",
     215                 :            :                             tf_dir_2_str(parms->dir),
     216                 :            :                             tf_tbl_type_2_str(parms->type),
     217                 :            :                             parms->idx);
     218                 :          0 :                 return -EINVAL;
     219                 :            :         }
     220                 :            : 
     221                 :            :         /* If this is counter table, clear the entry on free */
     222         [ #  # ]:          0 :         if (parms->type == TF_TBL_TYPE_ACT_STATS_64) {
     223                 :          0 :                 uint8_t data[8] = { 0 };
     224                 :          0 :                 uint16_t hcapi_type = 0;
     225                 :          0 :                 struct tf_rm_get_hcapi_parms hparms = { 0 };
     226                 :            : 
     227                 :            :                 /* Get the hcapi type */
     228                 :          0 :                 hparms.rm_db = tbl_db->tbl_db[parms->dir];
     229                 :          0 :                 hparms.subtype = parms->type;
     230                 :          0 :                 hparms.hcapi_type = &hcapi_type;
     231                 :          0 :                 rc = tf_rm_get_hcapi_type(&hparms);
     232         [ #  # ]:          0 :                 if (rc) {
     233                 :          0 :                         TFP_DRV_LOG(ERR,
     234                 :            :                                     "%s, Failed type lookup, type:%s, rc:%s\n",
     235                 :            :                                     tf_dir_2_str(parms->dir),
     236                 :            :                                     tf_tbl_type_2_str(parms->type),
     237                 :            :                                     strerror(-rc));
     238                 :          0 :                         return rc;
     239                 :            :                 }
     240                 :            :                 /* Clear the counter
     241                 :            :                  */
     242                 :          0 :                 rc = tf_msg_set_tbl_entry(tfp,
     243                 :            :                                           parms->dir,
     244                 :            :                                           hcapi_type,
     245                 :            :                                           sizeof(data),
     246                 :            :                                           data,
     247                 :            :                                           parms->idx);
     248         [ #  # ]:          0 :                 if (rc) {
     249                 :          0 :                         TFP_DRV_LOG(ERR,
     250                 :            :                                     "%s, Set failed, type:%s, rc:%s\n",
     251                 :            :                                     tf_dir_2_str(parms->dir),
     252                 :            :                                     tf_tbl_type_2_str(parms->type),
     253                 :            :                                     strerror(-rc));
     254                 :          0 :                         return rc;
     255                 :            :                 }
     256                 :            :         }
     257                 :            : 
     258                 :            :         /* Free requested element */
     259                 :          0 :         fparms.rm_db = tbl_db->tbl_db[parms->dir];
     260                 :          0 :         fparms.subtype = parms->type;
     261                 :          0 :         fparms.index = parms->idx;
     262                 :          0 :         rc = tf_rm_free(&fparms);
     263         [ #  # ]:          0 :         if (rc) {
     264                 :          0 :                 TFP_DRV_LOG(ERR,
     265                 :            :                             "%s: Free failed, type:%s, index:%d\n",
     266                 :            :                             tf_dir_2_str(parms->dir),
     267                 :            :                             tf_tbl_type_2_str(parms->type),
     268                 :            :                             parms->idx);
     269                 :          0 :                 return rc;
     270                 :            :         }
     271                 :            : 
     272                 :            :         return 0;
     273                 :            : }
     274                 :            : 
     275                 :            : int
     276                 :          0 : tf_tbl_set(struct tf *tfp,
     277                 :            :            struct tf_tbl_set_parms *parms)
     278                 :            : {
     279                 :            :         int rc;
     280                 :          0 :         int allocated = 0;
     281                 :            :         uint16_t hcapi_type;
     282                 :          0 :         struct tf_rm_is_allocated_parms aparms = { 0 };
     283                 :          0 :         struct tf_rm_get_hcapi_parms hparms = { 0 };
     284                 :            :         struct tf_session *tfs;
     285                 :            :         struct tf_dev_info *dev;
     286                 :            :         struct tbl_rm_db *tbl_db;
     287                 :          0 :         void *tbl_db_ptr = NULL;
     288                 :            : 
     289   [ #  #  #  # ]:          0 :         TF_CHECK_PARMS3(tfp, parms, parms->data);
     290                 :            : 
     291                 :            :         /* Retrieve the session information */
     292                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     293         [ #  # ]:          0 :         if (rc)
     294                 :            :                 return rc;
     295                 :            : 
     296                 :            :         /* Retrieve the device information */
     297                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     298         [ #  # ]:          0 :         if (rc)
     299                 :            :                 return rc;
     300                 :            : 
     301                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     302         [ #  # ]:          0 :         if (rc) {
     303                 :          0 :                 TFP_DRV_LOG(ERR,
     304                 :            :                             "Failed to get em_ext_db from session, rc:%s\n",
     305                 :            :                             strerror(-rc));
     306                 :          0 :                 return rc;
     307                 :            :         }
     308                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     309                 :            : 
     310                 :            :         /* Verify that the entry has been previously allocated.
     311                 :            :          * for meter drop counter, check the corresponding meter
     312                 :            :          * entry
     313                 :            :          */
     314                 :          0 :         aparms.rm_db = tbl_db->tbl_db[parms->dir];
     315         [ #  # ]:          0 :         if (parms->type != TF_TBL_TYPE_METER_DROP_CNT)
     316                 :          0 :                 aparms.subtype = parms->type;
     317                 :            :         else
     318                 :          0 :                 aparms.subtype = TF_TBL_TYPE_METER_INST;
     319                 :          0 :         aparms.allocated = &allocated;
     320                 :          0 :         aparms.index = parms->idx;
     321                 :          0 :         rc = tf_rm_is_allocated(&aparms);
     322         [ #  # ]:          0 :         if (rc)
     323                 :            :                 return rc;
     324                 :            : 
     325         [ #  # ]:          0 :         if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
     326                 :          0 :                 TFP_DRV_LOG(ERR,
     327                 :            :                       "%s, Invalid or not allocated, type:%s, idx:%d\n",
     328                 :            :                       tf_dir_2_str(parms->dir),
     329                 :            :                       tf_tbl_type_2_str(parms->type),
     330                 :            :                       parms->idx);
     331                 :          0 :                 return -EINVAL;
     332                 :            :         }
     333                 :            : 
     334                 :            :         /* Set the entry */
     335                 :          0 :         hparms.rm_db = tbl_db->tbl_db[parms->dir];
     336                 :          0 :         hparms.subtype = parms->type;
     337                 :          0 :         hparms.hcapi_type = &hcapi_type;
     338                 :          0 :         rc = tf_rm_get_hcapi_type(&hparms);
     339         [ #  # ]:          0 :         if (rc) {
     340                 :          0 :                 TFP_DRV_LOG(ERR,
     341                 :            :                             "%s, Failed type lookup, type:%s, rc:%s\n",
     342                 :            :                             tf_dir_2_str(parms->dir),
     343                 :            :                             tf_tbl_type_2_str(parms->type),
     344                 :            :                             strerror(-rc));
     345                 :          0 :                 return rc;
     346                 :            :         }
     347                 :            : 
     348                 :          0 :         rc = tf_msg_set_tbl_entry(tfp,
     349                 :            :                                   parms->dir,
     350                 :            :                                   hcapi_type,
     351                 :          0 :                                   parms->data_sz_in_bytes,
     352                 :            :                                   parms->data,
     353                 :            :                                   parms->idx);
     354         [ #  # ]:          0 :         if (rc) {
     355                 :          0 :                 TFP_DRV_LOG(ERR,
     356                 :            :                             "%s, Set failed, type:%s, rc:%s\n",
     357                 :            :                             tf_dir_2_str(parms->dir),
     358                 :            :                             tf_tbl_type_2_str(parms->type),
     359                 :            :                             strerror(-rc));
     360                 :          0 :                 return rc;
     361                 :            :         }
     362                 :            : 
     363                 :            :         return 0;
     364                 :            : }
     365                 :            : 
     366                 :            : int
     367                 :          0 : tf_tbl_get(struct tf *tfp,
     368                 :            :            struct tf_tbl_get_parms *parms)
     369                 :            : {
     370                 :            :         int rc;
     371                 :            :         uint16_t hcapi_type;
     372                 :          0 :         int allocated = 0;
     373                 :          0 :         struct tf_rm_is_allocated_parms aparms = { 0 };
     374                 :          0 :         struct tf_rm_get_hcapi_parms hparms = { 0 };
     375                 :            :         struct tf_session *tfs;
     376                 :            :         struct tf_dev_info *dev;
     377                 :            :         struct tbl_rm_db *tbl_db;
     378                 :          0 :         void *tbl_db_ptr = NULL;
     379                 :            : 
     380   [ #  #  #  # ]:          0 :         TF_CHECK_PARMS3(tfp, parms, parms->data);
     381                 :            : 
     382                 :            :         /* Retrieve the session information */
     383                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     384         [ #  # ]:          0 :         if (rc)
     385                 :            :                 return rc;
     386                 :            : 
     387                 :            :         /* Retrieve the device information */
     388                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     389         [ #  # ]:          0 :         if (rc)
     390                 :            :                 return rc;
     391                 :            : 
     392                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     393         [ #  # ]:          0 :         if (rc) {
     394                 :          0 :                 TFP_DRV_LOG(ERR,
     395                 :            :                             "Failed to get em_ext_db from session, rc:%s\n",
     396                 :            :                             strerror(-rc));
     397                 :          0 :                 return rc;
     398                 :            :         }
     399                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     400                 :            : 
     401                 :            :         /* Verify that the entry has been previously allocated.
     402                 :            :          * for meter drop counter, check the corresponding meter
     403                 :            :          * entry
     404                 :            :          */
     405                 :          0 :         aparms.rm_db = tbl_db->tbl_db[parms->dir];
     406         [ #  # ]:          0 :         if (parms->type != TF_TBL_TYPE_METER_DROP_CNT)
     407                 :          0 :                 aparms.subtype = parms->type;
     408                 :            :         else
     409                 :          0 :                 aparms.subtype = TF_TBL_TYPE_METER_INST;
     410                 :          0 :         aparms.index = parms->idx;
     411                 :          0 :         aparms.allocated = &allocated;
     412                 :          0 :         rc = tf_rm_is_allocated(&aparms);
     413         [ #  # ]:          0 :         if (rc)
     414                 :            :                 return rc;
     415                 :            : 
     416         [ #  # ]:          0 :         if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
     417                 :          0 :                 TFP_DRV_LOG(ERR,
     418                 :            :                    "%s, Invalid or not allocated index, type:%s, idx:%d\n",
     419                 :            :                    tf_dir_2_str(parms->dir),
     420                 :            :                    tf_tbl_type_2_str(parms->type),
     421                 :            :                    parms->idx);
     422                 :          0 :                 return -EINVAL;
     423                 :            :         }
     424                 :            : 
     425                 :            :         /* Set the entry */
     426                 :          0 :         hparms.rm_db = tbl_db->tbl_db[parms->dir];
     427                 :          0 :         hparms.subtype = parms->type;
     428                 :          0 :         hparms.hcapi_type = &hcapi_type;
     429                 :          0 :         rc = tf_rm_get_hcapi_type(&hparms);
     430         [ #  # ]:          0 :         if (rc) {
     431                 :          0 :                 TFP_DRV_LOG(ERR,
     432                 :            :                             "%s, Failed type lookup, type:%s, rc:%s\n",
     433                 :            :                             tf_dir_2_str(parms->dir),
     434                 :            :                             tf_tbl_type_2_str(parms->type),
     435                 :            :                             strerror(-rc));
     436                 :          0 :                 return rc;
     437                 :            :         }
     438                 :            : 
     439                 :            :         /* Get the entry */
     440                 :          0 :         rc = tf_msg_get_tbl_entry(tfp,
     441                 :            :                                   parms->dir,
     442                 :            :                                   hcapi_type,
     443                 :          0 :                                   parms->data_sz_in_bytes,
     444                 :            :                                   parms->data,
     445                 :            :                                   parms->idx,
     446                 :            :                                   false);
     447         [ #  # ]:          0 :         if (rc) {
     448                 :          0 :                 TFP_DRV_LOG(ERR,
     449                 :            :                             "%s, Get failed, type:%s, rc:%s\n",
     450                 :            :                             tf_dir_2_str(parms->dir),
     451                 :            :                             tf_tbl_type_2_str(parms->type),
     452                 :            :                             strerror(-rc));
     453                 :          0 :                 return rc;
     454                 :            :         }
     455                 :            : 
     456                 :            :         return 0;
     457                 :            : }
     458                 :            : 
     459                 :            : int
     460                 :          0 : tf_tbl_bulk_get(struct tf *tfp,
     461                 :            :                 struct tf_tbl_get_bulk_parms *parms)
     462                 :            : {
     463                 :            :         int rc;
     464                 :            :         uint16_t hcapi_type;
     465                 :          0 :         struct tf_rm_get_hcapi_parms hparms = { 0 };
     466                 :          0 :         struct tf_rm_check_indexes_in_range_parms cparms = { 0 };
     467                 :            :         struct tf_session *tfs;
     468                 :            :         struct tf_dev_info *dev;
     469                 :            :         struct tbl_rm_db *tbl_db;
     470                 :          0 :         void *tbl_db_ptr = NULL;
     471                 :            : 
     472         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     473                 :            : 
     474                 :            :         /* Retrieve the session information */
     475                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     476         [ #  # ]:          0 :         if (rc)
     477                 :            :                 return rc;
     478                 :            : 
     479                 :            :         /* Retrieve the device information */
     480                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     481         [ #  # ]:          0 :         if (rc)
     482                 :            :                 return rc;
     483                 :            : 
     484                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     485         [ #  # ]:          0 :         if (rc) {
     486                 :          0 :                 TFP_DRV_LOG(ERR,
     487                 :            :                             "Failed to get em_ext_db from session, rc:%s\n",
     488                 :            :                             strerror(-rc));
     489                 :          0 :                 return rc;
     490                 :            :         }
     491                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     492                 :            : 
     493                 :            :         /* Verify that the entries are in the range of reserved resources. */
     494                 :          0 :         cparms.rm_db = tbl_db->tbl_db[parms->dir];
     495                 :          0 :         cparms.subtype = parms->type;
     496                 :          0 :         cparms.num_entries = parms->num_entries;
     497                 :          0 :         cparms.starting_index = parms->starting_idx;
     498                 :            : 
     499                 :          0 :         rc = tf_rm_check_indexes_in_range(&cparms);
     500         [ #  # ]:          0 :         if (rc) {
     501                 :          0 :                 TFP_DRV_LOG(ERR,
     502                 :            :                             "%s, Invalid or %d index starting from %d"
     503                 :            :                             " not in range, type:%s",
     504                 :            :                             tf_dir_2_str(parms->dir),
     505                 :            :                             parms->starting_idx,
     506                 :            :                             parms->num_entries,
     507                 :            :                             tf_tbl_type_2_str(parms->type));
     508                 :          0 :                 return rc;
     509                 :            :         }
     510                 :            : 
     511                 :          0 :         hparms.rm_db = tbl_db->tbl_db[parms->dir];
     512                 :          0 :         hparms.subtype = parms->type;
     513                 :          0 :         hparms.hcapi_type = &hcapi_type;
     514                 :          0 :         rc = tf_rm_get_hcapi_type(&hparms);
     515         [ #  # ]:          0 :         if (rc) {
     516                 :          0 :                 TFP_DRV_LOG(ERR,
     517                 :            :                             "%s, Failed type lookup, type:%s, rc:%s\n",
     518                 :            :                             tf_dir_2_str(parms->dir),
     519                 :            :                             tf_tbl_type_2_str(parms->type),
     520                 :            :                             strerror(-rc));
     521                 :          0 :                 return rc;
     522                 :            :         }
     523                 :            : 
     524                 :            :         /* Get the entries */
     525                 :          0 :         rc = tf_msg_bulk_get_tbl_entry(tfp,
     526                 :            :                                        parms->dir,
     527                 :            :                                        hcapi_type,
     528                 :            :                                        parms->starting_idx,
     529                 :          0 :                                        parms->num_entries,
     530                 :          0 :                                        parms->entry_sz_in_bytes,
     531                 :            :                                        parms->physical_mem_addr,
     532                 :            :                                        false);
     533         [ #  # ]:          0 :         if (rc) {
     534                 :          0 :                 TFP_DRV_LOG(ERR,
     535                 :            :                             "%s, Bulk get failed, type:%s, rc:%s\n",
     536                 :            :                             tf_dir_2_str(parms->dir),
     537                 :            :                             tf_tbl_type_2_str(parms->type),
     538                 :            :                             strerror(-rc));
     539                 :            :         }
     540                 :            : 
     541                 :            :         return rc;
     542                 :            : }
     543                 :            : 
     544                 :            : int
     545                 :          0 : tf_tbl_get_resc_info(struct tf *tfp,
     546                 :            :                      struct tf_tbl_resource_info *tbl)
     547                 :            : {
     548                 :            :         int rc;
     549                 :            :         int d, i;
     550                 :            :         struct tf_resource_info *dinfo;
     551                 :            :         struct tf_rm_get_alloc_info_parms ainfo;
     552                 :          0 :         void *tbl_db_ptr = NULL;
     553                 :            :         struct tbl_rm_db *tbl_db;
     554                 :            :         struct tf_dev_info *dev;
     555                 :            :         struct tf_session *tfs;
     556                 :          0 :         uint16_t base = 0, shift = 0;
     557                 :            : 
     558         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, tbl);
     559                 :            : 
     560                 :            :         /* Retrieve the session information */
     561                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     562         [ #  # ]:          0 :         if (rc)
     563                 :            :                 return rc;
     564                 :            : 
     565                 :            :         /* Retrieve the device information */
     566                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     567         [ #  # ]:          0 :         if (rc)
     568                 :            :                 return rc;
     569                 :            : 
     570                 :          0 :         rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TABLE, &tbl_db_ptr);
     571         [ #  # ]:          0 :         if (rc == -ENOMEM)
     572                 :            :                 return 0; /* db doesn't exist */
     573         [ #  # ]:          0 :         else if (rc)
     574                 :            :                 return rc; /* error getting db */
     575                 :            : 
     576                 :          0 :         tbl_db = (struct tbl_rm_db *)tbl_db_ptr;
     577                 :            : 
     578         [ #  # ]:          0 :         for (d = 0; d < TF_DIR_MAX; d++) {
     579                 :          0 :                 ainfo.rm_db = tbl_db->tbl_db[d];
     580                 :          0 :                 dinfo = tbl[d].info;
     581                 :            : 
     582         [ #  # ]:          0 :                 if (!ainfo.rm_db)
     583                 :          0 :                         continue;
     584                 :            : 
     585                 :          0 :                 ainfo.info = (struct tf_rm_alloc_info *)dinfo;
     586                 :          0 :                 ainfo.subtype = 0;
     587                 :          0 :                 rc = tf_rm_get_all_info(&ainfo, TF_TBL_TYPE_MAX);
     588         [ #  # ]:          0 :                 if (rc)
     589                 :          0 :                         return rc;
     590                 :            : 
     591         [ #  # ]:          0 :                 if (dev->ops->tf_dev_get_tbl_info) {
     592                 :            :                         /* Adjust all */
     593         [ #  # ]:          0 :                         for (i = 0; i < TF_TBL_TYPE_MAX; i++) {
     594                 :            :                                 /* Only get table info if required for the device */
     595                 :          0 :                                 rc = dev->ops->tf_dev_get_tbl_info(tfp,
     596                 :          0 :                                                                    tbl_db->tbl_db[d],
     597                 :            :                                                                    i,
     598                 :            :                                                                    &base,
     599                 :            :                                                                    &shift);
     600         [ #  # ]:          0 :                                 if (rc) {
     601                 :          0 :                                         TFP_DRV_LOG(ERR,
     602                 :            :                                                     "%s: Failed to get table info:%d\n",
     603                 :            :                                                     tf_dir_2_str(d),
     604                 :            :                                                     i);
     605                 :          0 :                                         return rc;
     606                 :            :                                 }
     607         [ #  # ]:          0 :                                 if (dinfo[i].stride)
     608                 :          0 :                                         TF_TBL_RM_TO_PTR(&dinfo[i].start,
     609                 :            :                                                          dinfo[i].start,
     610                 :            :                                                          base,
     611                 :            :                                                          shift);
     612                 :            :                         }
     613                 :            :                 }
     614                 :            :         }
     615                 :            : 
     616                 :            :         return 0;
     617                 :            : }

Generated by: LCOV version 1.14