diff options
Diffstat (limited to 'drivers/net/ethernet/freescale/fec_main.c')
-rw-r--r-- | drivers/net/ethernet/freescale/fec_main.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 99492b7e3713..f6a3a7abd468 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c | |||
@@ -1189,13 +1189,12 @@ static void | |||
1189 | fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) | 1189 | fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) |
1190 | { | 1190 | { |
1191 | struct fec_enet_private *fep; | 1191 | struct fec_enet_private *fep; |
1192 | struct bufdesc *bdp, *bdp_t; | 1192 | struct bufdesc *bdp; |
1193 | unsigned short status; | 1193 | unsigned short status; |
1194 | struct sk_buff *skb; | 1194 | struct sk_buff *skb; |
1195 | struct fec_enet_priv_tx_q *txq; | 1195 | struct fec_enet_priv_tx_q *txq; |
1196 | struct netdev_queue *nq; | 1196 | struct netdev_queue *nq; |
1197 | int index = 0; | 1197 | int index = 0; |
1198 | int i, bdnum; | ||
1199 | int entries_free; | 1198 | int entries_free; |
1200 | 1199 | ||
1201 | fep = netdev_priv(ndev); | 1200 | fep = netdev_priv(ndev); |
@@ -1216,29 +1215,18 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) | |||
1216 | if (bdp == txq->cur_tx) | 1215 | if (bdp == txq->cur_tx) |
1217 | break; | 1216 | break; |
1218 | 1217 | ||
1219 | bdp_t = bdp; | 1218 | index = fec_enet_get_bd_index(txq->tx_bd_base, bdp, fep); |
1220 | bdnum = 1; | ||
1221 | index = fec_enet_get_bd_index(txq->tx_bd_base, bdp_t, fep); | ||
1222 | skb = txq->tx_skbuff[index]; | ||
1223 | while (!skb) { | ||
1224 | bdp_t = fec_enet_get_nextdesc(bdp_t, fep, queue_id); | ||
1225 | index = fec_enet_get_bd_index(txq->tx_bd_base, bdp_t, fep); | ||
1226 | skb = txq->tx_skbuff[index]; | ||
1227 | bdnum++; | ||
1228 | } | ||
1229 | if (skb_shinfo(skb)->nr_frags && | ||
1230 | (status = bdp_t->cbd_sc) & BD_ENET_TX_READY) | ||
1231 | break; | ||
1232 | 1219 | ||
1233 | for (i = 0; i < bdnum; i++) { | 1220 | skb = txq->tx_skbuff[index]; |
1234 | if (!IS_TSO_HEADER(txq, bdp->cbd_bufaddr)) | ||
1235 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, | ||
1236 | bdp->cbd_datlen, DMA_TO_DEVICE); | ||
1237 | bdp->cbd_bufaddr = 0; | ||
1238 | if (i < bdnum - 1) | ||
1239 | bdp = fec_enet_get_nextdesc(bdp, fep, queue_id); | ||
1240 | } | ||
1241 | txq->tx_skbuff[index] = NULL; | 1221 | txq->tx_skbuff[index] = NULL; |
1222 | if (!IS_TSO_HEADER(txq, bdp->cbd_bufaddr)) | ||
1223 | dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, | ||
1224 | bdp->cbd_datlen, DMA_TO_DEVICE); | ||
1225 | bdp->cbd_bufaddr = 0; | ||
1226 | if (!skb) { | ||
1227 | bdp = fec_enet_get_nextdesc(bdp, fep, queue_id); | ||
1228 | continue; | ||
1229 | } | ||
1242 | 1230 | ||
1243 | /* Check for errors. */ | 1231 | /* Check for errors. */ |
1244 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | | 1232 | if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | |
@@ -1479,8 +1467,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id) | |||
1479 | 1467 | ||
1480 | vlan_packet_rcvd = true; | 1468 | vlan_packet_rcvd = true; |
1481 | 1469 | ||
1482 | skb_copy_to_linear_data_offset(skb, VLAN_HLEN, | 1470 | memmove(skb->data + VLAN_HLEN, data, ETH_ALEN * 2); |
1483 | data, (2 * ETH_ALEN)); | ||
1484 | skb_pull(skb, VLAN_HLEN); | 1471 | skb_pull(skb, VLAN_HLEN); |
1485 | } | 1472 | } |
1486 | 1473 | ||
@@ -1967,6 +1954,7 @@ static int fec_enet_mii_init(struct platform_device *pdev) | |||
1967 | struct fec_enet_private *fep = netdev_priv(ndev); | 1954 | struct fec_enet_private *fep = netdev_priv(ndev); |
1968 | struct device_node *node; | 1955 | struct device_node *node; |
1969 | int err = -ENXIO, i; | 1956 | int err = -ENXIO, i; |
1957 | u32 mii_speed, holdtime; | ||
1970 | 1958 | ||
1971 | /* | 1959 | /* |
1972 | * The i.MX28 dual fec interfaces are not equal. | 1960 | * The i.MX28 dual fec interfaces are not equal. |
@@ -2004,10 +1992,33 @@ static int fec_enet_mii_init(struct platform_device *pdev) | |||
2004 | * Reference Manual has an error on this, and gets fixed on i.MX6Q | 1992 | * Reference Manual has an error on this, and gets fixed on i.MX6Q |
2005 | * document. | 1993 | * document. |
2006 | */ | 1994 | */ |
2007 | fep->phy_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000); | 1995 | mii_speed = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 5000000); |
2008 | if (fep->quirks & FEC_QUIRK_ENET_MAC) | 1996 | if (fep->quirks & FEC_QUIRK_ENET_MAC) |
2009 | fep->phy_speed--; | 1997 | mii_speed--; |
2010 | fep->phy_speed <<= 1; | 1998 | if (mii_speed > 63) { |
1999 | dev_err(&pdev->dev, | ||
2000 | "fec clock (%lu) to fast to get right mii speed\n", | ||
2001 | clk_get_rate(fep->clk_ipg)); | ||
2002 | err = -EINVAL; | ||
2003 | goto err_out; | ||
2004 | } | ||
2005 | |||
2006 | /* | ||
2007 | * The i.MX28 and i.MX6 types have another filed in the MSCR (aka | ||
2008 | * MII_SPEED) register that defines the MDIO output hold time. Earlier | ||
2009 | * versions are RAZ there, so just ignore the difference and write the | ||
2010 | * register always. | ||
2011 | * The minimal hold time according to IEE802.3 (clause 22) is 10 ns. | ||
2012 | * HOLDTIME + 1 is the number of clk cycles the fec is holding the | ||
2013 | * output. | ||
2014 | * The HOLDTIME bitfield takes values between 0 and 7 (inclusive). | ||
2015 | * Given that ceil(clkrate / 5000000) <= 64, the calculation for | ||
2016 | * holdtime cannot result in a value greater than 3. | ||
2017 | */ | ||
2018 | holdtime = DIV_ROUND_UP(clk_get_rate(fep->clk_ipg), 100000000) - 1; | ||
2019 | |||
2020 | fep->phy_speed = mii_speed << 1 | holdtime << 8; | ||
2021 | |||
2011 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); | 2022 | writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED); |
2012 | 2023 | ||
2013 | fep->mii_bus = mdiobus_alloc(); | 2024 | fep->mii_bus = mdiobus_alloc(); |