Skip to content

Commit adbf100

Browse files
Naveen Mamindlapallikuba-moo
authored andcommitted
octeontx2-pf: consider both Rx and Tx packet stats for adaptive interrupt coalescing
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: 6e144b4 ("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>
1 parent 6b17a59 commit adbf100

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,14 @@ static void otx2_do_set_rx_mode(struct otx2_nic *pf)
16881688
mutex_unlock(&pf->mbox.lock);
16891689
}
16901690

1691+
static void otx2_set_irq_coalesce(struct otx2_nic *pfvf)
1692+
{
1693+
int cint;
1694+
1695+
for (cint = 0; cint < pfvf->hw.cint_cnt; cint++)
1696+
otx2_config_irq_coalescing(pfvf, cint);
1697+
}
1698+
16911699
static void otx2_dim_work(struct work_struct *w)
16921700
{
16931701
struct dim_cq_moder cur_moder;
@@ -1703,6 +1711,7 @@ static void otx2_dim_work(struct work_struct *w)
17031711
CQ_TIMER_THRESH_MAX : cur_moder.usec;
17041712
pfvf->hw.cq_ecount_wait = (cur_moder.pkts > NAPI_POLL_WEIGHT) ?
17051713
NAPI_POLL_WEIGHT : cur_moder.pkts;
1714+
otx2_set_irq_coalesce(pfvf);
17061715
dim->state = DIM_START_MEASURE;
17071716
}
17081717

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,18 @@ static void otx2_adjust_adaptive_coalese(struct otx2_nic *pfvf, struct otx2_cq_p
512512
{
513513
struct dim_sample dim_sample;
514514
u64 rx_frames, rx_bytes;
515+
u64 tx_frames, tx_bytes;
515516

516517
rx_frames = OTX2_GET_RX_STATS(RX_BCAST) + OTX2_GET_RX_STATS(RX_MCAST) +
517518
OTX2_GET_RX_STATS(RX_UCAST);
518519
rx_bytes = OTX2_GET_RX_STATS(RX_OCTS);
519-
dim_update_sample(pfvf->napi_events, rx_frames, rx_bytes, &dim_sample);
520+
tx_bytes = OTX2_GET_TX_STATS(TX_OCTS);
521+
tx_frames = OTX2_GET_TX_STATS(TX_UCAST);
522+
523+
dim_update_sample(pfvf->napi_events,
524+
rx_frames + tx_frames,
525+
rx_bytes + tx_bytes,
526+
&dim_sample);
520527
net_dim(&cq_poll->dim, dim_sample);
521528
}
522529

@@ -558,16 +565,9 @@ int otx2_napi_handler(struct napi_struct *napi, int budget)
558565
if (pfvf->flags & OTX2_FLAG_INTF_DOWN)
559566
return workdone;
560567

561-
/* Check for adaptive interrupt coalesce */
562-
if (workdone != 0 &&
563-
((pfvf->flags & OTX2_FLAG_ADPTV_INT_COAL_ENABLED) ==
564-
OTX2_FLAG_ADPTV_INT_COAL_ENABLED)) {
565-
/* Adjust irq coalese using net_dim */
568+
/* Adjust irq coalese using net_dim */
569+
if (pfvf->flags & OTX2_FLAG_ADPTV_INT_COAL_ENABLED)
566570
otx2_adjust_adaptive_coalese(pfvf, cq_poll);
567-
/* Update irq coalescing */
568-
for (i = 0; i < pfvf->hw.cint_cnt; i++)
569-
otx2_config_irq_coalescing(pfvf, i);
570-
}
571571

572572
if (unlikely(!filled_cnt)) {
573573
struct refill_work *work;

0 commit comments

Comments
 (0)