Deleted Added
full compact
altq_priq.c (281642) altq_priq.c (287009)
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 $
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 $
27 * $FreeBSD: head/sys/net/altq/altq_priq.c 287009 2015-08-21 22:02:22Z loos $
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
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#ifndef ALTQ_CODEL
294 if (flags & PRCF_CODEL) {
295#ifdef ALTQ_DEBUG
296 printf("priq_class_create: CODEL not configured for PRIQ!\n");
297#endif
298 return (NULL);
299 }
300#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
301
302 if ((cl = pif->pif_classes[pri]) != NULL) {
303 /* modify the class instead of creating a new one */
304 s = splnet();
305 IFQ_LOCK(cl->cl_pif->pif_ifq);
306 if (!qempty(cl->cl_q))
307 priq_purgeq(cl);
308 IFQ_UNLOCK(cl->cl_pif->pif_ifq);
309 splx(s);
310#ifdef ALTQ_RIO
311 if (q_is_rio(cl->cl_q))
312 rio_destroy((rio_t *)cl->cl_red);
313#endif
314#ifdef ALTQ_RED
315 if (q_is_red(cl->cl_q))
316 red_destroy(cl->cl_red);
317#endif
318#ifdef ALTQ_CODEL
319 if (q_is_codel(cl->cl_q))
320 codel_destroy(cl->cl_codel);
321#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;
322 } else {
323 cl = malloc(sizeof(struct priq_class), M_DEVBUF,
324 M_NOWAIT | M_ZERO);
325 if (cl == NULL)
326 return (NULL);
327
328 cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF,
329 M_NOWAIT | M_ZERO);

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

334 pif->pif_classes[pri] = cl;
335 if (flags & PRCF_DEFAULTCLASS)
336 pif->pif_default = cl;
337 if (qlimit == 0)
338 qlimit = 50; /* use default */
339 qlimit(cl->cl_q) = qlimit;
340 qtype(cl->cl_q) = Q_DROPTAIL;
341 qlen(cl->cl_q) = 0;
342 qsize(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 */
343 cl->cl_flags = flags;
344 cl->cl_pri = pri;
345 if (pri > pif->pif_maxpri)
346 pif->pif_maxpri = pri;
347 cl->cl_pif = pif;
348 cl->cl_handle = qid;
349
350#ifdef ALTQ_RED

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

378 qlimit(cl->cl_q) * 30/100,
379 red_flags, red_pkttime);
380 if (cl->cl_red == NULL)
381 goto err_ret;
382 qtype(cl->cl_q) = Q_RED;
383 }
384 }
385#endif /* ALTQ_RED */
386#ifdef ALTQ_CODEL
387 if (flags & PRCF_CODEL) {
388 cl->cl_codel = codel_alloc(5, 100, 0);
389 if (cl->cl_codel != NULL)
390 qtype(cl->cl_q) = Q_CODEL;
391 }
392#endif
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
393
394 return (cl);
395
396 err_ret:
397 if (cl->cl_red != NULL) {
398#ifdef ALTQ_RIO
399 if (q_is_rio(cl->cl_q))
400 rio_destroy((rio_t *)cl->cl_red);
401#endif
402#ifdef ALTQ_RED
403 if (q_is_red(cl->cl_q))
404 red_destroy(cl->cl_red);
405#endif
406#ifdef ALTQ_CODEL
407 if (q_is_codel(cl->cl_q))
408 codel_destroy(cl->cl_codel);
409#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
410 }
411 if (cl->cl_q != NULL)
412 free(cl->cl_q, M_DEVBUF);
413 free(cl, M_DEVBUF);
414 return (NULL);
415}
416
417static int

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

449#ifdef ALTQ_RIO
450 if (q_is_rio(cl->cl_q))
451 rio_destroy((rio_t *)cl->cl_red);
452#endif
453#ifdef ALTQ_RED
454 if (q_is_red(cl->cl_q))
455 red_destroy(cl->cl_red);
456#endif
457#ifdef ALTQ_CODEL
458 if (q_is_codel(cl->cl_q))
459 codel_destroy(cl->cl_codel);
460#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
461 }
462 free(cl->cl_q, M_DEVBUF);
463 free(cl, M_DEVBUF);
464 return (0);
465}
466
467/*
468 * priq_enqueue is an enqueue function to be registered to

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

568 if (q_is_rio(cl->cl_q))
569 return rio_addq((rio_t *)cl->cl_red, cl->cl_q, m,
570 cl->cl_pktattr);
571#endif
572#ifdef ALTQ_RED
573 if (q_is_red(cl->cl_q))
574 return red_addq(cl->cl_red, cl->cl_q, m, cl->cl_pktattr);
575#endif
576#ifdef ALTQ_CODEL
577 if (q_is_codel(cl->cl_q))
578 return codel_addq(cl->cl_codel, cl->cl_q, m);
579#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
580 if (qlen(cl->cl_q) >= qlimit(cl->cl_q)) {
581 m_freem(m);
582 return (-1);
583 }
584
585 if (cl->cl_flags & PRCF_CLEARDSCP)
586 write_dsfield(m, cl->cl_pktattr, 0);
587

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

596#ifdef ALTQ_RIO
597 if (q_is_rio(cl->cl_q))
598 return rio_getq((rio_t *)cl->cl_red, cl->cl_q);
599#endif
600#ifdef ALTQ_RED
601 if (q_is_red(cl->cl_q))
602 return red_getq(cl->cl_red, cl->cl_q);
603#endif
604#ifdef ALTQ_CODEL
605 if (q_is_codel(cl->cl_q))
606 return codel_getq(cl->cl_codel, cl->cl_q);
607#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
608 return _getq(cl->cl_q);
609}
610
611static struct mbuf *
612priq_pollq(cl)
613 struct priq_class *cl;
614{
615 return qhead(cl->cl_q);

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

644#ifdef ALTQ_RED
645 if (q_is_red(cl->cl_q))
646 red_getstats(cl->cl_red, &sp->red[0]);
647#endif
648#ifdef ALTQ_RIO
649 if (q_is_rio(cl->cl_q))
650 rio_getstats((rio_t *)cl->cl_red, &sp->red[0]);
651#endif
616
652#ifdef ALTQ_CODEL
653 if (q_is_codel(cl->cl_q))
654 codel_getstats(cl->cl_codel, &sp->codel);
655#endif
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 ---
656}
657
658/* convert a class handle to the corresponding class pointer */
659static struct priq_class *
660clh_to_clp(struct priq_if *pif, u_int32_t chandle)
661{
662 struct priq_class *cl;
663 int idx;

--- 407 unchanged lines hidden ---