Skip to content

Commit

Permalink
net/mlx5e: Fix no rewrite fields with the same match
Browse files Browse the repository at this point in the history
With commit 27c11b6 ("net/mlx5e: Do not rewrite fields with the
same match") there are no rewrites if the rewrite value is the same as
the matched value. However, if the field is not matched, the rewrite is
also wrongly skipped. Fix it.

Fixes: 27c11b6 ("net/mlx5e: Do not rewrite fields with the same match")
Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
  • Loading branch information
Eli Britstein authored and Saeed Mahameed committed May 17, 2019
1 parent c979c44 commit 2ef8687
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1916,23 +1916,33 @@ struct mlx5_fields {
offsetof(struct pedit_headers, field) + (off), \
MLX5_BYTE_OFF(fte_match_set_lyr_2_4, match_field)}

/* masked values are the same and there are no rewrites that do not have a
* match.
*/
#define SAME_VAL_MASK(type, valp, maskp, matchvalp, matchmaskp) ({ \
type matchmaskx = *(type *)(matchmaskp); \
type matchvalx = *(type *)(matchvalp); \
type maskx = *(type *)(maskp); \
type valx = *(type *)(valp); \
\
(valx & maskx) == (matchvalx & matchmaskx) && !(maskx & (maskx ^ \
matchmaskx)); \
})

static bool cmp_val_mask(void *valp, void *maskp, void *matchvalp,
void *matchmaskp, int size)
{
bool same = false;

switch (size) {
case sizeof(u8):
same = ((*(u8 *)valp) & (*(u8 *)maskp)) ==
((*(u8 *)matchvalp) & (*(u8 *)matchmaskp));
same = SAME_VAL_MASK(u8, valp, maskp, matchvalp, matchmaskp);
break;
case sizeof(u16):
same = ((*(u16 *)valp) & (*(u16 *)maskp)) ==
((*(u16 *)matchvalp) & (*(u16 *)matchmaskp));
same = SAME_VAL_MASK(u16, valp, maskp, matchvalp, matchmaskp);
break;
case sizeof(u32):
same = ((*(u32 *)valp) & (*(u32 *)maskp)) ==
((*(u32 *)matchvalp) & (*(u32 *)matchmaskp));
same = SAME_VAL_MASK(u32, valp, maskp, matchvalp, matchmaskp);
break;
}

Expand Down

0 comments on commit 2ef8687

Please sign in to comment.