virtio-net: remove unnecessary parameter of virtnet_xdp_xmit()
Subsystems (4)
PATCH 1/3 virtio-net: remove unnecessary parameter of virtnet_xdp_xmit()
--- drivers/net/virtio_net.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +2 -3
@@ -373,7 +373,6 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi, }static bool virtnet_xdp_xmit (struct virtnet_info *vi, -struct receive_queue *rq,struct xdp_buff *xdp) {struct virtio_net_hdr_mrg_rxbuf *hdr;
@@ -542,7 +541,7 @@ static struct sk_buff *receive_small(struct net_device *dev, delta = orig_data - xdp.data;break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, rq, &xdp))) +if (unlikely (!virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);rcu_read_unlock (); goto xdp_xmit;
@@ -677,7 +676,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, rq, &xdp))) +if (unlikely (!virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len);if (unlikely (xdp_page != page))
Signature · 1 line
2.7.4
PATCH 2/3 virtio-net: add packet len average only when needed during XDP
There's no need to add packet len average in the case of XDP_PASS since it will be done soon after skb is created.
--- drivers/net/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +3 -3
@@ -656,6 +656,9 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, xdp.data_end = xdp.data + (len - vi->hdr_len); act =bpf_prog_run_xdp (xdp_prog, &xdp); +if (act !=XDP_PASS ) +ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len); +switch (act) {case XDP_PASS :/* recalculate offset to account for any header
@@ -671,14 +674,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,put_page (page); head_skb =page_to_skb (vi, rq, xdp_page, offset, len,PAGE_SIZE ); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len);return head_skb; }break ;case XDP_TX :if (unlikely (!virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len);if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock ();
@@ -690,7 +691,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,case XDP_DROP :if (unlikely (xdp_page != page))__free_pages (xdp_page,0 ); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len); goto err_xdp; } }
Signature · 1 line
2.7.4
PATCH 2/3 virtio-net: add packet len average only when needed during XDP
In reply to Jason WangThere's no need to add packet len average in the case of XDP_PASS since it will be done soon after skb is created.
--- drivers/net/virtio_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +3 -3
@@ -656,6 +656,9 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, xdp.data_end = xdp.data + (len - vi->hdr_len); act =bpf_prog_run_xdp (xdp_prog, &xdp); +if (act !=XDP_PASS ) +ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len); +switch (act) {case XDP_PASS :/* recalculate offset to account for any header
@@ -671,14 +674,12 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,put_page (page); head_skb =page_to_skb (vi, rq, xdp_page, offset, len,PAGE_SIZE ); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len);return head_skb; }break ;case XDP_TX :if (unlikely (!virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len);if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock ();
@@ -690,7 +691,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,case XDP_DROP :if (unlikely (xdp_page != page))__free_pages (xdp_page,0 ); -ewma_pkt_len_add (&rq->mrg_avg_pkt_len, len); goto err_xdp; } }
Signature · 1 line
2.7.4
PATCH 3/3 virtio-net: support XDP_REDIRECT
In reply to Jason WangThis patch tries to add XDP_REDIRECT for virtio-net. The changes are not complex as we could use exist XDP_TX helpers for most of the work. The rest is passing the XDP_TX to NAPI handler for implementing batching.
--- drivers/net/virtio_net. | 0 drivers/net/virtio_net.c | 77 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 drivers/net/virtio_net.
drivers/net/virtio_net. new file +0 -0
drivers/net/virtio_net.c +62 -15
192 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 3/3 virtio-net: support XDP_REDIRECT
In reply to Jason WangThis patch tries to add XDP_REDIRECT for virtio-net. The changes are not complex as we could use exist XDP_TX helpers for most of the work. The rest is passing the XDP_TX to NAPI handler for implementing batching.
--- drivers/net/virtio_net. | 0 drivers/net/virtio_net.c | 77 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 drivers/net/virtio_net.
drivers/net/virtio_net. new file +0 -0
drivers/net/virtio_net.c +62 -15
192 lines not on this page · raw message
Signature · 1 line
2.7.4
From: Jason Wang <[email protected]>
Date: Tue, 19 Sep 2017 17:42:41 +0800
Quoted 2 lines
CC John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied.
Re: [PATCH net-next 2/3] virtio-net: add packet len average only when needed during XDP
In reply to Jason WangFrom: Jason Wang <[email protected]>
Date: Tue, 19 Sep 2017 17:42:42 +0800
Quoted 5 lines
There's no need to add packet len average in the case of
XDP_PASSsince it will be done soon after skb is created.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied.
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to Jason WangFrom: Jason Wang <[email protected]>
Date: Tue, 19 Sep 2017 17:42:43 +0800
Quoted 7 lines
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied.
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to Jason WangFrom: Jason Wang <[email protected]>
Date: Tue, 19 Sep 2017 17:42:43 +0800
Quoted 7 lines
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied.
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to Jason WangQuoted 8 lines · Jason Wang
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>---
[...]
Quoted 7 lines
drivers/net/virtio_net.c +1
-1@@ -678,12 +711,20 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, &xdp))) +if (unlikely (!__virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);
drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 725
Quoted 10 lines
drivers/net/virtio_net.c +6
-0+else + *xdp_xmit = true;if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock (); goto xdp_xmit; +case XDP_REDIRECT : + err =xdp_do_redirect (dev, &xdp, xdp_prog); +if (err) + *xdp_xmit = true;
Is this a typo? Should above be
if (!err) *xdp_xmit = true;
this would match the pattern in receive_small and also make more sense.
drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 830
Quoted 8 lines
drivers/net/virtio_net.c +2
-0+rcu_read_unlock (); + goto xdp_xmit;default :bpf_warn_invalid_xdp_action (act);case XDP_ABORTED :@@ -788,7 +829,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }
[...]
Otherwise looks good to me thanks for doing this.
.John
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to Jason WangQuoted 8 lines · Jason Wang
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>---
[...]
Quoted 7 lines
drivers/net/virtio_net.c +1
-1@@ -678,12 +711,20 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, &xdp))) +if (unlikely (!__virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);
drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 725
Quoted 10 lines
drivers/net/virtio_net.c +6
-0+else + *xdp_xmit = true;if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock (); goto xdp_xmit; +case XDP_REDIRECT : + err =xdp_do_redirect (dev, &xdp, xdp_prog); +if (err) + *xdp_xmit = true;
Is this a typo? Should above be
if (!err) *xdp_xmit = true;
this would match the pattern in receive_small and also make more sense.
drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 830
Quoted 8 lines
drivers/net/virtio_net.c +2
-0+rcu_read_unlock (); + goto xdp_xmit;default :bpf_warn_invalid_xdp_action (act);case XDP_ABORTED :@@ -788,7 +829,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }
[...]
Otherwise looks good to me thanks for doing this.
.John
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to John FastabendQuoted 30 lines · John Fastabend
Quoted 8 lines · Jason Wang
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>---
[...]
Quoted 7 lines
drivers/net/virtio_net.c +1
-1@@ -678,12 +711,20 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, &xdp))) +if (unlikely (!__virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 725
Quoted 10 lines
drivers/net/virtio_net.c +6
-0+else + *xdp_xmit = true;if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock (); goto xdp_xmit; +case XDP_REDIRECT : + err =xdp_do_redirect (dev, &xdp, xdp_prog); +if (err) + *xdp_xmit = true;Is this a typo? Should above be
Quoted 4 lines
if (!err) *xdp_xmit = true;this would match the pattern in
receive_smalland also make more sense.
Right, will post a fix.
Quoted 11 lines
Quoted 9 lines
drivers/net/virtio_net.c +2
-0+rcu_read_unlock (); + goto xdp_xmit;default :bpf_warn_invalid_xdp_action (act);case XDP_ABORTED :@@ -788,7 +829,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }[...]
Quoted 4 lines
Otherwise looks good to me thanks for doing this.
.John
Thanks for the reviewing.
Re: [PATCH net-next 3/3] virtio-net: support XDP_REDIRECT
In reply to John FastabendQuoted 30 lines · John Fastabend
Quoted 8 lines · Jason Wang
This patch tries to add
XDP_REDIRECTfor virtio-net. The changes are not complex as we could use existXDP_TXhelpers for most of the work. The rest is passing theXDP_TXto NAPI handler for implementing batching.Cc John Fastabend <[email protected]>Signed-off-by Jason Wang <[email protected]>---
[...]
Quoted 7 lines
drivers/net/virtio_net.c +1
-1@@ -678,12 +711,20 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }break ;case XDP_TX : -if (unlikely (!virtnet_xdp_xmit (vi, &xdp))) +if (unlikely (!__virtnet_xdp_xmit (vi, &xdp)))trace_xdp_exception (vi->dev, xdp_prog, act);drivers/net/virtio_net.c static struct sk_buff *receive_mergeable(struct net_device *dev, · line 725
Quoted 10 lines
drivers/net/virtio_net.c +6
-0+else + *xdp_xmit = true;if (unlikely (xdp_page != page)) goto err_xdp;rcu_read_unlock (); goto xdp_xmit; +case XDP_REDIRECT : + err =xdp_do_redirect (dev, &xdp, xdp_prog); +if (err) + *xdp_xmit = true;Is this a typo? Should above be
Quoted 4 lines
if (!err) *xdp_xmit = true;this would match the pattern in
receive_smalland also make more sense.
Right, will post a fix.
Quoted 11 lines
Quoted 9 lines
drivers/net/virtio_net.c +2
-0+rcu_read_unlock (); + goto xdp_xmit;default :bpf_warn_invalid_xdp_action (act);case XDP_ABORTED :@@ -788,7 +829,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev, }[...]
Quoted 4 lines
Otherwise looks good to me thanks for doing this.
.John
Thanks for the reviewing.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization