aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/fs_enet/fs_enet-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/fs_enet/fs_enet-main.c')
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c93
1 files changed, 69 insertions, 24 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index ec2f5034457f..0770e2f6da6b 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -108,9 +108,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
108 * the last indicator should be set. 108 * the last indicator should be set.
109 */ 109 */
110 if ((sc & BD_ENET_RX_LAST) == 0) 110 if ((sc & BD_ENET_RX_LAST) == 0)
111 printk(KERN_WARNING DRV_MODULE_NAME 111 dev_warn(fep->dev, "rcv is not +last\n");
112 ": %s rcv is not +last\n",
113 dev->name);
114 112
115 /* 113 /*
116 * Check for errors. 114 * Check for errors.
@@ -178,9 +176,8 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget)
178 received++; 176 received++;
179 netif_receive_skb(skb); 177 netif_receive_skb(skb);
180 } else { 178 } else {
181 printk(KERN_WARNING DRV_MODULE_NAME 179 dev_warn(fep->dev,
182 ": %s Memory squeeze, dropping packet.\n", 180 "Memory squeeze, dropping packet.\n");
183 dev->name);
184 fep->stats.rx_dropped++; 181 fep->stats.rx_dropped++;
185 skbn = skb; 182 skbn = skb;
186 } 183 }
@@ -242,9 +239,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
242 * the last indicator should be set. 239 * the last indicator should be set.
243 */ 240 */
244 if ((sc & BD_ENET_RX_LAST) == 0) 241 if ((sc & BD_ENET_RX_LAST) == 0)
245 printk(KERN_WARNING DRV_MODULE_NAME 242 dev_warn(fep->dev, "rcv is not +last\n");
246 ": %s rcv is not +last\n",
247 dev->name);
248 243
249 /* 244 /*
250 * Check for errors. 245 * Check for errors.
@@ -313,9 +308,8 @@ static int fs_enet_rx_non_napi(struct net_device *dev)
313 received++; 308 received++;
314 netif_rx(skb); 309 netif_rx(skb);
315 } else { 310 } else {
316 printk(KERN_WARNING DRV_MODULE_NAME 311 dev_warn(fep->dev,
317 ": %s Memory squeeze, dropping packet.\n", 312 "Memory squeeze, dropping packet.\n");
318 dev->name);
319 fep->stats.rx_dropped++; 313 fep->stats.rx_dropped++;
320 skbn = skb; 314 skbn = skb;
321 } 315 }
@@ -388,10 +382,10 @@ static void fs_enet_tx(struct net_device *dev)
388 } else 382 } else
389 fep->stats.tx_packets++; 383 fep->stats.tx_packets++;
390 384
391 if (sc & BD_ENET_TX_READY) 385 if (sc & BD_ENET_TX_READY) {
392 printk(KERN_WARNING DRV_MODULE_NAME 386 dev_warn(fep->dev,
393 ": %s HEY! Enet xmit interrupt and TX_READY.\n", 387 "HEY! Enet xmit interrupt and TX_READY.\n");
394 dev->name); 388 }
395 389
396 /* 390 /*
397 * Deferred means some collisions occurred during transmit, 391 * Deferred means some collisions occurred during transmit,
@@ -511,9 +505,8 @@ void fs_init_bds(struct net_device *dev)
511 for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { 505 for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) {
512 skb = dev_alloc_skb(ENET_RX_FRSIZE); 506 skb = dev_alloc_skb(ENET_RX_FRSIZE);
513 if (skb == NULL) { 507 if (skb == NULL) {
514 printk(KERN_WARNING DRV_MODULE_NAME 508 dev_warn(fep->dev,
515 ": %s Memory squeeze, unable to allocate skb\n", 509 "Memory squeeze, unable to allocate skb\n");
516 dev->name);
517 break; 510 break;
518 } 511 }
519 skb_align(skb, ENET_RX_ALIGN); 512 skb_align(skb, ENET_RX_ALIGN);
@@ -587,6 +580,40 @@ void fs_cleanup_bds(struct net_device *dev)
587 580
588/**********************************************************************************/ 581/**********************************************************************************/
589 582
583#ifdef CONFIG_FS_ENET_MPC5121_FEC
584/*
585 * MPC5121 FEC requeries 4-byte alignment for TX data buffer!
586 */
587static struct sk_buff *tx_skb_align_workaround(struct net_device *dev,
588 struct sk_buff *skb)
589{
590 struct sk_buff *new_skb;
591 struct fs_enet_private *fep = netdev_priv(dev);
592
593 /* Alloc new skb */
594 new_skb = dev_alloc_skb(skb->len + 4);
595 if (!new_skb) {
596 if (net_ratelimit()) {
597 dev_warn(fep->dev,
598 "Memory squeeze, dropping tx packet.\n");
599 }
600 return NULL;
601 }
602
603 /* Make sure new skb is properly aligned */
604 skb_align(new_skb, 4);
605
606 /* Copy data to new skb ... */
607 skb_copy_from_linear_data(skb, new_skb->data, skb->len);
608 skb_put(new_skb, skb->len);
609
610 /* ... and free an old one */
611 dev_kfree_skb_any(skb);
612
613 return new_skb;
614}
615#endif
616
590static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) 617static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
591{ 618{
592 struct fs_enet_private *fep = netdev_priv(dev); 619 struct fs_enet_private *fep = netdev_priv(dev);
@@ -595,6 +622,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
595 u16 sc; 622 u16 sc;
596 unsigned long flags; 623 unsigned long flags;
597 624
625#ifdef CONFIG_FS_ENET_MPC5121_FEC
626 if (((unsigned long)skb->data) & 0x3) {
627 skb = tx_skb_align_workaround(dev, skb);
628 if (!skb) {
629 /*
630 * We have lost packet due to memory allocation error
631 * in tx_skb_align_workaround(). Hopefully original
632 * skb is still valid, so try transmit it later.
633 */
634 return NETDEV_TX_BUSY;
635 }
636 }
637#endif
598 spin_lock_irqsave(&fep->tx_lock, flags); 638 spin_lock_irqsave(&fep->tx_lock, flags);
599 639
600 /* 640 /*
@@ -610,8 +650,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
610 * Ooops. All transmit buffers are full. Bail out. 650 * Ooops. All transmit buffers are full. Bail out.
611 * This should not happen, since the tx queue should be stopped. 651 * This should not happen, since the tx queue should be stopped.
612 */ 652 */
613 printk(KERN_WARNING DRV_MODULE_NAME 653 dev_warn(fep->dev, "tx queue full!.\n");
614 ": %s tx queue full!.\n", dev->name);
615 return NETDEV_TX_BUSY; 654 return NETDEV_TX_BUSY;
616 } 655 }
617 656
@@ -788,8 +827,7 @@ static int fs_enet_open(struct net_device *dev)
788 r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED, 827 r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED,
789 "fs_enet-mac", dev); 828 "fs_enet-mac", dev);
790 if (r != 0) { 829 if (r != 0) {
791 printk(KERN_ERR DRV_MODULE_NAME 830 dev_err(fep->dev, "Could not allocate FS_ENET IRQ!");
792 ": %s Could not allocate FS_ENET IRQ!", dev->name);
793 if (fep->fpi->use_napi) 831 if (fep->fpi->use_napi)
794 napi_disable(&fep->napi); 832 napi_disable(&fep->napi);
795 return -EINVAL; 833 return -EINVAL;
@@ -1053,7 +1091,7 @@ static int __devinit fs_enet_probe(struct of_device *ofdev,
1053 if (ret) 1091 if (ret)
1054 goto out_free_bd; 1092 goto out_free_bd;
1055 1093
1056 printk(KERN_INFO "%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr); 1094 pr_info("%s: fs_enet: %pM\n", ndev->name, ndev->dev_addr);
1057 1095
1058 return 0; 1096 return 0;
1059 1097
@@ -1103,11 +1141,18 @@ static struct of_device_id fs_enet_match[] = {
1103 }, 1141 },
1104#endif 1142#endif
1105#ifdef CONFIG_FS_ENET_HAS_FEC 1143#ifdef CONFIG_FS_ENET_HAS_FEC
1144#ifdef CONFIG_FS_ENET_MPC5121_FEC
1145 {
1146 .compatible = "fsl,mpc5121-fec",
1147 .data = (void *)&fs_fec_ops,
1148 },
1149#else
1106 { 1150 {
1107 .compatible = "fsl,pq1-fec-enet", 1151 .compatible = "fsl,pq1-fec-enet",
1108 .data = (void *)&fs_fec_ops, 1152 .data = (void *)&fs_fec_ops,
1109 }, 1153 },
1110#endif 1154#endif
1155#endif
1111 {} 1156 {}
1112}; 1157};
1113MODULE_DEVICE_TABLE(of, fs_enet_match); 1158MODULE_DEVICE_TABLE(of, fs_enet_match);