All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com,
	qemu-devel@nongnu.org, agraf@suse.de,
	Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [Qemu-devel] [PATCHv2] e1000: multi-buffer packet support
Date: Tue, 08 Feb 2011 15:07:58 +0100	[thread overview]
Message-ID: <4D514E3E.6020704@redhat.com> (raw)
In-Reply-To: <20110203164910.GA10672@redhat.com>

Am 03.02.2011 17:49, schrieb Michael S. Tsirkin:
> e1000 supports multi-buffer packets larger than rxbuf_size.
> 
> This fixes the following (on linux):
> - in guest: ifconfig eth1 mtu 16110
> - in host: ifconfig tap0 mtu 16110
>            ping -s 16082 <guest-ip>
> 
> Red Hat bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=602205
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
> Changes from v1:
> 	removed dead code
> 
>  hw/e1000.c |   29 +++++++++++++++++++----------
>  1 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/hw/e1000.c b/hw/e1000.c
> index af101bd..3427ff3 100644
> --- a/hw/e1000.c
> +++ b/hw/e1000.c
> @@ -642,6 +642,8 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
>      uint16_t vlan_special = 0;
>      uint8_t vlan_status = 0, vlan_offset = 0;
>      uint8_t min_buf[MIN_BUF_SIZE];
> +    size_t desc_offset;
> +    size_t desc_size;
>  
>      if (!(s->mac_reg[RCTL] & E1000_RCTL_EN))
>          return -1;
> @@ -654,12 +656,6 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
>          size = sizeof(min_buf);
>      }
>  
> -    if (size > s->rxbuf_size) {
> -        DBGOUT(RX, "packet too large for buffers (%lu > %d)\n",
> -               (unsigned long)size, s->rxbuf_size);
> -        return -1;
> -    }
> -
>      if (!receive_filter(s, buf, size))
>          return size;
>  
> @@ -672,8 +668,15 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
>      }
>  
>      rdh_start = s->mac_reg[RDH];
> +    desc_offset = 0;
>      do {
> +        desc_size = size - desc_offset;
> +        if (desc_size > s->rxbuf_size) {
> +            desc_size = s->rxbuf_size;
> +        }
>          if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {
> +            /* Discard all data written so far */
> +            s->mac_reg[RDH] = rdh_start;
>              set_ics(s, 0, E1000_ICS_RXO);
>              return -1;
>          }
> @@ -684,9 +687,15 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
>          desc.status |= (vlan_status | E1000_RXD_STAT_DD);
>          if (desc.buffer_addr) {
>              cpu_physical_memory_write(le64_to_cpu(desc.buffer_addr),
> -                                      (void *)(buf + vlan_offset), size);
> -            desc.length = cpu_to_le16(size + fcs_len(s));
> -            desc.status |= E1000_RXD_STAT_EOP|E1000_RXD_STAT_IXSM;
> +                                      (void *)(buf + desc_offset + vlan_offset),
> +                                      desc_size);
> +            desc_offset += desc_size;
> +            if (desc_offset >= size) {
> +                desc.length = cpu_to_le16(desc_size + fcs_len(s));

I think this is not quite right: What happens if desc_size + fcs_len(s)
> s->rxbuf_size? IIUC, we would seemingly overflow the guests buffer (in
reality we leave the extra bytes untouched, but we may confuse the guest).

Kevin

  parent reply	other threads:[~2011-02-08 14:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03 16:49 [Qemu-devel] [PATCHv2] e1000: multi-buffer packet support Michael S. Tsirkin
2011-02-03 17:11 ` [Qemu-devel] " Alex Williamson
2011-02-04  6:20 ` [Qemu-devel] " Stefan Hajnoczi
2011-02-08 14:07 ` Kevin Wolf [this message]
2011-02-08 16:02   ` 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=4D514E3E.6020704@redhat.com \
    --to=kwolf@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=agraf@suse.de \
    --cc=alex.williamson@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.