aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2010-07-26 08:05:27 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2010-07-26 08:05:27 -0500
commit7ed6184bf24dffe81e767ab449f90247bb38e204 (patch)
tree3d33efd6db0d79aa45d59329f17454b296fb12aa /hw
parentcdcf9153e5e17dde340135fee5dcc7c299f2d4f5 (diff)
parentd154e0bafbd51bfd029ade9f1362bdff612b0f55 (diff)
Merge remote branch 'mst/for_anthony' into staging
Diffstat (limited to 'hw')
-rw-r--r--hw/e1000.c12
-rw-r--r--hw/vhost.c21
2 files changed, 21 insertions, 12 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index db9143d2bc..80b78bc618 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -343,6 +343,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)
{
@@ -648,7 +657,6 @@ e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
}
rdh_start = s->mac_reg[RDH];
- size += 4; // for the header
do {
if (s->mac_reg[RDH] == s->mac_reg[RDT] && s->check_rxov) {
set_ics(s, 0, E1000_ICS_RXO);
@@ -662,7 +670,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);
+ 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");
diff --git a/hw/vhost.c b/hw/vhost.c
index d37a66e0ea..65709d005d 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -659,6 +659,16 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
r = -errno;
goto fail;
}
+ for (i = 0; i < hdev->nvqs; ++i) {
+ r = vhost_virtqueue_init(hdev,
+ vdev,
+ hdev->vqs + i,
+ i);
+ if (r < 0) {
+ goto fail_vq;
+ }
+ }
+
if (hdev->log_enabled) {
hdev->log_size = vhost_get_log_size(hdev);
hdev->log = hdev->log_size ?
@@ -667,19 +677,10 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
(uint64_t)(unsigned long)hdev->log);
if (r < 0) {
r = -errno;
- goto fail;
- }
- }
-
- for (i = 0; i < hdev->nvqs; ++i) {
- r = vhost_virtqueue_init(hdev,
- vdev,
- hdev->vqs + i,
- i);
- if (r < 0) {
goto fail_vq;
}
}
+
hdev->started = true;
return 0;