]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: ethernet: ti: cpsw: Enable PHY timestamping
authorKurt Kanzenbach <kurt@linutronix.de>
Tue, 16 Nov 2021 08:03:25 +0000 (09:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 17 Nov 2021 14:34:33 +0000 (14:34 +0000)
If the used PHYs also support hardware timestamping, all configuration requests
should be forwared to the PHYs instead of being processed by the MAC driver
itself.

This enables PHY timestamping in combination with the cpsw driver.

Tested with an am335x based board with two DP83640 PHYs connected to the cpsw
switch.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/cpsw_priv.c

index ecc2a6b7e28f226a4f08ec7f1f83772d6058787c..c99dd9735087ded91833c15b6bb04231dd3cef47 100644 (file)
@@ -710,20 +710,26 @@ int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
        struct cpsw_priv *priv = netdev_priv(dev);
        struct cpsw_common *cpsw = priv->cpsw;
        int slave_no = cpsw_slave_index(cpsw, priv);
+       struct phy_device *phy;
 
        if (!netif_running(dev))
                return -EINVAL;
 
-       switch (cmd) {
-       case SIOCSHWTSTAMP:
-               return cpsw_hwtstamp_set(dev, req);
-       case SIOCGHWTSTAMP:
-               return cpsw_hwtstamp_get(dev, req);
+       phy = cpsw->slaves[slave_no].phy;
+
+       if (!phy_has_hwtstamp(phy)) {
+               switch (cmd) {
+               case SIOCSHWTSTAMP:
+                       return cpsw_hwtstamp_set(dev, req);
+               case SIOCGHWTSTAMP:
+                       return cpsw_hwtstamp_get(dev, req);
+               }
        }
 
-       if (!cpsw->slaves[slave_no].phy)
-               return -EOPNOTSUPP;
-       return phy_mii_ioctl(cpsw->slaves[slave_no].phy, req, cmd);
+       if (phy)
+               return phy_mii_ioctl(phy, req, cmd);
+
+       return -EOPNOTSUPP;
 }
 
 int cpsw_ndo_set_tx_maxrate(struct net_device *ndev, int queue, u32 rate)