Skip to content

Commit 18117a8

Browse files
Heng Qidavem330
authored andcommitted
virtio-net: remove xdp related info from page_to_skb()
For the clear construction of xdp_buff, we remove the xdp processing interleaved with page_to_skb(). Now, the logic of xdp and building skb from xdp are separate and independent. Signed-off-by: Heng Qi <hengqi@linux.alibaba.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b26aa48 commit 18117a8

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

drivers/net/virtio_net.c

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,7 @@ static unsigned int mergeable_ctx_to_truesize(void *mrg_ctx)
446446
static struct sk_buff *page_to_skb(struct virtnet_info *vi,
447447
struct receive_queue *rq,
448448
struct page *page, unsigned int offset,
449-
unsigned int len, unsigned int truesize,
450-
bool hdr_valid, unsigned int metasize,
451-
unsigned int headroom)
449+
unsigned int len, unsigned int truesize)
452450
{
453451
struct sk_buff *skb;
454452
struct virtio_net_hdr_mrg_rxbuf *hdr;
@@ -466,21 +464,11 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
466464
else
467465
hdr_padded_len = sizeof(struct padded_vnet_hdr);
468466

469-
/* If headroom is not 0, there is an offset between the beginning of the
470-
* data and the allocated space, otherwise the data and the allocated
471-
* space are aligned.
472-
*
473-
* Buffers with headroom use PAGE_SIZE as alloc size, see
474-
* add_recvbuf_mergeable() + get_mergeable_buf_len()
475-
*/
476-
truesize = headroom ? PAGE_SIZE : truesize;
477-
tailroom = truesize - headroom;
478-
buf = p - headroom;
479-
467+
buf = p;
480468
len -= hdr_len;
481469
offset += hdr_padded_len;
482470
p += hdr_padded_len;
483-
tailroom -= hdr_padded_len + len;
471+
tailroom = truesize - hdr_padded_len - len;
484472

485473
shinfo_size = SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
486474

@@ -510,7 +498,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
510498
if (len <= skb_tailroom(skb))
511499
copy = len;
512500
else
513-
copy = ETH_HLEN + metasize;
501+
copy = ETH_HLEN;
514502
skb_put_data(skb, p, copy);
515503

516504
len -= copy;
@@ -549,19 +537,11 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
549537
give_pages(rq, page);
550538

551539
ok:
552-
/* hdr_valid means no XDP, so we can copy the vnet header */
553-
if (hdr_valid) {
554-
hdr = skb_vnet_hdr(skb);
555-
memcpy(hdr, hdr_p, hdr_len);
556-
}
540+
hdr = skb_vnet_hdr(skb);
541+
memcpy(hdr, hdr_p, hdr_len);
557542
if (page_to_free)
558543
put_page(page_to_free);
559544

560-
if (metasize) {
561-
__skb_pull(skb, metasize);
562-
skb_metadata_set(skb, metasize);
563-
}
564-
565545
return skb;
566546
}
567547

@@ -945,7 +925,7 @@ static struct sk_buff *receive_big(struct net_device *dev,
945925
{
946926
struct page *page = buf;
947927
struct sk_buff *skb =
948-
page_to_skb(vi, rq, page, 0, len, PAGE_SIZE, true, 0, 0);
928+
page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
949929

950930
stats->bytes += len - vi->hdr_len;
951931
if (unlikely(!skb))
@@ -1243,9 +1223,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
12431223
rcu_read_unlock();
12441224
put_page(page);
12451225
head_skb = page_to_skb(vi, rq, xdp_page, offset,
1246-
len, PAGE_SIZE, false,
1247-
metasize,
1248-
headroom);
1226+
len, PAGE_SIZE);
12491227
return head_skb;
12501228
}
12511229
break;
@@ -1312,8 +1290,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
13121290
rcu_read_unlock();
13131291

13141292
skip_xdp:
1315-
head_skb = page_to_skb(vi, rq, page, offset, len, truesize, !xdp_prog,
1316-
metasize, headroom);
1293+
head_skb = page_to_skb(vi, rq, page, offset, len, truesize);
13171294
curr_skb = head_skb;
13181295

13191296
if (unlikely(!curr_skb))

0 commit comments

Comments
 (0)