• Jacob Keller's avatar
    ixgbe: Check PTP Rx timestamps via BPF filter · 1d1a79b5
    Jacob Keller authored
    This patch fixes a potential Rx timestamp deadlock that causes the Rx
    timestamping to stall indefinitely. The issue could occur when a PTP packet is
    timestamped by hardware but never reaches the Rx queue. In order to prevent a
    permanent loss of timestamping, the RXSTMP(L/H) registers have to be read to
    unlock them. (This used to only occur when a packet that was timestamped
    reached the software.) However the registers can't be read early otherwise
    there is no way to correlate them to the packet.
    
    This patch introduces a filter function which can be used to determine if a
    packet should have been timestamped. Supplied with the filter setup by the
    hwtstamp ioctl, check to make sure the PTP protocol and message type match the
    expected values. If so, then read the timestamp registers (to free them.) At
    this point check the descriptor bit, if the bit is set then we know this
    packet correlates to the timestamp stored in the RXTSTAMP registers.
    Otherwise, assume that packet was dropped by the hardware, and ignore this
    timestamp value. However, we have at least unlocked the rxtstamp registers for
    future timestamping.
    
    Due to the way the driver handles skb data, it cannot be directly accessed. In
    order to work around this, a copy of the skb data into a linear buffer is
    made. From this buffer it becomes possible to read the data correctly
    Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: default avatarRichard Cochran <richardcochran@gmail.com>
    Tested-by: default avatarPhil Schmitt <phillip.j.schmitt@intel.com>
    Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
    1d1a79b5
ixgbe_ptp.c 28.9 KB