LCOV - code coverage report
Current view: top level - drivers/net/bnxt/tf_core - tf_device_p4.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 73 0.0 %
Date: 2024-01-22 15:35:40 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 37 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 <rte_common.h>
       7                 :            : 
       8                 :            : #include "cfa_resource_types.h"
       9                 :            : #include "tf_device.h"
      10                 :            : #include "tf_identifier.h"
      11                 :            : #include "tf_tbl.h"
      12                 :            : #include "tf_tcam.h"
      13                 :            : #include "tf_tcam_shared.h"
      14                 :            : #include "tf_em.h"
      15                 :            : #include "tf_if_tbl.h"
      16                 :            : #include "tfp.h"
      17                 :            : #include "tf_msg_common.h"
      18                 :            : 
      19                 :            : #define TF_DEV_P4_PARIF_MAX 16
      20                 :            : #define TF_DEV_P4_PF_MASK 0xfUL
      21                 :            : 
      22                 :            : const char *tf_resource_str_p4[CFA_RESOURCE_TYPE_P4_LAST + 1] = {
      23                 :            :         [CFA_RESOURCE_TYPE_P4_MCG] = "mc_group",
      24                 :            :         [CFA_RESOURCE_TYPE_P4_ENCAP_8B] = "encap_8 ",
      25                 :            :         [CFA_RESOURCE_TYPE_P4_ENCAP_16B] = "encap_16",
      26                 :            :         [CFA_RESOURCE_TYPE_P4_ENCAP_64B] = "encap_64",
      27                 :            :         [CFA_RESOURCE_TYPE_P4_SP_MAC] = "sp_mac  ",
      28                 :            :         [CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4] = "sp_macv4",
      29                 :            :         [CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6] = "sp_macv6",
      30                 :            :         [CFA_RESOURCE_TYPE_P4_COUNTER_64B] = "ctr_64b ",
      31                 :            :         [CFA_RESOURCE_TYPE_P4_NAT_PORT] = "nat_port",
      32                 :            :         [CFA_RESOURCE_TYPE_P4_NAT_IPV4] = "nat_ipv4",
      33                 :            :         [CFA_RESOURCE_TYPE_P4_METER] = "meter   ",
      34                 :            :         [CFA_RESOURCE_TYPE_P4_FLOW_STATE] = "flow_st ",
      35                 :            :         [CFA_RESOURCE_TYPE_P4_FULL_ACTION] = "full_act",
      36                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_0_ACTION] = "fmt0_act",
      37                 :            :         [CFA_RESOURCE_TYPE_P4_EXT_FORMAT_0_ACTION] = "ext0_act",
      38                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_1_ACTION] = "fmt1_act",
      39                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_2_ACTION] = "fmt2_act",
      40                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_3_ACTION] = "fmt3_act",
      41                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_4_ACTION] = "fmt4_act",
      42                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_5_ACTION] = "fmt5_act",
      43                 :            :         [CFA_RESOURCE_TYPE_P4_FORMAT_6_ACTION] = "fmt6_act",
      44                 :            :         [CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_HIGH] = "l2ctx_hi",
      45                 :            :         [CFA_RESOURCE_TYPE_P4_L2_CTXT_TCAM_LOW] = "l2ctx_lo",
      46                 :            :         [CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_HIGH] = "l2ctr_hi",
      47                 :            :         [CFA_RESOURCE_TYPE_P4_L2_CTXT_REMAP_LOW] = "l2ctr_lo",
      48                 :            :         [CFA_RESOURCE_TYPE_P4_PROF_FUNC] = "prf_func",
      49                 :            :         [CFA_RESOURCE_TYPE_P4_PROF_TCAM] = "prf_tcam",
      50                 :            :         [CFA_RESOURCE_TYPE_P4_EM_PROF_ID] = "em_prof ",
      51                 :            :         [CFA_RESOURCE_TYPE_P4_EM_REC] = "em_rec  ",
      52                 :            :         [CFA_RESOURCE_TYPE_P4_WC_TCAM_PROF_ID] = "wc_prof ",
      53                 :            :         [CFA_RESOURCE_TYPE_P4_WC_TCAM] = "wc_tcam ",
      54                 :            :         [CFA_RESOURCE_TYPE_P4_METER_PROF] = "mtr_prof",
      55                 :            :         [CFA_RESOURCE_TYPE_P4_MIRROR] = "mirror  ",
      56                 :            :         [CFA_RESOURCE_TYPE_P4_SP_TCAM] = "sp_tcam ",
      57                 :            :         [CFA_RESOURCE_TYPE_P4_TBL_SCOPE] = "tb_scope",
      58                 :            : };
      59                 :            : 
      60                 :            : struct tf_rm_element_cfg tf_tbl_p4[TF_DIR_MAX][TF_TBL_TYPE_MAX] = {
      61                 :            :         [TF_DIR_RX][TF_TBL_TYPE_FULL_ACT_RECORD] = {
      62                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION,
      63                 :            :                 0, 0
      64                 :            :         },
      65                 :            :         [TF_DIR_RX][TF_TBL_TYPE_MCAST_GROUPS] = {
      66                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG,
      67                 :            :                 0, 0
      68                 :            :         },
      69                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_8B] = {
      70                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B,
      71                 :            :                 0, 0
      72                 :            :         },
      73                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_16B] = {
      74                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B,
      75                 :            :                 0, 0
      76                 :            :         },
      77                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_ENCAP_64B] = {
      78                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B,
      79                 :            :                 0, 0
      80                 :            :         },
      81                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC] = {
      82                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC,
      83                 :            :                 0, 0
      84                 :            :         },
      85                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
      86                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4,
      87                 :            :                 0, 0
      88                 :            :         },
      89                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
      90                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6,
      91                 :            :                 0, 0
      92                 :            :         },
      93                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_STATS_64] = {
      94                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B,
      95                 :            :                 0, 0
      96                 :            :         },
      97                 :            :         [TF_DIR_RX][TF_TBL_TYPE_ACT_MODIFY_IPV4] = {
      98                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4,
      99                 :            :                 0, 0
     100                 :            :         },
     101                 :            :         [TF_DIR_RX][TF_TBL_TYPE_METER_PROF] = {
     102                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF,
     103                 :            :                 0, 0
     104                 :            :         },
     105                 :            :         [TF_DIR_RX][TF_TBL_TYPE_METER_INST] = {
     106                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER,
     107                 :            :                 0, 0
     108                 :            :         },
     109                 :            :         [TF_DIR_RX][TF_TBL_TYPE_MIRROR_CONFIG] = {
     110                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR,
     111                 :            :                 0, 0
     112                 :            :         },
     113                 :            :         [TF_DIR_TX][TF_TBL_TYPE_FULL_ACT_RECORD] = {
     114                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_FULL_ACTION,
     115                 :            :                 0, 0
     116                 :            :         },
     117                 :            :         [TF_DIR_TX][TF_TBL_TYPE_MCAST_GROUPS] = {
     118                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MCG,
     119                 :            :                 0, 0
     120                 :            :         },
     121                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_8B] = {
     122                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_8B,
     123                 :            :                 0, 0
     124                 :            :         },
     125                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_16B] = {
     126                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_16B,
     127                 :            :                 0, 0
     128                 :            :         },
     129                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_ENCAP_64B] = {
     130                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_ENCAP_64B,
     131                 :            :                 0, 0
     132                 :            :         },
     133                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC] = {
     134                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC,
     135                 :            :                 0, 0
     136                 :            :         },
     137                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = {
     138                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV4,
     139                 :            :                 0, 0
     140                 :            :         },
     141                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = {
     142                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_SP_MAC_IPV6,
     143                 :            :                 0, 0
     144                 :            :         },
     145                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_STATS_64] = {
     146                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_COUNTER_64B,
     147                 :            :                 0, 0
     148                 :            :         },
     149                 :            :         [TF_DIR_TX][TF_TBL_TYPE_ACT_MODIFY_IPV4] = {
     150                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_NAT_IPV4,
     151                 :            :                 0, 0
     152                 :            :         },
     153                 :            :         [TF_DIR_TX][TF_TBL_TYPE_METER_PROF] = {
     154                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER_PROF,
     155                 :            :                 0, 0
     156                 :            :         },
     157                 :            :         [TF_DIR_TX][TF_TBL_TYPE_METER_INST] = {
     158                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_METER,
     159                 :            :                 0, 0
     160                 :            :         },
     161                 :            :         [TF_DIR_TX][TF_TBL_TYPE_MIRROR_CONFIG] = {
     162                 :            :                 TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P4_MIRROR,
     163                 :            :                 0, 0
     164                 :            :         },
     165                 :            : };
     166                 :            : 
     167                 :            : /**
     168                 :            :  * Device specific function that retrieves the MAX number of HCAPI
     169                 :            :  * types the device supports.
     170                 :            :  *
     171                 :            :  * [in] tfp
     172                 :            :  *   Pointer to TF handle
     173                 :            :  *
     174                 :            :  * [out] max_types
     175                 :            :  *   Pointer to the MAX number of CFA resource types supported
     176                 :            :  *
     177                 :            :  * Returns
     178                 :            :  *   - (0) if successful.
     179                 :            :  *   - (-EINVAL) on failure.
     180                 :            :  */
     181                 :            : static int
     182                 :          0 : tf_dev_p4_get_max_types(struct tf *tfp,
     183                 :            :                         uint16_t *max_types)
     184                 :            : {
     185         [ #  # ]:          0 :         if (max_types == NULL || tfp == NULL)
     186                 :            :                 return -EINVAL;
     187                 :            : 
     188                 :          0 :         *max_types = CFA_RESOURCE_TYPE_P4_LAST + 1;
     189                 :            : 
     190                 :          0 :         return 0;
     191                 :            : }
     192                 :            : /**
     193                 :            :  * Device specific function that retrieves a human readable
     194                 :            :  * string to identify a CFA resource type.
     195                 :            :  *
     196                 :            :  * [in] tfp
     197                 :            :  *   Pointer to TF handle
     198                 :            :  *
     199                 :            :  * [in] resource_id
     200                 :            :  *   HCAPI CFA resource id
     201                 :            :  *
     202                 :            :  * [out] resource_str
     203                 :            :  *   Resource string
     204                 :            :  *
     205                 :            :  * Returns
     206                 :            :  *   - (0) if successful.
     207                 :            :  *   - (-EINVAL) on failure.
     208                 :            :  */
     209                 :            : static int
     210                 :          0 : tf_dev_p4_get_resource_str(struct tf *tfp __rte_unused,
     211                 :            :                            uint16_t resource_id,
     212                 :            :                            const char **resource_str)
     213                 :            : {
     214         [ #  # ]:          0 :         if (resource_str == NULL)
     215                 :            :                 return -EINVAL;
     216                 :            : 
     217         [ #  # ]:          0 :         if (resource_id > CFA_RESOURCE_TYPE_P4_LAST)
     218                 :            :                 return -EINVAL;
     219                 :            : 
     220                 :          0 :         *resource_str = tf_resource_str_p4[resource_id];
     221                 :            : 
     222                 :          0 :         return 0;
     223                 :            : }
     224                 :            : 
     225                 :            : /**
     226                 :            :  * Device specific function that set the WC TCAM slices the
     227                 :            :  * device supports.
     228                 :            :  *
     229                 :            :  * [in] tfp
     230                 :            :  *   Pointer to TF handle
     231                 :            :  *
     232                 :            :  * [in] num_slices_per_row
     233                 :            :  *   The WC TCAM row slice configuration
     234                 :            :  *
     235                 :            :  * Returns
     236                 :            :  *   - (0) if successful.
     237                 :            :  *   - (-EINVAL) on failure.
     238                 :            :  */
     239                 :            : static int
     240                 :          0 : tf_dev_p4_set_tcam_slice_info(struct tf *tfp,
     241                 :            :                               enum tf_wc_num_slice num_slices_per_row)
     242                 :            : {
     243                 :            :         int rc;
     244                 :          0 :         struct tf_session *tfs = NULL;
     245                 :            : 
     246                 :            :         /* Retrieve the session information */
     247                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     248         [ #  # ]:          0 :         if (rc)
     249                 :            :                 return rc;
     250                 :            : 
     251         [ #  # ]:          0 :         switch (num_slices_per_row) {
     252                 :          0 :         case TF_WC_TCAM_1_SLICE_PER_ROW:
     253                 :            :         case TF_WC_TCAM_2_SLICE_PER_ROW:
     254                 :            :         case TF_WC_TCAM_4_SLICE_PER_ROW:
     255                 :          0 :                 tfs->wc_num_slices_per_row = num_slices_per_row;
     256                 :            :         break;
     257                 :            :         default:
     258                 :            :                 return -EINVAL;
     259                 :            :         }
     260                 :            : 
     261                 :          0 :         return 0;
     262                 :            : }
     263                 :            : 
     264                 :            : /**
     265                 :            :  * Device specific function that retrieves the TCAM slices the
     266                 :            :  * device supports.
     267                 :            :  *
     268                 :            :  * [in] tfp
     269                 :            :  *   Pointer to TF handle
     270                 :            :  *
     271                 :            :  * [in] type
     272                 :            :  *   TF TCAM type
     273                 :            :  *
     274                 :            :  * [in] key_sz
     275                 :            :  *   The key size
     276                 :            :  *
     277                 :            :  * [out] num_slices_per_row
     278                 :            :  *   Pointer to the WC TCAM row slice configuration
     279                 :            :  *
     280                 :            :  * Returns
     281                 :            :  *   - (0) if successful.
     282                 :            :  *   - (-EINVAL) on failure.
     283                 :            :  */
     284                 :            : static int
     285                 :          0 : tf_dev_p4_get_tcam_slice_info(struct tf *tfp,
     286                 :            :                               enum tf_tcam_tbl_type type,
     287                 :            :                               uint16_t key_sz,
     288                 :            :                               uint16_t *num_slices_per_row)
     289                 :            : {
     290                 :            :         int rc;
     291                 :            :         struct tf_session *tfs;
     292                 :            : 
     293                 :            :         /* Retrieve the session information */
     294                 :          0 :         rc = tf_session_get_session_internal(tfp, &tfs);
     295         [ #  # ]:          0 :         if (rc)
     296                 :            :                 return rc;
     297                 :            : 
     298                 :            : /* Single slice support */
     299                 :            : #define CFA_P4_WC_TCAM_SLICE_SIZE   (12)
     300         [ #  # ]:          0 :         if (type == TF_TCAM_TBL_TYPE_WC_TCAM) {
     301         [ #  # ]:          0 :                 if (key_sz <= 1 * CFA_P4_WC_TCAM_SLICE_SIZE)
     302                 :          0 :                         *num_slices_per_row = TF_WC_TCAM_1_SLICE_PER_ROW;
     303         [ #  # ]:          0 :                 else if (key_sz <= 2 * CFA_P4_WC_TCAM_SLICE_SIZE)
     304                 :          0 :                         *num_slices_per_row = TF_WC_TCAM_2_SLICE_PER_ROW;
     305         [ #  # ]:          0 :                 else if (key_sz <= 4 * CFA_P4_WC_TCAM_SLICE_SIZE)
     306                 :          0 :                         *num_slices_per_row = TF_WC_TCAM_4_SLICE_PER_ROW;
     307                 :            :                 else
     308                 :            :                         return -ENOTSUP;
     309                 :            :         } else { /* for other type of tcam */
     310                 :          0 :                 *num_slices_per_row = 1;
     311                 :            :         }
     312                 :            : 
     313                 :            :         return 0;
     314                 :            : }
     315                 :            : 
     316                 :            : static int
     317                 :          0 : tf_dev_p4_map_parif(struct tf *tfp __rte_unused,
     318                 :            :                     uint16_t parif_bitmask,
     319                 :            :                     uint16_t pf,
     320                 :            :                     uint8_t *data,
     321                 :            :                     uint8_t *mask,
     322                 :            :                     uint16_t sz_in_bytes)
     323                 :            : {
     324                 :          0 :         uint32_t parif_pf[2] = { 0 };
     325                 :          0 :         uint32_t parif_pf_mask[2] = { 0 };
     326                 :            :         uint32_t parif;
     327                 :            :         uint32_t shift;
     328                 :            : 
     329         [ #  # ]:          0 :         if (sz_in_bytes != sizeof(uint64_t))
     330                 :            :                 return -ENOTSUP;
     331                 :            : 
     332         [ #  # ]:          0 :         for (parif = 0; parif < TF_DEV_P4_PARIF_MAX; parif++) {
     333         [ #  # ]:          0 :                 if (parif_bitmask & (1UL << parif)) {
     334         [ #  # ]:          0 :                         if (parif < 8) {
     335                 :          0 :                                 shift = 4 * parif;
     336                 :          0 :                                 parif_pf_mask[0] |= TF_DEV_P4_PF_MASK << shift;
     337                 :          0 :                                 parif_pf[0] |= pf << shift;
     338                 :            :                         } else {
     339                 :          0 :                                 shift = 4 * (parif - 8);
     340                 :          0 :                                 parif_pf_mask[1] |= TF_DEV_P4_PF_MASK << shift;
     341                 :          0 :                                 parif_pf[1] |= pf << shift;
     342                 :            :                         }
     343                 :            :                 }
     344                 :            :         }
     345                 :          0 :         tfp_memcpy(data, parif_pf, sz_in_bytes);
     346                 :          0 :         tfp_memcpy(mask, parif_pf_mask, sz_in_bytes);
     347                 :            : 
     348                 :          0 :         return 0;
     349                 :            : }
     350                 :            : 
     351                 :            : /**
     352                 :            :  * Device specific function that retrieves the increment
     353                 :            :  * required for certain table types in a shared session
     354                 :            :  *
     355                 :            :  * [in] tfp
     356                 :            :  *  tf handle
     357                 :            :  *
     358                 :            :  * [in/out] parms
     359                 :            :  *   pointer to parms structure
     360                 :            :  *
     361                 :            :  * Returns
     362                 :            :  *   - (0) if successful.
     363                 :            :  *   - (-EINVAL) on failure.
     364                 :            :  */
     365                 :          0 : static int tf_dev_p4_get_shared_tbl_increment(struct tf *tfp __rte_unused,
     366                 :            :                                 struct tf_get_shared_tbl_increment_parms *parms)
     367                 :            : {
     368                 :          0 :         parms->increment_cnt = 1;
     369                 :          0 :         return 0;
     370                 :            : }
     371                 :          0 : static int tf_dev_p4_get_mailbox(void)
     372                 :            : {
     373                 :          0 :         return TF_KONG_MB;
     374                 :            : }
     375                 :            : 
     376                 :          0 : static int tf_dev_p4_word_align(uint16_t size)
     377                 :            : {
     378                 :          0 :         return ((((size) + 31) >> 5) * 4);
     379                 :            : }
     380                 :            : 
     381                 :            : /**
     382                 :            :  * Indicates whether the index table type is SRAM managed
     383                 :            :  *
     384                 :            :  * [in] tfp
     385                 :            :  *   Pointer to TF handle
     386                 :            :  *
     387                 :            :  * [in] type
     388                 :            :  *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
     389                 :            :  *
     390                 :            :  * Returns
     391                 :            :  *   - (0) if the table is not managed by the SRAM manager
     392                 :            :  *   - (1) if the table is managed by the SRAM manager
     393                 :            :  */
     394                 :          0 : static bool tf_dev_p4_is_sram_managed(struct tf *tfp __rte_unused,
     395                 :            :                                       enum tf_tbl_type type __rte_unused)
     396                 :            : {
     397                 :          0 :         return false;
     398                 :            : }
     399                 :            : 
     400                 :            : /**
     401                 :            :  * Device specific function that maps the hcapi resource types
     402                 :            :  * to Truflow type.
     403                 :            :  *
     404                 :            :  * [in] hcapi_caps
     405                 :            :  *   CFA resource type bitmap
     406                 :            :  *
     407                 :            :  * [out] ident_caps
     408                 :            :  *   Pointer to identifier type bitmap
     409                 :            :  *
     410                 :            :  * [out] tcam_caps
     411                 :            :  *   Pointer to tcam type bitmap
     412                 :            :  *
     413                 :            :  * [out] tbl_caps
     414                 :            :  *   Pointer to table type bitmap
     415                 :            :  *
     416                 :            :  * [out] em_caps
     417                 :            :  *   Pointer to em type bitmap
     418                 :            :  *
     419                 :            :  * Returns
     420                 :            :  *   - (0) if successful.
     421                 :            :  *   - (-EINVAL) on failure.
     422                 :            :  */
     423                 :          0 : static int tf_dev_p4_map_hcapi_caps(uint64_t hcapi_caps,
     424                 :            :                                     uint32_t *ident_caps,
     425                 :            :                                     uint32_t *tcam_caps,
     426                 :            :                                     uint32_t *tbl_caps,
     427                 :            :                                     uint32_t *em_caps)
     428                 :            : {
     429                 :            :         uint32_t i;
     430                 :            : 
     431                 :          0 :         *ident_caps = 0;
     432                 :          0 :         *tcam_caps = 0;
     433                 :          0 :         *tbl_caps = 0;
     434                 :          0 :         *em_caps = 0;
     435                 :            : 
     436         [ #  # ]:          0 :         for (i = 0; i <= CFA_RESOURCE_TYPE_P4_LAST; i++) {
     437         [ #  # ]:          0 :                 if (hcapi_caps & 1ULL << i) {
     438   [ #  #  #  #  :          0 :                         switch (tf_hcapi_res_map_p4[i].module_type) {
                      # ]
     439                 :          0 :                         case TF_MODULE_TYPE_IDENTIFIER:
     440                 :          0 :                                 *ident_caps |= tf_hcapi_res_map_p4[i].type_caps;
     441                 :          0 :                                 break;
     442                 :          0 :                         case TF_MODULE_TYPE_TABLE:
     443                 :          0 :                                 *tbl_caps |= tf_hcapi_res_map_p4[i].type_caps;
     444                 :          0 :                                 break;
     445                 :          0 :                         case TF_MODULE_TYPE_TCAM:
     446                 :          0 :                                 *tcam_caps |= tf_hcapi_res_map_p4[i].type_caps;
     447                 :          0 :                                 break;
     448                 :          0 :                         case TF_MODULE_TYPE_EM:
     449                 :          0 :                                 *em_caps |= tf_hcapi_res_map_p4[i].type_caps;
     450                 :          0 :                                 break;
     451                 :            :                         default:
     452                 :            :                                 return -EINVAL;
     453                 :            :                         }
     454                 :            :                 }
     455                 :            :         }
     456                 :            : 
     457                 :            :         return 0;
     458                 :            : }
     459                 :            : 
     460                 :            : /**
     461                 :            :  * Truflow P4 device specific functions
     462                 :            :  */
     463                 :            : const struct tf_dev_ops tf_dev_ops_p4_init = {
     464                 :            :         .tf_dev_get_max_types = tf_dev_p4_get_max_types,
     465                 :            :         .tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
     466                 :            :         .tf_dev_set_tcam_slice_info = tf_dev_p4_set_tcam_slice_info,
     467                 :            :         .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
     468                 :            :         .tf_dev_alloc_ident = NULL,
     469                 :            :         .tf_dev_free_ident = NULL,
     470                 :            :         .tf_dev_search_ident = NULL,
     471                 :            :         .tf_dev_get_ident_resc_info = NULL,
     472                 :            :         .tf_dev_get_tbl_info = NULL,
     473                 :            :         .tf_dev_is_sram_managed = tf_dev_p4_is_sram_managed,
     474                 :            :         .tf_dev_alloc_ext_tbl = NULL,
     475                 :            :         .tf_dev_alloc_tbl = NULL,
     476                 :            :         .tf_dev_alloc_sram_tbl = NULL,
     477                 :            :         .tf_dev_free_ext_tbl = NULL,
     478                 :            :         .tf_dev_free_tbl = NULL,
     479                 :            :         .tf_dev_free_sram_tbl = NULL,
     480                 :            :         .tf_dev_set_tbl = NULL,
     481                 :            :         .tf_dev_set_ext_tbl = NULL,
     482                 :            :         .tf_dev_set_sram_tbl = NULL,
     483                 :            :         .tf_dev_get_tbl = NULL,
     484                 :            :         .tf_dev_get_sram_tbl = NULL,
     485                 :            :         .tf_dev_get_bulk_tbl = NULL,
     486                 :            :         .tf_dev_get_bulk_sram_tbl = NULL,
     487                 :            :         .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
     488                 :            :         .tf_dev_get_tbl_resc_info = NULL,
     489                 :            :         .tf_dev_alloc_tcam = NULL,
     490                 :            :         .tf_dev_free_tcam = NULL,
     491                 :            :         .tf_dev_alloc_search_tcam = NULL,
     492                 :            :         .tf_dev_set_tcam = NULL,
     493                 :            :         .tf_dev_get_tcam = NULL,
     494                 :            :         .tf_dev_get_tcam_resc_info = NULL,
     495                 :            :         .tf_dev_insert_int_em_entry = NULL,
     496                 :            :         .tf_dev_delete_int_em_entry = NULL,
     497                 :            :         .tf_dev_insert_ext_em_entry = NULL,
     498                 :            :         .tf_dev_delete_ext_em_entry = NULL,
     499                 :            :         .tf_dev_get_em_resc_info = NULL,
     500                 :            :         .tf_dev_alloc_tbl_scope = NULL,
     501                 :            :         .tf_dev_map_tbl_scope = NULL,
     502                 :            :         .tf_dev_map_parif = NULL,
     503                 :            :         .tf_dev_free_tbl_scope = NULL,
     504                 :            :         .tf_dev_set_if_tbl = NULL,
     505                 :            :         .tf_dev_get_if_tbl = NULL,
     506                 :            :         .tf_dev_set_global_cfg = NULL,
     507                 :            :         .tf_dev_get_global_cfg = NULL,
     508                 :            :         .tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
     509                 :            :         .tf_dev_word_align = NULL,
     510                 :            :         .tf_dev_map_hcapi_caps = tf_dev_p4_map_hcapi_caps,
     511                 :            :         .tf_dev_get_sram_resources = NULL,
     512                 :            :         .tf_dev_set_sram_policy = NULL,
     513                 :            :         .tf_dev_get_sram_policy = NULL,
     514                 :            : };
     515                 :            : 
     516                 :            : /**
     517                 :            :  * Truflow P4 device specific functions
     518                 :            :  */
     519                 :            : const struct tf_dev_ops tf_dev_ops_p4 = {
     520                 :            :         .tf_dev_get_max_types = tf_dev_p4_get_max_types,
     521                 :            :         .tf_dev_get_resource_str = tf_dev_p4_get_resource_str,
     522                 :            :         .tf_dev_set_tcam_slice_info = tf_dev_p4_set_tcam_slice_info,
     523                 :            :         .tf_dev_get_tcam_slice_info = tf_dev_p4_get_tcam_slice_info,
     524                 :            :         .tf_dev_alloc_ident = tf_ident_alloc,
     525                 :            :         .tf_dev_free_ident = tf_ident_free,
     526                 :            :         .tf_dev_search_ident = tf_ident_search,
     527                 :            :         .tf_dev_get_ident_resc_info = tf_ident_get_resc_info,
     528                 :            :         .tf_dev_get_tbl_info = NULL,
     529                 :            :         .tf_dev_is_sram_managed = tf_dev_p4_is_sram_managed,
     530                 :            :         .tf_dev_alloc_tbl = tf_tbl_alloc,
     531                 :            :         .tf_dev_alloc_ext_tbl = tf_tbl_ext_alloc,
     532                 :            :         .tf_dev_alloc_sram_tbl = tf_tbl_alloc,
     533                 :            :         .tf_dev_free_tbl = tf_tbl_free,
     534                 :            :         .tf_dev_free_ext_tbl = tf_tbl_ext_free,
     535                 :            :         .tf_dev_free_sram_tbl = tf_tbl_free,
     536                 :            :         .tf_dev_set_tbl = tf_tbl_set,
     537                 :            :         .tf_dev_set_ext_tbl = tf_tbl_ext_common_set,
     538                 :            :         .tf_dev_set_sram_tbl = NULL,
     539                 :            :         .tf_dev_get_tbl = tf_tbl_get,
     540                 :            :         .tf_dev_get_sram_tbl = NULL,
     541                 :            :         .tf_dev_get_bulk_tbl = tf_tbl_bulk_get,
     542                 :            :         .tf_dev_get_bulk_sram_tbl = NULL,
     543                 :            :         .tf_dev_get_shared_tbl_increment = tf_dev_p4_get_shared_tbl_increment,
     544                 :            :         .tf_dev_get_tbl_resc_info = tf_tbl_get_resc_info,
     545                 :            :         .tf_dev_alloc_tcam = tf_tcam_shared_alloc,
     546                 :            :         .tf_dev_free_tcam = tf_tcam_shared_free,
     547                 :            :         .tf_dev_set_tcam = tf_tcam_shared_set,
     548                 :            :         .tf_dev_get_tcam = tf_tcam_shared_get,
     549                 :            :         .tf_dev_move_tcam = tf_tcam_shared_move_p4,
     550                 :            :         .tf_dev_clear_tcam = tf_tcam_shared_clear,
     551                 :            :         .tf_dev_get_tcam_resc_info = tf_tcam_get_resc_info,
     552                 :            :         .tf_dev_insert_int_em_entry = tf_em_insert_int_entry,
     553                 :            :         .tf_dev_delete_int_em_entry = tf_em_delete_int_entry,
     554                 :            :         .tf_dev_insert_ext_em_entry = tf_em_insert_ext_entry,
     555                 :            :         .tf_dev_delete_ext_em_entry = tf_em_delete_ext_entry,
     556                 :            :         .tf_dev_get_em_resc_info = tf_em_get_resc_info,
     557                 :            :         .tf_dev_alloc_tbl_scope = tf_em_ext_common_alloc,
     558                 :            :         .tf_dev_map_tbl_scope = tf_em_ext_map_tbl_scope,
     559                 :            :         .tf_dev_map_parif = tf_dev_p4_map_parif,
     560                 :            :         .tf_dev_free_tbl_scope = tf_em_ext_common_free,
     561                 :            :         .tf_dev_set_if_tbl = tf_if_tbl_set,
     562                 :            :         .tf_dev_get_if_tbl = tf_if_tbl_get,
     563                 :            :         .tf_dev_set_global_cfg = tf_global_cfg_set,
     564                 :            :         .tf_dev_get_global_cfg = tf_global_cfg_get,
     565                 :            :         .tf_dev_get_mailbox = tf_dev_p4_get_mailbox,
     566                 :            :         .tf_dev_word_align = tf_dev_p4_word_align,
     567                 :            :         .tf_dev_cfa_key_hash = hcapi_cfa_p4_key_hash,
     568                 :            :         .tf_dev_map_hcapi_caps = tf_dev_p4_map_hcapi_caps,
     569                 :            :         .tf_dev_get_sram_resources = NULL,
     570                 :            :         .tf_dev_set_sram_policy = NULL,
     571                 :            :         .tf_dev_get_sram_policy = NULL,
     572                 :            : };

Generated by: LCOV version 1.14