[v3,07/11] net/octeon_ep: flush pending DMA operations

Message ID 20230424125512.40013-8-sedara@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [v3,01/11] net/octeon_ep: support cnf95n and cnf95o SoC |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sathesh B Edara April 24, 2023, 12:55 p.m. UTC
  Flushes the pending DMA operations while reading
the packets by reading control and status register.

Signed-off-by: Sathesh Edara <sedara@marvell.com>
---
 drivers/net/octeon_ep/otx_ep_common.h | 8 ++++++++
 drivers/net/octeon_ep/otx_ep_rxtx.c   | 4 ++++
 2 files changed, 12 insertions(+)
  

Patch

diff --git a/drivers/net/octeon_ep/otx_ep_common.h b/drivers/net/octeon_ep/otx_ep_common.h
index 76528ed49d..444136923f 100644
--- a/drivers/net/octeon_ep/otx_ep_common.h
+++ b/drivers/net/octeon_ep/otx_ep_common.h
@@ -345,6 +345,14 @@  struct otx_ep_droq {
 	 */
 	void *pkts_sent_reg;
 
+	/** Handle DMA incompletion during pkt reads.
+	 * This variable is used to initiate a sent_reg_read
+	 * that completes pending dma
+	 * this variable is used as lvalue so compiler cannot optimize
+	 * the reads.
+	 */
+	uint32_t sent_reg_val;
+
 	/* Statistics for this DROQ. */
 	struct otx_ep_droq_stats stats;
 
diff --git a/drivers/net/octeon_ep/otx_ep_rxtx.c b/drivers/net/octeon_ep/otx_ep_rxtx.c
index c4153bd583..ca968f6fe7 100644
--- a/drivers/net/octeon_ep/otx_ep_rxtx.c
+++ b/drivers/net/octeon_ep/otx_ep_rxtx.c
@@ -917,6 +917,10 @@  otx_ep_droq_read_packet(struct otx_ep_device *otx_ep,
 		struct rte_mbuf *first_buf = NULL;
 		struct rte_mbuf *last_buf = NULL;
 
+		/* csr read helps to flush pending dma */
+		droq->sent_reg_val = rte_read32(droq->pkts_sent_reg);
+		rte_rmb();
+
 		while (pkt_len < total_pkt_len) {
 			int cpy_len = 0;