DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues
@ 2022-01-19  9:43 Rahul Bhansali
  2022-01-19  9:43 ` [PATCH v2 2/2] net/cnxk: ethdev Rx/Tx queue status callbacks Rahul Bhansali
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rahul Bhansali @ 2022-01-19  9:43 UTC (permalink / raw)
  To: dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
	Satha Rao, Ray Kinsella
  Cc: jerinj, Rahul Bhansali

Adds roc APIs roc_nix_cq_head_tail_get, roc_nix_sq_head_tail_get
to get head-tail of receive and transmit queue respectively.

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
---
v2 changes:
 - No change

 drivers/common/cnxk/roc_nix.h       |  4 +++
 drivers/common/cnxk/roc_nix_queue.c | 53 +++++++++++++++++++++++++++++
 drivers/common/cnxk/version.map     |  2 ++
 3 files changed, 59 insertions(+)

diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index 69a5e8e7b4..d79abfef9f 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -795,8 +795,12 @@ int __roc_api roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable);
 int __roc_api roc_nix_rq_fini(struct roc_nix_rq *rq);
 int __roc_api roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq);
 int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
+void __roc_api roc_nix_cq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
+					uint32_t *head, uint32_t *tail);
 int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
 int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
+void __roc_api roc_nix_sq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
+					uint32_t *head, uint32_t *tail);

 /* PTP */
 int __roc_api roc_nix_ptp_rx_ena_dis(struct roc_nix *roc_nix, int enable);
diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
index c638cd43e4..67f83acdf2 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -969,3 +969,56 @@ roc_nix_sq_fini(struct roc_nix_sq *sq)

 	return rc;
 }
+
+void
+roc_nix_cq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid, uint32_t *head,
+			 uint32_t *tail)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	uint64_t reg, val;
+	int64_t *addr;
+
+	if (head == NULL || tail == NULL)
+		return;
+
+	reg = (((uint64_t)qid) << 32);
+	addr = (int64_t *)(nix->base + NIX_LF_CQ_OP_STATUS);
+	val = roc_atomic64_add_nosync(reg, addr);
+	if (val &
+	    (BIT_ULL(NIX_CQ_OP_STAT_OP_ERR) | BIT_ULL(NIX_CQ_OP_STAT_CQ_ERR)))
+		val = 0;
+
+	*tail = (uint32_t)(val & 0xFFFFF);
+	*head = (uint32_t)((val >> 20) & 0xFFFFF);
+}
+
+void
+roc_nix_sq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid, uint32_t *head,
+			 uint32_t *tail)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct roc_nix_sq *sq = nix->sqs[qid];
+	uint16_t sqes_per_sqb, sqb_cnt;
+	uint64_t reg, val;
+	int64_t *addr;
+
+	if (head == NULL || tail == NULL)
+		return;
+
+	reg = (((uint64_t)qid) << 32);
+	addr = (int64_t *)(nix->base + NIX_LF_SQ_OP_STATUS);
+	val = roc_atomic64_add_nosync(reg, addr);
+	if (val & BIT_ULL(NIX_CQ_OP_STAT_OP_ERR)) {
+		val = 0;
+		return;
+	}
+
+	*tail = (uint32_t)((val >> 28) & 0x3F);
+	*head = (uint32_t)((val >> 20) & 0x3F);
+	sqb_cnt = (uint16_t)(val & 0xFFFF);
+
+	sqes_per_sqb = 1 << sq->sqes_per_sqb_log2;
+
+	/* Update tail index as per used sqb count */
+	*tail += (sqes_per_sqb * (sqb_cnt - 1));
+}
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 07c6720f0c..a9dba47e0e 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -107,6 +107,7 @@ INTERNAL {
 	roc_nix_bpf_timeunit_get;
 	roc_nix_cq_dump;
 	roc_nix_cq_fini;
+	roc_nix_cq_head_tail_get;
 	roc_nix_cq_init;
 	roc_nix_cqe_dump;
 	roc_nix_dev_fini;
@@ -222,6 +223,7 @@ INTERNAL {
 	roc_nix_rx_queue_intr_enable;
 	roc_nix_sq_dump;
 	roc_nix_sq_fini;
+	roc_nix_sq_head_tail_get;
 	roc_nix_sq_init;
 	roc_nix_stats_get;
 	roc_nix_stats_queue_get;
--
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] net/cnxk: ethdev Rx/Tx queue status callbacks
  2022-01-19  9:43 [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Rahul Bhansali
@ 2022-01-19  9:43 ` Rahul Bhansali
  2022-01-19 10:54 ` [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Ray Kinsella
  2022-01-20  6:39 ` Jerin Jacob
  2 siblings, 0 replies; 4+ messages in thread
From: Rahul Bhansali @ 2022-01-19  9:43 UTC (permalink / raw)
  To: dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori, Satha Rao
  Cc: jerinj, Rahul Bhansali

Provides ethdev callback support of rx_queue_count,
rx_descriptor_status and tx_descriptor_status.

Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
---
v2 changes:
 - Updated doc/guides/nics/features/cnxk* for
   "Rx descriptor status" and "Tx descriptor status"

 doc/guides/nics/features/cnxk.ini     |  2 +
 doc/guides/nics/features/cnxk_vec.ini |  2 +
 doc/guides/nics/features/cnxk_vf.ini  |  2 +
 drivers/net/cnxk/cnxk_ethdev.c        |  3 ++
 drivers/net/cnxk/cnxk_ethdev.h        |  5 +++
 drivers/net/cnxk/cnxk_ethdev_ops.c    | 60 +++++++++++++++++++++++++++
 6 files changed, 74 insertions(+)

diff --git a/doc/guides/nics/features/cnxk.ini b/doc/guides/nics/features/cnxk.ini
index 1623a1803e..0eba334eb4 100644
--- a/doc/guides/nics/features/cnxk.ini
+++ b/doc/guides/nics/features/cnxk.ini
@@ -37,6 +37,8 @@ Inner L4 checksum    = Y
 Packet type parsing  = Y
 Timesync             = Y
 Timestamp offload    = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
diff --git a/doc/guides/nics/features/cnxk_vec.ini b/doc/guides/nics/features/cnxk_vec.ini
index 4b7c2bce4d..df5f358a3e 100644
--- a/doc/guides/nics/features/cnxk_vec.ini
+++ b/doc/guides/nics/features/cnxk_vec.ini
@@ -33,6 +33,8 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
diff --git a/doc/guides/nics/features/cnxk_vf.ini b/doc/guides/nics/features/cnxk_vf.ini
index 0523be434d..a78fbcada0 100644
--- a/doc/guides/nics/features/cnxk_vf.ini
+++ b/doc/guides/nics/features/cnxk_vf.ini
@@ -29,6 +29,8 @@ L4 checksum offload  = Y
 Inner L3 checksum    = Y
 Inner L4 checksum    = Y
 Packet type parsing  = Y
+Rx descriptor status = Y
+Tx descriptor status = Y
 Basic stats          = Y
 Stats per queue      = Y
 Extended stats       = Y
diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c
index 74f625553d..183fd241d8 100644
--- a/drivers/net/cnxk/cnxk_ethdev.c
+++ b/drivers/net/cnxk/cnxk_ethdev.c
@@ -1595,6 +1595,9 @@ cnxk_eth_dev_init(struct rte_eth_dev *eth_dev)
 	int rc, max_entries;

 	eth_dev->dev_ops = &cnxk_eth_dev_ops;
+	eth_dev->rx_queue_count = cnxk_nix_rx_queue_count;
+	eth_dev->rx_descriptor_status = cnxk_nix_rx_descriptor_status;
+	eth_dev->tx_descriptor_status = cnxk_nix_tx_descriptor_status;

 	/* Alloc security context */
 	sec_ctx = plt_zmalloc(sizeof(struct rte_security_ctx), 0);
diff --git a/drivers/net/cnxk/cnxk_ethdev.h b/drivers/net/cnxk/cnxk_ethdev.h
index 5bfda3d815..43814a81fc 100644
--- a/drivers/net/cnxk/cnxk_ethdev.h
+++ b/drivers/net/cnxk/cnxk_ethdev.h
@@ -559,6 +559,11 @@ void cnxk_nix_rxq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
 void cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
 			   struct rte_eth_txq_info *qinfo);

+/* Queue status */
+int cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset);
+int cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset);
+uint32_t cnxk_nix_rx_queue_count(void *rxq);
+
 /* Lookup configuration */
 const uint32_t *cnxk_nix_supported_ptypes_get(struct rte_eth_dev *eth_dev);
 void *cnxk_nix_fastpath_lookup_mem_get(void);
diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
index 34e4809650..f20f201db2 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -695,6 +695,66 @@ cnxk_nix_txq_info_get(struct rte_eth_dev *eth_dev, uint16_t qid,
 	memcpy(&qinfo->conf, &txq_sp->qconf.conf.tx, sizeof(qinfo->conf));
 }

+uint32_t
+cnxk_nix_rx_queue_count(void *rxq)
+{
+	struct cnxk_eth_rxq_sp *rxq_sp = cnxk_eth_rxq_to_sp(rxq);
+	struct roc_nix *nix = &rxq_sp->dev->nix;
+	uint32_t head, tail;
+
+	roc_nix_cq_head_tail_get(nix, rxq_sp->qid, &head, &tail);
+	return (tail - head) % (rxq_sp->qconf.nb_desc);
+}
+
+static inline int
+nix_offset_has_packet(uint32_t head, uint32_t tail, uint16_t offset, bool is_rx)
+{
+	/* Check given offset(queue index) has packet filled/xmit by HW
+	 * in case of Rx or Tx.
+	 * Also, checks for wrap around case.
+	 */
+	return ((tail > head && offset <= tail && offset >= head) ||
+		(head > tail && (offset >= head || offset <= tail))) ?
+		       is_rx :
+		       !is_rx;
+}
+
+int
+cnxk_nix_rx_descriptor_status(void *rxq, uint16_t offset)
+{
+	struct cnxk_eth_rxq_sp *rxq_sp = cnxk_eth_rxq_to_sp(rxq);
+	struct roc_nix *nix = &rxq_sp->dev->nix;
+	uint32_t head, tail;
+
+	if (rxq_sp->qconf.nb_desc <= offset)
+		return -EINVAL;
+
+	roc_nix_cq_head_tail_get(nix, rxq_sp->qid, &head, &tail);
+
+	if (nix_offset_has_packet(head, tail, offset, 1))
+		return RTE_ETH_RX_DESC_DONE;
+	else
+		return RTE_ETH_RX_DESC_AVAIL;
+}
+
+int
+cnxk_nix_tx_descriptor_status(void *txq, uint16_t offset)
+{
+	struct cnxk_eth_txq_sp *txq_sp = cnxk_eth_txq_to_sp(txq);
+	struct roc_nix *nix = &txq_sp->dev->nix;
+	uint32_t head = 0, tail = 0;
+
+	if (txq_sp->qconf.nb_desc <= offset)
+		return -EINVAL;
+
+	roc_nix_sq_head_tail_get(nix, txq_sp->qid, &head, &tail);
+
+	if (nix_offset_has_packet(head, tail, offset, 0))
+		return RTE_ETH_TX_DESC_DONE;
+	else
+		return RTE_ETH_TX_DESC_FULL;
+}
+
 /* It is a NOP for cnxk as HW frees the buffer on xmit */
 int
 cnxk_nix_tx_done_cleanup(void *txq, uint32_t free_cnt)
--
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues
  2022-01-19  9:43 [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Rahul Bhansali
  2022-01-19  9:43 ` [PATCH v2 2/2] net/cnxk: ethdev Rx/Tx queue status callbacks Rahul Bhansali
@ 2022-01-19 10:54 ` Ray Kinsella
  2022-01-20  6:39 ` Jerin Jacob
  2 siblings, 0 replies; 4+ messages in thread
From: Ray Kinsella @ 2022-01-19 10:54 UTC (permalink / raw)
  To: Rahul Bhansali
  Cc: dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
	Satha Rao, jerinj


Rahul Bhansali <rbhansali@marvell.com> writes:

> Adds roc APIs roc_nix_cq_head_tail_get, roc_nix_sq_head_tail_get
> to get head-tail of receive and transmit queue respectively.
>
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
> ---
> v2 changes:
>  - No change
>
>  drivers/common/cnxk/roc_nix.h       |  4 +++
>  drivers/common/cnxk/roc_nix_queue.c | 53 +++++++++++++++++++++++++++++
>  drivers/common/cnxk/version.map     |  2 ++
>  3 files changed, 59 insertions(+)
>

Acked-by: Ray Kinsella <mdr@ashroe.eu>

-- 
Regards, Ray K

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues
  2022-01-19  9:43 [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Rahul Bhansali
  2022-01-19  9:43 ` [PATCH v2 2/2] net/cnxk: ethdev Rx/Tx queue status callbacks Rahul Bhansali
  2022-01-19 10:54 ` [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Ray Kinsella
@ 2022-01-20  6:39 ` Jerin Jacob
  2 siblings, 0 replies; 4+ messages in thread
From: Jerin Jacob @ 2022-01-20  6:39 UTC (permalink / raw)
  To: Rahul Bhansali, Ferruh Yigit
  Cc: dpdk-dev, Nithin Dabilpuram, Kiran Kumar K, Sunil Kumar Kori,
	Satha Rao, Ray Kinsella, Jerin Jacob

On Wed, Jan 19, 2022 at 3:14 PM Rahul Bhansali <rbhansali@marvell.com> wrote:
>
> Adds roc APIs roc_nix_cq_head_tail_get, roc_nix_sq_head_tail_get
> to get head-tail of receive and transmit queue respectively.
>
> Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>

Series Acked-by: Jerin Jacob <jerinj@marvell.com>
Series applied to dpdk-next-net-mrvl/for-next-net. Thanks.


Changed the git log to:

    common/cnxk: get head and tail of Rx and Tx queues

    Adds roc APIs roc_nix_cq_head_tail_get(), roc_nix_sq_head_tail_get()
    to get tail and head of receive and transmit queue respectively.

    Signed-off-by: Rahul Bhansali <rbhansali@marvell.com>
    Acked-by: Ray Kinsella <mdr@ashroe.eu>
    Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
> v2 changes:
>  - No change
>
>  drivers/common/cnxk/roc_nix.h       |  4 +++
>  drivers/common/cnxk/roc_nix_queue.c | 53 +++++++++++++++++++++++++++++
>  drivers/common/cnxk/version.map     |  2 ++
>  3 files changed, 59 insertions(+)
>
> diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
> index 69a5e8e7b4..d79abfef9f 100644
> --- a/drivers/common/cnxk/roc_nix.h
> +++ b/drivers/common/cnxk/roc_nix.h
> @@ -795,8 +795,12 @@ int __roc_api roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable);
>  int __roc_api roc_nix_rq_fini(struct roc_nix_rq *rq);
>  int __roc_api roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq);
>  int __roc_api roc_nix_cq_fini(struct roc_nix_cq *cq);
> +void __roc_api roc_nix_cq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
> +                                       uint32_t *head, uint32_t *tail);
>  int __roc_api roc_nix_sq_init(struct roc_nix *roc_nix, struct roc_nix_sq *sq);
>  int __roc_api roc_nix_sq_fini(struct roc_nix_sq *sq);
> +void __roc_api roc_nix_sq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid,
> +                                       uint32_t *head, uint32_t *tail);
>
>  /* PTP */
>  int __roc_api roc_nix_ptp_rx_ena_dis(struct roc_nix *roc_nix, int enable);
> diff --git a/drivers/common/cnxk/roc_nix_queue.c b/drivers/common/cnxk/roc_nix_queue.c
> index c638cd43e4..67f83acdf2 100644
> --- a/drivers/common/cnxk/roc_nix_queue.c
> +++ b/drivers/common/cnxk/roc_nix_queue.c
> @@ -969,3 +969,56 @@ roc_nix_sq_fini(struct roc_nix_sq *sq)
>
>         return rc;
>  }
> +
> +void
> +roc_nix_cq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid, uint32_t *head,
> +                        uint32_t *tail)
> +{
> +       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +       uint64_t reg, val;
> +       int64_t *addr;
> +
> +       if (head == NULL || tail == NULL)
> +               return;
> +
> +       reg = (((uint64_t)qid) << 32);
> +       addr = (int64_t *)(nix->base + NIX_LF_CQ_OP_STATUS);
> +       val = roc_atomic64_add_nosync(reg, addr);
> +       if (val &
> +           (BIT_ULL(NIX_CQ_OP_STAT_OP_ERR) | BIT_ULL(NIX_CQ_OP_STAT_CQ_ERR)))
> +               val = 0;
> +
> +       *tail = (uint32_t)(val & 0xFFFFF);
> +       *head = (uint32_t)((val >> 20) & 0xFFFFF);
> +}
> +
> +void
> +roc_nix_sq_head_tail_get(struct roc_nix *roc_nix, uint16_t qid, uint32_t *head,
> +                        uint32_t *tail)
> +{
> +       struct nix *nix = roc_nix_to_nix_priv(roc_nix);
> +       struct roc_nix_sq *sq = nix->sqs[qid];
> +       uint16_t sqes_per_sqb, sqb_cnt;
> +       uint64_t reg, val;
> +       int64_t *addr;
> +
> +       if (head == NULL || tail == NULL)
> +               return;
> +
> +       reg = (((uint64_t)qid) << 32);
> +       addr = (int64_t *)(nix->base + NIX_LF_SQ_OP_STATUS);
> +       val = roc_atomic64_add_nosync(reg, addr);
> +       if (val & BIT_ULL(NIX_CQ_OP_STAT_OP_ERR)) {
> +               val = 0;
> +               return;
> +       }
> +
> +       *tail = (uint32_t)((val >> 28) & 0x3F);
> +       *head = (uint32_t)((val >> 20) & 0x3F);
> +       sqb_cnt = (uint16_t)(val & 0xFFFF);
> +
> +       sqes_per_sqb = 1 << sq->sqes_per_sqb_log2;
> +
> +       /* Update tail index as per used sqb count */
> +       *tail += (sqes_per_sqb * (sqb_cnt - 1));
> +}
> diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
> index 07c6720f0c..a9dba47e0e 100644
> --- a/drivers/common/cnxk/version.map
> +++ b/drivers/common/cnxk/version.map
> @@ -107,6 +107,7 @@ INTERNAL {
>         roc_nix_bpf_timeunit_get;
>         roc_nix_cq_dump;
>         roc_nix_cq_fini;
> +       roc_nix_cq_head_tail_get;
>         roc_nix_cq_init;
>         roc_nix_cqe_dump;
>         roc_nix_dev_fini;
> @@ -222,6 +223,7 @@ INTERNAL {
>         roc_nix_rx_queue_intr_enable;
>         roc_nix_sq_dump;
>         roc_nix_sq_fini;
> +       roc_nix_sq_head_tail_get;
>         roc_nix_sq_init;
>         roc_nix_stats_get;
>         roc_nix_stats_queue_get;
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-20  6:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19  9:43 [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Rahul Bhansali
2022-01-19  9:43 ` [PATCH v2 2/2] net/cnxk: ethdev Rx/Tx queue status callbacks Rahul Bhansali
2022-01-19 10:54 ` [PATCH v2 1/2] common/cnxk: get head-tail of Rx and Tx queues Ray Kinsella
2022-01-20  6:39 ` Jerin Jacob

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).