linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: cyrille.pitchen@atmel.com (Cyrille Pitchen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] net/macb: add RX checksum offload feature
Date: Fri, 18 Jul 2014 16:21:16 +0200	[thread overview]
Message-ID: <f29965fee23dc0de99b388373017efeffa1aac10.1405689937.git.cyrille.pitchen@atmel.com> (raw)
In-Reply-To: <cover.1405689937.git.cyrille.pitchen@atmel.com>

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
---
 drivers/net/ethernet/cadence/macb.c | 29 ++++++++++++++++++++++++++++-
 drivers/net/ethernet/cadence/macb.h |  2 ++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 9bdcd1b..6acd6e2 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -766,6 +766,8 @@ static int gem_rx(struct macb *bp, int budget)
 
 		skb->protocol = eth_type_trans(skb, bp->dev);
 		skb_checksum_none_assert(skb);
+		if (bp->dev->features & NETIF_F_RXCSUM)
+			skb->ip_summed = CHECKSUM_UNNECESSARY;
 
 		bp->stats.rx_packets++;
 		bp->stats.rx_bytes += skb->len;
@@ -1506,6 +1508,18 @@ static u32 macb_dbw(struct macb *bp)
 }
 
 /*
+ * Configure the RX checksum offload
+ */
+static u32 macb_rxcsum(struct macb *bp)
+{
+	if (macb_is_gem(bp) &&
+	    (bp->dev->features & NETIF_F_RXCSUM))
+		return GEM_BIT(RXCOEN);
+
+	return 0;
+}
+
+/*
  * Configure the receive DMA engine
  * - use the correct receive buffer size
  * - set best burst length for DMA operations
@@ -1550,6 +1564,7 @@ static void macb_init_hw(struct macb *bp)
 	if (!(bp->dev->flags & IFF_BROADCAST))
 		config |= MACB_BIT(NBC);	/* No BroadCast */
 	config |= macb_dbw(bp);
+	config |= macb_rxcsum(bp);
 	macb_writel(bp, NCFGR, config);
 	bp->speed = SPEED_10;
 	bp->duplex = DUPLEX_HALF;
@@ -1945,6 +1960,18 @@ static int macb_set_features(struct net_device *netdev,
 		gem_writel(bp, DMACFG, dmacfg);
 	}
 
+	/* RX checksum offload */
+	if ((changed & NETIF_F_RXCSUM) && macb_is_gem(bp)) {
+		u32 netcfg;
+
+		netcfg = gem_readl(bp, NCFGR);
+		if (features & NETIF_F_RXCSUM)
+			netcfg |= GEM_BIT(RXCOEN);
+		else
+			netcfg &= ~GEM_BIT(RXCOEN);
+		gem_writel(bp, NCFGR, netcfg);
+	}
+
 	return 0;
 }
 
@@ -2146,7 +2173,7 @@ static int __init macb_probe(struct platform_device *pdev)
 	dev->hw_features = NETIF_F_SG;
 	if (macb_is_gem(bp) && !(bp->caps & MACB_CAPS_FIFO_MODE)) {
 		/* Checksum offload is only available on packet buffer design */
-		dev->hw_features |= NETIF_F_HW_CSUM;
+		dev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
 	}
 	if (bp->caps & MACB_CAPS_SG_DISABLED)
 		dev->hw_features &= ~NETIF_F_SG;
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h
index 7bf8285..3678b83 100644
--- a/drivers/net/ethernet/cadence/macb.h
+++ b/drivers/net/ethernet/cadence/macb.h
@@ -164,6 +164,8 @@
 #define GEM_CLK_SIZE				3
 #define GEM_DBW_OFFSET				21
 #define GEM_DBW_SIZE				2
+#define GEM_RXCOEN_OFFSET			24
+#define GEM_RXCOEN_SIZE				1
 
 /* Constants for data bus width. */
 #define GEM_DBW32				0
-- 
1.8.2.2

  parent reply	other threads:[~2014-07-18 14:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 14:21 [PATCH 0/6] net/macb: add HW features to macb driver Cyrille Pitchen
2014-07-18 14:21 ` [PATCH 1/6] net/macb: configure for FIFO mode and non-gigabit Cyrille Pitchen
2014-07-21  4:12   ` David Miller
2014-07-18 14:21 ` [PATCH 2/6] net/macb: add scatter-gather hw feature Cyrille Pitchen
2014-07-21  4:13   ` David Miller
2014-07-23  7:45     ` Cyrille Pitchen
2014-07-18 14:21 ` [PATCH 3/6] net/macb: add TX checksum offload feature Cyrille Pitchen
2014-07-18 14:21 ` Cyrille Pitchen [this message]
2014-07-18 15:36   ` [PATCH 4/6] net/macb: add RX " Eric Dumazet
2014-07-22 16:27     ` Cyrille Pitchen
2014-07-22 16:39       ` Florian Fainelli
2014-07-22 22:58       ` Eric Dumazet
2014-07-24 11:59         ` Cyrille Pitchen
2014-07-18 14:32 ` [PATCH 5/6] ARM: at91: change compatibility string for sama5d3x gem Cyrille Pitchen
2014-07-18 14:32 ` [PATCH 6/6] net/macb: enable scatter-gather feature and set DMA burst length for sama5d4 gem Cyrille Pitchen

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=f29965fee23dc0de99b388373017efeffa1aac10.1405689937.git.cyrille.pitchen@atmel.com \
    --to=cyrille.pitchen@atmel.com \
    --cc=linux-arm-kernel@lists.infradead.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).