]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
hv_netvsc: Link queues to NAPIs
authorJoe Damato <jdamato@fastly.com>
Mon, 30 Sep 2024 17:27:09 +0000 (17:27 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Sep 2025 13:31:50 +0000 (15:31 +0200)
[ Upstream commit 8b641b5e4c782464c8818a71b443eeef8984bf34 ]

Use netif_queue_set_napi to link queues to NAPI instances so that they
can be queried with netlink.

Shradha Gupta tested the patch and reported that the results are
as expected:

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

 [{'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'rx'},
  {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'rx'},
  {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'},
  {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'},
  {'id': 4, 'ifindex': 2, 'napi-id': 8197, 'type': 'rx'},
  {'id': 5, 'ifindex': 2, 'napi-id': 8198, 'type': 'rx'},
  {'id': 6, 'ifindex': 2, 'napi-id': 8199, 'type': 'rx'},
  {'id': 7, 'ifindex': 2, 'napi-id': 8200, 'type': 'rx'},
  {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'tx'},
  {'id': 1, 'ifindex': 2, 'napi-id': 8194, 'type': 'tx'},
  {'id': 2, 'ifindex': 2, 'napi-id': 8195, 'type': 'tx'},
  {'id': 3, 'ifindex': 2, 'napi-id': 8196, 'type': 'tx'},
  {'id': 4, 'ifindex': 2, 'napi-id': 8197, 'type': 'tx'},
  {'id': 5, 'ifindex': 2, 'napi-id': 8198, 'type': 'tx'},
  {'id': 6, 'ifindex': 2, 'napi-id': 8199, 'type': 'tx'},
  {'id': 7, 'ifindex': 2, 'napi-id': 8200, 'type': 'tx'}]

Signed-off-by: Joe Damato <jdamato@fastly.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Tested-by: Shradha Gupta <shradhagupta@linux.microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Stable-dep-of: 9448ccd85336 ("net: hv_netvsc: fix loss of early receive events from host during channel open.")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/rndis_filter.c

index 807465dd4c8e34ce3e8ddcadeeca6661c4cc4cea..87ac2a5f180913bf17912d060e10c90e9103d0c7 100644 (file)
@@ -712,8 +712,13 @@ void netvsc_device_remove(struct hv_device *device)
        for (i = 0; i < net_device->num_chn; i++) {
                /* See also vmbus_reset_channel_cb(). */
                /* only disable enabled NAPI channel */
-               if (i < ndev->real_num_rx_queues)
+               if (i < ndev->real_num_rx_queues) {
+                       netif_queue_set_napi(ndev, i, NETDEV_QUEUE_TYPE_TX,
+                                            NULL);
+                       netif_queue_set_napi(ndev, i, NETDEV_QUEUE_TYPE_RX,
+                                            NULL);
                        napi_disable(&net_device->chan_table[i].napi);
+               }
 
                netif_napi_del(&net_device->chan_table[i].napi);
        }
@@ -1826,6 +1831,10 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
        netdev_dbg(ndev, "hv_netvsc channel opened successfully\n");
 
        napi_enable(&net_device->chan_table[0].napi);
+       netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_RX,
+                            &net_device->chan_table[0].napi);
+       netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_TX,
+                            &net_device->chan_table[0].napi);
 
        /* Connect with the NetVsp */
        ret = netvsc_connect_vsp(device, net_device, device_info);
@@ -1844,6 +1853,8 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
 
 close:
        RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
+       netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_TX, NULL);
+       netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_RX, NULL);
        napi_disable(&net_device->chan_table[0].napi);
 
        /* Now, we can close the channel safely */
index e457f809fe3110801fcdc74ed91cacb829a5958b..9b8769a8b77a12c4af660661bf3d04247f3709a6 100644 (file)
@@ -1255,10 +1255,15 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
        ret = vmbus_open(new_sc, netvsc_ring_bytes,
                         netvsc_ring_bytes, NULL, 0,
                         netvsc_channel_cb, nvchan);
-       if (ret == 0)
+       if (ret == 0) {
                napi_enable(&nvchan->napi);
-       else
+               netif_queue_set_napi(ndev, chn_index, NETDEV_QUEUE_TYPE_RX,
+                                    &nvchan->napi);
+               netif_queue_set_napi(ndev, chn_index, NETDEV_QUEUE_TYPE_TX,
+                                    &nvchan->napi);
+       } else {
                netdev_notice(ndev, "sub channel open failed: %d\n", ret);
+       }
 
        if (atomic_inc_return(&nvscdev->open_chn) == nvscdev->num_chn)
                wake_up(&nvscdev->subchan_open);