@@ -443,22 +443,52 @@ static int ixgbe_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
443
443
}
444
444
445
445
/**
446
- * ixgbe_ptp_gettime
446
+ * ixgbe_ptp_gettimex
447
447
* @ptp: the ptp clock structure
448
- * @ts: timespec structure to hold the current time value
448
+ * @ts: timespec to hold the PHC timestamp
449
+ * @sts: structure to hold the system time before and after reading the PHC
449
450
*
450
451
* read the timecounter and return the correct value on ns,
451
452
* after converting it into a struct timespec.
452
453
*/
453
- static int ixgbe_ptp_gettime (struct ptp_clock_info * ptp , struct timespec64 * ts )
454
+ static int ixgbe_ptp_gettimex (struct ptp_clock_info * ptp ,
455
+ struct timespec64 * ts ,
456
+ struct ptp_system_timestamp * sts )
454
457
{
455
458
struct ixgbe_adapter * adapter =
456
459
container_of (ptp , struct ixgbe_adapter , ptp_caps );
460
+ struct ixgbe_hw * hw = & adapter -> hw ;
457
461
unsigned long flags ;
458
- u64 ns ;
462
+ u64 ns , stamp ;
459
463
460
464
spin_lock_irqsave (& adapter -> tmreg_lock , flags );
461
- ns = timecounter_read (& adapter -> hw_tc );
465
+
466
+ switch (adapter -> hw .mac .type ) {
467
+ case ixgbe_mac_X550 :
468
+ case ixgbe_mac_X550EM_x :
469
+ case ixgbe_mac_x550em_a :
470
+ /* Upper 32 bits represent billions of cycles, lower 32 bits
471
+ * represent cycles. However, we use timespec64_to_ns for the
472
+ * correct math even though the units haven't been corrected
473
+ * yet.
474
+ */
475
+ ptp_read_system_prets (sts );
476
+ IXGBE_READ_REG (hw , IXGBE_SYSTIMR );
477
+ ptp_read_system_postts (sts );
478
+ ts -> tv_nsec = IXGBE_READ_REG (hw , IXGBE_SYSTIML );
479
+ ts -> tv_sec = IXGBE_READ_REG (hw , IXGBE_SYSTIMH );
480
+ stamp = timespec64_to_ns (ts );
481
+ break ;
482
+ default :
483
+ ptp_read_system_prets (sts );
484
+ stamp = IXGBE_READ_REG (hw , IXGBE_SYSTIML );
485
+ ptp_read_system_postts (sts );
486
+ stamp |= (u64 )IXGBE_READ_REG (hw , IXGBE_SYSTIMH ) << 32 ;
487
+ break ;
488
+ }
489
+
490
+ ns = timecounter_cyc2time (& adapter -> hw_tc , stamp );
491
+
462
492
spin_unlock_irqrestore (& adapter -> tmreg_lock , flags );
463
493
464
494
* ts = ns_to_timespec64 (ns );
@@ -567,10 +597,14 @@ void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter)
567
597
{
568
598
bool timeout = time_is_before_jiffies (adapter -> last_overflow_check +
569
599
IXGBE_OVERFLOW_PERIOD );
570
- struct timespec64 ts ;
600
+ unsigned long flags ;
571
601
572
602
if (timeout ) {
573
- ixgbe_ptp_gettime (& adapter -> ptp_caps , & ts );
603
+ /* Update the timecounter */
604
+ spin_lock_irqsave (& adapter -> tmreg_lock , flags );
605
+ timecounter_read (& adapter -> hw_tc );
606
+ spin_unlock_irqrestore (& adapter -> tmreg_lock , flags );
607
+
574
608
adapter -> last_overflow_check = jiffies ;
575
609
}
576
610
}
@@ -1216,7 +1250,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)
1216
1250
adapter -> ptp_caps .pps = 1 ;
1217
1251
adapter -> ptp_caps .adjfreq = ixgbe_ptp_adjfreq_82599 ;
1218
1252
adapter -> ptp_caps .adjtime = ixgbe_ptp_adjtime ;
1219
- adapter -> ptp_caps .gettime64 = ixgbe_ptp_gettime ;
1253
+ adapter -> ptp_caps .gettimex64 = ixgbe_ptp_gettimex ;
1220
1254
adapter -> ptp_caps .settime64 = ixgbe_ptp_settime ;
1221
1255
adapter -> ptp_caps .enable = ixgbe_ptp_feature_enable ;
1222
1256
adapter -> ptp_setup_sdp = ixgbe_ptp_setup_sdp_x540 ;
@@ -1233,7 +1267,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)
1233
1267
adapter -> ptp_caps .pps = 0 ;
1234
1268
adapter -> ptp_caps .adjfreq = ixgbe_ptp_adjfreq_82599 ;
1235
1269
adapter -> ptp_caps .adjtime = ixgbe_ptp_adjtime ;
1236
- adapter -> ptp_caps .gettime64 = ixgbe_ptp_gettime ;
1270
+ adapter -> ptp_caps .gettimex64 = ixgbe_ptp_gettimex ;
1237
1271
adapter -> ptp_caps .settime64 = ixgbe_ptp_settime ;
1238
1272
adapter -> ptp_caps .enable = ixgbe_ptp_feature_enable ;
1239
1273
break ;
@@ -1249,7 +1283,7 @@ static long ixgbe_ptp_create_clock(struct ixgbe_adapter *adapter)
1249
1283
adapter -> ptp_caps .pps = 0 ;
1250
1284
adapter -> ptp_caps .adjfreq = ixgbe_ptp_adjfreq_X550 ;
1251
1285
adapter -> ptp_caps .adjtime = ixgbe_ptp_adjtime ;
1252
- adapter -> ptp_caps .gettime64 = ixgbe_ptp_gettime ;
1286
+ adapter -> ptp_caps .gettimex64 = ixgbe_ptp_gettimex ;
1253
1287
adapter -> ptp_caps .settime64 = ixgbe_ptp_settime ;
1254
1288
adapter -> ptp_caps .enable = ixgbe_ptp_feature_enable ;
1255
1289
adapter -> ptp_setup_sdp = NULL ;
0 commit comments