net/bnxt: support more resource functions in flow database
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Fri, 12 Jun 2020 12:49:54 +0000 (18:19 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 30 Jun 2020 12:52:30 +0000 (14:52 +0200)
Added support to include more resource functions in the flow
database. The number of bits increased from 3 to 8 for storing
the resource function.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_flow_db.c
drivers/net/bnxt/tf_ulp/ulp_flow_db.h
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_mapper.h
drivers/net/bnxt/tf_ulp/ulp_template_db.h

index 35a7f86..30a809a 100644 (file)
@@ -16,6 +16,9 @@
 #define ULP_FLOW_DB_RES_FUNC_BITS      28
 #define ULP_FLOW_DB_RES_FUNC_MASK      0x70000000
 #define ULP_FLOW_DB_RES_NXT_MASK       0x0FFFFFFF
+#define ULP_FLOW_DB_RES_FUNC_UPPER     5
+#define ULP_FLOW_DB_RES_FUNC_NEED_LOWER        0x80
+#define ULP_FLOW_DB_RES_FUNC_LOWER_MASK        0x1F
 
 /* Macro to copy the nxt_resource_idx */
 #define ULP_FLOW_DB_RES_NXT_SET(dst, src)      {(dst) |= ((src) &\
@@ -77,20 +80,32 @@ ulp_flow_db_active_flow_is_set(struct bnxt_ulp_flow_tbl     *flow_tbl,
  * returns none
  */
 static void
-ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info   *resource_info,
-                              struct ulp_flow_db_res_params  *params)
+ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info *resource_info,
+                              struct ulp_flow_db_res_params *params)
 {
+       uint32_t resource_func;
+
        resource_info->nxt_resource_idx |= ((params->direction <<
                                      ULP_FLOW_DB_RES_DIR_BIT) &
                                     ULP_FLOW_DB_RES_DIR_MASK);
-       resource_info->nxt_resource_idx |= ((params->resource_func <<
+       resource_func = (params->resource_func >> ULP_FLOW_DB_RES_FUNC_UPPER);
+       resource_info->nxt_resource_idx |= ((resource_func <<
                                             ULP_FLOW_DB_RES_FUNC_BITS) &
                                            ULP_FLOW_DB_RES_FUNC_MASK);
 
+       if (params->resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) {
+               /* Break the resource func into two parts */
+               resource_func = (params->resource_func &
+                                ULP_FLOW_DB_RES_FUNC_LOWER_MASK);
+               resource_info->resource_func_lower = resource_func;
+       }
+
+       /* Store the handle as 64bit only for EM table entries */
        if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
                resource_info->resource_hndl = (uint32_t)params->resource_hndl;
                resource_info->resource_type = params->resource_type;
-
+               resource_info->resource_sub_type = params->resource_sub_type;
+               resource_info->reserved = params->reserved;
        } else {
                resource_info->resource_em_handle = params->resource_hndl;
        }
@@ -106,22 +121,34 @@ ulp_flow_db_res_params_to_info(struct ulp_fdb_resource_info   *resource_info,
  * returns none
  */
 static void
-ulp_flow_db_res_info_to_params(struct ulp_fdb_resource_info   *resource_info,
-                              struct ulp_flow_db_res_params  *params)
+ulp_flow_db_res_info_to_params(struct ulp_fdb_resource_info *resource_info,
+                              struct ulp_flow_db_res_params *params)
 {
+       uint8_t resource_func_upper;
+
        memset(params, 0, sizeof(struct ulp_flow_db_res_params));
        params->direction = ((resource_info->nxt_resource_idx &
                                 ULP_FLOW_DB_RES_DIR_MASK) >>
                                 ULP_FLOW_DB_RES_DIR_BIT);
-       params->resource_func = ((resource_info->nxt_resource_idx &
-                                ULP_FLOW_DB_RES_FUNC_MASK) >>
-                                ULP_FLOW_DB_RES_FUNC_BITS);
+       resource_func_upper = (((resource_info->nxt_resource_idx &
+                               ULP_FLOW_DB_RES_FUNC_MASK) >>
+                              ULP_FLOW_DB_RES_FUNC_BITS) <<
+                              ULP_FLOW_DB_RES_FUNC_UPPER);
+
+       /* The reource func is split into upper and lower */
+       if (resource_func_upper & ULP_FLOW_DB_RES_FUNC_NEED_LOWER)
+               params->resource_func = (resource_func_upper |
+                                        resource_info->resource_func_lower);
+       else
+               params->resource_func = resource_func_upper;
 
-       if (params->resource_func != BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+       if (params->resource_func == BNXT_ULP_RESOURCE_FUNC_EM_TABLE) {
+               params->resource_hndl = resource_info->resource_em_handle;
+       } else if (params->resource_func & ULP_FLOW_DB_RES_FUNC_NEED_LOWER) {
                params->resource_hndl = resource_info->resource_hndl;
                params->resource_type = resource_info->resource_type;
-       } else {
-               params->resource_hndl = resource_info->resource_em_handle;
+               params->resource_sub_type = resource_info->resource_sub_type;
+               params->reserved = resource_info->reserved;
        }
 }
 
index ebca849..9037dc5 100644 (file)
 #define BNXT_FLOW_DB_DEFAULT_NUM_FLOWS         128
 #define BNXT_FLOW_DB_DEFAULT_NUM_RESOURCES     5
 
-/* Structure for the flow database resource information. */
+/*
+ * Structure for the flow database resource information
+ * The below structure is based on the below paritions
+ * nxt_resource_idx = dir[31],resource_func_upper[30:28],nxt_resource_idx[27:0]
+ * If resource_func is EM_TBL then use resource_em_handle.
+ * Else the other part of the union is used and
+ * resource_func is resource_func_upper[30:28] << 5 | resource_func_lower
+ */
 struct ulp_fdb_resource_info {
        /* Points to next resource in the chained list. */
-       uint32_t        nxt_resource_idx;
+       uint32_t                        nxt_resource_idx;
        union {
-               uint64_t        resource_em_handle;
+               uint64_t                resource_em_handle;
                struct {
-                       uint32_t        resource_type;
+                       uint8_t         resource_func_lower;
+                       uint8_t         resource_type;
+                       uint8_t         resource_sub_type;
+                       uint8_t         reserved;
                        uint32_t        resource_hndl;
                };
        };
@@ -59,9 +69,11 @@ struct bnxt_ulp_flow_db {
 struct ulp_flow_db_res_params {
        enum tf_dir                     direction;
        enum bnxt_ulp_resource_func     resource_func;
+       uint8_t                         resource_type;
+       uint8_t                         resource_sub_type;
+       uint8_t                         reserved;
+       uint8_t                         critical_resource;
        uint64_t                        resource_hndl;
-       uint32_t                        resource_type;
-       uint32_t                        critical_resource;
 };
 
 /*
index 88b5142..e60d9d5 100644 (file)
@@ -292,9 +292,8 @@ ulp_mapper_cache_res_type_set(struct ulp_flow_db_res_params *res,
                              uint16_t tbl_type,
                              uint16_t tbl_id)
 {
-       res->resource_type =
-               ((uint32_t)tbl_id << ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) |
-               ((uint32_t)tbl_type << ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT);
+       res->resource_type = tbl_type;
+       res->resource_sub_type = tbl_id;
 }
 
 /* Extracts the tbl_type and tbl_id from the 32bit resource type. */
@@ -303,12 +302,8 @@ ulp_mapper_cache_res_type_get(struct ulp_flow_db_res_params *res,
                              uint16_t *tbl_type,
                              uint16_t *tbl_id)
 {
-       *tbl_type = (uint16_t)((res->resource_type >>
-                               ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT) &
-                              ULP_MAPPER_CACHE_RES_TBL_MASK);
-       *tbl_id = (uint16_t)((res->resource_type >>
-                             ULP_MAPPER_CACHE_RES_TBL_ID_SHFT) &
-                            ULP_MAPPER_CACHE_RES_TBL_MASK);
+       *tbl_type = res->resource_type;
+       *tbl_id = res->resource_sub_type;
 }
 
 static int32_t
index e794795..1263315 100644 (file)
@@ -17,9 +17,6 @@
 
 #define ULP_SZ_BITS2BYTES(x) (((x) + 7) / 8)
 #define ULP_IDENTS_INVALID ((uint16_t)0xffff)
-#define ULP_MAPPER_CACHE_RES_TBL_ID_SHFT 16
-#define ULP_MAPPER_CACHE_RES_TBL_TYPE_SHFT 0
-#define ULP_MAPPER_CACHE_RES_TBL_MASK ((uint32_t)0x0000ffff)
 
 /*
  * The cache table opcode is used to convey informat from the cache handler
index 212068f..4e18366 100644 (file)
@@ -195,14 +195,16 @@ enum bnxt_ulp_regfile_index {
 };
 
 enum bnxt_ulp_resource_func {
-       BNXT_ULP_RESOURCE_FUNC_INVALID = 0,
-       BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 1,
-       BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 2,
-       BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 3,
-       BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 4,
-       BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 5,
-       BNXT_ULP_RESOURCE_FUNC_HW_FID = 6,
-       BNXT_ULP_RESOURCE_FUNC_LAST = 7
+       BNXT_ULP_RESOURCE_FUNC_INVALID = 0x00,
+       BNXT_ULP_RESOURCE_FUNC_EM_TABLE = 0x20,
+       BNXT_ULP_RESOURCE_FUNC_RSVD1 = 0x40,
+       BNXT_ULP_RESOURCE_FUNC_RSVD2 = 0x60,
+       BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE = 0x80,
+       BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE = 0x81,
+       BNXT_ULP_RESOURCE_FUNC_CACHE_TABLE = 0x82,
+       BNXT_ULP_RESOURCE_FUNC_IDENTIFIER = 0x83,
+       BNXT_ULP_RESOURCE_FUNC_IF_TABLE = 0x84,
+       BNXT_ULP_RESOURCE_FUNC_HW_FID = 0x85
 };
 
 enum bnxt_ulp_result_opc {