From: cyrille.pitchen@atmel.com (Cyrille Pitchen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/6] net/macb: add TX checksum offload feature
Date: Fri, 18 Jul 2014 16:21:15 +0200 [thread overview]
Message-ID: <81148356bc5a52d07c49b18f68833fa7b2f97f2d.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 | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 06e9934..9bdcd1b 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1524,6 +1524,10 @@ static void macb_configure_dma(struct macb *bp)
dmacfg = GEM_BFINS(FBLDO, bp->dma_burst_length, dmacfg);
dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
dmacfg &= ~GEM_BIT(ENDIA);
+ if (bp->dev->features & NETIF_F_HW_CSUM)
+ dmacfg |= GEM_BIT(TXCOEN);
+ else
+ dmacfg &= ~GEM_BIT(TXCOEN);
netdev_dbg(bp->dev, "Cadence configure DMA with 0x%08x\n", dmacfg);
gem_writel(bp, DMACFG, dmacfg);
}
@@ -1923,6 +1927,27 @@ int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
}
EXPORT_SYMBOL_GPL(macb_ioctl);
+static int macb_set_features(struct net_device *netdev,
+ netdev_features_t features)
+{
+ struct macb *bp = netdev_priv(netdev);
+ netdev_features_t changed = features ^ netdev->features;
+
+ /* TX checksum offload */
+ if ((changed & NETIF_F_HW_CSUM) && macb_is_gem(bp)) {
+ u32 dmacfg;
+
+ dmacfg = gem_readl(bp, DMACFG);
+ if (features & NETIF_F_HW_CSUM)
+ dmacfg |= GEM_BIT(TXCOEN);
+ else
+ dmacfg &= ~GEM_BIT(TXCOEN);
+ gem_writel(bp, DMACFG, dmacfg);
+ }
+
+ return 0;
+}
+
static const struct net_device_ops macb_netdev_ops = {
.ndo_open = macb_open,
.ndo_stop = macb_close,
@@ -1936,6 +1961,7 @@ static const struct net_device_ops macb_netdev_ops = {
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = macb_poll_controller,
#endif
+ .ndo_set_features = macb_set_features,
};
#if defined(CONFIG_OF)
@@ -2118,6 +2144,10 @@ static int __init macb_probe(struct platform_device *pdev)
/* Set features */
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;
+ }
if (bp->caps & MACB_CAPS_SG_DISABLED)
dev->hw_features &= ~NETIF_F_SG;
dev->features = dev->hw_features;
--
1.8.2.2
next prev 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 ` Cyrille Pitchen [this message]
2014-07-18 14:21 ` [PATCH 4/6] net/macb: add RX checksum offload feature Cyrille Pitchen
2014-07-18 15:36 ` 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=81148356bc5a52d07c49b18f68833fa7b2f97f2d.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).