diff options
author | Peter Crosthwaite <peter.crosthwaite@xilinx.com> | 2013-12-03 21:56:15 -0800 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2013-12-10 13:28:50 +0000 |
commit | 7cfd65e41c51cd8a55730524af750638cd416f95 (patch) | |
tree | f6450cc9d610a2f2a5f3f7a13ab0d1494951ec41 | |
parent | 11785f5352d45c6ef3efe3349ade42387ccebd5d (diff) | |
download | qemu-7cfd65e41c51cd8a55730524af750638cd416f95.zip qemu-7cfd65e41c51cd8a55730524af750638cd416f95.tar.gz qemu-7cfd65e41c51cd8a55730524af750638cd416f95.tar.bz2 |
net/cadence_gem: simplify rx buf descriptor walking
There was a replication of the rx descriptor address walking logic.
Reorder the flow control to remove. This refactoring also obsoletes
the local variables packet_desc_addr and last_desc_addr.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 2a425b457ff0b57274bf206ad2236690cd7f5909.1386136219.git.peter.crosthwaite@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/net/cadence_gem.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index b0f3dba..69ad87e 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -586,7 +586,6 @@ static int gem_mac_address_filter(GemState *s, const uint8_t *packet) static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) { unsigned desc[2]; - hwaddr packet_desc_addr, last_desc_addr; GemState *s; unsigned rxbufsize, bytes_to_copy; unsigned rxbuf_offset; @@ -667,17 +666,16 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) DB_PRINT("config bufsize: %d packet size: %ld\n", rxbufsize, size); - packet_desc_addr = s->rx_desc_addr; - while (1) { - DB_PRINT("read descriptor 0x%x\n", (unsigned)packet_desc_addr); + while (bytes_to_copy) { + DB_PRINT("read descriptor 0x%x\n", (unsigned)s->rx_desc_addr); /* read current descriptor */ - cpu_physical_memory_read(packet_desc_addr, + cpu_physical_memory_read(s->rx_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); /* Descriptor owned by software ? */ if (rx_desc_get_ownership(desc) == 1) { DB_PRINT("descriptor 0x%x owned by sw.\n", - (unsigned)packet_desc_addr); + (unsigned)s->rx_desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; s->regs[GEM_ISR] |= GEM_INT_RXUSED & ~(s->regs[GEM_IMR]); /* Handle interrupt consequences */ @@ -705,36 +703,19 @@ static ssize_t gem_receive(NetClientState *nc, const uint8_t *buf, size_t size) } rx_desc_set_ownership(desc); /* Descriptor write-back. */ - cpu_physical_memory_write(packet_desc_addr, + cpu_physical_memory_write(s->rx_desc_addr, (uint8_t *)&desc[0], sizeof(desc)); - if (bytes_to_copy == 0) { - break; - } - /* Next descriptor */ if (rx_desc_get_wrap(desc)) { - packet_desc_addr = s->regs[GEM_RXQBASE]; + DB_PRINT("wrapping RX descriptor list\n"); + s->rx_desc_addr = s->regs[GEM_RXQBASE]; } else { - packet_desc_addr += 8; + DB_PRINT("incrementing RX descriptor list\n"); + s->rx_desc_addr += 8; } } - DB_PRINT("set length: %ld, EOF on descriptor 0x%x\n", size, - (unsigned)packet_desc_addr); - - /* Advance RX packet descriptor Q */ - last_desc_addr = packet_desc_addr; - packet_desc_addr = s->rx_desc_addr; - s->rx_desc_addr = last_desc_addr; - if (rx_desc_get_wrap(desc)) { - s->rx_desc_addr = s->regs[GEM_RXQBASE]; - DB_PRINT("wrapping RX descriptor list\n"); - } else { - DB_PRINT("incrementing RX descriptor list\n"); - s->rx_desc_addr += 8; - } - /* Count it */ gem_receive_updatestats(s, buf, size); |