diff options
Diffstat (limited to 'drivers/net/fs_enet/fs_enet-main.c')
-rw-r--r-- | drivers/net/fs_enet/fs_enet-main.c | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c index 83c9bf27ecfd..dcbe83c773ee 100644 --- a/drivers/net/fs_enet/fs_enet-main.c +++ b/drivers/net/fs_enet/fs_enet-main.c | |||
@@ -1,17 +1,17 @@ | |||
1 | /* | 1 | /* |
2 | * Combined Ethernet driver for Motorola MPC8xx and MPC82xx. | 2 | * Combined Ethernet driver for Motorola MPC8xx and MPC82xx. |
3 | * | 3 | * |
4 | * Copyright (c) 2003 Intracom S.A. | 4 | * Copyright (c) 2003 Intracom S.A. |
5 | * by Pantelis Antoniou <panto@intracom.gr> | 5 | * by Pantelis Antoniou <panto@intracom.gr> |
6 | * | 6 | * |
7 | * 2005 (c) MontaVista Software, Inc. | 7 | * 2005 (c) MontaVista Software, Inc. |
8 | * Vitaly Bordug <vbordug@ru.mvista.com> | 8 | * Vitaly Bordug <vbordug@ru.mvista.com> |
9 | * | 9 | * |
10 | * Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com> | 10 | * Heavily based on original FEC driver by Dan Malek <dan@embeddededge.com> |
11 | * and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se> | 11 | * and modifications by Joakim Tjernlund <joakim.tjernlund@lumentis.se> |
12 | * | 12 | * |
13 | * This file is licensed under the terms of the GNU General Public License | 13 | * This file is licensed under the terms of the GNU General Public License |
14 | * version 2. This program is licensed "as is" without any warranty of any | 14 | * version 2. This program is licensed "as is" without any warranty of any |
15 | * kind, whether express or implied. | 15 | * kind, whether express or implied. |
16 | */ | 16 | */ |
17 | 17 | ||
@@ -59,6 +59,9 @@ module_param(fs_enet_debug, int, 0); | |||
59 | MODULE_PARM_DESC(fs_enet_debug, | 59 | MODULE_PARM_DESC(fs_enet_debug, |
60 | "Freescale bitmapped debugging message enable value"); | 60 | "Freescale bitmapped debugging message enable value"); |
61 | 61 | ||
62 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
63 | static void fs_enet_netpoll(struct net_device *dev); | ||
64 | #endif | ||
62 | 65 | ||
63 | static void fs_set_multicast_list(struct net_device *dev) | 66 | static void fs_set_multicast_list(struct net_device *dev) |
64 | { | 67 | { |
@@ -104,7 +107,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) | |||
104 | dev->name); | 107 | dev->name); |
105 | 108 | ||
106 | /* | 109 | /* |
107 | * Check for errors. | 110 | * Check for errors. |
108 | */ | 111 | */ |
109 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | | 112 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | |
110 | BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { | 113 | BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { |
@@ -181,7 +184,7 @@ static int fs_enet_rx_napi(struct napi_struct *napi, int budget) | |||
181 | CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); | 184 | CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); |
182 | 185 | ||
183 | /* | 186 | /* |
184 | * Update BD pointer to next entry. | 187 | * Update BD pointer to next entry. |
185 | */ | 188 | */ |
186 | if ((sc & BD_ENET_RX_WRAP) == 0) | 189 | if ((sc & BD_ENET_RX_WRAP) == 0) |
187 | bdp++; | 190 | bdp++; |
@@ -234,7 +237,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev) | |||
234 | dev->name); | 237 | dev->name); |
235 | 238 | ||
236 | /* | 239 | /* |
237 | * Check for errors. | 240 | * Check for errors. |
238 | */ | 241 | */ |
239 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | | 242 | if (sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_CL | |
240 | BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { | 243 | BD_ENET_RX_NO | BD_ENET_RX_CR | BD_ENET_RX_OV)) { |
@@ -312,7 +315,7 @@ static int fs_enet_rx_non_napi(struct net_device *dev) | |||
312 | CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); | 315 | CBDW_SC(bdp, (sc & ~BD_ENET_RX_STATS) | BD_ENET_RX_EMPTY); |
313 | 316 | ||
314 | /* | 317 | /* |
315 | * Update BD pointer to next entry. | 318 | * Update BD pointer to next entry. |
316 | */ | 319 | */ |
317 | if ((sc & BD_ENET_RX_WRAP) == 0) | 320 | if ((sc & BD_ENET_RX_WRAP) == 0) |
318 | bdp++; | 321 | bdp++; |
@@ -349,7 +352,7 @@ static void fs_enet_tx(struct net_device *dev) | |||
349 | skb = fep->tx_skbuff[dirtyidx]; | 352 | skb = fep->tx_skbuff[dirtyidx]; |
350 | 353 | ||
351 | /* | 354 | /* |
352 | * Check for errors. | 355 | * Check for errors. |
353 | */ | 356 | */ |
354 | if (sc & (BD_ENET_TX_HB | BD_ENET_TX_LC | | 357 | if (sc & (BD_ENET_TX_HB | BD_ENET_TX_LC | |
355 | BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) { | 358 | BD_ENET_TX_RL | BD_ENET_TX_UN | BD_ENET_TX_CSL)) { |
@@ -389,13 +392,13 @@ static void fs_enet_tx(struct net_device *dev) | |||
389 | skb->len, DMA_TO_DEVICE); | 392 | skb->len, DMA_TO_DEVICE); |
390 | 393 | ||
391 | /* | 394 | /* |
392 | * Free the sk buffer associated with this last transmit. | 395 | * Free the sk buffer associated with this last transmit. |
393 | */ | 396 | */ |
394 | dev_kfree_skb_irq(skb); | 397 | dev_kfree_skb_irq(skb); |
395 | fep->tx_skbuff[dirtyidx] = NULL; | 398 | fep->tx_skbuff[dirtyidx] = NULL; |
396 | 399 | ||
397 | /* | 400 | /* |
398 | * Update pointer to next buffer descriptor to be transmitted. | 401 | * Update pointer to next buffer descriptor to be transmitted. |
399 | */ | 402 | */ |
400 | if ((sc & BD_ENET_TX_WRAP) == 0) | 403 | if ((sc & BD_ENET_TX_WRAP) == 0) |
401 | bdp++; | 404 | bdp++; |
@@ -491,7 +494,7 @@ void fs_init_bds(struct net_device *dev) | |||
491 | fep->cur_rx = fep->rx_bd_base; | 494 | fep->cur_rx = fep->rx_bd_base; |
492 | 495 | ||
493 | /* | 496 | /* |
494 | * Initialize the receive buffer descriptors. | 497 | * Initialize the receive buffer descriptors. |
495 | */ | 498 | */ |
496 | for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { | 499 | for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { |
497 | skb = dev_alloc_skb(ENET_RX_FRSIZE); | 500 | skb = dev_alloc_skb(ENET_RX_FRSIZE); |
@@ -511,7 +514,7 @@ void fs_init_bds(struct net_device *dev) | |||
511 | ((i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP)); | 514 | ((i < fep->rx_ring - 1) ? 0 : BD_SC_WRAP)); |
512 | } | 515 | } |
513 | /* | 516 | /* |
514 | * if we failed, fillup remainder | 517 | * if we failed, fillup remainder |
515 | */ | 518 | */ |
516 | for (; i < fep->rx_ring; i++, bdp++) { | 519 | for (; i < fep->rx_ring; i++, bdp++) { |
517 | fep->rx_skbuff[i] = NULL; | 520 | fep->rx_skbuff[i] = NULL; |
@@ -519,7 +522,7 @@ void fs_init_bds(struct net_device *dev) | |||
519 | } | 522 | } |
520 | 523 | ||
521 | /* | 524 | /* |
522 | * ...and the same for transmit. | 525 | * ...and the same for transmit. |
523 | */ | 526 | */ |
524 | for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) { | 527 | for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) { |
525 | fep->tx_skbuff[i] = NULL; | 528 | fep->tx_skbuff[i] = NULL; |
@@ -537,7 +540,7 @@ void fs_cleanup_bds(struct net_device *dev) | |||
537 | int i; | 540 | int i; |
538 | 541 | ||
539 | /* | 542 | /* |
540 | * Reset SKB transmit buffers. | 543 | * Reset SKB transmit buffers. |
541 | */ | 544 | */ |
542 | for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) { | 545 | for (i = 0, bdp = fep->tx_bd_base; i < fep->tx_ring; i++, bdp++) { |
543 | if ((skb = fep->tx_skbuff[i]) == NULL) | 546 | if ((skb = fep->tx_skbuff[i]) == NULL) |
@@ -552,7 +555,7 @@ void fs_cleanup_bds(struct net_device *dev) | |||
552 | } | 555 | } |
553 | 556 | ||
554 | /* | 557 | /* |
555 | * Reset SKB receive buffers | 558 | * Reset SKB receive buffers |
556 | */ | 559 | */ |
557 | for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { | 560 | for (i = 0, bdp = fep->rx_bd_base; i < fep->rx_ring; i++, bdp++) { |
558 | if ((skb = fep->rx_skbuff[i]) == NULL) | 561 | if ((skb = fep->rx_skbuff[i]) == NULL) |
@@ -582,7 +585,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
582 | spin_lock_irqsave(&fep->tx_lock, flags); | 585 | spin_lock_irqsave(&fep->tx_lock, flags); |
583 | 586 | ||
584 | /* | 587 | /* |
585 | * Fill in a Tx ring entry | 588 | * Fill in a Tx ring entry |
586 | */ | 589 | */ |
587 | bdp = fep->cur_tx; | 590 | bdp = fep->cur_tx; |
588 | 591 | ||
@@ -601,19 +604,19 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
601 | 604 | ||
602 | curidx = bdp - fep->tx_bd_base; | 605 | curidx = bdp - fep->tx_bd_base; |
603 | /* | 606 | /* |
604 | * Clear all of the status flags. | 607 | * Clear all of the status flags. |
605 | */ | 608 | */ |
606 | CBDC_SC(bdp, BD_ENET_TX_STATS); | 609 | CBDC_SC(bdp, BD_ENET_TX_STATS); |
607 | 610 | ||
608 | /* | 611 | /* |
609 | * Save skb pointer. | 612 | * Save skb pointer. |
610 | */ | 613 | */ |
611 | fep->tx_skbuff[curidx] = skb; | 614 | fep->tx_skbuff[curidx] = skb; |
612 | 615 | ||
613 | fep->stats.tx_bytes += skb->len; | 616 | fep->stats.tx_bytes += skb->len; |
614 | 617 | ||
615 | /* | 618 | /* |
616 | * Push the data cache so the CPM does not get stale memory data. | 619 | * Push the data cache so the CPM does not get stale memory data. |
617 | */ | 620 | */ |
618 | CBDW_BUFADDR(bdp, dma_map_single(fep->dev, | 621 | CBDW_BUFADDR(bdp, dma_map_single(fep->dev, |
619 | skb->data, skb->len, DMA_TO_DEVICE)); | 622 | skb->data, skb->len, DMA_TO_DEVICE)); |
@@ -622,7 +625,7 @@ static int fs_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
622 | dev->trans_start = jiffies; | 625 | dev->trans_start = jiffies; |
623 | 626 | ||
624 | /* | 627 | /* |
625 | * If this was the last BD in the ring, start at the beginning again. | 628 | * If this was the last BD in the ring, start at the beginning again. |
626 | */ | 629 | */ |
627 | if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0) | 630 | if ((CBDR_SC(bdp) & BD_ENET_TX_WRAP) == 0) |
628 | fep->cur_tx++; | 631 | fep->cur_tx++; |
@@ -1003,13 +1006,13 @@ static struct net_device *fs_init_instance(struct device *dev, | |||
1003 | spin_lock_init(&fep->tx_lock); | 1006 | spin_lock_init(&fep->tx_lock); |
1004 | 1007 | ||
1005 | /* | 1008 | /* |
1006 | * Set the Ethernet address. | 1009 | * Set the Ethernet address. |
1007 | */ | 1010 | */ |
1008 | for (i = 0; i < 6; i++) | 1011 | for (i = 0; i < 6; i++) |
1009 | ndev->dev_addr[i] = fpi->macaddr[i]; | 1012 | ndev->dev_addr[i] = fpi->macaddr[i]; |
1010 | 1013 | ||
1011 | r = (*fep->ops->allocate_bd)(ndev); | 1014 | r = (*fep->ops->allocate_bd)(ndev); |
1012 | 1015 | ||
1013 | if (fep->ring_base == NULL) { | 1016 | if (fep->ring_base == NULL) { |
1014 | printk(KERN_ERR DRV_MODULE_NAME | 1017 | printk(KERN_ERR DRV_MODULE_NAME |
1015 | ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r); | 1018 | ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r); |
@@ -1028,7 +1031,7 @@ static struct net_device *fs_init_instance(struct device *dev, | |||
1028 | fep->rx_ring = fpi->rx_ring; | 1031 | fep->rx_ring = fpi->rx_ring; |
1029 | 1032 | ||
1030 | /* | 1033 | /* |
1031 | * The FEC Ethernet specific entries in the device structure. | 1034 | * The FEC Ethernet specific entries in the device structure. |
1032 | */ | 1035 | */ |
1033 | ndev->open = fs_enet_open; | 1036 | ndev->open = fs_enet_open; |
1034 | ndev->hard_start_xmit = fs_enet_start_xmit; | 1037 | ndev->hard_start_xmit = fs_enet_start_xmit; |
@@ -1037,6 +1040,11 @@ static struct net_device *fs_init_instance(struct device *dev, | |||
1037 | ndev->stop = fs_enet_close; | 1040 | ndev->stop = fs_enet_close; |
1038 | ndev->get_stats = fs_enet_get_stats; | 1041 | ndev->get_stats = fs_enet_get_stats; |
1039 | ndev->set_multicast_list = fs_set_multicast_list; | 1042 | ndev->set_multicast_list = fs_set_multicast_list; |
1043 | |||
1044 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1045 | ndev->poll_controller = fs_enet_netpoll; | ||
1046 | #endif | ||
1047 | |||
1040 | netif_napi_add(ndev, &fep->napi, | 1048 | netif_napi_add(ndev, &fep->napi, |
1041 | fs_enet_rx_napi, fpi->napi_weight); | 1049 | fs_enet_rx_napi, fpi->napi_weight); |
1042 | 1050 | ||
@@ -1251,7 +1259,7 @@ static int __init fs_init(void) | |||
1251 | err: | 1259 | err: |
1252 | cleanup_immap(); | 1260 | cleanup_immap(); |
1253 | return r; | 1261 | return r; |
1254 | 1262 | ||
1255 | } | 1263 | } |
1256 | 1264 | ||
1257 | static void __exit fs_cleanup(void) | 1265 | static void __exit fs_cleanup(void) |
@@ -1262,6 +1270,15 @@ static void __exit fs_cleanup(void) | |||
1262 | cleanup_immap(); | 1270 | cleanup_immap(); |
1263 | } | 1271 | } |
1264 | 1272 | ||
1273 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
1274 | static void fs_enet_netpoll(struct net_device *dev) | ||
1275 | { | ||
1276 | disable_irq(dev->irq); | ||
1277 | fs_enet_interrupt(dev->irq, dev, NULL); | ||
1278 | enable_irq(dev->irq); | ||
1279 | } | ||
1280 | #endif | ||
1281 | |||
1265 | /**************************************************************************************/ | 1282 | /**************************************************************************************/ |
1266 | 1283 | ||
1267 | module_init(fs_init); | 1284 | module_init(fs_init); |