Skip to content

Commit 9a2d57a

Browse files
mlichvarJeff Kirsher
authored andcommitted
i40e: extend PTP gettime function to read system clock
This adds support for the PTP_SYS_OFFSET_EXTENDED ioctl. Cc: Richard Cochran <[email protected]> Cc: Jacob Keller <[email protected]> Signed-off-by: Miroslav Lichvar <[email protected]> Tested-by: Andrew Bowers <[email protected]> Acked-by: Jacob Keller <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 31389b5 commit 9a2d57a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/net/ethernet/intel/i40e/i40e_ptp.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,23 @@
2828
* i40e_ptp_read - Read the PHC time from the device
2929
* @pf: Board private structure
3030
* @ts: timespec structure to hold the current time value
31+
* @sts: structure to hold the system time before and after reading the PHC
3132
*
3233
* This function reads the PRTTSYN_TIME registers and stores them in a
3334
* timespec. However, since the registers are 64 bits of nanoseconds, we must
3435
* convert the result to a timespec before we can return.
3536
**/
36-
static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts)
37+
static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts,
38+
struct ptp_system_timestamp *sts)
3739
{
3840
struct i40e_hw *hw = &pf->hw;
3941
u32 hi, lo;
4042
u64 ns;
4143

4244
/* The timer latches on the lowest register read. */
45+
ptp_read_system_prets(sts);
4346
lo = rd32(hw, I40E_PRTTSYN_TIME_L);
47+
ptp_read_system_postts(sts);
4448
hi = rd32(hw, I40E_PRTTSYN_TIME_H);
4549

4650
ns = (((u64)hi) << 32) | lo;
@@ -146,7 +150,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
146150

147151
mutex_lock(&pf->tmreg_lock);
148152

149-
i40e_ptp_read(pf, &now);
153+
i40e_ptp_read(pf, &now, NULL);
150154
timespec64_add_ns(&now, delta);
151155
i40e_ptp_write(pf, (const struct timespec64 *)&now);
152156

@@ -156,19 +160,21 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
156160
}
157161

158162
/**
159-
* i40e_ptp_gettime - Get the time of the PHC
163+
* i40e_ptp_gettimex - Get the time of the PHC
160164
* @ptp: The PTP clock structure
161165
* @ts: timespec structure to hold the current time value
166+
* @sts: structure to hold the system time before and after reading the PHC
162167
*
163168
* Read the device clock and return the correct value on ns, after converting it
164169
* into a timespec struct.
165170
**/
166-
static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
171+
static int i40e_ptp_gettimex(struct ptp_clock_info *ptp, struct timespec64 *ts,
172+
struct ptp_system_timestamp *sts)
167173
{
168174
struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
169175

170176
mutex_lock(&pf->tmreg_lock);
171-
i40e_ptp_read(pf, ts);
177+
i40e_ptp_read(pf, ts, sts);
172178
mutex_unlock(&pf->tmreg_lock);
173179

174180
return 0;
@@ -702,7 +708,7 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
702708
pf->ptp_caps.pps = 0;
703709
pf->ptp_caps.adjfreq = i40e_ptp_adjfreq;
704710
pf->ptp_caps.adjtime = i40e_ptp_adjtime;
705-
pf->ptp_caps.gettime64 = i40e_ptp_gettime;
711+
pf->ptp_caps.gettimex64 = i40e_ptp_gettimex;
706712
pf->ptp_caps.settime64 = i40e_ptp_settime;
707713
pf->ptp_caps.enable = i40e_ptp_feature_enable;
708714

0 commit comments

Comments
 (0)