netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: <netdev@vger.kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	David Miller <davem@davemloft.net>
Subject: [PATCH net-next v1 12/21] amd-xgbe: Add a workaround for Tx timestamp issue
Date: Thu, 3 Nov 2016 08:29:47 -0500	[thread overview]
Message-ID: <20161103132947.3437.26130.stgit@tlendack-t1.amdoffice.net> (raw)
In-Reply-To: <20161103132744.3437.27332.stgit@tlendack-t1.amdoffice.net>

Update the reading of the Tx timestamp to account for a hardware issue
on how the fields and interrupt are cleared.  The "seconds" portion of
the timestamp should be read first, followed by the "nanoseconds" portion.
Reading the "nanoseconds" portion should clear the timestamp data and the
interrupt.  Because of an issue with the hardware this order is reversed
and reading the "seconds" portion actually clears the timestamp.  The code
currently follows this workaround, but to guard against future versions
where this is fixed add a field to the version data to indicate if the
workaround is required or not.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-dev.c      |   13 ++++++++++---
 drivers/net/ethernet/amd/xgbe/xgbe-platform.c |    1 +
 drivers/net/ethernet/amd/xgbe/xgbe.h          |    1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
index 698712b..ecc0d45 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -1360,14 +1360,21 @@ static u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata)
 
 static u64 xgbe_get_tx_tstamp(struct xgbe_prv_data *pdata)
 {
-	unsigned int tx_snr;
+	unsigned int tx_snr, tx_ssr;
 	u64 nsec;
 
-	tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+	if (pdata->vdata->tx_tstamp_workaround) {
+		tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+		tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR);
+	} else {
+		tx_ssr = XGMAC_IOREAD(pdata, MAC_TXSSR);
+		tx_snr = XGMAC_IOREAD(pdata, MAC_TXSNR);
+	}
+
 	if (XGMAC_GET_BITS(tx_snr, MAC_TXSNR, TXTSSTSMIS))
 		return 0;
 
-	nsec = XGMAC_IOREAD(pdata, MAC_TXSSR);
+	nsec = tx_ssr;
 	nsec *= NSEC_PER_SEC;
 	nsec += tx_snr;
 
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
index 0edbcd5..7a701de 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
@@ -581,6 +581,7 @@ static int xgbe_platform_resume(struct device *dev)
 	.xpcs_access			= XGBE_XPCS_ACCESS_V1,
 	.tx_max_fifo_size		= 81920,
 	.rx_max_fifo_size		= 81920,
+	.tx_tstamp_workaround		= 1,
 };
 
 #ifdef CONFIG_ACPI
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h
index 0779247..8523779 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe.h
+++ b/drivers/net/ethernet/amd/xgbe/xgbe.h
@@ -805,6 +805,7 @@ struct xgbe_version_data {
 	unsigned int mmc_64bit;
 	unsigned int tx_max_fifo_size;
 	unsigned int rx_max_fifo_size;
+	unsigned int tx_tstamp_workaround;
 };
 
 struct xgbe_prv_data {

  parent reply	other threads:[~2016-11-03 13:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03 13:27 [PATCH net-next v1 00/21] amd-xgbe: AMD XGBE driver updates 2016-11-01 Tom Lendacky
2016-11-03 13:27 ` [PATCH net-next v1 01/21] amd-xgbe: Fix formatting of PCS register dump Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 02/21] amd-xgbe: Prepare for priority-based FIFO allocation Tom Lendacky
2016-11-03 13:51   ` Mintz, Yuval
2016-11-03 14:50     ` Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 03/21] amd-xgbe: Perform priority-based hardware " Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 04/21] amd-xgbe: Prepare for working with more than one type of phy Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 05/21] amd-xgbe: Prepare for introduction of clause 37 autoneg Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 06/21] amd-xgbe: Add support for clause 37 auto-negotiation Tom Lendacky
2016-11-03 13:28 ` [PATCH net-next v1 07/21] amd-xgbe: Prepare for a new PCS register access method Tom Lendacky
2016-11-03 13:29 ` [PATCH net-next v1 08/21] amd-xgbe: Support for 64-bit management counter registers Tom Lendacky
2016-11-03 13:29 ` [PATCH net-next v1 09/21] amd-xgbe: Update how to determine DMA channel status Tom Lendacky
2016-11-03 13:29 ` [PATCH net-next v1 10/21] amd-xgbe: Prepare for supporting PCI devices Tom Lendacky
2016-11-03 13:29 ` [PATCH net-next v1 11/21] amd-xgbe: Guard against incorrectly generated interrupts Tom Lendacky
2016-11-03 13:29 ` Tom Lendacky [this message]
2016-11-03 13:29 ` [PATCH net-next v1 13/21] amd-xgbe: Add PCI device support Tom Lendacky
2016-11-03 13:30 ` [PATCH net-next v1 14/21] amd-xgbe: Allow for a greater number of Rx queues Tom Lendacky
2016-11-03 13:30 ` [PATCH net-next v1 15/21] amd-xgbe: Add support for new DMA interrupt mode Tom Lendacky
2016-11-03 13:30 ` [PATCH net-next v1 16/21] amd-xgbe: Add ECC status support for the device memory Tom Lendacky
2016-11-03 13:30 ` [PATCH net-next v1 17/21] amd-xgbe: Add I2C support for determining SFP media types Tom Lendacky
2016-11-03 14:28   ` Andrew Lunn
2016-11-03 15:01     ` Tom Lendacky
2016-11-03 15:18       ` Andrew Lunn
2016-11-09 15:35         ` Tom Lendacky
2016-11-03 13:30 ` [PATCH net-next v1 18/21] net: phy: expose phy_aneg_done API for use by drivers Tom Lendacky
2016-11-04  2:13   ` kbuild test robot
2016-11-07 15:01     ` Tom Lendacky
2016-11-08 10:17       ` Andreas Larsson
2016-11-03 13:30 ` [PATCH net-next v1 19/21] amd-xgbe: Add support for SFP+ modules Tom Lendacky
2016-11-03 13:31 ` [PATCH net-next v1 20/21] amd-xgbe: Add support for MDIO attached PHYs Tom Lendacky
2016-11-03 13:31 ` [PATCH net-next v1 21/21] amd-xgbe: Add support for a KR redriver Tom Lendacky
2016-11-03 17:14 ` [PATCH net-next v1 00/21] amd-xgbe: AMD XGBE driver updates 2016-11-01 David Miller
2016-11-03 17:23   ` Tom Lendacky

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=20161103132947.3437.26130.stgit@tlendack-t1.amdoffice.net \
    --to=thomas.lendacky@amd.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.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).