diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-22 03:12:37 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-07-22 03:12:37 -0400 |
commit | 8725f25acc656c1522d48a6746055099efdaca4c (patch) | |
tree | e241424fa58178ed6c2a95a4eb931ea83dbea33c /drivers/net/gianfar.c | |
parent | c69cccc95fe4b90dde5fe33e6a3b77880b534fa4 (diff) | |
parent | 93ded9b8fd42abe2c3607097963d8de6ad9117eb (diff) |
Merge commit 'origin/master'
Manually fixed up:
drivers/net/fs_enet/fs_enet-main.c
Diffstat (limited to 'drivers/net/gianfar.c')
-rw-r--r-- | drivers/net/gianfar.c | 81 |
1 files changed, 8 insertions, 73 deletions
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 36f229ff52f2..b8394cf134e8 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -44,8 +44,7 @@ | |||
44 | * happen immediately, but will wait until either a set number | 44 | * happen immediately, but will wait until either a set number |
45 | * of frames or amount of time have passed). In NAPI, the | 45 | * of frames or amount of time have passed). In NAPI, the |
46 | * interrupt handler will signal there is work to be done, and | 46 | * interrupt handler will signal there is work to be done, and |
47 | * exit. Without NAPI, the packet(s) will be handled | 47 | * exit. This method will start at the last known empty |
48 | * immediately. Both methods will start at the last known empty | ||
49 | * descriptor, and process every subsequent descriptor until there | 48 | * descriptor, and process every subsequent descriptor until there |
50 | * are none left with data (NAPI will stop after a set number of | 49 | * are none left with data (NAPI will stop after a set number of |
51 | * packets to give time to other tasks, but will eventually | 50 | * packets to give time to other tasks, but will eventually |
@@ -101,12 +100,6 @@ | |||
101 | #undef BRIEF_GFAR_ERRORS | 100 | #undef BRIEF_GFAR_ERRORS |
102 | #undef VERBOSE_GFAR_ERRORS | 101 | #undef VERBOSE_GFAR_ERRORS |
103 | 102 | ||
104 | #ifdef CONFIG_GFAR_NAPI | ||
105 | #define RECEIVE(x) netif_receive_skb(x) | ||
106 | #else | ||
107 | #define RECEIVE(x) netif_rx(x) | ||
108 | #endif | ||
109 | |||
110 | const char gfar_driver_name[] = "Gianfar Ethernet"; | 103 | const char gfar_driver_name[] = "Gianfar Ethernet"; |
111 | const char gfar_driver_version[] = "1.3"; | 104 | const char gfar_driver_version[] = "1.3"; |
112 | 105 | ||
@@ -131,9 +124,7 @@ static void free_skb_resources(struct gfar_private *priv); | |||
131 | static void gfar_set_multi(struct net_device *dev); | 124 | static void gfar_set_multi(struct net_device *dev); |
132 | static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); | 125 | static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); |
133 | static void gfar_configure_serdes(struct net_device *dev); | 126 | static void gfar_configure_serdes(struct net_device *dev); |
134 | #ifdef CONFIG_GFAR_NAPI | ||
135 | static int gfar_poll(struct napi_struct *napi, int budget); | 127 | static int gfar_poll(struct napi_struct *napi, int budget); |
136 | #endif | ||
137 | #ifdef CONFIG_NET_POLL_CONTROLLER | 128 | #ifdef CONFIG_NET_POLL_CONTROLLER |
138 | static void gfar_netpoll(struct net_device *dev); | 129 | static void gfar_netpoll(struct net_device *dev); |
139 | #endif | 130 | #endif |
@@ -264,9 +255,7 @@ static int gfar_probe(struct platform_device *pdev) | |||
264 | dev->hard_start_xmit = gfar_start_xmit; | 255 | dev->hard_start_xmit = gfar_start_xmit; |
265 | dev->tx_timeout = gfar_timeout; | 256 | dev->tx_timeout = gfar_timeout; |
266 | dev->watchdog_timeo = TX_TIMEOUT; | 257 | dev->watchdog_timeo = TX_TIMEOUT; |
267 | #ifdef CONFIG_GFAR_NAPI | ||
268 | netif_napi_add(dev, &priv->napi, gfar_poll, GFAR_DEV_WEIGHT); | 258 | netif_napi_add(dev, &priv->napi, gfar_poll, GFAR_DEV_WEIGHT); |
269 | #endif | ||
270 | #ifdef CONFIG_NET_POLL_CONTROLLER | 259 | #ifdef CONFIG_NET_POLL_CONTROLLER |
271 | dev->poll_controller = gfar_netpoll; | 260 | dev->poll_controller = gfar_netpoll; |
272 | #endif | 261 | #endif |
@@ -367,11 +356,7 @@ static int gfar_probe(struct platform_device *pdev) | |||
367 | 356 | ||
368 | /* Even more device info helps when determining which kernel */ | 357 | /* Even more device info helps when determining which kernel */ |
369 | /* provided which set of benchmarks. */ | 358 | /* provided which set of benchmarks. */ |
370 | #ifdef CONFIG_GFAR_NAPI | ||
371 | printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name); | 359 | printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name); |
372 | #else | ||
373 | printk(KERN_INFO "%s: Running with NAPI disabled\n", dev->name); | ||
374 | #endif | ||
375 | printk(KERN_INFO "%s: %d/%d RX/TX BD ring size\n", | 360 | printk(KERN_INFO "%s: %d/%d RX/TX BD ring size\n", |
376 | dev->name, priv->rx_ring_size, priv->tx_ring_size); | 361 | dev->name, priv->rx_ring_size, priv->tx_ring_size); |
377 | 362 | ||
@@ -1039,7 +1024,7 @@ rx_irq_fail: | |||
1039 | tx_irq_fail: | 1024 | tx_irq_fail: |
1040 | free_irq(priv->interruptError, dev); | 1025 | free_irq(priv->interruptError, dev); |
1041 | err_irq_fail: | 1026 | err_irq_fail: |
1042 | err_rxalloc_fail: | 1027 | err_rxalloc_fail: |
1043 | rx_skb_fail: | 1028 | rx_skb_fail: |
1044 | free_skb_resources(priv); | 1029 | free_skb_resources(priv); |
1045 | tx_skb_fail: | 1030 | tx_skb_fail: |
@@ -1056,14 +1041,10 @@ tx_skb_fail: | |||
1056 | /* Returns 0 for success. */ | 1041 | /* Returns 0 for success. */ |
1057 | static int gfar_enet_open(struct net_device *dev) | 1042 | static int gfar_enet_open(struct net_device *dev) |
1058 | { | 1043 | { |
1059 | #ifdef CONFIG_GFAR_NAPI | ||
1060 | struct gfar_private *priv = netdev_priv(dev); | 1044 | struct gfar_private *priv = netdev_priv(dev); |
1061 | #endif | ||
1062 | int err; | 1045 | int err; |
1063 | 1046 | ||
1064 | #ifdef CONFIG_GFAR_NAPI | ||
1065 | napi_enable(&priv->napi); | 1047 | napi_enable(&priv->napi); |
1066 | #endif | ||
1067 | 1048 | ||
1068 | /* Initialize a bunch of registers */ | 1049 | /* Initialize a bunch of registers */ |
1069 | init_registers(dev); | 1050 | init_registers(dev); |
@@ -1073,17 +1054,13 @@ static int gfar_enet_open(struct net_device *dev) | |||
1073 | err = init_phy(dev); | 1054 | err = init_phy(dev); |
1074 | 1055 | ||
1075 | if(err) { | 1056 | if(err) { |
1076 | #ifdef CONFIG_GFAR_NAPI | ||
1077 | napi_disable(&priv->napi); | 1057 | napi_disable(&priv->napi); |
1078 | #endif | ||
1079 | return err; | 1058 | return err; |
1080 | } | 1059 | } |
1081 | 1060 | ||
1082 | err = startup_gfar(dev); | 1061 | err = startup_gfar(dev); |
1083 | if (err) { | 1062 | if (err) { |
1084 | #ifdef CONFIG_GFAR_NAPI | ||
1085 | napi_disable(&priv->napi); | 1063 | napi_disable(&priv->napi); |
1086 | #endif | ||
1087 | return err; | 1064 | return err; |
1088 | } | 1065 | } |
1089 | 1066 | ||
@@ -1239,9 +1216,7 @@ static int gfar_close(struct net_device *dev) | |||
1239 | { | 1216 | { |
1240 | struct gfar_private *priv = netdev_priv(dev); | 1217 | struct gfar_private *priv = netdev_priv(dev); |
1241 | 1218 | ||
1242 | #ifdef CONFIG_GFAR_NAPI | ||
1243 | napi_disable(&priv->napi); | 1219 | napi_disable(&priv->napi); |
1244 | #endif | ||
1245 | 1220 | ||
1246 | stop_gfar(dev); | 1221 | stop_gfar(dev); |
1247 | 1222 | ||
@@ -1370,7 +1345,7 @@ static void gfar_timeout(struct net_device *dev) | |||
1370 | startup_gfar(dev); | 1345 | startup_gfar(dev); |
1371 | } | 1346 | } |
1372 | 1347 | ||
1373 | netif_schedule(dev); | 1348 | netif_tx_schedule_all(dev); |
1374 | } | 1349 | } |
1375 | 1350 | ||
1376 | /* Interrupt Handler for Transmit complete */ | 1351 | /* Interrupt Handler for Transmit complete */ |
@@ -1538,14 +1513,9 @@ irqreturn_t gfar_receive(int irq, void *dev_id) | |||
1538 | { | 1513 | { |
1539 | struct net_device *dev = (struct net_device *) dev_id; | 1514 | struct net_device *dev = (struct net_device *) dev_id; |
1540 | struct gfar_private *priv = netdev_priv(dev); | 1515 | struct gfar_private *priv = netdev_priv(dev); |
1541 | #ifdef CONFIG_GFAR_NAPI | ||
1542 | u32 tempval; | 1516 | u32 tempval; |
1543 | #else | ||
1544 | unsigned long flags; | ||
1545 | #endif | ||
1546 | 1517 | ||
1547 | /* support NAPI */ | 1518 | /* support NAPI */ |
1548 | #ifdef CONFIG_GFAR_NAPI | ||
1549 | /* Clear IEVENT, so interrupts aren't called again | 1519 | /* Clear IEVENT, so interrupts aren't called again |
1550 | * because of the packets that have already arrived */ | 1520 | * because of the packets that have already arrived */ |
1551 | gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK); | 1521 | gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK); |
@@ -1562,38 +1532,10 @@ irqreturn_t gfar_receive(int irq, void *dev_id) | |||
1562 | dev->name, gfar_read(&priv->regs->ievent), | 1532 | dev->name, gfar_read(&priv->regs->ievent), |
1563 | gfar_read(&priv->regs->imask)); | 1533 | gfar_read(&priv->regs->imask)); |
1564 | } | 1534 | } |
1565 | #else | ||
1566 | /* Clear IEVENT, so rx interrupt isn't called again | ||
1567 | * because of this interrupt */ | ||
1568 | gfar_write(&priv->regs->ievent, IEVENT_RX_MASK); | ||
1569 | |||
1570 | spin_lock_irqsave(&priv->rxlock, flags); | ||
1571 | gfar_clean_rx_ring(dev, priv->rx_ring_size); | ||
1572 | |||
1573 | /* If we are coalescing interrupts, update the timer */ | ||
1574 | /* Otherwise, clear it */ | ||
1575 | if (likely(priv->rxcoalescing)) { | ||
1576 | gfar_write(&priv->regs->rxic, 0); | ||
1577 | gfar_write(&priv->regs->rxic, | ||
1578 | mk_ic_value(priv->rxcount, priv->rxtime)); | ||
1579 | } | ||
1580 | |||
1581 | spin_unlock_irqrestore(&priv->rxlock, flags); | ||
1582 | #endif | ||
1583 | 1535 | ||
1584 | return IRQ_HANDLED; | 1536 | return IRQ_HANDLED; |
1585 | } | 1537 | } |
1586 | 1538 | ||
1587 | static inline int gfar_rx_vlan(struct sk_buff *skb, | ||
1588 | struct vlan_group *vlgrp, unsigned short vlctl) | ||
1589 | { | ||
1590 | #ifdef CONFIG_GFAR_NAPI | ||
1591 | return vlan_hwaccel_receive_skb(skb, vlgrp, vlctl); | ||
1592 | #else | ||
1593 | return vlan_hwaccel_rx(skb, vlgrp, vlctl); | ||
1594 | #endif | ||
1595 | } | ||
1596 | |||
1597 | static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) | 1539 | static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb) |
1598 | { | 1540 | { |
1599 | /* If valid headers were found, and valid sums | 1541 | /* If valid headers were found, and valid sums |
@@ -1650,10 +1592,11 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, | |||
1650 | skb->protocol = eth_type_trans(skb, dev); | 1592 | skb->protocol = eth_type_trans(skb, dev); |
1651 | 1593 | ||
1652 | /* Send the packet up the stack */ | 1594 | /* Send the packet up the stack */ |
1653 | if (unlikely(priv->vlgrp && (fcb->flags & RXFCB_VLN))) | 1595 | if (unlikely(priv->vlgrp && (fcb->flags & RXFCB_VLN))) { |
1654 | ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl); | 1596 | ret = vlan_hwaccel_receive_skb(skb, priv->vlgrp, |
1655 | else | 1597 | fcb->vlctl); |
1656 | ret = RECEIVE(skb); | 1598 | } else |
1599 | ret = netif_receive_skb(skb); | ||
1657 | 1600 | ||
1658 | if (NET_RX_DROP == ret) | 1601 | if (NET_RX_DROP == ret) |
1659 | priv->extra_stats.kernel_dropped++; | 1602 | priv->extra_stats.kernel_dropped++; |
@@ -1740,7 +1683,6 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1740 | return howmany; | 1683 | return howmany; |
1741 | } | 1684 | } |
1742 | 1685 | ||
1743 | #ifdef CONFIG_GFAR_NAPI | ||
1744 | static int gfar_poll(struct napi_struct *napi, int budget) | 1686 | static int gfar_poll(struct napi_struct *napi, int budget) |
1745 | { | 1687 | { |
1746 | struct gfar_private *priv = container_of(napi, struct gfar_private, napi); | 1688 | struct gfar_private *priv = container_of(napi, struct gfar_private, napi); |
@@ -1775,7 +1717,6 @@ static int gfar_poll(struct napi_struct *napi, int budget) | |||
1775 | 1717 | ||
1776 | return howmany; | 1718 | return howmany; |
1777 | } | 1719 | } |
1778 | #endif | ||
1779 | 1720 | ||
1780 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1721 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1781 | /* | 1722 | /* |
@@ -1895,7 +1836,6 @@ static void adjust_link(struct net_device *dev) | |||
1895 | if (!priv->oldlink) { | 1836 | if (!priv->oldlink) { |
1896 | new_state = 1; | 1837 | new_state = 1; |
1897 | priv->oldlink = 1; | 1838 | priv->oldlink = 1; |
1898 | netif_schedule(dev); | ||
1899 | } | 1839 | } |
1900 | } else if (priv->oldlink) { | 1840 | } else if (priv->oldlink) { |
1901 | new_state = 1; | 1841 | new_state = 1; |
@@ -2119,11 +2059,6 @@ static irqreturn_t gfar_error(int irq, void *dev_id) | |||
2119 | 2059 | ||
2120 | gfar_receive(irq, dev_id); | 2060 | gfar_receive(irq, dev_id); |
2121 | 2061 | ||
2122 | #ifndef CONFIG_GFAR_NAPI | ||
2123 | /* Clear the halt bit in RSTAT */ | ||
2124 | gfar_write(&priv->regs->rstat, RSTAT_CLEAR_RHALT); | ||
2125 | #endif | ||
2126 | |||
2127 | if (netif_msg_rx_err(priv)) | 2062 | if (netif_msg_rx_err(priv)) |
2128 | printk(KERN_DEBUG "%s: busy error (rstat: %x)\n", | 2063 | printk(KERN_DEBUG "%s: busy error (rstat: %x)\n", |
2129 | dev->name, gfar_read(&priv->regs->rstat)); | 2064 | dev->name, gfar_read(&priv->regs->rstat)); |