common/cnxk: change NIX debug API and queue API interface
[dpdk.git] / drivers / common / cnxk / roc_nix_queue.c
index 76e439e..cff0ec3 100644 (file)
@@ -2,6 +2,8 @@
  * Copyright(C) 2021 Marvell.
  */
 
+#include <math.h>
+
 #include "roc_api.h"
 #include "roc_priv.h"
 
@@ -27,11 +29,9 @@ nix_qsize_clampup(uint32_t val)
 }
 
 int
-roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable)
+nix_rq_ena_dis(struct dev *dev, struct roc_nix_rq *rq, bool enable)
 {
-       struct nix *nix = roc_nix_to_nix_priv(rq->roc_nix);
-       struct mbox *mbox = (&nix->dev)->mbox;
-       int rc;
+       struct mbox *mbox = dev->mbox;
 
        /* Pkts will be dropped silently if RQ is disabled */
        if (roc_model_is_cn9k()) {
@@ -56,17 +56,27 @@ roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable)
                aq->rq_mask.ena = ~(aq->rq_mask.ena);
        }
 
-       rc = mbox_process(mbox);
+       return mbox_process(mbox);
+}
+
+int
+roc_nix_rq_ena_dis(struct roc_nix_rq *rq, bool enable)
+{
+       struct nix *nix = roc_nix_to_nix_priv(rq->roc_nix);
+       int rc;
+
+       rc = nix_rq_ena_dis(&nix->dev, rq, enable);
 
        if (roc_model_is_cn10k())
                plt_write64(rq->qid, nix->base + NIX_LF_OP_VWQE_FLUSH);
        return rc;
 }
 
-static int
-rq_cn9k_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
+int
+nix_rq_cn9k_cfg(struct dev *dev, struct roc_nix_rq *rq, uint16_t qints,
+               bool cfg, bool ena)
 {
-       struct mbox *mbox = (&nix->dev)->mbox;
+       struct mbox *mbox = dev->mbox;
        struct nix_aq_enq_req *aq;
 
        aq = mbox_alloc_msg_nix_aq_enq(mbox);
@@ -116,7 +126,7 @@ rq_cn9k_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
        aq->rq.xqe_imm_size = 0; /* No pkt data copy to CQE */
        aq->rq.rq_int_ena = 0;
        /* Many to one reduction */
-       aq->rq.qint_idx = rq->qid % nix->qints;
+       aq->rq.qint_idx = rq->qid % qints;
        aq->rq.xqe_drop_ena = 1;
 
        /* If RED enabled, then fill enable for all cases */
@@ -177,11 +187,12 @@ rq_cn9k_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
        return 0;
 }
 
-static int
-rq_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
+int
+nix_rq_cfg(struct dev *dev, struct roc_nix_rq *rq, uint16_t qints, bool cfg,
+          bool ena)
 {
-       struct mbox *mbox = (&nix->dev)->mbox;
        struct nix_cn10k_aq_enq_req *aq;
+       struct mbox *mbox = dev->mbox;
 
        aq = mbox_alloc_msg_nix_cn10k_aq_enq(mbox);
        aq->qidx = rq->qid;
@@ -218,8 +229,10 @@ rq_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
                aq->rq.cq = rq->qid;
        }
 
-       if (rq->ipsech_ena)
+       if (rq->ipsech_ena) {
                aq->rq.ipsech_ena = 1;
+               aq->rq.ipsecd_drop_en = 1;
+       }
 
        aq->rq.lpb_aura = roc_npa_aura_handle_to_aura(rq->aura_handle);
 
@@ -258,7 +271,7 @@ rq_cfg(struct nix *nix, struct roc_nix_rq *rq, bool cfg, bool ena)
        aq->rq.xqe_imm_size = 0; /* No pkt data copy to CQE */
        aq->rq.rq_int_ena = 0;
        /* Many to one reduction */
-       aq->rq.qint_idx = rq->qid % nix->qints;
+       aq->rq.qint_idx = rq->qid % qints;
        aq->rq.xqe_drop_ena = 1;
 
        /* If RED enabled, then fill enable for all cases */
@@ -357,6 +370,7 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
        struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct mbox *mbox = (&nix->dev)->mbox;
        bool is_cn9k = roc_model_is_cn9k();
+       struct dev *dev = &nix->dev;
        int rc;
 
        if (roc_nix == NULL || rq == NULL)
@@ -368,9 +382,9 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
        rq->roc_nix = roc_nix;
 
        if (is_cn9k)
-               rc = rq_cn9k_cfg(nix, rq, false, ena);
+               rc = nix_rq_cn9k_cfg(dev, rq, nix->qints, false, ena);
        else
-               rc = rq_cfg(nix, rq, false, ena);
+               rc = nix_rq_cfg(dev, rq, nix->qints, false, ena);
 
        if (rc)
                return rc;
@@ -384,6 +398,7 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
        struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct mbox *mbox = (&nix->dev)->mbox;
        bool is_cn9k = roc_model_is_cn9k();
+       struct dev *dev = &nix->dev;
        int rc;
 
        if (roc_nix == NULL || rq == NULL)
@@ -395,9 +410,9 @@ roc_nix_rq_modify(struct roc_nix *roc_nix, struct roc_nix_rq *rq, bool ena)
        rq->roc_nix = roc_nix;
 
        if (is_cn9k)
-               rc = rq_cn9k_cfg(nix, rq, true, ena);
+               rc = nix_rq_cn9k_cfg(dev, rq, nix->qints, true, ena);
        else
-               rc = rq_cfg(nix, rq, true, ena);
+               rc = nix_rq_cfg(dev, rq, nix->qints, true, ena);
 
        if (rc)
                return rc;
@@ -435,7 +450,6 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
        cq->status = (int64_t *)(nix->base + NIX_LF_CQ_OP_STATUS);
        cq->wdata = (uint64_t)cq->qid << 32;
        cq->roc_nix = roc_nix;
-       cq->drop_thresh = NIX_CQ_THRESH_LEVEL;
 
        /* CQE of W16 */
        desc_sz = cq->nb_desc * NIX_CQ_ENTRY_SZ;
@@ -476,8 +490,19 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct roc_nix_cq *cq)
        /* Map CQ0 [RQ0] to CINT0 and so on till max 64 irqs */
        cq_ctx->cint_idx = cq->qid;
 
-       cq_ctx->drop = cq->drop_thresh;
-       cq_ctx->drop_ena = 1;
+       if (roc_model_is_cn96_a0() || roc_model_is_cn95_a0()) {
+               const float rx_cq_skid = NIX_CQ_FULL_ERRATA_SKID;
+               uint16_t min_rx_drop;
+
+               min_rx_drop = ceil(rx_cq_skid / (float)cq->nb_desc);
+               cq_ctx->drop = min_rx_drop;
+               cq_ctx->drop_ena = 1;
+               cq->drop_thresh = min_rx_drop;
+       } else {
+               cq->drop_thresh = NIX_CQ_THRESH_LEVEL;
+               cq_ctx->drop = cq->drop_thresh;
+               cq_ctx->drop_ena = 1;
+       }
 
        /* TX pause frames enable flow ctrl on RX side */
        if (nix->tx_pause) {