[dpdk-dev,2/3] net/ixgbe: enable signature match for consistent API

Message ID 1495828350-10259-3-git-send-email-qi.z.zhang@intel.com (mailing list archive)
State Not Applicable, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Qi Zhang May 26, 2017, 7:52 p.m. UTC
  Enable signature match for rte_flow API.
RTE_FLOW_ITEM_TYPE_ROUGHLY specify a signature match.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ixgbe/ixgbe_flow.c | 71 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 59 insertions(+), 12 deletions(-)
  

Comments

Wenzhuo Lu June 1, 2017, 5:50 a.m. UTC | #1
Hi Qi,

> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Saturday, May 27, 2017 3:52 AM
> To: Zhang, Helin; Lu, Wenzhuo
> Cc: dev@dpdk.org; Zhang, Qi Z
> Subject: [PATCH 2/3] net/ixgbe: enable signature match for consistent API
> 
> Enable signature match for rte_flow API.
> RTE_FLOW_ITEM_TYPE_ROUGHLY specify a signature match.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

Now I understand why you want to change the macro to the function in the first patch. :)
  
Qi Zhang June 1, 2017, 5:56 a.m. UTC | #2
> -----Original Message-----
> From: Lu, Wenzhuo
> Sent: Thursday, June 1, 2017 1:50 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Helin
> <helin.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for consistent
> API
> 
> Hi Qi,
> 
> > -----Original Message-----
> > From: Zhang, Qi Z
> > Sent: Saturday, May 27, 2017 3:52 AM
> > To: Zhang, Helin; Lu, Wenzhuo
> > Cc: dev@dpdk.org; Zhang, Qi Z
> > Subject: [PATCH 2/3] net/ixgbe: enable signature match for consistent API
> >
> > Enable signature match for rte_flow API.
> > RTE_FLOW_ITEM_TYPE_ROUGHLY specify a signature match.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> 
> Now I understand why you want to change the macro to the function in the
> first patch. :)

OK, I can merge the 2 patches into 1 in v2, if you think it's not necessary to separate.

Thanks
Qi
  
Wenzhuo Lu June 1, 2017, 6:13 a.m. UTC | #3
Hi Qi,

> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Thursday, June 1, 2017 1:56 PM
> To: Lu, Wenzhuo; Zhang, Helin
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for consistent
> API
> 
> 
> 
> > -----Original Message-----
> > From: Lu, Wenzhuo
> > Sent: Thursday, June 1, 2017 1:50 PM
> > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Helin
> > <helin.zhang@intel.com>
> > Cc: dev@dpdk.org
> > Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for
> > consistent API
> >
> > Hi Qi,
> >
> > > -----Original Message-----
> > > From: Zhang, Qi Z
> > > Sent: Saturday, May 27, 2017 3:52 AM
> > > To: Zhang, Helin; Lu, Wenzhuo
> > > Cc: dev@dpdk.org; Zhang, Qi Z
> > > Subject: [PATCH 2/3] net/ixgbe: enable signature match for
> > > consistent API
> > >
> > > Enable signature match for rte_flow API.
> > > RTE_FLOW_ITEM_TYPE_ROUGHLY specify a signature match.
> > >
> > > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> >
> > Now I understand why you want to change the macro to the function in
> > the first patch. :)
> 
> OK, I can merge the 2 patches into 1 in v2, if you think it's not necessary to
> separate.
It's better to have these 2 patches. Adding more info of the purpose in the commit log, like "removing the index ...", can make it easier to understand. :)

> 
> Thanks
> Qi
  
Qi Zhang June 1, 2017, 6:14 a.m. UTC | #4
> -----Original Message-----
> From: Lu, Wenzhuo
> Sent: Thursday, June 1, 2017 2:13 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Helin
> <helin.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for consistent
> API
> 
> Hi Qi,
> 
> > -----Original Message-----
> > From: Zhang, Qi Z
> > Sent: Thursday, June 1, 2017 1:56 PM
> > To: Lu, Wenzhuo; Zhang, Helin
> > Cc: dev@dpdk.org
> > Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for
> > consistent API
> >
> >
> >
> > > -----Original Message-----
> > > From: Lu, Wenzhuo
> > > Sent: Thursday, June 1, 2017 1:50 PM
> > > To: Zhang, Qi Z <qi.z.zhang@intel.com>; Zhang, Helin
> > > <helin.zhang@intel.com>
> > > Cc: dev@dpdk.org
> > > Subject: RE: [PATCH 2/3] net/ixgbe: enable signature match for
> > > consistent API
> > >
> > > Hi Qi,
> > >
> > > > -----Original Message-----
> > > > From: Zhang, Qi Z
> > > > Sent: Saturday, May 27, 2017 3:52 AM
> > > > To: Zhang, Helin; Lu, Wenzhuo
> > > > Cc: dev@dpdk.org; Zhang, Qi Z
> > > > Subject: [PATCH 2/3] net/ixgbe: enable signature match for
> > > > consistent API
> > > >
> > > > Enable signature match for rte_flow API.
> > > > RTE_FLOW_ITEM_TYPE_ROUGHLY specify a signature match.
> > > >
> > > > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> > > Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > >
> > > Now I understand why you want to change the macro to the function in
> > > the first patch. :)
> >
> > OK, I can merge the 2 patches into 1 in v2, if you think it's not
> > necessary to separate.
> It's better to have these 2 patches. Adding more info of the purpose in the
> commit log, like "removing the index ...", can make it easier to understand. :)

OK, that make sense.
> 
> >
> > Thanks
> > Qi
  

Patch

diff --git a/drivers/net/ixgbe/ixgbe_flow.c b/drivers/net/ixgbe/ixgbe_flow.c
index c6fb2f8..0638c32 100644
--- a/drivers/net/ixgbe/ixgbe_flow.c
+++ b/drivers/net/ixgbe/ixgbe_flow.c
@@ -1268,6 +1268,47 @@  ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
 	return 0;
 }
 
+/* search next no void pattern and skip roughly */
+static inline
+const struct rte_flow_item *next_no_roughly_pattern(
+		const struct rte_flow_item pattern[],
+		const struct rte_flow_item *cur)
+{
+	const struct rte_flow_item *next =
+		next_no_void_pattern(pattern, cur);
+	while (1) {
+		if (next->type != RTE_FLOW_ITEM_TYPE_ROUGHLY)
+			return next;
+		next = next_no_void_pattern(pattern, next);
+	}
+}
+
+static inline uint8_t signature_match(const struct rte_flow_item pattern[])
+{
+	const struct rte_flow_item_roughly *spec;
+	const struct rte_flow_item *item;
+	int i = 0;
+
+	while (1) {
+		item = pattern + i;
+		if (item->type == RTE_FLOW_ITEM_TYPE_END)
+			break;
+
+		if (item->type == RTE_FLOW_ITEM_TYPE_ROUGHLY) {
+			spec =
+			(const struct rte_flow_item_roughly *)item->spec;
+			if (spec->threshold)
+				return 1;
+			else
+				return 0;
+		}
+
+		i++;
+	}
+
+	return 0;
+}
+
 /**
  * Parse the rule to see if it is a IP or MAC VLAN flow director rule.
  * And get the flow director filter info BTW.
@@ -1277,6 +1318,7 @@  ixgbe_parse_fdir_act_attr(const struct rte_flow_attr *attr,
  * The next not void item could be UDP or TCP or SCTP (optional)
  * The next not void item could be RAW (for flexbyte, optional)
  * The next not void item must be END.
+ * A Roughly Match pattern can appear at any place before END (optional)
  * MAC VLAN PATTERN:
  * The first not void item must be ETH.
  * The second not void item must be MAC VLAN.
@@ -1371,7 +1413,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 	 * The first not void item should be
 	 * MAC or IPv4 or TCP or UDP or SCTP.
 	 */
-	item = next_no_void_pattern(pattern, NULL);
+	item = next_no_roughly_pattern(pattern, NULL);
 	if (item->type != RTE_FLOW_ITEM_TYPE_ETH &&
 	    item->type != RTE_FLOW_ITEM_TYPE_IPV4 &&
 	    item->type != RTE_FLOW_ITEM_TYPE_TCP &&
@@ -1384,7 +1426,10 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 		return -rte_errno;
 	}
 
-	rule->mode = RTE_FDIR_MODE_PERFECT;
+	if (signature_match(pattern))
+		rule->mode = RTE_FDIR_MODE_SIGNATURE;
+	else
+		rule->mode = RTE_FDIR_MODE_PERFECT;
 
 	/*Not supported last point for range*/
 	if (item->last) {
@@ -1421,14 +1466,13 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 
 
 		if (item->mask) {
-			/* If ethernet has meaning, it means MAC VLAN mode. */
-			rule->mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
 
 			rule->b_mask = TRUE;
 			eth_mask = (const struct rte_flow_item_eth *)item->mask;
 
 			/* Ether type should be masked. */
-			if (eth_mask->type) {
+			if (eth_mask->type ||
+			    rule->mode == RTE_FDIR_MODE_SIGNATURE) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1436,6 +1480,9 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 				return -rte_errno;
 			}
 
+			/* If ethernet has meaning, it means MAC VLAN mode. */
+			rule->mode = RTE_FDIR_MODE_PERFECT_MAC_VLAN;
+
 			/**
 			 * src MAC address must be masked,
 			 * and don't support dst MAC address mask.
@@ -1464,7 +1511,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 		 * Check if the next not void item is vlan or ipv4.
 		 * IPv6 is not supported.
 		 */
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (rule->mode == RTE_FDIR_MODE_PERFECT_MAC_VLAN) {
 			if (item->type != RTE_FLOW_ITEM_TYPE_VLAN) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
@@ -1513,7 +1560,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 		/**
 		 * Check if the next not void item is not vlan.
 		 */
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_END) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 			rte_flow_error_set(error, EINVAL,
@@ -1583,7 +1630,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 		 * Check if the next not void item is
 		 * TCP or UDP or SCTP or END.
 		 */
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_TCP &&
 		    item->type != RTE_FLOW_ITEM_TYPE_UDP &&
 		    item->type != RTE_FLOW_ITEM_TYPE_SCTP &&
@@ -1650,7 +1697,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 				tcp_spec->hdr.dst_port;
 		}
 
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
 		    item->type != RTE_FLOW_ITEM_TYPE_END) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
@@ -1710,7 +1757,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 				udp_spec->hdr.dst_port;
 		}
 
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
 		    item->type != RTE_FLOW_ITEM_TYPE_END) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
@@ -1772,7 +1819,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 				sctp_spec->hdr.dst_port;
 		}
 
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_RAW &&
 		    item->type != RTE_FLOW_ITEM_TYPE_END) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
@@ -1860,7 +1907,7 @@  ixgbe_parse_fdir_filter_normal(const struct rte_flow_attr *attr,
 
 	if (item->type != RTE_FLOW_ITEM_TYPE_END) {
 		/* check if the next not void item is END */
-		item = next_no_void_pattern(pattern, item);
+		item = next_no_roughly_pattern(pattern, item);
 		if (item->type != RTE_FLOW_ITEM_TYPE_END) {
 			memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 			rte_flow_error_set(error, EINVAL,