From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: <netdev@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>, <davem@davemloft.net>,
<havard@skinnemoen.net>, <nicolas.ferre@atmel.com>,
<plagnioj@jcrosoft.com>, <jamie@jamieiles.com>,
<linux-kernel@vger.kernel.org>, <patrice.vilchez@atmel.com>
Subject: [PATCH 10/10] net/macb: Offset first RX buffer by two bytes
Date: Wed, 5 Sep 2012 11:04:06 +0200 [thread overview]
Message-ID: <68a0e4baf2ace47c04874f1918a3bd5f1e5784dc.1346775479.git.nicolas.ferre@atmel.com> (raw)
In-Reply-To: <cover.1346775479.git.nicolas.ferre@atmel.com>
From: Havard Skinnemoen <havard@skinnemoen.net>
Make the ethernet frame payload word-aligned, possibly making the
memcpy into the skb a bit faster. This will be even more important
after we eliminate the copy altogether.
Also eliminate the redundant RX_OFFSET constant -- it has the same
definition and purpose as NET_IP_ALIGN.
Signed-off-by: Havard Skinnemoen <havard@skinnemoen.net>
[nicolas.ferre@atmel.com: adapt to newer kernel]
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
drivers/net/ethernet/cadence/macb.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index f31c0a7..f7716b6 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -33,9 +33,6 @@
#define RX_RING_SIZE 512
#define RX_RING_BYTES (sizeof(struct macb_dma_desc) * RX_RING_SIZE)
-/* Make the IP header word-aligned (the ethernet header is 14 bytes) */
-#define RX_OFFSET 2
-
#define TX_RING_SIZE 128
#define TX_RING_BYTES (sizeof(struct macb_dma_desc) * TX_RING_SIZE)
@@ -466,7 +463,7 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
{
unsigned int len;
unsigned int frag;
- unsigned int offset = 0;
+ unsigned int offset;
struct sk_buff *skb;
struct macb_dma_desc *desc;
@@ -477,7 +474,16 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
macb_rx_ring_wrap(first_frag),
macb_rx_ring_wrap(last_frag), len);
- skb = netdev_alloc_skb(bp->dev, len + RX_OFFSET);
+ /*
+ * The ethernet header starts NET_IP_ALIGN bytes into the
+ * first buffer. Since the header is 14 bytes, this makes the
+ * payload word-aligned.
+ *
+ * Instead of calling skb_reserve(NET_IP_ALIGN), we just copy
+ * the two padding bytes into the skb so that we avoid hitting
+ * the slowpath in memcpy(), and pull them off afterwards.
+ */
+ skb = netdev_alloc_skb(bp->dev, len + NET_IP_ALIGN);
if (!skb) {
bp->stats.rx_dropped++;
for (frag = first_frag; ; frag++) {
@@ -493,7 +499,8 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
return 1;
}
- skb_reserve(skb, RX_OFFSET);
+ offset = 0;
+ len += NET_IP_ALIGN;
skb_checksum_none_assert(skb);
skb_put(skb, len);
@@ -517,10 +524,11 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
/* Make descriptor updates visible to hardware */
wmb();
+ __skb_pull(skb, NET_IP_ALIGN);
skb->protocol = eth_type_trans(skb, bp->dev);
bp->stats.rx_packets++;
- bp->stats.rx_bytes += len;
+ bp->stats.rx_bytes += skb->len;
netdev_vdbg(bp->dev, "received skb of length %u, csum: %08x\n",
skb->len, skb->csum);
netif_receive_skb(skb);
@@ -985,6 +993,7 @@ static void macb_init_hw(struct macb *bp)
__macb_set_hwaddr(bp);
config = macb_mdc_clk_div(bp);
+ config |= MACB_BF(RBOF, NET_IP_ALIGN); /* Make eth data aligned */
config |= MACB_BIT(PAE); /* PAuse Enable */
config |= MACB_BIT(DRFCS); /* Discard Rx FCS */
config |= MACB_BIT(BIG); /* Receive oversized frames */
--
1.7.10
prev parent reply other threads:[~2012-09-05 9:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:19 [PATCH 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup Nicolas Ferre
2012-09-05 8:19 ` [PATCH 01/10] net/macb: Add support for Gigabit Ethernet mode Nicolas Ferre
2012-09-05 8:19 ` [PATCH 02/10] net/macb: memory barriers cleanup Nicolas Ferre
2012-09-05 8:19 ` [PATCH 03/10] net/macb: change debugging messages Nicolas Ferre
2012-09-05 8:19 ` [PATCH 04/10] net/macb: Fix a race in macb_start_xmit() Nicolas Ferre
2012-09-05 21:30 ` David Miller
2012-09-06 14:52 ` Nicolas Ferre
2012-09-06 15:49 ` Havard Skinnemoen
2012-09-07 16:34 ` Nicolas Ferre
2012-09-05 9:00 ` [PATCH 05/10] net/macb: clean up ring buffer logic Nicolas Ferre
2012-09-05 9:00 ` [PATCH 06/10] net/macb: better manage tx errors Nicolas Ferre
2012-09-05 9:00 ` [PATCH 07/10] net/macb: tx status is more than 8 bits now Nicolas Ferre
2012-09-05 9:00 ` [PATCH 08/10] net/macb: macb_get_drvinfo: add GEM/MACB suffix to differentiate revision Nicolas Ferre
2012-09-05 21:31 ` David Miller
2012-09-05 23:27 ` Ben Hutchings
2012-09-06 14:01 ` Nicolas Ferre
2012-09-06 17:42 ` David Miller
2012-09-05 9:00 ` [PATCH 09/10] net/macb: ethtool interface: add register dump feature Nicolas Ferre
2012-09-05 21:32 ` David Miller
2012-09-05 23:36 ` Ben Hutchings
2012-09-06 14:20 ` [PATCH v2 " Nicolas Ferre
2012-09-06 14:34 ` Ben Hutchings
2012-09-05 9:04 ` Nicolas Ferre [this message]
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=68a0e4baf2ace47c04874f1918a3bd5f1e5784dc.1346775479.git.nicolas.ferre@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=davem@davemloft.net \
--cc=havard@skinnemoen.net \
--cc=jamie@jamieiles.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=patrice.vilchez@atmel.com \
--cc=plagnioj@jcrosoft.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).