Commit f3e02e47 authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed

net/mlx5e: Use tc sample stubs instead of ifdefs in source file

Instead of having sparse ifdefs in source files use a single
ifdef in the tc sample header file and use stubs.
Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
Reviewed-by: default avatarMaor Dickman <maord@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 1cc35b70
...@@ -647,9 +647,7 @@ static void mlx5e_restore_skb_sample(struct mlx5e_priv *priv, struct sk_buff *sk ...@@ -647,9 +647,7 @@ static void mlx5e_restore_skb_sample(struct mlx5e_priv *priv, struct sk_buff *sk
"Failed to restore tunnel info for sampled packet\n"); "Failed to restore tunnel info for sampled packet\n");
return; return;
} }
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
mlx5e_tc_sample_skb(skb, mapped_obj); mlx5e_tc_sample_skb(skb, mapped_obj);
#endif /* CONFIG_MLX5_TC_SAMPLE */
mlx5_rep_tc_post_napi_receive(tc_priv); mlx5_rep_tc_post_napi_receive(tc_priv);
} }
......
...@@ -19,6 +19,8 @@ struct mlx5e_sample_attr { ...@@ -19,6 +19,8 @@ struct mlx5e_sample_attr {
struct mlx5e_sample_flow *sample_flow; struct mlx5e_sample_flow *sample_flow;
}; };
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj); void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj);
struct mlx5_flow_handle * struct mlx5_flow_handle *
...@@ -38,4 +40,29 @@ mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act); ...@@ -38,4 +40,29 @@ mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act);
void void
mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample); mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample);
#else /* CONFIG_MLX5_TC_SAMPLE */
static inline struct mlx5_flow_handle *
mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample,
struct mlx5_flow_spec *spec,
struct mlx5_flow_attr *attr,
u32 tunnel_id)
{ return ERR_PTR(-EOPNOTSUPP); }
static inline void
mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample,
struct mlx5_flow_handle *rule,
struct mlx5_flow_attr *attr) {}
static inline struct mlx5e_tc_psample *
mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act)
{ return ERR_PTR(-EOPNOTSUPP); }
static inline void
mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample) {}
static inline void
mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj) {}
#endif /* CONFIG_MLX5_TC_SAMPLE */
#endif /* __MLX5_EN_TC_SAMPLE_H__ */ #endif /* __MLX5_EN_TC_SAMPLE_H__ */
...@@ -246,7 +246,6 @@ get_ct_priv(struct mlx5e_priv *priv) ...@@ -246,7 +246,6 @@ get_ct_priv(struct mlx5e_priv *priv)
return priv->fs.tc.ct; return priv->fs.tc.ct;
} }
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
static struct mlx5e_tc_psample * static struct mlx5e_tc_psample *
get_sample_priv(struct mlx5e_priv *priv) get_sample_priv(struct mlx5e_priv *priv)
{ {
...@@ -263,7 +262,6 @@ get_sample_priv(struct mlx5e_priv *priv) ...@@ -263,7 +262,6 @@ get_sample_priv(struct mlx5e_priv *priv)
return NULL; return NULL;
} }
#endif
struct mlx5_flow_handle * struct mlx5_flow_handle *
mlx5_tc_rule_insert(struct mlx5e_priv *priv, mlx5_tc_rule_insert(struct mlx5e_priv *priv,
...@@ -1146,11 +1144,9 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw, ...@@ -1146,11 +1144,9 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,
rule = mlx5_tc_ct_flow_offload(get_ct_priv(flow->priv), rule = mlx5_tc_ct_flow_offload(get_ct_priv(flow->priv),
flow, spec, attr, flow, spec, attr,
mod_hdr_acts); mod_hdr_acts);
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
} else if (flow_flag_test(flow, SAMPLE)) { } else if (flow_flag_test(flow, SAMPLE)) {
rule = mlx5e_tc_sample_offload(get_sample_priv(flow->priv), spec, attr, rule = mlx5e_tc_sample_offload(get_sample_priv(flow->priv), spec, attr,
mlx5e_tc_get_flow_tun_id(flow)); mlx5e_tc_get_flow_tun_id(flow));
#endif
} else { } else {
rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr); rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
} }
...@@ -1186,12 +1182,10 @@ void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw, ...@@ -1186,12 +1182,10 @@ void mlx5e_tc_unoffload_fdb_rules(struct mlx5_eswitch *esw,
return; return;
} }
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
if (flow_flag_test(flow, SAMPLE)) { if (flow_flag_test(flow, SAMPLE)) {
mlx5e_tc_sample_unoffload(get_sample_priv(flow->priv), flow->rule[0], attr); mlx5e_tc_sample_unoffload(get_sample_priv(flow->priv), flow->rule[0], attr);
return; return;
} }
#endif
if (attr->esw_attr->split_count) if (attr->esw_attr->split_count)
mlx5_eswitch_del_fwd_rule(esw, flow->rule[1], attr); mlx5_eswitch_del_fwd_rule(esw, flow->rule[1], attr);
...@@ -4993,9 +4987,7 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht) ...@@ -4993,9 +4987,7 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
MLX5_FLOW_NAMESPACE_FDB, MLX5_FLOW_NAMESPACE_FDB,
uplink_priv->post_act); uplink_priv->post_act);
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
uplink_priv->tc_psample = mlx5e_tc_sample_init(esw, uplink_priv->post_act); uplink_priv->tc_psample = mlx5e_tc_sample_init(esw, uplink_priv->post_act);
#endif
mapping_id = mlx5_query_nic_system_image_guid(esw->dev); mapping_id = mlx5_query_nic_system_image_guid(esw->dev);
...@@ -5039,9 +5031,7 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht) ...@@ -5039,9 +5031,7 @@ int mlx5e_tc_esw_init(struct rhashtable *tc_ht)
err_enc_opts_mapping: err_enc_opts_mapping:
mapping_destroy(uplink_priv->tunnel_mapping); mapping_destroy(uplink_priv->tunnel_mapping);
err_tun_mapping: err_tun_mapping:
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
mlx5e_tc_sample_cleanup(uplink_priv->tc_psample); mlx5e_tc_sample_cleanup(uplink_priv->tc_psample);
#endif
mlx5_tc_ct_clean(uplink_priv->ct_priv); mlx5_tc_ct_clean(uplink_priv->ct_priv);
netdev_warn(priv->netdev, netdev_warn(priv->netdev,
"Failed to initialize tc (eswitch), err: %d", err); "Failed to initialize tc (eswitch), err: %d", err);
...@@ -5061,9 +5051,7 @@ void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht) ...@@ -5061,9 +5051,7 @@ void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht)
mapping_destroy(uplink_priv->tunnel_enc_opts_mapping); mapping_destroy(uplink_priv->tunnel_enc_opts_mapping);
mapping_destroy(uplink_priv->tunnel_mapping); mapping_destroy(uplink_priv->tunnel_mapping);
#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE)
mlx5e_tc_sample_cleanup(uplink_priv->tc_psample); mlx5e_tc_sample_cleanup(uplink_priv->tc_psample);
#endif
mlx5_tc_ct_clean(uplink_priv->ct_priv); mlx5_tc_ct_clean(uplink_priv->ct_priv);
mlx5e_tc_post_act_destroy(uplink_priv->post_act); mlx5e_tc_post_act_destroy(uplink_priv->post_act);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment