aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>2018-10-15 19:52:25 -0400
committerDavid S. Miller <davem@davemloft.net>2018-10-16 02:17:25 -0400
commit140b6abac26d799f75d772ab5e969b34ad8d68f1 (patch)
treed9045222d4b3dda9bf3292f5f16fe305ccb1fa0f
parentd08c9e589300b015e72e5b41ff4dfed6eb8e7421 (diff)
nfp: flower: use offsets provided by pedit instead of index for ipv6
Previously when populating the set ipv6 address action, we incorrectly made use of pedit's key index to determine which 32bit word should be set. We now calculate which word has been selected based on the offset provided by the pedit action. Fixes: 354b82bb320e ("nfp: add set ipv6 source and destination address") Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/action.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index c39d7fdf73e6..7a1e9cd9cc62 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -450,12 +450,12 @@ nfp_fl_set_ip4(const struct tc_action *action, int idx, u32 off,
450} 450}
451 451
452static void 452static void
453nfp_fl_set_ip6_helper(int opcode_tag, int idx, __be32 exact, __be32 mask, 453nfp_fl_set_ip6_helper(int opcode_tag, u8 word, __be32 exact, __be32 mask,
454 struct nfp_fl_set_ipv6_addr *ip6) 454 struct nfp_fl_set_ipv6_addr *ip6)
455{ 455{
456 ip6->ipv6[idx % 4].mask |= mask; 456 ip6->ipv6[word].mask |= mask;
457 ip6->ipv6[idx % 4].exact &= ~mask; 457 ip6->ipv6[word].exact &= ~mask;
458 ip6->ipv6[idx % 4].exact |= exact & mask; 458 ip6->ipv6[word].exact |= exact & mask;
459 459
460 ip6->reserved = cpu_to_be16(0); 460 ip6->reserved = cpu_to_be16(0);
461 ip6->head.jump_id = opcode_tag; 461 ip6->head.jump_id = opcode_tag;
@@ -468,6 +468,7 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
468 struct nfp_fl_set_ipv6_addr *ip_src) 468 struct nfp_fl_set_ipv6_addr *ip_src)
469{ 469{
470 __be32 exact, mask; 470 __be32 exact, mask;
471 u8 word;
471 472
472 /* We are expecting tcf_pedit to return a big endian value */ 473 /* We are expecting tcf_pedit to return a big endian value */
473 mask = (__force __be32)~tcf_pedit_mask(action, idx); 474 mask = (__force __be32)~tcf_pedit_mask(action, idx);
@@ -476,17 +477,20 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
476 if (exact & ~mask) 477 if (exact & ~mask)
477 return -EOPNOTSUPP; 478 return -EOPNOTSUPP;
478 479
479 if (off < offsetof(struct ipv6hdr, saddr)) 480 if (off < offsetof(struct ipv6hdr, saddr)) {
480 return -EOPNOTSUPP; 481 return -EOPNOTSUPP;
481 else if (off < offsetof(struct ipv6hdr, daddr)) 482 } else if (off < offsetof(struct ipv6hdr, daddr)) {
482 nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_SRC, idx, 483 word = (off - offsetof(struct ipv6hdr, saddr)) / sizeof(exact);
484 nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_SRC, word,
483 exact, mask, ip_src); 485 exact, mask, ip_src);
484 else if (off < offsetof(struct ipv6hdr, daddr) + 486 } else if (off < offsetof(struct ipv6hdr, daddr) +
485 sizeof(struct in6_addr)) 487 sizeof(struct in6_addr)) {
486 nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_DST, idx, 488 word = (off - offsetof(struct ipv6hdr, daddr)) / sizeof(exact);
489 nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_DST, word,
487 exact, mask, ip_dst); 490 exact, mask, ip_dst);
488 else 491 } else {
489 return -EOPNOTSUPP; 492 return -EOPNOTSUPP;
493 }
490 494
491 return 0; 495 return 0;
492} 496}