Lines Matching refs:rp

179 	red_t	*rp;
183 rp = malloc(sizeof(red_t), M_DEVBUF, M_NOWAIT | M_ZERO);
184 if (rp == NULL)
188 rp->red_weight = W_WEIGHT;
190 rp->red_weight = weight;
193 rp->red_wtab = wtab_alloc(rp->red_weight);
194 if (rp->red_wtab == NULL) {
195 free(rp, M_DEVBUF);
199 rp->red_avg = 0;
200 rp->red_idle = 1;
203 rp->red_inv_pmax = default_inv_pmax;
205 rp->red_inv_pmax = inv_pmax;
207 rp->red_thmin = default_th_min;
209 rp->red_thmin = th_min;
211 rp->red_thmax = default_th_max;
213 rp->red_thmax = th_max;
215 rp->red_flags = flags;
219 rp->red_pkttime = 800;
221 rp->red_pkttime = pkttime;
225 npkts_per_sec = 1000000 / rp->red_pkttime;
228 rp->red_weight = W_WEIGHT_2;
231 rp->red_weight = W_WEIGHT_1;
236 w = rp->red_weight;
239 rp->red_wshift = i;
240 w = 1 << rp->red_wshift;
241 if (w != rp->red_weight) {
243 rp->red_weight, w);
244 rp->red_weight = w;
251 rp->red_thmin_s = rp->red_thmin << (rp->red_wshift + FP_SHIFT);
252 rp->red_thmax_s = rp->red_thmax << (rp->red_wshift + FP_SHIFT);
258 rp->red_probd = (2 * (rp->red_thmax - rp->red_thmin)
259 * rp->red_inv_pmax) << FP_SHIFT;
261 microtime(&rp->red_last);
262 return (rp);
266 red_destroy(red_t *rp)
268 wtab_destroy(rp->red_wtab);
269 free(rp, M_DEVBUF);
273 red_getstats(red_t *rp, struct redstats *sp)
275 sp->q_avg = rp->red_avg >> rp->red_wshift;
276 sp->xmit_cnt = rp->red_stats.xmit_cnt;
277 sp->drop_cnt = rp->red_stats.drop_cnt;
278 sp->drop_forced = rp->red_stats.drop_forced;
279 sp->drop_unforced = rp->red_stats.drop_unforced;
280 sp->marked_packets = rp->red_stats.marked_packets;
284 red_addq(red_t *rp, class_queue_t *q, struct mbuf *m,
290 avg = rp->red_avg;
296 if (rp->red_idle) {
300 rp->red_idle = 0;
302 t = (now.tv_sec - rp->red_last.tv_sec);
310 t = t * 1000000 + (now.tv_usec - rp->red_last.tv_usec);
311 n = t / rp->red_pkttime - 1;
316 pow_w(rp->red_wtab, n);
321 avg += (qlen(q) << FP_SHIFT) - (avg >> rp->red_wshift);
322 rp->red_avg = avg; /* save the new value */
328 rp->red_count++;
332 if (avg >= rp->red_thmin_s && qlen(q) > 1) {
333 if (avg >= rp->red_thmax_s) {
336 } else if (rp->red_old == 0) {
338 rp->red_count = 1;
339 rp->red_old = 1;
340 } else if (drop_early((avg - rp->red_thmin_s) >> rp->red_wshift,
341 rp->red_probd, rp->red_count)) {
343 if ((rp->red_flags & REDF_ECN) &&
344 mark_ecn(m, pktattr, rp->red_flags)) {
346 rp->red_count = 0;
348 rp->red_stats.marked_packets++;
357 rp->red_old = 0;
379 rp->red_stats.drop_unforced++;
387 rp->red_stats.drop_forced++;
391 PKTCNTR_ADD(&rp->red_stats.drop_cnt, m_pktlen(m));
393 rp->red_count = 0;
399 PKTCNTR_ADD(&rp->red_stats.xmit_cnt, m_pktlen(m));
528 red_getq(rp, q)
529 red_t *rp;
535 if (rp->red_idle == 0) {
536 rp->red_idle = 1;
537 microtime(&rp->red_last);
542 rp->red_idle = 0;