Skip to content

Commit

Permalink
net/mlx5: DR, Merge similar DR STE SET macros
Browse files Browse the repository at this point in the history
Merge DR_STE_STE macros for better code reuse, the macro
DR_STE_SET_MASK_V and DR_STE_SET_TAG are merged to avoid
tag and bit_mask function creation which are usually the
same.

Signed-off-by: Alex Vesker <valex@nvidia.com>
Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
  • Loading branch information
Yevgeny Kliteynik authored and Saeed Mahameed committed Jan 5, 2021
1 parent 7863c91 commit 4677909
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 415 deletions.
35 changes: 11 additions & 24 deletions drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@
} \
} while (0)

/* Set to STE spec->s_fname to tag->t_fname */
/* Set to STE spec->s_fname to tag->t_fname set spec->s_fname as used */
#define DR_STE_SET_TAG(lookup_type, tag, t_fname, spec, s_fname) \
DR_STE_SET_VAL(lookup_type, tag, t_fname, spec, s_fname, spec->s_fname)

/* Set to STE -1 to bit_mask->bm_fname and set spec->s_fname as used */
#define DR_STE_SET_MASK(lookup_type, bit_mask, bm_fname, spec, s_fname) \
DR_STE_SET_VAL(lookup_type, bit_mask, bm_fname, spec, s_fname, -1)

/* Set to STE spec->s_fname to bit_mask->bm_fname and set spec->s_fname as used */
#define DR_STE_SET_MASK_V(lookup_type, bit_mask, bm_fname, spec, s_fname) \
DR_STE_SET_VAL(lookup_type, bit_mask, bm_fname, spec, s_fname, (spec)->s_fname)
/* Set to STE -1 to tag->t_fname and set spec->s_fname as used */
#define DR_STE_SET_ONES(lookup_type, tag, t_fname, spec, s_fname) \
DR_STE_SET_VAL(lookup_type, tag, t_fname, spec, s_fname, -1)

#define DR_STE_SET_TCP_FLAGS(lookup_type, tag, spec) do { \
MLX5_SET(ste_##lookup_type, tag, tcp_ns, !!((spec)->tcp_flags & (1 << 8))); \
Expand All @@ -48,25 +44,16 @@
MLX5_SET(ste_##lookup_type, tag, tcp_fin, !!((spec)->tcp_flags & (1 << 0))); \
} while (0)

#define DR_STE_SET_MPLS_MASK(lookup_type, mask, in_out, bit_mask) do { \
DR_STE_SET_MASK_V(lookup_type, bit_mask, mpls0_label, mask, \
in_out##_first_mpls_label);\
DR_STE_SET_MASK_V(lookup_type, bit_mask, mpls0_s_bos, mask, \
in_out##_first_mpls_s_bos); \
DR_STE_SET_MASK_V(lookup_type, bit_mask, mpls0_exp, mask, \
in_out##_first_mpls_exp); \
DR_STE_SET_MASK_V(lookup_type, bit_mask, mpls0_ttl, mask, \
in_out##_first_mpls_ttl); \
} while (0)

#define DR_STE_SET_MPLS_TAG(lookup_type, mask, in_out, tag) do { \
DR_STE_SET_TAG(lookup_type, tag, mpls0_label, mask, \
#define DR_STE_SET_MPLS(lookup_type, mask, in_out, tag) do { \
struct mlx5dr_match_misc2 *_mask = mask; \
u8 *_tag = tag; \
DR_STE_SET_TAG(lookup_type, _tag, mpls0_label, _mask, \
in_out##_first_mpls_label);\
DR_STE_SET_TAG(lookup_type, tag, mpls0_s_bos, mask, \
DR_STE_SET_TAG(lookup_type, _tag, mpls0_s_bos, _mask, \
in_out##_first_mpls_s_bos); \
DR_STE_SET_TAG(lookup_type, tag, mpls0_exp, mask, \
DR_STE_SET_TAG(lookup_type, _tag, mpls0_exp, _mask, \
in_out##_first_mpls_exp); \
DR_STE_SET_TAG(lookup_type, tag, mpls0_ttl, mask, \
DR_STE_SET_TAG(lookup_type, _tag, mpls0_ttl, _mask, \
in_out##_first_mpls_ttl); \
} while (0)

Expand Down
Loading

0 comments on commit 4677909

Please sign in to comment.