]> git.droids-corp.org - dpdk.git/commitdiff
common/cnxk: get head and tail of Rx and Tx queues
authorRahul Bhansali <rbhansali@marvell.com>
Wed, 19 Jan 2022 09:43:26 +0000 (15:13 +0530)
committerJerin Jacob <jerinj@marvell.com>
Thu, 20 Jan 2022 06:37:33 +0000 (07:37 +0100)
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>
drivers/common/cnxk/roc_nix.h
drivers/common/cnxk/roc_nix_queue.c
drivers/common/cnxk/version.map

index 69a5e8e7b481f1c6abfdccd54708baceb62f19b0..d79abfef9f60c887c1ec850065696428e767e81d 100644 (file)
@@ -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);
index bd63e091a9eac8c63bfab06aed09335b15644ef9..ab578496d19a2010564f5cc1074666cfbeb51cca 100644 (file)
@@ -984,3 +984,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));
+}
index e3948d369d8361ae97f1573ee66a234635de2c1f..ad1b5e8476c2d01cbbdbbaf281c9ee8582b2858e 100644 (file)
@@ -109,6 +109,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;
@@ -224,6 +225,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;