Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+42 -25
+2 -3
drivers/net/ethernet/stmicro/stmmac/common.h
··· 365 365 unsigned int arpoffsel; 366 366 }; 367 367 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 371 370 #define BUF_SIZE_8KiB 8188 372 371 #define BUF_SIZE_4KiB 4096 373 372 #define BUF_SIZE_2KiB 2048
+2
drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
··· 343 343 #define XGMAC_DMA_CH_RX_CONTROL(x) (0x00003108 + (0x80 * (x))) 344 344 #define XGMAC_RxPBL GENMASK(21, 16) 345 345 #define XGMAC_RxPBL_SHIFT 16 346 + #define XGMAC_RBSZ GENMASK(14, 1) 347 + #define XGMAC_RBSZ_SHIFT 1 346 348 #define XGMAC_RXST BIT(0) 347 349 #define XGMAC_DMA_CH_TxDESC_HADDR(x) (0x00003110 + (0x80 * (x))) 348 350 #define XGMAC_DMA_CH_TxDESC_LADDR(x) (0x00003114 + (0x80 * (x)))
+2 -1
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
··· 482 482 u32 value; 483 483 484 484 value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan)); 485 - value |= bfsize << 1; 485 + value &= ~XGMAC_RBSZ; 486 + value |= bfsize << XGMAC_RBSZ_SHIFT; 486 487 writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan)); 487 488 } 488 489
+32 -21
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 46 46 #include "dwxgmac2.h" 47 47 #include "hwif.h" 48 48 49 - #define STMMAC_ALIGN(x) __ALIGN_KERNEL(x, SMP_CACHE_BYTES) 49 + #define STMMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16) 50 50 #define TSO_MAX_BUFF_SIZE (SZ_16K - 1) 51 51 52 52 /* Module parameters */ ··· 1109 1109 { 1110 1110 int ret = bufsize; 1111 1111 1112 - if (mtu >= BUF_SIZE_4KiB) 1112 + if (mtu >= BUF_SIZE_8KiB) 1113 + ret = BUF_SIZE_16KiB; 1114 + else if (mtu >= BUF_SIZE_4KiB) 1113 1115 ret = BUF_SIZE_8KiB; 1114 1116 else if (mtu >= BUF_SIZE_2KiB) 1115 1117 ret = BUF_SIZE_4KiB; ··· 1295 1293 struct stmmac_priv *priv = netdev_priv(dev); 1296 1294 u32 rx_count = priv->plat->rx_queues_to_use; 1297 1295 int ret = -ENOMEM; 1298 - int bfsize = 0; 1299 1296 int queue; 1300 1297 int i; 1301 - 1302 - bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu); 1303 - if (bfsize < 0) 1304 - bfsize = 0; 1305 - 1306 - if (bfsize < BUF_SIZE_16KiB) 1307 - bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz); 1308 - 1309 - priv->dma_buf_sz = bfsize; 1310 1298 1311 1299 /* RX INITIALIZATION */ 1312 1300 netif_dbg(priv, probe, priv->dev, ··· 1338 1346 rx_q->dma_rx_phy, DMA_RX_SIZE, 0); 1339 1347 } 1340 1348 } 1341 - 1342 - buf_sz = bfsize; 1343 1349 1344 1350 return 0; 1345 1351 ··· 2648 2658 static int stmmac_open(struct net_device *dev) 2649 2659 { 2650 2660 struct stmmac_priv *priv = netdev_priv(dev); 2661 + int bfsize = 0; 2651 2662 u32 chan; 2652 2663 int ret; 2653 2664 ··· 2668 2677 memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); 2669 2678 priv->xstats.threshold = tc; 2670 2679 2671 - priv->dma_buf_sz = STMMAC_ALIGN(buf_sz); 2680 + bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu); 2681 + if (bfsize < 0) 2682 + bfsize = 0; 2683 + 2684 + if (bfsize < BUF_SIZE_16KiB) 2685 + bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz); 2686 + 2687 + priv->dma_buf_sz = bfsize; 2688 + buf_sz = bfsize; 2689 + 2672 2690 priv->rx_copybreak = STMMAC_RX_COPYBREAK; 2673 2691 2674 2692 ret = alloc_dma_desc_resources(priv); ··· 3053 3053 tx_q->tx_count_frames = 0; 3054 3054 stmmac_set_tx_ic(priv, desc); 3055 3055 priv->xstats.tx_set_ic_bit++; 3056 - } else { 3057 - stmmac_tx_timer_arm(priv, queue); 3058 3056 } 3059 3057 3060 3058 /* We've used all descriptors we need for this skb, however, ··· 3123 3125 3124 3126 tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); 3125 3127 stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); 3128 + stmmac_tx_timer_arm(priv, queue); 3126 3129 3127 3130 return NETDEV_TX_OK; 3128 3131 ··· 3275 3276 tx_q->tx_count_frames = 0; 3276 3277 stmmac_set_tx_ic(priv, desc); 3277 3278 priv->xstats.tx_set_ic_bit++; 3278 - } else { 3279 - stmmac_tx_timer_arm(priv, queue); 3280 3279 } 3281 3280 3282 3281 /* We've used all descriptors we need for this skb, however, ··· 3363 3366 3364 3367 tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc)); 3365 3368 stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue); 3369 + stmmac_tx_timer_arm(priv, queue); 3366 3370 3367 3371 return NETDEV_TX_OK; 3368 3372 ··· 3644 3646 * feature is always disabled and packets need to be 3645 3647 * stripped manually. 3646 3648 */ 3647 - if (unlikely(priv->synopsys_id >= DWMAC_CORE_4_00) || 3648 - unlikely(status != llc_snap)) { 3649 + if (likely(!(status & rx_not_ls)) && 3650 + (likely(priv->synopsys_id >= DWMAC_CORE_4_00) || 3651 + unlikely(status != llc_snap))) { 3649 3652 if (buf2_len) 3650 3653 buf2_len -= ETH_FCS_LEN; 3651 3654 else ··· 3828 3829 static int stmmac_change_mtu(struct net_device *dev, int new_mtu) 3829 3830 { 3830 3831 struct stmmac_priv *priv = netdev_priv(dev); 3832 + int txfifosz = priv->plat->tx_fifo_size; 3833 + 3834 + if (txfifosz == 0) 3835 + txfifosz = priv->dma_cap.tx_fifo_size; 3836 + 3837 + txfifosz /= priv->plat->tx_queues_to_use; 3831 3838 3832 3839 if (netif_running(dev)) { 3833 3840 netdev_err(priv->dev, "must be stopped to change its MTU\n"); 3834 3841 return -EBUSY; 3835 3842 } 3843 + 3844 + new_mtu = STMMAC_ALIGN(new_mtu); 3845 + 3846 + /* If condition true, FIFO is too small or MTU too large */ 3847 + if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB)) 3848 + return -EINVAL; 3836 3849 3837 3850 dev->mtu = new_mtu; 3838 3851
+4
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
··· 624 624 return -EOPNOTSUPP; 625 625 if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) 626 626 return -EOPNOTSUPP; 627 + if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) 628 + return -EOPNOTSUPP; 627 629 628 630 while (--tries) { 629 631 /* We only need to check the mc_addr for collisions */ ··· 667 665 int ret, tries = 256; 668 666 669 667 if (stmmac_filter_check(priv)) 668 + return -EOPNOTSUPP; 669 + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries) 670 670 return -EOPNOTSUPP; 671 671 if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins) 672 672 return -EOPNOTSUPP;