@@ -534,7 +534,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
534
534
}
535
535
536
536
/**
537
- * stmmac_hwtstamp_ioctl - control hardware timestamping.
537
+ * stmmac_hwtstamp_set - control hardware timestamping.
538
538
* @dev: device pointer.
539
539
* @ifr: An IOCTL specific structure, that can contain a pointer to
540
540
* a proprietary structure used to pass information to the driver.
@@ -544,7 +544,7 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p,
544
544
* Return Value:
545
545
* 0 on success and an appropriate -ve integer on failure.
546
546
*/
547
- static int stmmac_hwtstamp_ioctl (struct net_device * dev , struct ifreq * ifr )
547
+ static int stmmac_hwtstamp_set (struct net_device * dev , struct ifreq * ifr )
548
548
{
549
549
struct stmmac_priv * priv = netdev_priv (dev );
550
550
struct hwtstamp_config config ;
@@ -573,7 +573,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
573
573
}
574
574
575
575
if (copy_from_user (& config , ifr -> ifr_data ,
576
- sizeof (struct hwtstamp_config )))
576
+ sizeof (config )))
577
577
return - EFAULT ;
578
578
579
579
netdev_dbg (priv -> dev , "%s config flags:0x%x, tx_type:0x%x, rx_filter:0x%x\n" ,
@@ -765,8 +765,31 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
765
765
(u32 )now .tv_sec , now .tv_nsec );
766
766
}
767
767
768
+ memcpy (& priv -> tstamp_config , & config , sizeof (config ));
769
+
768
770
return copy_to_user (ifr -> ifr_data , & config ,
769
- sizeof (struct hwtstamp_config )) ? - EFAULT : 0 ;
771
+ sizeof (config )) ? - EFAULT : 0 ;
772
+ }
773
+
774
+ /**
775
+ * stmmac_hwtstamp_get - read hardware timestamping.
776
+ * @dev: device pointer.
777
+ * @ifr: An IOCTL specific structure, that can contain a pointer to
778
+ * a proprietary structure used to pass information to the driver.
779
+ * Description:
780
+ * This function obtain the current hardware timestamping settings
781
+ as requested.
782
+ */
783
+ static int stmmac_hwtstamp_get (struct net_device * dev , struct ifreq * ifr )
784
+ {
785
+ struct stmmac_priv * priv = netdev_priv (dev );
786
+ struct hwtstamp_config * config = & priv -> tstamp_config ;
787
+
788
+ if (!(priv -> dma_cap .time_stamp || priv -> dma_cap .atime_stamp ))
789
+ return - EOPNOTSUPP ;
790
+
791
+ return copy_to_user (ifr -> ifr_data , config ,
792
+ sizeof (* config )) ? - EFAULT : 0 ;
770
793
}
771
794
772
795
/**
@@ -3767,7 +3790,10 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
3767
3790
ret = phy_mii_ioctl (dev -> phydev , rq , cmd );
3768
3791
break ;
3769
3792
case SIOCSHWTSTAMP :
3770
- ret = stmmac_hwtstamp_ioctl (dev , rq );
3793
+ ret = stmmac_hwtstamp_set (dev , rq );
3794
+ break ;
3795
+ case SIOCGHWTSTAMP :
3796
+ ret = stmmac_hwtstamp_get (dev , rq );
3771
3797
break ;
3772
3798
default :
3773
3799
break ;
0 commit comments