diff mbox series

[net-next,v2,1/2] ena: Link IRQs to NAPI instances

Message ID 20241002001331.65444-2-jdamato@fastly.com (mailing list archive)
State Accepted
Commit 989867846f7ff2cfd931aa0c6134e71ab8716647
Delegated to: Netdev Maintainers
Headers show
Series ena: Link IRQs, queues, and NAPI instances | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-03--18-00 (tests: 772)

Commit Message

Joe Damato Oct. 2, 2024, 12:13 a.m. UTC
Link IRQs to NAPI instances with netif_napi_set_irq. This information
can be queried with the netdev-genl API. Note that the ENA device
appears to allocate an IRQ for management purposes which does not have a
NAPI associated with it; this commit takes this into consideration to
accurately construct a map between IRQs and NAPI instances.

Compare the output of /proc/interrupts for my ena device with the output of
netdev-genl after applying this patch:

$ cat /proc/interrupts | grep enp55s0 | cut -f1 --delimiter=':'
 94
 95
 96
 97
 98
 99
100
101

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
			 --dump napi-get --json='{"ifindex": 2}'

[{'id': 8208, 'ifindex': 2, 'irq': 101},
 {'id': 8207, 'ifindex': 2, 'irq': 100},
 {'id': 8206, 'ifindex': 2, 'irq': 99},
 {'id': 8205, 'ifindex': 2, 'irq': 98},
 {'id': 8204, 'ifindex': 2, 'irq': 97},
 {'id': 8203, 'ifindex': 2, 'irq': 96},
 {'id': 8202, 'ifindex': 2, 'irq': 95},
 {'id': 8201, 'ifindex': 2, 'irq': 94}]

Signed-off-by: Joe Damato <jdamato@fastly.com>
---
 v2:
   - Preserve reverse christmas tree order in ena_request_io_irq
   - No functional changes

 drivers/net/ethernet/amazon/ena/ena_netdev.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Arinzon, David Oct. 2, 2024, 6:27 a.m. UTC | #1
> Link IRQs to NAPI instances with netif_napi_set_irq. This information can be
> queried with the netdev-genl API. Note that the ENA device appears to
> allocate an IRQ for management purposes which does not have a NAPI
> associated with it; this commit takes this into consideration to accurately
> construct a map between IRQs and NAPI instances.
> 
> Compare the output of /proc/interrupts for my ena device with the output
> of netdev-genl after applying this patch:
> 
> $ cat /proc/interrupts | grep enp55s0 | cut -f1 --delimiter=':'
>  94
>  95
>  96
>  97
>  98
>  99
> 100
> 101
> 
> $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
>                          --dump napi-get --json='{"ifindex": 2}'
> 
> [{'id': 8208, 'ifindex': 2, 'irq': 101},
>  {'id': 8207, 'ifindex': 2, 'irq': 100},
>  {'id': 8206, 'ifindex': 2, 'irq': 99},
>  {'id': 8205, 'ifindex': 2, 'irq': 98},
>  {'id': 8204, 'ifindex': 2, 'irq': 97},
>  {'id': 8203, 'ifindex': 2, 'irq': 96},
>  {'id': 8202, 'ifindex': 2, 'irq': 95},
>  {'id': 8201, 'ifindex': 2, 'irq': 94}]
> 
> Signed-off-by: Joe Damato <jdamato@fastly.com>
> ---
>  v2:
>    - Preserve reverse christmas tree order in ena_request_io_irq
>    - No functional changes
> 
>  drivers/net/ethernet/amazon/ena/ena_netdev.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> index c5b50cfa935a..74ce9fa45cf8 100644
> --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
> +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
> @@ -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:
> --
> 2.25.1

LGTM.

Reviewed-by: David Arinzon <darinzon@amazon.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index c5b50cfa935a..74ce9fa45cf8 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -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: