]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: mscc: allow offloading timestamping operations to the PHY
authorAntoine Tenart <antoine.tenart@bootlin.com>
Tue, 26 May 2020 15:01:49 +0000 (17:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 21:54:31 +0000 (14:54 -0700)
This patch adds support for offloading timestamping operations not only
to the Ocelot switch (as already supported) but to compatible PHYs.
When both the PHY and the Ocelot switch support timestamping operations,
the PHY implementation is chosen as the timestamp will happen closer to
the medium.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/mscc/ocelot_board.c

index 2151c08a57c78e84d1d0e3e38ab5fbf779d6d1dc..9cfe1fd98c3078f8a15eb25b12d7fdc0378073e7 100644 (file)
@@ -1204,7 +1204,10 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        struct ocelot *ocelot = priv->port.ocelot;
        int port = priv->chip_port;
 
-       if (ocelot->ptp) {
+       /* If the attached PHY device isn't capable of timestamping operations,
+        * use our own (when possible).
+        */
+       if (!phy_has_hwtstamp(dev->phydev) && ocelot->ptp) {
                switch (cmd) {
                case SIOCSHWTSTAMP:
                        return ocelot_hwstamp_set(ocelot, port, ifr);
index 67a8d61c926a666258a97ad2aa427ee4eac47fc6..4a15d2ff8b7064aad6b7067ee4a168d3653fc4ca 100644 (file)
@@ -189,7 +189,8 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg)
                        skb->offload_fwd_mark = 1;
 
                skb->protocol = eth_type_trans(skb, dev);
-               netif_rx(skb);
+               if (!skb_defer_rx_timestamp(skb))
+                       netif_rx(skb);
                dev->stats.rx_bytes += len;
                dev->stats.rx_packets++;
        } while (ocelot_read(ocelot, QS_XTR_DATA_PRESENT) & BIT(grp));