net/bnxt: add wildcard TCAM byte order for Thor
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Mon, 20 Sep 2021 07:42:09 +0000 (13:12 +0530)
committerAjit Khaparde <ajit.khaparde@broadcom.com>
Tue, 21 Sep 2021 04:40:00 +0000 (06:40 +0200)
The wild card TCAM for Thor platform is different from the profile TCAM
byte order.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Shuanglin Wang <shuanglin.wang@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c
drivers/net/bnxt/tf_ulp/ulp_mapper.c
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index b5bce6f..68f1b5f 100644 (file)
@@ -201,6 +201,7 @@ struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
        .key_byte_order          = BNXT_ULP_BYTE_ORDER_LE,
        .result_byte_order       = BNXT_ULP_BYTE_ORDER_LE,
        .encap_byte_order        = BNXT_ULP_BYTE_ORDER_BE,
+       .wc_key_byte_order       = BNXT_ULP_BYTE_ORDER_BE,
        .encap_byte_swap         = 1,
        .int_flow_db_num_entries = 16384,
        .ext_flow_db_num_entries = 32768,
@@ -223,6 +224,7 @@ struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
        .key_byte_order          = BNXT_ULP_BYTE_ORDER_LE,
        .result_byte_order       = BNXT_ULP_BYTE_ORDER_LE,
        .encap_byte_order        = BNXT_ULP_BYTE_ORDER_BE,
+       .wc_key_byte_order       = BNXT_ULP_BYTE_ORDER_BE,
        .encap_byte_swap         = 1,
        .int_flow_db_num_entries = 16384,
        .ext_flow_db_num_entries = 32768,
index 2687a54..bcc089b 100644 (file)
@@ -1953,6 +1953,15 @@ static void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob)
 #endif
 }
 
+static int32_t ulp_mapper_tcam_is_wc_tcam(struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+       if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
+           tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
+           tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW)
+               return 1;
+       return 0;
+}
+
 static int32_t
 ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
                            struct bnxt_ulp_mapper_tbl_info *tbl)
@@ -1972,6 +1981,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        uint32_t hit = 0;
        uint16_t tmplen = 0;
        uint16_t idx;
+       enum bnxt_ulp_byte_order key_byte_order;
 
        /* Set the key and mask to the original key and mask. */
        key = &okey;
@@ -2003,10 +2013,13 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
                return -EINVAL;
        }
 
-       if (!ulp_blob_init(key, tbl->blob_key_bit_size,
-                          dparms->key_byte_order) ||
-           !ulp_blob_init(mask, tbl->blob_key_bit_size,
-                          dparms->key_byte_order) ||
+       if (ulp_mapper_tcam_is_wc_tcam(tbl))
+               key_byte_order = dparms->wc_key_byte_order;
+       else
+               key_byte_order = dparms->key_byte_order;
+
+       if (!ulp_blob_init(key, tbl->blob_key_bit_size, key_byte_order) ||
+           !ulp_blob_init(mask, tbl->blob_key_bit_size, key_byte_order) ||
            !ulp_blob_init(&data, tbl->result_bit_size,
                           dparms->result_byte_order) ||
            !ulp_blob_init(&update_data, tbl->result_bit_size,
@@ -2043,9 +2056,7 @@ ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
        }
 
        /* For wild card tcam perform the post process to swap the blob */
-       if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
-           tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
-           tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW) {
+       if (ulp_mapper_tcam_is_wc_tcam(tbl)) {
                if (dparms->dynamic_pad_en) {
                        /* Sets up the slices for writing to the WC TCAM */
                        rc = ulp_mapper_wc_tcam_tbl_dyn_post_process(dparms,
index 904763f..e2a4b81 100644 (file)
@@ -212,6 +212,7 @@ struct bnxt_ulp_device_params {
        enum bnxt_ulp_byte_order        key_byte_order;
        enum bnxt_ulp_byte_order        result_byte_order;
        enum bnxt_ulp_byte_order        encap_byte_order;
+       enum bnxt_ulp_byte_order        wc_key_byte_order;
        uint8_t                         encap_byte_swap;
        uint8_t                         num_phy_ports;
        uint32_t                        mark_db_lfid_entries;