diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-12 14:07:32 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-04-12 14:07:32 +0000 |
commit | 0581f44f7967f4fecb7f0098b9eb7940ef315c23 (patch) | |
tree | 258487b65a8578f0ca6747ad8b455d06404a5eb1 /sys/altq | |
parent | 44599f015d7dd23da7fb1c3b11d5754892219524 (diff) |
ansi and a bit style; ok kjc@
Diffstat (limited to 'sys/altq')
-rw-r--r-- | sys/altq/altq_hfsc.c | 283 |
1 files changed, 109 insertions, 174 deletions
diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index 5139e1163d8..ee317ce6504 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_hfsc.c,v 1.14 2003/03/27 11:53:13 henning Exp $ */ +/* $OpenBSD: altq_hfsc.c,v 1.15 2003/04/12 14:07:31 henning Exp $ */ /* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */ /* @@ -63,62 +63,66 @@ /* * function prototypes */ -static int hfsc_clear_interface(struct hfsc_if *); -static int hfsc_request(struct ifaltq *, int, void *); -static void hfsc_purge(struct hfsc_if *); -static struct hfsc_class *hfsc_class_create(struct hfsc_if *, +static int hfsc_clear_interface(struct hfsc_if *); +static int hfsc_request(struct ifaltq *, int, void *); +static void hfsc_purge(struct hfsc_if *); +static struct hfsc_class *hfsc_class_create(struct hfsc_if *, struct service_curve *, struct service_curve *, struct service_curve *, struct hfsc_class *, int, int, int); -static int hfsc_class_destroy(struct hfsc_class *); -static struct hfsc_class *hfsc_nextclass(struct hfsc_class *); -static int hfsc_enqueue(struct ifaltq *, struct mbuf *, struct altq_pktattr *); -static struct mbuf *hfsc_dequeue(struct ifaltq *, int); - -static int hfsc_addq(struct hfsc_class *, struct mbuf *); -static struct mbuf *hfsc_getq(struct hfsc_class *); -static struct mbuf *hfsc_pollq(struct hfsc_class *); -static void hfsc_purgeq(struct hfsc_class *); - -static void update_cfmin(struct hfsc_class *); -static void set_active(struct hfsc_class *, int); -static void set_passive(struct hfsc_class *); - -static void init_ed(struct hfsc_class *, int); -static void update_ed(struct hfsc_class *, int); -static void update_d(struct hfsc_class *, int); -static void init_vf(struct hfsc_class *, int); -static void update_vf(struct hfsc_class *, int, u_int64_t); -static ellist_t *ellist_alloc(void); -static void ellist_destroy(ellist_t *); -static void ellist_insert(struct hfsc_class *); -static void ellist_remove(struct hfsc_class *); -static void ellist_update(struct hfsc_class *); -struct hfsc_class *ellist_get_mindl(ellist_t *, u_int64_t); -static actlist_t *actlist_alloc(void); -static void actlist_destroy(actlist_t *); -static void actlist_insert(struct hfsc_class *); -static void actlist_remove(struct hfsc_class *); -static void actlist_update(struct hfsc_class *); -static struct hfsc_class *actlist_firstfit(struct hfsc_class *, u_int64_t); - -static __inline u_int64_t seg_x2y(u_int64_t, u_int64_t); -static __inline u_int64_t seg_y2x(u_int64_t, u_int64_t); -static __inline u_int64_t m2sm(u_int); -static __inline u_int64_t m2ism(u_int); -static __inline u_int64_t d2dx(u_int); -static u_int sm2m(u_int64_t); -static u_int dx2d(u_int64_t); - -static void sc2isc(struct service_curve *, struct internal_sc *); -static void rtsc_init(struct runtime_sc *, struct internal_sc *, - u_int64_t, u_int64_t); -static u_int64_t rtsc_y2x(struct runtime_sc *, u_int64_t); -static u_int64_t rtsc_x2y(struct runtime_sc *, u_int64_t); -static void rtsc_min(struct runtime_sc *, struct internal_sc *, - u_int64_t, u_int64_t); - -static void get_class_stats(struct hfsc_classstats *, struct hfsc_class *); -static struct hfsc_class *clh_to_clp(struct hfsc_if *, u_int32_t); +static int hfsc_class_destroy(struct hfsc_class *); +static struct hfsc_class *hfsc_nextclass(struct hfsc_class *); +static int hfsc_enqueue(struct ifaltq *, struct mbuf *, + struct altq_pktattr *); +static struct mbuf *hfsc_dequeue(struct ifaltq *, int); + +static int hfsc_addq(struct hfsc_class *, struct mbuf *); +static struct mbuf *hfsc_getq(struct hfsc_class *); +static struct mbuf *hfsc_pollq(struct hfsc_class *); +static void hfsc_purgeq(struct hfsc_class *); + +static void update_cfmin(struct hfsc_class *); +static void set_active(struct hfsc_class *, int); +static void set_passive(struct hfsc_class *); + +static void init_ed(struct hfsc_class *, int); +static void update_ed(struct hfsc_class *, int); +static void update_d(struct hfsc_class *, int); +static void init_vf(struct hfsc_class *, int); +static void update_vf(struct hfsc_class *, int, u_int64_t); +static ellist_t *ellist_alloc(void); +static void ellist_destroy(ellist_t *); +static void ellist_insert(struct hfsc_class *); +static void ellist_remove(struct hfsc_class *); +static void ellist_update(struct hfsc_class *); +struct hfsc_class *ellist_get_mindl(ellist_t *, u_int64_t); +static actlist_t *actlist_alloc(void); +static void actlist_destroy(actlist_t *); +static void actlist_insert(struct hfsc_class *); +static void actlist_remove(struct hfsc_class *); +static void actlist_update(struct hfsc_class *); + +static struct hfsc_class *actlist_firstfit(struct hfsc_class *, + u_int64_t); + +static __inline u_int64_t seg_x2y(u_int64_t, u_int64_t); +static __inline u_int64_t seg_y2x(u_int64_t, u_int64_t); +static __inline u_int64_t m2sm(u_int); +static __inline u_int64_t m2ism(u_int); +static __inline u_int64_t d2dx(u_int); +static u_int sm2m(u_int64_t); +static u_int dx2d(u_int64_t); + +static void sc2isc(struct service_curve *, struct internal_sc *); +static void rtsc_init(struct runtime_sc *, struct internal_sc *, + u_int64_t, u_int64_t); +static u_int64_t rtsc_y2x(struct runtime_sc *, u_int64_t); +static u_int64_t rtsc_x2y(struct runtime_sc *, u_int64_t); +static void rtsc_min(struct runtime_sc *, struct internal_sc *, + u_int64_t, u_int64_t); + +static void get_class_stats(struct hfsc_classstats *, + struct hfsc_class *); +static struct hfsc_class *clh_to_clp(struct hfsc_if *, u_int32_t); /* * macros @@ -294,8 +298,7 @@ hfsc_getqstats(struct pf_altq *a, void *ubuf, int *nbytes) * all the filters and classes except the root class. */ static int -hfsc_clear_interface(hif) - struct hfsc_if *hif; +hfsc_clear_interface(struct hfsc_if *hif) { struct hfsc_class *cl; @@ -317,10 +320,7 @@ hfsc_clear_interface(hif) } static int -hfsc_request(ifq, req, arg) - struct ifaltq *ifq; - int req; - void *arg; +hfsc_request(struct ifaltq *ifq, int req, void *arg) { struct hfsc_if *hif = (struct hfsc_if *)ifq->altq_disc; @@ -334,8 +334,7 @@ hfsc_request(ifq, req, arg) /* discard all the queued packets on the interface */ static void -hfsc_purge(hif) - struct hfsc_if *hif; +hfsc_purge(struct hfsc_if *hif) { struct hfsc_class *cl; @@ -347,11 +346,9 @@ hfsc_purge(hif) } struct hfsc_class * -hfsc_class_create(hif, rsc, fsc, usc, parent, qlimit, flags, qid) - struct hfsc_if *hif; - struct service_curve *rsc, *fsc, *usc; - struct hfsc_class *parent; - int qlimit, flags, qid; +hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, + struct service_curve *fsc, struct service_curve *usc, + struct hfsc_class *parent, int qlimit, int flags, int qid) { struct hfsc_class *cl, *p; int i, s, chandle; @@ -521,8 +518,7 @@ hfsc_class_create(hif, rsc, fsc, usc, parent, qlimit, flags, qid) } static int -hfsc_class_destroy(cl) - struct hfsc_class *cl; +hfsc_class_destroy(struct hfsc_class *cl) { int s; @@ -584,8 +580,7 @@ hfsc_class_destroy(cl) * do_something; */ static struct hfsc_class * -hfsc_nextclass(cl) - struct hfsc_class *cl; +hfsc_nextclass(struct hfsc_class *cl) { if (cl->cl_children != NULL) cl = cl->cl_children; @@ -607,10 +602,7 @@ hfsc_nextclass(cl) * (*altq_enqueue) in struct ifaltq. */ static int -hfsc_enqueue(ifq, m, pktattr) - struct ifaltq *ifq; - struct mbuf *m; - struct altq_pktattr *pktattr; +hfsc_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) { struct hfsc_if *hif = (struct hfsc_if *)ifq->altq_disc; struct hfsc_class *cl; @@ -663,9 +655,7 @@ hfsc_enqueue(ifq, m, pktattr) * after ALTDQ_POLL. */ static struct mbuf * -hfsc_dequeue(ifq, op) - struct ifaltq *ifq; - int op; +hfsc_dequeue(struct ifaltq *ifq, int op) { struct hfsc_if *hif = (struct hfsc_if *)ifq->altq_disc; struct hfsc_class *cl; @@ -765,9 +755,7 @@ hfsc_dequeue(ifq, op) } static int -hfsc_addq(cl, m) - struct hfsc_class *cl; - struct mbuf *m; +hfsc_addq(struct hfsc_class *cl, struct mbuf *m) { #ifdef ALTQ_RIO @@ -793,8 +781,7 @@ hfsc_addq(cl, m) } static struct mbuf * -hfsc_getq(cl) - struct hfsc_class *cl; +hfsc_getq(struct hfsc_class *cl) { #ifdef ALTQ_RIO if (q_is_rio(cl->cl_q)) @@ -808,15 +795,13 @@ hfsc_getq(cl) } static struct mbuf * -hfsc_pollq(cl) - struct hfsc_class *cl; +hfsc_pollq(struct hfsc_class *cl) { return qhead(cl->cl_q); } static void -hfsc_purgeq(cl) - struct hfsc_class *cl; +hfsc_purgeq(struct hfsc_class *cl) { struct mbuf *m; @@ -836,9 +821,7 @@ hfsc_purgeq(cl) } static void -set_active(cl, len) - struct hfsc_class *cl; - int len; +set_active(struct hfsc_class *cl, int len) { if (cl->cl_rsc != NULL) init_ed(cl, len); @@ -849,8 +832,7 @@ set_active(cl, len) } static void -set_passive(cl) - struct hfsc_class *cl; +set_passive(struct hfsc_class *cl) { if (cl->cl_rsc != NULL) ellist_remove(cl); @@ -862,9 +844,7 @@ set_passive(cl) } static void -init_ed(cl, next_len) - struct hfsc_class *cl; - int next_len; +init_ed(struct hfsc_class *cl, int next_len) { u_int64_t cur_time; @@ -892,9 +872,7 @@ init_ed(cl, next_len) } static void -update_ed(cl, next_len) - struct hfsc_class *cl; - int next_len; +update_ed(struct hfsc_class *cl, int next_len) { cl->cl_e = rtsc_y2x(&cl->cl_eligible, cl->cl_cumul); cl->cl_d = rtsc_y2x(&cl->cl_deadline, cl->cl_cumul + next_len); @@ -903,17 +881,13 @@ update_ed(cl, next_len) } static void -update_d(cl, next_len) - struct hfsc_class *cl; - int next_len; +update_d(struct hfsc_class *cl, int next_len) { cl->cl_d = rtsc_y2x(&cl->cl_deadline, cl->cl_cumul + next_len); } static void -init_vf(cl, len) - struct hfsc_class *cl; - int len; +init_vf(struct hfsc_class *cl, int len) { struct hfsc_class *max_cl, *p; u_int64_t vt, f, cur_time; @@ -1004,10 +978,7 @@ init_vf(cl, len) } static void -update_vf(cl, len, cur_time) - struct hfsc_class *cl; - int len; - u_int64_t cur_time; +update_vf(struct hfsc_class *cl, int len, u_int64_t cur_time) { u_int64_t f, myf_bound, delta; int go_passive; @@ -1092,8 +1063,7 @@ update_vf(cl, len, cur_time) } static void -update_cfmin(cl) - struct hfsc_class *cl; +update_cfmin(struct hfsc_class *cl) { struct hfsc_class *p; u_int64_t cfmin; @@ -1124,7 +1094,7 @@ update_cfmin(cl) */ static ellist_t * -ellist_alloc() +ellist_alloc(void) { ellist_t *head; @@ -1134,15 +1104,13 @@ ellist_alloc() } static void -ellist_destroy(head) - ellist_t *head; +ellist_destroy(ellist_t *head) { FREE(head, M_DEVBUF); } static void -ellist_insert(cl) - struct hfsc_class *cl; +ellist_insert(struct hfsc_class *cl) { struct hfsc_if *hif = cl->cl_hif; struct hfsc_class *p; @@ -1164,8 +1132,7 @@ ellist_insert(cl) } static void -ellist_remove(cl) - struct hfsc_class *cl; +ellist_remove(struct hfsc_class *cl) { struct hfsc_if *hif = cl->cl_hif; @@ -1173,8 +1140,7 @@ ellist_remove(cl) } static void -ellist_update(cl) - struct hfsc_class *cl; +ellist_update(struct hfsc_class *cl) { struct hfsc_if *hif = cl->cl_hif; struct hfsc_class *p, *last; @@ -1212,9 +1178,7 @@ ellist_update(cl) /* find the class with the minimum deadline among the eligible classes */ struct hfsc_class * -ellist_get_mindl(head, cur_time) - ellist_t *head; - u_int64_t cur_time; +ellist_get_mindl(ellist_t *head, u_int64_t cur_time) { struct hfsc_class *p, *cl = NULL; @@ -1233,7 +1197,7 @@ ellist_get_mindl(head, cur_time) * each intermediate class has one active children list. */ static actlist_t * -actlist_alloc() +actlist_alloc(void) { actlist_t *head; @@ -1243,14 +1207,12 @@ actlist_alloc() } static void -actlist_destroy(head) - actlist_t *head; +actlist_destroy(actlist_t *head) { FREE(head, M_DEVBUF); } static void -actlist_insert(cl) - struct hfsc_class *cl; +actlist_insert(struct hfsc_class *cl) { struct hfsc_class *p; @@ -1271,15 +1233,13 @@ actlist_insert(cl) } static void -actlist_remove(cl) - struct hfsc_class *cl; +actlist_remove(struct hfsc_class *cl) { TAILQ_REMOVE(cl->cl_parent->cl_actc, cl, cl_actlist); } static void -actlist_update(cl) - struct hfsc_class *cl; +actlist_update(struct hfsc_class *cl) { struct hfsc_class *p, *last; @@ -1316,9 +1276,7 @@ actlist_update(cl) } static struct hfsc_class * -actlist_firstfit(cl, cur_time) - struct hfsc_class *cl; - u_int64_t cur_time; +actlist_firstfit(struct hfsc_class *cl, u_int64_t cur_time) { struct hfsc_class *p; @@ -1362,9 +1320,7 @@ actlist_firstfit(cl, cur_time) #define ISM_MASK ((1LL << ISM_SHIFT) - 1) static __inline u_int64_t -seg_x2y(x, sm) - u_int64_t x; - u_int64_t sm; +seg_x2y(u_int64_t x, u_int64_t sm) { u_int64_t y; @@ -1378,9 +1334,7 @@ seg_x2y(x, sm) } static __inline u_int64_t -seg_y2x(y, ism) - u_int64_t y; - u_int64_t ism; +seg_y2x(u_int64_t y, u_int64_t ism) { u_int64_t x; @@ -1396,8 +1350,7 @@ seg_y2x(y, ism) } static __inline u_int64_t -m2sm(m) - u_int m; +m2sm(u_int m) { u_int64_t sm; @@ -1406,8 +1359,7 @@ m2sm(m) } static __inline u_int64_t -m2ism(m) - u_int m; +m2ism(u_int m) { u_int64_t ism; @@ -1419,8 +1371,7 @@ m2ism(m) } static __inline u_int64_t -d2dx(d) - u_int d; +d2dx(u_int d) { u_int64_t dx; @@ -1429,8 +1380,7 @@ d2dx(d) } static u_int -sm2m(sm) - u_int64_t sm; +sm2m(u_int64_t sm) { u_int64_t m; @@ -1439,8 +1389,7 @@ sm2m(sm) } static u_int -dx2d(dx) - u_int64_t dx; +dx2d(u_int64_t dx) { u_int64_t d; @@ -1449,9 +1398,7 @@ dx2d(dx) } static void -sc2isc(sc, isc) - struct service_curve *sc; - struct internal_sc *isc; +sc2isc(struct service_curve *sc, struct internal_sc *isc) { isc->sm1 = m2sm(sc->m1); isc->ism1 = m2ism(sc->m1); @@ -1466,10 +1413,8 @@ sc2isc(sc, isc) * service curve starting at (x, y). */ static void -rtsc_init(rtsc, isc, x, y) - struct runtime_sc *rtsc; - struct internal_sc *isc; - u_int64_t x, y; +rtsc_init(struct runtime_sc *rtsc, struct internal_sc * isc, u_int64_t x, + u_int64_t y) { rtsc->x = x; rtsc->y = y; @@ -1486,9 +1431,7 @@ rtsc_init(rtsc, isc, x, y) * given x-projection value */ static u_int64_t -rtsc_y2x(rtsc, y) - struct runtime_sc *rtsc; - u_int64_t y; +rtsc_y2x(struct runtime_sc *rtsc, u_int64_t y) { u_int64_t x; @@ -1509,9 +1452,7 @@ rtsc_y2x(rtsc, y) } static u_int64_t -rtsc_x2y(rtsc, x) - struct runtime_sc *rtsc; - u_int64_t x; +rtsc_x2y(struct runtime_sc *rtsc, u_int64_t x) { u_int64_t y; @@ -1532,10 +1473,8 @@ rtsc_x2y(rtsc, x) * runtime service curve and the service curve starting at (x, y). */ static void -rtsc_min(rtsc, isc, x, y) - struct runtime_sc *rtsc; - struct internal_sc *isc; - u_int64_t x, y; +rtsc_min(struct runtime_sc *rtsc, struct internal_sc *isc, u_int64_t x, + u_int64_t y) { u_int64_t y1, y2, dx, dy; @@ -1595,9 +1534,7 @@ rtsc_min(rtsc, isc, x, y) } static void -get_class_stats(sp, cl) - struct hfsc_classstats *sp; - struct hfsc_class *cl; +get_class_stats(struct hfsc_classstats *sp, struct hfsc_class *cl) { sp->class_id = cl->cl_id; sp->class_handle = cl->cl_handle; @@ -1672,9 +1609,7 @@ get_class_stats(sp, cl) /* convert a class handle to the corresponding class pointer */ static struct hfsc_class * -clh_to_clp(hif, chandle) - struct hfsc_if *hif; - u_int32_t chandle; +clh_to_clp(struct hfsc_if *hif, u_int32_t chandle) { u_int idx; |