Skip to content

Commit

Permalink
net/mlx5e: Allow IPv4 ttl & IPv6 hop_limit rewrite for all L4 protocols
Browse files Browse the repository at this point in the history
For some protocols we are not allowing IP header rewrite offload, since
the HW is not capable to properly adjust the l4 checksum. However, TTL
& HOPLIMIT modification can be done for all IP protocols, because they
are not part of the pseudo header taken into account for checksum.

Fixes: 7386788 ("drivers: net: use flow action infrastructure")
Signed-off-by: Dmytro Linkin <dmitrolin@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
  • Loading branch information
Dmytro Linkin authored and Saeed Mahameed committed Mar 29, 2019
1 parent bc87a00 commit 8998576
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2158,16 +2158,62 @@ static bool csum_offload_supported(struct mlx5e_priv *priv,
return true;
}

struct ip_ttl_word {
__u8 ttl;
__u8 protocol;
__sum16 check;
};

struct ipv6_hoplimit_word {
__be16 payload_len;
__u8 nexthdr;
__u8 hop_limit;
};

static bool is_action_keys_supported(const struct flow_action_entry *act)
{
u32 mask, offset;
u8 htype;

htype = act->mangle.htype;
offset = act->mangle.offset;
mask = ~act->mangle.mask;
/* For IPv4 & IPv6 header check 4 byte word,
* to determine that modified fields
* are NOT ttl & hop_limit only.
*/
if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4) {
struct ip_ttl_word *ttl_word =
(struct ip_ttl_word *)&mask;

if (offset != offsetof(struct iphdr, ttl) ||
ttl_word->protocol ||
ttl_word->check) {
return true;
}
} else if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) {
struct ipv6_hoplimit_word *hoplimit_word =
(struct ipv6_hoplimit_word *)&mask;

if (offset != offsetof(struct ipv6hdr, payload_len) ||
hoplimit_word->payload_len ||
hoplimit_word->nexthdr) {
return true;
}
}
return false;
}

static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
struct flow_action *flow_action,
u32 actions,
struct netlink_ext_ack *extack)
{
const struct flow_action_entry *act;
bool modify_ip_header;
u8 htype, ip_proto;
void *headers_v;
u16 ethertype;
u8 ip_proto;
int i;

if (actions & MLX5_FLOW_CONTEXT_ACTION_DECAP)
Expand All @@ -2187,9 +2233,7 @@ static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
act->id != FLOW_ACTION_ADD)
continue;

htype = act->mangle.htype;
if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4 ||
htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) {
if (is_action_keys_supported(act)) {
modify_ip_header = true;
break;
}
Expand Down

0 comments on commit 8998576

Please sign in to comment.