From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Subject: Re: [PATCH net-next 3/3] net: bcmgenet: Fix coalescing settings handling Date: Thu, 29 Mar 2018 10:54:13 -0700 Message-ID: <58e880e0-09e7-260c-40be-7c4e6053c239@gmail.com> References: <20180327194707.31857-1-f.fainelli@gmail.com> <20180327194707.31857-4-f.fainelli@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: davem@davemloft.net, jaedon.shin@gmail.com, pgynther@google.com, Michael Chan , gospo@broadcom.com, talgi@mellanox.com, saeedm@mellanox.com To: Doug Berger , netdev@vger.kernel.org Return-path: Received: from mail-qk0-f194.google.com ([209.85.220.194]:42218 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbeC2RyY (ORCPT ); Thu, 29 Mar 2018 13:54:24 -0400 Received: by mail-qk0-f194.google.com with SMTP id b198so6816935qkg.9 for ; Thu, 29 Mar 2018 10:54:24 -0700 (PDT) In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 03/29/2018 10:51 AM, Doug Berger wrote: > On 03/27/2018 12:47 PM, Florian Fainelli wrote: >> There were a number of issues with setting the RX coalescing parameters: >> >> - we would not be preserving values that would have been configured >> across close/open calls, instead we would always reset to no timeout >> and 1 interrupt per packet, this would also prevent DIM from setting its >> default usec/pkts values >> >> - when adaptive RX would be turned on, we woud not be fetching the >> default parameters, we would stay with no timeout/1 packet per interrupt >> until the estimator kicks in and changes that >> >> - finally disabling adaptive RX coalescing while providing parameters >> would not be honored, and we would stay with whatever DIM had previously >> determined instead of the user requested parameters >> >> Fixes: 9f4ca05827a2 ("net: bcmgenet: Add support for adaptive RX coalescing") >> Signed-off-by: Florian Fainelli >> --- >> drivers/net/ethernet/broadcom/genet/bcmgenet.c | 78 ++++++++++++++++++-------- >> drivers/net/ethernet/broadcom/genet/bcmgenet.h | 4 +- >> 2 files changed, 57 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> index 7db8edc643ec..76409debb796 100644 >> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c >> @@ -625,18 +625,18 @@ static int bcmgenet_get_coalesce(struct net_device *dev, >> return 0; >> } >> >> -static void bcmgenet_set_rx_coalesce(struct bcmgenet_rx_ring *ring) >> +static void bcmgenet_set_rx_coalesce(struct bcmgenet_rx_ring *ring, >> + u32 usecs, u32 pkts) >> { >> struct bcmgenet_priv *priv = ring->priv; >> unsigned int i = ring->index; >> u32 reg; >> >> - bcmgenet_rdma_ring_writel(priv, i, ring->dim.coal_pkts, >> - DMA_MBUF_DONE_THRESH); >> + bcmgenet_rdma_ring_writel(priv, i, pkts, DMA_MBUF_DONE_THRESH); >> >> reg = bcmgenet_rdma_readl(priv, DMA_RING0_TIMEOUT + i); >> reg &= ~DMA_TIMEOUT_MASK; >> - reg |= DIV_ROUND_UP(ring->dim.coal_usecs * 1000, 8192); >> + reg |= DIV_ROUND_UP(usecs * 1000, 8192); >> bcmgenet_rdma_writel(priv, reg, DMA_RING0_TIMEOUT + i); >> } >> >> @@ -645,6 +645,8 @@ static int bcmgenet_set_coalesce(struct net_device *dev, >> { >> struct bcmgenet_priv *priv = netdev_priv(dev); >> struct bcmgenet_rx_ring *ring; >> + struct net_dim_cq_moder moder; >> + u32 usecs, pkts; >> unsigned int i; >> >> /* Base system clock is 125Mhz, DMA timeout is this reference clock >> @@ -682,25 +684,37 @@ static int bcmgenet_set_coalesce(struct net_device *dev, >> >> for (i = 0; i < priv->hw_params->rx_queues; i++) { >> ring = &priv->rx_rings[i]; >> - ring->dim.coal_usecs = ec->rx_coalesce_usecs; >> - ring->dim.coal_pkts = ec->rx_max_coalesced_frames; >> - if (!ec->use_adaptive_rx_coalesce && ring->dim.use_dim) { >> - ring->dim.coal_pkts = 1; >> - ring->dim.coal_usecs = 0; >> + >> + ring->rx_coalesce_usecs = ec->rx_coalesce_usecs; >> + ring->rx_max_coalesced_frames = ec->rx_max_coalesced_frames; >> + usecs = ring->rx_coalesce_usecs; >> + pkts = ring->rx_max_coalesced_frames; >> + >> + if (ec->use_adaptive_rx_coalesce) { >> + moder = net_dim_get_def_profile(ring->dim.dim.mode); >> + usecs = moder.usec; >> + pkts = moder.pkts; >> } >> + >> ring->dim.use_dim = ec->use_adaptive_rx_coalesce; >> - bcmgenet_set_rx_coalesce(ring); >> + bcmgenet_set_rx_coalesce(ring, usecs, pkts); > You might want to put this loop code in a separate function with ring > and ec parameters Indeed, that also itched me, v2 has this in a function: http://patchwork.ozlabs.org/patch/892509/ (gmail coalescing threads, oh oh oh, what a good pun). Thanks! -- Florian