DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiaoyun Li <xiaoyun.li@intel.com>
To: beilei.xing@intel.com, qi.z.zhang@intel.com
Cc: dev@dpdk.org, zhiyong.yang@intel.com, Xiaoyun Li <xiaoyun.li@intel.com>
Subject: [dpdk-dev] [PATCH v2] net/i40e: add interface to choose latest vector path
Date: Fri, 31 Aug 2018 19:24:48 +0800	[thread overview]
Message-ID: <20180831112448.11680-1-xiaoyun.li@intel.com> (raw)
In-Reply-To: <1535595399-430873-1-git-send-email-xiaoyun.li@intel.com>

Right now, vector path is limited to only use on later platform due
to the frequency penalty. This patch adds a devarg enable-latest-vec
to allow the users to use the latest vector path that the platform
supported. Namely, using AVX2 vector path on broadwell is possible.

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
v2:
 * Correct the calling of the wrong function last time.
 * Fix seg fault bug.
---
 doc/guides/nics/i40e.rst               |  8 ++++++
 doc/guides/rel_notes/release_18_11.rst |  4 +++
 drivers/net/i40e/i40e_ethdev.c         | 38 ++++++++++++++++++++++++++
 drivers/net/i40e/i40e_ethdev.h         |  1 +
 drivers/net/i40e/i40e_rxtx.c           | 27 ++++++++++++++++++
 5 files changed, 78 insertions(+)

diff --git a/doc/guides/nics/i40e.rst b/doc/guides/nics/i40e.rst
index 65d87f869..75605bdce 100644
--- a/doc/guides/nics/i40e.rst
+++ b/doc/guides/nics/i40e.rst
@@ -163,6 +163,14 @@ Runtime Config Options
   Currently hot-plugging of representor ports is not supported so all required
   representors must be specified on the creation of the PF.
 
+- ``Enable latest vector`` (default ``disable``)
+
+  AVX2 vector path cannot be chosen on platforms like HSW/BDW due to throttling
+  penalty. But users may want AVX2 vector path on HSW/BDW because it can get better
+  perf such as in VPP. So ``devargs`` parameter ``enable-latest-vec`` is introduced,
+  for example::
+    -w 84:00.0,enable-latest-vec=1
+
 Driver compilation and testing
 ------------------------------
 
diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst
index 3ae6b3f58..f8b0f3189 100644
--- a/doc/guides/rel_notes/release_18_11.rst
+++ b/doc/guides/rel_notes/release_18_11.rst
@@ -54,6 +54,10 @@ New Features
      Also, make sure to start the actual text at the margin.
      =========================================================
 
+* **Added a devarg to eable the latest vector path.**
+  A new devarg ``enable-latest-vec`` was introduced to allow users to choose
+  the latest vector path that the platform supported. For example, VPP users
+  can use AVX2 vector path on BDW/HSW to get better performance.
 
 API Changes
 -----------
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 85a6a867f..16b5345fb 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -12513,6 +12513,44 @@ i40e_config_rss_filter(struct i40e_pf *pf,
 	return 0;
 }
 
+#define ETH_I40E_ENABLE_LATEST_VEC	"enable-latest-vec"
+
+bool
+i40e_parse_latest_vec(struct rte_eth_dev *dev)
+{
+	static const char *const valid_keys[] = {
+		ETH_I40E_ENABLE_LATEST_VEC, NULL};
+	int enable_latest_vec;
+	struct rte_kvargs *kvlist;
+
+	if (!dev->device->devargs)
+		return 0;
+
+	kvlist = rte_kvargs_parse(dev->device->devargs->args, valid_keys);
+	if (!kvlist)
+		return -EINVAL;
+
+	if (!rte_kvargs_count(kvlist, ETH_I40E_ENABLE_LATEST_VEC))
+		return 0;
+
+	if (rte_kvargs_count(kvlist, ETH_I40E_ENABLE_LATEST_VEC) > 1)
+		PMD_DRV_LOG(WARNING, "More than one argument \"%s\" and only "
+			    "the first one is used !",
+			    ETH_I40E_ENABLE_LATEST_VEC);
+
+	enable_latest_vec = atoi((&kvlist->pairs[0])->value);
+
+	rte_kvargs_free(kvlist);
+
+	if (enable_latest_vec != 0 && enable_latest_vec != 1)
+		PMD_DRV_LOG(WARNING, "Value should be 0 or 1, set it as 1!");
+
+	if (enable_latest_vec)
+		return true;
+	else
+		return false;
+}
+
 RTE_INIT(i40e_init_log)
 {
 	i40e_logtype_init = rte_log_register("pmd.net.i40e.init");
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index 3fffe5a55..cdf68cd93 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -1243,6 +1243,7 @@ int i40e_config_rss_filter(struct i40e_pf *pf,
 		struct i40e_rte_flow_rss_conf *conf, bool add);
 int i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params);
 int i40e_vf_representor_uninit(struct rte_eth_dev *ethdev);
+bool i40e_parse_latest_vec(struct rte_eth_dev *dev);
 
 #define I40E_DEV_TO_PCI(eth_dev) \
 	RTE_DEV_TO_PCI((eth_dev)->device)
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 2a28ee348..75f8ec284 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2960,6 +2960,15 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
 				dev->rx_pkt_burst =
 					i40e_recv_scattered_pkts_vec_avx2;
+			/*
+			 * Give users chance to use the latest vector path
+			 * that the platform supported.
+			 */
+			if (i40e_parse_latest_vec(dev)) {
+				if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+					dev->rx_pkt_burst =
+					i40e_recv_scattered_pkts_vec_avx2;
+			}
 #endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Using a Scattered with bulk "
@@ -2989,6 +2998,15 @@ i40e_set_rx_function(struct rte_eth_dev *dev)
 		 */
 		if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
 			dev->rx_pkt_burst = i40e_recv_pkts_vec_avx2;
+		/*
+		 * Give users chance to use the latest vector path
+		 * that the platform supported.
+		 */
+		if (i40e_parse_latest_vec(dev)) {
+			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+				dev->rx_pkt_burst =
+					i40e_recv_pkts_vec_avx2;
+		}
 #endif
 	} else if (ad->rx_bulk_alloc_allowed) {
 		PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
@@ -3083,6 +3101,15 @@ i40e_set_tx_function(struct rte_eth_dev *dev)
 			 */
 			if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F))
 				dev->tx_pkt_burst = i40e_xmit_pkts_vec_avx2;
+			/*
+			 * Give users chance to use the latest vector path
+			 * that the platform supported.
+			 */
+			if (i40e_parse_latest_vec(dev)) {
+				if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2))
+					dev->tx_pkt_burst =
+					i40e_xmit_pkts_vec_avx2;
+			}
 #endif
 		} else {
 			PMD_INIT_LOG(DEBUG, "Simple tx finally be used.");
-- 
2.17.1

  reply	other threads:[~2018-08-31 11:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30  2:16 [dpdk-dev] [PATCH] " Xiaoyun Li
2018-08-31 11:24 ` Xiaoyun Li [this message]
2018-09-04 11:39 ` [dpdk-dev] [PATCH v3] " Xiaoyun Li
2018-09-05 12:21   ` Zhang, Qi Z
2018-09-07  9:23     ` Li, Xiaoyun
2018-09-10 10:17 ` [dpdk-dev] [PATCH v4] " Xiaoyun Li
2018-09-12  7:45   ` Zhang, Qi Z
2018-09-12  7:50     ` Zhang, Qi Z
2018-09-12 10:12 ` [dpdk-dev] [PATCH v5] " Xiaoyun Li
2018-09-13  1:38   ` Zhang, Qi Z
2018-09-13 13:27   ` Ferruh Yigit
2018-09-17  7:12     ` Li, Xiaoyun
2018-09-17  9:58 ` [dpdk-dev] [PATCH v6] net/i40e: add interface to use latest vec path Xiaoyun Li
2018-09-17 14:14   ` Ferruh Yigit
2018-09-17 14:37     ` Thomas Monjalon
2018-09-18  1:28       ` Li, Xiaoyun
2018-09-18  2:22 ` [dpdk-dev] [PATCH v7] " Xiaoyun Li
2018-09-18 13:01   ` Ferruh Yigit
2018-09-18 13:52     ` Zhang, Qi Z

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=20180831112448.11680-1-xiaoyun.li@intel.com \
    --to=xiaoyun.li@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=qi.z.zhang@intel.com \
    --cc=zhiyong.yang@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).