diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
commit | cf9b59e9d3e008591d1f54830f570982bb307a0d (patch) | |
tree | 113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/net/gianfar.c | |
parent | 44504b2bebf8b5823c59484e73096a7d6574471d (diff) | |
parent | f4b87dee923342505e1ddba8d34ce9de33e75050 (diff) |
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and
build failures in vio.c after merge.
Conflicts:
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-mpc.c
drivers/net/gianfar.c
Also fixed up one line in arch/powerpc/kernel/vio.c to use the
correct node pointer.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r-- | drivers/net/gianfar.c | 227 |
1 files changed, 169 insertions, 58 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index c3b292a31328..1830f3199cb5 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -82,6 +82,7 @@ | |||
82 | #include <linux/tcp.h> | 82 | #include <linux/tcp.h> |
83 | #include <linux/udp.h> | 83 | #include <linux/udp.h> |
84 | #include <linux/in.h> | 84 | #include <linux/in.h> |
85 | #include <linux/net_tstamp.h> | ||
85 | 86 | ||
86 | #include <asm/io.h> | 87 | #include <asm/io.h> |
87 | #include <asm/irq.h> | 88 | #include <asm/irq.h> |
@@ -377,6 +378,13 @@ static void gfar_init_mac(struct net_device *ndev) | |||
377 | rctrl |= RCTRL_PADDING(priv->padding); | 378 | rctrl |= RCTRL_PADDING(priv->padding); |
378 | } | 379 | } |
379 | 380 | ||
381 | /* Insert receive time stamps into padding alignment bytes */ | ||
382 | if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) { | ||
383 | rctrl &= ~RCTRL_PAL_MASK; | ||
384 | rctrl |= RCTRL_PRSDEP_INIT | RCTRL_TS_ENABLE | RCTRL_PADDING(8); | ||
385 | priv->padding = 8; | ||
386 | } | ||
387 | |||
380 | /* keep vlan related bits if it's enabled */ | 388 | /* keep vlan related bits if it's enabled */ |
381 | if (priv->vlgrp) { | 389 | if (priv->vlgrp) { |
382 | rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT; | 390 | rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT; |
@@ -501,7 +509,8 @@ void unlock_tx_qs(struct gfar_private *priv) | |||
501 | /* Returns 1 if incoming frames use an FCB */ | 509 | /* Returns 1 if incoming frames use an FCB */ |
502 | static inline int gfar_uses_fcb(struct gfar_private *priv) | 510 | static inline int gfar_uses_fcb(struct gfar_private *priv) |
503 | { | 511 | { |
504 | return priv->vlgrp || priv->rx_csum_enable; | 512 | return priv->vlgrp || priv->rx_csum_enable || |
513 | (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER); | ||
505 | } | 514 | } |
506 | 515 | ||
507 | static void free_tx_pointers(struct gfar_private *priv) | 516 | static void free_tx_pointers(struct gfar_private *priv) |
@@ -549,12 +558,8 @@ static int gfar_parse_group(struct device_node *np, | |||
549 | struct gfar_private *priv, const char *model) | 558 | struct gfar_private *priv, const char *model) |
550 | { | 559 | { |
551 | u32 *queue_mask; | 560 | u32 *queue_mask; |
552 | u64 addr, size; | ||
553 | |||
554 | addr = of_translate_address(np, | ||
555 | of_get_address(np, 0, &size, NULL)); | ||
556 | priv->gfargrp[priv->num_grps].regs = ioremap(addr, size); | ||
557 | 561 | ||
562 | priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0); | ||
558 | if (!priv->gfargrp[priv->num_grps].regs) | 563 | if (!priv->gfargrp[priv->num_grps].regs) |
559 | return -ENOMEM; | 564 | return -ENOMEM; |
560 | 565 | ||
@@ -742,7 +747,8 @@ static int gfar_of_init(struct of_device *ofdev, struct net_device **pdev) | |||
742 | FSL_GIANFAR_DEV_HAS_CSUM | | 747 | FSL_GIANFAR_DEV_HAS_CSUM | |
743 | FSL_GIANFAR_DEV_HAS_VLAN | | 748 | FSL_GIANFAR_DEV_HAS_VLAN | |
744 | FSL_GIANFAR_DEV_HAS_MAGIC_PACKET | | 749 | FSL_GIANFAR_DEV_HAS_MAGIC_PACKET | |
745 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; | 750 | FSL_GIANFAR_DEV_HAS_EXTENDED_HASH | |
751 | FSL_GIANFAR_DEV_HAS_TIMER; | ||
746 | 752 | ||
747 | ctype = of_get_property(np, "phy-connection-type", NULL); | 753 | ctype = of_get_property(np, "phy-connection-type", NULL); |
748 | 754 | ||
@@ -772,6 +778,48 @@ err_grp_init: | |||
772 | return err; | 778 | return err; |
773 | } | 779 | } |
774 | 780 | ||
781 | static int gfar_hwtstamp_ioctl(struct net_device *netdev, | ||
782 | struct ifreq *ifr, int cmd) | ||
783 | { | ||
784 | struct hwtstamp_config config; | ||
785 | struct gfar_private *priv = netdev_priv(netdev); | ||
786 | |||
787 | if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) | ||
788 | return -EFAULT; | ||
789 | |||
790 | /* reserved for future extensions */ | ||
791 | if (config.flags) | ||
792 | return -EINVAL; | ||
793 | |||
794 | switch (config.tx_type) { | ||
795 | case HWTSTAMP_TX_OFF: | ||
796 | priv->hwts_tx_en = 0; | ||
797 | break; | ||
798 | case HWTSTAMP_TX_ON: | ||
799 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) | ||
800 | return -ERANGE; | ||
801 | priv->hwts_tx_en = 1; | ||
802 | break; | ||
803 | default: | ||
804 | return -ERANGE; | ||
805 | } | ||
806 | |||
807 | switch (config.rx_filter) { | ||
808 | case HWTSTAMP_FILTER_NONE: | ||
809 | priv->hwts_rx_en = 0; | ||
810 | break; | ||
811 | default: | ||
812 | if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)) | ||
813 | return -ERANGE; | ||
814 | priv->hwts_rx_en = 1; | ||
815 | config.rx_filter = HWTSTAMP_FILTER_ALL; | ||
816 | break; | ||
817 | } | ||
818 | |||
819 | return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? | ||
820 | -EFAULT : 0; | ||
821 | } | ||
822 | |||
775 | /* Ioctl MII Interface */ | 823 | /* Ioctl MII Interface */ |
776 | static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 824 | static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
777 | { | 825 | { |
@@ -780,6 +828,9 @@ static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
780 | if (!netif_running(dev)) | 828 | if (!netif_running(dev)) |
781 | return -EINVAL; | 829 | return -EINVAL; |
782 | 830 | ||
831 | if (cmd == SIOCSHWTSTAMP) | ||
832 | return gfar_hwtstamp_ioctl(dev, rq, cmd); | ||
833 | |||
783 | if (!priv->phydev) | 834 | if (!priv->phydev) |
784 | return -ENODEV; | 835 | return -ENODEV; |
785 | 836 | ||
@@ -982,7 +1033,8 @@ static int gfar_probe(struct of_device *ofdev, | |||
982 | else | 1033 | else |
983 | priv->padding = 0; | 1034 | priv->padding = 0; |
984 | 1035 | ||
985 | if (dev->features & NETIF_F_IP_CSUM) | 1036 | if (dev->features & NETIF_F_IP_CSUM || |
1037 | priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) | ||
986 | dev->hard_header_len += GMAC_FCB_LEN; | 1038 | dev->hard_header_len += GMAC_FCB_LEN; |
987 | 1039 | ||
988 | /* Program the isrg regs only if number of grps > 1 */ | 1040 | /* Program the isrg regs only if number of grps > 1 */ |
@@ -1292,21 +1344,9 @@ static struct dev_pm_ops gfar_pm_ops = { | |||
1292 | 1344 | ||
1293 | #define GFAR_PM_OPS (&gfar_pm_ops) | 1345 | #define GFAR_PM_OPS (&gfar_pm_ops) |
1294 | 1346 | ||
1295 | static int gfar_legacy_suspend(struct of_device *ofdev, pm_message_t state) | ||
1296 | { | ||
1297 | return gfar_suspend(&ofdev->dev); | ||
1298 | } | ||
1299 | |||
1300 | static int gfar_legacy_resume(struct of_device *ofdev) | ||
1301 | { | ||
1302 | return gfar_resume(&ofdev->dev); | ||
1303 | } | ||
1304 | |||
1305 | #else | 1347 | #else |
1306 | 1348 | ||
1307 | #define GFAR_PM_OPS NULL | 1349 | #define GFAR_PM_OPS NULL |
1308 | #define gfar_legacy_suspend NULL | ||
1309 | #define gfar_legacy_resume NULL | ||
1310 | 1350 | ||
1311 | #endif | 1351 | #endif |
1312 | 1352 | ||
@@ -1515,9 +1555,9 @@ static void gfar_halt_nodisable(struct net_device *dev) | |||
1515 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); | 1555 | tempval |= (DMACTRL_GRS | DMACTRL_GTS); |
1516 | gfar_write(®s->dmactrl, tempval); | 1556 | gfar_write(®s->dmactrl, tempval); |
1517 | 1557 | ||
1518 | while (!(gfar_read(®s->ievent) & | 1558 | spin_event_timeout(((gfar_read(®s->ievent) & |
1519 | (IEVENT_GRSC | IEVENT_GTSC))) | 1559 | (IEVENT_GRSC | IEVENT_GTSC)) == |
1520 | cpu_relax(); | 1560 | (IEVENT_GRSC | IEVENT_GTSC)), -1, 0); |
1521 | } | 1561 | } |
1522 | } | 1562 | } |
1523 | 1563 | ||
@@ -1653,6 +1693,7 @@ static void free_skb_resources(struct gfar_private *priv) | |||
1653 | sizeof(struct rxbd8) * priv->total_rx_ring_size, | 1693 | sizeof(struct rxbd8) * priv->total_rx_ring_size, |
1654 | priv->tx_queue[0]->tx_bd_base, | 1694 | priv->tx_queue[0]->tx_bd_base, |
1655 | priv->tx_queue[0]->tx_bd_dma_base); | 1695 | priv->tx_queue[0]->tx_bd_dma_base); |
1696 | skb_queue_purge(&priv->rx_recycle); | ||
1656 | } | 1697 | } |
1657 | 1698 | ||
1658 | void gfar_start(struct net_device *dev) | 1699 | void gfar_start(struct net_device *dev) |
@@ -1686,7 +1727,7 @@ void gfar_start(struct net_device *dev) | |||
1686 | gfar_write(®s->imask, IMASK_DEFAULT); | 1727 | gfar_write(®s->imask, IMASK_DEFAULT); |
1687 | } | 1728 | } |
1688 | 1729 | ||
1689 | dev->trans_start = jiffies; | 1730 | dev->trans_start = jiffies; /* prevent tx timeout */ |
1690 | } | 1731 | } |
1691 | 1732 | ||
1692 | void gfar_configure_coalescing(struct gfar_private *priv, | 1733 | void gfar_configure_coalescing(struct gfar_private *priv, |
@@ -1926,23 +1967,29 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1926 | struct netdev_queue *txq; | 1967 | struct netdev_queue *txq; |
1927 | struct gfar __iomem *regs = NULL; | 1968 | struct gfar __iomem *regs = NULL; |
1928 | struct txfcb *fcb = NULL; | 1969 | struct txfcb *fcb = NULL; |
1929 | struct txbd8 *txbdp, *txbdp_start, *base; | 1970 | struct txbd8 *txbdp, *txbdp_start, *base, *txbdp_tstamp = NULL; |
1930 | u32 lstatus; | 1971 | u32 lstatus; |
1931 | int i, rq = 0; | 1972 | int i, rq = 0, do_tstamp = 0; |
1932 | u32 bufaddr; | 1973 | u32 bufaddr; |
1933 | unsigned long flags; | 1974 | unsigned long flags; |
1934 | unsigned int nr_frags, length; | 1975 | unsigned int nr_frags, nr_txbds, length; |
1935 | 1976 | union skb_shared_tx *shtx; | |
1936 | 1977 | ||
1937 | rq = skb->queue_mapping; | 1978 | rq = skb->queue_mapping; |
1938 | tx_queue = priv->tx_queue[rq]; | 1979 | tx_queue = priv->tx_queue[rq]; |
1939 | txq = netdev_get_tx_queue(dev, rq); | 1980 | txq = netdev_get_tx_queue(dev, rq); |
1940 | base = tx_queue->tx_bd_base; | 1981 | base = tx_queue->tx_bd_base; |
1941 | regs = tx_queue->grp->regs; | 1982 | regs = tx_queue->grp->regs; |
1983 | shtx = skb_tx(skb); | ||
1984 | |||
1985 | /* check if time stamp should be generated */ | ||
1986 | if (unlikely(shtx->hardware && priv->hwts_tx_en)) | ||
1987 | do_tstamp = 1; | ||
1942 | 1988 | ||
1943 | /* make space for additional header when fcb is needed */ | 1989 | /* make space for additional header when fcb is needed */ |
1944 | if (((skb->ip_summed == CHECKSUM_PARTIAL) || | 1990 | if (((skb->ip_summed == CHECKSUM_PARTIAL) || |
1945 | (priv->vlgrp && vlan_tx_tag_present(skb))) && | 1991 | (priv->vlgrp && vlan_tx_tag_present(skb)) || |
1992 | unlikely(do_tstamp)) && | ||
1946 | (skb_headroom(skb) < GMAC_FCB_LEN)) { | 1993 | (skb_headroom(skb) < GMAC_FCB_LEN)) { |
1947 | struct sk_buff *skb_new; | 1994 | struct sk_buff *skb_new; |
1948 | 1995 | ||
@@ -1959,8 +2006,14 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1959 | /* total number of fragments in the SKB */ | 2006 | /* total number of fragments in the SKB */ |
1960 | nr_frags = skb_shinfo(skb)->nr_frags; | 2007 | nr_frags = skb_shinfo(skb)->nr_frags; |
1961 | 2008 | ||
2009 | /* calculate the required number of TxBDs for this skb */ | ||
2010 | if (unlikely(do_tstamp)) | ||
2011 | nr_txbds = nr_frags + 2; | ||
2012 | else | ||
2013 | nr_txbds = nr_frags + 1; | ||
2014 | |||
1962 | /* check if there is space to queue this packet */ | 2015 | /* check if there is space to queue this packet */ |
1963 | if ((nr_frags+1) > tx_queue->num_txbdfree) { | 2016 | if (nr_txbds > tx_queue->num_txbdfree) { |
1964 | /* no space, stop the queue */ | 2017 | /* no space, stop the queue */ |
1965 | netif_tx_stop_queue(txq); | 2018 | netif_tx_stop_queue(txq); |
1966 | dev->stats.tx_fifo_errors++; | 2019 | dev->stats.tx_fifo_errors++; |
@@ -1972,9 +2025,19 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1972 | txq->tx_packets ++; | 2025 | txq->tx_packets ++; |
1973 | 2026 | ||
1974 | txbdp = txbdp_start = tx_queue->cur_tx; | 2027 | txbdp = txbdp_start = tx_queue->cur_tx; |
2028 | lstatus = txbdp->lstatus; | ||
2029 | |||
2030 | /* Time stamp insertion requires one additional TxBD */ | ||
2031 | if (unlikely(do_tstamp)) | ||
2032 | txbdp_tstamp = txbdp = next_txbd(txbdp, base, | ||
2033 | tx_queue->tx_ring_size); | ||
1975 | 2034 | ||
1976 | if (nr_frags == 0) { | 2035 | if (nr_frags == 0) { |
1977 | lstatus = txbdp->lstatus | BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT); | 2036 | if (unlikely(do_tstamp)) |
2037 | txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_LAST | | ||
2038 | TXBD_INTERRUPT); | ||
2039 | else | ||
2040 | lstatus |= BD_LFLAG(TXBD_LAST | TXBD_INTERRUPT); | ||
1978 | } else { | 2041 | } else { |
1979 | /* Place the fragment addresses and lengths into the TxBDs */ | 2042 | /* Place the fragment addresses and lengths into the TxBDs */ |
1980 | for (i = 0; i < nr_frags; i++) { | 2043 | for (i = 0; i < nr_frags; i++) { |
@@ -2020,11 +2083,32 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2020 | gfar_tx_vlan(skb, fcb); | 2083 | gfar_tx_vlan(skb, fcb); |
2021 | } | 2084 | } |
2022 | 2085 | ||
2023 | /* setup the TxBD length and buffer pointer for the first BD */ | 2086 | /* Setup tx hardware time stamping if requested */ |
2087 | if (unlikely(do_tstamp)) { | ||
2088 | shtx->in_progress = 1; | ||
2089 | if (fcb == NULL) | ||
2090 | fcb = gfar_add_fcb(skb); | ||
2091 | fcb->ptp = 1; | ||
2092 | lstatus |= BD_LFLAG(TXBD_TOE); | ||
2093 | } | ||
2094 | |||
2024 | txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, | 2095 | txbdp_start->bufPtr = dma_map_single(&priv->ofdev->dev, skb->data, |
2025 | skb_headlen(skb), DMA_TO_DEVICE); | 2096 | skb_headlen(skb), DMA_TO_DEVICE); |
2026 | 2097 | ||
2027 | lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb); | 2098 | /* |
2099 | * If time stamping is requested one additional TxBD must be set up. The | ||
2100 | * first TxBD points to the FCB and must have a data length of | ||
2101 | * GMAC_FCB_LEN. The second TxBD points to the actual frame data with | ||
2102 | * the full frame length. | ||
2103 | */ | ||
2104 | if (unlikely(do_tstamp)) { | ||
2105 | txbdp_tstamp->bufPtr = txbdp_start->bufPtr + GMAC_FCB_LEN; | ||
2106 | txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) | | ||
2107 | (skb_headlen(skb) - GMAC_FCB_LEN); | ||
2108 | lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN; | ||
2109 | } else { | ||
2110 | lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb); | ||
2111 | } | ||
2028 | 2112 | ||
2029 | /* | 2113 | /* |
2030 | * We can work in parallel with gfar_clean_tx_ring(), except | 2114 | * We can work in parallel with gfar_clean_tx_ring(), except |
@@ -2064,9 +2148,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2064 | tx_queue->cur_tx = next_txbd(txbdp, base, tx_queue->tx_ring_size); | 2148 | tx_queue->cur_tx = next_txbd(txbdp, base, tx_queue->tx_ring_size); |
2065 | 2149 | ||
2066 | /* reduce TxBD free count */ | 2150 | /* reduce TxBD free count */ |
2067 | tx_queue->num_txbdfree -= (nr_frags + 1); | 2151 | tx_queue->num_txbdfree -= (nr_txbds); |
2068 | |||
2069 | dev->trans_start = jiffies; | ||
2070 | 2152 | ||
2071 | /* If the next BD still needs to be cleaned up, then the bds | 2153 | /* If the next BD still needs to be cleaned up, then the bds |
2072 | are full. We need to tell the kernel to stop sending us stuff. */ | 2154 | are full. We need to tell the kernel to stop sending us stuff. */ |
@@ -2092,7 +2174,6 @@ static int gfar_close(struct net_device *dev) | |||
2092 | 2174 | ||
2093 | disable_napi(priv); | 2175 | disable_napi(priv); |
2094 | 2176 | ||
2095 | skb_queue_purge(&priv->rx_recycle); | ||
2096 | cancel_work_sync(&priv->reset_task); | 2177 | cancel_work_sync(&priv->reset_task); |
2097 | stop_gfar(dev); | 2178 | stop_gfar(dev); |
2098 | 2179 | ||
@@ -2255,16 +2336,18 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2255 | struct net_device *dev = tx_queue->dev; | 2336 | struct net_device *dev = tx_queue->dev; |
2256 | struct gfar_private *priv = netdev_priv(dev); | 2337 | struct gfar_private *priv = netdev_priv(dev); |
2257 | struct gfar_priv_rx_q *rx_queue = NULL; | 2338 | struct gfar_priv_rx_q *rx_queue = NULL; |
2258 | struct txbd8 *bdp; | 2339 | struct txbd8 *bdp, *next = NULL; |
2259 | struct txbd8 *lbdp = NULL; | 2340 | struct txbd8 *lbdp = NULL; |
2260 | struct txbd8 *base = tx_queue->tx_bd_base; | 2341 | struct txbd8 *base = tx_queue->tx_bd_base; |
2261 | struct sk_buff *skb; | 2342 | struct sk_buff *skb; |
2262 | int skb_dirtytx; | 2343 | int skb_dirtytx; |
2263 | int tx_ring_size = tx_queue->tx_ring_size; | 2344 | int tx_ring_size = tx_queue->tx_ring_size; |
2264 | int frags = 0; | 2345 | int frags = 0, nr_txbds = 0; |
2265 | int i; | 2346 | int i; |
2266 | int howmany = 0; | 2347 | int howmany = 0; |
2267 | u32 lstatus; | 2348 | u32 lstatus; |
2349 | size_t buflen; | ||
2350 | union skb_shared_tx *shtx; | ||
2268 | 2351 | ||
2269 | rx_queue = priv->rx_queue[tx_queue->qindex]; | 2352 | rx_queue = priv->rx_queue[tx_queue->qindex]; |
2270 | bdp = tx_queue->dirty_tx; | 2353 | bdp = tx_queue->dirty_tx; |
@@ -2274,7 +2357,18 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2274 | unsigned long flags; | 2357 | unsigned long flags; |
2275 | 2358 | ||
2276 | frags = skb_shinfo(skb)->nr_frags; | 2359 | frags = skb_shinfo(skb)->nr_frags; |
2277 | lbdp = skip_txbd(bdp, frags, base, tx_ring_size); | 2360 | |
2361 | /* | ||
2362 | * When time stamping, one additional TxBD must be freed. | ||
2363 | * Also, we need to dma_unmap_single() the TxPAL. | ||
2364 | */ | ||
2365 | shtx = skb_tx(skb); | ||
2366 | if (unlikely(shtx->in_progress)) | ||
2367 | nr_txbds = frags + 2; | ||
2368 | else | ||
2369 | nr_txbds = frags + 1; | ||
2370 | |||
2371 | lbdp = skip_txbd(bdp, nr_txbds - 1, base, tx_ring_size); | ||
2278 | 2372 | ||
2279 | lstatus = lbdp->lstatus; | 2373 | lstatus = lbdp->lstatus; |
2280 | 2374 | ||
@@ -2283,10 +2377,24 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2283 | (lstatus & BD_LENGTH_MASK)) | 2377 | (lstatus & BD_LENGTH_MASK)) |
2284 | break; | 2378 | break; |
2285 | 2379 | ||
2286 | dma_unmap_single(&priv->ofdev->dev, | 2380 | if (unlikely(shtx->in_progress)) { |
2287 | bdp->bufPtr, | 2381 | next = next_txbd(bdp, base, tx_ring_size); |
2288 | bdp->length, | 2382 | buflen = next->length + GMAC_FCB_LEN; |
2289 | DMA_TO_DEVICE); | 2383 | } else |
2384 | buflen = bdp->length; | ||
2385 | |||
2386 | dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr, | ||
2387 | buflen, DMA_TO_DEVICE); | ||
2388 | |||
2389 | if (unlikely(shtx->in_progress)) { | ||
2390 | struct skb_shared_hwtstamps shhwtstamps; | ||
2391 | u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7); | ||
2392 | memset(&shhwtstamps, 0, sizeof(shhwtstamps)); | ||
2393 | shhwtstamps.hwtstamp = ns_to_ktime(*ns); | ||
2394 | skb_tstamp_tx(skb, &shhwtstamps); | ||
2395 | bdp->lstatus &= BD_LFLAG(TXBD_WRAP); | ||
2396 | bdp = next; | ||
2397 | } | ||
2290 | 2398 | ||
2291 | bdp->lstatus &= BD_LFLAG(TXBD_WRAP); | 2399 | bdp->lstatus &= BD_LFLAG(TXBD_WRAP); |
2292 | bdp = next_txbd(bdp, base, tx_ring_size); | 2400 | bdp = next_txbd(bdp, base, tx_ring_size); |
@@ -2318,7 +2426,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) | |||
2318 | 2426 | ||
2319 | howmany++; | 2427 | howmany++; |
2320 | spin_lock_irqsave(&tx_queue->txlock, flags); | 2428 | spin_lock_irqsave(&tx_queue->txlock, flags); |
2321 | tx_queue->num_txbdfree += frags + 1; | 2429 | tx_queue->num_txbdfree += nr_txbds; |
2322 | spin_unlock_irqrestore(&tx_queue->txlock, flags); | 2430 | spin_unlock_irqrestore(&tx_queue->txlock, flags); |
2323 | } | 2431 | } |
2324 | 2432 | ||
@@ -2474,6 +2582,17 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, | |||
2474 | skb_pull(skb, amount_pull); | 2582 | skb_pull(skb, amount_pull); |
2475 | } | 2583 | } |
2476 | 2584 | ||
2585 | /* Get receive timestamp from the skb */ | ||
2586 | if (priv->hwts_rx_en) { | ||
2587 | struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); | ||
2588 | u64 *ns = (u64 *) skb->data; | ||
2589 | memset(shhwtstamps, 0, sizeof(*shhwtstamps)); | ||
2590 | shhwtstamps->hwtstamp = ns_to_ktime(*ns); | ||
2591 | } | ||
2592 | |||
2593 | if (priv->padding) | ||
2594 | skb_pull(skb, priv->padding); | ||
2595 | |||
2477 | if (priv->rx_csum_enable) | 2596 | if (priv->rx_csum_enable) |
2478 | gfar_rx_checksum(skb, fcb); | 2597 | gfar_rx_checksum(skb, fcb); |
2479 | 2598 | ||
@@ -2510,8 +2629,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit) | |||
2510 | bdp = rx_queue->cur_rx; | 2629 | bdp = rx_queue->cur_rx; |
2511 | base = rx_queue->rx_bd_base; | 2630 | base = rx_queue->rx_bd_base; |
2512 | 2631 | ||
2513 | amount_pull = (gfar_uses_fcb(priv) ? GMAC_FCB_LEN : 0) + | 2632 | amount_pull = (gfar_uses_fcb(priv) ? GMAC_FCB_LEN : 0); |
2514 | priv->padding; | ||
2515 | 2633 | ||
2516 | while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) { | 2634 | while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) { |
2517 | struct sk_buff *newskb; | 2635 | struct sk_buff *newskb; |
@@ -2798,7 +2916,7 @@ static void adjust_link(struct net_device *dev) | |||
2798 | * whenever dev->flags is changed */ | 2916 | * whenever dev->flags is changed */ |
2799 | static void gfar_set_multi(struct net_device *dev) | 2917 | static void gfar_set_multi(struct net_device *dev) |
2800 | { | 2918 | { |
2801 | struct dev_mc_list *mc_ptr; | 2919 | struct netdev_hw_addr *ha; |
2802 | struct gfar_private *priv = netdev_priv(dev); | 2920 | struct gfar_private *priv = netdev_priv(dev); |
2803 | struct gfar __iomem *regs = priv->gfargrp[0].regs; | 2921 | struct gfar __iomem *regs = priv->gfargrp[0].regs; |
2804 | u32 tempval; | 2922 | u32 tempval; |
@@ -2871,17 +2989,14 @@ static void gfar_set_multi(struct net_device *dev) | |||
2871 | return; | 2989 | return; |
2872 | 2990 | ||
2873 | /* Parse the list, and set the appropriate bits */ | 2991 | /* Parse the list, and set the appropriate bits */ |
2874 | netdev_for_each_mc_addr(mc_ptr, dev) { | 2992 | netdev_for_each_mc_addr(ha, dev) { |
2875 | if (idx < em_num) { | 2993 | if (idx < em_num) { |
2876 | gfar_set_mac_for_addr(dev, idx, | 2994 | gfar_set_mac_for_addr(dev, idx, ha->addr); |
2877 | mc_ptr->dmi_addr); | ||
2878 | idx++; | 2995 | idx++; |
2879 | } else | 2996 | } else |
2880 | gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr); | 2997 | gfar_set_hash_for_addr(dev, ha->addr); |
2881 | } | 2998 | } |
2882 | } | 2999 | } |
2883 | |||
2884 | return; | ||
2885 | } | 3000 | } |
2886 | 3001 | ||
2887 | 3002 | ||
@@ -2922,8 +3037,6 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr) | |||
2922 | tempval = gfar_read(priv->hash_regs[whichreg]); | 3037 | tempval = gfar_read(priv->hash_regs[whichreg]); |
2923 | tempval |= value; | 3038 | tempval |= value; |
2924 | gfar_write(priv->hash_regs[whichreg], tempval); | 3039 | gfar_write(priv->hash_regs[whichreg], tempval); |
2925 | |||
2926 | return; | ||
2927 | } | 3040 | } |
2928 | 3041 | ||
2929 | 3042 | ||
@@ -3062,8 +3175,6 @@ static struct of_platform_driver gfar_driver = { | |||
3062 | }, | 3175 | }, |
3063 | .probe = gfar_probe, | 3176 | .probe = gfar_probe, |
3064 | .remove = gfar_remove, | 3177 | .remove = gfar_remove, |
3065 | .suspend = gfar_legacy_suspend, | ||
3066 | .resume = gfar_legacy_resume, | ||
3067 | }; | 3178 | }; |
3068 | 3179 | ||
3069 | static int __init gfar_init(void) | 3180 | static int __init gfar_init(void) |