From: John Fastabend <john.fastabend@gmail.com>
To: kubakici@wp.pl, jasowang@redhat.com, ast@fb.com, mst@redhat.com
Cc: john.r.fastabend@intel.com, netdev@vger.kernel.org,
john.fastabend@gmail.com
Subject: [net-next PATCH v2 3/5] virtio_net: remove duplicate queue pair binding in XDP
Date: Thu, 02 Feb 2017 19:15:32 -0800 [thread overview]
Message-ID: <20170203031532.23054.52077.stgit@john-Precision-Tower-5810> (raw)
In-Reply-To: <20170203031251.23054.25387.stgit@john-Precision-Tower-5810>
Factor out qp assignment.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
drivers/net/virtio_net.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 3b49363..dba5afb 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -341,15 +341,19 @@ 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 send_queue *sq,
struct xdp_buff *xdp,
void *data)
{
struct virtio_net_hdr_mrg_rxbuf *hdr;
unsigned int num_sg, len;
+ struct send_queue *sq;
+ unsigned int qp;
void *xdp_sent;
int err;
+ qp = vi->curr_queue_pairs - vi->xdp_queue_pairs + smp_processor_id();
+ sq = &vi->sq[qp];
+
/* Free up any pending old buffers before queueing new ones. */
while ((xdp_sent = virtqueue_get_buf(sq->vq, &len)) != NULL) {
if (vi->mergeable_rx_bufs) {
@@ -415,7 +419,6 @@ static struct sk_buff *receive_small(struct net_device *dev,
if (xdp_prog) {
struct virtio_net_hdr_mrg_rxbuf *hdr = buf;
struct xdp_buff xdp;
- unsigned int qp;
u32 act;
if (unlikely(hdr->hdr.gso_type || hdr->hdr.flags))
@@ -429,11 +432,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
case XDP_PASS:
break;
case XDP_TX:
- qp = vi->curr_queue_pairs -
- vi->xdp_queue_pairs +
- smp_processor_id();
- if (unlikely(!virtnet_xdp_xmit(vi, rq, &vi->sq[qp],
- &xdp, skb)))
+ if (unlikely(!virtnet_xdp_xmit(vi, rq, &xdp, skb)))
trace_xdp_exception(vi->dev, xdp_prog, act);
rcu_read_unlock();
goto xdp_xmit;
@@ -560,7 +559,6 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
if (xdp_prog) {
struct page *xdp_page;
struct xdp_buff xdp;
- unsigned int qp;
void *data;
u32 act;
@@ -602,11 +600,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
}
break;
case XDP_TX:
- qp = vi->curr_queue_pairs -
- vi->xdp_queue_pairs +
- smp_processor_id();
- if (unlikely(!virtnet_xdp_xmit(vi, rq, &vi->sq[qp],
- &xdp, data)))
+ if (unlikely(!virtnet_xdp_xmit(vi, rq, &xdp, data)))
trace_xdp_exception(vi->dev, xdp_prog, act);
ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len);
if (unlikely(xdp_page != page))
next prev parent reply other threads:[~2017-02-03 3:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 3:14 [net-next PATCH v2 0/5] XDP adjust head support for virtio John Fastabend
2017-02-03 3:14 ` [net-next PATCH v2 1/5] virtio_net: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-02-06 6:48 ` Jason Wang
2017-02-03 3:15 ` [net-next PATCH v2 2/5] virtio_net: factor out xdp handler for readability John Fastabend
2017-02-06 6:49 ` Jason Wang
2017-02-03 3:15 ` John Fastabend [this message]
2017-02-06 7:06 ` [net-next PATCH v2 3/5] virtio_net: remove duplicate queue pair binding in XDP Jason Wang
2017-02-03 3:16 ` [net-next PATCH v2 4/5] virtio_net: refactor freeze/restore logic into virtnet reset logic John Fastabend
2017-02-06 7:07 ` Jason Wang
2017-02-03 3:16 ` [net-next PATCH v2 5/5] virtio_net: XDP support for adjust_head John Fastabend
2017-02-03 4:04 ` Michael S. Tsirkin
2017-02-06 7:08 ` Jason Wang
2017-02-06 19:29 ` John Fastabend
2017-02-07 2:23 ` Jason Wang
2017-02-03 3:29 ` [net-next PATCH v2 0/5] XDP adjust head support for virtio Alexei Starovoitov
2017-02-03 3:55 ` Jakub Kicinski
2017-02-05 22:36 ` David Miller
2017-02-06 4:39 ` Michael S. Tsirkin
2017-02-06 7:12 ` Jason Wang
2017-02-06 16:37 ` David Miller
2017-02-07 4:15 ` Michael S. Tsirkin
2017-02-07 15:05 ` David Miller
2017-02-08 16:39 ` John Fastabend
2017-02-08 16:50 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170203031532.23054.52077.stgit@john-Precision-Tower-5810 \
--to=john.fastabend@gmail.com \
--cc=ast@fb.com \
--cc=jasowang@redhat.com \
--cc=john.r.fastabend@intel.com \
--cc=kubakici@wp.pl \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox