RE: [PATCH v8 net-next 8/9] net: dsa: netc: add PTP two-step timestamping support

From: Wei Fang

Date: Mon Nov 23 2026 - 01:30:58 EST


> > +static int netc_port_del_ptp_filter(struct netc_port *np)
> > +{
> > + struct netc_switch *priv = np->switch_priv;
> > + int ret = 0;
> > + int err;
> > +
> > + for (int i = 0; i < NETC_PTP_MAX; i++) {
> > + if (np->ptp_ipft_eid[i] == NTMP_NULL_ENTRY_ID)
> > + continue;
> > +
> > + /* No -ETIMEDOUT here: with the command BD ring enabled,
> the
> > + * hardware execution time for a command is much less than
> > + * 1ms, so no timeout error will occur. Any remaining error
> > + * means the entry is still present in the table.
> > + */
> > + err = ntmp_ipft_delete_entry(&priv->ntmp,
> > + np->ptp_ipft_eid[i]);
> > + if (likely(!err)) {
> > + np->ptp_ipft_eid[i] = NTMP_NULL_ENTRY_ID;
> > + continue;
> > + }
> > +
> > + ret = err;
> > + dev_err(priv->dev,
> > + "Delete PTP entry 0x%x (type %d) on port %d
> failed\n",
> > + np->ptp_ipft_eid[i], i, np->dp->index);
> > + }
>
> [Severity: Low]
> Is the claim in this comment guaranteed by the NTMP layer? The delete
> goes through this path:
>
> netc_port_hwtstamp_set()
> netc_port_set_ptp_filter()
> netc_port_del_ptp_filter()
> ntmp_ipft_delete_entry()
> ntmp_delete_entry_by_id()
> netc_xmit_ntmp_cmd()
>
> netc_xmit_ntmp_cmd() hands the BD to hardware and only then waits:
>
> drivers/net/ethernet/freescale/enetc/ntmp.c:netc_xmit_ntmp_cmd() {
> ...
> i = (i + 1) % cbdr->bd_num;
> cbdr->next_to_use = i;
> netc_write(cbdr->regs.pir, i);
>
> err = read_poll_timeout(netc_read, val,
> (val & NETC_CBDRCIR_INDEX) == i,
> NETC_CBDR_DELAY_US,
> NETC_CBDR_TIMEOUT,
> true, cbdr->regs.cir);
> if (unlikely(err))
> return err;
> ...
> }
>
> If the consumer index does not advance within NETC_CBDR_TIMEOUT, this
> returns -ETIMEDOUT. The hardware may still run the DELETE after that.
>
> In that case np->ptp_ipft_eid[i] is kept. netc_port_current_rx_filter()
> would then report an rx_filter that is no longer installed. The commit
> message says this design avoids exactly that:
>
> "so a delete or rollback that fails partway does not leave software
> reporting a filter that no longer matches the hardware."
>
> Every later netc_port_set_ptp_filter() also starts by deleting the stale
> entry ID. If the hardware rejects deleting a missing entry (the response
> error status maps to -EIO), could every later hwtstamp_set on that port
> fail until the switch is set up again?
>
> This needs the hardware itself to stall, because read_poll_timeout()
> reads once more after the deadline. The host-flood path added earlier in
> the series by "net: dsa: netc: check return value of
> ntmp_ipft_delete_entry()" makes the same assumption. This patch adds a
> second user whose reported state depends on it.
>
> Should -ETIMEDOUT be handled separately here, for example by treating
> the entry state as unknown? Or should the comment say this is an
> assumption about the hardware rather than a guarantee?

As explained in the email thread for patch 6, the -ETIMEDOUT error will not
occur, so there is no need to worry about this.