From: "Wang, Ying A" <ying.a.wang@intel.com>
To: "Ye, Xiaolong" <xiaolong.ye@intel.com>
Cc: "Zhang, Qi Z" <qi.z.zhang@intel.com>,
"Yang, Qiming" <qiming.yang@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>, "Zhao1, Wei" <wei.zhao1@intel.com>
Subject: Re: [dpdk-dev] [PATCH 2/4] net/ice: rework for generic flow enabling
Date: Mon, 9 Sep 2019 01:45:36 +0000 [thread overview]
Message-ID: <44DE8E8A53B4014CA1985CEE86C07F2A0B989DD6@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: <20190906161258.GA108591@intel.com>
Hi, Xiaolong
> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Saturday, September 7, 2019 12:13 AM
> To: Wang, Ying A <ying.a.wang@intel.com>
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>; dev@dpdk.org; Zhao1, Wei <wei.zhao1@intel.com>
> Subject: Re: [PATCH 2/4] net/ice: rework for generic flow enabling
>
> On 09/04, Ying Wang wrote:
> >The patch reworks the generic flow API (rte_flow) implementation.
> >It introduces an abstract layer which provides a unified interface for
> >low-level filter engine (switch, fdir, hash) to register supported
> >patterns and actions and implement flow validate/create/destroy/flush/
> >query activities.
> >
> >The patch also removes the existing switch filter implementation to
> >avoid compile error. Switch filter implementation for the new framework
> >will be added in the following patch.
> >
> >Signed-off-by: Ying Wang <ying.a.wang@intel.com>
> >---
> > drivers/net/ice/ice_ethdev.c | 22 +-
> > drivers/net/ice/ice_ethdev.h | 15 +-
> > drivers/net/ice/ice_generic_flow.c | 768
> >+++++++++++++++--------------------
> > drivers/net/ice/ice_generic_flow.h | 782
> >++++++++----------------------------
> > drivers/net/ice/ice_switch_filter.c | 511 -----------------------
> >drivers/net/ice/ice_switch_filter.h | 18 -
> > 6 files changed, 525 insertions(+), 1591 deletions(-)
> >
> >diff --git a/drivers/net/ice/ice_ethdev.c
> >b/drivers/net/ice/ice_ethdev.c index 4e0645db1..647aca3ed 100644
> >--- a/drivers/net/ice/ice_ethdev.c
> >+++ b/drivers/net/ice/ice_ethdev.c
> >@@ -15,7 +15,7 @@
> > #include "base/ice_dcb.h"
> > #include "ice_ethdev.h"
> > #include "ice_rxtx.h"
> >-#include "ice_switch_filter.h"
> >+#include "ice_generic_flow.h"
> >
> > /* devargs */
> > #define ICE_SAFE_MODE_SUPPORT_ARG "safe-mode-support"
> >@@ -1677,7 +1677,11 @@ ice_dev_init(struct rte_eth_dev *dev)
> > /* get base queue pairs index in the device */
> > ice_base_queue_get(pf);
> >
> >- TAILQ_INIT(&pf->flow_list);
> >+ ret = ice_flow_init(ad);
> >+ if (ret) {
> >+ PMD_INIT_LOG(ERR, "Failed to initialize flow");
> >+ return ret;
> >+ }
> >
> > return 0;
> >
> >@@ -1796,6 +1800,8 @@ ice_dev_close(struct rte_eth_dev *dev) {
> > struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> > struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> >+ struct ice_adapter *ad =
> >+ ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> >
> > /* Since stop will make link down, then the link event will be
> > * triggered, disable the irq firstly to avoid the port_infoe etc @@
> >-1806,6 +1812,8 @@ ice_dev_close(struct rte_eth_dev *dev)
> >
> > ice_dev_stop(dev);
> >
> >+ ice_flow_uninit(ad);
> >+
> > /* release all queue resource */
> > ice_free_queues(dev);
> >
> >@@ -1822,8 +1830,6 @@ ice_dev_uninit(struct rte_eth_dev *dev) {
> > struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
> > struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
> >- struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> >- struct rte_flow *p_flow;
> >
> > ice_dev_close(dev);
> >
> >@@ -1840,14 +1846,6 @@ ice_dev_uninit(struct rte_eth_dev *dev)
> > /* unregister callback func from eal lib */
> > rte_intr_callback_unregister(intr_handle,
> > ice_interrupt_handler, dev);
> >-
> >- /* Remove all flows */
> >- while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
> >- TAILQ_REMOVE(&pf->flow_list, p_flow, node);
> >- ice_free_switch_filter_rule(p_flow->rule);
> >- rte_free(p_flow);
> >- }
> >-
> > return 0;
> > }
> >
> >diff --git a/drivers/net/ice/ice_ethdev.h
> >b/drivers/net/ice/ice_ethdev.h index 9bf5de08d..d1d07641d 100644
> >--- a/drivers/net/ice/ice_ethdev.h
> >+++ b/drivers/net/ice/ice_ethdev.h
> >@@ -241,16 +241,14 @@ struct ice_vsi {
> > bool offset_loaded;
> > };
> >
> >-extern const struct rte_flow_ops ice_flow_ops;
> >-
> >-/* Struct to store flow created. */
> >-struct rte_flow {
> >- TAILQ_ENTRY(rte_flow) node;
> >- void *rule;
> >-};
> >
> >+struct rte_flow;
> > TAILQ_HEAD(ice_flow_list, rte_flow);
> >
> >+
> >+struct ice_flow_parser;
> >+TAILQ_HEAD(ice_parser_list, ice_flow_parser);
> >+
> > struct ice_pf {
> > struct ice_adapter *adapter; /* The adapter this PF associate to */
> > struct ice_vsi *main_vsi; /* pointer to main VSI structure */ @@
> >-278,6 +276,9 @@ struct ice_pf {
> > bool offset_loaded;
> > bool adapter_stopped;
> > struct ice_flow_list flow_list;
> >+ struct ice_parser_list rss_parser_list;
> >+ struct ice_parser_list perm_parser_list;
> >+ struct ice_parser_list dist_parser_list;
> > };
> >
> > /**
> >diff --git a/drivers/net/ice/ice_generic_flow.c
> >b/drivers/net/ice/ice_generic_flow.c
> >index 1c0adc779..aa11d6170 100644
> >--- a/drivers/net/ice/ice_generic_flow.c
> >+++ b/drivers/net/ice/ice_generic_flow.c
> >@@ -17,7 +17,22 @@
> >
> > #include "ice_ethdev.h"
> > #include "ice_generic_flow.h"
> >-#include "ice_switch_filter.h"
> >+
> >+/**
> >+ * Non-pipeline mode, fdir and swith both used as distributor,
>
> s/swith/switch
OK, will fix it in v2.
>
> >+ * fdir used first, switch used as fdir's backup.
> >+ */
> >+#define ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY 0 /*Pipeline mode,
> >+switch used at permission stage*/ #define
> >+ICE_FLOW_CLASSIFY_STAGE_PERMISSION 1 /*Pipeline mode, fdir used at
> >+distributor stage*/ #define ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR 2
> >+
> >+static int ice_pipeline_stage =
> >+ ICE_FLOW_CLASSIFY_STAGE_DISTRIBUTOR_ONLY;
> >+
> >+static struct ice_engine_list engine_list =
> >+ TAILQ_HEAD_INITIALIZER(engine_list);
> >
> > static int ice_flow_validate(struct rte_eth_dev *dev,
> > const struct rte_flow_attr *attr,
> >@@ -34,17 +49,153 @@ static int ice_flow_destroy(struct rte_eth_dev *dev,
> > struct rte_flow_error *error);
> > static int ice_flow_flush(struct rte_eth_dev *dev,
> > struct rte_flow_error *error);
> >+static int ice_flow_query_count(struct rte_eth_dev *dev,
> >+ struct rte_flow *flow,
> >+ const struct rte_flow_action *actions,
> >+ void *data,
> >+ struct rte_flow_error *error);
> >
> > const struct rte_flow_ops ice_flow_ops = {
> > .validate = ice_flow_validate,
> > .create = ice_flow_create,
> > .destroy = ice_flow_destroy,
> > .flush = ice_flow_flush,
> >+ .query = ice_flow_query_count,
> > };
> >
> >+
> >+void
> >+ice_register_flow_engine(struct ice_flow_engine *engine) {
> >+ TAILQ_INSERT_TAIL(&engine_list, engine, node); }
> >+
> >+int
> >+ice_flow_init(struct ice_adapter *ad)
> >+{
> >+ int ret = 0;
> >+ struct ice_pf *pf = &ad->pf;
> >+ void *temp;
> >+ struct ice_flow_engine *engine = NULL;
> >+
> >+ TAILQ_INIT(&pf->flow_list);
> >+ TAILQ_INIT(&pf->rss_parser_list);
> >+ TAILQ_INIT(&pf->perm_parser_list);
> >+ TAILQ_INIT(&pf->dist_parser_list);
> >+
> >+ TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
> >+ if (engine->init == NULL)
> >+ return -EINVAL;
> >+
> >+ ret = engine->init(ad);
> >+ if (ret)
> >+ return ret;
> >+ }
> >+ return 0;
> >+}
> >+
> >+void
> >+ice_flow_uninit(struct ice_adapter *ad) {
> >+ struct ice_pf *pf = &ad->pf;
> >+ struct ice_flow_engine *engine;
> >+ struct rte_flow *p_flow;
> >+ struct ice_flow_parser *p_parser;
> >+ void *temp;
> >+
> >+ TAILQ_FOREACH_SAFE(engine, &engine_list, node, temp) {
> >+ if (engine->uninit)
> >+ engine->uninit(ad);
> >+ }
> >+
> >+ /* Remove all flows */
> >+ while ((p_flow = TAILQ_FIRST(&pf->flow_list))) {
> >+ TAILQ_REMOVE(&pf->flow_list, p_flow, node);
> >+ if (p_flow->engine->free)
> >+ p_flow->engine->free(p_flow);
> >+ rte_free(p_flow);
> >+ }
> >+
> >+ /* Cleanup parser list */
> >+ while ((p_parser = TAILQ_FIRST(&pf->rss_parser_list)))
> >+ TAILQ_REMOVE(&pf->rss_parser_list, p_parser, node);
> >+
> >+ while ((p_parser = TAILQ_FIRST(&pf->perm_parser_list)))
> >+ TAILQ_REMOVE(&pf->perm_parser_list, p_parser, node);
> >+
> >+ while ((p_parser = TAILQ_FIRST(&pf->dist_parser_list)))
> >+ TAILQ_REMOVE(&pf->dist_parser_list, p_parser, node); }
> >+
> >+int
> >+ice_register_parser(struct ice_flow_parser *parser,
> >+ struct ice_adapter *ad)
> >+{
> >+ struct ice_parser_list *list = NULL;
> >+ struct ice_pf *pf = &ad->pf;
> >+
> >+ switch (parser->stage) {
> >+ case ICE_FLOW_STAGE_RSS:
> >+ list = &pf->rss_parser_list;
> >+ break;
> >+ case ICE_FLOW_STAGE_PERMISSION:
> >+ list = &pf->perm_parser_list;
> >+ break;
> >+ case ICE_FLOW_STAGE_DISTRIBUTOR:
> >+ list = &pf->dist_parser_list;
> >+ break;
> >+ default:
> >+ return -EINVAL;
> >+ }
> >+
> >+ if (ad->devargs.pipeline_mode_support)
> >+ TAILQ_INSERT_TAIL(list, parser, node);
> >+ else {
> >+ if (parser->engine->type == ICE_FLOW_ENGINE_SWITCH
> >+ || parser->engine->type == ICE_FLOW_ENGINE_HASH)
> >+ TAILQ_INSERT_TAIL(list, parser, node);
> >+ else if (parser->engine->type == ICE_FLOW_ENGINE_FDIR)
> >+ TAILQ_INSERT_HEAD(list, parser, node);
> >+ else
> >+ return -EINVAL;
> >+ }
> >+ return 0;
> >+}
> >+
> >+void
> >+ice_unregister_parser(struct ice_flow_parser *parser,
> >+ struct ice_adapter *ad)
> >+{
> >+ struct ice_pf *pf = &ad->pf;
> >+ struct ice_parser_list *list;
> >+ struct ice_flow_parser *p_parser;
> >+ void *temp;
> >+
> >+ switch (parser->stage) {
> >+ case ICE_FLOW_STAGE_RSS:
> >+ list = &pf->rss_parser_list;
> >+ break;
> >+ case ICE_FLOW_STAGE_PERMISSION:
> >+ list = &pf->perm_parser_list;
> >+ break;
> >+ case ICE_FLOW_STAGE_DISTRIBUTOR:
> >+ list = &pf->dist_parser_list;
> >+ break;
> >+ default:
> >+ return;
> >+ }
>
> The switch blocks in above functions are the same, it's better to use a common
> function to reduce the duplicated code.
The switch blocks in the above two functions have little difference in the default behavior, one is return -EINVAL, the other is just return, for register/unregister funcs have different return value types. So, Can I just keep this format?
>
> Thanks,
> Xiaolong
Thanks,
Ying
next prev parent reply other threads:[~2019-09-09 1:45 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 22:15 [dpdk-dev] [PATCH 0/4] rework for ice generic flow framework and switch filter Ying Wang
2019-09-03 22:15 ` [dpdk-dev] [PATCH 1/4] net/ice: add devargs to control pipeline mode Ying Wang
2019-09-04 12:34 ` Ye Xiaolong
2019-09-09 3:08 ` Yang, Qiming
2019-09-09 9:17 ` Ye Xiaolong
2019-09-10 7:10 ` Yang, Qiming
2019-09-04 18:29 ` Stillwell Jr, Paul M
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 0/5] rework for ice generic flow framework and switch filter Ying Wang
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 1/5] net/ice: minor code clean Ying Wang
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 0/5] rework for ice generic flow framework and switch filter Ying Wang
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 1/5] net/ice: minor code clean Ying Wang
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 0/5] rework for ice generic flow framework and switch filter Ying Wang
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 1/5] net/ice: minor code clean Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 0/5] rework for ice generic flow framework and switch filter Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 1/5] net/ice: minor code clean Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 2/5] net/ice: add devargs to control pipeline mode Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 3/5] net/ice: rework for generic flow enabling Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 4/5] net/ice: add pattern manifest Ying Wang
2019-10-16 18:33 ` [dpdk-dev] [PATCH v5 5/5] net/ice: rework switch filter Ying Wang
2019-10-17 3:03 ` [dpdk-dev] [PATCH v5 0/5] rework for ice generic flow framework and " Ye Xiaolong
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 2/5] net/ice: add devargs to control pipeline mode Ying Wang
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 3/5] net/ice: rework for generic flow enabling Ying Wang
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 4/5] net/ice: add pattern manifest Ying Wang
2019-10-14 3:42 ` [dpdk-dev] [PATCH v4 5/5] net/ice: rework switch filter Ying Wang
2019-10-16 2:55 ` Ye Xiaolong
2019-10-16 3:03 ` Wang, Ying A
2019-10-17 2:26 ` [dpdk-dev] [PATCH v4 0/5] rework for ice generic flow framework and " Ye Xiaolong
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 2/5] net/ice: add devargs to control pipeline mode Ying Wang
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 3/5] net/ice: rework for generic flow enabling Ying Wang
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 4/5] net/ice: add pattern manifest Ying Wang
2019-09-26 18:55 ` [dpdk-dev] [PATCH v3 5/5] net/ice: rework switch filter Ying Wang
2019-09-30 0:27 ` [dpdk-dev] [PATCH v3 0/5] rework for ice generic flow framework and " Zhang, Qi Z
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 2/5] net/ice: add devargs to control pipeline mode Ying Wang
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 3/5] net/ice: rework for generic flow enabling Ying Wang
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 4/5] net/ice: add pattern manifest Ying Wang
2019-09-16 23:06 ` [dpdk-dev] [PATCH v2 5/5] net/ice: rework switch filter Ying Wang
2019-09-03 22:15 ` [dpdk-dev] [PATCH 2/4] net/ice: rework for generic flow enabling Ying Wang
2019-09-04 14:44 ` Ye Xiaolong
2019-09-05 12:59 ` Wang, Ying A
2019-09-05 13:26 ` Ye Xiaolong
2019-09-06 16:12 ` Ye Xiaolong
2019-09-09 1:45 ` Wang, Ying A [this message]
2019-09-09 9:53 ` Ye Xiaolong
2019-09-09 10:21 ` Wang, Ying A
2019-09-08 15:55 ` Ye Xiaolong
2019-09-09 2:12 ` Wang, Ying A
2019-09-09 9:31 ` Ye Xiaolong
2019-09-03 22:15 ` [dpdk-dev] [PATCH 3/4] net/ice: add pattern manifest Ying Wang
2019-09-03 22:15 ` [dpdk-dev] [PATCH 4/4] net/ice: rework switch filter Ying Wang
2019-09-08 12:04 ` Ye Xiaolong
2019-09-09 3:03 ` Zhao1, Wei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44DE8E8A53B4014CA1985CEE86C07F2A0B989DD6@SHSMSX101.ccr.corp.intel.com \
--to=ying.a.wang@intel.com \
--cc=dev@dpdk.org \
--cc=qi.z.zhang@intel.com \
--cc=qiming.yang@intel.com \
--cc=wei.zhao1@intel.com \
--cc=xiaolong.ye@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).