diff mbox

[v1,1/3] xilinx_ethlite: fix eth_can_rx() for ping-pong

Message ID fb1b5d76-55ca-428d-9ca5-a6e172782381@CH1EHSMHS024.ehs.local
State New
Headers show

Commit Message

Peter Crosthwaite Jan. 26, 2013, 8:36 p.m. UTC
The eth_can_rx() function only checks the first buffers status ("ping"). The
controller should be able to receive into "pong" when ping-pong is enabled.
Checks the active buffer (either "ping" or "pong") when determining can_rx()
rather than just testing "ping".

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
 hw/xilinx_ethlite.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Edgar E. Iglesias Jan. 27, 2013, 12:09 a.m. UTC | #1
On Sat, Jan 26, 2013 at 12:36:22PM -0800, Peter Crosthwaite wrote:
> The eth_can_rx() function only checks the first buffers status ("ping"). The
> controller should be able to receive into "pong" when ping-pong is enabled.
> Checks the active buffer (either "ping" or "pong") when determining can_rx()
> rather than just testing "ping".

Ouch, good catch!

Applied the patch

thanks

> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>  hw/xilinx_ethlite.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c
> index 2254851..972b85e 100644
> --- a/hw/xilinx_ethlite.c
> +++ b/hw/xilinx_ethlite.c
> @@ -163,9 +163,9 @@ static const MemoryRegionOps eth_ops = {
>  static int eth_can_rx(NetClientState *nc)
>  {
>      struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque;
> -    int r;
> -    r = !(s->regs[R_RX_CTRL0] & CTRL_S);
> -    return r;
> +    unsigned int rxbase = s->rxbuf * (0x800 / 4);
> +
> +    return !(s->regs[rxbase + R_RX_CTRL0] & CTRL_S);
>  }
>  
>  static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)
> -- 
> 1.7.12.1.396.g16eed7c
> 
>
diff mbox

Patch

diff --git a/hw/xilinx_ethlite.c b/hw/xilinx_ethlite.c
index 2254851..972b85e 100644
--- a/hw/xilinx_ethlite.c
+++ b/hw/xilinx_ethlite.c
@@ -163,9 +163,9 @@  static const MemoryRegionOps eth_ops = {
 static int eth_can_rx(NetClientState *nc)
 {
     struct xlx_ethlite *s = DO_UPCAST(NICState, nc, nc)->opaque;
-    int r;
-    r = !(s->regs[R_RX_CTRL0] & CTRL_S);
-    return r;
+    unsigned int rxbase = s->rxbuf * (0x800 / 4);
+
+    return !(s->regs[rxbase + R_RX_CTRL0] & CTRL_S);
 }
 
 static ssize_t eth_rx(NetClientState *nc, const uint8_t *buf, size_t size)