From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, linux-kernel@vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, Michael Dalton <mwdalton@google.com>,
Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH 2/2] virtio-net: make all RX paths handle erors consistently
Date: Thu, 28 Nov 2013 14:06:33 +0800 [thread overview]
Message-ID: <5296DD69.4080201@redhat.com> (raw)
In-Reply-To: <1385569684-26595-2-git-send-email-mst@redhat.com>
On 11/28/2013 12:31 AM, Michael S. Tsirkin wrote:
> receive mergeable now handles errors internally.
> Do same for big and small packet paths, otherwise
> the logic is too hard to follow.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> While I can't point at a bug this fixes, I'm not sure
> there's no bug in the existing logic.
> So not exactly a bug fix bug I think it's justified for net.
>
> drivers/net/virtio_net.c | 53 +++++++++++++++++++++++++++++++++---------------
> 1 file changed, 37 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 0e6ea69..97c6212 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -299,6 +299,35 @@ static struct sk_buff *page_to_skb(struct receive_queue *rq,
> return skb;
> }
>
> +static struct sk_buff *receive_small(void *buf, unsigned int len)
> +{
> + struct sk_buff * skb = buf;
> +
> + len -= sizeof(struct virtio_net_hdr);
> + skb_trim(skb, len);
> +
> + return skb;
> +}
> +
> +static struct sk_buff *receive_big(struct net_device *dev,
> + struct receive_queue *rq,
> + void *buf,
> + unsigned int len)
> +{
> + struct page *page = buf;
> + struct sk_buff *skb = page_to_skb(rq, page, 0, len, PAGE_SIZE);
> +
> + if (unlikely(!skb))
> + goto err;
> +
> + return skb;
> +
> +err:
> + dev->stats.rx_dropped++;
> + give_pages(rq, page);
> + return NULL;
> +}
> +
> static struct sk_buff *receive_mergeable(struct net_device *dev,
> struct receive_queue *rq,
> void *buf,
> @@ -407,23 +436,15 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
> return;
> }
>
> - if (!vi->mergeable_rx_bufs && !vi->big_packets) {
> - skb = buf;
> - len -= sizeof(struct virtio_net_hdr);
> - skb_trim(skb, len);
> - } else if (vi->mergeable_rx_bufs) {
> + if (vi->mergeable_rx_bufs)
> skb = receive_mergeable(dev, rq, buf, len);
> - if (unlikely(!skb))
> - return;
> - } else {
> - page = buf;
> - skb = page_to_skb(rq, page, 0, len, PAGE_SIZE);
> - if (unlikely(!skb)) {
> - dev->stats.rx_dropped++;
> - give_pages(rq, page);
> - return;
> - }
> - }
> + else if (vi->big_packets)
> + skb = receive_big(dev, rq, buf, len);
> + else
> + skb = receive_small(buf, len);
> +
> + if (unlikely(!skb))
> + return;
>
> hdr = skb_vnet_hdr(skb);
>
Acked-by: Jason Wang <jasowang@redhat.com>
next prev parent reply other threads:[~2013-11-28 6:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 16:31 [PATCH 1/2] virtio_net: fix error handling for mergeable buffers Michael S. Tsirkin
2013-11-27 16:31 ` [PATCH 2/2] virtio-net: make all RX paths handle erors consistently Michael S. Tsirkin
2013-11-28 6:06 ` Jason Wang [this message]
2013-11-28 3:14 ` [PATCH 1/2] virtio_net: fix error handling for mergeable buffers Jason Wang
2013-11-28 11:14 ` 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=5296DD69.4080201@redhat.com \
--to=jasowang@redhat.com \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mwdalton@google.com \
--cc=netdev@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.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).