From 463af5349a787160642f023dad10eaf0cb419fb7 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 18 May 2009 12:55:27 +0100 Subject: net: add fd_readv() handler to qemu_new_vlan_client() args This, apparently, is the style we prefer - all VLANClientState should be an argument to qemu_new_vlan_client(). Signed-off-by: Mark McLoughlin --- hw/etraxfs_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/etraxfs_eth.c') diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index 68b8de38eb..bb612840c1 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -593,7 +593,7 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env, cpu_register_physical_memory (base, 0x5c, eth->ethregs); eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, - eth_receive, eth_can_receive, + eth_can_receive, eth_receive, NULL, eth_cleanup, eth); eth->vc->opaque = eth; eth->vc->link_status_changed = eth_set_link; -- cgit v1.2.3 From cda9046ba7dbba45f3016e5d60caffa2d72960fa Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 18 May 2009 13:13:16 +0100 Subject: net: re-name vc->fd_read() to vc->receive() VLANClientState's fd_read() handler doesn't read from file descriptors, it adds a buffer to the client's receive queue. Re-name the handlers to make things a little less confusing. Signed-off-by: Mark McLoughlin --- hw/etraxfs_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/etraxfs_eth.c') diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index bb612840c1..2446f0dcb9 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -501,7 +501,7 @@ static int eth_can_receive(void *opaque) return 1; } -static void eth_receive(void *opaque, const uint8_t *buf, int size) +static void eth_receive(void *opaque, const uint8_t *buf, size_t size) { unsigned char sa_bcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct fs_eth *eth = opaque; -- cgit v1.2.3 From e3f5ec2b5e92706e3b807059f79b1fb5d936e567 Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Mon, 18 May 2009 13:33:03 +0100 Subject: net: pass VLANClientState* as first arg to receive handlers Give static type checking a chance to catch errors. Signed-off-by: Mark McLoughlin --- hw/etraxfs_eth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'hw/etraxfs_eth.c') diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c index 2446f0dcb9..78af76b9bb 100644 --- a/hw/etraxfs_eth.c +++ b/hw/etraxfs_eth.c @@ -496,15 +496,15 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa) return match; } -static int eth_can_receive(void *opaque) +static int eth_can_receive(VLANClientState *vc) { return 1; } -static void eth_receive(void *opaque, const uint8_t *buf, size_t size) +static void 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 = opaque; + struct fs_eth *eth = vc->opaque; int use_ma0 = eth->regs[RW_REC_CTRL] & 1; int use_ma1 = eth->regs[RW_REC_CTRL] & 2; int r_bcast = eth->regs[RW_REC_CTRL] & 8; -- cgit v1.2.3 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 78af76b9bb..c7df44ee45 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.2.3