DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 10/11] net/sfc: add UDP in flow API filters support
Date: Thu, 2 Mar 2017 16:03:10 +0000	[thread overview]
Message-ID: <1488470591-5853-11-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1488470591-5853-1-git-send-email-arybchenko@solarflare.com>

From: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>

Exact match of source and destination ports is supported by parser.
IP protocol match is enforced to UDP.

Signed-off-by: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
---
 doc/guides/nics/sfc_efx.rst |  2 ++
 drivers/net/sfc/sfc_flow.c  | 76 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 7e00fdc..4d91b1d 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -139,6 +139,8 @@ Supported pattern items:
 
 - TCP (exact match of source/destination ports)
 
+- UDP (exact match of source/destination ports)
+
 Supported actions:
 
 - VOID
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 6825d04..7a1f38f 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -76,6 +76,7 @@ static sfc_flow_item_parse sfc_flow_parse_vlan;
 static sfc_flow_item_parse sfc_flow_parse_ipv4;
 static sfc_flow_item_parse sfc_flow_parse_ipv6;
 static sfc_flow_item_parse sfc_flow_parse_tcp;
+static sfc_flow_item_parse sfc_flow_parse_udp;
 
 static boolean_t
 sfc_flow_is_zero(const uint8_t *buf, unsigned int size)
@@ -555,6 +556,75 @@ sfc_flow_parse_tcp(const struct rte_flow_item *item,
 	return -rte_errno;
 }
 
+static int
+sfc_flow_parse_udp(const struct rte_flow_item *item,
+		   efx_filter_spec_t *efx_spec,
+		   struct rte_flow_error *error)
+{
+	int rc;
+	const struct rte_flow_item_udp *spec = NULL;
+	const struct rte_flow_item_udp *mask = NULL;
+	const struct rte_flow_item_udp supp_mask = {
+		.hdr = {
+			.src_port = 0xffff,
+			.dst_port = 0xffff,
+		}
+	};
+
+	rc = sfc_flow_parse_init(item,
+				 (const void **)&spec,
+				 (const void **)&mask,
+				 &supp_mask,
+				 &rte_flow_item_udp_mask,
+				 sizeof(struct rte_flow_item_udp),
+				 error);
+	if (rc != 0)
+		return rc;
+
+	/*
+	 * Filtering by UDP source and destination ports requires
+	 * the appropriate IP_PROTO in hardware filters
+	 */
+	if (!(efx_spec->efs_match_flags & EFX_FILTER_MATCH_IP_PROTO)) {
+		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_IP_PROTO;
+		efx_spec->efs_ip_proto = EFX_IPPROTO_UDP;
+	} else if (efx_spec->efs_ip_proto != EFX_IPPROTO_UDP) {
+		rte_flow_error_set(error, EINVAL,
+			RTE_FLOW_ERROR_TYPE_ITEM, item,
+			"IP proto in pattern with UDP item should be appropriate");
+		return -rte_errno;
+	}
+
+	if (spec == NULL)
+		return 0;
+
+	/*
+	 * Source and destination ports are in big-endian byte order in item and
+	 * in little-endian in efx_spec, so byte swap is used
+	 */
+	if (mask->hdr.src_port == supp_mask.hdr.src_port) {
+		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_PORT;
+		efx_spec->efs_rem_port = rte_bswap16(spec->hdr.src_port);
+	} else if (mask->hdr.src_port != 0) {
+		goto fail_bad_mask;
+	}
+
+	if (mask->hdr.dst_port == supp_mask.hdr.dst_port) {
+		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_PORT;
+		efx_spec->efs_loc_port = rte_bswap16(spec->hdr.dst_port);
+	} else if (mask->hdr.dst_port != 0) {
+		goto fail_bad_mask;
+	}
+
+	return 0;
+
+fail_bad_mask:
+	rte_flow_error_set(error, EINVAL,
+			   RTE_FLOW_ERROR_TYPE_ITEM, item,
+			   "Bad mask in the UDP pattern item");
+	return -rte_errno;
+}
+
 static const struct sfc_flow_item sfc_flow_items[] = {
 	{
 		.type = RTE_FLOW_ITEM_TYPE_VOID,
@@ -592,6 +662,12 @@ static const struct sfc_flow_item sfc_flow_items[] = {
 		.layer = SFC_FLOW_ITEM_L4,
 		.parse = sfc_flow_parse_tcp,
 	},
+	{
+		.type = RTE_FLOW_ITEM_TYPE_UDP,
+		.prev_layer = SFC_FLOW_ITEM_L3,
+		.layer = SFC_FLOW_ITEM_L4,
+		.parse = sfc_flow_parse_udp,
+	},
 };
 
 /*
-- 
2.9.3

  parent reply	other threads:[~2017-03-02 16:04 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 16:03 [dpdk-dev] [PATCH 00/11] Support flow API in Solarflare PMD Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 01/11] net/sfc/base: split local MAC I/G back into separate flags Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 02/11] net/sfc/base: improve API to get supported filter matches Andrew Rybchenko
2017-03-07 13:25   ` Ferruh Yigit
2017-03-07 14:47     ` Andrew Rybchenko
2017-03-07 14:56       ` Ferruh Yigit
2017-03-02 16:03 ` [dpdk-dev] [PATCH 03/11] net/sfc: implement dummy filter control callback Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 04/11] net/sfc: provide a way to check if filter is supported Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 05/11] net/sfc: add flow API filters support Andrew Rybchenko
2017-03-07 13:21   ` Ferruh Yigit
2017-03-09 15:29     ` Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 06/11] net/sfc: add VLAN in " Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 07/11] net/sfc: add IPV4 " Andrew Rybchenko
2017-03-07 13:21   ` Ferruh Yigit
2017-03-02 16:03 ` [dpdk-dev] [PATCH 08/11] net/sfc: add IPV6 " Andrew Rybchenko
2017-03-02 16:03 ` [dpdk-dev] [PATCH 09/11] net/sfc: add TCP " Andrew Rybchenko
2017-03-02 16:03 ` Andrew Rybchenko [this message]
2017-03-02 16:03 ` [dpdk-dev] [PATCH 11/11] net/sfc: add unknown unicast/multicast match in flow API Andrew Rybchenko
2017-03-07 13:27 ` [dpdk-dev] [PATCH 00/11] Support flow API in Solarflare PMD Ferruh Yigit
2017-03-07 14:56   ` Andrew Rybchenko
2017-03-09 15:26 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 01/11] net/sfc/base: split local MAC I/G back into separate flags Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 02/11] net/sfc/base: improve API to get supported filter matches Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 03/11] net/sfc: implement dummy filter control callback Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 04/11] net/sfc: provide a way to check if filter is supported Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 05/11] net/sfc: add flow API filters support Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 06/11] net/sfc: add VLAN in " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 07/11] net/sfc: add IPV4 " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 08/11] net/sfc: add IPV6 " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 09/11] net/sfc: add TCP " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 10/11] net/sfc: add UDP " Andrew Rybchenko
2017-03-09 15:26   ` [dpdk-dev] [PATCH v2 11/11] net/sfc: add unknown unicast/multicast match in flow API Andrew Rybchenko
2017-03-09 17:28   ` [dpdk-dev] [PATCH v2 00/11] Support flow API in Solarflare PMD Ferruh Yigit

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=1488470591-5853-11-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=Roman.Zhukov@oktetlabs.ru \
    --cc=dev@dpdk.org \
    /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).