• Vladimir Oltean's avatar
    gianfar: Fix TX timestamping with a stacked DSA driver · c26a2c2d
    Vladimir Oltean authored
    The driver wrongly assumes that it is the only entity that can set the
    SKBTX_IN_PROGRESS bit of the current skb. Therefore, in the
    gfar_clean_tx_ring function, where the TX timestamp is collected if
    necessary, the aforementioned bit is used to discriminate whether or not
    the TX timestamp should be delivered to the socket's error queue.
    
    But a stacked driver such as a DSA switch can also set the
    SKBTX_IN_PROGRESS bit, which is actually exactly what it should do in
    order to denote that the hardware timestamping process is undergoing.
    
    Therefore, gianfar would misinterpret the "in progress" bit as being its
    own, and deliver a second skb clone in the socket's error queue,
    completely throwing off a PTP process which is not expecting to receive
    it, _even though_ TX timestamping is not enabled for gianfar.
    
    There have been discussions [0] as to whether non-MAC drivers need or
    not to set SKBTX_IN_PROGRESS at all (whose purpose is to avoid sending 2
    timestamps, a sw and a hw one, to applications which only expect one).
    But as of this patch, there are at least 2 PTP drivers that would break
    in conjunction with gianfar: the sja1105 DSA switch and the felix
    switch, by way of its ocelot core driver.
    
    So regardless of that conclusion, fix the gianfar driver to not do stuff
    based on flags set by others and not intended for it.
    
    [0]: https://www.spinics.net/lists/netdev/msg619699.html
    
    Fixes: f0ee7acf ("gianfar: Add hardware TX timestamping support")
    Signed-off-by: default avatarVladimir Oltean <olteanv@gmail.com>
    Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c26a2c2d
gianfar.c 95.7 KB