Skip to contentSkip to conversation

net/igc: support Tx timestamp offload

PATCH New Simei Su 4 participants 14 messages Dec 20, 2022 – Feb 3, 2023 Network drivers

lore
Share & tools
lore

Simei Su

author
#0 lore raw

cover net/igc: support Tx timestamp offload

[PATCH 1/2] add related definitions to support Tx timestamp offload. [PATCH 2/2] enable Tx timestamp offload by "Launch Time".

Simei Su (2):
net/igc/base: support Tx timestamp offload
net/igc: enable Tx timestamp offload

 drivers/net/igc/base/igc_defines.h |  9 +++++
 drivers/net/igc/base/igc_regs.h    |  8 +++++
 drivers/net/igc/igc_ethdev.c       | 70 ++++++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h       |  6 +++-
 drivers/net/igc/igc_txrx.c         | 58 ++++++++++++++++++++++++++-----
 drivers/net/igc/igc_txrx.h         |  3 ++
 6 files changed, 145 insertions(+), 9 deletions(-)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH 1/2 net/igc/base: support Tx timestamp offload

Add definitions for Tx timestamp offload
"RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP".

---
 drivers/net/igc/base/igc_defines.h | 9 +++++++++
 drivers/net/igc/base/igc_regs.h    | 8 ++++++++
 2 files changed, 17 insertions(+)
drivers/net/igc/base/igc_defines.h +9 -0
index dd7330a..280570b 100644
@@ -188,6 +188,15 @@
 #define IGC_RCTL_BSEX		0x02000000 /* Buffer size extension */
 #define IGC_RCTL_SECRC	0x04000000 /* Strip Ethernet CRC */
 
+#define IGC_DTXMXPKTSZ_TSN     0x19 /* 1600 bytes of max TX DMA packet size */
+#define IGC_TXPBSIZE_TSN       0x04145145 /* 5k bytes buffer for each queue */
+
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV      0x00000008
+
+#define IGC_TXQCTL_QUEUE_MODE_LAUNCHT  0x00000001
+
 /* Use byte values for the following shift parameters
  * Usage:
  *     psrctl |= (((ROUNDUP(value0, 128) >> IGC_PSRCTL_BSIZE0_SHIFT) &
drivers/net/igc/base/igc_regs.h +8 -0
index d424387..e423814 100644
@@ -602,6 +602,14 @@
 #define IGC_RXMTRL	0x0B634 /* Time sync Rx EtherType and Msg Type - RW */
 #define IGC_RXUDP	0x0B638 /* Time Sync Rx UDP Port - RW */
 
+#define IGC_QBVCYCLET	0x331C
+#define IGC_QBVCYCLET_S 0x3320
+#define IGC_STQT(_n)	(0x3324 + 0x4 * (_n))
+#define IGC_ENDQT(_n)	(0x3334 + 0x4 * (_n))
+#define IGC_TXQCTL(_n)	(0x3344 + 0x4 * (_n))
+#define IGC_BASET_L	0x3314
+#define IGC_BASET_H	0x3318
+
 /* Filtering Registers */
 #define IGC_SAQF(_n)	(0x05980 + (4 * (_n))) /* Source Address Queue Fltr */
 #define IGC_DAQF(_n)	(0x059A0 + (4 * (_n))) /* Dest Address Queue Fltr */
Signature · 1 line
2.9.5
author
#2 lore raw

PATCH 2/2 net/igc: enable Tx timestamp offload

In reply to Simei Su

This patch supports Tx timestamp offload by leveraging NIC's "Launch Time" for "RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP".

---
 drivers/net/igc/igc_ethdev.c | 70 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h |  6 +++-
 drivers/net/igc/igc_txrx.c   | 58 +++++++++++++++++++++++++++++++-----
 drivers/net/igc/igc_txrx.h   |  3 ++
 4 files changed, 128 insertions(+), 9 deletions(-)
drivers/net/igc/igc_ethdev.c +70 -0
index ef3346b..28f6cd5 100644
@@ -88,6 +88,9 @@
 #define IGC_I225_RX_LATENCY_1000	300
 #define IGC_I225_RX_LATENCY_2500	1485
 
+uint64_t igc_timestamp_dynflag;
+int igc_timestamp_dynfield_offset = -1;
+
 static const struct rte_eth_desc_lim rx_desc_lim = {
 	.nb_max = IGC_MAX_RXD,
 	.nb_min = IGC_MIN_RXD,
@@ -267,6 +270,7 @@ static int eth_igc_timesync_read_time(struct rte_eth_dev *dev,
 				  struct timespec *timestamp);
 static int eth_igc_timesync_write_time(struct rte_eth_dev *dev,
 				   const struct timespec *timestamp);
+static int eth_igc_read_clock(struct rte_eth_dev *dev, uint64_t *clock);
 
 static const struct eth_dev_ops eth_igc_ops = {
 	.dev_configure		= eth_igc_configure,
@@ -327,6 +331,7 @@ static const struct eth_dev_ops eth_igc_ops = {
 	.timesync_adjust_time	= eth_igc_timesync_adjust_time,
 	.timesync_read_time	= eth_igc_timesync_read_time,
 	.timesync_write_time	= eth_igc_timesync_write_time,
+	.read_clock             = eth_igc_read_clock,
 };
 
 /*
@@ -949,7 +954,12 @@ eth_igc_start(struct rte_eth_dev *dev)
 	struct igc_adapter *adapter = IGC_DEV_PRIVATE(dev);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	uint32_t nsec, sec, baset_l, baset_h, tqavctrl;
+	struct timespec system_time;
+	int64_t n, systime;
+	uint32_t txqctl = 0;
 	uint32_t *speeds;
+	uint16_t i;
 	int ret;
 
 	PMD_INIT_FUNC_TRACE();
@@ -1009,6 +1019,55 @@ eth_igc_start(struct rte_eth_dev *dev)
 		return ret;
 	}
 
+	if (igc_timestamp_dynflag > 0) {
+		adapter->base_time = 0;
+		adapter->cycle_time = NSEC_PER_SEC;
+
+		IGC_WRITE_REG(hw, IGC_TSSDP, 0);
+		IGC_WRITE_REG(hw, IGC_TSIM, TSINTR_TXTS);
+		IGC_WRITE_REG(hw, IGC_IMS, IGC_ICR_TS);
+
+		IGC_WRITE_REG(hw, IGC_TSAUXC, 0);
+		IGC_WRITE_REG(hw, IGC_I350_DTXMXPKTSZ, IGC_DTXMXPKTSZ_TSN);
+		IGC_WRITE_REG(hw, IGC_TXPBS, IGC_TXPBSIZE_TSN);
+
+		tqavctrl = IGC_READ_REG(hw, IGC_I210_TQAVCTRL);
+		tqavctrl |= IGC_TQAVCTRL_TRANSMIT_MODE_TSN |
+			    IGC_TQAVCTRL_ENHANCED_QAV;
+		IGC_WRITE_REG(hw, IGC_I210_TQAVCTRL, tqavctrl);
+
+		IGC_WRITE_REG(hw, IGC_QBVCYCLET_S, adapter->cycle_time);
+		IGC_WRITE_REG(hw, IGC_QBVCYCLET, adapter->cycle_time);
+
+		for (i = 0; i < dev->data->nb_tx_queues; i++) {
+			IGC_WRITE_REG(hw, IGC_STQT(i), 0);
+			IGC_WRITE_REG(hw, IGC_ENDQT(i), NSEC_PER_SEC);
+
+			txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT;
+			IGC_WRITE_REG(hw, IGC_TXQCTL(i), txqctl);
+		}
+
+		clock_gettime(CLOCK_REALTIME, &system_time);
+		IGC_WRITE_REG(hw, IGC_SYSTIML, system_time.tv_nsec);
+		IGC_WRITE_REG(hw, IGC_SYSTIMH, system_time.tv_sec);
+
+		nsec = IGC_READ_REG(hw, IGC_SYSTIML);
+		sec = IGC_READ_REG(hw, IGC_SYSTIMH);
+		systime = (int64_t)sec * NSEC_PER_SEC + (int64_t)nsec;
+
+		if (systime > adapter->base_time) {
+			n = (systime - adapter->base_time) /
+			     adapter->cycle_time;
+			adapter->base_time = adapter->base_time +
+				(n + 1) * adapter->cycle_time;
+		}
+
+		baset_h = adapter->base_time / NSEC_PER_SEC;
+		baset_l = adapter->base_time % NSEC_PER_SEC;
+		IGC_WRITE_REG(hw, IGC_BASET_H, baset_h);
+		IGC_WRITE_REG(hw, IGC_BASET_L, baset_l);
+	}
+
 	igc_clear_hw_cntrs_base_generic(hw);
 
 	/* VLAN Offload Settings */
@@ -2804,6 +2863,17 @@ eth_igc_timesync_disable(struct rte_eth_dev *dev)
 }
 
 static int
+eth_igc_read_clock(__rte_unused struct rte_eth_dev *dev, uint64_t *clock)
+{
+	struct timespec system_time;
+
+	clock_gettime(CLOCK_REALTIME, &system_time);
+	*clock = system_time.tv_sec * NSEC_PER_SEC + system_time.tv_nsec;
+
+	return 0;
+}
+
+static int
 eth_igc_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	struct rte_pci_device *pci_dev)
 {
drivers/net/igc/igc_ethdev.h +5 -1
index 237d3c1..8d7eb54 100644
@@ -87,7 +87,8 @@ extern "C" {
 	RTE_ETH_TX_OFFLOAD_SCTP_CKSUM  | \
 	RTE_ETH_TX_OFFLOAD_TCP_TSO     | \
 	RTE_ETH_TX_OFFLOAD_UDP_TSO	   | \
-	RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
+	RTE_ETH_TX_OFFLOAD_MULTI_SEGS  | \
+	RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)
 
 #define IGC_RSS_OFFLOAD_ALL	(    \
 	RTE_ETH_RSS_IPV4               | \
@@ -240,6 +241,9 @@ struct igc_adapter {
 	struct igc_syn_filter syn_filter;
 	struct igc_rss_filter rss_filter;
 	struct igc_flow_list flow_list;
+
+	int64_t base_time;
+	uint32_t cycle_time;
 };
 
 #define IGC_DEV_PRIVATE(_dev)	((_dev)->data->dev_private)
drivers/net/igc/igc_txrx.c +50 -8

108 lines not on this page · raw message

drivers/net/igc/igc_txrx.h +3 -0
index e7272f8..73757d2 100644
@@ -11,6 +11,9 @@
 extern "C" {
 #endif
 
+extern uint64_t igc_timestamp_dynflag;
+extern int igc_timestamp_dynfield_offset;
+
 struct igc_rx_entry {
 	struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
 };
Signature · 1 line
2.9.5
author
#3 lore raw

v2 cover net/igc: support launch time offloading

In reply to Simei Su

[PATCH v2 1/2] expose packet pacing registers
[PATCH v2 2/2] enable launch time offloading

v2:
* Refine title and commit log.
* Add release notes.
* Rename variable name.

Simei Su (2):
net/igc/base: expose packet pacing registers
net/igc: enable launch time offloading

 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/base/igc_defines.h     |  9 +++++
 drivers/net/igc/base/igc_regs.h        |  8 ++++
 drivers/net/igc/igc_ethdev.c           | 70 ++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++----
 drivers/net/igc/igc_txrx.h             |  3 ++
 7 files changed, 146 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.5
author
#4 lore raw

PATCH v2 1/2 net/igc/base: expose packet pacing registers

Add definitions for packet pacing(launch time offloading) related registers.

---
 drivers/net/igc/base/igc_defines.h | 9 +++++++++
 drivers/net/igc/base/igc_regs.h    | 8 ++++++++
 2 files changed, 17 insertions(+)
drivers/net/igc/base/igc_defines.h +9 -0
index dd7330a..280570b 100644
@@ -188,6 +188,15 @@
 #define IGC_RCTL_BSEX		0x02000000 /* Buffer size extension */
 #define IGC_RCTL_SECRC	0x04000000 /* Strip Ethernet CRC */
 
+#define IGC_DTXMXPKTSZ_TSN     0x19 /* 1600 bytes of max TX DMA packet size */
+#define IGC_TXPBSIZE_TSN       0x04145145 /* 5k bytes buffer for each queue */
+
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV      0x00000008
+
+#define IGC_TXQCTL_QUEUE_MODE_LAUNCHT  0x00000001
+
 /* Use byte values for the following shift parameters
  * Usage:
  *     psrctl |= (((ROUNDUP(value0, 128) >> IGC_PSRCTL_BSIZE0_SHIFT) &
drivers/net/igc/base/igc_regs.h +8 -0
index d424387..e423814 100644
@@ -602,6 +602,14 @@
 #define IGC_RXMTRL	0x0B634 /* Time sync Rx EtherType and Msg Type - RW */
 #define IGC_RXUDP	0x0B638 /* Time Sync Rx UDP Port - RW */
 
+#define IGC_QBVCYCLET	0x331C
+#define IGC_QBVCYCLET_S 0x3320
+#define IGC_STQT(_n)	(0x3324 + 0x4 * (_n))
+#define IGC_ENDQT(_n)	(0x3334 + 0x4 * (_n))
+#define IGC_TXQCTL(_n)	(0x3344 + 0x4 * (_n))
+#define IGC_BASET_L	0x3314
+#define IGC_BASET_H	0x3318
+
 /* Filtering Registers */
 #define IGC_SAQF(_n)	(0x05980 + (4 * (_n))) /* Source Address Queue Fltr */
 #define IGC_DAQF(_n)	(0x059A0 + (4 * (_n))) /* Dest Address Queue Fltr */
Signature · 1 line
2.9.5
author
#5 lore raw

PATCH v2 2/2 net/igc: enable launch time offloading

In reply to Simei Su

The LaunchTime defines the scheduling time of the packet from the packet buffer to the MAC. The launchtime of each packet is specified as an offset applied to the BaseT registers while BaseT is automatically incremented each cycle.

This patch supports Tx timestamp based packet pacing by leveraging offload flag "RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP". We should set the expected launchtime to the advanced transmit descriptor.

---
 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/igc_ethdev.c           | 70 ++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++----
 drivers/net/igc/igc_txrx.h             |  3 ++
 5 files changed, 129 insertions(+), 10 deletions(-)
doc/guides/rel_notes/release_23_03.rst +1 -1
index d175f8e..5bca6af 100644
@@ -79,7 +79,7 @@ New Features
 * **Updated Intel igc driver.**
 
   * Added timesync API support.
-
+  * Added packet pacing(launch time offloading) support.
 
 Removed Items
 -------------
drivers/net/igc/igc_ethdev.c +70 -0

107 lines not on this page · raw message

drivers/net/igc/igc_ethdev.h +5 -1
index 237d3c1..8d7eb54 100644
@@ -87,7 +87,8 @@ extern "C" {
 	RTE_ETH_TX_OFFLOAD_SCTP_CKSUM  | \
 	RTE_ETH_TX_OFFLOAD_TCP_TSO     | \
 	RTE_ETH_TX_OFFLOAD_UDP_TSO	   | \
-	RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
+	RTE_ETH_TX_OFFLOAD_MULTI_SEGS  | \
+	RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)
 
 #define IGC_RSS_OFFLOAD_ALL	(    \
 	RTE_ETH_RSS_IPV4               | \
@@ -240,6 +241,9 @@ struct igc_adapter {
 	struct igc_syn_filter syn_filter;
 	struct igc_rss_filter rss_filter;
 	struct igc_flow_list flow_list;
+
+	int64_t base_time;
+	uint32_t cycle_time;
 };
 
 #define IGC_DEV_PRIVATE(_dev)	((_dev)->data->dev_private)
drivers/net/igc/igc_txrx.c +50 -8

108 lines not on this page · raw message

drivers/net/igc/igc_txrx.h +3 -0
index e7272f8..ad7d3b4 100644
@@ -11,6 +11,9 @@
 extern "C" {
 #endif
 
+extern uint64_t igc_tx_timestamp_dynflag;
+extern int igc_tx_timestamp_dynfield_offset;
+
 struct igc_rx_entry {
 	struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
 };
Signature · 1 line
2.9.5
#6 lore raw

RE: [PATCH v2 2/2] net/igc: enable launch time offloading

Quoted 16 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Wednesday, February 1, 2023 3:30 PM
To: Zhang, Qi Z <[email protected]>; Guo, Junfeng <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v2 2/2] net/igc: enable launch time offloading

The LaunchTime defines the scheduling time of the packet from the packet buffer to the MAC. The launchtime of each packet is specified as an offset applied to the BaseT registers while BaseT is automatically incremented each cycle.

Quoted 5 lines

This patch supports Tx timestamp based packet pacing by leveraging offload flag "RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP". We should set the expected launchtime to the advanced transmit descriptor.

There is a coding style warning need to fix.

You can use devtools/checkpatches.sh to check the coding style before submit.

Otherwise, the patchset looks good.

#7 lore raw

RE: [PATCH v2 0/2] net/igc: support launch time offloading

In reply to Simei Su

+To: Ferruh, Matan and Viacheslav, regarding feature documentation

Quoted 26 lines

From: Simei Su [mailto:[email protected]]
Sent: Wednesday, 1 February 2023 08.30

[PATCH v2 1/2] expose packet pacing registers
[PATCH v2 2/2] enable launch time offloading

v2:
* Refine title and commit log.
* Add release notes.
* Rename variable name.

Simei Su (2):
net/igc/base: expose packet pacing registers
net/igc: enable launch time offloading

 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/base/igc_defines.h     |  9 +++++
 drivers/net/igc/base/igc_regs.h        |  8 ++++
 drivers/net/igc/igc_ethdev.c           | 70
++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++--
--
 drivers/net/igc/igc_txrx.h             |  3 ++
 7 files changed, 146 insertions(+), 10 deletions(-)
Quoted 3 lines

--
2.9.5

Please also note:

This RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP feature should be added to the documentation of NIC features [1] and [2].

[1]: https://doc.dpdk.org/guides/nics/overview.html
[2]: https://doc.dpdk.org/guides/nics/features.html

This should have been done when the feature was introduced by the mlx5 PMD. But apparently, no one thought about it back then. And late is better than never.

Also, adding the feature to the documentation might help deciding on a common name for it.

author
#8 lore raw

v3 cover net/igc: support launch time offloading

In reply to Simei Su

[PATCH v3 1/2] expose packet pacing registers
[PATCH v3 2/2] enable launch time offloading

v3:
* Fix coding style issue.

v2:
* Refine title and commit log.
* Add release notes.
* Rename variable name.

Simei Su (2):
net/igc/base: expose packet pacing registers
net/igc: enable launch time offloading

 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/base/igc_defines.h     |  9 +++++
 drivers/net/igc/base/igc_regs.h        |  8 ++++
 drivers/net/igc/igc_ethdev.c           | 70 ++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++----
 drivers/net/igc/igc_txrx.h             |  3 ++
 7 files changed, 146 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.5
author
#9 lore raw

PATCH v3 1/2 net/igc/base: expose packet pacing registers

Add definitions for packet pacing(launch time offloading) related registers.

---
 drivers/net/igc/base/igc_defines.h | 9 +++++++++
 drivers/net/igc/base/igc_regs.h    | 8 ++++++++
 2 files changed, 17 insertions(+)
drivers/net/igc/base/igc_defines.h +9 -0
index dd7330a..280570b 100644
@@ -188,6 +188,15 @@
 #define IGC_RCTL_BSEX		0x02000000 /* Buffer size extension */
 #define IGC_RCTL_SECRC	0x04000000 /* Strip Ethernet CRC */
 
+#define IGC_DTXMXPKTSZ_TSN     0x19 /* 1600 bytes of max TX DMA packet size */
+#define IGC_TXPBSIZE_TSN       0x04145145 /* 5k bytes buffer for each queue */
+
+/* Transmit Scheduling */
+#define IGC_TQAVCTRL_TRANSMIT_MODE_TSN 0x00000001
+#define IGC_TQAVCTRL_ENHANCED_QAV      0x00000008
+
+#define IGC_TXQCTL_QUEUE_MODE_LAUNCHT  0x00000001
+
 /* Use byte values for the following shift parameters
  * Usage:
  *     psrctl |= (((ROUNDUP(value0, 128) >> IGC_PSRCTL_BSIZE0_SHIFT) &
drivers/net/igc/base/igc_regs.h +8 -0
index d424387..e423814 100644
@@ -602,6 +602,14 @@
 #define IGC_RXMTRL	0x0B634 /* Time sync Rx EtherType and Msg Type - RW */
 #define IGC_RXUDP	0x0B638 /* Time Sync Rx UDP Port - RW */
 
+#define IGC_QBVCYCLET	0x331C
+#define IGC_QBVCYCLET_S 0x3320
+#define IGC_STQT(_n)	(0x3324 + 0x4 * (_n))
+#define IGC_ENDQT(_n)	(0x3334 + 0x4 * (_n))
+#define IGC_TXQCTL(_n)	(0x3344 + 0x4 * (_n))
+#define IGC_BASET_L	0x3314
+#define IGC_BASET_H	0x3318
+
 /* Filtering Registers */
 #define IGC_SAQF(_n)	(0x05980 + (4 * (_n))) /* Source Address Queue Fltr */
 #define IGC_DAQF(_n)	(0x059A0 + (4 * (_n))) /* Dest Address Queue Fltr */
Signature · 1 line
2.9.5
author
#10 lore raw

PATCH v3 2/2 net/igc: enable launch time offloading

In reply to Simei Su

The LaunchTime defines the scheduling time of the packet from the packet buffer to the MAC. The launchtime of each packet is specified as an offset applied to the BaseT registers while BaseT is automatically incremented each cycle.

This patch supports Tx timestamp based packet pacing by leveraging offload flag "RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP". We should set the expected launchtime to the advanced transmit descriptor.

---
 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/igc_ethdev.c           | 70 ++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++----
 drivers/net/igc/igc_txrx.h             |  3 ++
 5 files changed, 129 insertions(+), 10 deletions(-)
doc/guides/rel_notes/release_23_03.rst +1 -1
index d175f8e..5bca6af 100644
@@ -79,7 +79,7 @@ New Features
 * **Updated Intel igc driver.**
 
   * Added timesync API support.
-
+  * Added packet pacing(launch time offloading) support.
 
 Removed Items
 -------------
drivers/net/igc/igc_ethdev.c +70 -0

107 lines not on this page · raw message

drivers/net/igc/igc_ethdev.h +5 -1
index 237d3c1..8d7eb54 100644
@@ -87,7 +87,8 @@ extern "C" {
 	RTE_ETH_TX_OFFLOAD_SCTP_CKSUM  | \
 	RTE_ETH_TX_OFFLOAD_TCP_TSO     | \
 	RTE_ETH_TX_OFFLOAD_UDP_TSO	   | \
-	RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
+	RTE_ETH_TX_OFFLOAD_MULTI_SEGS  | \
+	RTE_ETH_TX_OFFLOAD_SEND_ON_TIMESTAMP)
 
 #define IGC_RSS_OFFLOAD_ALL	(    \
 	RTE_ETH_RSS_IPV4               | \
@@ -240,6 +241,9 @@ struct igc_adapter {
 	struct igc_syn_filter syn_filter;
 	struct igc_rss_filter rss_filter;
 	struct igc_flow_list flow_list;
+
+	int64_t base_time;
+	uint32_t cycle_time;
 };
 
 #define IGC_DEV_PRIVATE(_dev)	((_dev)->data->dev_private)
drivers/net/igc/igc_txrx.c +50 -8

108 lines not on this page · raw message

drivers/net/igc/igc_txrx.h +3 -0
index e7272f8..ad7d3b4 100644
@@ -11,6 +11,9 @@
 extern "C" {
 #endif
 
+extern uint64_t igc_tx_timestamp_dynflag;
+extern int igc_tx_timestamp_dynfield_offset;
+
 struct igc_rx_entry {
 	struct rte_mbuf *mbuf; /**< mbuf associated with RX descriptor. */
 };
Signature · 1 line
2.9.5
#11 lore raw

Re: [PATCH v3 2/2] net/igc: enable launch time offloading

drivers/net/igc/igc_txrx.c what_advctx_update(struct igc_tx_queue *txq, uint64_t flags, · line 1425

Quoted 13 lines · On Thu, 2 Feb 2023 15:18:01 +0800 Simei Su <[email protected]> wrote:
drivers/net/igc/igc_txrx.c +12 -0
+static uint32_t igc_tx_launchtime(uint64_t txtime, uint16_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	struct igc_adapter *adapter = IGC_DEV_PRIVATE(dev);
+	uint64_t base_time = adapter->base_time;
+	uint64_t cycle_time = adapter->cycle_time;
+	uint32_t launchtime;
+
+	launchtime = (txtime - base_time) % cycle_time;
+
+	return rte_cpu_to_le_32(launchtime);
+}

Divide in transmit path will slow things down.
Better to use something like rte_reciprocal_divide_64() to avoid slow 64 bit divide.

author
#12 lore raw

RE: [PATCH v3 2/2] net/igc: enable launch time offloading

Hi Stephen,

Quoted 13 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, February 3, 2023 8:31 AM
To: Su, Simei <[email protected]>
Cc: Zhang, Qi Z <[email protected]>; Guo, Junfeng <[email protected]>; [email protected]; Wu, Wenjun1 <[email protected]>
Subject: Re: [PATCH v3 2/2] net/igc: enable launch time offloading

Quoted 1 line · On Thu, 2 Feb 2023 15:18:01 +0800 Simei Su <[email protected]> wrote:
Quoted 16 lines

drivers/net/igc/igc_txrx.c what_advctx_update(struct igc_tx_queue *txq, uint64_t flags,

Quoted 11 lines
drivers/net/igc/igc_txrx.c +11 -0
+static uint32_t igc_tx_launchtime(uint64_t txtime, uint16_t port_id)
+{
+	struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+	struct igc_adapter *adapter = IGC_DEV_PRIVATE(dev);
+	uint64_t base_time = adapter->base_time;
+	uint64_t cycle_time = adapter->cycle_time;
+	uint32_t launchtime;
+
+	launchtime = (txtime - base_time) % cycle_time;
+
+	return rte_cpu_to_le_32(launchtime); }

Divide in transmit path will slow things down.
Better to use something like rte_reciprocal_divide_64() to avoid slow 64 bit divide.

Thanks for your comments.
The performance won't be affected if the launchtime function is turned off. If the function is turned on, it indeed doesn't need high performance based on the function.

Thanks,
Simei

Acked-by on the v3 series Applied
#13 lore raw

RE: [PATCH v3 0/2] net/igc: support launch time offloading

In reply to Simei Su
Quoted 36 lines

-----Original Message-----
From: Su, Simei <[email protected]>
Sent: Thursday, February 2, 2023 3:18 PM
To: Zhang, Qi Z <[email protected]>; Guo, Junfeng <[email protected]>
Cc: [email protected]; Wu, Wenjun1 <[email protected]>; Su, Simei <[email protected]>
Subject: [PATCH v3 0/2] net/igc: support launch time offloading

[PATCH v3 1/2] expose packet pacing registers [PATCH v3 2/2] enable launch time offloading

v3:
* Fix coding style issue.

v2:
* Refine title and commit log.
* Add release notes.
* Rename variable name.

Simei Su (2):
net/igc/base: expose packet pacing registers
net/igc: enable launch time offloading

 doc/guides/rel_notes/release_23_03.rst |  2 +-
 drivers/net/igc/base/igc_defines.h     |  9 +++++
 drivers/net/igc/base/igc_regs.h        |  8 ++++
 drivers/net/igc/igc_ethdev.c           | 70
++++++++++++++++++++++++++++++++++
 drivers/net/igc/igc_ethdev.h           |  6 ++-
 drivers/net/igc/igc_txrx.c             | 58 ++++++++++++++++++++++++----
 drivers/net/igc/igc_txrx.h             |  3 ++
 7 files changed, 146 insertions(+), 10 deletions(-)
Quoted 2 lines

--
2.9.5

Applied to dpdk-next-net-intel.

Thanks
Qi