octeon_ep: set backpressure watermark for RX queues
authorShinas Rasheed <srasheed@marvell.com>
Wed, 29 Nov 2023 05:31:31 +0000 (21:31 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Dec 2023 12:14:32 +0000 (12:14 +0000)
Set backpressure watermark for hardware RX queues. Backpressure
gets triggered when the available buffers of a hardware RX queue
falls below the set watermark. This backpressure will propagate
to packet processing pipeline in the OCTEON card, so that the host
receives fewer packets and prevents packet dropping at host.

Signed-off-by: Shinas Rasheed <srasheed@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c
drivers/net/ethernet/marvell/octeon_ep/octep_config.h
drivers/net/ethernet/marvell/octeon_ep/octep_regs_cnxk_pf.h

index abb03e9119e720fdf47105cf8c5c9959ee750cb2..098a0c5c4d1c8113d1e94176364513050176c845 100644 (file)
@@ -258,6 +258,7 @@ static void octep_init_config_cnxk_pf(struct octep_device *oct)
        conf->oq.refill_threshold = OCTEP_OQ_REFILL_THRESHOLD;
        conf->oq.oq_intr_pkt = OCTEP_OQ_INTR_PKT_THRESHOLD;
        conf->oq.oq_intr_time = OCTEP_OQ_INTR_TIME_THRESHOLD;
+       conf->oq.wmark = OCTEP_OQ_WMARK_MIN;
 
        conf->msix_cfg.non_ioq_msix = CNXK_NUM_NON_IOQ_INTR;
        conf->msix_cfg.ioq_msix = conf->pf_ring_cfg.active_io_rings;
@@ -378,6 +379,12 @@ static void octep_setup_oq_regs_cnxk_pf(struct octep_device *oct, int oq_no)
        reg_val = ((u64)time_threshold << 32) |
                  CFG_GET_OQ_INTR_PKT(oct->conf);
        octep_write_csr64(oct, CNXK_SDP_R_OUT_INT_LEVELS(oq_no), reg_val);
+
+       /* set watermark for backpressure */
+       reg_val = octep_read_csr64(oct, CNXK_SDP_R_OUT_WMARK(oq_no));
+       reg_val &= ~0xFFFFFFFFULL;
+       reg_val |= CFG_GET_OQ_WMARK(oct->conf);
+       octep_write_csr64(oct, CNXK_SDP_R_OUT_WMARK(oq_no), reg_val);
 }
 
 /* Setup registers for a PF mailbox */
index 4c937ba5589fcc5c2274de74a63183510e0f87a0..c528344a7d0c80bbf306ae1a747b1a2d2d740a9e 100644 (file)
@@ -20,6 +20,9 @@
 /* Packet threshold for Tx queue interrupt */
 #define OCTEP_IQ_INTR_THRESHOLD     0x0
 
+/* Minimum watermark for backpressure */
+#define OCTEP_OQ_WMARK_MIN 256
+
 /* Rx Queue: maximum descriptors per ring */
 #define OCTEP_OQ_MAX_DESCRIPTORS   1024
 
@@ -67,6 +70,7 @@
 #define CFG_GET_OQ_REFILL_THRESHOLD(cfg)  ((cfg)->oq.refill_threshold)
 #define CFG_GET_OQ_INTR_PKT(cfg)          ((cfg)->oq.oq_intr_pkt)
 #define CFG_GET_OQ_INTR_TIME(cfg)         ((cfg)->oq.oq_intr_time)
+#define CFG_GET_OQ_WMARK(cfg)             ((cfg)->oq.wmark)
 
 #define CFG_GET_PORTS_MAX_IO_RINGS(cfg)    ((cfg)->pf_ring_cfg.max_io_rings)
 #define CFG_GET_PORTS_ACTIVE_IO_RINGS(cfg) ((cfg)->pf_ring_cfg.active_io_rings)
@@ -136,6 +140,12 @@ struct octep_oq_config {
         * default. The time is specified in microseconds.
         */
        u32 oq_intr_time;
+
+       /* Water mark for backpressure.
+        * Output queue sends backpressure signal to source when
+        * free buffer count falls below wmark.
+        */
+       u32 wmark;
 };
 
 /* Tx/Rx configuration */
index abe02df8af1171c75e1b3c03b1886e5f98f926b7..ea677f760ef07a8069f1d8e75ca451d4fc1b88e1 100644 (file)
 #define    CNXK_SDP_R_OUT_SLIST_DBELL(ring)          \
        (CNXK_SDP_R_OUT_SLIST_DBELL_START + ((ring) * CNXK_RING_OFFSET))
 
+#define    CNXK_SDP_R_OUT_WMARK(ring)         \
+       (CNXK_SDP_R_OUT_WMARK_START + ((ring) * CNXK_RING_OFFSET))
+
 #define    CNXK_SDP_R_OUT_CNTS(ring)          \
        (CNXK_SDP_R_OUT_CNTS_START + ((ring) * CNXK_RING_OFFSET))