Skip to contentSkip to conversation

net: dsa: microchip: add PTP support for KSZ9x and LAN937x

RFC PATCH In review Arun Ramadoss 4 participants 30 messages Nov 21, 2022 – Nov 25, 2022 Page 2 of 2

Subsystems (5)
lore
Share & tools
lore
maintainer
#28 lore raw

Re: [RFC Patch net-next v2 8/8] net: dsa: microchip: ptp: add periodic output signal

In reply to Arun Ramadoss
Quoted 21 lines · Arun Ramadoss
drivers/net/dsa/microchip/ksz_ptp.c +21 -0
+static int ksz_ptp_restart_perout(struct ksz_device *dev)
+{
+	struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+	s64 now_ns, first_ns, period_ns, next_ns;
+	struct timespec64 now;
+	unsigned int count;
+	int ret;
+
+	ret = _ksz_ptp_gettime(dev, &now);
+	if (ret)
+		return ret;
+
+	now_ns = timespec64_to_ns(&now);
+	first_ns = timespec64_to_ns(&ptp_data->perout_target_time_first);
+
+	/* Calculate next perout event based on start time and period */
+	period_ns = timespec64_to_ns(&ptp_data->perout_period);
+
+	if (first_ns < now_ns) {
+		count = div_u64(now_ns - first_ns, period_ns);
+		next_ns = first_ns + count * period_ns;

drivers/net/dsa/microchip/ksz_ptp.c static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) · line 690

Quoted 10 lines
drivers/net/dsa/microchip/ksz_ptp.c +10 -0
+	} else {
+		next_ns = first_ns;
+	}
+
+	/* Ensure 100 ms guard time prior next event */
+	while (next_ns < now_ns + 100000000)
+		next_ns += period_ns;
+
+	/* Restart periodic output signal */
+	{

CodingStyle: avoid anonymous blocks. Move to helper function instead?

Thanks,
Richard

Quoted 20 lines
drivers/net/dsa/microchip/ksz_ptp.c +20 -0
+		struct timespec64 next = ns_to_timespec64(next_ns);
+		struct ptp_perout_request perout_request = {
+			.start = {
+				.sec  = next.tv_sec,
+				.nsec = next.tv_nsec
+			},
+			.period = {
+				.sec  = ptp_data->perout_period.tv_sec,
+				.nsec = ptp_data->perout_period.tv_nsec
+			},
+			.index = 0,
+			.flags = 0,  /* keep current values */
+		};
+		ret = ksz_ptp_enable_perout(dev, &perout_request, 1);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
maintainer
#29 lore raw
In reply to Arun Ramadoss

Hi Arun,

Quoted 7 lines · Arun Ramadoss

The LAN937x switch has capable for supporting IEEE 1588 PTP protocol. This patch series add PTP support and tested using the ptp4l application. LAN937x has the same PTP register set similar to KSZ9563, hence the implementation has been made common for the ksz switches. KSZ9563 does not support two step timestamping but LAN937x supports both. Tested the 1step & 2step p2p timestamping in LAN937x and p2p1step timestamping in KSZ9563.

A process-related pattern I noticed in your patches. The Author: is in general the same as the first Signed-off-by:. I don't know of cases where that's not true.

There can be more subsequent Signed-off-by: tags, and those are people through the hands of whom those patches have passed, and who might have made changes to them.

When you use Christian's patches (verbatim or with non-radical rework, like fixes here and there, styling rework, commit message rewrite), you need Christian to appear in the Author: and first Signed-off-by:
field, and you in the second. When patches are more or less a complete rework (such that it no longer resembles Christian's original intentions and it would be misleading to put his sign off on something which he did not write), you can put yourself as author and first sign off, and use
Co-developed-by: + Signed-off-by for Christian's work (the sign off still seems to be required for some reason). You need to use your judgement here, you can't always put your name on others' work. You can also say "based on a previous patch posted on the mailing lists which was heavily reworked" and provide a Link: tag with a lore.kernel.org or patchwork.kernel.org link. Under the "---" sign in the patch you can also clarify the changes you've made, if you decide to keep Christian's authorship but make significant but not radical changes. These annotations will always be visible in patchwork even if not in git. At least that's what I would do.