diff -ur iproute2-2.6.9.orig/include/linux/pkt_sched.h iproute2-2.6.9/include/linux/pkt_sched.h --- iproute2-2.6.9.orig/include/linux/pkt_sched.h Tue Oct 19 22:49:02 2004 +++ iproute2-2.6.9/include/linux/pkt_sched.h Fri Nov 12 20:14:00 2004 @@ -78,7 +78,7 @@ unsigned char cell_log; unsigned char __reserved; unsigned short feature; - short addend; + unsigned short overhead; unsigned short mpu; __u32 rate; }; diff -ur iproute2-2.6.9.orig/tc/q_htb.c iproute2-2.6.9/tc/q_htb.c --- iproute2-2.6.9.orig/tc/q_htb.c Tue Oct 19 22:49:02 2004 +++ iproute2-2.6.9/tc/q_htb.c Sat Mar 12 18:53:09 2005 @@ -42,6 +42,9 @@ " mpu minimum packet size used in rate computations\n" " overhead per-packet size overhead used in rate computations\n" + " cell_size used to calculate ATM SAR overhead \n" + " cell_payload (SAR = segmentation and reassembly) \n" + " ceil definite upper class rate (no borrows) {rate}\n" " cburst burst but for ceil {computed}\n" " mtu max packet size we create rate map for {1600}\n" @@ -108,7 +111,9 @@ unsigned buffer=0,cbuffer=0; int cell_log=-1,ccell_log = -1; unsigned mtu, mpu; - unsigned char mpu8 = 0, overhead = 0; + unsigned short cell_size, cell_payload; + unsigned char mpu8 = 0; + unsigned short overhead = 0; struct rtattr *tail; memset(&opt, 0, sizeof(opt)); mtu = 1600; /* eth packet len */ @@ -132,7 +137,7 @@ } } else if (matches(*argv, "overhead") == 0) { NEXT_ARG(); - if (get_u8(&overhead, *argv, 10)) { + if (get_u16(&overhead, *argv, 10)) { explain1("overhead"); return -1; } } else if (matches(*argv, "quantum") == 0) { @@ -140,6 +145,16 @@ if (get_u32(&opt.quantum, *argv, 10)) { explain1("quantum"); return -1; } + } else if (matches(*argv, "cell_size") == 0) { + NEXT_ARG(); + if (get_u16(&cell_size, *argv, 10)) { + explain1("cell_size"); return -1; + } + } else if (matches(*argv, "cell_payload") == 0) { + NEXT_ARG(); + if (get_u16(&cell_payload, *argv, 10)) { + explain1("cell_payload"); return -1; + } } else if (matches(*argv, "burst") == 0 || strcmp(*argv, "buffer") == 0 || strcmp(*argv, "maxburst") == 0) { @@ -205,10 +220,11 @@ sute that buffer is larger than mtu and to have some safeguard space */ if (!buffer) buffer = opt.rate.rate / get_hz() + mtu; if (!cbuffer) cbuffer = opt.ceil.rate / get_hz() + mtu; - + + opt.ceil.mpu = mpu8; opt.rate.mpu = mpu8; + opt.ceil.overhead = overhead; opt.rate.overhead = overhead; /* encode overhead and mpu, 8 bits each, into lower 16 bits */ mpu = (unsigned)mpu8 | (unsigned)overhead << 8; - opt.ceil.mpu = mpu; opt.rate.mpu = mpu; if ((cell_log = tc_calc_rtable(opt.rate.rate, rtab, cell_log, mtu, mpu)) < 0) { fprintf(stderr, "htb: failed to calculate rate table.\n"); @@ -272,8 +288,8 @@ fprintf(f, "cburst %s/%u mpu %s overhead %s ", sprint_size(cbuffer, b1), 1<ceil.cell_log, - sprint_size(hopt->ceil.mpu&0xFF, b2), - sprint_size((hopt->ceil.mpu>>8)&0xFF, b3)); + sprint_size(hopt->ceil.mpu, b2), + sprint_size(hopt->ceil.overhead, b3)); fprintf(f, "level %d ", (int)hopt->level); } else { fprintf(f, "burst %s ", sprint_size(buffer, b1)); diff -ur iproute2-2.6.9.orig/tc/tc_core.c iproute2-2.6.9/tc/tc_core.c --- iproute2-2.6.9.orig/tc/tc_core.c Tue Oct 19 22:49:02 2004 +++ iproute2-2.6.9/tc/tc_core.c Sat Mar 12 18:53:09 2005 @@ -42,6 +42,35 @@ return tc_core_usec2tick(1000000*((double)size/rate)); } +#ifndef ATM_CELL_SIZE +#define ATM_CELL_SIZE 53 /* ATM cell size incl. header */ +#endif +#ifndef ATM_CELL_PAYLOAD +#define ATM_CELL_PAYLOAD 48 /* ATM payload size */ +#endif + +#define ATM_ALIGN y + +/* + The align_to_cells is used for determining the (ATM) SAR alignment + overhead at the ATM layer. (SAR = Segmentation And Reassembly) + This is for example needed when scheduling packet on an ADSL + connection. The ATM-AAL overhead should preferably be added in the + kernel when doing table lookups (due to precision/alignment of the + table), if not the ATM-AAL overhead should be added to the size + before calling the function. --Hawk, d.7/11-2004. + */ +unsigned tc_align_to_cells(unsigned size, int cell_size, int cell_payload) +{ + int linksize, cells; + cells = size / cell_payload; + if ((size % cell_payload) > 0) { + cells++; + } + linksize = cells * cell_size; + return linksize; +} + /* rtab[pkt_len>>cell_log] = pkt_xmit_time */ @@ -62,11 +91,16 @@ cell_log++; } for (i=0; i<256; i++) { - unsigned sz = (i<