DPDK patches and discussions
 help / color / mirror / Atom feed
From: <shaibran@amazon.com>
To: <ferruh.yigit@amd.com>
Cc: <dev@dpdk.org>, Shai Brandes <shaibran@amazon.com>
Subject: [PATCH v4 06/31] net/ena: restructure the llq policy setting process
Date: Tue, 12 Mar 2024 20:06:51 +0200	[thread overview]
Message-ID: <20240312180716.8515-7-shaibran@amazon.com> (raw)
In-Reply-To: <20240312180716.8515-1-shaibran@amazon.com>

From: Shai Brandes <shaibran@amazon.com>

The driver will set the size of the LLQ header size
according to the recommendation from the device.
The user can bypass the recommendation via devargs:
- The existing devarg 'large_llq_hdr' (default 0)
  allows user to enforce large llq header policy.
- The existing devarg 'enable_llq' (default 1)
  allows user to disable llq usage.
- A new devarg 'normal_llq_hdr' (default 0)
  allows user to enforce normal llq header policy.

Signed-off-by: Shai Brandes <shaibran@amazon.com>
Reviewed-by: Amit Bernstein <amitbern@amazon.com>
---
 doc/guides/nics/ena.rst                |  4 ++
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 60 ++++++++++++++++++++++----
 drivers/net/ena/ena_ethdev.h           | 11 ++++-
 4 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/doc/guides/nics/ena.rst b/doc/guides/nics/ena.rst
index b039e75ead..725215b36d 100644
--- a/doc/guides/nics/ena.rst
+++ b/doc/guides/nics/ena.rst
@@ -113,6 +113,10 @@ Runtime Configuration
      effect only if the device also supports large LLQ headers. Otherwise, the
      default value will be used.
 
+   * **normal_llq_hdr** (default 0)
+
+     Enforce normal LLQ policy.
+
    * **miss_txc_to** (default 5)
 
      Number of seconds after which the Tx packet will be considered missing.
diff --git a/doc/guides/rel_notes/release_24_03.rst b/doc/guides/rel_notes/release_24_03.rst
index cbd4669cbb..58d092194e 100644
--- a/doc/guides/rel_notes/release_24_03.rst
+++ b/doc/guides/rel_notes/release_24_03.rst
@@ -108,6 +108,7 @@ New Features
   * Removed the reporting of `rx_overruns` errors from xstats and instead updated `imissed` stat with its value.
   * Added support for sub-optimal configuration notifications from the device.
   * Restructured fast release of mbufs when RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE optimization is enabled.
+  * Added `normal_llq_hdr` devarg that enforce normal llq header policy.
 
 * **Updated Atomic Rules' Arkville driver.**
 
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index 537ee9f8c3..e23edd4bd2 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -40,6 +40,8 @@
 
 #define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
 
+#define DECIMAL_BASE 10
+
 /*
  * We should try to keep ENA_CLEANUP_BUF_SIZE lower than
  * RTE_MEMPOOL_CACHE_MAX_SIZE, so we can fit this in mempool local cache.
@@ -75,6 +77,7 @@ struct ena_stats {
 
 /* Device arguments */
 #define ENA_DEVARG_LARGE_LLQ_HDR "large_llq_hdr"
+#define ENA_DEVARG_NORMAL_LLQ_HDR "normal_llq_hdr"
 /* Timeout in seconds after which a single uncompleted Tx packet should be
  * considered as a missing.
  */
@@ -297,6 +300,8 @@ static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev,
 static int ena_configure_aenq(struct ena_adapter *adapter);
 static int ena_mp_primary_handle(const struct rte_mp_msg *mp_msg,
 				 const void *peer);
+static ena_llq_policy ena_define_llq_hdr_policy(struct ena_adapter *adapter);
+static bool ena_use_large_llq_hdr(struct ena_adapter *adapter, uint8_t recommended_entry_size);
 
 static const struct eth_dev_ops ena_dev_ops = {
 	.dev_configure          = ena_dev_configure,
@@ -1135,6 +1140,7 @@ ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *ctx,
 	ctx->max_tx_queue_size = max_tx_queue_size;
 	ctx->max_rx_queue_size = max_rx_queue_size;
 
+	PMD_DRV_LOG(INFO, "tx queue size %u\n", max_tx_queue_size);
 	return 0;
 }
 
@@ -2034,7 +2040,7 @@ ena_set_queues_placement_policy(struct ena_adapter *adapter,
 	int rc;
 	u32 llq_feature_mask;
 
-	if (!adapter->enable_llq) {
+	if (adapter->llq_header_policy == ENA_LLQ_POLICY_DISABLED) {
 		PMD_DRV_LOG(WARNING,
 			"NOTE: LLQ has been disabled as per user's request. "
 			"This may lead to a huge performance degradation!\n");
@@ -2241,12 +2247,16 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	adapter->missing_tx_completion_to = ENA_TX_TIMEOUT;
 	adapter->enable_llq = true;
 	adapter->use_large_llq_hdr = false;
+	adapter->use_normal_llq_hdr = false;
 
+	/* Get user bypass */
 	rc = ena_parse_devargs(adapter, pci_dev->device.devargs);
 	if (rc != 0) {
 		PMD_INIT_LOG(CRIT, "Failed to parse devargs\n");
 		goto err;
 	}
+	adapter->llq_header_policy = ena_define_llq_hdr_policy(adapter);
+
 	rc = ena_com_allocate_customer_metrics_buffer(ena_dev);
 	if (rc != 0) {
 		PMD_INIT_LOG(CRIT, "Failed to allocate customer metrics buffer\n");
@@ -2264,8 +2274,9 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	if (!(adapter->all_aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE)))
 		adapter->edev_data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
 
-	set_default_llq_configurations(&llq_config, &get_feat_ctx.llq,
-		adapter->use_large_llq_hdr);
+	bool use_large_llq_hdr = ena_use_large_llq_hdr(adapter,
+						       get_feat_ctx.llq.entry_size_recommended);
+	set_default_llq_configurations(&llq_config, &get_feat_ctx.llq, use_large_llq_hdr);
 	rc = ena_set_queues_placement_policy(adapter, ena_dev,
 					     &get_feat_ctx.llq, &llq_config);
 	if (unlikely(rc)) {
@@ -2273,18 +2284,19 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 		return rc;
 	}
 
-	if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_HOST)
+	if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_HOST) {
 		queue_type_str = "Regular";
-	else
+	} else {
 		queue_type_str = "Low latency";
+		PMD_DRV_LOG(INFO, "LLQ entry size %uB\n", llq_config.llq_ring_entry_size_value);
+	}
 	PMD_DRV_LOG(INFO, "Placement policy: %s\n", queue_type_str);
 
 	calc_queue_ctx.ena_dev = ena_dev;
 	calc_queue_ctx.get_feat_ctx = &get_feat_ctx;
 
 	max_num_io_queues = ena_calc_max_io_queue_num(ena_dev, &get_feat_ctx);
-	rc = ena_calc_io_queue_size(&calc_queue_ctx,
-		adapter->use_large_llq_hdr);
+	rc = ena_calc_io_queue_size(&calc_queue_ctx, use_large_llq_hdr);
 	if (unlikely((rc != 0) || (max_num_io_queues == 0))) {
 		rc = -EFAULT;
 		goto err_device_destroy;
@@ -3632,7 +3644,7 @@ static int ena_process_uint_devarg(const char *key,
 	char *str_end;
 	uint64_t uint_value;
 
-	uint_value = strtoull(value, &str_end, 10);
+	uint_value = strtoull(value, &str_end, DECIMAL_BASE);
 	if (value == str_end) {
 		PMD_INIT_LOG(ERR,
 			"Invalid value for key '%s'. Only uint values are accepted.\n",
@@ -3685,6 +3697,8 @@ static int ena_process_bool_devarg(const char *key,
 	/* Now, assign it to the proper adapter field. */
 	if (strcmp(key, ENA_DEVARG_LARGE_LLQ_HDR) == 0)
 		adapter->use_large_llq_hdr = bool_value;
+	else if (strcmp(key, ENA_DEVARG_NORMAL_LLQ_HDR) == 0)
+		adapter->use_normal_llq_hdr = bool_value;
 	else if (strcmp(key, ENA_DEVARG_ENABLE_LLQ) == 0)
 		adapter->enable_llq = bool_value;
 
@@ -3696,6 +3710,7 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 {
 	static const char * const allowed_args[] = {
 		ENA_DEVARG_LARGE_LLQ_HDR,
+		ENA_DEVARG_NORMAL_LLQ_HDR,
 		ENA_DEVARG_MISS_TXC_TO,
 		ENA_DEVARG_ENABLE_LLQ,
 		NULL,
@@ -3717,6 +3732,10 @@ static int ena_parse_devargs(struct ena_adapter *adapter,
 		ena_process_bool_devarg, adapter);
 	if (rc != 0)
 		goto exit;
+	rc = rte_kvargs_process(kvlist, ENA_DEVARG_NORMAL_LLQ_HDR,
+		ena_process_bool_devarg, adapter);
+	if (rc != 0)
+		goto exit;
 	rc = rte_kvargs_process(kvlist, ENA_DEVARG_MISS_TXC_TO,
 		ena_process_uint_devarg, adapter);
 	if (rc != 0)
@@ -3943,6 +3962,7 @@ RTE_PMD_REGISTER_PCI_TABLE(net_ena, pci_id_ena_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_ena, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_PMD_REGISTER_PARAM_STRING(net_ena,
 	ENA_DEVARG_LARGE_LLQ_HDR "=<0|1> "
+	ENA_DEVARG_NORMAL_LLQ_HDR "=<0|1> "
 	ENA_DEVARG_ENABLE_LLQ "=<0|1> "
 	ENA_DEVARG_MISS_TXC_TO "=<uint>");
 RTE_LOG_REGISTER_SUFFIX(ena_logtype_init, init, NOTICE);
@@ -4129,3 +4149,27 @@ ena_mp_primary_handle(const struct rte_mp_msg *mp_msg, const void *peer)
 	/* Return just IPC processing status */
 	return rte_mp_reply(&mp_rsp, peer);
 }
+
+static ena_llq_policy ena_define_llq_hdr_policy(struct ena_adapter *adapter)
+{
+	if (!adapter->enable_llq)
+		return ENA_LLQ_POLICY_DISABLED;
+	if (adapter->use_large_llq_hdr)
+		return ENA_LLQ_POLICY_LARGE;
+	if (adapter->use_normal_llq_hdr)
+		return ENA_LLQ_POLICY_NORMAL;
+	return ENA_LLQ_POLICY_RECOMMENDED;
+}
+
+static bool ena_use_large_llq_hdr(struct ena_adapter *adapter, uint8_t recommended_entry_size)
+{
+	if (adapter->llq_header_policy == ENA_LLQ_POLICY_LARGE) {
+		return true;
+	} else if (adapter->llq_header_policy == ENA_LLQ_POLICY_RECOMMENDED) {
+		PMD_DRV_LOG(INFO, "Recommended device entry size policy %u\n",
+			recommended_entry_size);
+		if (recommended_entry_size == ENA_ADMIN_LIST_ENTRY_SIZE_256B)
+			return true;
+	}
+	return false;
+}
diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h
index 20b8307836..7358f28caf 100644
--- a/drivers/net/ena/ena_ethdev.h
+++ b/drivers/net/ena/ena_ethdev.h
@@ -85,6 +85,14 @@ enum ena_ring_type {
 	ENA_RING_TYPE_TX = 2,
 };
 
+typedef enum ena_llq_policy_t {
+	ENA_LLQ_POLICY_DISABLED    = 0, /* Host queues */
+	ENA_LLQ_POLICY_RECOMMENDED = 1, /* Device recommendation */
+	ENA_LLQ_POLICY_NORMAL      = 2, /* 128B long LLQ entry */
+	ENA_LLQ_POLICY_LARGE       = 3, /* 256B long LLQ entry */
+	ENA_LLQ_POLICY_LAST,
+} ena_llq_policy;
+
 struct ena_tx_buffer {
 	struct rte_mbuf *mbuf;
 	unsigned int tx_descs;
@@ -328,9 +336,10 @@ struct ena_adapter {
 	uint32_t active_aenq_groups;
 
 	bool trigger_reset;
-
 	bool enable_llq;
 	bool use_large_llq_hdr;
+	bool use_normal_llq_hdr;
+	ena_llq_policy llq_header_policy;
 
 	uint32_t last_tx_comp_qid;
 	uint64_t missing_tx_completion_to;
-- 
2.17.1


  parent reply	other threads:[~2024-03-12 18:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 18:06 [PATCH v4 00/31] net/ena: v2.9.0 driver release shaibran
2024-03-12 18:06 ` [PATCH v4 01/31] net/ena: rework the metrics multi-process functions shaibran
2024-03-12 18:06 ` [PATCH v4 02/31] net/ena: report new supported link speed capabilities shaibran
2024-03-12 18:06 ` [PATCH v4 03/31] net/ena: update imissed stat with Rx overruns shaibran
2024-03-13 15:59   ` Ferruh Yigit
2024-03-12 18:06 ` [PATCH v4 04/31] net/ena: sub-optimal configuration notifications support shaibran
2024-03-12 18:06 ` [PATCH v4 05/31] net/ena: fix fast mbuf free shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:06 ` shaibran [this message]
2024-03-12 18:06 ` [PATCH v4 07/31] net/ena/base: limit exponential backoff exp shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:06 ` [PATCH v4 08/31] net/ena/base: add a new csum offload bit shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:06 ` [PATCH v4 09/31] net/ena/base: optimize Rx ring submission queue shaibran
2024-03-12 18:06 ` [PATCH v4 10/31] net/ena/base: rename fields in completion descriptors shaibran
2024-03-12 18:06 ` [PATCH v4 11/31] net/ena/base: use correct read once on u8 field shaibran
2024-03-12 18:06 ` [PATCH v4 12/31] net/ena/base: add completion descriptor corruption check shaibran
2024-03-12 18:06 ` [PATCH v4 13/31] net/ena/base: malformed Tx descriptor error reason shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:06 ` [PATCH v4 14/31] net/ena/base: phc feature modifications shaibran
2024-03-12 18:07 ` [PATCH v4 15/31] net/ena/base: restructure interrupt handling shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:07 ` [PATCH v4 16/31] net/ena/base: add unlikely to error checks shaibran
2024-03-12 18:07 ` [PATCH v4 17/31] net/ena/base: missing admin interrupt reset reason shaibran
2024-03-12 18:07 ` [PATCH v4 18/31] net/ena/base: check for existing keep alive notification shaibran
2024-03-12 18:07 ` [PATCH v4 19/31] net/ena/base: modify memory barrier comment shaibran
2024-03-12 18:07 ` [PATCH v4 20/31] net/ena/base: rework Rx ring submission queue shaibran
2024-03-12 18:07 ` [PATCH v4 21/31] net/ena/base: remove operating system type enum shaibran
2024-03-12 18:07 ` [PATCH v4 22/31] net/ena/base: handle command abort shaibran
2024-03-12 18:07 ` [PATCH v4 23/31] net/ena/base: add support for device reset request shaibran
2024-03-12 18:07 ` [PATCH v4 24/31] net/ena: cosmetic changes shaibran
2024-03-13 15:58   ` Ferruh Yigit
2024-03-12 18:07 ` [PATCH v4 25/31] net/ena/base: modify customer metrics memory management shaibran
2024-03-12 18:07 ` [PATCH v4 26/31] net/ena/base: modify logs to use unsigned format specifier shaibran
2024-03-12 18:07 ` [PATCH v4 27/31] net/ena: update device-preferred size of rings shaibran
2024-03-12 18:07 ` [PATCH v4 28/31] net/ena: exhaust interrupt callbacks in device close shaibran
2024-03-12 18:07 ` [PATCH v4 29/31] net/ena: support max large llq depth from the device shaibran
2024-03-12 18:07 ` [PATCH v4 30/31] net/ena: control path pure polling mode shaibran
2024-03-12 18:07 ` [PATCH v4 31/31] net/ena: upgrade driver version to 2.9.0 shaibran
2024-03-13 16:00 ` [PATCH v4 00/31] net/ena: v2.9.0 driver release Ferruh Yigit
2024-03-13 17:07   ` Brandes, Shai

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=20240312180716.8515-7-shaibran@amazon.com \
    --to=shaibran@amazon.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.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).