Skip to contentSkip to conversation

net/cnxk: support Tx queue descriptor count

PATCH Superseded [email protected] 2 participants 10 messages Jan 24, 2024 – Mar 4, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/cnxk: support Tx queue descriptor count

From: Satha Rao <[email protected]>

Added cnxk APIs to get used txq descriptor count.

---
 doc/guides/nics/features/cnxk.ini |  1 +
 drivers/net/cnxk/cn10k_ethdev.c   | 10 ++++++++++
 drivers/net/cnxk/cn9k_ethdev.c    | 10 ++++++++++
 drivers/net/cnxk/cnxk_ethdev.h    | 11 +++++++++++
 4 files changed, 32 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index ac7de9a..5cc12ef 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
drivers/net/cnxk/cn10k_ethdev.c +10 -0
index 4a4e972..3a3b8db 100644
@@ -768,6 +768,14 @@
 	return rc;
 }
 
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
 /* Update platform specific eth dev ops */
 static void
 nix_eth_dev_ops_override(void)
@@ -866,6 +874,8 @@
 		return -ENOENT;
 	}
 
+	eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
 		/* Setup callbacks for secondary process */
 		cn10k_eth_set_tx_function(eth_dev);
drivers/net/cnxk/cn9k_ethdev.c +10 -0
index bae4dda..b7c4f59 100644
@@ -689,6 +689,14 @@
 		cn9k_nix_timesync_read_tx_timestamp;
 }
 
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
 /* Update platform specific eth dev ops */
 static void
 nix_tm_ops_override(void)
@@ -759,6 +767,8 @@
 		return -ENOENT;
 	}
 
+	eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
 		/* Setup callbacks for secondary process */
 		cn9k_eth_set_tx_function(eth_dev);
drivers/net/cnxk/cnxk_ethdev.h +11 -0
index 4d3ebf1..0fe8b72 100644
@@ -458,6 +458,17 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit(mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH v2 1/1 net/cnxk: support Tx queue descriptor count

In reply to [email protected]

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 24 ++++++++++++++++++++++++
 5 files changed, 71 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index 94e7a6a..ab18f38 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 32d0ad8..5f8fb9e 100644
@@ -110,6 +110,7 @@ New Features
 
   * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
   * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
+  * Added support for fast path function ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
 	rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..0e09ed6 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -60,6 +78,11 @@
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
 
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 	rte_mb();
 #else
 	RTE_SET_USED(eth_dev);
drivers/net/cnxk/cnxk_ethdev.h +24 -0
index 37b6395..f810bb8 100644
@@ -458,6 +458,30 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit(mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+	uint64_t sq_cnt, sec_cnt, val;
+
+	sq_cnt = rte_atomic_load_explicit(mem, rte_memory_order_relaxed);
+	sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+	sec_cnt = rte_atomic_load_explicit(sec_fc, rte_memory_order_relaxed);
+	val = RTE_MAX(sq_cnt, sec_cnt);
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
#3 lore raw
Quoted 5 lines · On Fri, Feb 23, 2024 at 9:10 PM <[email protected]> wrote:

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

Quoted 7 lines

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.

1)Please rebase to next-net-mrvl. Also update release notes as following
* Added support for ``rte_eth_tx_queue_count()``.

2)There are build issue with clang

[1710/2932] Generating drivers/rte_net_thunderx.pmd.c with a custom command [1711/2932] Generating drivers/rte_net_txgbe.pmd.c with a custom command [1712/2932] Compiling C object drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o
FAILED: drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o ccache clang -Idrivers/libtmp_rte_net_cnxk.a.p -Idrivers -I../drivers -Idrivers/net/cnxk -I../drivers/net/cnxk -Ilib/ethdev -I../lib/ethdev -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I..
/lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Ilib/pci -I../lib/pci -Idriv
ers/bus/vdev -I../drivers/bus/vdev -Ilib/cryptodev -I../lib/cryptodev -Ilib/rcu -I../lib/rcu -Ilib/eventdev -I../lib/eventdev -Ilib/hash -I../lib/hash -Ilib/timer -I../lib/timer -Ilib/dmadev -I../lib/dmadev -Ilib/security -I../lib/securi
ty -Idrivers/common/cnxk -I../drivers/common/cnxk -Idrivers/mempool/cnxk -I../drivers/mempool/cnxk -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O2 -g -include rte_config.h -Wcast-qual -W deprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-pack ed-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -flax-vector-conversions -Wno-strict-aliasing -Wno-asm-operand-widths -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.cnxk
-MD -MQ drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o -MF drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o.d -o drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o -c ../drivers/net/cnxk/cn10k_ethde
v_sec.c
In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:469:8: error: address argument to atomic operation must be a pointer to _Atomic type ('uint64_t *' (aka 'unsigned long *') invalid)

        val = rte_atomic_load_explicit(mem, rte_memory_order_relaxed);
              ^                        ~~~

../lib/eal/include/rte_stdatomic.h:73:2: note: expanded from macro 'rte_atomic_load_explicit'
atomic_load_explicit(ptr, memorder)
^ ~~~
/usr/lib/clang/16/include/stdatomic.h:134:30: note: expanded from macro 'atomic_load_explicit'

#define atomic_load_explicit __c11_atomic_load
                             ^

In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:480:11: error: address argument to atomic operation must be a pointer to _Atomic type ('uint64_t *' (aka 'unsigned long *') invalid)

        sq_cnt = rte_atomic_load_explicit(mem, rte_memory_order_relaxed);
                 ^                        ~~~

../lib/eal/include/rte_stdatomic.h:73:2: note: expanded from macro 'rte_atomic_load_explicit'
atomic_load_explicit(ptr, memorder)
^ ~~~
/usr/lib/clang/16/include/stdatomic.h:134:30: note: expanded from macro 'atomic_load_explicit'

#define atomic_load_explicit __c11_atomic_load
                             ^

In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:482:12: error: address argument to atomic operation must be a pointer to _Atomic type ('uint64_t *' (aka 'unsigned long *') invalid)

        sec_cnt = rte_atomic_load_explicit(sec_fc, rte_memory_order_relaxed);
                  ^                        ~~~~~~

../lib/eal/include/rte_stdatomic.h:73:2: note: expanded from macro 'rte_atomic_load_explicit'
atomic_load_explicit(ptr, memorder)
^ ~~~
/usr/lib/clang/16/include/stdatomic.h:134:30: note: expanded from macro 'atomic_load_explicit'

#define atomic_load_explicit __c11_atomic_load
                             ^
#4 lore raw

PATCH v3 1/1 net/cnxk: support Tx queue descriptor count

In reply to [email protected]

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.
v3:
Addressed review comments

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 24 ++++++++++++++++++++++++
 5 files changed, 71 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index 94e7a6a..ab18f38 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 8d440d5..1f85cda 100644
@@ -111,6 +111,7 @@ New Features
   * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
   * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
   * Added support for Rx inject.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
 	rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
 	rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +24 -0
index 80a9dc8..43eb43b 100644
@@ -461,6 +461,30 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+	uint64_t sq_cnt, sec_cnt, val;
+
+	sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+	sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+	sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))sec_fc, rte_memory_order_relaxed);
+	val = RTE_MAX(sq_cnt, sec_cnt);
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH v4 1/1 net/cnxk: support Tx queue descriptor count

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.
v3:
Addressed review comments

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index 94e7a6a..ab18f38 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 8d440d5..1f85cda 100644
@@ -111,6 +111,7 @@ New Features
   * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
   * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
   * Added support for Rx inject.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
 	rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
 	rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +25 -0
index 80a9dc8..a5670a0 100644
@@ -461,6 +461,31 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+	uint64_t sq_cnt, sec_cnt, val;
+
+	sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+	sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+	sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))sec_fc,
+					   rte_memory_order_relaxed);
+	val = RTE_MAX(sq_cnt, sec_cnt);
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
#6 lore raw
Quoted 9 lines · On Fri, Mar 1, 2024 at 3:19 PM <[email protected]> wrote:

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

Following build issue clang

[1734/2932] Generating drivers/rte_net_ice.sym_chk with a custom command (wrapped by meson to capture output)
[1735/2932] Compiling C object drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o
FAILED: drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o ccache clang -Idrivers/libtmp_rte_net_cnxk.a.p -Idrivers -I../drivers -Idrivers/net/cnxk -I../drivers/net/cnxk -Ilib/ethdev -I../lib/ethdev -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Ilib/pci -I../lib/pci -Idrivers/bus/vdev -I../drivers/bus/vdev -Ilib/cryptodev -I../lib/cryptodev -Ilib/rcu -I../lib/rcu -Ilib/eventdev -I../lib/eventdev -Ilib/hash -I../lib/hash -Ilib/timer -I../lib/timer -Ilib/dmadev -I../lib/dmadev -Ilib/security -I../lib/security -Idrivers/common/cnxk -I../drivers/common/cnxk -Idrivers/mempool/cnxk -I../drivers/mempool/cnxk -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O2 -g -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-address-of-packed-member -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -flax-vector-conversions -Wno-strict-aliasing -Wno-asm-operand-widths -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.cnxk -MD -MQ drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o -MF drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o.d -o drivers/libtmp_rte_net_cnxk.a.p/net_cnxk_cn10k_ethdev_sec.c.o -c ../drivers/net/cnxk/cn10k_ethdev_sec.c
In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:469:33: error: used type '_Atomic(uint64_t *)' where arithmetic or pointer type is required

        val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem,

rte_memory_order_relaxed);
^ ~~~
../lib/eal/include/rte_stdatomic.h:73:23: note: expanded from macro 'rte_atomic_load_explicit'

        atomic_load_explicit(ptr, memorder)
                             ^~~

In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:480:36: error: used type '_Atomic(uint64_t *)' where arithmetic or pointer type is required

        sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem,

rte_memory_order_relaxed);
^ ~~~
../lib/eal/include/rte_stdatomic.h:73:23: note: expanded from macro 'rte_atomic_load_explicit'

        atomic_load_explicit(ptr, memorder)
                             ^~~

In file included from ../drivers/net/cnxk/cn10k_ethdev_sec.c:11:
In file included from ../drivers/net/cnxk/cn10k_ethdev.h:7:
../drivers/net/cnxk/cnxk_ethdev.h:482:37: error: used type '_Atomic(uint64_t *)' where arithmetic or pointer type is required

        sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))sec_fc,
                                           ^                       ~~~~~~

../lib/eal/include/rte_stdatomic.h:73:23: note: expanded from macro 'rte_atomic_load_explicit'
atomic_load_explicit(ptr, memorder)

[for-main]dell[dpdk-next-net-mrvl] $ clang -v
clang version 16.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/13.2.1 Found candidate GCC installation:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/13.2.1 Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

Quoted 157 lines

v2:
Updated release notes and fixed API for CPT queues.
v3:
Addressed review comments

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index 94e7a6a..ab18f38 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 8d440d5..1f85cda 100644
@@ -111,6 +111,7 @@ New Features
   * Added support for ``RTE_FLOW_ITEM_TYPE_PPPOES`` flow item.
   * Added support for ``RTE_FLOW_ACTION_TYPE_SAMPLE`` flow item.
   * Added support for Rx inject.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
                        eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+       struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+       struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
                if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
                        pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
        }
+       if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+               eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+       else
+               eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
        rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
                        eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+       struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+       struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
                if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
                        pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
        }
+       if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+               eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+       else
+               eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
        rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +25 -1
index 80a9dc8..a5670a0 100644
@@ -461,6 +461,31 @@ struct cnxk_eth_txq_sp {
        return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+       uint64_t val;
+
+       val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+       val = (val << sqes_per_sqb_log2) - val;
+
+       return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+       uint64_t sq_cnt, sec_cnt, val;
+
+       sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))mem, rte_memory_order_relaxed);
+       sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+       sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t *))sec_fc,
+                                          rte_memory_order_relaxed);
+       val = RTE_MAX(sq_cnt, sec_cnt);
+
+       return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
--

1.8.3.1

#7 lore raw

PATCH v5 1/1 net/cnxk: support Tx queue descriptor count

In reply to [email protected]

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---
 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index b5d9f7e..1c8db1a 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 2b160cf..b1942b5 100644
@@ -113,6 +113,7 @@ New Features
   * Added support for Rx inject.
   * Optimized SW external mbuf free for better performance and avoid SQ corruption.
   * Added support for port representors.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
 	rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
 	rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +25 -0
index 5d42e13..b42af88 100644
@@ -464,6 +464,31 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t) *)mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+	uint64_t sq_cnt, sec_cnt, val;
+
+	sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t) *)mem, rte_memory_order_relaxed);
+	sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+	sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t) *)sec_fc,
+					   rte_memory_order_relaxed);
+	val = RTE_MAX(sq_cnt, sec_cnt);
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
#8 lore raw

PATCH v6 1/1 net/cnxk: support Tx queue descriptor count

In reply to [email protected]

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.
v3:
Addressed review comments
v5:
Fixed compilation errors
v6:
Fixed checkpatch

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index b5d9f7e..1c8db1a 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 2b160cf..b1942b5 100644
@@ -113,6 +113,7 @@ New Features
   * Added support for Rx inject.
   * Optimized SW external mbuf free for better performance and avoid SQ corruption.
   * Added support for port representors.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
 	rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
 			eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+	struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+	return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
 		if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
 			pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
 	}
+	if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+	else
+		eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
 	rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +25 -0
index 5d42e13..5e04064 100644
@@ -464,6 +464,31 @@ struct cnxk_eth_txq_sp {
 	return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+	uint64_t val;
+
+	val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
+	val = (val << sqes_per_sqb_log2) - val;
+
+	return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+	uint64_t sq_cnt, sec_cnt, val;
+
+	sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
+	sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+	sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)sec_fc,
+					   rte_memory_order_relaxed);
+	val = RTE_MAX(sq_cnt, sec_cnt);
+
+	return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
Signature · 1 line
1.8.3.1
Applied
#9 lore raw
Quoted 6 lines · On Mon, Mar 4, 2024 at 3:30 PM <[email protected]> wrote:

From: Satha Rao <[email protected]>

Added CNXK APIs to get used txq descriptor count.

Applied to dpdk-next-net-mrvl/for-main. Thanks

Quoted 164 lines

---

Depends-on: series-30833 ("ethdev: support Tx queue used count")

v2:
Updated release notes and fixed API for CPT queues.
v3:
Addressed review comments
v5:
Fixed compilation errors
v6:
Fixed checkpatch

 doc/guides/nics/features/cnxk.ini      |  1 +
 doc/guides/rel_notes/release_24_03.rst |  1 +
 drivers/net/cnxk/cn10k_tx_select.c     | 22 ++++++++++++++++++++++
 drivers/net/cnxk/cn9k_tx_select.c      | 23 +++++++++++++++++++++++
 drivers/net/cnxk/cnxk_ethdev.h         | 25 +++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
doc/guides/nics/features/cnxk.ini +1 -0
index b5d9f7e..1c8db1a 100644
@@ -40,6 +40,7 @@ Timesync             = Y
 Timestamp offload    = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Tx queue count       = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
doc/guides/rel_notes/release_24_03.rst +1 -0
index 2b160cf..b1942b5 100644
@@ -113,6 +113,7 @@ New Features
   * Added support for Rx inject.
   * Optimized SW external mbuf free for better performance and avoid SQ corruption.
   * Added support for port representors.
+  * Added support for ``rte_eth_tx_queue_count``.
 
 * **Updated Marvell OCTEON EP driver.**
 
drivers/net/cnxk/cn10k_tx_select.c +22 -0
index 404f5ba..aa0620e 100644
@@ -20,6 +20,24 @@
                        eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn10k_nix_tx_queue_count(void *tx_queue)
+{
+       struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn10k_nix_tx_queue_sec_count(void *tx_queue)
+{
+       struct cn10k_eth_txq *txq = (struct cn10k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn10k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -63,6 +81,10 @@
                if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
                        pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
        }
+       if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+               eth_dev->tx_queue_count = cn10k_nix_tx_queue_sec_count;
+       else
+               eth_dev->tx_queue_count = cn10k_nix_tx_queue_count;
 
        rte_mb();
 #else
drivers/net/cnxk/cn9k_tx_select.c +23 -0
index e08883f..5ecf919 100644
@@ -20,6 +20,24 @@
                        eth_dev->tx_pkt_burst;
 }
 
+#if defined(RTE_ARCH_ARM64)
+static int
+cn9k_nix_tx_queue_count(void *tx_queue)
+{
+       struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2);
+}
+
+static int
+cn9k_nix_tx_queue_sec_count(void *tx_queue)
+{
+       struct cn9k_eth_txq *txq = (struct cn9k_eth_txq *)tx_queue;
+
+       return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc);
+}
+#endif
+
 void
 cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev)
 {
@@ -59,6 +77,11 @@
                if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS)
                        pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg);
        }
+       if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
+               eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count;
+       else
+               eth_dev->tx_queue_count = cn9k_nix_tx_queue_count;
+
 
        rte_mb();
 #else
drivers/net/cnxk/cnxk_ethdev.h +25 -1
index 5d42e13..5e04064 100644
@@ -464,6 +464,31 @@ struct cnxk_eth_txq_sp {
        return ((struct cnxk_eth_txq_sp *)__txq) - 1;
 }
 
+static inline int
+cnxk_nix_tx_queue_count(uint64_t *mem, uint16_t sqes_per_sqb_log2)
+{
+       uint64_t val;
+
+       val = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
+       val = (val << sqes_per_sqb_log2) - val;
+
+       return (val & 0xFFFF);
+}
+
+static inline int
+cnxk_nix_tx_queue_sec_count(uint64_t *mem, uint16_t sqes_per_sqb_log2, uint64_t *sec_fc)
+{
+       uint64_t sq_cnt, sec_cnt, val;
+
+       sq_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)mem, rte_memory_order_relaxed);
+       sq_cnt = (sq_cnt << sqes_per_sqb_log2) - sq_cnt;
+       sec_cnt = rte_atomic_load_explicit((RTE_ATOMIC(uint64_t)*)sec_fc,
+                                          rte_memory_order_relaxed);
+       val = RTE_MAX(sq_cnt, sec_cnt);
+
+       return (val & 0xFFFF);
+}
+
 /* Common ethdev ops */
 extern struct eth_dev_ops cnxk_eth_dev_ops;
 
--

1.8.3.1