Skip to content

Commit 8998576

Browse files
DmytroLinkinSaeed Mahameed
authored andcommitted
net/mlx5e: Allow IPv4 ttl & IPv6 hop_limit rewrite for all L4 protocols
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 <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent bc87a00 commit 8998576

File tree

1 file changed

+48
-4
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+48
-4
lines changed

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

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,16 +2158,62 @@ static bool csum_offload_supported(struct mlx5e_priv *priv,
21582158
return true;
21592159
}
21602160

2161+
struct ip_ttl_word {
2162+
__u8 ttl;
2163+
__u8 protocol;
2164+
__sum16 check;
2165+
};
2166+
2167+
struct ipv6_hoplimit_word {
2168+
__be16 payload_len;
2169+
__u8 nexthdr;
2170+
__u8 hop_limit;
2171+
};
2172+
2173+
static bool is_action_keys_supported(const struct flow_action_entry *act)
2174+
{
2175+
u32 mask, offset;
2176+
u8 htype;
2177+
2178+
htype = act->mangle.htype;
2179+
offset = act->mangle.offset;
2180+
mask = ~act->mangle.mask;
2181+
/* For IPv4 & IPv6 header check 4 byte word,
2182+
* to determine that modified fields
2183+
* are NOT ttl & hop_limit only.
2184+
*/
2185+
if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4) {
2186+
struct ip_ttl_word *ttl_word =
2187+
(struct ip_ttl_word *)&mask;
2188+
2189+
if (offset != offsetof(struct iphdr, ttl) ||
2190+
ttl_word->protocol ||
2191+
ttl_word->check) {
2192+
return true;
2193+
}
2194+
} else if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) {
2195+
struct ipv6_hoplimit_word *hoplimit_word =
2196+
(struct ipv6_hoplimit_word *)&mask;
2197+
2198+
if (offset != offsetof(struct ipv6hdr, payload_len) ||
2199+
hoplimit_word->payload_len ||
2200+
hoplimit_word->nexthdr) {
2201+
return true;
2202+
}
2203+
}
2204+
return false;
2205+
}
2206+
21612207
static bool modify_header_match_supported(struct mlx5_flow_spec *spec,
21622208
struct flow_action *flow_action,
21632209
u32 actions,
21642210
struct netlink_ext_ack *extack)
21652211
{
21662212
const struct flow_action_entry *act;
21672213
bool modify_ip_header;
2168-
u8 htype, ip_proto;
21692214
void *headers_v;
21702215
u16 ethertype;
2216+
u8 ip_proto;
21712217
int i;
21722218

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

2190-
htype = act->mangle.htype;
2191-
if (htype == FLOW_ACT_MANGLE_HDR_TYPE_IP4 ||
2192-
htype == FLOW_ACT_MANGLE_HDR_TYPE_IP6) {
2236+
if (is_action_keys_supported(act)) {
21932237
modify_ip_header = true;
21942238
break;
21952239
}

0 commit comments

Comments
 (0)