Lines Matching refs:rp

230 	red_t	*rp;
234 rp = malloc(sizeof(red_t), M_DEVBUF, M_WAITOK);
235 if (rp == NULL)
237 bzero(rp, sizeof(red_t));
239 rp->red_avg = 0;
240 rp->red_idle = 1;
243 rp->red_weight = W_WEIGHT;
245 rp->red_weight = weight;
247 rp->red_inv_pmax = default_inv_pmax;
249 rp->red_inv_pmax = inv_pmax;
251 rp->red_thmin = default_th_min;
253 rp->red_thmin = th_min;
255 rp->red_thmax = default_th_max;
257 rp->red_thmax = th_max;
259 rp->red_flags = flags;
263 rp->red_pkttime = 800;
265 rp->red_pkttime = pkttime;
269 npkts_per_sec = 1000000 / rp->red_pkttime;
272 rp->red_weight = W_WEIGHT_2;
275 rp->red_weight = W_WEIGHT_1;
280 w = rp->red_weight;
283 rp->red_wshift = i;
284 w = 1 << rp->red_wshift;
285 if (w != rp->red_weight) {
287 rp->red_weight, w);
288 rp->red_weight = w;
295 rp->red_thmin_s = rp->red_thmin << (rp->red_wshift + FP_SHIFT);
296 rp->red_thmax_s = rp->red_thmax << (rp->red_wshift + FP_SHIFT);
302 rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
303 * rp->red_inv_pmax) << FP_SHIFT;
306 rp->red_wtab = wtab_alloc(rp->red_weight);
308 microtime(&rp->red_last);
309 return (rp);
313 red_destroy(red_t *rp)
317 if (rp->red_flowvalve != NULL)
318 fv_destroy(rp->red_flowvalve);
321 wtab_destroy(rp->red_wtab);
322 free(rp, M_DEVBUF);
326 red_getstats(red_t *rp, struct redstats *sp)
328 sp->q_avg = rp->red_avg >> rp->red_wshift;
329 sp->xmit_cnt = rp->red_stats.xmit_cnt;
330 sp->drop_cnt = rp->red_stats.drop_cnt;
331 sp->drop_forced = rp->red_stats.drop_forced;
332 sp->drop_unforced = rp->red_stats.drop_unforced;
333 sp->marked_packets = rp->red_stats.marked_packets;
337 red_addq(red_t *rp, class_queue_t *q, struct mbuf *m,
346 if (rp->red_flowvalve != NULL && rp->red_flowvalve->fv_flows > 0)
347 if (fv_checkflow(rp->red_flowvalve, pktattr, &fve)) {
354 avg = rp->red_avg;
360 if (rp->red_idle) {
364 rp->red_idle = 0;
366 t = (now.tv_sec - rp->red_last.tv_sec);
374 t = t * 1000000 + (now.tv_usec - rp->red_last.tv_usec);
375 n = t / rp->red_pkttime - 1;
380 pow_w(rp->red_wtab, n);
385 avg += (qlen(q) << FP_SHIFT) - (avg >> rp->red_wshift);
386 rp->red_avg = avg; /* save the new value */
392 rp->red_count++;
396 if (avg >= rp->red_thmin_s && qlen(q) > 1) {
397 if (avg >= rp->red_thmax_s) {
400 } else if (rp->red_old == 0) {
402 rp->red_count = 1;
403 rp->red_old = 1;
404 } else if (drop_early((avg - rp->red_thmin_s) >> rp->red_wshift,
405 rp->red_probd, rp->red_count)) {
407 if ((rp->red_flags & REDF_ECN) &&
408 mark_ecn(m, pktattr, rp->red_flags)) {
410 rp->red_count = 0;
412 rp->red_stats.marked_packets++;
421 rp->red_old = 0;
443 rp->red_stats.drop_unforced++;
451 rp->red_stats.drop_forced++;
455 PKTCNTR_ADD(&rp->red_stats.drop_cnt, m_pktlen(m));
457 rp->red_count = 0;
460 if (rp->red_flowvalve != NULL)
461 fv_dropbyred(rp->red_flowvalve, pktattr, fve);
469 PKTCNTR_ADD(&rp->red_stats.xmit_cnt, m_pktlen(m));
603 red_getq(rp, q)
604 red_t *rp;
610 if (rp->red_idle == 0) {
611 rp->red_idle = 1;
612 microtime(&rp->red_last);
617 rp->red_idle = 0;
872 red_t *rp;
884 rp = rqp->rq_red;
885 q_stats->q_avg = rp->red_avg >> rp->red_wshift;
886 q_stats->xmit_cnt = rp->red_stats.xmit_cnt;
887 q_stats->drop_cnt = rp->red_stats.drop_cnt;
888 q_stats->drop_forced = rp->red_stats.drop_forced;
889 q_stats->drop_unforced = rp->red_stats.drop_unforced;
890 q_stats->marked_packets = rp->red_stats.marked_packets;
892 q_stats->weight = rp->red_weight;
893 q_stats->inv_pmax = rp->red_inv_pmax;
894 q_stats->th_min = rp->red_thmin;
895 q_stats->th_max = rp->red_thmax;
898 if (rp->red_flowvalve != NULL) {
899 struct flowvalve *fv = rp->red_flowvalve;
969 struct redparams *rp;
971 rp = (struct redparams *)addr;
973 default_th_min = rp->th_min;
974 default_th_max = rp->th_max;
975 default_inv_pmax = rp->inv_pmax;
1285 fv_alloc(rp)
1286 struct red *rp;
1316 fv->fv_pthresh = (FV_PSCALE(1) << FP_SHIFT) / rp->red_inv_pmax;
1334 fv->fv_p2ftab[i] = (f / (rp->red_thmax + FV_ALPHA)) >> 8;