net/bnxt: match flow API actions with flow template actions
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Wed, 15 Apr 2020 08:19:01 +0000 (13:49 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:08 +0000 (13:57 +0200)
This patch does the following
1. Takes act_bitmap generated from the rte_flow_actions
2. Iterates through the static act_bitmap list
3. Returns success if a match is found, otherwise an error

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_matcher.c
drivers/net/bnxt/tf_ulp/ulp_matcher.h
drivers/net/bnxt/tf_ulp/ulp_template_db.c
drivers/net/bnxt/tf_ulp/ulp_template_db.h
drivers/net/bnxt/tf_ulp/ulp_template_struct.h

index f367e4c..ec4121d 100644 (file)
@@ -150,3 +150,39 @@ ulp_matcher_pattern_match(enum ulp_direction_type   dir,
        *class_id = 0;
        return BNXT_TF_RC_ERROR;
 }
+
+/*
+ * Function to handle the matching of RTE Flows and validating
+ * the action against the flow templates.
+ */
+int32_t
+ulp_matcher_action_match(enum ulp_direction_type               dir,
+                        struct ulp_rte_act_bitmap              *act_bitmap,
+                        uint32_t                               *act_id)
+{
+       struct bnxt_ulp_action_match_info       *sel_act_match;
+       uint32_t                                act_num, idx;
+
+       /* Select the ingress or egress template to match against */
+       if (dir == ULP_DIR_INGRESS) {
+               sel_act_match = ulp_ingress_act_match_list;
+               act_num = BNXT_ULP_INGRESS_ACT_MATCH_SZ;
+       } else {
+               sel_act_match = ulp_egress_act_match_list;
+               act_num = BNXT_ULP_EGRESS_ACT_MATCH_SZ;
+       }
+
+       /* Loop through the list of action templates to find the match */
+       for (idx = 0; idx < act_num; idx++, sel_act_match++) {
+               if (!ULP_BITSET_CMP(&sel_act_match->act_bitmap,
+                                   act_bitmap)) {
+                       *act_id = sel_act_match->act_tmpl_id;
+                       BNXT_TF_DBG(DEBUG, "Found matching act template %u\n",
+                                   *act_id);
+                       return BNXT_TF_RC_SUCCESS;
+               }
+       }
+       BNXT_TF_DBG(DEBUG, "Did not find any matching action template\n");
+       *act_id = 0;
+       return BNXT_TF_RC_ERROR;
+}
index 57a161d..c818bbe 100644 (file)
@@ -23,4 +23,13 @@ ulp_matcher_pattern_match(enum ulp_direction_type        dir,
                          struct ulp_rte_act_bitmap        *act_bitmap,
                          uint32_t                         *class_id);
 
+/*
+ * Function to handle the matching of RTE Flows and validating
+ * the action against the flow templates.
+ */
+int32_t
+ulp_matcher_action_match(enum ulp_direction_type       dir,
+                        struct ulp_rte_act_bitmap      *act_bitmap,
+                        uint32_t                       *act_id);
+
 #endif /* ULP_MATCHER_H_ */
index 9fc4b08..5a5b1f1 100644 (file)
@@ -1121,6 +1121,18 @@ struct bnxt_ulp_mapper_ident_info ulp_ident_list[] = {
        }
 };
 
+struct bnxt_ulp_action_match_info ulp_ingress_act_match_list[] = {
+       {
+       .act_bitmap = { .bits =
+               BNXT_ULP_ACTION_BIT_MARK |
+               BNXT_ULP_ACTION_BIT_RSS },
+       .act_tmpl_id = 0
+       }
+};
+
+struct bnxt_ulp_action_match_info ulp_egress_act_match_list[] = {
+};
+
 struct bnxt_ulp_mapper_tbl_list_info ulp_act_tmpl_list[] = {
        [((0 << BNXT_ULP_LOG2_MAX_NUM_DEV) | BNXT_ULP_DEVICE_ID_WH_PLUS)] = {
        .device_name = BNXT_ULP_DEVICE_ID_WH_PLUS,
index 319500a..f4850bf 100644 (file)
@@ -15,6 +15,8 @@
 #define BNXT_ULP_LOG2_MAX_NUM_DEV 2
 #define BNXT_ULP_INGRESS_HDR_MATCH_SZ 2
 #define BNXT_ULP_EGRESS_HDR_MATCH_SZ 1
+#define BNXT_ULP_INGRESS_ACT_MATCH_SZ 2
+#define BNXT_ULP_EGRESS_ACT_MATCH_SZ 1
 
 enum bnxt_ulp_action_bit {
        BNXT_ULP_ACTION_BIT_MARK             = 0x0000000000000001,
index dd06fb1..0e811ec 100644 (file)
@@ -62,6 +62,16 @@ extern struct bnxt_ulp_header_match_info  ulp_egress_hdr_match_list[];
 /* Flow field match Information Structure Array defined in template source*/
 extern struct bnxt_ulp_matcher_field_info      ulp_field_match[];
 
+/* Flow Matcher Action structures */
+struct bnxt_ulp_action_match_info {
+       struct ulp_rte_act_bitmap               act_bitmap;
+       uint32_t                                act_tmpl_id;
+};
+
+/* Flow Matcher templates Structure Array defined in template source */
+extern struct bnxt_ulp_action_match_info  ulp_ingress_act_match_list[];
+extern struct bnxt_ulp_action_match_info  ulp_egress_act_match_list[];
+
 /* Device specific parameters */
 struct bnxt_ulp_device_params {
        uint8_t                         description[16];