[05/15] net/ena/base: add method to check used entries

Message ID 20240702144626.14545-6-shaibran@amazon.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/ena: driver release 2.10.0 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Brandes, Shai July 2, 2024, 2:46 p.m. UTC
From: Shai Brandes <shaibran@amazon.com>

Provide a method to check the number of used entries in the send queue

Signed-off-by: Shai Brandes <shaibran@amazon.com>
---
 drivers/net/ena/base/ena_eth_com.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
  

Patch

diff --git a/drivers/net/ena/base/ena_eth_com.h b/drivers/net/ena/base/ena_eth_com.h
index 4e3d0fb6fd..877668612c 100644
--- a/drivers/net/ena/base/ena_eth_com.h
+++ b/drivers/net/ena/base/ena_eth_com.h
@@ -82,15 +82,14 @@  static inline void ena_com_unmask_intr(struct ena_com_io_cq *io_cq,
 	ENA_REG_WRITE32(io_cq->bus, intr_reg->intr_control, io_cq->unmask_reg);
 }
 
-static inline int ena_com_free_q_entries(struct ena_com_io_sq *io_sq)
+static inline u16 ena_com_used_q_entries(struct ena_com_io_sq *io_sq)
 {
-	u16 tail, next_to_comp, cnt;
-
-	next_to_comp = io_sq->next_to_comp;
-	tail = io_sq->tail;
-	cnt = tail - next_to_comp;
+	return io_sq->tail - io_sq->next_to_comp;
+}
 
-	return io_sq->q_depth - 1 - cnt;
+static inline int ena_com_free_q_entries(struct ena_com_io_sq *io_sq)
+{
+	return io_sq->q_depth - 1 - ena_com_used_q_entries(io_sq);
 }
 
 /* Check if the submission queue has enough space to hold required_buffers */