]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
octeontx2-pf: consider both Rx and Tx packet stats for adaptive interrupt coalescing
authorNaveen Mamindlapalli <naveenm@marvell.com>
Fri, 1 Dec 2023 05:33:30 +0000 (11:03 +0530)
committerJakub Kicinski <kuba@kernel.org>
Tue, 5 Dec 2023 02:22:47 +0000 (18:22 -0800)
The current adaptive interrupt coalescing code updates only rx
packet stats for dim algorithm. This patch also updates tx packet
stats which will be useful when there is only tx traffic.
Also moved configuring hardware adaptive interrupt setting to
driver dim callback.

Fixes: 6e144b47f560 ("octeontx2-pf: Add support for adaptive interrupt coalescing")
Signed-off-by: Naveen Mamindlapalli <naveenm@marvell.com>
Signed-off-by: Suman Ghosh <sumang@marvell.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Link: https://lore.kernel.org/r/20231201053330.3903694-1-sumang@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

index 532e324bdcc8e6cbd975017474d06a6af303ae85..0c17ebdda148735b0e2954778ca8cb777696cc97 100644 (file)
@@ -1688,6 +1688,14 @@ static void otx2_do_set_rx_mode(struct otx2_nic *pf)
        mutex_unlock(&pf->mbox.lock);
 }
 
+static void otx2_set_irq_coalesce(struct otx2_nic *pfvf)
+{
+       int cint;
+
+       for (cint = 0; cint < pfvf->hw.cint_cnt; cint++)
+               otx2_config_irq_coalescing(pfvf, cint);
+}
+
 static void otx2_dim_work(struct work_struct *w)
 {
        struct dim_cq_moder cur_moder;
@@ -1703,6 +1711,7 @@ static void otx2_dim_work(struct work_struct *w)
                CQ_TIMER_THRESH_MAX : cur_moder.usec;
        pfvf->hw.cq_ecount_wait = (cur_moder.pkts > NAPI_POLL_WEIGHT) ?
                NAPI_POLL_WEIGHT : cur_moder.pkts;
+       otx2_set_irq_coalesce(pfvf);
        dim->state = DIM_START_MEASURE;
 }
 
index 6ee15f3c25ede947ce0103a7d8b00cd7291c177e..4d519ea833b2c7c4fa439ee56fdd07962221030c 100644 (file)
@@ -512,11 +512,18 @@ static void otx2_adjust_adaptive_coalese(struct otx2_nic *pfvf, struct otx2_cq_p
 {
        struct dim_sample dim_sample;
        u64 rx_frames, rx_bytes;
+       u64 tx_frames, tx_bytes;
 
        rx_frames = OTX2_GET_RX_STATS(RX_BCAST) + OTX2_GET_RX_STATS(RX_MCAST) +
                OTX2_GET_RX_STATS(RX_UCAST);
        rx_bytes = OTX2_GET_RX_STATS(RX_OCTS);
-       dim_update_sample(pfvf->napi_events, rx_frames, rx_bytes, &dim_sample);
+       tx_bytes = OTX2_GET_TX_STATS(TX_OCTS);
+       tx_frames = OTX2_GET_TX_STATS(TX_UCAST);
+
+       dim_update_sample(pfvf->napi_events,
+                         rx_frames + tx_frames,
+                         rx_bytes + tx_bytes,
+                         &dim_sample);
        net_dim(&cq_poll->dim, dim_sample);
 }
 
@@ -558,16 +565,9 @@ int otx2_napi_handler(struct napi_struct *napi, int budget)
                if (pfvf->flags & OTX2_FLAG_INTF_DOWN)
                        return workdone;
 
-               /* Check for adaptive interrupt coalesce */
-               if (workdone != 0 &&
-                   ((pfvf->flags & OTX2_FLAG_ADPTV_INT_COAL_ENABLED) ==
-                    OTX2_FLAG_ADPTV_INT_COAL_ENABLED)) {
-                       /* Adjust irq coalese using net_dim */
+               /* Adjust irq coalese using net_dim */
+               if (pfvf->flags & OTX2_FLAG_ADPTV_INT_COAL_ENABLED)
                        otx2_adjust_adaptive_coalese(pfvf, cq_poll);
-                       /* Update irq coalescing */
-                       for (i = 0; i < pfvf->hw.cint_cnt; i++)
-                               otx2_config_irq_coalescing(pfvf, i);
-               }
 
                if (unlikely(!filled_cnt)) {
                        struct refill_work *work;