net/i40e: enable flow query RSS
authorChenxu Di <chenxux.di@intel.com>
Wed, 8 Jul 2020 01:18:40 +0000 (01:18 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Sat, 11 Jul 2020 04:18:52 +0000 (06:18 +0200)
This patch enables flow query function to get the
configuration of the specified rule.

Signed-off-by: Chenxu Di <chenxux.di@intel.com>
Acked-by: Jeff Guo <jia.guo@intel.com>
doc/guides/rel_notes/release_20_08.rst
drivers/net/i40e/i40e_flow.c

index 17c3af4..eb16d13 100644 (file)
@@ -134,6 +134,7 @@ New Features
   * Supported cloud filter for IPv4/6_TCP/UDP/SCTP with SRC port only or DST port only.
   * Re-implemented get_fdir_info and get_fdir_stat in private API.
   * Re-implemented set_gre_key_len in private API.
+  * Added support for flow query RSS.
 
 * **Updated the Intel ixgbe driver.**
 
index 955aead..7cd5373 100644 (file)
@@ -43,6 +43,10 @@ static int i40e_flow_destroy(struct rte_eth_dev *dev,
                             struct rte_flow_error *error);
 static int i40e_flow_flush(struct rte_eth_dev *dev,
                           struct rte_flow_error *error);
+static int i40e_flow_query(struct rte_eth_dev *dev,
+                          struct rte_flow *flow,
+                          const struct rte_flow_action *actions,
+                          void *data, struct rte_flow_error *error);
 static int
 i40e_flow_parse_ethertype_pattern(struct rte_eth_dev *dev,
                                  const struct rte_flow_item *pattern,
@@ -135,6 +139,7 @@ const struct rte_flow_ops i40e_flow_ops = {
        .create = i40e_flow_create,
        .destroy = i40e_flow_destroy,
        .flush = i40e_flow_flush,
+       .query = i40e_flow_query,
 };
 
 static union i40e_filter_t cons_filter;
@@ -5692,3 +5697,47 @@ i40e_flow_flush_rss_filter(struct rte_eth_dev *dev)
 
        return ret;
 }
+
+static int
+i40e_flow_query(struct rte_eth_dev *dev __rte_unused,
+               struct rte_flow *flow,
+               const struct rte_flow_action *actions,
+               void *data, struct rte_flow_error *error)
+{
+       struct i40e_rss_filter *rss_rule = (struct i40e_rss_filter *)flow->rule;
+       enum rte_filter_type filter_type = flow->filter_type;
+       struct rte_flow_action_rss *rss_conf = data;
+
+       if (!rss_rule) {
+               rte_flow_error_set(error, EINVAL,
+                                  RTE_FLOW_ERROR_TYPE_HANDLE,
+                                  NULL, "Invalid rule");
+               return -rte_errno;
+       }
+
+       for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) {
+               switch (actions->type) {
+               case RTE_FLOW_ACTION_TYPE_VOID:
+                       break;
+               case RTE_FLOW_ACTION_TYPE_RSS:
+                       if (filter_type != RTE_ETH_FILTER_HASH) {
+                               rte_flow_error_set(error, ENOTSUP,
+                                                  RTE_FLOW_ERROR_TYPE_ACTION,
+                                                  actions,
+                                                  "action not supported");
+                               return -rte_errno;
+                       }
+                       rte_memcpy(rss_conf,
+                                  &rss_rule->rss_filter_info.conf,
+                                  sizeof(struct rte_flow_action_rss));
+                       break;
+               default:
+                       return rte_flow_error_set(error, ENOTSUP,
+                                                 RTE_FLOW_ERROR_TYPE_ACTION,
+                                                 actions,
+                                                 "action not supported");
+               }
+       }
+
+       return 0;
+}