Lines Matching refs:rp
234 red_t *rp;
238 rp = malloc(sizeof(red_t), M_DEVBUF, M_WAITOK|M_ZERO);
239 if (rp == NULL)
242 rp->red_avg = 0;
243 rp->red_idle = 1;
246 rp->red_weight = W_WEIGHT;
248 rp->red_weight = weight;
250 rp->red_inv_pmax = default_inv_pmax;
252 rp->red_inv_pmax = inv_pmax;
254 rp->red_thmin = default_th_min;
256 rp->red_thmin = th_min;
258 rp->red_thmax = default_th_max;
260 rp->red_thmax = th_max;
262 rp->red_flags = flags;
266 rp->red_pkttime = 800;
268 rp->red_pkttime = pkttime;
272 npkts_per_sec = 1000000 / rp->red_pkttime;
275 rp->red_weight = W_WEIGHT_2;
278 rp->red_weight = W_WEIGHT_1;
283 w = rp->red_weight;
286 rp->red_wshift = i;
287 w = 1 << rp->red_wshift;
288 if (w != rp->red_weight) {
290 rp->red_weight, w);
291 rp->red_weight = w;
298 rp->red_thmin_s = rp->red_thmin << (rp->red_wshift + FP_SHIFT);
299 rp->red_thmax_s = rp->red_thmax << (rp->red_wshift + FP_SHIFT);
305 rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
306 * rp->red_inv_pmax) << FP_SHIFT;
309 rp->red_wtab = wtab_alloc(rp->red_weight);
311 microtime(&rp->red_last);
315 rp->red_flowvalve = fv_alloc(rp);
319 return rp;
323 red_destroy(red_t *rp)
327 if (rp->red_flowvalve != NULL)
328 fv_destroy(rp->red_flowvalve);
331 wtab_destroy(rp->red_wtab);
332 free(rp, M_DEVBUF);
336 red_getstats(red_t *rp, struct redstats *sp)
338 sp->q_avg = rp->red_avg >> rp->red_wshift;
339 sp->xmit_cnt = rp->red_stats.xmit_cnt;
340 sp->drop_cnt = rp->red_stats.drop_cnt;
341 sp->drop_forced = rp->red_stats.drop_forced;
342 sp->drop_unforced = rp->red_stats.drop_unforced;
343 sp->marked_packets = rp->red_stats.marked_packets;
347 red_addq(red_t *rp, class_queue_t *q, struct mbuf *m,
356 if (rp->red_flowvalve != NULL && rp->red_flowvalve->fv_flows > 0)
357 if (fv_checkflow(rp->red_flowvalve, pktattr, &fve)) {
364 avg = rp->red_avg;
370 if (rp->red_idle) {
374 rp->red_idle = 0;
376 t = (now.tv_sec - rp->red_last.tv_sec);
384 t = t * 1000000 + (now.tv_usec - rp->red_last.tv_usec);
385 n = t / rp->red_pkttime - 1;
390 pow_w(rp->red_wtab, n);
395 avg += (qlen(q) << FP_SHIFT) - (avg >> rp->red_wshift);
396 rp->red_avg = avg; /* save the new value */
402 rp->red_count++;
406 if (avg >= rp->red_thmin_s && qlen(q) > 1) {
407 if (avg >= rp->red_thmax_s) {
410 } else if (rp->red_old == 0) {
412 rp->red_count = 1;
413 rp->red_old = 1;
414 } else if (drop_early((avg - rp->red_thmin_s) >> rp->red_wshift,
415 rp->red_probd, rp->red_count)) {
417 if ((rp->red_flags & REDF_ECN) &&
418 mark_ecn(m, pktattr, rp->red_flags)) {
420 rp->red_count = 0;
422 rp->red_stats.marked_packets++;
431 rp->red_old = 0;
453 rp->red_stats.drop_unforced++;
461 rp->red_stats.drop_forced++;
465 PKTCNTR_ADD(&rp->red_stats.drop_cnt, m_pktlen(m));
467 rp->red_count = 0;
470 if (rp->red_flowvalve != NULL)
471 fv_dropbyred(rp->red_flowvalve, pktattr, fve);
479 PKTCNTR_ADD(&rp->red_stats.xmit_cnt, m_pktlen(m));
622 red_getq(red_t *rp, class_queue_t *q)
627 if (rp->red_idle == 0) {
628 rp->red_idle = 1;
629 microtime(&rp->red_last);
634 rp->red_idle = 0;
862 red_t *rp;
874 rp = rqp->rq_red;
875 q_stats->q_avg = rp->red_avg >> rp->red_wshift;
876 q_stats->xmit_cnt = rp->red_stats.xmit_cnt;
877 q_stats->drop_cnt = rp->red_stats.drop_cnt;
878 q_stats->drop_forced = rp->red_stats.drop_forced;
879 q_stats->drop_unforced = rp->red_stats.drop_unforced;
880 q_stats->marked_packets = rp->red_stats.marked_packets;
882 q_stats->weight = rp->red_weight;
883 q_stats->inv_pmax = rp->red_inv_pmax;
884 q_stats->th_min = rp->red_thmin;
885 q_stats->th_max = rp->red_thmax;
888 if (rp->red_flowvalve != NULL) {
889 struct flowvalve *fv = rp->red_flowvalve;
955 struct redparams *rp;
957 rp = (struct redparams *)addr;
959 default_th_min = rp->th_min;
960 default_th_max = rp->th_max;
961 default_inv_pmax = rp->inv_pmax;
1249 fv_alloc(struct red *rp)
1276 fv->fv_pthresh = (FV_PSCALE(1) << FP_SHIFT) / rp->red_inv_pmax;
1293 fv->fv_p2ftab[i] = (f / (rp->red_thmax + FV_ALPHA)) >> 8;