Message ID | 20230328120412.110114-6-xuanzhuo@linux.alibaba.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio_net: refactor xdp codes | expand |
Context | Check | Description |
---|---|---|
netdev/series_format | success | Posting correctly formatted |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 18 this patch: 18 |
netdev/cc_maintainers | success | CCed 9 of 9 maintainers |
netdev/build_clang | success | Errors and warnings before: 18 this patch: 18 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/deprecated_api | success | None detected |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 18 this patch: 18 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 48 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On Tue, Mar 28, 2023 at 8:04 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote: > > This patch introduce a new function that frees the rest mergeable buf. > The subsequent patch will reuse this function. > > Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Thanks > --- > drivers/net/virtio_net.c | 36 ++++++++++++++++++++++++------------ > 1 file changed, 24 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 09aed60e2f51..a3f2bcb3db27 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1076,6 +1076,28 @@ static struct sk_buff *receive_big(struct net_device *dev, > return NULL; > } > > +static void mergeable_buf_free(struct receive_queue *rq, int num_buf, > + struct net_device *dev, > + struct virtnet_rq_stats *stats) > +{ > + struct page *page; > + void *buf; > + int len; > + > + while (num_buf-- > 1) { > + buf = virtqueue_get_buf(rq->vq, &len); > + if (unlikely(!buf)) { > + pr_debug("%s: rx error: %d buffers missing\n", > + dev->name, num_buf); > + dev->stats.rx_length_errors++; > + break; > + } > + stats->bytes += len; > + page = virt_to_head_page(buf); > + put_page(page); > + } > +} > + > /* Why not use xdp_build_skb_from_frame() ? > * XDP core assumes that xdp frags are PAGE_SIZE in length, while in > * virtio-net there are 2 points that do not match its requirements: > @@ -1436,18 +1458,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, > stats->xdp_drops++; > err_skb: > put_page(page); > - while (num_buf-- > 1) { > - buf = virtqueue_get_buf(rq->vq, &len); > - if (unlikely(!buf)) { > - pr_debug("%s: rx error: %d buffers missing\n", > - dev->name, num_buf); > - dev->stats.rx_length_errors++; > - break; > - } > - stats->bytes += len; > - page = virt_to_head_page(buf); > - put_page(page); > - } > + mergeable_buf_free(rq, num_buf, dev, stats); > + > err_buf: > stats->drops++; > dev_kfree_skb(head_skb); > -- > 2.32.0.3.g01195cf9f >
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 09aed60e2f51..a3f2bcb3db27 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1076,6 +1076,28 @@ static struct sk_buff *receive_big(struct net_device *dev, return NULL; } +static void mergeable_buf_free(struct receive_queue *rq, int num_buf, + struct net_device *dev, + struct virtnet_rq_stats *stats) +{ + struct page *page; + void *buf; + int len; + + while (num_buf-- > 1) { + buf = virtqueue_get_buf(rq->vq, &len); + if (unlikely(!buf)) { + pr_debug("%s: rx error: %d buffers missing\n", + dev->name, num_buf); + dev->stats.rx_length_errors++; + break; + } + stats->bytes += len; + page = virt_to_head_page(buf); + put_page(page); + } +} + /* Why not use xdp_build_skb_from_frame() ? * XDP core assumes that xdp frags are PAGE_SIZE in length, while in * virtio-net there are 2 points that do not match its requirements: @@ -1436,18 +1458,8 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, stats->xdp_drops++; err_skb: put_page(page); - while (num_buf-- > 1) { - buf = virtqueue_get_buf(rq->vq, &len); - if (unlikely(!buf)) { - pr_debug("%s: rx error: %d buffers missing\n", - dev->name, num_buf); - dev->stats.rx_length_errors++; - break; - } - stats->bytes += len; - page = virt_to_head_page(buf); - put_page(page); - } + mergeable_buf_free(rq, num_buf, dev, stats); + err_buf: stats->drops++; dev_kfree_skb(head_skb);
This patch introduce a new function that frees the rest mergeable buf. The subsequent patch will reuse this function. Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> --- drivers/net/virtio_net.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-)