aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/netdevice.h69
-rw-r--r--include/net/sch_generic.h37
2 files changed, 72 insertions, 34 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 570cf7affa72..f25d4f5a31b0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -463,7 +463,7 @@ struct netdev_queue {
463 struct Qdisc *qdisc_sleeping; 463 struct Qdisc *qdisc_sleeping;
464 struct list_head qdisc_list; 464 struct list_head qdisc_list;
465 struct netdev_queue *next_sched; 465 struct netdev_queue *next_sched;
466}; 466} ____cacheline_aligned_in_smp;
467 467
468/* 468/*
469 * The DEVICE structure. 469 * The DEVICE structure.
@@ -641,7 +641,9 @@ struct net_device
641 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 641 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
642 642
643 struct netdev_queue rx_queue; 643 struct netdev_queue rx_queue;
644 struct netdev_queue tx_queue ____cacheline_aligned_in_smp; 644
645 struct netdev_queue *_tx ____cacheline_aligned_in_smp;
646 unsigned int num_tx_queues;
645 unsigned long tx_queue_len; /* Max frames per queue allowed */ 647 unsigned long tx_queue_len; /* Max frames per queue allowed */
646 648
647/* 649/*
@@ -764,6 +766,25 @@ struct net_device
764#define NETDEV_ALIGN 32 766#define NETDEV_ALIGN 32
765#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) 767#define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1)
766 768
769static inline
770struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
771 unsigned int index)
772{
773 return &dev->_tx[index];
774}
775
776static inline void netdev_for_each_tx_queue(struct net_device *dev,
777 void (*f)(struct net_device *,
778 struct netdev_queue *,
779 void *),
780 void *arg)
781{
782 unsigned int i;
783
784 for (i = 0; i < dev->num_tx_queues; i++)
785 f(dev, &dev->_tx[i], arg);
786}
787
767/* 788/*
768 * Net namespace inlines 789 * Net namespace inlines
769 */ 790 */
@@ -977,7 +998,7 @@ static inline void netif_schedule_queue(struct netdev_queue *txq)
977 998
978static inline void netif_schedule(struct net_device *dev) 999static inline void netif_schedule(struct net_device *dev)
979{ 1000{
980 netif_schedule_queue(&dev->tx_queue); 1001 netif_schedule_queue(netdev_get_tx_queue(dev, 0));
981} 1002}
982 1003
983/** 1004/**
@@ -993,7 +1014,7 @@ static inline void netif_tx_start_queue(struct netdev_queue *dev_queue)
993 1014
994static inline void netif_start_queue(struct net_device *dev) 1015static inline void netif_start_queue(struct net_device *dev)
995{ 1016{
996 netif_tx_start_queue(&dev->tx_queue); 1017 netif_tx_start_queue(netdev_get_tx_queue(dev, 0));
997} 1018}
998 1019
999/** 1020/**
@@ -1017,7 +1038,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
1017 1038
1018static inline void netif_wake_queue(struct net_device *dev) 1039static inline void netif_wake_queue(struct net_device *dev)
1019{ 1040{
1020 netif_tx_wake_queue(&dev->tx_queue); 1041 netif_tx_wake_queue(netdev_get_tx_queue(dev, 0));
1021} 1042}
1022 1043
1023/** 1044/**
@@ -1034,7 +1055,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)
1034 1055
1035static inline void netif_stop_queue(struct net_device *dev) 1056static inline void netif_stop_queue(struct net_device *dev)
1036{ 1057{
1037 netif_tx_stop_queue(&dev->tx_queue); 1058 netif_tx_stop_queue(netdev_get_tx_queue(dev, 0));
1038} 1059}
1039 1060
1040/** 1061/**
@@ -1050,7 +1071,7 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1050 1071
1051static inline int netif_queue_stopped(const struct net_device *dev) 1072static inline int netif_queue_stopped(const struct net_device *dev)
1052{ 1073{
1053 return netif_tx_queue_stopped(&dev->tx_queue); 1074 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1054} 1075}
1055 1076
1056/** 1077/**
@@ -1134,7 +1155,7 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
1134#endif 1155#endif
1135 if (test_and_clear_bit(__QUEUE_STATE_XOFF, 1156 if (test_and_clear_bit(__QUEUE_STATE_XOFF,
1136 &dev->egress_subqueue[queue_index].state)) 1157 &dev->egress_subqueue[queue_index].state))
1137 __netif_schedule(&dev->tx_queue); 1158 __netif_schedule(netdev_get_tx_queue(dev, 0));
1138} 1159}
1139 1160
1140/** 1161/**
@@ -1430,18 +1451,19 @@ static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu)
1430 1451
1431static inline void netif_tx_lock(struct net_device *dev) 1452static inline void netif_tx_lock(struct net_device *dev)
1432{ 1453{
1433 __netif_tx_lock(&dev->tx_queue, smp_processor_id()); 1454 int cpu = smp_processor_id();
1434} 1455 unsigned int i;
1435 1456
1436static inline void __netif_tx_lock_bh(struct netdev_queue *txq) 1457 for (i = 0; i < dev->num_tx_queues; i++) {
1437{ 1458 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1438 spin_lock_bh(&txq->_xmit_lock); 1459 __netif_tx_lock(txq, cpu);
1439 txq->xmit_lock_owner = smp_processor_id(); 1460 }
1440} 1461}
1441 1462
1442static inline void netif_tx_lock_bh(struct net_device *dev) 1463static inline void netif_tx_lock_bh(struct net_device *dev)
1443{ 1464{
1444 __netif_tx_lock_bh(&dev->tx_queue); 1465 local_bh_disable();
1466 netif_tx_lock(dev);
1445} 1467}
1446 1468
1447static inline int __netif_tx_trylock(struct netdev_queue *txq) 1469static inline int __netif_tx_trylock(struct netdev_queue *txq)
@@ -1454,7 +1476,7 @@ static inline int __netif_tx_trylock(struct netdev_queue *txq)
1454 1476
1455static inline int netif_tx_trylock(struct net_device *dev) 1477static inline int netif_tx_trylock(struct net_device *dev)
1456{ 1478{
1457 return __netif_tx_trylock(&dev->tx_queue); 1479 return __netif_tx_trylock(netdev_get_tx_queue(dev, 0));
1458} 1480}
1459 1481
1460static inline void __netif_tx_unlock(struct netdev_queue *txq) 1482static inline void __netif_tx_unlock(struct netdev_queue *txq)
@@ -1465,18 +1487,19 @@ static inline void __netif_tx_unlock(struct netdev_queue *txq)
1465 1487
1466static inline void netif_tx_unlock(struct net_device *dev) 1488static inline void netif_tx_unlock(struct net_device *dev)
1467{ 1489{
1468 __netif_tx_unlock(&dev->tx_queue); 1490 unsigned int i;
1469} 1491
1492 for (i = 0; i < dev->num_tx_queues; i++) {
1493 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
1494 __netif_tx_unlock(txq);
1495 }
1470 1496
1471static inline void __netif_tx_unlock_bh(struct netdev_queue *txq)
1472{
1473 txq->xmit_lock_owner = -1;
1474 spin_unlock_bh(&txq->_xmit_lock);
1475} 1497}
1476 1498
1477static inline void netif_tx_unlock_bh(struct net_device *dev) 1499static inline void netif_tx_unlock_bh(struct net_device *dev)
1478{ 1500{
1479 __netif_tx_unlock_bh(&dev->tx_queue); 1501 netif_tx_unlock(dev);
1502 local_bh_enable();
1480} 1503}
1481 1504
1482#define HARD_TX_LOCK(dev, txq, cpu) { \ 1505#define HARD_TX_LOCK(dev, txq, cpu) { \
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 5ba66b555578..b47f556c66f8 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -230,32 +230,47 @@ extern void tcf_destroy_chain(struct tcf_proto **fl);
230/* Reset all TX qdiscs of a device. */ 230/* Reset all TX qdiscs of a device. */
231static inline void qdisc_reset_all_tx(struct net_device *dev) 231static inline void qdisc_reset_all_tx(struct net_device *dev)
232{ 232{
233 qdisc_reset(dev->tx_queue.qdisc); 233 unsigned int i;
234 for (i = 0; i < dev->num_tx_queues; i++)
235 qdisc_reset(netdev_get_tx_queue(dev, i)->qdisc);
234} 236}
235 237
236/* Are all TX queues of the device empty? */ 238/* Are all TX queues of the device empty? */
237static inline bool qdisc_all_tx_empty(const struct net_device *dev) 239static inline bool qdisc_all_tx_empty(const struct net_device *dev)
238{ 240{
239 const struct netdev_queue *txq = &dev->tx_queue; 241 unsigned int i;
240 const struct Qdisc *q = txq->qdisc; 242 for (i = 0; i < dev->num_tx_queues; i++) {
243 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
244 const struct Qdisc *q = txq->qdisc;
241 245
242 return (q->q.qlen == 0); 246 if (q->q.qlen)
247 return false;
248 }
249 return true;
243} 250}
244 251
245/* Are any of the TX qdiscs changing? */ 252/* Are any of the TX qdiscs changing? */
246static inline bool qdisc_tx_changing(struct net_device *dev) 253static inline bool qdisc_tx_changing(struct net_device *dev)
247{ 254{
248 struct netdev_queue *txq = &dev->tx_queue; 255 unsigned int i;
249 256 for (i = 0; i < dev->num_tx_queues; i++) {
250 return (txq->qdisc != txq->qdisc_sleeping); 257 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
258 if (txq->qdisc != txq->qdisc_sleeping)
259 return true;
260 }
261 return false;
251} 262}
252 263
253/* Is the device using the noop qdisc? */ 264/* Is the device using the noop qdisc on all queues? */
254static inline bool qdisc_tx_is_noop(const struct net_device *dev) 265static inline bool qdisc_tx_is_noop(const struct net_device *dev)
255{ 266{
256 const struct netdev_queue *txq = &dev->tx_queue; 267 unsigned int i;
257 268 for (i = 0; i < dev->num_tx_queues; i++) {
258 return (txq->qdisc == &noop_qdisc); 269 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
270 if (txq->qdisc != &noop_qdisc)
271 return false;
272 }
273 return true;
259} 274}
260 275
261static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, 276static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch,