Merge branch 'ena-link-irqs-queues-and-napi-instances'

Joe Damato says:

====================
ena: Link IRQs, queues, and NAPI instances

This series uses the netdev-genl API to link IRQs and queues to NAPI IDs
so that this information is queryable by user apps. This is particularly
useful for epoll-based busy polling apps which rely on having access to
the NAPI ID.

I've tested these commits on an EC2 instance with an ENA NIC configured
and have included test output in the commit messages for each patch
showing how to query the information.

I noted in the implementation that the driver requests an IRQ for
management purposes which does not have an associated NAPI. I tried
to take this into account in patch 1, but would appreciate if ENA
maintainers can verify I did this correctly.

v1: https://lore.kernel.org/all/20240930195617.37369-1-jdamato@fastly.com/
====================

Link: https://patch.msgid.link/20241002001331.65444-1-jdamato@fastly.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2024-10-03 16:13:49 -07:00
commit 35d8471e24

View File

@ -1677,9 +1677,9 @@ static int ena_request_mgmnt_irq(struct ena_adapter *adapter)
static int ena_request_io_irq(struct ena_adapter *adapter)
{
u32 io_queue_count = adapter->num_io_queues + adapter->xdp_num_queues;
int rc = 0, i, k, irq_idx;
unsigned long flags = 0;
struct ena_irq *irq;
int rc = 0, i, k;
if (!test_bit(ENA_FLAG_MSIX_ENABLED, &adapter->flags)) {
netif_err(adapter, ifup, adapter->netdev,
@ -1705,6 +1705,16 @@ static int ena_request_io_irq(struct ena_adapter *adapter)
irq_set_affinity_hint(irq->vector, &irq->affinity_hint_mask);
}
/* Now that IO IRQs have been successfully allocated map them to the
* corresponding IO NAPI instance. Note that the mgmnt IRQ does not
* have a NAPI, so care must be taken to correctly map IRQs to NAPIs.
*/
for (i = 0; i < io_queue_count; i++) {
irq_idx = ENA_IO_IRQ_IDX(i);
irq = &adapter->irq_tbl[irq_idx];
netif_napi_set_irq(&adapter->ena_napi[i].napi, irq->vector);
}
return rc;
err:
@ -1811,20 +1821,40 @@ static void ena_napi_disable_in_range(struct ena_adapter *adapter,
int first_index,
int count)
{
struct napi_struct *napi;
int i;
for (i = first_index; i < first_index + count; i++)
napi_disable(&adapter->ena_napi[i].napi);
for (i = first_index; i < first_index + count; i++) {
napi = &adapter->ena_napi[i].napi;
if (!ENA_IS_XDP_INDEX(adapter, i)) {
/* This API is supported for non-XDP queues only */
netif_queue_set_napi(adapter->netdev, i,
NETDEV_QUEUE_TYPE_TX, NULL);
netif_queue_set_napi(adapter->netdev, i,
NETDEV_QUEUE_TYPE_RX, NULL);
}
napi_disable(napi);
}
}
static void ena_napi_enable_in_range(struct ena_adapter *adapter,
int first_index,
int count)
{
struct napi_struct *napi;
int i;
for (i = first_index; i < first_index + count; i++)
napi_enable(&adapter->ena_napi[i].napi);
for (i = first_index; i < first_index + count; i++) {
napi = &adapter->ena_napi[i].napi;
napi_enable(napi);
if (!ENA_IS_XDP_INDEX(adapter, i)) {
/* This API is supported for non-XDP queues only */
netif_queue_set_napi(adapter->netdev, i,
NETDEV_QUEUE_TYPE_RX, napi);
netif_queue_set_napi(adapter->netdev, i,
NETDEV_QUEUE_TYPE_TX, napi);
}
}
}
/* Configure the Rx forwarding */