From a690e68bc4a8d8152a78d6857434af56f0e4348a Mon Sep 17 00:00:00 2001 From: Ajay Gupta Date: Mon, 4 Nov 2019 15:02:10 -0800 Subject: [PATCH] nvethernetrm: enable rx frame based interrupt coalescing Rx frame based coalescing can be enabled only when Rx timer based coalescing is also enabled. This is to avoid no rx interrupt issue for applications which send only limited frames and expects reply. Bug 200529168 Change-Id: If20ec8322d6597f0a018c5668a9d632e456f60cd Signed-off-by: Ajay Gupta Reviewed-on: https://git-master.nvidia.com/r/2233501 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert GVS: Gerrit_Virtual_Submit Reviewed-by: Srinivas Ramachandran Reviewed-by: Bhadram Varka Reviewed-by: Ashutosh Jha Reviewed-by: mobile promotions Tested-by: mobile promotions --- include/osi_common.h | 1 + include/osi_dma.h | 6 ++++++ osi/dma/osi_dma.c | 9 +++++++++ osi/dma/osi_dma_txrx.c | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/include/osi_common.h b/include/osi_common.h index d1fab0d..301eb48 100644 --- a/include/osi_common.h +++ b/include/osi_common.h @@ -39,6 +39,7 @@ #define OSI_ONE_MEGA_HZ 1000000U #define OSI_MAX_RX_COALESCE_USEC 1020U #define OSI_MIN_RX_COALESCE_USEC 3U +#define OSI_MIN_RX_COALESCE_FRAMES 1U #define OSI_PAUSE_FRAMES_ENABLE 0U #define OSI_PAUSE_FRAMES_DISABLE 1U diff --git a/include/osi_dma.h b/include/osi_dma.h index 74144e7..40db561 100644 --- a/include/osi_dma.h +++ b/include/osi_dma.h @@ -365,6 +365,10 @@ struct osi_dma_priv_data { unsigned int rx_riwt; /** Flag which decides riwt is enabled(1) or disabled(0) */ unsigned int use_riwt; + /** Max no of pkts to be received before triggering Rx interrupt */ + unsigned int rx_frames; + /** Flag which decides rx_frames is enabled(1) or disabled(0) */ + unsigned int use_rx_frames; /** Functional safety config to do periodic read-verify of * certain safety critical dma registers */ void *safety_config; @@ -664,6 +668,8 @@ int osi_process_rx_completions(struct osi_dma_priv_data *osi, * channels * 12) osi_dma->use_riwt ==> OSI_DISABLE/OSI_ENABLE * 13) osi_dma->rx_riwt ===> Actual value read from DT + * 14) osi_dma->use_rx_frames ==> OSI_DISABLE/OSI_ENABLE + * 15) osi_dma->rx_frames ===> Actual value read from DT * * @retval 0 on success * @retval -1 on failure. diff --git a/osi/dma/osi_dma.c b/osi/dma/osi_dma.c index 5dfa797..5583777 100644 --- a/osi/dma/osi_dma.c +++ b/osi/dma/osi_dma.c @@ -237,6 +237,15 @@ int osi_rx_dma_desc_init(struct osi_dma_priv_data *osi_dma, /* reset IOC bit if RWIT is enabled */ if (osi_dma->use_riwt == OSI_ENABLE) { rx_desc->rdes3 &= ~RDES3_IOC; + /* update IOC bit if rx_frames is enabled. Rx_frames + * can be enabled only along with RWIT. + */ + if (osi_dma->use_rx_frames == OSI_ENABLE) { + if ((rx_ring->refill_idx % + osi_dma->rx_frames) == OSI_NONE) { + rx_desc->rdes3 |= RDES3_IOC; + } + } } INCR_RX_DESC_INDEX(rx_ring->refill_idx, 1U); diff --git a/osi/dma/osi_dma_txrx.c b/osi/dma/osi_dma_txrx.c index 4a0f222..2b1cb0f 100644 --- a/osi/dma/osi_dma_txrx.c +++ b/osi/dma/osi_dma_txrx.c @@ -773,6 +773,13 @@ static int rx_dma_desc_initialization(struct osi_dma_priv_data *osi, /* reconfigure INTE bit if RX watchdog timer is enabled */ if (osi->use_riwt == OSI_ENABLE) { rx_desc->rdes3 &= ~RDES3_IOC; + /* update IOC bit if rx_frames is enabled. Rx_frames + * can be enabled only along with RWIT. + */ + if (osi->use_rx_frames == OSI_ENABLE) { + if ((i % osi->rx_frames) == OSI_NONE) + rx_desc->rdes3 |= RDES3_IOC; + } } rx_swcx->flags = 0;