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_hfsc.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_hfsc.h,v 1.5 2003/01/06 15:20:24 christos Exp $   */
    2 /*      $KAME: altq_hfsc.h,v 1.6 2000/12/14 08:12:46 thorpej Exp $      */
    3 
    4 /*
    5  * Copyright (c) 1997-1999 Carnegie Mellon University. All Rights Reserved.
    6  *
    7  * Permission to use, copy, modify, and distribute this software and
    8  * its documentation is hereby granted (including for commercial or
    9  * for-profit use), provided that both the copyright notice and this
   10  * permission notice appear in all copies of the software, derivative
   11  * works, or modified versions, and any portions thereof, and that
   12  * both notices appear in supporting documentation, and that credit
   13  * is given to Carnegie Mellon University in all publications reporting
   14  * on direct or indirect use of this code or its derivatives.
   15  *
   16  * THIS SOFTWARE IS EXPERIMENTAL AND IS KNOWN TO HAVE BUGS, SOME OF
   17  * WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON PROVIDES THIS
   18  * SOFTWARE IN ITS ``AS IS'' CONDITION, AND ANY EXPRESS OR IMPLIED
   19  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   21  * DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
   22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
   24  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
   25  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   26  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
   28  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
   29  * DAMAGE.
   30  *
   31  * Carnegie Mellon encourages (but does not require) users of this
   32  * software to return any improvements or extensions that they make,
   33  * and to grant Carnegie Mellon the rights to redistribute these
   34  * changes without encumbrance.
   35  */
   36 #ifndef _ALTQ_ALTQ_HFSC_H_
   37 #define _ALTQ_ALTQ_HFSC_H_
   38 
   39 #include <altq/altq.h>
   40 #include <altq/altq_classq.h>
   41 #include <altq/altq_red.h>
   42 #include <altq/altq_rio.h>
   43 
   44 #ifdef __cplusplus
   45 extern "C" {
   46 #endif 
   47 
   48 struct hfsc_interface {
   49         char    hfsc_ifname[IFNAMSIZ];  /* interface name (e.g., fxp0) */
   50 };
   51 
   52 struct hfsc_attach {
   53         struct hfsc_interface   iface;
   54         u_int                   bandwidth;  /* link bandwidth in bits/sec */
   55 };
   56 
   57 struct service_curve {
   58         u_int   m1;     /* slope of the first segment in bits/sec */
   59         u_int   d;      /* the x-projection of the first segment in msec */
   60         u_int   m2;     /* slope of the second segment in bits/sec */
   61 };
   62 
   63 struct hfsc_add_class {
   64         struct hfsc_interface   iface;
   65         u_long                  parent_handle;
   66         struct service_curve    service_curve;
   67         int                     qlimit;
   68         int                     flags;
   69 
   70         u_long                  class_handle;  /* return value */
   71 };
   72 
   73 /* special class handles */
   74 #define HFSC_ROOTCLASS_HANDLE   0
   75 #define HFSC_NULLCLASS_HANDLE   0
   76 
   77 /* hfsc class flags */
   78 #define HFCF_RED                0x0001  /* use RED */
   79 #define HFCF_ECN                0x0002  /* use RED/ECN */
   80 #define HFCF_RIO                0x0004  /* use RIO */
   81 #define HFCF_CLEARDSCP          0x0010  /* clear diffserv codepoint */
   82 #define HFCF_DEFAULTCLASS       0x1000  /* default class */
   83 
   84 struct hfsc_delete_class {
   85         struct hfsc_interface   iface;
   86         u_long                  class_handle;
   87 };
   88 
   89 /* service curve types */
   90 #define HFSC_REALTIMESC         1
   91 #define HFSC_LINKSHARINGSC      2
   92 #define HFSC_DEFAULTSC          (HFSC_REALTIMESC|HFSC_LINKSHARINGSC)
   93 
   94 struct hfsc_modify_class {
   95         struct hfsc_interface   iface;
   96         u_long                  class_handle;
   97         struct service_curve    service_curve;
   98         int                     sctype;
   99 };
  100 
  101 struct hfsc_add_filter {
  102         struct hfsc_interface   iface;
  103         u_long                  class_handle;
  104         struct flow_filter      filter;
  105 
  106         u_long                  filter_handle;  /* return value */
  107 };
  108 
  109 struct hfsc_delete_filter {
  110         struct hfsc_interface   iface;
  111         u_long                  filter_handle;
  112 };
  113 
  114 struct hfsc_basic_class_stats {
  115         u_int                   class_id;
  116         u_long                  class_handle;
  117         struct service_curve    rsc;
  118         struct service_curve    fsc;
  119 
  120         u_int64_t               total;  /* total work in bytes */
  121         u_int64_t               cumul;  /* cumulative work in bytes
  122                                            done by real-time criteria */
  123         u_int64_t               d;              /* deadline */
  124         u_int64_t               e;              /* eligible time */
  125         u_int64_t               vt;             /* virtual time */
  126 
  127         u_int                   qlength;
  128         struct pktcntr          xmit_cnt;
  129         struct pktcntr          drop_cnt;
  130         u_int                   period;
  131 
  132         /* red and rio related info */
  133         int             qtype;
  134         struct redstats red[3];
  135 };
  136 
  137 struct hfsc_class_stats {
  138         struct hfsc_interface   iface;
  139         int                     nskip;          /* skip # of classes */
  140         int                     nclasses;       /* # of class stats (WR) */
  141         u_int64_t               cur_time;       /* current time */
  142         u_int                   hif_classes;    /* # of classes in the tree */
  143         u_int                   hif_packets;    /* # of packets in the tree */
  144         struct hfsc_basic_class_stats   *stats; /* pointer to stats array */
  145 };
  146 
  147 #define HFSC_IF_ATTACH          _IOW('Q', 1, struct hfsc_attach)
  148 #define HFSC_IF_DETACH          _IOW('Q', 2, struct hfsc_interface)
  149 #define HFSC_ENABLE             _IOW('Q', 3, struct hfsc_interface)
  150 #define HFSC_DISABLE            _IOW('Q', 4, struct hfsc_interface)
  151 #define HFSC_CLEAR_HIERARCHY    _IOW('Q', 5, struct hfsc_interface)
  152 #define HFSC_ADD_CLASS          _IOWR('Q', 7, struct hfsc_add_class)
  153 #define HFSC_DEL_CLASS          _IOW('Q', 8, struct hfsc_delete_class)
  154 #define HFSC_MOD_CLASS          _IOW('Q', 9, struct hfsc_modify_class)
  155 #define HFSC_ADD_FILTER         _IOWR('Q', 10, struct hfsc_add_filter)
  156 #define HFSC_DEL_FILTER         _IOW('Q', 11, struct hfsc_delete_filter)
  157 #define HFSC_GETSTATS           _IOWR('Q', 12, struct hfsc_class_stats)
  158 
  159 #ifdef _KERNEL
  160 /*
  161  * kernel internal service curve representation
  162  *      coordinates are given by 64 bit unsigned integers.
  163  *      x-axis: unit is clock count.  for the intel x86 architecture,
  164  *              the raw Pentium TSC (Timestamp Counter) value is used.
  165  *              virtual time is also calculated in this time scale.
  166  *      y-axis: unit is byte.
  167  *
  168  *      the service curve parameters are converted to the internal
  169  *      representation.
  170  *      the slope values are scaled to avoid overflow.
  171  *      the inverse slope values as well as the y-projection of the 1st
  172  *      segment are kept in order to to avoid 64-bit divide operations
  173  *      that are expensive on 32-bit architectures.
  174  *
  175  *  note: Intel Pentium TSC never wraps around in several thousands of years.
  176  *      x-axis doesn't wrap around for 1089 years with 1GHz clock.
  177  *      y-axis doesn't wrap around for 4358 years with 1Gbps bandwidth.
  178  */
  179 
  180 /* kernel internal representation of a service curve */
  181 struct internal_sc {
  182         u_int64_t       sm1;    /* scaled slope of the 1st segment */
  183         u_int64_t       ism1;   /* scaled inverse-slope of the 1st segment */
  184         u_int64_t       dx;     /* the x-projection of the 1st segment */
  185         u_int64_t       dy;     /* the y-projection of the 1st segment */
  186         u_int64_t       sm2;    /* scaled slope of the 2nd segment */
  187         u_int64_t       ism2;   /* scaled inverse-slope of the 2nd segment */
  188 };
  189 
  190 /* runtime service curve */
  191 struct runtime_sc {
  192         u_int64_t       x;      /* current starting position on x-axis */
  193         u_int64_t       y;      /* current starting position on x-axis */
  194         u_int64_t       sm1;    /* scaled slope of the 1st segment */
  195         u_int64_t       ism1;   /* scaled inverse-slope of the 1st segment */
  196         u_int64_t       dx;     /* the x-projection of the 1st segment */
  197         u_int64_t       dy;     /* the y-projection of the 1st segment */
  198         u_int64_t       sm2;    /* scaled slope of the 2nd segment */
  199         u_int64_t       ism2;   /* scaled inverse-slope of the 2nd segment */
  200 };
  201 
  202 /* for TAILQ based ellist and actlist implementation */
  203 struct hfsc_class;
  204 typedef TAILQ_HEAD(_eligible, hfsc_class) ellist_t;
  205 typedef TAILQ_ENTRY(hfsc_class) elentry_t;
  206 typedef TAILQ_HEAD(_active, hfsc_class) actlist_t;
  207 typedef TAILQ_ENTRY(hfsc_class) actentry_t;
  208 #define ellist_first(s)         TAILQ_FIRST(s)
  209 #define actlist_first(s)        TAILQ_FIRST(s)
  210 #define actlist_last(s)         TAILQ_LAST(s, _active)
  211 
  212 struct hfsc_class {
  213         u_int           cl_id;          /* class id (just for debug) */
  214         u_long          cl_handle;      /* class handle */
  215         struct hfsc_if  *cl_hif;        /* back pointer to struct hfsc_if */
  216         int             cl_flags;       /* misc flags */
  217 
  218         struct hfsc_class *cl_parent;   /* parent class */
  219         struct hfsc_class *cl_siblings; /* sibling classes */
  220         struct hfsc_class *cl_children; /* child classes */
  221 
  222         class_queue_t   *cl_q;          /* class queue structure */
  223         struct red      *cl_red;        /* RED state */
  224         struct altq_pktattr *cl_pktattr; /* saved header used by ECN */
  225 
  226         u_int64_t       cl_total;       /* total work in bytes */
  227         u_int64_t       cl_cumul;       /* cumulative work in bytes
  228                                            done by real-time criteria */
  229         u_int64_t       cl_d;           /* deadline */
  230         u_int64_t       cl_e;           /* eligible time */
  231         u_int64_t       cl_vt;          /* virtual time */
  232 
  233         struct internal_sc *cl_rsc;     /* internal real-time service curve */
  234         struct internal_sc *cl_fsc;     /* internal fair service curve */
  235         struct runtime_sc  cl_deadline; /* deadline curve */
  236         struct runtime_sc  cl_eligible; /* eligible curve */
  237         struct runtime_sc  cl_virtual;  /* virtual curve */
  238 
  239         u_int           cl_vtperiod;    /* vt period sequence no */
  240         u_int           cl_parentperiod;  /* parent's vt period seqno */
  241         int             cl_nactive;     /* number of active children */
  242         actlist_t       *cl_actc;       /* active children list */
  243 
  244         actentry_t      cl_actlist;     /* active children list entry */
  245         elentry_t       cl_ellist;      /* eligible list entry */
  246 
  247         struct {
  248                 struct pktcntr  xmit_cnt;
  249                 struct pktcntr  drop_cnt;
  250                 u_int period;
  251         } cl_stats;
  252 };
  253 
  254 /*
  255  * hfsc interface state
  256  */
  257 struct hfsc_if {
  258         struct hfsc_if          *hif_next;      /* interface state list */
  259         struct ifaltq           *hif_ifq;       /* backpointer to ifaltq */
  260         struct hfsc_class       *hif_rootclass;         /* root class */
  261         struct hfsc_class       *hif_defaultclass;      /* default class */
  262         struct hfsc_class       *hif_pollcache; /* cache for poll operation */
  263 
  264         u_int   hif_classes;                    /* # of classes in the tree */
  265         u_int   hif_packets;                    /* # of packets in the tree */
  266         u_int   hif_classid;                    /* class id sequence number */
  267         
  268         ellist_t *hif_eligible;                 /* eligible list */
  269 
  270         struct acc_classifier   hif_classifier;
  271 };
  272 
  273 #endif /* _KERNEL */
  274 
  275 #ifdef __cplusplus
  276 }
  277 #endif 
  278 
  279 #endif /* _ALTQ_ALTQ_HFSC_H_ */

Cache object: 95ebd82a89b135c65fea5ad58b3635b8


[ 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.