The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/altq/altq_jobs.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: altq_jobs.h,v 1.4 2008/08/29 00:40:42 gmcgarry Exp $   */
    2 /*      $KAME: altq_jobs.h,v 1.6 2003/07/10 12:07:48 kjc Exp $  */
    3 /*
    4  * Copyright (c) 2001, Rector and Visitors of the University of 
    5  * Virginia.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, 
    9  * with or without modification, are permitted provided 
   10  * that the following conditions are met:
   11  *
   12  * Redistributions of source code must retain the above 
   13  * copyright notice, this list of conditions and the following 
   14  * disclaimer. 
   15  *
   16  * Redistributions in binary form must reproduce the above 
   17  * copyright notice, this list of conditions and the following 
   18  * disclaimer in the documentation and/or other materials provided 
   19  * with the distribution. 
   20  *
   21  * Neither the name of the University of Virginia nor the names 
   22  * of its contributors may be used to endorse or promote products 
   23  * derived from this software without specific prior written 
   24  * permission. 
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
   27  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
   28  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
   29  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
   30  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 
   31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
   32  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
   33  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
   34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
   35  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
   36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
   37  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
   38  * THE POSSIBILITY OF SUCH DAMAGE.
   39  */
   40 /*                                                                     
   41  * JoBS - altq prototype implementation                                
   42  *                                                                     
   43  * Author: Nicolas Christin <nicolas@cs.virginia.edu>
   44  *
   45  * JoBS algorithms originally devised and proposed by                  
   46  * Nicolas Christin and Jorg Liebeherr.
   47  * Grateful Acknowledgments to Tarek Abdelzaher for his help and       
   48  * comments, and to Kenjiro Cho for some helpful advice.
   49  * Contributed by the Multimedia Networks Group at the University
   50  * of Virginia. 
   51  *
   52  * Papers and additional info can be found at 
   53  * http://qosbox.cs.virginia.edu
   54  *                                                                      
   55  */                                                                    
   56 
   57 #ifndef _ALTQ_ALTQ_JOBS_H_
   58 #define _ALTQ_ALTQ_JOBS_H_
   59 
   60 #include <altq/altq.h>
   61 #include <altq/altq_classq.h>
   62 
   63 #ifdef __cplusplus
   64 extern "C" {
   65 #endif
   66 
   67 #define JOBS_MAXPRI     16      /* upper limit on the number of priorities */
   68 #define SCALE_RATE      32
   69 #define SCALE_LOSS      32
   70 #define SCALE_SHARE     16
   71 #define GRANULARITY     1000000 /* microseconds */
   72 #ifndef INFINITY
   73 #define INFINITY        LLONG_MAX
   74 #endif
   75 
   76 /* list of packet arrival times */
   77 struct _tsentry;
   78 typedef TAILQ_HEAD(_timestamps, _tsentry) TSLIST;  
   79 typedef struct _tsentry {
   80         TAILQ_ENTRY(_tsentry) ts_list;
   81         uint64_t        timestamp;
   82 } TSENTRY;
   83 
   84 /*
   85  * timestamp list macros
   86  */
   87 
   88 #define tslist_first(s) TAILQ_FIRST(s)
   89 #define tslist_last(s)  TAILQ_LAST(s, _timestamps)
   90 #define tslist_empty(s) TAILQ_EMPTY(s)
   91 
   92 /*
   93  * scaling/conversion macros
   94  * none of these macros present side-effects, hence the lowercase
   95  */
   96 
   97 #define secs_to_ticks(x)        ((x) * machclk_freq)
   98 #define ticks_to_secs(x)        ((x) / machclk_freq)
   99 #define invsecs_to_invticks(x)  ticks_to_secs(x)
  100 #define invticks_to_invsecs(x)  secs_to_ticks(x)
  101 #define bits_to_bytes(x)        ((x) >> 3)
  102 #define bytes_to_bits(x)        ((x) << 3)
  103 #define scale_rate(x)           ((x) << SCALE_RATE)
  104 #define unscale_rate(x)         ((x) >> SCALE_RATE)
  105 #define bps_to_internal(x)      (invsecs_to_invticks(bits_to_bytes(scale_rate(x))))
  106 #define internal_to_bps(x)      (unscale_rate(invticks_to_invsecs(bytes_to_bits(x))))
  107 
  108 /*
  109  * this macro takes care of possible wraparound
  110  * effects in the computation of a delay
  111  * no side-effects here either
  112  */
  113 
  114 #define delay_diff(x, y) ((x >= y)?(x - y):((ULLONG_MAX-y)+x+1))
  115 
  116 /*
  117  * additional macros (PKTCNTR_ADD can be found
  118  * in the original distribution)
  119  */
  120 
  121 #define PKTCNTR_SUB(cntr, len) do {                                     \
  122         (cntr)->packets--;                                              \
  123         (cntr)->bytes -= len;                                           \
  124 } while (/*CONSTCOND*/ 0)
  125 
  126 #define PKTCNTR_RESET(cntr) do {                                        \
  127         (cntr)->packets = 0;                                            \
  128         (cntr)->bytes = 0;                                              \
  129 } while (/*CONSTCOND*/ 0)
  130 
  131 struct jobs_interface {
  132         char    jobs_ifname[IFNAMSIZ];  /* interface name (e.g., fxp0) */
  133         u_long  arg;                    /* request-specific argument */
  134 };
  135 struct jobs_attach {
  136         struct  jobs_interface iface;
  137         u_int   bandwidth;              /* link bandwidth in bits/sec */
  138         u_int   qlimit;                 /* buffer size in packets */
  139         u_int   separate;               /* separate buffers flag */
  140 };
  141 
  142 struct jobs_add_class {
  143         struct  jobs_interface  iface;
  144         int     pri;                    /* priority (0 is the lowest) */
  145         int     flags;                  /* misc flags (see below) */
  146 
  147         /*
  148          * Delay Bound (-1 = NO ADC) is provided in us,
  149          * and is converted to clock ticks
  150          */
  151         int64_t cl_adc;
  152 
  153         /*
  154          * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1
  155          * and is converted to a fraction of  2^(SCALE_LOSS)
  156          */
  157         int64_t cl_alc;
  158 
  159         /*
  160          * lower bound on throughput (-1 = no ARC)
  161          * is provided in (string) and
  162          * is converted to internal format
  163          */
  164         int64_t cl_arc;
  165 
  166         /* RDC weight (-1 = NO RDC) - no unit */
  167         int64_t cl_rdc;
  168 
  169         /* RLC weight (-1 = NO RLC) - no unit */
  170         int64_t cl_rlc;
  171 
  172         u_long  class_handle;           /* return value */
  173 };
  174 
  175 /* jobs class flags */
  176 #define JOCF_CLEARDSCP          0x0010  /* clear diffserv codepoint */
  177 #define JOCF_DEFAULTCLASS       0x1000  /* default class */
  178 
  179 /* special class handles */
  180 #define JOBS_NULLCLASS_HANDLE   0
  181 
  182 struct jobs_delete_class {
  183         struct  jobs_interface  iface;
  184         u_long  class_handle;
  185 };
  186 
  187 struct jobs_modify_class {
  188         struct  jobs_interface  iface;
  189         u_long  class_handle;
  190         int     pri;
  191 
  192         /* 
  193          * Delay Bound (-1 = NO ADC) is provided in us,
  194          * and is converted to clock ticks
  195          */
  196         int64_t cl_adc;
  197 
  198         /*
  199          * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1
  200          * and is converted to a fraction of  2^(SCALE_LOSS)
  201          */
  202         int64_t cl_alc;
  203 
  204         /*
  205          * lower bound on throughput (-1 = no ARC)
  206          * is provided in (string) and
  207          * is converted to internal format
  208          */
  209         int64_t cl_arc;
  210 
  211         /* RDC weight (-1 = NO RDC) - no unit */
  212         int64_t cl_rdc;
  213 
  214         /* RLC weight (-1 = NO RLC) - no unit */
  215         int64_t cl_rlc;
  216 
  217         int     flags;
  218 };
  219 
  220 struct jobs_add_filter {
  221         struct  jobs_interface iface;
  222         u_long  class_handle;
  223 #ifdef ALTQ3_CLFIER_COMPAT
  224         struct  flow_filter filter;
  225 #endif
  226         u_long  filter_handle;          /* return value */
  227 };
  228 
  229 struct jobs_delete_filter {
  230         struct  jobs_interface iface;
  231         u_long  filter_handle;
  232 };
  233 
  234 struct class_stats {
  235         u_int   adc_violations;
  236         u_int   totallength;
  237         u_int   period;
  238         u_int   qlength;
  239 
  240         u_long  class_handle;
  241 
  242         int64_t service_rate;           /* bps that should be out */
  243 
  244         u_int64_t       avg_cycles_dequeue;
  245         u_int64_t       avg_cycles_enqueue;
  246         u_int64_t       avg_cycles2_dequeue;
  247         u_int64_t       avg_cycles2_enqueue;
  248         u_int64_t       avgdel;         /* in us */
  249         u_int64_t       bc_cycles_dequeue;
  250         u_int64_t       bc_cycles_enqueue;
  251         u_int64_t       busylength;     /* in ms */
  252         u_int64_t       lastdel;        /* in us */
  253         u_int64_t       total_dequeued;
  254         u_int64_t       total_enqueued;
  255         u_int64_t       wc_cycles_dequeue;
  256         u_int64_t       wc_cycles_enqueue;
  257 
  258         struct  pktcntr arrival;        /* rin+dropped */
  259         struct  pktcntr arrivalbusy;
  260         struct  pktcntr rin;            /* dropped packet counter */
  261         struct  pktcntr rout;           /* transmitted packet counter */
  262         struct  pktcntr dropcnt;        /* dropped packet counter */
  263 };
  264 
  265 struct jobs_class_stats {
  266         struct  class_stats *stats;     /* pointer to stats array */
  267         int     maxpri;                 /* in/out */
  268         struct  jobs_interface iface;
  269 };
  270 
  271 #define JOBS_IF_ATTACH          _IOW('Q', 1, struct jobs_attach)
  272 #define JOBS_IF_DETACH          _IOW('Q', 2, struct jobs_interface)
  273 #define JOBS_ENABLE             _IOW('Q', 3, struct jobs_interface)
  274 #define JOBS_DISABLE            _IOW('Q', 4, struct jobs_interface)
  275 #define JOBS_CLEAR              _IOW('Q', 6, struct jobs_interface)
  276 #define JOBS_ADD_CLASS          _IOWR('Q', 7, struct jobs_add_class)
  277 #define JOBS_DEL_CLASS          _IOW('Q', 8, struct jobs_delete_class)
  278 #define JOBS_MOD_CLASS          _IOW('Q', 9, struct jobs_modify_class)
  279 #define JOBS_ADD_FILTER         _IOWR('Q', 10, struct jobs_add_filter)
  280 #define JOBS_DEL_FILTER         _IOW('Q', 11, struct jobs_delete_filter)
  281 #define JOBS_GETSTATS           _IOWR('Q', 12, struct jobs_class_stats)
  282 
  283 #ifdef _KERNEL
  284 
  285 struct jobs_class {
  286         TSLIST  *arv_tm;                /* list of timestamps */
  287         struct  jobs_if *cl_jif;        /* back pointer to jif */
  288         class_queue_t   *cl_q;          /* class queue structure */
  289 
  290         int     cl_pri;                 /* priority */
  291         int     cl_flags;               /* class flags */
  292 
  293         u_long  cl_handle;              /* class handle */
  294 
  295         /* control variables */
  296 
  297         /*
  298          * internal representation:
  299          * bytes/unit_time << 32 = (bps /8 << 32)*1/machclk_freq
  300          */
  301         int64_t service_rate;           /* bps that should be out */
  302         int64_t min_rate_adc;           /* bps that should be out for ADC/ARC */
  303 
  304         u_int64_t       current_loss;   /* % of packets dropped */
  305         u_int64_t       cl_lastdel;     /* in clock ticks */
  306         u_int64_t       cl_avgdel;
  307 
  308         /* statistics */
  309         u_int   cl_period;              /* backlog period */
  310         struct  pktcntr cl_arrival;     /* arrived packet counter */
  311         struct  pktcntr cl_dropcnt;     /* dropped packet counter */
  312         struct  pktcntr cl_rin;         /* let in packet counter */
  313         struct  pktcntr cl_rout;        /* transmitted packet counter */
  314 
  315 
  316         /* modified deficit round-robin specific variables */
  317 
  318         /*
  319          * rout_th is SCALED for precision, as opposed to rout.
  320          */
  321         int64_t st_service_rate;
  322         u_int64_t       cl_last_rate_update;
  323         struct  pktcntr cl_rout_th;     /* theoretical transmissions */
  324         struct  pktcntr st_arrival;     /* rin+dropped */
  325         struct  pktcntr st_rin;         /* dropped packet counter */
  326         struct  pktcntr st_rout;        /* transmitted packet counter */
  327         struct  pktcntr st_dropcnt;     /* dropped packet counter */
  328 
  329         /* service guarantees */
  330         u_int   adc_violations;
  331         int     concerned_adc;
  332         int     concerned_alc;
  333         int     concerned_arc;
  334         int     concerned_rdc;
  335         int     concerned_rlc;
  336         /*
  337          * Delay Bound (-1 = NO ADC) is provided in us,
  338          * and is converted to clock ticks
  339          */
  340         int64_t cl_adc;
  341 
  342         /*
  343          * Loss Rate Bound (-1 = NO ALC) is provided in fraction of 1
  344          * and is converted to a fraction of  2^(SCALE_LOSS)
  345          */
  346         int64_t cl_alc;
  347 
  348         /*
  349          * lower bound on throughput (-1 = no ARC)
  350          * is provided in (string) and
  351          * is converted to internal format
  352          */
  353         int64_t cl_arc;
  354 
  355         /* RDC weight (-1 = NO RDC) - no unit */
  356         int64_t cl_rdc;
  357 
  358         /* RLC weight (-1 = NO RLC) - no unit */
  359         int64_t cl_rlc;
  360 
  361         u_int64_t       delay_prod_others;
  362         u_int64_t       loss_prod_others;
  363         u_int64_t       idletime;
  364 };
  365 
  366 /*
  367  * jobs interface state
  368  */
  369 struct jobs_if {
  370         struct  jobs_if *jif_next;              /* interface state list */
  371         struct  ifaltq  *jif_ifq;               /* backpointer to ifaltq */
  372         struct  jobs_class *jif_default;        /* default class */
  373         struct  jobs_class *jif_classes[JOBS_MAXPRI]; /* classes */
  374 #ifdef ALTQ3_CLFIER_COMPAT
  375         struct  acc_classifier jif_classifier;  /* classifier */
  376 #endif
  377         int     jif_maxpri;                     /* max priority in use */
  378 
  379         u_int   jif_bandwidth;                  /* link bandwidth in bps */
  380         u_int   jif_qlimit;                     /* buffer size in packets */
  381         u_int   jif_separate;                   /* separate buffers or not */
  382         u_int64_t       avg_cycles_dequeue;
  383         u_int64_t       avg_cycles_enqueue;
  384         u_int64_t       avg_cycles2_dequeue;
  385         u_int64_t       avg_cycles2_enqueue;
  386         u_int64_t       bc_cycles_dequeue;
  387         u_int64_t       bc_cycles_enqueue;
  388         u_int64_t       wc_cycles_dequeue;
  389         u_int64_t       wc_cycles_enqueue;
  390         u_int64_t       total_dequeued;
  391         u_int64_t       total_enqueued;
  392 };
  393 
  394 #endif /* _KERNEL */
  395 
  396 #ifdef __cplusplus
  397 }
  398 #endif
  399 
  400 #endif /* _ALTQ_ALTQ_JOBS_H_ */

Cache object: 58f2394a56ea122f5f6ada1d2466b98b


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.