Skip to content

Commit 6fea33e

Browse files
yoongsiang2bruce-richardson
authored andcommitted
net/e1000: use device timestamp for clock read in igc
Change eth_igc_read_clock() to read from hardware timestamp registers (E1000_SYSTIML/E1000_SYSTIMH) instead of using system clock_gettime(). This ensures that the clock reading is consistent with the hardware's internal time base used for Qbv cycle and launch time scheduling, providing better accuracy for Time-Sensitive Networking applications. Fixes: 9630f7c ("net/igc: enable launch time offloading") Cc: [email protected] Signed-off-by: David Zage <[email protected]> Signed-off-by: Song Yoong Siang <[email protected]> Acked-by: Bruce Richardson <[email protected]>
1 parent cd60dcd commit 6fea33e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.mailmap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ David Riddoch <[email protected]>
351351
352352
David Verbeiren <[email protected]>
353353
David Wilder <[email protected]>
354+
David Zage <[email protected]>
354355
David Zeng <[email protected]>
355356
Davide Caratti <[email protected]>
356357
Dawid Gorecki <[email protected]>
@@ -1525,6 +1526,7 @@ Solal Pirelli <[email protected]>
15251526
Solganik Alexander <[email protected]>
15261527
Somnath Kotur <[email protected]>
15271528
Song Jiale <[email protected]>
1529+
Song Yoong Siang <[email protected]>
15281530
15291531
Sony Chacko <[email protected]>
15301532
Sotiris Salloumis <[email protected]>

drivers/net/intel/e1000/igc_ethdev.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,6 +2813,12 @@ eth_igc_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
28132813
{
28142814
struct e1000_hw *hw = IGC_DEV_PRIVATE_HW(dev);
28152815

2816+
/*
2817+
* Reading the SYSTIML register latches the upper 32 bits to the SYSTIMH
2818+
* shadow register for coherent access. As long as we read SYSTIML first
2819+
* followed by SYSTIMH, we avoid race conditions where the time rolls
2820+
* over between the two register reads.
2821+
*/
28162822
ts->tv_nsec = E1000_READ_REG(hw, E1000_SYSTIML);
28172823
ts->tv_sec = E1000_READ_REG(hw, E1000_SYSTIMH);
28182824

@@ -2972,10 +2978,10 @@ eth_igc_timesync_disable(struct rte_eth_dev *dev)
29722978
static int
29732979
eth_igc_read_clock(__rte_unused struct rte_eth_dev *dev, uint64_t *clock)
29742980
{
2975-
struct timespec system_time;
2981+
struct timespec ts;
29762982

2977-
clock_gettime(CLOCK_REALTIME, &system_time);
2978-
*clock = system_time.tv_sec * NSEC_PER_SEC + system_time.tv_nsec;
2983+
eth_igc_timesync_read_time(dev, &ts);
2984+
*clock = rte_timespec_to_ns(&ts);
29792985

29802986
return 0;
29812987
}

0 commit comments

Comments
 (0)