git: 2d4d2ed3fef6 - main - ena: Reinit RSS table on device restore when queue count shrinks

From: Arthur Kiyanovski <akiyano_at_FreeBSD.org>
Date: Thu, 29 Oct 2026 03:29:37 UTC
The branch main has been updated by akiyano:

URL: https://cgit.FreeBSD.org/src/commit/?id=2d4d2ed3fef6acda9269f545f6703d6f32f2f0b7

commit 2d4d2ed3fef6acda9269f545f6703d6f32f2f0b7
Author:     Gilad Ben Yakov <giladben@amazon.com>
AuthorDate: 2026-05-05 10:02:13 +0000
Commit:     Arthur Kiyanovski <akiyano@FreeBSD.org>
CommitDate: 2026-10-29 03:25:50 +0000

    ena: Reinit RSS table on device restore when queue count shrinks
    
    When ena_restore_device() is called after a reset, pci_alloc_msix()
    may return fewer MSI-X vectors than requested, causing num_io_queues
    to shrink. When this happens, the RSS indirection table retains
    entries referencing queues that no longer exist, routing packets to
    non-existent queues and causing connectivity loss.
    
    Extract ena_set_io_queue_count() to pair the queue count update with
    ena_com_rss_destroy(), ensuring the RSS table is always invalidated
    when the queue count changes. Use it from both ena_update_io_rings()
    and ena_restore_device().
    
    Reviewed by: cperciva
    Fixes: e2735b095b7e ("Fix assumptions about number of IO queues in the ENA")
    MFC after: 3 days
    Sponsored by: Amazon, Inc.
---
 sys/dev/ena/ena.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c
index 211e33b8a4ce..b16e8ff324be 100644
--- a/sys/dev/ena/ena.c
+++ b/sys/dev/ena/ena.c
@@ -1299,13 +1299,18 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size,
 }
 
 static void
-ena_update_io_rings(struct ena_adapter *adapter, uint32_t num)
+ena_set_io_queue_count(struct ena_adapter *adapter, uint32_t num)
 {
-	ena_free_all_io_rings_resources(adapter);
+	adapter->num_io_queues = num;
 	/* Force indirection table to be reinitialized */
 	ena_com_rss_destroy(adapter->ena_dev);
+}
 
-	adapter->num_io_queues = num;
+static void
+ena_update_io_rings(struct ena_adapter *adapter, uint32_t num)
+{
+	ena_free_all_io_rings_resources(adapter);
+	ena_set_io_queue_count(adapter, num);
 	ena_init_io_rings(adapter);
 }
 
@@ -3680,7 +3685,8 @@ ena_restore_device(struct ena_adapter *adapter)
 	 * are available.
 	 */
 	if ((adapter->msix_vecs - ENA_ADMIN_MSIX_VEC) < adapter->num_io_queues)
-		adapter->num_io_queues = adapter->msix_vecs - ENA_ADMIN_MSIX_VEC;
+		ena_set_io_queue_count(adapter,
+		    adapter->msix_vecs - ENA_ADMIN_MSIX_VEC);
 
 	/* Re-initialize rings basic information */
 	ena_init_io_rings(adapter);