Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1c7b587 authored by Sneh Shah's avatar Sneh Shah
Browse files

net: stmmac: fix PTP packet configuration



Snapshot bit being set before was selectively timestamping some packets.
Updated the snapshot bit to timestamp all type of PTP packets.
Adjust/init systime was not checking for previous incomplete updates.
Added check to fix it.

Change-Id: I2cfa63421fb8d1f36cab02e2e2fc5e3be1f28ac3
Signed-off-by: default avatarSneh Shah <snehshah@codeaurora.org>
parent 7c3314cd
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
#include "common.h"
#include "stmmac_ptp.h"

#define PTP_LIMIT 100000

static void stmmac_config_hw_tstamping(void __iomem *ioaddr, u32 data)
{
	writel(data, ioaddr + PTP_TCR);
@@ -65,6 +67,16 @@ static int stmmac_init_systime(void __iomem *ioaddr, u32 sec, u32 nsec)
	int limit;
	u32 value;

	/* wait for previous(if any) time initialization to complete. */
	limit = PTP_LIMIT;
	while (limit--) {
		if (!(readl_relaxed(ioaddr + PTP_TCR) &  PTP_TCR_TSINIT))
			break;
		usleep_range(1000, 1500);
	}
	if (limit < 0)
		return -EBUSY;

	writel(sec, ioaddr + PTP_STSUR);
	writel(nsec, ioaddr + PTP_STNSUR);
	/* issue command to initialize the system time value */
@@ -115,6 +127,16 @@ static int stmmac_adjust_systime(void __iomem *ioaddr, u32 sec, u32 nsec,
	u32 value;
	int limit;

	/* wait for previous(if any) time adjust/update to complete. */
	limit = PTP_LIMIT;
	while (limit--) {
		if (!(readl_relaxed(ioaddr + PTP_TCR) & PTP_TCR_TSUPDT))
			break;
		usleep_range(1000, 1500);
	}
	if (limit < 0)
		return -EBUSY;

	if (add_sub) {
		/* If the new sec value needs to be subtracted with
		 * the system time, then MAC_STSUR reg should be
+0 −9
Original line number Diff line number Diff line
@@ -562,9 +562,6 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
			/* 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 (priv->plat->has_gmac4)
				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
			else
				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;

			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
@@ -597,9 +594,6 @@ static int stmmac_hwtstamp_ioctl(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 (priv->plat->has_gmac4)
				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
			else
				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;

			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;
@@ -634,9 +628,6 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
			config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
			ptp_v2 = PTP_TCR_TSVER2ENA;
			/* take time stamp for all event messages */
			if (priv->plat->has_gmac4)
				snap_type_sel = PTP_GMAC4_TCR_SNAPTYPSEL_1;
			else
				snap_type_sel = PTP_TCR_SNAPTYPSEL_1;

			ptp_over_ipv4_udp = PTP_TCR_TSIPV4ENA;