From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <johndale@cisco.com>
Received: from alln-iport-7.cisco.com (alln-iport-7.cisco.com [173.37.142.94])
 by dpdk.org (Postfix) with ESMTP id 5B90B37A0
 for <dev@dpdk.org>; Thu, 30 Mar 2017 23:28:48 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=cisco.com; i=@cisco.com; l=7088; q=dns/txt; s=iport;
 t=1490909328; x=1492118928;
 h=from:to:cc:subject:date:message-id:in-reply-to: references;
 bh=RjunC33cBYG5BdqZFiFYvIkHfvv/A7x5FtKEHpmk7co=;
 b=UPg4/YTtWQa6y0W5mzFZjw0q+p0vBhDOWpeCWh+xKKluRuuzswWOSGKs
 yDsr9wy+x52V0MPGDZpJfc/oHr7KwipynHiHasBooPvTo56GcgREzQJlw
 +cNyIfwIRxatWEW/cywqkDAZuamqyujb7HeW3En4FI+Hwr6Bzk5ar/2AL s=;
X-IronPort-AV: E=Sophos;i="5.36,248,1486425600"; d="scan'208";a="405383868"
Received: from rcdn-core-5.cisco.com ([173.37.93.156])
 by alln-iport-7.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 30 Mar 2017 21:28:47 +0000
Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48])
 by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id v2ULSl5x027975;
 Thu, 30 Mar 2017 21:28:47 GMT
Received: by cisco.com (Postfix, from userid 392789)
 id 230603FAAF13; Thu, 30 Mar 2017 14:28:47 -0700 (PDT)
From: John Daley <johndale@cisco.com>
To: ferruh.yigit@intel.com
Cc: dev@dpdk.org, adrien.mazarguil@6wind.com, John Daley <johndale@cisco.com>
Date: Thu, 30 Mar 2017 14:28:36 -0700
Message-Id: <20170330212838.31291-4-johndale@cisco.com>
X-Mailer: git-send-email 2.12.0
In-Reply-To: <20170330212838.31291-1-johndale@cisco.com>
References: <20170330212838.31291-1-johndale@cisco.com>
Subject: [dpdk-dev] [PATCH 4/6] net/enic: flow API for NICs with advanced
	filters disabled
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 30 Mar 2017 21:28:49 -0000

Flow support for 1300 series adapters with the 'Advanced Filter'
mode disabled via the UCS management interface. This allows:
Attributes: ingress
Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth (full hdr masking)
Actions: queue and void
Selectors: 'is', 'spec' and 'mask'. 'last' is not supported

With advanced filters disabled, an IPv4 or IPv6 item must be specified
in the pattern.

Signed-off-by: John Daley <johndale@cisco.com>
Reviewed-by: Nelson Escobar <neescoba@cisco.com>
---
 drivers/net/enic/enic_flow.c | 135 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 133 insertions(+), 2 deletions(-)

diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c
index 1ea2770c4..21da80a88 100644
--- a/drivers/net/enic/enic_flow.c
+++ b/drivers/net/enic/enic_flow.c
@@ -101,8 +101,85 @@ static enic_copy_item_fn enic_copy_item_tcp_v2;
 static enic_copy_item_fn enic_copy_item_sctp_v2;
 static enic_copy_item_fn enic_copy_item_sctp_v2;
 static enic_copy_item_fn enic_copy_item_vxlan_v2;
+static copy_action_fn enic_copy_action_v1;
 static copy_action_fn enic_copy_action_v2;
 
+/**
+ * NICs have Advanced Filters capability but they are disabled. This means
+ * that layer 3 must be specified.
+ */
+static const struct enic_items enic_items_v2[] = {
+	[RTE_FLOW_ITEM_TYPE_ETH] = {
+		.copy_item = enic_copy_item_eth_v2,
+		.valid_start_item = 1,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_VXLAN,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_VLAN] = {
+		.copy_item = enic_copy_item_vlan_v2,
+		.valid_start_item = 1,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_ETH,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_IPV4] = {
+		.copy_item = enic_copy_item_ipv4_v2,
+		.valid_start_item = 1,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_ETH,
+			       RTE_FLOW_ITEM_TYPE_VLAN,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_IPV6] = {
+		.copy_item = enic_copy_item_ipv6_v2,
+		.valid_start_item = 1,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_ETH,
+			       RTE_FLOW_ITEM_TYPE_VLAN,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_UDP] = {
+		.copy_item = enic_copy_item_udp_v2,
+		.valid_start_item = 0,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_IPV4,
+			       RTE_FLOW_ITEM_TYPE_IPV6,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_TCP] = {
+		.copy_item = enic_copy_item_tcp_v2,
+		.valid_start_item = 0,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_IPV4,
+			       RTE_FLOW_ITEM_TYPE_IPV6,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_SCTP] = {
+		.copy_item = enic_copy_item_sctp_v2,
+		.valid_start_item = 0,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_IPV4,
+			       RTE_FLOW_ITEM_TYPE_IPV6,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+	[RTE_FLOW_ITEM_TYPE_VXLAN] = {
+		.copy_item = enic_copy_item_vxlan_v2,
+		.valid_start_item = 0,
+		.prev_items = (const enum rte_flow_item_type[]) {
+			       RTE_FLOW_ITEM_TYPE_UDP,
+			       RTE_FLOW_ITEM_TYPE_END,
+		},
+	},
+};
+
 /** NICs with Advanced filters enabled */
 static const struct enic_items enic_items_v3[] = {
 	[RTE_FLOW_ITEM_TYPE_ETH] = {
@@ -178,11 +255,20 @@ static const struct enic_items enic_items_v3[] = {
 
 /** Filtering capabilites indexed this NICs supported filter type. */
 static const struct enic_filter_cap enic_filter_cap[] = {
+	[FILTER_USNIC_IP] = {
+		.item_info = enic_items_v2,
+	},
 	[FILTER_DPDK_1] = {
 		.item_info = enic_items_v3,
 	},
 };
 
+/** Supported actions for older NICs */
+static const enum rte_flow_action_type enic_supported_actions_v1[] = {
+	RTE_FLOW_ACTION_TYPE_QUEUE,
+	RTE_FLOW_ACTION_TYPE_END,
+};
+
 /** Supported actions for newer NICs */
 static const enum rte_flow_action_type enic_supported_actions_v2[] = {
 	RTE_FLOW_ACTION_TYPE_QUEUE,
@@ -193,6 +279,10 @@ static const enum rte_flow_action_type enic_supported_actions_v2[] = {
 
 /** Action capabilites indexed by NIC version information */
 static const struct enic_action_cap enic_action_cap[] = {
+	[FILTER_ACTION_RQ_STEERING_FLAG] = {
+		.actions = enic_supported_actions_v1,
+		.copy_fn = enic_copy_action_v1,
+	},
 	[FILTER_ACTION_V2_ALL] = {
 		.actions = enic_supported_actions_v2,
 		.copy_fn = enic_copy_action_v2,
@@ -607,7 +697,6 @@ enic_copy_filter(const struct rte_flow_item pattern[],
 	enum rte_flow_item_type prev_item;
 	const struct enic_items *item_info;
 
-	enic_filter->type = FILTER_DPDK_1;
 	u8 is_first_item = 1;
 
 	FLOW_TRACE();
@@ -645,6 +734,44 @@ enic_copy_filter(const struct rte_flow_item pattern[],
 			   item, "stacking error");
 	return -rte_errno;
 }
+
+/**
+ * Build the intenal version 1 NIC action structure from the provided pattern.
+ * The pattern is validated as the items are copied.
+ *
+ * @param actions[in]
+ * @param enic_action[out]
+ *   NIC specfilc actions derived from the actions.
+ * @param error[out]
+ */
+static int
+enic_copy_action_v1(const struct rte_flow_action actions[],
+		    struct filter_action_v2 *enic_action)
+{
+	FLOW_TRACE();
+
+	for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+		if (actions->type == RTE_FLOW_ACTION_TYPE_VOID)
+			continue;
+
+		switch (actions->type) {
+		case RTE_FLOW_ACTION_TYPE_QUEUE: {
+			const struct rte_flow_action_queue *queue =
+				(const struct rte_flow_action_queue *)
+				actions->conf;
+			enic_action->rq_idx =
+				enic_rte_rq_idx_to_sop_idx(queue->index);
+			break;
+		}
+		default:
+			RTE_ASSERT(0);
+			break;
+		}
+	}
+	enic_action->type = FILTER_ACTION_RQ_STEERING;
+	return 0;
+}
+
 /**
  * Build the intenal version 2 NIC action structure from the provided pattern.
  * The pattern is validated as the items are copied.
@@ -719,7 +846,8 @@ static const struct enic_filter_cap *
 enic_get_filter_cap(struct enic *enic)
 {
 	/* FIXME: only support advanced filters for now */
-	if (enic->flow_filter_mode != FILTER_DPDK_1)
+	if ((enic->flow_filter_mode != FILTER_DPDK_1) &&
+	   (enic->flow_filter_mode != FILTER_USNIC_IP))
 		return (const struct enic_filter_cap *)NULL;
 
 	if (enic->flow_filter_mode)
@@ -736,6 +864,8 @@ enic_get_action_cap(struct enic *enic)
 
 	if (enic->filter_tags)
 		ea = &enic_action_cap[FILTER_ACTION_V2_ALL];
+	else
+		ea = &enic_action_cap[FILTER_ACTION_RQ_STEERING_FLAG];
 	return ea;
 }
 /**
@@ -848,6 +978,7 @@ enic_flow_parse(struct rte_eth_dev *dev,
 			   NULL, "Flow API not available");
 		return -rte_errno;
 	}
+	enic_filter->type = enic->flow_filter_mode;
 	ret = enic_copy_filter(pattern, enic_filter_cap->item_info,
 				       enic_filter, error);
 	return ret;
-- 
2.12.0