Lines Matching refs:rp
218 red_t *rp;
224 rp = zalloc(red_zone);
225 if (rp == NULL)
228 bzero(rp, red_size);
229 rp->red_avg = 0;
230 rp->red_idle = 1;
233 rp->red_weight = W_WEIGHT;
235 rp->red_weight = weight;
237 rp->red_inv_pmax = default_inv_pmax;
239 rp->red_inv_pmax = inv_pmax;
241 rp->red_thmin = default_th_min;
243 rp->red_thmin = th_min;
245 rp->red_thmax = default_th_max;
247 rp->red_thmax = th_max;
249 rp->red_flags = (flags & REDF_USERFLAGS);
250 rp->red_ifp = ifp;
254 rp->red_pkttime = 800;
256 rp->red_pkttime = pkttime;
260 npkts_per_sec = 1000000 / rp->red_pkttime;
263 rp->red_weight = W_WEIGHT_2;
266 rp->red_weight = W_WEIGHT_1;
271 w = rp->red_weight;
274 rp->red_wshift = i;
275 w = 1 << rp->red_wshift;
276 if (w != rp->red_weight) {
278 rp->red_weight, w);
279 rp->red_weight = w;
286 rp->red_thmin_s = rp->red_thmin << (rp->red_wshift + FP_SHIFT);
287 rp->red_thmax_s = rp->red_thmax << (rp->red_wshift + FP_SHIFT);
293 rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin) *
294 rp->red_inv_pmax) << FP_SHIFT;
297 rp->red_wtab = wtab_alloc(rp->red_weight);
298 if (rp->red_wtab == NULL) {
299 red_destroy(rp);
303 microuptime(&rp->red_last);
304 return (rp);
308 red_destroy(red_t *rp)
310 if (rp->red_wtab != NULL) {
311 wtab_destroy(rp->red_wtab);
312 rp->red_wtab = NULL;
314 zfree(red_zone, rp);
318 red_getstats(red_t *rp, struct red_stats *sp)
320 sp->q_avg = rp->red_avg >> rp->red_wshift;
321 sp->drop_forced = rp->red_stats.drop_forced;
322 sp->drop_unforced = rp->red_stats.drop_unforced;
323 sp->marked_packets = rp->red_stats.marked_packets;
327 red_addq(red_t *rp, class_queue_t *q, struct mbuf *m, struct pf_mtag *tag)
332 avg = rp->red_avg;
338 if (rp->red_idle) {
342 rp->red_idle = 0;
344 t = (now.tv_sec - rp->red_last.tv_sec);
352 t = t * 1000000 + (now.tv_usec - rp->red_last.tv_usec);
353 n = t / rp->red_pkttime - 1;
358 pow_w(rp->red_wtab, n);
363 avg += (qlen(q) << FP_SHIFT) - (avg >> rp->red_wshift);
364 rp->red_avg = avg; /* save the new value */
370 rp->red_count++;
374 if (avg >= rp->red_thmin_s && qlen(q) > 1) {
375 if (avg >= rp->red_thmax_s) {
378 } else if (rp->red_old == 0) {
380 rp->red_count = 1;
381 rp->red_old = 1;
382 } else if (drop_early((avg - rp->red_thmin_s) >> rp->red_wshift,
383 rp->red_probd, rp->red_count)) {
385 if ((rp->red_flags & REDF_ECN) &&
387 mark_ecn(m, tag, rp->red_flags)) {
389 rp->red_count = 0;
390 rp->red_stats.marked_packets++;
398 rp->red_old = 0;
419 rp->red_stats.drop_unforced++;
425 rp->red_stats.drop_forced++;
427 rp->red_count = 0;
428 IFCQ_CONVERT_LOCK(&rp->red_ifp->if_snd);
470 red_getq_flow(struct red *rp, class_queue_t *q, u_int32_t flow, boolean_t purge)
477 if (rp->red_idle == 0) {
478 rp->red_idle = 1;
479 microuptime(&rp->red_last);
484 rp->red_idle = 0;
489 red_getq(red_t *rp, class_queue_t *q)
491 return (red_getq_flow(rp, q, 0, FALSE));
495 red_purgeq(struct red *rp, class_queue_t *q, u_int32_t flow, u_int32_t *packets,
501 IFCQ_CONVERT_LOCK(&rp->red_ifp->if_snd);
503 while ((m = red_getq_flow(rp, q, flow, TRUE)) != NULL) {
516 red_updateq(red_t *rp, cqev_t ev)
518 #pragma unused(rp, ev)
523 red_suspendq(red_t *rp, class_queue_t *q, boolean_t on)
525 #pragma unused(rp, q, on)