From: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
To: netdev@vger.kernel.org
Cc: Patrick McHardy <kaber@trash.net>,
Stephen Hemminger <shemminger@osdl.org>
Subject: [PATCH v2 1/2] [iproute2/tc] tc_core: add size table
Date: Tue, 24 Jun 2008 11:55:14 +0300 [thread overview]
Message-ID: <20080624085514.22540.91038.stgit@fate.lan> (raw)
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.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
include/linux/pkt_sched.h | 10 ++++++
tc/tc_core.c | 73 ++++++++++++++++++++++++++++++++++++---------
tc/tc_core.h | 2 +
3 files changed, 70 insertions(+), 15 deletions(-)
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index dbb7ac3..b8366fb 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -85,6 +85,16 @@ struct tc_ratespec
#define TC_RTAB_SIZE 1024
+struct tc_sizespec {
+ unsigned char cell_log;
+ unsigned char size_log;
+ unsigned short overhead;
+ short cell_align;
+ unsigned short mpu;
+};
+
+#define TC_STAB_SIZE 1024
+
/* FIFO section */
struct tc_fifo_qopt
diff --git a/tc/tc_core.c b/tc/tc_core.c
index 855c115..ca509d9 100644
--- a/tc/tc_core.c
+++ b/tc/tc_core.c
@@ -87,6 +87,25 @@ unsigned tc_align_to_atm(unsigned size)
return linksize;
}
+unsigned tc_adjust_size(unsigned sz, unsigned mpu, enum link_layer linklayer)
+{
+ if (sz < mpu)
+ sz = mpu;
+
+ switch (linklayer) {
+ case LINKLAYER_ATM:
+ sz = tc_align_to_atm(sz);
+ break;
+ case LINKLAYER_ETHERNET:
+ // No size adjustments on Ethernet
+ break;
+ default:
+ break;
+ }
+
+ return sz;
+}
+
/*
rtab[pkt_len>>cell_log] = pkt_xmit_time
*/
@@ -109,21 +128,7 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
}
for (i=0; i<256; i++) {
- unsigned sz = (i+1)<<cell_log;
- if (sz < mpu)
- sz = mpu;
-
- switch (linklayer) {
- case LINKLAYER_ATM:
- sz = tc_align_to_atm(sz);
- break;
- case LINKLAYER_ETHERNET:
- // No size adjustments on Ethernet
- break;
- default:
- break;
- }
-
+ unsigned sz = tc_adjust_size((i+1)<<cell_log, mpu, linklayer);
rtab[i] = tc_calc_xmittime(bps, sz);
}
@@ -132,6 +137,44 @@ int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
return cell_log;
}
+/*
+ stab[pkt_len>>cell_log] = pkt_xmit_size
+ */
+
+int tc_calc_stable(struct tc_sizespec *s, __u16 *stab,
+ int cell_log, unsigned mtu,
+ enum link_layer linklayer)
+{
+ int i;
+ unsigned mpu = s->mpu;
+ unsigned size_log = 0;
+ unsigned sz;
+
+ if (mtu == 0)
+ mtu = 2047;
+
+ if (cell_log < 0) {
+ cell_log = 0;
+ while ((mtu >> cell_log) > 512 - 1)
+ cell_log++;
+ }
+
+again:
+ for (i = 512 - 1; i >= 0; i--) {
+ sz = tc_adjust_size((i + 1) << cell_log, mpu, linklayer);
+ if ((sz >> size_log) > UINT16_MAX) {
+ size_log++;
+ goto again;
+ }
+ stab[i] = sz >> size_log;
+ }
+
+ s->size_log = size_log;
+ s->cell_align = -1; // Due to the sz calc
+ s->cell_log = cell_log;
+ return cell_log;
+}
+
int tc_core_init()
{
FILE *fp;
diff --git a/tc/tc_core.h b/tc/tc_core.h
index 9f835e8..97a4894 100644
--- a/tc/tc_core.h
+++ b/tc/tc_core.h
@@ -21,6 +21,8 @@ unsigned tc_calc_xmittime(unsigned rate, unsigned size);
unsigned tc_calc_xmitsize(unsigned rate, unsigned ticks);
int tc_calc_rtable(struct tc_ratespec *r, __u32 *rtab,
int cell_log, unsigned mtu, enum link_layer link_layer);
+int tc_calc_stable(struct tc_sizespec *r, __u16 *stab,
+ int cell_log, unsigned mtu, enum link_layer link_layer);
int tc_setup_estimator(unsigned A, unsigned time_const, struct tc_estimator *est);
next reply other threads:[~2008-06-24 8:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-24 8:55 Jussi Kivilinna [this message]
2008-06-24 8:55 ` [PATCH v2 2/2] [iproute2/tc] hfsc: add link layer overhead adaption Jussi Kivilinna
2008-06-24 10:14 ` Andy Furniss
2008-06-24 19:58 ` Jussi Kivilinna
2008-06-24 21:39 ` Andy Furniss
2008-06-25 11:07 ` Patrick McHardy
2008-06-26 23:31 ` Jussi Kivilinna
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080624085514.22540.91038.stgit@fate.lan \
--to=jussi.kivilinna@mbnet.fi \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).