Commit a8e4f0c4 authored by Or Gerlitz's avatar Or Gerlitz Committed by Saeed Mahameed

net/mlx5e: Use macro for TC header re-write offload field mapping

Use a macro for the static mapping between the enumeration of field
supported by the firmware for header re-write to the corresponding
network header field. This improves the readability of the code and
doesn't change any functionality.
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: default avatarPaul Blakey <paulb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent a8ade55f
...@@ -1058,32 +1058,36 @@ struct mlx5_fields { ...@@ -1058,32 +1058,36 @@ struct mlx5_fields {
u32 offset; u32 offset;
}; };
#define OFFLOAD(fw_field, size, field, off) \
{MLX5_ACTION_IN_FIELD_OUT_ ## fw_field, size, offsetof(struct pedit_headers, field) + (off)}
static struct mlx5_fields fields[] = { static struct mlx5_fields fields[] = {
{MLX5_ACTION_IN_FIELD_OUT_DMAC_47_16, 4, offsetof(struct pedit_headers, eth.h_dest[0])}, OFFLOAD(DMAC_47_16, 4, eth.h_dest[0], 0),
{MLX5_ACTION_IN_FIELD_OUT_DMAC_15_0, 2, offsetof(struct pedit_headers, eth.h_dest[4])}, OFFLOAD(DMAC_47_16, 4, eth.h_dest[0], 0),
{MLX5_ACTION_IN_FIELD_OUT_SMAC_47_16, 4, offsetof(struct pedit_headers, eth.h_source[0])}, OFFLOAD(DMAC_15_0, 2, eth.h_dest[4], 0),
{MLX5_ACTION_IN_FIELD_OUT_SMAC_15_0, 2, offsetof(struct pedit_headers, eth.h_source[4])}, OFFLOAD(SMAC_47_16, 4, eth.h_source[0], 0),
{MLX5_ACTION_IN_FIELD_OUT_ETHERTYPE, 2, offsetof(struct pedit_headers, eth.h_proto)}, OFFLOAD(SMAC_15_0, 2, eth.h_source[4], 0),
OFFLOAD(ETHERTYPE, 2, eth.h_proto, 0),
{MLX5_ACTION_IN_FIELD_OUT_IP_TTL, 1, offsetof(struct pedit_headers, ip4.ttl)},
{MLX5_ACTION_IN_FIELD_OUT_SIPV4, 4, offsetof(struct pedit_headers, ip4.saddr)}, OFFLOAD(IP_TTL, 1, ip4.ttl, 0),
{MLX5_ACTION_IN_FIELD_OUT_DIPV4, 4, offsetof(struct pedit_headers, ip4.daddr)}, OFFLOAD(SIPV4, 4, ip4.saddr, 0),
OFFLOAD(DIPV4, 4, ip4.daddr, 0),
{MLX5_ACTION_IN_FIELD_OUT_SIPV6_127_96, 4, offsetof(struct pedit_headers, ip6.saddr.s6_addr32[0])},
{MLX5_ACTION_IN_FIELD_OUT_SIPV6_95_64, 4, offsetof(struct pedit_headers, ip6.saddr.s6_addr32[1])}, OFFLOAD(SIPV6_127_96, 4, ip6.saddr.s6_addr32[0], 0),
{MLX5_ACTION_IN_FIELD_OUT_SIPV6_63_32, 4, offsetof(struct pedit_headers, ip6.saddr.s6_addr32[2])}, OFFLOAD(SIPV6_95_64, 4, ip6.saddr.s6_addr32[1], 0),
{MLX5_ACTION_IN_FIELD_OUT_SIPV6_31_0, 4, offsetof(struct pedit_headers, ip6.saddr.s6_addr32[3])}, OFFLOAD(SIPV6_63_32, 4, ip6.saddr.s6_addr32[2], 0),
{MLX5_ACTION_IN_FIELD_OUT_DIPV6_127_96, 4, offsetof(struct pedit_headers, ip6.daddr.s6_addr32[0])}, OFFLOAD(SIPV6_31_0, 4, ip6.saddr.s6_addr32[3], 0),
{MLX5_ACTION_IN_FIELD_OUT_DIPV6_95_64, 4, offsetof(struct pedit_headers, ip6.daddr.s6_addr32[1])}, OFFLOAD(DIPV6_127_96, 4, ip6.daddr.s6_addr32[0], 0),
{MLX5_ACTION_IN_FIELD_OUT_DIPV6_63_32, 4, offsetof(struct pedit_headers, ip6.daddr.s6_addr32[2])}, OFFLOAD(DIPV6_95_64, 4, ip6.daddr.s6_addr32[1], 0),
{MLX5_ACTION_IN_FIELD_OUT_DIPV6_31_0, 4, offsetof(struct pedit_headers, ip6.daddr.s6_addr32[3])}, OFFLOAD(DIPV6_63_32, 4, ip6.daddr.s6_addr32[2], 0),
OFFLOAD(DIPV6_31_0, 4, ip6.daddr.s6_addr32[3], 0),
{MLX5_ACTION_IN_FIELD_OUT_TCP_SPORT, 2, offsetof(struct pedit_headers, tcp.source)},
{MLX5_ACTION_IN_FIELD_OUT_TCP_DPORT, 2, offsetof(struct pedit_headers, tcp.dest)}, OFFLOAD(TCP_SPORT, 2, tcp.source, 0),
{MLX5_ACTION_IN_FIELD_OUT_TCP_FLAGS, 1, offsetof(struct pedit_headers, tcp.ack_seq) + 5}, OFFLOAD(TCP_DPORT, 2, tcp.dest, 0),
OFFLOAD(TCP_FLAGS, 1, tcp.ack_seq, 5),
{MLX5_ACTION_IN_FIELD_OUT_UDP_SPORT, 2, offsetof(struct pedit_headers, udp.source)},
{MLX5_ACTION_IN_FIELD_OUT_UDP_DPORT, 2, offsetof(struct pedit_headers, udp.dest)}, OFFLOAD(UDP_SPORT, 2, udp.source, 0),
OFFLOAD(UDP_DPORT, 2, udp.dest, 0),
}; };
/* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at /* On input attr->num_mod_hdr_actions tells how many HW actions can be parsed at
......
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