aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-07-09 02:13:53 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-09 02:13:53 -0400
commitc773e847ea8f6812804e40f52399c6921a00eab1 (patch)
tree952e0e262cc0b0f2136bc2a62938ae1d186f896a /net/core/dev.c
parenteb6aafe3f843cb0e939546c03540a3b4911b6964 (diff)
netdev: Move _xmit_lock and xmit_lock_owner into netdev_queue.
Accesses are mostly structured such that when there are multiple TX queues the code transformations will be a little bit simpler. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 0218b0b9be80..a29a359b15d1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -258,7 +258,7 @@ DEFINE_PER_CPU(struct softnet_data, softnet_data);
258 258
259#ifdef CONFIG_DEBUG_LOCK_ALLOC 259#ifdef CONFIG_DEBUG_LOCK_ALLOC
260/* 260/*
261 * register_netdevice() inits dev->_xmit_lock and sets lockdep class 261 * register_netdevice() inits txq->_xmit_lock and sets lockdep class
262 * according to dev->type 262 * according to dev->type
263 */ 263 */
264static const unsigned short netdev_lock_type[] = 264static const unsigned short netdev_lock_type[] =
@@ -1758,19 +1758,19 @@ gso:
1758 if (dev->flags & IFF_UP) { 1758 if (dev->flags & IFF_UP) {
1759 int cpu = smp_processor_id(); /* ok because BHs are off */ 1759 int cpu = smp_processor_id(); /* ok because BHs are off */
1760 1760
1761 if (dev->xmit_lock_owner != cpu) { 1761 if (txq->xmit_lock_owner != cpu) {
1762 1762
1763 HARD_TX_LOCK(dev, cpu); 1763 HARD_TX_LOCK(dev, txq, cpu);
1764 1764
1765 if (!netif_queue_stopped(dev) && 1765 if (!netif_queue_stopped(dev) &&
1766 !netif_subqueue_stopped(dev, skb)) { 1766 !netif_subqueue_stopped(dev, skb)) {
1767 rc = 0; 1767 rc = 0;
1768 if (!dev_hard_start_xmit(skb, dev)) { 1768 if (!dev_hard_start_xmit(skb, dev)) {
1769 HARD_TX_UNLOCK(dev); 1769 HARD_TX_UNLOCK(dev, txq);
1770 goto out; 1770 goto out;
1771 } 1771 }
1772 } 1772 }
1773 HARD_TX_UNLOCK(dev); 1773 HARD_TX_UNLOCK(dev, txq);
1774 if (net_ratelimit()) 1774 if (net_ratelimit())
1775 printk(KERN_CRIT "Virtual device %s asks to " 1775 printk(KERN_CRIT "Virtual device %s asks to "
1776 "queue packet!\n", dev->name); 1776 "queue packet!\n", dev->name);
@@ -3761,6 +3761,20 @@ static void rollback_registered(struct net_device *dev)
3761 dev_put(dev); 3761 dev_put(dev);
3762} 3762}
3763 3763
3764static void __netdev_init_queue_locks_one(struct netdev_queue *dev_queue,
3765 struct net_device *dev)
3766{
3767 spin_lock_init(&dev_queue->_xmit_lock);
3768 netdev_set_lockdep_class(&dev_queue->_xmit_lock, dev->type);
3769 dev_queue->xmit_lock_owner = -1;
3770}
3771
3772static void netdev_init_queue_locks(struct net_device *dev)
3773{
3774 __netdev_init_queue_locks_one(&dev->tx_queue, dev);
3775 __netdev_init_queue_locks_one(&dev->rx_queue, dev);
3776}
3777
3764/** 3778/**
3765 * register_netdevice - register a network device 3779 * register_netdevice - register a network device
3766 * @dev: device to register 3780 * @dev: device to register
@@ -3795,9 +3809,7 @@ int register_netdevice(struct net_device *dev)
3795 BUG_ON(!dev_net(dev)); 3809 BUG_ON(!dev_net(dev));
3796 net = dev_net(dev); 3810 net = dev_net(dev);
3797 3811
3798 spin_lock_init(&dev->_xmit_lock); 3812 netdev_init_queue_locks(dev);
3799 netdev_set_lockdep_class(&dev->_xmit_lock, dev->type);
3800 dev->xmit_lock_owner = -1;
3801 3813
3802 dev->iflink = -1; 3814 dev->iflink = -1;
3803 3815