fq: split out backlog update logic

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>
diff --git a/include/net/fq_impl.h b/include/net/fq_impl.h
index 02eab7c..163f3ed 100644
--- a/include/net/fq_impl.h
+++ b/include/net/fq_impl.h
@@ -120,25 +120,12 @@
 	return flow;
 }
 
-static void fq_tin_enqueue(struct fq *fq,
-			   struct fq_tin *tin,
-			   struct sk_buff *skb,
-			   fq_skb_free_t free_func,
-			   fq_flow_get_default_t get_default_func)
+static void fq_recalc_backlog(struct fq *fq,
+			      struct fq_tin *tin,
+			      struct fq_flow *flow)
 {
-	struct fq_flow *flow;
 	struct fq_flow *i;
 
-	lockdep_assert_held(&fq->lock);
-
-	flow = fq_flow_classify(fq, tin, skb, get_default_func);
-
-	flow->tin = tin;
-	flow->backlog += skb->len;
-	tin->backlog_bytes += skb->len;
-	tin->backlog_packets++;
-	fq->backlog++;
-
 	if (list_empty(&flow->backlogchain))
 		list_add_tail(&flow->backlogchain, &fq->backlogs);
 
@@ -149,6 +136,27 @@
 			break;
 
 	list_move(&flow->backlogchain, &i->backlogchain);
+}
+
+static void fq_tin_enqueue(struct fq *fq,
+			   struct fq_tin *tin,
+			   struct sk_buff *skb,
+			   fq_skb_free_t free_func,
+			   fq_flow_get_default_t get_default_func)
+{
+	struct fq_flow *flow;
+
+	lockdep_assert_held(&fq->lock);
+
+	flow = fq_flow_classify(fq, tin, skb, get_default_func);
+
+	flow->tin = tin;
+	flow->backlog += skb->len;
+	tin->backlog_bytes += skb->len;
+	tin->backlog_packets++;
+	fq->backlog++;
+
+	fq_recalc_backlog(fq, tin, flow);
 
 	if (list_empty(&flow->flowchain)) {
 		flow->deficit = fq->quantum;