In case of force_tail_drop is enabled, a different set of
CQ drop and backpressure threshold will be configured
to avoid CQ FULL interrupts.
Also, drop thresholds are optimized for security packets.

Signed-off-by: Rahul Bhansali <rbhans...@marvell.com>
---
 drivers/common/cnxk/roc_nix.h       |  4 ++++
 drivers/common/cnxk/roc_nix_fc.c    | 10 +++++----
 drivers/common/cnxk/roc_nix_priv.h  | 14 +++++++++---
 drivers/common/cnxk/roc_nix_queue.c | 35 ++++++++++++++++++++++-------
 4 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index 1e543d8f11..75b414a32a 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -189,6 +189,7 @@ struct roc_nix_fc_cfg {
                        uint32_t rq;
                        uint16_t tc;
                        uint16_t cq_drop;
+                       uint16_t cq_bp;
                        bool enable;
                } cq_cfg;
 
@@ -196,6 +197,7 @@ struct roc_nix_fc_cfg {
                        uint32_t rq;
                        uint16_t tc;
                        uint16_t cq_drop;
+                       uint16_t cq_bp;
                        uint64_t pool;
                        uint64_t spb_pool;
                        uint64_t pool_drop_pct;
@@ -371,6 +373,7 @@ struct roc_nix_cq {
        uint8_t stash_thresh;
        /* End of Input parameters */
        uint16_t drop_thresh;
+       uint16_t bp_thresh;
        struct roc_nix *roc_nix;
        uintptr_t door;
        int64_t *status;
@@ -483,6 +486,7 @@ struct roc_nix {
        uint32_t root_sched_weight;
        uint16_t inb_cfg_param1;
        uint16_t inb_cfg_param2;
+       bool force_tail_drop;
        /* End of input parameters */
        /* LMT line base for "Per Core Tx LMT line" mode*/
        uintptr_t lmt_base;
diff --git a/drivers/common/cnxk/roc_nix_fc.c b/drivers/common/cnxk/roc_nix_fc.c
index 3e162ede8e..e35c993f96 100644
--- a/drivers/common/cnxk/roc_nix_fc.c
+++ b/drivers/common/cnxk/roc_nix_fc.c
@@ -157,7 +157,8 @@ nix_fc_cq_config_get(struct roc_nix *roc_nix, struct 
roc_nix_fc_cfg *fc_cfg)
        if (rc)
                goto exit;
 
-       fc_cfg->cq_cfg.cq_drop = rsp->cq.bp;
+       fc_cfg->cq_cfg.cq_drop = rsp->cq.drop;
+       fc_cfg->cq_cfg.cq_bp = rsp->cq.bp;
        fc_cfg->cq_cfg.enable = rsp->cq.bp_ena;
        fc_cfg->type = ROC_NIX_FC_CQ_CFG;
 
@@ -288,7 +289,7 @@ nix_fc_cq_config_set(struct roc_nix *roc_nix, struct 
roc_nix_fc_cfg *fc_cfg)
                if (fc_cfg->cq_cfg.enable) {
                        aq->cq.bpid = nix->bpid[fc_cfg->cq_cfg.tc];
                        aq->cq_mask.bpid = ~(aq->cq_mask.bpid);
-                       aq->cq.bp = fc_cfg->cq_cfg.cq_drop;
+                       aq->cq.bp = fc_cfg->cq_cfg.cq_bp;
                        aq->cq_mask.bp = ~(aq->cq_mask.bp);
                }
 
@@ -310,7 +311,7 @@ nix_fc_cq_config_set(struct roc_nix *roc_nix, struct 
roc_nix_fc_cfg *fc_cfg)
                if (fc_cfg->cq_cfg.enable) {
                        aq->cq.bpid = nix->bpid[fc_cfg->cq_cfg.tc];
                        aq->cq_mask.bpid = ~(aq->cq_mask.bpid);
-                       aq->cq.bp = fc_cfg->cq_cfg.cq_drop;
+                       aq->cq.bp = fc_cfg->cq_cfg.cq_bp;
                        aq->cq_mask.bp = ~(aq->cq_mask.bp);
                }
 
@@ -332,7 +333,7 @@ nix_fc_cq_config_set(struct roc_nix *roc_nix, struct 
roc_nix_fc_cfg *fc_cfg)
                if (fc_cfg->cq_cfg.enable) {
                        aq->cq.bpid = nix->bpid[fc_cfg->cq_cfg.tc];
                        aq->cq_mask.bpid = ~(aq->cq_mask.bpid);
-                       aq->cq.bp = fc_cfg->cq_cfg.cq_drop;
+                       aq->cq.bp = fc_cfg->cq_cfg.cq_bp;
                        aq->cq_mask.bp = ~(aq->cq_mask.bp);
                }
 
@@ -389,6 +390,7 @@ nix_fc_rq_config_set(struct roc_nix *roc_nix, struct 
roc_nix_fc_cfg *fc_cfg)
        tmp.cq_cfg.rq = fc_cfg->rq_cfg.rq;
        tmp.cq_cfg.tc = fc_cfg->rq_cfg.tc;
        tmp.cq_cfg.cq_drop = fc_cfg->rq_cfg.cq_drop;
+       tmp.cq_cfg.cq_bp = fc_cfg->rq_cfg.cq_bp;
        tmp.cq_cfg.enable = fc_cfg->rq_cfg.enable;
 
        rc = nix_fc_cq_config_set(roc_nix, &tmp);
diff --git a/drivers/common/cnxk/roc_nix_priv.h 
b/drivers/common/cnxk/roc_nix_priv.h
index 09a55e43ce..dc3450a3d4 100644
--- a/drivers/common/cnxk/roc_nix_priv.h
+++ b/drivers/common/cnxk/roc_nix_priv.h
@@ -15,10 +15,18 @@
 #define NIX_SQB_PREFETCH     ((uint16_t)1)
 
 /* Apply BP/DROP when CQ is 95% full */
-#define NIX_CQ_THRESH_LEVEL    (5 * 256 / 100)
-#define NIX_CQ_SEC_THRESH_LEVEL (25 * 256 / 100)
+#define NIX_CQ_THRESH_LEVEL       (5 * 256 / 100)
+#define NIX_CQ_SEC_BP_THRESH_LEVEL (25 * 256 / 100)
+
+/* Applicable when force_tail_drop is enabled */
+#define NIX_CQ_THRESH_LEVEL_REF1       (50 * 256 / 100)
+#define NIX_CQ_SEC_THRESH_LEVEL_REF1   (20 * 256 / 100)
+#define NIX_CQ_BP_THRESH_LEVEL_REF1    (60 * 256 / 100)
+#define NIX_CQ_SEC_BP_THRESH_LEVEL_REF1 (50 * 256 / 100)
+#define NIX_CQ_LBP_THRESH_FRAC_REF1    (80 * 16 / 100)
+
 /* Apply LBP at 75% of actual BP */
-#define NIX_CQ_LPB_THRESH_FRAC (75 * 16 / 100)
+#define NIX_CQ_LBP_THRESH_FRAC (75 * 16 / 100)
 #define NIX_CQ_FULL_ERRATA_SKID (1024ull * 256)
 #define NIX_RQ_AURA_BP_THRESH(percent, limit, shift) ((((limit) * (percent)) / 
100) >> (shift))
 
diff --git a/drivers/common/cnxk/roc_nix_queue.c 
b/drivers/common/cnxk/roc_nix_queue.c
index 39bd051c94..84a736e3bb 100644
--- a/drivers/common/cnxk/roc_nix_queue.c
+++ b/drivers/common/cnxk/roc_nix_queue.c
@@ -954,7 +954,8 @@ roc_nix_rq_init(struct roc_nix *roc_nix, struct roc_nix_rq 
*rq, bool ena)
        rq->tc = ROC_NIX_PFC_CLASS_INVALID;
 
        /* Enable XQE/CQ drop on cn10k to count pkt drops only when inline is 
disabled */
-       if (roc_model_is_cn10k() && !roc_nix_inl_inb_is_enabled(roc_nix))
+       if (roc_model_is_cn10k() &&
+           (roc_nix->force_tail_drop || !roc_nix_inl_inb_is_enabled(roc_nix)))
                rq->xqe_drop_ena = true;
 
        if (is_cn9k)
@@ -1150,9 +1151,9 @@ roc_nix_cn20k_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
                        cq_ctx->lbpid_low = cpt_lbpid & 0x7;
                        cq_ctx->lbpid_med = (cpt_lbpid >> 3) & 0x7;
                        cq_ctx->lbpid_high = (cpt_lbpid >> 6) & 0x7;
-                       cq_ctx->lbp_frac = NIX_CQ_LPB_THRESH_FRAC;
+                       cq_ctx->lbp_frac = NIX_CQ_LBP_THRESH_FRAC;
                }
-               drop_thresh = NIX_CQ_SEC_THRESH_LEVEL;
+               drop_thresh = NIX_CQ_SEC_BP_THRESH_LEVEL;
        }
 
        /* Many to one reduction */
@@ -1178,6 +1179,7 @@ roc_nix_cn20k_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
                        cq_ctx->drop_ena = 1;
                }
        }
+       cq->bp_thresh = cq->drop_thresh;
        cq_ctx->bp = cq->drop_thresh;
 
        if (roc_feature_nix_has_cqe_stash()) {
@@ -1206,9 +1208,11 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
        struct nix *nix = roc_nix_to_nix_priv(roc_nix);
        struct mbox *mbox = (&nix->dev)->mbox;
        volatile struct nix_cq_ctx_s *cq_ctx = NULL;
-       uint16_t drop_thresh = NIX_CQ_THRESH_LEVEL;
        uint16_t cpt_lbpid = nix->cpt_lbpid;
        enum nix_q_size qsize;
+       bool force_tail_drop;
+       uint16_t drop_thresh;
+       uint16_t bp_thresh;
        size_t desc_sz;
        int rc;
 
@@ -1262,6 +1266,8 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
                cq_ctx = &aq->cq;
        }
 
+       force_tail_drop = roc_nix->force_tail_drop;
+
        cq_ctx->ena = 1;
        cq_ctx->caching = 1;
        cq_ctx->qsize = qsize;
@@ -1269,6 +1275,9 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
        cq_ctx->avg_level = 0xff;
        cq_ctx->cq_err_int_ena = BIT(NIX_CQERRINT_CQE_FAULT);
        cq_ctx->cq_err_int_ena |= BIT(NIX_CQERRINT_DOOR_ERR);
+       drop_thresh = force_tail_drop ? NIX_CQ_THRESH_LEVEL_REF1 : 
NIX_CQ_THRESH_LEVEL;
+       bp_thresh = force_tail_drop ? NIX_CQ_BP_THRESH_LEVEL_REF1 : drop_thresh;
+
        if (roc_feature_nix_has_late_bp() && 
roc_nix_inl_inb_is_enabled(roc_nix)) {
                cq_ctx->cq_err_int_ena |= BIT(NIX_CQERRINT_CPT_DROP);
                cq_ctx->cpt_drop_err_en = 1;
@@ -1278,9 +1287,16 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
                        cq_ctx->lbpid_low = cpt_lbpid & 0x7;
                        cq_ctx->lbpid_med = (cpt_lbpid >> 3) & 0x7;
                        cq_ctx->lbpid_high = (cpt_lbpid >> 6) & 0x7;
-                       cq_ctx->lbp_frac = NIX_CQ_LPB_THRESH_FRAC;
+                       cq_ctx->lbp_frac = force_tail_drop ? 
NIX_CQ_LBP_THRESH_FRAC_REF1 :
+                                                            
NIX_CQ_LBP_THRESH_FRAC;
                }
-               drop_thresh = NIX_CQ_SEC_THRESH_LEVEL;
+
+               /* CQ drop is disabled by default when inline device in use and
+                * force_tail_drop disabled, so will not configure drop 
threshold.
+                */
+               drop_thresh = force_tail_drop ? NIX_CQ_SEC_THRESH_LEVEL_REF1 : 
0;
+               bp_thresh = force_tail_drop ? NIX_CQ_SEC_BP_THRESH_LEVEL_REF1 :
+                                             NIX_CQ_SEC_BP_THRESH_LEVEL;
        }
 
        /* Many to one reduction */
@@ -1296,17 +1312,20 @@ roc_nix_cq_init(struct roc_nix *roc_nix, struct 
roc_nix_cq *cq)
                cq_ctx->drop = min_rx_drop;
                cq_ctx->drop_ena = 1;
                cq->drop_thresh = min_rx_drop;
+               bp_thresh = min_rx_drop;
+               cq->bp_thresh = bp_thresh;
        } else {
                cq->drop_thresh = drop_thresh;
+               cq->bp_thresh = bp_thresh;
                /* Drop processing or red drop cannot be enabled due to
                 * due to packets coming for second pass from CPT.
                 */
-               if (!roc_nix_inl_inb_is_enabled(roc_nix)) {
+               if (!roc_nix_inl_inb_is_enabled(roc_nix) || force_tail_drop) {
                        cq_ctx->drop = cq->drop_thresh;
                        cq_ctx->drop_ena = 1;
                }
        }
-       cq_ctx->bp = cq->drop_thresh;
+       cq_ctx->bp = bp_thresh;
 
        if (roc_feature_nix_has_cqe_stash()) {
                if (cq_ctx->caching) {
-- 
2.25.1

Reply via email to