DPDK patches and discussions
 help / color / mirror / Atom feed
From: Michal Krawczyk <mk@semihalf.com>
To: dev@dpdk.org
Cc: shaibran@amazon.com, upstream@semihalf.com,
	Michal Krawczyk <mk@semihalf.com>,
	Dawid Gorecki <dgr@semihalf.com>
Subject: [PATCH 06/21] net/ena: make LSC configurable
Date: Tue, 22 Feb 2022 17:06:19 +0100	[thread overview]
Message-ID: <20220222160634.24489-7-mk@semihalf.com> (raw)
In-Reply-To: <20220222160634.24489-1-mk@semihalf.com>

ENA uses AENQ for notification about various events, like LSC, keep
alive etc. By default it was enabling all AENQ that were supported by
both the driver and the device. As a result the LSC was always processed
even if the application turned it off explicitly.

As the DPDK provides application with the possibility to configure the
LSC, ENA should respect that. AENQ groups are now being updated upon
configure step, thus LSC can be activated or disabled between ENA PMD
reconfigurations. Moreover, the LSC capability for the device is being
determined dynamically.

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Dawid Gorecki <dgr@semihalf.com>
Reviewed-by: Shai Brandes <shaibran@amazon.com>
---
 doc/guides/rel_notes/release_22_03.rst |  1 +
 drivers/net/ena/ena_ethdev.c           | 66 +++++++++++++++++++-------
 drivers/net/ena/ena_ethdev.h           |  5 +-
 3 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst
index 6b69763f85..f803402138 100644
--- a/doc/guides/rel_notes/release_22_03.rst
+++ b/doc/guides/rel_notes/release_22_03.rst
@@ -111,6 +111,7 @@ New Features
 
   * Added new checksum related xstats: ``l3_csum_bad``, ``l4_csum_bad`` and
     ``l4_csum_good``.
+  * Added support for the link status configuration.
 
 * **Updated Cisco enic driver.**
 
diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index d534b93749..a2793f13cd 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -160,10 +160,9 @@ static const struct rte_pci_id pci_id_ena_map[] = {
 
 static struct ena_aenq_handlers aenq_handlers;
 
-static int ena_device_init(struct ena_com_dev *ena_dev,
+static int ena_device_init(struct ena_adapter *adapter,
 			   struct rte_pci_device *pdev,
-			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
-			   bool *wd_state);
+			   struct ena_com_dev_get_features_ctx *get_feat_ctx);
 static int ena_dev_configure(struct rte_eth_dev *dev);
 static void ena_tx_map_mbuf(struct ena_ring *tx_ring,
 	struct ena_tx_buffer *tx_info,
@@ -249,6 +248,7 @@ static int ena_rx_queue_intr_enable(struct rte_eth_dev *dev,
 				    uint16_t queue_id);
 static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev,
 				     uint16_t queue_id);
+static int ena_configure_aenq(struct ena_adapter *adapter);
 
 static const struct eth_dev_ops ena_dev_ops = {
 	.dev_configure        = ena_dev_configure,
@@ -1416,11 +1416,11 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
 	return i;
 }
 
-static int ena_device_init(struct ena_com_dev *ena_dev,
+static int ena_device_init(struct ena_adapter *adapter,
 			   struct rte_pci_device *pdev,
-			   struct ena_com_dev_get_features_ctx *get_feat_ctx,
-			   bool *wd_state)
+			   struct ena_com_dev_get_features_ctx *get_feat_ctx)
 {
+	struct ena_com_dev *ena_dev = &adapter->ena_dev;
 	uint32_t aenq_groups;
 	int rc;
 	bool readless_supported;
@@ -1485,13 +1485,8 @@ static int ena_device_init(struct ena_com_dev *ena_dev,
 		      BIT(ENA_ADMIN_WARNING);
 
 	aenq_groups &= get_feat_ctx->aenq.supported_groups;
-	rc = ena_com_set_aenq_config(ena_dev, aenq_groups);
-	if (rc) {
-		PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc: %d\n", rc);
-		goto err_admin_init;
-	}
 
-	*wd_state = !!(aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE));
+	adapter->all_aenq_groups = aenq_groups;
 
 	return 0;
 
@@ -1517,7 +1512,7 @@ static void ena_interrupt_handler_rte(void *cb_arg)
 
 static void check_for_missing_keep_alive(struct ena_adapter *adapter)
 {
-	if (!adapter->wd_state)
+	if (!(adapter->active_aenq_groups & BIT(ENA_ADMIN_KEEP_ALIVE)))
 		return;
 
 	if (adapter->keep_alive_timeout == ENA_HW_HINTS_NO_TIMEOUT)
@@ -1798,7 +1793,6 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	int rc;
 	static int adapters_found;
 	bool disable_meta_caching;
-	bool wd_state = false;
 
 	eth_dev->dev_ops = &ena_dev_ops;
 	eth_dev->rx_pkt_burst = &eth_ena_recv_pkts;
@@ -1850,12 +1844,15 @@ static int eth_ena_dev_init(struct rte_eth_dev *eth_dev)
 	}
 
 	/* device specific initialization routine */
-	rc = ena_device_init(ena_dev, pci_dev, &get_feat_ctx, &wd_state);
+	rc = ena_device_init(adapter, pci_dev, &get_feat_ctx);
 	if (rc) {
 		PMD_INIT_LOG(CRIT, "Failed to init ENA device\n");
 		goto err;
 	}
-	adapter->wd_state = wd_state;
+
+	/* Check if device supports LSC */
+	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);
@@ -1999,6 +1996,7 @@ static int eth_ena_dev_uninit(struct rte_eth_dev *eth_dev)
 static int ena_dev_configure(struct rte_eth_dev *dev)
 {
 	struct ena_adapter *adapter = dev->data->dev_private;
+	int rc;
 
 	adapter->state = ENA_ADAPTER_STATE_CONFIG;
 
@@ -2025,7 +2023,9 @@ static int ena_dev_configure(struct rte_eth_dev *dev)
 	 */
 	adapter->tx_cleanup_stall_delay = adapter->missing_tx_completion_to / 2;
 
-	return 0;
+	rc = ena_configure_aenq(adapter);
+
+	return rc;
 }
 
 static void ena_init_rings(struct ena_adapter *adapter,
@@ -3165,6 +3165,38 @@ static int ena_rx_queue_intr_disable(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int ena_configure_aenq(struct ena_adapter *adapter)
+{
+	uint32_t aenq_groups = adapter->all_aenq_groups;
+	int rc;
+
+	/* All_aenq_groups holds all AENQ functions supported by the device and
+	 * the HW, so at first we need to be sure the LSC request is valid.
+	 */
+	if (adapter->edev_data->dev_conf.intr_conf.lsc != 0) {
+		if (!(aenq_groups & BIT(ENA_ADMIN_LINK_CHANGE))) {
+			PMD_DRV_LOG(ERR,
+				"LSC requested, but it's not supported by the AENQ\n");
+			return -EINVAL;
+		}
+	} else {
+		/* If LSC wasn't enabled by the app, let's enable all supported
+		 * AENQ procedures except the LSC.
+		 */
+		aenq_groups &= ~BIT(ENA_ADMIN_LINK_CHANGE);
+	}
+
+	rc = ena_com_set_aenq_config(&adapter->ena_dev, aenq_groups);
+	if (rc != 0) {
+		PMD_DRV_LOG(ERR, "Cannot configure AENQ groups, rc=%d\n", rc);
+		return rc;
+	}
+
+	adapter->active_aenq_groups = aenq_groups;
+
+	return 0;
+}
+
 /*********************************************************************
  *  PMD configuration
  *********************************************************************/
diff --git a/drivers/net/ena/ena_ethdev.h b/drivers/net/ena/ena_ethdev.h
index 42c47c9455..f660b6a7cb 100644
--- a/drivers/net/ena/ena_ethdev.h
+++ b/drivers/net/ena/ena_ethdev.h
@@ -291,9 +291,10 @@ struct ena_adapter {
 	struct ena_stats_dev dev_stats;
 	struct ena_stats_eni eni_stats;
 
-	bool trigger_reset;
+	uint32_t all_aenq_groups;
+	uint32_t active_aenq_groups;
 
-	bool wd_state;
+	bool trigger_reset;
 
 	bool use_large_llq_hdr;
 
-- 
2.25.1


  parent reply	other threads:[~2022-02-22 16:07 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 16:06 [PATCH 00/21] net/ena: v2.6.0 driver update Michal Krawczyk
2022-02-22 16:06 ` [PATCH 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-22 16:06 ` [PATCH 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-22 16:06 ` [PATCH 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-22 16:06 ` [PATCH 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-22 16:06 ` [PATCH 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-22 16:06 ` Michal Krawczyk [this message]
2022-02-22 16:06 ` [PATCH 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 16:06 ` [PATCH 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-22 16:06 ` [PATCH 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-22 16:06 ` [PATCH 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-22 16:06 ` [PATCH 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-22 16:06 ` [PATCH 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-22 16:06 ` [PATCH 13/21] net/ena: expose Tx cleanup function Michal Krawczyk
2022-02-22 16:06 ` [PATCH 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-22 16:06 ` [PATCH 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-22 16:06 ` [PATCH 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-22 16:06 ` [PATCH 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 16:06 ` [PATCH 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-22 16:06 ` [PATCH 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 16:06 ` [PATCH 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-22 16:06 ` [PATCH 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-22 18:11 ` [PATCH v2 00/21] net/ena: v2.6.0 driver update Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 06/21] net/ena: make LSC configurable Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-22 22:24     ` Ferruh Yigit
2022-02-23  0:50       ` Ferruh Yigit
2022-02-22 18:11   ` [PATCH v2 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 13/21] net/ena: expose Tx cleanup function Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-22 18:11   ` [PATCH v2 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-22 22:21   ` [PATCH v2 00/21] net/ena: v2.6.0 driver update Ferruh Yigit
2022-02-23 10:07     ` Michał Krawczyk
2022-02-23 12:19   ` [PATCH v3 " Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 01/21] net/ena: remove linearization function Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 02/21] net/ena: add assertion on Tx info mbuf Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 03/21] net/ena: remove unused enumeration Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 12:19     ` [PATCH v3 04/21] net/ena: remove unused offloads variables Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 17:47         ` Michał Krawczyk
2022-02-23 18:12           ` Ferruh Yigit
2022-02-23 12:19     ` [PATCH v3 05/21] net/ena: add extra Rx checksum related xstats Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 06/21] net/ena: make LSC configurable Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 07/21] net/ena: skip timer if the reset is triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 08/21] net/ena: perform Tx cleanup before sending pkts Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 09/21] net/ena/base: use optimized memcpy version also on Arm Michal Krawczyk
2022-02-23 17:25       ` Ferruh Yigit
2022-02-23 17:40         ` Michał Krawczyk
2022-02-23 12:19     ` [PATCH v3 10/21] net/ena: proxy AQ calls to primary process Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 11/21] net/ena: enable stats get function for MP mode Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 12/21] net/ena/base: make IO memzone unique per port Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 13/21] net/ena: expose Tx cleanup function Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 14/21] net/ena: add API for probing xstat names by ID Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 15/21] net/ena: check if reset was already triggered Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 16/21] net/ena: make Tx completion timeout configurable Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 17/21] net/ena: fix meta-desc DF flag setup Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 18/21] net/ena: extend debug prints for invalid req ID resets Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 19/21] net/ena: don't initialize LLQ when membar isn't exposed Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 20/21] net/ena: don't indicate bad csum for L4 csum error Michal Krawczyk
2022-02-23 12:19     ` [PATCH v3 21/21] net/ena: update version to 2.6.0 Michal Krawczyk
2022-02-23 18:12     ` [PATCH v3 00/21] net/ena: v2.6.0 driver update 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=20220222160634.24489-7-mk@semihalf.com \
    --to=mk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=dgr@semihalf.com \
    --cc=shaibran@amazon.com \
    --cc=upstream@semihalf.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).