Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5615765imu; Mon, 26 Nov 2018 03:03:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/XR8OEgF87uI+xcoh1AisM1tkctDqTypylSBhgwaVWQE4OhSMLr4HbGHxQPB9PYSWlruUqC X-Received: by 2002:a65:5a4c:: with SMTP id z12mr24562441pgs.188.1543230198887; Mon, 26 Nov 2018 03:03:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230198; cv=none; d=google.com; s=arc-20160816; b=jGWFQ09iJz4u9V3FJQtSUcROJoJLkEjujuYLfX17LSY/PZlqrzTaK/gUKH2z3m7+Ng tfllx1sLL1Gn/kpjE9WiJE+UKrYw6ZiB/QRDaj1h2wk4gniRbnl3u/hPofo2570fUlSS sRE1Ux3fgzPPQLTAU4VobKKtVO8DOQEtaGeAk11RUwHn7BieyFt0veANT8Onp3ixq/OE J//oUKtm6PuI5fAUs8qhPMLbaOj2Za3bXd0YoPAErkWoYa0EeKoQ+cdHW6h7y2AmLRj4 w+5eV/CQWEkGQshVk+wejks4mlXOcCod+MXCcjJ0czoSLm1kGfRhbImAWaQ6Kfl3lT6A YhJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=54z5oTHd/+Lbcq4xj/hw594M0zVQKIlY3WFPWUncd6c=; b=LuLSrCLXe2ZfwsLav6X4YOc/iDb0/mou6zedfPIdntz5yIHgeuLKQrDvFSBd5LGhxh Dg/724YSz1fNsR9YZucUepF4rF1AipRAy6FquSJjxN8YrZmKXy3pkPiy+56iBEeSPJP9 ILnj8g2EQ7l4CuOAvJs/tc22iR6pS/4a+I0uFMj8qf4VvvPIYz4BjvMe9UhOJDSuMZ0z 2OE2DsG9WtPU0Z63e6rdBKjvw4a0bGkNKiI1iFvTHpl6W7msovw7D+ljQZ7wt5XhcLE0 NM47N+9Etgr92vvR8JIVh6Nk9l12L8qreCtiynwdXZyLRonx6Sc5X91QStFY3vLLQ6fI qYEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fAbDQ7Y9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x128si7618689pfb.128.2018.11.26.03.02.41; Mon, 26 Nov 2018 03:03:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fAbDQ7Y9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730160AbeKZVzR (ORCPT + 99 others); Mon, 26 Nov 2018 16:55:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:37788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728901AbeKZVzQ (ORCPT ); Mon, 26 Nov 2018 16:55:16 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 795F920817; Mon, 26 Nov 2018 11:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230090; bh=GRfwLCfgGe9kBYti5QFr5n8XZhIM5MhDcPgNJHURQ6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fAbDQ7Y9O4LsN4yPAaUHWxF8oGMf+5tbwkyqOFG/uepbFftNHMtcRPuRc3kvSGLCb vhtC35VA9uMRMr2djlgbcSOyB1d1ZP++0q5Uqu5U2rEeW0pxC9WsqnopJ2h39njndo 8iJz+hjBeW1Z+SmlJCAjsJuf4aZGeS8fyYkfkT7Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jose Abreu , Thor Thayer , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 39/62] net: stmmac: Fix RX packet size > 8191 Date: Mon, 26 Nov 2018 11:51:20 +0100 Message-Id: <20181126105053.821380773@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105050.592727680@linuxfoundation.org> References: <20181126105050.592727680@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8137b6ef0ce469154e5cf19f8e7fe04d9a72ac5e ] Ping problems with packets > 8191 as shown: PING 192.168.1.99 (192.168.1.99) 8150(8178) bytes of data. 8158 bytes from 192.168.1.99: icmp_seq=1 ttl=64 time=0.669 ms wrong data byte 8144 should be 0xd0 but was 0x0 16 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f %< ---------------snip-------------------------------------- 8112 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf 8144 0 0 0 0 d0 d1 ^^^^^^^ Notice the 4 bytes of 0 before the expected byte of d0. Databook notes that the RX buffer must be a multiple of 4/8/16 bytes [1]. Update the DMA Buffer size define to 8188 instead of 8192. Remove the -1 from the RX buffer size allocations and use the new DMA Buffer size directly. [1] Synopsys DesignWare Cores Ethernet MAC Universal v3.70a [section 8.4.2 - Table 8-24] Tested on SoCFPGA Stratix10 with ping sweep from 100 to 8300 byte packets. Fixes: 286a83721720 ("stmmac: add CHAINED descriptor mode support (V4)") Suggested-by: Jose Abreu Signed-off-by: Thor Thayer Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/common.h | 3 ++- drivers/net/ethernet/stmicro/stmmac/descs_com.h | 2 +- drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 2 +- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 627fec210e2f..8e2a19616bc9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -340,7 +340,8 @@ struct dma_features { /* GMAC TX FIFO is 8K, Rx FIFO is 16K */ #define BUF_SIZE_16KiB 16384 -#define BUF_SIZE_8KiB 8192 +/* RX Buffer size must be < 8191 and multiple of 4/8/16 bytes */ +#define BUF_SIZE_8KiB 8188 #define BUF_SIZE_4KiB 4096 #define BUF_SIZE_2KiB 2048 diff --git a/drivers/net/ethernet/stmicro/stmmac/descs_com.h b/drivers/net/ethernet/stmicro/stmmac/descs_com.h index ca9d7e48034c..40d6356a7e73 100644 --- a/drivers/net/ethernet/stmicro/stmmac/descs_com.h +++ b/drivers/net/ethernet/stmicro/stmmac/descs_com.h @@ -31,7 +31,7 @@ /* Enhanced descriptors */ static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end) { - p->des1 |= cpu_to_le32(((BUF_SIZE_8KiB - 1) + p->des1 |= cpu_to_le32((BUF_SIZE_8KiB << ERDES1_BUFFER2_SIZE_SHIFT) & ERDES1_BUFFER2_SIZE_MASK); diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 2a828a312814..acd65a4f94d4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c @@ -262,7 +262,7 @@ static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic, int mode, int end) { p->des0 |= cpu_to_le32(RDES0_OWN); - p->des1 |= cpu_to_le32((BUF_SIZE_8KiB - 1) & ERDES1_BUFFER1_SIZE_MASK); + p->des1 |= cpu_to_le32(BUF_SIZE_8KiB & ERDES1_BUFFER1_SIZE_MASK); if (mode == STMMAC_CHAIN_MODE) ehn_desc_rx_set_on_chain(p); diff --git a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c index 28e4b5d50ce6..1af7b078b94d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -143,7 +143,7 @@ static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) static int stmmac_set_16kib_bfsize(int mtu) { int ret = 0; - if (unlikely(mtu >= BUF_SIZE_8KiB)) + if (unlikely(mtu > BUF_SIZE_8KiB)) ret = BUF_SIZE_16KiB; return ret; } -- 2.17.1