net/mlx5e: Set default can_offload action
authorPaul Blakey <paulb@nvidia.com>
Mon, 13 Mar 2023 13:38:52 +0000 (15:38 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 6 Apr 2023 01:57:31 +0000 (18:57 -0700)
Many parsers of tc actions just return true on their can_offload()
implementation, without checking the input flow/action.
Set the default can_offload action to true (allow), and avoid
having many can_offload implementations that do just that.

This patch doesn't change any functionality.

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/accept.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/drop.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/pedit.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/ptype.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/trap.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/tun.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/vlan_mangle.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index a278f52..9db1b53 100644 (file)
@@ -4,15 +4,6 @@
 #include "act.h"
 #include "en/tc_priv.h"
 
-static bool
-tc_act_can_offload_accept(struct mlx5e_tc_act_parse_state *parse_state,
-                         const struct flow_action_entry *act,
-                         int act_index,
-                         struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state,
                    const struct flow_action_entry *act,
@@ -26,7 +17,6 @@ tc_act_parse_accept(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_accept = {
-       .can_offload = tc_act_can_offload_accept,
        .parse_action = tc_act_parse_accept,
        .is_terminating_action = true,
 };
index 7d16aea..5dc8171 100644 (file)
@@ -4,15 +4,6 @@
 #include "act.h"
 #include "en/tc_priv.h"
 
-static bool
-tc_act_can_offload_drop(struct mlx5e_tc_act_parse_state *parse_state,
-                       const struct flow_action_entry *act,
-                       int act_index,
-                       struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_drop(struct mlx5e_tc_act_parse_state *parse_state,
                  const struct flow_action_entry *act,
@@ -25,7 +16,6 @@ tc_act_parse_drop(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_drop = {
-       .can_offload = tc_act_can_offload_drop,
        .parse_action = tc_act_parse_drop,
        .is_terminating_action = true,
 };
index 47597c5..3b272bb 100644 (file)
@@ -78,15 +78,6 @@ out_err:
        return err;
 }
 
-static bool
-tc_act_can_offload_pedit(struct mlx5e_tc_act_parse_state *parse_state,
-                        const struct flow_action_entry *act,
-                        int act_index,
-                        struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state,
                   const struct flow_action_entry *act,
@@ -114,6 +105,5 @@ tc_act_parse_pedit(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_pedit = {
-       .can_offload = tc_act_can_offload_pedit,
        .parse_action = tc_act_parse_pedit,
 };
index 6454b03..80b4bc6 100644 (file)
@@ -4,15 +4,6 @@
 #include "act.h"
 #include "en/tc_priv.h"
 
-static bool
-tc_act_can_offload_ptype(struct mlx5e_tc_act_parse_state *parse_state,
-                        const struct flow_action_entry *act,
-                        int act_index,
-                        struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_ptype(struct mlx5e_tc_act_parse_state *parse_state,
                   const struct flow_action_entry *act,
@@ -31,6 +22,5 @@ tc_act_parse_ptype(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_ptype = {
-       .can_offload = tc_act_can_offload_ptype,
        .parse_action = tc_act_parse_ptype,
 };
index 915ce20..1b78bd9 100644 (file)
@@ -5,15 +5,6 @@
 #include "en/tc_priv.h"
 #include "eswitch.h"
 
-static bool
-tc_act_can_offload_trap(struct mlx5e_tc_act_parse_state *parse_state,
-                       const struct flow_action_entry *act,
-                       int act_index,
-                       struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state,
                  const struct flow_action_entry *act,
@@ -27,6 +18,5 @@ tc_act_parse_trap(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_trap = {
-       .can_offload = tc_act_can_offload_trap,
        .parse_action = tc_act_parse_trap,
 };
index b4fa2de..f1cae21 100644 (file)
@@ -32,15 +32,6 @@ tc_act_parse_tun_encap(struct mlx5e_tc_act_parse_state *parse_state,
        return 0;
 }
 
-static bool
-tc_act_can_offload_tun_decap(struct mlx5e_tc_act_parse_state *parse_state,
-                            const struct flow_action_entry *act,
-                            int act_index,
-                            struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_tun_decap(struct mlx5e_tc_act_parse_state *parse_state,
                       const struct flow_action_entry *act,
@@ -58,6 +49,5 @@ struct mlx5e_tc_act mlx5e_tc_act_tun_encap = {
 };
 
 struct mlx5e_tc_act mlx5e_tc_act_tun_decap = {
-       .can_offload = tc_act_can_offload_tun_decap,
        .parse_action = tc_act_parse_tun_decap,
 };
index 2e0d88b..c8a3eaf 100644 (file)
@@ -141,15 +141,6 @@ mlx5e_tc_act_vlan_add_pop_action(struct mlx5e_priv *priv,
        return err;
 }
 
-static bool
-tc_act_can_offload_vlan(struct mlx5e_tc_act_parse_state *parse_state,
-                       const struct flow_action_entry *act,
-                       int act_index,
-                       struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
                  const struct flow_action_entry *act,
@@ -205,7 +196,6 @@ tc_act_post_parse_vlan(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_vlan = {
-       .can_offload = tc_act_can_offload_vlan,
        .parse_action = tc_act_parse_vlan,
        .post_parse = tc_act_post_parse_vlan,
 };
index 9a8a1a6..310b992 100644 (file)
@@ -50,15 +50,6 @@ mlx5e_tc_act_vlan_add_rewrite_action(struct mlx5e_priv *priv, int namespace,
        return err;
 }
 
-static bool
-tc_act_can_offload_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
-                              const struct flow_action_entry *act,
-                              int act_index,
-                              struct mlx5_flow_attr *attr)
-{
-       return true;
-}
-
 static int
 tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
                         const struct flow_action_entry *act,
@@ -81,6 +72,5 @@ tc_act_parse_vlan_mangle(struct mlx5e_tc_act_parse_state *parse_state,
 }
 
 struct mlx5e_tc_act mlx5e_tc_act_vlan_mangle = {
-       .can_offload = tc_act_can_offload_vlan_mangle,
        .parse_action = tc_act_parse_vlan_mangle,
 };
index 083ce31..4140155 100644 (file)
@@ -4096,7 +4096,7 @@ parse_tc_actions(struct mlx5e_tc_act_parse_state *parse_state,
                        goto out_free;
                }
 
-               if (!tc_act->can_offload(parse_state, act, i, attr)) {
+               if (tc_act->can_offload && !tc_act->can_offload(parse_state, act, i, attr)) {
                        err = -EOPNOTSUPP;
                        goto out_free;
                }