Skip to content

Commit 5d626c8

Browse files
joabreudavem330
authored andcommitted
net: stmmac: Determine earlier the size of RX buffer
Split Header feature needs to know the size of RX buffer but current code is determining it too late. Fix this by moving the RX buffer computation to earlier stage. Changes from v2: - Do not try to align already aligned buffer size Fixes: 67afd6d ("net: stmmac: Add Split Header support and enable it in XGMAC cores") Signed-off-by: Jose Abreu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08c9654 commit 5d626c8

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,19 +1293,9 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
12931293
struct stmmac_priv *priv = netdev_priv(dev);
12941294
u32 rx_count = priv->plat->rx_queues_to_use;
12951295
int ret = -ENOMEM;
1296-
int bfsize = 0;
12971296
int queue;
12981297
int i;
12991298

1300-
bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
1301-
if (bfsize < 0)
1302-
bfsize = 0;
1303-
1304-
if (bfsize < BUF_SIZE_16KiB)
1305-
bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
1306-
1307-
priv->dma_buf_sz = bfsize;
1308-
13091299
/* RX INITIALIZATION */
13101300
netif_dbg(priv, probe, priv->dev,
13111301
"SKB addresses:\nskb\t\tskb data\tdma data\n");
@@ -1347,8 +1337,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
13471337
}
13481338
}
13491339

1350-
buf_sz = bfsize;
1351-
13521340
return 0;
13531341

13541342
err_init_rx_buffers:
@@ -2658,6 +2646,7 @@ static void stmmac_hw_teardown(struct net_device *dev)
26582646
static int stmmac_open(struct net_device *dev)
26592647
{
26602648
struct stmmac_priv *priv = netdev_priv(dev);
2649+
int bfsize = 0;
26612650
u32 chan;
26622651
int ret;
26632652

@@ -2677,7 +2666,16 @@ static int stmmac_open(struct net_device *dev)
26772666
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
26782667
priv->xstats.threshold = tc;
26792668

2680-
priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
2669+
bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
2670+
if (bfsize < 0)
2671+
bfsize = 0;
2672+
2673+
if (bfsize < BUF_SIZE_16KiB)
2674+
bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
2675+
2676+
priv->dma_buf_sz = bfsize;
2677+
buf_sz = bfsize;
2678+
26812679
priv->rx_copybreak = STMMAC_RX_COPYBREAK;
26822680

26832681
ret = alloc_dma_desc_resources(priv);

0 commit comments

Comments
 (0)