Skip to content

Commit

Permalink
ionic: fix up dim accounting for tx and rx
Browse files Browse the repository at this point in the history
[ Upstream commit 76ed8a4 ]

We need to count the correct Tx and/or Rx packets for dynamic
interrupt moderation, depending on which we're processing on
the queue interrupt.

Fixes: 04a8345 ("ionic: dynamic interrupt moderation")
Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
emusln authored and gregkh committed Aug 4, 2021
1 parent a7c85a5 commit 60decbe
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions drivers/net/ethernet/pensando/ionic/ionic_txrx.c
Expand Up @@ -417,22 +417,36 @@ void ionic_rx_empty(struct ionic_queue *q)
}
}

static void ionic_dim_update(struct ionic_qcq *qcq)
static void ionic_dim_update(struct ionic_qcq *qcq, int napi_mode)
{
struct dim_sample dim_sample;
struct ionic_lif *lif;
unsigned int qi;
u64 pkts, bytes;

if (!qcq->intr.dim_coal_hw)
return;

lif = qcq->q.lif;
qi = qcq->cq.bound_q->index;

switch (napi_mode) {
case IONIC_LIF_F_TX_DIM_INTR:
pkts = lif->txqstats[qi].pkts;
bytes = lif->txqstats[qi].bytes;
break;
case IONIC_LIF_F_RX_DIM_INTR:
pkts = lif->rxqstats[qi].pkts;
bytes = lif->rxqstats[qi].bytes;
break;
default:
pkts = lif->txqstats[qi].pkts + lif->rxqstats[qi].pkts;
bytes = lif->txqstats[qi].bytes + lif->rxqstats[qi].bytes;
break;
}

dim_update_sample(qcq->cq.bound_intr->rearm_count,
lif->txqstats[qi].pkts,
lif->txqstats[qi].bytes,
&dim_sample);
pkts, bytes, &dim_sample);

net_dim(&qcq->dim, dim_sample);
}
Expand All @@ -453,7 +467,7 @@ int ionic_tx_napi(struct napi_struct *napi, int budget)
ionic_tx_service, NULL, NULL);

if (work_done < budget && napi_complete_done(napi, work_done)) {
ionic_dim_update(qcq);
ionic_dim_update(qcq, IONIC_LIF_F_TX_DIM_INTR);
flags |= IONIC_INTR_CRED_UNMASK;
cq->bound_intr->rearm_count++;
}
Expand Down Expand Up @@ -489,7 +503,7 @@ int ionic_rx_napi(struct napi_struct *napi, int budget)
ionic_rx_fill(cq->bound_q);

if (work_done < budget && napi_complete_done(napi, work_done)) {
ionic_dim_update(qcq);
ionic_dim_update(qcq, IONIC_LIF_F_RX_DIM_INTR);
flags |= IONIC_INTR_CRED_UNMASK;
cq->bound_intr->rearm_count++;
}
Expand Down Expand Up @@ -531,7 +545,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
ionic_rx_fill_cb(rxcq->bound_q);

if (rx_work_done < budget && napi_complete_done(napi, rx_work_done)) {
ionic_dim_update(qcq);
ionic_dim_update(qcq, 0);
flags |= IONIC_INTR_CRED_UNMASK;
rxcq->bound_intr->rearm_count++;
}
Expand Down

0 comments on commit 60decbe

Please sign in to comment.