When CONFIG_NET_RX_BUSY_POLL is deactivated, fetching RX HW timestamps
from the NIC no longer works as expected, often resulting in incorrect
or negative values such as "HW raw -121948.050407424".
This occurs because disabling CONFIG_NET_RX_BUSY_POLL disables the
SKB NAPI mapping in __skb_mark_napi_id(). Consequently, get_timestamp()
fails to perform its driver lookup, and the igc driver's struct
net_device_ops::ndo_get_tstamp is never invoked.
Instead, get_timestamp() falls back to use shhwtstamps(skb)->hwtstamp,
a field that the driver has not populated. This results in incorrect
timestamps.
Fix this by populating the hwtstamp field with the correct timestamp
in the default timer when CONFIG_NET_RX_BUSY_POLL is disabled.
The "igc_adapter" is passed to igc_construct_skb() to enable
igc_ptp_rx_pktstamp() to access the necessary adapter details for
adjusting the timestamp.
Test case:
Disable CONFIG_NET_RX_BUSY_POLL.
Sender:
# tools/testing/selftests/net/timestamping en0 \
SOF_TIMESTAMPING_TX_HARDWARE PTPV2 IP_MULTICAST_LOOP
Receiver:
# tools/testing/selftests/net/timestamping en0 \
SOF_TIMESTAMPING_RX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE PTPV2
Before patch, receiver prints
HW raw -121948.050407424
After patch, receiver prints
HW raw 1760648763.746974064
Fixes: 069b142f5819 ("igc: Add support for PTP .getcyclesx64()")
Cc: stable@vger.kernel.org
Co-developed-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Ding Meng <meng.ding@siemens.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Piotr Kwapulinski <piotr.kwapulinski@intel.com>
---
V2:
- update commit message(suggested by Paul Menzel):
add error log
explain why need to pass igc_adapter
add test case
- move variable declarations on top of the function
- Cc stable@vger.kernel.org
V1: https://lore.kernel.org/intel-wired-lan/20260622041718.6106-1-meng.ding@siemens.com/
---
drivers/net/ethernet/intel/igc/igc_main.c | 41 ++++++++++++++++-------
1 file changed, 29 insertions(+), 12 deletions(-)
Tested-by: Avigail Dahan <avigailx.dahan@intel.com>