octeontx2-pf: Add support for adaptive interrupt coalescing
PATCH v3 1/1 octeontx2-pf: Add support for adaptive interrupt coalescing
Added support for adaptive IRQ coalescing. It uses net_dim algorithm to find the suitable delay/IRQ count based on the current packet rate.
Signed-off-by Suman Ghosh <[email protected]>
---
Changes since V2
- Addressed review comments.
.../net/ethernet/marvell/octeontx2/Kconfig | 1 + .../marvell/octeontx2/nic/otx2_common.c | 5 --- .../marvell/octeontx2/nic/otx2_common.h | 10 +++++ .../marvell/octeontx2/nic/otx2_ethtool.c | 45 +++++++++++++++++-- .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 22 +++++++++ .../marvell/octeontx2/nic/otx2_txrx.c | 23 ++++++++++ .../marvell/octeontx2/nic/otx2_txrx.h | 1 + 7 files changed, 99 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/octeontx2/Kconfig +1 -0
@@ -33,6 +33,7 @@ config OCTEONTX2_PF select OCTEONTX2_MBOX select NET_DEVLINK depends on (64BIT && COMPILE_TEST) || ARM64 + select DIMLIB depends on PCI depends on PTP_1588_CLOCK_OPTIONAL help
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +0 -5
@@ -97,11 +97,6 @@ void otx2_get_dev_stats(struct otx2_nic *pfvf) {struct otx2_dev_stats *dev_stats = &pfvf->hw.dev_stats; -#define OTX2_GET_RX_STATS (reg) \ - otx2_read64(pfvf, NIX_LF_RX_STATX(reg)) -#define OTX2_GET_TX_STATS (reg) \ - otx2_read64(pfvf, NIX_LF_TX_STATX(reg)) - dev_stats->rx_bytes =OTX2_GET_RX_STATS (RX_OCTS ); dev_stats->rx_drops =OTX2_GET_RX_STATS (RX_DROP ); dev_stats->rx_bcast_frames =OTX2_GET_RX_STATS (RX_BCAST );
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +10 -0
@@ -18,6 +18,7 @@#include <net/pkt_cls.h> #include <net/devlink.h> #include <linux/time64.h> +#include <linux/dim.h> #include <mbox.h> #include <npc.h>
@@ -54,6 +55,11 @@ enum arua_mapped_qtypes {/* Send skid of 2000 packets required for CQ size of 4K CQEs. */ #define SEND_CQ_SKID 2000 +#define OTX2_GET_RX_STATS (reg) \ + otx2_read64(pfvf, NIX_LF_RX_STATX(reg)) +#define OTX2_GET_TX_STATS (reg) \ + otx2_read64(pfvf, NIX_LF_TX_STATX(reg)) +struct otx2_lmt_info {u64 lmt_addr;u16 lmt_id;
@@ -351,6 +357,7 @@ struct otx2_nic {#define OTX2_FLAG_TC_MATCHALL_EGRESS_ENABLED BIT_ULL(12)#define OTX2_FLAG_TC_MATCHALL_INGRESS_ENABLED BIT_ULL(13)#define OTX2_FLAG_DMACFLTR_SUPPORT BIT_ULL(14) +#define OTX2_FLAG_ADPTV_INT_COAL_ENABLED BIT_ULL(16)u64 flags;u64 *cq_op_addr;
@@ -408,6 +415,9 @@ struct otx2_nic {u8 pfc_en;u8 *queue_to_pfc_map;#endif + +/* napi event count. It is needed for adaptive irq coalescing. */ +u32 napi_events; };static inline bool is_otx2_lbkvf (struct pci_dev *pdev)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +42 -3
81 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +22 -0
@@ -1254,6 +1254,7 @@ static irqreturn_t otx2_cq_intr_handler(int irq, void *cq_irq)otx2_write64 (pf,NIX_LF_CINTX_ENA_W1C (qidx),BIT_ULL (0 ));/* Schedule NAPI */ + pf->napi_events++;napi_schedule_irqoff (&cq_poll->napi);return IRQ_HANDLED ;
@@ -1267,6 +1268,7 @@ static void otx2_disable_napi(struct otx2_nic *pf)for (qidx =0 ; qidx < pf->hw.cint_cnt; qidx++) { cq_poll = &qset->napi[qidx]; +cancel_work_sync (&cq_poll->dim.work);napi_disable (&cq_poll->napi);netif_napi_del (&cq_poll->napi); }
@@ -1546,6 +1548,24 @@ static void otx2_do_set_rx_mode(struct otx2_nic *pf)mutex_unlock (&pf->mbox.lock); } +static void otx2_dim_work (struct work_struct *w) +{ +struct dim_cq_moder cur_moder; +struct otx2_cq_poll *cq_poll; +struct otx2_nic *pfvf; +struct dim *dim; + + dim = container_of(w, struct dim, work); + cur_moder =net_dim_get_rx_moderation (dim->mode, dim->profile_ix); + cq_poll = container_of(dim, struct otx2_cq_poll, dim); + pfvf = (struct otx2_nic *)cq_poll->dev; + pfvf->hw.cq_time_wait = (cur_moder.usec >CQ_TIMER_THRESH_MAX ) ? +CQ_TIMER_THRESH_MAX : cur_moder.usec; + pfvf->hw.cq_ecount_wait = (cur_moder.pkts >NAPI_POLL_WEIGHT ) ? +NAPI_POLL_WEIGHT : cur_moder.pkts; + dim->state =DIM_START_MEASURE ; +} +int otx2_open (struct net_device *netdev) {struct otx2_nic *pf =netdev_priv (netdev);
@@ -1612,6 +1632,8 @@ int otx2_open(struct net_device *netdev) cq_poll->cq_ids[CQ_XDP ] =CINT_INVALID_CQ ; cq_poll->dev = (void *)pf; + cq_poll->dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_CQE ; +INIT_WORK (&cq_poll->dim.work, otx2_dim_work);netif_napi_add (netdev, &cq_poll->napi, otx2_napi_handler,NAPI_POLL_WEIGHT );napi_enable (&cq_poll->napi);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +23 -0
@@ -484,6 +484,18 @@ static int otx2_tx_napi_handler(struct otx2_nic *pfvf,return 0 ; } +static void otx2_adjust_adaptive_coalese (struct otx2_nic *pfvf,struct otx2_cq_poll *cq_poll) +{ +struct dim_sample dim_sample; +u64 rx_frames, rx_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); +net_dim (&cq_poll->dim, dim_sample); +} +int otx2_napi_handler (struct napi_struct *napi,int budget) {struct otx2_cq_queue *rx_cq =NULL ;
@@ -521,6 +533,17 @@ 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 */ +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); + } +/* Re-enable interrupts */ otx2_write64 (pfvf,NIX_LF_CINTX_ENA_W1S (cq_poll->cint_idx),BIT_ULL (0 ));
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.h +1 -0
@@ -109,6 +109,7 @@ struct otx2_cq_poll {#define CINT_INVALID_CQ 255u8 cint_idx;u8 cq_ids[CQS_PER_CINT ]; +struct dim dim;struct napi_struct napi; };
Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 17 May 2022 10:10:55 +0530 you wrote:
Added support for adaptive IRQ coalescing. It uses
net_dimalgorithm to find the suitable delay/IRQ count based on the current packet rate.Signed-off-by Suman Ghosh <[email protected]>---
Changes since V2
- Addressed review comments.[...]
Here is the summary with links:
- [net-next,V3] octeontx2-pf: Add support for adaptive interrupt coalescing
https://git.kernel.org/netdev/net-next/c/6e144b47f560
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html