[PATCH] hfsc: add link layer overhead adaption

Previous thread: [patch v1.2.30] wan: add driver retina by Matti Linnanvuori on Monday, June 23, 2008 - 2:19 am. (1 message)

Next thread: [PATCH] [iproute2/tc] hfsc: add link layer overhead adaption by Jussi Kivilinna on Monday, June 23, 2008 - 3:25 am. (1 message)
From: Jussi Kivilinna
Date: Monday, June 23, 2008 - 3:25 am

CBQ and HTB have options for emulating overhead of underlying link layer
(mpu/overhead/linklayer options). This patch makes sch_hfsc use rate table
to emulate link layer overhead.

Patch uses rate table to convert packet length to emulated link layer packet
length using qdisc_l2t() in get_linklayer_len(). Converted packet length is
passed to hfsc calculations instead of real. If rate table isn't passed to
kernel, hfsc works as before.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---

 include/linux/pkt_sched.h |    2 +
 net/sched/sch_hfsc.c      |  125 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 102 insertions(+), 25 deletions(-)

diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index dbb7ac3..1d2cb24 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -316,6 +316,8 @@ enum
 	TCA_HFSC_RSC,
 	TCA_HFSC_FSC,
 	TCA_HFSC_USC,
+	TCA_HFSC_RATEOPTS,
+	TCA_HFSC_RTAB,
 	__TCA_HFSC_MAX,
 };
 
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index fdfaa3f..94fd130 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -128,6 +128,8 @@ struct hfsc_class
 	struct list_head siblings;	/* sibling classes */
 	struct list_head children;	/* child classes */
 	struct Qdisc	*qdisc;		/* leaf qdisc */
+	struct qdisc_rate_table *rtab;	/* rate table used for link layer
+					   overhead adaption */
 
 	struct rb_node el_node;		/* qdisc's eligible tree member */
 	struct rb_root vt_tree;		/* active children sorted by cl_vt */
@@ -496,6 +498,20 @@ sc2isc(struct tc_service_curve *sc, struct internal_sc *isc)
 	isc->ism2 = m2ism(sc->m2);
 }
 
+/* convert packet length to link layer packet length */
+static unsigned int get_linklayer_len(struct hfsc_class *cl, unsigned int len)
+{
+	u64 ll_len;
+	if (likely(len) && unlikely(cl->rtab)) {
+		ll_len = qdisc_l2t(cl->rtab, len);
+		if (unlikely(cl->rtab->rate.rate != PSCHED_TICKS_PER_SEC))
+			ll_len = div_u64(ll_len * ...
From: Patrick McHardy
Date: Monday, June 23, 2008 - 3:57 am

This looks like an abuse of rate tables, which usually convert
packet sizes to transmission times. You undo that above using
expensive calculations.

I think this should be done by performing the length calculation
in the kernel directly.
--

From: Jussi Kivilinna
Date: Monday, June 23, 2008 - 4:24 am

Yes, it's abuse, and actually table is created using false rate (rate  
= PSCHED_TICKS_PER_SEC) so div_u64 is avoided. Div_u64 is there just  
in case something goes wrong in userspace. Using rate table allows  
changes/updates to link layer emulation with only userspace updates  
avoiding, but maybe abuse of rate table isn't right way to do this  
after all.

So would it be better if I add 'length table' to kernel&userspace and  
use it instead?

  - Jussi


--

From: Patrick McHardy
Date: Monday, June 23, 2008 - 4:27 am

Yes, I even posted an unfinished patch for this one or two years
ago, in response to the overhead calculation patches for HTB etc.

I can't find it right now, but haven't tried too hard. It was
called qdisc STABs (for size tables), you should be able to find
it in the archives.
--

From: Jussi Kivilinna
Date: Monday, June 23, 2008 - 12:15 pm

Well, my LTAB didn't end up being exactly same your earlier STAB, but  
I renamed LTAB to STAB as it sounds better. Hope you don't mind :]


--

From: Patrick McHardy
Date: Monday, June 23, 2008 - 12:37 pm

Not at all :) Did you already post that patch?
--

From: Jussi Kivilinna
Date: Monday, June 23, 2008 - 3:29 pm

Need to do some more testing, I'll post patch(es) tomorrow.



--

Previous thread: [patch v1.2.30] wan: add driver retina by Matti Linnanvuori on Monday, June 23, 2008 - 2:19 am. (1 message)

Next thread: [PATCH] [iproute2/tc] hfsc: add link layer overhead adaption by Jussi Kivilinna on Monday, June 23, 2008 - 3:25 am. (1 message)