aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/gianfar.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r--drivers/net/gianfar.c159
1 files changed, 89 insertions, 70 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 4f7c3f3ca234..dfa55f94ba7f 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -10,7 +10,7 @@
10 * Maintainer: Kumar Gala 10 * Maintainer: Kumar Gala
11 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> 11 * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com>
12 * 12 *
13 * Copyright 2002-2009 Freescale Semiconductor, Inc. 13 * Copyright 2002-2009, 2011 Freescale Semiconductor, Inc.
14 * Copyright 2007 MontaVista Software, Inc. 14 * Copyright 2007 MontaVista Software, Inc.
15 * 15 *
16 * This program is free software; you can redistribute it and/or modify it 16 * This program is free software; you can redistribute it and/or modify it
@@ -95,6 +95,7 @@
95#include <linux/phy.h> 95#include <linux/phy.h>
96#include <linux/phy_fixed.h> 96#include <linux/phy_fixed.h>
97#include <linux/of.h> 97#include <linux/of.h>
98#include <linux/of_net.h>
98 99
99#include "gianfar.h" 100#include "gianfar.h"
100#include "fsl_pq_mdio.h" 101#include "fsl_pq_mdio.h"
@@ -122,8 +123,7 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id);
122static void adjust_link(struct net_device *dev); 123static void adjust_link(struct net_device *dev);
123static void init_registers(struct net_device *dev); 124static void init_registers(struct net_device *dev);
124static int init_phy(struct net_device *dev); 125static int init_phy(struct net_device *dev);
125static int gfar_probe(struct platform_device *ofdev, 126static int gfar_probe(struct platform_device *ofdev);
126 const struct of_device_id *match);
127static int gfar_remove(struct platform_device *ofdev); 127static int gfar_remove(struct platform_device *ofdev);
128static void free_skb_resources(struct gfar_private *priv); 128static void free_skb_resources(struct gfar_private *priv);
129static void gfar_set_multi(struct net_device *dev); 129static void gfar_set_multi(struct net_device *dev);
@@ -143,7 +143,8 @@ void gfar_halt(struct net_device *dev);
143static void gfar_halt_nodisable(struct net_device *dev); 143static void gfar_halt_nodisable(struct net_device *dev);
144void gfar_start(struct net_device *dev); 144void gfar_start(struct net_device *dev);
145static void gfar_clear_exact_match(struct net_device *dev); 145static void gfar_clear_exact_match(struct net_device *dev);
146static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr); 146static void gfar_set_mac_for_addr(struct net_device *dev, int num,
147 const u8 *addr);
147static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 148static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
148 149
149MODULE_AUTHOR("Freescale Semiconductor, Inc"); 150MODULE_AUTHOR("Freescale Semiconductor, Inc");
@@ -364,7 +365,7 @@ static void gfar_init_mac(struct net_device *ndev)
364 gfar_write(&regs->rir0, DEFAULT_RIR0); 365 gfar_write(&regs->rir0, DEFAULT_RIR0);
365 } 366 }
366 367
367 if (priv->rx_csum_enable) 368 if (ndev->features & NETIF_F_RXCSUM)
368 rctrl |= RCTRL_CHECKSUMMING; 369 rctrl |= RCTRL_CHECKSUMMING;
369 370
370 if (priv->extended_hash) { 371 if (priv->extended_hash) {
@@ -432,7 +433,6 @@ static void gfar_init_mac(struct net_device *ndev)
432static struct net_device_stats *gfar_get_stats(struct net_device *dev) 433static struct net_device_stats *gfar_get_stats(struct net_device *dev)
433{ 434{
434 struct gfar_private *priv = netdev_priv(dev); 435 struct gfar_private *priv = netdev_priv(dev);
435 struct netdev_queue *txq;
436 unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0; 436 unsigned long rx_packets = 0, rx_bytes = 0, rx_dropped = 0;
437 unsigned long tx_packets = 0, tx_bytes = 0; 437 unsigned long tx_packets = 0, tx_bytes = 0;
438 int i = 0; 438 int i = 0;
@@ -448,9 +448,8 @@ static struct net_device_stats *gfar_get_stats(struct net_device *dev)
448 dev->stats.rx_dropped = rx_dropped; 448 dev->stats.rx_dropped = rx_dropped;
449 449
450 for (i = 0; i < priv->num_tx_queues; i++) { 450 for (i = 0; i < priv->num_tx_queues; i++) {
451 txq = netdev_get_tx_queue(dev, i); 451 tx_bytes += priv->tx_queue[i]->stats.tx_bytes;
452 tx_bytes += txq->tx_bytes; 452 tx_packets += priv->tx_queue[i]->stats.tx_packets;
453 tx_packets += txq->tx_packets;
454 } 453 }
455 454
456 dev->stats.tx_bytes = tx_bytes; 455 dev->stats.tx_bytes = tx_bytes;
@@ -464,6 +463,7 @@ static const struct net_device_ops gfar_netdev_ops = {
464 .ndo_start_xmit = gfar_start_xmit, 463 .ndo_start_xmit = gfar_start_xmit,
465 .ndo_stop = gfar_close, 464 .ndo_stop = gfar_close,
466 .ndo_change_mtu = gfar_change_mtu, 465 .ndo_change_mtu = gfar_change_mtu,
466 .ndo_set_features = gfar_set_features,
467 .ndo_set_multicast_list = gfar_set_multi, 467 .ndo_set_multicast_list = gfar_set_multi,
468 .ndo_tx_timeout = gfar_timeout, 468 .ndo_tx_timeout = gfar_timeout,
469 .ndo_do_ioctl = gfar_ioctl, 469 .ndo_do_ioctl = gfar_ioctl,
@@ -476,9 +476,6 @@ static const struct net_device_ops gfar_netdev_ops = {
476#endif 476#endif
477}; 477};
478 478
479unsigned int ftp_rqfpr[MAX_FILER_IDX + 1];
480unsigned int ftp_rqfcr[MAX_FILER_IDX + 1];
481
482void lock_rx_qs(struct gfar_private *priv) 479void lock_rx_qs(struct gfar_private *priv)
483{ 480{
484 int i = 0x0; 481 int i = 0x0;
@@ -514,7 +511,7 @@ void unlock_tx_qs(struct gfar_private *priv)
514/* Returns 1 if incoming frames use an FCB */ 511/* Returns 1 if incoming frames use an FCB */
515static inline int gfar_uses_fcb(struct gfar_private *priv) 512static inline int gfar_uses_fcb(struct gfar_private *priv)
516{ 513{
517 return priv->vlgrp || priv->rx_csum_enable || 514 return priv->vlgrp || (priv->ndev->features & NETIF_F_RXCSUM) ||
518 (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER); 515 (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER);
519} 516}
520 517
@@ -577,11 +574,10 @@ static int gfar_parse_group(struct device_node *np,
577 irq_of_parse_and_map(np, 1); 574 irq_of_parse_and_map(np, 1);
578 priv->gfargrp[priv->num_grps].interruptError = 575 priv->gfargrp[priv->num_grps].interruptError =
579 irq_of_parse_and_map(np,2); 576 irq_of_parse_and_map(np,2);
580 if (priv->gfargrp[priv->num_grps].interruptTransmit < 0 || 577 if (priv->gfargrp[priv->num_grps].interruptTransmit == NO_IRQ ||
581 priv->gfargrp[priv->num_grps].interruptReceive < 0 || 578 priv->gfargrp[priv->num_grps].interruptReceive == NO_IRQ ||
582 priv->gfargrp[priv->num_grps].interruptError < 0) { 579 priv->gfargrp[priv->num_grps].interruptError == NO_IRQ)
583 return -EINVAL; 580 return -EINVAL;
584 }
585 } 581 }
586 582
587 priv->gfargrp[priv->num_grps].grp_id = priv->num_grps; 583 priv->gfargrp[priv->num_grps].grp_id = priv->num_grps;
@@ -654,9 +650,8 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
654 priv->node = ofdev->dev.of_node; 650 priv->node = ofdev->dev.of_node;
655 priv->ndev = dev; 651 priv->ndev = dev;
656 652
657 dev->num_tx_queues = num_tx_qs;
658 dev->real_num_tx_queues = num_tx_qs;
659 priv->num_tx_queues = num_tx_qs; 653 priv->num_tx_queues = num_tx_qs;
654 netif_set_real_num_rx_queues(dev, num_rx_qs);
660 priv->num_rx_queues = num_rx_qs; 655 priv->num_rx_queues = num_rx_qs;
661 priv->num_grps = 0x0; 656 priv->num_grps = 0x0;
662 657
@@ -870,28 +865,28 @@ static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar,
870 865
871 rqfar--; 866 rqfar--;
872 rqfcr = RQFCR_CLE | RQFCR_PID_MASK | RQFCR_CMP_EXACT; 867 rqfcr = RQFCR_CLE | RQFCR_PID_MASK | RQFCR_CMP_EXACT;
873 ftp_rqfpr[rqfar] = rqfpr; 868 priv->ftp_rqfpr[rqfar] = rqfpr;
874 ftp_rqfcr[rqfar] = rqfcr; 869 priv->ftp_rqfcr[rqfar] = rqfcr;
875 gfar_write_filer(priv, rqfar, rqfcr, rqfpr); 870 gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
876 871
877 rqfar--; 872 rqfar--;
878 rqfcr = RQFCR_CMP_NOMATCH; 873 rqfcr = RQFCR_CMP_NOMATCH;
879 ftp_rqfpr[rqfar] = rqfpr; 874 priv->ftp_rqfpr[rqfar] = rqfpr;
880 ftp_rqfcr[rqfar] = rqfcr; 875 priv->ftp_rqfcr[rqfar] = rqfcr;
881 gfar_write_filer(priv, rqfar, rqfcr, rqfpr); 876 gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
882 877
883 rqfar--; 878 rqfar--;
884 rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_PARSE | RQFCR_CLE | RQFCR_AND; 879 rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_PARSE | RQFCR_CLE | RQFCR_AND;
885 rqfpr = class; 880 rqfpr = class;
886 ftp_rqfcr[rqfar] = rqfcr; 881 priv->ftp_rqfcr[rqfar] = rqfcr;
887 ftp_rqfpr[rqfar] = rqfpr; 882 priv->ftp_rqfpr[rqfar] = rqfpr;
888 gfar_write_filer(priv, rqfar, rqfcr, rqfpr); 883 gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
889 884
890 rqfar--; 885 rqfar--;
891 rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_MASK | RQFCR_AND; 886 rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_MASK | RQFCR_AND;
892 rqfpr = class; 887 rqfpr = class;
893 ftp_rqfcr[rqfar] = rqfcr; 888 priv->ftp_rqfcr[rqfar] = rqfcr;
894 ftp_rqfpr[rqfar] = rqfpr; 889 priv->ftp_rqfpr[rqfar] = rqfpr;
895 gfar_write_filer(priv, rqfar, rqfcr, rqfpr); 890 gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
896 891
897 return rqfar; 892 return rqfar;
@@ -906,8 +901,8 @@ static void gfar_init_filer_table(struct gfar_private *priv)
906 901
907 /* Default rule */ 902 /* Default rule */
908 rqfcr = RQFCR_CMP_MATCH; 903 rqfcr = RQFCR_CMP_MATCH;
909 ftp_rqfcr[rqfar] = rqfcr; 904 priv->ftp_rqfcr[rqfar] = rqfcr;
910 ftp_rqfpr[rqfar] = rqfpr; 905 priv->ftp_rqfpr[rqfar] = rqfpr;
911 gfar_write_filer(priv, rqfar, rqfcr, rqfpr); 906 gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
912 907
913 rqfar = cluster_entry_per_class(priv, rqfar, RQFPR_IPV6); 908 rqfar = cluster_entry_per_class(priv, rqfar, RQFPR_IPV6);
@@ -923,8 +918,8 @@ static void gfar_init_filer_table(struct gfar_private *priv)
923 /* Rest are masked rules */ 918 /* Rest are masked rules */
924 rqfcr = RQFCR_CMP_NOMATCH; 919 rqfcr = RQFCR_CMP_NOMATCH;
925 for (i = 0; i < rqfar; i++) { 920 for (i = 0; i < rqfar; i++) {
926 ftp_rqfcr[i] = rqfcr; 921 priv->ftp_rqfcr[i] = rqfcr;
927 ftp_rqfpr[i] = rqfpr; 922 priv->ftp_rqfpr[i] = rqfpr;
928 gfar_write_filer(priv, i, rqfcr, rqfpr); 923 gfar_write_filer(priv, i, rqfcr, rqfpr);
929 } 924 }
930} 925}
@@ -952,6 +947,11 @@ static void gfar_detect_errata(struct gfar_private *priv)
952 (pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0)) 947 (pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
953 priv->errata |= GFAR_ERRATA_A002; 948 priv->errata |= GFAR_ERRATA_A002;
954 949
950 /* MPC8313 Rev < 2.0, MPC8548 rev 2.0 */
951 if ((pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020) ||
952 (pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020))
953 priv->errata |= GFAR_ERRATA_12;
954
955 if (priv->errata) 955 if (priv->errata)
956 dev_info(dev, "enabled errata workarounds, flags: 0x%x\n", 956 dev_info(dev, "enabled errata workarounds, flags: 0x%x\n",
957 priv->errata); 957 priv->errata);
@@ -959,8 +959,7 @@ static void gfar_detect_errata(struct gfar_private *priv)
959 959
960/* Set up the ethernet device structure, private data, 960/* Set up the ethernet device structure, private data,
961 * and anything else we need before we start */ 961 * and anything else we need before we start */
962static int gfar_probe(struct platform_device *ofdev, 962static int gfar_probe(struct platform_device *ofdev)
963 const struct of_device_id *match)
964{ 963{
965 u32 tempval; 964 u32 tempval;
966 struct net_device *dev = NULL; 965 struct net_device *dev = NULL;
@@ -1029,10 +1028,11 @@ static int gfar_probe(struct platform_device *ofdev,
1029 netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT); 1028 netif_napi_add(dev, &priv->gfargrp[i].napi, gfar_poll, GFAR_DEV_WEIGHT);
1030 1029
1031 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) { 1030 if (priv->device_flags & FSL_GIANFAR_DEV_HAS_CSUM) {
1032 priv->rx_csum_enable = 1; 1031 dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
1033 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; 1032 NETIF_F_RXCSUM;
1034 } else 1033 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG |
1035 priv->rx_csum_enable = 0; 1034 NETIF_F_RXCSUM | NETIF_F_HIGHDMA;
1035 }
1036 1036
1037 priv->vlgrp = NULL; 1037 priv->vlgrp = NULL;
1038 1038
@@ -1859,7 +1859,7 @@ static int register_grp_irqs(struct gfar_priv_grp *grp)
1859 printk(KERN_ERR "%s: Can't get IRQ %d\n", 1859 printk(KERN_ERR "%s: Can't get IRQ %d\n",
1860 dev->name, grp->interruptError); 1860 dev->name, grp->interruptError);
1861 1861
1862 goto err_irq_fail; 1862 goto err_irq_fail;
1863 } 1863 }
1864 1864
1865 if ((err = request_irq(grp->interruptTransmit, gfar_transmit, 1865 if ((err = request_irq(grp->interruptTransmit, gfar_transmit,
@@ -1922,7 +1922,7 @@ int startup_gfar(struct net_device *ndev)
1922 if (err) { 1922 if (err) {
1923 for (j = 0; j < i; j++) 1923 for (j = 0; j < i; j++)
1924 free_grp_irqs(&priv->gfargrp[j]); 1924 free_grp_irqs(&priv->gfargrp[j]);
1925 goto irq_fail; 1925 goto irq_fail;
1926 } 1926 }
1927 } 1927 }
1928 1928
@@ -2048,7 +2048,6 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2048 u32 bufaddr; 2048 u32 bufaddr;
2049 unsigned long flags; 2049 unsigned long flags;
2050 unsigned int nr_frags, nr_txbds, length; 2050 unsigned int nr_frags, nr_txbds, length;
2051 union skb_shared_tx *shtx;
2052 2051
2053 /* 2052 /*
2054 * TOE=1 frames larger than 2500 bytes may see excess delays 2053 * TOE=1 frames larger than 2500 bytes may see excess delays
@@ -2069,15 +2068,15 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2069 txq = netdev_get_tx_queue(dev, rq); 2068 txq = netdev_get_tx_queue(dev, rq);
2070 base = tx_queue->tx_bd_base; 2069 base = tx_queue->tx_bd_base;
2071 regs = tx_queue->grp->regs; 2070 regs = tx_queue->grp->regs;
2072 shtx = skb_tx(skb);
2073 2071
2074 /* check if time stamp should be generated */ 2072 /* check if time stamp should be generated */
2075 if (unlikely(shtx->hardware && priv->hwts_tx_en)) 2073 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
2074 priv->hwts_tx_en))
2076 do_tstamp = 1; 2075 do_tstamp = 1;
2077 2076
2078 /* make space for additional header when fcb is needed */ 2077 /* make space for additional header when fcb is needed */
2079 if (((skb->ip_summed == CHECKSUM_PARTIAL) || 2078 if (((skb->ip_summed == CHECKSUM_PARTIAL) ||
2080 (priv->vlgrp && vlan_tx_tag_present(skb)) || 2079 vlan_tx_tag_present(skb) ||
2081 unlikely(do_tstamp)) && 2080 unlikely(do_tstamp)) &&
2082 (skb_headroom(skb) < GMAC_FCB_LEN)) { 2081 (skb_headroom(skb) < GMAC_FCB_LEN)) {
2083 struct sk_buff *skb_new; 2082 struct sk_buff *skb_new;
@@ -2110,8 +2109,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2110 } 2109 }
2111 2110
2112 /* Update transmit stats */ 2111 /* Update transmit stats */
2113 txq->tx_bytes += skb->len; 2112 tx_queue->stats.tx_bytes += skb->len;
2114 txq->tx_packets ++; 2113 tx_queue->stats.tx_packets++;
2115 2114
2116 txbdp = txbdp_start = tx_queue->cur_tx; 2115 txbdp = txbdp_start = tx_queue->cur_tx;
2117 lstatus = txbdp->lstatus; 2116 lstatus = txbdp->lstatus;
@@ -2159,11 +2158,18 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2159 /* Set up checksumming */ 2158 /* Set up checksumming */
2160 if (CHECKSUM_PARTIAL == skb->ip_summed) { 2159 if (CHECKSUM_PARTIAL == skb->ip_summed) {
2161 fcb = gfar_add_fcb(skb); 2160 fcb = gfar_add_fcb(skb);
2162 lstatus |= BD_LFLAG(TXBD_TOE); 2161 /* as specified by errata */
2163 gfar_tx_checksum(skb, fcb); 2162 if (unlikely(gfar_has_errata(priv, GFAR_ERRATA_12)
2163 && ((unsigned long)fcb % 0x20) > 0x18)) {
2164 __skb_pull(skb, GMAC_FCB_LEN);
2165 skb_checksum_help(skb);
2166 } else {
2167 lstatus |= BD_LFLAG(TXBD_TOE);
2168 gfar_tx_checksum(skb, fcb);
2169 }
2164 } 2170 }
2165 2171
2166 if (priv->vlgrp && vlan_tx_tag_present(skb)) { 2172 if (vlan_tx_tag_present(skb)) {
2167 if (unlikely(NULL == fcb)) { 2173 if (unlikely(NULL == fcb)) {
2168 fcb = gfar_add_fcb(skb); 2174 fcb = gfar_add_fcb(skb);
2169 lstatus |= BD_LFLAG(TXBD_TOE); 2175 lstatus |= BD_LFLAG(TXBD_TOE);
@@ -2174,7 +2180,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2174 2180
2175 /* Setup tx hardware time stamping if requested */ 2181 /* Setup tx hardware time stamping if requested */
2176 if (unlikely(do_tstamp)) { 2182 if (unlikely(do_tstamp)) {
2177 shtx->in_progress = 1; 2183 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
2178 if (fcb == NULL) 2184 if (fcb == NULL)
2179 fcb = gfar_add_fcb(skb); 2185 fcb = gfar_add_fcb(skb);
2180 fcb->ptp = 1; 2186 fcb->ptp = 1;
@@ -2283,6 +2289,23 @@ static int gfar_set_mac_address(struct net_device *dev)
2283 return 0; 2289 return 0;
2284} 2290}
2285 2291
2292/* Check if rx parser should be activated */
2293void gfar_check_rx_parser_mode(struct gfar_private *priv)
2294{
2295 struct gfar __iomem *regs;
2296 u32 tempval;
2297
2298 regs = priv->gfargrp[0].regs;
2299
2300 tempval = gfar_read(&regs->rctrl);
2301 /* If parse is no longer required, then disable parser */
2302 if (tempval & RCTRL_REQ_PARSER)
2303 tempval |= RCTRL_PRSDEP_INIT;
2304 else
2305 tempval &= ~RCTRL_PRSDEP_INIT;
2306 gfar_write(&regs->rctrl, tempval);
2307}
2308
2286 2309
2287/* Enables and disables VLAN insertion/extraction */ 2310/* Enables and disables VLAN insertion/extraction */
2288static void gfar_vlan_rx_register(struct net_device *dev, 2311static void gfar_vlan_rx_register(struct net_device *dev,
@@ -2319,12 +2342,9 @@ static void gfar_vlan_rx_register(struct net_device *dev,
2319 /* Disable VLAN tag extraction */ 2342 /* Disable VLAN tag extraction */
2320 tempval = gfar_read(&regs->rctrl); 2343 tempval = gfar_read(&regs->rctrl);
2321 tempval &= ~RCTRL_VLEX; 2344 tempval &= ~RCTRL_VLEX;
2322 /* If parse is no longer required, then disable parser */
2323 if (tempval & RCTRL_REQ_PARSER)
2324 tempval |= RCTRL_PRSDEP_INIT;
2325 else
2326 tempval &= ~RCTRL_PRSDEP_INIT;
2327 gfar_write(&regs->rctrl, tempval); 2345 gfar_write(&regs->rctrl, tempval);
2346
2347 gfar_check_rx_parser_mode(priv);
2328 } 2348 }
2329 2349
2330 gfar_change_mtu(dev, dev->mtu); 2350 gfar_change_mtu(dev, dev->mtu);
@@ -2446,7 +2466,6 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2446 int howmany = 0; 2466 int howmany = 0;
2447 u32 lstatus; 2467 u32 lstatus;
2448 size_t buflen; 2468 size_t buflen;
2449 union skb_shared_tx *shtx;
2450 2469
2451 rx_queue = priv->rx_queue[tx_queue->qindex]; 2470 rx_queue = priv->rx_queue[tx_queue->qindex];
2452 bdp = tx_queue->dirty_tx; 2471 bdp = tx_queue->dirty_tx;
@@ -2461,8 +2480,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2461 * When time stamping, one additional TxBD must be freed. 2480 * When time stamping, one additional TxBD must be freed.
2462 * Also, we need to dma_unmap_single() the TxPAL. 2481 * Also, we need to dma_unmap_single() the TxPAL.
2463 */ 2482 */
2464 shtx = skb_tx(skb); 2483 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS))
2465 if (unlikely(shtx->in_progress))
2466 nr_txbds = frags + 2; 2484 nr_txbds = frags + 2;
2467 else 2485 else
2468 nr_txbds = frags + 1; 2486 nr_txbds = frags + 1;
@@ -2476,7 +2494,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2476 (lstatus & BD_LENGTH_MASK)) 2494 (lstatus & BD_LENGTH_MASK))
2477 break; 2495 break;
2478 2496
2479 if (unlikely(shtx->in_progress)) { 2497 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
2480 next = next_txbd(bdp, base, tx_ring_size); 2498 next = next_txbd(bdp, base, tx_ring_size);
2481 buflen = next->length + GMAC_FCB_LEN; 2499 buflen = next->length + GMAC_FCB_LEN;
2482 } else 2500 } else
@@ -2485,7 +2503,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2485 dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr, 2503 dma_unmap_single(&priv->ofdev->dev, bdp->bufPtr,
2486 buflen, DMA_TO_DEVICE); 2504 buflen, DMA_TO_DEVICE);
2487 2505
2488 if (unlikely(shtx->in_progress)) { 2506 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
2489 struct skb_shared_hwtstamps shhwtstamps; 2507 struct skb_shared_hwtstamps shhwtstamps;
2490 u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7); 2508 u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7);
2491 memset(&shhwtstamps, 0, sizeof(shhwtstamps)); 2509 memset(&shhwtstamps, 0, sizeof(shhwtstamps));
@@ -2515,7 +2533,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2515 skb_recycle_check(skb, priv->rx_buffer_size + 2533 skb_recycle_check(skb, priv->rx_buffer_size +
2516 RXBUF_ALIGNMENT)) { 2534 RXBUF_ALIGNMENT)) {
2517 gfar_align_skb(skb); 2535 gfar_align_skb(skb);
2518 __skb_queue_head(&priv->rx_recycle, skb); 2536 skb_queue_head(&priv->rx_recycle, skb);
2519 } else 2537 } else
2520 dev_kfree_skb_any(skb); 2538 dev_kfree_skb_any(skb);
2521 2539
@@ -2598,7 +2616,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev)
2598 struct gfar_private *priv = netdev_priv(dev); 2616 struct gfar_private *priv = netdev_priv(dev);
2599 struct sk_buff *skb = NULL; 2617 struct sk_buff *skb = NULL;
2600 2618
2601 skb = __skb_dequeue(&priv->rx_recycle); 2619 skb = skb_dequeue(&priv->rx_recycle);
2602 if (!skb) 2620 if (!skb)
2603 skb = gfar_alloc_skb(dev); 2621 skb = gfar_alloc_skb(dev);
2604 2622
@@ -2657,7 +2675,7 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
2657 if ((fcb->flags & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU)) 2675 if ((fcb->flags & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU))
2658 skb->ip_summed = CHECKSUM_UNNECESSARY; 2676 skb->ip_summed = CHECKSUM_UNNECESSARY;
2659 else 2677 else
2660 skb->ip_summed = CHECKSUM_NONE; 2678 skb_checksum_none_assert(skb);
2661} 2679}
2662 2680
2663 2681
@@ -2692,7 +2710,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
2692 if (priv->padding) 2710 if (priv->padding)
2693 skb_pull(skb, priv->padding); 2711 skb_pull(skb, priv->padding);
2694 2712
2695 if (priv->rx_csum_enable) 2713 if (dev->features & NETIF_F_RXCSUM)
2696 gfar_rx_checksum(skb, fcb); 2714 gfar_rx_checksum(skb, fcb);
2697 2715
2698 /* Tell the skb what kind of packet this is */ 2716 /* Tell the skb what kind of packet this is */
@@ -2754,7 +2772,7 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
2754 if (unlikely(!newskb)) 2772 if (unlikely(!newskb))
2755 newskb = skb; 2773 newskb = skb;
2756 else if (skb) 2774 else if (skb)
2757 __skb_queue_head(&priv->rx_recycle, skb); 2775 skb_queue_head(&priv->rx_recycle, skb);
2758 } else { 2776 } else {
2759 /* Increment the number of packets */ 2777 /* Increment the number of packets */
2760 rx_queue->stats.rx_packets++; 2778 rx_queue->stats.rx_packets++;
@@ -3099,10 +3117,10 @@ static void gfar_set_multi(struct net_device *dev)
3099static void gfar_clear_exact_match(struct net_device *dev) 3117static void gfar_clear_exact_match(struct net_device *dev)
3100{ 3118{
3101 int idx; 3119 int idx;
3102 u8 zero_arr[MAC_ADDR_LEN] = {0,0,0,0,0,0}; 3120 static const u8 zero_arr[MAC_ADDR_LEN] = {0, 0, 0, 0, 0, 0};
3103 3121
3104 for(idx = 1;idx < GFAR_EM_NUM + 1;idx++) 3122 for(idx = 1;idx < GFAR_EM_NUM + 1;idx++)
3105 gfar_set_mac_for_addr(dev, idx, (u8 *)zero_arr); 3123 gfar_set_mac_for_addr(dev, idx, zero_arr);
3106} 3124}
3107 3125
3108/* Set the appropriate hash bit for the given addr */ 3126/* Set the appropriate hash bit for the given addr */
@@ -3137,7 +3155,8 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
3137/* There are multiple MAC Address register pairs on some controllers 3155/* There are multiple MAC Address register pairs on some controllers
3138 * This function sets the numth pair to a given address 3156 * This function sets the numth pair to a given address
3139 */ 3157 */
3140static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr) 3158static void gfar_set_mac_for_addr(struct net_device *dev, int num,
3159 const u8 *addr)
3141{ 3160{
3142 struct gfar_private *priv = netdev_priv(dev); 3161 struct gfar_private *priv = netdev_priv(dev);
3143 struct gfar __iomem *regs = priv->gfargrp[0].regs; 3162 struct gfar __iomem *regs = priv->gfargrp[0].regs;
@@ -3260,7 +3279,7 @@ static struct of_device_id gfar_match[] =
3260MODULE_DEVICE_TABLE(of, gfar_match); 3279MODULE_DEVICE_TABLE(of, gfar_match);
3261 3280
3262/* Structure for a device driver */ 3281/* Structure for a device driver */
3263static struct of_platform_driver gfar_driver = { 3282static struct platform_driver gfar_driver = {
3264 .driver = { 3283 .driver = {
3265 .name = "fsl-gianfar", 3284 .name = "fsl-gianfar",
3266 .owner = THIS_MODULE, 3285 .owner = THIS_MODULE,
@@ -3273,12 +3292,12 @@ static struct of_platform_driver gfar_driver = {
3273 3292
3274static int __init gfar_init(void) 3293static int __init gfar_init(void)
3275{ 3294{
3276 return of_register_platform_driver(&gfar_driver); 3295 return platform_driver_register(&gfar_driver);
3277} 3296}
3278 3297
3279static void __exit gfar_exit(void) 3298static void __exit gfar_exit(void)
3280{ 3299{
3281 of_unregister_platform_driver(&gfar_driver); 3300 platform_driver_unregister(&gfar_driver);
3282} 3301}
3283 3302
3284module_init(gfar_init); 3303module_init(gfar_init);