• Petr Machata's avatar
    mlxsw: spectrum_ptp: Keep unmatched entries in a linked list · 8028ccda
    Petr Machata authored
    To identify timestamps for matching with their packets, Spectrum-1 uses a
    five-tuple of (port, direction, domain number, message type, sequence ID).
    If there are several clients from the same domain behind a single port
    sending Delay_Req's, the only thing differentiating these packets, as far
    as Spectrum-1 is concerned, is the sequence ID. Should sequence IDs between
    individual clients be similar, conflicts may arise. That is not a problem
    to hardware, which will simply deliver timestamps on a first comes, first
    served basis.
    
    However the driver uses a simple hash table to store the unmatched pieces.
    When a new conflicting piece arrives, it pushes out the previously stored
    one, which if it is a packet, is delivered without timestamp. Later on as
    the corresponding timestamps arrive, the first one is mismatched to the
    second packet, and the second one is never matched and eventually is GCd.
    
    To correct this issue, instead of using a simple rhashtable, use rhltable
    to keep the unmatched entries.
    
    Previously, a found unmatched entry would always be removed from the hash
    table. That is not the case anymore--an incompatible entry is left in the
    hash table. Therefore removal from the hash table cannot be used to confirm
    the validity of the looked-up pointer, instead the lookup would simply need
    to be redone. Therefore move it inside the critical section. This
    simplifies a lot of the code.
    
    Fixes: 87486427 ("mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls")
    Reported-by: default avatarAlex Veber <alexve@mellanox.com>
    Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
    Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    8028ccda
spectrum_ptp.c 29.6 KB