* [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload
@ 2026-12-02 12:57 Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support Soumyadeep Hore
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
This series adds the Earliest TxTime First (ETF) offload, also known as
Tx packet pacing or send-on-timestamp, to the iavf driver on E830.
The first three patches take the virtchnl and register definitions from
the shared base code used by the Linux iavf driver. The VF requests the
VIRTCHNL_VF_OFFLOAD_TXTIME capability with VIRTCHNL_OP_GET_VF_CAPS2 and
passes a timestamp ring per Tx queue to the PF, which configures the Tx
time queue context. The launch time handling follows the fixed E830 PF
support: full PHC timestamp encoding rounded to 128 ns, a 30 ms horizon
and immediate send of unscheduled packets. As a device clock read is a
request to the PF, the Tx path estimates the clock with the TSC.
The offload needs a PF driver that supports Tx time for VFs.
Tested on an E830 100G VF, with a receiver timestamping every packet
in hardware:
- packets 10 us apart: 98.6% of the gaps within +-256 ns, 73 ns launch
jitter
- 8 Tx queues, bursts of 8 packets 128 ns apart: 100% within +-256 ns,
47 ns launch jitter
Known issue: the Linux ice PF driver does not disable the Tx time queue
of a VF when the VF stops its queues. Packets still pending then leave
the Tx time engine stuck until a core reset. This is being fixed in the
PF driver.
Paul Greenwalt (3):
net/iavf/base: add VF Earliest TxTime First offload support
net/iavf/base: add VF Earliest TxTime First offload flag
net/iavf/base: add VF Earliest TxTime First offload register
Soumyadeep Hore (3):
net/intel/common: add Tx time queue field for iavf
net/iavf: support Earliest TxTime First offload
doc: add iavf Earliest TxTime First offload
doc/guides/nics/intel_vf.rst | 35 ++++
doc/guides/rel_notes/release_27_03.rst | 6 +
drivers/net/intel/common/tx.h | 1 +
drivers/net/intel/iavf/base/iavf_register.h | 1 +
drivers/net/intel/iavf/base/iavf_type.h | 5 +
drivers/net/intel/iavf/base/virtchnl.h | 60 ++++++-
drivers/net/intel/iavf/iavf.h | 43 +++++
drivers/net/intel/iavf/iavf_ethdev.c | 181 ++++++++++++++++++++
drivers/net/intel/iavf/iavf_rxtx.c | 145 +++++++++++++++-
drivers/net/intel/iavf/iavf_rxtx.h | 23 +++
drivers/net/intel/iavf/iavf_vchnl.c | 65 +++++++
11 files changed, 561 insertions(+), 4 deletions(-)
base-commit: ddb3b0c47d172d951b1b3660e8acd754a6a92eb0
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 8:08 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag Soumyadeep Hore
` (4 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
From: Paul Greenwalt <paul.greenwalt@intel.com>
Virtual Function (VF) Earliest TxTime First (ETF) hardware offload
support is available on E830 hardware.
Changes made to support VF ETF:
- VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC accounts for the additional timestamp
descriptors required when wrapping around the timestamp ring. This
addresses a known hardware requirement when wrapping around the
timestamp ring that can produce a malicious driver detection event.
- struct virtchnl_txq_info and struct virtchnl_vsi_queue_config_info have
been updated to use a deprecated union for the ETF TxTime stamp.
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
drivers/net/intel/iavf/base/virtchnl.h | 30 +++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/net/intel/iavf/base/virtchnl.h b/drivers/net/intel/iavf/base/virtchnl.h
index c0d52ddd32..513e4b5d52 100644
--- a/drivers/net/intel/iavf/base/virtchnl.h
+++ b/drivers/net/intel/iavf/base/virtchnl.h
@@ -531,13 +531,36 @@ struct virtchnl_txq_info {
u16 vsi_id;
u16 queue_id;
u16 ring_len; /* number of descriptors, multiple of 8 */
- u16 headwb_enabled; /* deprecated with AVF 1.0 */
+ union {
+ u16 headwb_enabled; /* deprecated with AVF 1.0 */
+ u16 flags; /* see virtchnl_txq_info_flags */
+ };
u64 dma_ring_addr;
- u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
+ union {
+ u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
+ u64 dma_txtime_addr; /* address of the txtime buffer */
+ };
};
VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
+/* virtchnl_txq_info_flags - definition of bits in the flags field of the
+ * virtchnl_txq_info structure.
+ *
+ * @VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED: request to enable TXTIME offload
+ *
+ * Other flag bits are currently reserved and they may be extended in the
+ * future.
+ */
+enum virtchnl_txq_info_flags {
+ VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED = BIT(0),
+};
+
+/* Additional timestamp descriptors are required when wrapping around the
+ * timestamp ring, to avoid a malicious driver detection (MDD) event.
+ */
+#define VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC 16
+
/* RX descriptor IDs (range from 0 to 63) */
enum virtchnl_rx_desc_ids {
VIRTCHNL_RXDID_0_16B_BASE = 0,
@@ -658,7 +681,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
struct virtchnl_vsi_queue_config_info {
u16 vsi_id;
u16 num_queue_pairs;
- u32 pad;
+ u16 txtime_txqs; /* bitmap of TX queues with txtime enabled */
+ u16 pad;
struct virtchnl_queue_pair_info qpair[1];
};
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 8:09 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register Soumyadeep Hore
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
From: Paul Greenwalt <paul.greenwalt@intel.com>
Add the VF capability flag VIRTCHNL_VF_OFFLOAD_TXTIME to negotiate VF ETF
support between the PF and VF driver.
As the flag is beyond bit 31 of the legacy vf_cap_flags field, it is
negotiated through the extended capability message VIRTCHNL_OP_GET_VF_CAPS2
(struct virtchnl_vf_caps2), which is gated by the VIRTCHNL_VF_CAPS2 flag
in vf_cap_flags.
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
drivers/net/intel/iavf/base/virtchnl.h | 30 ++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/net/intel/iavf/base/virtchnl.h b/drivers/net/intel/iavf/base/virtchnl.h
index 513e4b5d52..f3f1965f00 100644
--- a/drivers/net/intel/iavf/base/virtchnl.h
+++ b/drivers/net/intel/iavf/base/virtchnl.h
@@ -195,6 +195,7 @@ enum virtchnl_ops {
VIRTCHNL_OP_HQOS_ELEMS_DEL = 133,
VIRTCHNL_OP_HQOS_ELEMS_MOVE = 134,
VIRTCHNL_OP_HQOS_ELEMS_CONF = 135,
+ VIRTCHNL_OP_GET_VF_CAPS2 = 136,
VIRTCHNL_OP_MAX,
};
@@ -361,6 +362,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
return "VIRTCHNL_OP_HQOS_ELEMS_MOVE";
case VIRTCHNL_OP_HQOS_ELEMS_CONF:
return "VIRTCHNL_OP_HQOS_ELEMS_CONF";
+ case VIRTCHNL_OP_GET_VF_CAPS2:
+ return "VIRTCHNL_OP_GET_VF_CAPS2";
case VIRTCHNL_OP_MAX:
return "VIRTCHNL_OP_MAX";
default:
@@ -471,6 +474,10 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
#define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
#define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
#define VIRTCHNL_VF_OFFLOAD_RSVD BIT(2)
+/* If set in vf_cap_flags, the VF and PF support the extended capability
+ * negotiation via VIRTCHNL_OP_GET_VF_CAPS2 (shares bit 2 with RSVD).
+ */
+#define VIRTCHNL_VF_CAPS2 BIT(2)
#define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
#define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
#define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
@@ -501,6 +508,14 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
#define VIRTCHNL_VF_CAP_DCF BIT(30)
#define VIRTCHNL_VF_CAP_PTP BIT(31)
+/* Extended VF capability flags negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
+ * These are bit positions in the extended capability bitmap (which includes
+ * the original 32 bits at the same positions), not bits within the 32-bit
+ * vf_cap_flags field. Flags greater than 31 are only available via caps2.
+ */
+#define VIRTCHNL_VF_OFFLOAD_TXTIME 32
+#define VIRTCHNL_VF_CAPS_MAX 33
+
#define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
VIRTCHNL_VF_OFFLOAD_VLAN | \
VIRTCHNL_VF_OFFLOAD_RSS_PF)
@@ -520,6 +535,21 @@ struct virtchnl_vf_resource {
VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
+/* VIRTCHNL_OP_GET_VF_CAPS2
+ * Generic extended capability flags. The VF sends this message to negotiate an
+ * extended set of capability flags if VIRTCHNL_VF_CAPS2 is set in
+ * virtchnl_vf_resource::vf_cap_flags. On send, the VF sets what capabilities it
+ * requests; on reply, the PF indicates what has been enabled for the VF. The
+ * bitmap includes the original 32 vf_cap_flags bits at the same positions, plus
+ * flags that do not fit there (e.g. VIRTCHNL_VF_OFFLOAD_TXTIME).
+ */
+struct virtchnl_vf_caps2 {
+ u32 flags_len;
+ u32 vf_cap_flags[];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_vf_caps2);
+
/* VIRTCHNL_OP_CONFIG_TX_QUEUE
* VF sends this message to set up parameters for one TX queue.
* External data buffer contains one instance of virtchnl_txq_info.
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 8:09 ` Kumar, Rajesh
2026-12-04 8:17 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf Soumyadeep Hore
` (2 subsequent siblings)
5 siblings, 2 replies; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
From: Paul Greenwalt <paul.greenwalt@intel.com>
Virtual Function (VF) Earliest TxTime First (ETF) hardware offload
support is available on E830 hardware.
Add the timestamp ring doorbell register IAVF_GLQTX_TXTIME_DBELL_LSB and
the Tx time stamp descriptor struct iavf_ts_desc.
Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
drivers/net/intel/iavf/base/iavf_register.h | 1 +
drivers/net/intel/iavf/base/iavf_type.h | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/drivers/net/intel/iavf/base/iavf_register.h b/drivers/net/intel/iavf/base/iavf_register.h
index 96df411e06..1ca5110c6a 100644
--- a/drivers/net/intel/iavf/base/iavf_register.h
+++ b/drivers/net/intel/iavf/base/iavf_register.h
@@ -83,6 +83,7 @@
#define IAVF_VFINT_STAT_CTL01 0x00005400 /* Reset: CORER */
#define IAVF_QRX_TAIL1(_Q) (0x00002000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: CORER */
#define IAVF_QTX_TAIL1(_Q) (0x00000000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: PFR */
+#define IAVF_GLQTX_TXTIME_DBELL_LSB(_Q) (0x0000D000 + ((_Q) * 8)) /* _Q=0...255 */ /* Reset: PFR */
#define IAVF_VFQF_HENA(_i) (0x0000C400 + ((_i) * 4)) /* _i=0...1 */ /* Reset: CORER */
#define IAVF_VFQF_HKEY(_i) (0x0000CC00 + ((_i) * 4)) /* _i=0...12 */ /* Reset: CORER */
#define IAVF_VFQF_HKEY_MAX_INDEX 12
diff --git a/drivers/net/intel/iavf/base/iavf_type.h b/drivers/net/intel/iavf/base/iavf_type.h
index b7d7027b9d..1597a49150 100644
--- a/drivers/net/intel/iavf/base/iavf_type.h
+++ b/drivers/net/intel/iavf/base/iavf_type.h
@@ -713,6 +713,11 @@ enum iavf_rx_prog_status_desc_error_bits {
#define IAVF_FOUR_BIT_MASK 0xF
#define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF
+/* Tx time stamp descriptor */
+struct iavf_ts_desc {
+ __le32 tx_desc_idx_tstamp;
+};
+
/* TX Descriptor */
struct iavf_tx_desc {
__le64 buffer_addr; /* Address of descriptor's data buf */
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
` (2 preceding siblings ...)
2026-12-02 12:57 ` [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 8:17 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 6/6] doc: add iavf " Soumyadeep Hore
5 siblings, 1 reply; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
The iavf driver gains Earliest TxTime First (ETF) offload support and
needs a pointer to its Tx time queue in the shared Tx queue structure.
Add it to the iavf-specific fields of struct ci_tx_queue.
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
drivers/net/intel/common/tx.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/intel/common/tx.h b/drivers/net/intel/common/tx.h
index 00bf90181c..2f47f62ce1 100644
--- a/drivers/net/intel/common/tx.h
+++ b/drivers/net/intel/common/tx.h
@@ -244,6 +244,7 @@ struct ci_tx_queue {
uint8_t vlan_flag;
uint8_t tc;
bool lldp_enabled;
+ struct iavf_txtime *iavf_tsq; /* Tx Time based queue */
};
struct { /* ixgbe specific values */
const struct ixgbe_txq_ops *ops;
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
` (3 preceding siblings ...)
2026-12-02 12:57 ` [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 10:41 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 6/6] doc: add iavf " Soumyadeep Hore
5 siblings, 1 reply; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
Add support for the Earliest TxTime First (ETF) offload, also known as
Tx Packet Pacing (SO_TXTIME), on iavf. It is available on E830 adapters
and is negotiated with the PF through the VIRTCHNL_VF_OFFLOAD_TXTIME
extended capability.
When RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP is requested on a Tx queue, the
driver allocates a timestamp ring alongside the Tx descriptor ring. For
each packet, the per-packet launch time is read from the dynamic mbuf Tx
timestamp field and written to the timestamp ring, and a dedicated
timestamp-ring doorbell is rung so that hardware transmits the packet at
the scheduled time. Extra timestamp descriptors are programmed on ring
wrap-around to avoid a malicious driver detection event.
The launch time is encoded from the PHC nanoseconds, rounded to the 128 ns
timestamp resolution. As the hardware treats the half of its 19-bit
timestamp window ahead of the current time as the future, launch times
further than 30 ms ahead are sent at that limit, and packets without a
launch time are sent immediately. The device time is estimated with the
TSC from the last PHC read, which is refreshed every second while Tx Time
is in use, so no PF request is needed in the Tx path.
The timestamp ring address and the per-queue enable flag are passed to
the PF via VIRTCHNL_OP_CONFIG_VSI_QUEUES. The extended VF capabilities
are negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
The PTP timesync dev ops (enable, disable, read Rx timestamp) and
read_clock are also implemented; applications such as testpmd use
read_clock to program the Tx launch times.
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
drivers/net/intel/iavf/iavf.h | 43 +++++++
drivers/net/intel/iavf/iavf_ethdev.c | 181 +++++++++++++++++++++++++++
drivers/net/intel/iavf/iavf_rxtx.c | 145 ++++++++++++++++++++-
drivers/net/intel/iavf/iavf_rxtx.h | 23 ++++
drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++
5 files changed, 456 insertions(+), 1 deletion(-)
diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 0c98ae28e1..67dbf21989 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -8,7 +8,9 @@
#include <sys/queue.h>
#include <ethdev_driver.h>
+#include <rte_cycles.h>
#include <rte_kvargs.h>
+#include <rte_seqlock.h>
#include <rte_tm_driver.h>
#include <iavf_prototype.h>
@@ -80,6 +82,9 @@
#define IAVF_ALARM_INTERVAL 50000 /* us */
#define IAVF_PHC_SYNC_ALARM_INTERVAL_US 200000
+/* Tx time clock anchor refresh period and age beyond which it is unused */
+#define IAVF_TXTIME_CLOCK_REFRESH_US 1000000
+#define IAVF_TXTIME_CLOCK_MAX_AGE_US 2000000
/* The overhead from MTU to max frame size.
* Considering QinQ packet, the VLAN tag needs to be counted twice.
@@ -297,6 +302,8 @@ struct iavf_info {
bool start_pending;
uint32_t ptp_caps;
+ uint64_t vf_cap_flags2; /* extended caps negotiated via GET_VF_CAPS2 */
+ bool stop_txtime; /* request a no-TXTIME reconfigure on teardown */
rte_spinlock_t phc_time_aq_lock;
};
@@ -381,6 +388,13 @@ enum iavf_tx_func_type {
#define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
#define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
+/* PHC time paired with the TSC at the middle of the PF request reading it */
+struct iavf_txtime_clock {
+ rte_seqlock_t lock;
+ uint64_t phc;
+ uint64_t tsc;
+};
+
/* Structure to store private data for each VF instance. */
struct iavf_adapter {
struct iavf_hw hw;
@@ -399,6 +413,7 @@ struct iavf_adapter {
rte_spinlock_t phc_sync_lock;
uint8_t phc_sync_ticks;
bool phc_sync_paused;
+ struct iavf_txtime_clock txtime_clk;
struct iavf_devargs devargs;
bool mac_primary_set;
bool adminq_polling; /* Interrupt setup fell back to alarm polling. */
@@ -421,6 +436,33 @@ iavf_get_eth_dev(struct iavf_adapter *adapter)
#define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX(adapter) \
(((struct iavf_adapter *)adapter)->security_ctx)
+/* Test an extended VF capability (bit position, e.g. VIRTCHNL_VF_OFFLOAD_TXTIME)
+ * negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
+ */
+#define IAVF_VF_CAP2(vf, bit) (((vf)->vf_cap_flags2 & RTE_BIT64(bit)) != 0)
+
+/* PHC time extrapolated with the TSC from the last PF read, 0 if unknown */
+static inline uint64_t
+iavf_txtime_clock_now(struct iavf_adapter *adapter)
+{
+ uint64_t hz = rte_get_tsc_hz();
+ uint64_t phc, tsc, elapsed;
+ uint32_t sn;
+
+ do {
+ sn = rte_seqlock_read_begin(&adapter->txtime_clk.lock);
+ phc = adapter->txtime_clk.phc;
+ tsc = adapter->txtime_clk.tsc;
+ } while (rte_seqlock_read_retry(&adapter->txtime_clk.lock, sn));
+
+ if (tsc == 0)
+ return 0;
+ elapsed = rte_rdtsc() - tsc;
+ if (elapsed > hz / US_PER_S * IAVF_TXTIME_CLOCK_MAX_AGE_US)
+ return 0;
+ return phc + elapsed * NS_PER_S / hz;
+}
+
/* IAVF_VSI_TO */
#define IAVF_VSI_TO_HW(vsi) \
(&(((struct iavf_vsi *)vsi)->adapter->hw))
@@ -529,6 +571,7 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
uint8_t *resp_msg, size_t resp_msg_len);
extern const struct rte_tm_ops iavf_tm_ops;
int iavf_get_ptp_cap(struct iavf_adapter *adapter);
+int iavf_get_vf_caps2(struct iavf_adapter *adapter);
int iavf_get_phc_time(struct ci_rx_queue *rxq);
int iavf_flow_sub(struct iavf_adapter *adapter,
struct iavf_fsub_conf *filter);
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index 10069feae2..efd6b2a122 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -169,6 +169,12 @@ static uint64_t iavf_get_restore_flags(struct rte_eth_dev *dev,
enum rte_eth_dev_operation op);
static int iavf_post_reset_reconfig(struct rte_eth_dev *dev);
static int iavf_timesync_read_time(struct rte_eth_dev *dev, struct timespec *timestamp);
+static int iavf_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
+static int iavf_timesync_enable(struct rte_eth_dev *dev);
+static int iavf_timesync_disable(struct rte_eth_dev *dev);
+static int iavf_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
+ struct timespec *timestamp,
+ uint32_t flags);
static const struct rte_pci_id pci_id_iavf_map[] = {
{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
@@ -270,6 +276,10 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
.tm_ops_get = iavf_tm_ops_get,
.get_restore_flags = iavf_get_restore_flags,
.timesync_read_time = iavf_timesync_read_time,
+ .read_clock = iavf_read_clock,
+ .timesync_enable = iavf_timesync_enable,
+ .timesync_disable = iavf_timesync_disable,
+ .timesync_read_rx_timestamp = iavf_timesync_read_rx_timestamp,
};
static int
@@ -1134,6 +1144,29 @@ iavf_dev_start(struct rte_eth_dev *dev)
return -1;
}
+/* Max time HW can hold a Tx time packet: 2^19 x 128 ns launch window. */
+#define IAVF_TXTIME_DRAIN_MS 68
+
+/* Disabling a Tx time queue while packets are still scheduled leaves the
+ * PF scheduler in a state that breaks Tx time in later runs, so give
+ * pending packets one launch window to be sent first.
+ */
+static void
+iavf_txtime_drain(struct rte_eth_dev *dev)
+{
+ uint16_t i;
+
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ struct ci_tx_queue *txq = dev->data->tx_queues[i];
+
+ if (txq != NULL && txq->iavf_tsq != NULL &&
+ txq->nb_tx_free < txq->nb_tx_desc - 1) {
+ rte_delay_ms(IAVF_TXTIME_DRAIN_MS);
+ return;
+ }
+ }
+}
+
static int
iavf_dev_stop(struct rte_eth_dev *dev)
{
@@ -1161,7 +1194,34 @@ iavf_dev_stop(struct rte_eth_dev *dev)
/* Rx interrupt vector mapping free */
rte_intr_vec_list_free(intr_handle);
+ iavf_txtime_drain(dev);
+
iavf_stop_queues(dev);
+
+ /* If Tx Time (ETF) was active, reconfigure the queues without the
+ * TXTIME flag so the PF cleanly releases the timestamp scheduler
+ * context. Tearing down while packets are still scheduled otherwise
+ * leaves stale state that breaks Tx Time in later runs.
+ */
+ if (vf->vf_cap_flags2 & RTE_BIT64(VIRTCHNL_VF_OFFLOAD_TXTIME)) {
+ bool txtime_active = false;
+ uint16_t i;
+
+ for (i = 0; i < dev->data->nb_tx_queues; i++) {
+ struct ci_tx_queue *txq = dev->data->tx_queues[i];
+
+ if (txq != NULL && txq->iavf_tsq != NULL) {
+ txtime_active = true;
+ break;
+ }
+ }
+ if (txtime_active) {
+ vf->stop_txtime = true;
+ if (iavf_configure_queues(adapter, vf->num_queue_pairs) != 0)
+ PMD_DRV_LOG(WARNING, "failed to disable Tx time queues");
+ vf->stop_txtime = false;
+ }
+ }
rte_free(vf->qv_map);
vf->qv_map = NULL;
@@ -1225,6 +1285,7 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
CI_TX_VEC_OFFLOAD_PATH_OFFLOADS | CI_TX_VEC_CTX_OFFLOAD_PATH_OFFLOADS) &
~(RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM |
RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
+ RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP |
RTE_ETH_TX_OFFLOAD_SECURITY);
/* X710 does not support outer udp checksum */
@@ -1238,6 +1299,9 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP)
dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
+ if (IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME))
+ dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP;
+
if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2 &&
vf->vlan_v2_caps.offloads.insertion_support.inner &&
vf->vlan_v2_caps.offloads.insertion_support.outer)
@@ -2726,6 +2790,12 @@ iavf_init_vf(struct rte_eth_dev *dev)
PMD_INIT_LOG(ERR, "iavf_get_vf_config failed");
goto err_alloc;
}
+
+ /* Negotiate extended capabilities (e.g. TXTIME) if the PF supports it. */
+ if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAPS2) {
+ if (iavf_get_vf_caps2(adapter) != 0)
+ PMD_INIT_LOG(WARNING, "failed to get VF extended capabilities");
+ }
/* Allocate memort for RSS info */
if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
vf->rss_key = rte_zmalloc("rss_key",
@@ -2921,6 +2991,29 @@ iavf_phc_sync_tick(struct rte_eth_dev *dev)
rte_spinlock_unlock(&adapter->phc_sync_lock);
}
+/* Keep the Tx time clock anchor fresh while Tx time is used */
+static void
+iavf_txtime_clock_tick(struct rte_eth_dev *dev)
+{
+ struct iavf_adapter *adapter =
+ IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+ uint64_t refresh = rte_get_tsc_hz() / US_PER_S * IAVF_TXTIME_CLOCK_REFRESH_US;
+ uint64_t phc;
+
+ if (!dev->data->dev_started || adapter->closed ||
+ !(dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) ||
+ !IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME) ||
+ !(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
+ !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_READ_PHC))
+ return;
+
+ if (rte_rdtsc() - adapter->txtime_clk.tsc < refresh)
+ return;
+
+ iavf_phc_get_time(adapter, &phc);
+}
+
void
iavf_dev_alarm_handler(void *param)
{
@@ -2948,6 +3041,7 @@ iavf_dev_alarm_handler(void *param)
}
iavf_phc_sync_tick(dev);
+ iavf_txtime_clock_tick(dev);
rte_eal_alarm_set(IAVF_ALARM_INTERVAL,
iavf_dev_alarm_handler, dev);
@@ -3084,6 +3178,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
adapter->tpid = RTE_ETHER_TYPE_VLAN; /* VLAN TPID set to 0x8100 by default */
rte_spinlock_init(&adapter->phc_sync_lock);
rte_spinlock_init(&vf->watchdog_lock);
+ rte_seqlock_init(&adapter->txtime_clk.lock);
if (!rte_atomic_load_explicit(&vf->in_reset_recovery, rte_memory_order_relaxed) &&
iavf_dev_event_handler_init())
@@ -3799,6 +3894,92 @@ iavf_timesync_read_time(struct rte_eth_dev *dev, struct timespec *timestamp)
return 0;
}
+static int
+iavf_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
+{
+ struct timespec ts;
+ int ret;
+
+ ret = iavf_timesync_read_time(dev, &ts);
+ if (ret)
+ return ret;
+
+ *clock = (uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
+
+ return 0;
+}
+
+static int
+iavf_timesync_enable(struct rte_eth_dev *dev)
+{
+ struct iavf_adapter *adapter =
+ IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+
+ if (adapter->closed)
+ return -EIO;
+
+ if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
+ !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))
+ return -ENOTSUP;
+
+ /* Rx timestamping is driven by the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload
+ * programmed at queue setup; there is nothing else to enable on the VF.
+ */
+ if (dev->data->dev_started &&
+ !(dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
+ PMD_DRV_LOG(ERR, "Rx timestamp offload not configured");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int
+iavf_timesync_disable(struct rte_eth_dev *dev)
+{
+ struct iavf_adapter *adapter =
+ IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+ if (adapter->closed)
+ return -EIO;
+
+ /* Nothing VF-specific to tear down; disabling the Rx timestamp offload
+ * is handled through the normal queue reconfiguration path.
+ */
+ return 0;
+}
+
+static int
+iavf_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
+ struct timespec *timestamp, uint32_t flags)
+{
+ struct iavf_adapter *adapter =
+ IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+ struct ci_rx_queue *rxq;
+
+ if (adapter->closed)
+ return -EIO;
+
+ if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
+ !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))
+ return -ENOTSUP;
+
+ /* The 'flags' argument carries the Rx queue index to read from. */
+ if (flags >= dev->data->nb_rx_queues)
+ return -EINVAL;
+
+ rxq = dev->data->rx_queues[flags];
+ if (rxq == NULL)
+ return -EINVAL;
+
+ /* The Rx path stores the most recent converted 64-bit timestamp. */
+ *timestamp = rte_ns_to_timespec(rxq->phc_time);
+
+ return 0;
+}
+
RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
diff --git a/drivers/net/intel/iavf/iavf_rxtx.c b/drivers/net/intel/iavf/iavf_rxtx.c
index 8c84991b86..af35ea538c 100644
--- a/drivers/net/intel/iavf/iavf_rxtx.c
+++ b/drivers/net/intel/iavf/iavf_rxtx.c
@@ -16,6 +16,7 @@
#include <rte_string_fns.h>
#include <rte_memzone.h>
#include <rte_mbuf.h>
+#include <rte_mbuf_dyn.h>
#include <rte_malloc.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -26,6 +27,7 @@
#include <rte_net.h>
#include <rte_vect.h>
#include <rte_bitops.h>
+#include <rte_cycles.h>
#include <rte_vxlan.h>
#include <rte_gtp.h>
#include <rte_geneve.h>
@@ -864,6 +866,64 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
dev->data->tx_queues[queue_idx] = txq;
txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx);
+ /* Earliest TxTime First (SO_TXTIME) offload: allocate a timestamp ring
+ * alongside the Tx descriptor ring. HW reads the per-packet transmit
+ * time from this ring to schedule the packet.
+ */
+ if (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
+ struct iavf_txtime *tsq;
+ const struct rte_memzone *ts_mz;
+ uint32_t ts_ring_size;
+
+ if (!(IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME))) {
+ PMD_INIT_LOG(ERR, "Tx Time offload is not supported by the PF");
+ iavf_dev_tx_queue_release(dev, queue_idx);
+ dev->data->tx_queues[queue_idx] = NULL;
+ return -ENOTSUP;
+ }
+
+ tsq = rte_zmalloc_socket("iavf txtime queue", sizeof(*tsq),
+ RTE_CACHE_LINE_SIZE, socket_id);
+ if (!tsq) {
+ PMD_INIT_LOG(ERR, "Failed to allocate memory for Tx time queue");
+ iavf_dev_tx_queue_release(dev, queue_idx);
+ dev->data->tx_queues[queue_idx] = NULL;
+ return -ENOMEM;
+ }
+ txq->iavf_tsq = tsq;
+
+ if (rte_mbuf_dyn_tx_timestamp_register(&tsq->ts_offset,
+ &tsq->ts_flag)) {
+ PMD_INIT_LOG(ERR, "Cannot register Tx mbuf field/flag for timestamp");
+ iavf_dev_tx_queue_release(dev, queue_idx);
+ dev->data->tx_queues[queue_idx] = NULL;
+ return -EINVAL;
+ }
+
+ /* Extra descriptors are needed to handle ring wrap-around. */
+ tsq->nb_ts_desc = nb_desc + VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC;
+ ts_ring_size = sizeof(struct iavf_ts_desc) * tsq->nb_ts_desc;
+ ts_ring_size = RTE_ALIGN(ts_ring_size, IAVF_DMA_MEM_ALIGN);
+ ts_mz = rte_eth_dma_zone_reserve(dev, "iavf_tstamp_ring", queue_idx,
+ ts_ring_size, IAVF_RING_BASE_ALIGN,
+ socket_id);
+ if (!ts_mz) {
+ PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for Tx timestamp ring");
+ iavf_dev_tx_queue_release(dev, queue_idx);
+ dev->data->tx_queues[queue_idx] = NULL;
+ return -ENOMEM;
+ }
+ tsq->ts_mz = ts_mz;
+ tsq->ts_ring = ts_mz->addr;
+ tsq->ts_tail = 0;
+
+ /* Tx Time uses a dedicated timestamp-ring doorbell register. The
+ * normal qtx_tail is kept so queue init writes the standard tail;
+ * the TS doorbell is only rung from the xmit path.
+ */
+ tsq->tail = hw->hw_addr + IAVF_GLQTX_TXTIME_DBELL_LSB(queue_idx);
+ }
+
if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
vf->tm_conf.committed) {
int tc;
@@ -956,6 +1016,16 @@ iavf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
txq = dev->data->tx_queues[tx_queue_id];
+ /* For a Tx Time queue, start from a clean timestamp ring and tail so a
+ * stale state left by a previous, non-drained run is not fetched by
+ * hardware once the queue is re-enabled.
+ */
+ if (txq->iavf_tsq != NULL) {
+ memset((void *)(uintptr_t)txq->iavf_tsq->ts_ring, 0,
+ txq->iavf_tsq->nb_ts_desc * sizeof(struct iavf_ts_desc));
+ txq->iavf_tsq->ts_tail = 0;
+ }
+
/* Init the RX tail register. */
IAVF_PCI_REG_WRITE(txq->qtx_tail, 0);
IAVF_WRITE_FLUSH(hw);
@@ -1068,6 +1138,11 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
ci_txq_release_all_mbufs(q, q->use_ctx);
rte_free(q->sw_ring);
rte_free(q->rs_last_id);
+ if (q->iavf_tsq) {
+ rte_memzone_free(q->iavf_tsq->ts_mz);
+ rte_free(q->iavf_tsq);
+ q->iavf_tsq = NULL;
+ }
rte_memzone_free(q->mz);
rte_free(q);
}
@@ -2591,6 +2666,62 @@ iavf_get_context_desc(uint64_t ol_flags, const struct rte_mbuf *mbuf,
return 1; /* One context descriptor needed */
}
+/* Tx Time (SO_TXTIME / ETF) timestamp-queue callbacks for ci_xmit_pkts */
+static uint16_t
+iavf_get_ts_tail(struct ci_tx_queue *txq)
+{
+ return txq->iavf_tsq->ts_tail;
+}
+
+static uint16_t
+iavf_write_ts_desc(struct ci_tx_queue *txq, struct rte_mbuf *tx_pkt,
+ uint16_t tx_id, uint16_t ts_id)
+{
+ struct iavf_txtime *tsq = txq->iavf_tsq;
+ uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, tsq->ts_offset, uint64_t *);
+ const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
+ uint32_t tstamp = 0;
+ rte_le32_t ts_desc;
+
+ /* Timestamp 0 means not paced: send unscheduled and long late packets now */
+ if ((tx_pkt->ol_flags & tsq->ts_flag) &&
+ (tsq->now == 0 || txtime + IAVF_TXTIME_HORIZON_NS >= tsq->now)) {
+ /* The clock estimate is coarse, only keep far times in the window */
+ if (tsq->now != 0 && txtime > tsq->now + IAVF_TXTIME_HORIZON_NS)
+ txtime = tsq->now + IAVF_TXTIME_HORIZON_NS;
+ /* The hardware compares against the free running PHC, not ns in second */
+ tstamp = (uint32_t)((txtime + IAVF_TXTIME_ROUND_NS) >>
+ IAVF_TXTIME_RESOLUTION_128NS);
+ tstamp &= IAVF_TXTIME_STAMP_M >> IAVF_TXTIME_STAMP_S;
+ if (tstamp == 0)
+ tstamp = 1;
+ }
+ ts_desc = rte_cpu_to_le_32((desc_tx_id & IAVF_TXTIME_TX_DESC_IDX_M) |
+ ((tstamp << IAVF_TXTIME_STAMP_S) & IAVF_TXTIME_STAMP_M));
+
+ tsq->ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
+ ts_id++;
+
+ /* To prevent an MDD, when wrapping the timestamp ring create additional
+ * TS descriptors equal to the number of fetch TS descriptors. HW merges
+ * TS descriptors with the same timestamp value into a single descriptor.
+ */
+ if (ts_id == tsq->nb_ts_desc) {
+ uint16_t fetch = tsq->nb_ts_desc - txq->nb_tx_desc;
+ ts_id = 0;
+ for (; ts_id < fetch; ts_id++)
+ tsq->ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
+ }
+ return ts_id;
+}
+
+static void
+iavf_write_ts_tail(struct ci_tx_queue *txq, uint16_t ts_id)
+{
+ IAVF_PCI_REG_WRITE(txq->iavf_tsq->tail, ts_id);
+ txq->iavf_tsq->ts_tail = ts_id;
+}
+
/* TX function */
uint16_t
iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
@@ -2605,7 +2736,19 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
.calc_segment_len = iavf_calc_ipsec_segment_len,
};
- /* IAVF does not support timestamp queues, so pass NULL for ts_fns */
+ /* If Tx Time offload is enabled, drive the timestamp ring doorbell. */
+ if (txq->iavf_tsq != NULL && txq->iavf_tsq->ts_flag > 0) {
+ const struct ci_timestamp_queue_fns ts_fns = {
+ .get_ts_tail = iavf_get_ts_tail,
+ .write_ts_desc = iavf_write_ts_desc,
+ .write_ts_tail = iavf_write_ts_tail,
+ };
+
+ txq->iavf_tsq->now = iavf_txtime_clock_now(txq->iavf_vsi->adapter);
+ return ci_xmit_pkts(txq, tx_pkts, nb_pkts, vlan_pos, vlan_pos,
+ iavf_get_context_desc, &ipsec_ops, &ts_fns);
+ }
+
return ci_xmit_pkts(txq, tx_pkts, nb_pkts, vlan_pos, vlan_pos,
iavf_get_context_desc, &ipsec_ops, NULL);
}
diff --git a/drivers/net/intel/iavf/iavf_rxtx.h b/drivers/net/intel/iavf/iavf_rxtx.h
index 812d7e23ee..5efa920974 100644
--- a/drivers/net/intel/iavf/iavf_rxtx.h
+++ b/drivers/net/intel/iavf/iavf_rxtx.h
@@ -21,6 +21,28 @@
/* Base address of the HW descriptor ring should be 128B aligned. */
#define IAVF_RING_BASE_ALIGN 128
+/* Tx Time (Earliest TxTime First / SO_TXTIME) offload definitions */
+#define IAVF_TXTIME_TX_DESC_IDX_M RTE_GENMASK32(12, 0)
+#define IAVF_TXTIME_STAMP_S 13
+#define IAVF_TXTIME_STAMP_M RTE_GENMASK32(31, 13)
+/* Tx time ring timestamp resolution is 128ns */
+#define IAVF_TXTIME_RESOLUTION_128NS 7
+#define IAVF_TXTIME_ROUND_NS (1 << (IAVF_TXTIME_RESOLUTION_128NS - 1))
+/* Furthest launch time accepted, inside the ~33.5 ms future half of the window */
+#define IAVF_TXTIME_HORIZON_NS 30000000ULL
+
+/* Structure associated with a Tx Time based queue */
+struct iavf_txtime {
+ volatile struct iavf_ts_desc *ts_ring; /* Tx time ring virtual address */
+ volatile uint8_t *tail; /* timestamp ring doorbell register address */
+ uint16_t nb_ts_desc; /* number of Tx Time descriptors */
+ 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; /* estimated PHC time at the start of a Tx burst, 0 if unknown */
+ const struct rte_memzone *ts_mz;
+};
+
/* used for Rx Bulk Allocate */
#define IAVF_RX_MAX_BURST CI_RX_MAX_BURST
@@ -51,6 +73,7 @@
RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | \
RTE_ETH_TX_OFFLOAD_SECURITY | \
+ RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP | \
RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
/* basic scalar path */
diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
index 64ca93c20b..57a6644896 100644
--- a/drivers/net/intel/iavf/iavf_vchnl.c
+++ b/drivers/net/intel/iavf/iavf_vchnl.c
@@ -856,6 +856,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
VIRTCHNL_VF_LARGE_NUM_QPAIRS |
VIRTCHNL_VF_OFFLOAD_QOS |
VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO |
+ VIRTCHNL_VF_CAPS2 |
VIRTCHNL_VF_CAP_PTP;
args.in_args = (uint8_t *)∩︀
@@ -1489,6 +1490,17 @@ iavf_configure_queue_pair(struct iavf_adapter *adapter,
if (q_idx < adapter->dev_data->nb_tx_queues) {
vc_qp->txq.ring_len = txq[q_idx]->nb_tx_desc;
vc_qp->txq.dma_ring_addr = txq[q_idx]->tx_ring_dma;
+
+ /* Tx Time (SO_TXTIME / ETF) offload: pass the timestamp ring
+ * address and request the PF to enable TXTIME on this queue.
+ * On teardown stop_txtime is set so the queue is reconfigured
+ * without the flag, releasing the PF scheduler context.
+ */
+ if (txq[q_idx]->iavf_tsq != NULL && !vf->stop_txtime) {
+ vc_qp->txq.flags |= VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED;
+ vc_qp->txq.dma_txtime_addr =
+ txq[q_idx]->iavf_tsq->ts_mz->iova;
+ }
}
/* is this rxq active? */
@@ -2568,6 +2580,51 @@ iavf_get_ptp_cap(struct iavf_adapter *adapter)
return 0;
}
+int
+iavf_get_vf_caps2(struct iavf_adapter *adapter)
+{
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+ uint8_t msg_buf[IAVF_AQ_BUF_SZ] = {0};
+ /* flags_len words cover all bits up to VIRTCHNL_VF_CAPS_MAX */
+ const uint32_t flags_len =
+ (VIRTCHNL_VF_CAPS_MAX + 31) / 32;
+ uint8_t req_buf[sizeof(struct virtchnl_vf_caps2) +
+ ((VIRTCHNL_VF_CAPS_MAX + 31) / 32) * sizeof(uint32_t)] = {0};
+ struct virtchnl_vf_caps2 *caps2 = (struct virtchnl_vf_caps2 *)req_buf;
+ struct virtchnl_vf_caps2 *resp;
+ struct iavf_cmd_info args;
+ uint32_t i;
+ int err;
+
+ /* Request the already-granted base caps plus the extended TXTIME bit. */
+ caps2->flags_len = flags_len;
+ caps2->vf_cap_flags[0] = vf->vf_res->vf_cap_flags;
+ caps2->vf_cap_flags[VIRTCHNL_VF_OFFLOAD_TXTIME / 32] |=
+ RTE_BIT32(VIRTCHNL_VF_OFFLOAD_TXTIME % 32);
+
+ args.ops = VIRTCHNL_OP_GET_VF_CAPS2;
+ args.in_args = req_buf;
+ args.in_args_size = sizeof(struct virtchnl_vf_caps2) +
+ flags_len * sizeof(uint32_t);
+ args.out_buffer = msg_buf;
+ args.out_size = IAVF_AQ_BUF_SZ;
+
+ err = iavf_execute_vf_cmd_safe(adapter, &args);
+ if (err) {
+ PMD_DRV_LOG(ERR,
+ "Failed to execute command of VIRTCHNL_OP_GET_VF_CAPS2");
+ return err;
+ }
+
+ /* The PF replies with the bitmap of enabled extended capabilities. */
+ resp = (struct virtchnl_vf_caps2 *)args.out_buffer;
+ vf->vf_cap_flags2 = 0;
+ for (i = 0; i < resp->flags_len && i < 2; i++)
+ vf->vf_cap_flags2 |= (uint64_t)resp->vf_cap_flags[i] << (32 * i);
+
+ return 0;
+}
+
int
iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
{
@@ -2575,6 +2632,7 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
uint8_t msg_buf[IAVF_AQ_BUF_SZ] = {0};
struct virtchnl_phc_time phc_time;
struct iavf_cmd_info args;
+ uint64_t tsc_start;
int err = 0;
args.ops = VIRTCHNL_OP_1588_PTP_GET_TIME;
@@ -2584,6 +2642,7 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
args.out_size = IAVF_AQ_BUF_SZ;
rte_spinlock_lock(&vf->phc_time_aq_lock);
+ tsc_start = rte_rdtsc();
err = iavf_execute_vf_cmd_safe(adapter, &args);
if (err) {
PMD_DRV_LOG(ERR,
@@ -2592,6 +2651,12 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
}
*time = ((struct virtchnl_phc_time *)args.out_buffer)->time;
+ /* anchor the Tx time clock estimate to the middle of the request */
+ rte_seqlock_write_lock(&adapter->txtime_clk.lock);
+ adapter->txtime_clk.phc = *time;
+ adapter->txtime_clk.tsc = tsc_start + (rte_rdtsc() - tsc_start) / 2;
+ rte_seqlock_write_unlock(&adapter->txtime_clk.lock);
+
out:
rte_spinlock_unlock(&vf->phc_time_aq_lock);
return err;
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v1 6/6] doc: add iavf Earliest TxTime First offload
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
` (4 preceding siblings ...)
2026-12-02 12:57 ` [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
@ 2026-12-02 12:57 ` Soumyadeep Hore
2026-12-04 8:07 ` Kumar, Rajesh
5 siblings, 1 reply; 14+ messages in thread
From: Soumyadeep Hore @ 2026-12-02 12:57 UTC (permalink / raw)
To: dev, bruce.richardson, rajesh3.kumar, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
Document the Earliest TxTime First (ETF) offload, also known as Tx packet
pacing, in the Intel VF guide and add a release note entry.
Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
---
doc/guides/nics/intel_vf.rst | 35 ++++++++++++++++++++++++++
doc/guides/rel_notes/release_27_03.rst | 6 +++++
2 files changed, 41 insertions(+)
diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
index 51e1f49607..f3946becc8 100644
--- a/doc/guides/nics/intel_vf.rst
+++ b/doc/guides/nics/intel_vf.rst
@@ -681,6 +681,41 @@ Inline IPsec Support
documentation.
+Tx Packet Pacing
+----------------
+
+Earliest TxTime First (ETF), also known as Tx packet pacing, allows the
+application to request a per-packet transmit time, with hardware enforcing
+the scheduled transmit time. This feature is currently supported only on
+E830 adapters, and the PF must advertise the ``VIRTCHNL_VF_OFFLOAD_TXTIME``
+capability.
+
+The offload is enabled per Tx queue through the
+``RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP`` offload flag. When enabled, a
+timestamp ring is allocated alongside the Tx descriptor ring, and the
+per-packet transmit time is taken from the dynamic mbuf Tx timestamp field
+(registered with ``rte_mbuf_dyn_tx_timestamp_register()``). The DPDK library
+must be built with PTP support enabled.
+
+For example, to deliver timestamps internally in ``testpmd`` the initial
+time is fetched using ``rte_eth_read_clock()`` and the ``set txtimes``
+command provides the inter-burst and intra-burst time intervals in
+nanoseconds::
+
+ dpdk-testpmd -a 0000:xx:xx.x -- -i --tx-offloads=0x200000
+ set fwd txonly
+ set txtimes <inter_burst>,<intra_burst>
+ start
+
+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 are sent immediately.
+The VF estimates the device time from the last PHC read,
+so applications should read the clock with ``rte_eth_read_clock()``
+before scheduling packets.
+
+
Diagnostic Utilities
--------------------
diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst
index a91813faca..d933fcea9f 100644
--- a/doc/guides/rel_notes/release_27_03.rst
+++ b/doc/guides/rel_notes/release_27_03.rst
@@ -55,6 +55,12 @@ New Features
Also, make sure to start the actual text at the margin.
=======================================================
+* **Updated Intel iavf driver.**
+
+ * Added Earliest TxTime First (ETF) offload, also known as Tx packet pacing,
+ advertised as ``RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP`` and available on
+ E830 adapters.
+
Removed Items
-------------
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v1 6/6] doc: add iavf Earliest TxTime First offload
2026-12-02 12:57 ` [PATCH v1 6/6] doc: add iavf " Soumyadeep Hore
@ 2026-12-04 8:07 ` Kumar, Rajesh
0 siblings, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:07 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> Document the Earliest TxTime First (ETF) offload, also known as Tx packet
> pacing, in the Intel VF guide and add a release note entry.
>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> doc/guides/nics/intel_vf.rst | 35 ++++++++++++++++++++++++++
> doc/guides/rel_notes/release_27_03.rst | 6 +++++
> 2 files changed, 41 insertions(+)
>
> diff --git a/doc/guides/nics/intel_vf.rst b/doc/guides/nics/intel_vf.rst
> index 51e1f49607..f3946becc8 100644
> --- a/doc/guides/nics/intel_vf.rst
> +++ b/doc/guides/nics/intel_vf.rst
> @@ -681,6 +681,41 @@ Inline IPsec Support
> documentation.
>
>
> +Tx Packet Pacing
> +----------------
> +
> +Earliest TxTime First (ETF), also known as Tx packet pacing, allows the
> +application to request a per-packet transmit time, with hardware enforcing
> +the scheduled transmit time. This feature is currently supported only on
> +E830 adapters, and the PF must advertise the ``VIRTCHNL_VF_OFFLOAD_TXTIME``
> +capability.
> +
> +The offload is enabled per Tx queue through the
> +``RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP`` offload flag. When enabled, a
> +timestamp ring is allocated alongside the Tx descriptor ring, and the
> +per-packet transmit time is taken from the dynamic mbuf Tx timestamp field
> +(registered with ``rte_mbuf_dyn_tx_timestamp_register()``). The DPDK library
> +must be built with PTP support enabled.
> +
> +For example, to deliver timestamps internally in ``testpmd`` the initial
> +time is fetched using ``rte_eth_read_clock()`` and the ``set txtimes``
> +command provides the inter-burst and intra-burst time intervals in
> +nanoseconds::
> +
> + dpdk-testpmd -a 0000:xx:xx.x -- -i --tx-offloads=0x200000
> + set fwd txonly
> + set txtimes <inter_burst>,<intra_burst>
> + start
> +
> +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 are sent immediately.
> +The VF estimates the device time from the last PHC read,
> +so applications should read the clock with ``rte_eth_read_clock()``
> +before scheduling packets.
> +
> +
> Diagnostic Utilities
> --------------------
>
> diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst
> index a91813faca..d933fcea9f 100644
> --- a/doc/guides/rel_notes/release_27_03.rst
> +++ b/doc/guides/rel_notes/release_27_03.rst
> @@ -55,6 +55,12 @@ New Features
> Also, make sure to start the actual text at the margin.
> =======================================================
>
> +* **Updated Intel iavf driver.**
> +
> + * Added Earliest TxTime First (ETF) offload, also known as Tx packet pacing,
> + advertised as ``RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP`` and available on
> + E830 adapters.
> +
>
> Removed Items
> -------------
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support
2026-12-02 12:57 ` [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support Soumyadeep Hore
@ 2026-12-04 8:08 ` Kumar, Rajesh
0 siblings, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:08 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> From: Paul Greenwalt <paul.greenwalt@intel.com>
>
> Virtual Function (VF) Earliest TxTime First (ETF) hardware offload
> support is available on E830 hardware.
>
> Changes made to support VF ETF:
>
> - VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC accounts for the additional timestamp
> descriptors required when wrapping around the timestamp ring. This
> addresses a known hardware requirement when wrapping around the
> timestamp ring that can produce a malicious driver detection event.
> - struct virtchnl_txq_info and struct virtchnl_vsi_queue_config_info have
> been updated to use a deprecated union for the ETF TxTime stamp.
>
> Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/iavf/base/virtchnl.h | 30 +++++++++++++++++++++++---
> 1 file changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/intel/iavf/base/virtchnl.h b/drivers/net/intel/iavf/base/virtchnl.h
> index c0d52ddd32..513e4b5d52 100644
> --- a/drivers/net/intel/iavf/base/virtchnl.h
> +++ b/drivers/net/intel/iavf/base/virtchnl.h
> @@ -531,13 +531,36 @@ struct virtchnl_txq_info {
> u16 vsi_id;
> u16 queue_id;
> u16 ring_len; /* number of descriptors, multiple of 8 */
> - u16 headwb_enabled; /* deprecated with AVF 1.0 */
> + union {
> + u16 headwb_enabled; /* deprecated with AVF 1.0 */
> + u16 flags; /* see virtchnl_txq_info_flags */
> + };
> u64 dma_ring_addr;
> - u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
> + union {
> + u64 dma_headwb_addr; /* deprecated with AVF 1.0 */
> + u64 dma_txtime_addr; /* address of the txtime buffer */
> + };
> };
>
> VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_txq_info);
>
> +/* virtchnl_txq_info_flags - definition of bits in the flags field of the
> + * virtchnl_txq_info structure.
> + *
> + * @VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED: request to enable TXTIME offload
> + *
> + * Other flag bits are currently reserved and they may be extended in the
> + * future.
> + */
> +enum virtchnl_txq_info_flags {
> + VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED = BIT(0),
> +};
> +
> +/* Additional timestamp descriptors are required when wrapping around the
> + * timestamp ring, to avoid a malicious driver detection (MDD) event.
> + */
> +#define VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC 16
> +
> /* RX descriptor IDs (range from 0 to 63) */
> enum virtchnl_rx_desc_ids {
> VIRTCHNL_RXDID_0_16B_BASE = 0,
> @@ -658,7 +681,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(64, virtchnl_queue_pair_info);
> struct virtchnl_vsi_queue_config_info {
> u16 vsi_id;
> u16 num_queue_pairs;
> - u32 pad;
> + u16 txtime_txqs; /* bitmap of TX queues with txtime enabled */
> + u16 pad;
> struct virtchnl_queue_pair_info qpair[1];
> };
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag
2026-12-02 12:57 ` [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag Soumyadeep Hore
@ 2026-12-04 8:09 ` Kumar, Rajesh
0 siblings, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:09 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> From: Paul Greenwalt <paul.greenwalt@intel.com>
>
> Add the VF capability flag VIRTCHNL_VF_OFFLOAD_TXTIME to negotiate VF ETF
> support between the PF and VF driver.
>
> As the flag is beyond bit 31 of the legacy vf_cap_flags field, it is
> negotiated through the extended capability message VIRTCHNL_OP_GET_VF_CAPS2
> (struct virtchnl_vf_caps2), which is gated by the VIRTCHNL_VF_CAPS2 flag
> in vf_cap_flags.
>
> Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/iavf/base/virtchnl.h | 30 ++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/net/intel/iavf/base/virtchnl.h b/drivers/net/intel/iavf/base/virtchnl.h
> index 513e4b5d52..f3f1965f00 100644
> --- a/drivers/net/intel/iavf/base/virtchnl.h
> +++ b/drivers/net/intel/iavf/base/virtchnl.h
> @@ -195,6 +195,7 @@ enum virtchnl_ops {
> VIRTCHNL_OP_HQOS_ELEMS_DEL = 133,
> VIRTCHNL_OP_HQOS_ELEMS_MOVE = 134,
> VIRTCHNL_OP_HQOS_ELEMS_CONF = 135,
> + VIRTCHNL_OP_GET_VF_CAPS2 = 136,
> VIRTCHNL_OP_MAX,
> };
>
> @@ -361,6 +362,8 @@ static inline const char *virtchnl_op_str(enum virtchnl_ops v_opcode)
> return "VIRTCHNL_OP_HQOS_ELEMS_MOVE";
> case VIRTCHNL_OP_HQOS_ELEMS_CONF:
> return "VIRTCHNL_OP_HQOS_ELEMS_CONF";
> + case VIRTCHNL_OP_GET_VF_CAPS2:
> + return "VIRTCHNL_OP_GET_VF_CAPS2";
> case VIRTCHNL_OP_MAX:
> return "VIRTCHNL_OP_MAX";
> default:
> @@ -471,6 +474,10 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
> #define VIRTCHNL_VF_OFFLOAD_L2 BIT(0)
> #define VIRTCHNL_VF_OFFLOAD_IWARP BIT(1)
> #define VIRTCHNL_VF_OFFLOAD_RSVD BIT(2)
> +/* If set in vf_cap_flags, the VF and PF support the extended capability
> + * negotiation via VIRTCHNL_OP_GET_VF_CAPS2 (shares bit 2 with RSVD).
> + */
> +#define VIRTCHNL_VF_CAPS2 BIT(2)
> #define VIRTCHNL_VF_OFFLOAD_RSS_AQ BIT(3)
> #define VIRTCHNL_VF_OFFLOAD_RSS_REG BIT(4)
> #define VIRTCHNL_VF_OFFLOAD_WB_ON_ITR BIT(5)
> @@ -501,6 +508,14 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
> #define VIRTCHNL_VF_CAP_DCF BIT(30)
> #define VIRTCHNL_VF_CAP_PTP BIT(31)
>
> +/* Extended VF capability flags negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
> + * These are bit positions in the extended capability bitmap (which includes
> + * the original 32 bits at the same positions), not bits within the 32-bit
> + * vf_cap_flags field. Flags greater than 31 are only available via caps2.
> + */
> +#define VIRTCHNL_VF_OFFLOAD_TXTIME 32
> +#define VIRTCHNL_VF_CAPS_MAX 33
> +
> #define VF_BASE_MODE_OFFLOADS (VIRTCHNL_VF_OFFLOAD_L2 | \
> VIRTCHNL_VF_OFFLOAD_VLAN | \
> VIRTCHNL_VF_OFFLOAD_RSS_PF)
> @@ -520,6 +535,21 @@ struct virtchnl_vf_resource {
>
> VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_vf_resource);
>
> +/* VIRTCHNL_OP_GET_VF_CAPS2
> + * Generic extended capability flags. The VF sends this message to negotiate an
> + * extended set of capability flags if VIRTCHNL_VF_CAPS2 is set in
> + * virtchnl_vf_resource::vf_cap_flags. On send, the VF sets what capabilities it
> + * requests; on reply, the PF indicates what has been enabled for the VF. The
> + * bitmap includes the original 32 vf_cap_flags bits at the same positions, plus
> + * flags that do not fit there (e.g. VIRTCHNL_VF_OFFLOAD_TXTIME).
> + */
> +struct virtchnl_vf_caps2 {
> + u32 flags_len;
> + u32 vf_cap_flags[];
> +};
> +
> +VIRTCHNL_CHECK_STRUCT_LEN(4, virtchnl_vf_caps2);
> +
> /* VIRTCHNL_OP_CONFIG_TX_QUEUE
> * VF sends this message to set up parameters for one TX queue.
> * External data buffer contains one instance of virtchnl_txq_info.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register
2026-12-02 12:57 ` [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register Soumyadeep Hore
@ 2026-12-04 8:09 ` Kumar, Rajesh
2026-12-04 8:17 ` Kumar, Rajesh
1 sibling, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:09 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> From: Paul Greenwalt <paul.greenwalt@intel.com>
>
> Virtual Function (VF) Earliest TxTime First (ETF) hardware offload
> support is available on E830 hardware.
>
> Add the timestamp ring doorbell register IAVF_GLQTX_TXTIME_DBELL_LSB and
> the Tx time stamp descriptor struct iavf_ts_desc.
>
> Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/iavf/base/iavf_register.h | 1 +
> drivers/net/intel/iavf/base/iavf_type.h | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/net/intel/iavf/base/iavf_register.h b/drivers/net/intel/iavf/base/iavf_register.h
> index 96df411e06..1ca5110c6a 100644
> --- a/drivers/net/intel/iavf/base/iavf_register.h
> +++ b/drivers/net/intel/iavf/base/iavf_register.h
> @@ -83,6 +83,7 @@
> #define IAVF_VFINT_STAT_CTL01 0x00005400 /* Reset: CORER */
> #define IAVF_QRX_TAIL1(_Q) (0x00002000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: CORER */
> #define IAVF_QTX_TAIL1(_Q) (0x00000000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: PFR */
> +#define IAVF_GLQTX_TXTIME_DBELL_LSB(_Q) (0x0000D000 + ((_Q) * 8)) /* _Q=0...255 */ /* Reset: PFR */
> #define IAVF_VFQF_HENA(_i) (0x0000C400 + ((_i) * 4)) /* _i=0...1 */ /* Reset: CORER */
> #define IAVF_VFQF_HKEY(_i) (0x0000CC00 + ((_i) * 4)) /* _i=0...12 */ /* Reset: CORER */
> #define IAVF_VFQF_HKEY_MAX_INDEX 12
> diff --git a/drivers/net/intel/iavf/base/iavf_type.h b/drivers/net/intel/iavf/base/iavf_type.h
> index b7d7027b9d..1597a49150 100644
> --- a/drivers/net/intel/iavf/base/iavf_type.h
> +++ b/drivers/net/intel/iavf/base/iavf_type.h
> @@ -713,6 +713,11 @@ enum iavf_rx_prog_status_desc_error_bits {
> #define IAVF_FOUR_BIT_MASK 0xF
> #define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF
>
> +/* Tx time stamp descriptor */
> +struct iavf_ts_desc {
> + __le32 tx_desc_idx_tstamp;
> +};
> +
> /* TX Descriptor */
> struct iavf_tx_desc {
> __le64 buffer_addr; /* Address of descriptor's data buf */
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register
2026-12-02 12:57 ` [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register Soumyadeep Hore
2026-12-04 8:09 ` Kumar, Rajesh
@ 2026-12-04 8:17 ` Kumar, Rajesh
1 sibling, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:17 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, Paul Greenwalt,
vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> From: Paul Greenwalt <paul.greenwalt@intel.com>
>
> Virtual Function (VF) Earliest TxTime First (ETF) hardware offload
> support is available on E830 hardware.
>
> Add the timestamp ring doorbell register IAVF_GLQTX_TXTIME_DBELL_LSB and
> the Tx time stamp descriptor struct iavf_ts_desc.
>
> Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/iavf/base/iavf_register.h | 1 +
> drivers/net/intel/iavf/base/iavf_type.h | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/drivers/net/intel/iavf/base/iavf_register.h b/drivers/net/intel/iavf/base/iavf_register.h
> index 96df411e06..1ca5110c6a 100644
> --- a/drivers/net/intel/iavf/base/iavf_register.h
> +++ b/drivers/net/intel/iavf/base/iavf_register.h
> @@ -83,6 +83,7 @@
> #define IAVF_VFINT_STAT_CTL01 0x00005400 /* Reset: CORER */
> #define IAVF_QRX_TAIL1(_Q) (0x00002000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: CORER */
> #define IAVF_QTX_TAIL1(_Q) (0x00000000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: PFR */
> +#define IAVF_GLQTX_TXTIME_DBELL_LSB(_Q) (0x0000D000 + ((_Q) * 8)) /* _Q=0...255 */ /* Reset: PFR */
> #define IAVF_VFQF_HENA(_i) (0x0000C400 + ((_i) * 4)) /* _i=0...1 */ /* Reset: CORER */
> #define IAVF_VFQF_HKEY(_i) (0x0000CC00 + ((_i) * 4)) /* _i=0...12 */ /* Reset: CORER */
> #define IAVF_VFQF_HKEY_MAX_INDEX 12
> diff --git a/drivers/net/intel/iavf/base/iavf_type.h b/drivers/net/intel/iavf/base/iavf_type.h
> index b7d7027b9d..1597a49150 100644
> --- a/drivers/net/intel/iavf/base/iavf_type.h
> +++ b/drivers/net/intel/iavf/base/iavf_type.h
> @@ -713,6 +713,11 @@ enum iavf_rx_prog_status_desc_error_bits {
> #define IAVF_FOUR_BIT_MASK 0xF
> #define IAVF_EIGHTEEN_BIT_MASK 0x3FFFF
>
> +/* Tx time stamp descriptor */
> +struct iavf_ts_desc {
> + __le32 tx_desc_idx_tstamp;
> +};
> +
> /* TX Descriptor */
> struct iavf_tx_desc {
> __le64 buffer_addr; /* Address of descriptor's data buf */
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf
2026-12-02 12:57 ` [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf Soumyadeep Hore
@ 2026-12-04 8:17 ` Kumar, Rajesh
0 siblings, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 8:17 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
Acked-By: Rajesh Kumar <rajesh3.kumar@intel.com>
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> The iavf driver gains Earliest TxTime First (ETF) offload support and
> needs a pointer to its Tx time queue in the shared Tx queue structure.
> Add it to the iavf-specific fields of struct ci_tx_queue.
>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/common/tx.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/intel/common/tx.h b/drivers/net/intel/common/tx.h
> index 00bf90181c..2f47f62ce1 100644
> --- a/drivers/net/intel/common/tx.h
> +++ b/drivers/net/intel/common/tx.h
> @@ -244,6 +244,7 @@ struct ci_tx_queue {
> uint8_t vlan_flag;
> uint8_t tc;
> bool lldp_enabled;
> + struct iavf_txtime *iavf_tsq; /* Tx Time based queue */
> };
> struct { /* ixgbe specific values */
> const struct ixgbe_txq_ops *ops;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload
2026-12-02 12:57 ` [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
@ 2026-12-04 10:41 ` Kumar, Rajesh
0 siblings, 0 replies; 14+ messages in thread
From: Kumar, Rajesh @ 2026-12-04 10:41 UTC (permalink / raw)
To: Soumyadeep Hore, dev, bruce.richardson, aman.deep.singh
Cc: dawid.wesierski, manoj.kumar.subbarao, vladimir.medvedkin
Few comments from AI. Lets take a look.
> + bool stop_txtime; /* request a no-TXTIME reconfigure on teardown */
This is a hidden argument to iavf_configure_queues(), set and cleared
around a single call in iavf_dev_stop(). Please pass it explicitly
instead of keeping it as state in struct iavf_info.
> +iavf_txtime_drain(struct rte_eth_dev *dev)
[...]
> + if (txq != NULL && txq->iavf_tsq != NULL &&
> + txq->nb_tx_free < txq->nb_tx_desc - 1) {
> + rte_delay_ms(IAVF_TXTIME_DRAIN_MS);
nb_tx_free is only refreshed lazily by ci_tx_xmit_cleanup() from the Tx
burst path, so this condition is true for any queue that has sent a
packet since it was started. It does not tell whether packets are still
scheduled in hardware. In practice this is an unconditional 68 ms delay
on every stop, and rte_delay_ms() busy-waits by default.
Also, IAVF_TXTIME_DRAIN_MS should be derived from the timestamp width
and resolution macros rather than hardcoded as 68.
> + iavf_txtime_drain(dev);
> +
> iavf_stop_queues(dev);
> +
> + /* If Tx Time (ETF) was active, reconfigure the queues without the
> + * TXTIME flag so the PF cleanly releases the timestamp scheduler
[...]
> + if (iavf_configure_queues(adapter, vf->num_queue_pairs)
!= 0)
A few concerns with this teardown sequence:
1. iavf_dev_stop() is also reached during reset recovery:
iavf_handle_hw_reset() -> iavf_dev_reset() -> iavf_dev_uninit() ->
iavf_dev_close() -> iavf_dev_stop(). In that state iavf_stop_queues()
deliberately skips virtchnl (in_reset_recovery) and iavf_dev_close()
skips its virtchnl teardown (pf_reset_in_progress). This new
VIRTCHNL_OP_CONFIG_VSI_QUEUES and the drain delay should be skipped
there too.
2. iavf_dev_tx_queue_stop() gets neither the drain nor the reconfigure,
so a per-queue stop/start behaves differently from a port stop/start.
3. The comments say that disabling a queue with packets still scheduled
leaves the PF scheduler in a state that breaks Tx time in later runs.
If so, an application that crashes or is killed leaves the PF broken,
since none of this runs. Should this not be handled on the PF side
when the queue is disabled?
Minor: please use IAVF_VF_CAP2() here as elsewhere in the patch, and
share one helper for the "any Tx time queue" loop, which is duplicated
in iavf_txtime_drain().
> + if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAPS2) {
> + if (iavf_get_vf_caps2(adapter) != 0)
> + PMD_INIT_LOG(WARNING, "failed to get VF extended
capabilities");
> + }
iavf_init_vf() runs again after a VF reset, and vf_cap_flags2 is only
written when the command succeeds. If the PF no longer advertises
VIRTCHNL_VF_CAPS2, or the command fails, the previous TXTIME bit stays
set. Please clear vf_cap_flags2 before negotiating.
> +iavf_txtime_clock_tick(struct rte_eth_dev *dev)
[...]
> + if (rte_rdtsc() - adapter->txtime_clk.tsc < refresh)
> + return;
> +
> + iavf_phc_get_time(adapter, &phc);
txtime_clk.tsc is read here without the seqlock, while it can be written
from another thread through rte_eth_read_clock() or
rte_eth_timesync_read_time().
The return value is ignored. On failure the anchor is not updated, so the
request is retried on every alarm (50 ms), with an ERR log from
iavf_phc_get_time() each time.
Unlike iavf_phc_sync_tick(), this is not gated on adapter->stopped or a
pause flag, so it can issue a request from the interrupt thread while
iavf_dev_stop() is running.
> + .read_clock = iavf_read_clock,
> + .timesync_enable = iavf_timesync_enable,
> + .timesync_disable = iavf_timesync_disable,
> + .timesync_read_rx_timestamp = iavf_timesync_read_rx_timestamp,
Only read_clock is needed for Tx pacing (testpmd "set txtimes" calls
rte_eth_read_clock()). The three timesync ops are a separate topic and
should not be in this patch.
They are also incomplete as a timesync implementation: there is no
timesync_read_tx_timestamp, adjust_time or write_time, and the iavf Rx
paths do not set RTE_MBUF_F_RX_IEEE1588_PTP.
> + /* The Rx path stores the most recent converted 64-bit timestamp. */
> + *timestamp = rte_ns_to_timespec(rxq->phc_time);
This comment is not accurate. rxq->phc_time is overwritten with the
current PHC time by iavf_phc_sync_tick() every 200 ms and by
iavf_dev_rx_queue_start(), so the value returned is not necessarily the
timestamp of a received packet. ice keeps a dedicated field
(rxq->time_high) for this.
Please drop these ops from this patch, or send them as a separate and
complete timesync patch.
> + if (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
[...]
> + if (!(IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME))) {
> + PMD_INIT_LOG(ERR, "Tx Time offload is not supported by
the PF");
> + iavf_dev_tx_queue_release(dev, queue_idx);
> + dev->data->tx_queues[queue_idx] = NULL;
> + return -ENOTSUP;
The capability check can be done at the top of the function, before
anything is allocated. The release/NULL/return sequence is repeated four
times in this block; a single error label would be clearer.
> + /* Extra descriptors are needed to handle ring wrap-around. */
> + tsq->nb_ts_desc = nb_desc + VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC;
Question: the timestamp ring length is not carried in virtchnl, so the PF
and VF must agree on this value implicitly. The ice PMD computes the
extra count from the E830_GLTXTIME_FETCH_PROFILE registers
(ice_calc_ts_ring_count()). Is 16 guaranteed to match what the PF
programs for a VF queue?
Related: patch 1 adds virtchnl_vsi_queue_config_info.txtime_txqs, but
nothing in this series sets it. Is it required by the PF? As a u16 bitmap
it also cannot describe more than 16 queues.
> + if (txq->iavf_tsq != NULL) {
> + memset((void *)(uintptr_t)txq->iavf_tsq->ts_ring, 0,
> + txq->iavf_tsq->nb_ts_desc * sizeof(struct iavf_ts_desc));
> + txq->iavf_tsq->ts_tail = 0;
> + }
Question: only the software tail is reset here. The ice PMD also writes 0
to the TXTIME doorbell when the queue is started. Is the VF doorbell
guaranteed to be reset by the PF on queue configuration? If not, the
hardware and software tails differ after a stop/start.
> + /* Timestamp 0 means not paced: send unscheduled and long late
packets now */
> + if ((tx_pkt->ol_flags & tsq->ts_flag) &&
> + (tsq->now == 0 || txtime + IAVF_TXTIME_HORIZON_NS >=
tsq->now)) {
[...]
> + /* The hardware compares against the free running PHC, not
ns in second */
> + tstamp = (uint32_t)((txtime + IAVF_TXTIME_ROUND_NS) >>
> + IAVF_TXTIME_RESOLUTION_128NS);
> + tstamp &= IAVF_TXTIME_STAMP_M >> IAVF_TXTIME_STAMP_S;
> + if (tstamp == 0)
> + tstamp = 1;
This differs from ice_write_ts_desc() for the same hardware, which uses
(txtime % NS_PER_S) >> 7, does not round, and gives no special meaning
to 0. Questions:
1. Which conversion is correct? If the hardware compares against the
free running PHC as the comment says, the ice PMD needs a fix too.
Please explain this in the commit message.
2. Is a timestamp of 0 really treated by the hardware as "send
immediately"? If it is an ordinary value in the 19-bit window, packets
without the flag and late packets would be held until the window
wraps.
3. Rounding to nearest can launch a packet up to 64 ns before the
requested time. Is that intended?
Readability: tsq->now == 0 is tested twice inside the two conditions.
Named intermediates (clock known, too late, beyond horizon) would make
the three cases easier to follow.
> + if (txq->iavf_tsq != NULL && txq->iavf_tsq->ts_flag > 0) {
The ts_flag test is redundant, since queue setup fails when the dynamic
flag cannot be registered.
> + uint8_t req_buf[sizeof(struct virtchnl_vf_caps2) +
> + ((VIRTCHNL_VF_CAPS_MAX + 31) / 32) * sizeof(uint32_t)] =
{0};
> + struct virtchnl_vf_caps2 *caps2 = (struct virtchnl_vf_caps2
*)req_buf;
A uint8_t array has no alignment guarantee for a struct of u32. Please
use a wrapper struct, as iavf_configure_queue_chunk() does for its
request. That also avoids repeating the length expression.
> + for (i = 0; i < resp->flags_len && i < 2; i++)
Please replace the magic 2 with something derived from the size of
vf_cap_flags2.
> + /* anchor the Tx time clock estimate to the middle of the request */
> + rte_seqlock_write_lock(&adapter->txtime_clk.lock);
> + adapter->txtime_clk.phc = *time;
> + adapter->txtime_clk.tsc = tsc_start + (rte_rdtsc() - tsc_start) / 2;
The duration of the request is not bounded. iavf_wait_for_msg() polls
with a 1 ms sleep and can wait up to MAX_TRY_TIMES iterations, and the
PF may answer late. The midpoint can be off by up to half of the round
trip, while the margin between IAVF_TXTIME_HORIZON_NS (30 ms) and the
hardware window (about 33.5 ms) is only 3.5 ms. A single slow reply
then gives a wrong estimate until the next refresh.
Please consider discarding samples whose round trip exceeds a threshold.
A PHC step on the PF also leaves the anchor wrong until the next
refresh.
On 02-12-2026 06:27 pm, Soumyadeep Hore wrote:
> Add support for the Earliest TxTime First (ETF) offload, also known as
> Tx Packet Pacing (SO_TXTIME), on iavf. It is available on E830 adapters
> and is negotiated with the PF through the VIRTCHNL_VF_OFFLOAD_TXTIME
> extended capability.
>
> When RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP is requested on a Tx queue, the
> driver allocates a timestamp ring alongside the Tx descriptor ring. For
> each packet, the per-packet launch time is read from the dynamic mbuf Tx
> timestamp field and written to the timestamp ring, and a dedicated
> timestamp-ring doorbell is rung so that hardware transmits the packet at
> the scheduled time. Extra timestamp descriptors are programmed on ring
> wrap-around to avoid a malicious driver detection event.
>
> The launch time is encoded from the PHC nanoseconds, rounded to the 128 ns
> timestamp resolution. As the hardware treats the half of its 19-bit
> timestamp window ahead of the current time as the future, launch times
> further than 30 ms ahead are sent at that limit, and packets without a
> launch time are sent immediately. The device time is estimated with the
> TSC from the last PHC read, which is refreshed every second while Tx Time
> is in use, so no PF request is needed in the Tx path.
>
> The timestamp ring address and the per-queue enable flag are passed to
> the PF via VIRTCHNL_OP_CONFIG_VSI_QUEUES. The extended VF capabilities
> are negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
>
> The PTP timesync dev ops (enable, disable, read Rx timestamp) and
> read_clock are also implemented; applications such as testpmd use
> read_clock to program the Tx launch times.
>
> Signed-off-by: Soumyadeep Hore <soumyadeep.hore@intel.com>
> ---
> drivers/net/intel/iavf/iavf.h | 43 +++++++
> drivers/net/intel/iavf/iavf_ethdev.c | 181 +++++++++++++++++++++++++++
> drivers/net/intel/iavf/iavf_rxtx.c | 145 ++++++++++++++++++++-
> drivers/net/intel/iavf/iavf_rxtx.h | 23 ++++
> drivers/net/intel/iavf/iavf_vchnl.c | 65 ++++++++++
> 5 files changed, 456 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
> index 0c98ae28e1..67dbf21989 100644
> --- a/drivers/net/intel/iavf/iavf.h
> +++ b/drivers/net/intel/iavf/iavf.h
> @@ -8,7 +8,9 @@
> #include <sys/queue.h>
>
> #include <ethdev_driver.h>
> +#include <rte_cycles.h>
> #include <rte_kvargs.h>
> +#include <rte_seqlock.h>
> #include <rte_tm_driver.h>
>
> #include <iavf_prototype.h>
> @@ -80,6 +82,9 @@
>
> #define IAVF_ALARM_INTERVAL 50000 /* us */
> #define IAVF_PHC_SYNC_ALARM_INTERVAL_US 200000
> +/* Tx time clock anchor refresh period and age beyond which it is unused */
> +#define IAVF_TXTIME_CLOCK_REFRESH_US 1000000
> +#define IAVF_TXTIME_CLOCK_MAX_AGE_US 2000000
>
> /* The overhead from MTU to max frame size.
> * Considering QinQ packet, the VLAN tag needs to be counted twice.
> @@ -297,6 +302,8 @@ struct iavf_info {
> bool start_pending;
>
> uint32_t ptp_caps;
> + uint64_t vf_cap_flags2; /* extended caps negotiated via GET_VF_CAPS2 */
> + bool stop_txtime; /* request a no-TXTIME reconfigure on teardown */
> rte_spinlock_t phc_time_aq_lock;
> };
>
> @@ -381,6 +388,13 @@ enum iavf_tx_func_type {
> #define IAVF_MBUF_CHECK_F_TX_SEGMENT (1ULL << 2)
> #define IAVF_MBUF_CHECK_F_TX_OFFLOAD (1ULL << 3)
>
> +/* PHC time paired with the TSC at the middle of the PF request reading it */
> +struct iavf_txtime_clock {
> + rte_seqlock_t lock;
> + uint64_t phc;
> + uint64_t tsc;
> +};
> +
> /* Structure to store private data for each VF instance. */
> struct iavf_adapter {
> struct iavf_hw hw;
> @@ -399,6 +413,7 @@ struct iavf_adapter {
> rte_spinlock_t phc_sync_lock;
> uint8_t phc_sync_ticks;
> bool phc_sync_paused;
> + struct iavf_txtime_clock txtime_clk;
> struct iavf_devargs devargs;
> bool mac_primary_set;
> bool adminq_polling; /* Interrupt setup fell back to alarm polling. */
> @@ -421,6 +436,33 @@ iavf_get_eth_dev(struct iavf_adapter *adapter)
> #define IAVF_DEV_PRIVATE_TO_IAVF_SECURITY_CTX(adapter) \
> (((struct iavf_adapter *)adapter)->security_ctx)
>
> +/* Test an extended VF capability (bit position, e.g. VIRTCHNL_VF_OFFLOAD_TXTIME)
> + * negotiated via VIRTCHNL_OP_GET_VF_CAPS2.
> + */
> +#define IAVF_VF_CAP2(vf, bit) (((vf)->vf_cap_flags2 & RTE_BIT64(bit)) != 0)
> +
> +/* PHC time extrapolated with the TSC from the last PF read, 0 if unknown */
> +static inline uint64_t
> +iavf_txtime_clock_now(struct iavf_adapter *adapter)
> +{
> + uint64_t hz = rte_get_tsc_hz();
> + uint64_t phc, tsc, elapsed;
> + uint32_t sn;
> +
> + do {
> + sn = rte_seqlock_read_begin(&adapter->txtime_clk.lock);
> + phc = adapter->txtime_clk.phc;
> + tsc = adapter->txtime_clk.tsc;
> + } while (rte_seqlock_read_retry(&adapter->txtime_clk.lock, sn));
> +
> + if (tsc == 0)
> + return 0;
> + elapsed = rte_rdtsc() - tsc;
> + if (elapsed > hz / US_PER_S * IAVF_TXTIME_CLOCK_MAX_AGE_US)
> + return 0;
> + return phc + elapsed * NS_PER_S / hz;
> +}
> +
> /* IAVF_VSI_TO */
> #define IAVF_VSI_TO_HW(vsi) \
> (&(((struct iavf_vsi *)vsi)->adapter->hw))
> @@ -529,6 +571,7 @@ int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
> uint8_t *resp_msg, size_t resp_msg_len);
> extern const struct rte_tm_ops iavf_tm_ops;
> int iavf_get_ptp_cap(struct iavf_adapter *adapter);
> +int iavf_get_vf_caps2(struct iavf_adapter *adapter);
> int iavf_get_phc_time(struct ci_rx_queue *rxq);
> int iavf_flow_sub(struct iavf_adapter *adapter,
> struct iavf_fsub_conf *filter);
> diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
> index 10069feae2..efd6b2a122 100644
> --- a/drivers/net/intel/iavf/iavf_ethdev.c
> +++ b/drivers/net/intel/iavf/iavf_ethdev.c
> @@ -169,6 +169,12 @@ static uint64_t iavf_get_restore_flags(struct rte_eth_dev *dev,
> enum rte_eth_dev_operation op);
> static int iavf_post_reset_reconfig(struct rte_eth_dev *dev);
> static int iavf_timesync_read_time(struct rte_eth_dev *dev, struct timespec *timestamp);
> +static int iavf_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
> +static int iavf_timesync_enable(struct rte_eth_dev *dev);
> +static int iavf_timesync_disable(struct rte_eth_dev *dev);
> +static int iavf_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
> + struct timespec *timestamp,
> + uint32_t flags);
>
> static const struct rte_pci_id pci_id_iavf_map[] = {
> { RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
> @@ -270,6 +276,10 @@ static const struct eth_dev_ops iavf_eth_dev_ops = {
> .tm_ops_get = iavf_tm_ops_get,
> .get_restore_flags = iavf_get_restore_flags,
> .timesync_read_time = iavf_timesync_read_time,
> + .read_clock = iavf_read_clock,
> + .timesync_enable = iavf_timesync_enable,
> + .timesync_disable = iavf_timesync_disable,
> + .timesync_read_rx_timestamp = iavf_timesync_read_rx_timestamp,
These ops are related to basic time-sync enable unrelated to tx packet
packing, I think we should enable basic time sync functionality as
separate patch
> };
>
> static int
> @@ -1134,6 +1144,29 @@ iavf_dev_start(struct rte_eth_dev *dev)
> return -1;
> }
>
> +/* Max time HW can hold a Tx time packet: 2^19 x 128 ns launch window. */
> +#define IAVF_TXTIME_DRAIN_MS 68
> +
> +/* Disabling a Tx time queue while packets are still scheduled leaves the
> + * PF scheduler in a state that breaks Tx time in later runs, so give
> + * pending packets one launch window to be sent first.
> + */
> +static void
> +iavf_txtime_drain(struct rte_eth_dev *dev)
> +{
> + uint16_t i;
> +
> + for (i = 0; i < dev->data->nb_tx_queues; i++) {
> + struct ci_tx_queue *txq = dev->data->tx_queues[i];
> +
> + if (txq != NULL && txq->iavf_tsq != NULL &&
> + txq->nb_tx_free < txq->nb_tx_desc - 1) {
> + rte_delay_ms(IAVF_TXTIME_DRAIN_MS);
> + return;
> + }
> + }
> +}
> +
> static int
> iavf_dev_stop(struct rte_eth_dev *dev)
> {
> @@ -1161,7 +1194,34 @@ iavf_dev_stop(struct rte_eth_dev *dev)
> /* Rx interrupt vector mapping free */
> rte_intr_vec_list_free(intr_handle);
>
> + iavf_txtime_drain(dev);
> +
> iavf_stop_queues(dev);
> +
> + /* If Tx Time (ETF) was active, reconfigure the queues without the
> + * TXTIME flag so the PF cleanly releases the timestamp scheduler
> + * context. Tearing down while packets are still scheduled otherwise
> + * leaves stale state that breaks Tx Time in later runs.
> + */
> + if (vf->vf_cap_flags2 & RTE_BIT64(VIRTCHNL_VF_OFFLOAD_TXTIME)) {
> + bool txtime_active = false;
> + uint16_t i;
> +
> + for (i = 0; i < dev->data->nb_tx_queues; i++) {
> + struct ci_tx_queue *txq = dev->data->tx_queues[i];
> +
> + if (txq != NULL && txq->iavf_tsq != NULL) {
> + txtime_active = true;
> + break;
> + }
> + }
> + if (txtime_active) {
> + vf->stop_txtime = true;
> + if (iavf_configure_queues(adapter, vf->num_queue_pairs) != 0)
> + PMD_DRV_LOG(WARNING, "failed to disable Tx time queues");
> + vf->stop_txtime = false;
> + }
> + }
> rte_free(vf->qv_map);
> vf->qv_map = NULL;
>
> @@ -1225,6 +1285,7 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> CI_TX_VEC_OFFLOAD_PATH_OFFLOADS | CI_TX_VEC_CTX_OFFLOAD_PATH_OFFLOADS) &
> ~(RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM |
> RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
> + RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP |
> RTE_ETH_TX_OFFLOAD_SECURITY);
>
> /* X710 does not support outer udp checksum */
> @@ -1238,6 +1299,9 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP)
> dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP;
>
> + if (IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME))
> + dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP;
> +
> if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2 &&
> vf->vlan_v2_caps.offloads.insertion_support.inner &&
> vf->vlan_v2_caps.offloads.insertion_support.outer)
> @@ -2726,6 +2790,12 @@ iavf_init_vf(struct rte_eth_dev *dev)
> PMD_INIT_LOG(ERR, "iavf_get_vf_config failed");
> goto err_alloc;
> }
> +
> + /* Negotiate extended capabilities (e.g. TXTIME) if the PF supports it. */
> + if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAPS2) {
> + if (iavf_get_vf_caps2(adapter) != 0)
> + PMD_INIT_LOG(WARNING, "failed to get VF extended capabilities");
> + }
> /* Allocate memort for RSS info */
> if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
> vf->rss_key = rte_zmalloc("rss_key",
> @@ -2921,6 +2991,29 @@ iavf_phc_sync_tick(struct rte_eth_dev *dev)
> rte_spinlock_unlock(&adapter->phc_sync_lock);
> }
>
> +/* Keep the Tx time clock anchor fresh while Tx time is used */
> +static void
> +iavf_txtime_clock_tick(struct rte_eth_dev *dev)
> +{
> + struct iavf_adapter *adapter =
> + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
> + uint64_t refresh = rte_get_tsc_hz() / US_PER_S * IAVF_TXTIME_CLOCK_REFRESH_US;
> + uint64_t phc;
> +
> + if (!dev->data->dev_started || adapter->closed ||
> + !(dev->data->dev_conf.txmode.offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) ||
> + !IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME) ||
> + !(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
> + !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_READ_PHC))
> + return;
> +
> + if (rte_rdtsc() - adapter->txtime_clk.tsc < refresh)
> + return;
> +
> + iavf_phc_get_time(adapter, &phc);
> +}
> +
> void
> iavf_dev_alarm_handler(void *param)
> {
> @@ -2948,6 +3041,7 @@ iavf_dev_alarm_handler(void *param)
> }
>
> iavf_phc_sync_tick(dev);
> + iavf_txtime_clock_tick(dev);
>
> rte_eal_alarm_set(IAVF_ALARM_INTERVAL,
> iavf_dev_alarm_handler, dev);
> @@ -3084,6 +3178,7 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
> adapter->tpid = RTE_ETHER_TYPE_VLAN; /* VLAN TPID set to 0x8100 by default */
> rte_spinlock_init(&adapter->phc_sync_lock);
> rte_spinlock_init(&vf->watchdog_lock);
> + rte_seqlock_init(&adapter->txtime_clk.lock);
>
> if (!rte_atomic_load_explicit(&vf->in_reset_recovery, rte_memory_order_relaxed) &&
> iavf_dev_event_handler_init())
> @@ -3799,6 +3894,92 @@ iavf_timesync_read_time(struct rte_eth_dev *dev, struct timespec *timestamp)
> return 0;
> }
>
> +static int
> +iavf_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
> +{
> + struct timespec ts;
> + int ret;
> +
> + ret = iavf_timesync_read_time(dev, &ts);
> + if (ret)
> + return ret;
> +
> + *clock = (uint64_t)ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec;
> +
> + return 0;
> +}
> +
> +static int
> +iavf_timesync_enable(struct rte_eth_dev *dev)
> +{
> + struct iavf_adapter *adapter =
> + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
> +
> + if (adapter->closed)
> + return -EIO;
> +
> + if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
> + !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))
> + return -ENOTSUP;
> +
> + /* Rx timestamping is driven by the RTE_ETH_RX_OFFLOAD_TIMESTAMP offload
> + * programmed at queue setup; there is nothing else to enable on the VF.
> + */
> + if (dev->data->dev_started &&
> + !(dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
> + PMD_DRV_LOG(ERR, "Rx timestamp offload not configured");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int
> +iavf_timesync_disable(struct rte_eth_dev *dev)
> +{
> + struct iavf_adapter *adapter =
> + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> +
> + if (adapter->closed)
> + return -EIO;
> +
> + /* Nothing VF-specific to tear down; disabling the Rx timestamp offload
> + * is handled through the normal queue reconfiguration path.
> + */
> + return 0;
> +}
> +
> +static int
> +iavf_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
> + struct timespec *timestamp, uint32_t flags)
> +{
> + struct iavf_adapter *adapter =
> + IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
> + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
> + struct ci_rx_queue *rxq;
> +
> + if (adapter->closed)
> + return -EIO;
> +
> + if (!(vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP) ||
> + !(vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))
> + return -ENOTSUP;
> +
> + /* The 'flags' argument carries the Rx queue index to read from. */
> + if (flags >= dev->data->nb_rx_queues)
> + return -EINVAL;
> +
> + rxq = dev->data->rx_queues[flags];
> + if (rxq == NULL)
> + return -EINVAL;
> +
> + /* The Rx path stores the most recent converted 64-bit timestamp. */
> + *timestamp = rte_ns_to_timespec(rxq->phc_time);
> +
> + return 0;
> +}
> +
> RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
> RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
> RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
> diff --git a/drivers/net/intel/iavf/iavf_rxtx.c b/drivers/net/intel/iavf/iavf_rxtx.c
> index 8c84991b86..af35ea538c 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx.c
> +++ b/drivers/net/intel/iavf/iavf_rxtx.c
> @@ -16,6 +16,7 @@
> #include <rte_string_fns.h>
> #include <rte_memzone.h>
> #include <rte_mbuf.h>
> +#include <rte_mbuf_dyn.h>
> #include <rte_malloc.h>
> #include <rte_ether.h>
> #include <ethdev_driver.h>
> @@ -26,6 +27,7 @@
> #include <rte_net.h>
> #include <rte_vect.h>
> #include <rte_bitops.h>
> +#include <rte_cycles.h>
> #include <rte_vxlan.h>
> #include <rte_gtp.h>
> #include <rte_geneve.h>
> @@ -864,6 +866,64 @@ iavf_dev_tx_queue_setup(struct rte_eth_dev *dev,
> dev->data->tx_queues[queue_idx] = txq;
> txq->qtx_tail = hw->hw_addr + IAVF_QTX_TAIL1(queue_idx);
>
> + /* Earliest TxTime First (SO_TXTIME) offload: allocate a timestamp ring
> + * alongside the Tx descriptor ring. HW reads the per-packet transmit
> + * time from this ring to schedule the packet.
> + */
> + if (offloads & RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP) {
> + struct iavf_txtime *tsq;
> + const struct rte_memzone *ts_mz;
> + uint32_t ts_ring_size;
> +
> + if (!(IAVF_VF_CAP2(vf, VIRTCHNL_VF_OFFLOAD_TXTIME))) {
> + PMD_INIT_LOG(ERR, "Tx Time offload is not supported by the PF");
> + iavf_dev_tx_queue_release(dev, queue_idx);
> + dev->data->tx_queues[queue_idx] = NULL;
> + return -ENOTSUP;
> + }
> +
> + tsq = rte_zmalloc_socket("iavf txtime queue", sizeof(*tsq),
> + RTE_CACHE_LINE_SIZE, socket_id);
> + if (!tsq) {
> + PMD_INIT_LOG(ERR, "Failed to allocate memory for Tx time queue");
> + iavf_dev_tx_queue_release(dev, queue_idx);
> + dev->data->tx_queues[queue_idx] = NULL;
> + return -ENOMEM;
> + }
> + txq->iavf_tsq = tsq;
> +
> + if (rte_mbuf_dyn_tx_timestamp_register(&tsq->ts_offset,
> + &tsq->ts_flag)) {
> + PMD_INIT_LOG(ERR, "Cannot register Tx mbuf field/flag for timestamp");
> + iavf_dev_tx_queue_release(dev, queue_idx);
> + dev->data->tx_queues[queue_idx] = NULL;
> + return -EINVAL;
> + }
> +
> + /* Extra descriptors are needed to handle ring wrap-around. */
> + tsq->nb_ts_desc = nb_desc + VIRTCHNL_MAX_TXTIME_FETCH_TX_DESC;
> + ts_ring_size = sizeof(struct iavf_ts_desc) * tsq->nb_ts_desc;
> + ts_ring_size = RTE_ALIGN(ts_ring_size, IAVF_DMA_MEM_ALIGN);
> + ts_mz = rte_eth_dma_zone_reserve(dev, "iavf_tstamp_ring", queue_idx,
> + ts_ring_size, IAVF_RING_BASE_ALIGN,
> + socket_id);
> + if (!ts_mz) {
> + PMD_INIT_LOG(ERR, "Failed to reserve DMA memory for Tx timestamp ring");
> + iavf_dev_tx_queue_release(dev, queue_idx);
> + dev->data->tx_queues[queue_idx] = NULL;
> + return -ENOMEM;
> + }
> + tsq->ts_mz = ts_mz;
> + tsq->ts_ring = ts_mz->addr;
> + tsq->ts_tail = 0;
> +
> + /* Tx Time uses a dedicated timestamp-ring doorbell register. The
> + * normal qtx_tail is kept so queue init writes the standard tail;
> + * the TS doorbell is only rung from the xmit path.
> + */
> + tsq->tail = hw->hw_addr + IAVF_GLQTX_TXTIME_DBELL_LSB(queue_idx);
> + }
> +
> if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS &&
> vf->tm_conf.committed) {
> int tc;
> @@ -956,6 +1016,16 @@ iavf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
>
> txq = dev->data->tx_queues[tx_queue_id];
>
> + /* For a Tx Time queue, start from a clean timestamp ring and tail so a
> + * stale state left by a previous, non-drained run is not fetched by
> + * hardware once the queue is re-enabled.
> + */
> + if (txq->iavf_tsq != NULL) {
> + memset((void *)(uintptr_t)txq->iavf_tsq->ts_ring, 0,
> + txq->iavf_tsq->nb_ts_desc * sizeof(struct iavf_ts_desc));
> + txq->iavf_tsq->ts_tail = 0;
> + }
> +
> /* Init the RX tail register. */
> IAVF_PCI_REG_WRITE(txq->qtx_tail, 0);
> IAVF_WRITE_FLUSH(hw);
> @@ -1068,6 +1138,11 @@ iavf_dev_tx_queue_release(struct rte_eth_dev *dev, uint16_t qid)
> ci_txq_release_all_mbufs(q, q->use_ctx);
> rte_free(q->sw_ring);
> rte_free(q->rs_last_id);
> + if (q->iavf_tsq) {
> + rte_memzone_free(q->iavf_tsq->ts_mz);
> + rte_free(q->iavf_tsq);
> + q->iavf_tsq = NULL;
> + }
> rte_memzone_free(q->mz);
> rte_free(q);
> }
> @@ -2591,6 +2666,62 @@ iavf_get_context_desc(uint64_t ol_flags, const struct rte_mbuf *mbuf,
> return 1; /* One context descriptor needed */
> }
>
> +/* Tx Time (SO_TXTIME / ETF) timestamp-queue callbacks for ci_xmit_pkts */
> +static uint16_t
> +iavf_get_ts_tail(struct ci_tx_queue *txq)
> +{
> + return txq->iavf_tsq->ts_tail;
> +}
> +
> +static uint16_t
> +iavf_write_ts_desc(struct ci_tx_queue *txq, struct rte_mbuf *tx_pkt,
> + uint16_t tx_id, uint16_t ts_id)
> +{
> + struct iavf_txtime *tsq = txq->iavf_tsq;
> + uint64_t txtime = *RTE_MBUF_DYNFIELD(tx_pkt, tsq->ts_offset, uint64_t *);
> + const uint32_t desc_tx_id = (tx_id == 0) ? txq->nb_tx_desc : tx_id;
> + uint32_t tstamp = 0;
> + rte_le32_t ts_desc;
> +
> + /* Timestamp 0 means not paced: send unscheduled and long late packets now */
> + if ((tx_pkt->ol_flags & tsq->ts_flag) &&
> + (tsq->now == 0 || txtime + IAVF_TXTIME_HORIZON_NS >= tsq->now)) {
> + /* The clock estimate is coarse, only keep far times in the window */
> + if (tsq->now != 0 && txtime > tsq->now + IAVF_TXTIME_HORIZON_NS)
> + txtime = tsq->now + IAVF_TXTIME_HORIZON_NS;
> + /* The hardware compares against the free running PHC, not ns in second */
> + tstamp = (uint32_t)((txtime + IAVF_TXTIME_ROUND_NS) >>
> + IAVF_TXTIME_RESOLUTION_128NS);
> + tstamp &= IAVF_TXTIME_STAMP_M >> IAVF_TXTIME_STAMP_S;
> + if (tstamp == 0)
> + tstamp = 1;
> + }
> + ts_desc = rte_cpu_to_le_32((desc_tx_id & IAVF_TXTIME_TX_DESC_IDX_M) |
> + ((tstamp << IAVF_TXTIME_STAMP_S) & IAVF_TXTIME_STAMP_M));
> +
> + tsq->ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
> + ts_id++;
> +
> + /* To prevent an MDD, when wrapping the timestamp ring create additional
> + * TS descriptors equal to the number of fetch TS descriptors. HW merges
> + * TS descriptors with the same timestamp value into a single descriptor.
> + */
> + if (ts_id == tsq->nb_ts_desc) {
> + uint16_t fetch = tsq->nb_ts_desc - txq->nb_tx_desc;
> + ts_id = 0;
> + for (; ts_id < fetch; ts_id++)
> + tsq->ts_ring[ts_id].tx_desc_idx_tstamp = ts_desc;
> + }
> + return ts_id;
> +}
> +
> +static void
> +iavf_write_ts_tail(struct ci_tx_queue *txq, uint16_t ts_id)
> +{
> + IAVF_PCI_REG_WRITE(txq->iavf_tsq->tail, ts_id);
> + txq->iavf_tsq->ts_tail = ts_id;
> +}
> +
> /* TX function */
> uint16_t
> iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
> @@ -2605,7 +2736,19 @@ iavf_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
> .calc_segment_len = iavf_calc_ipsec_segment_len,
> };
>
> - /* IAVF does not support timestamp queues, so pass NULL for ts_fns */
> + /* If Tx Time offload is enabled, drive the timestamp ring doorbell. */
> + if (txq->iavf_tsq != NULL && txq->iavf_tsq->ts_flag > 0) {
> + const struct ci_timestamp_queue_fns ts_fns = {
> + .get_ts_tail = iavf_get_ts_tail,
> + .write_ts_desc = iavf_write_ts_desc,
> + .write_ts_tail = iavf_write_ts_tail,
> + };
> +
> + txq->iavf_tsq->now = iavf_txtime_clock_now(txq->iavf_vsi->adapter);
> + return ci_xmit_pkts(txq, tx_pkts, nb_pkts, vlan_pos, vlan_pos,
> + iavf_get_context_desc, &ipsec_ops, &ts_fns);
> + }
> +
> return ci_xmit_pkts(txq, tx_pkts, nb_pkts, vlan_pos, vlan_pos,
> iavf_get_context_desc, &ipsec_ops, NULL);
> }
> diff --git a/drivers/net/intel/iavf/iavf_rxtx.h b/drivers/net/intel/iavf/iavf_rxtx.h
> index 812d7e23ee..5efa920974 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx.h
> +++ b/drivers/net/intel/iavf/iavf_rxtx.h
> @@ -21,6 +21,28 @@
> /* Base address of the HW descriptor ring should be 128B aligned. */
> #define IAVF_RING_BASE_ALIGN 128
>
> +/* Tx Time (Earliest TxTime First / SO_TXTIME) offload definitions */
> +#define IAVF_TXTIME_TX_DESC_IDX_M RTE_GENMASK32(12, 0)
> +#define IAVF_TXTIME_STAMP_S 13
> +#define IAVF_TXTIME_STAMP_M RTE_GENMASK32(31, 13)
> +/* Tx time ring timestamp resolution is 128ns */
> +#define IAVF_TXTIME_RESOLUTION_128NS 7
> +#define IAVF_TXTIME_ROUND_NS (1 << (IAVF_TXTIME_RESOLUTION_128NS - 1))
> +/* Furthest launch time accepted, inside the ~33.5 ms future half of the window */
> +#define IAVF_TXTIME_HORIZON_NS 30000000ULL
> +
> +/* Structure associated with a Tx Time based queue */
> +struct iavf_txtime {
> + volatile struct iavf_ts_desc *ts_ring; /* Tx time ring virtual address */
> + volatile uint8_t *tail; /* timestamp ring doorbell register address */
> + uint16_t nb_ts_desc; /* number of Tx Time descriptors */
> + 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; /* estimated PHC time at the start of a Tx burst, 0 if unknown */
> + const struct rte_memzone *ts_mz;
> +};
> +
> /* used for Rx Bulk Allocate */
> #define IAVF_RX_MAX_BURST CI_RX_MAX_BURST
>
> @@ -51,6 +73,7 @@
> RTE_ETH_TX_OFFLOAD_MULTI_SEGS | \
> RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | \
> RTE_ETH_TX_OFFLOAD_SECURITY | \
> + RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP | \
> RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM)
>
> /* basic scalar path */
> diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
> index 64ca93c20b..57a6644896 100644
> --- a/drivers/net/intel/iavf/iavf_vchnl.c
> +++ b/drivers/net/intel/iavf/iavf_vchnl.c
> @@ -856,6 +856,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter)
> VIRTCHNL_VF_LARGE_NUM_QPAIRS |
> VIRTCHNL_VF_OFFLOAD_QOS |
> VIRTCHNL_VF_OFFLOAD_INLINE_IPSEC_CRYPTO |
> + VIRTCHNL_VF_CAPS2 |
> VIRTCHNL_VF_CAP_PTP;
>
> args.in_args = (uint8_t *)∩︀
> @@ -1489,6 +1490,17 @@ iavf_configure_queue_pair(struct iavf_adapter *adapter,
> if (q_idx < adapter->dev_data->nb_tx_queues) {
> vc_qp->txq.ring_len = txq[q_idx]->nb_tx_desc;
> vc_qp->txq.dma_ring_addr = txq[q_idx]->tx_ring_dma;
> +
> + /* Tx Time (SO_TXTIME / ETF) offload: pass the timestamp ring
> + * address and request the PF to enable TXTIME on this queue.
> + * On teardown stop_txtime is set so the queue is reconfigured
> + * without the flag, releasing the PF scheduler context.
> + */
> + if (txq[q_idx]->iavf_tsq != NULL && !vf->stop_txtime) {
> + vc_qp->txq.flags |= VIRTCHNL_TXQ_FLAG_TXTIME_ENABLED;
> + vc_qp->txq.dma_txtime_addr =
> + txq[q_idx]->iavf_tsq->ts_mz->iova;
> + }
> }
>
> /* is this rxq active? */
> @@ -2568,6 +2580,51 @@ iavf_get_ptp_cap(struct iavf_adapter *adapter)
> return 0;
> }
>
> +int
> +iavf_get_vf_caps2(struct iavf_adapter *adapter)
> +{
> + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
> + uint8_t msg_buf[IAVF_AQ_BUF_SZ] = {0};
> + /* flags_len words cover all bits up to VIRTCHNL_VF_CAPS_MAX */
> + const uint32_t flags_len =
> + (VIRTCHNL_VF_CAPS_MAX + 31) / 32;
> + uint8_t req_buf[sizeof(struct virtchnl_vf_caps2) +
> + ((VIRTCHNL_VF_CAPS_MAX + 31) / 32) * sizeof(uint32_t)] = {0};
> + struct virtchnl_vf_caps2 *caps2 = (struct virtchnl_vf_caps2 *)req_buf;
> + struct virtchnl_vf_caps2 *resp;
> + struct iavf_cmd_info args;
> + uint32_t i;
> + int err;
> +
> + /* Request the already-granted base caps plus the extended TXTIME bit. */
> + caps2->flags_len = flags_len;
> + caps2->vf_cap_flags[0] = vf->vf_res->vf_cap_flags;
> + caps2->vf_cap_flags[VIRTCHNL_VF_OFFLOAD_TXTIME / 32] |=
> + RTE_BIT32(VIRTCHNL_VF_OFFLOAD_TXTIME % 32);
> +
> + args.ops = VIRTCHNL_OP_GET_VF_CAPS2;
> + args.in_args = req_buf;
> + args.in_args_size = sizeof(struct virtchnl_vf_caps2) +
> + flags_len * sizeof(uint32_t);
> + args.out_buffer = msg_buf;
> + args.out_size = IAVF_AQ_BUF_SZ;
> +
> + err = iavf_execute_vf_cmd_safe(adapter, &args);
> + if (err) {
> + PMD_DRV_LOG(ERR,
> + "Failed to execute command of VIRTCHNL_OP_GET_VF_CAPS2");
> + return err;
> + }
> +
> + /* The PF replies with the bitmap of enabled extended capabilities. */
> + resp = (struct virtchnl_vf_caps2 *)args.out_buffer;
> + vf->vf_cap_flags2 = 0;
> + for (i = 0; i < resp->flags_len && i < 2; i++)
> + vf->vf_cap_flags2 |= (uint64_t)resp->vf_cap_flags[i] << (32 * i);
> +
> + return 0;
> +}
> +
> int
> iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
> {
> @@ -2575,6 +2632,7 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
> uint8_t msg_buf[IAVF_AQ_BUF_SZ] = {0};
> struct virtchnl_phc_time phc_time;
> struct iavf_cmd_info args;
> + uint64_t tsc_start;
> int err = 0;
>
> args.ops = VIRTCHNL_OP_1588_PTP_GET_TIME;
> @@ -2584,6 +2642,7 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
> args.out_size = IAVF_AQ_BUF_SZ;
>
> rte_spinlock_lock(&vf->phc_time_aq_lock);
> + tsc_start = rte_rdtsc();
> err = iavf_execute_vf_cmd_safe(adapter, &args);
> if (err) {
> PMD_DRV_LOG(ERR,
> @@ -2592,6 +2651,12 @@ iavf_phc_get_time(struct iavf_adapter *adapter, uint64_t *time)
> }
> *time = ((struct virtchnl_phc_time *)args.out_buffer)->time;
>
> + /* anchor the Tx time clock estimate to the middle of the request */
> + rte_seqlock_write_lock(&adapter->txtime_clk.lock);
> + adapter->txtime_clk.phc = *time;
> + adapter->txtime_clk.tsc = tsc_start + (rte_rdtsc() - tsc_start) / 2;
> + rte_seqlock_write_unlock(&adapter->txtime_clk.lock);
> +
> out:
> rte_spinlock_unlock(&vf->phc_time_aq_lock);
> return err;
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-12-04 10:41 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:57 [PATCH v1 0/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
2026-12-02 12:57 ` [PATCH v1 1/6] net/iavf/base: add VF Earliest TxTime First offload support Soumyadeep Hore
2026-12-04 8:08 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 2/6] net/iavf/base: add VF Earliest TxTime First offload flag Soumyadeep Hore
2026-12-04 8:09 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 3/6] net/iavf/base: add VF Earliest TxTime First offload register Soumyadeep Hore
2026-12-04 8:09 ` Kumar, Rajesh
2026-12-04 8:17 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 4/6] net/intel/common: add Tx time queue field for iavf Soumyadeep Hore
2026-12-04 8:17 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 5/6] net/iavf: support Earliest TxTime First offload Soumyadeep Hore
2026-12-04 10:41 ` Kumar, Rajesh
2026-12-02 12:57 ` [PATCH v1 6/6] doc: add iavf " Soumyadeep Hore
2026-12-04 8:07 ` Kumar, Rajesh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox