qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-arm] [PATCH 07/17] imx_fec: Emulate SHIFT16 in ENETx_RACC


From: Peter Maydell
Subject: Re: [Qemu-arm] [PATCH 07/17] imx_fec: Emulate SHIFT16 in ENETx_RACC
Date: Fri, 6 Oct 2017 15:02:41 +0100

On 18 September 2017 at 20:50, Andrey Smirnov <address@hidden> wrote:
> Needed to support latest Linux kernel driver which relies on that
> functionality.
>
> Cc: Peter Maydell <address@hidden>
> Cc: Jason Wang <address@hidden>
> Cc: address@hidden
> Cc: address@hidden
> Cc: address@hidden
> Signed-off-by: Andrey Smirnov <address@hidden>
> ---
>  hw/net/imx_fec.c         | 23 +++++++++++++++++++++++
>  include/hw/net/imx_fec.h |  2 ++
>  2 files changed, 25 insertions(+)
>
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index 8a77136d38..bd62d7a75f 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -1037,6 +1037,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, 
> const uint8_t *buf,
>      uint32_t buf_addr;
>      unsigned int buf_len;
>      size_t size = len;
> +    bool shift16 = s->regs[ENET_RACC] & ENET_RACC_SHIFT16;
>
>      FEC_PRINTF("len %d\n", (int)size);
>
> @@ -1049,6 +1050,10 @@ static ssize_t imx_enet_receive(NetClientState *nc, 
> const uint8_t *buf,
>      /* 4 bytes for the CRC.  */
>      size += 4;
>
> +    if (shift16) {
> +        size += 2;
> +    }
> +
>      /* Huge frames are truncted.  */
>      if (size > s->regs[ENET_FTRL]) {
>          size = s->regs[ENET_FTRL];
> @@ -1085,6 +1090,24 @@ static ssize_t imx_enet_receive(NetClientState *nc, 
> const uint8_t *buf,
>              buf_len += size - 4;
>          }
>          buf_addr = bd.data;
> +
> +        if (shift16) {
> +            /*
> +             * If SHIFT16 bit of ENETx_RACC register is set we need to
> +             * align the payload to 4-byte boundary.
> +             */
> +            const uint8_t zeros[2] = { 0 };
> +
> +            dma_memory_write(&address_space_memory, buf_addr,
> +                             zeros, sizeof(zeros));
> +
> +            buf_addr += sizeof(zeros);
> +            buf_len  -= sizeof(zeros);
> +
> +            shift16 = false; /* We only do this once per Ethernet
> +                              * frame */
> +        }
> +

Can you avoid having an end-of-source-line comment that wraps
to multiple lines, please? (put it on a line of its own, or
edit down to fit.) Otherwise

Reviewed-by: Peter Maydell <address@hidden>

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]