net/i40e: support ether pattern for FDIR
authorBeilei Xing <beilei.xing@intel.com>
Fri, 9 Jun 2017 08:21:23 +0000 (16:21 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:29 +0000 (10:41 +0100)
Previously, i40e PMD will select ethertype filter
parser when adding ether pattern rules. In fact,
FDIR also supports ether pattern.
This patch adds ether pattern support for FDIR.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/i40e/i40e_flow.c

index 16c899b..c7589ce 100644 (file)
@@ -1572,6 +1572,7 @@ static struct i40e_valid_pattern i40e_supported_patterns[] = {
        /* Ethertype */
        { pattern_ethertype, i40e_flow_parse_ethertype_filter },
        /* FDIR - support default flow type without flexible payload*/
+       { pattern_ethertype, i40e_flow_parse_fdir_filter },
        { pattern_fdir_ipv4, i40e_flow_parse_fdir_filter },
        { pattern_fdir_ipv4_udp, i40e_flow_parse_fdir_filter },
        { pattern_fdir_ipv4_tcp, i40e_flow_parse_fdir_filter },
@@ -1817,10 +1818,10 @@ i40e_match_pattern(enum rte_flow_item_type *item_array,
 
 /* Find if there's parse filter function matched */
 static parse_filter_t
-i40e_find_parse_filter_func(struct rte_flow_item *pattern)
+i40e_find_parse_filter_func(struct rte_flow_item *pattern, uint32_t *idx)
 {
        parse_filter_t parse_filter = NULL;
-       uint8_t i = 0;
+       uint8_t i = *idx;
 
        for (; i < RTE_DIM(i40e_supported_patterns); i++) {
                if (i40e_match_pattern(i40e_supported_patterns[i].items,
@@ -1830,6 +1831,8 @@ i40e_find_parse_filter_func(struct rte_flow_item *pattern)
                }
        }
 
+       *idx = ++i;
+
        return parse_filter;
 }
 
@@ -3770,7 +3773,8 @@ i40e_flow_validate(struct rte_eth_dev *dev,
        parse_filter_t parse_filter;
        uint32_t item_num = 0; /* non-void item number of pattern*/
        uint32_t i = 0;
-       int ret;
+       bool flag = false;
+       int ret = I40E_NOT_SUPPORTED;
 
        if (!pattern) {
                rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
@@ -3812,16 +3816,21 @@ i40e_flow_validate(struct rte_eth_dev *dev,
 
        i40e_pattern_skip_void_item(items, pattern);
 
-       /* Find if there's matched parse filter function */
-       parse_filter = i40e_find_parse_filter_func(items);
-       if (!parse_filter) {
-               rte_flow_error_set(error, EINVAL,
-                                  RTE_FLOW_ERROR_TYPE_ITEM,
-                                  pattern, "Unsupported pattern");
-               return -rte_errno;
-       }
-
-       ret = parse_filter(dev, attr, items, actions, error, &cons_filter);
+       i = 0;
+       do {
+               parse_filter = i40e_find_parse_filter_func(items, &i);
+               if (!parse_filter && !flag) {
+                       rte_flow_error_set(error, EINVAL,
+                                          RTE_FLOW_ERROR_TYPE_ITEM,
+                                          pattern, "Unsupported pattern");
+                       rte_free(items);
+                       return -rte_errno;
+               }
+               if (parse_filter)
+                       ret = parse_filter(dev, attr, items, actions,
+                                          error, &cons_filter);
+               flag = true;
+       } while ((ret < 0) && (i < RTE_DIM(i40e_supported_patterns)));
 
        rte_free(items);