[09/27] igb: Use timecounter_initialize interface

Message ID 1513323522-15021-10-git-send-email-sagar.a.kamble@intel.com
State Awaiting Upstream
Delegated to: Jeff Kirsher
Headers show
Series
  • [01/27] timecounter: Make cyclecounter struct part of timecounter struct
Related show

Commit Message

Sagar Arun Kamble Dec. 15, 2017, 7:38 a.m.
With new interface timecounter_initialize we can initialize timecounter
fields and underlying cyclecounter together. Update igb ptp timecounter
init with this new function.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/net/ethernet/intel/igb/igb.h     |  4 ++++
 drivers/net/ethernet/intel/igb/igb_ptp.c | 23 ++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

Comments

Brown, Aaron F Jan. 6, 2018, 5:14 a.m. | #1
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On
> Behalf Of Sagar Arun Kamble
> Sent: Thursday, December 14, 2017 11:38 PM
> To: linux-kernel@vger.kernel.org
> Cc: intel-wired-lan@lists.osuosl.org; Richard Cochran
> <richardcochran@gmail.com>; Kamble, Sagar A
> <sagar.a.kamble@intel.com>; netdev@vger.kernel.org
> Subject: [Intel-wired-lan] [PATCH 09/27] igb: Use timecounter_initialize
> interface
> 
> With new interface timecounter_initialize we can initialize timecounter
> fields and underlying cyclecounter together. Update igb ptp timecounter
> init with this new function.
> 
> Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> Cc: intel-wired-lan@lists.osuosl.org
> Cc: netdev@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> ---
>  drivers/net/ethernet/intel/igb/igb.h     |  4 ++++
>  drivers/net/ethernet/intel/igb/igb_ptp.c | 23 ++++++++++++++---------
>  2 files changed, 18 insertions(+), 9 deletions(-)
> 

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index 4eac4f2..4ef5632 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -566,6 +566,10 @@  struct igb_adapter {
 	unsigned int ptp_flags;
 	spinlock_t tmreg_lock;
 	struct timecounter tc;
+	u64 (*cc_read)(const struct cyclecounter *cc);
+	u64 cc_mask;
+	u32 cc_mult;
+	u32 cc_shift;
 	u32 tx_hwtstamp_timeouts;
 	u32 tx_hwtstamp_skipped;
 	u32 rx_hwtstamp_cleared;
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 0745eff..f6c1a8d 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -1126,10 +1126,10 @@  void igb_ptp_init(struct igb_adapter *adapter)
 		adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576;
 		adapter->ptp_caps.settime64 = igb_ptp_settime_82576;
 		adapter->ptp_caps.enable = igb_ptp_feature_enable;
-		adapter->tc.cc.read = igb_ptp_read_82576;
-		adapter->tc.cc.mask = CYCLECOUNTER_MASK(64);
-		adapter->tc.cc.mult = 1;
-		adapter->tc.cc.shift = IGB_82576_TSYNC_SHIFT;
+		adapter->cc_read = igb_ptp_read_82576;
+		adapter->cc_mask = CYCLECOUNTER_MASK(64);
+		adapter->cc_mult = 1;
+		adapter->cc_shift = IGB_82576_TSYNC_SHIFT;
 		adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK;
 		break;
 	case e1000_82580:
@@ -1145,10 +1145,10 @@  void igb_ptp_init(struct igb_adapter *adapter)
 		adapter->ptp_caps.gettime64 = igb_ptp_gettime_82576;
 		adapter->ptp_caps.settime64 = igb_ptp_settime_82576;
 		adapter->ptp_caps.enable = igb_ptp_feature_enable;
-		adapter->tc.cc.read = igb_ptp_read_82580;
-		adapter->tc.cc.mask = CYCLECOUNTER_MASK(IGB_NBITS_82580);
-		adapter->tc.cc.mult = 1;
-		adapter->tc.cc.shift = 0;
+		adapter->cc_read = igb_ptp_read_82580;
+		adapter->cc_mask = CYCLECOUNTER_MASK(IGB_NBITS_82580);
+		adapter->cc_mult = 1;
+		adapter->cc_shift = 0;
 		adapter->ptp_flags |= IGB_PTP_OVERFLOW_CHECK;
 		break;
 	case e1000_i210:
@@ -1289,7 +1289,12 @@  void igb_ptp_reset(struct igb_adapter *adapter)
 
 		igb_ptp_write_i210(adapter, &ts);
 	} else {
-		timecounter_init(&adapter->tc, ktime_to_ns(ktime_get_real()));
+		timecounter_initialize(&adapter->tc,
+				       adapter->cc_read,
+				       adapter->cc_mask,
+				       adapter->cc_mult,
+				       adapter->cc_shift,
+				       ktime_to_ns(ktime_get_real()));
 	}
 out:
 	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);