LCOV - code coverage report
Current view: top level - drivers/net/bnxt/tf_core - tf_core.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 734 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 35 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 394 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                 :            : #include <stdio.h>
       7                 :            : 
       8                 :            : #include "tf_core.h"
       9                 :            : #include "tf_util.h"
      10                 :            : #include "tf_session.h"
      11                 :            : #include "tf_tbl.h"
      12                 :            : #include "tf_em.h"
      13                 :            : #include "tf_rm.h"
      14                 :            : #include "tf_global_cfg.h"
      15                 :            : #include "tf_msg.h"
      16                 :            : #include "tfp.h"
      17                 :            : #include "bitalloc.h"
      18                 :            : #include "bnxt.h"
      19                 :            : #include "rand.h"
      20                 :            : #include "tf_common.h"
      21                 :            : #include "tf_ext_flow_handle.h"
      22                 :            : 
      23                 :            : int
      24                 :          0 : tf_open_session(struct tf *tfp,
      25                 :            :                 struct tf_open_session_parms *parms)
      26                 :            : {
      27                 :            :         int rc;
      28                 :            :         unsigned int domain, bus, slot, device;
      29                 :            :         struct tf_session_open_session_parms oparms;
      30                 :            : 
      31         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
      32                 :            : 
      33                 :            :         /* Filter out any non-supported device types on the Core
      34                 :            :          * side. It is assumed that the Firmware will be supported if
      35                 :            :          * firmware open session succeeds.
      36                 :            :          */
      37         [ #  # ]:          0 :         if (parms->device_type != TF_DEVICE_TYPE_P4 &&
      38         [ #  # ]:          0 :             parms->device_type != TF_DEVICE_TYPE_P5 &&
      39                 :            :             parms->device_type != TF_DEVICE_TYPE_SR) {
      40                 :          0 :                 TFP_DRV_LOG(ERR,
      41                 :            :                             "Unsupported device type %d\n",
      42                 :            :                             parms->device_type);
      43                 :          0 :                 return -ENOTSUP;
      44                 :            :         }
      45                 :            : 
      46                 :            :         /* Verify control channel and build the beginning of session_id */
      47                 :          0 :         rc = sscanf(parms->ctrl_chan_name,
      48                 :            :                     "%x:%x:%x.%u",
      49                 :            :                     &domain,
      50                 :            :                     &bus,
      51                 :            :                     &slot,
      52                 :            :                     &device);
      53         [ #  # ]:          0 :         if (rc != 4) {
      54                 :            :                 /* PCI Domain not provided (optional in DPDK), thus we
      55                 :            :                  * force domain to 0 and recheck.
      56                 :            :                  */
      57                 :          0 :                 domain = 0;
      58                 :            : 
      59                 :            :                 /* Check parsing of bus/slot/device */
      60                 :          0 :                 rc = sscanf(parms->ctrl_chan_name,
      61                 :            :                             "%x:%x.%u",
      62                 :            :                             &bus,
      63                 :            :                             &slot,
      64                 :            :                             &device);
      65         [ #  # ]:          0 :                 if (rc != 3) {
      66                 :          0 :                         TFP_DRV_LOG(ERR,
      67                 :            :                             "Failed to scan device ctrl_chan_name\n");
      68                 :          0 :                         return -EINVAL;
      69                 :            :                 }
      70                 :            :         }
      71                 :            : 
      72                 :          0 :         parms->session_id.internal.domain = domain;
      73                 :          0 :         parms->session_id.internal.bus = bus;
      74                 :          0 :         parms->session_id.internal.device = device;
      75                 :          0 :         oparms.open_cfg = parms;
      76                 :            : 
      77                 :            :         /* Session vs session client is decided in
      78                 :            :          * tf_session_open_session()
      79                 :            :          */
      80                 :          0 :         rc = tf_session_open_session(tfp, &oparms);
      81                 :            :         /* Logging handled by tf_session_open_session */
      82         [ #  # ]:          0 :         if (rc)
      83                 :            :                 return rc;
      84                 :            : 
      85                 :          0 :         TFP_DRV_LOG(INFO,
      86                 :            :                     "domain:%x, bus:%x, device:%u\n",
      87                 :            :                     parms->session_id.internal.domain,
      88                 :            :                     parms->session_id.internal.bus,
      89                 :            :                     parms->session_id.internal.device);
      90                 :            : 
      91                 :          0 :         return 0;
      92                 :            : }
      93                 :            : 
      94                 :            : int
      95                 :          0 : tf_attach_session(struct tf *tfp,
      96                 :            :                   struct tf_attach_session_parms *parms)
      97                 :            : {
      98                 :            :         int rc;
      99                 :            :         unsigned int domain, bus, slot, device;
     100                 :            :         struct tf_session_attach_session_parms aparms;
     101                 :            : 
     102         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     103                 :            : 
     104                 :            :         /* Verify control channel */
     105                 :          0 :         rc = sscanf(parms->ctrl_chan_name,
     106                 :            :                     "%x:%x:%x.%u",
     107                 :            :                     &domain,
     108                 :            :                     &bus,
     109                 :            :                     &slot,
     110                 :            :                     &device);
     111         [ #  # ]:          0 :         if (rc != 4) {
     112                 :          0 :                 TFP_DRV_LOG(ERR,
     113                 :            :                             "Failed to scan device ctrl_chan_name\n");
     114                 :          0 :                 return -EINVAL;
     115                 :            :         }
     116                 :            : 
     117                 :            :         /* Verify 'attach' channel */
     118                 :          0 :         rc = sscanf(parms->attach_chan_name,
     119                 :            :                     "%x:%x:%x.%u",
     120                 :            :                     &domain,
     121                 :            :                     &bus,
     122                 :            :                     &slot,
     123                 :            :                     &device);
     124         [ #  # ]:          0 :         if (rc != 4) {
     125                 :          0 :                 TFP_DRV_LOG(ERR,
     126                 :            :                             "Failed to scan device attach_chan_name\n");
     127                 :          0 :                 return -EINVAL;
     128                 :            :         }
     129                 :            : 
     130                 :            :         /* Prepare return value of session_id, using ctrl_chan_name
     131                 :            :          * device values as it becomes the session id.
     132                 :            :          */
     133                 :          0 :         parms->session_id.internal.domain = domain;
     134                 :          0 :         parms->session_id.internal.bus = bus;
     135                 :          0 :         parms->session_id.internal.device = device;
     136                 :          0 :         aparms.attach_cfg = parms;
     137                 :          0 :         rc = tf_session_attach_session(tfp,
     138                 :            :                                        &aparms);
     139                 :            :         /* Logging handled by dev_bind */
     140         [ #  # ]:          0 :         if (rc)
     141                 :            :                 return rc;
     142                 :            : 
     143                 :          0 :         TFP_DRV_LOG(INFO,
     144                 :            :                     "Attached to session, session_id:%d\n",
     145                 :            :                     parms->session_id.id);
     146                 :            : 
     147                 :          0 :         TFP_DRV_LOG(INFO,
     148                 :            :                     "domain:%d, bus:%d, device:%d, fw_session_id:%d\n",
     149                 :            :                     parms->session_id.internal.domain,
     150                 :            :                     parms->session_id.internal.bus,
     151                 :            :                     parms->session_id.internal.device,
     152                 :            :                     parms->session_id.internal.fw_session_id);
     153                 :            : 
     154                 :          0 :         return rc;
     155                 :            : }
     156                 :            : 
     157                 :            : int
     158                 :          0 : tf_close_session(struct tf *tfp)
     159                 :            : {
     160                 :            :         int rc;
     161                 :          0 :         struct tf_session_close_session_parms cparms = { 0 };
     162                 :          0 :         union tf_session_id session_id = { 0 };
     163                 :            :         uint8_t ref_count;
     164                 :            : 
     165         [ #  # ]:          0 :         TF_CHECK_PARMS1(tfp);
     166                 :            : 
     167                 :          0 :         cparms.ref_count = &ref_count;
     168                 :          0 :         cparms.session_id = &session_id;
     169                 :            :         /* Session vs session client is decided in
     170                 :            :          * tf_session_close_session()
     171                 :            :          */
     172                 :          0 :         rc = tf_session_close_session(tfp,
     173                 :            :                                       &cparms);
     174                 :            :         /* Logging handled by tf_session_close_session */
     175         [ #  # ]:          0 :         if (rc)
     176                 :            :                 return rc;
     177                 :            : 
     178                 :          0 :         TFP_DRV_LOG(INFO,
     179                 :            :                     "domain:%d, bus:%x, device:%d\n",
     180                 :            :                     cparms.session_id->internal.domain,
     181                 :            :                     cparms.session_id->internal.bus,
     182                 :            :                     cparms.session_id->internal.device);
     183                 :            : 
     184                 :          0 :         return rc;
     185                 :            : }
     186                 :            : 
     187                 :            : /** insert EM hash entry API
     188                 :            :  *
     189                 :            :  *    returns:
     190                 :            :  *    0       - Success
     191                 :            :  *    -EINVAL - Error
     192                 :            :  */
     193                 :          0 : int tf_insert_em_entry(struct tf *tfp,
     194                 :            :                        struct tf_insert_em_entry_parms *parms)
     195                 :            : {
     196                 :            :         struct tf_session      *tfs;
     197                 :            :         struct tf_dev_info     *dev;
     198                 :            :         int rc;
     199                 :            : 
     200         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     201                 :            : 
     202                 :            :         /* Retrieve the session information */
     203                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     204         [ #  # ]:          0 :         if (rc) {
     205                 :          0 :                 TFP_DRV_LOG(ERR,
     206                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     207                 :            :                             tf_dir_2_str(parms->dir),
     208                 :            :                             strerror(-rc));
     209                 :          0 :                 return rc;
     210                 :            :         }
     211                 :            : 
     212                 :            :         /* Retrieve the device information */
     213                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     214         [ #  # ]:          0 :         if (rc) {
     215                 :          0 :                 TFP_DRV_LOG(ERR,
     216                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     217                 :            :                             tf_dir_2_str(parms->dir),
     218                 :            :                             strerror(-rc));
     219                 :          0 :                 return rc;
     220                 :            :         }
     221                 :            : 
     222         [ #  # ]:          0 :         if (parms->mem == TF_MEM_EXTERNAL &&
     223         [ #  # ]:          0 :                 dev->ops->tf_dev_insert_ext_em_entry != NULL)
     224                 :          0 :                 rc = dev->ops->tf_dev_insert_ext_em_entry(tfp, parms);
     225         [ #  # ]:          0 :         else if (parms->mem == TF_MEM_INTERNAL &&
     226         [ #  # ]:          0 :                 dev->ops->tf_dev_insert_int_em_entry != NULL)
     227                 :          0 :                 rc = dev->ops->tf_dev_insert_int_em_entry(tfp, parms);
     228                 :            :         else
     229                 :            :                 return -EINVAL;
     230                 :            : 
     231         [ #  # ]:          0 :         if (rc) {
     232                 :          0 :                 TFP_DRV_LOG(ERR,
     233                 :            :                             "%s: EM insert failed, rc:%s\n",
     234                 :            :                             tf_dir_2_str(parms->dir),
     235                 :            :                             strerror(-rc));
     236                 :          0 :                 return rc;
     237                 :            :         }
     238                 :            : 
     239                 :            :         return 0;
     240                 :            : }
     241                 :            : 
     242                 :            : /** Delete EM hash entry API
     243                 :            :  *
     244                 :            :  *    returns:
     245                 :            :  *    0       - Success
     246                 :            :  *    -EINVAL - Error
     247                 :            :  */
     248                 :          0 : int tf_delete_em_entry(struct tf *tfp,
     249                 :            :                        struct tf_delete_em_entry_parms *parms)
     250                 :            : {
     251                 :            :         struct tf_session      *tfs;
     252                 :            :         struct tf_dev_info     *dev;
     253                 :            :         int rc;
     254                 :            :         unsigned int flag = 0;
     255                 :            : 
     256         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     257                 :            : 
     258                 :            :         /* Retrieve the session information */
     259                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     260         [ #  # ]:          0 :         if (rc) {
     261                 :          0 :                 TFP_DRV_LOG(ERR,
     262                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     263                 :            :                             tf_dir_2_str(parms->dir),
     264                 :            :                             strerror(-rc));
     265                 :          0 :                 return rc;
     266                 :            :         }
     267                 :            : 
     268                 :            :         /* Retrieve the device information */
     269                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     270         [ #  # ]:          0 :         if (rc) {
     271                 :          0 :                 TFP_DRV_LOG(ERR,
     272                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     273                 :            :                             tf_dir_2_str(parms->dir),
     274                 :            :                             strerror(-rc));
     275                 :          0 :                 return rc;
     276                 :            :         }
     277                 :            : 
     278                 :          0 :         TF_GET_FLAG_FROM_FLOW_HANDLE(parms->flow_handle, flag);
     279         [ #  # ]:          0 :         if ((flag & TF_FLAGS_FLOW_HANDLE_INTERNAL))
     280                 :          0 :                 rc = dev->ops->tf_dev_delete_int_em_entry(tfp, parms);
     281                 :            :         else
     282                 :          0 :                 rc = dev->ops->tf_dev_delete_ext_em_entry(tfp, parms);
     283                 :            : 
     284         [ #  # ]:          0 :         if (rc) {
     285                 :          0 :                 TFP_DRV_LOG(ERR,
     286                 :            :                             "%s: EM delete failed, rc:%s\n",
     287                 :            :                             tf_dir_2_str(parms->dir),
     288                 :            :                             strerror(-rc));
     289                 :          0 :                 return rc;
     290                 :            :         }
     291                 :            : 
     292                 :            :         return rc;
     293                 :            : }
     294                 :            : 
     295                 :            : /** Get global configuration API
     296                 :            :  *
     297                 :            :  *    returns:
     298                 :            :  *    0       - Success
     299                 :            :  *    -EINVAL - Error
     300                 :            :  */
     301                 :          0 : int tf_get_global_cfg(struct tf *tfp,
     302                 :            :                       struct tf_global_cfg_parms *parms)
     303                 :            : {
     304                 :            :         int rc = 0;
     305                 :            :         struct tf_session *tfs;
     306                 :            :         struct tf_dev_info *dev;
     307                 :            : 
     308         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     309                 :            : 
     310                 :            :         /* Retrieve the session information */
     311                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     312         [ #  # ]:          0 :         if (rc) {
     313                 :          0 :                 TFP_DRV_LOG(ERR,
     314                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     315                 :            :                             tf_dir_2_str(parms->dir),
     316                 :            :                             strerror(-rc));
     317                 :          0 :                 return rc;
     318                 :            :         }
     319                 :            : 
     320                 :            :         /* Retrieve the device information */
     321                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     322         [ #  # ]:          0 :         if (rc) {
     323                 :          0 :                 TFP_DRV_LOG(ERR,
     324                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     325                 :            :                             tf_dir_2_str(parms->dir),
     326                 :            :                             strerror(-rc));
     327                 :          0 :                 return rc;
     328                 :            :         }
     329                 :            : 
     330         [ #  # ]:          0 :         if (parms->config == NULL ||
     331         [ #  # ]:          0 :            parms->config_sz_in_bytes == 0) {
     332                 :          0 :                 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
     333                 :          0 :                 return -EINVAL;
     334                 :            :         }
     335                 :            : 
     336         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_global_cfg == NULL) {
     337                 :            :                 rc = -EOPNOTSUPP;
     338                 :          0 :                 TFP_DRV_LOG(ERR,
     339                 :            :                             "%s: Operation not supported, rc:%s\n",
     340                 :            :                             tf_dir_2_str(parms->dir),
     341                 :            :                             strerror(-rc));
     342                 :          0 :                 return -EOPNOTSUPP;
     343                 :            :         }
     344                 :            : 
     345                 :          0 :         rc = dev->ops->tf_dev_get_global_cfg(tfp, parms);
     346         [ #  # ]:          0 :         if (rc) {
     347                 :          0 :                 TFP_DRV_LOG(ERR,
     348                 :            :                             "%s: Global Cfg get failed, rc:%s\n",
     349                 :            :                             tf_dir_2_str(parms->dir),
     350                 :            :                             strerror(-rc));
     351                 :          0 :                 return rc;
     352                 :            :         }
     353                 :            : 
     354                 :            :         return rc;
     355                 :            : }
     356                 :            : 
     357                 :            : /** Set global configuration API
     358                 :            :  *
     359                 :            :  *    returns:
     360                 :            :  *    0       - Success
     361                 :            :  *    -EINVAL - Error
     362                 :            :  */
     363                 :          0 : int tf_set_global_cfg(struct tf *tfp,
     364                 :            :                       struct tf_global_cfg_parms *parms)
     365                 :            : {
     366                 :            :         int rc = 0;
     367                 :            :         struct tf_session *tfs;
     368                 :            :         struct tf_dev_info *dev;
     369                 :            : 
     370         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     371                 :            : 
     372                 :            :         /* Retrieve the session information */
     373                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     374         [ #  # ]:          0 :         if (rc) {
     375                 :          0 :                 TFP_DRV_LOG(ERR,
     376                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     377                 :            :                             tf_dir_2_str(parms->dir),
     378                 :            :                             strerror(-rc));
     379                 :          0 :                 return rc;
     380                 :            :         }
     381                 :            : 
     382                 :            :         /* Retrieve the device information */
     383                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     384         [ #  # ]:          0 :         if (rc) {
     385                 :          0 :                 TFP_DRV_LOG(ERR,
     386                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     387                 :            :                             tf_dir_2_str(parms->dir),
     388                 :            :                             strerror(-rc));
     389                 :          0 :                 return rc;
     390                 :            :         }
     391                 :            : 
     392         [ #  # ]:          0 :         if (parms->config == NULL ||
     393         [ #  # ]:          0 :            parms->config_sz_in_bytes == 0) {
     394                 :          0 :                 TFP_DRV_LOG(ERR, "Invalid Argument(s)\n");
     395                 :          0 :                 return -EINVAL;
     396                 :            :         }
     397                 :            : 
     398         [ #  # ]:          0 :         if (dev->ops->tf_dev_set_global_cfg == NULL) {
     399                 :            :                 rc = -EOPNOTSUPP;
     400                 :          0 :                 TFP_DRV_LOG(ERR,
     401                 :            :                             "%s: Operation not supported, rc:%s\n",
     402                 :            :                             tf_dir_2_str(parms->dir),
     403                 :            :                             strerror(-rc));
     404                 :          0 :                 return -EOPNOTSUPP;
     405                 :            :         }
     406                 :            : 
     407                 :          0 :         rc = dev->ops->tf_dev_set_global_cfg(tfp, parms);
     408         [ #  # ]:          0 :         if (rc) {
     409                 :          0 :                 TFP_DRV_LOG(ERR,
     410                 :            :                             "%s: Global Cfg set failed, rc:%s\n",
     411                 :            :                             tf_dir_2_str(parms->dir),
     412                 :            :                             strerror(-rc));
     413                 :          0 :                 return rc;
     414                 :            :         }
     415                 :            : 
     416                 :            :         return rc;
     417                 :            : }
     418                 :            : 
     419                 :            : int
     420                 :          0 : tf_alloc_identifier(struct tf *tfp,
     421                 :            :                     struct tf_alloc_identifier_parms *parms)
     422                 :            : {
     423                 :            :         int rc;
     424                 :            :         struct tf_session *tfs;
     425                 :            :         struct tf_dev_info *dev;
     426                 :            :         struct tf_ident_alloc_parms aparms;
     427                 :            :         uint16_t id;
     428                 :            : 
     429         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     430                 :            : 
     431                 :            :         /* Can't do static initialization due to UT enum check */
     432                 :            :         memset(&aparms, 0, sizeof(struct tf_ident_alloc_parms));
     433                 :            : 
     434                 :            :         /* Retrieve the session information */
     435                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     436         [ #  # ]:          0 :         if (rc) {
     437                 :          0 :                 TFP_DRV_LOG(ERR,
     438                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     439                 :            :                             tf_dir_2_str(parms->dir),
     440                 :            :                             strerror(-rc));
     441                 :          0 :                 return rc;
     442                 :            :         }
     443                 :            : 
     444                 :            :         /* Retrieve the device information */
     445                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     446         [ #  # ]:          0 :         if (rc) {
     447                 :          0 :                 TFP_DRV_LOG(ERR,
     448                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     449                 :            :                             tf_dir_2_str(parms->dir),
     450                 :            :                             strerror(-rc));
     451                 :          0 :                 return rc;
     452                 :            :         }
     453                 :            : 
     454         [ #  # ]:          0 :         if (dev->ops->tf_dev_alloc_ident == NULL) {
     455                 :            :                 rc = -EOPNOTSUPP;
     456                 :          0 :                 TFP_DRV_LOG(ERR,
     457                 :            :                             "%s: Operation not supported, rc:%s\n",
     458                 :            :                             tf_dir_2_str(parms->dir),
     459                 :            :                             strerror(-rc));
     460                 :          0 :                 return -EOPNOTSUPP;
     461                 :            :         }
     462                 :            : 
     463                 :          0 :         aparms.dir = parms->dir;
     464                 :          0 :         aparms.type = parms->ident_type;
     465                 :          0 :         aparms.id = &id;
     466                 :          0 :         rc = dev->ops->tf_dev_alloc_ident(tfp, &aparms);
     467         [ #  # ]:          0 :         if (rc) {
     468                 :          0 :                 TFP_DRV_LOG(ERR,
     469                 :            :                             "%s: Identifier allocation failed, rc:%s\n",
     470                 :            :                             tf_dir_2_str(parms->dir),
     471                 :            :                             strerror(-rc));
     472                 :          0 :                 return rc;
     473                 :            :         }
     474                 :            : 
     475                 :          0 :         parms->id = id;
     476                 :            : 
     477                 :          0 :         return 0;
     478                 :            : }
     479                 :            : 
     480                 :            : int
     481                 :          0 : tf_free_identifier(struct tf *tfp,
     482                 :            :                    struct tf_free_identifier_parms *parms)
     483                 :            : {
     484                 :            :         int rc;
     485                 :            :         struct tf_session *tfs;
     486                 :            :         struct tf_dev_info *dev;
     487                 :            :         struct tf_ident_free_parms fparms;
     488                 :            : 
     489         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     490                 :            : 
     491                 :            :         /* Can't do static initialization due to UT enum check */
     492                 :            :         memset(&fparms, 0, sizeof(struct tf_ident_free_parms));
     493                 :            : 
     494                 :            :         /* Retrieve the session information */
     495                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     496         [ #  # ]:          0 :         if (rc) {
     497                 :          0 :                 TFP_DRV_LOG(ERR,
     498                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     499                 :            :                             tf_dir_2_str(parms->dir),
     500                 :            :                             strerror(-rc));
     501                 :          0 :                 return rc;
     502                 :            :         }
     503                 :            : 
     504                 :            :         /* Retrieve the device information */
     505                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     506         [ #  # ]:          0 :         if (rc) {
     507                 :          0 :                 TFP_DRV_LOG(ERR,
     508                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     509                 :            :                             tf_dir_2_str(parms->dir),
     510                 :            :                             strerror(-rc));
     511                 :          0 :                 return rc;
     512                 :            :         }
     513                 :            : 
     514         [ #  # ]:          0 :         if (dev->ops->tf_dev_free_ident == NULL) {
     515                 :            :                 rc = -EOPNOTSUPP;
     516                 :          0 :                 TFP_DRV_LOG(ERR,
     517                 :            :                             "%s: Operation not supported, rc:%s\n",
     518                 :            :                             tf_dir_2_str(parms->dir),
     519                 :            :                             strerror(-rc));
     520                 :          0 :                 return -EOPNOTSUPP;
     521                 :            :         }
     522                 :            : 
     523                 :          0 :         fparms.dir = parms->dir;
     524                 :          0 :         fparms.type = parms->ident_type;
     525                 :          0 :         fparms.id = parms->id;
     526                 :          0 :         fparms.ref_cnt = &parms->ref_cnt;
     527                 :          0 :         rc = dev->ops->tf_dev_free_ident(tfp, &fparms);
     528         [ #  # ]:          0 :         if (rc) {
     529                 :          0 :                 TFP_DRV_LOG(ERR,
     530                 :            :                             "%s: Identifier free failed, rc:%s\n",
     531                 :            :                             tf_dir_2_str(parms->dir),
     532                 :            :                             strerror(-rc));
     533                 :          0 :                 return rc;
     534                 :            :         }
     535                 :            : 
     536                 :            :         return 0;
     537                 :            : }
     538                 :            : 
     539                 :            : int
     540                 :          0 : tf_search_identifier(struct tf *tfp,
     541                 :            :                      struct tf_search_identifier_parms *parms)
     542                 :            : {
     543                 :            :         int rc;
     544                 :            :         struct tf_session *tfs;
     545                 :            :         struct tf_dev_info *dev;
     546                 :            :         struct tf_ident_search_parms sparms;
     547                 :            : 
     548         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     549                 :            : 
     550                 :            :         /* Can't do static initialization due to UT enum check */
     551                 :            :         memset(&sparms, 0, sizeof(struct tf_ident_search_parms));
     552                 :            : 
     553                 :            :         /* Retrieve the session information */
     554                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     555         [ #  # ]:          0 :         if (rc) {
     556                 :          0 :                 TFP_DRV_LOG(ERR,
     557                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     558                 :            :                             tf_dir_2_str(parms->dir),
     559                 :            :                             strerror(-rc));
     560                 :          0 :                 return rc;
     561                 :            :         }
     562                 :            : 
     563                 :            :         /* Retrieve the device information */
     564                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     565         [ #  # ]:          0 :         if (rc) {
     566                 :          0 :                 TFP_DRV_LOG(ERR,
     567                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     568                 :            :                             tf_dir_2_str(parms->dir),
     569                 :            :                             strerror(-rc));
     570                 :          0 :                 return rc;
     571                 :            :         }
     572                 :            : 
     573         [ #  # ]:          0 :         if (dev->ops->tf_dev_search_ident == NULL) {
     574                 :            :                 rc = -EOPNOTSUPP;
     575                 :          0 :                 TFP_DRV_LOG(ERR,
     576                 :            :                             "%s: Operation not supported, rc:%s\n",
     577                 :            :                             tf_dir_2_str(parms->dir),
     578                 :            :                             strerror(-rc));
     579                 :          0 :                 return rc;
     580                 :            :         }
     581                 :            : 
     582                 :          0 :         sparms.dir = parms->dir;
     583                 :          0 :         sparms.type = parms->ident_type;
     584                 :          0 :         sparms.search_id = parms->search_id;
     585                 :          0 :         sparms.hit = &parms->hit;
     586                 :          0 :         sparms.ref_cnt = &parms->ref_cnt;
     587                 :          0 :         rc = dev->ops->tf_dev_search_ident(tfp, &sparms);
     588         [ #  # ]:          0 :         if (rc) {
     589                 :          0 :                 TFP_DRV_LOG(ERR,
     590                 :            :                             "%s: Identifier search failed, rc:%s\n",
     591                 :            :                             tf_dir_2_str(parms->dir),
     592                 :            :                             strerror(-rc));
     593                 :          0 :                 return rc;
     594                 :            :         }
     595                 :            : 
     596                 :            :         return 0;
     597                 :            : }
     598                 :            : 
     599                 :            : int
     600                 :          0 : tf_search_tcam_entry(struct tf *tfp,
     601                 :            :                      struct tf_search_tcam_entry_parms *parms)
     602                 :            : {
     603                 :            :         int rc;
     604                 :            :         struct tf_session *tfs;
     605                 :            :         struct tf_dev_info *dev;
     606                 :            :         struct tf_tcam_alloc_search_parms sparms;
     607                 :            : 
     608         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     609                 :            : 
     610                 :            :         memset(&sparms, 0, sizeof(struct tf_tcam_alloc_search_parms));
     611                 :            : 
     612                 :            :         /* Retrieve the session information */
     613                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     614         [ #  # ]:          0 :         if (rc) {
     615                 :          0 :                 TFP_DRV_LOG(ERR,
     616                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     617                 :            :                             tf_dir_2_str(parms->dir),
     618                 :            :                             strerror(-rc));
     619                 :          0 :                 return rc;
     620                 :            :         }
     621                 :            : 
     622                 :            :         /* Retrieve the device information */
     623                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     624         [ #  # ]:          0 :         if (rc) {
     625                 :          0 :                 TFP_DRV_LOG(ERR,
     626                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     627                 :            :                             tf_dir_2_str(parms->dir),
     628                 :            :                             strerror(-rc));
     629                 :          0 :                 return rc;
     630                 :            :         }
     631                 :            : 
     632         [ #  # ]:          0 :         if (dev->ops->tf_dev_alloc_search_tcam == NULL) {
     633                 :            :                 rc = -EOPNOTSUPP;
     634                 :          0 :                 TFP_DRV_LOG(ERR,
     635                 :            :                             "%s: Operation not supported, rc:%s\n",
     636                 :            :                             tf_dir_2_str(parms->dir),
     637                 :            :                             strerror(-rc));
     638                 :          0 :                 return rc;
     639                 :            :         }
     640                 :            : 
     641                 :          0 :         sparms.dir = parms->dir;
     642                 :          0 :         sparms.type = parms->tcam_tbl_type;
     643                 :          0 :         sparms.key = parms->key;
     644                 :          0 :         sparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
     645                 :          0 :         sparms.mask = parms->mask;
     646                 :          0 :         sparms.priority = parms->priority;
     647                 :          0 :         sparms.alloc = parms->alloc;
     648                 :            : 
     649                 :            :         /* Result is an in/out and so no need to copy during outputs */
     650                 :          0 :         sparms.result = parms->result;
     651                 :          0 :         sparms.result_size =
     652                 :          0 :                 TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
     653                 :            : 
     654                 :          0 :         rc = dev->ops->tf_dev_alloc_search_tcam(tfp, &sparms);
     655         [ #  # ]:          0 :         if (rc) {
     656                 :          0 :                 TFP_DRV_LOG(ERR,
     657                 :            :                             "%s: TCAM allocation failed, rc:%s\n",
     658                 :            :                             tf_dir_2_str(parms->dir),
     659                 :            :                             strerror(-rc));
     660                 :          0 :                 return rc;
     661                 :            :         }
     662                 :            : 
     663                 :            :         /* Copy the outputs */
     664                 :          0 :         parms->hit = sparms.hit;
     665                 :          0 :         parms->search_status = sparms.search_status;
     666                 :          0 :         parms->ref_cnt = sparms.ref_cnt;
     667                 :          0 :         parms->idx = sparms.idx;
     668                 :            : 
     669                 :          0 :         return 0;
     670                 :            : }
     671                 :            : 
     672                 :            : int
     673                 :          0 : tf_alloc_tcam_entry(struct tf *tfp,
     674                 :            :                     struct tf_alloc_tcam_entry_parms *parms)
     675                 :            : {
     676                 :            :         int rc;
     677                 :            :         struct tf_session *tfs;
     678                 :            :         struct tf_dev_info *dev;
     679                 :            :         struct tf_tcam_alloc_parms aparms;
     680                 :            : 
     681         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     682                 :            : 
     683                 :            :         memset(&aparms, 0, sizeof(struct tf_tcam_alloc_parms));
     684                 :            : 
     685                 :            :         /* Retrieve the session information */
     686                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     687         [ #  # ]:          0 :         if (rc) {
     688                 :          0 :                 TFP_DRV_LOG(ERR,
     689                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     690                 :            :                             tf_dir_2_str(parms->dir),
     691                 :            :                             strerror(-rc));
     692                 :          0 :                 return rc;
     693                 :            :         }
     694                 :            : 
     695                 :            :         /* Retrieve the device information */
     696                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     697         [ #  # ]:          0 :         if (rc) {
     698                 :          0 :                 TFP_DRV_LOG(ERR,
     699                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     700                 :            :                             tf_dir_2_str(parms->dir),
     701                 :            :                             strerror(-rc));
     702                 :          0 :                 return rc;
     703                 :            :         }
     704                 :            : 
     705         [ #  # ]:          0 :         if (dev->ops->tf_dev_alloc_tcam == NULL) {
     706                 :            :                 rc = -EOPNOTSUPP;
     707                 :          0 :                 TFP_DRV_LOG(ERR,
     708                 :            :                             "%s: Operation not supported, rc:%s\n",
     709                 :            :                             tf_dir_2_str(parms->dir),
     710                 :            :                             strerror(-rc));
     711                 :          0 :                 return rc;
     712                 :            :         }
     713                 :            : 
     714                 :          0 :         aparms.dir = parms->dir;
     715                 :          0 :         aparms.type = parms->tcam_tbl_type;
     716                 :          0 :         aparms.key_size = TF_BITS2BYTES_WORD_ALIGN(parms->key_sz_in_bits);
     717                 :          0 :         aparms.priority = parms->priority;
     718                 :          0 :         rc = dev->ops->tf_dev_alloc_tcam(tfp, &aparms);
     719         [ #  # ]:          0 :         if (rc) {
     720                 :          0 :                 TFP_DRV_LOG(ERR,
     721                 :            :                             "%s: TCAM allocation failed, rc:%s\n",
     722                 :            :                             tf_dir_2_str(parms->dir),
     723                 :            :                             strerror(-rc));
     724                 :          0 :                 return rc;
     725                 :            :         }
     726                 :            : 
     727                 :          0 :         parms->idx = aparms.idx;
     728                 :            : 
     729                 :          0 :         return 0;
     730                 :            : }
     731                 :            : 
     732                 :            : int
     733                 :          0 : tf_set_tcam_entry(struct tf *tfp,
     734                 :            :                   struct tf_set_tcam_entry_parms *parms)
     735                 :            : {
     736                 :            :         int rc;
     737                 :            :         struct tf_session *tfs;
     738                 :            :         struct tf_dev_info *dev;
     739                 :            :         struct tf_tcam_set_parms sparms;
     740                 :            : 
     741         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     742                 :            : 
     743                 :            :         memset(&sparms, 0, sizeof(struct tf_tcam_set_parms));
     744                 :            : 
     745                 :            :         /* Retrieve the session information */
     746                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     747         [ #  # ]:          0 :         if (rc) {
     748                 :          0 :                 TFP_DRV_LOG(ERR,
     749                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     750                 :            :                             tf_dir_2_str(parms->dir),
     751                 :            :                             strerror(-rc));
     752                 :          0 :                 return rc;
     753                 :            :         }
     754                 :            : 
     755                 :            :         /* Retrieve the device information */
     756                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     757         [ #  # ]:          0 :         if (rc) {
     758                 :          0 :                 TFP_DRV_LOG(ERR,
     759                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     760                 :            :                             tf_dir_2_str(parms->dir),
     761                 :            :                             strerror(-rc));
     762                 :          0 :                 return rc;
     763                 :            :         }
     764                 :            : 
     765         [ #  # ]:          0 :         if (dev->ops->tf_dev_set_tcam == NULL ||
     766         [ #  # ]:          0 :             dev->ops->tf_dev_word_align == NULL) {
     767                 :            :                 rc = -EOPNOTSUPP;
     768                 :          0 :                 TFP_DRV_LOG(ERR,
     769                 :            :                             "%s: Operation not supported, rc:%s\n",
     770                 :            :                             tf_dir_2_str(parms->dir),
     771                 :            :                             strerror(-rc));
     772                 :          0 :                 return rc;
     773                 :            :         }
     774                 :            : 
     775                 :          0 :         sparms.dir = parms->dir;
     776                 :          0 :         sparms.type = parms->tcam_tbl_type;
     777                 :          0 :         sparms.idx = parms->idx;
     778                 :          0 :         sparms.key = parms->key;
     779                 :          0 :         sparms.mask = parms->mask;
     780                 :          0 :         sparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
     781                 :          0 :         sparms.result = parms->result;
     782                 :          0 :         sparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
     783                 :            : 
     784                 :          0 :         rc = dev->ops->tf_dev_set_tcam(tfp, &sparms);
     785         [ #  # ]:          0 :         if (rc) {
     786                 :          0 :                 TFP_DRV_LOG(ERR,
     787                 :            :                             "%s: TCAM set failed, rc:%s\n",
     788                 :            :                             tf_dir_2_str(parms->dir),
     789                 :            :                             strerror(-rc));
     790                 :          0 :                 return rc;
     791                 :            :         }
     792                 :          0 :         TFP_DRV_LOG(DEBUG,
     793                 :            :                     "%s: TCAM type %d set idx:%d key size %d result size %d\n",
     794                 :            :                     tf_dir_2_str(parms->dir), sparms.type,
     795                 :            :                     sparms.idx, sparms.key_size, sparms.result_size);
     796                 :            : 
     797                 :          0 :         return 0;
     798                 :            : }
     799                 :            : 
     800                 :            : int
     801                 :          0 : tf_get_tcam_entry(struct tf *tfp __rte_unused,
     802                 :            :                   struct tf_get_tcam_entry_parms *parms)
     803                 :            : {
     804                 :            :         int rc;
     805                 :            :         struct tf_session *tfs;
     806                 :            :         struct tf_dev_info *dev;
     807                 :            :         struct tf_tcam_get_parms gparms;
     808                 :            : 
     809         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     810                 :            : 
     811                 :            :         memset(&gparms, 0, sizeof(struct tf_tcam_get_parms));
     812                 :            : 
     813                 :            :         /* Retrieve the session information */
     814                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     815         [ #  # ]:          0 :         if (rc) {
     816                 :          0 :                 TFP_DRV_LOG(ERR,
     817                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     818                 :            :                             tf_dir_2_str(parms->dir),
     819                 :            :                             strerror(-rc));
     820                 :          0 :                 return rc;
     821                 :            :         }
     822                 :            : 
     823                 :            :         /* Retrieve the device information */
     824                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     825         [ #  # ]:          0 :         if (rc) {
     826                 :          0 :                 TFP_DRV_LOG(ERR,
     827                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     828                 :            :                             tf_dir_2_str(parms->dir),
     829                 :            :                             strerror(-rc));
     830                 :          0 :                 return rc;
     831                 :            :         }
     832                 :            : 
     833         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_tcam == NULL) {
     834                 :            :                 rc = -EOPNOTSUPP;
     835                 :          0 :                 TFP_DRV_LOG(ERR,
     836                 :            :                             "%s: Operation not supported, rc:%s\n",
     837                 :            :                             tf_dir_2_str(parms->dir),
     838                 :            :                             strerror(-rc));
     839                 :          0 :                 return rc;
     840                 :            :         }
     841                 :            : 
     842                 :          0 :         gparms.dir = parms->dir;
     843                 :          0 :         gparms.type = parms->tcam_tbl_type;
     844                 :          0 :         gparms.idx = parms->idx;
     845                 :          0 :         gparms.key = parms->key;
     846                 :          0 :         gparms.key_size = dev->ops->tf_dev_word_align(parms->key_sz_in_bits);
     847                 :          0 :         gparms.mask = parms->mask;
     848                 :          0 :         gparms.result = parms->result;
     849                 :          0 :         gparms.result_size = TF_BITS2BYTES_WORD_ALIGN(parms->result_sz_in_bits);
     850                 :            : 
     851                 :          0 :         rc = dev->ops->tf_dev_get_tcam(tfp, &gparms);
     852         [ #  # ]:          0 :         if (rc) {
     853                 :          0 :                 TFP_DRV_LOG(ERR,
     854                 :            :                             "%s: TCAM get failed, rc:%s\n",
     855                 :            :                             tf_dir_2_str(parms->dir),
     856                 :            :                             strerror(-rc));
     857                 :          0 :                 return rc;
     858                 :            :         }
     859                 :          0 :         parms->key_sz_in_bits = gparms.key_size * 8;
     860                 :          0 :         parms->result_sz_in_bits = gparms.result_size * 8;
     861                 :            : 
     862                 :          0 :         return 0;
     863                 :            : }
     864                 :            : 
     865                 :            : int
     866                 :          0 : tf_free_tcam_entry(struct tf *tfp,
     867                 :            :                    struct tf_free_tcam_entry_parms *parms)
     868                 :            : {
     869                 :            :         int rc;
     870                 :            :         struct tf_session *tfs;
     871                 :            :         struct tf_dev_info *dev;
     872                 :            :         struct tf_tcam_free_parms fparms;
     873                 :            : 
     874         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     875                 :            : 
     876                 :            :         memset(&fparms, 0, sizeof(struct tf_tcam_free_parms));
     877                 :            : 
     878                 :            :         /* Retrieve the session information */
     879                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     880         [ #  # ]:          0 :         if (rc) {
     881                 :          0 :                 TFP_DRV_LOG(ERR,
     882                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     883                 :            :                             tf_dir_2_str(parms->dir),
     884                 :            :                             strerror(-rc));
     885                 :          0 :                 return rc;
     886                 :            :         }
     887                 :            : 
     888                 :            :         /* Retrieve the device information */
     889                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     890         [ #  # ]:          0 :         if (rc) {
     891                 :          0 :                 TFP_DRV_LOG(ERR,
     892                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     893                 :            :                             tf_dir_2_str(parms->dir),
     894                 :            :                             strerror(-rc));
     895                 :          0 :                 return rc;
     896                 :            :         }
     897                 :            : 
     898         [ #  # ]:          0 :         if (dev->ops->tf_dev_free_tcam == NULL) {
     899                 :            :                 rc = -EOPNOTSUPP;
     900                 :          0 :                 TFP_DRV_LOG(ERR,
     901                 :            :                             "%s: Operation not supported, rc:%s\n",
     902                 :            :                             tf_dir_2_str(parms->dir),
     903                 :            :                             strerror(-rc));
     904                 :          0 :                 return rc;
     905                 :            :         }
     906                 :            : 
     907                 :          0 :         fparms.dir = parms->dir;
     908                 :          0 :         fparms.type = parms->tcam_tbl_type;
     909                 :          0 :         fparms.idx = parms->idx;
     910                 :          0 :         rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
     911         [ #  # ]:          0 :         if (rc) {
     912                 :          0 :                 TFP_DRV_LOG(ERR,
     913                 :            :                             "%s: TCAM free failed, rc:%s\n",
     914                 :            :                             tf_dir_2_str(parms->dir),
     915                 :            :                             strerror(-rc));
     916                 :          0 :                 return rc;
     917                 :            :         }
     918                 :            : 
     919                 :            :         return 0;
     920                 :            : }
     921                 :            : 
     922                 :            : int
     923                 :          0 : tf_move_tcam_shared_entries(struct tf *tfp,
     924                 :            :                             struct tf_move_tcam_shared_entries_parms *parms)
     925                 :            : {
     926                 :            :         int rc;
     927                 :            :         struct tf_session *tfs;
     928                 :            :         struct tf_dev_info *dev;
     929                 :            : 
     930         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     931                 :            : 
     932                 :            :         /* Retrieve the session information */
     933                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     934         [ #  # ]:          0 :         if (rc) {
     935                 :          0 :                 TFP_DRV_LOG(ERR,
     936                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     937                 :            :                             tf_dir_2_str(parms->dir),
     938                 :            :                             strerror(-rc));
     939                 :          0 :                 return rc;
     940                 :            :         }
     941                 :            : 
     942                 :            :         /* Retrieve the device information */
     943                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     944         [ #  # ]:          0 :         if (rc) {
     945                 :          0 :                 TFP_DRV_LOG(ERR,
     946                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     947                 :            :                             tf_dir_2_str(parms->dir),
     948                 :            :                             strerror(-rc));
     949                 :          0 :                 return rc;
     950                 :            :         }
     951                 :            : 
     952         [ #  # ]:          0 :         if (dev->ops->tf_dev_move_tcam == NULL) {
     953                 :            :                 rc = -EOPNOTSUPP;
     954                 :          0 :                 TFP_DRV_LOG(ERR,
     955                 :            :                             "%s: Operation not supported, rc:%s\n",
     956                 :            :                             tf_dir_2_str(parms->dir),
     957                 :            :                             strerror(-rc));
     958                 :          0 :                 return rc;
     959                 :            :         }
     960                 :            : 
     961                 :          0 :         rc = dev->ops->tf_dev_move_tcam(tfp, parms);
     962         [ #  # ]:          0 :         if (rc) {
     963                 :          0 :                 TFP_DRV_LOG(ERR,
     964                 :            :                             "%s: TCAM shared entries move failed, rc:%s\n",
     965                 :            :                             tf_dir_2_str(parms->dir),
     966                 :            :                             strerror(-rc));
     967                 :          0 :                 return rc;
     968                 :            :         }
     969                 :            : 
     970                 :            :         return 0;
     971                 :            : }
     972                 :            : 
     973                 :            : int
     974                 :          0 : tf_clear_tcam_shared_entries(struct tf *tfp,
     975                 :            :                              struct tf_clear_tcam_shared_entries_parms *parms)
     976                 :            : {
     977                 :            :         int rc;
     978                 :            :         struct tf_session *tfs;
     979                 :            :         struct tf_dev_info *dev;
     980                 :            : 
     981         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
     982                 :            : 
     983                 :            :         /* Retrieve the session information */
     984                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
     985         [ #  # ]:          0 :         if (rc) {
     986                 :          0 :                 TFP_DRV_LOG(ERR,
     987                 :            :                             "%s: Failed to lookup session, rc:%s\n",
     988                 :            :                             tf_dir_2_str(parms->dir),
     989                 :            :                             strerror(-rc));
     990                 :          0 :                 return rc;
     991                 :            :         }
     992                 :            : 
     993                 :            :         /* Retrieve the device information */
     994                 :          0 :         rc = tf_session_get_device(tfs, &dev);
     995         [ #  # ]:          0 :         if (rc) {
     996                 :          0 :                 TFP_DRV_LOG(ERR,
     997                 :            :                             "%s: Failed to lookup device, rc:%s\n",
     998                 :            :                             tf_dir_2_str(parms->dir),
     999                 :            :                             strerror(-rc));
    1000                 :          0 :                 return rc;
    1001                 :            :         }
    1002                 :            : 
    1003         [ #  # ]:          0 :         if (dev->ops->tf_dev_clear_tcam == NULL) {
    1004                 :            :                 rc = -EOPNOTSUPP;
    1005                 :          0 :                 TFP_DRV_LOG(ERR,
    1006                 :            :                             "%s: Operation not supported, rc:%s\n",
    1007                 :            :                             tf_dir_2_str(parms->dir),
    1008                 :            :                             strerror(-rc));
    1009                 :          0 :                 return rc;
    1010                 :            :         }
    1011                 :            : 
    1012                 :          0 :         rc = dev->ops->tf_dev_clear_tcam(tfp, parms);
    1013         [ #  # ]:          0 :         if (rc) {
    1014                 :          0 :                 TFP_DRV_LOG(ERR,
    1015                 :            :                             "%s: TCAM shared entries clear failed, rc:%s\n",
    1016                 :            :                             tf_dir_2_str(parms->dir),
    1017                 :            :                             strerror(-rc));
    1018                 :          0 :                 return rc;
    1019                 :            :         }
    1020                 :            : 
    1021                 :            :         return 0;
    1022                 :            : }
    1023                 :            : 
    1024                 :            : int
    1025                 :          0 : tf_alloc_tbl_entry(struct tf *tfp,
    1026                 :            :                    struct tf_alloc_tbl_entry_parms *parms)
    1027                 :            : {
    1028                 :            :         int rc;
    1029                 :            :         struct tf_session *tfs;
    1030                 :            :         struct tf_dev_info *dev;
    1031                 :            :         struct tf_tbl_alloc_parms aparms;
    1032                 :            :         uint32_t idx;
    1033                 :            : 
    1034         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1035                 :            : 
    1036                 :            :         /* Can't do static initialization due to UT enum check */
    1037                 :            :         memset(&aparms, 0, sizeof(struct tf_tbl_alloc_parms));
    1038                 :            : 
    1039                 :            :         /* Retrieve the session information */
    1040                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1041         [ #  # ]:          0 :         if (rc) {
    1042                 :          0 :                 TFP_DRV_LOG(ERR,
    1043                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1044                 :            :                             tf_dir_2_str(parms->dir),
    1045                 :            :                             strerror(-rc));
    1046                 :          0 :                 return rc;
    1047                 :            :         }
    1048                 :            : 
    1049                 :            :         /* Retrieve the device information */
    1050                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1051         [ #  # ]:          0 :         if (rc) {
    1052                 :          0 :                 TFP_DRV_LOG(ERR,
    1053                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1054                 :            :                             tf_dir_2_str(parms->dir),
    1055                 :            :                             strerror(-rc));
    1056                 :          0 :                 return rc;
    1057                 :            :         }
    1058                 :            : 
    1059                 :          0 :         aparms.dir = parms->dir;
    1060                 :          0 :         aparms.type = parms->type;
    1061                 :          0 :         aparms.idx = &idx;
    1062                 :          0 :         aparms.tbl_scope_id = parms->tbl_scope_id;
    1063                 :            : 
    1064         [ #  # ]:          0 :         if (parms->type == TF_TBL_TYPE_EXT) {
    1065         [ #  # ]:          0 :                 if (dev->ops->tf_dev_alloc_ext_tbl == NULL) {
    1066                 :            :                         rc = -EOPNOTSUPP;
    1067                 :          0 :                         TFP_DRV_LOG(ERR,
    1068                 :            :                                     "%s: Operation not supported, rc:%s\n",
    1069                 :            :                                     tf_dir_2_str(parms->dir),
    1070                 :            :                                     strerror(-rc));
    1071                 :          0 :                         return -EOPNOTSUPP;
    1072                 :            :                 }
    1073                 :            : 
    1074                 :          0 :                 rc = dev->ops->tf_dev_alloc_ext_tbl(tfp, &aparms);
    1075         [ #  # ]:          0 :                 if (rc) {
    1076                 :          0 :                         TFP_DRV_LOG(ERR,
    1077                 :            :                                     "%s: External table allocation failed, rc:%s\n",
    1078                 :            :                                     tf_dir_2_str(parms->dir),
    1079                 :            :                                     strerror(-rc));
    1080                 :          0 :                         return rc;
    1081                 :            :                 }
    1082         [ #  # ]:          0 :         } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
    1083                 :          0 :                 rc = dev->ops->tf_dev_alloc_sram_tbl(tfp, &aparms);
    1084         [ #  # ]:          0 :                 if (rc) {
    1085                 :          0 :                         TFP_DRV_LOG(ERR,
    1086                 :            :                                     "%s: SRAM table allocation failed, rc:%s\n",
    1087                 :            :                                     tf_dir_2_str(parms->dir),
    1088                 :            :                                     strerror(-rc));
    1089                 :          0 :                         return rc;
    1090                 :            :                 }
    1091                 :            :         } else {
    1092                 :          0 :                 rc = dev->ops->tf_dev_alloc_tbl(tfp, &aparms);
    1093         [ #  # ]:          0 :                 if (rc) {
    1094                 :          0 :                         TFP_DRV_LOG(ERR,
    1095                 :            :                                     "%s: Table allocation failed, rc:%s\n",
    1096                 :            :                                     tf_dir_2_str(parms->dir),
    1097                 :            :                                     strerror(-rc));
    1098                 :          0 :                         return rc;
    1099                 :            :                 }
    1100                 :            :         }
    1101                 :            : 
    1102                 :          0 :         parms->idx = idx;
    1103                 :            : 
    1104                 :          0 :         return 0;
    1105                 :            : }
    1106                 :            : 
    1107                 :            : int
    1108                 :          0 : tf_free_tbl_entry(struct tf *tfp,
    1109                 :            :                   struct tf_free_tbl_entry_parms *parms)
    1110                 :            : {
    1111                 :            :         int rc;
    1112                 :            :         struct tf_session *tfs;
    1113                 :            :         struct tf_dev_info *dev;
    1114                 :            :         struct tf_tbl_free_parms fparms;
    1115                 :            : 
    1116         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1117                 :            : 
    1118                 :            :         /* Can't do static initialization due to UT enum check */
    1119                 :            :         memset(&fparms, 0, sizeof(struct tf_tbl_free_parms));
    1120                 :            : 
    1121                 :            :         /* Retrieve the session information */
    1122                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1123         [ #  # ]:          0 :         if (rc) {
    1124                 :          0 :                 TFP_DRV_LOG(ERR,
    1125                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1126                 :            :                             tf_dir_2_str(parms->dir),
    1127                 :            :                             strerror(-rc));
    1128                 :          0 :                 return rc;
    1129                 :            :         }
    1130                 :            : 
    1131                 :            :         /* Retrieve the device information */
    1132                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1133         [ #  # ]:          0 :         if (rc) {
    1134                 :          0 :                 TFP_DRV_LOG(ERR,
    1135                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1136                 :            :                             tf_dir_2_str(parms->dir),
    1137                 :            :                             strerror(-rc));
    1138                 :          0 :                 return rc;
    1139                 :            :         }
    1140                 :            : 
    1141                 :          0 :         fparms.dir = parms->dir;
    1142                 :          0 :         fparms.type = parms->type;
    1143                 :          0 :         fparms.idx = parms->idx;
    1144                 :          0 :         fparms.tbl_scope_id = parms->tbl_scope_id;
    1145                 :            : 
    1146         [ #  # ]:          0 :         if (parms->type == TF_TBL_TYPE_EXT) {
    1147         [ #  # ]:          0 :                 if (dev->ops->tf_dev_free_ext_tbl == NULL) {
    1148                 :            :                         rc = -EOPNOTSUPP;
    1149                 :          0 :                         TFP_DRV_LOG(ERR,
    1150                 :            :                                     "%s: Operation not supported, rc:%s\n",
    1151                 :            :                                     tf_dir_2_str(parms->dir),
    1152                 :            :                                     strerror(-rc));
    1153                 :          0 :                         return -EOPNOTSUPP;
    1154                 :            :                 }
    1155                 :            : 
    1156                 :          0 :                 rc = dev->ops->tf_dev_free_ext_tbl(tfp, &fparms);
    1157         [ #  # ]:          0 :                 if (rc) {
    1158                 :          0 :                         TFP_DRV_LOG(ERR,
    1159                 :            :                                     "%s: Table free failed, rc:%s\n",
    1160                 :            :                                     tf_dir_2_str(parms->dir),
    1161                 :            :                                     strerror(-rc));
    1162                 :          0 :                         return rc;
    1163                 :            :                 }
    1164         [ #  # ]:          0 :         } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
    1165                 :          0 :                 rc = dev->ops->tf_dev_free_sram_tbl(tfp, &fparms);
    1166         [ #  # ]:          0 :                 if (rc) {
    1167                 :          0 :                         TFP_DRV_LOG(ERR,
    1168                 :            :                                     "%s: SRAM table free failed, rc:%s\n",
    1169                 :            :                                     tf_dir_2_str(parms->dir),
    1170                 :            :                                     strerror(-rc));
    1171                 :          0 :                         return rc;
    1172                 :            :                 }
    1173                 :            :         } else {
    1174                 :            : 
    1175                 :          0 :                 rc = dev->ops->tf_dev_free_tbl(tfp, &fparms);
    1176         [ #  # ]:          0 :                 if (rc) {
    1177                 :          0 :                         TFP_DRV_LOG(ERR,
    1178                 :            :                                     "%s: Table free failed, rc:%s\n",
    1179                 :            :                                     tf_dir_2_str(parms->dir),
    1180                 :            :                                     strerror(-rc));
    1181                 :          0 :                         return rc;
    1182                 :            :                 }
    1183                 :            :         }
    1184                 :            :         return 0;
    1185                 :            : }
    1186                 :            : 
    1187                 :            : int
    1188                 :          0 : tf_set_tbl_entry(struct tf *tfp,
    1189                 :            :                  struct tf_set_tbl_entry_parms *parms)
    1190                 :            : {
    1191                 :            :         int rc = 0;
    1192                 :            :         struct tf_session *tfs;
    1193                 :            :         struct tf_dev_info *dev;
    1194                 :            :         struct tf_tbl_set_parms sparms;
    1195                 :            : 
    1196   [ #  #  #  # ]:          0 :         TF_CHECK_PARMS3(tfp, parms, parms->data);
    1197                 :            : 
    1198                 :            :         /* Can't do static initialization due to UT enum check */
    1199                 :            :         memset(&sparms, 0, sizeof(struct tf_tbl_set_parms));
    1200                 :            : 
    1201                 :            :         /* Retrieve the session information */
    1202                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1203         [ #  # ]:          0 :         if (rc) {
    1204                 :          0 :                 TFP_DRV_LOG(ERR,
    1205                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1206                 :            :                             tf_dir_2_str(parms->dir),
    1207                 :            :                             strerror(-rc));
    1208                 :          0 :                 return rc;
    1209                 :            :         }
    1210                 :            : 
    1211                 :            :         /* Retrieve the device information */
    1212                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1213         [ #  # ]:          0 :         if (rc) {
    1214                 :          0 :                 TFP_DRV_LOG(ERR,
    1215                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1216                 :            :                             tf_dir_2_str(parms->dir),
    1217                 :            :                             strerror(-rc));
    1218                 :          0 :                 return rc;
    1219                 :            :         }
    1220                 :            : 
    1221                 :          0 :         sparms.dir = parms->dir;
    1222                 :          0 :         sparms.type = parms->type;
    1223                 :          0 :         sparms.data = parms->data;
    1224                 :          0 :         sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
    1225                 :          0 :         sparms.idx = parms->idx;
    1226                 :          0 :         sparms.tbl_scope_id = parms->tbl_scope_id;
    1227                 :            : 
    1228         [ #  # ]:          0 :         if (parms->type == TF_TBL_TYPE_EXT) {
    1229         [ #  # ]:          0 :                 if (dev->ops->tf_dev_set_ext_tbl == NULL) {
    1230                 :            :                         rc = -EOPNOTSUPP;
    1231                 :          0 :                         TFP_DRV_LOG(ERR,
    1232                 :            :                                     "%s: Operation not supported, rc:%s\n",
    1233                 :            :                                     tf_dir_2_str(parms->dir),
    1234                 :            :                                     strerror(-rc));
    1235                 :          0 :                         return -EOPNOTSUPP;
    1236                 :            :                 }
    1237                 :            : 
    1238                 :          0 :                 rc = dev->ops->tf_dev_set_ext_tbl(tfp, &sparms);
    1239         [ #  # ]:          0 :                 if (rc) {
    1240                 :          0 :                         TFP_DRV_LOG(ERR,
    1241                 :            :                                     "%s: Table set failed, rc:%s\n",
    1242                 :            :                                     tf_dir_2_str(parms->dir),
    1243                 :            :                                     strerror(-rc));
    1244                 :          0 :                         return rc;
    1245                 :            :                 }
    1246         [ #  # ]:          0 :         }  else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
    1247                 :          0 :                 rc = dev->ops->tf_dev_set_sram_tbl(tfp, &sparms);
    1248         [ #  # ]:          0 :                 if (rc) {
    1249                 :          0 :                         TFP_DRV_LOG(ERR,
    1250                 :            :                                     "%s: SRAM table set failed, rc:%s\n",
    1251                 :            :                                     tf_dir_2_str(parms->dir),
    1252                 :            :                                     strerror(-rc));
    1253                 :          0 :                         return rc;
    1254                 :            :                 }
    1255                 :            :         } else {
    1256         [ #  # ]:          0 :                 if (dev->ops->tf_dev_set_tbl == NULL) {
    1257                 :            :                         rc = -EOPNOTSUPP;
    1258                 :          0 :                         TFP_DRV_LOG(ERR,
    1259                 :            :                                     "%s: Operation not supported, rc:%s\n",
    1260                 :            :                                     tf_dir_2_str(parms->dir),
    1261                 :            :                                     strerror(-rc));
    1262                 :          0 :                         return -EOPNOTSUPP;
    1263                 :            :                 }
    1264                 :            : 
    1265                 :          0 :                 rc = dev->ops->tf_dev_set_tbl(tfp, &sparms);
    1266         [ #  # ]:          0 :                 if (rc) {
    1267                 :          0 :                         TFP_DRV_LOG(ERR,
    1268                 :            :                                     "%s: Table set failed, rc:%s\n",
    1269                 :            :                                     tf_dir_2_str(parms->dir),
    1270                 :            :                                     strerror(-rc));
    1271                 :          0 :                         return rc;
    1272                 :            :                 }
    1273                 :            :         }
    1274                 :            : 
    1275                 :            :         return rc;
    1276                 :            : }
    1277                 :            : 
    1278                 :            : int
    1279                 :          0 : tf_get_tbl_entry(struct tf *tfp,
    1280                 :            :                  struct tf_get_tbl_entry_parms *parms)
    1281                 :            : {
    1282                 :            :         int rc = 0;
    1283                 :            :         struct tf_session *tfs;
    1284                 :            :         struct tf_dev_info *dev;
    1285                 :            :         struct tf_tbl_get_parms gparms;
    1286                 :            : 
    1287   [ #  #  #  # ]:          0 :         TF_CHECK_PARMS3(tfp, parms, parms->data);
    1288                 :            : 
    1289                 :            :         /* Can't do static initialization due to UT enum check */
    1290                 :            :         memset(&gparms, 0, sizeof(struct tf_tbl_get_parms));
    1291                 :            : 
    1292                 :            :         /* Retrieve the session information */
    1293                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1294         [ #  # ]:          0 :         if (rc) {
    1295                 :          0 :                 TFP_DRV_LOG(ERR,
    1296                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1297                 :            :                             tf_dir_2_str(parms->dir),
    1298                 :            :                             strerror(-rc));
    1299                 :          0 :                 return rc;
    1300                 :            :         }
    1301                 :            : 
    1302                 :            :         /* Retrieve the device information */
    1303                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1304         [ #  # ]:          0 :         if (rc) {
    1305                 :          0 :                 TFP_DRV_LOG(ERR,
    1306                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1307                 :            :                             tf_dir_2_str(parms->dir),
    1308                 :            :                             strerror(-rc));
    1309                 :          0 :                 return rc;
    1310                 :            :         }
    1311                 :          0 :         gparms.dir = parms->dir;
    1312                 :          0 :         gparms.type = parms->type;
    1313                 :          0 :         gparms.data = parms->data;
    1314                 :          0 :         gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
    1315                 :          0 :         gparms.idx = parms->idx;
    1316                 :            : 
    1317         [ #  # ]:          0 :         if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
    1318                 :          0 :                 rc = dev->ops->tf_dev_get_sram_tbl(tfp, &gparms);
    1319         [ #  # ]:          0 :                 if (rc) {
    1320                 :          0 :                         TFP_DRV_LOG(ERR,
    1321                 :            :                                     "%s: SRAM table get failed, rc:%s\n",
    1322                 :            :                                     tf_dir_2_str(parms->dir),
    1323                 :            :                                     strerror(-rc));
    1324                 :          0 :                         return rc;
    1325                 :            :                 }
    1326                 :            :         } else {
    1327         [ #  # ]:          0 :                 if (dev->ops->tf_dev_get_tbl == NULL) {
    1328                 :            :                         rc = -EOPNOTSUPP;
    1329                 :          0 :                         TFP_DRV_LOG(ERR,
    1330                 :            :                                     "%s: Operation not supported, rc:%s\n",
    1331                 :            :                                     tf_dir_2_str(parms->dir),
    1332                 :            :                                     strerror(-rc));
    1333                 :          0 :                         return -EOPNOTSUPP;
    1334                 :            :                 }
    1335                 :            : 
    1336                 :          0 :                 rc = dev->ops->tf_dev_get_tbl(tfp, &gparms);
    1337         [ #  # ]:          0 :                 if (rc) {
    1338                 :          0 :                         TFP_DRV_LOG(ERR,
    1339                 :            :                                     "%s: Table get failed, rc:%s\n",
    1340                 :            :                                     tf_dir_2_str(parms->dir),
    1341                 :            :                                     strerror(-rc));
    1342                 :          0 :                         return rc;
    1343                 :            :                 }
    1344                 :            :         }
    1345                 :            : 
    1346                 :            :         return rc;
    1347                 :            : }
    1348                 :            : 
    1349                 :            : int
    1350                 :          0 : tf_bulk_get_tbl_entry(struct tf *tfp,
    1351                 :            :                  struct tf_bulk_get_tbl_entry_parms *parms)
    1352                 :            : {
    1353                 :            :         int rc = 0;
    1354                 :            :         struct tf_session *tfs;
    1355                 :            :         struct tf_dev_info *dev;
    1356                 :            :         struct tf_tbl_get_bulk_parms bparms;
    1357                 :            : 
    1358         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1359                 :            : 
    1360                 :            :         /* Can't do static initialization due to UT enum check */
    1361                 :            :         memset(&bparms, 0, sizeof(struct tf_tbl_get_bulk_parms));
    1362                 :            : 
    1363                 :            :         /* Retrieve the session information */
    1364                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1365         [ #  # ]:          0 :         if (rc) {
    1366                 :          0 :                 TFP_DRV_LOG(ERR,
    1367                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1368                 :            :                             tf_dir_2_str(parms->dir),
    1369                 :            :                             strerror(-rc));
    1370                 :          0 :                 return rc;
    1371                 :            :         }
    1372                 :            : 
    1373                 :            :         /* Retrieve the device information */
    1374                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1375         [ #  # ]:          0 :         if (rc) {
    1376                 :          0 :                 TFP_DRV_LOG(ERR,
    1377                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1378                 :            :                             tf_dir_2_str(parms->dir),
    1379                 :            :                             strerror(-rc));
    1380                 :          0 :                 return rc;
    1381                 :            :         }
    1382                 :            : 
    1383                 :          0 :         bparms.dir = parms->dir;
    1384                 :          0 :         bparms.type = parms->type;
    1385                 :          0 :         bparms.starting_idx = parms->starting_idx;
    1386                 :          0 :         bparms.num_entries = parms->num_entries;
    1387                 :          0 :         bparms.entry_sz_in_bytes = parms->entry_sz_in_bytes;
    1388                 :          0 :         bparms.physical_mem_addr = parms->physical_mem_addr;
    1389                 :            : 
    1390         [ #  # ]:          0 :         if (parms->type == TF_TBL_TYPE_EXT) {
    1391                 :            :                 /* Not supported, yet */
    1392                 :            :                 rc = -EOPNOTSUPP;
    1393                 :          0 :                 TFP_DRV_LOG(ERR,
    1394                 :            :                             "%s, External table type not supported, rc:%s\n",
    1395                 :            :                             tf_dir_2_str(parms->dir),
    1396                 :            :                             strerror(-rc));
    1397                 :            : 
    1398                 :          0 :                 return rc;
    1399         [ #  # ]:          0 :         } else if (dev->ops->tf_dev_is_sram_managed(tfp, parms->type)) {
    1400                 :          0 :                 rc = dev->ops->tf_dev_get_bulk_sram_tbl(tfp, &bparms);
    1401         [ #  # ]:          0 :                 if (rc) {
    1402                 :          0 :                         TFP_DRV_LOG(ERR,
    1403                 :            :                                     "%s: SRAM table bulk get failed, rc:%s\n",
    1404                 :            :                                     tf_dir_2_str(parms->dir),
    1405                 :            :                                     strerror(-rc));
    1406                 :            :                 }
    1407                 :          0 :                 return rc;
    1408                 :            :         }
    1409                 :            : 
    1410         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_bulk_tbl == NULL) {
    1411                 :            :                 rc = -EOPNOTSUPP;
    1412                 :          0 :                 TFP_DRV_LOG(ERR,
    1413                 :            :                             "%s: Operation not supported, rc:%s\n",
    1414                 :            :                             tf_dir_2_str(parms->dir),
    1415                 :            :                             strerror(-rc));
    1416                 :          0 :                 return -EOPNOTSUPP;
    1417                 :            :         }
    1418                 :            : 
    1419                 :          0 :         rc = dev->ops->tf_dev_get_bulk_tbl(tfp, &bparms);
    1420         [ #  # ]:          0 :         if (rc) {
    1421                 :          0 :                 TFP_DRV_LOG(ERR,
    1422                 :            :                             "%s: Table get bulk failed, rc:%s\n",
    1423                 :            :                             tf_dir_2_str(parms->dir),
    1424                 :            :                             strerror(-rc));
    1425                 :          0 :                 return rc;
    1426                 :            :         }
    1427                 :            :         return rc;
    1428                 :            : }
    1429                 :            : 
    1430                 :          0 : int tf_get_shared_tbl_increment(struct tf *tfp,
    1431                 :            :                                 struct tf_get_shared_tbl_increment_parms *parms)
    1432                 :            : {
    1433                 :            :         int rc = 0;
    1434                 :            :         struct tf_session *tfs;
    1435                 :            :         struct tf_dev_info *dev;
    1436                 :            : 
    1437         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1438                 :            : 
    1439                 :            :         /* Retrieve the session information */
    1440                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1441         [ #  # ]:          0 :         if (rc) {
    1442                 :          0 :                 TFP_DRV_LOG(ERR,
    1443                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1444                 :            :                             tf_dir_2_str(parms->dir),
    1445                 :            :                             strerror(-rc));
    1446                 :          0 :                 return rc;
    1447                 :            :         }
    1448                 :            : 
    1449                 :            :         /* Retrieve the device information */
    1450                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1451         [ #  # ]:          0 :         if (rc) {
    1452                 :          0 :                 TFP_DRV_LOG(ERR,
    1453                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1454                 :            :                             tf_dir_2_str(parms->dir),
    1455                 :            :                             strerror(-rc));
    1456                 :          0 :                 return rc;
    1457                 :            :         }
    1458                 :            : 
    1459                 :            :         /* Internal table type processing */
    1460                 :            : 
    1461         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_shared_tbl_increment == NULL) {
    1462                 :            :                 rc = -EOPNOTSUPP;
    1463                 :          0 :                 TFP_DRV_LOG(ERR,
    1464                 :            :                             "%s: Operation not supported, rc:%s\n",
    1465                 :            :                             tf_dir_2_str(parms->dir),
    1466                 :            :                             strerror(-rc));
    1467                 :          0 :                 return -EOPNOTSUPP;
    1468                 :            :         }
    1469                 :            : 
    1470                 :          0 :         rc = dev->ops->tf_dev_get_shared_tbl_increment(tfp, parms);
    1471         [ #  # ]:          0 :         if (rc) {
    1472                 :          0 :                 TFP_DRV_LOG(ERR,
    1473                 :            :                             "%s: Get table increment not supported, rc:%s\n",
    1474                 :            :                             tf_dir_2_str(parms->dir),
    1475                 :            :                             strerror(-rc));
    1476                 :          0 :                 return rc;
    1477                 :            :         }
    1478                 :            : 
    1479                 :            :         return rc;
    1480                 :            : }
    1481                 :            : 
    1482                 :            : int
    1483                 :          0 : tf_alloc_tbl_scope(struct tf *tfp,
    1484                 :            :                    struct tf_alloc_tbl_scope_parms *parms)
    1485                 :            : {
    1486                 :            :         struct tf_session *tfs;
    1487                 :            :         struct tf_dev_info *dev;
    1488                 :            :         int rc;
    1489                 :            : 
    1490         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1491                 :            : 
    1492                 :            :         /* Retrieve the session information */
    1493                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1494         [ #  # ]:          0 :         if (rc) {
    1495                 :          0 :                 TFP_DRV_LOG(ERR,
    1496                 :            :                             "Failed to lookup session, rc:%s\n",
    1497                 :            :                             strerror(-rc));
    1498                 :          0 :                 return rc;
    1499                 :            :         }
    1500                 :            : 
    1501                 :            :         /* Retrieve the device information */
    1502                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1503         [ #  # ]:          0 :         if (rc) {
    1504                 :          0 :                 TFP_DRV_LOG(ERR,
    1505                 :            :                             "Failed to lookup device, rc:%s\n",
    1506                 :            :                             strerror(-rc));
    1507                 :          0 :                 return rc;
    1508                 :            :         }
    1509                 :            : 
    1510         [ #  # ]:          0 :         if (dev->ops->tf_dev_alloc_tbl_scope != NULL) {
    1511                 :          0 :                 rc = dev->ops->tf_dev_alloc_tbl_scope(tfp, parms);
    1512                 :            :         } else {
    1513                 :          0 :                 TFP_DRV_LOG(ERR,
    1514                 :            :                             "Alloc table scope not supported by device\n");
    1515                 :          0 :                 return -EINVAL;
    1516                 :            :         }
    1517                 :            : 
    1518                 :          0 :         return rc;
    1519                 :            : }
    1520                 :            : int
    1521                 :          0 : tf_map_tbl_scope(struct tf *tfp,
    1522                 :            :                    struct tf_map_tbl_scope_parms *parms)
    1523                 :            : {
    1524                 :            :         struct tf_session *tfs;
    1525                 :            :         struct tf_dev_info *dev;
    1526                 :            :         int rc;
    1527                 :            : 
    1528         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1529                 :            : 
    1530                 :            :         /* Retrieve the session information */
    1531                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1532         [ #  # ]:          0 :         if (rc) {
    1533                 :          0 :                 TFP_DRV_LOG(ERR,
    1534                 :            :                             "Failed to lookup session, rc:%s\n",
    1535                 :            :                             strerror(-rc));
    1536                 :          0 :                 return rc;
    1537                 :            :         }
    1538                 :            : 
    1539                 :            :         /* Retrieve the device information */
    1540                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1541         [ #  # ]:          0 :         if (rc) {
    1542                 :          0 :                 TFP_DRV_LOG(ERR,
    1543                 :            :                             "Failed to lookup device, rc:%s\n",
    1544                 :            :                             strerror(-rc));
    1545                 :          0 :                 return rc;
    1546                 :            :         }
    1547                 :            : 
    1548         [ #  # ]:          0 :         if (dev->ops->tf_dev_map_tbl_scope != NULL) {
    1549                 :          0 :                 rc = dev->ops->tf_dev_map_tbl_scope(tfp, parms);
    1550                 :            :         } else {
    1551                 :          0 :                 TFP_DRV_LOG(ERR,
    1552                 :            :                             "Map table scope not supported by device\n");
    1553                 :          0 :                 return -EINVAL;
    1554                 :            :         }
    1555                 :            : 
    1556                 :          0 :         return rc;
    1557                 :            : }
    1558                 :            : 
    1559                 :            : int
    1560                 :          0 : tf_free_tbl_scope(struct tf *tfp,
    1561                 :            :                   struct tf_free_tbl_scope_parms *parms)
    1562                 :            : {
    1563                 :            :         struct tf_session *tfs;
    1564                 :            :         struct tf_dev_info *dev;
    1565                 :            :         int rc;
    1566                 :            : 
    1567         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1568                 :            : 
    1569                 :            :         /* Retrieve the session information */
    1570                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1571         [ #  # ]:          0 :         if (rc) {
    1572                 :          0 :                 TFP_DRV_LOG(ERR,
    1573                 :            :                             "Failed to lookup session, rc:%s\n",
    1574                 :            :                             strerror(-rc));
    1575                 :          0 :                 return rc;
    1576                 :            :         }
    1577                 :            : 
    1578                 :            :         /* Retrieve the device information */
    1579                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1580         [ #  # ]:          0 :         if (rc) {
    1581                 :          0 :                 TFP_DRV_LOG(ERR,
    1582                 :            :                             "Failed to lookup device, rc:%s\n",
    1583                 :            :                             strerror(-rc));
    1584                 :          0 :                 return rc;
    1585                 :            :         }
    1586                 :            : 
    1587         [ #  # ]:          0 :         if (dev->ops->tf_dev_free_tbl_scope) {
    1588                 :          0 :                 rc = dev->ops->tf_dev_free_tbl_scope(tfp, parms);
    1589                 :            :         } else {
    1590                 :          0 :                 TFP_DRV_LOG(ERR,
    1591                 :            :                             "Free table scope not supported by device\n");
    1592                 :          0 :                 return -EINVAL;
    1593                 :            :         }
    1594                 :            : 
    1595                 :          0 :         return rc;
    1596                 :            : }
    1597                 :            : 
    1598                 :            : int
    1599                 :          0 : tf_set_if_tbl_entry(struct tf *tfp,
    1600                 :            :                     struct tf_set_if_tbl_entry_parms *parms)
    1601                 :            : {
    1602                 :            :         int rc;
    1603                 :            :         struct tf_session *tfs;
    1604                 :            :         struct tf_dev_info *dev;
    1605                 :          0 :         struct tf_if_tbl_set_parms sparms = { 0 };
    1606                 :            : 
    1607         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1608                 :            : 
    1609                 :            :         /* Retrieve the session information */
    1610                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1611         [ #  # ]:          0 :         if (rc) {
    1612                 :          0 :                 TFP_DRV_LOG(ERR,
    1613                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1614                 :            :                             tf_dir_2_str(parms->dir),
    1615                 :            :                             strerror(-rc));
    1616                 :          0 :                 return rc;
    1617                 :            :         }
    1618                 :            : 
    1619                 :            :         /* Retrieve the device information */
    1620                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1621         [ #  # ]:          0 :         if (rc) {
    1622                 :          0 :                 TFP_DRV_LOG(ERR,
    1623                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1624                 :            :                             tf_dir_2_str(parms->dir),
    1625                 :            :                             strerror(-rc));
    1626                 :          0 :                 return rc;
    1627                 :            :         }
    1628                 :            : 
    1629         [ #  # ]:          0 :         if (dev->ops->tf_dev_set_if_tbl == NULL) {
    1630                 :            :                 rc = -EOPNOTSUPP;
    1631                 :          0 :                 TFP_DRV_LOG(ERR,
    1632                 :            :                             "%s: Operation not supported, rc:%s\n",
    1633                 :            :                             tf_dir_2_str(parms->dir),
    1634                 :            :                             strerror(-rc));
    1635                 :          0 :                 return rc;
    1636                 :            :         }
    1637                 :            : 
    1638                 :          0 :         sparms.dir = parms->dir;
    1639                 :          0 :         sparms.type = parms->type;
    1640                 :          0 :         sparms.idx = parms->idx;
    1641                 :          0 :         sparms.data_sz_in_bytes = parms->data_sz_in_bytes;
    1642                 :          0 :         sparms.data = parms->data;
    1643                 :            : 
    1644                 :          0 :         rc = dev->ops->tf_dev_set_if_tbl(tfp, &sparms);
    1645         [ #  # ]:          0 :         if (rc) {
    1646                 :          0 :                 TFP_DRV_LOG(ERR,
    1647                 :            :                             "%s: If_tbl set failed, rc:%s\n",
    1648                 :            :                             tf_dir_2_str(parms->dir),
    1649                 :            :                             strerror(-rc));
    1650                 :          0 :                 return rc;
    1651                 :            :         }
    1652                 :            : 
    1653                 :            :         return 0;
    1654                 :            : }
    1655                 :            : 
    1656                 :            : int
    1657                 :          0 : tf_get_if_tbl_entry(struct tf *tfp,
    1658                 :            :                     struct tf_get_if_tbl_entry_parms *parms)
    1659                 :            : {
    1660                 :            :         int rc;
    1661                 :            :         struct tf_session *tfs;
    1662                 :            :         struct tf_dev_info *dev;
    1663                 :          0 :         struct tf_if_tbl_get_parms gparms = { 0 };
    1664                 :            : 
    1665         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1666                 :            : 
    1667                 :            :         /* Retrieve the session information */
    1668                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1669         [ #  # ]:          0 :         if (rc) {
    1670                 :          0 :                 TFP_DRV_LOG(ERR,
    1671                 :            :                             "%s: Failed to lookup session, rc:%s\n",
    1672                 :            :                             tf_dir_2_str(parms->dir),
    1673                 :            :                             strerror(-rc));
    1674                 :          0 :                 return rc;
    1675                 :            :         }
    1676                 :            : 
    1677                 :            :         /* Retrieve the device information */
    1678                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1679         [ #  # ]:          0 :         if (rc) {
    1680                 :          0 :                 TFP_DRV_LOG(ERR,
    1681                 :            :                             "%s: Failed to lookup device, rc:%s\n",
    1682                 :            :                             tf_dir_2_str(parms->dir),
    1683                 :            :                             strerror(-rc));
    1684                 :          0 :                 return rc;
    1685                 :            :         }
    1686                 :            : 
    1687         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_if_tbl == NULL) {
    1688                 :            :                 rc = -EOPNOTSUPP;
    1689                 :          0 :                 TFP_DRV_LOG(ERR,
    1690                 :            :                             "%s: Operation not supported, rc:%s\n",
    1691                 :            :                             tf_dir_2_str(parms->dir),
    1692                 :            :                             strerror(-rc));
    1693                 :          0 :                 return rc;
    1694                 :            :         }
    1695                 :            : 
    1696                 :          0 :         gparms.dir = parms->dir;
    1697                 :          0 :         gparms.type = parms->type;
    1698                 :          0 :         gparms.idx = parms->idx;
    1699                 :          0 :         gparms.data_sz_in_bytes = parms->data_sz_in_bytes;
    1700                 :          0 :         gparms.data = parms->data;
    1701                 :            : 
    1702                 :          0 :         rc = dev->ops->tf_dev_get_if_tbl(tfp, &gparms);
    1703         [ #  # ]:          0 :         if (rc) {
    1704                 :          0 :                 TFP_DRV_LOG(ERR,
    1705                 :            :                             "%s: If_tbl get failed, rc:%s\n",
    1706                 :            :                             tf_dir_2_str(parms->dir),
    1707                 :            :                             strerror(-rc));
    1708                 :          0 :                 return rc;
    1709                 :            :         }
    1710                 :            : 
    1711                 :            :         return 0;
    1712                 :            : }
    1713                 :            : 
    1714                 :          0 : int tf_get_session_info(struct tf *tfp,
    1715                 :            :                         struct tf_get_session_info_parms *parms)
    1716                 :            : {
    1717                 :            :         int rc;
    1718                 :            :         struct tf_session      *tfs;
    1719                 :            :         struct tf_dev_info     *dev;
    1720                 :            : 
    1721         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1722                 :            : 
    1723                 :            :         /* Retrieve the session information */
    1724                 :          0 :         rc = tf_session_get_session(tfp, &tfs);
    1725         [ #  # ]:          0 :         if (rc) {
    1726                 :          0 :                 TFP_DRV_LOG(ERR,
    1727                 :            :                             "Failed to lookup session, rc:%s\n",
    1728                 :            :                             strerror(-rc));
    1729                 :          0 :                 return rc;
    1730                 :            :         }
    1731                 :            : 
    1732                 :            :         /* Retrieve the device information */
    1733                 :          0 :         rc = tf_session_get_device(tfs, &dev);
    1734         [ #  # ]:          0 :         if (rc) {
    1735                 :          0 :                 TFP_DRV_LOG(ERR,
    1736                 :            :                             "Failed to lookup device, rc:%s\n",
    1737                 :            :                             strerror(-rc));
    1738                 :          0 :                 return rc;
    1739                 :            :         }
    1740                 :            : 
    1741                 :            :         TF_CHECK_PARMS2(tfp, parms);
    1742                 :            : 
    1743         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_ident_resc_info == NULL) {
    1744                 :            :                 rc = -EOPNOTSUPP;
    1745                 :          0 :                 TFP_DRV_LOG(ERR,
    1746                 :            :                             "Operation not supported, rc:%s\n",
    1747                 :            :                             strerror(-rc));
    1748                 :          0 :                 return rc;
    1749                 :            :         }
    1750                 :            : 
    1751                 :          0 :         rc = dev->ops->tf_dev_get_ident_resc_info(tfp, parms->session_info.ident);
    1752         [ #  # ]:          0 :         if (rc) {
    1753                 :          0 :                 TFP_DRV_LOG(ERR,
    1754                 :            :                             "Ident get resc info failed, rc:%s\n",
    1755                 :            :                             strerror(-rc));
    1756                 :            :         }
    1757                 :            : 
    1758         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
    1759                 :            :                 rc = -EOPNOTSUPP;
    1760                 :          0 :                 TFP_DRV_LOG(ERR,
    1761                 :            :                             "Operation not supported, rc:%s\n",
    1762                 :            :                             strerror(-rc));
    1763                 :          0 :                 return rc;
    1764                 :            :         }
    1765                 :            : 
    1766                 :          0 :         rc = dev->ops->tf_dev_get_tbl_resc_info(tfp, parms->session_info.tbl);
    1767         [ #  # ]:          0 :         if (rc) {
    1768                 :          0 :                 TFP_DRV_LOG(ERR,
    1769                 :            :                             "Tbl get resc info failed, rc:%s\n",
    1770                 :            :                             strerror(-rc));
    1771                 :            :         }
    1772                 :            : 
    1773         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
    1774                 :            :                 rc = -EOPNOTSUPP;
    1775                 :          0 :                 TFP_DRV_LOG(ERR,
    1776                 :            :                             "Operation not supported, rc:%s\n",
    1777                 :            :                             strerror(-rc));
    1778                 :          0 :                 return rc;
    1779                 :            :         }
    1780                 :            : 
    1781                 :          0 :         rc = dev->ops->tf_dev_get_tcam_resc_info(tfp, parms->session_info.tcam);
    1782         [ #  # ]:          0 :         if (rc) {
    1783                 :          0 :                 TFP_DRV_LOG(ERR,
    1784                 :            :                             "TCAM get resc info failed, rc:%s\n",
    1785                 :            :                             strerror(-rc));
    1786                 :            :         }
    1787                 :            : 
    1788         [ #  # ]:          0 :         if (dev->ops->tf_dev_get_em_resc_info == NULL) {
    1789                 :            :                 rc = -EOPNOTSUPP;
    1790                 :          0 :                 TFP_DRV_LOG(ERR,
    1791                 :            :                             "Operation not supported, rc:%s\n",
    1792                 :            :                             strerror(-rc));
    1793                 :          0 :                 return rc;
    1794                 :            :         }
    1795                 :            : 
    1796                 :          0 :         rc = dev->ops->tf_dev_get_em_resc_info(tfp, parms->session_info.em);
    1797         [ #  # ]:          0 :         if (rc) {
    1798                 :          0 :                 TFP_DRV_LOG(ERR,
    1799                 :            :                             "EM get resc info failed, rc:%s\n",
    1800                 :            :                             strerror(-rc));
    1801                 :            :         }
    1802                 :            : 
    1803                 :            :         return 0;
    1804                 :            : }
    1805                 :            : 
    1806                 :          0 : int tf_get_version(struct tf *tfp,
    1807                 :            :                    struct tf_get_version_parms *parms)
    1808                 :            : {
    1809                 :            :         int rc;
    1810                 :            :         struct tf_dev_info dev;
    1811                 :            : 
    1812         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1813                 :            : 
    1814                 :            :         /* This function can be called before open session, filter
    1815                 :            :          * out any non-supported device types on the Core side.
    1816                 :            :          */
    1817         [ #  # ]:          0 :         if (parms->device_type != TF_DEVICE_TYPE_P4 &&
    1818         [ #  # ]:          0 :             parms->device_type != TF_DEVICE_TYPE_P5 &&
    1819                 :            :             parms->device_type != TF_DEVICE_TYPE_SR) {
    1820                 :          0 :                 TFP_DRV_LOG(ERR,
    1821                 :            :                             "Unsupported device type %d\n",
    1822                 :            :                             parms->device_type);
    1823                 :          0 :                 return -ENOTSUP;
    1824                 :            :         }
    1825                 :            : 
    1826                 :          0 :         tf_dev_bind_ops(parms->device_type, &dev);
    1827                 :            : 
    1828                 :          0 :         rc = tf_msg_get_version(parms->bp, &dev, parms);
    1829         [ #  # ]:          0 :         if (rc)
    1830                 :          0 :                 return rc;
    1831                 :            : 
    1832                 :            :         return 0;
    1833                 :            : }
    1834                 :            : 
    1835                 :          0 : int tf_query_sram_resources(struct tf *tfp,
    1836                 :            :                             struct tf_query_sram_resources_parms *parms)
    1837                 :            : {
    1838                 :            :         int rc;
    1839                 :            :         struct tf_dev_info dev;
    1840                 :            :         uint16_t max_types;
    1841                 :            :         struct tfp_calloc_parms cparms;
    1842                 :            :         struct tf_rm_resc_req_entry *query;
    1843                 :            :         enum tf_rm_resc_resv_strategy resv_strategy;
    1844                 :            : 
    1845         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1846                 :            : 
    1847                 :            :         /* This function can be called before open session, filter
    1848                 :            :          * out any non-supported device types on the Core side.
    1849                 :            :          */
    1850         [ #  # ]:          0 :         if (parms->device_type != TF_DEVICE_TYPE_P5) {
    1851                 :          0 :                 TFP_DRV_LOG(ERR,
    1852                 :            :                             "Unsupported device type %d\n",
    1853                 :            :                             parms->device_type);
    1854                 :          0 :                 return -ENOTSUP;
    1855                 :            :         }
    1856                 :            : 
    1857                 :          0 :         tf_dev_bind_ops(parms->device_type, &dev);
    1858                 :            : 
    1859         [ #  # ]:          0 :         if (dev.ops->tf_dev_get_max_types == NULL) {
    1860                 :            :                 rc = -EOPNOTSUPP;
    1861                 :          0 :                 TFP_DRV_LOG(ERR,
    1862                 :            :                             "%s: Operation not supported, rc:%s\n",
    1863                 :            :                             tf_dir_2_str(parms->dir),
    1864                 :            :                             strerror(-rc));
    1865                 :          0 :                 return -EOPNOTSUPP;
    1866                 :            :         }
    1867                 :            : 
    1868                 :            :         /* Need device max number of elements for the RM QCAPS */
    1869                 :          0 :         rc = dev.ops->tf_dev_get_max_types(tfp, &max_types);
    1870         [ #  # ]:          0 :         if (rc) {
    1871                 :          0 :                 TFP_DRV_LOG(ERR,
    1872                 :            :                             "Get SRAM resc info failed, rc:%s\n",
    1873                 :            :                             strerror(-rc));
    1874                 :          0 :                 return rc;
    1875                 :            :         }
    1876                 :            : 
    1877                 :            :         /* Allocate memory for RM QCAPS request */
    1878                 :          0 :         cparms.nitems = max_types;
    1879                 :          0 :         cparms.size = sizeof(struct tf_rm_resc_req_entry);
    1880                 :          0 :         cparms.alignment = 0;
    1881                 :          0 :         rc = tfp_calloc(&cparms);
    1882         [ #  # ]:          0 :         if (rc)
    1883                 :            :                 return rc;
    1884                 :            : 
    1885                 :          0 :         query = (struct tf_rm_resc_req_entry *)cparms.mem_va;
    1886                 :          0 :         tfp->bp = parms->bp;
    1887                 :            : 
    1888                 :            :         /* Get Firmware Capabilities */
    1889                 :          0 :         rc = tf_msg_session_resc_qcaps(tfp,
    1890                 :            :                                        &dev,
    1891                 :            :                                        parms->dir,
    1892                 :            :                                        max_types,
    1893                 :            :                                        query,
    1894                 :            :                                        &resv_strategy,
    1895                 :            :                                        &parms->sram_profile);
    1896         [ #  # ]:          0 :         if (rc)
    1897                 :            :                 return rc;
    1898                 :            : 
    1899         [ #  # ]:          0 :         if (dev.ops->tf_dev_get_sram_resources == NULL) {
    1900                 :            :                 rc = -EOPNOTSUPP;
    1901                 :          0 :                 TFP_DRV_LOG(ERR,
    1902                 :            :                             "%s: Operation not supported, rc:%s\n",
    1903                 :            :                             tf_dir_2_str(parms->dir),
    1904                 :            :                             strerror(-rc));
    1905                 :          0 :                 return -EOPNOTSUPP;
    1906                 :            :         }
    1907                 :            : 
    1908                 :          0 :         rc = dev.ops->tf_dev_get_sram_resources((void *)query,
    1909                 :          0 :                         parms->bank_resc_count,
    1910                 :            :                         &parms->dynamic_sram_capable);
    1911         [ #  # ]:          0 :         if (rc) {
    1912                 :          0 :                 TFP_DRV_LOG(ERR,
    1913                 :            :                             "Get SRAM resc info failed, rc:%s\n",
    1914                 :            :                             strerror(-rc));
    1915                 :          0 :                 return rc;
    1916                 :            :         }
    1917                 :            : 
    1918                 :            :         return 0;
    1919                 :            : }
    1920                 :            : 
    1921                 :          0 : int tf_set_sram_policy(struct tf *tfp,
    1922                 :            :                        struct tf_set_sram_policy_parms *parms)
    1923                 :            : {
    1924                 :            :         int rc = 0;
    1925                 :            :         struct tf_dev_info dev;
    1926                 :            : 
    1927         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1928                 :            : 
    1929                 :            :         /* This function can be called before open session, filter
    1930                 :            :          * out any non-supported device types on the Core side.
    1931                 :            :          */
    1932         [ #  # ]:          0 :         if (parms->device_type != TF_DEVICE_TYPE_P5) {
    1933                 :          0 :                 TFP_DRV_LOG(ERR,
    1934                 :            :                             "Unsupported device type %d\n",
    1935                 :            :                             parms->device_type);
    1936                 :          0 :                 return -ENOTSUP;
    1937                 :            :         }
    1938                 :            : 
    1939                 :          0 :         tf_dev_bind_ops(parms->device_type, &dev);
    1940                 :            : 
    1941         [ #  # ]:          0 :         if (dev.ops->tf_dev_set_sram_policy == NULL) {
    1942                 :            :                 rc = -EOPNOTSUPP;
    1943                 :          0 :                 TFP_DRV_LOG(ERR,
    1944                 :            :                             "%s: Operation not supported, rc:%s\n",
    1945                 :            :                             tf_dir_2_str(parms->dir),
    1946                 :            :                             strerror(-rc));
    1947                 :          0 :                 return rc;
    1948                 :            :         }
    1949                 :            : 
    1950                 :          0 :         rc = dev.ops->tf_dev_set_sram_policy(parms->dir, parms->bank_id);
    1951         [ #  # ]:          0 :         if (rc) {
    1952                 :          0 :                 TFP_DRV_LOG(ERR,
    1953                 :            :                             "%s: SRAM policy set failed, rc:%s\n",
    1954                 :            :                             tf_dir_2_str(parms->dir),
    1955                 :            :                             strerror(-rc));
    1956                 :          0 :                 return rc;
    1957                 :            :         }
    1958                 :            : 
    1959                 :            :         return rc;
    1960                 :            : }
    1961                 :            : 
    1962                 :          0 : int tf_get_sram_policy(struct tf *tfp,
    1963                 :            :                        struct tf_get_sram_policy_parms *parms)
    1964                 :            : {
    1965                 :            :         int rc = 0;
    1966                 :            :         struct tf_dev_info dev;
    1967                 :            : 
    1968         [ #  # ]:          0 :         TF_CHECK_PARMS2(tfp, parms);
    1969                 :            : 
    1970                 :            :         /* This function can be called before open session, filter
    1971                 :            :          * out any non-supported device types on the Core side.
    1972                 :            :          */
    1973         [ #  # ]:          0 :         if (parms->device_type != TF_DEVICE_TYPE_P5) {
    1974                 :          0 :                 TFP_DRV_LOG(ERR,
    1975                 :            :                             "Unsupported device type %d\n",
    1976                 :            :                             parms->device_type);
    1977                 :          0 :                 return -ENOTSUP;
    1978                 :            :         }
    1979                 :            : 
    1980                 :          0 :         tf_dev_bind_ops(parms->device_type, &dev);
    1981                 :            : 
    1982         [ #  # ]:          0 :         if (dev.ops->tf_dev_get_sram_policy == NULL) {
    1983                 :            :                 rc = -EOPNOTSUPP;
    1984                 :          0 :                 TFP_DRV_LOG(ERR,
    1985                 :            :                             "%s: Operation not supported, rc:%s\n",
    1986                 :            :                             tf_dir_2_str(parms->dir),
    1987                 :            :                             strerror(-rc));
    1988                 :          0 :                 return rc;
    1989                 :            :         }
    1990                 :            : 
    1991                 :          0 :         rc = dev.ops->tf_dev_get_sram_policy(parms->dir, parms->bank_id);
    1992         [ #  # ]:          0 :         if (rc) {
    1993                 :          0 :                 TFP_DRV_LOG(ERR,
    1994                 :            :                             "%s: SRAM policy get failed, rc:%s\n",
    1995                 :            :                             tf_dir_2_str(parms->dir),
    1996                 :            :                             strerror(-rc));
    1997                 :          0 :                 return rc;
    1998                 :            :         }
    1999                 :            : 
    2000                 :            :         return rc;
    2001                 :            : }
    2002                 :            : 
    2003                 :          0 : int tf_set_session_hotup_state(struct tf *tfp,
    2004                 :            :                                struct tf_set_session_hotup_state_parms *parms)
    2005                 :            : {
    2006                 :            :         int rc = 0;
    2007                 :            : 
    2008         [ #  # ]:          0 :         TF_CHECK_PARMS1(tfp);
    2009                 :            : 
    2010                 :          0 :         rc = tf_session_set_hotup_state(tfp, parms);
    2011         [ #  # ]:          0 :         if (rc)
    2012                 :          0 :                 return rc;
    2013                 :            : 
    2014                 :            :         return rc;
    2015                 :            : }
    2016                 :            : 
    2017                 :          0 : int tf_get_session_hotup_state(struct tf *tfp,
    2018                 :            :                                struct tf_get_session_hotup_state_parms *parms)
    2019                 :            : {
    2020                 :            :         int rc = 0;
    2021                 :            : 
    2022         [ #  # ]:          0 :         TF_CHECK_PARMS1(tfp);
    2023                 :            : 
    2024                 :          0 :         rc = tf_session_get_hotup_state(tfp, parms);
    2025         [ #  # ]:          0 :         if (rc)
    2026                 :          0 :                 return rc;
    2027                 :            : 
    2028                 :            :         return rc;
    2029                 :            : }

Generated by: LCOV version 1.14