Skip to content

Commit 22b6f45

Browse files
jdamato-fslygregkh
authored andcommitted
hv_netvsc: Link queues to NAPIs
[ Upstream commit 8b641b5 ] 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: 9448ccd ("net: hv_netvsc: fix loss of early receive events from host during channel open.") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6037d6f commit 22b6f45

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,13 @@ void netvsc_device_remove(struct hv_device *device)
712712
for (i = 0; i < net_device->num_chn; i++) {
713713
/* See also vmbus_reset_channel_cb(). */
714714
/* only disable enabled NAPI channel */
715-
if (i < ndev->real_num_rx_queues)
715+
if (i < ndev->real_num_rx_queues) {
716+
netif_queue_set_napi(ndev, i, NETDEV_QUEUE_TYPE_TX,
717+
NULL);
718+
netif_queue_set_napi(ndev, i, NETDEV_QUEUE_TYPE_RX,
719+
NULL);
716720
napi_disable(&net_device->chan_table[i].napi);
721+
}
717722

718723
netif_napi_del(&net_device->chan_table[i].napi);
719724
}
@@ -1826,6 +1831,10 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
18261831
netdev_dbg(ndev, "hv_netvsc channel opened successfully\n");
18271832

18281833
napi_enable(&net_device->chan_table[0].napi);
1834+
netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_RX,
1835+
&net_device->chan_table[0].napi);
1836+
netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_TX,
1837+
&net_device->chan_table[0].napi);
18291838

18301839
/* Connect with the NetVsp */
18311840
ret = netvsc_connect_vsp(device, net_device, device_info);
@@ -1844,6 +1853,8 @@ struct netvsc_device *netvsc_device_add(struct hv_device *device,
18441853

18451854
close:
18461855
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
1856+
netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_TX, NULL);
1857+
netif_queue_set_napi(ndev, 0, NETDEV_QUEUE_TYPE_RX, NULL);
18471858
napi_disable(&net_device->chan_table[0].napi);
18481859

18491860
/* Now, we can close the channel safely */

drivers/net/hyperv/rndis_filter.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,10 +1255,15 @@ static void netvsc_sc_open(struct vmbus_channel *new_sc)
12551255
ret = vmbus_open(new_sc, netvsc_ring_bytes,
12561256
netvsc_ring_bytes, NULL, 0,
12571257
netvsc_channel_cb, nvchan);
1258-
if (ret == 0)
1258+
if (ret == 0) {
12591259
napi_enable(&nvchan->napi);
1260-
else
1260+
netif_queue_set_napi(ndev, chn_index, NETDEV_QUEUE_TYPE_RX,
1261+
&nvchan->napi);
1262+
netif_queue_set_napi(ndev, chn_index, NETDEV_QUEUE_TYPE_TX,
1263+
&nvchan->napi);
1264+
} else {
12611265
netdev_notice(ndev, "sub channel open failed: %d\n", ret);
1266+
}
12621267

12631268
if (atomic_inc_return(&nvscdev->open_chn) == nvscdev->num_chn)
12641269
wake_up(&nvscdev->subchan_open);

0 commit comments

Comments
 (0)