Deleted Added
sdiff udiff text old ( 281642 ) new ( 287009 )
full compact
1/*-
2 * Copyright (C) 2000-2003
3 * Sony Computer Science Laboratories Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 10 unchanged lines hidden (view full) ---

19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $KAME: altq_priq.c,v 1.11 2003/09/17 14:23:25 kjc Exp $
27 * $FreeBSD: head/sys/net/altq/altq_priq.c 281642 2015-04-17 06:38:31Z glebius $
28 */
29/*
30 * priority queue
31 */
32
33#include "opt_altq.h"
34#include "opt_inet.h"
35#include "opt_inet6.h"

--- 249 unchanged lines hidden (view full) ---

285#ifndef ALTQ_RED
286 if (flags & PRCF_RED) {
287#ifdef ALTQ_DEBUG
288 printf("priq_class_create: RED not configured for PRIQ!\n");
289#endif
290 return (NULL);
291 }
292#endif
293
294 if ((cl = pif->pif_classes[pri]) != NULL) {
295 /* modify the class instead of creating a new one */
296 s = splnet();
297 IFQ_LOCK(cl->cl_pif->pif_ifq);
298 if (!qempty(cl->cl_q))
299 priq_purgeq(cl);
300 IFQ_UNLOCK(cl->cl_pif->pif_ifq);
301 splx(s);
302#ifdef ALTQ_RIO
303 if (q_is_rio(cl->cl_q))
304 rio_destroy((rio_t *)cl->cl_red);
305#endif
306#ifdef ALTQ_RED
307 if (q_is_red(cl->cl_q))
308 red_destroy(cl->cl_red);
309#endif
310 } else {
311 cl = malloc(sizeof(struct priq_class), M_DEVBUF,
312 M_NOWAIT | M_ZERO);
313 if (cl == NULL)
314 return (NULL);
315
316 cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF,
317 M_NOWAIT | M_ZERO);

--- 4 unchanged lines hidden (view full) ---

322 pif->pif_classes[pri] = cl;
323 if (flags & PRCF_DEFAULTCLASS)
324 pif->pif_default = cl;
325 if (qlimit == 0)
326 qlimit = 50; /* use default */
327 qlimit(cl->cl_q) = qlimit;
328 qtype(cl->cl_q) = Q_DROPTAIL;
329 qlen(cl->cl_q) = 0;
330 cl->cl_flags = flags;
331 cl->cl_pri = pri;
332 if (pri > pif->pif_maxpri)
333 pif->pif_maxpri = pri;
334 cl->cl_pif = pif;
335 cl->cl_handle = qid;
336
337#ifdef ALTQ_RED

--- 27 unchanged lines hidden (view full) ---

365 qlimit(cl->cl_q) * 30/100,
366 red_flags, red_pkttime);
367 if (cl->cl_red == NULL)
368 goto err_ret;
369 qtype(cl->cl_q) = Q_RED;
370 }
371 }
372#endif /* ALTQ_RED */
373
374 return (cl);
375
376 err_ret:
377 if (cl->cl_red != NULL) {
378#ifdef ALTQ_RIO
379 if (q_is_rio(cl->cl_q))
380 rio_destroy((rio_t *)cl->cl_red);
381#endif
382#ifdef ALTQ_RED
383 if (q_is_red(cl->cl_q))
384 red_destroy(cl->cl_red);
385#endif
386 }
387 if (cl->cl_q != NULL)
388 free(cl->cl_q, M_DEVBUF);
389 free(cl, M_DEVBUF);
390 return (NULL);
391}
392
393static int

--- 31 unchanged lines hidden (view full) ---

425#ifdef ALTQ_RIO
426 if (q_is_rio(cl->cl_q))
427 rio_destroy((rio_t *)cl->cl_red);
428#endif
429#ifdef ALTQ_RED
430 if (q_is_red(cl->cl_q))
431 red_destroy(cl->cl_red);
432#endif
433 }
434 free(cl->cl_q, M_DEVBUF);
435 free(cl, M_DEVBUF);
436 return (0);
437}
438
439/*
440 * priq_enqueue is an enqueue function to be registered to

--- 99 unchanged lines hidden (view full) ---

540 if (q_is_rio(cl->cl_q))
541 return rio_addq((rio_t *)cl->cl_red, cl->cl_q, m,
542 cl->cl_pktattr);
543#endif
544#ifdef ALTQ_RED
545 if (q_is_red(cl->cl_q))
546 return red_addq(cl->cl_red, cl->cl_q, m, cl->cl_pktattr);
547#endif
548 if (qlen(cl->cl_q) >= qlimit(cl->cl_q)) {
549 m_freem(m);
550 return (-1);
551 }
552
553 if (cl->cl_flags & PRCF_CLEARDSCP)
554 write_dsfield(m, cl->cl_pktattr, 0);
555

--- 8 unchanged lines hidden (view full) ---

564#ifdef ALTQ_RIO
565 if (q_is_rio(cl->cl_q))
566 return rio_getq((rio_t *)cl->cl_red, cl->cl_q);
567#endif
568#ifdef ALTQ_RED
569 if (q_is_red(cl->cl_q))
570 return red_getq(cl->cl_red, cl->cl_q);
571#endif
572 return _getq(cl->cl_q);
573}
574
575static struct mbuf *
576priq_pollq(cl)
577 struct priq_class *cl;
578{
579 return qhead(cl->cl_q);

--- 28 unchanged lines hidden (view full) ---

608#ifdef ALTQ_RED
609 if (q_is_red(cl->cl_q))
610 red_getstats(cl->cl_red, &sp->red[0]);
611#endif
612#ifdef ALTQ_RIO
613 if (q_is_rio(cl->cl_q))
614 rio_getstats((rio_t *)cl->cl_red, &sp->red[0]);
615#endif
616
617}
618
619/* convert a class handle to the corresponding class pointer */
620static struct priq_class *
621clh_to_clp(struct priq_if *pif, u_int32_t chandle)
622{
623 struct priq_class *cl;
624 int idx;

--- 407 unchanged lines hidden ---