]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: sched: move and reuse mq_change_real_num_tx()
authorJakub Kicinski <kuba@kernel.org>
Fri, 17 Sep 2021 13:55:06 +0000 (06:55 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 19 Sep 2021 12:26:01 +0000 (13:26 +0100)
The code for handling active queue changes is identical
between mq and mqprio, reuse it.

Suggested-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h
net/sched/sch_generic.c
net/sched/sch_mq.c
net/sched/sch_mqprio.c

index 8c2d611639fcadb5bd2f9109eeb4c2e557ff1589..5a011f8d394ea4da13ff9a4b3e79b74943702978 100644 (file)
@@ -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,
                                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));
 
 #endif
index 66d2fbe9ef5014a4eb849008221091121ad71c08..8c64a552a64fe44485f8b6d37243ad15e22ca0b3 100644 (file)
@@ -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);
 }
 
+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)
 {
        bool up = dev->flags & IFF_UP;
index db18d8a860f9cc50608afe47d1b0fa9996295505..e04f1a87642b9f9f68ed2261cff564c68e9c2c4b 100644 (file)
@@ -125,29 +125,6 @@ static void mq_attach(struct Qdisc *sch)
        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)
 {
        struct net_device *dev = qdisc_dev(sch);
index 7f23a92849d5df1fc538fe8bd242b7c6fbf6e4be..0bc10234e30660b7a3580c00fb2162d2d13e2c86 100644 (file)
@@ -306,28 +306,6 @@ static void mqprio_attach(struct Qdisc *sch)
        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,
                                             unsigned long cl)
 {
@@ -645,7 +623,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
        .init           = mqprio_init,
        .destroy        = mqprio_destroy,
        .attach         = mqprio_attach,
-       .change_real_num_tx = mqprio_change_real_num_tx,
+       .change_real_num_tx = mq_change_real_num_tx,
        .dump           = mqprio_dump,
        .owner          = THIS_MODULE,
 };