]> git.karo-electronics.de Git - linux-beck.git/commitdiff
fq: split out backlog update logic
authorMichal Kazior <michal.kazior@tieto.com>
Wed, 27 Apr 2016 10:59:13 +0000 (12:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Apr 2016 21:03:38 +0000 (17:03 -0400)
mac80211 (which will be the first user of the
fq.h) recently started to support software A-MSDU
aggregation. It glues skbuffs together into a
single one so the backlog accounting needs to be
more fine-grained.

To avoid backlog sorting logic duplication split
it up for re-use.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/fq_impl.h

index 02eab7c51adbbdd4b99102e2a750e6b0b5b8dd1f..163f3ed0f05a741ed0f18933895f48a7c91bf754 100644 (file)
@@ -120,6 +120,24 @@ static struct fq_flow *fq_flow_classify(struct fq *fq,
        return flow;
 }
 
+static void fq_recalc_backlog(struct fq *fq,
+                             struct fq_tin *tin,
+                             struct fq_flow *flow)
+{
+       struct fq_flow *i;
+
+       if (list_empty(&flow->backlogchain))
+               list_add_tail(&flow->backlogchain, &fq->backlogs);
+
+       i = flow;
+       list_for_each_entry_continue_reverse(i, &fq->backlogs,
+                                            backlogchain)
+               if (i->backlog > flow->backlog)
+                       break;
+
+       list_move(&flow->backlogchain, &i->backlogchain);
+}
+
 static void fq_tin_enqueue(struct fq *fq,
                           struct fq_tin *tin,
                           struct sk_buff *skb,
@@ -127,7 +145,6 @@ static void fq_tin_enqueue(struct fq *fq,
                           fq_flow_get_default_t get_default_func)
 {
        struct fq_flow *flow;
-       struct fq_flow *i;
 
        lockdep_assert_held(&fq->lock);
 
@@ -139,16 +156,7 @@ static void fq_tin_enqueue(struct fq *fq,
        tin->backlog_packets++;
        fq->backlog++;
 
-       if (list_empty(&flow->backlogchain))
-               list_add_tail(&flow->backlogchain, &fq->backlogs);
-
-       i = flow;
-       list_for_each_entry_continue_reverse(i, &fq->backlogs,
-                                            backlogchain)
-               if (i->backlog > flow->backlog)
-                       break;
-
-       list_move(&flow->backlogchain, &i->backlogchain);
+       fq_recalc_backlog(fq, tin, flow);
 
        if (list_empty(&flow->flowchain)) {
                flow->deficit = fq->quantum;