Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5626146imu; Mon, 26 Nov 2018 03:11:05 -0800 (PST) X-Google-Smtp-Source: AJdET5eT+EBKJ7YmbUn7HTMtT7ov/em2mATbQL+36zAHFAMMaYovGbBtezRwIYHfOeZPmSwnv2Lp X-Received: by 2002:a62:7504:: with SMTP id q4mr26998699pfc.180.1543230664983; Mon, 26 Nov 2018 03:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543230664; cv=none; d=google.com; s=arc-20160816; b=cLQVoOrziXSe8iA76SBeEA2gpIPnSHgL00in+/zwPRQIfpgXlzyOa1yDrzizjC3ui4 WwfANNj3ItiQ5Bm6K/UTFn+2o3Z3QequJh04TOa2xfTzlISRGEf9IffXSw3gnrGaAEjw bbwMGjdIN1WSdlSQToUh+ydPqH0No4YfyKC88lsaZ9SKKi/CuGUmu5KYWWsx8LHJVT2P vfQQ9QEZfPSA3w1Zjd0nE04csZZDP06Ko5XFDe+qFwRsmC+lWS0UYyzOsoKGPGupbHx3 G5zj82GQX2mJmdcPY7Nsv9Aujhzt68JcvNwSwUZwIpNPDPU2tPZ7iRIeqt0n0rRqpzNc Y83g== 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=ZwnavoSEZ5hA1dBfXE304wIk06vcXCAe7cN1MuL2u+k=; b=c0sb+MQHr/hJpx1X5NPneK9r5z44Bi7qyWNFZLhK1cFkP74kcb7XNGV7RqG1uI3c45 8bCCOy03H8SmMeZCJcpa5WH2TrY5W4RunkN3gQxpj7MdLEXM2No6tYKBwQiJTVXtRZNV l8fGBxhrjL6ZbPe/XX1RkHXzdjgoaahLWKm7t08hYIWXaMIYO4mLAgmzd9v7oVvtYuze Yuqddk18fKdX5w2VCdADbFUxtK71F8VQo+F2iOa5cdB0Hc8lZeFZU3wJQuTuqnmsto8H /wJJdyrznljOmJ13yy12Ca/ywvyUyB9T3/T4klcJoLWaJ8fBJqzU/xs0BTpgmg+As5yY vpog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nVn1xruk; 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 j11si40324467plb.253.2018.11.26.03.10.49; Mon, 26 Nov 2018 03:11:04 -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=nVn1xruk; 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 S1731180AbeKZV6t (ORCPT + 99 others); Mon, 26 Nov 2018 16:58:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:44296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbeKZV6s (ORCPT ); Mon, 26 Nov 2018 16:58:48 -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 82BE620645; Mon, 26 Nov 2018 11:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230302; bh=69c9lbCFPpbncDtmdDUr9t6dB2VT2irCivm3Fo4Yfzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nVn1xruk2MCRXWrCi9vGErh3kCBdmAGUOY1YgQZbtdAh6pqGWJtwlI5bbtYkpufxj 7pLAgLstfJtIk40GSNyue7/LXt9X4NmhIJjuscXSmGwB0tqpGmh9TVSS06OPc276ru VjAB/JfDcucAHQi37443k3R+eMcWa7yiRqEq86hQ= 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.19 085/118] net: stmmac: Fix RX packet size > 8191 Date: Mon, 26 Nov 2018 11:51:19 +0100 Message-Id: <20181126105105.113341438@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105059.832485122@linuxfoundation.org> References: <20181126105059.832485122@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.19-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 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