* [PATCH 1/2] net: stmmac: Fix TX timestamp calculation
@ 2017-12-18 22:33 Fredrik Hallenberg
2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
2017-12-19 19:12 ` [PATCH 1/2] net: stmmac: Fix TX timestamp calculation David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Fredrik Hallenberg @ 2017-12-18 22:33 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Jose Abreu, David S . Miller, Giuseppe Cavallaro,
Alexandre Torgue, Fredrik Hallenberg
When using GMAC4 the value written in PTP_SSIR should be shifted however
the shifted value is also used in subsequent calculations which results
in a bad timestamp value.
Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
index 721b61655..08c19ebd5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
@@ -34,6 +34,7 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
{
u32 value = readl(ioaddr + PTP_TCR);
unsigned long data;
+ u32 reg_value;
/* For GMAC3.x, 4.x versions, convert the ptp_clock to nano second
* formula = (1/ptp_clock) * 1000000000
@@ -50,10 +51,11 @@ static u32 stmmac_config_sub_second_increment(void __iomem *ioaddr,
data &= PTP_SSIR_SSINC_MASK;
+ reg_value = data;
if (gmac4)
- data = data << GMAC4_PTP_SSIR_SSINC_SHIFT;
+ reg_value <<= GMAC4_PTP_SSIR_SSINC_SHIFT;
- writel(data, ioaddr + PTP_SSIR);
+ writel(reg_value, ioaddr + PTP_SSIR);
return data;
}
--
2.15.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction
2017-12-18 22:33 [PATCH 1/2] net: stmmac: Fix TX timestamp calculation Fredrik Hallenberg
@ 2017-12-18 22:34 ` Fredrik Hallenberg
2017-12-19 19:12 ` David Miller
2017-12-19 19:12 ` [PATCH 1/2] net: stmmac: Fix TX timestamp calculation David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Fredrik Hallenberg @ 2017-12-18 22:34 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Jose Abreu, David S . Miller, Giuseppe Cavallaro,
Alexandre Torgue, Fredrik Hallenberg
As noted in dwmac4_wrback_get_rx_timestamp_status the timestamp is found
in the context descriptor following the current descriptor. However the
current code looks for the context descriptor in the current
descriptor, which will always fail.
Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 2 +-
drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c | 5 +++--
drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 3 ++-
drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 2 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
5 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index e1e5ac053..ce2ea2d49 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -409,7 +409,7 @@ struct stmmac_desc_ops {
/* get timestamp value */
u64(*get_timestamp) (void *desc, u32 ats);
/* get rx timestamp status */
- int (*get_rx_timestamp_status) (void *desc, u32 ats);
+ int (*get_rx_timestamp_status)(void *desc, void *next_desc, u32 ats);
/* Display ring */
void (*display_ring)(void *head, unsigned int size, bool rx);
/* set MSS via context descriptor */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
index 4b286e27c..7e089bf90 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
@@ -258,7 +258,8 @@ static int dwmac4_rx_check_timestamp(void *desc)
return ret;
}
-static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats)
+static int dwmac4_wrback_get_rx_timestamp_status(void *desc, void *next_desc,
+ u32 ats)
{
struct dma_desc *p = (struct dma_desc *)desc;
int ret = -EINVAL;
@@ -270,7 +271,7 @@ static int dwmac4_wrback_get_rx_timestamp_status(void *desc, u32 ats)
/* Check if timestamp is OK from context descriptor */
do {
- ret = dwmac4_rx_check_timestamp(desc);
+ ret = dwmac4_rx_check_timestamp(next_desc);
if (ret < 0)
goto exit;
i++;
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
index 7546b3664..2a828a312 100644
--- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
@@ -400,7 +400,8 @@ static u64 enh_desc_get_timestamp(void *desc, u32 ats)
return ns;
}
-static int enh_desc_get_rx_timestamp_status(void *desc, u32 ats)
+static int enh_desc_get_rx_timestamp_status(void *desc, void *next_desc,
+ u32 ats)
{
if (ats) {
struct dma_extended_desc *p = (struct dma_extended_desc *)desc;
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
index f817f8f36..db4cee57b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
@@ -265,7 +265,7 @@ static u64 ndesc_get_timestamp(void *desc, u32 ats)
return ns;
}
-static int ndesc_get_rx_timestamp_status(void *desc, u32 ats)
+static int ndesc_get_rx_timestamp_status(void *desc, void *next_desc, u32 ats)
{
struct dma_desc *p = (struct dma_desc *)desc;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index d7250539d..337d53d12 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -482,7 +482,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
desc = np;
/* Check if timestamp is available */
- if (priv->hw->desc->get_rx_timestamp_status(desc, priv->adv_ts)) {
+ if (priv->hw->desc->get_rx_timestamp_status(p, np, priv->adv_ts)) {
ns = priv->hw->desc->get_timestamp(desc, priv->adv_ts);
netdev_dbg(priv->dev, "get valid RX hw timestamp %llu\n", ns);
shhwtstamp = skb_hwtstamps(skb);
--
2.15.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] net: stmmac: Fix TX timestamp calculation
2017-12-18 22:33 [PATCH 1/2] net: stmmac: Fix TX timestamp calculation Fredrik Hallenberg
2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
@ 2017-12-19 19:12 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-19 19:12 UTC (permalink / raw)
To: megahallon
Cc: netdev, linux-kernel, Jose.Abreu, peppe.cavallaro, alexandre.torgue
From: Fredrik Hallenberg <megahallon@gmail.com>
Date: Mon, 18 Dec 2017 23:33:59 +0100
> When using GMAC4 the value written in PTP_SSIR should be shifted however
> the shifted value is also used in subsequent calculations which results
> in a bad timestamp value.
>
> Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction
2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
@ 2017-12-19 19:12 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-12-19 19:12 UTC (permalink / raw)
To: megahallon
Cc: netdev, linux-kernel, Jose.Abreu, peppe.cavallaro, alexandre.torgue
From: Fredrik Hallenberg <megahallon@gmail.com>
Date: Mon, 18 Dec 2017 23:34:00 +0100
> As noted in dwmac4_wrback_get_rx_timestamp_status the timestamp is found
> in the context descriptor following the current descriptor. However the
> current code looks for the context descriptor in the current
> descriptor, which will always fail.
>
> Signed-off-by: Fredrik Hallenberg <megahallon@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-12-19 19:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-18 22:33 [PATCH 1/2] net: stmmac: Fix TX timestamp calculation Fredrik Hallenberg
2017-12-18 22:34 ` [PATCH 2/2] net: stmmac: Fix bad RX timestamp extraction Fredrik Hallenberg
2017-12-19 19:12 ` David Miller
2017-12-19 19:12 ` [PATCH 1/2] net: stmmac: Fix TX timestamp calculation David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®