Skip to content

Commit 59c871c

Browse files
kuba-mooJeff Kirsher
authored andcommitted
e1000e: add timeout for TX HW time stamping work
Hardware may fail to report time stamp e.g.: - when hardware time stamping is not enabled - when time stamp is requested shortly after ifup Timeout time stamp reading work to prevent it from scheduling itself indefinitely. Report timeout events via system log and device stats. Signed-off-by: Jakub Kicinski <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 13c2884 commit 59c871c

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ struct e1000_adapter {
262262
u32 tx_head_addr;
263263
u32 tx_fifo_size;
264264
u32 tx_dma_failed;
265+
u32 tx_hwtstamp_timeouts;
265266

266267
/* Rx */
267268
bool (*clean_rx) (struct e1000_ring *ring, int *work_done,
@@ -334,6 +335,7 @@ struct e1000_adapter {
334335
struct hwtstamp_config hwtstamp_config;
335336
struct delayed_work systim_overflow_work;
336337
struct sk_buff *tx_hwtstamp_skb;
338+
unsigned long tx_hwtstamp_start;
337339
struct work_struct tx_hwtstamp_work;
338340
spinlock_t systim_lock; /* protects SYSTIML/H regsters */
339341
struct cyclecounter cc;

drivers/net/ethernet/intel/e1000e/ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static const struct e1000_stats e1000_gstrings_stats[] = {
104104
E1000_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
105105
E1000_STAT("uncorr_ecc_errors", uncorr_errors),
106106
E1000_STAT("corr_ecc_errors", corr_errors),
107+
E1000_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts),
107108
};
108109

109110
#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,12 @@ static void e1000e_tx_hwtstamp_work(struct work_struct *work)
11631163
skb_tstamp_tx(adapter->tx_hwtstamp_skb, &shhwtstamps);
11641164
dev_kfree_skb_any(adapter->tx_hwtstamp_skb);
11651165
adapter->tx_hwtstamp_skb = NULL;
1166+
} else if (time_after(jiffies, adapter->tx_hwtstamp_start
1167+
+ adapter->tx_timeout_factor * HZ)) {
1168+
dev_kfree_skb_any(adapter->tx_hwtstamp_skb);
1169+
adapter->tx_hwtstamp_skb = NULL;
1170+
adapter->tx_hwtstamp_timeouts++;
1171+
e_warn("clearing Tx timestamp hang");
11661172
} else {
11671173
/* reschedule to check later */
11681174
schedule_work(&adapter->tx_hwtstamp_work);
@@ -5567,6 +5573,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
55675573
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
55685574
tx_flags |= E1000_TX_FLAGS_HWTSTAMP;
55695575
adapter->tx_hwtstamp_skb = skb_get(skb);
5576+
adapter->tx_hwtstamp_start = jiffies;
55705577
schedule_work(&adapter->tx_hwtstamp_work);
55715578
} else {
55725579
skb_tx_timestamp(skb);

0 commit comments

Comments
 (0)