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 11/14] net/sfc: multiply of specs w/o inner frame destination MAC
Date: Tue, 27 Feb 2018 12:45:23 +0000	[thread overview]
Message-ID: <1519735526-2259-12-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1519735526-2259-1-git-send-email-arybchenko@solarflare.com>

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

Knowledge of a network identifier is not sufficient to construct a
workable hardware filter for encapsulated traffic. It's obligatory to
specify one of the match flags associated with inner frame destination
MAC. If the address is unknown, then one needs to specify either unknown
unicast or unknown multicast destination match flag.

In terms of RTE flow API, this would require adding multiple flow rules
with corresponding ETH items besides the tunnel item. In order to avoid
such a complication, the patch implements a mechanism to auto-complete
an underlying filter representation of a flow rule in order to create
additional filter specififcations featuring the missing match flags.

Signed-off-by: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
---
 drivers/net/sfc/sfc_flow.c | 114 ++++++++++++++++++++++++++++++++++++++++++++-
 drivers/net/sfc/sfc_flow.h |   2 +-
 2 files changed, 113 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 244fcdb..2d45827 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -68,6 +68,10 @@ typedef int (sfc_flow_spec_set_vals)(struct sfc_flow_spec *spec,
 				     unsigned int filters_count_for_one_val,
 				     struct rte_flow_error *error);
 
+typedef boolean_t (sfc_flow_spec_check)(efx_filter_match_flags_t match,
+					efx_filter_spec_t *spec,
+					struct sfc_filter *filter);
+
 struct sfc_flow_copy_flag {
 	/* EFX filter specification match flag */
 	efx_filter_match_flags_t flag;
@@ -75,9 +79,16 @@ struct sfc_flow_copy_flag {
 	unsigned int vals_count;
 	/* Function to set values in specifications */
 	sfc_flow_spec_set_vals *set_vals;
+	/*
+	 * Function to check that the specification is suitable
+	 * for adding this match flag
+	 */
+	sfc_flow_spec_check *spec_check;
 };
 
 static sfc_flow_spec_set_vals sfc_flow_set_ethertypes;
+static sfc_flow_spec_set_vals sfc_flow_set_ifrm_unknown_dst_flags;
+static sfc_flow_spec_check sfc_flow_check_ifrm_unknown_dst_flags;
 
 static boolean_t
 sfc_flow_is_zero(const uint8_t *buf, unsigned int size)
@@ -1548,12 +1559,98 @@ sfc_flow_set_ethertypes(struct sfc_flow_spec *spec,
 	return 0;
 }
 
+/**
+ * Set the EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST and
+ * EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST match flags in the same
+ * specifications after copying.
+ *
+ * @param spec[in, out]
+ *   SFC flow specification to update.
+ * @param filters_count_for_one_val[in]
+ *   How many specifications should have the same match flag, what is the
+ *   number of specifications before copying.
+ * @param error[out]
+ *   Perform verbose error reporting if not NULL.
+ */
+static int
+sfc_flow_set_ifrm_unknown_dst_flags(struct sfc_flow_spec *spec,
+				    unsigned int filters_count_for_one_val,
+				    struct rte_flow_error *error)
+{
+	unsigned int i;
+	static const efx_filter_match_flags_t vals[] = {
+		EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST,
+		EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST
+	};
+
+	if (filters_count_for_one_val * RTE_DIM(vals) != spec->count) {
+		rte_flow_error_set(error, EINVAL,
+			RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+			"Number of specifications is incorrect while copying "
+			"by inner frame unknown destination flags");
+		return -rte_errno;
+	}
+
+	for (i = 0; i < spec->count; i++) {
+		/* The check above ensures that divisor can't be zero here */
+		spec->filters[i].efs_match_flags |=
+			vals[i / filters_count_for_one_val];
+	}
+
+	return 0;
+}
+
+/**
+ * Check that the following conditions are met:
+ * - the specification corresponds to a filter for encapsulated traffic
+ * - the list of supported filters has a filter
+ *   with EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST flag instead of
+ *   EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST, since this filter will also
+ *   be inserted.
+ *
+ * @param match[in]
+ *   The match flags of filter.
+ * @param spec[in]
+ *   Specification to be supplemented.
+ * @param filter[in]
+ *   SFC filter with list of supported filters.
+ */
+static boolean_t
+sfc_flow_check_ifrm_unknown_dst_flags(efx_filter_match_flags_t match,
+				      efx_filter_spec_t *spec,
+				      struct sfc_filter *filter)
+{
+	unsigned int i;
+	efx_tunnel_protocol_t encap_type = spec->efs_encap_type;
+	efx_filter_match_flags_t match_mcast_dst;
+
+	if (encap_type == EFX_TUNNEL_PROTOCOL_NONE)
+		return B_FALSE;
+
+	match_mcast_dst =
+		(match & ~EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST) |
+		EFX_FILTER_MATCH_IFRM_UNKNOWN_MCAST_DST;
+	for (i = 0; i < filter->supported_match_num; i++) {
+		if (match_mcast_dst == filter->supported_match[i])
+			return B_TRUE;
+	}
+
+	return B_FALSE;
+}
+
 /* Match flags that can be automatically added to filters */
 static const struct sfc_flow_copy_flag sfc_flow_copy_flags[] = {
 	{
 		.flag = EFX_FILTER_MATCH_ETHER_TYPE,
 		.vals_count = 2,
 		.set_vals = sfc_flow_set_ethertypes,
+		.spec_check = NULL,
+	},
+	{
+		.flag = EFX_FILTER_MATCH_IFRM_UNKNOWN_UCAST_DST,
+		.vals_count = 2,
+		.set_vals = sfc_flow_set_ifrm_unknown_dst_flags,
+		.spec_check = sfc_flow_check_ifrm_unknown_dst_flags,
 	},
 };
 
@@ -1630,21 +1727,33 @@ sfc_flow_spec_add_match_flag(struct sfc_flow_spec *spec,
  *
  * @param miss_flags[in]
  *   Flags that are missing until the supported filter.
+ * @param spec[in]
+ *   Specification to be supplemented.
+ * @param filter[in]
+ *   SFC filter.
  *
  * @return
  *   Number of specifications after copy or 0, if the flags can not be added.
  */
 static unsigned int
-sfc_flow_check_missing_flags(efx_filter_match_flags_t miss_flags)
+sfc_flow_check_missing_flags(efx_filter_match_flags_t miss_flags,
+			     efx_filter_spec_t *spec,
+			     struct sfc_filter *filter)
 {
 	unsigned int i;
 	efx_filter_match_flags_t copy_flags = 0;
 	efx_filter_match_flags_t flag;
+	efx_filter_match_flags_t match = spec->efs_match_flags | miss_flags;
+	sfc_flow_spec_check *check;
 	unsigned int multiplier = 1;
 
 	for (i = 0; i < RTE_DIM(sfc_flow_copy_flags); i++) {
 		flag = sfc_flow_copy_flags[i].flag;
+		check = sfc_flow_copy_flags[i].spec_check;
 		if ((flag & miss_flags) == flag) {
+			if (check != NULL && (!check(match, spec, filter)))
+				continue;
+
 			copy_flags |= flag;
 			multiplier *= sfc_flow_copy_flags[i].vals_count;
 		}
@@ -1690,7 +1799,8 @@ sfc_flow_spec_filters_complete(struct sfc_adapter *sa,
 	for (i = 0; i < filter->supported_match_num; i++) {
 		if ((match & filter->supported_match[i]) == match) {
 			miss_flags = filter->supported_match[i] & (~match);
-			multiplier = sfc_flow_check_missing_flags(miss_flags);
+			multiplier = sfc_flow_check_missing_flags(miss_flags,
+				&spec->template, filter);
 			if (multiplier > 0) {
 				if (multiplier <= min_multiplier) {
 					min_multiplier = multiplier;
diff --git a/drivers/net/sfc/sfc_flow.h b/drivers/net/sfc/sfc_flow.h
index c4302c7..2b287dd 100644
--- a/drivers/net/sfc/sfc_flow.h
+++ b/drivers/net/sfc/sfc_flow.h
@@ -24,7 +24,7 @@ extern "C" {
  * which can be produced from a template by means of multiplication, if
  * missing match flags are needed to be taken into account
  */
-#define SF_FLOW_SPEC_NB_FILTERS_MAX 2
+#define SF_FLOW_SPEC_NB_FILTERS_MAX 4
 
 #if EFSYS_OPT_RX_SCALE
 /* RSS configuration storage */
-- 
2.7.4

  parent reply	other threads:[~2018-02-27 12:45 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-27 12:45 [dpdk-dev] [PATCH 00/14] net/sfc: support flow API for tunnels Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 01/14] net/sfc/base: support filters for encapsulated packets Andrew Rybchenko
2018-03-06 15:13   ` Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 02/14] net/sfc/base: support VNI/VSID and inner frame local MAC Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 03/14] net/sfc/base: support VXLAN filter creation Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 04/14] net/sfc/base: distinguish filters for encapsulated packets Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 05/14] net/sfc: add VXLAN in flow API filters support Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 06/14] net/sfc: add NVGRE " Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 07/14] net/sfc: add GENEVE " Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 08/14] net/sfc: add inner frame ETH " Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 09/14] net/sfc: add infrastructure to make many filters from flow Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 10/14] net/sfc: multiply of specs with an unknown EtherType Andrew Rybchenko
2018-02-27 12:45 ` Andrew Rybchenko [this message]
2018-02-27 12:45 ` [dpdk-dev] [PATCH 12/14] net/sfc: multiply of specs with an unknown destination MAC Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 13/14] net/sfc: avoid creation of ineffective flow rules Andrew Rybchenko
2018-02-27 12:45 ` [dpdk-dev] [PATCH 14/14] doc: add net/sfc flow API support for tunnels Andrew Rybchenko
2018-03-06 15:24 ` [dpdk-dev] [PATCH v2 00/14] net/sfc: support flow API " Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 01/14] net/sfc/base: support filters for encapsulated packets Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 02/14] net/sfc/base: support VNI/VSID and inner frame local MAC Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 03/14] net/sfc/base: support VXLAN filter creation Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 04/14] net/sfc/base: distinguish filters for encapsulated packets Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 05/14] net/sfc: add VXLAN in flow API filters support Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 06/14] net/sfc: add NVGRE " Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 07/14] net/sfc: add GENEVE " Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 08/14] net/sfc: add inner frame ETH " Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 09/14] net/sfc: add infrastructure to make many filters from flow Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 10/14] net/sfc: multiply of specs with an unknown EtherType Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 11/14] net/sfc: multiply of specs w/o inner frame destination MAC Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 12/14] net/sfc: multiply of specs with an unknown " Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 13/14] net/sfc: avoid creation of ineffective flow rules Andrew Rybchenko
2018-03-06 15:24   ` [dpdk-dev] [PATCH v2 14/14] doc: add net/sfc flow API support for tunnels Andrew Rybchenko
2018-03-09 10:37   ` [dpdk-dev] [PATCH v2 00/14] net/sfc: support flow API " 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=1519735526-2259-12-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).