net/bnxt: support src and dst port actions
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Mon, 6 Jul 2020 08:24:59 +0000 (13:54 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:53 +0000 (06:18 +0200)
Added support for set transport port source and destination
rewrite action items. This allows changing the tcp or udp
source/destination ports for a given flow.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/tf_ulp/ulp_rte_parser.c
drivers/net/bnxt/tf_ulp/ulp_rte_parser.h
drivers/net/bnxt/tf_ulp/ulp_template_db_enum.h
drivers/net/bnxt/tf_ulp/ulp_template_db_tbl.c

index ac432b2..2f6a15d 100644 (file)
@@ -1736,3 +1736,47 @@ ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item,
        BNXT_TF_DBG(ERR, "Parse Error: set ipv4 dst arg is invalid\n");
        return BNXT_TF_RC_ERROR;
 }
+
+/* Function to handle the parsing of RTE Flow action set tp src.*/
+int32_t
+ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item,
+                              struct ulp_rte_parser_params *params)
+{
+       const struct rte_flow_action_set_tp *set_tp;
+       struct ulp_rte_act_prop *act = &params->act_prop;
+
+       set_tp = action_item->conf;
+       if (set_tp) {
+               memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC],
+                      &set_tp->port, BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC);
+               /* Update the hdr_bitmap with set tp src */
+               ULP_BITMAP_SET(params->act_bitmap.bits,
+                              BNXT_ULP_ACTION_BIT_SET_TP_SRC);
+               return BNXT_TF_RC_SUCCESS;
+       }
+
+       BNXT_TF_DBG(ERR, "Parse Error: set tp src arg is invalid\n");
+       return BNXT_TF_RC_ERROR;
+}
+
+/* Function to handle the parsing of RTE Flow action set tp dst.*/
+int32_t
+ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
+                              struct ulp_rte_parser_params *params)
+{
+       const struct rte_flow_action_set_tp *set_tp;
+       struct ulp_rte_act_prop *act = &params->act_prop;
+
+       set_tp = action_item->conf;
+       if (set_tp) {
+               memcpy(&act->act_details[BNXT_ULP_ACT_PROP_IDX_SET_TP_DST],
+                      &set_tp->port, BNXT_ULP_ACT_PROP_SZ_SET_TP_DST);
+               /* Update the hdr_bitmap with set tp dst */
+               ULP_BITMAP_SET(params->act_bitmap.bits,
+                              BNXT_ULP_ACTION_BIT_SET_TP_DST);
+               return BNXT_TF_RC_SUCCESS;
+       }
+
+       BNXT_TF_DBG(ERR, "Parse Error: set tp src arg is invalid\n");
+       return BNXT_TF_RC_ERROR;
+}
index 6cb83b9..e155250 100644 (file)
@@ -206,4 +206,14 @@ int32_t
 ulp_rte_set_ipv4_dst_act_handler(const struct rte_flow_action *action_item,
                                 struct ulp_rte_parser_params *params);
 
+/* Function to handle the parsing of RTE Flow action set tp src.*/
+int32_t
+ulp_rte_set_tp_src_act_handler(const struct rte_flow_action *action_item,
+                              struct ulp_rte_parser_params *params);
+
+/* Function to handle the parsing of RTE Flow action set tp dst.*/
+int32_t
+ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
+                              struct ulp_rte_parser_params *params);
+
 #endif /* _ULP_RTE_PARSER_H_ */
index 436f54c..6b68b95 100644 (file)
@@ -560,8 +560,8 @@ enum bnxt_ulp_act_prop_sz {
        BNXT_ULP_ACT_PROP_SZ_SET_IPV4_DST = 4,
        BNXT_ULP_ACT_PROP_SZ_SET_IPV6_SRC = 16,
        BNXT_ULP_ACT_PROP_SZ_SET_IPV6_DST = 16,
-       BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC = 4,
-       BNXT_ULP_ACT_PROP_SZ_SET_TP_DST = 4,
+       BNXT_ULP_ACT_PROP_SZ_SET_TP_SRC = 2,
+       BNXT_ULP_ACT_PROP_SZ_SET_TP_DST = 2,
        BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_0 = 4,
        BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_1 = 4,
        BNXT_ULP_ACT_PROP_SZ_OF_PUSH_MPLS_2 = 4,
@@ -605,23 +605,23 @@ enum bnxt_ulp_act_prop_idx {
        BNXT_ULP_ACT_PROP_IDX_SET_IPV6_SRC = 85,
        BNXT_ULP_ACT_PROP_IDX_SET_IPV6_DST = 101,
        BNXT_ULP_ACT_PROP_IDX_SET_TP_SRC = 117,
-       BNXT_ULP_ACT_PROP_IDX_SET_TP_DST = 121,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0 = 125,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1 = 129,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2 = 133,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3 = 137,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4 = 141,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5 = 145,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6 = 149,
-       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7 = 153,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC = 157,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC = 163,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 169,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 177,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 209,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 225,
-       BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 229,
-       BNXT_ULP_ACT_PROP_IDX_LAST = 261
+       BNXT_ULP_ACT_PROP_IDX_SET_TP_DST = 119,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_0 = 121,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_1 = 125,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_2 = 129,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_3 = 133,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_4 = 137,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_5 = 141,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_6 = 145,
+       BNXT_ULP_ACT_PROP_IDX_OF_PUSH_MPLS_7 = 149,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_DMAC = 153,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_L2_SMAC = 159,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_VTAG = 165,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP = 173,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_IP_SRC = 205,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_UDP = 221,
+       BNXT_ULP_ACT_PROP_IDX_ENCAP_TUN = 225,
+       BNXT_ULP_ACT_PROP_IDX_LAST = 257
 };
 
 enum bnxt_ulp_class_hid {
index 6fa74f8..5847e58 100644 (file)
@@ -247,12 +247,12 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
                .proto_act_func          = NULL
        },
        [RTE_FLOW_ACTION_TYPE_SET_TP_SRC] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_set_tp_src_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_SET_TP_DST] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_set_tp_dst_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_MAC_SWAP] = {
                .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,