All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Subject: [PATCH 21/23] net/sfc: make processing of flow rule actions more uniform
Date: Thu, 19 Apr 2018 12:37:04 +0100	[thread overview]
Message-ID: <1524137826-5675-22-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1524137826-5675-1-git-send-email-arybchenko@solarflare.com>

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

Prepare function that parse flow rule actions to support not
fate-deciding actions.

Signed-off-by: Roman Zhukov <Roman.Zhukov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_flow.c | 57 ++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 20 deletions(-)

diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 55226f1..bec29ae 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -1498,7 +1498,10 @@ sfc_flow_parse_actions(struct sfc_adapter *sa,
 		       struct rte_flow_error *error)
 {
 	int rc;
-	boolean_t is_specified = B_FALSE;
+	uint32_t actions_set = 0;
+	const uint32_t fate_actions_mask = (1UL << RTE_FLOW_ACTION_TYPE_QUEUE) |
+					   (1UL << RTE_FLOW_ACTION_TYPE_RSS) |
+					   (1UL << RTE_FLOW_ACTION_TYPE_DROP);
 
 	if (actions == NULL) {
 		rte_flow_error_set(error, EINVAL,
@@ -1507,21 +1510,22 @@ sfc_flow_parse_actions(struct sfc_adapter *sa,
 		return -rte_errno;
 	}
 
+#define SFC_BUILD_SET_OVERFLOW(_action, _set) \
+	RTE_BUILD_BUG_ON(_action >= sizeof(_set) * CHAR_BIT)
+
 	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
-		/* This one may appear anywhere multiple times. */
-		if (actions->type == RTE_FLOW_ACTION_TYPE_VOID)
-			continue;
-		/* Fate-deciding actions may appear exactly once. */
-		if (is_specified) {
-			rte_flow_error_set
-				(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION,
-				 actions,
-				 "Cannot combine several fate-deciding actions,"
-				 "choose between QUEUE, RSS or DROP");
-			return -rte_errno;
-		}
 		switch (actions->type) {
+		case RTE_FLOW_ACTION_TYPE_VOID:
+			SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_VOID,
+					       actions_set);
+			break;
+
 		case RTE_FLOW_ACTION_TYPE_QUEUE:
+			SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_QUEUE,
+					       actions_set);
+			if ((actions_set & fate_actions_mask) != 0)
+				goto fail_fate_actions;
+
 			rc = sfc_flow_parse_queue(sa, actions->conf, flow);
 			if (rc != 0) {
 				rte_flow_error_set(error, EINVAL,
@@ -1529,11 +1533,14 @@ sfc_flow_parse_actions(struct sfc_adapter *sa,
 					"Bad QUEUE action");
 				return -rte_errno;
 			}
-
-			is_specified = B_TRUE;
 			break;
 
 		case RTE_FLOW_ACTION_TYPE_RSS:
+			SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_RSS,
+					       actions_set);
+			if ((actions_set & fate_actions_mask) != 0)
+				goto fail_fate_actions;
+
 			rc = sfc_flow_parse_rss(sa, actions->conf, flow);
 			if (rc != 0) {
 				rte_flow_error_set(error, rc,
@@ -1541,15 +1548,16 @@ sfc_flow_parse_actions(struct sfc_adapter *sa,
 					"Bad RSS action");
 				return -rte_errno;
 			}
-
-			is_specified = B_TRUE;
 			break;
 
 		case RTE_FLOW_ACTION_TYPE_DROP:
+			SFC_BUILD_SET_OVERFLOW(RTE_FLOW_ACTION_TYPE_DROP,
+					       actions_set);
+			if ((actions_set & fate_actions_mask) != 0)
+				goto fail_fate_actions;
+
 			flow->spec.template.efs_dmaq_id =
 				EFX_FILTER_SPEC_RX_DMAQ_ID_DROP;
-
-			is_specified = B_TRUE;
 			break;
 
 		default:
@@ -1558,15 +1566,24 @@ sfc_flow_parse_actions(struct sfc_adapter *sa,
 					   "Action is not supported");
 			return -rte_errno;
 		}
+
+		actions_set |= (1UL << actions->type);
 	}
+#undef SFC_BUILD_SET_OVERFLOW
 
 	/* When fate is unknown, drop traffic. */
-	if (!is_specified) {
+	if ((actions_set & fate_actions_mask) == 0) {
 		flow->spec.template.efs_dmaq_id =
 			EFX_FILTER_SPEC_RX_DMAQ_ID_DROP;
 	}
 
 	return 0;
+
+fail_fate_actions:
+	rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions,
+			   "Cannot combine several fate-deciding actions, "
+			   "choose between QUEUE, RSS or DROP");
+	return -rte_errno;
 }
 
 /**
-- 
2.7.4

  parent reply	other threads:[~2018-04-19 11:37 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 11:36 [PATCH 00/23] net/sfc: support equal stride super-buffer Rx mode Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 01/23] net/sfc/base: update autogenerated MCDI and TLV headers Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 02/23] net/sfc/base: make RxQ type data an union Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 03/23] net/sfc/base: detect equal stride super-buffer support Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 04/23] net/sfc/base: support equal stride super-buffer Rx mode Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 05/23] net/sfc/base: add equal stride super-buffer prefix layout Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 06/23] net/sfc: factor out function to push Rx doorbell Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 07/23] net/sfc: prepare EF10 Rx event parser to be reused Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 08/23] net/sfc: move EF10 Rx event parser to shared header Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 09/23] net/sfc: conditionally compile support for tunnel packets Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 10/23] net/sfc: allow one Rx queue entry carry many packet buffers Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 11/23] net/sfc: allow to take mbuf pool into account when sizing Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 12/23] net/sfc: support equal stride super-buffer Rx mode Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 13/23] net/sfc: support callback to check if mempool is supported Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 14/23] net/sfc: check mempool when equal stride super-buffer used Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 15/23] net/sfc: support DPDK firmware variant Andrew Rybchenko
2018-04-19 11:36 ` [PATCH 16/23] net/sfc: add Rx descriptor wait timeout Andrew Rybchenko
2018-04-19 11:37 ` [PATCH 17/23] net/sfc: support flow marks in equal stride super-buffer Rx Andrew Rybchenko
2018-04-19 11:37 ` [PATCH 18/23] net/sfc/base: get actions MARK and FLAG support Andrew Rybchenko
2018-04-19 11:37 ` [PATCH 19/23] net/sfc/base: support MARK and FLAG actions in filters Andrew Rybchenko
2018-04-19 11:37 ` [PATCH 20/23] net/sfc/base: get max supported value for action MARK Andrew Rybchenko
2018-04-19 11:37 ` Andrew Rybchenko [this message]
2018-04-19 11:37 ` [PATCH 22/23] net/sfc: support MARK and FLAG actions in flow API Andrew Rybchenko
2018-04-19 11:37 ` [PATCH 23/23] doc: advertise equal stride super-buffer Rx mode support in net/sfc Andrew Rybchenko
2018-04-26 22:47 ` [PATCH 00/23] net/sfc: support equal stride super-buffer Rx mode 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=1524137826-5675-22-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.