net/sched: use tc_qdisc_stats_dump() in qdisc
authorZhengchao Shao <shaozhengchao@huawei.com>
Wed, 21 Sep 2022 02:41:18 +0000 (10:41 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 23 Sep 2022 00:34:10 +0000 (17:34 -0700)
use tc_qdisc_stats_dump() in qdisc.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Tested-by: Victor Nogueira <victor@mojatatu.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
22 files changed:
net/sched/sch_atm.c
net/sched/sch_cake.c
net/sched/sch_cbq.c
net/sched/sch_cbs.c
net/sched/sch_drr.c
net/sched/sch_dsmark.c
net/sched/sch_ets.c
net/sched/sch_fq_codel.c
net/sched/sch_hfsc.c
net/sched/sch_htb.c
net/sched/sch_mq.c
net/sched/sch_mqprio.c
net/sched/sch_multiq.c
net/sched/sch_netem.c
net/sched/sch_prio.c
net/sched/sch_qfq.c
net/sched/sch_red.c
net/sched/sch_sfb.c
net/sched/sch_sfq.c
net/sched/sch_skbprio.c
net/sched/sch_taprio.c
net/sched/sch_tbf.c

index 816fd0d7ba38ad5c6cd791b32eef6af4bfb1b30c..f52255fea652beae735e514489db958a6ad1b7a1 100644 (file)
@@ -354,12 +354,8 @@ static void atm_tc_walk(struct Qdisc *sch, struct qdisc_walker *walker)
        if (walker->stop)
                return;
        list_for_each_entry(flow, &p->flows, list) {
-               if (walker->count >= walker->skip &&
-                   walker->fn(sch, (unsigned long)flow, walker) < 0) {
-                       walker->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, (unsigned long)flow, walker))
                        break;
-               }
-               walker->count++;
        }
 }
 
index 36acc95d611e5c243795ab8f0d0271dd99722812..55c6879d2c7e7fe0a452102e1704b9a00ba74684 100644 (file)
@@ -3061,16 +3061,13 @@ static void cake_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                struct cake_tin_data *b = &q->tins[q->tin_order[i]];
 
                for (j = 0; j < CAKE_QUEUES; j++) {
-                       if (list_empty(&b->flows[j].flowchain) ||
-                           arg->count < arg->skip) {
+                       if (list_empty(&b->flows[j].flowchain)) {
                                arg->count++;
                                continue;
                        }
-                       if (arg->fn(sch, i * CAKE_QUEUES + j + 1, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, i * CAKE_QUEUES + j + 1,
+                                                arg))
                                break;
-                       }
-                       arg->count++;
                }
        }
 }
index ba99ce05cd5274e1f9e2396a1382a48e5527bce2..6568e17c4c634184493d8e5414b6671aecc2d276 100644 (file)
@@ -1676,15 +1676,8 @@ static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        for (h = 0; h < q->clhash.hashsize; h++) {
                hlist_for_each_entry(cl, &q->clhash.hash[h], common.hnode) {
-                       if (arg->count < arg->skip) {
-                               arg->count++;
-                               continue;
-                       }
-                       if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, (unsigned long)cl, arg))
                                return;
-                       }
-                       arg->count++;
                }
        }
 }
index 459cc240eda9c44ded125519c9f86384f98a18f2..cac870eb7897305e952398108a7cb1edce71a27a 100644 (file)
@@ -520,13 +520,7 @@ static unsigned long cbs_find(struct Qdisc *sch, u32 classid)
 static void cbs_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 {
        if (!walker->stop) {
-               if (walker->count >= walker->skip) {
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               }
-               walker->count++;
+               tc_qdisc_stats_dump(sch, 1, walker);
        }
 }
 
index 4e5b1cf11b858dd5e9ef68ac4d85f7a776ad023e..e35a4e90f4e6ccfbaa033e2d9779c24fe1c983ad 100644 (file)
@@ -284,15 +284,8 @@ static void drr_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
-                       if (arg->count < arg->skip) {
-                               arg->count++;
-                               continue;
-                       }
-                       if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, (unsigned long)cl, arg))
                                return;
-                       }
-                       arg->count++;
                }
        }
 }
index 7da6dc38a3828293b8128929ad1e405ed6c096d8..401ffaf87d6221cda528dbfcbf2f0fe3d4c81585 100644 (file)
@@ -176,16 +176,12 @@ static void dsmark_walk(struct Qdisc *sch, struct qdisc_walker *walker)
                return;
 
        for (i = 0; i < p->indices; i++) {
-               if (p->mv[i].mask == 0xff && !p->mv[i].value)
-                       goto ignore;
-               if (walker->count >= walker->skip) {
-                       if (walker->fn(sch, i + 1, walker) < 0) {
-                               walker->stop = 1;
-                               break;
-                       }
+               if (p->mv[i].mask == 0xff && !p->mv[i].value) {
+                       walker->count++;
+                       continue;
                }
-ignore:
-               walker->count++;
+               if (!tc_qdisc_stats_dump(sch, i + 1, walker))
+                       break;
        }
 }
 
index a3aea22ef09da5dbfa347f6e073c369aa0a95750..b10efeaf0629d2ab8a5bbe2b080c3ef84d52717f 100644 (file)
@@ -341,15 +341,8 @@ static void ets_qdisc_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (i = 0; i < q->nbands; i++) {
-               if (arg->count < arg->skip) {
-                       arg->count++;
-                       continue;
-               }
-               if (arg->fn(sch, i + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, i + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index eeea8c6d54e29c6dd34a37a7452b6fc58893ea0b..99d318b60568237de48b5904b3198e1e8475b383 100644 (file)
@@ -673,16 +673,12 @@ static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (i = 0; i < q->flows_cnt; i++) {
-               if (list_empty(&q->flows[i].flowchain) ||
-                   arg->count < arg->skip) {
+               if (list_empty(&q->flows[i].flowchain)) {
                        arg->count++;
                        continue;
                }
-               if (arg->fn(sch, i + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, i + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index c8bef923c79c04d12c0f6a20a5e31809ff9e7235..70b0c5873d32666fb1a5469dfd25d1a43e4f63ef 100644 (file)
@@ -1349,15 +1349,8 @@ hfsc_walk(struct Qdisc *sch, struct qdisc_walker *arg)
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry(cl, &q->clhash.hash[i],
                                     cl_common.hnode) {
-                       if (arg->count < arg->skip) {
-                               arg->count++;
-                               continue;
-                       }
-                       if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, (unsigned long)cl, arg))
                                return;
-                       }
-                       arg->count++;
                }
        }
 }
index 78d0c7549c748615c073fd8788f77b53d7f8ca7d..e5b4bbf3ce3d5f36edb512d4017ebd97209bb377 100644 (file)
@@ -2119,15 +2119,8 @@ static void htb_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
-                       if (arg->count < arg->skip) {
-                               arg->count++;
-                               continue;
-                       }
-                       if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, (unsigned long)cl, arg))
                                return;
-                       }
-                       arg->count++;
                }
        }
 }
index 83d2e54bf303a4353be84416d998a76f37734086..d0bc660d7401f9d0b1509ac65e641622f51a99b3 100644 (file)
@@ -247,11 +247,8 @@ static void mq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        arg->count = arg->skip;
        for (ntx = arg->skip; ntx < dev->num_tx_queues; ntx++) {
-               if (arg->fn(sch, ntx + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, ntx + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index b29f3453c6eafe85208c1e5fe38961ef2203000e..4c68abaa289bd0c626a9bc82fac0f17fc61a94ba 100644 (file)
@@ -558,11 +558,8 @@ static void mqprio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
        /* Walk hierarchy with a virtual class per tc */
        arg->count = arg->skip;
        for (ntx = arg->skip; ntx < netdev_get_num_tc(dev); ntx++) {
-               if (arg->fn(sch, ntx + TC_H_MIN_PRIORITY, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, ntx + TC_H_MIN_PRIORITY, arg))
                        return;
-               }
-               arg->count++;
        }
 
        /* Pad the values and skip over unused traffic classes */
index f28050c7f12d6ffe161a025b2b1fd87428384fb8..75c9c860182b406e06e747455b1b7084fbab415d 100644 (file)
@@ -353,15 +353,8 @@ static void multiq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (band = 0; band < q->bands; band++) {
-               if (arg->count < arg->skip) {
-                       arg->count++;
-                       continue;
-               }
-               if (arg->fn(sch, band + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, band + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index b70ac04110dd50612e29a422c8173053221286c6..18f4273a835b9a4cd651e00cc673b36f20e87659 100644 (file)
@@ -1251,12 +1251,8 @@ static unsigned long netem_find(struct Qdisc *sch, u32 classid)
 static void netem_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 {
        if (!walker->stop) {
-               if (walker->count >= walker->skip)
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               walker->count++;
+               if (!tc_qdisc_stats_dump(sch, 1, walker))
+                       return;
        }
 }
 
index 298794c04836fc73fc1d3df6b9a7ea1f4acf70d3..fdc5ef52c3ee92c40232a5af7c68ce920b61b7e6 100644 (file)
@@ -376,15 +376,8 @@ static void prio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (prio = 0; prio < q->bands; prio++) {
-               if (arg->count < arg->skip) {
-                       arg->count++;
-                       continue;
-               }
-               if (arg->fn(sch, prio + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, prio + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index 13246a9dc5c1c0f1f74dbf46cc25c356c9b99366..cf5ebe43b3b4eb7f163da31cc565bc7faaab69e5 100644 (file)
@@ -659,15 +659,8 @@ static void qfq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        for (i = 0; i < q->clhash.hashsize; i++) {
                hlist_for_each_entry(cl, &q->clhash.hash[i], common.hnode) {
-                       if (arg->count < arg->skip) {
-                               arg->count++;
-                               continue;
-                       }
-                       if (arg->fn(sch, (unsigned long)cl, arg) < 0) {
-                               arg->stop = 1;
+                       if (!tc_qdisc_stats_dump(sch, (unsigned long)cl, arg))
                                return;
-                       }
-                       arg->count++;
                }
        }
 }
index 4952406f70b95073f56c56084d76649ddf2d9af6..a5a401f93c1a2654b6ada19177e6111079312b3b 100644 (file)
@@ -516,12 +516,7 @@ static unsigned long red_find(struct Qdisc *sch, u32 classid)
 static void red_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 {
        if (!walker->stop) {
-               if (walker->count >= walker->skip)
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               walker->count++;
+               tc_qdisc_stats_dump(sch, 1, walker);
        }
 }
 
index 1be8d04d69dc8a9b3bbe53d5f819fb222d6d6b62..e2389fa3cff8ac5ead731335e06fa9acff8b8ef4 100644 (file)
@@ -659,12 +659,7 @@ static int sfb_delete(struct Qdisc *sch, unsigned long cl,
 static void sfb_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 {
        if (!walker->stop) {
-               if (walker->count >= walker->skip)
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               walker->count++;
+               tc_qdisc_stats_dump(sch, 1, walker);
        }
 }
 
index f8e569f79f1367563bf92793dbd2a9c0a4ce957b..abd436307d6a8492d2d297c138d3b3e0309b949f 100644 (file)
@@ -888,16 +888,12 @@ static void sfq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (i = 0; i < q->divisor; i++) {
-               if (q->ht[i] == SFQ_EMPTY_SLOT ||
-                   arg->count < arg->skip) {
+               if (q->ht[i] == SFQ_EMPTY_SLOT) {
                        arg->count++;
                        continue;
                }
-               if (arg->fn(sch, i + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, i + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index df72fb83d9c7d88bb93d08c9a7453abe8a055eb0..5df2dacb7b1abaecdeaa5df5f38d98dc5e2f920d 100644 (file)
@@ -265,15 +265,8 @@ static void skbprio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
                return;
 
        for (i = 0; i < SKBPRIO_MAX_PRIORITY; i++) {
-               if (arg->count < arg->skip) {
-                       arg->count++;
-                       continue;
-               }
-               if (arg->fn(sch, i + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, i + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index 1853f08b7b12f4e20b8cf41a218cd2df202dd9cf..136ae21ebce95b839b0524a6bce87412510e96b7 100644 (file)
@@ -1953,11 +1953,8 @@ static void taprio_walk(struct Qdisc *sch, struct qdisc_walker *arg)
 
        arg->count = arg->skip;
        for (ntx = arg->skip; ntx < dev->num_tx_queues; ntx++) {
-               if (arg->fn(sch, ntx + 1, arg) < 0) {
-                       arg->stop = 1;
+               if (!tc_qdisc_stats_dump(sch, ntx + 1, arg))
                        break;
-               }
-               arg->count++;
        }
 }
 
index e031c1a41ea6b87524bb677b5613305c605ad660..277ad11f4d6135373e0a196ed423e0beddec1470 100644 (file)
@@ -580,12 +580,7 @@ static unsigned long tbf_find(struct Qdisc *sch, u32 classid)
 static void tbf_walk(struct Qdisc *sch, struct qdisc_walker *walker)
 {
        if (!walker->stop) {
-               if (walker->count >= walker->skip)
-                       if (walker->fn(sch, 1, walker) < 0) {
-                               walker->stop = 1;
-                               return;
-                       }
-               walker->count++;
+               tc_qdisc_stats_dump(sch, 1, walker);
        }
 }