Skip to contentSkip to conversation

octeontx2-pf: Use hardware register for CQE count

PATCH Superseded Geetha sowjanya 1 participant 1 message Sep 27, 2021

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Geetha sowjanya

author maintainer
#0 lore raw

PATCH 1/1 octeontx2-pf: Use hardware register for CQE count

Current driver uses a software CQ head pointer to poll on CQE header in memory to determine if CQE is valid. Software needs to make sure, that the reads of the CQE do not get re-ordered so much that it ends up with an inconsistent view of the CQE. To ensure that DMB barrier after reads to first CQE cacheline and before reading of the rest of the CQE is needed. But having barrier for every CQE read will impact the performance, instead use hardware CQ head and tail pointers to find the valid number of CQEs.

---
 .../marvell/octeontx2/nic/otx2_common.c       |  2 +
 .../marvell/octeontx2/nic/otx2_common.h       |  1 +
 .../marvell/octeontx2/nic/otx2_txrx.c         | 69 +++++++++++++++++--
 .../marvell/octeontx2/nic/otx2_txrx.h         |  5 ++
 include/linux/soc/marvell/octeontx2/asm.h     | 15 ++++
 5 files changed, 85 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +2 -0
index 78df173e6df2..72692a48a870 100644
@@ -1006,6 +1006,8 @@ int otx2_config_nix_queues(struct otx2_nic *pfvf)
 			return err;
 	}
 
+	pfvf->cq_op_addr = (u64 *)otx2_get_regaddr(pfvf, NIX_LF_CQ_OP_STATUS);
+
 	/* Initialize work queue for receive buffer refill */
 	pfvf->refill_wrk = devm_kcalloc(pfvf->dev, pfvf->qset.cq_cnt,
 					sizeof(struct refill_work), GFP_KERNEL);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +1 -0
index 8e51a1db7e29..ef855dc4123a 100644
@@ -337,6 +337,7 @@ struct otx2_nic {
 #define OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED	BIT_ULL(13)
 #define OTX2_FLAG_DMACFLTR_SUPPORT		BIT_ULL(14)
 	u64			flags;
+	u64			*cq_op_addr;
 
 	struct otx2_qset	qset;
 	struct otx2_hw		hw;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +62 -7

118 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +5 -0
index 3ff1ad79c001..6a97631ff226 100644
@@ -56,6 +56,9 @@
  */
 #define CQ_QCOUNT_DEFAULT	1
 
+#define CQ_OP_STAT_OP_ERR       63
+#define CQ_OP_STAT_CQ_ERR       46
+
 struct queue_stats {
 	u64	bytes;
 	u64	pkts;
@@ -122,6 +125,8 @@ struct otx2_cq_queue {
 	u16			pool_ptrs;
 	u32			cqe_cnt;
 	u32			cq_head;
+	u32			cq_tail;
+	u32			pend_cqe;
 	void			*cqe_base;
 	struct qmem		*cqe;
 	struct otx2_pool	*rbpool;
include/linux/soc/marvell/octeontx2/asm.h +15 -0
index fa1d6af0164e..52ba8f08461b 100644
@@ -34,9 +34,24 @@
 			 : [rf] "+r"(val)		\
 			 : [rs] "r"(addr));		\
 })
+
+static inline u64 otx2_atomic64_fetch_add(u64 incr, u64 *ptr)
+{
+	u64 result;
+
+	asm volatile (
+		".cpu  generic+lse\n"
+		"ldadda %x[i], %x[r], [%[b]]"
+		: [r] "=r" (result), "+m" (*ptr)
+		: [i] "r" (incr), [b] "r" (ptr)
+		: "memory");
+	return result;
+}
+
 #else
 #define otx2_lmt_flush(ioaddr)          ({ 0; })
 #define cn10k_lmt_flush(val, addr)	({ addr = val; })
+#define otx2_atomic64_fetch_add(incr, ptr)	({ 0; })
 #endif
 
 #endif /* __SOC_OTX2_ASM_H */
Signature · 1 line
2.17.1