From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49437 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYPUO-0005RE-6Q for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:20:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYPUM-0003zp-Tz for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:20:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37840) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYPUM-0003zh-MU for qemu-devel@nongnu.org; Mon, 12 Jul 2010 16:20:30 -0400 From: Alex Williamson In-Reply-To: <20100712174945.GA11440@redhat.com> References: <20100712174945.GA11440@redhat.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 12 Jul 2010 14:20:25 -0600 Message-ID: <1278966025.20397.243.camel@x201> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH RFC] e1000: secrc support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org On Mon, 2010-07-12 at 20:49 +0300, Michael S. Tsirkin wrote: > Add support for secrc field. Reportedly needed by old RHEL guests. > > Signed-off-by: Michael S. Tsirkin > --- > hw/e1000.c | 11 ++++++++++- > 1 files changed, 10 insertions(+), 1 deletions(-) > > Anthony, Alex, please review. Acked-by: Alex Williamson > diff --git a/hw/e1000.c b/hw/e1000.c > index 70aba11..8d87492 100644 > --- a/hw/e1000.c > +++ b/hw/e1000.c > @@ -344,6 +344,15 @@ is_vlan_txd(uint32_t txd_lower) > return ((txd_lower & E1000_TXD_CMD_VLE) != 0); > } > > +/* FCS aka Ethernet CRC-32. We don't get it from backends and can't > + * fill it in, just pad descriptor length by 4 bytes unless guest > + * told us to trip it off the packet. */ > +static inline int > +fcs_len(E1000State *s) > +{ > + return (s->mac_reg[RCTL] & E1000_RCTL_SECRC) ? 0 : 4; > +} > + > static void > xmit_seg(E1000State *s) > { > @@ -662,7 +671,7 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size) > 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 + 4 /* for FCS */); > + desc.length = cpu_to_le16(size + fcs_len(s)); > desc.status |= E1000_RXD_STAT_EOP|E1000_RXD_STAT_IXSM; > } else // as per intel docs; skip descriptors with null buf addr > DBGOUT(RX, "Null RX descriptor!!\n");