Skip to content

Commit

Permalink
virtio-net: add missing virtqueue kick when flushing packets
Browse files Browse the repository at this point in the history
We tends to batch submitting packets during XDP_TX. This requires to
kick virtqueue after a batch, we tried to do it through
xdp_do_flush_map() which only makes sense for devmap not XDP_TX. So
explicitly kick the virtqueue in this case.

Reported-by: Kimitoshi Takahashi <[email protected]>
Tested-by: Kimitoshi Takahashi <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Fixes: 186b3c9 ("virtio-net: support XDP_REDIRECT")
Signed-off-by: Jason Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jasowang authored and davem330 committed Apr 13, 2018
1 parent 2290482 commit 9267c43
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,9 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
{
struct receive_queue *rq =
container_of(napi, struct receive_queue, napi);
unsigned int received;
struct virtnet_info *vi = rq->vq->vdev->priv;
struct send_queue *sq;
unsigned int received, qp;
bool xdp_xmit = false;

virtnet_poll_cleantx(rq);
Expand All @@ -1280,8 +1282,13 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
if (received < budget)
virtqueue_napi_complete(napi, rq->vq, received);

if (xdp_xmit)
if (xdp_xmit) {
qp = vi->curr_queue_pairs - vi->xdp_queue_pairs +
smp_processor_id();
sq = &vi->sq[qp];
virtqueue_kick(sq->vq);
xdp_do_flush_map();
}

return received;
}
Expand Down

0 comments on commit 9267c43

Please sign in to comment.