netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@arm.linux.org.uk>
To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org
Cc: Fugang Duan <B38611@freescale.com>
Subject: [PATCH CFT 30/30] net: fec: consolidate hwtstamp implementation
Date: Fri, 27 Jun 2014 16:21:26 +0100	[thread overview]
Message-ID: <E1X0Xxu-0001PB-Ia@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20140627151542.GL32514@n2100.arm.linux.org.uk>

Both transmit and receive use the same infrastructure for calculating
the packet timestamp.  Rather than duplicating the code, provide a
function to do this common work.  Model this function in the Intel
e1000e version which avoids calling ns_to_ktime() within the spinlock;
the spinlock is critical for timecounter_cyc2time() but not
ns_to_ktime().

Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 drivers/net/ethernet/freescale/fec_main.c | 37 ++++++++++++++++---------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 916b9ab97da4..dc925136ff01 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1065,6 +1065,21 @@ static void fec_enet_timeout_work(struct work_struct *work)
 }
 
 static void
+fec_enet_hwtstamp(struct fec_enet_private *fep, unsigned ts,
+	struct skb_shared_hwtstamps *hwtstamps)
+{
+	unsigned long flags;
+	u64 ns;
+
+	spin_lock_irqsave(&fep->tmreg_lock, flags);
+	ns = timecounter_cyc2time(&fep->tc, ts);
+	spin_unlock_irqrestore(&fep->tmreg_lock, flags);
+
+	memset(hwtstamps, 0, sizeof(*hwtstamps));
+	hwtstamps->hwtstamp = ns_to_ktime(ns);
+}
+
+static void
 fec_enet_tx(struct net_device *ndev)
 {
 	struct	fec_enet_private *fep;
@@ -1122,14 +1137,9 @@ fec_enet_tx(struct net_device *ndev)
 		if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS) &&
 			fep->bufdesc_ex) {
 			struct skb_shared_hwtstamps shhwtstamps;
-			unsigned long flags;
 			struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp;
 
-			memset(&shhwtstamps, 0, sizeof(shhwtstamps));
-			spin_lock_irqsave(&fep->tmreg_lock, flags);
-			shhwtstamps.hwtstamp = ns_to_ktime(
-				timecounter_cyc2time(&fep->tc, ebdp->ts));
-			spin_unlock_irqrestore(&fep->tmreg_lock, flags);
+			fec_enet_hwtstamp(fep, ebdp->ts, &shhwtstamps);
 			skb_tstamp_tx(skb, &shhwtstamps);
 		}
 
@@ -1288,18 +1298,9 @@ fec_enet_rx(struct net_device *ndev, int budget)
 			skb->protocol = eth_type_trans(skb, ndev);
 
 			/* Get receive timestamp from the skb */
-			if (fep->hwts_rx_en && fep->bufdesc_ex) {
-				struct skb_shared_hwtstamps *shhwtstamps =
-							    skb_hwtstamps(skb);
-				unsigned long flags;
-
-				memset(shhwtstamps, 0, sizeof(*shhwtstamps));
-
-				spin_lock_irqsave(&fep->tmreg_lock, flags);
-				shhwtstamps->hwtstamp = ns_to_ktime(
-				    timecounter_cyc2time(&fep->tc, ebdp->ts));
-				spin_unlock_irqrestore(&fep->tmreg_lock, flags);
-			}
+			if (fep->hwts_rx_en && fep->bufdesc_ex)
+				fec_enet_hwtstamp(fep, ebdp->ts,
+						  skb_hwtstamps(skb));
 
 			if (fep->bufdesc_ex &&
 			    (fep->csum_flags & FLAG_RX_CSUM_ENABLED)) {
-- 
1.8.3.1

  parent reply	other threads:[~2014-06-27 15:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27 15:15 [PATCH CFT 00/30] Initial round of Freescale FEC ethernet patches Russell King - ARM Linux
2014-06-27 15:18 ` [PATCH CFT 01/30] net: fec: Don't clear IPV6 header checksum field when IP accelerator enable Russell King
2014-06-27 15:19 ` [PATCH CFT 02/30] net: fec: iMX6 FEC does not support half-duplex gigabit Russell King
2014-07-08  6:46   ` Uwe Kleine-König
2014-07-08 11:47     ` Russell King - ARM Linux
2014-06-27 15:19 ` [PATCH CFT 03/30] net: fec: fix ethtool set_pauseparam duplex bug Russell King
2014-06-27 15:19 ` [PATCH CFT 04/30] net: fec: fix interrupt handling races Russell King
2014-06-27 15:19 ` [PATCH CFT 05/30] net: fec: use netif_tx_disable() rather than netif_stop_queue() Russell King
2014-06-27 15:19 ` [PATCH CFT 06/30] net: fec: remove checking for NULL phy_dev in fec_enet_close() Russell King
2014-06-27 15:19 ` [PATCH CFT 07/30] net: fec: ensure that a disconnected phy isn't configured Russell King
2014-06-27 15:19 ` [PATCH CFT 08/30] net: fec: stop the phy before shutting down the MAC Russell King
2014-06-27 15:19 ` [PATCH CFT 09/30] net: fec: remove useless fep->opened Russell King
2014-06-27 15:19 ` [PATCH CFT 10/30] net: fec: make rx skb handling more robust Russell King
2014-06-27 15:19 ` [PATCH CFT 11/30] net: fec: clean up transmit descriptor setup Russell King
2014-06-27 15:19 ` [PATCH CFT 12/30] net: fec: ensure fec_enet_free_buffers() properly cleans the rings Russell King
2014-06-27 18:48   ` Sergei Shtylyov
2014-07-01 14:48     ` Russell King - ARM Linux
2014-06-27 15:19 ` [PATCH CFT 13/30] net: fec: fix missing kmalloc() failure check in fec_enet_alloc_buffers() Russell King
2014-06-27 15:20 ` [PATCH CFT 14/30] net: fec: improve safety of suspend/resume/transmit timeout paths Russell King
2014-06-27 15:20 ` [PATCH CFT 15/30] net: fec: ensure fec_enet_close() copes with resume failure Russell King
2014-06-27 15:20 ` [PATCH CFT 16/30] net: fec: only restart or stop the device if it is present and running Russell King
2014-06-27 15:20 ` [PATCH CFT 17/30] net: fec: move calls to quiesce/resume packet processing out of fec_restart() Russell King
2014-06-27 15:20 ` [PATCH CFT 18/30] net: fec: remove inappropriate calls around fec_restart() Russell King
2014-06-27 15:20 ` [PATCH CFT 19/30] net: fec: quiesce packet processing before stopping device in fec_suspend() Russell King
2014-06-27 15:20 ` [PATCH CFT 20/30] net: fec: quiesce packet processing before stopping device in fec_set_features() Russell King
2014-06-27 15:20 ` [PATCH CFT 21/30] net: fec: quiesce packet processing before changing features Russell King
2014-06-27 15:20 ` [PATCH CFT 22/30] net: fec: quiesce packet processing when taking link down in fec_enet_adjust_link() Russell King
2014-06-27 15:20 ` [PATCH CFT 23/30] net: fec: clean up duplex mode handling Russell King
2014-06-27 15:20 ` [PATCH CFT 24/30] net: fec: better implementation of iMX6 ERR006358 quirk Russell King
2014-06-27 15:21 ` [PATCH CFT 25/30] net: fec: replace delayed work with standard work Russell King
2014-06-27 15:21 ` [PATCH CFT 26/30] net: fec: clear receive interrupts before processing a packet Russell King
2014-06-27 15:40   ` Russell King - ARM Linux
2014-06-27 15:21 ` [PATCH CFT 27/30] net: fec: reorder ethtool ops to match order in struct declaration Russell King
2014-06-27 15:21 ` [PATCH CFT 28/30] net: fec: add support for dumping transmit ring on timeout Russell King
2014-06-27 15:21 ` [PATCH CFT 29/30] net: fec: remove useless status check in tx reap path Russell King
2014-06-27 15:21 ` Russell King [this message]
2014-07-01  3:23 ` [PATCH CFT 00/30] Initial round of Freescale FEC ethernet patches fugang.duan
2014-07-01 14:21 ` Nathan Lynch
2014-07-01 14:34   ` Russell King - ARM Linux
2014-07-01 14:56     ` Nathan Lynch
2014-07-07 21:41 ` Russell King - ARM Linux
2014-07-07 22:45   ` 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=E1X0Xxu-0001PB-Ia@rmk-PC.arm.linux.org.uk \
    --to=rmk+kernel@arm.linux.org.uk \
    --cc=B38611@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --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).