Lines Matching full:rp

176 	red_t	*rp;  in red_alloc()  local
180 rp = malloc(sizeof(red_t), M_DEVBUF, M_NOWAIT | M_ZERO); in red_alloc()
181 if (rp == NULL) in red_alloc()
185 rp->red_weight = W_WEIGHT; in red_alloc()
187 rp->red_weight = weight; in red_alloc()
190 rp->red_wtab = wtab_alloc(rp->red_weight); in red_alloc()
191 if (rp->red_wtab == NULL) { in red_alloc()
192 free(rp, M_DEVBUF); in red_alloc()
196 rp->red_avg = 0; in red_alloc()
197 rp->red_idle = 1; in red_alloc()
200 rp->red_inv_pmax = default_inv_pmax; in red_alloc()
202 rp->red_inv_pmax = inv_pmax; in red_alloc()
204 rp->red_thmin = default_th_min; in red_alloc()
206 rp->red_thmin = th_min; in red_alloc()
208 rp->red_thmax = default_th_max; in red_alloc()
210 rp->red_thmax = th_max; in red_alloc()
212 rp->red_flags = flags; in red_alloc()
216 rp->red_pkttime = 800; in red_alloc()
218 rp->red_pkttime = pkttime; in red_alloc()
222 npkts_per_sec = 1000000 / rp->red_pkttime; in red_alloc()
225 rp->red_weight = W_WEIGHT_2; in red_alloc()
228 rp->red_weight = W_WEIGHT_1; in red_alloc()
233 w = rp->red_weight; in red_alloc()
236 rp->red_wshift = i; in red_alloc()
237 w = 1 << rp->red_wshift; in red_alloc()
238 if (w != rp->red_weight) { in red_alloc()
240 rp->red_weight, w); in red_alloc()
241 rp->red_weight = w; in red_alloc()
248 rp->red_thmin_s = rp->red_thmin << (rp->red_wshift + FP_SHIFT); in red_alloc()
249 rp->red_thmax_s = rp->red_thmax << (rp->red_wshift + FP_SHIFT); in red_alloc()
255 rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin) in red_alloc()
256 * rp->red_inv_pmax) << FP_SHIFT; in red_alloc()
258 microtime(&rp->red_last); in red_alloc()
259 return (rp); in red_alloc()
263 red_destroy(red_t *rp) in red_destroy() argument
265 wtab_destroy(rp->red_wtab); in red_destroy()
266 free(rp, M_DEVBUF); in red_destroy()
270 red_getstats(red_t *rp, struct redstats *sp) in red_getstats() argument
272 sp->q_avg = rp->red_avg >> rp->red_wshift; in red_getstats()
273 sp->xmit_cnt = rp->red_stats.xmit_cnt; in red_getstats()
274 sp->drop_cnt = rp->red_stats.drop_cnt; in red_getstats()
275 sp->drop_forced = rp->red_stats.drop_forced; in red_getstats()
276 sp->drop_unforced = rp->red_stats.drop_unforced; in red_getstats()
277 sp->marked_packets = rp->red_stats.marked_packets; in red_getstats()
281 red_addq(red_t *rp, class_queue_t *q, struct mbuf *m, in red_addq() argument
287 avg = rp->red_avg; in red_addq()
293 if (rp->red_idle) { in red_addq()
297 rp->red_idle = 0; in red_addq()
299 t = (now.tv_sec - rp->red_last.tv_sec); in red_addq()
307 t = t * 1000000 + (now.tv_usec - rp->red_last.tv_usec); in red_addq()
308 n = t / rp->red_pkttime - 1; in red_addq()
313 pow_w(rp->red_wtab, n); in red_addq()
318 avg += (qlen(q) << FP_SHIFT) - (avg >> rp->red_wshift); in red_addq()
319 rp->red_avg = avg; /* save the new value */ in red_addq()
325 rp->red_count++; in red_addq()
329 if (avg >= rp->red_thmin_s && qlen(q) > 1) { in red_addq()
330 if (avg >= rp->red_thmax_s) { in red_addq()
333 } else if (rp->red_old == 0) { in red_addq()
335 rp->red_count = 1; in red_addq()
336 rp->red_old = 1; in red_addq()
337 } else if (drop_early((avg - rp->red_thmin_s) >> rp->red_wshift, in red_addq()
338 rp->red_probd, rp->red_count)) { in red_addq()
340 if ((rp->red_flags & REDF_ECN) && in red_addq()
341 mark_ecn(m, pktattr, rp->red_flags)) { in red_addq()
343 rp->red_count = 0; in red_addq()
345 rp->red_stats.marked_packets++; in red_addq()
354 rp->red_old = 0; in red_addq()
376 rp->red_stats.drop_unforced++; in red_addq()
384 rp->red_stats.drop_forced++; in red_addq()
388 PKTCNTR_ADD(&rp->red_stats.drop_cnt, m_pktlen(m)); in red_addq()
390 rp->red_count = 0; in red_addq()
396 PKTCNTR_ADD(&rp->red_stats.xmit_cnt, m_pktlen(m)); in red_addq()
525 red_getq(red_t *rp, class_queue_t *q) in red_getq() argument
530 if (rp->red_idle == 0) { in red_getq()
531 rp->red_idle = 1; in red_getq()
532 microtime(&rp->red_last); in red_getq()
537 rp->red_idle = 0; in red_getq()