Loading include/linux/pkt_sched.h +22 −26 Original line number Diff line number Diff line Loading @@ -194,15 +194,11 @@ enum #define TCA_GRED_MAX (__TCA_GRED_MAX - 1) #define TCA_SET_OFF TCA_GRED_PARMS struct tc_gred_qopt { __u32 limit; /* HARD maximal queue length (bytes) */ __u32 qth_min; /* Min average length threshold (bytes) */ __u32 qth_max; /* Max average length threshold (bytes) */ __u32 limit; /* HARD maximal queue length (bytes) */ __u32 qth_min; /* Min average length threshold (bytes) */ __u32 qth_max; /* Max average length threshold (bytes) */ __u32 DP; /* upto 2^32 DPs */ __u32 backlog; __u32 qave; Loading @@ -210,14 +206,14 @@ struct tc_gred_qopt __u32 early; __u32 other; __u32 pdrop; unsigned char Wlog; /* log(W) */ unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ unsigned char Scell_log; /* cell size for idle damping */ __u8 Wlog; /* log(W) */ __u8 Plog; /* log(P_max/(qth_max-qth_min)) */ __u8 Scell_log; /* cell size for idle damping */ __u8 prio; /* prio of this VQ */ __u32 packets; __u32 bytesin; }; /* gred setup */ struct tc_gred_sopt { Loading net/sched/sch_gred.c +31 −69 Original line number Diff line number Diff line Loading @@ -15,50 +15,18 @@ * from Ren Liu * - More error checks * * * * For all the glorious comments look at Alexey's sch_red.c * For all the glorious comments look at include/net/red.h */ #include <linux/config.h> #include <linux/module.h> #include <asm/uaccess.h> #include <asm/system.h> #include <linux/bitops.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/in.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/if_ether.h> #include <linux/inet.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/notifier.h> #include <net/ip.h> #include <net/route.h> #include <linux/skbuff.h> #include <net/sock.h> #include <net/pkt_sched.h> #include <net/red.h> #if 1 /* control */ #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) #else #define DPRINTK(format,args...) #endif #if 0 /* data */ #define D2PRINTK(format,args...) printk(KERN_DEBUG format,##args) #else #define D2PRINTK(format,args...) #endif #define GRED_DEF_PRIO (MAX_DPs / 2) #define GRED_VQ_MASK (MAX_DPs - 1) Loading Loading @@ -172,13 +140,11 @@ static inline void gred_store_wred_set(struct gred_sched *table, table->wred_set.qavg = q->parms.qavg; } static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) { struct gred_sched_data *q=NULL; struct gred_sched *t= qdisc_priv(sch); unsigned long qavg = 0; int i=0; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading @@ -202,11 +168,10 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) /* sum up all the qaves of prios <= to ours to get the new qave */ if (!gred_wred_mode(t) && gred_rio_mode(t)) { for (i=0;i<t->DPs;i++) { if ((!t->tab[i]) || (i==q->DP)) continue; int i; if (t->tab[i]->prio < q->prio && for (i = 0; i < t->DPs; i++) { if (t->tab[i] && t->tab[i]->prio < q->prio && !red_is_idling(&t->tab[i]->parms)) qavg +=t->tab[i]->parms.qavg; } Loading @@ -216,10 +181,8 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) q->packetsin++; q->bytesin += skb->len; if (gred_wred_mode(t)) { qavg = 0; if (gred_wred_mode(t)) gred_load_wred_set(t, q); } q->parms.qavg = red_calc_qavg(&q->parms, gred_backlog(t, q, sch)); Loading Loading @@ -258,8 +221,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) return NET_XMIT_CN; } static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch) static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch) { struct gred_sched *t = qdisc_priv(sch); struct gred_sched_data *q; Loading @@ -279,16 +241,15 @@ gred_requeue(struct sk_buff *skb, struct Qdisc* sch) return qdisc_requeue(skb, sch); } static struct sk_buff * gred_dequeue(struct Qdisc* sch) static struct sk_buff *gred_dequeue(struct Qdisc* sch) { struct sk_buff *skb; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); skb = qdisc_dequeue_head(sch); if (skb) { struct gred_sched_data *q; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading @@ -315,13 +276,12 @@ gred_dequeue(struct Qdisc* sch) static unsigned int gred_drop(struct Qdisc* sch) { struct sk_buff *skb; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); skb = qdisc_dequeue_tail(sch); if (skb) { unsigned int len = skb->len; struct gred_sched_data *q; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading Loading @@ -351,15 +311,16 @@ static unsigned int gred_drop(struct Qdisc* sch) static void gred_reset(struct Qdisc* sch) { int i; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); qdisc_reset_queue(sch); for (i = 0; i < t->DPs; i++) { q= t->tab[i]; struct gred_sched_data *q = t->tab[i]; if (!q) continue; red_restart(&q->parms); q->backlog = 0; } Loading Loading @@ -597,8 +558,6 @@ static void gred_destroy(struct Qdisc *sch) } static struct Qdisc_ops gred_qdisc_ops = { .next = NULL, .cl_ops = NULL, .id = "gred", .priv_size = sizeof(struct gred_sched), .enqueue = gred_enqueue, Loading @@ -617,10 +576,13 @@ static int __init gred_module_init(void) { return register_qdisc(&gred_qdisc_ops); } static void __exit gred_module_exit(void) { unregister_qdisc(&gred_qdisc_ops); } module_init(gred_module_init) module_exit(gred_module_exit) MODULE_LICENSE("GPL"); Loading
include/linux/pkt_sched.h +22 −26 Original line number Diff line number Diff line Loading @@ -194,15 +194,11 @@ enum #define TCA_GRED_MAX (__TCA_GRED_MAX - 1) #define TCA_SET_OFF TCA_GRED_PARMS struct tc_gred_qopt { __u32 limit; /* HARD maximal queue length (bytes) */ __u32 qth_min; /* Min average length threshold (bytes) */ __u32 qth_max; /* Max average length threshold (bytes) */ __u32 limit; /* HARD maximal queue length (bytes) */ __u32 qth_min; /* Min average length threshold (bytes) */ __u32 qth_max; /* Max average length threshold (bytes) */ __u32 DP; /* upto 2^32 DPs */ __u32 backlog; __u32 qave; Loading @@ -210,14 +206,14 @@ struct tc_gred_qopt __u32 early; __u32 other; __u32 pdrop; unsigned char Wlog; /* log(W) */ unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ unsigned char Scell_log; /* cell size for idle damping */ __u8 Wlog; /* log(W) */ __u8 Plog; /* log(P_max/(qth_max-qth_min)) */ __u8 Scell_log; /* cell size for idle damping */ __u8 prio; /* prio of this VQ */ __u32 packets; __u32 bytesin; }; /* gred setup */ struct tc_gred_sopt { Loading
net/sched/sch_gred.c +31 −69 Original line number Diff line number Diff line Loading @@ -15,50 +15,18 @@ * from Ren Liu * - More error checks * * * * For all the glorious comments look at Alexey's sch_red.c * For all the glorious comments look at include/net/red.h */ #include <linux/config.h> #include <linux/module.h> #include <asm/uaccess.h> #include <asm/system.h> #include <linux/bitops.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/socket.h> #include <linux/sockios.h> #include <linux/in.h> #include <linux/errno.h> #include <linux/interrupt.h> #include <linux/if_ether.h> #include <linux/inet.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/notifier.h> #include <net/ip.h> #include <net/route.h> #include <linux/skbuff.h> #include <net/sock.h> #include <net/pkt_sched.h> #include <net/red.h> #if 1 /* control */ #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args) #else #define DPRINTK(format,args...) #endif #if 0 /* data */ #define D2PRINTK(format,args...) printk(KERN_DEBUG format,##args) #else #define D2PRINTK(format,args...) #endif #define GRED_DEF_PRIO (MAX_DPs / 2) #define GRED_VQ_MASK (MAX_DPs - 1) Loading Loading @@ -172,13 +140,11 @@ static inline void gred_store_wred_set(struct gred_sched *table, table->wred_set.qavg = q->parms.qavg; } static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) static int gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) { struct gred_sched_data *q=NULL; struct gred_sched *t= qdisc_priv(sch); unsigned long qavg = 0; int i=0; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading @@ -202,11 +168,10 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) /* sum up all the qaves of prios <= to ours to get the new qave */ if (!gred_wred_mode(t) && gred_rio_mode(t)) { for (i=0;i<t->DPs;i++) { if ((!t->tab[i]) || (i==q->DP)) continue; int i; if (t->tab[i]->prio < q->prio && for (i = 0; i < t->DPs; i++) { if (t->tab[i] && t->tab[i]->prio < q->prio && !red_is_idling(&t->tab[i]->parms)) qavg +=t->tab[i]->parms.qavg; } Loading @@ -216,10 +181,8 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) q->packetsin++; q->bytesin += skb->len; if (gred_wred_mode(t)) { qavg = 0; if (gred_wred_mode(t)) gred_load_wred_set(t, q); } q->parms.qavg = red_calc_qavg(&q->parms, gred_backlog(t, q, sch)); Loading Loading @@ -258,8 +221,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) return NET_XMIT_CN; } static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch) static int gred_requeue(struct sk_buff *skb, struct Qdisc* sch) { struct gred_sched *t = qdisc_priv(sch); struct gred_sched_data *q; Loading @@ -279,16 +241,15 @@ gred_requeue(struct sk_buff *skb, struct Qdisc* sch) return qdisc_requeue(skb, sch); } static struct sk_buff * gred_dequeue(struct Qdisc* sch) static struct sk_buff *gred_dequeue(struct Qdisc* sch) { struct sk_buff *skb; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); skb = qdisc_dequeue_head(sch); if (skb) { struct gred_sched_data *q; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading @@ -315,13 +276,12 @@ gred_dequeue(struct Qdisc* sch) static unsigned int gred_drop(struct Qdisc* sch) { struct sk_buff *skb; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); skb = qdisc_dequeue_tail(sch); if (skb) { unsigned int len = skb->len; struct gred_sched_data *q; u16 dp = tc_index_to_dp(skb); if (dp >= t->DPs || (q = t->tab[dp]) == NULL) { Loading Loading @@ -351,15 +311,16 @@ static unsigned int gred_drop(struct Qdisc* sch) static void gred_reset(struct Qdisc* sch) { int i; struct gred_sched_data *q; struct gred_sched *t = qdisc_priv(sch); qdisc_reset_queue(sch); for (i = 0; i < t->DPs; i++) { q= t->tab[i]; struct gred_sched_data *q = t->tab[i]; if (!q) continue; red_restart(&q->parms); q->backlog = 0; } Loading Loading @@ -597,8 +558,6 @@ static void gred_destroy(struct Qdisc *sch) } static struct Qdisc_ops gred_qdisc_ops = { .next = NULL, .cl_ops = NULL, .id = "gred", .priv_size = sizeof(struct gred_sched), .enqueue = gred_enqueue, Loading @@ -617,10 +576,13 @@ static int __init gred_module_init(void) { return register_qdisc(&gred_qdisc_ops); } static void __exit gred_module_exit(void) { unregister_qdisc(&gred_qdisc_ops); } module_init(gred_module_init) module_exit(gred_module_exit) MODULE_LICENSE("GPL");