diff options
author | John Fastabend <john.fastabend@gmail.com> | 2017-01-25 21:22:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-01-25 22:48:17 -0500 |
commit | b68df015609eac67f045c155cb3195e5a1061d66 (patch) | |
tree | 6591853f9de1cc61b8ebdd0cd705da4a3fa440f9 | |
parent | 7480888f27e080ad5addb51456b2e03514721c3a (diff) |
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: bb91accf2733 ("virtio-net: XDP support for small buffers")
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/virtio_net.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 3d1519ea0669..4c6e9b43f1d3 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -1898,8 +1898,12 @@ static void free_receive_page_frags(struct virtnet_info *vi) | |||
1898 | put_page(vi->rq[i].alloc_frag.page); | 1898 | put_page(vi->rq[i].alloc_frag.page); |
1899 | } | 1899 | } |
1900 | 1900 | ||
1901 | static bool is_xdp_queue(struct virtnet_info *vi, int q) | 1901 | static bool is_xdp_raw_buffer_queue(struct virtnet_info *vi, int q) |
1902 | { | 1902 | { |
1903 | /* For small receive mode always use kfree_skb variants */ | ||
1904 | if (!vi->mergeable_rx_bufs) | ||
1905 | return false; | ||
1906 | |||
1903 | if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) | 1907 | if (q < (vi->curr_queue_pairs - vi->xdp_queue_pairs)) |
1904 | return false; | 1908 | return false; |
1905 | else if (q < vi->curr_queue_pairs) | 1909 | else if (q < vi->curr_queue_pairs) |
@@ -1916,7 +1920,7 @@ static void free_unused_bufs(struct virtnet_info *vi) | |||
1916 | for (i = 0; i < vi->max_queue_pairs; i++) { | 1920 | for (i = 0; i < vi->max_queue_pairs; i++) { |
1917 | struct virtqueue *vq = vi->sq[i].vq; | 1921 | struct virtqueue *vq = vi->sq[i].vq; |
1918 | while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { | 1922 | while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { |
1919 | if (!is_xdp_queue(vi, i)) | 1923 | if (!is_xdp_raw_buffer_queue(vi, i)) |
1920 | dev_kfree_skb(buf); | 1924 | dev_kfree_skb(buf); |
1921 | else | 1925 | else |
1922 | put_page(virt_to_head_page(buf)); | 1926 | put_page(virt_to_head_page(buf)); |