Commit 589983cd authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

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: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af356afa
...@@ -302,6 +302,8 @@ extern void dev_init_scheduler(struct net_device *dev); ...@@ -302,6 +302,8 @@ extern void dev_init_scheduler(struct net_device *dev);
extern void dev_shutdown(struct net_device *dev); extern void dev_shutdown(struct net_device *dev);
extern void dev_activate(struct net_device *dev); extern void dev_activate(struct net_device *dev);
extern void dev_deactivate(struct net_device *dev); extern void dev_deactivate(struct net_device *dev);
extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
struct Qdisc *qdisc);
extern void qdisc_reset(struct Qdisc *qdisc); extern void qdisc_reset(struct Qdisc *qdisc);
extern void qdisc_destroy(struct Qdisc *qdisc); extern void qdisc_destroy(struct Qdisc *qdisc);
extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n);
......
...@@ -610,32 +610,6 @@ static u32 qdisc_alloc_handle(struct net_device *dev) ...@@ -610,32 +610,6 @@ static u32 qdisc_alloc_handle(struct net_device *dev)
return i>0 ? autohandle : 0; return i>0 ? autohandle : 0;
} }
/* Attach toplevel qdisc to device queue. */
static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
struct Qdisc *qdisc)
{
struct Qdisc *oqdisc = dev_queue->qdisc_sleeping;
spinlock_t *root_lock;
root_lock = qdisc_lock(oqdisc);
spin_lock_bh(root_lock);
/* Prune old scheduler */
if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1)
qdisc_reset(oqdisc);
/* ... and graft new one */
if (qdisc == NULL)
qdisc = &noop_qdisc;
dev_queue->qdisc_sleeping = qdisc;
rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc);
spin_unlock_bh(root_lock);
return oqdisc;
}
void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n) void qdisc_tree_decrease_qlen(struct Qdisc *sch, unsigned int n)
{ {
const struct Qdisc_class_ops *cops; const struct Qdisc_class_ops *cops;
......
...@@ -623,6 +623,31 @@ void qdisc_destroy(struct Qdisc *qdisc) ...@@ -623,6 +623,31 @@ void qdisc_destroy(struct Qdisc *qdisc)
} }
EXPORT_SYMBOL(qdisc_destroy); EXPORT_SYMBOL(qdisc_destroy);
/* Attach toplevel qdisc to device queue. */
struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue,
struct Qdisc *qdisc)
{
struct Qdisc *oqdisc = dev_queue->qdisc_sleeping;
spinlock_t *root_lock;
root_lock = qdisc_lock(oqdisc);
spin_lock_bh(root_lock);
/* Prune old scheduler */
if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1)
qdisc_reset(oqdisc);
/* ... and graft new one */
if (qdisc == NULL)
qdisc = &noop_qdisc;
dev_queue->qdisc_sleeping = qdisc;
rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc);
spin_unlock_bh(root_lock);
return oqdisc;
}
static void attach_one_default_qdisc(struct net_device *dev, static void attach_one_default_qdisc(struct net_device *dev,
struct netdev_queue *dev_queue, struct netdev_queue *dev_queue,
void *_unused) void *_unused)
......
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