From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <hyonkim@cisco.com>
Received: from alln-iport-2.cisco.com (alln-iport-2.cisco.com [173.37.142.89])
 by dpdk.org (Postfix) with ESMTP id A83404C74
 for <dev@dpdk.org>; Sat,  2 Mar 2019 11:44:42 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=cisco.com; i=@cisco.com; l=4128; q=dns/txt; s=iport;
 t=1551523482; x=1552733082;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=pYrkt6WqCMrajrmJMPPHCjWUw+/C808Fue1gv2yI/Wk=;
 b=EH7stdy+SrG+Ws3rEuMEJvts+0HGjuQ+//3O3ECeVIEdEZnz72v6hJZQ
 OPaB15iHUki47sDkVJqdEvoe7oZZ/ssCGTB58Bbdh0/A5dzgcpwbwbGMo
 Zr2nPoK6W3hJ+ByNvJv7m0P6fu/638E43GTin8ZC2ouQq7WqFcGbVhT10 g=;
X-IronPort-AV: E=Sophos;i="5.58,431,1544486400"; d="scan'208";a="241896055"
Received: from rcdn-core-12.cisco.com ([173.37.93.148])
 by alln-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 02 Mar 2019 10:44:41 +0000
Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48])
 by rcdn-core-12.cisco.com (8.15.2/8.15.2) with ESMTP id x22Aif2e001188;
 Sat, 2 Mar 2019 10:44:41 GMT
Received: by cisco.com (Postfix, from userid 508933)
 id 4401E20F2001; Sat,  2 Mar 2019 02:44:41 -0800 (PST)
From: Hyong Youb Kim <hyonkim@cisco.com>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, John Daley <johndale@cisco.com>,
 Hyong Youb Kim <hyonkim@cisco.com>
Date: Sat,  2 Mar 2019 02:42:45 -0800
Message-Id: <20190302104251.32565-8-hyonkim@cisco.com>
X-Mailer: git-send-email 2.16.2
In-Reply-To: <20190302104251.32565-1-hyonkim@cisco.com>
References: <20190302104251.32565-1-hyonkim@cisco.com>
X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com
X-Outbound-Node: rcdn-core-12.cisco.com
Subject: [dpdk-dev] [PATCH v2 07/13] net/enic: enable limited PASSTHRU flow
	action
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sat, 02 Mar 2019 10:44:43 -0000

Some apps like VPP use PASSTHRU+MARK flow rules to offload packet
matching to the NIC. Just like MARK+RSS used by OVS-DPDK and others,
PASSTHRU+MARK is used to "mark and then receive normally". Recent VIC
adapters support such flow rules, so enable PASSTHRU for this limited
use case.

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
---
 doc/guides/nics/enic.rst               |  6 +++++-
 doc/guides/rel_notes/release_19_05.rst |  1 +
 drivers/net/enic/enic_flow.c           | 20 ++++++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/enic.rst b/doc/guides/nics/enic.rst
index ed093ef44..526e58ce9 100644
--- a/doc/guides/nics/enic.rst
+++ b/doc/guides/nics/enic.rst
@@ -256,7 +256,7 @@ Generic Flow API is supported. The baseline support is:
 
   - Attributes: ingress
   - Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth, ipv4, ipv6, udp, tcp
-  - Actions: queue, mark, drop, flag, rss, and void
+  - Actions: queue, mark, drop, flag, rss, passthru, and void
   - Selectors: 'is', 'spec' and 'mask'. 'last' is not supported
   - In total, up to 64 bytes of mask is allowed across all headers
 
@@ -451,6 +451,10 @@ PKT_RX_VLAN_STRIPPED mbuf flags would not be set. This mode is enabled with the
     were added. Since there currently is no grouping or priority support,
     'catch-all' filters should be added last.
   - The supported range of IDs for the 'MARK' action is 0 - 0xFFFD.
+  - RSS and PASSTHRU actions only support "receive normally". They are limited
+    to supporting MARK + RSS and PASSTHRU + MARK to allow the application to mark
+    packets and then receive them normally. These require 1400 series VIC adapters
+    and latest firmware.
 
 - **Statistics**
 
diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst
index 73403c79e..c8c12c47a 100644
--- a/doc/guides/rel_notes/release_19_05.rst
+++ b/doc/guides/rel_notes/release_19_05.rst
@@ -80,6 +80,7 @@ New Features
 * **Updated the enic driver.**
 
   * Added limited support for RSS.
+  * Added limited support for PASSTHRU.
 
 Removed Items
 -------------
diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c
index 0f6b6b930..c6ed9e1b9 100644
--- a/drivers/net/enic/enic_flow.c
+++ b/drivers/net/enic/enic_flow.c
@@ -283,6 +283,7 @@ static const enum rte_flow_action_type enic_supported_actions_v2_id[] = {
 	RTE_FLOW_ACTION_TYPE_MARK,
 	RTE_FLOW_ACTION_TYPE_FLAG,
 	RTE_FLOW_ACTION_TYPE_RSS,
+	RTE_FLOW_ACTION_TYPE_PASSTHRU,
 	RTE_FLOW_ACTION_TYPE_END,
 };
 
@@ -292,6 +293,7 @@ static const enum rte_flow_action_type enic_supported_actions_v2_drop[] = {
 	RTE_FLOW_ACTION_TYPE_FLAG,
 	RTE_FLOW_ACTION_TYPE_DROP,
 	RTE_FLOW_ACTION_TYPE_RSS,
+	RTE_FLOW_ACTION_TYPE_PASSTHRU,
 	RTE_FLOW_ACTION_TYPE_END,
 };
 
@@ -302,6 +304,7 @@ static const enum rte_flow_action_type enic_supported_actions_v2_count[] = {
 	RTE_FLOW_ACTION_TYPE_DROP,
 	RTE_FLOW_ACTION_TYPE_COUNT,
 	RTE_FLOW_ACTION_TYPE_RSS,
+	RTE_FLOW_ACTION_TYPE_PASSTHRU,
 	RTE_FLOW_ACTION_TYPE_END,
 };
 
@@ -1072,6 +1075,7 @@ enic_copy_action_v2(struct enic *enic,
 {
 	enum { FATE = 1, MARK = 2, };
 	uint32_t overlap = 0;
+	bool passthru = false;
 
 	FLOW_TRACE();
 
@@ -1164,6 +1168,19 @@ enic_copy_action_v2(struct enic *enic,
 			overlap |= FATE;
 			break;
 		}
+		case RTE_FLOW_ACTION_TYPE_PASSTHRU: {
+			/*
+			 * Like RSS above, PASSTHRU + MARK may be used to
+			 * "mark and then receive normally". MARK usually comes
+			 * after PASSTHRU, so remember we have seen passthru
+			 * and check for mark later.
+			 */
+			if (overlap & FATE)
+				return ENOTSUP;
+			overlap |= FATE;
+			passthru = true;
+			break;
+		}
 		case RTE_FLOW_ACTION_TYPE_VOID:
 			continue;
 		default:
@@ -1171,6 +1188,9 @@ enic_copy_action_v2(struct enic *enic,
 			break;
 		}
 	}
+	/* Only PASSTHRU + MARK is allowed */
+	if (passthru && !(overlap & MARK))
+		return ENOTSUP;
 	if (!(overlap & FATE))
 		return ENOTSUP;
 	enic_action->type = FILTER_ACTION_V2;
-- 
2.16.2