提交 b68df015 编写于 作者: J John Fastabend 提交者: David S. Miller

virtio_net: use dev_kfree_skb for small buffer XDP receive

In the small buffer case during driver unload we currently use
put_page instead of dev_kfree_skb. Resolve this by adding a check
for virtnet mode when checking XDP queue type. Also name the
function so that the code reads correctly to match the additional
check.

Fixes: bb91accf ("virtio-net: XDP support for small buffers")
Signed-off-by: NJohn Fastabend <john.r.fastabend@intel.com>
Acked-by: NJason Wang <jasowang@redhat.com>
Acked-by: NMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7480888f
...@@ -1898,8 +1898,12 @@ static void free_receive_page_frags(struct virtnet_info *vi) ...@@ -1898,8 +1898,12 @@ static void free_receive_page_frags(struct virtnet_info *vi)
put_page(vi->rq[i].alloc_frag.page); put_page(vi->rq[i].alloc_frag.page);
} }
static bool is_xdp_queue(struct virtnet_info *vi, int q) static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q)
{ {
/* For small receive mode always use kfree_skb variants */
if (!vi->mergeable_rx_bufs)
return false;
if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs))
return false; return false;
else if (q < vi->curr_queue_pairs) else if (q < vi->curr_queue_pairs)
...@@ -1916,7 +1920,7 @@ static void free_unused_bufs(struct virtnet_info *vi) ...@@ -1916,7 +1920,7 @@ static void free_unused_bufs(struct virtnet_info *vi)
for (i = 0; i < vi->max_queue_pairs; i++) { for (i = 0; i < vi->max_queue_pairs; i++) {
struct virtqueue *vq = vi->sq[i].vq; struct virtqueue *vq = vi->sq[i].vq;
while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) {
if (!is_xdp_queue(vi, i)) if (!is_xdp_raw_buffer_queue(vi, i))
dev_kfree_skb(buf); dev_kfree_skb(buf);
else else
put_page(virt_to_head_page(buf)); put_page(virt_to_head_page(buf));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册