aboutsummaryrefslogtreecommitdiff
path: root/hw/ne2000.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-05-18 13:40:55 +0100
committerMark McLoughlin <markmc@redhat.com>2009-06-09 11:38:49 +0100
commit4f1c942b7fb29864ad86cb3af9076da38f38f74e (patch)
tree2f51a121e715476c3986c0ae0b4513be555d8ee8 /hw/ne2000.c
parente3f5ec2b5e92706e3b807059f79b1fb5d936e567 (diff)
net: add return value to packet receive handler
This allows us to handle queue full conditions rather than dropping the packet on the floor. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'hw/ne2000.c')
-rw-r--r--hw/ne2000.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/hw/ne2000.c b/hw/ne2000.c
index c0fc34c4b2..f5ae9d7394 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -224,9 +224,10 @@ static int ne2000_can_receive(VLANClientState *vc)
#define MIN_BUF_SIZE 60
-static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
+static ssize_t ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size_)
{
NE2000State *s = vc->opaque;
+ int size = size_;
uint8_t *p;
unsigned int total_len, next, avail, len, index, mcast_idx;
uint8_t buf1[60];
@@ -238,7 +239,7 @@ static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
#endif
if (s->cmd & E8390_STOP || ne2000_buffer_full(s))
- return;
+ return -1;
/* XXX: check this */
if (s->rxcr & 0x10) {
@@ -247,14 +248,14 @@ static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
if (!memcmp(buf, broadcast_macaddr, 6)) {
/* broadcast address */
if (!(s->rxcr & 0x04))
- return;
+ return size;
} else if (buf[0] & 0x01) {
/* multicast */
if (!(s->rxcr & 0x08))
- return;
+ return size;
mcast_idx = compute_mcast_idx(buf);
if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))))
- return;
+ return size;
} else if (s->mem[0] == buf[0] &&
s->mem[2] == buf[1] &&
s->mem[4] == buf[2] &&
@@ -263,7 +264,7 @@ static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
s->mem[10] == buf[5]) {
/* match */
} else {
- return;
+ return size;
}
}
@@ -316,6 +317,8 @@ static void ne2000_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
/* now we can signal we have received something */
s->isr |= ENISR_RX;
ne2000_update_irq(s);
+
+ return size_;
}
static void ne2000_ioport_write(void *opaque, uint32_t addr, uint32_t val)