Skip to content

Commit e753b2b

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5: Add helper to initialize a flow steering actions struct instance
There are bunch of places in the code where the intermediate struct that keeps the elements related to flow actions is initialized with the same default values. Put that into a small DECLARE type helper. This patch doesn't change any functionality. Signed-off-by: Or Gerlitz <[email protected]> Reviewed-by: Hadar Hen Zion <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent aa0cbba commit e753b2b

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,9 @@ static int arfs_add_default_rule(struct mlx5e_priv *priv,
174174
enum arfs_type type)
175175
{
176176
struct arfs_table *arfs_t = &priv->fs.arfs.arfs_tables[type];
177-
struct mlx5_flow_act flow_act = {
178-
.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
179-
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG,
180-
.encap_id = 0,
181-
};
182-
struct mlx5_flow_destination dest;
183177
struct mlx5e_tir *tir = priv->indir_tir;
178+
struct mlx5_flow_destination dest;
179+
MLX5_DECLARE_FLOW_ACT(flow_act);
184180
struct mlx5_flow_spec *spec;
185181
int err = 0;
186182

@@ -469,15 +465,11 @@ static struct arfs_table *arfs_get_table(struct mlx5e_arfs_tables *arfs,
469465
static struct mlx5_flow_handle *arfs_add_rule(struct mlx5e_priv *priv,
470466
struct arfs_rule *arfs_rule)
471467
{
472-
struct mlx5_flow_act flow_act = {
473-
.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
474-
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG,
475-
.encap_id = 0,
476-
};
477468
struct mlx5e_arfs_tables *arfs = &priv->fs.arfs;
478469
struct arfs_tuple *tuple = &arfs_rule->tuple;
479470
struct mlx5_flow_handle *rule = NULL;
480471
struct mlx5_flow_destination dest;
472+
MLX5_DECLARE_FLOW_ACT(flow_act);
481473
struct arfs_table *arfs_table;
482474
struct mlx5_flow_spec *spec;
483475
struct mlx5_flow_table *ft;

drivers/net/ethernet/mellanox/mlx5/core/en_fs.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,10 @@ static int __mlx5e_add_vlan_rule(struct mlx5e_priv *priv,
159159
enum mlx5e_vlan_rule_type rule_type,
160160
u16 vid, struct mlx5_flow_spec *spec)
161161
{
162-
struct mlx5_flow_act flow_act = {
163-
.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
164-
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG,
165-
.encap_id = 0,
166-
};
167162
struct mlx5_flow_table *ft = priv->fs.vlan.ft.t;
168163
struct mlx5_flow_destination dest;
169164
struct mlx5_flow_handle **rule_p;
165+
MLX5_DECLARE_FLOW_ACT(flow_act);
170166
int err = 0;
171167

172168
dest.type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE;
@@ -659,11 +655,7 @@ mlx5e_generate_ttc_rule(struct mlx5e_priv *priv,
659655
u16 etype,
660656
u8 proto)
661657
{
662-
struct mlx5_flow_act flow_act = {
663-
.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
664-
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG,
665-
.encap_id = 0,
666-
};
658+
MLX5_DECLARE_FLOW_ACT(flow_act);
667659
struct mlx5_flow_handle *rule;
668660
struct mlx5_flow_spec *spec;
669661
int err = 0;
@@ -848,13 +840,9 @@ static void mlx5e_del_l2_flow_rule(struct mlx5e_priv *priv,
848840
static int mlx5e_add_l2_flow_rule(struct mlx5e_priv *priv,
849841
struct mlx5e_l2_rule *ai, int type)
850842
{
851-
struct mlx5_flow_act flow_act = {
852-
.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,
853-
.flow_tag = MLX5_FS_DEFAULT_FLOW_TAG,
854-
.encap_id = 0,
855-
};
856843
struct mlx5_flow_table *ft = priv->fs.l2.ft.t;
857844
struct mlx5_flow_destination dest;
845+
MLX5_DECLARE_FLOW_ACT(flow_act);
858846
struct mlx5_flow_spec *spec;
859847
int err = 0;
860848
u8 *mc_dmac;

include/linux/mlx5/fs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ struct mlx5_flow_act {
136136
u32 encap_id;
137137
};
138138

139+
#define MLX5_DECLARE_FLOW_ACT(name) \
140+
struct mlx5_flow_act name = {MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\
141+
MLX5_FS_DEFAULT_FLOW_TAG, 0}
142+
139143
/* Single destination per rule.
140144
* Group ID is implied by the match criteria.
141145
*/
@@ -156,5 +160,4 @@ struct mlx5_fc *mlx5_fc_create(struct mlx5_core_dev *dev, bool aging);
156160
void mlx5_fc_destroy(struct mlx5_core_dev *dev, struct mlx5_fc *counter);
157161
void mlx5_fc_query_cached(struct mlx5_fc *counter,
158162
u64 *bytes, u64 *packets, u64 *lastuse);
159-
160163
#endif

0 commit comments

Comments
 (0)