From 4f1c942b7fb29864ad86cb3af9076da38f38f74e Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 18 May 2009 13:40:55 +0100 Subject: 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 --- hw/etraxfs_eth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'hw/etraxfs_eth.c') diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index 78af76b..c7df44e 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -501,7 +501,7 @@ static int eth_can_receive(VLANClientState *vc) return 1; } -static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) +static ssize_t eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) { unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct fs_eth *eth = vc->opaque; @@ -510,7 +510,7 @@ static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) int r_bcast = eth->regs[RW_REC_CTRL] & 8; if (size < 12) - return; + return -1; D(printf("%x.%x.%x.%x.%x.%x ma=%d %d bc=%d\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], @@ -521,10 +521,12 @@ static void eth_receive(VLANClientState *vc, const uint8_t *buf, size_t size) && (!use_ma1 || memcmp(buf, eth->macaddr[1], 6)) && (!r_bcast || memcmp(buf, sa_bcast, 6)) && !eth_match_groupaddr(eth, buf)) - return; + return size; /* FIXME: Find another way to pass on the fake csum. */ etraxfs_dmac_input(eth->dma_in, (void *)buf, size + 4, 1); + + return size; } static int eth_tx_push(void *opaque, unsigned char *buf, int len) -- cgit v1.1