From: Michael Weiser <michael.weiser@gmx.de>
To: netdev@vger.kernel.org
Cc: Michael Weiser <michael.weiser@gmx.de>,
Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: [PATCH 3/3] net: ethernet: sun4i-emac: Read rxhdr in CPU byte-order
Date: Mon, 14 Nov 2016 18:58:07 +0100 [thread overview]
Message-ID: <20161114175807.4747-4-michael.weiser@gmx.de> (raw)
In-Reply-To: <20161114175807.4747-1-michael.weiser@gmx.de>
The EMAC EMAC_RX_IO_DATA_REG data register is dual-purpose: On one hand
it is used to move actual packet data off the wire. This will be in
wire-format and accepted as such by higher layers such as IP. Therefore
it is correctly read as-is (i.e. raw) using readsl.
On the other hand it provides metadata about incoming transfers to the
driver such as length and checksum validation status. This data is
little-endian, always and it is interpreted by the driver. Therefore it
needs to be swapped to CPU endianness to make sense to the driver. This
is already done for the "receive header" but not rxhdr.
Read rxhdr using readl in order for sun4i-emac to work correctly when
running a big-endian kernel.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: netdev@vger.kernel.org
---
drivers/net/ethernet/allwinner/sun4i-emac.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index cd08885..87d0b87 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -592,8 +592,7 @@ static void emac_rx(struct net_device *dev)
/* A packet ready now & Get status/length */
good_packet = true;
- emac_inblk_32bit(db->membase + EMAC_RX_IO_DATA_REG,
- &rxhdr, sizeof(rxhdr));
+ rxhdr = readl(db->membase + EMAC_RX_IO_DATA_REG);
if (netif_msg_rx_status(db))
dev_dbg(db->dev, "rxhdr: %x\n", *((int *)(&rxhdr)));
--
2.9.3 (Apple Git-75)
next prev parent reply other threads:[~2016-11-14 19:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-14 17:58 [PATCH 0/3 v5] Fixes for running a big-endian kernel on Cubieboard2 Michael Weiser
2016-11-14 17:58 ` [PATCH 1/3] net: ethernet: stmmac: change dma descriptors to __le32 Michael Weiser
2016-11-14 17:58 ` [PATCH 2/3] net: ethernet: sun4i-emac: Allow to enable netif messages Michael Weiser
2016-11-14 19:00 ` Maxime Ripard
2016-11-14 17:58 ` Michael Weiser [this message]
2016-11-14 18:59 ` [PATCH 3/3] net: ethernet: sun4i-emac: Read rxhdr in CPU byte-order Maxime Ripard
2016-11-16 3:06 ` [PATCH 0/3 v5] Fixes for running a big-endian kernel on Cubieboard2 David Miller
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=20161114175807.4747-4-michael.weiser@gmx.de \
--to=michael.weiser@gmx.de \
--cc=maxime.ripard@free-electrons.com \
--cc=netdev@vger.kernel.org \
/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).