Allow partial MSI-x allocation in ENA driver

The situation, where part of the MSI-x was not configured properly, was
not properly handled. Now, the driver reduces number of queues to
reflect number of existing and properly configured MSI-x vectors.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Reviewed by: byenduri_gmail.com
Obtained from: Semihalf
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D12863
This commit is contained in:
mw 2017-11-09 12:03:06 +00:00
parent b71b2254ba
commit 19a406342b
2 changed files with 11 additions and 2 deletions

View File

@ -1796,7 +1796,8 @@ static int
ena_enable_msix(struct ena_adapter *adapter)
{
device_t dev = adapter->pdev;
int i, msix_vecs, rc = 0;
int msix_vecs, msix_req;
int i, rc = 0;
/* Reserved the max msix vectors we might need */
msix_vecs = ENA_MAX_MSIX_VEC(adapter->num_queues);
@ -1813,6 +1814,7 @@ ena_enable_msix(struct ena_adapter *adapter)
adapter->msix_entries[i].vector = i + 1;
}
msix_req = msix_vecs;
rc = pci_alloc_msix(dev, &msix_vecs);
if (unlikely(rc != 0)) {
device_printf(dev,
@ -1822,6 +1824,12 @@ ena_enable_msix(struct ena_adapter *adapter)
goto err_msix_free;
}
if (msix_vecs != msix_req) {
device_printf(dev, "Enable only %d MSI-x (out of %d), reduce "
"the number of queues\n", msix_vecs, msix_req);
adapter->num_queues = msix_vecs - ENA_ADMIN_MSIX_VEC;
}
adapter->msix_vecs = msix_vecs;
adapter->msix_enabled = true;

View File

@ -58,7 +58,8 @@
#define ENA_DMA_BIT_MASK(x) ((1ULL << (x)) - 1ULL)
/* 1 for AENQ + ADMIN */
#define ENA_MAX_MSIX_VEC(io_queues) (1 + (io_queues))
#define ENA_ADMIN_MSIX_VEC 1
#define ENA_MAX_MSIX_VEC(io_queues) (ENA_ADMIN_MSIX_VEC + (io_queues))
#define ENA_REG_BAR 0
#define ENA_MEM_BAR 2