mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-09 14:14:00 +08:00
virtio-net: realign page_to_skb() after merges
We ended up merging two versions of the same patch set: commit8fb7da9e99
("virtio_net: get build_skb() buf by data ptr") commit5c37711d9f
("virtio-net: fix for unable to handle page fault for address") into net, and commit7bf64460e3
("virtio-net: get build_skb() buf by data ptr") commit6c66c147b9
("virtio-net: fix for unable to handle page fault for address") into net-next. Redo the merge from commit126285651b
("Merge ra.kernel.org:/pub/scm/linux/kernel/git/netdev/net"), so that the most recent code remains. Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
dc1a8079eb
commit
c32325b8fd
@ -380,7 +380,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
|
|||||||
struct page *page, unsigned int offset,
|
struct page *page, unsigned int offset,
|
||||||
unsigned int len, unsigned int truesize,
|
unsigned int len, unsigned int truesize,
|
||||||
bool hdr_valid, unsigned int metasize,
|
bool hdr_valid, unsigned int metasize,
|
||||||
bool whole_page)
|
unsigned int headroom)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct virtio_net_hdr_mrg_rxbuf *hdr;
|
struct virtio_net_hdr_mrg_rxbuf *hdr;
|
||||||
@ -398,28 +398,16 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
|
|||||||
else
|
else
|
||||||
hdr_padded_len = sizeof(struct padded_vnet_hdr);
|
hdr_padded_len = sizeof(struct padded_vnet_hdr);
|
||||||
|
|
||||||
/* If whole_page, there is an offset between the beginning of the
|
/* If headroom is not 0, there is an offset between the beginning of the
|
||||||
* data and the allocated space, otherwise the data and the allocated
|
* data and the allocated space, otherwise the data and the allocated
|
||||||
* space are aligned.
|
* space are aligned.
|
||||||
*
|
*
|
||||||
* Buffers with headroom use PAGE_SIZE as alloc size, see
|
* Buffers with headroom use PAGE_SIZE as alloc size, see
|
||||||
* add_recvbuf_mergeable() + get_mergeable_buf_len()
|
* add_recvbuf_mergeable() + get_mergeable_buf_len()
|
||||||
*/
|
*/
|
||||||
if (whole_page) {
|
truesize = headroom ? PAGE_SIZE : truesize;
|
||||||
/* Buffers with whole_page use PAGE_SIZE as alloc size,
|
tailroom = truesize - len - headroom;
|
||||||
* see add_recvbuf_mergeable() + get_mergeable_buf_len()
|
buf = p - headroom;
|
||||||
*/
|
|
||||||
truesize = PAGE_SIZE;
|
|
||||||
|
|
||||||
/* page maybe head page, so we should get the buf by p, not the
|
|
||||||
* page
|
|
||||||
*/
|
|
||||||
tailroom = truesize - len - offset_in_page(p);
|
|
||||||
buf = (char *)((unsigned long)p & PAGE_MASK);
|
|
||||||
} else {
|
|
||||||
tailroom = truesize - len;
|
|
||||||
buf = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
len -= hdr_len;
|
len -= hdr_len;
|
||||||
offset += hdr_padded_len;
|
offset += hdr_padded_len;
|
||||||
@ -978,7 +966,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
|
|||||||
put_page(page);
|
put_page(page);
|
||||||
head_skb = page_to_skb(vi, rq, xdp_page, offset,
|
head_skb = page_to_skb(vi, rq, xdp_page, offset,
|
||||||
len, PAGE_SIZE, false,
|
len, PAGE_SIZE, false,
|
||||||
metasize, true);
|
metasize,
|
||||||
|
VIRTIO_XDP_HEADROOM);
|
||||||
return head_skb;
|
return head_skb;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1029,7 +1018,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
|
|||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog,
|
head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog,
|
||||||
metasize, !!headroom);
|
metasize, headroom);
|
||||||
curr_skb = head_skb;
|
curr_skb = head_skb;
|
||||||
|
|
||||||
if (unlikely(!curr_skb))
|
if (unlikely(!curr_skb))
|
||||||
|
Loading…
Reference in New Issue
Block a user