: net: Use queue aware tests throughout.
Subsystems (3)
David Miller
maintainerPATCH 5/13 : net: Use queue aware tests throughout.
This effectively "flips the switch" by making the core networking and multiqueue-aware drivers use the new TX multiqueue structures.
Non-multiqueue drivers need no changes. The interfaces they use such as netif_stop_queue() degenerate into an operation on TX queue zero. So everything "just works" for them.
Code that really wants to do "X" to all TX queues now invokes a routine that does so, such as netif_tx_wake_all_queues(), netif_tx_stop_all_queues(), etc.
pktgen and netpoll required a little bit more surgery than the others.
In particular the pktgen changes, whilst functional, could be largely improved. The initial check in pktgen_xmit() will sometimes check the wrong queue, which is mostly harmless. The thing to do is probably to invoke fill_packet() earlier.
The bulk of the netpoll changes is to make the code operate solely on the TX queue indicated by by the SKB queue mapping.
Setting of the SKB queue mapping is entirely confined inside of net/core/dev.c:dev_pick_tx(). If we end up needing any kind of special semantics (drops, for example) it will be implemented here.
Finally, we now have a "real_num_tx_queues" which is where the driver indicates how many TX queues are actually active. This value must be stable while the device is open. It may only be modified while the device is down.
--- drivers/net/cpmac.c | 20 ++++----- drivers/net/ixgbe/ixgbe_ethtool.c | 10 +---- drivers/net/ixgbe/ixgbe_main.c | 15 ++----- drivers/net/s2io.c | 48 +++++++++------------- include/linux/netdevice.h | 82 +++++++++++++++++++++++++++++++++---- include/net/pkt_sched.h | 4 +- net/core/dev.c | 28 +++++------- net/core/netpoll.c | 24 ++++++----- net/core/pktgen.c | 69 ++++++++++++++++++++----------- net/sched/sch_generic.c | 5 +- net/sched/sch_teql.c | 6 +-- 11 files changed, 182 insertions(+), 129 deletions(-)
drivers/net/cpmac.c +8 -12
@@ -544,7 +544,7 @@ fatal_error:spin_unlock (&priv->rx_lock);netif_rx_complete (priv->dev, napi); -netif_stop_queue (priv->dev); +netif_tx_stop_all_queues (priv->dev);napi_disable (&priv->napi);atomic_inc (&priv->reset_pending);
@@ -750,9 +750,7 @@ static void cpmac_hw_error(struct work_struct *work)barrier ();atomic_dec (&priv->reset_pending); -for (i =0 ; i <CPMAC_QUEUES ; i++) -netif_wake_subqueue (priv->dev, i); -netif_wake_queue (priv->dev); +netif_tx_wake_all_queues (priv->dev);cpmac_write (priv->regs,CPMAC_MAC_INT_ENABLE ,3 ); }
@@ -781,7 +779,7 @@ static void cpmac_check_status(struct net_device *dev) dev->name, tx_code, tx_channel, macstatus); } -netif_stop_queue (dev); +netif_tx_stop_all_queues (dev);cpmac_hw_stop (dev);if (schedule_work (&priv->reset_work))atomic_inc (&priv->reset_pending);
@@ -842,9 +840,7 @@ static void cpmac_tx_timeout(struct net_device *dev)barrier ();atomic_dec (&priv->reset_pending); -netif_wake_queue (priv->dev); -for (i =0 ; i <CPMAC_QUEUES ; i++) -netif_wake_subqueue (dev, i); +netif_tx_wake_all_queues (priv->dev); }static int cpmac_ioctl (struct net_device *dev,struct ifreq *ifr,int cmd)
@@ -935,7 +931,7 @@ static void cpmac_adjust_link(struct net_device *dev)spin_lock (&priv->lock);if (priv->phy->link) { -netif_start_queue (dev); +netif_tx_start_all_queues (dev);if (priv->phy->duplex != priv->oldduplex) { new_state =1 ; priv->oldduplex = priv->phy->duplex;
@@ -949,10 +945,10 @@ static void cpmac_adjust_link(struct net_device *dev)if (!priv->oldlink) { new_state =1 ; priv->oldlink =1 ; -netif_schedule (dev); +netif_tx_schedule_all (dev); } }else if (priv->oldlink) { -netif_stop_queue (dev); +netif_tx_stop_all_queues (dev); new_state =1 ; priv->oldlink =0 ; priv->oldspeed =0 ;
@@ -1072,7 +1068,7 @@ static int cpmac_stop(struct net_device *dev)struct cpmac_priv *priv =netdev_priv (dev);struct resource *mem; -netif_stop_queue (dev); +netif_tx_stop_all_queues (dev);cancel_work_sync (&priv->reset_work);napi_disable (&priv->napi);
drivers/net/ixgbe/ixgbe_ethtool.c +2 -8
@@ -252,16 +252,10 @@ static int ixgbe_set_tso(struct net_device *netdev, u32 data) netdev->features |=NETIF_F_TSO ; netdev->features |=NETIF_F_TSO6 ; }else { -struct ixgbe_adapter *adapter =netdev_priv (netdev); -int i; -netif_stop_queue (netdev); -for (i =0 ; i < adapter->num_tx_queues; i++) -netif_stop_subqueue (netdev, i); +netif_tx_stop_all_queues (netdev); netdev->features &= ~NETIF_F_TSO ; netdev->features &= ~NETIF_F_TSO6 ; -for (i =0 ; i < adapter->num_tx_queues; i++) -netif_start_subqueue (netdev, i); -netif_start_queue (netdev); +netif_tx_start_all_queues (netdev); }return 0 ; }
drivers/net/ixgbe/ixgbe_main.c +5 -10
@@ -2009,7 +2009,7 @@ void ixgbe_down(struct ixgbe_adapter *adapter)del_timer_sync (&adapter->watchdog_timer);netif_carrier_off (netdev); -netif_stop_queue (netdev); +netif_tx_stop_all_queues (netdev);if (!pci_channel_offline (adapter->pdev))ixgbe_reset (adapter);
@@ -2355,7 +2355,7 @@ try_msi: out:/* Notify the stack of the (possibly) reduced Tx Queue count. */ - adapter->netdev->egress_subqueue_count = adapter->num_tx_queues; + adapter->netdev->real_num_tx_queues = adapter->num_tx_queues;return err; }
@@ -2892,7 +2892,6 @@ static void ixgbe_watchdog(unsigned long data)struct net_device *netdev = adapter->netdev;bool link_up;u32 link_speed =0 ; -int i; adapter->hw.mac.ops.check_link (&adapter->hw, &(link_speed), &link_up);
@@ -2913,9 +2912,7 @@ static void ixgbe_watchdog(unsigned long data) (FLOW_TX ? "TX" : "None"))));netif_carrier_on (netdev); -netif_wake_queue (netdev); -for (i =0 ; i < adapter->num_tx_queues; i++) -netif_wake_subqueue (netdev, i); +netif_tx_wake_all_queues (netdev); }else {/* Force detection of hung controller */ adapter->detect_tx_hung = true;
@@ -2924,7 +2921,7 @@ static void ixgbe_watchdog(unsigned long data)if (netif_carrier_ok (netdev)) {DPRINTK (LINK ,INFO ,"NIC Link is Down\n" );netif_carrier_off (netdev); -netif_stop_queue (netdev); +netif_tx_stop_all_queues (netdev); } }
@@ -3627,9 +3624,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,ixgbe_start_hw (hw);netif_carrier_off (netdev); -netif_stop_queue (netdev); -for (i =0 ; i < adapter->num_tx_queues; i++) -netif_stop_subqueue (netdev, i); +netif_tx_stop_all_queues (netdev);ixgbe_napi_add_all (adapter);
drivers/net/s2io.c +19 -29
87 lines not on this page · raw message
include/linux/netdevice.h +73 -9
170 lines not on this page · raw message
include/net/pkt_sched.h +1 -3
@@ -88,9 +88,7 @@ extern void __qdisc_run(struct netdev_queue *txq);static inline void qdisc_run (struct netdev_queue *txq) { -struct net_device *dev = txq->dev; - -if (!netif_queue_stopped (dev) && +if (!netif_tx_queue_stopped (txq) && !test_and_set_bit (__QUEUE_STATE_QDISC_RUNNING, &txq->state))__qdisc_run (txq); }
net/core/dev.c +12 -16
@@ -1598,7 +1598,8 @@ static int dev_gso_segment(struct sk_buff *skb)return 0 ; } -int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev) +int dev_hard_start_xmit (struct sk_buff *skb,struct net_device *dev, +struct netdev_queue *txq) {if (likely (!skb->next)) {if (!list_empty (&ptype_all))
@@ -1627,9 +1628,7 @@ gso: skb->next = nskb;return rc; } -if (unlikely ((netif_queue_stopped (dev) || -netif_subqueue_stopped (dev, skb)) && - skb->next)) +if (unlikely (netif_tx_queue_stopped (txq) && skb->next))return NETDEV_TX_BUSY ; }while (skb->next);
@@ -1669,7 +1668,10 @@ out_kfree_skb:static struct netdev_queue *dev_pick_tx (struct net_device *dev,struct sk_buff *skb) { -return netdev_get_tx_queue (dev,0 ); +u16 queue_index =0 ; + +skb_set_queue_mapping (skb, queue_index); +return netdev_get_tx_queue (dev, queue_index); }int dev_queue_xmit (struct sk_buff *skb)
@@ -1737,8 +1739,6 @@ gso:spin_lock (&txq->lock); q = txq->qdisc;if (q->enqueue) { -/* reset queue_mapping to zero */ -skb_set_queue_mapping (skb,0 ); rc = q->enqueue (skb, q);qdisc_run (txq);spin_unlock (&txq->lock);
@@ -1768,10 +1768,9 @@ gso:HARD_TX_LOCK (dev, txq, cpu); -if (!netif_queue_stopped (dev) && - !netif_subqueue_stopped (dev, skb)) { +if (!netif_tx_queue_stopped (txq)) { rc =0 ; -if (!dev_hard_start_xmit (skb, dev)) { +if (!dev_hard_start_xmit (skb, dev, txq)) {HARD_TX_UNLOCK (dev, txq); goto out; }
@@ -4132,8 +4131,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,BUG_ON (strlen (name) >=sizeof (dev->name)); - alloc_size =sizeof (struct net_device ) + -sizeof (struct net_device_subqueue ) * (queue_count -1 ); + alloc_size =sizeof (struct net_device );if (sizeof_priv) {/* ensure 32-byte alignment of private area */ alloc_size = (alloc_size +NETDEV_ALIGN_CONST ) & ~NETDEV_ALIGN_CONST ;
@@ -4163,16 +4161,14 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, dev->_tx = tx; dev->num_tx_queues = queue_count; + dev->real_num_tx_queues = queue_count;if (sizeof_priv) { dev->priv = ((char *)dev + - ((sizeof (struct net_device ) + - (sizeof (struct net_device_subqueue ) * - (queue_count -1 )) +NETDEV_ALIGN_CONST ) + ((sizeof (struct net_device ) +NETDEV_ALIGN_CONST ) & ~NETDEV_ALIGN_CONST )); } - dev->egress_subqueue_count = queue_count; dev->gso_max_size =GSO_MAX_SIZE ;netdev_init_queues (dev);
net/core/netpoll.c +14 -10
@@ -58,25 +58,27 @@ static void queue_process(struct work_struct *work)while ((skb =skb_dequeue (&npinfo->txq))) {struct net_device *dev = skb->dev; +struct netdev_queue *txq;if (!netif_device_present (dev) || !netif_running (dev)) {__kfree_skb (skb);continue ; } + txq =netdev_get_tx_queue (dev,skb_get_queue_mapping (skb)); +local_irq_save (flags); -netif_tx_lock (dev); -if ((netif_queue_stopped (dev) || -netif_subqueue_stopped (dev, skb)) || - dev->hard_start_xmit (skb, dev) !=NETDEV_TX_OK ) { +__netif_tx_lock (txq,smp_processor_id ()); +if (netif_tx_queue_stopped (txq) || + dev->hard_start_xmit (skb, dev) !=NETDEV_TX_OK ) {skb_queue_head (&npinfo->txq, skb); -netif_tx_unlock (dev); +__netif_tx_unlock (txq);local_irq_restore (flags);schedule_delayed_work (&npinfo->tx_work,HZ /10 );return ; } -netif_tx_unlock (dev); +__netif_tx_unlock (txq);local_irq_restore (flags); } }
@@ -278,17 +280,19 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)/* don't get messages out of order, and no recursion */ if (skb_queue_len (&npinfo->txq) ==0 && !netpoll_owner_active (dev)) { +struct netdev_queue *txq;unsigned long flags; + txq =netdev_get_tx_queue (dev,skb_get_queue_mapping (skb)); +local_irq_save (flags);/* try until next clock tick */ for (tries =jiffies_to_usecs (1 )/USEC_PER_POLL ; tries >0 ; --tries) { -if (netif_tx_trylock (dev)) { -if (!netif_queue_stopped (dev) && - !netif_subqueue_stopped (dev, skb)) +if (__netif_tx_trylock (txq)) { +if (!netif_tx_queue_stopped (txq)) status = dev->hard_start_xmit (skb, dev); -netif_tx_unlock (dev); +__netif_tx_unlock (txq);if (status ==NETDEV_TX_OK )break ;
net/core/pktgen.c +44 -25
148 lines not on this page · raw message
net/sched/sch_generic.c +2 -3
@@ -166,7 +166,7 @@ static inline int qdisc_restart(struct netdev_queue *txq)HARD_TX_LOCK (dev, txq,smp_processor_id ());if (!netif_subqueue_stopped (dev, skb)) - ret =dev_hard_start_xmit (skb, dev); + ret =dev_hard_start_xmit (skb, dev, txq);HARD_TX_UNLOCK (dev, txq);spin_lock (&txq->lock);
@@ -198,11 +198,10 @@ static inline int qdisc_restart(struct netdev_queue *txq)void __qdisc_run (struct netdev_queue *txq) { -struct net_device *dev = txq->dev;unsigned long start_time = jiffies;while (qdisc_restart (txq)) { -if (netif_queue_stopped (dev)) +if (netif_tx_queue_stopped (txq))break ;/*
net/sched/sch_teql.c +2 -4
@@ -295,8 +295,7 @@ restart: slave_txq =netdev_get_tx_queue (slave,0 );if (slave_txq->qdisc_sleeping != q)continue ; -if (netif_queue_stopped (slave) || -__netif_subqueue_stopped (slave, subq) || +if (__netif_subqueue_stopped (slave, subq) || !netif_running (slave)) { busy =1 ;continue ;
@@ -305,8 +304,7 @@ restart:switch (teql_resolve (skb, skb_res, slave)) {case 0 :if (netif_tx_trylock (slave)) { -if (!netif_queue_stopped (slave) && - !__netif_subqueue_stopped (slave, subq) && +if (!__netif_subqueue_stopped (slave, subq) && slave->hard_start_xmit (skb, slave) ==0 ) {netif_tx_unlock (slave); master->slaves =NEXT_SLAVE (q);
Signature · 1 line
1.5.6.2.255.gbed62