net/bnxt: support decrement TTL action
authorKishore Padmanabha <kishore.padmanabha@broadcom.com>
Wed, 15 Jul 2020 13:50:38 +0000 (19:20 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Jul 2020 11:54:54 +0000 (13:54 +0200)
Added support for decrement TTL action.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@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_tbl.c

index 68e59c4..4c1221a 100644 (file)
@@ -189,6 +189,26 @@ bnxt_ulp_rte_parser_post_process(struct ulp_rte_parser_params *params)
            match_port_type == BNXT_ULP_INTF_TYPE_VF_REP)
                ULP_COMP_FLD_IDX_WR(params, BNXT_ULP_CF_IDX_VF_TO_VF, 1);
 
+       /* Update the decrement ttl computational fields */
+       if (ULP_BITMAP_ISSET(params->act_bitmap.bits,
+                            BNXT_ULP_ACTION_BIT_DEC_TTL)) {
+               /*
+                * Check that vxlan proto is included and vxlan decap
+                * action is not set then decrement tunnel ttl.
+                * Similarly add GRE and NVGRE in future.
+                */
+               if ((ULP_BITMAP_ISSET(params->hdr_bitmap.bits,
+                                     BNXT_ULP_HDR_BIT_T_VXLAN) &&
+                   !ULP_BITMAP_ISSET(params->act_bitmap.bits,
+                                     BNXT_ULP_ACTION_BIT_VXLAN_DECAP))) {
+                       ULP_COMP_FLD_IDX_WR(params,
+                                           BNXT_ULP_CF_IDX_ACT_T_DEC_TTL, 1);
+               } else {
+                       ULP_COMP_FLD_IDX_WR(params,
+                                           BNXT_ULP_CF_IDX_ACT_DEC_TTL, 1);
+               }
+       }
+
        /* TBD: Handle the flow rejection scenarios */
        return 0;
 }
@@ -1814,3 +1834,13 @@ ulp_rte_set_tp_dst_act_handler(const struct rte_flow_action *action_item,
        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 dec ttl.*/
+int32_t
+ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *act __rte_unused,
+                           struct ulp_rte_parser_params *params)
+{
+       /* Update the act_bitmap with dec ttl */
+       ULP_BITMAP_SET(params->act_bitmap.bits, BNXT_ULP_ACTION_BIT_DEC_TTL);
+       return BNXT_TF_RC_SUCCESS;
+}
index e155250..7b6b57e 100644 (file)
@@ -216,4 +216,9 @@ int32_t
 ulp_rte_set_tp_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 dec ttl.*/
+int32_t
+ulp_rte_dec_ttl_act_handler(const struct rte_flow_action *action_item,
+                           struct ulp_rte_parser_params *params);
+
 #endif /* _ULP_RTE_PARSER_H_ */
index 5847e58..9a27cbf 100644 (file)
@@ -259,8 +259,8 @@ struct bnxt_ulp_rte_act_info ulp_act_info[] = {
                .proto_act_func          = NULL
        },
        [RTE_FLOW_ACTION_TYPE_DEC_TTL] = {
-               .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,
-               .proto_act_func          = NULL
+               .act_type                = BNXT_ULP_ACT_TYPE_SUPPORTED,
+               .proto_act_func          = ulp_rte_dec_ttl_act_handler
        },
        [RTE_FLOW_ACTION_TYPE_SET_TTL] = {
                .act_type                = BNXT_ULP_ACT_TYPE_NOT_SUPPORTED,