summaryrefslogtreecommitdiff
path: root/hw/smc91c111.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/smc91c111.c
parente3f5ec2b5e92706e3b807059f79b1fb5d936e567 (diff)
downloadqemu-4f1c942b7fb29864ad86cb3af9076da38f38f74e.tar.gz
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/smc91c111.c')
-rw-r--r--hw/smc91c111.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hw/smc91c111.c b/hw/smc91c111.c
index 383f0b7daa..93a1fae0dc 100644
--- a/hw/smc91c111.c
+++ b/hw/smc91c111.c
@@ -602,7 +602,7 @@ static int smc91c111_can_receive(VLANClientState *vc)
return 1;
}
-static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
+static ssize_t smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t size)
{
smc91c111_state *s = vc->opaque;
int status;
@@ -612,7 +612,7 @@ static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t si
uint8_t *p;
if ((s->rcr & RCR_RXEN) == 0 || (s->rcr & RCR_SOFT_RST))
- return;
+ return -1;
/* Short packets are padded with zeros. Receiving a packet
< 64 bytes long is considered an error condition. */
if (size < 64)
@@ -625,10 +625,10 @@ static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t si
packetsize += 4;
/* TODO: Flag overrun and receive errors. */
if (packetsize > 2048)
- return;
+ return -1;
packetnum = smc91c111_allocate_packet(s);
if (packetnum == 0x80)
- return;
+ return -1;
s->rx_fifo[s->rx_fifo_len++] = packetnum;
p = &s->data[packetnum][0];
@@ -676,6 +676,8 @@ static void smc91c111_receive(VLANClientState *vc, const uint8_t *buf, size_t si
/* TODO: Raise early RX interrupt? */
s->int_level |= INT_RCV;
smc91c111_update(s);
+
+ return size;
}
static CPUReadMemoryFunc *smc91c111_readfn[] = {