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/netgraph/atm/uni/ng_uni_cust.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 /*-
    2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    3  *
    4  * Copyright (c) 2001-2003
    5  *      Fraunhofer Institute for Open Communication Systems (FhG Fokus).
    6  *      All rights reserved.
    7  *
    8  * Author: Hartmut Brandt <harti@freebsd.org>
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  * Customisation of signalling source to the NG environment.
   32  *
   33  * $FreeBSD$
   34  */
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/kernel.h>
   39 #include <sys/malloc.h>
   40 #include <sys/queue.h>
   41 #include <sys/lock.h>
   42 #include <sys/mutex.h>
   43 #include <sys/mbuf.h>
   44 #include <netgraph/ng_message.h>
   45 #include <netgraph/netgraph.h>
   46 #include <netgraph/atm/ngatmbase.h>
   47 
   48 #define ASSERT(E, M) KASSERT(E,M)
   49 
   50 /*
   51  * Memory
   52  */
   53 enum unimem {
   54         UNIMEM_INS = 0,
   55         UNIMEM_ALL,
   56         UNIMEM_SIG,
   57         UNIMEM_CALL,
   58         UNIMEM_PARTY,
   59 };
   60 #define UNIMEM_TYPES    5
   61 
   62 void *ng_uni_malloc(enum unimem, const char *, u_int);
   63 void ng_uni_free(enum unimem, void *, const char *, u_int);
   64 
   65 #define INS_ALLOC()     ng_uni_malloc(UNIMEM_INS, __FILE__, __LINE__)
   66 #define INS_FREE(P)     ng_uni_free(UNIMEM_INS, P, __FILE__, __LINE__)
   67 
   68 #define UNI_ALLOC()     ng_uni_malloc(UNIMEM_ALL, __FILE__, __LINE__)
   69 #define UNI_FREE(P)     ng_uni_free(UNIMEM_ALL, P, __FILE__, __LINE__)
   70 
   71 #define SIG_ALLOC()     ng_uni_malloc(UNIMEM_SIG, __FILE__, __LINE__)
   72 #define SIG_FREE(P)     ng_uni_free(UNIMEM_SIG, P, __FILE__, __LINE__)
   73 
   74 #define CALL_ALLOC()    ng_uni_malloc(UNIMEM_CALL, __FILE__, __LINE__)
   75 #define CALL_FREE(P)    ng_uni_free(UNIMEM_CALL, P, __FILE__, __LINE__)
   76 
   77 #define PARTY_ALLOC()   ng_uni_malloc(UNIMEM_PARTY, __FILE__, __LINE__)
   78 #define PARTY_FREE(P)   ng_uni_free(UNIMEM_PARTY, P, __FILE__, __LINE__)
   79 
   80 /*
   81  * Timers
   82  */
   83 struct uni_timer {
   84         struct callout c;
   85 };
   86 
   87 #define _TIMER_INIT(X,T)        ng_callout_init(&(X)->T.c)
   88 #define _TIMER_DESTROY(UNI,FIELD) _TIMER_STOP(UNI,FIELD)
   89 #define _TIMER_STOP(UNI,FIELD) do {                                             \
   90         ng_uncallout(&FIELD.c, (UNI)->arg);                                     \
   91     } while (0)
   92 #define TIMER_ISACT(UNI,T)      (callout_active(&(UNI)->T.c) ||         \
   93         callout_pending(&(UNI)->T.c))
   94 #define _TIMER_START(UNI,ARG,FIELD,DUE,FUNC) do {                       \
   95         _TIMER_STOP(UNI, FIELD);                                        \
   96         ng_callout(&FIELD.c, (UNI)->arg, NULL,                          \
   97             hz * (DUE) / 1000, FUNC, (ARG), 0);                         \
   98     } while (0)
   99 
  100 #define TIMER_FUNC_UNI(T,F)                                             \
  101 static void F(struct uni *);                                            \
  102 static void                                                             \
  103 _##T##_func(node_p node, hook_p hook, void *arg1, int arg2)             \
  104 {                                                                       \
  105         struct uni *uni = (struct uni *)arg1;                           \
  106                                                                         \
  107         (F)(uni);                                                       \
  108         uni_work(uni);                                                  \
  109 }
  110 
  111 /*
  112  * Be careful: call may be invalid after the call to F
  113  */
  114 #define TIMER_FUNC_CALL(T,F)                                            \
  115 static void F(struct call *);                                           \
  116 static void                                                             \
  117 _##T##_func(node_p node, hook_p hook, void *arg1, int arg2)             \
  118 {                                                                       \
  119         struct call *call = (struct call *)arg1;                        \
  120         struct uni *uni = call->uni;                                    \
  121                                                                         \
  122         (F)(call);                                                      \
  123         uni_work(uni);                                                  \
  124 }
  125 
  126 /*
  127  * Be careful: call/party may be invalid after the call to F
  128  */
  129 #define TIMER_FUNC_PARTY(T,F)                                           \
  130 static void F(struct party *);                                          \
  131 static void                                                             \
  132 _##T##_func(node_p node, hook_p hook, void *arg1, int arg2)             \
  133 {                                                                       \
  134         struct party *party = (struct party *)arg1;                     \
  135         struct uni *uni = party->call->uni;                             \
  136                                                                         \
  137         (F)(party);                                                     \
  138         uni_work(uni);                                                  \
  139 }
  140 
  141 extern size_t unimem_sizes[UNIMEM_TYPES];
  142 
  143 #define UNICORE                                                         \
  144 size_t unimem_sizes[UNIMEM_TYPES] = {                                   \
  145         [UNIMEM_INS]    = sizeof(struct uni),                           \
  146         [UNIMEM_ALL]    = sizeof(struct uni_all),                       \
  147         [UNIMEM_SIG]    = sizeof(struct sig),                           \
  148         [UNIMEM_CALL]   = sizeof(struct call),                          \
  149         [UNIMEM_PARTY]  = sizeof(struct party)                          \
  150 };

Cache object: 85fdb636e7c282b4d28d7eede5c7d024


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