net/bnxt: support flow meter drop counter
authorJay Ding <jay.ding@broadcom.com>
Mon, 20 Sep 2021 07:42:04 +0000 (13:12 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Tue, 21 Sep 2021 03:16:29 +0000 (05:16 +0200)
This patch adds flow meter drop counter support for Thor.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_core/cfa_resource_types.h
drivers/net/bnxt/tf_core/tf_core.h
drivers/net/bnxt/tf_core/tf_device_p58.c
drivers/net/bnxt/tf_core/tf_device_p58.h
drivers/net/bnxt/tf_core/tf_tbl.c
drivers/net/bnxt/tf_core/tf_util.c

index cbab0d0..36a55d4 100644 (file)
 #define CFA_RESOURCE_TYPE_P58_WC_FKB             0x12UL
 /* VEB TCAM */
 #define CFA_RESOURCE_TYPE_P58_VEB_TCAM           0x13UL
+/* Metadata */
+#define CFA_RESOURCE_TYPE_P58_METADATA           0x14UL
 /* Meter drop counter */
 #define CFA_RESOURCE_TYPE_P58_METER_DROP_CNT     0x15UL
-#define CFA_RESOURCE_TYPE_P58_LAST               CFA_RESOURCE_TYPE_P58_METER_DROP_CNT
-
+#define CFA_RESOURCE_TYPE_P58_LAST              CFA_RESOURCE_TYPE_P58_METER_DROP_CNT
 
 /* Multicast Group */
 #define CFA_RESOURCE_TYPE_P45_MCG                 0x0UL
index 7e0cdf7..af8d13b 100644 (file)
@@ -283,9 +283,9 @@ enum tf_tbl_type {
        TF_TBL_TYPE_ACT_MODIFY_32B,
        /** TH 64B Modify Record */
        TF_TBL_TYPE_ACT_MODIFY_64B,
-       /** (Future) Meter Profiles */
+       /** Meter Profiles */
        TF_TBL_TYPE_METER_PROF,
-       /** (Future) Meter Instance */
+       /** Meter Instance */
        TF_TBL_TYPE_METER_INST,
        /** Wh+/SR/Th Mirror Config */
        TF_TBL_TYPE_MIRROR_CONFIG,
@@ -301,6 +301,8 @@ enum tf_tbl_type {
        TF_TBL_TYPE_EM_FKB,
        /** TH WC Flexible Key builder */
        TF_TBL_TYPE_WC_FKB,
+       /** Meter Drop Counter */
+       TF_TBL_TYPE_METER_DROP_CNT,
 
        /* External */
 
@@ -2194,6 +2196,8 @@ enum tf_global_config_type {
        TF_TUNNEL_ENCAP,  /**< Tunnel Encap Config(TECT) */
        TF_ACTION_BLOCK,  /**< Action Block Config(ABCR) */
        TF_COUNTER_CFG,   /**< Counter Configuration (CNTRS_CTRL) */
+       TF_METER_CFG,     /**< Meter Config(ACTP4_FMTCR) */
+       TF_METER_INTERVAL_CFG, /**< Meter Interval Config(FMTCR_INTERVAL)  */
        TF_GLOBAL_CFG_TYPE_MAX
 };
 
index 808dcb1..a492c62 100644 (file)
@@ -43,6 +43,7 @@ const char *tf_resource_str_p58[CFA_RESOURCE_TYPE_P58_LAST + 1] = {
        [CFA_RESOURCE_TYPE_P58_EM_FKB]             = "em_fkb  ",
        [CFA_RESOURCE_TYPE_P58_WC_FKB]             = "wc_fkb  ",
        [CFA_RESOURCE_TYPE_P58_VEB_TCAM]           = "veb     ",
+       [CFA_RESOURCE_TYPE_P58_METADATA]           = "metadata",
 };
 
 /**
index 66b0f4e..8c2e07a 100644 (file)
@@ -75,10 +75,18 @@ struct tf_rm_element_cfg tf_tbl_p58[TF_TBL_TYPE_MAX] = {
                TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER,
                0, 0, 0
        },
+       [TF_TBL_TYPE_METER_DROP_CNT] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METER_DROP_CNT,
+               0, 0, 0
+       },
        [TF_TBL_TYPE_MIRROR_CONFIG] = {
                TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_MIRROR,
                0, 0, 0
        },
+       [TF_TBL_TYPE_METADATA] = {
+               TF_RM_ELEM_CFG_HCAPI_BA, CFA_RESOURCE_TYPE_P58_METADATA,
+               0, 0, 0
+       },
        /* Policy - ARs in bank 1 */
        [TF_TBL_TYPE_FULL_ACT_RECORD] = {
                .cfg_type        = TF_RM_ELEM_CFG_HCAPI_BA_PARENT,
@@ -194,5 +202,11 @@ struct tf_global_cfg_cfg tf_global_cfg_p58[TF_GLOBAL_CFG_TYPE_MAX] = {
        [TF_COUNTER_CFG] = {
                TF_GLOBAL_CFG_CFG_HCAPI, TF_COUNTER_CFG
        },
+       [TF_METER_CFG] = {
+               TF_GLOBAL_CFG_CFG_HCAPI, TF_METER_CFG
+       },
+       [TF_METER_INTERVAL_CFG] = {
+               TF_GLOBAL_CFG_CFG_HCAPI, TF_METER_INTERVAL_CFG
+       },
 };
 #endif /* _TF_DEVICE_P58_H_ */
index e77399c..7011edc 100644 (file)
@@ -374,23 +374,28 @@ tf_tbl_set(struct tf *tfp,
                }
        }
 
-       /* Verify that the entry has been previously allocated */
-       aparms.rm_db = tbl_db->tbl_db[parms->dir];
-       aparms.subtype = parms->type;
-       TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
-
-       aparms.allocated = &allocated;
-       rc = tf_rm_is_allocated(&aparms);
-       if (rc)
-               return rc;
+       /* Do not check meter drop counter because it is not allocated
+        * resources
+        */
+       if (parms->type != TF_TBL_TYPE_METER_DROP_CNT) {
+               /* Verify that the entry has been previously allocated */
+               aparms.rm_db = tbl_db->tbl_db[parms->dir];
+               aparms.subtype = parms->type;
+               TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
+
+               aparms.allocated = &allocated;
+               rc = tf_rm_is_allocated(&aparms);
+               if (rc)
+                       return rc;
 
-       if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
-               TFP_DRV_LOG(ERR,
-                  "%s, Invalid or not allocated index, type:%d, idx:%d\n",
-                  tf_dir_2_str(parms->dir),
-                  parms->type,
-                  parms->idx);
-               return -EINVAL;
+               if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+                       TFP_DRV_LOG(ERR,
+                          "%s, Invalid or not allocated index, type:%d, idx:%d\n",
+                          tf_dir_2_str(parms->dir),
+                          parms->type,
+                          parms->idx);
+                       return -EINVAL;
+               }
        }
 
        /* Set the entry */
@@ -477,23 +482,28 @@ tf_tbl_get(struct tf *tfp,
                }
        }
 
-       /* Verify that the entry has been previously allocated */
-       aparms.rm_db = tbl_db->tbl_db[parms->dir];
-       aparms.subtype = parms->type;
-       TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
-
-       aparms.allocated = &allocated;
-       rc = tf_rm_is_allocated(&aparms);
-       if (rc)
-               return rc;
+       /* Do not check meter drop counter because it is not allocated
+        * resources.
+        */
+       if (parms->type != TF_TBL_TYPE_METER_DROP_CNT) {
+               /* Verify that the entry has been previously allocated */
+               aparms.rm_db = tbl_db->tbl_db[parms->dir];
+               aparms.subtype = parms->type;
+               TF_TBL_PTR_TO_RM(&aparms.index, parms->idx, base, shift);
+
+               aparms.allocated = &allocated;
+               rc = tf_rm_is_allocated(&aparms);
+               if (rc)
+                       return rc;
 
-       if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
-               TFP_DRV_LOG(ERR,
-                  "%s, Invalid or not allocated index, type:%d, idx:%d\n",
-                  tf_dir_2_str(parms->dir),
-                  parms->type,
-                  parms->idx);
-               return -EINVAL;
+               if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
+                       TFP_DRV_LOG(ERR,
+                          "%s, Invalid or not allocated index, type:%d, idx:%d\n",
+                          tf_dir_2_str(parms->dir),
+                          parms->type,
+                          parms->idx);
+                       return -EINVAL;
+               }
        }
 
        /* Set the entry */
index e712816..d100399 100644 (file)
@@ -112,6 +112,8 @@ tf_tbl_type_2_str(enum tf_tbl_type tbl_type)
                return "WC Flexible Key Builder";
        case TF_TBL_TYPE_EXT:
                return "External";
+       case TF_TBL_TYPE_METER_DROP_CNT:
+               return "Meter drop counter";
        default:
                return "Invalid tbl type";
        }