diff mbox series

[net-next] net: stmmac: fix ptp timestamping on Rx on gmac4

Message ID 1549368920-1989-1-git-send-email-ilias.apalodimas@linaro.org
State New
Headers show
Series [net-next] net: stmmac: fix ptp timestamping on Rx on gmac4 | expand

Commit Message

Ilias Apalodimas Feb. 5, 2019, 12:15 p.m. UTC
The current driver only enables Pdelay_Req and Pdelay_Resp when
HWTSTAMP_FILTER_PTP_V2_EVENT, HWTSTAMP_FILTER_PTP_V1_L4_EVENT or
HWTSTAMP_FILTER_PTP_V2_L4_EVENT is requested. This results in ptp sync on
slave mode to report 'received SYNC without timestamp' when using ptp4l.

Although the hardware can support Sync, Pdelay_Req and Pdelay_resp by
setting bit14 annd bits 17/16 to 01 this leaves Delay_Req timestamps out.

Fix this by enabling all event and general messages timestamps.
This includes SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req,
Pdelay_Resp and Pdelay_Resp_Follow_Up messages.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++++---------------
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h  |  9 ++++++--
 2 files changed, 16 insertions(+), 18 deletions(-)

-- 
2.7.4

Comments

Jose Abreu Feb. 6, 2019, 11:45 a.m. UTC | #1
On 2/5/2019 12:15 PM, Ilias Apalodimas wrote:
> The current driver only enables Pdelay_Req and Pdelay_Resp when

> HWTSTAMP_FILTER_PTP_V2_EVENT, HWTSTAMP_FILTER_PTP_V1_L4_EVENT or

> HWTSTAMP_FILTER_PTP_V2_L4_EVENT is requested. This results in ptp sync on

> slave mode to report 'received SYNC without timestamp' when using ptp4l.

> 

> Although the hardware can support Sync, Pdelay_Req and Pdelay_resp by

> setting bit14 annd bits 17/16 to 01 this leaves Delay_Req timestamps out.

> 

> Fix this by enabling all event and general messages timestamps.

> This includes SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req,

> Pdelay_Resp and Pdelay_Resp_Follow_Up messages.

> 

> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>


Acked-by: Jose Abreu <joabreu@synopsys.com>


and, on XGMAC2: Tested-by: Jose Abreu <joabreu@synopsys.com>

Thanks,
Jose Miguel Abreu
Alexandre TORGUE Feb. 6, 2019, 12:56 p.m. UTC | #2
Hi Ilias

On 2/5/19 1:15 PM, Ilias Apalodimas wrote:
> The current driver only enables Pdelay_Req and Pdelay_Resp when

> HWTSTAMP_FILTER_PTP_V2_EVENT, HWTSTAMP_FILTER_PTP_V1_L4_EVENT or

> HWTSTAMP_FILTER_PTP_V2_L4_EVENT is requested. This results in ptp sync on

> slave mode to report 'received SYNC without timestamp' when using ptp4l.

> 

> Although the hardware can support Sync, Pdelay_Req and Pdelay_resp by

> setting bit14 annd bits 17/16 to 01 this leaves Delay_Req timestamps out.

> 

> Fix this by enabling all event and general messages timestamps.

> This includes SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req,

> Pdelay_Resp and Pdelay_Resp_Follow_Up messages.

> 

> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>


For GMAC4 part:

Tested-by: Alexandre TORGUE <alexandre.torgue@st.com>
David Miller Feb. 7, 2019, 1:28 a.m. UTC | #3
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Date: Tue,  5 Feb 2019 14:15:20 +0200

> The current driver only enables Pdelay_Req and Pdelay_Resp when

> HWTSTAMP_FILTER_PTP_V2_EVENT, HWTSTAMP_FILTER_PTP_V1_L4_EVENT or

> HWTSTAMP_FILTER_PTP_V2_L4_EVENT is requested. This results in ptp sync on

> slave mode to report 'received SYNC without timestamp' when using ptp4l.

> 

> Although the hardware can support Sync, Pdelay_Req and Pdelay_resp by

> setting bit14 annd bits 17/16 to 01 this leaves Delay_Req timestamps out.

> 

> Fix this by enabling all event and general messages timestamps.

> This includes SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req,

> Pdelay_Resp and Pdelay_Resp_Follow_Up messages.

> 

> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>


Applied to net-next, thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 517555b..effff17 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -597,12 +597,13 @@  static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 		case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
 			/* PTP v1, UDP, any kind of event packet */
 			config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-			/* take time stamp for all event messages */
-			if (xmac)
-				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-			else
-				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-
+			/* 'xmac' hardware can support Sync, Pdelay_Req and
+			 * Pdelay_resp by setting bit14 and bits17/16 to 01
+			 * This leaves Delay_Req timestamps out.
+			 * Enable all events *and* general purpose message
+			 * timestamping
+			 */
+			snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
 			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
 			ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
 			break;
@@ -633,10 +634,7 @@  static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 			config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
 			ptp_v2 = PTP_TCR_TSVER2ENA;
 			/* take time stamp for all event messages */
-			if (xmac)
-				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-			else
-				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
+			snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
 
 			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
 			ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
@@ -669,12 +667,7 @@  static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 			/* PTP v2/802.AS1 any layer, any kind of event packet */
 			config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
 			ptp_v2 = PTP_TCR_TSVER2ENA;
-			/* take time stamp for all event messages */
-			if (xmac)
-				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
-			else
-				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
-
+			snap_type_sel = PTP_TCR_SNAPTYPSEL_1;
 			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
 			ptp_over_ipv6_udp = PTP_TCR_TSIPV6ENA;
 			ptp_over_ethernet = PTP_TCR_TSIPENA;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
index ecccf89..e852821 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h
@@ -59,9 +59,14 @@ 
 #define	PTP_TCR_TSEVNTENA	BIT(14)
 /* Enable Snapshot for Messages Relevant to Master */
 #define	PTP_TCR_TSMSTRENA	BIT(15)
-/* Select PTP packets for Taking Snapshots */
+/* Select PTP packets for Taking Snapshots
+ * On gmac4 specifically:
+ * Enable SYNC, Pdelay_Req, Pdelay_Resp when TSEVNTENA is enabled.
+ * or
+ * Enable  SYNC, Follow_Up, Delay_Req, Delay_Resp, Pdelay_Req, Pdelay_Resp,
+ * Pdelay_Resp_Follow_Up if TSEVNTENA is disabled
+ */
 #define	PTP_TCR_SNAPTYPSEL_1	BIT(16)
-#define	PTP_GMAC4_TCR_SNAPTYPSEL_1	GENMASK(17, 16)
 /* Enable MAC address for PTP Frame Filtering */
 #define	PTP_TCR_TSENMACADDR	BIT(18)