From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 52C821B147 for ; Sun, 30 Sep 2018 04:38:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2018 19:38:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,322,1534834800"; d="scan'208";a="87888139" Received: from dpdk-xiaoyun3.sh.intel.com ([10.67.119.56]) by orsmga003.jf.intel.com with ESMTP; 29 Sep 2018 19:38:02 -0700 From: Xiaoyun Li To: ferruh.yigit@intel.com, qi.z.zhang@intel.com, beilei.xing@intel.com, dev@dpdk.org Cc: Xiaoyun Li Date: Sun, 30 Sep 2018 10:29:50 +0800 Message-Id: <20180930022950.48747-1-xiaoyun.li@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180928072453.6348-1-xiaoyun.li@intel.com> References: <20180928072453.6348-1-xiaoyun.li@intel.com> Subject: [dpdk-dev] [PATCH v5] net/i40e: config fdir automatically X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Sep 2018 02:38:13 -0000 I40e driver needed users to config exact fdir mode to create rte_flow rules but it shouldn't. This patch allows users to create rte_flow rules without configuring fdir mode and let the driver config fdir automatically. And remove the workaround in flow filtering example. Signed-off-by: Xiaoyun Li --- v5: * Added missing comment in v4. v4: * Polished commit log. * Added comments that the original fdir config codes should be removed * when the legacy filter API is deprecated. v3: * Fixed fdir config doesn't automatically remove when last flow is * destroyed. v2: * Added fdir teardown in i40e_flow_flush_fdir_filter. * Replace TAILQ_FIRST with TAILQ_EMPTY which is more intuitive. * Remove the workaround in flow_filtering example since the driver will * set the fdir config automatically. --- drivers/net/i40e/i40e_ethdev.c | 15 ++++++++++++++- drivers/net/i40e/i40e_flow.c | 35 +++++++++++++++++++++++++++++----- examples/flow_filtering/main.c | 16 ---------------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index de25de650..63e5b4c85 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -1787,6 +1787,10 @@ i40e_dev_configure(struct rte_eth_dev *dev) ad->tx_simple_allowed = true; ad->tx_vec_allowed = true; + /* Only legacy filter API needs the following fdir config. So when the + * legacy filter API is deprecated, the following codes should also be + * removed. + */ if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT) { ret = i40e_fdir_setup(pf); if (ret != I40E_SUCCESS) { @@ -1844,7 +1848,11 @@ i40e_dev_configure(struct rte_eth_dev *dev) rte_free(pf->vmdq); pf->vmdq = NULL; err: - /* need to release fdir resource if exists */ + /* Need to release fdir resource if exists. + * Only legacy filter API needs the following fdir config. So when the + * legacy filter API is deprecated, the following code should also be + * removed. + */ i40e_fdir_teardown(pf); return ret; } @@ -2482,6 +2490,11 @@ i40e_dev_close(struct rte_eth_dev *dev) i40e_pf_disable_irq0(hw); rte_intr_disable(intr_handle); + /* + * Only legacy filter API needs the following fdir config. So when the + * legacy filter API is deprecated, the following code should also be + * removed. + */ i40e_fdir_teardown(pf); /* shutdown and destroy the HMC */ diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c index c67b264de..68ae00a27 100644 --- a/drivers/net/i40e/i40e_flow.c +++ b/drivers/net/i40e/i40e_flow.c @@ -3127,6 +3127,7 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, struct rte_flow_error *error, union i40e_filter_t *filter) { + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); struct i40e_fdir_filter_conf *fdir_filter = &filter->fdir_filter; int ret; @@ -3148,14 +3149,29 @@ i40e_flow_parse_fdir_filter(struct rte_eth_dev *dev, if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) { - rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, - "Check the mode in fdir_conf."); - return -rte_errno; + /* Enable fdir when fdir flow is added at first time. */ + ret = i40e_fdir_setup(pf); + if (ret != I40E_SUCCESS) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, "Failed to setup fdir."); + return -rte_errno; + } + ret = i40e_fdir_configure(dev); + if (ret < 0) { + rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, "Failed to configure fdir."); + goto err; + } + + dev->data->dev_conf.fdir_conf.mode = RTE_FDIR_MODE_PERFECT; } return 0; +err: + i40e_fdir_teardown(pf); + return -rte_errno; } /* Parse to get the action info of a tunnel filter @@ -4708,6 +4724,13 @@ i40e_flow_destroy(struct rte_eth_dev *dev, case RTE_ETH_FILTER_FDIR: ret = i40e_flow_add_del_fdir_filter(dev, &((struct i40e_fdir_filter *)flow->rule)->fdir, 0); + + /* If the last flow is destroyed, disable fdir. */ + if (!ret && !TAILQ_EMPTY(&pf->fdir.fdir_list)) { + i40e_fdir_teardown(pf); + dev->data->dev_conf.fdir_conf.mode = + RTE_FDIR_MODE_NONE; + } break; case RTE_ETH_FILTER_HASH: ret = i40e_config_rss_filter_del(dev, @@ -4900,6 +4923,8 @@ i40e_flow_flush_fdir_filter(struct i40e_pf *pf) pf->fdir.inset_flag[pctype] = 0; } + i40e_fdir_teardown(pf); + return ret; } diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c index b3f85b563..a73d120e3 100644 --- a/examples/flow_filtering/main.c +++ b/examples/flow_filtering/main.c @@ -131,22 +131,6 @@ init_port(void) DEV_TX_OFFLOAD_SCTP_CKSUM | DEV_TX_OFFLOAD_TCP_TSO, }, - /* - * Initialize fdir_conf of rte_eth_conf. - * Fdir is used in flow filtering for I40e, - * so rte_flow rules involve some fdir - * configurations. In long term it's better - * that drivers don't require any fdir - * configuration for rte_flow, but we need to - * get this workaround so that sample app can - * run on I40e. - */ - .fdir_conf = { - .mode = RTE_FDIR_MODE_PERFECT, - .pballoc = RTE_FDIR_PBALLOC_64K, - .status = RTE_FDIR_REPORT_STATUS, - .drop_queue = 127, - }, }; struct rte_eth_txconf txq_conf; struct rte_eth_rxconf rxq_conf; -- 2.17.1