aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2014-06-05 03:25:10 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2014-06-11 11:45:55 -0400
commit9f62ecf4255ea0fb3e653fc5fc91ef7b38812bb5 (patch)
tree20de60c1bbb89bd9e68f194b2089d6f39c6c88e6
parent23d87824de22002b6e073049bb57c97c309e5263 (diff)
igb: separate hardware setting from the set_ts_config ioctl
This patch separates the hardware logic from the set function, so that we can re-use it during a ptp_reset. This enables the reset to return functionality to the last known timestamp mode, rather than resetting the value. We initialize the mode to off during the ptp_init cycle. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ptp.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index e291be20dc98..794c139f0cc0 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -559,10 +559,11 @@ int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
559 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? 559 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ?
560 -EFAULT : 0; 560 -EFAULT : 0;
561} 561}
562
562/** 563/**
563 * igb_ptp_set_ts_config - control hardware time stamping 564 * igb_ptp_set_timestamp_mode - setup hardware for timestamping
564 * @netdev: 565 * @adapter: networking device structure
565 * @ifreq: 566 * @config: hwtstamp configuration
566 * 567 *
567 * Outgoing time stamping can be enabled and disabled. Play nice and 568 * Outgoing time stamping can be enabled and disabled. Play nice and
568 * disable it when requested, although it shouldn't case any overhead 569 * disable it when requested, although it shouldn't case any overhead
@@ -575,12 +576,11 @@ int igb_ptp_get_ts_config(struct net_device *netdev, struct ifreq *ifr)
575 * type has to be specified. Matching the kind of event packet is 576 * type has to be specified. Matching the kind of event packet is
576 * not supported, with the exception of "all V2 events regardless of 577 * not supported, with the exception of "all V2 events regardless of
577 * level 2 or 4". 578 * level 2 or 4".
578 **/ 579 */
579int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr) 580static int igb_ptp_set_timestamp_mode(struct igb_adapter *adapter,
581 struct hwtstamp_config *config)
580{ 582{
581 struct igb_adapter *adapter = netdev_priv(netdev);
582 struct e1000_hw *hw = &adapter->hw; 583 struct e1000_hw *hw = &adapter->hw;
583 struct hwtstamp_config *config = &adapter->tstamp_config;
584 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED; 584 u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED;
585 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; 585 u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED;
586 u32 tsync_rx_cfg = 0; 586 u32 tsync_rx_cfg = 0;
@@ -588,9 +588,6 @@ int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
588 bool is_l2 = false; 588 bool is_l2 = false;
589 u32 regval; 589 u32 regval;
590 590
591 if (copy_from_user(config, ifr->ifr_data, sizeof(*config)))
592 return -EFAULT;
593
594 /* reserved for future extensions */ 591 /* reserved for future extensions */
595 if (config->flags) 592 if (config->flags)
596 return -EINVAL; 593 return -EINVAL;
@@ -725,7 +722,33 @@ int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
725 regval = rd32(E1000_RXSTMPL); 722 regval = rd32(E1000_RXSTMPL);
726 regval = rd32(E1000_RXSTMPH); 723 regval = rd32(E1000_RXSTMPH);
727 724
728 return copy_to_user(ifr->ifr_data, config, sizeof(*config)) ? 725 return 0;
726}
727
728/**
729 * igb_ptp_set_ts_config - set hardware time stamping config
730 * @netdev:
731 * @ifreq:
732 *
733 **/
734int igb_ptp_set_ts_config(struct net_device *netdev, struct ifreq *ifr)
735{
736 struct igb_adapter *adapter = netdev_priv(netdev);
737 struct hwtstamp_config config;
738 int err;
739
740 if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
741 return -EFAULT;
742
743 err = igb_ptp_set_timestamp_mode(adapter, &config);
744 if (err)
745 return err;
746
747 /* save these settings for future reference */
748 memcpy(&adapter->tstamp_config, &config,
749 sizeof(adapter->tstamp_config));
750
751 return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
729 -EFAULT : 0; 752 -EFAULT : 0;
730} 753}
731 754
@@ -820,6 +843,9 @@ void igb_ptp_init(struct igb_adapter *adapter)
820 wr32(E1000_IMS, E1000_IMS_TS); 843 wr32(E1000_IMS, E1000_IMS_TS);
821 } 844 }
822 845
846 adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
847 adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
848
823 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps, 849 adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
824 &adapter->pdev->dev); 850 &adapter->pdev->dev);
825 if (IS_ERR(adapter->ptp_clock)) { 851 if (IS_ERR(adapter->ptp_clock)) {
@@ -884,7 +910,7 @@ void igb_ptp_reset(struct igb_adapter *adapter)
884 return; 910 return;
885 911
886 /* reset the tstamp_config */ 912 /* reset the tstamp_config */
887 memset(&adapter->tstamp_config, 0, sizeof(adapter->tstamp_config)); 913 igb_ptp_set_timestamp_mode(adapter, &adapter->tstamp_config);
888 914
889 switch (adapter->hw.mac.type) { 915 switch (adapter->hw.mac.type) {
890 case e1000_82576: 916 case e1000_82576: