DPDK patches and discussions
 help / color / mirror / Atom feed
From: Moti Haimovsky <motih@mellanox.com>
To: shahafs@mellanox.com
Cc: dev@dpdk.org, Moti Haimovsky <motih@mellanox.com>
Subject: [dpdk-dev] [RFC] net/mlx5: support e-switch TCP-flags flow filter
Date: Wed, 22 Aug 2018 18:55:07 +0300	[thread overview]
Message-ID: <1534953307-8683-1-git-send-email-motih@mellanox.com> (raw)

Today, it is possible to offload an interface flow rules to the hardware
using DPDK flow commands.
With mlx5 it is also possible to offload a limited set of flow rules to
the mlxsw (or e-switch) using the same DPDK flow commands.
A 'transfer' attribute was added to the flow rule creation command in
order to distinguish between configuring port flows and E-switch flows.
The commands destined for the switch are transposed to TC flower rules
and are send, as Netlink messages, to the mlx5 driver, or more precisely
to the netdev which represent the mlxsw port.
The limited set of e-switch flow rules also supports filtering according
to the values found in the TCP flags. but the mlx5 PMD does not
implement this filter.
The purpose of this RFC is to propose an enhancement to the e-switch
flow filtering rules to also include filtering according to the TCP
flags.

Below is the propose enhancement.

NOTE:
 This code is supposed to be applied on top of the flow steering
 rework not committed yet and therefore may be subject to changes.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/mlx5/Makefile       | 10 ++++++++++
 drivers/net/mlx5/mlx5_nl_flow.c | 20 +++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/Makefile b/drivers/net/mlx5/Makefile
index 2e70dec..02139ce 100644
--- a/drivers/net/mlx5/Makefile
+++ b/drivers/net/mlx5/Makefile
@@ -335,6 +335,16 @@ mlx5_autoconf.h.new: $(RTE_SDK)/buildtools/auto-config-h.sh
 		enum TCA_FLOWER_KEY_VLAN_ETH_TYPE \
 		$(AUTOCONF_OUTPUT)
 	$Q sh -- '$<' '$@' \
+		HAVE_TCA_FLOWER_KEY_TCP_FLAGS \
+		linux/pkt_cls.h \
+		enum TCA_FLOWER_KEY_TCP_FLAGS \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
+		HAVE_TCA_FLOWER_KEY_TCP_FLAGS_MASK \
+		linux/pkt_cls.h \
+		enum TCA_FLOWER_KEY_TCP_FLAGS_MASK \
+		$(AUTOCONF_OUTPUT)
+	$Q sh -- '$<' '$@' \
 		HAVE_TC_ACT_VLAN \
 		linux/tc_act/tc_vlan.h \
 		enum TCA_VLAN_PUSH_VLAN_PRIORITY \
diff --git a/drivers/net/mlx5/mlx5_nl_flow.c b/drivers/net/mlx5/mlx5_nl_flow.c
index beb03c9..af66ae1 100644
--- a/drivers/net/mlx5/mlx5_nl_flow.c
+++ b/drivers/net/mlx5/mlx5_nl_flow.c
@@ -146,6 +146,12 @@ struct tc_vlan {
 #ifndef HAVE_TCA_FLOWER_KEY_VLAN_ETH_TYPE
 #define TCA_FLOWER_KEY_VLAN_ETH_TYPE 25
 #endif
+#ifndef TCA_FLOWER_KEY_TCP_FLAGS
+#define TCA_FLOWER_KEY_TCP_FLAGS 71
+#endif
+#ifndef TCA_FLOWER_KEY_TCP_FLAGS_MASK
+#define TCA_FLOWER_KEY_TCP_FLAGS_MASK 72
+#endif
 
 /** Parser state definitions for mlx5_nl_flow_trans[]. */
 enum mlx5_nl_flow_trans {
@@ -258,6 +264,7 @@ enum mlx5_nl_flow_trans {
 	.tcp.hdr = {
 		.src_port = RTE_BE16(0xffff),
 		.dst_port = RTE_BE16(0xffff),
+		.tcp_flags = 0xff,
 	},
 	.udp.hdr = {
 		.src_port = RTE_BE16(0xffff),
@@ -812,7 +819,18 @@ enum mlx5_nl_flow_trans {
 					      spec.tcp->hdr.dst_port) ||
 		      !mnl_attr_put_u16_check(buf, size,
 					      TCA_FLOWER_KEY_TCP_DST_MASK,
-					      mask.tcp->hdr.dst_port))))
+					      mask.tcp->hdr.dst_port))) ||
+		    (mask.tcp->hdr.tcp_flags &&
+		     (!mnl_attr_put_u16_check
+				     (buf, size,
+				      TCA_FLOWER_KEY_TCP_FLAGS,
+				      rte_cpu_to_be_16
+						(spec.tcp->hdr.tcp_flags)) ||
+		      !mnl_attr_put_u16_check
+				     (buf, size,
+				      TCA_FLOWER_KEY_TCP_FLAGS_MASK,
+				      rte_cpu_to_be_16
+						(mask.tcp->hdr.tcp_flags)))))
 			goto error_nobufs;
 		++item;
 		break;
-- 
1.8.3.1

                 reply	other threads:[~2018-08-22 15:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1534953307-8683-1-git-send-email-motih@mellanox.com \
    --to=motih@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).