net/ice: support flow redirect
authorBeilei Xing <beilei.xing@intel.com>
Mon, 30 Mar 2020 17:38:52 +0000 (01:38 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:05 +0000 (13:57 +0200)
Add a new ops "redirect" to flow engine, it's used to implement the
function that redirect a flow's destination. Currently only support
VSI-Redirect which will be used by DCF for handling VF-VSI mapping
table change.
A new API "ice_flow_redirect" is exposed, current usage is: it could
be called when there's VF-VSI mapping table change caused by VF reset.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/ice_generic_flow.c
drivers/net/ice/ice_generic_flow.h

index a1648ee..823ff0e 100644 (file)
@@ -1961,3 +1961,25 @@ ice_flow_query(struct rte_eth_dev *dev,
        }
        return ret;
 }
+
+int
+ice_flow_redirect(struct ice_adapter *ad,
+                 struct ice_flow_redirect *rd)
+{
+       struct ice_pf *pf = &ad->pf;
+       struct rte_flow *p_flow;
+       void *temp;
+       int ret;
+
+       TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) {
+               if (!p_flow->engine->redirect)
+                       continue;
+               ret = p_flow->engine->redirect(ad, p_flow, rd);
+               if (ret) {
+                       PMD_DRV_LOG(ERR, "Failed to redirect flows");
+                       return ret;
+               }
+       }
+
+       return 0;
+}
index adc30ee..ede6ec8 100644 (file)
@@ -417,6 +417,20 @@ struct ice_pattern_match_item {
        void *meta;
 };
 
+enum ice_flow_redirect_type {
+       ICE_FLOW_REDIRECT_VSI,
+};
+
+struct ice_flow_redirect {
+       enum ice_flow_redirect_type type;
+       union {
+               struct {
+                       uint16_t vsi_handle;
+                       uint16_t new_vsi_num;
+               };
+       };
+};
+
 typedef int (*engine_init_t)(struct ice_adapter *ad);
 typedef void (*engine_uninit_t)(struct ice_adapter *ad);
 typedef int (*engine_create_t)(struct ice_adapter *ad,
@@ -430,6 +444,9 @@ typedef int (*engine_query_t)(struct ice_adapter *ad,
                struct rte_flow *flow,
                struct rte_flow_query_count *count,
                struct rte_flow_error *error);
+typedef int(*engine_redirect_t)(struct ice_adapter *ad,
+                               struct rte_flow *flow,
+                               struct ice_flow_redirect *redirect);
 typedef void (*engine_free_t) (struct rte_flow *flow);
 typedef int (*parse_pattern_action_t)(struct ice_adapter *ad,
                struct ice_pattern_match_item *array,
@@ -447,6 +464,7 @@ struct ice_flow_engine {
        engine_create_t create;
        engine_destroy_t destroy;
        engine_query_t query_count;
+       engine_redirect_t redirect;
        engine_free_t free;
        enum ice_flow_engine_type type;
 };
@@ -485,4 +503,7 @@ ice_search_pattern_match_item(const struct rte_flow_item pattern[],
                struct ice_pattern_match_item *array,
                uint32_t array_len,
                struct rte_flow_error *error);
+int
+ice_flow_redirect(struct ice_adapter *ad,
+                 struct ice_flow_redirect *rd);
 #endif