ena: Link queues to NAPIs
authorJoe Damato <jdamato@fastly.com>
Wed, 2 Oct 2024 00:13:28 +0000 (00:13 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Oct 2024 23:13:47 +0000 (16:13 -0700)
Link queues to NAPIs using the netdev-genl API so this information is
queryable.

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

[{'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'rx'},
 {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'rx'},
 {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'rx'},
 {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'rx'},
 {'id': 4, 'ifindex': 2, 'napi-id': 8205, 'type': 'rx'},
 {'id': 5, 'ifindex': 2, 'napi-id': 8206, 'type': 'rx'},
 {'id': 6, 'ifindex': 2, 'napi-id': 8207, 'type': 'rx'},
 {'id': 7, 'ifindex': 2, 'napi-id': 8208, 'type': 'rx'},
 {'id': 0, 'ifindex': 2, 'napi-id': 8201, 'type': 'tx'},
 {'id': 1, 'ifindex': 2, 'napi-id': 8202, 'type': 'tx'},
 {'id': 2, 'ifindex': 2, 'napi-id': 8203, 'type': 'tx'},
 {'id': 3, 'ifindex': 2, 'napi-id': 8204, 'type': 'tx'},
 {'id': 4, 'ifindex': 2, 'napi-id': 8205, 'type': 'tx'},
 {'id': 5, 'ifindex': 2, 'napi-id': 8206, 'type': 'tx'},
 {'id': 6, 'ifindex': 2, 'napi-id': 8207, 'type': 'tx'},
 {'id': 7, 'ifindex': 2, 'napi-id': 8208, 'type': 'tx'}]

Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: David Arinzon <darinzon@amazon.com>
Link: https://patch.msgid.link/20241002001331.65444-3-jdamato@fastly.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amazon/ena/ena_netdev.c

index 74ce9fa45cf87400ac7b71ee93a34d343137976a..96df20854eb95a33b760294c352961d92d58a802 100644 (file)
@@ -1821,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 */