[6/8] net/mlx5: add convenience macros to switch flow rule engine
diff mbox series

Message ID 20180831092038.23051-7-adrien.mazarguil@6wind.com
State Superseded, archived
Headers show
Series
  • net/mlx5: add switch offload for VXLAN encap/decap
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Adrien Mazarguil Aug. 31, 2018, 9:57 a.m. UTC
Upcoming patches will rely on them.

Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
 drivers/net/mlx5/mlx5_nl_flow.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/mlx5/mlx5_nl_flow.c b/drivers/net/mlx5/mlx5_nl_flow.c
index d20416026..91ff90a13 100644
--- a/drivers/net/mlx5/mlx5_nl_flow.c
+++ b/drivers/net/mlx5/mlx5_nl_flow.c
@@ -236,6 +236,13 @@  static const union {
 	struct rte_flow_item_udp udp;
 } mlx5_nl_flow_mask_empty;
 
+#define ETHER_ADDR_MASK "\xff\xff\xff\xff\xff\xff"
+#define IN_ADDR_MASK RTE_BE32(0xffffffff)
+#define IN6_ADDR_MASK \
+	"\xff\xff\xff\xff\xff\xff\xff\xff" \
+	"\xff\xff\xff\xff\xff\xff\xff\xff"
+#define BE16_MASK RTE_BE16(0xffff)
+
 /** Supported masks for known item types. */
 static const struct {
 	struct rte_flow_item_port_id port_id;
@@ -251,8 +258,8 @@  static const struct {
 	},
 	.eth = {
 		.type = RTE_BE16(0xffff),
-		.dst.addr_bytes = "\xff\xff\xff\xff\xff\xff",
-		.src.addr_bytes = "\xff\xff\xff\xff\xff\xff",
+		.dst.addr_bytes = ETHER_ADDR_MASK,
+		.src.addr_bytes = ETHER_ADDR_MASK,
 	},
 	.vlan = {
 		/* PCP and VID only, no DEI. */
@@ -261,25 +268,21 @@  static const struct {
 	},
 	.ipv4.hdr = {
 		.next_proto_id = 0xff,
-		.src_addr = RTE_BE32(0xffffffff),
-		.dst_addr = RTE_BE32(0xffffffff),
+		.src_addr = IN_ADDR_MASK,
+		.dst_addr = IN_ADDR_MASK,
 	},
 	.ipv6.hdr = {
 		.proto = 0xff,
-		.src_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		.src_addr = IN6_ADDR_MASK,
+		.dst_addr = IN6_ADDR_MASK,
 	},
 	.tcp.hdr = {
-		.src_port = RTE_BE16(0xffff),
-		.dst_port = RTE_BE16(0xffff),
+		.src_port = BE16_MASK,
+		.dst_port = BE16_MASK,
 	},
 	.udp.hdr = {
-		.src_port = RTE_BE16(0xffff),
-		.dst_port = RTE_BE16(0xffff),
+		.src_port = BE16_MASK,
+		.dst_port = BE16_MASK,
 	},
 };