From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: qemu-arm@nongnu.org
Cc: "Andrey Smirnov" <andrew.smirnov@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Jason Wang" <jasowang@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
qemu-devel@nongnu.org, yurovsky@gmail.com
Subject: [Qemu-devel] [PATCH v2 07/15] imx_fec: Emulate SHIFT16 in ENETx_RACC
Date: Thu, 14 Dec 2017 06:52:47 -0800 [thread overview]
Message-ID: <20171214145255.31545-8-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20171214145255.31545-1-andrew.smirnov@gmail.com>
Needed to support latest Linux kernel driver which relies on that
functionality.
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
Cc: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Cc: yurovsky@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
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 6feda18742..825c879a28 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,
uint8_t *crc_ptr;
unsigned int buf_len;
size_t size = len;
+ bool shift16 = s->regs[ENET_RACC] & ENET_RACC_SHIFT16;
FEC_PRINTF("len %d\n", (int)size);
@@ -1051,6 +1052,10 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
crc = cpu_to_be32(crc32(~0, buf, size));
crc_ptr = (uint8_t *) &crc;
+ if (shift16) {
+ size += 2;
+ }
+
/* Huge frames are truncted. */
if (size > s->regs[ENET_FTRL]) {
size = s->regs[ENET_FTRL];
@@ -1087,6 +1092,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);
+
+ /* We only do this once per Ethernet frame */
+ shift16 = false;
+ }
+
dma_memory_write(&address_space_memory, buf_addr, buf, buf_len);
buf += buf_len;
if (size < 4) {
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
index a390d704a6..af0840a0fa 100644
--- a/include/hw/net/imx_fec.h
+++ b/include/hw/net/imx_fec.h
@@ -170,6 +170,8 @@
#define ENET_TWFR_TFWR_LENGTH (6)
#define ENET_TWFR_STRFWD (1 << 8)
+#define ENET_RACC_SHIFT16 BIT(7)
+
/* Buffer Descriptor. */
typedef struct {
uint16_t length;
--
2.14.3
next prev parent reply other threads:[~2017-12-14 14:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 14:52 [Qemu-devel] [PATCH v2 00/15] i.MX FEC and SD changes Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 01/15] imx_fec: Do not link to netdev Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 02/15] imx_fec: Refactor imx_eth_enable_rx() Andrey Smirnov
2017-12-15 10:06 ` Philippe Mathieu-Daudé
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 03/15] imx_fec: Change queue flushing heuristics Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 04/15] imx_fec: Move Tx frame buffer away from the stack Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 05/15] imx_fec: Use ENET_FTRL to determine truncation length Andrey Smirnov
2017-12-15 10:15 ` Philippe Mathieu-Daudé
2017-12-17 0:41 ` Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 06/15] imx_fec: Use MIN instead of explicit ternary operator Andrey Smirnov
2017-12-14 14:52 ` Andrey Smirnov [this message]
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 08/15] imx_fec: Add support for multiple Tx DMA rings Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 09/15] imx_fec: Use correct length for packet size Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 10/15] imx_fec: Fix a typo in imx_enet_receive() Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 11/15] imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 12/15] sdhci: Add i.MX specific subtype of SDHCI Andrey Smirnov
2017-12-15 2:31 ` Philippe Mathieu-Daudé
2017-12-15 18:51 ` Andrey Smirnov
2017-12-15 20:15 ` Philippe Mathieu-Daudé
2017-12-17 0:21 ` Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 13/15] hw: i.MX: Convert i.MX6 to use TYPE_IMX_USDHC Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 14/15] sd: Check for READ_MULTIPLE_BLOCK size limit violation first Andrey Smirnov
2017-12-14 16:45 ` Andrey Smirnov
2017-12-14 14:52 ` [Qemu-devel] [PATCH v2 15/15] sdhci: Implement write method of ACMD12ERRSTS register Andrey Smirnov
2017-12-15 2:18 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171214145255.31545-8-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yurovsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).