Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7260331imu; Wed, 14 Nov 2018 14:25:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dyrXIIBhL76fJH2Qq7Pe/HoxUHQCJZ8d9RSI63TxfoQw7QhjEHsGmtXPJJOmsfhy/Wkzy7 X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr3833764pfa.82.1542234310606; Wed, 14 Nov 2018 14:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542234310; cv=none; d=google.com; s=arc-20160816; b=rcpevF9y+jxQgccPaWb2N73qVjJQefgUVK/wGd9qB3iQrgRyLFbXuEQSC6Wf6G5PeJ PwhR0ZDND7hvXmXYo1ij12XoKAnz+/lS5DJhYQTd30dRqTs9XNylzXlRpwK6zB+bhmaA Xgigk3SLGb2cZsIF4S80/VC/iFZlmwLv83eX2Fbx3PeDOGv8kjO8NMrUlNb/CiaHNLur qPXxC3/kHvMCty34eGfwYHl45a2+BHw87A/zq0BPvrzJYiub3RXBQYjaM9sGlBUelV2v DX6GS0mgwmymuL9xdW6w+8+EtYITw92equF/flm4Cb8OO3DPXIVmgOY18KLMm1/wyy4E hqJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4wxxGfhUN8n1/QkziLtSxQ9txZsotYHCs4QhGRnuP/I=; b=RkgSlzHIiyFNv1HV73cA0GvF92DJvYPOWrwkrxL3BLMB48Zlop8WpBjHTvC/uZPYR5 PHXe2sb5TAmtv9F29EoPPArd+JyVS8OvLBYwqnOdu2j8386jj0rKupaQn/HOvAMAnSwz hQwb90J29vvoCa76cTk4efcwkhM67/DIVFU8d9073KWb9HxprueLV5e9rDcr9Mm2e9dI HL14jBl9AfIeLggvwcXST2P7532SWD1MUH6um3j0mxjpPxUXykUfnG+66anJFLGVa8ab R0PL4gzN0YLl1kQQjE+9W5GYL4Bhqy2e2gROVMwEk/joW4oWOCmxL4Zljq2TiUd9/Pe3 jvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wrHLtjwE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11-v6si1440051plr.115.2018.11.14.14.24.56; Wed, 14 Nov 2018 14:25:10 -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=wrHLtjwE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387779AbeKOI2k (ORCPT + 99 others); Thu, 15 Nov 2018 03:28:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:34416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729032AbeKOI11 (ORCPT ); Thu, 15 Nov 2018 03:27:27 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0FD6E22527; Wed, 14 Nov 2018 22:22:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234144; bh=iQoC23f2OPy4jsdNlbZQ6KvEjMv0nqFHDwrABUUg/+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wrHLtjwE/Q4SJ3VxG79GUEfAiWmLD+bm2DF/GF9JeZf8gX8AjUkTlKK1gIjSA0nra VOUrjaYhamseKCErm22CbU70T42e5ssQIguPIOSXrgnijGdwOKniS1zSzeXKVAAx1b LgwDj+dDadfwSzdnptAatQw31UwtCMNTPd33stCg= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Thor Thayer , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 64/73] net: stmmac: Fix RX packet size > 8191 Date: Wed, 14 Nov 2018 17:21:58 -0500 Message-Id: <20181114222207.98701-64-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thor Thayer [ 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 b1b305f8f414..272b9ca66314 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -365,7 +365,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 77914c89d749..5ef91a790f9d 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 a7ffc73fffe8..bc83ced94e1b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/ring_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/ring_mode.c @@ -140,7 +140,7 @@ static void clean_desc3(void *priv_ptr, struct dma_desc *p) static int 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