[v4,5/7] common/idpf: add timestamp enable flag for rxq

Message ID 20230519083110.809913-6-wenjing.qiao@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Qi Zhang
Headers
Series fix idpf and cpfl timestamp |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Wenjing Qiao May 19, 2023, 8:31 a.m. UTC
  A rxq can be configured with timestamp offload.
So, add timestamp enable flag for rxq.

Fixes: 8c6098afa075 ("common/idpf: add Rx/Tx data path")
Cc: stable@dpdk.org

Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>
Suggested-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/common/idpf/idpf_common_rxtx.c | 11 ++++++++++-
 drivers/common/idpf/idpf_common_rxtx.h |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/common/idpf/idpf_common_rxtx.c b/drivers/common/idpf/idpf_common_rxtx.c
index 13e94dda43..26aaddb106 100644
--- a/drivers/common/idpf/idpf_common_rxtx.c
+++ b/drivers/common/idpf/idpf_common_rxtx.c
@@ -416,7 +416,7 @@  int
 idpf_qc_ts_mbuf_register(struct idpf_rx_queue *rxq)
 {
 	int err;
-	if ((rxq->offloads & IDPF_RX_OFFLOAD_TIMESTAMP) != 0) {
+	if (!rxq->ts_enable && (rxq->offloads & IDPF_RX_OFFLOAD_TIMESTAMP)) {
 		/* Register mbuf field and flag for Rx timestamp */
 		err = rte_mbuf_dyn_rx_timestamp_register(&idpf_timestamp_dynfield_offset,
 							 &idpf_timestamp_dynflag);
@@ -425,6 +425,7 @@  idpf_qc_ts_mbuf_register(struct idpf_rx_queue *rxq)
 				"Cannot register mbuf field/flag for timestamp");
 			return -EINVAL;
 		}
+		rxq->ts_enable = TRUE;
 	}
 	return 0;
 }
@@ -433,9 +434,17 @@  idpf_qc_ts_mbuf_register(struct idpf_rx_queue *rxq)
 int
 idpf_rx_timestamp_start(struct idpf_adapter *base)
 {
+	int ret;
 	rte_eal_alarm_set(1000 * 1000,
 			  &idpf_dev_read_time_hw,
 			  (void *)base);
+	/* Register mbuf field and flag for Rx timestamp */
+	ret = rte_mbuf_dyn_rx_timestamp_register(&idpf_timestamp_dynfield_offset,
+						 &idpf_timestamp_dynflag);
+	if (ret != 0) {
+		DRV_LOG(ERR, "Cannot register mbuf field/flag for timestamp");
+		return -EINVAL;
+	}
 	return 0;
 }
 
diff --git a/drivers/common/idpf/idpf_common_rxtx.h b/drivers/common/idpf/idpf_common_rxtx.h
index 53049b1a31..e902c4f275 100644
--- a/drivers/common/idpf/idpf_common_rxtx.h
+++ b/drivers/common/idpf/idpf_common_rxtx.h
@@ -145,6 +145,8 @@  struct idpf_rx_queue {
 	struct idpf_rx_queue *bufq2;
 
 	uint64_t offloads;
+
+	bool ts_enable; /* if timestamp is enabled */
 };
 
 struct idpf_tx_entry {