From patchwork Thu Jun 20 08:52:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 13705010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0EADC27C79 for ; Thu, 20 Jun 2024 08:52:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=eB/cLhg3WSWwUi9V50hFyuG/XhsXVW1cGn/by2rdEtI=; b=X6Q6pRefoFNFTaUFrS3grFfk3J M7Dq/O/v7r66dmdgXAqgajIMzw6hHMUgpIKm4EmDxHuF0YEMWXwWamdT1kI9LG+r9xxbAPKXHS7RI JO9EfP5qFenFhUaXUbt/SPGjs/u34C8QoGLgb1W42SVUC8GHMnC4+nwA0SWt0HI+u0KmH2wKjx3wF ADOBrMTxf1jrXYCdOiOjHkcrjrV4l1Ftup1paFEd80RpOoXpVix69+VEiDzq6vCRodBl2FsLPzJyD ZD9kF+bowJKfz18IlOJW9Mp5vWPOywpQGdHEGg0cC00ohLo3h/DfhNWo6zJkwiLrHvKnOSbqdoTee eSXa46IA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKDX9-00000004Gco-01Gd; Thu, 20 Jun 2024 08:52:43 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKDX5-00000004GbC-0pL4 for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 08:52:40 +0000 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7042a8ad9f5so1110796b3a.0 for ; Thu, 20 Jun 2024 01:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718873558; x=1719478358; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eB/cLhg3WSWwUi9V50hFyuG/XhsXVW1cGn/by2rdEtI=; b=LcBgAquYepMYuUbcecYsiD+Pts7j1RS7TkILhRky1t7gFn/jDI2fQo24IrCntTJ1ZL ylRvZ++7FG88UGBLYUhK3IsRp86synAxNe1aeXXN6weoBnel5s79lKUtLbmp46CHm7xt zf68nLgZp9aXdwtzzUR0SGfqyacMu1oomEA+wB5tqFefidnAu5LzG73jhYgZdRfBDnYa DmY7fsh6+x3jRjxfQmMKGGA+AGKwGcwBKVz53QFM1eF3EJhqwydRgxfcpBI35A9XMu4H TMOIUG1a4lyuwi2yn4AT7MVRosdlL0WWtbBHKrvCP5PAxPMR1MqXD85VY+qsoxx+lPTB 7adA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718873558; x=1719478358; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eB/cLhg3WSWwUi9V50hFyuG/XhsXVW1cGn/by2rdEtI=; b=Pxd2/hpqeGkDvJibz3wYL7n+mF0qJEYktWVk1dWdQjW5Gk/3XJNo6qN1af+na4XVke n12K1OTP9Vr2PYnDy4/MYm0YW7nueEgSymVB87wKhQEp203t0csG0CjgwyqFynZpmFQW BXS/6keG/I0otH1hTUMN8oiPBPiY9UUZaOWHj/Xz0fnW7PqwVD04f2nw5lzSenz51XDu yMGbm8OXR6v/prt6VUdPpFeb7afsgDyvdre+4Nl7XFl7HyaTCPvYqlgBcMvCBjfi67bQ CHmNcKg4F7P02rhP8D7I46RBVb/2qfYFPm30onnyHi8xPPC/ED+afJtbfUOwnXz3juru RtOA== X-Forwarded-Encrypted: i=1; AJvYcCUCTh52oEf++fGfCOSNTVrA5brej6fSOVSY0fnacvGG9lmc8U8J0qb3mPwpKJsnqynPn/9uP/3gP1njBS1lKaxrToIIbI88jnOopdqRMI1crsALPi0= X-Gm-Message-State: AOJu0Yx05TAgh05p15J1F2pNZcEDyLPXv+x4HFqPIY7VslYNXh5/DqeP 8JCc2uxq3/0LmDdoPWz5baxBQqyOT2bz0tVFeHoN2ZRVgto5BqoyMZkpGg== X-Google-Smtp-Source: AGHT+IEmKmHEsNjSGrqpoUKBQw6eg+ckhuujPTMdS+oAOp1CeIUP6o8hfE4wARCQsHOeFNPFZkI2zg== X-Received: by 2002:a17:90a:f281:b0:2c4:f32c:6b with SMTP id 98e67ed59e1d1-2c7b3ba85abmr7335661a91.19.1718873557978; Thu, 20 Jun 2024 01:52:37 -0700 (PDT) Received: from localhost.localdomain ([129.146.253.192]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2c7e4ff8affsm1133215a91.11.2024.06.20.01.52.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 01:52:37 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , Simon Horman Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH net-next v1] net: stmmac: xgmac: increase length limit of descriptor ring Date: Thu, 20 Jun 2024 16:52:00 +0800 Message-Id: <20240620085200.583709-1-0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240620_015239_260312_B88F275B X-CRM114-Status: GOOD ( 13.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DWXGMAC CORE supports a ring length of 65536 descriptors, bump max length from 1024 to 65536 Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../net/ethernet/stmicro/stmmac/dwxgmac2.h | 2 ++ .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 24 +++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h index 6a2c7d22df1e..264f4f876c74 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h @@ -11,6 +11,8 @@ /* Misc */ #define XGMAC_JUMBO_LEN 16368 +#define XGMAC_DMA_MAX_TX_SIZE 65536 +#define XGMAC_DMA_MAX_RX_SIZE 65536 /* MAC Registers */ #define XGMAC_TX_CONFIG 0x00000000 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 18468c0228f0..3ae465c5a712 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -491,9 +491,16 @@ static void stmmac_get_ringparam(struct net_device *netdev, struct netlink_ext_ack *extack) { struct stmmac_priv *priv = netdev_priv(netdev); + u32 dma_max_rx_size = DMA_MAX_RX_SIZE; + u32 dma_max_tx_size = DMA_MAX_TX_SIZE; - ring->rx_max_pending = DMA_MAX_RX_SIZE; - ring->tx_max_pending = DMA_MAX_TX_SIZE; + if (priv->plat->has_xgmac) { + dma_max_rx_size = XGMAC_DMA_MAX_RX_SIZE; + dma_max_tx_size = XGMAC_DMA_MAX_TX_SIZE; + } + + ring->rx_max_pending = dma_max_rx_size; + ring->tx_max_pending = dma_max_tx_size; ring->rx_pending = priv->dma_conf.dma_rx_size; ring->tx_pending = priv->dma_conf.dma_tx_size; } @@ -503,12 +510,21 @@ static int stmmac_set_ringparam(struct net_device *netdev, struct kernel_ethtool_ringparam *kernel_ring, struct netlink_ext_ack *extack) { + struct stmmac_priv *priv = netdev_priv(netdev); + u32 dma_max_rx_size = DMA_MAX_RX_SIZE; + u32 dma_max_tx_size = DMA_MAX_TX_SIZE; + + if (priv->plat->has_xgmac) { + dma_max_rx_size = XGMAC_DMA_MAX_RX_SIZE; + dma_max_tx_size = XGMAC_DMA_MAX_TX_SIZE; + } + if (ring->rx_mini_pending || ring->rx_jumbo_pending || ring->rx_pending < DMA_MIN_RX_SIZE || - ring->rx_pending > DMA_MAX_RX_SIZE || + ring->rx_pending > dma_max_rx_size || !is_power_of_2(ring->rx_pending) || ring->tx_pending < DMA_MIN_TX_SIZE || - ring->tx_pending > DMA_MAX_TX_SIZE || + ring->tx_pending > dma_max_tx_size || !is_power_of_2(ring->tx_pending)) return -EINVAL;