Re: [PATCH 6/7] net: dsa: b53: Add logic for TX timestamping

From: Martin Kaistra
Date: Mon Nov 08 2021 - 04:57:55 EST


Am 06.11.21 um 03:50 schrieb Florian Fainelli:


On 11/4/2021 6:32 AM, Martin Kaistra wrote:
In order to get the switch to generate a timestamp for a transmitted
packet, we need to set the TS bit in the BRCM tag. The switch will then
create a status frame, which gets send back to the cpu.
In b53_port_txtstamp() we put the skb into a waiting position.

When a status frame is received, we extract the timestamp and put the time
according to our timecounter into the waiting skb. When
TX_TSTAMP_TIMEOUT is reached and we have no means to correctly get back
a full timestamp, we cancel the process.

As the status frame doesn't contain a reference to the original packet,
only one packet with timestamp request can be sent at a time.

Signed-off-by: Martin Kaistra <martin.kaistra@xxxxxxxxxxxxx>
---

[snip]

+static long b53_hwtstamp_work(struct ptp_clock_info *ptp)
+{
+    struct b53_device *dev =
+        container_of(ptp, struct b53_device, ptp_clock_info);
+    struct dsa_switch *ds = dev->ds;
+    int i;
+
+    for (i = 0; i < ds->num_ports; i++) {
+        struct b53_port_hwtstamp *ps;
+
+        if (!dsa_is_user_port(ds, i))
+            continue;

Can you also check on !dsa_port_is_unused()?
After the currently implemented check, dp->type should be DSA_PORT_TYPE_USER, so it can't be DSA_PORT_TYPE_UNUSED, right?


Thanks,
Martin