Index: sys/netpfil/ipfw/dn_aqm.h =================================================================== --- sys/netpfil/ipfw/dn_aqm.h +++ sys/netpfil/ipfw/dn_aqm.h @@ -54,7 +54,7 @@ #define BOUND_VAR(x,l,h) ((x) > (h)? (h) : ((x) > (l)? (x) : (l))) /* sysctl variable to count number of dropped packets */ -extern unsigned long io_pkt_drop; +extern unsigned long io_pkt_drop; /* * Structure for holding data and function pointers that together represent a @@ -66,38 +66,38 @@ uint32_t type; /* AQM type number */ /* Methods implemented by AQM algorithm: - * + * * enqueue enqueue packet 'm' on queue 'q'. * Return 0 on success, 1 on drop. - * + * * dequeue dequeue a packet from queue 'q'. * Return a packet, NULL if no packet available. - * + * * config configure AQM algorithm - * If required, this function should allocate space to store + * If required, this function should allocate space to store * the configurations and set 'fs->aqmcfg' to point to this space. * 'dn_extra_parms' includes array of parameters send * from ipfw userland command. * Return 0 on success, non-zero otherwise. - * + * * deconfig deconfigure AQM algorithm. * The allocated configuration memory space should be freed here. * Return 0 on success, non-zero otherwise. - * + * * init initialise AQM status variables of queue 'q' * This function is used to allocate space and init AQM status for a * queue and q->aqm_status to point to this space. * Return 0 on success, non-zero otherwise. - * + * * cleanup cleanup AQM status variables of queue 'q' * The allocated memory space for AQM status should be freed here. * Return 0 on success, non-zero otherwise. - * - * getconfig retrieve AQM configurations + * + * getconfig retrieve AQM configurations * This function is used to return AQM parameters to userland - * command. The function should fill 'dn_extra_parms' struct with + * command. The function should fill 'dn_extra_parms' struct with * the AQM configurations using 'par' array. - * + * */ int (*enqueue)(struct dn_queue *, struct mbuf *); @@ -160,6 +160,6 @@ }; \ DECLARE_MODULE(name, name##_mod, \ SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); \ - MODULE_DEPEND(name, dummynet, 3, 3, 3) + MODULE_DEPEND(name, dummynet, 3, 3, 3) #endif Index: sys/netpfil/ipfw/dn_aqm_codel.h =================================================================== --- sys/netpfil/ipfw/dn_aqm_codel.h +++ sys/netpfil/ipfw/dn_aqm_codel.h @@ -50,7 +50,7 @@ #define _IP_DN_AQM_CODEL_H // XXX How to choose MTAG? -#define FIX_POINT_BITS 16 +#define FIX_POINT_BITS 16 enum { CODEL_ECN_ENABLED = 1 @@ -127,10 +127,10 @@ return m; } -/* +/* * Dequeue a packet from queue 'q' */ -__inline static struct mbuf * +__inline static struct mbuf * codel_dequeue(struct dn_queue *q) { struct mbuf *m; @@ -205,7 +205,7 @@ * is a good approximation of the time from the last drop * until now.) */ - cst->count = (cst->count > 2 && ((aqm_stime_t)now - + cst->count = (cst->count > 2 && ((aqm_stime_t)now - (aqm_stime_t)cst->drop_next_time) < 8* cprms->interval)? cst->count - 2 : 1; /* we don't have to set initial guess for Newton's method isqrt as Index: sys/netpfil/ipfw/dn_aqm_codel.c =================================================================== --- sys/netpfil/ipfw/dn_aqm_codel.c +++ sys/netpfil/ipfw/dn_aqm_codel.c @@ -134,12 +134,12 @@ "CoDel interval in microsecond"); #endif -/* This function computes codel_interval/sqrt(count) +/* This function computes codel_interval/sqrt(count) * Newton's method of approximation is used to compute 1/sqrt(count). * http://betterexplained.com/articles/ - * understanding-quakes-fast-inverse-square-root/ + * understanding-quakes-fast-inverse-square-root/ */ -aqm_time_t +aqm_time_t control_law(struct codel_status *cst, struct dn_aqm_codel_parms *cprms, aqm_time_t t) { @@ -159,7 +159,7 @@ * Multiplying both sides by 2 to make all the constants intergers * newguess * 2 = g(3 - c*g^2) g=old guess, c=count * So, newguess = newguess /2 - * Fixed point operations are used here. + * Fixed point operations are used here. */ /* Calculate g^2 */ @@ -167,14 +167,14 @@ /* Calculate (3 - c*g^2) i.e. (3 - c * temp) */ temp = (3ULL<< (FIX_POINT_BITS*2)) - (count * temp); - /* - * Divide by 2 because we multiplied the original equation by two - * Also, we shift the result by 8 bits to prevent overflow. + /* + * Divide by 2 because we multiplied the original equation by two + * Also, we shift the result by 8 bits to prevent overflow. * */ - temp >>= (1 + 8); + temp >>= (1 + 8); /* Now, temp = (1.5 - 0.5*c*g^2) - * Calculate g (1.5 - 0.5*c*g^2) i.e. g * temp + * Calculate g (1.5 - 0.5*c*g^2) i.e. g * temp */ temp = (cst->isqrt * temp) >> (FIX_POINT_BITS + FIX_POINT_BITS - 8); cst->isqrt = temp; @@ -211,7 +211,7 @@ *pkt_ts = 0; } else { *pkt_ts = *(aqm_time_t *)(mtag + 1); - m_tag_delete(m,mtag); + m_tag_delete(m,mtag); } return m; @@ -237,7 +237,7 @@ } /* Finding maximum packet size */ - // XXX we can get MTU from driver instead + // XXX we can get MTU from driver instead if (len > cst->maxpkt_size) cst->maxpkt_size = len; @@ -257,7 +257,7 @@ mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); + m_freem(m); goto drop; } @@ -275,17 +275,17 @@ } /* Dequeue a pcaket from queue q */ -static struct mbuf * +static struct mbuf * aqm_codel_dequeue(struct dn_queue *q) { return codel_dequeue(q); } -/* - * initialize Codel for queue 'q' +/* + * initialize Codel for queue 'q' * First allocate memory for codel status. */ -static int +static int aqm_codel_init(struct dn_queue *q) { struct codel_status *cst; @@ -299,7 +299,7 @@ M_DUMMYNET, M_NOWAIT | M_ZERO); if (q->aqm_status == NULL) { D("Cannot allocate AQM_codel private data"); - return ENOMEM ; + return ENOMEM ; } /* init codel status variables */ @@ -316,8 +316,8 @@ return 0; } -/* - * Clean up Codel status for queue 'q' +/* + * Clean up Codel status for queue 'q' * Destroy memory allocated for codel status. */ static int @@ -335,7 +335,7 @@ return 0; } -/* +/* * Config codel parameters * also allocate memory for codel configurations */ @@ -349,7 +349,7 @@ D("invalid sched parms length got %d need %d", len, l); return EINVAL; } - /* we free the old cfg because maybe the original allocation + /* we free the old cfg because maybe the original allocation * not the same size as the new one (different AQM type). */ if (fs->aqmcfg) { @@ -361,7 +361,7 @@ M_DUMMYNET, M_NOWAIT | M_ZERO); if (fs->aqmcfg== NULL) { D("cannot allocate AQM_codel configuration parameters"); - return ENOMEM; + return ENOMEM; } /* configure codel parameters */ @@ -409,9 +409,9 @@ return 0; } -/* +/* * Retrieve Codel configuration parameters. - */ + */ static int aqm_codel_getconfig(struct dn_fsk *fs, struct dn_extra_parms * ep) { Index: sys/netpfil/ipfw/dn_aqm_pie.h =================================================================== --- sys/netpfil/ipfw/dn_aqm_pie.h +++ sys/netpfil/ipfw/dn_aqm_pie.h @@ -37,7 +37,7 @@ #define DN_AQM_PIE 2 #define PIE_DQ_THRESHOLD_BITS 14 /* 2^14 =16KB */ -#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) +#define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) #define MEAN_PKTSIZE 800 /* 31-bits because random() generates range from 0->(2**31)-1 */ @@ -82,24 +82,24 @@ uint32_t sflags; struct dn_aqm_pie_parms *parms; /* pointer to PIE configurations */ /* pointer to parent queue of FQ-PIE sub-queues, or queue of owner fs. */ - struct dn_queue *pq; + struct dn_queue *pq; struct mtx lock_mtx; uint32_t one_third_q_size; /* 1/3 of queue size, for speed optization */ }; -enum { +enum { ENQUE = 1, DROP, MARKECN }; /* PIE current state */ -enum { +enum { PIE_ACTIVE = 1, PIE_INMEASUREMENT = 2 }; -/* +/* * Check if eneque should drop packet to control delay or not based on * PIe algorithm. * return DROP if it is time to drop or ENQUE otherwise. @@ -126,11 +126,11 @@ if (pprms->flags & PIE_DERAND_ENABLED) pst->accu_prob += pst->drop_prob; - /* De-randomize option + /* De-randomize option * if accu_prob < 0.85 -> enqueue * if accu_prob>8.5 ->drop * between 0.85 and 8.5 || !De-randomize --> drop on prob - * + * * (0.85 = 17/20 ,8.5 = 17/2) */ if (pprms->flags & PIE_DERAND_ENABLED) { Index: sys/netpfil/ipfw/dn_aqm_pie.c =================================================================== --- sys/netpfil/ipfw/dn_aqm_pie.c +++ sys/netpfil/ipfw/dn_aqm_pie.c @@ -76,10 +76,10 @@ static struct dn_aqm pie_desc; /* PIE defaults - * target=15ms, tupdate=15ms, max_burst=150ms, - * max_ecnth=0.1, alpha=0.125, beta=1.25, + * target=15ms, tupdate=15ms, max_burst=150ms, + * max_ecnth=0.1, alpha=0.125, beta=1.25, */ -struct dn_aqm_pie_parms pie_sysctl = +struct dn_aqm_pie_parms pie_sysctl = { 15 * AQM_TIME_1MS, 15 * AQM_TIME_1MS, 150 * AQM_TIME_1MS, PIE_SCALE/10 , PIE_SCALE * 0.125, PIE_SCALE * 1.25 , PIE_CAPDROP_ENABLED | PIE_DEPRATEEST_ENABLED | PIE_DERAND_ENABLED }; @@ -94,7 +94,7 @@ value = pie_sysctl.alpha; else value = pie_sysctl.beta; - + value = value * 1000 / PIE_SCALE; error = sysctl_handle_long(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) @@ -196,7 +196,7 @@ #endif /* - * Callout function for drop probability calculation + * Callout function for drop probability calculation * This function is called over tupdate ms and takes pointer of PIE * status variables as an argument */ @@ -213,27 +213,27 @@ /* calculate current qdelay using DRE method. * If TS is used and no data in the queue, reset current_qdelay - * as it stays at last value during dequeue process. + * as it stays at last value during dequeue process. */ if (pprms->flags & PIE_DEPRATEEST_ENABLED) pst->current_qdelay = ((uint64_t)pst->pq->ni.len_bytes * pst->avg_dq_time) >> PIE_DQ_THRESHOLD_BITS; - else + else if (!pst->pq->ni.len_bytes) pst->current_qdelay = 0; /* calculate drop probability */ - p = (int64_t)pprms->alpha * - ((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); - p +=(int64_t) pprms->beta * - ((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); + p = (int64_t)pprms->alpha * + ((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); + p +=(int64_t) pprms->beta * + ((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); /* take absolute value so right shift result is well defined */ p_isneg = p < 0; if (p_isneg) { p = -p; } - + /* We PIE_MAX_PROB shift by 12-bits to increase the division precision */ p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S; @@ -289,7 +289,7 @@ } else { if (pst->current_qdelay == 0 && pst->qdelay_old == 0) { /* 0.98 ~= 1- 1/64 */ - prob = prob - (prob >> 6); + prob = prob - (prob >> 6); } if (prob > PIE_MAX_PROB) { @@ -304,10 +304,10 @@ /* update burst allowance */ if ((pst->sflags & PIE_ACTIVE) && pst->burst_allowance>0) { - + if (pst->burst_allowance > pprms->tupdate ) pst->burst_allowance -= pprms->tupdate; - else + else pst->burst_allowance = 0; } @@ -348,13 +348,13 @@ *pkt_ts = 0; } else { *pkt_ts = *(aqm_time_t *)(mtag + 1); - m_tag_delete(m,mtag); + m_tag_delete(m,mtag); } } return m; } -/* +/* * Initiate PIE variable and optionally activate it */ __inline static void @@ -383,8 +383,8 @@ mtx_unlock(&pst->lock_mtx); } -/* - * Deactivate PIE and stop probe update callout +/* + * Deactivate PIE and stop probe update callout */ __inline static void deactivate_pie(struct pie_status *pst) @@ -396,7 +396,7 @@ mtx_unlock(&pst->lock_mtx); } -/* +/* * Dequeue and return a pcaket from queue 'q' or NULL if 'q' is empty. * Also, caculate depature time or queue delay using timestamp */ @@ -404,7 +404,7 @@ aqm_pie_dequeue(struct dn_queue *q) { struct mbuf *m; - struct dn_flow *ni; /* stats for scheduler instance */ + struct dn_flow *ni; /* stats for scheduler instance */ struct dn_aqm_pie_parms *pprms; struct pie_status *pst; aqm_time_t now; @@ -430,17 +430,17 @@ if (pst->dq_count >= PIE_DQ_THRESHOLD) { dq_time = now - pst->measurement_start; - /* - * if we don't have old avg dq_time i.e PIE is (re)initialized, + /* + * if we don't have old avg dq_time i.e PIE is (re)initialized, * don't use weight to calculate new avg_dq_time */ if(pst->avg_dq_time == 0) pst->avg_dq_time = dq_time; else { - /* - * weight = PIE_DQ_THRESHOLD/2^6, but we scaled - * weight by 2^8. Thus, scaled - * weight = PIE_DQ_THRESHOLD /2^8 + /* + * weight = PIE_DQ_THRESHOLD/2^6, but we scaled + * weight by 2^8. Thus, scaled + * weight = PIE_DQ_THRESHOLD /2^8 * */ w = PIE_DQ_THRESHOLD >> 8; pst->avg_dq_time = (dq_time* w @@ -450,11 +450,11 @@ } } - /* + /* * Start new measurment cycle when the queue has * PIE_DQ_THRESHOLD worth of bytes. */ - if(!(pst->sflags & PIE_INMEASUREMENT) && + if(!(pst->sflags & PIE_INMEASUREMENT) && q->ni.len_bytes >= PIE_DQ_THRESHOLD) { pst->sflags |= PIE_INMEASUREMENT; pst->measurement_start = now; @@ -465,7 +465,7 @@ else pst->current_qdelay = now - pkt_ts; - return m; + return m; } /* @@ -507,8 +507,8 @@ /* drop/mark the packet when PIE is active and burst time elapsed */ else if ((pst->sflags & PIE_ACTIVE) && pst->burst_allowance==0 && drop_early(pst, q->ni.len_bytes) == DROP) { - /* - * if drop_prob over ECN threshold, drop the packet + /* + * if drop_prob over ECN threshold, drop the packet * otherwise mark and enqueue it. */ if ((pprms->flags & PIE_ECN_ENABLED) && pst->drop_prob < @@ -519,7 +519,7 @@ t = DROP; } - /* Turn PIE on when 1/3 of the queue is full */ + /* Turn PIE on when 1/3 of the queue is full */ if (!(pst->sflags & PIE_ACTIVE) && qlen >= pst->one_third_q_size) { init_activate_pie(pst, 1); } @@ -542,7 +542,7 @@ mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); + m_freem(m); t = DROP; } *(aqm_time_t *)(mtag + 1) = AQM_UNOW; @@ -564,8 +564,8 @@ return 0; } -/* - * initialize PIE for queue 'q' +/* + * initialize PIE for queue 'q' * First allocate memory for PIE status. */ static int @@ -588,28 +588,28 @@ M_DUMMYNET, M_NOWAIT | M_ZERO); if (q->aqm_status == NULL) { D("cannot allocate PIE private data"); - err = ENOMEM ; + err = ENOMEM ; break; } pst = q->aqm_status; /* increase reference count for PIE module */ pie_desc.ref_count++; - + pst->pq = q; pst->parms = pprms; - + /* For speed optimization, we caculate 1/3 queue size once here */ // we can use x/3 = (x >>2) + (x >>4) + (x >>7) pst->one_third_q_size = q->fs->fs.qsize/3; - + mtx_init(&pst->lock_mtx, "mtx_pie", NULL, MTX_DEF); callout_init_mtx(&pst->aqm_pie_callout, &pst->lock_mtx, CALLOUT_RETURNUNLOCKED); - + pst->current_qdelay = 0; init_activate_pie(pst, !(pprms->flags & PIE_ON_OFF_MODE_ENABLED)); - + //DX(2, "aqm_PIE_init"); } while(0); @@ -617,7 +617,7 @@ return err; } -/* +/* * Callout function to destroy pie mtx and free PIE status memory */ static void @@ -633,8 +633,8 @@ DN_BH_WUNLOCK(); } -/* - * Clean up PIE status for queue 'q' +/* + * Clean up PIE status for queue 'q' * Destroy memory allocated for PIE status. */ static int @@ -659,11 +659,11 @@ return 1; } - /* + /* * Free PIE status allocated memory using pie_callout_cleanup() callout * function to avoid any potential race. * We reset aqm_pie_callout to call pie_callout_cleanup() in next 1um. This - * stops the scheduled calculate_drop_prob() callout and call pie_callout_cleanup() + * stops the scheduled calculate_drop_prob() callout and call pie_callout_cleanup() * which does memory freeing. */ mtx_lock(&pst->lock_mtx); @@ -675,13 +675,13 @@ return 0; } -/* +/* * Config PIE parameters * also allocate memory for PIE configurations */ -static int +static int aqm_pie_config(struct dn_fsk* fs, struct dn_extra_parms *ep, int len) -{ +{ struct dn_aqm_pie_parms *pcfg; int l = sizeof(struct dn_extra_parms); @@ -689,7 +689,7 @@ D("invalid sched parms length got %d need %d", len, l); return EINVAL; } - /* we free the old cfg because maybe the orignal allocation + /* we free the old cfg because maybe the orignal allocation * was used for diffirent AQM type. */ if (fs->aqmcfg) { @@ -701,7 +701,7 @@ M_DUMMYNET, M_NOWAIT | M_ZERO); if (fs->aqmcfg== NULL) { D("cannot allocate PIE configuration parameters"); - return ENOMEM; + return ENOMEM; } /* par array contains pie configuration as follow @@ -768,10 +768,10 @@ return 0; } -/* +/* * Retrieve PIE configuration parameters. - */ -static int + */ +static int aqm_pie_getconfig (struct dn_fsk *fs, struct dn_extra_parms * ep) { struct dn_aqm_pie_parms *pcfg; Index: sys/netpfil/ipfw/dn_heap.h =================================================================== --- sys/netpfil/ipfw/dn_heap.h +++ sys/netpfil/ipfw/dn_heap.h @@ -166,10 +166,10 @@ */ struct dn_ht; /* should be opaque */ -struct dn_ht *dn_ht_init(struct dn_ht *, int buckets, int ofs, - uint32_t (*hash)(uintptr_t, int, void *), - int (*match)(void *, uintptr_t, int, void *), - void *(*newh)(uintptr_t, int, void *)); +struct dn_ht *dn_ht_init(struct dn_ht *, int buckets, int ofs, + uint32_t (*hash)(uintptr_t, int, void *), + int (*match)(void *, uintptr_t, int, void *), + void *(*newh)(uintptr_t, int, void *)); void dn_ht_free(struct dn_ht *, int flags); void *dn_ht_find(struct dn_ht *, uintptr_t, int, void *); @@ -181,13 +181,13 @@ * first two are returned by the scan callback to indicate * to delete the matching element or to end the scan */ - DNHT_SCAN_DEL = 0x0001, - DNHT_SCAN_END = 0x0002, - DNHT_KEY_IS_OBJ = 0x0004, /* key is the obj pointer */ - DNHT_MATCH_PTR = 0x0008, /* match by pointer, not match() */ - DNHT_INSERT = 0x0010, /* insert if not found */ - DNHT_UNIQUE = 0x0020, /* report error if already there */ - DNHT_REMOVE = 0x0040, /* remove on find or dn_ht_free */ -}; + DNHT_SCAN_DEL = 0x0001, + DNHT_SCAN_END = 0x0002, + DNHT_KEY_IS_OBJ = 0x0004, /* key is the obj pointer */ + DNHT_MATCH_PTR = 0x0008, /* match by pointer, not match() */ + DNHT_INSERT = 0x0010, /* insert if not found */ + DNHT_UNIQUE = 0x0020, /* report error if already there */ + DNHT_REMOVE = 0x0040, /* remove on find or dn_ht_free */ +}; #endif /* _IP_DN_HEAP_H */ Index: sys/netpfil/ipfw/dn_heap.c =================================================================== --- sys/netpfil/ipfw/dn_heap.c +++ sys/netpfil/ipfw/dn_heap.c @@ -320,13 +320,13 @@ */ struct dn_ht { - int buckets; /* how many buckets, really buckets - 1*/ - int entries; /* how many entries */ - int ofs; /* offset of link field */ - uint32_t (*hash)(uintptr_t, int, void *arg); - int (*match)(void *_el, uintptr_t key, int, void *); - void *(*newh)(uintptr_t, int, void *); - void **ht; /* bucket heads */ + int buckets; /* how many buckets, really buckets - 1*/ + int entries; /* how many entries */ + int ofs; /* offset of link field */ + uint32_t (*hash)(uintptr_t, int, void *arg); + int (*match)(void *_el, uintptr_t key, int, void *); + void *(*newh)(uintptr_t, int, void *); + void **ht; /* bucket heads */ }; /* * Initialize, allocating bucket pointers inline. @@ -336,8 +336,8 @@ */ struct dn_ht * dn_ht_init(struct dn_ht *ht, int buckets, int ofs, - uint32_t (*h)(uintptr_t, int, void *), - int (*match)(void *, uintptr_t, int, void *), + uint32_t (*h)(uintptr_t, int, void *), + int (*match)(void *, uintptr_t, int, void *), void *(*newh)(uintptr_t, int, void *)) { int l; Index: sys/netpfil/ipfw/dn_sched.h =================================================================== --- sys/netpfil/ipfw/dn_sched.h +++ sys/netpfil/ipfw/dn_sched.h @@ -77,7 +77,7 @@ * This function is called in two cases: * - when a new packet arrives to the scheduler; * - when a scheduler is reconfigured. In this case the - * call is issued by the new_queue callback, with a + * call is issued by the new_queue callback, with a * non empty queue (q) and m pointing to the first * mbuf in the queue. For this reason, the function * should internally check for (m != q->mq.head) @@ -199,5 +199,5 @@ }; \ DECLARE_MODULE(name, name##_mod, \ SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY); \ - MODULE_DEPEND(name, dummynet, 3, 3, 3) + MODULE_DEPEND(name, dummynet, 3, 3, 3) #endif /* _DN_SCHED_H */ Index: sys/netpfil/ipfw/dn_sched_fifo.c =================================================================== --- sys/netpfil/ipfw/dn_sched_fifo.c +++ sys/netpfil/ipfw/dn_sched_fifo.c @@ -62,7 +62,7 @@ * queue size and policy. * Enqueue and dequeue use the default library functions. */ -static int +static int fifo_enqueue(struct dn_sch_inst *si, struct dn_queue *q, struct mbuf *m) { /* XXX if called with q != NULL and m=NULL, this is a @@ -85,7 +85,7 @@ /* This scheduler instance contains the queue */ struct dn_queue *q = (struct dn_queue *)(si + 1); - set_oid(&q->ni.oid, DN_QUEUE, sizeof(*q)); + set_oid(&q->ni.oid, DN_QUEUE, sizeof(*q)); q->_si = si; q->fs = si->sched->fs; return 0; Index: sys/netpfil/ipfw/dn_sched_fq_codel.h =================================================================== --- sys/netpfil/ipfw/dn_sched_fq_codel.h +++ sys/netpfil/ipfw/dn_sched_fq_codel.h @@ -95,7 +95,7 @@ { int inc = 0; - if (len < 0) + if (len < 0) inc = -1; else if (len > 0) inc = 1; @@ -105,7 +105,7 @@ q->stats.drops ++; si->_si.ni.drops ++; io_pkt_drop ++; - } + } if (!drop || (drop && len < 0)) { /* Update stats for the main queue */ @@ -124,10 +124,10 @@ if (inc > 0) { si->main_q.ni.tot_bytes += len; si->main_q.ni.tot_pkts ++; - + q->stats.tot_bytes +=len; q->stats.tot_pkts++; - + si->_si.ni.tot_bytes +=len; si->_si.ni.tot_pkts ++; } @@ -157,7 +157,7 @@ *pkt_ts = 0; } else { *pkt_ts = *(aqm_time_t *)(mtag + 1); - m_tag_delete(m,mtag); + m_tag_delete(m,mtag); } return m; Index: sys/netpfil/ipfw/dn_sched_fq_codel.c =================================================================== --- sys/netpfil/ipfw/dn_sched_fq_codel.c +++ sys/netpfil/ipfw/dn_sched_fq_codel.c @@ -71,9 +71,9 @@ #include #endif -/* NOTE: In fq_codel module, we reimplements CoDel AQM functions - * because fq_codel use different flows (sub-queues) structure and - * dn_queue includes many variables not needed by a flow (sub-queue +/* NOTE: In fq_codel module, we reimplements CoDel AQM functions + * because fq_codel use different flows (sub-queues) structure and + * dn_queue includes many variables not needed by a flow (sub-queue * )i.e. avoid extra overhead (88 bytes vs 208 bytes). * Also, CoDel functions manages stats of sub-queues as well as the main queue. */ @@ -83,7 +83,7 @@ static struct dn_alg fq_codel_desc; /* fq_codel default parameters including codel */ -struct dn_sch_fq_codel_parms +struct dn_sch_fq_codel_parms fq_codel_sysctl = {{5000 * AQM_TIME_1US, 100000 * AQM_TIME_1US, CODEL_ECN_ENABLED}, 1024, 10240, 1514}; @@ -146,7 +146,7 @@ SYSCTL_UINT(_net_inet_ip_dummynet_fqcodel, OID_AUTO, quantum, CTLFLAG_RW, &fq_codel_sysctl.quantum, 1514, "FQ_CoDel quantum"); SYSCTL_UINT(_net_inet_ip_dummynet_fqcodel, OID_AUTO, flows, - CTLFLAG_RW, &fq_codel_sysctl.flows_cnt, 1024, + CTLFLAG_RW, &fq_codel_sysctl.flows_cnt, 1024, "Number of queues for FQ_CoDel"); SYSCTL_UINT(_net_inet_ip_dummynet_fqcodel, OID_AUTO, limit, CTLFLAG_RW, &fq_codel_sysctl.limit, 10240, "FQ_CoDel queues size limit"); @@ -171,7 +171,7 @@ } /* Enqueue a packet 'm' to a queue 'q' and add timestamp to that packet. - * Return 1 when unable to add timestamp, otherwise return 0 + * Return 1 when unable to add timestamp, otherwise return 0 */ static int codel_enqueue(struct fq_codel_flow *q, struct mbuf *m, struct fq_codel_si *si) @@ -190,7 +190,7 @@ mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); + m_freem(m); goto drop; } *(aqm_time_t *)(mtag + 1) = AQM_UNOW; @@ -208,7 +208,7 @@ /* * Classify a packet to queue number using Jenkins hash function. - * Return: queue number + * Return: queue number * the input of the hash are protocol no, perturbation, src IP, dst IP, * src port, dst port, */ @@ -252,7 +252,7 @@ hash = jenkins_hash(tuple, 41, HASHINIT) % fcount; return hash; - } + } //#endif /* IPv4 */ @@ -285,8 +285,8 @@ * Enqueue a packet into an appropriate queue according to * FQ_CODEL algorithm. */ -static int -fq_codel_enqueue(struct dn_sch_inst *_si, struct dn_queue *_q, +static int +fq_codel_enqueue(struct dn_sch_inst *_si, struct dn_queue *_q, struct mbuf *m) { struct fq_codel_si *si; @@ -303,11 +303,11 @@ /* classify a packet to queue number*/ idx = fq_codel_classify_flow(m, param->flows_cnt, si); /* enqueue packet into appropriate queue using CoDel AQM. - * Note: 'codel_enqueue' function returns 1 only when it unable to + * Note: 'codel_enqueue' function returns 1 only when it unable to * add timestamp to packet (no limit check)*/ drop = codel_enqueue(&si->flows[idx], m, si); - /* codel unable to timestamp a packet */ + /* codel unable to timestamp a packet */ if (drop) return 1; @@ -324,7 +324,7 @@ } /* check the limit for all queues and remove a packet from the - * largest one + * largest one */ if (mainq->ni.length > schk->cfg.limit) { D("over limit"); /* find first active flow */ @@ -333,7 +333,7 @@ break; if (maxidx < schk->cfg.flows_cnt) { /* find the largest sub- queue */ - for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) + for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) if (si->flows[i].active && si->flows[i].stats.length > si->flows[maxidx].stats.length) maxidx = i; @@ -372,7 +372,7 @@ fq_codel_flowlist = &si->newflows; /* Both new and old queue lists are empty, return NULL */ - if (STAILQ_EMPTY(fq_codel_flowlist)) + if (STAILQ_EMPTY(fq_codel_flowlist)) return NULL; f = STAILQ_FIRST(fq_codel_flowlist); @@ -386,14 +386,14 @@ f->deficit += param->quantum; STAILQ_REMOVE_HEAD(fq_codel_flowlist, flowchain); STAILQ_INSERT_TAIL(&si->oldflows, f, flowchain); - } else + } else break; f = STAILQ_FIRST(fq_codel_flowlist); } - + /* the new flows list is empty, try old flows list */ - if (STAILQ_EMPTY(fq_codel_flowlist)) + if (STAILQ_EMPTY(fq_codel_flowlist)) continue; /* Dequeue a packet from the selected flow */ @@ -401,7 +401,7 @@ /* Codel did not return a packet */ if (!mbuf) { - /* If the selected flow belongs to new flows list, then move + /* If the selected flow belongs to new flows list, then move * it to the tail of old flows list. Otherwise, deactivate it and * remove it from the old list and */ @@ -416,7 +416,7 @@ continue; } - /* we have a packet to return, + /* we have a packet to return, * update flow deficit and return the packet*/ f->deficit -= mbuf->m_pkthdr.len; return mbuf; @@ -458,7 +458,7 @@ sizeof(struct fq_codel_flow), M_DUMMYNET, M_NOWAIT | M_ZERO); if (si->flows == NULL) { D("cannot allocate memory for fq_codel configuration parameters"); - return ENOMEM ; + return ENOMEM ; } /* init perturbation for this si */ @@ -547,7 +547,7 @@ fqc_cfg->flows_cnt = ep->par[5]; /* Bound the configurations */ - fqc_cfg->ccfg.target = BOUND_VAR(fqc_cfg->ccfg.target, 1 , + fqc_cfg->ccfg.target = BOUND_VAR(fqc_cfg->ccfg.target, 1 , 5 * AQM_TIME_1S); ; fqc_cfg->ccfg.interval = BOUND_VAR(fqc_cfg->ccfg.interval, 1, 100 * AQM_TIME_1S); @@ -566,7 +566,7 @@ * Return fq_codel scheduler configurations * the configurations for the scheduler is passed to userland. */ -static int +static int fq_codel_getconfig (struct dn_schk *_schk, struct dn_extra_parms *ep) { struct fq_codel_schk *schk = (struct fq_codel_schk *)(_schk+1); struct dn_sch_fq_codel_parms *fqc_cfg; Index: sys/netpfil/ipfw/dn_sched_fq_codel_helper.h =================================================================== --- sys/netpfil/ipfw/dn_sched_fq_codel_helper.h +++ sys/netpfil/ipfw/dn_sched_fq_codel_helper.h @@ -96,7 +96,7 @@ } /* Codel dequeue function */ -__inline static struct mbuf * +__inline static struct mbuf * fqc_codel_dequeue(struct fq_codel_flow *q, struct fq_codel_si *si) { struct mbuf *m; @@ -171,7 +171,7 @@ * is a good approximation of the time from the last drop * until now.) */ - cst->count = (cst->count > 2 && ((aqm_stime_t)now - + cst->count = (cst->count > 2 && ((aqm_stime_t)now - (aqm_stime_t)cst->drop_next_time) < 8* cprms->interval)? cst->count - 2 : 1; /* we don't have to set initial guess for Newton's method isqrt as Index: sys/netpfil/ipfw/dn_sched_fq_pie.c =================================================================== --- sys/netpfil/ipfw/dn_sched_fq_pie.c +++ sys/netpfil/ipfw/dn_sched_fq_pie.c @@ -133,7 +133,7 @@ /* fq_pie scheduler instance */ struct fq_pie_si { - struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST */ + struct dn_sch_inst _si; /* standard scheduler instance. SHOULD BE FIRST */ struct dn_queue main_q; /* main queue is after si directly */ uint32_t perturbation; /* random value */ struct fq_pie_list newflows; /* list of new queues */ @@ -145,14 +145,14 @@ /* Default FQ-PIE parameters including PIE */ /* PIE defaults - * target=15ms, max_burst=150ms, max_ecnth=0.1, + * target=15ms, max_burst=150ms, max_ecnth=0.1, * alpha=0.125, beta=1.25, tupdate=15ms * FQ- * flows=1024, limit=10240, quantum =1514 */ -struct dn_sch_fq_pie_parms +struct dn_sch_fq_pie_parms fq_pie_sysctl = {{15000 * AQM_TIME_1US, 15000 * AQM_TIME_1US, - 150000 * AQM_TIME_1US, PIE_SCALE * 0.1, PIE_SCALE * 0.125, + 150000 * AQM_TIME_1US, PIE_SCALE * 0.1, PIE_SCALE * 0.125, PIE_SCALE * 1.25, PIE_CAPDROP_ENABLED | PIE_DERAND_ENABLED}, 1024, 10240, 1514}; @@ -166,7 +166,7 @@ value = fq_pie_sysctl.pcfg.alpha; else value = fq_pie_sysctl.pcfg.beta; - + value = value * 1000 / PIE_SCALE; error = sysctl_handle_long(oidp, &value, 0, req); if (error != 0 || req->newptr == NULL) @@ -300,7 +300,7 @@ q->stats.drops ++; si->_si.ni.drops ++; io_pkt_drop ++; - } + } if (!drop || (drop && len < 0)) { /* Update stats for the main queue */ @@ -319,10 +319,10 @@ if (inc > 0) { si->main_q.ni.tot_bytes += len; si->main_q.ni.tot_pkts ++; - + q->stats.tot_bytes +=len; q->stats.tot_pkts++; - + si->_si.ni.tot_bytes +=len; si->_si.ni.tot_pkts ++; } @@ -358,14 +358,14 @@ *pkt_ts = 0; } else { *pkt_ts = *(aqm_time_t *)(mtag + 1); - m_tag_delete(m,mtag); + m_tag_delete(m,mtag); } } return m; } /* - * Callout function for drop probability calculation + * Callout function for drop probability calculation * This function is called over tupdate ms and takes pointer of FQ-PIE * flow as an argument */ @@ -374,7 +374,7 @@ { struct fq_pie_flow *q = (struct fq_pie_flow *) x; struct pie_status *pst = &q->pst; - struct dn_aqm_pie_parms *pprms; + struct dn_aqm_pie_parms *pprms; int64_t p, prob, oldprob; aqm_time_t now; int p_isneg; @@ -395,17 +395,17 @@ pst->current_qdelay = 0; /* calculate drop probability */ - p = (int64_t)pprms->alpha * - ((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); - p +=(int64_t) pprms->beta * - ((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); + p = (int64_t)pprms->alpha * + ((int64_t)pst->current_qdelay - (int64_t)pprms->qdelay_ref); + p +=(int64_t) pprms->beta * + ((int64_t)pst->current_qdelay - (int64_t)pst->qdelay_old); /* take absolute value so right shift result is well defined */ p_isneg = p < 0; if (p_isneg) { p = -p; } - + /* We PIE_MAX_PROB shift by 12-bits to increase the division precision */ p *= (PIE_MAX_PROB << 12) / AQM_TIME_1S; @@ -461,7 +461,7 @@ } else { if (pst->current_qdelay == 0 && pst->qdelay_old == 0) { /* 0.98 ~= 1- 1/64 */ - prob = prob - (prob >> 6); + prob = prob - (prob >> 6); } if (prob > PIE_MAX_PROB) { @@ -478,7 +478,7 @@ if ((pst->sflags & PIE_ACTIVE) && pst->burst_allowance) { if (pst->burst_allowance > pprms->tupdate) pst->burst_allowance -= pprms->tupdate; - else + else pst->burst_allowance = 0; } @@ -490,12 +490,12 @@ mtx_unlock(&pst->lock_mtx); } -/* +/* * Reset PIE variables & activate the queue */ __inline static void fq_activate_pie(struct fq_pie_flow *q) -{ +{ struct pie_status *pst = &q->pst; struct dn_aqm_pie_parms *pprms; @@ -519,12 +519,12 @@ mtx_unlock(&pst->lock_mtx); } - /* + /* * Deactivate PIE and stop probe update callout */ __inline static void fq_deactivate_pie(struct pie_status *pst) -{ +{ mtx_lock(&pst->lock_mtx); pst->sflags &= ~(PIE_ACTIVE | PIE_INMEASUREMENT); callout_stop(&pst->aqm_pie_callout); @@ -532,7 +532,7 @@ mtx_unlock(&pst->lock_mtx); } - /* + /* * Initialize PIE for sub-queue 'q' */ static int @@ -549,8 +549,8 @@ q->psi_extra->nr_active_q++; /* For speed optimization, we caculate 1/3 queue size once here */ - // XXX limit divided by number of queues divided by 3 ??? - pst->one_third_q_size = (fqpie_schk->cfg.limit / + // XXX limit divided by number of queues divided by 3 ??? + pst->one_third_q_size = (fqpie_schk->cfg.limit / fqpie_schk->cfg.flows_cnt) / 3; mtx_init(&pst->lock_mtx, "mtx_pie", NULL, MTX_DEF); @@ -561,7 +561,7 @@ return err; } -/* +/* * callout function to destroy PIE lock, and free fq_pie flows and fq_pie si * extra memory when number of active sub-queues reaches zero. * 'x' is a fq_pie_flow to be destroyed @@ -589,8 +589,8 @@ DN_BH_WUNLOCK(); } -/* - * Clean up PIE status for sub-queue 'q' +/* + * Clean up PIE status for sub-queue 'q' * Stop callout timer and destroy mtx using fqpie_callout_cleanup() callout. */ static int @@ -605,7 +605,7 @@ return 0; } -/* +/* * Dequeue and return a pcaket from sub-queue 'q' or NULL if 'q' is empty. * Also, caculate depature time or queue delay using timestamp */ @@ -623,7 +623,7 @@ pprms = q->pst.parms; /*we extarct packet ts only when Departure Rate Estimation dis not used*/ - m = fq_pie_extract_head(q, &pkt_ts, si, + m = fq_pie_extract_head(q, &pkt_ts, si, !(pprms->flags & PIE_DEPRATEEST_ENABLED)); if (!m || !(pst->sflags & PIE_ACTIVE)) @@ -638,17 +638,17 @@ if (pst->dq_count >= PIE_DQ_THRESHOLD) { dq_time = now - pst->measurement_start; - /* - * if we don't have old avg dq_time i.e PIE is (re)initialized, + /* + * if we don't have old avg dq_time i.e PIE is (re)initialized, * don't use weight to calculate new avg_dq_time */ if(pst->avg_dq_time == 0) pst->avg_dq_time = dq_time; else { - /* - * weight = PIE_DQ_THRESHOLD/2^6, but we scaled - * weight by 2^8. Thus, scaled - * weight = PIE_DQ_THRESHOLD /2^8 + /* + * weight = PIE_DQ_THRESHOLD/2^6, but we scaled + * weight by 2^8. Thus, scaled + * weight = PIE_DQ_THRESHOLD /2^8 * */ w = PIE_DQ_THRESHOLD >> 8; pst->avg_dq_time = (dq_time* w @@ -658,11 +658,11 @@ } } - /* + /* * Start new measurment cycle when the queue has * PIE_DQ_THRESHOLD worth of bytes. */ - if(!(pst->sflags & PIE_INMEASUREMENT) && + if(!(pst->sflags & PIE_INMEASUREMENT) && q->stats.len_bytes >= PIE_DQ_THRESHOLD) { pst->sflags |= PIE_INMEASUREMENT; pst->measurement_start = now; @@ -673,7 +673,7 @@ else pst->current_qdelay = now - pkt_ts; - return m; + return m; } /* @@ -698,11 +698,11 @@ /* drop/mark the packet when PIE is active and burst time elapsed */ if (pst->sflags & PIE_ACTIVE && pst->burst_allowance == 0 && drop_early(pst, q->stats.len_bytes) == DROP) { - /* - * if drop_prob over ECN threshold, drop the packet + /* + * if drop_prob over ECN threshold, drop the packet * otherwise mark and enqueue it. */ - if (pprms->flags & PIE_ECN_ENABLED && pst->drop_prob < + if (pprms->flags & PIE_ECN_ENABLED && pst->drop_prob < (pprms->max_ecnth << (PIE_PROB_BITS - PIE_FIX_POINT_BITS)) && ecn_mark(m)) t = ENQUE; @@ -710,8 +710,8 @@ t = DROP; } - /* Turn PIE on when 1/3 of the queue is full */ - if (!(pst->sflags & PIE_ACTIVE) && q->stats.len_bytes >= + /* Turn PIE on when 1/3 of the queue is full */ + if (!(pst->sflags & PIE_ACTIVE) && q->stats.len_bytes >= pst->one_third_q_size) { fq_activate_pie(q); } @@ -719,7 +719,7 @@ /* reset burst tolerance and optinally turn PIE off*/ if (pst->drop_prob == 0 && pst->current_qdelay < (pprms->qdelay_ref >> 1) && pst->qdelay_old < (pprms->qdelay_ref >> 1)) { - + pst->burst_allowance = pprms->max_burst; if (pprms->flags & PIE_ON_OFF_MODE_ENABLED && q->stats.len_bytes<=0) fq_deactivate_pie(pst); @@ -734,7 +734,7 @@ mtag = m_tag_alloc(MTAG_ABI_COMPAT, DN_AQM_MTAG_TS, sizeof(aqm_time_t), M_NOWAIT); if (mtag == NULL) { - m_freem(m); + m_freem(m); t = DROP; } *(aqm_time_t *)(mtag + 1) = AQM_UNOW; @@ -777,7 +777,7 @@ /* * Classify a packet to queue number using Jenkins hash function. - * Return: queue number + * Return: queue number * the input of the hash are protocol no, perturbation, src IP, dst IP, * src port, dst port, */ @@ -821,7 +821,7 @@ hash = jenkins_hash(tuple, 41, HASHINIT) % fcount; return hash; - } + } //#endif /* IPv4 */ @@ -854,10 +854,10 @@ * Enqueue a packet into an appropriate queue according to * FQ-CoDe; algorithm. */ -static int -fq_pie_enqueue(struct dn_sch_inst *_si, struct dn_queue *_q, +static int +fq_pie_enqueue(struct dn_sch_inst *_si, struct dn_queue *_q, struct mbuf *m) -{ +{ struct fq_pie_si *si; struct fq_pie_schk *schk; struct dn_sch_fq_pie_parms *param; @@ -875,11 +875,11 @@ idx = fq_pie_classify_flow(m, param->flows_cnt, si); /* enqueue packet into appropriate queue using PIE AQM. - * Note: 'pie_enqueue' function returns 1 only when it unable to + * Note: 'pie_enqueue' function returns 1 only when it unable to * add timestamp to packet (no limit check)*/ drop = pie_enqueue(&flows[idx], m, si); - /* pie unable to timestamp a packet */ + /* pie unable to timestamp a packet */ if (drop) return 1; @@ -894,7 +894,7 @@ } /* check the limit for all queues and remove a packet from the - * largest one + * largest one */ if (mainq->ni.length > schk->cfg.limit) { /* find first active flow */ @@ -903,7 +903,7 @@ break; if (maxidx < schk->cfg.flows_cnt) { /* find the largest sub- queue */ - for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) + for (i = maxidx + 1; i < schk->cfg.flows_cnt; i++) if (flows[i].active && flows[i].stats.length > flows[maxidx].stats.length) maxidx = i; @@ -921,7 +921,7 @@ */ static struct mbuf * fq_pie_dequeue(struct dn_sch_inst *_si) -{ +{ struct fq_pie_si *si; struct fq_pie_schk *schk; struct dn_sch_fq_pie_parms *param; @@ -941,7 +941,7 @@ fq_pie_flowlist = &si->newflows; /* Both new and old queue lists are empty, return NULL */ - if (STAILQ_EMPTY(fq_pie_flowlist)) + if (STAILQ_EMPTY(fq_pie_flowlist)) return NULL; f = STAILQ_FIRST(fq_pie_flowlist); @@ -955,14 +955,14 @@ f->deficit += param->quantum; STAILQ_REMOVE_HEAD(fq_pie_flowlist, flowchain); STAILQ_INSERT_TAIL(&si->oldflows, f, flowchain); - } else + } else break; f = STAILQ_FIRST(fq_pie_flowlist); } - + /* the new flows list is empty, try old flows list */ - if (STAILQ_EMPTY(fq_pie_flowlist)) + if (STAILQ_EMPTY(fq_pie_flowlist)) continue; /* Dequeue a packet from the selected flow */ @@ -970,7 +970,7 @@ /* pie did not return a packet */ if (!mbuf) { - /* If the selected flow belongs to new flows list, then move + /* If the selected flow belongs to new flows list, then move * it to the tail of old flows list. Otherwise, deactivate it and * remove it from the old list and */ @@ -986,7 +986,7 @@ continue; } - /* we have a packet to return, + /* we have a packet to return, * update flow deficit and return the packet*/ f->deficit -= mbuf->m_pkthdr.len; return mbuf; @@ -1029,7 +1029,7 @@ M_DUMMYNET, M_NOWAIT | M_ZERO); if (si->si_extra == NULL) { D("cannot allocate memory for fq_pie si extra vars"); - return ENOMEM ; + return ENOMEM ; } /* allocate memory for flows array */ si->si_extra->flows = mallocarray(schk->cfg.flows_cnt, @@ -1039,7 +1039,7 @@ free(si->si_extra, M_DUMMYNET); si->si_extra = NULL; D("cannot allocate memory for fq_pie flows"); - return ENOMEM ; + return ENOMEM ; } /* init perturbation for this si */ @@ -1176,7 +1176,7 @@ * Return FQ-PIE scheduler configurations * the configurations for the scheduler is passed to userland. */ -static int +static int fq_pie_getconfig (struct dn_schk *_schk, struct dn_extra_parms *ep) { struct fq_pie_schk *schk = (struct fq_pie_schk *)(_schk+1); struct dn_sch_fq_pie_parms *fqp_cfg; Index: sys/netpfil/ipfw/dn_sched_prio.c =================================================================== --- sys/netpfil/ipfw/dn_sched_prio.c +++ sys/netpfil/ipfw/dn_sched_prio.c @@ -83,7 +83,7 @@ * If a queue with the same priority is already backlogged, use * that one instead of the queue passed as argument. */ -static int +static int prio_enqueue(struct dn_sch_inst *_si, struct dn_queue *q, struct mbuf *m) { struct prio_si *si = (struct prio_si *)(_si + 1); Index: sys/netpfil/ipfw/dn_sched_qfq.c =================================================================== --- sys/netpfil/ipfw/dn_sched_qfq.c +++ sys/netpfil/ipfw/dn_sched_qfq.c @@ -135,12 +135,12 @@ one bit per index. QFQ_MAX_WSHIFT is the maximum power of two supported as a weight. The layout of the bits is as below: - + [ MTU_SHIFT ][ FRAC_BITS ] [ MAX_INDEX ][ MIN_SLOT_SHIFT ] ^.__grp->index = 0 *.__grp->slot_shift - + where MIN_SLOT_SHIFT is derived by difference from the others. The max group index corresponds to Lmax/w_min, where @@ -317,7 +317,7 @@ D("rounding weight to 1"); } cl->inv_w = ONE_FP/w; - w = ONE_FP/cl->inv_w; + w = ONE_FP/cl->inv_w; if (q->wsum + w > QFQ_MAX_WSUM) return EINVAL; Index: sys/netpfil/ipfw/ip_dn_glue.c =================================================================== --- sys/netpfil/ipfw/ip_dn_glue.c +++ sys/netpfil/ipfw/ip_dn_glue.c @@ -108,7 +108,7 @@ u_int32_t last_expired ; /* do not expire too frequently */ int backlogged ; /* #active queues for this flowset */ - /* RED parameters */ + /* RED parameters */ #define SCALE_RED 16 #define SCALE(x) ( (x) << SCALE_RED ) #define SCALE_VAL(x) ( (x) >> SCALE_RED ) @@ -435,8 +435,8 @@ } static int -dn_compat_config_pipe(struct dn_sch *sch, struct dn_link *p, - struct dn_fs *fs, void* v) +dn_compat_config_pipe(struct dn_sch *sch, struct dn_link *p, + struct dn_fs *fs, void* v) { struct dn_pipe7 *p7 = (struct dn_pipe7 *)v; struct dn_pipe8 *p8 = (struct dn_pipe8 *)v; Index: sys/netpfil/ipfw/ip_dn_io.c =================================================================== --- sys/netpfil/ipfw/ip_dn_io.c +++ sys/netpfil/ipfw/ip_dn_io.c @@ -101,7 +101,7 @@ * The heap is checked at every tick and all entities with expired events * are extracted. */ - + MALLOC_DEFINE(M_DUMMYNET, "dummynet", "dummynet heap"); extern void (*bridge_dn_p)(struct mbuf *, struct ifnet *); @@ -254,7 +254,7 @@ #ifdef NEW_AQM /* XXX: to skip ts m_tag. For Debugging only*/ if (mtag != NULL && mtag->m_tag_id == DN_AQM_MTAG_TS) { - m_tag_delete(m,mtag); + m_tag_delete(m,mtag); mtag = m_tag_first(m); D("skip TS tag"); } @@ -314,12 +314,12 @@ */ void dn_free_pkts(struct mbuf *mnext) { - struct mbuf *m; - - while ((m = mnext) != NULL) { - mnext = m->m_nextpkt; - FREE_PKT(m); - } + struct mbuf *m; + + while ((m = mnext) != NULL) { + mnext = m->m_nextpkt; + FREE_PKT(m); + } } static int @@ -494,7 +494,7 @@ */ int dn_enqueue(struct dn_queue *q, struct mbuf* m, int drop) -{ +{ struct dn_fs *f; struct dn_flow *ni; /* stats for scheduler instance */ uint64_t len; @@ -750,7 +750,7 @@ for (; m != NULL; m = n) { struct ifnet *ifp = NULL; /* gcc 3.4.6 complains */ - struct m_tag *tag; + struct m_tag *tag; int dst; n = m->m_nextpkt; @@ -948,7 +948,7 @@ /* optimization -- pass it back to ipfw for immediate send */ /* XXX Don't call dummynet_send() if scheduler return the packet * just enqueued. This avoid a lock order reversal. - * + * */ if (/*dn_cfg.io_fast &&*/ m == *m0 && (dir & PROTO_LAYER2) == 0 ) { /* fast io, rename the tag * to carry reinject info. */ Index: sys/netpfil/ipfw/ip_dn_private.h =================================================================== --- sys/netpfil/ipfw/ip_dn_private.h +++ sys/netpfil/ipfw/ip_dn_private.h @@ -44,9 +44,9 @@ #define ND(fmt, ...) do {} while (0) #define D1(fmt, ...) do {} while (0) #define D(fmt, ...) printf("%-10s " fmt "\n", \ - __FUNCTION__, ## __VA_ARGS__) + __FUNCTION__, ## __VA_ARGS__) #define DX(lev, fmt, ...) do { \ - if (dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) + if (dn_cfg.debug > lev) D(fmt, ## __VA_ARGS__); } while (0) #endif MALLOC_DECLARE(M_DUMMYNET); @@ -88,16 +88,16 @@ #endif struct mq { /* a basic queue of packets*/ - struct mbuf *head, *tail; + struct mbuf *head, *tail; int count; }; static inline void set_oid(struct dn_id *o, int type, int len) { - o->type = type; - o->len = len; - o->subtype = 0; + o->type = type; + o->len = len; + o->subtype = 0; } /* @@ -410,7 +410,7 @@ struct dn_pkt_tag * dn_tag_get(struct mbuf *m); struct dn_queue *ipdn_q_find(struct dn_fsk *, struct dn_sch_inst *, - struct ipfw_flow_id *); + struct ipfw_flow_id *); struct dn_sch_inst *ipdn_si_find(struct dn_schk *, struct ipfw_flow_id *); /* @@ -421,8 +421,8 @@ */ #define DEFAULT_RANGES 5 struct copy_range { - struct dn_id o; - uint32_t r[ 2 * DEFAULT_RANGES ]; + struct dn_id o; + uint32_t r[ 2 * DEFAULT_RANGES ]; }; struct copy_args { Index: sys/netpfil/ipfw/ip_dummynet.c =================================================================== --- sys/netpfil/ipfw/ip_dummynet.c +++ sys/netpfil/ipfw/ip_dummynet.c @@ -327,7 +327,7 @@ */ static void * q_new(uintptr_t key, int flags, void *arg) -{ +{ struct dn_queue *q, *template = arg; struct dn_fsk *fs = template->fs; int size = sizeof(*q) + fs->sched->fp->q_datalen; @@ -535,7 +535,7 @@ bzero(si, sizeof(*si)); // safety free(si, M_DUMMYNET); } - return NULL; + return NULL; } /* @@ -560,7 +560,7 @@ #ifdef NEW_AQM /* clean up AQM status for !DN_MULTIQUEUE sched * Note that all queues belong to fs were cleaned up in fsk_detach. - * When drain_scheduler is called s->fs and q->fs are pointing + * When drain_scheduler is called s->fs and q->fs are pointing * to a correct fs, so we can use fs in this case. */ if (!(s->fp->flags & DN_MULTIQUEUE)) { @@ -686,7 +686,7 @@ /* Clean up all AQM queues status belongs to flowset 'fs' and then * deconfig AQM for flowset 'fs' */ -static void +static void aqm_cleanup_deconfig_fs(struct dn_fsk *fs) { struct dn_sch_inst *si; @@ -702,7 +702,7 @@ if (si && fs->aqmfp && fs->aqmfp->cleanup) fs->aqmfp->cleanup((struct dn_queue *) (si+1)); } - } + } } /* clean up AQM status for all queues for DN_MULTIQUEUE sched*/ @@ -994,11 +994,11 @@ struct dn_queue *q = obj; struct copy_args *a = arg; struct dn_flow *ni = (struct dn_flow *)(*a->start); - if (copy_obj_q(a->start, a->end, &q->ni, "queue", -1)) - return DNHT_SCAN_END; - ni->oid.type = DN_FLOW; /* override the DN_QUEUE */ - ni->oid.id = si_hash((uintptr_t)&ni->fid, 0, NULL); - return 0; + if (copy_obj_q(a->start, a->end, &q->ni, "queue", -1)) + return DNHT_SCAN_END; + ni->oid.type = DN_FLOW; /* override the DN_QUEUE */ + ni->oid.id = si_hash((uintptr_t)&ni->fid, 0, NULL); + return 0; } static int @@ -1021,7 +1021,7 @@ { int have = a->end - *a->start; /* XXX here we check for max length */ - int profile_len = sizeof(struct dn_profile) - + int profile_len = sizeof(struct dn_profile) - ED_MAX_SAMPLES_NO*sizeof(int); if (p == NULL) @@ -1329,7 +1329,7 @@ } #ifdef NEW_AQM -/* Retrieve AQM configurations to ipfw userland +/* Retrieve AQM configurations to ipfw userland */ static int get_aqm_parms(struct sockopt *sopt) @@ -1423,7 +1423,7 @@ err = EINVAL; break; } - + if (schk->fp && schk->fp->getconfig) { if(schk->fp->getconfig(schk, ep)) { D("Error while trying to get sched params"); @@ -1614,13 +1614,13 @@ #endif ND("flowset %d", i); /* XXX other sanity checks */ - if (nfs->flags & DN_QSIZE_BYTES) { + if (nfs->flags & DN_QSIZE_BYTES) { ipdn_bound_var(&nfs->qsize, 16384, 1500, dn_cfg.byte_limit, NULL); // "queue byte size"); - } else { + } else { ipdn_bound_var(&nfs->qsize, 50, 1, dn_cfg.slot_limit, NULL); // "queue slot size"); - } + } if (nfs->flags & DN_HAVE_MASK) { /* make sure we have some buckets */ ipdn_bound_var((int *)&nfs->buckets, dn_cfg.hash_size, @@ -1638,7 +1638,7 @@ fs = dn_ht_find(dn_cfg.fshash, i, flags, NULL); if (fs == NULL) { D("missing sched for flowset %d", i); - break; + break; } /* grab some defaults from the existing one */ if (nfs->sched_nr == 0) /* reuse */ @@ -1758,7 +1758,7 @@ s = dn_ht_find(dn_cfg.schedhash, i, 0, &a); if (s != NULL) { a.fp = s->fp; - /* Scheduler exists, skip to FIFO scheduler + /* Scheduler exists, skip to FIFO scheduler * if command was pipe config... */ if (pipe_cmd) @@ -1797,7 +1797,7 @@ s->profile = NULL; /* XXX maybe not needed */ } else { s->profile = malloc(sizeof(struct dn_profile), - M_DUMMYNET, M_NOWAIT | M_ZERO); + M_DUMMYNET, M_NOWAIT | M_ZERO); if (s->profile == NULL) { D("cannot allocate profile"); goto error; //XXX @@ -1814,7 +1814,7 @@ DX(2, "sched %d type changed from %s to %s", i, s->fp->name, a.fp->name); DX(4, " type/sub %d/%d -> %d/%d", - s->sch.oid.type, s->sch.oid.subtype, + s->sch.oid.type, s->sch.oid.subtype, a.sch->oid.type, a.sch->oid.subtype); if (s->link.link_nr == 0) D("XXX WARNING link 0 for sched %d", i); @@ -1845,7 +1845,7 @@ * trying to reuse existing ones if available */ if (!(s->fp->flags & DN_MULTIQUEUE) && !s->fs) { - s->fs = dn_ht_find(dn_cfg.fshash, i, 0, NULL); + s->fs = dn_ht_find(dn_cfg.fshash, i, 0, NULL); if (!s->fs) { struct dn_fs fs; bzero(&fs, sizeof(fs)); @@ -2109,7 +2109,7 @@ compute_space(struct dn_id *cmd, struct copy_args *a) { int x = 0, need = 0; - int profile_size = sizeof(struct dn_profile) - + int profile_size = sizeof(struct dn_profile) - ED_MAX_SAMPLES_NO*sizeof(int); /* NOTE about compute space: @@ -2159,7 +2159,7 @@ x = DN_C_FS | DN_C_QUEUE; break; case DN_GET_COMPAT: /* compatibility mode */ - need = dn_compat_calc_size(); + need = dn_compat_calc_size(); break; } a->flags = x; @@ -2426,7 +2426,7 @@ drain_queue_cb, NULL); fs->drain_bucket++; } else { - /* No hash table for this flowset, null the pointer + /* No hash table for this flowset, null the pointer * if the queue is deleted */ if (fs->qht) { @@ -2443,7 +2443,7 @@ { /* scan a bucket of flowset */ dn_ht_scan_bucket(dn_cfg.fshash, &dn_cfg.drain_fs, - drain_queue_fs_cb, NULL); + drain_queue_fs_cb, NULL); dn_cfg.drain_fs++; }