Commit 325188e8 authored by Jeff Garzik's avatar Jeff Garzik

[NET] move netif_* helpers from tg3 driver to linux/netdevice.h

Helpers moved:
netif_poll_{enable,disable}, __netif_rx_complete, netif_tx_disable

Use the helpers in net/core/dev.c.
parent af42c0ff
...@@ -237,38 +237,6 @@ static void tg3_enable_ints(struct tg3 *tp) ...@@ -237,38 +237,6 @@ static void tg3_enable_ints(struct tg3 *tp)
tg3_cond_int(tp); tg3_cond_int(tp);
} }
/* these netif_xxx funcs should be moved into generic net layer */
static void netif_poll_disable(struct net_device *dev)
{
while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
}
static inline void netif_poll_enable(struct net_device *dev)
{
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
/* same as netif_rx_complete, except that local_irq_save(flags)
* has already been issued
*/
static inline void __netif_rx_complete(struct net_device *dev)
{
if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
list_del(&dev->poll_list);
smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
static inline void netif_tx_disable(struct net_device *dev)
{
spin_lock_bh(&dev->xmit_lock);
netif_stop_queue(dev);
spin_unlock_bh(&dev->xmit_lock);
}
static inline void tg3_netif_stop(struct tg3 *tp) static inline void tg3_netif_stop(struct tg3 *tp)
{ {
netif_poll_disable(tp->dev); netif_poll_disable(tp->dev);
......
...@@ -832,6 +832,38 @@ static inline void netif_rx_complete(struct net_device *dev) ...@@ -832,6 +832,38 @@ static inline void netif_rx_complete(struct net_device *dev)
local_irq_restore(flags); local_irq_restore(flags);
} }
static inline void netif_poll_disable(struct net_device *dev)
{
while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) {
/* No hurry. */
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
}
static inline void netif_poll_enable(struct net_device *dev)
{
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
/* same as netif_rx_complete, except that local_irq_save(flags)
* has already been issued
*/
static inline void __netif_rx_complete(struct net_device *dev)
{
if (!test_bit(__LINK_STATE_RX_SCHED, &dev->state)) BUG();
list_del(&dev->poll_list);
smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
}
static inline void netif_tx_disable(struct net_device *dev)
{
spin_lock_bh(&dev->xmit_lock);
netif_stop_queue(dev);
spin_unlock_bh(&dev->xmit_lock);
}
/* These functions live elsewhere (drivers/net/net_init.c, but related) */ /* These functions live elsewhere (drivers/net/net_init.c, but related) */
extern void ether_setup(struct net_device *dev); extern void ether_setup(struct net_device *dev);
......
...@@ -845,11 +845,7 @@ int dev_close(struct net_device *dev) ...@@ -845,11 +845,7 @@ int dev_close(struct net_device *dev)
* engine, but this requires more changes in devices. */ * engine, but this requires more changes in devices. */
smp_mb__after_clear_bit(); /* Commit netif_running(). */ smp_mb__after_clear_bit(); /* Commit netif_running(). */
while (test_bit(__LINK_STATE_RX_SCHED, &dev->state)) { netif_poll_disable(dev);
/* No hurry. */
current->state = TASK_INTERRUPTIBLE;
schedule_timeout(1);
}
/* /*
* Call the device specific close. This cannot fail. * Call the device specific close. This cannot fail.
...@@ -1657,7 +1653,7 @@ static int process_backlog(struct net_device *backlog_dev, int *budget) ...@@ -1657,7 +1653,7 @@ static int process_backlog(struct net_device *backlog_dev, int *budget)
list_del(&backlog_dev->poll_list); list_del(&backlog_dev->poll_list);
smp_mb__before_clear_bit(); smp_mb__before_clear_bit();
clear_bit(__LINK_STATE_RX_SCHED, &backlog_dev->state); netif_poll_enable(backlog_dev);
if (queue->throttle) { if (queue->throttle) {
queue->throttle = 0; queue->throttle = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment