Re: [PATCH net-next 0/5] PTP support for the SJA1105 DSA driver

From: Vladimir Oltean
Date: Sat Jun 01 2019 - 08:11:06 EST


On Sat, 1 Jun 2019 at 13:31, Vladimir Oltean <olteanv@xxxxxxxxx> wrote:
>
> On Sat, 1 Jun 2019 at 08:07, Richard Cochran <richardcochran@xxxxxxxxx> wrote:
> >
> > On Fri, May 31, 2019 at 09:12:03PM +0300, Vladimir Oltean wrote:
> > > It won't work unless I make changes to dsa_switch_rcv.
> >
> > Or to the tagging code.
> >
> > > Right now taggers can only return a pointer to the skb, or NULL, case
> > > in which DSA will free it.
> >
> > The tagger can re-write the skb. Why not reform it into a PTP frame?
> > This clever trick is what the phyter does in hardware. See dp83640.c.
> >
>
> I think you're missing the point here.
> If I dress the meta frame into a PTP frame (btw is there any
> preferable event message for this purpose?) then sure, I'll make
> dsa_skb_defer_rx_timestamp call my .port_rxtstamp and I can e.g. move
> my state machine there.
> The problem is that in the current DSA structure, I'll still have less
> timestampable frames waiting for a meta frame than meta frames
> themselves. This is because not all frames that the switch takes an RX
> timestamp for will make it to my .port_rxtstamp (in fact that is what
> my .can_timestamp patch changes). I can put the timestampable frame in
> a 1-entry wait queue which I'll deplete upon arrival of the first meta
> frame, but when I get meta frames and the wait queue is empty, it can
> mean multiple things: either DSA didn't care about this timestamp
> (ok), or the timestampable frame got reordered or dropped by the MAC,
> or what have you (not ok). So I can't exclude the possibility that the
> meta frame was holding a relevant timestamp.
> Sure, I can dress the meta frame into whatever the previous
> MAC-trapped frame was (PTP or not) and then I'll have .port_rxtstamp
> function see a 1-to-1 correspondence with meta frames in case
> everything works fine. But then I'll have non-PTP meta frames leaking
> up the stack...
>

Actually maybe this is exactly what you meant and I didn't think it through.
If RX timestamping is enabled, then I can just copy all MAC-trapped
frames to a private skb in a per-driver data structure, and have DSA
drop them.
Then when their meta frame arrives, I can just morph them into what
the previous frame was, just that now I'm also holding the partial
timestamp in skb->cb.
PTP frames will reconstruct the full timestamp without waiting for any
meta (they are the meta), while other MAC-trapped frames (STP etc)
will just carry a meaningless skb->cb when passed up the stack.
In retrospect, it would have been amazing if the switch gave me the
meta frames *before* the actual link-local frames that needed the
timestamp.

Thanks!
-Vladimir

> Regards,
> -Vladimir
>
> > Thanks,
> > Richard