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_var.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_var.h,v 1.5 2003/11/09 22:11:12 christos Exp $    */
    2 /*      $KAME: altq_var.h,v 1.7 2000/12/14 08:12:46 thorpej Exp $       */
    3 
    4 /*
    5  * Copyright (C) 1998-2000
    6  *      Sony Computer Science Laboratories Inc.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 #ifndef _ALTQ_ALTQ_VAR_H_
   30 #define _ALTQ_ALTQ_VAR_H_
   31 
   32 #ifdef _KERNEL
   33 
   34 #include <sys/param.h>
   35 #include <sys/kernel.h>
   36 #include <sys/queue.h>
   37 
   38 /*
   39  * filter structure for altq common classifier
   40  */
   41 struct acc_filter {
   42         LIST_ENTRY(acc_filter)  f_chain;
   43         void                    *f_class;       /* pointer to the class */
   44         u_long                  f_handle;       /* filter id */
   45         u_int32_t               f_fbmask;       /* filter bitmask */
   46         struct flow_filter      f_filter;       /* filter value */
   47 };
   48 
   49 /*
   50  * XXX ACC_FILTER_TABLESIZE can't be larger than 2048 unless we fix
   51  * the handle assignment.
   52  */
   53 #define ACC_FILTER_TABLESIZE    (256+1)
   54 #define ACC_FILTER_MASK         (ACC_FILTER_TABLESIZE - 2)
   55 #define ACC_WILDCARD_INDEX      (ACC_FILTER_TABLESIZE - 1)
   56 #ifdef __GNUC__
   57 #define ACC_GET_HASH_INDEX(addr) \
   58         ({int x = (addr) + ((addr) >> 16); (x + (x >> 8)) & ACC_FILTER_MASK;})
   59 #else
   60 #define ACC_GET_HASH_INDEX(addr) \
   61         (((addr) + ((addr) >> 8) + ((addr) >> 16) + ((addr) >> 24)) \
   62         & ACC_FILTER_MASK)
   63 #endif
   64 #define ACC_GET_HINDEX(handle) ((handle) >> 20)
   65 
   66 struct acc_classifier {
   67         u_int32_t                       acc_fbmask;
   68         LIST_HEAD(filt, acc_filter)     acc_filters[ACC_FILTER_TABLESIZE];
   69 };
   70 
   71 /*
   72  * flowinfo mask bits used by classifier
   73  */
   74 /* for ipv4 */
   75 #define FIMB4_PROTO     0x0001
   76 #define FIMB4_TOS       0x0002
   77 #define FIMB4_DADDR     0x0004
   78 #define FIMB4_SADDR     0x0008
   79 #define FIMB4_DPORT     0x0010
   80 #define FIMB4_SPORT     0x0020
   81 #define FIMB4_GPI       0x0040
   82 #define FIMB4_ALL       0x007f
   83 /* for ipv6 */
   84 #define FIMB6_PROTO     0x0100
   85 #define FIMB6_TCLASS    0x0200
   86 #define FIMB6_DADDR     0x0400
   87 #define FIMB6_SADDR     0x0800
   88 #define FIMB6_DPORT     0x1000
   89 #define FIMB6_SPORT     0x2000
   90 #define FIMB6_GPI       0x4000
   91 #define FIMB6_FLABEL    0x8000
   92 #define FIMB6_ALL       0xff00
   93 
   94 #define FIMB_ALL        (FIMB4_ALL|FIMB6_ALL)
   95 
   96 #define FIMB4_PORTS     (FIMB4_DPORT|FIMB4_SPORT|FIMB4_GPI)
   97 #define FIMB6_PORTS     (FIMB6_DPORT|FIMB6_SPORT|FIMB6_GPI)
   98 
   99 /*
  100  * machine dependent clock
  101  * a 64bit high resolution time counter.
  102  */
  103 extern u_int32_t machclk_freq;
  104 extern u_int32_t machclk_per_tick;
  105 extern void init_machclk(void);
  106 
  107 #if defined(__i386__) && !defined(I586_CPU) && !defined(I686_CPU)
  108 #ifndef ALTQ_NOPCC
  109 #define ALTQ_NOPCC      /* TSC is not available, ALTQ_NOPCC needed */
  110 #endif
  111 #endif
  112 
  113 #if defined(__i386__) && !defined(ALTQ_NOPCC)
  114 /* for pentium tsc */
  115 #include <machine/cpufunc.h>
  116 
  117 #define read_machclk()          rdtsc()
  118 #ifdef __OpenBSD__
  119 static __inline u_int64_t
  120 rdtsc(void)
  121 {
  122         u_int64_t rv;
  123         __asm __volatile(".byte 0x0f, 0x31" : "=A" (rv));
  124         return (rv);
  125 }
  126 #endif /* __OpenBSD__ */
  127 
  128 #elif defined(__alpha__) && !defined(ALTQ_NOPCC)
  129 /* for alpha rpcc */
  130 extern u_int64_t read_machclk(void);
  131 
  132 #else /* !i386 && !alpha */
  133 /* emulate 256MHz using microtime() */
  134 #define MACHCLK_SHIFT   8
  135 static __inline u_int64_t
  136 read_machclk(void)
  137 {
  138         struct timeval tv;
  139         microtime(&tv);
  140         return (((u_int64_t)(tv.tv_sec - boottime.tv_sec) * 1000000
  141                  + tv.tv_usec) << MACHCLK_SHIFT);
  142 }
  143 #endif /* !i386 && !alpha */
  144 
  145 /*
  146  * debug support
  147  */
  148 #ifdef ALTQ_DEBUG
  149 #ifdef __STDC__
  150 #define ASSERT(e)       ((e) ? (void)0 : altq_assert(__FILE__, __LINE__, #e))
  151 #else   /* PCC */
  152 #define ASSERT(e)       ((e) ? (void)0 : altq_assert(__FILE__, __LINE__, "e"))
  153 #endif
  154 #else
  155 #define ASSERT(e)       ((void)0)
  156 #endif
  157 
  158 /*
  159  * misc stuff for compatibility
  160  */
  161 /* ioctl cmd type */
  162 #if defined(__FreeBSD__) && (__FreeBSD__ < 3)
  163 typedef int ioctlcmd_t;
  164 #else
  165 typedef u_long ioctlcmd_t;
  166 #endif
  167 
  168 /*
  169  * queue macros:
  170  * the interface of TAILQ_LAST macro changed after the introduction
  171  * of softupdate. redefine it here to make it work with pre-2.2.7.
  172  */
  173 #undef TAILQ_LAST
  174 #define TAILQ_LAST(head, headname) \
  175         (*(((struct headname *)((head)->tqh_last))->tqh_last))
  176 
  177 #ifndef TAILQ_EMPTY
  178 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
  179 #endif
  180 #ifndef TAILQ_FOREACH
  181 #define TAILQ_FOREACH(var, head, field)                                 \
  182         for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
  183 #endif
  184 
  185 /* macro for timeout/untimeout */
  186 #if (__FreeBSD_version > 300000) || defined(__NetBSD__)
  187 /* use callout */
  188 #include <sys/callout.h>
  189 
  190 #define CALLOUT_INIT(c)         callout_init((c))
  191 #define CALLOUT_RESET(c,t,f,a)  callout_reset((c),(t),(f),(a))
  192 #define CALLOUT_STOP(c)         callout_stop((c))
  193 #ifndef CALLOUT_INITIALIZER
  194 #define CALLOUT_INITIALIZER     { { { NULL } }, 0, NULL, NULL, 0 }
  195 #endif
  196 #else
  197 /* use old-style timeout/untimeout */
  198 /* dummy callout structure */
  199 struct callout {
  200         void            *c_arg;                 /* function argument */
  201         void            (*c_func) __P((void *));/* functiuon to call */
  202 };
  203 #define CALLOUT_INIT(c)         do {    (void)memset((c), 0, sizeof(*(c))); \
  204                                 } while (/*CONSTCOND*/ 0)
  205 #define CALLOUT_RESET(c,t,f,a)  do {    (c)->c_arg = (a);       \
  206                                         (c)->c_func = (f);      \
  207                                         timeout((f),(a),(t));   \
  208                                 } while (/*CONSTCOND*/ 0)
  209 #define CALLOUT_STOP(c)         untimeout((c)->c_func,(c)->c_arg)
  210 #define CALLOUT_INITIALIZER     { NULL, NULL }
  211 #endif
  212 #if !defined(__FreeBSD__)
  213 typedef void (timeout_t)(void *);
  214 #endif
  215 
  216 #define m_pktlen(m)             ((m)->m_pkthdr.len)
  217 
  218 struct ifnet; struct mbuf; struct flowinfo;
  219 
  220 void *altq_lookup __P((char *, int));
  221 int altq_extractflow __P((struct mbuf *, int, struct flowinfo *, u_int32_t));
  222 int acc_add_filter __P((struct acc_classifier *, struct flow_filter *,
  223                            void *, u_long *));
  224 int acc_delete_filter __P((struct acc_classifier *, u_long));
  225 int acc_discard_filters __P((struct acc_classifier *, void *, int));
  226 void *acc_classify __P((void *, struct mbuf *, int));
  227 u_int8_t read_dsfield __P((struct mbuf *, struct altq_pktattr *));
  228 void write_dsfield __P((struct mbuf *, struct altq_pktattr *, u_int8_t));
  229 void altq_assert __P((const char *, int, const char *));
  230 int tbr_set __P((struct ifaltq *, struct tb_profile *));
  231 int tbr_get __P((struct ifaltq *, struct tb_profile *));
  232 
  233 #endif /* _KERNEL */
  234 #endif /* _ALTQ_ALTQ_VAR_H_ */

Cache object: 35d827821f390fedfbb20e52c6c2028a


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