aboutsummaryrefslogtreecommitdiff
path: root/hw/e1000.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-03-27 13:37:35 +0200
committerMichael S. Tsirkin <mst@redhat.com>2011-03-28 18:34:23 +0200
commit6cdfab2868dd593902e2b7db3ba9f49f2cc03e3f (patch)
treecbf07b58f482ef8a63b9d47e52b198ebb6b1e0fb /hw/e1000.c
parent89c473fd82daf7dddad8162a683bcd0ef671ecda (diff)
e1000: check buffer availability
Reduce spurious packet drops on RX ring empty by verifying that we have at least 1 buffer ahead of the time. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/e1000.c')
-rw-r--r--hw/e1000.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 2a4d5c726c..55daae0eba 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -625,14 +625,6 @@ e1000_set_link_status(VLANClientState *nc)
set_ics(s, 0, E1000_ICR_LSC);
}
-static int
-e1000_can_receive(VLANClientState *nc)
-{
- E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
-
- return (s->mac_reg[RCTL] & E1000_RCTL_EN);
-}
-
static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
{
int bufs;
@@ -651,6 +643,14 @@ static bool e1000_has_rxbufs(E1000State *s, size_t total_size)
return total_size <= bufs * s->rxbuf_size;
}
+static int
+e1000_can_receive(VLANClientState *nc)
+{
+ E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;
+
+ return (s->mac_reg[RCTL] & E1000_RCTL_EN) && e1000_has_rxbufs(s, 1);
+}
+
static ssize_t
e1000_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
{