Commit d08c9e58 authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by David S. Miller

nfp: flower: fix multiple keys per pedit action

Previously we only allowed a single header key per pedit action to
change the header. This used to result in the last header key in the
pedit action to overwrite previous headers. We now keep track of them
and allow multiple header keys per pedit action.

Fixes: c0b1bd9a ("nfp: add set ipv4 header action flower offload")
Fixes: 354b82bb ("nfp: add set ipv6 source and destination address")
Fixes: f8b7b0a6 ("nfp: add set tcp and udp header action flower offload")
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8913806f
...@@ -544,7 +544,7 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow, ...@@ -544,7 +544,7 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow,
struct nfp_fl_set_eth set_eth; struct nfp_fl_set_eth set_eth;
enum pedit_header_type htype; enum pedit_header_type htype;
int idx, nkeys, err; int idx, nkeys, err;
size_t act_size; size_t act_size = 0;
u32 offset, cmd; u32 offset, cmd;
u8 ip_proto = 0; u8 ip_proto = 0;
...@@ -602,7 +602,9 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow, ...@@ -602,7 +602,9 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow,
act_size = sizeof(set_eth); act_size = sizeof(set_eth);
memcpy(nfp_action, &set_eth, act_size); memcpy(nfp_action, &set_eth, act_size);
*a_len += act_size; *a_len += act_size;
} else if (set_ip_addr.head.len_lw) { }
if (set_ip_addr.head.len_lw) {
nfp_action += act_size;
act_size = sizeof(set_ip_addr); act_size = sizeof(set_ip_addr);
memcpy(nfp_action, &set_ip_addr, act_size); memcpy(nfp_action, &set_ip_addr, act_size);
*a_len += act_size; *a_len += act_size;
...@@ -610,10 +612,12 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow, ...@@ -610,10 +612,12 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow,
/* Hardware will automatically fix IPv4 and TCP/UDP checksum. */ /* Hardware will automatically fix IPv4 and TCP/UDP checksum. */
*csum_updated |= TCA_CSUM_UPDATE_FLAG_IPV4HDR | *csum_updated |= TCA_CSUM_UPDATE_FLAG_IPV4HDR |
nfp_fl_csum_l4_to_flag(ip_proto); nfp_fl_csum_l4_to_flag(ip_proto);
} else if (set_ip6_dst.head.len_lw && set_ip6_src.head.len_lw) { }
if (set_ip6_dst.head.len_lw && set_ip6_src.head.len_lw) {
/* TC compiles set src and dst IPv6 address as a single action, /* TC compiles set src and dst IPv6 address as a single action,
* the hardware requires this to be 2 separate actions. * the hardware requires this to be 2 separate actions.
*/ */
nfp_action += act_size;
act_size = sizeof(set_ip6_src); act_size = sizeof(set_ip6_src);
memcpy(nfp_action, &set_ip6_src, act_size); memcpy(nfp_action, &set_ip6_src, act_size);
*a_len += act_size; *a_len += act_size;
...@@ -626,6 +630,7 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow, ...@@ -626,6 +630,7 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow,
/* Hardware will automatically fix TCP/UDP checksum. */ /* Hardware will automatically fix TCP/UDP checksum. */
*csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto); *csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto);
} else if (set_ip6_dst.head.len_lw) { } else if (set_ip6_dst.head.len_lw) {
nfp_action += act_size;
act_size = sizeof(set_ip6_dst); act_size = sizeof(set_ip6_dst);
memcpy(nfp_action, &set_ip6_dst, act_size); memcpy(nfp_action, &set_ip6_dst, act_size);
*a_len += act_size; *a_len += act_size;
...@@ -633,13 +638,16 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow, ...@@ -633,13 +638,16 @@ nfp_fl_pedit(const struct tc_action *action, struct tc_cls_flower_offload *flow,
/* Hardware will automatically fix TCP/UDP checksum. */ /* Hardware will automatically fix TCP/UDP checksum. */
*csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto); *csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto);
} else if (set_ip6_src.head.len_lw) { } else if (set_ip6_src.head.len_lw) {
nfp_action += act_size;
act_size = sizeof(set_ip6_src); act_size = sizeof(set_ip6_src);
memcpy(nfp_action, &set_ip6_src, act_size); memcpy(nfp_action, &set_ip6_src, act_size);
*a_len += act_size; *a_len += act_size;
/* Hardware will automatically fix TCP/UDP checksum. */ /* Hardware will automatically fix TCP/UDP checksum. */
*csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto); *csum_updated |= nfp_fl_csum_l4_to_flag(ip_proto);
} else if (set_tport.head.len_lw) { }
if (set_tport.head.len_lw) {
nfp_action += act_size;
act_size = sizeof(set_tport); act_size = sizeof(set_tport);
memcpy(nfp_action, &set_tport, act_size); memcpy(nfp_action, &set_tport, act_size);
*a_len += act_size; *a_len += act_size;
......
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