Commit f7116fb4 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: sched: move and reuse mq_change_real_num_tx()

The code for handling active queue changes is identical
between mq and mqprio, reuse it.
Suggested-by: default avatarCong Wang <cong.wang@bytedance.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cbcca2e3
...@@ -1345,6 +1345,8 @@ void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc, ...@@ -1345,6 +1345,8 @@ void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc,
void mini_qdisc_pair_block_init(struct mini_Qdisc_pair *miniqp, void mini_qdisc_pair_block_init(struct mini_Qdisc_pair *miniqp,
struct tcf_block *block); struct tcf_block *block);
void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx);
int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb)); int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb));
#endif #endif
...@@ -1339,6 +1339,30 @@ void dev_qdisc_change_real_num_tx(struct net_device *dev, ...@@ -1339,6 +1339,30 @@ void dev_qdisc_change_real_num_tx(struct net_device *dev,
qdisc->ops->change_real_num_tx(qdisc, new_real_tx); qdisc->ops->change_real_num_tx(qdisc, new_real_tx);
} }
void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx)
{
#ifdef CONFIG_NET_SCHED
struct net_device *dev = qdisc_dev(sch);
struct Qdisc *qdisc;
unsigned int i;
for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
/* Only update the default qdiscs we created,
* qdiscs with handles are always hashed.
*/
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_del(qdisc);
}
for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_add(qdisc, false);
}
#endif
}
EXPORT_SYMBOL(mq_change_real_num_tx);
int dev_qdisc_change_tx_queue_len(struct net_device *dev) int dev_qdisc_change_tx_queue_len(struct net_device *dev)
{ {
bool up = dev->flags & IFF_UP; bool up = dev->flags & IFF_UP;
......
...@@ -125,29 +125,6 @@ static void mq_attach(struct Qdisc *sch) ...@@ -125,29 +125,6 @@ static void mq_attach(struct Qdisc *sch)
priv->qdiscs = NULL; priv->qdiscs = NULL;
} }
static void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx)
{
#ifdef CONFIG_NET_SCHED
struct net_device *dev = qdisc_dev(sch);
struct Qdisc *qdisc;
unsigned int i;
for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
/* Only update the default qdiscs we created,
* qdiscs with handles are always hashed.
*/
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_del(qdisc);
}
for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_add(qdisc, false);
}
#endif
}
static int mq_dump(struct Qdisc *sch, struct sk_buff *skb) static int mq_dump(struct Qdisc *sch, struct sk_buff *skb)
{ {
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
......
...@@ -306,28 +306,6 @@ static void mqprio_attach(struct Qdisc *sch) ...@@ -306,28 +306,6 @@ static void mqprio_attach(struct Qdisc *sch)
priv->qdiscs = NULL; priv->qdiscs = NULL;
} }
static void mqprio_change_real_num_tx(struct Qdisc *sch,
unsigned int new_real_tx)
{
struct net_device *dev = qdisc_dev(sch);
struct Qdisc *qdisc;
unsigned int i;
for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
/* Only update the default qdiscs we created,
* qdiscs with handles are always hashed.
*/
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_del(qdisc);
}
for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
if (qdisc != &noop_qdisc && !qdisc->handle)
qdisc_hash_add(qdisc, false);
}
}
static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch, static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch,
unsigned long cl) unsigned long cl)
{ {
...@@ -645,7 +623,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = { ...@@ -645,7 +623,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
.init = mqprio_init, .init = mqprio_init,
.destroy = mqprio_destroy, .destroy = mqprio_destroy,
.attach = mqprio_attach, .attach = mqprio_attach,
.change_real_num_tx = mqprio_change_real_num_tx, .change_real_num_tx = mq_change_real_num_tx,
.dump = mqprio_dump, .dump = mqprio_dump,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
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