|
52 | 52 | #include "stmmac.h"
|
53 | 53 |
|
54 | 54 | #define STMMAC_ALIGN(x) L1_CACHE_ALIGN(x)
|
55 |
| -#define JUMBO_LEN 9000 |
56 | 55 |
|
57 | 56 | /* Module parameters */
|
58 | 57 | #define TX_TIMEO 5000
|
@@ -988,6 +987,8 @@ static int init_dma_desc_rings(struct net_device *dev)
|
988 | 987 |
|
989 | 988 | priv->dma_buf_sz = bfsize;
|
990 | 989 |
|
| 990 | + priv->dma_buf_sz = bfsize; |
| 991 | + |
991 | 992 | if (netif_msg_probe(priv))
|
992 | 993 | pr_debug("%s: txsize %d, rxsize %d, bfsize %d\n", __func__,
|
993 | 994 | txsize, rxsize, bfsize);
|
@@ -1585,6 +1586,86 @@ static void stmmac_init_tx_coalesce(struct stmmac_priv *priv)
|
1585 | 1586 | add_timer(&priv->txtimer);
|
1586 | 1587 | }
|
1587 | 1588 |
|
| 1589 | +/** |
| 1590 | + * stmmac_hw_setup: setup mac in a usable state. |
| 1591 | + * @dev : pointer to the device structure. |
| 1592 | + * Description: |
| 1593 | + * This function sets up the ip in a usable state. |
| 1594 | + * Return value: |
| 1595 | + * 0 on success and an appropriate (-)ve integer as defined in errno.h |
| 1596 | + * file on failure. |
| 1597 | + */ |
| 1598 | +static int stmmac_hw_setup(struct net_device *dev) |
| 1599 | +{ |
| 1600 | + struct stmmac_priv *priv = netdev_priv(dev); |
| 1601 | + int ret; |
| 1602 | + |
| 1603 | + ret = init_dma_desc_rings(dev); |
| 1604 | + if (ret < 0) { |
| 1605 | + pr_err("%s: DMA descriptors initialization failed\n", __func__); |
| 1606 | + return ret; |
| 1607 | + } |
| 1608 | + /* DMA initialization and SW reset */ |
| 1609 | + ret = stmmac_init_dma_engine(priv); |
| 1610 | + if (ret < 0) { |
| 1611 | + pr_err("%s: DMA engine initialization failed\n", __func__); |
| 1612 | + return ret; |
| 1613 | + } |
| 1614 | + |
| 1615 | + /* Copy the MAC addr into the HW */ |
| 1616 | + priv->hw->mac->set_umac_addr(priv->ioaddr, dev->dev_addr, 0); |
| 1617 | + |
| 1618 | + /* If required, perform hw setup of the bus. */ |
| 1619 | + if (priv->plat->bus_setup) |
| 1620 | + priv->plat->bus_setup(priv->ioaddr); |
| 1621 | + |
| 1622 | + /* Initialize the MAC Core */ |
| 1623 | + priv->hw->mac->core_init(priv->ioaddr, dev->mtu); |
| 1624 | + |
| 1625 | + /* Enable the MAC Rx/Tx */ |
| 1626 | + stmmac_set_mac(priv->ioaddr, true); |
| 1627 | + |
| 1628 | + /* Set the HW DMA mode and the COE */ |
| 1629 | + stmmac_dma_operation_mode(priv); |
| 1630 | + |
| 1631 | + stmmac_mmc_setup(priv); |
| 1632 | + |
| 1633 | + ret = stmmac_init_ptp(priv); |
| 1634 | + if (ret) |
| 1635 | + pr_warn("%s: failed PTP initialisation\n", __func__); |
| 1636 | + |
| 1637 | +#ifdef CONFIG_STMMAC_DEBUG_FS |
| 1638 | + ret = stmmac_init_fs(dev); |
| 1639 | + if (ret < 0) |
| 1640 | + pr_warn("%s: failed debugFS registration\n", __func__); |
| 1641 | +#endif |
| 1642 | + /* Start the ball rolling... */ |
| 1643 | + pr_debug("%s: DMA RX/TX processes started...\n", dev->name); |
| 1644 | + priv->hw->dma->start_tx(priv->ioaddr); |
| 1645 | + priv->hw->dma->start_rx(priv->ioaddr); |
| 1646 | + |
| 1647 | + /* Dump DMA/MAC registers */ |
| 1648 | + if (netif_msg_hw(priv)) { |
| 1649 | + priv->hw->mac->dump_regs(priv->ioaddr); |
| 1650 | + priv->hw->dma->dump_regs(priv->ioaddr); |
| 1651 | + } |
| 1652 | + priv->tx_lpi_timer = STMMAC_DEFAULT_TWT_LS; |
| 1653 | + |
| 1654 | + priv->eee_enabled = stmmac_eee_init(priv); |
| 1655 | + |
| 1656 | + stmmac_init_tx_coalesce(priv); |
| 1657 | + |
| 1658 | + if ((priv->use_riwt) && (priv->hw->dma->rx_watchdog)) { |
| 1659 | + priv->rx_riwt = MAX_DMA_RIWT; |
| 1660 | + priv->hw->dma->rx_watchdog(priv->ioaddr, MAX_DMA_RIWT); |
| 1661 | + } |
| 1662 | + |
| 1663 | + if (priv->pcs && priv->hw->mac->ctrl_ane) |
| 1664 | + priv->hw->mac->ctrl_ane(priv->ioaddr, 0); |
| 1665 | + |
| 1666 | + return 0; |
| 1667 | +} |
| 1668 | + |
1588 | 1669 | /**
|
1589 | 1670 | * stmmac_open - open entry point of the driver
|
1590 | 1671 | * @dev : pointer to the device structure.
|
@@ -2238,6 +2319,14 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
|
2238 | 2319 | return -EBUSY;
|
2239 | 2320 | }
|
2240 | 2321 |
|
| 2322 | + if (priv->plat->enh_desc) |
| 2323 | + max_mtu = JUMBO_LEN; |
| 2324 | + else |
| 2325 | + max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN); |
| 2326 | + |
| 2327 | + if (priv->plat->maxmtu < max_mtu) |
| 2328 | + max_mtu = priv->plat->maxmtu; |
| 2329 | + |
2241 | 2330 | if ((new_mtu < 46) || (new_mtu > max_mtu)) {
|
2242 | 2331 | pr_err("%s: invalid MTU, max MTU is: %d\n", dev->name, max_mtu);
|
2243 | 2332 | return -EINVAL;
|
|
0 commit comments