aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2009-09-04 02:41:20 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-06 05:07:05 -0400
commit589983cd21f4a2e4ed74a958805a90fa676845c5 (patch)
tree21ce556958da203400d3e9d30911ff330be39e90
parentaf356afa010f3cd2c8b8fcc3bce90f7a7b7ec02a (diff)
net_sched: move dev_graft_qdisc() to sch_generic.c
It will be used in a following patch by the multiqueue qdisc. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sch_generic.h2
-rw-r--r--net/sched/sch_api.c26
-rw-r--r--net/sched/sch_generic.c25
3 files changed, 27 insertions, 26 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index a48a4cc7258b..a92dc6208eff 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -302,6 +302,8 @@ extern void dev_init_scheduler(struct net_device *dev);
302extern void dev_shutdown(struct net_device *dev); 302extern void dev_shutdown(struct net_device *dev);
303extern void dev_activate(struct net_device *dev); 303extern void dev_activate(struct net_device *dev);
304extern void dev_deactivate(struct net_device *dev); 304extern void dev_deactivate(struct net_device *dev);
305extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
306 struct Qdisc *qdisc);
305extern void qdisc_reset(struct Qdisc *qdisc); 307extern void qdisc_reset(struct Qdisc *qdisc);
306extern void qdisc_destroy(struct Qdisc *qdisc); 308extern void qdisc_destroy(struct Qdisc *qdisc);
307extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); 309extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 8aa9a0c5a9eb..d71f12be6e29 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -610,32 +610,6 @@ static u32 qdisc_alloc_handle(struct net_device *dev)
610 return i>0 ? autohandle : 0; 610 return i>0 ? autohandle : 0;
611} 611}
612 612
613/* Attach toplevel qdisc to device queue. */
614
615static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
616 struct Qdisc *qdisc)
617{
618 struct Qdisc *oqdisc = dev_queue->qdisc_sleeping;
619 spinlock_t *root_lock;
620
621 root_lock = qdisc_lock(oqdisc);
622 spin_lock_bh(root_lock);
623
624 /* Prune old scheduler */
625 if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1)
626 qdisc_reset(oqdisc);
627
628 /* ... and graft new one */
629 if (qdisc == NULL)
630 qdisc = &noop_qdisc;
631 dev_queue->qdisc_sleeping = qdisc;
632 rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc);
633
634 spin_unlock_bh(root_lock);
635
636 return oqdisc;
637}
638
639void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n) 613void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
640{ 614{
641 const struct Qdisc_class_ops *cops; 615 const struct Qdisc_class_ops *cops;
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index a91f079fb47a..e7c47ceb0098 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -623,6 +623,31 @@ void qdisc_destroy(struct Qdisc *qdisc)
623} 623}
624EXPORT_SYMBOL(qdisc_destroy); 624EXPORT_SYMBOL(qdisc_destroy);
625 625
626/* Attach toplevel qdisc to device queue. */
627struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
628 struct Qdisc *qdisc)
629{
630 struct Qdisc *oqdisc = dev_queue->qdisc_sleeping;
631 spinlock_t *root_lock;
632
633 root_lock = qdisc_lock(oqdisc);
634 spin_lock_bh(root_lock);
635
636 /* Prune old scheduler */
637 if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1)
638 qdisc_reset(oqdisc);
639
640 /* ... and graft new one */
641 if (qdisc == NULL)
642 qdisc = &noop_qdisc;
643 dev_queue->qdisc_sleeping = qdisc;
644 rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc);
645
646 spin_unlock_bh(root_lock);
647
648 return oqdisc;
649}
650
626static void attach_one_default_qdisc(struct net_device *dev, 651static void attach_one_default_qdisc(struct net_device *dev,
627 struct netdev_queue *dev_queue, 652 struct netdev_queue *dev_queue,
628 void *_unused) 653 void *_unused)