Skip to content

Commit 19a5a77

Browse files
fengidrikuba-moo
authored andcommitted
virtio_net: xsk: support wakeup
xsk wakeup is used to trigger the logic for xsk xmit by xsk framework or user. Virtio-net does not support to actively generate an interruption, so it tries to trigger tx NAPI on the local cpu. Signed-off-by: Xuan Zhuo <[email protected]> Acked-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 09d2b31 commit 19a5a77

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/net/virtio_net.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,29 @@ static void check_sq_full_and_disable(struct virtnet_info *vi,
10541054
}
10551055
}
10561056

1057+
static int virtnet_xsk_wakeup(struct net_device *dev, u32 qid, u32 flag)
1058+
{
1059+
struct virtnet_info *vi = netdev_priv(dev);
1060+
struct send_queue *sq;
1061+
1062+
if (!netif_running(dev))
1063+
return -ENETDOWN;
1064+
1065+
if (qid >= vi->curr_queue_pairs)
1066+
return -EINVAL;
1067+
1068+
sq = &vi->sq[qid];
1069+
1070+
if (napi_if_scheduled_mark_missed(&sq->napi))
1071+
return 0;
1072+
1073+
local_bh_disable();
1074+
virtqueue_napi_schedule(&sq->napi, sq->vq);
1075+
local_bh_enable();
1076+
1077+
return 0;
1078+
}
1079+
10571080
static int __virtnet_xdp_xmit_one(struct virtnet_info *vi,
10581081
struct send_queue *sq,
10591082
struct xdp_frame *xdpf)
@@ -5399,6 +5422,7 @@ static const struct net_device_ops virtnet_netdev = {
53995422
.ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
54005423
.ndo_bpf = virtnet_xdp,
54015424
.ndo_xdp_xmit = virtnet_xdp_xmit,
5425+
.ndo_xsk_wakeup = virtnet_xsk_wakeup,
54025426
.ndo_features_check = passthru_features_check,
54035427
.ndo_get_phys_port_name = virtnet_get_phys_port_name,
54045428
.ndo_set_features = virtnet_set_features,

0 commit comments

Comments
 (0)