Message ID | 20241112181044.92193-11-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | hw/net/xilinx_ethlite: Map RAM buffers as RAM and remove tswap() calls | expand |
On Tue, Nov 12, 2024 at 07:10:34PM +0100, Philippe Mathieu-Daudé wrote: > rxbuf_ptr() points to the beginning of a (RAM) RX buffer > within the device state. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com> > --- > hw/net/xilinx_ethlite.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c > index d4882f43f7..fdbf25fd91 100644 > --- a/hw/net/xilinx_ethlite.c > +++ b/hw/net/xilinx_ethlite.c > @@ -99,6 +99,13 @@ static void *txbuf_ptr(XlnxXpsEthLite *s, unsigned port_index) > return &s->regs[rxbase + R_TX_BUF0]; > } > > +static void *rxbuf_ptr(XlnxXpsEthLite *s, unsigned port_index) > +{ > + unsigned int rxbase = port_index * (0x800 / 4); > + > + return &s->regs[rxbase + R_RX_BUF0]; > +} > + > static uint64_t > eth_read(void *opaque, hwaddr addr, unsigned int size) > { > @@ -220,7 +227,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) > trace_ethlite_pkt_size_too_big(size); > return -1; > } > - memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size); > + memcpy(rxbuf_ptr(s, port_index), buf, size); > > s->regs[rxbase + R_RX_CTRL0] |= CTRL_S; > if (s->regs[R_RX_CTRL0] & CTRL_I) { > -- > 2.45.2 >
diff --git a/hw/net/xilinx_ethlite.c b/hw/net/xilinx_ethlite.c index d4882f43f7..fdbf25fd91 100644 --- a/hw/net/xilinx_ethlite.c +++ b/hw/net/xilinx_ethlite.c @@ -99,6 +99,13 @@ static void *txbuf_ptr(XlnxXpsEthLite *s, unsigned port_index) return &s->regs[rxbase + R_TX_BUF0]; } +static void *rxbuf_ptr(XlnxXpsEthLite *s, unsigned port_index) +{ + unsigned int rxbase = port_index * (0x800 / 4); + + return &s->regs[rxbase + R_RX_BUF0]; +} + static uint64_t eth_read(void *opaque, hwaddr addr, unsigned int size) { @@ -220,7 +227,7 @@ static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size) trace_ethlite_pkt_size_too_big(size); return -1; } - memcpy(&s->regs[rxbase + R_RX_BUF0], buf, size); + memcpy(rxbuf_ptr(s, port_index), buf, size); s->regs[rxbase + R_RX_CTRL0] |= CTRL_S; if (s->regs[R_RX_CTRL0] & CTRL_I) {
rxbuf_ptr() points to the beginning of a (RAM) RX buffer within the device state. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/net/xilinx_ethlite.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)