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/if_altq.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: if_altq.h,v 1.8 2002/09/22 20:09:15 jdolecek Exp $     */
    2 /*      $KAME: if_altq.h,v 1.7 2002/02/19 06:37:39 kjc Exp $    */
    3 
    4 /*
    5  * Copyright (C) 1997-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_IF_ALTQ_H_
   30 #define _ALTQ_IF_ALTQ_H_
   31 
   32 #if defined(_KERNEL_OPT)
   33 #include "opt_altq_enabled.h"
   34 #endif
   35 
   36 struct altq_pktattr; struct tb_regulator; struct top_cdnr;
   37 
   38 /*
   39  * Structure defining a queue for a network interface.
   40  */
   41 struct  ifaltq {
   42         /* fields compatible with struct ifqueue */
   43         struct  mbuf *ifq_head;
   44         struct  mbuf *ifq_tail;
   45         int     ifq_len;
   46         int     ifq_maxlen;
   47         int     ifq_drops;
   48 
   49         /* alternate queueing related fields */
   50         int     altq_type;              /* discipline type */
   51         int     altq_flags;             /* flags (e.g. ready, in-use) */
   52         void    *altq_disc;             /* for discipline-specific use */
   53         struct  ifnet *altq_ifp;        /* back pointer to interface */
   54 
   55         int     (*altq_enqueue) __P((struct ifaltq *, struct mbuf *,
   56                                      struct altq_pktattr *));
   57         struct  mbuf *(*altq_dequeue) __P((struct ifaltq *, int));
   58         int     (*altq_request) __P((struct ifaltq *, int, void *));
   59 
   60         /* classifier fields */
   61         void    *altq_clfier;           /* classifier-specific use */
   62         void    *(*altq_classify) __P((void *, struct mbuf *, int));
   63 
   64         /* token bucket regulator */
   65         struct  tb_regulator *altq_tbr;
   66 
   67         /* input traffic conditioner (doesn't belong to the output queue...) */
   68         struct top_cdnr *altq_cdnr;
   69 };
   70 
   71 
   72 #ifdef _KERNEL
   73 
   74 /*
   75  * packet attributes used by queueing disciplines.
   76  * pattr_class is a discipline-dependent scheduling class that is
   77  * set by a classifier.
   78  * pattr_hdr and pattr_af may be used by a discipline to access
   79  * the header within a mbuf.  (e.g. ECN needs to update the CE bit)
   80  * note that pattr_hdr could be stale after m_pullup, though link
   81  * layer output routines usually don't use m_pullup.  link-level
   82  * compression also invalidates these fields.  thus, pattr_hdr needs
   83  * to be verified when a discipline touches the header.
   84  */
   85 struct altq_pktattr {
   86         void    *pattr_class;           /* sched class set by classifier */
   87         int     pattr_af;               /* address family */
   88         caddr_t pattr_hdr;              /* saved header position in mbuf */
   89 };
   90 
   91 /*
   92  * a token-bucket regulator limits the rate that a network driver can
   93  * dequeue packets from the output queue.
   94  * modern cards are able to buffer a large amount of packets and dequeue
   95  * too many packets at a time.  this bursty dequeue behavior makes it
   96  * impossible to schedule packets by queueing disciplines.
   97  * a token-bucket is used to control the burst size in a device
   98  * independent manner.
   99  */
  100 struct tb_regulator {
  101         int64_t         tbr_rate;       /* (scaled) token bucket rate */
  102         int64_t         tbr_depth;      /* (scaled) token bucket depth */
  103 
  104         int64_t         tbr_token;      /* (scaled) current token */
  105         int64_t         tbr_filluptime; /* (scaled) time to fill up bucket */
  106         u_int64_t       tbr_last;       /* last time token was updated */
  107 
  108         int             tbr_lastop;     /* last dequeue operation type
  109                                            needed for poll-and-dequeue */
  110 };
  111 
  112 /* if_altqflags */
  113 #define ALTQF_READY      0x01   /* driver supports alternate queueing */
  114 #define ALTQF_ENABLED    0x02   /* altq is in use */
  115 #define ALTQF_CLASSIFY   0x04   /* classify packets */
  116 #define ALTQF_CNDTNING   0x08   /* altq traffic conditioning is enabled */
  117 #define ALTQF_DRIVER1    0x40   /* driver specific */
  118 
  119 /* if_altqflags set internally only: */
  120 #define ALTQF_CANTCHANGE        (ALTQF_READY)
  121 
  122 /* altq_dequeue 2nd arg */
  123 #define ALTDQ_REMOVE            1       /* dequeue mbuf from the queue */
  124 #define ALTDQ_POLL              2       /* don't dequeue mbuf from the queue */
  125 
  126 /* altq request types (currently only purge is defined) */
  127 #define ALTRQ_PURGE             1       /* purge all packets */
  128 
  129 #define ALTQ_IS_READY(ifq)              ((ifq)->altq_flags & ALTQF_READY)
  130 #define ALTQ_IS_ENABLED(ifq)            ((ifq)->altq_flags & ALTQF_ENABLED)
  131 #define ALTQ_NEEDS_CLASSIFY(ifq)        ((ifq)->altq_flags & ALTQF_CLASSIFY)
  132 #define ALTQ_IS_CNDTNING(ifq)           ((ifq)->altq_flags & ALTQF_CNDTNING)
  133 
  134 #define ALTQ_SET_CNDTNING(ifq)          ((ifq)->altq_flags |= ALTQF_CNDTNING)
  135 #define ALTQ_CLEAR_CNDTNING(ifq)        ((ifq)->altq_flags &= ~ALTQF_CNDTNING)
  136 #define ALTQ_IS_ATTACHED(ifq)           ((ifq)->altq_disc != NULL)
  137 
  138 #define ALTQ_ENQUEUE(ifq, m, pa, err)                                   \
  139         (err) = (*(ifq)->altq_enqueue)((ifq),(m),(pa))
  140 #define ALTQ_DEQUEUE(ifq, m)                                            \
  141         (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_REMOVE)
  142 #define ALTQ_POLL(ifq, m)                                               \
  143         (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_POLL)
  144 #define ALTQ_PURGE(ifq)                                                 \
  145         (void)(*(ifq)->altq_request)((ifq), ALTRQ_PURGE, (void *)0)
  146 #define ALTQ_IS_EMPTY(ifq)              ((ifq)->ifq_len == 0)
  147 #define TBR_IS_ENABLED(ifq)             ((ifq)->altq_tbr != NULL)
  148 
  149 extern int altq_attach __P((struct ifaltq *, int, void *,
  150                             int (*)(struct ifaltq *, struct mbuf *,
  151                                     struct altq_pktattr *),
  152                             struct mbuf *(*)(struct ifaltq *, int), 
  153                             int (*)(struct ifaltq *, int, void *),
  154                             void *,
  155                             void *(*)(void *, struct mbuf *, int)));
  156 extern int altq_detach __P((struct ifaltq *));
  157 extern int altq_enable __P((struct ifaltq *));
  158 extern int altq_disable __P((struct ifaltq *));
  159 extern struct mbuf *tbr_dequeue __P((struct ifaltq *, int));
  160 extern int (*altq_input) __P((struct mbuf *, int));
  161 void altq_etherclassify __P((struct ifaltq *, struct mbuf *,
  162                              struct altq_pktattr *));
  163 #endif /* _KERNEL */
  164 
  165 #endif /* _ALTQ_IF_ALTQ_H_ */

Cache object: 3d37f583bd32b90912652db96482e38e


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