Skip to content

Commit 9fcf024

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: Take PTP egress timestamp by port, not mgmt slot
The PTP egress timestamp N must be captured from register PTPEGR_TS[n], where n = 2 * PORT + TSREG. There are 10 PTPEGR_TS registers, 2 per port. We are only using TSREG=0. As opposed to the management slots, which are 4 in number (SJA1105_NUM_PORTS, minus the CPU port). Any management frame (which includes PTP frames) can be sent to any non-CPU port through any management slot. When the CPU port is not the last port (#4), there will be a mismatch between the slot and the port number. Luckily, the only mainline occurrence with this switch (arch/arm/boot/dts/ls1021a-tsn.dts) does have the CPU port as #4, so the issue did not manifest itself thus far. Fixes: 47ed985 ("net: dsa: sja1105: Add logic for TX timestamping") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0caeaf6 commit 9fcf024

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/net/dsa/sja1105/sja1105_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ static netdev_tx_t sja1105_port_deferred_xmit(struct dsa_switch *ds, int port,
18551855
if (!clone)
18561856
goto out;
18571857

1858-
sja1105_ptp_txtstamp_skb(ds, slot, clone);
1858+
sja1105_ptp_txtstamp_skb(ds, port, clone);
18591859

18601860
out:
18611861
mutex_unlock(&priv->mgmt_lock);

drivers/net/dsa/sja1105/sja1105_ptp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void sja1105_ptp_clock_unregister(struct dsa_switch *ds)
659659
ptp_data->clock = NULL;
660660
}
661661

662-
void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int slot,
662+
void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int port,
663663
struct sk_buff *skb)
664664
{
665665
struct sja1105_private *priv = ds->priv;
@@ -679,7 +679,7 @@ void sja1105_ptp_txtstamp_skb(struct dsa_switch *ds, int slot,
679679
goto out;
680680
}
681681

682-
rc = sja1105_ptpegr_ts_poll(ds, slot, &ts);
682+
rc = sja1105_ptpegr_ts_poll(ds, port, &ts);
683683
if (rc < 0) {
684684
dev_err(ds->dev, "timed out polling for tstamp\n");
685685
kfree_skb(skb);

0 commit comments

Comments
 (0)