Skip to content

Commit 6fa9a11

Browse files
committed
Merge branch 'stmmac-fixes'
Jose Abreu says: ==================== net: stmmac: Fixes for -net Fixes for stmmac. 1) Fixes the filtering selftests (again) for cases when the number of multicast filters are not enough. 2) Fixes SPH feature for MTU > default. 3) Fixes the behavior of accepting invalid MTU values. 4) Fixes FCS stripping for multi-descriptor packets. 5) Fixes the change of RX buffer size in XGMAC. 6) Fixes RX buffer size alignment. 7) Fixes the 16KB buffer alignment. 8) Fixes the enabling of 16KB buffer size feature. 9) Always arm the TX coalesce timer so that missed interrupts do not cause a TX queue timeout. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents b7ac893 + 4772f26 commit 6fa9a11

5 files changed

Lines changed: 42 additions & 25 deletions

File tree

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,8 @@ struct dma_features {
365365
unsigned int arpoffsel;
366366
};
367367

368-
/* GMAC TX FIFO is 8K, Rx FIFO is 16K */
369-
#define BUF_SIZE_16KiB 16384
370-
/* RX Buffer size must be < 8191 and multiple of 4/8/16 bytes */
368+
/* RX Buffer size must be multiple of 4/8/16 bytes */
369+
#define BUF_SIZE_16KiB 16368
371370
#define BUF_SIZE_8KiB 8188
372371
#define BUF_SIZE_4KiB 4096
373372
#define BUF_SIZE_2KiB 2048

‎drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@
343343
#define XGMAC_DMA_CH_RX_CONTROL(x) (0x00003108 + (0x80 * (x)))
344344
#define XGMAC_RxPBL GENMASK(21, 16)
345345
#define XGMAC_RxPBL_SHIFT 16
346+
#define XGMAC_RBSZ GENMASK(14, 1)
347+
#define XGMAC_RBSZ_SHIFT 1
346348
#define XGMAC_RXST BIT(0)
347349
#define XGMAC_DMA_CH_TxDESC_HADDR(x) (0x00003110 + (0x80 * (x)))
348350
#define XGMAC_DMA_CH_TxDESC_LADDR(x) (0x00003114 + (0x80 * (x)))

‎drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ static void dwxgmac2_set_bfsize(void __iomem *ioaddr, int bfsize, u32 chan)
482482
u32 value;
483483

484484
value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
485-
value |= bfsize << 1;
485+
value &= ~XGMAC_RBSZ;
486+
value |= bfsize << XGMAC_RBSZ_SHIFT;
486487
writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
487488
}
488489

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

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "dwxgmac2.h"
4747
#include "hwif.h"
4848

49-
#define STMMAC_ALIGN(x) __ALIGN_KERNEL(x, SMP_CACHE_BYTES)
49+
#define STMMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16)
5050
#define TSO_MAX_BUFF_SIZE (SZ_16K - 1)
5151

5252
/* Module parameters */
@@ -1109,7 +1109,9 @@ static int stmmac_set_bfsize(int mtu, int bufsize)
11091109
{
11101110
int ret = bufsize;
11111111

1112-
if (mtu >= BUF_SIZE_4KiB)
1112+
if (mtu >= BUF_SIZE_8KiB)
1113+
ret = BUF_SIZE_16KiB;
1114+
else if (mtu >= BUF_SIZE_4KiB)
11131115
ret = BUF_SIZE_8KiB;
11141116
else if (mtu >= BUF_SIZE_2KiB)
11151117
ret = BUF_SIZE_4KiB;
@@ -1293,19 +1295,9 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
12931295
struct stmmac_priv *priv = netdev_priv(dev);
12941296
u32 rx_count = priv->plat->rx_queues_to_use;
12951297
int ret = -ENOMEM;
1296-
int bfsize = 0;
12971298
int queue;
12981299
int i;
12991300

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-
13091301
/* RX INITIALIZATION */
13101302
netif_dbg(priv, probe, priv->dev,
13111303
"SKB addresses:\nskb\t\tskb data\tdma data\n");
@@ -1347,8 +1339,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
13471339
}
13481340
}
13491341

1350-
buf_sz = bfsize;
1351-
13521342
return 0;
13531343

13541344
err_init_rx_buffers:
@@ -2658,6 +2648,7 @@ static void stmmac_hw_teardown(struct net_device *dev)
26582648
static int stmmac_open(struct net_device *dev)
26592649
{
26602650
struct stmmac_priv *priv = netdev_priv(dev);
2651+
int bfsize = 0;
26612652
u32 chan;
26622653
int ret;
26632654

@@ -2677,7 +2668,16 @@ static int stmmac_open(struct net_device *dev)
26772668
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
26782669
priv->xstats.threshold = tc;
26792670

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

26832683
ret = alloc_dma_desc_resources(priv);
@@ -3053,8 +3053,6 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
30533053
tx_q->tx_count_frames = 0;
30543054
stmmac_set_tx_ic(priv, desc);
30553055
priv->xstats.tx_set_ic_bit++;
3056-
} else {
3057-
stmmac_tx_timer_arm(priv, queue);
30583056
}
30593057

30603058
/* We've used all descriptors we need for this skb, however,
@@ -3125,6 +3123,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
31253123

31263124
tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
31273125
stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
3126+
stmmac_tx_timer_arm(priv, queue);
31283127

31293128
return NETDEV_TX_OK;
31303129

@@ -3276,8 +3275,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
32763275
tx_q->tx_count_frames = 0;
32773276
stmmac_set_tx_ic(priv, desc);
32783277
priv->xstats.tx_set_ic_bit++;
3279-
} else {
3280-
stmmac_tx_timer_arm(priv, queue);
32813278
}
32823279

32833280
/* We've used all descriptors we need for this skb, however,
@@ -3366,6 +3363,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
33663363

33673364
tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
33683365
stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
3366+
stmmac_tx_timer_arm(priv, queue);
33693367

33703368
return NETDEV_TX_OK;
33713369

@@ -3646,8 +3644,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
36463644
* feature is always disabled and packets need to be
36473645
* stripped manually.
36483646
*/
3649-
if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
3650-
unlikely(status != llc_snap)) {
3647+
if (likely(!(status & rx_not_ls)) &&
3648+
(likely(priv->synopsys_id >= DWMAC_CORE_4_00) ||
3649+
unlikely(status != llc_snap))) {
36513650
if (buf2_len)
36523651
buf2_len -= ETH_FCS_LEN;
36533652
else
@@ -3829,12 +3828,24 @@ static void stmmac_set_rx_mode(struct net_device *dev)
38293828
static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
38303829
{
38313830
struct stmmac_priv *priv = netdev_priv(dev);
3831+
int txfifosz = priv->plat->tx_fifo_size;
3832+
3833+
if (txfifosz == 0)
3834+
txfifosz = priv->dma_cap.tx_fifo_size;
3835+
3836+
txfifosz /= priv->plat->tx_queues_to_use;
38323837

38333838
if (netif_running(dev)) {
38343839
netdev_err(priv->dev, "must be stopped to change its MTU\n");
38353840
return -EBUSY;
38363841
}
38373842

3843+
new_mtu = STMMAC_ALIGN(new_mtu);
3844+
3845+
/* If condition true, FIFO is too small or MTU too large */
3846+
if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
3847+
return -EINVAL;
3848+
38383849
dev->mtu = new_mtu;
38393850

38403851
netdev_update_features(dev);

‎drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)
624624
return -EOPNOTSUPP;
625625
if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
626626
return -EOPNOTSUPP;
627+
if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
628+
return -EOPNOTSUPP;
627629

628630
while (--tries) {
629631
/* We only need to check the mc_addr for collisions */
@@ -666,6 +668,8 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)
666668

667669
if (stmmac_filter_check(priv))
668670
return -EOPNOTSUPP;
671+
if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
672+
return -EOPNOTSUPP;
669673
if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
670674
return -EOPNOTSUPP;
671675

0 commit comments

Comments
 (0)