From: John Fastabend <john.fastabend@gmail.com>
To: Jason Wang <jasowang@redhat.com>, mst@redhat.com
Cc: john.r.fastabend@intel.com, netdev@vger.kernel.org,
alexei.starovoitov@gmail.com, daniel@iogearbox.net
Subject: Re: [net PATCH v3 3/5] virtio_net: factor out xdp handler for readability
Date: Fri, 13 Jan 2017 11:56:57 -0800 [thread overview]
Message-ID: <58793109.8050405@gmail.com> (raw)
In-Reply-To: <da246cbb-710c-275f-489c-251ea898a389@redhat.com>
On 17-01-12 11:40 PM, Jason Wang wrote:
>
>
> On 2017年01月13日 10:51, John Fastabend wrote:
>> At this point the do_xdp_prog is mostly if/else branches handling
>> the different modes of virtio_net. So remove it and handle running
>> the program in the per mode handlers.
>>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>> ---
>> drivers/net/virtio_net.c | 76 +++++++++++++++++-----------------------------
>> 1 file changed, 28 insertions(+), 48 deletions(-)
>>
>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> index 43cb2e0..ec54644 100644
>> --- a/drivers/net/virtio_net.c
>> +++ b/drivers/net/virtio_net.c
>> @@ -388,49 +388,6 @@ static void virtnet_xdp_xmit(struct virtnet_info *vi,
>> virtqueue_kick(sq->vq);
>> }
>>
>
> [...]
>
>> /* This happens when rx buffer size is underestimated */
>> @@ -598,8 +570,10 @@ static struct sk_buff *receive_mergeable(struct
>> net_device *dev,
>> if (unlikely(hdr->hdr.gso_type))
>> goto err_xdp;
>> - act = do_xdp_prog(vi, rq, xdp_prog,
>> - page_address(xdp_page) + offset, len);
>> + data = page_address(xdp_page) + offset;
>> + xdp.data = data + desc_room;
>> + xdp.data_end = xdp.data + (len - vi->hdr_len);
>
> It looks desc_room is always vi->hdr_len.
>
Seems to be the case I'll just use vi->hdr_len and remove the variable.
Thanks.
>> + act = bpf_prog_run_xdp(xdp_prog, &xdp);
>> switch (act) {
>> case XDP_PASS:
>> /* We can only create skb based on xdp_page. */
>> @@ -613,13 +587,19 @@ 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();
>> + virtnet_xdp_xmit(vi, rq, &vi->sq[qp], &xdp, data);
>> ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len);
>> if (unlikely(xdp_page != page))
>> goto err_xdp;
>> rcu_read_unlock();
>> goto xdp_xmit;
>> - case XDP_DROP:
>> default:
>> + bpf_warn_invalid_xdp_action(act);
>> + case XDP_ABORTED:
>> + case XDP_DROP:
>> if (unlikely(xdp_page != page))
>> __free_pages(xdp_page, 0);
>> ewma_pkt_len_add(&rq->mrg_avg_pkt_len, len);
>>
>
next prev parent reply other threads:[~2017-01-13 19:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 2:50 [net PATCH v3 0/5] virtio_net XDP fixes and adjust_header support John Fastabend
2017-01-13 2:50 ` [net PATCH v3 1/5] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-13 3:47 ` Jason Wang
2017-01-13 2:51 ` [net PATCH v3 2/5] net: virtio: wrap rtnl_lock in test for calling with lock already held John Fastabend
2017-01-13 16:34 ` Stephen Hemminger
2017-01-13 17:31 ` John Fastabend
2017-01-13 23:56 ` John Fastabend
2017-01-13 2:51 ` [net PATCH v3 3/5] virtio_net: factor out xdp handler for readability John Fastabend
2017-01-13 7:40 ` Jason Wang
2017-01-13 19:56 ` John Fastabend [this message]
2017-01-13 2:51 ` [net PATCH v3 4/5] virtio_net: remove duplicate queue pair binding in XDP John Fastabend
2017-01-13 2:52 ` [net PATCH v3 5/5] virtio_net: XDP support for adjust_head John Fastabend
2017-01-13 7:41 ` Jason Wang
2017-01-13 20:08 ` John Fastabend
2017-01-14 0:45 ` John Fastabend
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=58793109.8050405@gmail.com \
--to=john.fastabend@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jasowang@redhat.com \
--cc=john.r.fastabend@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).