DPDK patches and discussions
 help / color / mirror / Atom feed
From: Remy Horton <remy.horton@intel.com>
To: dev@dpdk.org
Cc: John McNamara <john.mcnamara@intel.com>,
	Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Qi Zhang <qi.z.zhang@intel.com>,
	Beilei Xing <beilei.xing@intel.com>,
	Shreyansh Jain <shreyansh.jain@nxp.com>,
	Thomas Monjalon <thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH v3 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters
Date: Wed,  4 Apr 2018 18:17:37 +0100	[thread overview]
Message-ID: <20180404171740.5084-2-remy.horton@intel.com> (raw)
In-Reply-To: <20180404171740.5084-1-remy.horton@intel.com>

The optimal values of several transmission & reception related
parameters, such as burst sizes, descriptor ring sizes, and number
of queues, varies between different network interface devices. This
patch allows individual PMDs to specify preferred parameter values.

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 doc/guides/rel_notes/deprecation.rst   | 13 ----------
 doc/guides/rel_notes/release_18_05.rst |  5 ++++
 lib/librte_ether/rte_ethdev.c          | 44 +++++++++++++++++++++++++++-------
 lib/librte_ether/rte_ethdev.h          | 25 +++++++++++++++++++
 4 files changed, 65 insertions(+), 22 deletions(-)

diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst
index 0c696f7..920df6b 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -115,19 +115,6 @@ Deprecation Notices
   The new API add rss_level field to ``rte_eth_rss_conf`` to enable a choice
   of RSS hash calculation on outer or inner header of tunneled packet.
 
-* ethdev:  Currently, if the  rte_eth_rx_burst() function returns a value less
-  than *nb_pkts*, the application will assume that no more packets are present.
-  Some of the hw queue based hardware can only support smaller burst for RX
-  and TX and thus break the expectation of the rx_burst API. Similar is the
-  case for TX burst as well as ring sizes. ``rte_eth_dev_info`` will be added
-  with following new parameters so as to support semantics for drivers to
-  define a preferred size for Rx/Tx burst and rings.
-
-  - Member ``struct preferred_size`` would be added to enclose all preferred
-    size to be fetched from driver/implementation.
-  - Members ``uint16_t rx_burst``,  ``uint16_t tx_burst``, ``uint16_t rx_ring``,
-    and ``uint16_t tx_ring`` would be added to ``struct preferred_size``.
-
 * ethdev: A work is being planned for 18.05 to expose VF port representors
   as a mean to perform control and data path operation on the different VFs.
   As VF representor is an ethdev port, new fields are needed in order to map
diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst
index 9cc77f8..129e874 100644
--- a/doc/guides/rel_notes/release_18_05.rst
+++ b/doc/guides/rel_notes/release_18_05.rst
@@ -58,6 +58,11 @@ New Features
   * Added support for NVGRE, VXLAN and GENEVE filters in flow API.
   * Added support for DROP action in flow API.
 
+* **Added PMD-recommended Tx and Rx parameters**
+
+  Applications can now query drivers for device-tuned values of
+  ring sizes, burst sizes, and number of queues.
+
 
 API Changes
 -----------
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 2c74f7e..209796d 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1061,6 +1061,26 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
 
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
+	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
+
+	/* If number of queues specified by application for both Rx and Tx is
+	 * zero, use driver preferred values. This cannot be done individually
+	 * as it is valid for either Tx or Rx (but not both) to be zero.
+	 * If driver does not provide any preferred valued, fall back on
+	 * EAL defaults.
+	 */
+	if (nb_rx_q == 0 && nb_tx_q == 0) {
+		nb_rx_q = dev_info.default_rxportconf.nb_queues;
+		if (nb_rx_q == 0)
+			nb_rx_q = RTE_ETH_DEV_FALLBACK_RX_NBQUEUES;
+		nb_tx_q = dev_info.default_txportconf.nb_queues;
+		if (nb_tx_q == 0)
+			nb_tx_q = RTE_ETH_DEV_FALLBACK_TX_NBQUEUES;
+	}
+
 	if (nb_rx_q > RTE_MAX_QUEUES_PER_PORT) {
 		RTE_PMD_DEBUG_TRACE(
 			"Number of RX queues requested (%u) is greater than max supported(%d)\n",
@@ -1075,8 +1095,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		return -EINVAL;
 	}
 
-	dev = &rte_eth_devices[port_id];
-
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_infos_get, -ENOTSUP);
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
 
@@ -1106,13 +1124,6 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * than the maximum number of RX and TX queues supported by the
 	 * configured device.
 	 */
-	(*dev->dev_ops->dev_infos_get)(dev, &dev_info);
-
-	if (nb_rx_q == 0 && nb_tx_q == 0) {
-		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d both rx and tx queue cannot be 0\n", port_id);
-		return -EINVAL;
-	}
-
 	if (nb_rx_q > dev_info.max_rx_queues) {
 		RTE_PMD_DEBUG_TRACE("ethdev port_id=%d nb_rx_queues=%d > %d\n",
 				port_id, nb_rx_q, dev_info.max_rx_queues);
@@ -1477,6 +1488,14 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id,
 		return -EINVAL;
 	}
 
+	/* Use default specified by driver, if nb_rx_desc is zero */
+	if (nb_rx_desc == 0) {
+		nb_rx_desc = dev_info.default_rxportconf.ring_size;
+		/* If driver default is also zero, fall back on EAL default */
+		if (nb_rx_desc == 0)
+			nb_rx_desc = RTE_ETH_DEV_FALLBACK_RX_RINGSIZE;
+	}
+
 	if (nb_rx_desc > dev_info.rx_desc_lim.nb_max ||
 			nb_rx_desc < dev_info.rx_desc_lim.nb_min ||
 			nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) {
@@ -1600,6 +1619,13 @@ rte_eth_tx_queue_setup(uint16_t port_id, uint16_t tx_queue_id,
 
 	rte_eth_dev_info_get(port_id, &dev_info);
 
+	/* Use default specified by driver, if nb_tx_desc is zero */
+	if (nb_tx_desc == 0) {
+		nb_tx_desc = dev_info.default_txportconf.ring_size;
+		/* If driver default is zero, fall back on EAL default */
+		if (nb_tx_desc == 0)
+			nb_tx_desc = RTE_ETH_DEV_FALLBACK_TX_RINGSIZE;
+	}
 	if (nb_tx_desc > dev_info.tx_desc_lim.nb_max ||
 	    nb_tx_desc < dev_info.tx_desc_lim.nb_min ||
 	    nb_tx_desc % dev_info.tx_desc_lim.nb_align != 0) {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 5e13dca..685145f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -988,6 +988,27 @@ struct rte_eth_conf {
 
 struct rte_pci_device;
 
+/*
+ * Fallback default preferred Rx/Tx port parameters.
+ * These are used if an application requests default parameters
+ * but the PMD does not provide preferred values.
+ */
+#define RTE_ETH_DEV_FALLBACK_RX_RINGSIZE 512
+#define RTE_ETH_DEV_FALLBACK_TX_RINGSIZE 512
+#define RTE_ETH_DEV_FALLBACK_RX_NBQUEUES 1
+#define RTE_ETH_DEV_FALLBACK_TX_NBQUEUES 1
+
+/**
+ * Preferred Rx/Tx port parameters.
+ * There are separate instances of this structure for transmission
+ * and reception respectively.
+ */
+struct rte_eth_dev_portconf {
+	uint16_t burst_size; /**< Device-preferred burst size */
+	uint16_t ring_size; /**< Device-preferred size of queue rings */
+	uint16_t nb_queues; /**< Device-preferred number of queues */
+};
+
 /**
  * Ethernet device information
  */
@@ -1029,6 +1050,10 @@ struct rte_eth_dev_info {
 	/** Configured number of rx/tx queues */
 	uint16_t nb_rx_queues; /**< Number of RX queues. */
 	uint16_t nb_tx_queues; /**< Number of TX queues. */
+	/** Rx parameter recommendations */
+	struct rte_eth_dev_portconf default_rxportconf;
+	/** Tx parameter recommendations */
+	struct rte_eth_dev_portconf default_txportconf;
 };
 
 /**
-- 
2.9.5

  reply	other threads:[~2018-04-04 17:17 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 12:08 [dpdk-dev] [RFC PATCH v1 0/4] ethdev: add per-PMD tuning of RxTx parmeters Remy Horton
2018-03-07 12:08 ` [dpdk-dev] [RFC PATCH v1 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters Remy Horton
2018-03-14 12:28   ` Shreyansh Jain
2018-03-14 14:09     ` Remy Horton
2018-03-14 14:43   ` Ferruh Yigit
2018-03-14 15:10     ` Shreyansh Jain
2018-03-15  9:02       ` Remy Horton
2018-03-14 15:48     ` Remy Horton
2018-03-14 16:42       ` Ferruh Yigit
2018-03-14 17:23         ` Shreyansh Jain
2018-03-14 17:52           ` Ferruh Yigit
2018-03-14 18:53             ` Ananyev, Konstantin
2018-03-14 21:02               ` Ferruh Yigit
2018-03-14 21:36                 ` Bruce Richardson
2018-03-15 13:57                   ` Ferruh Yigit
2018-03-15 14:39                     ` Bruce Richardson
2018-03-15 14:57                       ` Ferruh Yigit
2018-03-16 13:54                         ` Shreyansh Jain
2018-03-16 14:18                           ` Bruce Richardson
2018-03-16 15:36                           ` Remy Horton
2018-03-20 15:03                             ` Ferruh Yigit
2018-03-21 10:14                               ` Remy Horton
2018-03-21 13:56                                 ` Ferruh Yigit
2018-03-20 14:54                           ` Ferruh Yigit
2018-03-21  6:51                             ` Shreyansh Jain
2018-03-21 10:02                               ` Ferruh Yigit
2018-03-21 10:45                                 ` Shreyansh Jain
2018-03-15 12:51                 ` Ananyev, Konstantin
2018-03-15 13:57                   ` Ferruh Yigit
2018-03-15 14:42                     ` Bruce Richardson
2018-03-07 12:08 ` [dpdk-dev] [RFC PATCH v1 2/4] net/e1000: add TxRx tuning parameters Remy Horton
2018-03-07 12:08 ` [dpdk-dev] [RFC PATCH v1 3/4] net/i40e: " Remy Horton
2018-03-07 12:08 ` [dpdk-dev] [RFC PATCH v1 4/4] testpmd: make use of per-PMD TxRx parameters Remy Horton
2018-03-21 14:27 ` [dpdk-dev] [PATCH v2 0/4] ethdev: add per-PMD tuning of RxTx parmeters Remy Horton
2018-03-21 14:27   ` [dpdk-dev] [PATCH v2 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters Remy Horton
2018-03-28  7:11     ` Shreyansh Jain
2018-03-30 15:40     ` Thomas Monjalon
2018-03-30 15:57       ` Thomas Monjalon
2018-03-31  0:46     ` Thomas Monjalon
2018-03-21 14:27   ` [dpdk-dev] [PATCH v2 2/4] net/e1000: add TxRx tuning parameters Remy Horton
2018-03-21 14:27   ` [dpdk-dev] [PATCH v2 3/4] net/i40e: " Remy Horton
2018-03-21 14:27   ` [dpdk-dev] [PATCH v2 4/4] testpmd: make use of per-PMD TxRx parameters Remy Horton
2018-03-28  7:18     ` Shreyansh Jain
2018-04-03 11:00       ` Remy Horton
2018-03-31  0:01     ` Thomas Monjalon
2018-04-03  8:49       ` Remy Horton
2018-03-27 18:43   ` [dpdk-dev] [PATCH v2 0/4] ethdev: add per-PMD tuning of RxTx parmeters Ferruh Yigit
2018-03-30 10:34     ` Ferruh Yigit
2018-03-31  0:05       ` Thomas Monjalon
2018-04-04 17:17   ` [dpdk-dev] [PATCH v3 " Remy Horton
2018-04-04 17:17     ` Remy Horton [this message]
2018-04-04 18:56       ` [dpdk-dev] [PATCH v3 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters De Lara Guarch, Pablo
2018-04-05 10:16         ` Thomas Monjalon
2018-04-04 17:17     ` [dpdk-dev] [PATCH v3 2/4] net/e1000: add TxRx tuning parameters Remy Horton
2018-04-04 17:17     ` [dpdk-dev] [PATCH v3 3/4] net/i40e: " Remy Horton
2018-04-04 17:17     ` [dpdk-dev] [PATCH v3 4/4] testpmd: make use of per-PMD TxRx parameters Remy Horton
2018-04-06 14:49     ` [dpdk-dev] [PATCH v5 0/4] ethdev: add per-PMD tuning of RxTx parmeters Remy Horton
2018-04-06 14:49       ` [dpdk-dev] [PATCH v5 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters Remy Horton
2018-04-06 14:50       ` [dpdk-dev] [PATCH v5 2/4] net/e1000: add TxRx tuning parameters Remy Horton
2018-04-06 14:50       ` [dpdk-dev] [PATCH v5 3/4] net/i40e: " Remy Horton
2018-04-06 14:50       ` [dpdk-dev] [PATCH v5 4/4] testpmd: make use of per-PMD TxRx parameters Remy Horton
2018-04-09 12:55         ` Shreyansh Jain
2018-04-09 14:38           ` Remy Horton
2018-04-10  4:18             ` Shreyansh Jain
2018-04-10  6:09               ` Remy Horton
2018-04-10  6:39                 ` Shreyansh Jain
2018-04-06 17:01       ` [dpdk-dev] [PATCH v5 0/4] ethdev: add per-PMD tuning of RxTx parmeters Ferruh Yigit
2018-04-10  9:43       ` [dpdk-dev] [PATCH v6 " Remy Horton
2018-04-10  9:43         ` [dpdk-dev] [PATCH v6 1/4] ethdev: add support for PMD-tuned Tx/Rx parameters Remy Horton
2018-04-10  9:43         ` [dpdk-dev] [PATCH v6 2/4] net/e1000: add TxRx tuning parameters Remy Horton
2018-04-10  9:43         ` [dpdk-dev] [PATCH v6 3/4] net/i40e: " Remy Horton
2018-04-10  9:43         ` [dpdk-dev] [PATCH v6 4/4] testpmd: make use of per-PMD TxRx parameters Remy Horton
2018-04-10 12:57         ` [dpdk-dev] [PATCH v6 0/4] ethdev: add per-PMD tuning of RxTx parmeters Thomas Monjalon
2018-04-10 18:56         ` Ferruh Yigit

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=20180404171740.5084-2-remy.horton@intel.com \
    --to=remy.horton@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=john.mcnamara@intel.com \
    --cc=qi.z.zhang@intel.com \
    --cc=shreyansh.jain@nxp.com \
    --cc=thomas@monjalon.net \
    --cc=wenzhuo.lu@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).