From: =?iso-8859-1?q?alouini=20khalif?= Date: Sat, 08 Jun 2002 11:07:37 +0000 Subject: [LARTC] New qdisc path, please try it (what is the problem) Message-Id: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: lartc@vger.kernel.org hello, =20 this is my new qdisc patch, when i recompile the kernel with this patch i dn'nt succeed please look at it and if there are any mistakes plesease send me a mail =20 thanks in advance _______________________________________________________ --- linux-2.4.7-10orig/net/sched/Config.in +++ linux-2.4.4-10/net/sched/Config.in # Traffic control configuration. # tristate ' CBQ packet scheduler' CONFIG_NET_SCH_CBQ +tristate ' EPD packet scheduler' CONFIG_NET_SCH_EPD tristate ' CSZ packet scheduler' CONFIG_NET_SCH_CSZ #tristate ' H-PFQ packet scheduler' CONFIG_NET_SCH_HPFQ #tristate ' H-FSC packet scheduler' CONFIG_NET_SCH_HFCS --- linux-2.4.7-10orig/net/sched/Makefile +++ linux-2.4.7-10/net/sched/Makefile obj-$(CONFIG_NET_SCH_CSZ) +=3D sch_csz.o obj-$(CONFIG_NET_SCH_HPFQ) +=3D sch_hpfq.o obj-$(CONFIG_NET_SCH_HFSC) +=3D sch_hfsc.o +obj-$(CONFIG_NET_SCH_EPD) +=3D sch_epd.o obj-$(CONFIG_NET_SCH_SFQ) +=3D sch_sfq.o obj-$(CONFIG_NET_SCH_RED) +=3D sch_red.o obj-$(CONFIG_NET_SCH_TBF) +=3D sch_tbf.o --- linux-2.4.7-10orig/include/linux/pkt_sched.h +++ linux-2.4.7-10/include/linux/pkt_sched.h __u8 grio; }; +/* EPD section*/ +struct tc_epd_qopt +{ + __u32 limit; + __u32 threshold; +}; --- linux-2.4.7-10orig/net/sched/sch_api.c +++ linux-2.4.7-10/net/sched/sch_api.c #ifdef CONFIG_NET_SCH_CBQ INIT_QDISC(cbq); #endif +#ifdef CONFIG_NET_SCH_EPD + INIT_QDISC(epd); +#endif #ifdef CONFIG_NET_SCH_CSZ INIT_QDISC(csz); #endif --- linux-2.4.7-10orig/net/sched/sch_htb.c +++ linux-2.4.7-10/net/sched/sch_htb.c +/* + * net/sched/sch_epd.c Early packet discart (adaptation for multimedia stream.) + * + * This program is free software; you can redistribute it and/or + * modify it + * Authors: Alouini khalifa =20 + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Early packet discart (EPD) algorithm. Version 1.0 + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ This disciplin= e is taken from ATM world,this version is the simplest mode of EPD + In ATM, a packet is divided in many cells,if a new packet arrive and we reach a + threshold then we have to drop all new data unit (witch may be divided into + many cells) for the reason that one packet has no signification if some of its + data(cells) are dropped so if we have to reject one cell of a packet we have + to reject all sells that belongs to this packet (a packet=DAta unit) + To adaptate this discipline for multimedia stream, we market the IP packet + into the IP-OPION field (or TOS field) the number of data unit at which it + belongs then we only have to extract this information from the IP_OPTION + field (or from TOS fields) + +Short description. +------------------ + + When a new packet arrives we look at the queue length: + + + if (length packet passed. + if (length >threshold) ->tow possibilitties + if (it is a new data unit) -> packet dropped + if( it is an old data unit) ->packet accepted + if (length =3Dlimit) ->packet dropped + + Parameters, settable by user: + ----------------------------- + + limit - bytes + threshold -bytes +*/ +#define NET_XMIT_DROP 0 +#define NET_XMIT_SUCCESS 1 +struct epd_sched_data +{ +/* Parameters */ + unsigned limit; /* HARD maximal queue length */ + unsigned threshold; /* limit under witch, we drop a new data unit*/ + +/* Variables */ + unsigned current_unit ; /* the last unit=20 passed into the queue */ + unsigned dropped_unit; /*the unit that must be dropped because one packet of this unit + was dropped (it is the number of the last dropped unit) */ +}; + + +static int +epd_enqueue(struct sk_buff *skb, struct Qdisc* sch) +{ + struct epd_sched_data *q =3D (struct epd_sched_data *)sch->data; + int test =3Dverify_data_unit(skb,sch); /*verify if this packet belongs to data unit that is marked dropped + then we have to drop this packet*/ + if (test=3D0) + goto drop; + if (sch->stats.backlog <=3D q->threshold) + { + update_data_unit (skb,sch)/*if it is a new data unit we have to update the current_unit value*/ + goto enqueue; + } + else + { + u8 unit=3Dskb->nh.iph->tos; + if (unit =3D q->current_unit)/*if it is a segment of a data unit that is already enqueued + then we have to enqueue this packet*/ + goto enqueue; + else + { + update_reject_unit(skb,sch);/*if it is a new unit then apdate the dropped_unit value*/ + goto drop; + } + } +drop: + kfree_skb(skb); + sch->stats.drops++; + return NET_XMIT_DROP; + +enqueue: + __skb_queue_tail(&sch->q, skb); + sch->stats.backlog +=3D skb->len; + sch->stats.bytes +=3D skb->len; + sch->stats.packets++; + return NET_XMIT_SUCCESS; +} + +static int +epd_requeue(struct sk_buff *skb, struct Qdisc* sch) +{ + __skb_queue_head(&sch->q, skb); + sch->stats.backlog +=3D skb->len; + return 0; +} +static struct sk_buff * +epd_dequeue(struct Qdisc* sch) +{ + struct sk_buff *skb; + + skb =3D __skb_dequeue(&sch->q); + if (skb) + sch->stats.backlog -=3D skb->len; + return skb; + +static int +epd_drop(struct Qdisc* sch) +{ + struct sk_buff *skb; + skb =3D __skb_dequeue_tail(&sch->q); + if (skb) { + sch->stats.backlog -=3D skb->len; + sch->stats.drops++; + kfree_skb(skb); + return 1; + } + return 0; +} +static void +epd_reset(struct Qdisc* sch) +{ + skb_queue_purge(&sch->q); + sch->stats.backlog =3D 0; +} + + +static int epd_change(struct Qdisc *sch, struct rtattr *opt) +{ + return 0; +} + + + +static void epd_destroy(struct Qdisc *sch) +{ + MOD_DEC_USE_COUNT; +} + +static int +epd_init(struct Qdisc *sch, struct rtattr *opt) +{ + struct epd_sched_data *q =3D (void*)sch->data; + + if (opt =3D NULL) { + /* this is the first version ,no default attributes*/ + } + else + { + struct tc_epd_qopt *ctl =3D RTA_DATA(opt); + if (opt->rta_len < RTA_LENGTH(sizeof(*ctl))) + return -EINVAL; + q->limit =3D ctl->limit; + q->threshold=3D clt->threshold; + q->current_unit=3D0; + q->dropped_unit=3D0; + } + return 0; +} + +struct Qdisc_ops epd_qdisc_ops +{ + NULL, + NULL, + "epd", + sizeof(struct epd_sched_data), + + epd_enqueue, + epd_dequeue, + epd_requeue, + epd_drop, + + epd_init, + epd_reset, + epd_destroy, + epd_change, + + +#ifdef CONFIG_RTNETLINK + epd_dump, +#endif +}; + +#ifdef CONFIG_RTNETLINK +static int epd_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct epd_sched_data *q =3D (void*)sch->data; + unsigned char *b =3D skb->tail; + struct tc_epd_qopt opt; + + opt.limit =3D q->limit; + RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); + + return skb->len; + +rtattr_failure: + skb_trim(skb, b - skb->data); + return -1; +} + + +void +update_reject_unit(sk_buffer *skb,struct Qdisc *sch) +{ +unsigned unit=3D skb->nh.iph->tos; +struct epd_sched_data *q =3D (struct epd_sched_data *)sch->data; +q->dropped_unit=3Dunit; +} +void + update_data_unit (sk_buffer *skb,struct Qdisc *sch) +{ +unsigned unit=3D skb->nh.iph->tos; +struct epd_sched_data *q =3D (struct epd_sched_data *)sch->data; +if (q->current_unit !=3D unit) + q->current_unit=3Dunit; +} + +static int + verify_data_unit(skb,sch) +{ +unsigned unit=3Dskb->nh.iph->tos; +struct epd_sched_data *q =3D (struct epd_sched_data *)sch->data; +if (tos=3Dq->dropped_unit) + return 0; +else + return 1; +} ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran=E7ais ! Yahoo! Mail : http://fr.mail.yahoo.com _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/