net_sched: add size table functions
Subsystems (3)
PATCH v3 1/2 net_sched: add size table functions
Patch adds size table that is similiar to rate table, with difference that size table stores link layer packet size. It's needed for HFSC link layer adaption patch as it converts skb->len to link layer packet size directly, unlike HTB/CFQ/etc that convert packet length to link layer transfer time using rate tables.
---
include/linux/pkt_sched.h | 10 ++++++++++ include/net/pkt_sched.h | 3 +++ include/net/sch_generic.h | 23 ++++++++++++++++++++++ net/sched/sch_api.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 0 deletions(-)
include/linux/pkt_sched.h +10 -0
@@ -85,6 +85,16 @@ struct tc_ratespec#define TC_RTAB_SIZE 1024 +struct tc_sizespec { +unsigned char cell_log; +unsigned char size_log; +short overhead; +short cell_align; +unsigned short mpu; +}; + +#define TC_STAB_SIZE 1024 +/* FIFO section */ struct tc_fifo_qopt
include/net/pkt_sched.h +3 -0
@@ -78,7 +78,10 @@ extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);extern struct Qdisc *qdisc_lookup_class (struct net_device *dev,u32 handle);extern struct qdisc_rate_table *qdisc_get_rtab (struct tc_ratespec *r,struct nlattr *tab); +extern struct qdisc_size_table *qdisc_get_stab (struct tc_sizespec *s, +struct nlattr *tab);extern void qdisc_put_rtab (struct qdisc_rate_table *tab); +extern void qdisc_put_stab (struct qdisc_size_table *tab);extern void __qdisc_run (struct net_device *dev);
include/net/sch_generic.h +23 -0
@@ -23,6 +23,13 @@ struct qdisc_rate_tableint refcnt; }; +struct qdisc_size_table { +struct tc_sizespec szopts; +u16 data[512 ]; +struct qdisc_size_table *next; +int refcnt; +}; +struct Qdisc {int (*enqueue)(struct sk_buff *skb,struct Qdisc *dev);
@@ -316,6 +323,22 @@ static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen)return rtab->data[slot]; } +/* Length to link layer size lookup in a qdisc_size_table, to determine how +what size packet takes on link layer. +*/ +static inline u32 qdisc_linklayer_sz (struct qdisc_size_table *stab,u32 pktlen) +{ +int slot = pktlen + stab->szopts.cell_align + stab->szopts.overhead; +unsigned char size_log = stab->szopts.size_log; +if (unlikely (slot <0 )) + slot =0 ; + slot >>= stab->szopts.cell_log; +if (unlikely (slot >511 )) +return ((u32 )stab->data[511 ] << size_log) * (slot >>9 ) + + ((u32 )stab->data[slot &0x1FF ] << size_log); +return (u32 )stab->data[slot] << size_log; +} +#ifdef CONFIG_NET_CLS_ACT static inline struct sk_buff *skb_act_clone (struct sk_buff *skb,gfp_t gfp_mask) {
net/sched/sch_api.c +47 -0
53 lines not on this page · raw message
PATCH v3 2/2 hfsc: add link layer overhead adaption
CBQ and HTB have options for emulating overhead of underlying link layer (mpu/overhead/linklayer options). This patch makes sch_hfsc use size table to emulate link layer overhead.
Patch uses size table to convert packet length to emulated link layer packet length. Converted packet length is passed to hfsc calculations instead of real. If size table isn't passed to kernel, hfsc works as before.
---
include/linux/pkt_sched.h | 2 + net/sched/sch_hfsc.c | 116 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 93 insertions(+), 25 deletions(-)
include/linux/pkt_sched.h +2 -0
@@ -326,6 +326,8 @@ enumTCA_HFSC_RSC ,TCA_HFSC_FSC ,TCA_HFSC_USC , +TCA_HFSC_SZOPTS , +TCA_HFSC_STAB , __TCA_HFSC_MAX, };
net/sched/sch_hfsc.c +91 -25
236 lines not on this page · raw message
David Miller
maintainerFrom: Jussi Kivilinna <[email protected]>
Date: Fri, 04 Jul 2008 01:03:12 +0300
Quoted 7 lines
Patch adds size table that is similiar to rate table, with difference that size table stores link layer packet size. It's needed for HFSC link layer adaption patch as it converts
skb->lento link layer packet size directly, unlike HTB/CFQ/etc that convert packet length to link layer transfer time using rate tables.Signed-off-by Jussi Kivilinna <[email protected]>
Ok.
Patrick, can you give some feedback on these two patches?
Thanks!
Quoted 9 lines · David Miller
From: Jussi Kivilinna <[email protected]>
Date: Fri, 04 Jul 2008 01:03:12 +0300Quoted 6 lines
Patch adds size table that is similiar to rate table, with difference that size table stores link layer packet size. It's needed for HFSC link layer adaption patch as it converts
skb->lento link layer packet size directly, unlike HTB/CFQ/etc that convert packet length to link layer transfer time using rate tables.
Quoted 5 lines
Quoted 1 line
Signed-off-by Jussi Kivilinna <[email protected]>Ok.
Patrick, can you give some feedback on these two patches?
Sure, I'll review them tommorrow. Want to finish some VLAN fixes first.
Re: [PATCH v3 2/2] hfsc: add link layer overhead adaption
In reply to Jussi KivilinnaQuoted 8 lines · Jussi Kivilinna
CBQ and HTB have options for emulating overhead of underlying link layer (mpu/overhead/linklayer options). This patch makes
sch_hfscuse size table to emulate link layer overhead.Patch uses size table to convert packet length to emulated link layer packet length. Converted packet length is passed to hfsc calculations instead of real. If size table isn't passed to kernel, hfsc works as before.
net/sched/sch_hfsc.c sc2isc(struct tc_service_curve *sc, struct internal_sc *isc) · line 507
Quoted 7 lines
net/sched/sch_hfsc.c +7
-0+/* convert packet length to link layer packet length */ +static unsigned int get_linklayer_len (struct hfsc_class *cl,unsigned int len) +{ +if (unlikely (!len) ||likely (!cl->stab)) +return len; +return qdisc_linklayer_sz (cl->stab, len); +}
This means HFSC will use other packet sizes as inner qdiscs, policers, statistics etc, which I don't like very much. My original patch used the size tables to calculate the size when enqueing to the root qdisc and stored it in the cb, so all qdiscs in the hierarchy can use the same size.
net/sched/sch_hfsc.c hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc, · line 1004
Quoted 12 lines
net/sched/sch_hfsc.c +5
-3@@ -987,9 +997,11 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc, }static const struct nla_policy hfsc_policy[TCA_HFSC_MAX +1 ] = { - [TCA_HFSC_RSC ] = { .len =sizeof (struct tc_service_curve ) }, - [TCA_HFSC_FSC ] = { .len =sizeof (struct tc_service_curve ) }, - [TCA_HFSC_USC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_RSC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_FSC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_USC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_SZOPTS ] = { .len =sizeof (struct tc_sizespec ) }, + [TCA_HFSC_STAB ] = { .type =NLA_BINARY , .len =TC_STAB_SIZE },
Why are these two separate attributes?
Re: [PATCH v3 2/2] hfsc: add link layer overhead adaption
Quoting "Patrick McHardy" <[email protected]>:
Quoted 6 lines
This means HFSC will use other packet sizes as inner qdiscs, policers, statistics etc, which I don't like very much. My original patch used the size tables to calculate the size when enqueing to the root qdisc and stored it in the cb, so all qdiscs in the hierarchy can use the same size.
With this patch I have tried to make HFSC support link layer emulation in same way as done in HTB with rate table, so that overhead is defined on leaf qdisc (if have understood right).
I have used this patch to have different overhead between qdisc leafs to account for extra overhead of ipv6-in-ipv4 tunnel (redirecting traffic to IMQ device and filtering ipv4&ipv6 to corresponding leafs). If overhead/linklayer is defined on root qdisc, this wouldn't be possible?
I'm not too happy about statistics being affected either, I'll look in to it.
Quoted 6 lines
Quoted 6 lines
net/sched/sch_hfsc.c +0
-2@@ -987,9 +997,11 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc, }static const struct nla_policy hfsc_policy[TCA_HFSC_MAX +1 ] = { - [TCA_HFSC_RSC ] = { .len =sizeof (struct tc_service_curve ) }, - [TCA_HFSC_FSC ] = { .len =sizeof (struct tc_service_curve ) },
Quoted 8 lines
net/sched/sch_hfsc.c hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc, · line 1004
Quoted 6 lines
net/sched/sch_hfsc.c +5
-1- [TCA_HFSC_USC] = { .len = sizeof(struct tc_service_curve) }, + [TCA_HFSC_RSC] = { .len = sizeof(struct tc_service_curve) }, + [TCA_HFSC_FSC] = { .len = sizeof(struct tc_service_curve) }, + [TCA_HFSC_USC] = { .len = sizeof(struct tc_service_curve) }, + [TCA_HFSC_SZOPTS] = { .len = sizeof(struct tc_sizespec) }, + [TCA_HFSC_STAB] = { .type = NLA_BINARY, .len = TC_STAB_SIZE },Why are these two separate attributes?
I copied qdisc_get_rtab() to qdisc_get_stab() and qdisc_get_rtab uses nla_data(tab) to get the buffer. Should use single attribute instead?
I have worked on patch that would merge qdisc_get_rtab/stab to generic qdisc_get_xtab supporting both types of link layer emulation tables. With single attribute here, patch wouldn't work so easily.
- Jussi
Re: [PATCH v3 2/2] hfsc: add link layer overhead adaption
Quoted 9 lines · Jussi Kivilinna
Quoting "Patrick McHardy" <[email protected]>:
Quoted 6 lines
This means HFSC will use other packet sizes as inner qdiscs, policers, statistics etc, which I don't like very much. My original patch used the size tables to calculate the size when enqueing to the root qdisc and stored it in the cb, so all qdiscs in the hierarchy can use the same size.
With this patch I have tried to make HFSC support link layer emulation in same way as done in HTB with rate table, so that overhead is defined on leaf qdisc (if have understood right).
The difference is that with this approach you are actually able to make the entire qdisc hierarchy use the same size for calculations/statistics/etc. The rate tables only work in TBF based qdiscs and policers (which was always one of my complaints).
Quoted 2 lines
I have used this patch to have different overhead between qdisc leafs to account for extra overhead of ipv6-in-ipv4 tunnel (redirecting traffic to IMQ device and filtering ipv4&ipv6 to corresponding leafs). If overhead/linklayer is defined on root qdisc, this wouldn't be possible?
You could override the size in inner classes and qdiscs. Having an optional size table per qdisc would make this consistent from a user perspective with the top-level size calculation. (And I agree that including tunnel overhead makes sense).
Quoted 22 lines
I'm not too happy about statistics being affected either, I'll look in to it.
Quoted 10 lines
Quoted 10 lines
net/sched/sch_hfsc.c +2
-3@@ -987,9 +997,11 @@ hfsc_change_usc(struct hfsc_class *cl, struct tc_service_curve *usc, }static const struct nla_policy hfsc_policy[TCA_HFSC_MAX +1 ] = { - [TCA_HFSC_RSC ] = { .len =sizeof (struct tc_service_curve ) }, - [TCA_HFSC_FSC ] = { .len =sizeof (struct tc_service_curve ) }, - [TCA_HFSC_USC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_RSC ] = { .len =sizeof (struct tc_service_curve ) }, + [TCA_HFSC_FSC] = { .len = sizeof(structQuoted 8 lines
Quoted 6 lines
(quoted diff) +3
-0tc_service_curve) }, + [TCA_HFSC_USC] = { .len = sizeof(struct tc_service_curve) }, + [TCA_HFSC_SZOPTS] = { .len = sizeof(struct tc_sizespec) }, + [TCA_HFSC_STAB] = { .type = NLA_BINARY, .len =
TC_STAB_SIZE},Why are these two separate attributes?
Quoted 2 lines
I copied
qdisc_get_rtab()toqdisc_get_stab()andqdisc_get_rtabusesnla_data(tab)to get the buffer. Should use single attribute instead?
I have worked on patch that would merge qdisc_get_rtab/stab to genericqdisc_get_xtabsupporting both types of link layer emulation tables. With single attribute here, patch wouldn't work so easily.
Right, I forgot that rtabs also use two attribures. Well, usually they use one attribute and one structure embedded in their base structure, but only because they were using RTABs from the beginning. So that looks OK.
Re: [PATCH v3 2/2] hfsc: add link layer overhead adaption
Quoting "Patrick McHardy" <[email protected]>:
Quoted 18 lines
Quoted 9 lines · Jussi Kivilinna
Quoting "Patrick McHardy" <[email protected]>:
Quoted 6 lines
This means HFSC will use other packet sizes as inner qdiscs, policers, statistics etc, which I don't like very much. My original patch used the size tables to calculate the size when enqueing to the root qdisc and stored it in the cb, so all qdiscs in the hierarchy can use the same size.
With this patch I have tried to make HFSC support link layer emulation in same way as done in HTB with rate table, so that overhead is defined on leaf qdisc (if have understood right).
The difference is that with this approach you are actually able to make the entire qdisc hierarchy use the same size for calculations/statistics/etc. The rate tables only work in TBF based qdiscs and policers (which was always one of my complaints).
Quoted 1 line
Quoted 8 lines
Quoted 1 line
I have used this patch to have different overhead between qdisc leafs to account for extra overhead of ipv6-in-ipv4 tunnel (redirecting traffic to IMQ device and filtering ipv4&ipv6 to corresponding leafs). If overhead/linklayer is defined on root qdisc, this wouldn't be possible?
You could override the size in inner classes and qdiscs. Having an optional size table per qdisc would make this consistent from a user perspective with the top-level size calculation. (And I agree that including tunnel overhead makes sense).
Ok, having one table for whole qdisc tree (with overrides) sounds better.
- Jussi