[PATCH v1 2/4] net/ice: limit Tx time launch to hardware horizon
Soumyadeep Hore
soumyadeep.hore at intel.com
Wed Dec 2 13:56:21 CET 2026
The Tx time descriptor holds the launch time in 19 bits at 128 ns
resolution, a 67 ms window of which the hardware treats the half
ahead of the current time as the future and the other half as the
past. A launch time further ahead than about 33 ms wraps to an
unrelated time, so the packet is sent at the wrong time and can block
the queue head. The queue then drains far too slowly, and stopping
the port disables the Tx time queue with packets still pending, which
leaves the Tx time engine stuck until a core reset. Applications that
schedule far ahead, like testpmd txonly with a full Tx ring, hit it.
Sample the PHC once per Tx burst and send packets scheduled beyond
30 ms at that limit. Use the reserved timestamp 0 to send packets
without a launch time or with a launch time in the past immediately,
instead of using a stale mbuf timestamp, and never use it for a
scheduled packet.
Fixes: 0b6ff09a1f19 ("net/intel: support Tx packet pacing for E830")
Cc: stable at dpdk.org
Signed-off-by: Soumyadeep Hore <soumyadeep.hore at intel.com>
---
doc/guides/nics/ice.rst | 6 +++++
drivers/net/intel/ice/ice_rxtx.c | 42 ++++++++++++++++++++++++++++----
drivers/net/intel/ice/ice_rxtx.h | 3 +++
3 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/doc/guides/nics/ice.rst b/doc/guides/nics/ice.rst
index dab3aa53fb..993284d965 100644
--- a/doc/guides/nics/ice.rst
+++ b/doc/guides/nics/ice.rst
@@ -625,6 +625,12 @@ as to be placed in packet header.
The timestamps should be copied to packet mbufs
and manually adjust packet header length accordingly.
+The hardware can schedule a packet at most about 33 ms ahead.
+Packets with a launch time more than 30 ms in the future
+are sent 30 ms after they are queued,
+and packets without a launch time or with a launch time in the past
+are sent immediately.
+
Generic Flow Support
~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/net/intel/ice/ice_rxtx.c b/drivers/net/intel/ice/ice_rxtx.c
index cacfdbadd5..8a3c644b44 100644
--- a/drivers/net/intel/ice/ice_rxtx.c
+++ b/drivers/net/intel/ice/ice_rxtx.c
@@ -3105,6 +3105,23 @@ ice_get_ts_tail(struct ci_tx_queue *txq)
return txq->tsq->ts_tail;
}
+static uint64_t
+ice_txtime_now(struct ci_tx_queue *txq)
+{
+ struct ice_hw *hw = ICE_VSI_TO_HW(txq->ice_vsi);
+ uint8_t tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
+ uint32_t hi, lo, lo2;
+
+ lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
+ hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
+ lo2 = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
+ if (lo2 < lo) {
+ lo = ICE_READ_REG(hw, GLTSYN_TIME_L(tmr_idx));
+ hi = ICE_READ_REG(hw, GLTSYN_TIME_H(tmr_idx));
+ }
+ return ((uint64_t)hi << 32) | lo;
+}
+
static uint16_t
ice_write_ts_desc(struct ci_tx_queue *txq,
struct rte_mbuf *tx_pkt,
@@ -3112,9 +3129,22 @@ ice_write_ts_desc(struct ci_tx_queue *txq,
uint16_t ts_id)
{
uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, txq->tsq->ts_offset, uint64_t *);
- uint32_t tstamp = (uint32_t)(txtime % NS_PER_S) >> ICE_TXTIME_CTX_RESOLUTION_128NS;
+ uint32_t tstamp = 0;
const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
- __le32 ts_desc = rte_cpu_to_le_32(FIELD_PREP(ICE_TXTIME_TX_DESC_IDX_M, desc_tx_id) |
+ __le32 ts_desc;
+
+ /* Timestamp 0 means not paced: send unscheduled and late packets now */
+ if ((tx_pkt->ol_flags & txq->tsq->ts_flag) && txtime > txq->tsq->now) {
+ /* Further ahead the timestamp would read as expired */
+ if (txtime > txq->tsq->now + ICE_TXTIME_HORIZON_NS)
+ txtime = txq->tsq->now + ICE_TXTIME_HORIZON_NS;
+ tstamp = (uint32_t)(txtime % NS_PER_S) >> ICE_TXTIME_CTX_RESOLUTION_128NS;
+ tstamp &= ICE_TXTIME_STAMP_M >> rte_bsf32(ICE_TXTIME_STAMP_M);
+ if (tstamp == 0)
+ tstamp = 1;
+ }
+
+ ts_desc = rte_cpu_to_le_32(FIELD_PREP(ICE_TXTIME_TX_DESC_IDX_M, desc_tx_id) |
FIELD_PREP(ICE_TXTIME_STAMP_M, tstamp));
txq->tsq->ice_ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
@@ -3153,9 +3183,11 @@ ice_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
};
struct ci_tx_queue *txq = (struct ci_tx_queue *)tx_queue;
- if (txq->tsq != NULL && txq->tsq->ts_flag > 0)
- return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_TAG_IN_DATA_DESC, CI_TAG_IN_CTX_DESC,
- get_context_desc, NULL, &ts_fns);
+ if (txq->tsq != NULL && txq->tsq->ts_flag > 0) {
+ txq->tsq->now = ice_txtime_now(txq);
+ return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_TAG_IN_DATA_DESC,
+ CI_TAG_IN_CTX_DESC, get_context_desc, NULL, &ts_fns);
+ }
/* QinQ always places the outer tag in the ctx desc, inner in the data desc. */
return ci_xmit_pkts(txq, tx_pkts, nb_pkts, CI_TAG_IN_DATA_DESC, CI_TAG_IN_CTX_DESC,
diff --git a/drivers/net/intel/ice/ice_rxtx.h b/drivers/net/intel/ice/ice_rxtx.h
index 150e147df5..e4746e0193 100644
--- a/drivers/net/intel/ice/ice_rxtx.h
+++ b/drivers/net/intel/ice/ice_rxtx.h
@@ -40,6 +40,8 @@
/* Longer than the 19-bit, 128 ns Tx time horizon (~67 ms) */
#define ICE_TXTIME_DRAIN_TIMEOUT_US 100000
#define ICE_TXTIME_DRAIN_POLL_US 100
+/* Furthest launch time accepted, inside the ~33.5 ms future half of the window */
+#define ICE_TXTIME_HORIZON_NS 30000000ULL
#define ICE_REQ_DESC_MULTIPLE 32
#define ICE_RX_MAX_BURST CI_RX_MAX_BURST
@@ -162,6 +164,7 @@ struct ice_txtime {
uint16_t ts_tail; /* current value of tail register */
int ts_offset; /* dynamic mbuf Tx timestamp field offset */
uint64_t ts_flag; /* dynamic mbuf Tx timestamp flag */
+ uint64_t now; /* PHC time sampled at the start of a Tx burst */
const struct rte_memzone *ts_mz;
};
--
2.43.0
More information about the stable
mailing list