]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
e1000e: Link NAPI instances to queues and IRQs
authorJoe Damato <jdamato@fastly.com>
Mon, 30 Sep 2024 17:12:31 +0000 (17:12 +0000)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 8 Oct 2024 22:22:32 +0000 (15:22 -0700)
Add support for netdev-genl, allowing users to query IRQ, NAPI, and queue
information.

After this patch is applied, note the IRQs assigned to my NIC:

$ cat /proc/interrupts | grep ens | cut -f1 --delimiter=':'
 50
 51
 52

While e1000e allocates 3 IRQs (RX, TX, and other), it looks like e1000e
only has a single NAPI, so I've associated the NAPI with the RX IRQ (50
on my system, seen above).

Note the output from the cli:

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

This device supports only 1 rx and 1 tx queue. so querying that:

$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
                       --dump queue-get --json='{"ifindex": 2}'
[{'id': 0, 'ifindex': 2, 'napi-id': 145, 'type': 'rx'},
 {'id': 0, 'ifindex': 2, 'napi-id': 145, 'type': 'tx'}]

Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Acked-by: Vitaly Lifshits <vitaly.lifshits@intel.com>
Tested-by: Avigail Dahan <avigailx.dahan@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/e1000e/netdev.c

index 9c9d4cb7c7357c6da4b166aea193eec85532464a..3be78c872a1ca7d76b07ae5fc397a7273b8b76ff 100644 (file)
@@ -4607,6 +4607,7 @@ int e1000e_open(struct net_device *netdev)
        struct e1000_hw *hw = &adapter->hw;
        struct pci_dev *pdev = adapter->pdev;
        int err;
+       int irq;
 
        /* disallow open during test */
        if (test_bit(__E1000_TESTING, &adapter->state))
@@ -4670,7 +4671,15 @@ int e1000e_open(struct net_device *netdev)
        /* From here on the code is the same as e1000e_up() */
        clear_bit(__E1000_DOWN, &adapter->state);
 
+       if (adapter->int_mode == E1000E_INT_MODE_MSIX)
+               irq = adapter->msix_entries[0].vector;
+       else
+               irq = adapter->pdev->irq;
+
+       netif_napi_set_irq(&adapter->napi, irq);
        napi_enable(&adapter->napi);
+       netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_RX, &adapter->napi);
+       netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_TX, &adapter->napi);
 
        e1000_irq_enable(adapter);
 
@@ -4729,6 +4738,8 @@ int e1000e_close(struct net_device *netdev)
                netdev_info(netdev, "NIC Link is Down\n");
        }
 
+       netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_RX, NULL);
+       netif_queue_set_napi(netdev, 0, NETDEV_QUEUE_TYPE_TX, NULL);
        napi_disable(&adapter->napi);
 
        e1000e_free_tx_resources(adapter->tx_ring);