Skip to content

Commit 8137b6e

Browse files
tthayer-inteldavem330
authored andcommitted
net: stmmac: Fix RX packet size > 8191
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: 286a837 ("stmmac: add CHAINED descriptor mode support (V4)") Suggested-by: Jose Abreu <jose.abreu@synopsys.com> Signed-off-by: Thor Thayer <thor.thayer@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 81fe16e commit 8137b6e

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ struct dma_features {
365365

366366
/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
367367
#define BUF_SIZE_16KiB 16384
368-
#define BUF_SIZE_8KiB 8192
368+
/* RX Buffer size must be < 8191 and multiple of 4/8/16 bytes */
369+
#define BUF_SIZE_8KiB 8188
369370
#define BUF_SIZE_4KiB 4096
370371
#define BUF_SIZE_2KiB 2048
371372

drivers/net/ethernet/stmicro/stmmac/descs_com.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/* Enhanced descriptors */
3232
static inline void ehn_desc_rx_set_on_ring(struct dma_desc *p, int end)
3333
{
34-
p->des1 |= cpu_to_le32(((BUF_SIZE_8KiB - 1)
34+
p->des1 |= cpu_to_le32((BUF_SIZE_8KiB
3535
<< ERDES1_BUFFER2_SIZE_SHIFT)
3636
& ERDES1_BUFFER2_SIZE_MASK);
3737

drivers/net/ethernet/stmicro/stmmac/enh_desc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void enh_desc_init_rx_desc(struct dma_desc *p, int disable_rx_ic,
262262
int mode, int end)
263263
{
264264
p->des0 |= cpu_to_le32(RDES0_OWN);
265-
p->des1 |= cpu_to_le32((BUF_SIZE_8KiB - 1) & ERDES1_BUFFER1_SIZE_MASK);
265+
p->des1 |= cpu_to_le32(BUF_SIZE_8KiB & ERDES1_BUFFER1_SIZE_MASK);
266266

267267
if (mode == STMMAC_CHAIN_MODE)
268268
ehn_desc_rx_set_on_chain(p);

drivers/net/ethernet/stmicro/stmmac/ring_mode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static void clean_desc3(void *priv_ptr, struct dma_desc *p)
140140
static int set_16kib_bfsize(int mtu)
141141
{
142142
int ret = 0;
143-
if (unlikely(mtu >= BUF_SIZE_8KiB))
143+
if (unlikely(mtu > BUF_SIZE_8KiB))
144144
ret = BUF_SIZE_16KiB;
145145
return ret;
146146
}

0 commit comments

Comments
 (0)