提交 d48751ed 编写于 作者: E Edgar E. Iglesias

xilinx-ethlite: Simplify byteswapping to/from brams

Signed-off-by: NEdgar E. Iglesias <edgar.iglesias@petalogix.com>
上级 b651fc6f
...@@ -90,13 +90,8 @@ static uint32_t eth_readl (void *opaque, target_phys_addr_t addr) ...@@ -90,13 +90,8 @@ static uint32_t eth_readl (void *opaque, target_phys_addr_t addr)
D(qemu_log("%s %x=%x\n", __func__, addr * 4, r)); D(qemu_log("%s %x=%x\n", __func__, addr * 4, r));
break; break;
/* Rx packet data is endian fixed at the way into the rx rams. This
* speeds things up because the ethlite MAC does not have a len
* register. That means the CPU will issue MMIO reads for the entire
* 2k rx buffer even for small packets.
*/
default: default:
r = s->regs[addr]; r = tswap32(s->regs[addr]);
break; break;
} }
return r; return r;
...@@ -145,9 +140,8 @@ eth_writel (void *opaque, target_phys_addr_t addr, uint32_t value) ...@@ -145,9 +140,8 @@ eth_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
s->regs[addr] = value; s->regs[addr] = value;
break; break;
/* Packet data, make sure it stays BE. */
default: default:
s->regs[addr] = cpu_to_be32(value); s->regs[addr] = tswap32(value);
break; break;
} }
} }
...@@ -172,7 +166,6 @@ static ssize_t eth_rx(VLANClientState *nc, const uint8_t *buf, size_t size) ...@@ -172,7 +166,6 @@ static ssize_t eth_rx(VLANClientState *nc, const uint8_t *buf, size_t size)
{ {
struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque; struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque;
unsigned int rxbase = s->rxbuf * (0x800 / 4); unsigned int rxbase = s->rxbuf * (0x800 / 4);
int i;
/* DA filter. */ /* DA filter. */
if (!(buf[0] & 0x80) && memcmp(&s->conf.macaddr.a[0], buf, 6)) if (!(buf[0] & 0x80) && memcmp(&s->conf.macaddr.a[0], buf, 6))
...@@ -186,12 +179,6 @@ static ssize_t eth_rx(VLANClientState *nc, const uint8_t *buf, size_t size) ...@@ -186,12 +179,6 @@ static ssize_t eth_rx(VLANClientState *nc, const uint8_t *buf, size_t size)
D(qemu_log("%s %d rxbase=%x\n", __func__, size, rxbase)); D(qemu_log("%s %d rxbase=%x\n", __func__, size, rxbase));
memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size); memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size);
/* Bring it into host endianess. */
for (i = 0; i < ((size + 3) / 4); i++) {
uint32_t d = s->regs[rxbase + R_RX_BUF0 + i];
s->regs[rxbase + R_RX_BUF0 + i] = be32_to_cpu(d);
}
s->regs[rxbase + R_RX_CTRL0] |= CTRL_S; s->regs[rxbase + R_RX_CTRL0] |= CTRL_S;
if (s->regs[rxbase + R_RX_CTRL0] & CTRL_I) if (s->regs[rxbase + R_RX_CTRL0] & CTRL_I)
eth_pulse_irq(s); eth_pulse_irq(s);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册