FreeBSD Bugzilla – Attachment 155723 Details for
Bug 199538
clang crash building my sources
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
preprocessed source
if_media-1d1dff.c (text/plain), 710.48 KB, created by
Gleb Smirnoff
on 2015-04-19 09:56:21 UTC
(
hide
)
Description:
preprocessed source
Filename:
MIME Type:
Creator:
Gleb Smirnoff
Created:
2015-04-19 09:56:21 UTC
Size:
710.48 KB
patch
obsolete
># 1 "<built-in>" ># 1 "./opt_global.h" 1 >#define KDB 1 >#define KDTRACE_HOOKS 1 >#define NEW_PCIB 1 >#define INVARIANTS 1 >#define WITNESS 1 >#define SMP 1 >#define INVARIANT_SUPPORT 1 >#define MAC 1 >#define AUDIT 1 ># 1 "<built-in>" 2 ># 1 "/usr/src/ifnet/sys/net/if_media.c" >/* $NetBSD: if_media.c,v 1.1 1997/03/17 02:55:15 thorpej Exp $ */ >/* $FreeBSD: projects/ifnet/sys/net/if_media.c 281640 2015-04-17 05:55:07Z glebius $ */ > >/*- > * Copyright (c) 1997 > * Jonathan Stone and Jason R. Thorpe. All rights reserved. > * > * This software is derived from information provided by Matt Thomas. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Jonathan Stone > * and Jason R. Thorpe for the NetBSD Project. > * 4. The names of the authors may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/param.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)param.h 8.3 (Berkeley) 4/4/95 > * $FreeBSD: projects/ifnet/sys/sys/param.h 281640 2015-04-17 05:55:07Z glebius $ > */ > >#ifndef _SYS_PARAM_H_ >#define _SYS_PARAM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_null.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/_null.h" 1 >/*- > * Copyright (c) 2003 Marcel Moolenaar > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_null.h 228918 2011-12-27 21:36:31Z theraven $ > */ > >#ifndef NULL > >#if !defined(__cplusplus) >#define NULL ((void *)0) >#else ># 34 "/usr/src/ifnet/sys/sys/_null.h" >#if __cplusplus >= 201103L >#define NULL nullptr >#elif defined(__GNUG__) && defined(__GNUC__) && __GNUC__ >= 4 ># 37 "/usr/src/ifnet/sys/sys/_null.h" >#define NULL __null >#else ># 39 "/usr/src/ifnet/sys/sys/_null.h" >#if defined(__LP64__) >#define NULL (0L) >#else ># 42 "/usr/src/ifnet/sys/sys/_null.h" >#define NULL 0 >#endif /* __LP64__ */ ># 44 "/usr/src/ifnet/sys/sys/_null.h" >#endif /* __GNUG__ */ ># 45 "/usr/src/ifnet/sys/sys/_null.h" >#endif /* !__cplusplus */ ># 46 "/usr/src/ifnet/sys/sys/_null.h" > >#endif ># 48 "/usr/src/ifnet/sys/sys/_null.h" ># 42 "/usr/src/ifnet/sys/sys/param.h" 2 > >#define BSD 199506 /* System version (year & month). */ >#define BSD4_3 1 >#define BSD4_4 1 > >/* > * __FreeBSD_version numbers are documented in the Porter's Handbook. > * If you bump the version for any reason, you should update the documentation > * there. > * Currently this lives here in the doc/ repository: > * > * head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml > * > * scheme is: <major><two digit minor>Rxx > * 'R' is in the range 0 to 4 if this is a release branch or > * x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is > * in the range 5 to 9. > */ >#undef __FreeBSD_version >#define __FreeBSD_version 1100070 /* Master, propagated to newvers */ > >/* > * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, > * which by definition is always true on FreeBSD. This macro is also defined > * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD. > * > * It is tempting to use this macro in userland code when we want to enable > * kernel-specific routines, and in fact it's fine to do this in code that > * is part of FreeBSD itself. However, be aware that as presence of this > * macro is still not widespread (e.g. older FreeBSD versions, 3rd party > * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in > * external applications without also checking for __FreeBSD__ as an > * alternative. > */ >#undef __FreeBSD_kernel__ >#define __FreeBSD_kernel__ > >#ifdef _KERNEL >#define P_OSREL_SIGWAIT 700000 >#define P_OSREL_SIGSEGV 700004 >#define P_OSREL_MAP_ANON 800104 >#define P_OSREL_MAP_FSTRICT 1100036 > >#define P_OSREL_MAJOR(x) ((x) / 100000) >#endif ># 87 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef LOCORE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 89 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/types.h" 1 >/*- > * Copyright (c) 1982, 1986, 1991, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)types.h 8.6 (Berkeley) 2/19/95 > * $FreeBSD: projects/ifnet/sys/sys/types.h 280281 2015-03-20 14:12:04Z glebius $ > */ > >#ifndef _SYS_TYPES_H_ >#define _SYS_TYPES_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/types.h" ># 1 "/usr/src/ifnet/sys/sys/cdefs.h" 1 >/*- > * Copyright (c) 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * Berkeley Software Design, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 > * $FreeBSD: projects/ifnet/sys/sys/cdefs.h 281640 2015-04-17 05:55:07Z glebius $ > */ > >#ifndef _SYS_CDEFS_H_ >#define _SYS_CDEFS_H_ > >/* > * Testing against Clang-specific extensions. > */ > >#ifndef __has_attribute >#define __has_attribute(x) 0 >#endif ># 46 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __has_extension >#define __has_extension __has_feature >#endif ># 49 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __has_feature >#define __has_feature(x) 0 >#endif ># 52 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __has_include >#define __has_include(x) 0 >#endif ># 55 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __has_builtin >#define __has_builtin(x) 0 >#endif ># 58 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__cplusplus) >#define __BEGIN_DECLS extern "C" { >#define __END_DECLS } >#else ># 63 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __BEGIN_DECLS >#define __END_DECLS >#endif ># 66 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * This code has been put in place to help reduce the addition of > * compiler specific defines in FreeBSD code. It helps to aid in > * having a compiler-agnostic source tree. > */ > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) > >#if __GNUC__ >= 3 || defined(__INTEL_COMPILER) >#define __GNUCLIKE_ASM 3 >#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS >#else ># 79 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __GNUCLIKE_ASM 2 >#endif ># 81 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __GNUCLIKE___TYPEOF 1 >#define __GNUCLIKE___OFFSETOF 1 >#define __GNUCLIKE___SECTION 1 > >#ifndef __INTEL_COMPILER >#define __GNUCLIKE_CTOR_SECTION_HANDLING 1 >#endif ># 88 "/usr/src/ifnet/sys/sys/cdefs.h" > >#define __GNUCLIKE_BUILTIN_CONSTANT_P 1 >#if defined(__INTEL_COMPILER) && defined(__cplusplus) && \ > __INTEL_COMPILER < 800 >#undef __GNUCLIKE_BUILTIN_CONSTANT_P >#endif ># 94 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if (__GNUC_MINOR__ > 95 || __GNUC__ >= 3) && !defined(__INTEL_COMPILER) >#define __GNUCLIKE_BUILTIN_VARARGS 1 >#define __GNUCLIKE_BUILTIN_STDARG 1 >#define __GNUCLIKE_BUILTIN_VAALIST 1 >#endif ># 100 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__GNUC__) >#define __GNUC_VA_LIST_COMPATIBILITY 1 >#endif ># 104 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Compiler memory barriers, specific to gcc and clang. > */ >#if defined(__GNUC__) >#define __compiler_membar() __asm __volatile(" " : : : "memory") >#endif ># 111 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __INTEL_COMPILER >#define __GNUCLIKE_BUILTIN_NEXT_ARG 1 >#define __GNUCLIKE_MATH_BUILTIN_RELOPS >#endif ># 116 "/usr/src/ifnet/sys/sys/cdefs.h" > >#define __GNUCLIKE_BUILTIN_MEMCPY 1 > >/* XXX: if __GNUC__ >= 2: not tested everywhere originally, where replaced */ >#define __CC_SUPPORTS_INLINE 1 >#define __CC_SUPPORTS___INLINE 1 >#define __CC_SUPPORTS___INLINE__ 1 > >#define __CC_SUPPORTS___FUNC__ 1 >#define __CC_SUPPORTS_WARNING 1 > >#define __CC_SUPPORTS_VARADIC_XXX 1 /* see varargs.h */ > >#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1 > >#endif /* __GNUC__ || __INTEL_COMPILER */ ># 132 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Macro to test if we're using a specific version of gcc or later. > */ >#if defined(__GNUC__) && !defined(__INTEL_COMPILER) >#define __GNUC_PREREQ__(ma, mi) \ > (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) >#else ># 140 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __GNUC_PREREQ__(ma, mi) 0 >#endif ># 142 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * The __CONCAT macro is used to concatenate parts of symbol names, e.g. > * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. > * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI > * mode -- there must be no spaces between its arguments, and for nested > * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also > * concatenate double-quoted strings produced by the __STRING macro, but > * this only works with ANSI C. > * > * __XSTRING is like __STRING, but it expands any macros in its argument > * first. It is only available with ANSI C. > */ >#if defined(__STDC__) || defined(__cplusplus) >#define __P(protos) protos /* full-blown ANSI C */ >#define __CONCAT1(x,y) x ## y >#define __CONCAT(x,y) __CONCAT1(x,y) >#define __STRING(x) #x /* stringify without expanding x */ >#define __XSTRING(x) __STRING(x) /* expand x, then stringify */ > >#define __const const /* define reserved names to standard */ >#define __signed signed >#define __volatile volatile >#if defined(__cplusplus) >#define __inline inline /* convert to C++ keyword */ >#else ># 168 "/usr/src/ifnet/sys/sys/cdefs.h" >#if !(defined(__CC_SUPPORTS___INLINE)) >#define __inline /* delete GCC keyword */ >#endif /* ! __CC_SUPPORTS___INLINE */ ># 171 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif /* !__cplusplus */ ># 172 "/usr/src/ifnet/sys/sys/cdefs.h" > >#else /* !(__STDC__ || __cplusplus) */ ># 174 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __P(protos) () /* traditional C preprocessor */ >#define __CONCAT(x,y) x/**/y >#define __STRING(x) "x" > >#if !defined(__CC_SUPPORTS___INLINE) >#define __const /* delete pseudo-ANSI C keywords */ >#define __inline >#define __signed >#define __volatile >/* > * In non-ANSI C environments, new programs will want ANSI-only C keywords > * deleted from the program and old programs will want them left alone. > * When using a compiler other than gcc, programs using the ANSI C keywords > * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS. > * When using "gcc -traditional", we assume that this is the intent; if > * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone. > */ >#ifndef NO_ANSI_KEYWORDS >#define const /* delete ANSI C keywords */ >#define inline >#define signed >#define volatile >#endif /* !NO_ANSI_KEYWORDS */ ># 197 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif /* !__CC_SUPPORTS___INLINE */ ># 198 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif /* !(__STDC__ || __cplusplus) */ ># 199 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Compiler-dependent macros to help declare dead (non-returning) and > * pure (no side effects) functions, and unused variables. They are > * null except for versions of gcc that are known to support the features > * properly (old versions of gcc-2 supported the dead and pure features > * in a different (wrong) way). If we do not provide an implementation > * for a given compiler, let the compile fail if it is told to use > * a feature that we cannot live without. > */ >#ifdef lint >#define __dead2 >#define __pure2 >#define __unused >#define __packed >#define __aligned(x) >#define __section(x) >#define __weak >#else ># 218 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __weak __attribute__((__weak__)) >#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER) >#define __dead2 >#define __pure2 >#define __unused >#endif ># 224 "/usr/src/ifnet/sys/sys/cdefs.h" >#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused >/* XXX Find out what to do for __packed, __aligned and __section */ >#endif ># 230 "/usr/src/ifnet/sys/sys/cdefs.h" >#if __GNUC_PREREQ__(2, 7) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused __attribute__((__unused__)) >#define __used __attribute__((__used__)) >#define __packed __attribute__((__packed__)) >#define __aligned(x) __attribute__((__aligned__(x))) >#define __section(x) __attribute__((__section__(x))) >#endif ># 239 "/usr/src/ifnet/sys/sys/cdefs.h" >#if defined(__INTEL_COMPILER) >#define __dead2 __attribute__((__noreturn__)) >#define __pure2 __attribute__((__const__)) >#define __unused __attribute__((__unused__)) >#define __used __attribute__((__used__)) >#define __packed __attribute__((__packed__)) >#define __aligned(x) __attribute__((__aligned__(x))) >#define __section(x) __attribute__((__section__(x))) >#endif ># 248 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif /* lint */ ># 249 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if !__GNUC_PREREQ__(2, 95) >#define __alignof(x) __offsetof(struct { char __a; x __b; }, __b) >#endif ># 253 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Keywords added in C11. > */ > >#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L || defined(lint) > >#if !__has_extension(c_alignas) >#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ > __has_extension(cxx_alignas) >#define _Alignas(x) alignas(x) >#else ># 265 "/usr/src/ifnet/sys/sys/cdefs.h" >/* XXX: Only emulates _Alignas(constant-expression); not _Alignas(type-name). */ >#define _Alignas(x) __aligned(x) >#endif ># 268 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 269 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _Alignof(x) alignof(x) >#else ># 273 "/usr/src/ifnet/sys/sys/cdefs.h" >#define _Alignof(x) __alignof(x) >#endif ># 275 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if !__has_extension(c_atomic) && !__has_extension(cxx_atomic) >/* > * No native support for _Atomic(). Place object in structure to prevent > * most forms of direct non-atomic access. > */ >#define _Atomic(T) struct { T volatile __val; } >#endif ># 283 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _Noreturn [[noreturn]] >#else ># 287 "/usr/src/ifnet/sys/sys/cdefs.h" >#define _Noreturn __dead2 >#endif ># 289 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if !__has_extension(c_static_assert) >#if (defined(__cplusplus) && __cplusplus >= 201103L) || \ > __has_extension(cxx_static_assert) >#define _Static_assert(x, y) static_assert(x, y) >#elif __GNUC_PREREQ__(4,6) ># 295 "/usr/src/ifnet/sys/sys/cdefs.h" >/* Nothing, gcc 4.6 and higher has _Static_assert built-in */ >#elif defined(__COUNTER__) ># 297 "/usr/src/ifnet/sys/sys/cdefs.h" >#define _Static_assert(x, y) __Static_assert(x, __COUNTER__) >#define __Static_assert(x, y) ___Static_assert(x, y) >#define ___Static_assert(x, y) typedef char __assert_ ## y[(x) ? 1 : -1] \ > __unused >#else ># 302 "/usr/src/ifnet/sys/sys/cdefs.h" >#define _Static_assert(x, y) struct __hack >#endif ># 304 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 305 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if !__has_extension(c_thread_local) >/* > * XXX: Some compilers (Clang 3.3, GCC 4.7) falsely announce C++11 mode > * without actually supporting the thread_local keyword. Don't check for > * the presence of C++11 when defining _Thread_local. > */ >#if /* (defined(__cplusplus) && __cplusplus >= 201103L) || */ \ > __has_extension(cxx_thread_local) >#define _Thread_local thread_local >#else ># 316 "/usr/src/ifnet/sys/sys/cdefs.h" >#define _Thread_local __thread >#endif ># 318 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 319 "/usr/src/ifnet/sys/sys/cdefs.h" > >#endif /* __STDC_VERSION__ || __STDC_VERSION__ < 201112L */ ># 321 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Emulation of C11 _Generic(). Unlike the previously defined C11 > * keywords, it is not possible to implement this using exactly the same > * syntax. Therefore implement something similar under the name > * __generic(). Unlike _Generic(), this macro can only distinguish > * between a single type, so it requires nested invocations to > * distinguish multiple cases. > */ > >#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ > __has_extension(c_generic_selections) >#define __generic(expr, t, yes, no) \ > _Generic(expr, t: yes, default: no) >#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus) ># 336 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __generic(expr, t, yes, no) \ > __builtin_choose_expr( \ > __builtin_types_compatible_p(__typeof(expr), t), yes, no) >#endif ># 340 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(2, 96) >#define __malloc_like __attribute__((__malloc__)) >#define __pure __attribute__((__pure__)) >#else ># 345 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __malloc_like >#define __pure >#endif ># 348 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800) >#define __always_inline __attribute__((__always_inline__)) >#else ># 352 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __always_inline >#endif ># 354 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 1) >#define __noinline __attribute__ ((__noinline__)) >#else ># 358 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __noinline >#endif ># 360 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 3) >#define __nonnull(x) __attribute__((__nonnull__(x))) >#define __nonnull_all __attribute__((__nonnull__)) >#else ># 365 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __nonnull(x) >#define __nonnull_all >#endif ># 368 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(3, 4) >#define __fastcall __attribute__((__fastcall__)) >#define __result_use_check __attribute__((__warn_unused_result__)) >#else ># 373 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __fastcall >#define __result_use_check >#endif ># 376 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(4, 1) >#define __gnu_inline __attribute__((__gnu_inline__)) >#define __returns_twice __attribute__((__returns_twice__)) >#else ># 381 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __gnu_inline >#define __returns_twice >#endif ># 384 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __has_attribute(alloc_size) || __GNUC_PREREQ__(4, 3) >#define __alloc_size(x) __attribute__((__alloc_size__(x))) >#else ># 388 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __alloc_size(x) >#endif ># 390 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* XXX: should use `#if __STDC_VERSION__ < 199901'. */ >#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) >#define __func__ NULL >#endif ># 395 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901 >#define __LONG_LONG_SUPPORTED >#endif ># 399 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* C++11 exposes a load of C99 stuff */ >#if defined(__cplusplus) && __cplusplus >= 201103L >#define __LONG_LONG_SUPPORTED >#ifndef __STDC_LIMIT_MACROS >#define __STDC_LIMIT_MACROS >#endif ># 406 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __STDC_CONSTANT_MACROS >#define __STDC_CONSTANT_MACROS >#endif ># 409 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 410 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * GCC 2.95 provides `__restrict' as an extension to C90 to support the > * C99-specific `restrict' type qualifier. We happen to use `__restrict' as > * a way to define the `restrict' type qualifier without disturbing older > * software that is unaware of C99 keywords. > */ >#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) >#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 || defined(lint) >#define __restrict >#else ># 421 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __restrict restrict >#endif ># 423 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 424 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * GNU C version 2.96 adds explicit branch prediction so that > * the CPU back-end can hint the processor and also so that > * code blocks can be reordered such that the predicted path > * sees a more linear flow, thus improving cache behavior, etc. > * > * The following two macros provide us with a way to utilize this > * compiler feature. Use __predict_true() if you expect the expression > * to evaluate to true, and __predict_false() if you expect the > * expression to evaluate to false. > * > * A few notes about usage: > * > * * Generally, __predict_false() error condition checks (unless > * you have some _strong_ reason to do otherwise, in which case > * document it), and/or __predict_true() `no-error' condition > * checks, assuming you want to optimize for the no-error case. > * > * * Other than that, if you don't know the likelihood of a test > * succeeding from empirical or other `hard' evidence, don't > * make predictions. > * > * * These are meant to be used in places that are run `a lot'. > * It is wasteful to make predictions in code that is run > * seldomly (e.g. at subsystem initialization time) as the > * basic block reordering that this affects can often generate > * larger code. > */ >#if __GNUC_PREREQ__(2, 96) >#define __predict_true(exp) __builtin_expect((exp), 1) >#define __predict_false(exp) __builtin_expect((exp), 0) >#else ># 457 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __predict_true(exp) (exp) >#define __predict_false(exp) (exp) >#endif ># 460 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if __GNUC_PREREQ__(4, 2) >#define __hidden __attribute__((__visibility__("hidden"))) >#define __exported __attribute__((__visibility__("default"))) >#else ># 465 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __hidden >#define __exported >#endif ># 468 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> > * require it. > */ >#if __GNUC_PREREQ__(4, 1) >#define __offsetof(type, field) __builtin_offsetof(type, field) >#else ># 476 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifndef __cplusplus >#define __offsetof(type, field) \ > ((__size_t)(__uintptr_t)((const volatile void *)&((type *)0)->field)) >#else ># 480 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __offsetof(type, field) \ > (__offsetof__ (reinterpret_cast <__size_t> \ > (&reinterpret_cast <const volatile char &> \ > (static_cast<type *> (0)->field)))) >#endif ># 485 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 486 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __rangeof(type, start, end) \ > (__offsetof(type, end) - __offsetof(type, start)) > >/* > * Given the pointer x to the member m of the struct s, return > * a pointer to the containing structure. When using GCC, we first > * assign pointer x to a local variable, to check that its type is > * compatible with member m. > */ >#if __GNUC_PREREQ__(3, 1) >#define __containerof(x, s, m) ({ \ > const volatile __typeof(((s *)0)->m) *__x = (x); \ > __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));\ >}) >#else ># 501 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __containerof(x, s, m) \ > __DEQUALIFY(s *, (const volatile char *)(x) - __offsetof(s, m)) >#endif ># 504 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Compiler-dependent macros to declare that functions take printf-like > * or scanf-like arguments. They are null except for versions of gcc > * that are known to support the features properly (old versions of gcc-2 > * didn't permit keeping the keywords out of the application namespace). > */ >#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER) >#define __printflike(fmtarg, firstvararg) >#define __scanflike(fmtarg, firstvararg) >#define __format_arg(fmtarg) >#define __strfmonlike(fmtarg, firstvararg) >#define __strftimelike(fmtarg, firstvararg) >#else ># 518 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __printflike(fmtarg, firstvararg) \ > __attribute__((__format__ (__printf__, fmtarg, firstvararg))) >#define __scanflike(fmtarg, firstvararg) \ > __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) >#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) >#define __strfmonlike(fmtarg, firstvararg) \ > __attribute__((__format__ (__strfmon__, fmtarg, firstvararg))) >#define __strftimelike(fmtarg, firstvararg) \ > __attribute__((__format__ (__strftime__, fmtarg, firstvararg))) >#endif ># 528 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */ >#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \ > defined(__GNUC__) && !defined(__INTEL_COMPILER) >#define __printf0like(fmtarg, firstvararg) \ > __attribute__((__format__ (__printf0__, fmtarg, firstvararg))) >#else ># 535 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __printf0like(fmtarg, firstvararg) >#endif ># 537 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) >#ifndef __INTEL_COMPILER >#define __strong_reference(sym,aliassym) \ > extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) >#endif ># 543 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifdef __STDC__ >#define __weak_reference(sym,alias) \ > __asm__(".weak " #alias); \ > __asm__(".equ " #alias ", " #sym) >#define __warn_references(sym,msg) \ > __asm__(".section .gnu.warning." #sym); \ > __asm__(".asciz \"" msg "\""); \ > __asm__(".previous") >#define __sym_compat(sym,impl,verid) \ > __asm__(".symver " #impl ", " #sym "@" #verid) >#define __sym_default(sym,impl,verid) \ > __asm__(".symver " #impl ", " #sym "@@" #verid) >#else ># 556 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __weak_reference(sym,alias) \ > __asm__(".weak alias"); \ > __asm__(".equ alias, sym") >#define __warn_references(sym,msg) \ > __asm__(".section .gnu.warning.sym"); \ > __asm__(".asciz \"msg\""); \ > __asm__(".previous") >#define __sym_compat(sym,impl,verid) \ > __asm__(".symver impl, sym@verid") >#define __sym_default(impl,sym,verid) \ > __asm__(".symver impl, sym@@verid") >#endif /* __STDC__ */ ># 568 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif /* __GNUC__ || __INTEL_COMPILER */ ># 569 "/usr/src/ifnet/sys/sys/cdefs.h" > >#define __GLOBL1(sym) __asm__(".globl " #sym) >#define __GLOBL(sym) __GLOBL1(sym) > >#if defined(__GNUC__) || defined(__INTEL_COMPILER) >#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"") >#else ># 576 "/usr/src/ifnet/sys/sys/cdefs.h" >/* > * The following definition might not work well if used in header files, > * but it should be better than nothing. If you want a "do nothing" > * version, then it should generate some harmless declaration, such as: > * #define __IDSTRING(name,string) struct __hack > */ >#define __IDSTRING(name,string) static const char name[] __unused = string >#endif ># 584 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Embed the rcs id of a source file in the resulting library. Note that in > * more recent ELF binutils, we use .ident allowing the ID to be stripped. > * Usage: > * __FBSDID("$FreeBSD: projects/ifnet/sys/sys/cdefs.h 281640 2015-04-17 05:55:07Z glebius $"); > */ >#ifndef __FBSDID >#if !defined(lint) && !defined(STRIP_FBSDID) >#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) >#else ># 595 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __FBSDID(s) struct __hack >#endif ># 597 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 598 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __RCSID >#ifndef NO__RCSID >#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) >#else ># 603 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __RCSID(s) struct __hack >#endif ># 605 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 606 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __RCSID_SOURCE >#ifndef NO__RCSID_SOURCE >#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s) >#else ># 611 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __RCSID_SOURCE(s) struct __hack >#endif ># 613 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 614 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __SCCSID >#ifndef NO__SCCSID >#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s) >#else ># 619 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __SCCSID(s) struct __hack >#endif ># 621 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 622 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __COPYRIGHT >#ifndef NO__COPYRIGHT >#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s) >#else ># 627 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __COPYRIGHT(s) struct __hack >#endif ># 629 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 630 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __DECONST >#define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) >#endif ># 634 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __DEVOLATILE >#define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) >#endif ># 638 "/usr/src/ifnet/sys/sys/cdefs.h" > >#ifndef __DEQUALIFY >#define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) >#endif ># 642 "/usr/src/ifnet/sys/sys/cdefs.h" > >/*- > * The following definitions are an extension of the behavior originally > * implemented in <sys/_posix.h>, but with a different level of granularity. > * POSIX.1 requires that the macros we test be defined before any standard > * header file is included. > * > * Here's a quick run-down of the versions: > * defined(_POSIX_SOURCE) 1003.1-1988 > * _POSIX_C_SOURCE == 1 1003.1-1990 > * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option > * _POSIX_C_SOURCE == 199309 1003.1b-1993 > * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995, > * and the omnibus ISO/IEC 9945-1: 1996 > * _POSIX_C_SOURCE == 200112 1003.1-2001 > * _POSIX_C_SOURCE == 200809 1003.1-2008 > * > * In addition, the X/Open Portability Guide, which is now the Single UNIX > * Specification, defines a feature-test macro which indicates the version of > * that specification, and which subsumes _POSIX_C_SOURCE. > * > * Our macros begin with two underscores to avoid namespace screwage. > */ > >/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */ >#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1 >#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */ >#define _POSIX_C_SOURCE 199009 >#endif ># 671 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */ >#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 199209 >#endif ># 677 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* Deal with various X/Open Portability Guides and Single UNIX Spec. */ >#ifdef _XOPEN_SOURCE >#if _XOPEN_SOURCE - 0 >= 700 >#define __XSI_VISIBLE 700 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 200809 >#elif _XOPEN_SOURCE - 0 >= 600 ># 685 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __XSI_VISIBLE 600 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 200112 >#elif _XOPEN_SOURCE - 0 >= 500 ># 689 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __XSI_VISIBLE 500 >#undef _POSIX_C_SOURCE >#define _POSIX_C_SOURCE 199506 >#endif ># 693 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 694 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Deal with all versions of POSIX. The ordering relative to the tests above is > * important. > */ >#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) >#define _POSIX_C_SOURCE 198808 >#endif ># 702 "/usr/src/ifnet/sys/sys/cdefs.h" >#ifdef _POSIX_C_SOURCE >#if _POSIX_C_SOURCE >= 200809 >#define __POSIX_VISIBLE 200809 >#define __ISO_C_VISIBLE 1999 >#elif _POSIX_C_SOURCE >= 200112 ># 707 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 200112 >#define __ISO_C_VISIBLE 1999 >#elif _POSIX_C_SOURCE >= 199506 ># 710 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199506 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199309 ># 713 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199309 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199209 ># 716 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199209 >#define __ISO_C_VISIBLE 1990 >#elif _POSIX_C_SOURCE >= 199009 ># 719 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 199009 >#define __ISO_C_VISIBLE 1990 >#else ># 722 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 198808 >#define __ISO_C_VISIBLE 0 >#endif /* _POSIX_C_SOURCE */ ># 725 "/usr/src/ifnet/sys/sys/cdefs.h" >#else ># 726 "/usr/src/ifnet/sys/sys/cdefs.h" >/*- > * Deal with _ANSI_SOURCE: > * If it is defined, and no other compilation environment is explicitly > * requested, then define our internal feature-test macros to zero. This > * makes no difference to the preprocessor (undefined symbols in preprocessing > * expressions are defined to have value zero), but makes it more convenient for > * a test program to print out the values. > * > * If a program mistakenly defines _ANSI_SOURCE and some other macro such as > * _POSIX_C_SOURCE, we will assume that it wants the broader compilation > * environment (and in fact we will never get here). > */ >#if defined(_ANSI_SOURCE) /* Hide almost everything. */ >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 1990 >#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */ ># 744 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 1999 >#elif defined(_C11_SOURCE) /* Localism to specify strict C11 env. */ ># 749 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 0 >#define __XSI_VISIBLE 0 >#define __BSD_VISIBLE 0 >#define __ISO_C_VISIBLE 2011 >#else /* Default environment: show everything. */ ># 754 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __POSIX_VISIBLE 200809 >#define __XSI_VISIBLE 700 >#define __BSD_VISIBLE 1 >#define __ISO_C_VISIBLE 2011 >#endif ># 759 "/usr/src/ifnet/sys/sys/cdefs.h" >#endif ># 760 "/usr/src/ifnet/sys/sys/cdefs.h" > >#if defined(__mips) || defined(__powerpc64__) >#define __NO_TLS 1 >#endif ># 764 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* > * Lock annotations. > * > * Clang provides support for doing basic thread-safety tests at > * compile-time, by marking which locks will/should be held when > * entering/leaving a functions. > * > * Furthermore, it is also possible to annotate variables and structure > * members to enforce that they are only accessed when certain locks are > * held. > */ > >#if __has_extension(c_thread_safety_attributes) >#define __lock_annotate(x) __attribute__((x)) >#else ># 780 "/usr/src/ifnet/sys/sys/cdefs.h" >#define __lock_annotate(x) >#endif ># 782 "/usr/src/ifnet/sys/sys/cdefs.h" > >/* Structure implements a lock. */ >#define __lockable __lock_annotate(lockable) > >/* Function acquires an exclusive or shared lock. */ >#define __locks_exclusive(...) \ > __lock_annotate(exclusive_lock_function(__VA_ARGS__)) >#define __locks_shared(...) \ > __lock_annotate(shared_lock_function(__VA_ARGS__)) > >/* Function attempts to acquire an exclusive or shared lock. */ >#define __trylocks_exclusive(...) \ > __lock_annotate(exclusive_trylock_function(__VA_ARGS__)) >#define __trylocks_shared(...) \ > __lock_annotate(shared_trylock_function(__VA_ARGS__)) > >/* Function releases a lock. */ >#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__)) > >/* Function asserts that an exclusive or shared lock is held. */ >#define __asserts_exclusive(...) \ > __lock_annotate(assert_exclusive_lock(__VA_ARGS__)) >#define __asserts_shared(...) \ > __lock_annotate(assert_shared_lock(__VA_ARGS__)) > >/* Function requires that an exclusive or shared lock is or is not held. */ >#define __requires_exclusive(...) \ > __lock_annotate(exclusive_locks_required(__VA_ARGS__)) >#define __requires_shared(...) \ > __lock_annotate(shared_locks_required(__VA_ARGS__)) >#define __requires_unlocked(...) \ > __lock_annotate(locks_excluded(__VA_ARGS__)) > >/* Function should not be analyzed. */ >#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis) > >/* Guard variables and structure members by lock. */ >#define __guarded_by(x) __lock_annotate(guarded_by(x)) >#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x)) > >#endif /* !_SYS_CDEFS_H_ */ ># 823 "/usr/src/ifnet/sys/sys/cdefs.h" ># 42 "/usr/src/ifnet/sys/sys/types.h" 2 > >/* Machine type dependent parameters. */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/endian.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/sys/types.h" ># 1 "./machine/endian.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/endian.h 232266 2012-02-28 19:39:54Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/endian.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/endian.h" ># 1 "./x86/endian.h" 1 >/*- > * Copyright (c) 1987, 1991 Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)endian.h 7.8 (Berkeley) 4/3/91 > * $FreeBSD: projects/ifnet/sys/x86/include/endian.h 233684 2012-03-29 23:31:48Z dim $ > */ > >#ifndef _MACHINE_ENDIAN_H_ >#define _MACHINE_ENDIAN_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "./x86/endian.h" ># 37 "./x86/endian.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "./x86/endian.h" ># 1 "/usr/src/ifnet/sys/sys/_types.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_types.h 276845 2015-01-08 18:09:36Z glebius $ > */ > >#ifndef _SYS__TYPES_H_ >#define _SYS__TYPES_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/_types.h" ># 33 "/usr/src/ifnet/sys/sys/_types.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_types.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/ifnet/sys/sys/_types.h" ># 1 "./machine/_types.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/_types.h 232261 2012-02-28 18:15:28Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_types.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_types.h" ># 1 "./x86/_types.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * From: @(#)ansi.h 8.2 (Berkeley) 1/4/94 > * From: @(#)types.h 8.3 (Berkeley) 1/5/94 > * $FreeBSD: projects/ifnet/sys/x86/include/_types.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _MACHINE__TYPES_H_ >#define _MACHINE__TYPES_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 45 "./x86/_types.h" > >#define __NO_STRICT_ALIGNMENT > >/* > * Basic types upon which most other types are built. > */ >typedef signed char __int8_t; >typedef unsigned char __uint8_t; >typedef short __int16_t; >typedef unsigned short __uint16_t; >typedef int __int32_t; >typedef unsigned int __uint32_t; >#ifdef __LP64__ >typedef long __int64_t; >typedef unsigned long __uint64_t; >#else ># 61 "./x86/_types.h" >#ifndef lint >__extension__ >#endif ># 64 "./x86/_types.h" >/* LONGLONG */ >typedef long long __int64_t; >#ifndef lint >__extension__ >#endif ># 69 "./x86/_types.h" >/* LONGLONG */ >typedef unsigned long long __uint64_t; >#endif ># 72 "./x86/_types.h" > >/* > * Standard type definitions. > */ >#ifdef __LP64__ >typedef __int32_t __clock_t; /* clock()... */ >typedef __int64_t __critical_t; >typedef double __double_t; >typedef float __float_t; >typedef __int64_t __intfptr_t; >typedef __int64_t __intptr_t; >#else ># 84 "./x86/_types.h" >typedef unsigned long __clock_t; >typedef __int32_t __critical_t; >typedef long double __double_t; >typedef long double __float_t; >typedef __int32_t __intfptr_t; >typedef __int32_t __intptr_t; >#endif ># 91 "./x86/_types.h" >typedef __int64_t __intmax_t; >typedef __int32_t __int_fast8_t; >typedef __int32_t __int_fast16_t; >typedef __int32_t __int_fast32_t; >typedef __int64_t __int_fast64_t; >typedef __int8_t __int_least8_t; >typedef __int16_t __int_least16_t; >typedef __int32_t __int_least32_t; >typedef __int64_t __int_least64_t; >#ifdef __LP64__ >typedef __int64_t __ptrdiff_t; /* ptr1 - ptr2 */ >typedef __int64_t __register_t; >typedef __int64_t __segsz_t; /* segment size (in pages) */ >typedef __uint64_t __size_t; /* sizeof() */ >typedef __int64_t __ssize_t; /* byte count or error */ >typedef __int64_t __time_t; /* time()... */ >typedef __uint64_t __uintfptr_t; >typedef __uint64_t __uintptr_t; >#else ># 110 "./x86/_types.h" >typedef __int32_t __ptrdiff_t; >typedef __int32_t __register_t; >typedef __int32_t __segsz_t; >typedef __uint32_t __size_t; >typedef __int32_t __ssize_t; >typedef __int32_t __time_t; >typedef __uint32_t __uintfptr_t; >typedef __uint32_t __uintptr_t; >#endif ># 119 "./x86/_types.h" >typedef __uint64_t __uintmax_t; >typedef __uint32_t __uint_fast8_t; >typedef __uint32_t __uint_fast16_t; >typedef __uint32_t __uint_fast32_t; >typedef __uint64_t __uint_fast64_t; >typedef __uint8_t __uint_least8_t; >typedef __uint16_t __uint_least16_t; >typedef __uint32_t __uint_least32_t; >typedef __uint64_t __uint_least64_t; >#ifdef __LP64__ >typedef __uint64_t __u_register_t; >typedef __uint64_t __vm_offset_t; >typedef __uint64_t __vm_paddr_t; >typedef __uint64_t __vm_size_t; >#else ># 134 "./x86/_types.h" >typedef __uint32_t __u_register_t; >typedef __uint32_t __vm_offset_t; >#ifdef PAE >typedef __uint64_t __vm_paddr_t; >#else ># 139 "./x86/_types.h" >typedef __uint32_t __vm_paddr_t; >#endif ># 141 "./x86/_types.h" >typedef __uint32_t __vm_size_t; >#endif ># 143 "./x86/_types.h" >typedef __int64_t __vm_ooffset_t; >typedef __uint64_t __vm_pindex_t; >typedef int ___wchar_t; > >#define __WCHAR_MIN __INT_MIN /* min value for a wchar_t */ >#define __WCHAR_MAX __INT_MAX /* max value for a wchar_t */ > >/* > * Unusual type definitions. > */ >#ifdef __GNUCLIKE_BUILTIN_VARARGS >typedef __builtin_va_list __va_list; /* internally known to gcc */ >#elif defined(lint) ># 156 "./x86/_types.h" >typedef char * __va_list; /* pretend */ >#endif ># 158 "./x86/_types.h" >#if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \ > && !defined(__NO_GNUC_VA_LIST) >#define __GNUC_VA_LIST >typedef __va_list __gnuc_va_list; /* compatibility w/GNU headers*/ >#endif ># 163 "./x86/_types.h" > >#endif /* !_MACHINE__TYPES_H_ */ ># 165 "./x86/_types.h" ># 7 "./machine/_types.h" 2 ># 34 "/usr/src/ifnet/sys/sys/_types.h" 2 > >/* > * Standard type definitions. > */ >typedef __int32_t __blksize_t; /* file block size */ >typedef __int64_t __blkcnt_t; /* file block count */ >typedef __int32_t __clockid_t; /* clock_gettime()... */ >typedef __uint32_t __fflags_t; /* file flags */ >typedef __uint64_t __fsblkcnt_t; >typedef __uint64_t __fsfilcnt_t; >typedef __uint32_t __gid_t; >typedef __int64_t __id_t; /* can hold a gid_t, pid_t, or uid_t */ >typedef __uint32_t __ino_t; /* inode number */ >typedef long __key_t; /* IPC key (for Sys V IPC) */ >typedef __int32_t __lwpid_t; /* Thread ID (a.k.a. LWP) */ >typedef __uint16_t __mode_t; /* permissions */ >typedef int __accmode_t; /* access permissions */ >typedef int __nl_item; >typedef __uint16_t __nlink_t; /* link count */ >typedef __int64_t __off_t; /* file offset */ >typedef __int32_t __pid_t; /* process [group] */ >typedef __int64_t __rlim_t; /* resource limit - intentionally */ > /* signed, because of legacy code */ > /* that uses -1 for RLIM_INFINITY */ >typedef __uint8_t __sa_family_t; >typedef __uint32_t __socklen_t; >typedef long __suseconds_t; /* microseconds (signed) */ >typedef struct __timer *__timer_t; /* timer_gettime()... */ >typedef struct __mq *__mqd_t; /* mq_open()... */ >typedef __uint32_t __uid_t; >typedef unsigned int __useconds_t; /* microseconds (unsigned) */ >typedef int __cpuwhich_t; /* which parameter for cpuset. */ >typedef int __cpulevel_t; /* level parameter for cpuset. */ >typedef int __cpusetid_t; /* cpuset identifier. */ > >/* > * Unusual type definitions. > */ >/* > * rune_t is declared to be an ``int'' instead of the more natural > * ``unsigned long'' or ``long''. Two things are happening here. It is not > * unsigned so that EOF (-1) can be naturally assigned to it and used. Also, > * it looks like 10646 will be a 31 bit standard. This means that if your > * ints cannot hold 32 bits, you will be in trouble. The reason an int was > * chosen over a long is that the is*() and to*() routines take ints (says > * ANSI C), but they use __ct_rune_t instead of int. > * > * NOTE: rune_t is not covered by ANSI nor other standards, and should not > * be instantiated outside of lib/libc/locale. Use wchar_t. wint_t and > * rune_t must be the same type. Also, wint_t should be able to hold all > * members of the largest character set plus one extra value (WEOF), and > * must be at least 16 bits. > */ >typedef int __ct_rune_t; /* arg type for ctype funcs */ >typedef __ct_rune_t __rune_t; /* rune_t (see above) */ >typedef __ct_rune_t __wint_t; /* wint_t (see above) */ > >/* Clang already provides these types as built-ins, but only in C++ mode. */ >#if !defined(__clang__) || !defined(__cplusplus) >typedef __uint_least16_t __char16_t; >typedef __uint_least32_t __char32_t; >#endif ># 96 "/usr/src/ifnet/sys/sys/_types.h" >/* In C++11, char16_t and char32_t are built-in types. */ >#if defined(__cplusplus) && __cplusplus >= 201103L >#define _CHAR16_T_DECLARED >#define _CHAR32_T_DECLARED >#endif ># 101 "/usr/src/ifnet/sys/sys/_types.h" > >typedef __uint32_t __dev_t; /* device number */ > >typedef __uint32_t __fixpt_t; /* fixed point number */ > >/* > * mbstate_t is an opaque object to keep conversion state during multibyte > * stream conversions. > */ >typedef union { > char __mbstate8[128]; > __int64_t _mbstateL; /* for alignment */ >} __mbstate_t; > >#endif /* !_SYS__TYPES_H_ */ ># 116 "/usr/src/ifnet/sys/sys/_types.h" ># 38 "./x86/endian.h" 2 > >/* > * Define the order of 32-bit words in 64-bit words. > */ >#define _QUAD_HIGHWORD 1 >#define _QUAD_LOWWORD 0 > >/* > * Definitions for byte order, according to byte significance from low > * address to high. > */ >#define _LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ >#define _BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ >#define _PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ > >#define _BYTE_ORDER _LITTLE_ENDIAN > >/* > * Deprecated variants that don't have enough underscores to be useful in more > * strict namespaces. > */ >#if __BSD_VISIBLE >#define LITTLE_ENDIAN _LITTLE_ENDIAN >#define BIG_ENDIAN _BIG_ENDIAN >#define PDP_ENDIAN _PDP_ENDIAN >#define BYTE_ORDER _BYTE_ORDER >#endif ># 65 "./x86/endian.h" > >#define __bswap16_gen(x) (__uint16_t)((x) << 8 | (x) >> 8) >#define __bswap32_gen(x) \ > (((__uint32_t)__bswap16((x) & 0xffff) << 16) | __bswap16((x) >> 16)) >#define __bswap64_gen(x) \ > (((__uint64_t)__bswap32((x) & 0xffffffff) << 32) | __bswap32((x) >> 32)) > >#ifdef __GNUCLIKE_BUILTIN_CONSTANT_P >#define __bswap16(x) \ > ((__uint16_t)(__builtin_constant_p(x) ? \ > __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) >#define __bswap32(x) \ > (__builtin_constant_p(x) ? \ > __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) >#define __bswap64(x) \ > (__builtin_constant_p(x) ? \ > __bswap64_gen((__uint64_t)(x)) : __bswap64_var(x)) >#else ># 83 "./x86/endian.h" >/* XXX these are broken for use in static initializers. */ >#define __bswap16(x) __bswap16_var(x) >#define __bswap32(x) __bswap32_var(x) >#define __bswap64(x) __bswap64_var(x) >#endif ># 88 "./x86/endian.h" > >/* These are defined as functions to avoid multiple evaluation of x. */ > >static __inline __uint16_t >__bswap16_var(__uint16_t _x) >{ > > return (__bswap16_gen(_x)); >} > >static __inline __uint32_t >__bswap32_var(__uint32_t _x) >{ > >#ifdef __GNUCLIKE_ASM > __asm("bswap %0" : "+r" (_x)); > return (_x); >#else ># 106 "./x86/endian.h" > return (__bswap32_gen(_x)); >#endif ># 108 "./x86/endian.h" >} > >static __inline __uint64_t >__bswap64_var(__uint64_t _x) >{ > >#if defined(__amd64__) && defined(__GNUCLIKE_ASM) > __asm("bswap %0" : "+r" (_x)); > return (_x); >#else ># 118 "./x86/endian.h" > /* > * It is important for the optimizations that the following is not > * really generic, but expands to 2 __bswap32_var()'s. > */ > return (__bswap64_gen(_x)); >#endif ># 124 "./x86/endian.h" >} > >#define __htonl(x) __bswap32(x) >#define __htons(x) __bswap16(x) >#define __ntohl(x) __bswap32(x) >#define __ntohs(x) __bswap16(x) > >#endif /* !_MACHINE_ENDIAN_H_ */ ># 132 "./x86/endian.h" ># 7 "./machine/endian.h" 2 ># 45 "/usr/src/ifnet/sys/sys/types.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/ifnet/sys/sys/types.h" ># 46 "/usr/src/ifnet/sys/sys/types.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_pthreadtypes.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/ifnet/sys/sys/types.h" ># 1 "/usr/src/ifnet/sys/sys/_pthreadtypes.h" 1 >/* > * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu > * Copyright (c) 1995-1998 by John Birrell <jb@cimlogic.com.au> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Chris Provenzano. > * 4. The name of Chris Provenzano may not be used to endorse or promote > * products derived from this software without specific prior written > * permission. > * > * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_pthreadtypes.h 189828 2009-03-14 20:10:14Z das $ > */ > >#ifndef _SYS__PTHREADTYPES_H_ >#define _SYS__PTHREADTYPES_H_ > >/* > * Forward structure definitions. > * > * These are mostly opaque to the user. > */ >struct pthread; >struct pthread_attr; >struct pthread_cond; >struct pthread_cond_attr; >struct pthread_mutex; >struct pthread_mutex_attr; >struct pthread_once; >struct pthread_rwlock; >struct pthread_rwlockattr; >struct pthread_barrier; >struct pthread_barrier_attr; >struct pthread_spinlock; > >/* > * Primitive system data type definitions required by P1003.1c. > * > * Note that P1003.1c specifies that there are no defined comparison > * or assignment operators for the types pthread_attr_t, pthread_cond_t, > * pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t. > */ >#ifndef _PTHREAD_T_DECLARED >typedef struct pthread *pthread_t; >#define _PTHREAD_T_DECLARED >#endif ># 68 "/usr/src/ifnet/sys/sys/_pthreadtypes.h" >typedef struct pthread_attr *pthread_attr_t; >typedef struct pthread_mutex *pthread_mutex_t; >typedef struct pthread_mutex_attr *pthread_mutexattr_t; >typedef struct pthread_cond *pthread_cond_t; >typedef struct pthread_cond_attr *pthread_condattr_t; >typedef int pthread_key_t; >typedef struct pthread_once pthread_once_t; >typedef struct pthread_rwlock *pthread_rwlock_t; >typedef struct pthread_rwlockattr *pthread_rwlockattr_t; >typedef struct pthread_barrier *pthread_barrier_t; >typedef struct pthread_barrierattr *pthread_barrierattr_t; >typedef struct pthread_spinlock *pthread_spinlock_t; > >/* > * Additional type definitions: > * > * Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for > * use in header symbols. > */ >typedef void *pthread_addr_t; >typedef void *(*pthread_startroutine_t)(void *); > >/* > * Once definitions. > */ >struct pthread_once { > int state; > pthread_mutex_t mutex; >}; > >#endif /* ! _SYS__PTHREADTYPES_H_ */ ># 99 "/usr/src/ifnet/sys/sys/_pthreadtypes.h" ># 48 "/usr/src/ifnet/sys/sys/types.h" 2 > >#if __BSD_VISIBLE >typedef unsigned char u_char; >typedef unsigned short u_short; >typedef unsigned int u_int; >typedef unsigned long u_long; >#ifndef _KERNEL >typedef unsigned short ushort; /* Sys V compatibility */ >typedef unsigned int uint; /* Sys V compatibility */ >#endif ># 58 "/usr/src/ifnet/sys/sys/types.h" >#endif ># 59 "/usr/src/ifnet/sys/sys/types.h" > >/* > * XXX POSIX sized integrals that should appear only in <sys/stdint.h>. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 63 "/usr/src/ifnet/sys/sys/types.h" ># 1 "/usr/src/ifnet/sys/sys/_stdint.h" 1 >/*- > * Copyright (c) 2011 David E. O'Brien <obrien@FreeBSD.org> > * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_stdint.h 222813 2011-06-07 08:46:13Z attilio $ > */ > >#ifndef _SYS__STDINT_H_ >#define _SYS__STDINT_H_ > >#ifndef _INT8_T_DECLARED >typedef __int8_t int8_t; >#define _INT8_T_DECLARED >#endif ># 37 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _INT16_T_DECLARED >typedef __int16_t int16_t; >#define _INT16_T_DECLARED >#endif ># 42 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _INT32_T_DECLARED >typedef __int32_t int32_t; >#define _INT32_T_DECLARED >#endif ># 47 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _INT64_T_DECLARED >typedef __int64_t int64_t; >#define _INT64_T_DECLARED >#endif ># 52 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _UINT8_T_DECLARED >typedef __uint8_t uint8_t; >#define _UINT8_T_DECLARED >#endif ># 57 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _UINT16_T_DECLARED >typedef __uint16_t uint16_t; >#define _UINT16_T_DECLARED >#endif ># 62 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _UINT32_T_DECLARED >typedef __uint32_t uint32_t; >#define _UINT32_T_DECLARED >#endif ># 67 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _UINT64_T_DECLARED >typedef __uint64_t uint64_t; >#define _UINT64_T_DECLARED >#endif ># 72 "/usr/src/ifnet/sys/sys/_stdint.h" > >#ifndef _INTPTR_T_DECLARED >typedef __intptr_t intptr_t; >#define _INTPTR_T_DECLARED >#endif ># 77 "/usr/src/ifnet/sys/sys/_stdint.h" >#ifndef _UINTPTR_T_DECLARED >typedef __uintptr_t uintptr_t; >#define _UINTPTR_T_DECLARED >#endif ># 81 "/usr/src/ifnet/sys/sys/_stdint.h" > >#endif /* !_SYS__STDINT_H_ */ ># 83 "/usr/src/ifnet/sys/sys/_stdint.h" ># 64 "/usr/src/ifnet/sys/sys/types.h" 2 > >typedef __uint8_t u_int8_t; /* unsigned integrals (deprecated) */ >typedef __uint16_t u_int16_t; >typedef __uint32_t u_int32_t; >typedef __uint64_t u_int64_t; > >typedef __uint64_t u_quad_t; /* quads (deprecated) */ >typedef __int64_t quad_t; >typedef quad_t * qaddr_t; > >typedef char * caddr_t; /* core address */ >typedef const char * c_caddr_t; /* core address, pointer to const */ > >#ifndef _BLKSIZE_T_DECLARED >typedef __blksize_t blksize_t; >#define _BLKSIZE_T_DECLARED >#endif ># 81 "/usr/src/ifnet/sys/sys/types.h" > >typedef __cpuwhich_t cpuwhich_t; >typedef __cpulevel_t cpulevel_t; >typedef __cpusetid_t cpusetid_t; > >#ifndef _BLKCNT_T_DECLARED >typedef __blkcnt_t blkcnt_t; >#define _BLKCNT_T_DECLARED >#endif ># 90 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _CLOCK_T_DECLARED >typedef __clock_t clock_t; >#define _CLOCK_T_DECLARED >#endif ># 95 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _CLOCKID_T_DECLARED >typedef __clockid_t clockid_t; >#define _CLOCKID_T_DECLARED >#endif ># 100 "/usr/src/ifnet/sys/sys/types.h" > >typedef __critical_t critical_t; /* Critical section value */ >typedef __int64_t daddr_t; /* disk address */ > >#ifndef _DEV_T_DECLARED >typedef __dev_t dev_t; /* device number or struct cdev */ >#define _DEV_T_DECLARED >#endif ># 108 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _FFLAGS_T_DECLARED >typedef __fflags_t fflags_t; /* file flags */ >#define _FFLAGS_T_DECLARED >#endif ># 113 "/usr/src/ifnet/sys/sys/types.h" > >typedef __fixpt_t fixpt_t; /* fixed point number */ > >#ifndef _FSBLKCNT_T_DECLARED /* for statvfs() */ >typedef __fsblkcnt_t fsblkcnt_t; >typedef __fsfilcnt_t fsfilcnt_t; >#define _FSBLKCNT_T_DECLARED >#endif ># 121 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _GID_T_DECLARED >typedef __gid_t gid_t; /* group id */ >#define _GID_T_DECLARED >#endif ># 126 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _IN_ADDR_T_DECLARED >typedef __uint32_t in_addr_t; /* base type for internet address */ >#define _IN_ADDR_T_DECLARED >#endif ># 131 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _IN_PORT_T_DECLARED >typedef __uint16_t in_port_t; >#define _IN_PORT_T_DECLARED >#endif ># 136 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _ID_T_DECLARED >typedef __id_t id_t; /* can hold a uid_t or pid_t */ >#define _ID_T_DECLARED >#endif ># 141 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _INO_T_DECLARED >typedef __ino_t ino_t; /* inode number */ >#define _INO_T_DECLARED >#endif ># 146 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _KEY_T_DECLARED >typedef __key_t key_t; /* IPC key (for Sys V IPC) */ >#define _KEY_T_DECLARED >#endif ># 151 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _LWPID_T_DECLARED >typedef __lwpid_t lwpid_t; /* Thread ID (a.k.a. LWP) */ >#define _LWPID_T_DECLARED >#endif ># 156 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _MODE_T_DECLARED >typedef __mode_t mode_t; /* permissions */ >#define _MODE_T_DECLARED >#endif ># 161 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _ACCMODE_T_DECLARED >typedef __accmode_t accmode_t; /* access permissions */ >#define _ACCMODE_T_DECLARED >#endif ># 166 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _NLINK_T_DECLARED >typedef __nlink_t nlink_t; /* link count */ >#define _NLINK_T_DECLARED >#endif ># 171 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _OFF_T_DECLARED >typedef __off_t off_t; /* file offset */ >#define _OFF_T_DECLARED >#endif ># 176 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _PID_T_DECLARED >typedef __pid_t pid_t; /* process id */ >#define _PID_T_DECLARED >#endif ># 181 "/usr/src/ifnet/sys/sys/types.h" > >typedef __register_t register_t; > >#ifndef _RLIM_T_DECLARED >typedef __rlim_t rlim_t; /* resource limit */ >#define _RLIM_T_DECLARED >#endif ># 188 "/usr/src/ifnet/sys/sys/types.h" > >typedef __int64_t sbintime_t; > >typedef __segsz_t segsz_t; /* segment size (in pages) */ > >#ifndef _SIZE_T_DECLARED >typedef __size_t size_t; >#define _SIZE_T_DECLARED >#endif ># 197 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _SSIZE_T_DECLARED >typedef __ssize_t ssize_t; >#define _SSIZE_T_DECLARED >#endif ># 202 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _SUSECONDS_T_DECLARED >typedef __suseconds_t suseconds_t; /* microseconds (signed) */ >#define _SUSECONDS_T_DECLARED >#endif ># 207 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 212 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _TIMER_T_DECLARED >typedef __timer_t timer_t; >#define _TIMER_T_DECLARED >#endif ># 217 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _MQD_T_DECLARED >typedef __mqd_t mqd_t; >#define _MQD_T_DECLARED >#endif ># 222 "/usr/src/ifnet/sys/sys/types.h" > >typedef __u_register_t u_register_t; > >#ifndef _UID_T_DECLARED >typedef __uid_t uid_t; /* user id */ >#define _UID_T_DECLARED >#endif ># 229 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _USECONDS_T_DECLARED >typedef __useconds_t useconds_t; /* microseconds (unsigned) */ >#define _USECONDS_T_DECLARED >#endif ># 234 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _CAP_IOCTL_T_DECLARED >#define _CAP_IOCTL_T_DECLARED >typedef unsigned long cap_ioctl_t; >#endif ># 239 "/usr/src/ifnet/sys/sys/types.h" > >#ifndef _CAP_RIGHTS_T_DECLARED >#define _CAP_RIGHTS_T_DECLARED >struct cap_rights; > >typedef struct cap_rights cap_rights_t; >#endif ># 246 "/usr/src/ifnet/sys/sys/types.h" > >typedef __vm_offset_t vm_offset_t; >typedef __vm_ooffset_t vm_ooffset_t; >typedef __vm_paddr_t vm_paddr_t; >typedef __vm_pindex_t vm_pindex_t; >typedef __vm_size_t vm_size_t; > >#ifdef _KERNEL >typedef int boolean_t; >typedef struct device *device_t; >typedef __intfptr_t intfptr_t; > >/* > * XXX this is fixed width for historical reasons. It should have had type > * __int_fast32_t. Fixed-width types should not be used unless binary > * compatibility is essential. Least-width types should be used even less > * since they provide smaller benefits. > * > * XXX should be MD. > * > * XXX this is bogus in -current, but still used for spl*(). > */ >typedef __uint32_t intrmask_t; /* Interrupt mask (spl, xxx_imask...) */ > >typedef __uintfptr_t uintfptr_t; >typedef __uint64_t uoff_t; >typedef char vm_memattr_t; /* memory attribute codes */ >typedef struct vm_page *vm_page_t; > >#if !defined(__bool_true_false_are_defined) && !defined(__cplusplus) >#define __bool_true_false_are_defined 1 >#define false 0 >#define true 1 >#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER) >typedef int _Bool; >#endif ># 282 "/usr/src/ifnet/sys/sys/types.h" >typedef _Bool bool; >#endif /* !__bool_true_false_are_defined && !__cplusplus */ ># 284 "/usr/src/ifnet/sys/sys/types.h" > >#define offsetof(type, field) __offsetof(type, field) > >#endif /* !_KERNEL */ ># 288 "/usr/src/ifnet/sys/sys/types.h" > >/* > * The following are all things that really shouldn't exist in this header, > * since its purpose is to provide typedefs, not miscellaneous doodads. > */ >#if __BSD_VISIBLE > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/select.h> >#endif /* expanded by -frewrite-includes */ ># 295 "/usr/src/ifnet/sys/sys/types.h" ># 1 "/usr/src/ifnet/sys/sys/select.h" 1 >/*- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/select.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _SYS_SELECT_H_ >#define _SYS_SELECT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/select.h" ># 36 "/usr/src/ifnet/sys/sys/select.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/select.h" ># 37 "/usr/src/ifnet/sys/sys/select.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sigset.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/select.h" ># 1 "/usr/src/ifnet/sys/sys/_sigset.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)signal.h 8.4 (Berkeley) 5/4/95 > * $FreeBSD: projects/ifnet/sys/sys/_sigset.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS__SIGSET_H_ >#define _SYS__SIGSET_H_ > >/* > * sigset_t macros. > */ >#define _SIG_WORDS 4 >#define _SIG_MAXSIG 128 >#define _SIG_IDX(sig) ((sig) - 1) >#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5) >#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31)) >#define _SIG_VALID(sig) ((sig) <= _SIG_MAXSIG && (sig) > 0) > >typedef struct __sigset { > __uint32_t __bits[_SIG_WORDS]; >} __sigset_t; > >#if defined(_KERNEL) && defined(COMPAT_43) >typedef unsigned int osigset_t; >#endif ># 58 "/usr/src/ifnet/sys/sys/_sigset.h" > >#endif /* !_SYS__SIGSET_H_ */ ># 60 "/usr/src/ifnet/sys/sys/_sigset.h" ># 39 "/usr/src/ifnet/sys/sys/select.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/select.h" ># 1 "/usr/src/ifnet/sys/sys/_timeval.h" 1 >/*- > * Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_timeval.h 158471 2006-05-12 05:04:46Z jhb $ > */ > >#ifndef _SYS__TIMEVAL_H_ >#define _SYS__TIMEVAL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/_timeval.h" ># 33 "/usr/src/ifnet/sys/sys/_timeval.h" > >#ifndef _SUSECONDS_T_DECLARED >typedef __suseconds_t suseconds_t; >#define _SUSECONDS_T_DECLARED >#endif ># 38 "/usr/src/ifnet/sys/sys/_timeval.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 43 "/usr/src/ifnet/sys/sys/_timeval.h" > >/* > * Structure returned by gettimeofday(2) system call, and used in other calls. > */ >struct timeval { > time_t tv_sec; /* seconds */ > suseconds_t tv_usec; /* and microseconds */ >}; > >#endif /* !_SYS__TIMEVAL_H_ */ ># 53 "/usr/src/ifnet/sys/sys/_timeval.h" ># 40 "/usr/src/ifnet/sys/sys/select.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/timespec.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/select.h" ># 1 "/usr/src/ifnet/sys/sys/timespec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp > * $FreeBSD: projects/ifnet/sys/sys/timespec.h 205792 2010-03-28 13:13:22Z ed $ > */ > >#ifndef _SYS_TIMESPEC_H_ >#define _SYS_TIMESPEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/timespec.h" ># 38 "/usr/src/ifnet/sys/sys/timespec.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timespec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/timespec.h" ># 1 "/usr/src/ifnet/sys/sys/_timespec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * from: FreeBSD: src/sys/sys/time.h,v 1.43 2000/03/20 14:09:05 phk Exp > * $FreeBSD: projects/ifnet/sys/sys/_timespec.h 205792 2010-03-28 13:13:22Z ed $ > */ > >#ifndef _SYS__TIMESPEC_H_ >#define _SYS__TIMESPEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/_timespec.h" ># 38 "/usr/src/ifnet/sys/sys/_timespec.h" > >#ifndef _TIME_T_DECLARED >typedef __time_t time_t; >#define _TIME_T_DECLARED >#endif ># 43 "/usr/src/ifnet/sys/sys/_timespec.h" > >struct timespec { > time_t tv_sec; /* seconds */ > long tv_nsec; /* and nanoseconds */ >}; > >#endif /* !_SYS__TIMESPEC_H_ */ ># 50 "/usr/src/ifnet/sys/sys/_timespec.h" ># 39 "/usr/src/ifnet/sys/sys/timespec.h" 2 > >#if __BSD_VISIBLE >#define TIMEVAL_TO_TIMESPEC(tv, ts) \ > do { \ > (ts)->tv_sec = (tv)->tv_sec; \ > (ts)->tv_nsec = (tv)->tv_usec * 1000; \ > } while (0) >#define TIMESPEC_TO_TIMEVAL(tv, ts) \ > do { \ > (tv)->tv_sec = (ts)->tv_sec; \ > (tv)->tv_usec = (ts)->tv_nsec / 1000; \ > } while (0) > >#endif /* __BSD_VISIBLE */ ># 53 "/usr/src/ifnet/sys/sys/timespec.h" > >/* > * Structure defined by POSIX.1b to be like a itimerval, but with > * timespecs. Used in the timer_*() system calls. > */ >struct itimerspec { > struct timespec it_interval; > struct timespec it_value; >}; > >#endif /* _SYS_TIMESPEC_H_ */ ># 64 "/usr/src/ifnet/sys/sys/timespec.h" ># 41 "/usr/src/ifnet/sys/sys/select.h" 2 > >typedef unsigned long __fd_mask; >#if __BSD_VISIBLE >typedef __fd_mask fd_mask; >#endif ># 46 "/usr/src/ifnet/sys/sys/select.h" > >#ifndef _SIGSET_T_DECLARED >#define _SIGSET_T_DECLARED >typedef __sigset_t sigset_t; >#endif ># 51 "/usr/src/ifnet/sys/sys/select.h" > >/* > * Select uses bit masks of file descriptors in longs. These macros > * manipulate such bit fields (the filesystem macros use chars). > * FD_SETSIZE may be defined by the user, but the default here should > * be enough for most uses. > */ >#ifndef FD_SETSIZE >#define FD_SETSIZE 1024 >#endif ># 61 "/usr/src/ifnet/sys/sys/select.h" > >#define _NFDBITS (sizeof(__fd_mask) * 8) /* bits per mask */ >#if __BSD_VISIBLE >#define NFDBITS _NFDBITS >#endif ># 66 "/usr/src/ifnet/sys/sys/select.h" > >#ifndef _howmany >#define _howmany(x, y) (((x) + ((y) - 1)) / (y)) >#endif ># 70 "/usr/src/ifnet/sys/sys/select.h" > >typedef struct fd_set { > __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; >} fd_set; >#if __BSD_VISIBLE >#define fds_bits __fds_bits >#endif ># 77 "/usr/src/ifnet/sys/sys/select.h" > >#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) >#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) >#if __BSD_VISIBLE >#define FD_COPY(f, t) (void)(*(t) = *(f)) >#endif ># 83 "/usr/src/ifnet/sys/sys/select.h" >#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) >#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) >#define FD_ZERO(p) do { \ > fd_set *_p; \ > __size_t _n; \ > \ > _p = (p); \ > _n = _howmany(FD_SETSIZE, _NFDBITS); \ > while (_n > 0) \ > _p->__fds_bits[--_n] = 0; \ >} while (0) > >#ifndef _KERNEL > >__BEGIN_DECLS >int pselect(int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, > const struct timespec *__restrict, const sigset_t *__restrict); >#ifndef _SELECT_DECLARED >#define _SELECT_DECLARED >/* XXX missing restrict type-qualifier */ >int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); >#endif ># 105 "/usr/src/ifnet/sys/sys/select.h" >__END_DECLS >#endif /* !_KERNEL */ ># 107 "/usr/src/ifnet/sys/sys/select.h" > >#endif /* _SYS_SELECT_H_ */ ># 109 "/usr/src/ifnet/sys/sys/select.h" ># 296 "/usr/src/ifnet/sys/sys/types.h" 2 > >#ifdef __POPCNT__ >#define __bitcount64(x) __builtin_popcountll((__uint64_t)(x)) >#define __bitcount32(x) __builtin_popcount((__uint32_t)(x)) >#define __bitcount16(x) __builtin_popcount((__uint16_t)(x)) >#define __bitcountl(x) __builtin_popcountl((unsigned long)(x)) >#define __bitcount(x) __builtin_popcount((unsigned int)(x)) >#else ># 304 "/usr/src/ifnet/sys/sys/types.h" >/* > * Population count algorithm using SWAR approach > * - "SIMD Within A Register". > */ >static __inline __uint16_t >__bitcount16(__uint16_t _x) >{ > > _x = (_x & 0x5555) + ((_x & 0xaaaa) >> 1); > _x = (_x & 0x3333) + ((_x & 0xcccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f; > _x = (_x + (_x >> 8)) & 0x00ff; > return (_x); >} > >static __inline __uint32_t >__bitcount32(__uint32_t _x) >{ > > _x = (_x & 0x55555555) + ((_x & 0xaaaaaaaa) >> 1); > _x = (_x & 0x33333333) + ((_x & 0xcccccccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f0f0f; > _x = (_x + (_x >> 8)); > _x = (_x + (_x >> 16)) & 0x000000ff; > return (_x); >} > >#ifdef __LP64__ >static __inline __uint64_t >__bitcount64(__uint64_t _x) >{ > > _x = (_x & 0x5555555555555555) + ((_x & 0xaaaaaaaaaaaaaaaa) >> 1); > _x = (_x & 0x3333333333333333) + ((_x & 0xcccccccccccccccc) >> 2); > _x = (_x + (_x >> 4)) & 0x0f0f0f0f0f0f0f0f; > _x = (_x + (_x >> 8)); > _x = (_x + (_x >> 16)); > _x = (_x + (_x >> 32)) & 0x000000ff; > return (_x); >} > >#define __bitcountl(x) __bitcount64((unsigned long)(x)) >#else ># 347 "/usr/src/ifnet/sys/sys/types.h" >static __inline __uint64_t >__bitcount64(__uint64_t _x) >{ > > return (__bitcount32(_x >> 32) + __bitcount32(_x)); >} > >#define __bitcountl(x) __bitcount32((unsigned long)(x)) >#endif ># 356 "/usr/src/ifnet/sys/sys/types.h" >#define __bitcount(x) __bitcount32((unsigned int)(x)) >#endif ># 358 "/usr/src/ifnet/sys/sys/types.h" > >/* > * minor() gives a cookie instead of an index since we don't want to > * change the meanings of bits 0-15 or waste time and space shifting > * bits 16-31 for devices that don't use them. > */ >#define major(x) ((int)(((u_int)(x) >> 8)&0xff)) /* major number */ >#define minor(x) ((int)((x)&0xffff00ff)) /* minor number */ >#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */ > >/* > * These declarations belong elsewhere, but are repeated here and in > * <stdio.h> to give broken programs a better chance of working with > * 64-bit off_t's. > */ >#ifndef _KERNEL >__BEGIN_DECLS >#ifndef _FTRUNCATE_DECLARED >#define _FTRUNCATE_DECLARED >int ftruncate(int, off_t); >#endif ># 379 "/usr/src/ifnet/sys/sys/types.h" >#ifndef _LSEEK_DECLARED >#define _LSEEK_DECLARED >off_t lseek(int, off_t, int); >#endif ># 383 "/usr/src/ifnet/sys/sys/types.h" >#ifndef _MMAP_DECLARED >#define _MMAP_DECLARED >void * mmap(void *, size_t, int, int, int, off_t); >#endif ># 387 "/usr/src/ifnet/sys/sys/types.h" >#ifndef _TRUNCATE_DECLARED >#define _TRUNCATE_DECLARED >int truncate(const char *, off_t); >#endif ># 391 "/usr/src/ifnet/sys/sys/types.h" >__END_DECLS >#endif /* !_KERNEL */ ># 393 "/usr/src/ifnet/sys/sys/types.h" > >#endif /* __BSD_VISIBLE */ ># 395 "/usr/src/ifnet/sys/sys/types.h" > >#endif /* !_SYS_TYPES_H_ */ ># 397 "/usr/src/ifnet/sys/sys/types.h" ># 90 "/usr/src/ifnet/sys/sys/param.h" 2 >#endif ># 91 "/usr/src/ifnet/sys/sys/param.h" > >/* > * Machine-independent constants (some used in following include files). > * Redefined constants are from POSIX 1003.1 limits file. > * > * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/syslimits.h> >#endif /* expanded by -frewrite-includes */ ># 98 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/syslimits.h" 1 >/*- > * Copyright (c) 1988, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)syslimits.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: projects/ifnet/sys/sys/syslimits.h 194498 2009-06-19 17:10:35Z brooks $ > */ > >#ifndef _SYS_SYSLIMITS_H_ >#define _SYS_SYSLIMITS_H_ > >#if !defined(_KERNEL) && !defined(_LIMITS_H_) && !defined(_SYS_PARAM_H_) >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 40 "/usr/src/ifnet/sys/sys/syslimits.h" >#ifdef __CC_SUPPORTS_WARNING >#warning "No user-serviceable parts inside." >#endif ># 43 "/usr/src/ifnet/sys/sys/syslimits.h" >#endif ># 44 "/usr/src/ifnet/sys/sys/syslimits.h" > >/* > * Do not add any new variables here. (See the comment at the end of > * the file for why.) > */ >#define ARG_MAX 262144 /* max bytes for an exec function */ >#ifndef CHILD_MAX >#define CHILD_MAX 40 /* max simultaneous processes */ >#endif ># 53 "/usr/src/ifnet/sys/sys/syslimits.h" >#define LINK_MAX 32767 /* max file link count */ >#define MAX_CANON 255 /* max bytes in term canon input line */ >#define MAX_INPUT 255 /* max bytes in terminal input */ >#define NAME_MAX 255 /* max bytes in a file name */ >#ifndef NGROUPS_MAX >#define NGROUPS_MAX 1023 /* max supplemental group id's */ >#endif ># 60 "/usr/src/ifnet/sys/sys/syslimits.h" >#ifndef OPEN_MAX >#define OPEN_MAX 64 /* max open files per process */ >#endif ># 63 "/usr/src/ifnet/sys/sys/syslimits.h" >#define PATH_MAX 1024 /* max bytes in pathname */ >#define PIPE_BUF 512 /* max bytes for atomic pipe writes */ >#define IOV_MAX 1024 /* max elements in i/o vector */ > >/* > * We leave the following values undefined to force applications to either > * assume conservative values or call sysconf() to get the current value. > * > * HOST_NAME_MAX > * > * (We should do this for most of the values currently defined here, > * but many programs are not prepared to deal with this yet.) > */ >#endif ># 77 "/usr/src/ifnet/sys/sys/syslimits.h" ># 99 "/usr/src/ifnet/sys/sys/param.h" 2 > >#define MAXCOMLEN 19 /* max command name remembered */ >#define MAXINTERP PATH_MAX /* max interpreter file name length */ >#define MAXLOGNAME 33 /* max login name length (incl. NUL) */ >#define MAXUPRC CHILD_MAX /* max simultaneous processes */ >#define NCARGS ARG_MAX /* max bytes for an exec function */ >#define NGROUPS (NGROUPS_MAX+1) /* max number groups */ >#define NOFILE OPEN_MAX /* max open files per process */ >#define NOGROUP 65535 /* marker for empty group set member */ >#define MAXHOSTNAMELEN 256 /* max hostname size */ >#define SPECNAMELEN 63 /* max length of devicename */ > >/* More types and definitions used throughout the kernel. */ >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 113 "/usr/src/ifnet/sys/sys/param.h" ># 114 "/usr/src/ifnet/sys/sys/param.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/errno.h> >#endif /* expanded by -frewrite-includes */ ># 114 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/errno.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)errno.h 8.5 (Berkeley) 1/21/94 > * $FreeBSD: projects/ifnet/sys/sys/errno.h 250250 2013-05-04 19:07:22Z pluknet $ > */ > >#ifndef _SYS_ERRNO_H_ >#define _SYS_ERRNO_H_ > >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/errno.h" ># 43 "/usr/src/ifnet/sys/sys/errno.h" >__BEGIN_DECLS >int * __error(void); >__END_DECLS >#define errno (* __error()) >#endif ># 48 "/usr/src/ifnet/sys/sys/errno.h" > >#define EPERM 1 /* Operation not permitted */ >#define ENOENT 2 /* No such file or directory */ >#define ESRCH 3 /* No such process */ >#define EINTR 4 /* Interrupted system call */ >#define EIO 5 /* Input/output error */ >#define ENXIO 6 /* Device not configured */ >#define E2BIG 7 /* Argument list too long */ >#define ENOEXEC 8 /* Exec format error */ >#define EBADF 9 /* Bad file descriptor */ >#define ECHILD 10 /* No child processes */ >#define EDEADLK 11 /* Resource deadlock avoided */ > /* 11 was EAGAIN */ >#define ENOMEM 12 /* Cannot allocate memory */ >#define EACCES 13 /* Permission denied */ >#define EFAULT 14 /* Bad address */ >#ifndef _POSIX_SOURCE >#define ENOTBLK 15 /* Block device required */ >#endif ># 67 "/usr/src/ifnet/sys/sys/errno.h" >#define EBUSY 16 /* Device busy */ >#define EEXIST 17 /* File exists */ >#define EXDEV 18 /* Cross-device link */ >#define ENODEV 19 /* Operation not supported by device */ >#define ENOTDIR 20 /* Not a directory */ >#define EISDIR 21 /* Is a directory */ >#define EINVAL 22 /* Invalid argument */ >#define ENFILE 23 /* Too many open files in system */ >#define EMFILE 24 /* Too many open files */ >#define ENOTTY 25 /* Inappropriate ioctl for device */ >#ifndef _POSIX_SOURCE >#define ETXTBSY 26 /* Text file busy */ >#endif ># 80 "/usr/src/ifnet/sys/sys/errno.h" >#define EFBIG 27 /* File too large */ >#define ENOSPC 28 /* No space left on device */ >#define ESPIPE 29 /* Illegal seek */ >#define EROFS 30 /* Read-only filesystem */ >#define EMLINK 31 /* Too many links */ >#define EPIPE 32 /* Broken pipe */ > >/* math software */ >#define EDOM 33 /* Numerical argument out of domain */ >#define ERANGE 34 /* Result too large */ > >/* non-blocking and interrupt i/o */ >#define EAGAIN 35 /* Resource temporarily unavailable */ >#ifndef _POSIX_SOURCE >#define EWOULDBLOCK EAGAIN /* Operation would block */ >#define EINPROGRESS 36 /* Operation now in progress */ >#define EALREADY 37 /* Operation already in progress */ > >/* ipc/network software -- argument errors */ >#define ENOTSOCK 38 /* Socket operation on non-socket */ >#define EDESTADDRREQ 39 /* Destination address required */ >#define EMSGSIZE 40 /* Message too long */ >#define EPROTOTYPE 41 /* Protocol wrong type for socket */ >#define ENOPROTOOPT 42 /* Protocol not available */ >#define EPROTONOSUPPORT 43 /* Protocol not supported */ >#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ >#define EOPNOTSUPP 45 /* Operation not supported */ >#define ENOTSUP EOPNOTSUPP /* Operation not supported */ >#define EPFNOSUPPORT 46 /* Protocol family not supported */ >#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ >#define EADDRINUSE 48 /* Address already in use */ >#define EADDRNOTAVAIL 49 /* Can't assign requested address */ > >/* ipc/network software -- operational errors */ >#define ENETDOWN 50 /* Network is down */ >#define ENETUNREACH 51 /* Network is unreachable */ >#define ENETRESET 52 /* Network dropped connection on reset */ >#define ECONNABORTED 53 /* Software caused connection abort */ >#define ECONNRESET 54 /* Connection reset by peer */ >#define ENOBUFS 55 /* No buffer space available */ >#define EISCONN 56 /* Socket is already connected */ >#define ENOTCONN 57 /* Socket is not connected */ >#define ESHUTDOWN 58 /* Can't send after socket shutdown */ >#define ETOOMANYREFS 59 /* Too many references: can't splice */ >#define ETIMEDOUT 60 /* Operation timed out */ >#define ECONNREFUSED 61 /* Connection refused */ > >#define ELOOP 62 /* Too many levels of symbolic links */ >#endif /* _POSIX_SOURCE */ ># 129 "/usr/src/ifnet/sys/sys/errno.h" >#define ENAMETOOLONG 63 /* File name too long */ > >/* should be rearranged */ >#ifndef _POSIX_SOURCE >#define EHOSTDOWN 64 /* Host is down */ >#define EHOSTUNREACH 65 /* No route to host */ >#endif /* _POSIX_SOURCE */ ># 136 "/usr/src/ifnet/sys/sys/errno.h" >#define ENOTEMPTY 66 /* Directory not empty */ > >/* quotas & mush */ >#ifndef _POSIX_SOURCE >#define EPROCLIM 67 /* Too many processes */ >#define EUSERS 68 /* Too many users */ >#define EDQUOT 69 /* Disc quota exceeded */ > >/* Network File System */ >#define ESTALE 70 /* Stale NFS file handle */ >#define EREMOTE 71 /* Too many levels of remote in path */ >#define EBADRPC 72 /* RPC struct is bad */ >#define ERPCMISMATCH 73 /* RPC version wrong */ >#define EPROGUNAVAIL 74 /* RPC prog. not avail */ >#define EPROGMISMATCH 75 /* Program version wrong */ >#define EPROCUNAVAIL 76 /* Bad procedure for program */ >#endif /* _POSIX_SOURCE */ ># 153 "/usr/src/ifnet/sys/sys/errno.h" > >#define ENOLCK 77 /* No locks available */ >#define ENOSYS 78 /* Function not implemented */ > >#ifndef _POSIX_SOURCE >#define EFTYPE 79 /* Inappropriate file type or format */ >#define EAUTH 80 /* Authentication error */ >#define ENEEDAUTH 81 /* Need authenticator */ >#define EIDRM 82 /* Identifier removed */ >#define ENOMSG 83 /* No message of desired type */ >#define EOVERFLOW 84 /* Value too large to be stored in data type */ >#define ECANCELED 85 /* Operation canceled */ >#define EILSEQ 86 /* Illegal byte sequence */ >#define ENOATTR 87 /* Attribute not found */ > >#define EDOOFUS 88 /* Programming error */ >#endif /* _POSIX_SOURCE */ ># 170 "/usr/src/ifnet/sys/sys/errno.h" > >#define EBADMSG 89 /* Bad message */ >#define EMULTIHOP 90 /* Multihop attempted */ >#define ENOLINK 91 /* Link has been severed */ >#define EPROTO 92 /* Protocol error */ > >#ifndef _POSIX_SOURCE >#define ENOTCAPABLE 93 /* Capabilities insufficient */ >#define ECAPMODE 94 /* Not permitted in capability mode */ >#define ENOTRECOVERABLE 95 /* State not recoverable */ >#define EOWNERDEAD 96 /* Previous owner died */ >#endif /* _POSIX_SOURCE */ ># 182 "/usr/src/ifnet/sys/sys/errno.h" > >#ifndef _POSIX_SOURCE >#define ELAST 96 /* Must be equal largest errno */ >#endif /* _POSIX_SOURCE */ ># 186 "/usr/src/ifnet/sys/sys/errno.h" > >#ifdef _KERNEL >/* pseudo-errors returned inside kernel to modify return to process */ >#define ERESTART (-1) /* restart syscall */ >#define EJUSTRETURN (-2) /* don't modify regs, just return */ >#define ENOIOCTL (-3) /* ioctl not handled by this layer */ >#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */ >#endif ># 194 "/usr/src/ifnet/sys/sys/errno.h" > >#endif ># 196 "/usr/src/ifnet/sys/sys/errno.h" ># 115 "/usr/src/ifnet/sys/sys/param.h" 2 >#ifndef LOCORE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/time.h> >#endif /* expanded by -frewrite-includes */ ># 116 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/time.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)time.h 8.5 (Berkeley) 5/4/95 > * $FreeBSD: projects/ifnet/sys/sys/time.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_TIME_H_ >#define _SYS_TIME_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/time.h" ># 37 "/usr/src/ifnet/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/time.h" ># 38 "/usr/src/ifnet/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/timespec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/time.h" ># 39 "/usr/src/ifnet/sys/sys/time.h" > >struct timezone { > int tz_minuteswest; /* minutes west of Greenwich */ > int tz_dsttime; /* type of dst correction */ >}; >#define DST_NONE 0 /* not on dst */ >#define DST_USA 1 /* USA style dst */ >#define DST_AUST 2 /* Australian style dst */ >#define DST_WET 3 /* Western European dst */ >#define DST_MET 4 /* Middle European dst */ >#define DST_EET 5 /* Eastern European dst */ >#define DST_CAN 6 /* Canada */ > >#if __BSD_VISIBLE >struct bintime { > time_t sec; > uint64_t frac; >}; > >static __inline void >bintime_addx(struct bintime *_bt, uint64_t _x) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac += _x; > if (_u > _bt->frac) > _bt->sec++; >} > >static __inline void >bintime_add(struct bintime *_bt, const struct bintime *_bt2) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac += _bt2->frac; > if (_u > _bt->frac) > _bt->sec++; > _bt->sec += _bt2->sec; >} > >static __inline void >bintime_sub(struct bintime *_bt, const struct bintime *_bt2) >{ > uint64_t _u; > > _u = _bt->frac; > _bt->frac -= _bt2->frac; > if (_u < _bt->frac) > _bt->sec--; > _bt->sec -= _bt2->sec; >} > >static __inline void >bintime_mul(struct bintime *_bt, u_int _x) >{ > uint64_t _p1, _p2; > > _p1 = (_bt->frac & 0xffffffffull) * _x; > _p2 = (_bt->frac >> 32) * _x + (_p1 >> 32); > _bt->sec *= _x; > _bt->sec += (_p2 >> 32); > _bt->frac = (_p2 << 32) | (_p1 & 0xffffffffull); >} > >static __inline void >bintime_shift(struct bintime *_bt, int _exp) >{ > > if (_exp > 0) { > _bt->sec <<= _exp; > _bt->sec |= _bt->frac >> (64 - _exp); > _bt->frac <<= _exp; > } else if (_exp < 0) { > _bt->frac >>= -_exp; > _bt->frac |= (uint64_t)_bt->sec << (64 + _exp); > _bt->sec >>= -_exp; > } >} > >#define bintime_clear(a) ((a)->sec = (a)->frac = 0) >#define bintime_isset(a) ((a)->sec || (a)->frac) >#define bintime_cmp(a, b, cmp) \ > (((a)->sec == (b)->sec) ? \ > ((a)->frac cmp (b)->frac) : \ > ((a)->sec cmp (b)->sec)) > >#define SBT_1S ((sbintime_t)1 << 32) >#define SBT_1M (SBT_1S * 60) >#define SBT_1MS (SBT_1S / 1000) >#define SBT_1US (SBT_1S / 1000000) >#define SBT_1NS (SBT_1S / 1000000000) >#define SBT_MAX 0x7fffffffffffffffLL > >static __inline int >sbintime_getsec(sbintime_t _sbt) >{ > > return (_sbt >> 32); >} > >static __inline sbintime_t >bttosbt(const struct bintime _bt) >{ > > return (((sbintime_t)_bt.sec << 32) + (_bt.frac >> 32)); >} > >static __inline struct bintime >sbttobt(sbintime_t _sbt) >{ > struct bintime _bt; > > _bt.sec = _sbt >> 32; > _bt.frac = _sbt << 32; > return (_bt); >} > >/*- > * Background information: > * > * When converting between timestamps on parallel timescales of differing > * resolutions it is historical and scientific practice to round down rather > * than doing 4/5 rounding. > * > * The date changes at midnight, not at noon. > * > * Even at 15:59:59.999999999 it's not four'o'clock. > * > * time_second ticks after N.999999999 not after N.4999999999 > */ > >static __inline void >bintime2timespec(const struct bintime *_bt, struct timespec *_ts) >{ > > _ts->tv_sec = _bt->sec; > _ts->tv_nsec = ((uint64_t)1000000000 * > (uint32_t)(_bt->frac >> 32)) >> 32; >} > >static __inline void >timespec2bintime(const struct timespec *_ts, struct bintime *_bt) >{ > > _bt->sec = _ts->tv_sec; > /* 18446744073 = int(2^64 / 1000000000) */ > _bt->frac = _ts->tv_nsec * (uint64_t)18446744073LL; >} > >static __inline void >bintime2timeval(const struct bintime *_bt, struct timeval *_tv) >{ > > _tv->tv_sec = _bt->sec; > _tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(_bt->frac >> 32)) >> 32; >} > >static __inline void >timeval2bintime(const struct timeval *_tv, struct bintime *_bt) >{ > > _bt->sec = _tv->tv_sec; > /* 18446744073709 = int(2^64 / 1000000) */ > _bt->frac = _tv->tv_usec * (uint64_t)18446744073709LL; >} > >static __inline struct timespec >sbttots(sbintime_t _sbt) >{ > struct timespec _ts; > > _ts.tv_sec = _sbt >> 32; > _ts.tv_nsec = ((uint64_t)1000000000 * (uint32_t)_sbt) >> 32; > return (_ts); >} > >static __inline sbintime_t >tstosbt(struct timespec _ts) >{ > > return (((sbintime_t)_ts.tv_sec << 32) + > (_ts.tv_nsec * (((uint64_t)1 << 63) / 500000000) >> 32)); >} > >static __inline struct timeval >sbttotv(sbintime_t _sbt) >{ > struct timeval _tv; > > _tv.tv_sec = _sbt >> 32; > _tv.tv_usec = ((uint64_t)1000000 * (uint32_t)_sbt) >> 32; > return (_tv); >} > >static __inline sbintime_t >tvtosbt(struct timeval _tv) >{ > > return (((sbintime_t)_tv.tv_sec << 32) + > (_tv.tv_usec * (((uint64_t)1 << 63) / 500000) >> 32)); >} >#endif /* __BSD_VISIBLE */ ># 243 "/usr/src/ifnet/sys/sys/time.h" > >#ifdef _KERNEL > >/* Operations on timespecs */ >#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0) >#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec) >#define timespeccmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) >#define timespecadd(vvp, uvp) \ > do { \ > (vvp)->tv_sec += (uvp)->tv_sec; \ > (vvp)->tv_nsec += (uvp)->tv_nsec; \ > if ((vvp)->tv_nsec >= 1000000000) { \ > (vvp)->tv_sec++; \ > (vvp)->tv_nsec -= 1000000000; \ > } \ > } while (0) >#define timespecsub(vvp, uvp) \ > do { \ > (vvp)->tv_sec -= (uvp)->tv_sec; \ > (vvp)->tv_nsec -= (uvp)->tv_nsec; \ > if ((vvp)->tv_nsec < 0) { \ > (vvp)->tv_sec--; \ > (vvp)->tv_nsec += 1000000000; \ > } \ > } while (0) > >/* Operations on timevals. */ > >#define timevalclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) >#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) >#define timevalcmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) > >/* timevaladd and timevalsub are not inlined */ > >#endif /* _KERNEL */ ># 284 "/usr/src/ifnet/sys/sys/time.h" > >#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ > >#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) >#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) >#define timercmp(tvp, uvp, cmp) \ > (((tvp)->tv_sec == (uvp)->tv_sec) ? \ > ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ > ((tvp)->tv_sec cmp (uvp)->tv_sec)) >#define timeradd(tvp, uvp, vvp) \ > do { \ > (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ > (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ > if ((vvp)->tv_usec >= 1000000) { \ > (vvp)->tv_sec++; \ > (vvp)->tv_usec -= 1000000; \ > } \ > } while (0) >#define timersub(tvp, uvp, vvp) \ > do { \ > (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ > (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ > if ((vvp)->tv_usec < 0) { \ > (vvp)->tv_sec--; \ > (vvp)->tv_usec += 1000000; \ > } \ > } while (0) >#endif ># 312 "/usr/src/ifnet/sys/sys/time.h" > >/* > * Names of the interval timers, and structure > * defining a timer setting. > */ >#define ITIMER_REAL 0 >#define ITIMER_VIRTUAL 1 >#define ITIMER_PROF 2 > >struct itimerval { > struct timeval it_interval; /* timer interval */ > struct timeval it_value; /* current value */ >}; > >/* > * Getkerninfo clock information structure > */ >struct clockinfo { > int hz; /* clock frequency */ > int tick; /* micro-seconds per hz tick */ > int spare; > int stathz; /* statistics clock frequency */ > int profhz; /* profiling clock frequency */ >}; > >/* These macros are also in time.h. */ >#ifndef CLOCK_REALTIME >#define CLOCK_REALTIME 0 >#define CLOCK_VIRTUAL 1 >#define CLOCK_PROF 2 >#define CLOCK_MONOTONIC 4 >#define CLOCK_UPTIME 5 /* FreeBSD-specific. */ >#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */ >#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */ >#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */ >#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */ >#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */ >#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */ >#define CLOCK_SECOND 13 /* FreeBSD-specific. */ >#define CLOCK_THREAD_CPUTIME_ID 14 >#define CLOCK_PROCESS_CPUTIME_ID 15 >#endif ># 354 "/usr/src/ifnet/sys/sys/time.h" > >#ifndef TIMER_ABSTIME >#define TIMER_RELTIME 0x0 /* relative timer */ >#define TIMER_ABSTIME 0x1 /* absolute timer */ >#endif ># 359 "/usr/src/ifnet/sys/sys/time.h" > >#if __BSD_VISIBLE >#define CPUCLOCK_WHICH_PID 0 >#define CPUCLOCK_WHICH_TID 1 >#endif ># 364 "/usr/src/ifnet/sys/sys/time.h" > >#ifdef _KERNEL > >/* > * Kernel to clock driver interface. > */ >void inittodr(time_t base); >void resettodr(void); > >extern volatile time_t time_second; >extern volatile time_t time_uptime; >extern struct bintime boottimebin; >extern struct timeval boottime; >extern struct bintime tc_tick_bt; >extern sbintime_t tc_tick_sbt; >extern struct bintime tick_bt; >extern sbintime_t tick_sbt; >extern int tc_precexp; >extern int tc_timepercentage; >extern struct bintime bt_timethreshold; >extern struct bintime bt_tickthreshold; >extern sbintime_t sbt_timethreshold; >extern sbintime_t sbt_tickthreshold; > >/* > * Functions for looking at our clock: [get]{bin,nano,micro}[up]time() > * > * Functions without the "get" prefix returns the best timestamp > * we can produce in the given format. > * > * "bin" == struct bintime == seconds + 64 bit fraction of seconds. > * "nano" == struct timespec == seconds + nanoseconds. > * "micro" == struct timeval == seconds + microseconds. > * > * Functions containing "up" returns time relative to boot and > * should be used for calculating time intervals. > * > * Functions without "up" returns UTC time. > * > * Functions with the "get" prefix returns a less precise result > * much faster than the functions without "get" prefix and should > * be used where a precision of 1/hz seconds is acceptable or where > * performance is priority. (NB: "precision", _not_ "resolution" !) > */ > >void binuptime(struct bintime *bt); >void nanouptime(struct timespec *tsp); >void microuptime(struct timeval *tvp); > >static __inline sbintime_t >sbinuptime(void) >{ > struct bintime _bt; > > binuptime(&_bt); > return (bttosbt(_bt)); >} > >void bintime(struct bintime *bt); >void nanotime(struct timespec *tsp); >void microtime(struct timeval *tvp); > >void getbinuptime(struct bintime *bt); >void getnanouptime(struct timespec *tsp); >void getmicrouptime(struct timeval *tvp); > >static __inline sbintime_t >getsbinuptime(void) >{ > struct bintime _bt; > > getbinuptime(&_bt); > return (bttosbt(_bt)); >} > >void getbintime(struct bintime *bt); >void getnanotime(struct timespec *tsp); >void getmicrotime(struct timeval *tvp); > >/* Other functions */ >int itimerdecr(struct itimerval *itp, int usec); >int itimerfix(struct timeval *tv); >int ppsratecheck(struct timeval *, int *, int); >int ratecheck(struct timeval *, const struct timeval *); >void timevaladd(struct timeval *t1, const struct timeval *t2); >void timevalsub(struct timeval *t1, const struct timeval *t2); >int tvtohz(struct timeval *tv); > >#define TC_DEFAULTPERC 5 > >#define BT2FREQ(bt) \ > (((uint64_t)0x8000000000000000 + ((bt)->frac >> 2)) / \ > ((bt)->frac >> 1)) > >#define SBT2FREQ(sbt) ((SBT_1S + ((sbt) >> 1)) / (sbt)) > >#define FREQ2BT(freq, bt) \ >{ \ > (bt)->sec = 0; \ > (bt)->frac = ((uint64_t)0x8000000000000000 / (freq)) << 1; \ >} > >#define TIMESEL(sbt, sbt2) \ > (((sbt2) >= sbt_timethreshold) ? \ > ((*(sbt) = getsbinuptime()), 1) : ((*(sbt) = sbinuptime()), 0)) > >#else /* !_KERNEL */ ># 471 "/usr/src/ifnet/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <time.h> >#endif /* expanded by -frewrite-includes */ ># 471 "/usr/src/ifnet/sys/sys/time.h" ># 472 "/usr/src/ifnet/sys/sys/time.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 473 "/usr/src/ifnet/sys/sys/time.h" ># 474 "/usr/src/ifnet/sys/sys/time.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/select.h> >#endif /* expanded by -frewrite-includes */ ># 474 "/usr/src/ifnet/sys/sys/time.h" ># 475 "/usr/src/ifnet/sys/sys/time.h" > >__BEGIN_DECLS >int setitimer(int, const struct itimerval *, struct itimerval *); >int utimes(const char *, const struct timeval *); > >#if __BSD_VISIBLE >int adjtime(const struct timeval *, struct timeval *); >int clock_getcpuclockid2(id_t, int, clockid_t *); >int futimes(int, const struct timeval *); >int futimesat(int, const char *, const struct timeval [2]); >int lutimes(const char *, const struct timeval *); >int settimeofday(const struct timeval *, const struct timezone *); >#endif ># 488 "/usr/src/ifnet/sys/sys/time.h" > >#if __XSI_VISIBLE >int getitimer(int, struct itimerval *); >int gettimeofday(struct timeval *, struct timezone *); >#endif ># 493 "/usr/src/ifnet/sys/sys/time.h" > >__END_DECLS > >#endif /* !_KERNEL */ ># 497 "/usr/src/ifnet/sys/sys/time.h" > >#endif /* !_SYS_TIME_H_ */ ># 499 "/usr/src/ifnet/sys/sys/time.h" ># 117 "/usr/src/ifnet/sys/sys/param.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/priority.h> >#endif /* expanded by -frewrite-includes */ ># 117 "/usr/src/ifnet/sys/sys/param.h" ># 1 "/usr/src/ifnet/sys/sys/priority.h" 1 >/*- > * Copyright (c) 1994, Henrik Vestergaard Draboel > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Henrik Vestergaard Draboel. > * 4. The name of the author may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/priority.h 221829 2011-05-13 05:27:58Z mdf $ > */ > >#ifndef _SYS_PRIORITY_H_ >#define _SYS_PRIORITY_H_ > >/* > * Process priority specifications. > */ > >/* > * Priority classes. > */ > >#define PRI_ITHD 1 /* Interrupt thread. */ >#define PRI_REALTIME 2 /* Real time process. */ >#define PRI_TIMESHARE 3 /* Time sharing process. */ >#define PRI_IDLE 4 /* Idle process. */ > >/* > * PRI_FIFO is POSIX.1B SCHED_FIFO. > */ > >#define PRI_FIFO_BIT 8 >#define PRI_FIFO (PRI_FIFO_BIT | PRI_REALTIME) > >#define PRI_BASE(P) ((P) & ~PRI_FIFO_BIT) >#define PRI_IS_REALTIME(P) (PRI_BASE(P) == PRI_REALTIME) >#define PRI_NEED_RR(P) ((P) != PRI_FIFO) > >/* > * Priorities. Note that with 64 run queues, differences less than 4 are > * insignificant. > */ > >/* > * Priorities range from 0 to 255, but differences of less then 4 (RQ_PPQ) > * are insignificant. Ranges are as follows: > * > * Interrupt threads: 0 - 47 > * Realtime user threads: 48 - 79 > * Top half kernel threads: 80 - 119 > * Time sharing user threads: 120 - 223 > * Idle user threads: 224 - 255 > * > * XXX If/When the specific interrupt thread and top half thread ranges > * disappear, a larger range can be used for user processes. > */ > >#define PRI_MIN (0) /* Highest priority. */ >#define PRI_MAX (255) /* Lowest priority. */ > >#define PRI_MIN_ITHD (PRI_MIN) >#define PRI_MAX_ITHD (PRI_MIN_REALTIME - 1) > >#define PI_REALTIME (PRI_MIN_ITHD + 0) >#define PI_AV (PRI_MIN_ITHD + 4) >#define PI_NET (PRI_MIN_ITHD + 8) >#define PI_DISK (PRI_MIN_ITHD + 12) >#define PI_TTY (PRI_MIN_ITHD + 16) >#define PI_DULL (PRI_MIN_ITHD + 20) >#define PI_SOFT (PRI_MIN_ITHD + 24) >#define PI_SWI(x) (PI_SOFT + (x) * RQ_PPQ) > >#define PRI_MIN_REALTIME (48) >#define PRI_MAX_REALTIME (PRI_MIN_KERN - 1) > >#define PRI_MIN_KERN (80) >#define PRI_MAX_KERN (PRI_MIN_TIMESHARE - 1) > >#define PSWP (PRI_MIN_KERN + 0) >#define PVM (PRI_MIN_KERN + 4) >#define PINOD (PRI_MIN_KERN + 8) >#define PRIBIO (PRI_MIN_KERN + 12) >#define PVFS (PRI_MIN_KERN + 16) >#define PZERO (PRI_MIN_KERN + 20) >#define PSOCK (PRI_MIN_KERN + 24) >#define PWAIT (PRI_MIN_KERN + 28) >#define PLOCK (PRI_MIN_KERN + 32) >#define PPAUSE (PRI_MIN_KERN + 36) > >#define PRI_MIN_TIMESHARE (120) >#define PRI_MAX_TIMESHARE (PRI_MIN_IDLE - 1) > >#define PUSER (PRI_MIN_TIMESHARE) > >#define PRI_MIN_IDLE (224) >#define PRI_MAX_IDLE (PRI_MAX) > >#ifdef _KERNEL >/* Other arguments for kern_yield(9). */ >#define PRI_USER -2 /* Change to current user priority. */ >#define PRI_UNCHANGED -1 /* Do not change priority. */ >#endif ># 125 "/usr/src/ifnet/sys/sys/priority.h" > >struct priority { > u_char pri_class; /* Scheduling class. */ > u_char pri_level; /* Normal priority level. */ > u_char pri_native; /* Priority before propogation. */ > u_char pri_user; /* User priority based on p_cpu and p_nice. */ >}; > >#endif /* !_SYS_PRIORITY_H_ */ ># 134 "/usr/src/ifnet/sys/sys/priority.h" ># 118 "/usr/src/ifnet/sys/sys/param.h" 2 >#endif ># 119 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef FALSE >#define FALSE 0 >#endif ># 123 "/usr/src/ifnet/sys/sys/param.h" >#ifndef TRUE >#define TRUE 1 >#endif ># 126 "/usr/src/ifnet/sys/sys/param.h" >#endif ># 127 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef _KERNEL >/* Signals. */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/signal.h> >#endif /* expanded by -frewrite-includes */ ># 130 "/usr/src/ifnet/sys/sys/param.h" ># 131 "/usr/src/ifnet/sys/sys/param.h" >#endif ># 132 "/usr/src/ifnet/sys/sys/param.h" > >/* Machine type dependent parameters. */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 134 "/usr/src/ifnet/sys/sys/param.h" ># 1 "./machine/param.h" 1 >/*- > * Copyright (c) 2002 David E. O'Brien. All rights reserved. > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * the Systems Programming Group of the University of Utah Computer > * Science Department and Ralph Campbell. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)param.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: projects/ifnet/sys/amd64/include/param.h 272251 2014-09-28 12:18:21Z glebius $ > */ > > >#ifndef _AMD64_INCLUDE_PARAM_H_ >#define _AMD64_INCLUDE_PARAM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_align.h> >#endif /* expanded by -frewrite-includes */ ># 46 "./machine/param.h" ># 1 "./machine/_align.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_align.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_align.h" ># 1 "./x86/_align.h" 1 >/*- > * Copyright (c) 2001 David E. O'Brien > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the University of > * California, Berkeley and its contributors. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)param.h 5.8 (Berkeley) 6/28/91 > * $FreeBSD: projects/ifnet/sys/x86/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ > */ > >#ifndef _X86_INCLUDE__ALIGN_H_ >#define _X86_INCLUDE__ALIGN_H_ > >/* > * Round p (pointer or byte index) up to a correctly-aligned value > * for all data types (int, long, ...). The result is unsigned int > * and must be cast to any desired pointer type. > */ >#define _ALIGNBYTES (sizeof(register_t) - 1) >#define _ALIGN(p) (((uintptr_t)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) > >#endif /* !_X86_INCLUDE__ALIGN_H_ */ ># 53 "./x86/_align.h" ># 7 "./machine/_align.h" 2 ># 47 "./machine/param.h" 2 > >/* > * Machine dependent constants for AMD64. > */ > > >#define __HAVE_ACPI >#define __PCI_REROUTE_INTERRUPT > >#ifndef MACHINE >#define MACHINE "amd64" >#endif ># 59 "./machine/param.h" >#ifndef MACHINE_ARCH >#define MACHINE_ARCH "amd64" >#endif ># 62 "./machine/param.h" >#ifndef MACHINE_ARCH32 >#define MACHINE_ARCH32 "i386" >#endif ># 65 "./machine/param.h" > >#if defined(SMP) || defined(KLD_MODULE) >#ifndef MAXCPU >#define MAXCPU 256 >#endif ># 70 "./machine/param.h" >#else ># 71 "./machine/param.h" >#define MAXCPU 1 >#endif ># 73 "./machine/param.h" > >#ifndef MAXMEMDOM >#define MAXMEMDOM 1 >#endif ># 77 "./machine/param.h" > >#define ALIGNBYTES _ALIGNBYTES >#define ALIGN(p) _ALIGN(p) >/* > * ALIGNED_POINTER is a boolean macro that checks whether an address > * is valid to fetch data elements of type t from on this architecture. > * This does not reflect the optimal alignment, just the possibility > * (within reasonable limits). > */ >#define ALIGNED_POINTER(p, t) 1 > >/* > * CACHE_LINE_SIZE is the compile-time maximum cache line size for an > * architecture. It should be used with appropriate caution. > */ >#define CACHE_LINE_SHIFT 7 >#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) > >/* Size of the level 1 page table units */ >#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) >#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ >#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ >#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ >#define PAGE_MASK (PAGE_SIZE-1) >/* Size of the level 2 page directory units */ >#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) >#define NPDEPGSHIFT 9 /* LOG2(NPDEPG) */ >#define PDRSHIFT 21 /* LOG2(NBPDR) */ >#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ >#define PDRMASK (NBPDR-1) >/* Size of the level 3 page directory pointer table units */ >#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) >#define NPDPEPGSHIFT 9 /* LOG2(NPDPEPG) */ >#define PDPSHIFT 30 /* LOG2(NBPDP) */ >#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */ >#define PDPMASK (NBPDP-1) >/* Size of the level 4 page-map level-4 table units */ >#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) >#define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ >#define PML4SHIFT 39 /* LOG2(NBPML4) */ >#define NBPML4 (1UL<<PML4SHIFT)/* bytes/page map lev4 table */ >#define PML4MASK (NBPML4-1) > >#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ > >#define IOPAGES 2 /* pages of i/o permission bitmap */ >/* > * I/O permission bitmap has a bit for each I/O port plus an additional > * byte at the end with all bits set. See section "I/O Permission Bit Map" > * in the Intel SDM for more details. > */ >#define IOPERM_BITMAP_SIZE (IOPAGES * PAGE_SIZE + 1) > >#ifndef KSTACK_PAGES >#define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ >#endif ># 133 "./machine/param.h" >#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ > >/* > * Mach derived conversion macros > */ >#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) >#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) >#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) >#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) >#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) > >#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) >#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) > >#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) >#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) > >#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) > >#endif /* !_AMD64_INCLUDE_PARAM_H_ */ ># 153 "./machine/param.h" ># 135 "/usr/src/ifnet/sys/sys/param.h" 2 >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/limits.h> >#endif /* expanded by -frewrite-includes */ ># 136 "/usr/src/ifnet/sys/sys/param.h" ># 137 "/usr/src/ifnet/sys/sys/param.h" >#endif ># 138 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef DEV_BSHIFT >#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ >#endif ># 142 "/usr/src/ifnet/sys/sys/param.h" >#define DEV_BSIZE (1<<DEV_BSHIFT) > >#ifndef BLKDEV_IOSIZE >#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */ >#endif ># 147 "/usr/src/ifnet/sys/sys/param.h" >#ifndef DFLTPHYS >#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ >#endif ># 150 "/usr/src/ifnet/sys/sys/param.h" >#ifndef MAXPHYS >#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ >#endif ># 153 "/usr/src/ifnet/sys/sys/param.h" >#ifndef MAXDUMPPGS >#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) >#endif ># 156 "/usr/src/ifnet/sys/sys/param.h" > >/* > * Constants related to network buffer management. > * MCLBYTES must be no larger than PAGE_SIZE. > */ >#ifndef MSIZE >#define MSIZE 256 /* size of an mbuf */ >#endif ># 164 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef MCLSHIFT >#define MCLSHIFT 11 /* convert bytes to mbuf clusters */ >#endif /* MCLSHIFT */ ># 168 "/usr/src/ifnet/sys/sys/param.h" > >#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ > >#if PAGE_SIZE < 2048 >#define MJUMPAGESIZE MCLBYTES >#elif PAGE_SIZE <= 8192 ># 174 "/usr/src/ifnet/sys/sys/param.h" >#define MJUMPAGESIZE PAGE_SIZE >#else ># 176 "/usr/src/ifnet/sys/sys/param.h" >#define MJUMPAGESIZE (8 * 1024) >#endif ># 178 "/usr/src/ifnet/sys/sys/param.h" > >#define MJUM9BYTES (9 * 1024) /* jumbo cluster 9k */ >#define MJUM16BYTES (16 * 1024) /* jumbo cluster 16k */ > >/* > * Some macros for units conversion > */ > >/* clicks to bytes */ >#ifndef ctob >#define ctob(x) ((x)<<PAGE_SHIFT) >#endif ># 190 "/usr/src/ifnet/sys/sys/param.h" > >/* bytes to clicks */ >#ifndef btoc >#define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT) >#endif ># 195 "/usr/src/ifnet/sys/sys/param.h" > >/* > * btodb() is messy and perhaps slow because `bytes' may be an off_t. We > * want to shift an unsigned type to avoid sign extension and we don't > * want to widen `bytes' unnecessarily. Assume that the result fits in > * a daddr_t. > */ >#ifndef btodb >#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ > (sizeof (bytes) > sizeof(long) \ > ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ > : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) >#endif ># 208 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef dbtob >#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ > ((off_t)(db) << DEV_BSHIFT) >#endif ># 213 "/usr/src/ifnet/sys/sys/param.h" > >#define PRIMASK 0x0ff >#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ >#define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */ > >#define NZERO 0 /* default "nice" */ > >#define NBBY 8 /* number of bits in a byte */ >#define NBPW sizeof(int) /* number of bytes per word (integer) */ > >#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ > >#define NODEV (dev_t)(-1) /* non-existent device */ > >/* > * File system parameters and macros. > * > * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes > * per block. MAXBSIZE may be made larger without effecting > * any existing filesystems as long as it does not exceed MAXPHYS, > * and may be made smaller at the risk of not being able to use > * filesystems which require a block size exceeding MAXBSIZE. > * > * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the > * minimum KVM memory reservation the kernel is willing to make. > * Filesystems can of course request smaller chunks. Actual > * backing memory uses a chunk size of a page (PAGE_SIZE). > * > * If you make BKVASIZE too small you risk seriously fragmenting > * the buffer KVM map which may slow things down a bit. If you > * make it too big the kernel will not be able to optimally use > * the KVM memory reserved for the buffer cache and will wind > * up with too-few buffers. > * > * The default is 16384, roughly 2x the block size used by a > * normal UFS filesystem. > */ >#define MAXBSIZE 65536 /* must be power of 2 */ >#define BKVASIZE 16384 /* must be power of 2 */ >#define BKVAMASK (BKVASIZE-1) > >/* > * MAXPATHLEN defines the longest permissible path length after expanding > * symbolic links. It is used to allocate a temporary buffer from the buffer > * pool in which to do the name expansion, hence should be a power of two, > * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the > * maximum number of symbolic links that may be expanded in a path name. > * It should be set high enough to allow all legitimate uses, but halt > * infinite loops reasonably quickly. > */ >#define MAXPATHLEN PATH_MAX >#define MAXSYMLINKS 32 > >/* Bit map related macros. */ >#define setbit(a,i) (((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY)) >#define clrbit(a,i) (((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY))) >#define isset(a,i) \ > (((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) >#define isclr(a,i) \ > ((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0) > >/* Macros for counting and rounding. */ >#ifndef howmany >#define howmany(x, y) (((x)+((y)-1))/(y)) >#endif ># 278 "/usr/src/ifnet/sys/sys/param.h" >#define nitems(x) (sizeof((x)) / sizeof((x)[0])) >#define rounddown(x, y) (((x)/(y))*(y)) >#define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */ >#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ >#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ >#define powerof2(x) ((((x)-1)&(x))==0) > >/* Macros for min/max. */ >#define MIN(a,b) (((a)<(b))?(a):(b)) >#define MAX(a,b) (((a)>(b))?(a):(b)) > >#ifdef _KERNEL >/* > * Basic byte order function prototypes for non-inline functions. > */ >#ifndef LOCORE >#ifndef _BYTEORDER_PROTOTYPED >#define _BYTEORDER_PROTOTYPED >__BEGIN_DECLS >__uint32_t htonl(__uint32_t); >__uint16_t htons(__uint16_t); >__uint32_t ntohl(__uint32_t); >__uint16_t ntohs(__uint16_t); >__END_DECLS >#endif ># 303 "/usr/src/ifnet/sys/sys/param.h" >#endif ># 304 "/usr/src/ifnet/sys/sys/param.h" > >#ifndef lint >#ifndef _BYTEORDER_FUNC_DEFINED >#define _BYTEORDER_FUNC_DEFINED >#define htonl(x) __htonl(x) >#define htons(x) __htons(x) >#define ntohl(x) __ntohl(x) >#define ntohs(x) __ntohs(x) >#endif /* !_BYTEORDER_FUNC_DEFINED */ ># 313 "/usr/src/ifnet/sys/sys/param.h" >#endif /* lint */ ># 314 "/usr/src/ifnet/sys/sys/param.h" >#endif /* _KERNEL */ ># 315 "/usr/src/ifnet/sys/sys/param.h" > >/* > * Scale factor for scaled integers used to count %cpu time and load avgs. > * > * The number of CPU `tick's that map to a unique `%age' can be expressed > * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that > * can be calculated (assuming 32 bits) can be closely approximated using > * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). > * > * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', > * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. > */ >#define FSHIFT 11 /* bits to right of fixed binary point */ >#define FSCALE (1<<FSHIFT) > >#define dbtoc(db) /* calculates devblks to pages */ \ > ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT)) > >#define ctodb(db) /* calculates pages to devblks */ \ > ((db) << (PAGE_SHIFT - DEV_BSHIFT)) > >/* > * Old spelling of __containerof(). > */ >#define member2struct(s, m, x) \ > ((struct s *)(void *)((char *)(x) - offsetof(struct s, m))) > >/* > * Access a variable length array that has been declared as a fixed > * length array. > */ >#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset]) > >#endif /* _SYS_PARAM_H_ */ ># 349 "/usr/src/ifnet/sys/sys/param.h" ># 39 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/systm.h" 1 >/*- > * Copyright (c) 1982, 1988, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)systm.h 8.7 (Berkeley) 3/29/95 > * $FreeBSD: projects/ifnet/sys/sys/systm.h 280281 2015-03-20 14:12:04Z glebius $ > */ > >#ifndef _SYS_SYSTM_H_ >#define _SYS_SYSTM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/systm.h" ># 1 "./machine/atomic.h" 1 >/*- > * Copyright (c) 1998 Doug Rabson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/amd64/include/atomic.h 254618 2013-08-21 22:05:58Z jkim $ > */ >#ifndef _MACHINE_ATOMIC_H_ >#define _MACHINE_ATOMIC_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 34 "./machine/atomic.h" > >#define mb() __asm __volatile("mfence;" : : : "memory") >#define wmb() __asm __volatile("sfence;" : : : "memory") >#define rmb() __asm __volatile("lfence;" : : : "memory") > >/* > * Various simple operations on memory, each of which is atomic in the > * presence of interrupts and multiple processors. > * > * atomic_set_char(P, V) (*(u_char *)(P) |= (V)) > * atomic_clear_char(P, V) (*(u_char *)(P) &= ~(V)) > * atomic_add_char(P, V) (*(u_char *)(P) += (V)) > * atomic_subtract_char(P, V) (*(u_char *)(P) -= (V)) > * > * atomic_set_short(P, V) (*(u_short *)(P) |= (V)) > * atomic_clear_short(P, V) (*(u_short *)(P) &= ~(V)) > * atomic_add_short(P, V) (*(u_short *)(P) += (V)) > * atomic_subtract_short(P, V) (*(u_short *)(P) -= (V)) > * > * atomic_set_int(P, V) (*(u_int *)(P) |= (V)) > * atomic_clear_int(P, V) (*(u_int *)(P) &= ~(V)) > * atomic_add_int(P, V) (*(u_int *)(P) += (V)) > * atomic_subtract_int(P, V) (*(u_int *)(P) -= (V)) > * atomic_swap_int(P, V) (return (*(u_int *)(P)); *(u_int *)(P) = (V);) > * atomic_readandclear_int(P) (return (*(u_int *)(P)); *(u_int *)(P) = 0;) > * > * atomic_set_long(P, V) (*(u_long *)(P) |= (V)) > * atomic_clear_long(P, V) (*(u_long *)(P) &= ~(V)) > * atomic_add_long(P, V) (*(u_long *)(P) += (V)) > * atomic_subtract_long(P, V) (*(u_long *)(P) -= (V)) > * atomic_swap_long(P, V) (return (*(u_long *)(P)); *(u_long *)(P) = (V);) > * atomic_readandclear_long(P) (return (*(u_long *)(P)); *(u_long *)(P) = 0;) > */ > >/* > * The above functions are expanded inline in the statically-linked > * kernel. Lock prefixes are generated if an SMP kernel is being > * built. > * > * Kernel modules call real functions which are built into the kernel. > * This allows kernel modules to be portable between UP and SMP systems. > */ >#if defined(KLD_MODULE) || !defined(__GNUCLIKE_ASM) >#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \ >void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v); \ >void atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v) > >int atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src); >int atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src); >u_int atomic_fetchadd_int(volatile u_int *p, u_int v); >u_long atomic_fetchadd_long(volatile u_long *p, u_long v); >int atomic_testandset_int(volatile u_int *p, u_int v); >int atomic_testandset_long(volatile u_long *p, u_int v); > >#define ATOMIC_LOAD(TYPE, LOP) \ >u_##TYPE atomic_load_acq_##TYPE(volatile u_##TYPE *p) >#define ATOMIC_STORE(TYPE) \ >void atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v) > >#else /* !KLD_MODULE && __GNUCLIKE_ASM */ ># 94 "./machine/atomic.h" > >/* > * For userland, always use lock prefixes so that the binaries will run > * on both SMP and !SMP systems. > */ >#if defined(SMP) || !defined(_KERNEL) >#define MPLOCKED "lock ; " >#else ># 102 "./machine/atomic.h" >#define MPLOCKED >#endif ># 104 "./machine/atomic.h" > >/* > * The assembly is volatilized to avoid code chunk removal by the compiler. > * GCC aggressively reorders operations and memory clobbering is necessary > * in order to avoid that for memory barriers. > */ >#define ATOMIC_ASM(NAME, TYPE, OP, CONS, V) \ >static __inline void \ >atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __asm __volatile(MPLOCKED OP \ > : "+m" (*p) \ > : CONS (V) \ > : "cc"); \ >} \ > \ >static __inline void \ >atomic_##NAME##_barr_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __asm __volatile(MPLOCKED OP \ > : "+m" (*p) \ > : CONS (V) \ > : "memory", "cc"); \ >} \ >struct __hack > >/* > * Atomic compare and set, used by the mutex functions > * > * if (*dst == expect) *dst = src (all 32 bit words) > * > * Returns 0 on failure, non-zero on success > */ > >static __inline int >atomic_cmpset_int(volatile u_int *dst, u_int expect, u_int src) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " cmpxchgl %3,%1 ; " > " sete %0 ; " > "# atomic_cmpset_int" > : "=q" (res), /* 0 */ > "+m" (*dst), /* 1 */ > "+a" (expect) /* 2 */ > : "r" (src) /* 3 */ > : "memory", "cc"); > return (res); >} > >static __inline int >atomic_cmpset_long(volatile u_long *dst, u_long expect, u_long src) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " cmpxchgq %3,%1 ; " > " sete %0 ; " > "# atomic_cmpset_long" > : "=q" (res), /* 0 */ > "+m" (*dst), /* 1 */ > "+a" (expect) /* 2 */ > : "r" (src) /* 3 */ > : "memory", "cc"); > return (res); >} > >/* > * Atomically add the value of v to the integer pointed to by p and return > * the previous value of *p. > */ >static __inline u_int >atomic_fetchadd_int(volatile u_int *p, u_int v) >{ > > __asm __volatile( > " " MPLOCKED " " > " xaddl %0,%1 ; " > "# atomic_fetchadd_int" > : "+r" (v), /* 0 */ > "+m" (*p) /* 1 */ > : : "cc"); > return (v); >} > >/* > * Atomically add the value of v to the long integer pointed to by p and return > * the previous value of *p. > */ >static __inline u_long >atomic_fetchadd_long(volatile u_long *p, u_long v) >{ > > __asm __volatile( > " " MPLOCKED " " > " xaddq %0,%1 ; " > "# atomic_fetchadd_long" > : "+r" (v), /* 0 */ > "+m" (*p) /* 1 */ > : : "cc"); > return (v); >} > >static __inline int >atomic_testandset_int(volatile u_int *p, u_int v) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " btsl %2,%1 ; " > " setc %0 ; " > "# atomic_testandset_int" > : "=q" (res), /* 0 */ > "+m" (*p) /* 1 */ > : "Ir" (v & 0x1f) /* 2 */ > : "cc"); > return (res); >} > >static __inline int >atomic_testandset_long(volatile u_long *p, u_int v) >{ > u_char res; > > __asm __volatile( > " " MPLOCKED " " > " btsq %2,%1 ; " > " setc %0 ; " > "# atomic_testandset_long" > : "=q" (res), /* 0 */ > "+m" (*p) /* 1 */ > : "Jr" ((u_long)(v & 0x3f)) /* 2 */ > : "cc"); > return (res); >} > >/* > * We assume that a = b will do atomic loads and stores. Due to the > * IA32 memory model, a simple store guarantees release semantics. > * > * However, loads may pass stores, so for atomic_load_acq we have to > * ensure a Store/Load barrier to do the load in SMP kernels. We use > * "lock cmpxchg" as recommended by the AMD Software Optimization > * Guide, and not mfence. For UP kernels, however, the cache of the > * single processor is always consistent, so we only need to take care > * of the compiler. > */ >#define ATOMIC_STORE(TYPE) \ >static __inline void \ >atomic_store_rel_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\ >{ \ > __compiler_membar(); \ > *p = v; \ >} \ >struct __hack > >#if defined(_KERNEL) && !defined(SMP) > >#define ATOMIC_LOAD(TYPE, LOP) \ >static __inline u_##TYPE \ >atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ >{ \ > u_##TYPE tmp; \ > \ > tmp = *p; \ > __compiler_membar(); \ > return (tmp); \ >} \ >struct __hack > >#else /* !(_KERNEL && !SMP) */ ># 279 "./machine/atomic.h" > >#define ATOMIC_LOAD(TYPE, LOP) \ >static __inline u_##TYPE \ >atomic_load_acq_##TYPE(volatile u_##TYPE *p) \ >{ \ > u_##TYPE res; \ > \ > __asm __volatile(MPLOCKED LOP \ > : "=a" (res), /* 0 */ \ > "+m" (*p) /* 1 */ \ > : : "memory", "cc"); \ > return (res); \ >} \ >struct __hack > >#endif /* _KERNEL && !SMP */ ># 295 "./machine/atomic.h" > >#endif /* KLD_MODULE || !__GNUCLIKE_ASM */ ># 297 "./machine/atomic.h" > >ATOMIC_ASM(set, char, "orb %b1,%0", "iq", v); >ATOMIC_ASM(clear, char, "andb %b1,%0", "iq", ~v); >ATOMIC_ASM(add, char, "addb %b1,%0", "iq", v); >ATOMIC_ASM(subtract, char, "subb %b1,%0", "iq", v); > >ATOMIC_ASM(set, short, "orw %w1,%0", "ir", v); >ATOMIC_ASM(clear, short, "andw %w1,%0", "ir", ~v); >ATOMIC_ASM(add, short, "addw %w1,%0", "ir", v); >ATOMIC_ASM(subtract, short, "subw %w1,%0", "ir", v); > >ATOMIC_ASM(set, int, "orl %1,%0", "ir", v); >ATOMIC_ASM(clear, int, "andl %1,%0", "ir", ~v); >ATOMIC_ASM(add, int, "addl %1,%0", "ir", v); >ATOMIC_ASM(subtract, int, "subl %1,%0", "ir", v); > >ATOMIC_ASM(set, long, "orq %1,%0", "ir", v); >ATOMIC_ASM(clear, long, "andq %1,%0", "ir", ~v); >ATOMIC_ASM(add, long, "addq %1,%0", "ir", v); >ATOMIC_ASM(subtract, long, "subq %1,%0", "ir", v); > >ATOMIC_LOAD(char, "cmpxchgb %b0,%1"); >ATOMIC_LOAD(short, "cmpxchgw %w0,%1"); >ATOMIC_LOAD(int, "cmpxchgl %0,%1"); >ATOMIC_LOAD(long, "cmpxchgq %0,%1"); > >ATOMIC_STORE(char); >ATOMIC_STORE(short); >ATOMIC_STORE(int); >ATOMIC_STORE(long); > >#undef ATOMIC_ASM >#undef ATOMIC_LOAD >#undef ATOMIC_STORE > >#ifndef WANT_FUNCTIONS > >/* Read the current value and store a new value in the destination. */ >#ifdef __GNUCLIKE_ASM > >static __inline u_int >atomic_swap_int(volatile u_int *p, u_int v) >{ > > __asm __volatile( > " xchgl %1,%0 ; " > "# atomic_swap_int" > : "+r" (v), /* 0 */ > "+m" (*p)); /* 1 */ > return (v); >} > >static __inline u_long >atomic_swap_long(volatile u_long *p, u_long v) >{ > > __asm __volatile( > " xchgq %1,%0 ; " > "# atomic_swap_long" > : "+r" (v), /* 0 */ > "+m" (*p)); /* 1 */ > return (v); >} > >#else /* !__GNUCLIKE_ASM */ ># 362 "./machine/atomic.h" > >u_int atomic_swap_int(volatile u_int *p, u_int v); >u_long atomic_swap_long(volatile u_long *p, u_long v); > >#endif /* __GNUCLIKE_ASM */ ># 367 "./machine/atomic.h" > >#define atomic_set_acq_char atomic_set_barr_char >#define atomic_set_rel_char atomic_set_barr_char >#define atomic_clear_acq_char atomic_clear_barr_char >#define atomic_clear_rel_char atomic_clear_barr_char >#define atomic_add_acq_char atomic_add_barr_char >#define atomic_add_rel_char atomic_add_barr_char >#define atomic_subtract_acq_char atomic_subtract_barr_char >#define atomic_subtract_rel_char atomic_subtract_barr_char > >#define atomic_set_acq_short atomic_set_barr_short >#define atomic_set_rel_short atomic_set_barr_short >#define atomic_clear_acq_short atomic_clear_barr_short >#define atomic_clear_rel_short atomic_clear_barr_short >#define atomic_add_acq_short atomic_add_barr_short >#define atomic_add_rel_short atomic_add_barr_short >#define atomic_subtract_acq_short atomic_subtract_barr_short >#define atomic_subtract_rel_short atomic_subtract_barr_short > >#define atomic_set_acq_int atomic_set_barr_int >#define atomic_set_rel_int atomic_set_barr_int >#define atomic_clear_acq_int atomic_clear_barr_int >#define atomic_clear_rel_int atomic_clear_barr_int >#define atomic_add_acq_int atomic_add_barr_int >#define atomic_add_rel_int atomic_add_barr_int >#define atomic_subtract_acq_int atomic_subtract_barr_int >#define atomic_subtract_rel_int atomic_subtract_barr_int >#define atomic_cmpset_acq_int atomic_cmpset_int >#define atomic_cmpset_rel_int atomic_cmpset_int > >#define atomic_set_acq_long atomic_set_barr_long >#define atomic_set_rel_long atomic_set_barr_long >#define atomic_clear_acq_long atomic_clear_barr_long >#define atomic_clear_rel_long atomic_clear_barr_long >#define atomic_add_acq_long atomic_add_barr_long >#define atomic_add_rel_long atomic_add_barr_long >#define atomic_subtract_acq_long atomic_subtract_barr_long >#define atomic_subtract_rel_long atomic_subtract_barr_long >#define atomic_cmpset_acq_long atomic_cmpset_long >#define atomic_cmpset_rel_long atomic_cmpset_long > >#define atomic_readandclear_int(p) atomic_swap_int(p, 0) >#define atomic_readandclear_long(p) atomic_swap_long(p, 0) > >/* Operations on 8-bit bytes. */ >#define atomic_set_8 atomic_set_char >#define atomic_set_acq_8 atomic_set_acq_char >#define atomic_set_rel_8 atomic_set_rel_char >#define atomic_clear_8 atomic_clear_char >#define atomic_clear_acq_8 atomic_clear_acq_char >#define atomic_clear_rel_8 atomic_clear_rel_char >#define atomic_add_8 atomic_add_char >#define atomic_add_acq_8 atomic_add_acq_char >#define atomic_add_rel_8 atomic_add_rel_char >#define atomic_subtract_8 atomic_subtract_char >#define atomic_subtract_acq_8 atomic_subtract_acq_char >#define atomic_subtract_rel_8 atomic_subtract_rel_char >#define atomic_load_acq_8 atomic_load_acq_char >#define atomic_store_rel_8 atomic_store_rel_char > >/* Operations on 16-bit words. */ >#define atomic_set_16 atomic_set_short >#define atomic_set_acq_16 atomic_set_acq_short >#define atomic_set_rel_16 atomic_set_rel_short >#define atomic_clear_16 atomic_clear_short >#define atomic_clear_acq_16 atomic_clear_acq_short >#define atomic_clear_rel_16 atomic_clear_rel_short >#define atomic_add_16 atomic_add_short >#define atomic_add_acq_16 atomic_add_acq_short >#define atomic_add_rel_16 atomic_add_rel_short >#define atomic_subtract_16 atomic_subtract_short >#define atomic_subtract_acq_16 atomic_subtract_acq_short >#define atomic_subtract_rel_16 atomic_subtract_rel_short >#define atomic_load_acq_16 atomic_load_acq_short >#define atomic_store_rel_16 atomic_store_rel_short > >/* Operations on 32-bit double words. */ >#define atomic_set_32 atomic_set_int >#define atomic_set_acq_32 atomic_set_acq_int >#define atomic_set_rel_32 atomic_set_rel_int >#define atomic_clear_32 atomic_clear_int >#define atomic_clear_acq_32 atomic_clear_acq_int >#define atomic_clear_rel_32 atomic_clear_rel_int >#define atomic_add_32 atomic_add_int >#define atomic_add_acq_32 atomic_add_acq_int >#define atomic_add_rel_32 atomic_add_rel_int >#define atomic_subtract_32 atomic_subtract_int >#define atomic_subtract_acq_32 atomic_subtract_acq_int >#define atomic_subtract_rel_32 atomic_subtract_rel_int >#define atomic_load_acq_32 atomic_load_acq_int >#define atomic_store_rel_32 atomic_store_rel_int >#define atomic_cmpset_32 atomic_cmpset_int >#define atomic_cmpset_acq_32 atomic_cmpset_acq_int >#define atomic_cmpset_rel_32 atomic_cmpset_rel_int >#define atomic_swap_32 atomic_swap_int >#define atomic_readandclear_32 atomic_readandclear_int >#define atomic_fetchadd_32 atomic_fetchadd_int >#define atomic_testandset_32 atomic_testandset_int > >/* Operations on 64-bit quad words. */ >#define atomic_set_64 atomic_set_long >#define atomic_set_acq_64 atomic_set_acq_long >#define atomic_set_rel_64 atomic_set_rel_long >#define atomic_clear_64 atomic_clear_long >#define atomic_clear_acq_64 atomic_clear_acq_long >#define atomic_clear_rel_64 atomic_clear_rel_long >#define atomic_add_64 atomic_add_long >#define atomic_add_acq_64 atomic_add_acq_long >#define atomic_add_rel_64 atomic_add_rel_long >#define atomic_subtract_64 atomic_subtract_long >#define atomic_subtract_acq_64 atomic_subtract_acq_long >#define atomic_subtract_rel_64 atomic_subtract_rel_long >#define atomic_load_acq_64 atomic_load_acq_long >#define atomic_store_rel_64 atomic_store_rel_long >#define atomic_cmpset_64 atomic_cmpset_long >#define atomic_cmpset_acq_64 atomic_cmpset_acq_long >#define atomic_cmpset_rel_64 atomic_cmpset_rel_long >#define atomic_swap_64 atomic_swap_long >#define atomic_readandclear_64 atomic_readandclear_long >#define atomic_testandset_64 atomic_testandset_long > >/* Operations on pointers. */ >#define atomic_set_ptr atomic_set_long >#define atomic_set_acq_ptr atomic_set_acq_long >#define atomic_set_rel_ptr atomic_set_rel_long >#define atomic_clear_ptr atomic_clear_long >#define atomic_clear_acq_ptr atomic_clear_acq_long >#define atomic_clear_rel_ptr atomic_clear_rel_long >#define atomic_add_ptr atomic_add_long >#define atomic_add_acq_ptr atomic_add_acq_long >#define atomic_add_rel_ptr atomic_add_rel_long >#define atomic_subtract_ptr atomic_subtract_long >#define atomic_subtract_acq_ptr atomic_subtract_acq_long >#define atomic_subtract_rel_ptr atomic_subtract_rel_long >#define atomic_load_acq_ptr atomic_load_acq_long >#define atomic_store_rel_ptr atomic_store_rel_long >#define atomic_cmpset_ptr atomic_cmpset_long >#define atomic_cmpset_acq_ptr atomic_cmpset_acq_long >#define atomic_cmpset_rel_ptr atomic_cmpset_rel_long >#define atomic_swap_ptr atomic_swap_long >#define atomic_readandclear_ptr atomic_readandclear_long > >#endif /* !WANT_FUNCTIONS */ ># 510 "./machine/atomic.h" > >#endif /* !_MACHINE_ATOMIC_H_ */ ># 512 "./machine/atomic.h" ># 42 "/usr/src/ifnet/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/systm.h" ># 1 "./machine/cpufunc.h" 1 >/*- > * Copyright (c) 2003 Peter Wemm. > * Copyright (c) 1993 The Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/amd64/include/cpufunc.h 278931 2015-02-18 03:02:03Z glebius $ > */ > >/* > * Functions to provide access to special i386 instructions. > * This in included in sys/systm.h, and that file should be > * used in preference to this. > */ > >#ifndef _MACHINE_CPUFUNC_H_ >#define _MACHINE_CPUFUNC_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 45 "./machine/cpufunc.h" > >struct region_descriptor; > >#define readb(va) (*(volatile uint8_t *) (va)) >#define readw(va) (*(volatile uint16_t *) (va)) >#define readl(va) (*(volatile uint32_t *) (va)) >#define readq(va) (*(volatile uint64_t *) (va)) > >#define writeb(va, d) (*(volatile uint8_t *) (va) = (d)) >#define writew(va, d) (*(volatile uint16_t *) (va) = (d)) >#define writel(va, d) (*(volatile uint32_t *) (va) = (d)) >#define writeq(va, d) (*(volatile uint64_t *) (va) = (d)) > >#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE) > >static __inline void >breakpoint(void) >{ > __asm __volatile("int $3"); >} > >static __inline u_int >bsfl(u_int mask) >{ > u_int result; > > __asm __volatile("bsfl %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_long >bsfq(u_long mask) >{ > u_long result; > > __asm __volatile("bsfq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_int >bsrl(u_int mask) >{ > u_int result; > > __asm __volatile("bsrl %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline u_long >bsrq(u_long mask) >{ > u_long result; > > __asm __volatile("bsrq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline void >clflush(u_long addr) >{ > > __asm __volatile("clflush %0" : : "m" (*(char *)addr)); >} > >static __inline void >clts(void) >{ > > __asm __volatile("clts"); >} > >static __inline void >disable_intr(void) >{ > __asm __volatile("cli" : : : "memory"); >} > >static __inline void >do_cpuid(u_int ax, u_int *p) >{ > __asm __volatile("cpuid" > : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) > : "0" (ax)); >} > >static __inline void >cpuid_count(u_int ax, u_int cx, u_int *p) >{ > __asm __volatile("cpuid" > : "=a" (p[0]), "=b" (p[1]), "=c" (p[2]), "=d" (p[3]) > : "0" (ax), "c" (cx)); >} > >static __inline void >enable_intr(void) >{ > __asm __volatile("sti"); >} > >#ifdef _KERNEL > >#define HAVE_INLINE_FFS >#define ffs(x) __builtin_ffs(x) > >#define HAVE_INLINE_FFSL > >static __inline int >ffsl(long mask) >{ > return (mask == 0 ? mask : (int)bsfq((u_long)mask) + 1); >} > >#define HAVE_INLINE_FFSLL > >static __inline int >ffsll(long long mask) >{ > return (ffsl((long)mask)); >} > >#define HAVE_INLINE_FLS > >static __inline int >fls(int mask) >{ > return (mask == 0 ? mask : (int)bsrl((u_int)mask) + 1); >} > >#define HAVE_INLINE_FLSL > >static __inline int >flsl(long mask) >{ > return (mask == 0 ? mask : (int)bsrq((u_long)mask) + 1); >} > >#define HAVE_INLINE_FLSLL > >static __inline int >flsll(long long mask) >{ > return (flsl((long)mask)); >} > >#endif /* _KERNEL */ ># 190 "./machine/cpufunc.h" > >static __inline void >halt(void) >{ > __asm __volatile("hlt"); >} > >static __inline u_char >inb(u_int port) >{ > u_char data; > > __asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline u_int >inl(u_int port) >{ > u_int data; > > __asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline void >insb(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insb" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >insw(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insw" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >insl(u_int port, void *addr, size_t count) >{ > __asm __volatile("cld; rep; insl" > : "+D" (addr), "+c" (count) > : "d" (port) > : "memory"); >} > >static __inline void >invd(void) >{ > __asm __volatile("invd"); >} > >static __inline u_short >inw(u_int port) >{ > u_short data; > > __asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port)); > return (data); >} > >static __inline void >outb(u_int port, u_char data) >{ > __asm __volatile("outb %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline void >outl(u_int port, u_int data) >{ > __asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline void >outsb(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsb" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outsw(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsw" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outsl(u_int port, const void *addr, size_t count) >{ > __asm __volatile("cld; rep; outsl" > : "+S" (addr), "+c" (count) > : "d" (port)); >} > >static __inline void >outw(u_int port, u_short data) >{ > __asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port)); >} > >static __inline u_long >popcntq(u_long mask) >{ > u_long result; > > __asm __volatile("popcntq %1,%0" : "=r" (result) : "rm" (mask)); > return (result); >} > >static __inline void >lfence(void) >{ > > __asm __volatile("lfence" : : : "memory"); >} > >static __inline void >mfence(void) >{ > > __asm __volatile("mfence" : : : "memory"); >} > >static __inline void >ia32_pause(void) >{ > __asm __volatile("pause"); >} > >static __inline u_long >read_rflags(void) >{ > u_long rf; > > __asm __volatile("pushfq; popq %0" : "=r" (rf)); > return (rf); >} > >static __inline uint64_t >rdmsr(u_int msr) >{ > uint32_t low, high; > > __asm __volatile("rdmsr" : "=a" (low), "=d" (high) : "c" (msr)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint32_t >rdmsr32(u_int msr) >{ > uint32_t low; > > __asm __volatile("rdmsr" : "=a" (low) : "c" (msr) : "rdx"); > return (low); >} > >static __inline uint64_t >rdpmc(u_int pmc) >{ > uint32_t low, high; > > __asm __volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (pmc)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint64_t >rdtsc(void) >{ > uint32_t low, high; > > __asm __volatile("rdtsc" : "=a" (low), "=d" (high)); > return (low | ((uint64_t)high << 32)); >} > >static __inline uint32_t >rdtsc32(void) >{ > uint32_t rv; > > __asm __volatile("rdtsc" : "=a" (rv) : : "edx"); > return (rv); >} > >static __inline void >wbinvd(void) >{ > __asm __volatile("wbinvd"); >} > >static __inline void >write_rflags(u_long rf) >{ > __asm __volatile("pushq %0; popfq" : : "r" (rf)); >} > >static __inline void >wrmsr(u_int msr, uint64_t newval) >{ > uint32_t low, high; > > low = newval; > high = newval >> 32; > __asm __volatile("wrmsr" : : "a" (low), "d" (high), "c" (msr)); >} > >static __inline void >load_cr0(u_long data) >{ > > __asm __volatile("movq %0,%%cr0" : : "r" (data)); >} > >static __inline u_long >rcr0(void) >{ > u_long data; > > __asm __volatile("movq %%cr0,%0" : "=r" (data)); > return (data); >} > >static __inline u_long >rcr2(void) >{ > u_long data; > > __asm __volatile("movq %%cr2,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_cr3(u_long data) >{ > > __asm __volatile("movq %0,%%cr3" : : "r" (data) : "memory"); >} > >static __inline u_long >rcr3(void) >{ > u_long data; > > __asm __volatile("movq %%cr3,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_cr4(u_long data) >{ > __asm __volatile("movq %0,%%cr4" : : "r" (data)); >} > >static __inline u_long >rcr4(void) >{ > u_long data; > > __asm __volatile("movq %%cr4,%0" : "=r" (data)); > return (data); >} > >static __inline u_long >rxcr(u_int reg) >{ > u_int low, high; > > __asm __volatile("xgetbv" : "=a" (low), "=d" (high) : "c" (reg)); > return (low | ((uint64_t)high << 32)); >} > >static __inline void >load_xcr(u_int reg, u_long val) >{ > u_int low, high; > > low = val; > high = val >> 32; > __asm __volatile("xsetbv" : : "c" (reg), "a" (low), "d" (high)); >} > >/* > * Global TLB flush (except for thise for pages marked PG_G) > */ >static __inline void >invltlb(void) >{ > > load_cr3(rcr3()); >} > >#ifndef CR4_PGE >#define CR4_PGE 0x00000080 /* Page global enable */ >#endif ># 492 "./machine/cpufunc.h" > >/* > * Perform the guaranteed invalidation of all TLB entries. This > * includes the global entries, and entries in all PCIDs, not only the > * current context. The function works both on non-PCID CPUs and CPUs > * with the PCID turned off or on. See IA-32 SDM Vol. 3a 4.10.4.1 > * Operations that Invalidate TLBs and Paging-Structure Caches. > */ >static __inline void >invltlb_globpcid(void) >{ > uint64_t cr4; > > cr4 = rcr4(); > load_cr4(cr4 & ~CR4_PGE); > /* > * Although preemption at this point could be detrimental to > * performance, it would not lead to an error. PG_G is simply > * ignored if CR4.PGE is clear. Moreover, in case this block > * is re-entered, the load_cr4() either above or below will > * modify CR4.PGE flushing the TLB. > */ > load_cr4(cr4 | CR4_PGE); >} > >/* > * TLB flush for an individual page (even if it has PG_G). > * Only works on 486+ CPUs (i386 does not have PG_G). > */ >static __inline void >invlpg(u_long addr) >{ > > __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory"); >} > >#define INVPCID_ADDR 0 >#define INVPCID_CTX 1 >#define INVPCID_CTXGLOB 2 >#define INVPCID_ALLCTX 3 > >struct invpcid_descr { > uint64_t pcid:12 __packed; > uint64_t pad:52 __packed; > uint64_t addr; >} __packed; > >static __inline void >invpcid(struct invpcid_descr *d, int type) >{ > > /* invpcid (%rdx),%rax */ > __asm __volatile(".byte 0x66,0x0f,0x38,0x82,0x02" > : : "d" (d), "a" ((u_long)type) : "memory"); >} > >static __inline u_short >rfs(void) >{ > u_short sel; > __asm __volatile("movw %%fs,%0" : "=rm" (sel)); > return (sel); >} > >static __inline u_short >rgs(void) >{ > u_short sel; > __asm __volatile("movw %%gs,%0" : "=rm" (sel)); > return (sel); >} > >static __inline u_short >rss(void) >{ > u_short sel; > __asm __volatile("movw %%ss,%0" : "=rm" (sel)); > return (sel); >} > >static __inline void >load_ds(u_short sel) >{ > __asm __volatile("movw %0,%%ds" : : "rm" (sel)); >} > >static __inline void >load_es(u_short sel) >{ > __asm __volatile("movw %0,%%es" : : "rm" (sel)); >} > >static __inline void >cpu_monitor(const void *addr, u_long extensions, u_int hints) >{ > > __asm __volatile("monitor" > : : "a" (addr), "c" (extensions), "d" (hints)); >} > >static __inline void >cpu_mwait(u_long extensions, u_int hints) >{ > > __asm __volatile("mwait" : : "a" (hints), "c" (extensions)); >} > >#ifdef _KERNEL >/* This is defined in <machine/specialreg.h> but is too painful to get to */ >#ifndef MSR_FSBASE >#define MSR_FSBASE 0xc0000100 >#endif ># 604 "./machine/cpufunc.h" >static __inline void >load_fs(u_short sel) >{ > /* Preserve the fsbase value across the selector load */ > __asm __volatile("rdmsr; movw %0,%%fs; wrmsr" > : : "rm" (sel), "c" (MSR_FSBASE) : "eax", "edx"); >} > >#ifndef MSR_GSBASE >#define MSR_GSBASE 0xc0000101 >#endif ># 615 "./machine/cpufunc.h" >static __inline void >load_gs(u_short sel) >{ > /* > * Preserve the gsbase value across the selector load. > * Note that we have to disable interrupts because the gsbase > * being trashed happens to be the kernel gsbase at the time. > */ > __asm __volatile("pushfq; cli; rdmsr; movw %0,%%gs; wrmsr; popfq" > : : "rm" (sel), "c" (MSR_GSBASE) : "eax", "edx"); >} >#else ># 627 "./machine/cpufunc.h" >/* Usable by userland */ >static __inline void >load_fs(u_short sel) >{ > __asm __volatile("movw %0,%%fs" : : "rm" (sel)); >} > >static __inline void >load_gs(u_short sel) >{ > __asm __volatile("movw %0,%%gs" : : "rm" (sel)); >} >#endif ># 640 "./machine/cpufunc.h" > >static __inline void >lidt(struct region_descriptor *addr) >{ > __asm __volatile("lidt (%0)" : : "r" (addr)); >} > >static __inline void >lldt(u_short sel) >{ > __asm __volatile("lldt %0" : : "r" (sel)); >} > >static __inline void >ltr(u_short sel) >{ > __asm __volatile("ltr %0" : : "r" (sel)); >} > >static __inline uint64_t >rdr0(void) >{ > uint64_t data; > __asm __volatile("movq %%dr0,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr0(uint64_t dr0) >{ > __asm __volatile("movq %0,%%dr0" : : "r" (dr0)); >} > >static __inline uint64_t >rdr1(void) >{ > uint64_t data; > __asm __volatile("movq %%dr1,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr1(uint64_t dr1) >{ > __asm __volatile("movq %0,%%dr1" : : "r" (dr1)); >} > >static __inline uint64_t >rdr2(void) >{ > uint64_t data; > __asm __volatile("movq %%dr2,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr2(uint64_t dr2) >{ > __asm __volatile("movq %0,%%dr2" : : "r" (dr2)); >} > >static __inline uint64_t >rdr3(void) >{ > uint64_t data; > __asm __volatile("movq %%dr3,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr3(uint64_t dr3) >{ > __asm __volatile("movq %0,%%dr3" : : "r" (dr3)); >} > >static __inline uint64_t >rdr4(void) >{ > uint64_t data; > __asm __volatile("movq %%dr4,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr4(uint64_t dr4) >{ > __asm __volatile("movq %0,%%dr4" : : "r" (dr4)); >} > >static __inline uint64_t >rdr5(void) >{ > uint64_t data; > __asm __volatile("movq %%dr5,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr5(uint64_t dr5) >{ > __asm __volatile("movq %0,%%dr5" : : "r" (dr5)); >} > >static __inline uint64_t >rdr6(void) >{ > uint64_t data; > __asm __volatile("movq %%dr6,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr6(uint64_t dr6) >{ > __asm __volatile("movq %0,%%dr6" : : "r" (dr6)); >} > >static __inline uint64_t >rdr7(void) >{ > uint64_t data; > __asm __volatile("movq %%dr7,%0" : "=r" (data)); > return (data); >} > >static __inline void >load_dr7(uint64_t dr7) >{ > __asm __volatile("movq %0,%%dr7" : : "r" (dr7)); >} > >static __inline register_t >intr_disable(void) >{ > register_t rflags; > > rflags = read_rflags(); > disable_intr(); > return (rflags); >} > >static __inline void >intr_restore(register_t rflags) >{ > write_rflags(rflags); >} > >#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */ ># 788 "./machine/cpufunc.h" > >int breakpoint(void); >u_int bsfl(u_int mask); >u_int bsrl(u_int mask); >void clflush(u_long addr); >void clts(void); >void cpuid_count(u_int ax, u_int cx, u_int *p); >void disable_intr(void); >void do_cpuid(u_int ax, u_int *p); >void enable_intr(void); >void halt(void); >void ia32_pause(void); >u_char inb(u_int port); >u_int inl(u_int port); >void insb(u_int port, void *addr, size_t count); >void insl(u_int port, void *addr, size_t count); >void insw(u_int port, void *addr, size_t count); >register_t intr_disable(void); >void intr_restore(register_t rf); >void invd(void); >void invlpg(u_int addr); >void invltlb(void); >u_short inw(u_int port); >void lidt(struct region_descriptor *addr); >void lldt(u_short sel); >void load_cr0(u_long cr0); >void load_cr3(u_long cr3); >void load_cr4(u_long cr4); >void load_dr0(uint64_t dr0); >void load_dr1(uint64_t dr1); >void load_dr2(uint64_t dr2); >void load_dr3(uint64_t dr3); >void load_dr4(uint64_t dr4); >void load_dr5(uint64_t dr5); >void load_dr6(uint64_t dr6); >void load_dr7(uint64_t dr7); >void load_fs(u_short sel); >void load_gs(u_short sel); >void ltr(u_short sel); >void outb(u_int port, u_char data); >void outl(u_int port, u_int data); >void outsb(u_int port, const void *addr, size_t count); >void outsl(u_int port, const void *addr, size_t count); >void outsw(u_int port, const void *addr, size_t count); >void outw(u_int port, u_short data); >u_long rcr0(void); >u_long rcr2(void); >u_long rcr3(void); >u_long rcr4(void); >uint64_t rdmsr(u_int msr); >uint32_t rdmsr32(u_int msr); >uint64_t rdpmc(u_int pmc); >uint64_t rdr0(void); >uint64_t rdr1(void); >uint64_t rdr2(void); >uint64_t rdr3(void); >uint64_t rdr4(void); >uint64_t rdr5(void); >uint64_t rdr6(void); >uint64_t rdr7(void); >uint64_t rdtsc(void); >u_long read_rflags(void); >u_int rfs(void); >u_int rgs(void); >void wbinvd(void); >void write_rflags(u_int rf); >void wrmsr(u_int msr, uint64_t newval); > >#endif /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */ ># 857 "./machine/cpufunc.h" > >void reset_dbregs(void); > >#ifdef _KERNEL >int rdmsr_safe(u_int msr, uint64_t *val); >int wrmsr_safe(u_int msr, uint64_t newval); >#endif ># 864 "./machine/cpufunc.h" > >#endif /* !_MACHINE_CPUFUNC_H_ */ ># 866 "./machine/cpufunc.h" ># 43 "/usr/src/ifnet/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/callout.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/sys/systm.h" ># 1 "/usr/src/ifnet/sys/sys/callout.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)callout.h 8.2 (Berkeley) 1/21/94 > * $FreeBSD: projects/ifnet/sys/sys/callout.h 281023 2015-04-03 13:57:14Z glebius $ > */ > >#ifndef _SYS_CALLOUT_H_ >#define _SYS_CALLOUT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_callout.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/callout.h" ># 1 "/usr/src/ifnet/sys/sys/_callout.h" 1 >/*- > * Copyright (c) 1990, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)callout.h 8.2 (Berkeley) 1/21/94 > * $FreeBSD: projects/ifnet/sys/sys/_callout.h 281023 2015-04-03 13:57:14Z glebius $ > */ > >#ifndef _SYS__CALLOUT_H >#define _SYS__CALLOUT_H > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/_callout.h" ># 1 "/usr/src/ifnet/sys/sys/queue.h" 1 >/*- > * Copyright (c) 1991, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)queue.h 8.5 (Berkeley) 8/20/94 > * $FreeBSD: projects/ifnet/sys/sys/queue.h 279386 2015-02-28 00:16:36Z glebius $ > */ > >#ifndef _SYS_QUEUE_H_ >#define _SYS_QUEUE_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/queue.h" ># 37 "/usr/src/ifnet/sys/sys/queue.h" > >/* > * This file defines four types of data structures: singly-linked lists, > * singly-linked tail queues, lists and tail queues. > * > * A singly-linked list is headed by a single forward pointer. The elements > * are singly linked for minimum space and pointer manipulation overhead at > * the expense of O(n) removal for arbitrary elements. New elements can be > * added to the list after an existing element or at the head of the list. > * Elements being removed from the head of the list should use the explicit > * macro for this purpose for optimum efficiency. A singly-linked list may > * only be traversed in the forward direction. Singly-linked lists are ideal > * for applications with large datasets and few or no removals or for > * implementing a LIFO queue. > * > * A singly-linked tail queue is headed by a pair of pointers, one to the > * head of the list and the other to the tail of the list. The elements are > * singly linked for minimum space and pointer manipulation overhead at the > * expense of O(n) removal for arbitrary elements. New elements can be added > * to the list after an existing element, at the head of the list, or at the > * end of the list. Elements being removed from the head of the tail queue > * should use the explicit macro for this purpose for optimum efficiency. > * A singly-linked tail queue may only be traversed in the forward direction. > * Singly-linked tail queues are ideal for applications with large datasets > * and few or no removals or for implementing a FIFO queue. > * > * A list is headed by a single forward pointer (or an array of forward > * pointers for a hash table header). The elements are doubly linked > * so that an arbitrary element can be removed without a need to > * traverse the list. New elements can be added to the list before > * or after an existing element or at the head of the list. A list > * may be traversed in either direction. > * > * A tail queue is headed by a pair of pointers, one to the head of the > * list and the other to the tail of the list. The elements are doubly > * linked so that an arbitrary element can be removed without a need to > * traverse the list. New elements can be added to the list before or > * after an existing element, at the head of the list, or at the end of > * the list. A tail queue may be traversed in either direction. > * > * For details on the use of these macros, see the queue(3) manual page. > * > * > * SLIST LIST STAILQ TAILQ > * _HEAD + + + + > * _HEAD_INITIALIZER + + + + > * _ENTRY + + + + > * _INIT + + + + > * _EMPTY + + + + > * _FIRST + + + + > * _NEXT + + + + > * _PREV - + - + > * _LAST - - + + > * _FOREACH + + + + > * _FOREACH_FROM + + + + > * _FOREACH_SAFE + + + + > * _FOREACH_FROM_SAFE + + + + > * _FOREACH_REVERSE - - - + > * _FOREACH_REVERSE_FROM - - - + > * _FOREACH_REVERSE_SAFE - - - + > * _FOREACH_REVERSE_FROM_SAFE - - - + > * _INSERT_HEAD + + + + > * _INSERT_BEFORE - + - + > * _INSERT_AFTER + + + + > * _INSERT_TAIL - - + + > * _CONCAT - - + + > * _REMOVE_AFTER + - + - > * _REMOVE_HEAD + - + - > * _REMOVE + + + + > * _SWAP + + + + > * > */ >#ifdef QUEUE_MACRO_DEBUG >/* Store the last 2 places the queue element or head was altered */ >struct qm_trace { > unsigned long lastline; > unsigned long prevline; > const char *lastfile; > const char *prevfile; >}; > >#define TRACEBUF struct qm_trace trace; >#define TRACEBUF_INITIALIZER { __LINE__, 0, __FILE__, NULL } , >#define TRASHIT(x) do {(x) = (void *)-1;} while (0) >#define QMD_SAVELINK(name, link) void **name = (void *)&(link) > >#define QMD_TRACE_HEAD(head) do { \ > (head)->trace.prevline = (head)->trace.lastline; \ > (head)->trace.prevfile = (head)->trace.lastfile; \ > (head)->trace.lastline = __LINE__; \ > (head)->trace.lastfile = __FILE__; \ >} while (0) > >#define QMD_TRACE_ELEM(elem) do { \ > (elem)->trace.prevline = (elem)->trace.lastline; \ > (elem)->trace.prevfile = (elem)->trace.lastfile; \ > (elem)->trace.lastline = __LINE__; \ > (elem)->trace.lastfile = __FILE__; \ >} while (0) > >#else ># 138 "/usr/src/ifnet/sys/sys/queue.h" >#define QMD_TRACE_ELEM(elem) >#define QMD_TRACE_HEAD(head) >#define QMD_SAVELINK(name, link) >#define TRACEBUF >#define TRACEBUF_INITIALIZER >#define TRASHIT(x) >#endif /* QUEUE_MACRO_DEBUG */ ># 145 "/usr/src/ifnet/sys/sys/queue.h" > >/* > * Singly-linked List declarations. > */ >#define SLIST_HEAD(name, type) \ >struct name { \ > struct type *slh_first; /* first element */ \ >} > >#define SLIST_HEAD_INITIALIZER(head) \ > { NULL } > >#define SLIST_ENTRY(type) \ >struct { \ > struct type *sle_next; /* next element */ \ >} > >/* > * Singly-linked List functions. > */ >#define SLIST_EMPTY(head) ((head)->slh_first == NULL) > >#define SLIST_FIRST(head) ((head)->slh_first) > >#define SLIST_FOREACH(var, head, field) \ > for ((var) = SLIST_FIRST((head)); \ > (var); \ > (var) = SLIST_NEXT((var), field)) > >#define SLIST_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ > (var); \ > (var) = SLIST_NEXT((var), field)) > >#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = SLIST_FIRST((head)); \ > (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define SLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : SLIST_FIRST((head))); \ > (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \ > for ((varp) = &SLIST_FIRST((head)); \ > ((var) = *(varp)) != NULL; \ > (varp) = &SLIST_NEXT((var), field)) > >#define SLIST_INIT(head) do { \ > SLIST_FIRST((head)) = NULL; \ >} while (0) > >#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ > SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \ > SLIST_NEXT((slistelm), field) = (elm); \ >} while (0) > >#define SLIST_INSERT_HEAD(head, elm, field) do { \ > SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \ > SLIST_FIRST((head)) = (elm); \ >} while (0) > >#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) > >#define SLIST_REMOVE(head, elm, type, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.sle_next); \ > if (SLIST_FIRST((head)) == (elm)) { \ > SLIST_REMOVE_HEAD((head), field); \ > } \ > else { \ > struct type *curelm = SLIST_FIRST((head)); \ > while (SLIST_NEXT(curelm, field) != (elm)) \ > curelm = SLIST_NEXT(curelm, field); \ > SLIST_REMOVE_AFTER(curelm, field); \ > } \ > TRASHIT(*oldnext); \ >} while (0) > >#define SLIST_REMOVE_AFTER(elm, field) do { \ > SLIST_NEXT(elm, field) = \ > SLIST_NEXT(SLIST_NEXT(elm, field), field); \ >} while (0) > >#define SLIST_REMOVE_HEAD(head, field) do { \ > SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \ >} while (0) > >#define SLIST_SWAP(head1, head2, type) do { \ > struct type *swap_first = SLIST_FIRST(head1); \ > SLIST_FIRST(head1) = SLIST_FIRST(head2); \ > SLIST_FIRST(head2) = swap_first; \ >} while (0) > >/* > * Singly-linked Tail queue declarations. > */ >#define STAILQ_HEAD(name, type) \ >struct name { \ > struct type *stqh_first;/* first element */ \ > struct type **stqh_last;/* addr of last next element */ \ >} > >#define STAILQ_HEAD_INITIALIZER(head) \ > { NULL, &(head).stqh_first } > >#define STAILQ_ENTRY(type) \ >struct { \ > struct type *stqe_next; /* next element */ \ >} > >/* > * Singly-linked Tail queue functions. > */ >#define STAILQ_CONCAT(head1, head2) do { \ > if (!STAILQ_EMPTY((head2))) { \ > *(head1)->stqh_last = (head2)->stqh_first; \ > (head1)->stqh_last = (head2)->stqh_last; \ > STAILQ_INIT((head2)); \ > } \ >} while (0) > >#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) > >#define STAILQ_FIRST(head) ((head)->stqh_first) > >#define STAILQ_FOREACH(var, head, field) \ > for((var) = STAILQ_FIRST((head)); \ > (var); \ > (var) = STAILQ_NEXT((var), field)) > >#define STAILQ_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ > (var); \ > (var) = STAILQ_NEXT((var), field)) > >#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = STAILQ_FIRST((head)); \ > (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define STAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : STAILQ_FIRST((head))); \ > (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define STAILQ_INIT(head) do { \ > STAILQ_FIRST((head)) = NULL; \ > (head)->stqh_last = &STAILQ_FIRST((head)); \ >} while (0) > >#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ > if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ > STAILQ_NEXT((tqelm), field) = (elm); \ >} while (0) > >#define STAILQ_INSERT_HEAD(head, elm, field) do { \ > if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ > STAILQ_FIRST((head)) = (elm); \ >} while (0) > >#define STAILQ_INSERT_TAIL(head, elm, field) do { \ > STAILQ_NEXT((elm), field) = NULL; \ > *(head)->stqh_last = (elm); \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ >} while (0) > >#define STAILQ_LAST(head, type, field) \ > (STAILQ_EMPTY((head)) ? NULL : \ > __containerof((head)->stqh_last, struct type, field.stqe_next)) > >#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) > >#define STAILQ_REMOVE(head, elm, type, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \ > if (STAILQ_FIRST((head)) == (elm)) { \ > STAILQ_REMOVE_HEAD((head), field); \ > } \ > else { \ > struct type *curelm = STAILQ_FIRST((head)); \ > while (STAILQ_NEXT(curelm, field) != (elm)) \ > curelm = STAILQ_NEXT(curelm, field); \ > STAILQ_REMOVE_AFTER(head, curelm, field); \ > } \ > TRASHIT(*oldnext); \ >} while (0) > >#define STAILQ_REMOVE_AFTER(head, elm, field) do { \ > if ((STAILQ_NEXT(elm, field) = \ > STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \ > (head)->stqh_last = &STAILQ_NEXT((elm), field); \ >} while (0) > >#define STAILQ_REMOVE_HEAD(head, field) do { \ > if ((STAILQ_FIRST((head)) = \ > STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \ > (head)->stqh_last = &STAILQ_FIRST((head)); \ >} while (0) > >#define STAILQ_SWAP(head1, head2, type) do { \ > struct type *swap_first = STAILQ_FIRST(head1); \ > struct type **swap_last = (head1)->stqh_last; \ > STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \ > (head1)->stqh_last = (head2)->stqh_last; \ > STAILQ_FIRST(head2) = swap_first; \ > (head2)->stqh_last = swap_last; \ > if (STAILQ_EMPTY(head1)) \ > (head1)->stqh_last = &STAILQ_FIRST(head1); \ > if (STAILQ_EMPTY(head2)) \ > (head2)->stqh_last = &STAILQ_FIRST(head2); \ >} while (0) > > >/* > * List declarations. > */ >#define LIST_HEAD(name, type) \ >struct name { \ > struct type *lh_first; /* first element */ \ >} > >#define LIST_HEAD_INITIALIZER(head) \ > { NULL } > >#define LIST_ENTRY(type) \ >struct { \ > struct type *le_next; /* next element */ \ > struct type **le_prev; /* address of previous next element */ \ >} > >/* > * List functions. > */ > >#if (defined(_KERNEL) && defined(INVARIANTS)) >#define QMD_LIST_CHECK_HEAD(head, field) do { \ > if (LIST_FIRST((head)) != NULL && \ > LIST_FIRST((head))->field.le_prev != \ > &LIST_FIRST((head))) \ > panic("Bad list head %p first->prev != head", (head)); \ >} while (0) > >#define QMD_LIST_CHECK_NEXT(elm, field) do { \ > if (LIST_NEXT((elm), field) != NULL && \ > LIST_NEXT((elm), field)->field.le_prev != \ > &((elm)->field.le_next)) \ > panic("Bad link elm %p next->prev != elm", (elm)); \ >} while (0) > >#define QMD_LIST_CHECK_PREV(elm, field) do { \ > if (*(elm)->field.le_prev != (elm)) \ > panic("Bad link elm %p prev->next != elm", (elm)); \ >} while (0) >#else ># 401 "/usr/src/ifnet/sys/sys/queue.h" >#define QMD_LIST_CHECK_HEAD(head, field) >#define QMD_LIST_CHECK_NEXT(elm, field) >#define QMD_LIST_CHECK_PREV(elm, field) >#endif /* (_KERNEL && INVARIANTS) */ ># 405 "/usr/src/ifnet/sys/sys/queue.h" > >#define LIST_EMPTY(head) ((head)->lh_first == NULL) > >#define LIST_FIRST(head) ((head)->lh_first) > >#define LIST_FOREACH(var, head, field) \ > for ((var) = LIST_FIRST((head)); \ > (var); \ > (var) = LIST_NEXT((var), field)) > >#define LIST_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ > (var); \ > (var) = LIST_NEXT((var), field)) > >#define LIST_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = LIST_FIRST((head)); \ > (var) && ((tvar) = LIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define LIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : LIST_FIRST((head))); \ > (var) && ((tvar) = LIST_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define LIST_INIT(head) do { \ > LIST_FIRST((head)) = NULL; \ >} while (0) > >#define LIST_INSERT_AFTER(listelm, elm, field) do { \ > QMD_LIST_CHECK_NEXT(listelm, field); \ > if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\ > LIST_NEXT((listelm), field)->field.le_prev = \ > &LIST_NEXT((elm), field); \ > LIST_NEXT((listelm), field) = (elm); \ > (elm)->field.le_prev = &LIST_NEXT((listelm), field); \ >} while (0) > >#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ > QMD_LIST_CHECK_PREV(listelm, field); \ > (elm)->field.le_prev = (listelm)->field.le_prev; \ > LIST_NEXT((elm), field) = (listelm); \ > *(listelm)->field.le_prev = (elm); \ > (listelm)->field.le_prev = &LIST_NEXT((elm), field); \ >} while (0) > >#define LIST_INSERT_HEAD(head, elm, field) do { \ > QMD_LIST_CHECK_HEAD((head), field); \ > if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \ > LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\ > LIST_FIRST((head)) = (elm); \ > (elm)->field.le_prev = &LIST_FIRST((head)); \ >} while (0) > >#define LIST_NEXT(elm, field) ((elm)->field.le_next) > >#define LIST_PREV(elm, head, type, field) \ > ((elm)->field.le_prev == &LIST_FIRST((head)) ? NULL : \ > __containerof((elm)->field.le_prev, struct type, field.le_next)) > >#define LIST_REMOVE(elm, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.le_next); \ > QMD_SAVELINK(oldprev, (elm)->field.le_prev); \ > QMD_LIST_CHECK_NEXT(elm, field); \ > QMD_LIST_CHECK_PREV(elm, field); \ > if (LIST_NEXT((elm), field) != NULL) \ > LIST_NEXT((elm), field)->field.le_prev = \ > (elm)->field.le_prev; \ > *(elm)->field.le_prev = LIST_NEXT((elm), field); \ > TRASHIT(*oldnext); \ > TRASHIT(*oldprev); \ >} while (0) > >#define LIST_SWAP(head1, head2, type, field) do { \ > struct type *swap_tmp = LIST_FIRST((head1)); \ > LIST_FIRST((head1)) = LIST_FIRST((head2)); \ > LIST_FIRST((head2)) = swap_tmp; \ > if ((swap_tmp = LIST_FIRST((head1))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head1)); \ > if ((swap_tmp = LIST_FIRST((head2))) != NULL) \ > swap_tmp->field.le_prev = &LIST_FIRST((head2)); \ >} while (0) > >/* > * Tail queue declarations. > */ >#define TAILQ_HEAD(name, type) \ >struct name { \ > struct type *tqh_first; /* first element */ \ > struct type **tqh_last; /* addr of last next element */ \ > TRACEBUF \ >} > >#define TAILQ_HEAD_INITIALIZER(head) \ > { NULL, &(head).tqh_first, TRACEBUF_INITIALIZER } > >#define TAILQ_ENTRY(type) \ >struct { \ > struct type *tqe_next; /* next element */ \ > struct type **tqe_prev; /* address of previous next element */ \ > TRACEBUF \ >} > >/* > * Tail queue functions. > */ >#if (defined(_KERNEL) && defined(INVARIANTS)) >#define QMD_TAILQ_CHECK_HEAD(head, field) do { \ > if (!TAILQ_EMPTY(head) && \ > TAILQ_FIRST((head))->field.tqe_prev != \ > &TAILQ_FIRST((head))) \ > panic("Bad tailq head %p first->prev != head", (head)); \ >} while (0) > >#define QMD_TAILQ_CHECK_TAIL(head, field) do { \ > if (*(head)->tqh_last != NULL) \ > panic("Bad tailq NEXT(%p->tqh_last) != NULL", (head)); \ >} while (0) > >#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \ > if (TAILQ_NEXT((elm), field) != NULL && \ > TAILQ_NEXT((elm), field)->field.tqe_prev != \ > &((elm)->field.tqe_next)) \ > panic("Bad link elm %p next->prev != elm", (elm)); \ >} while (0) > >#define QMD_TAILQ_CHECK_PREV(elm, field) do { \ > if (*(elm)->field.tqe_prev != (elm)) \ > panic("Bad link elm %p prev->next != elm", (elm)); \ >} while (0) >#else ># 536 "/usr/src/ifnet/sys/sys/queue.h" >#define QMD_TAILQ_CHECK_HEAD(head, field) >#define QMD_TAILQ_CHECK_TAIL(head, headname) >#define QMD_TAILQ_CHECK_NEXT(elm, field) >#define QMD_TAILQ_CHECK_PREV(elm, field) >#endif /* (_KERNEL && INVARIANTS) */ ># 541 "/usr/src/ifnet/sys/sys/queue.h" > >#define TAILQ_CONCAT(head1, head2, field) do { \ > if (!TAILQ_EMPTY(head2)) { \ > *(head1)->tqh_last = (head2)->tqh_first; \ > (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ > (head1)->tqh_last = (head2)->tqh_last; \ > TAILQ_INIT((head2)); \ > QMD_TRACE_HEAD(head1); \ > QMD_TRACE_HEAD(head2); \ > } \ >} while (0) > >#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) > >#define TAILQ_FIRST(head) ((head)->tqh_first) > >#define TAILQ_FOREACH(var, head, field) \ > for ((var) = TAILQ_FIRST((head)); \ > (var); \ > (var) = TAILQ_NEXT((var), field)) > >#define TAILQ_FOREACH_FROM(var, head, field) \ > for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ > (var); \ > (var) = TAILQ_NEXT((var), field)) > >#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ > for ((var) = TAILQ_FIRST((head)); \ > (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ > for ((var) = ((var) ? (var) : TAILQ_FIRST((head))); \ > (var) && ((tvar) = TAILQ_NEXT((var), field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ > for ((var) = TAILQ_LAST((head), headname); \ > (var); \ > (var) = TAILQ_PREV((var), headname, field)) > >#define TAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ > for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ > (var); \ > (var) = TAILQ_PREV((var), headname, field)) > >#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ > for ((var) = TAILQ_LAST((head), headname); \ > (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ > (var) = (tvar)) > >#define TAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ > for ((var) = ((var) ? (var) : TAILQ_LAST((head), headname)); \ > (var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \ > (var) = (tvar)) > >#define TAILQ_INIT(head) do { \ > TAILQ_FIRST((head)) = NULL; \ > (head)->tqh_last = &TAILQ_FIRST((head)); \ > QMD_TRACE_HEAD(head); \ >} while (0) > >#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ > QMD_TAILQ_CHECK_NEXT(listelm, field); \ > if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\ > TAILQ_NEXT((elm), field)->field.tqe_prev = \ > &TAILQ_NEXT((elm), field); \ > else { \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_HEAD(head); \ > } \ > TAILQ_NEXT((listelm), field) = (elm); \ > (elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \ > QMD_TRACE_ELEM(&(elm)->field); \ > QMD_TRACE_ELEM(&(listelm)->field); \ >} while (0) > >#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ > QMD_TAILQ_CHECK_PREV(listelm, field); \ > (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ > TAILQ_NEXT((elm), field) = (listelm); \ > *(listelm)->field.tqe_prev = (elm); \ > (listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_ELEM(&(elm)->field); \ > QMD_TRACE_ELEM(&(listelm)->field); \ >} while (0) > >#define TAILQ_INSERT_HEAD(head, elm, field) do { \ > QMD_TAILQ_CHECK_HEAD(head, field); \ > if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \ > TAILQ_FIRST((head))->field.tqe_prev = \ > &TAILQ_NEXT((elm), field); \ > else \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > TAILQ_FIRST((head)) = (elm); \ > (elm)->field.tqe_prev = &TAILQ_FIRST((head)); \ > QMD_TRACE_HEAD(head); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_INSERT_TAIL(head, elm, field) do { \ > QMD_TAILQ_CHECK_TAIL(head, field); \ > TAILQ_NEXT((elm), field) = NULL; \ > (elm)->field.tqe_prev = (head)->tqh_last; \ > *(head)->tqh_last = (elm); \ > (head)->tqh_last = &TAILQ_NEXT((elm), field); \ > QMD_TRACE_HEAD(head); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_LAST(head, headname) \ > (*(((struct headname *)((head)->tqh_last))->tqh_last)) > >#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) > >#define TAILQ_PREV(elm, headname, field) \ > (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) > >#define TAILQ_REMOVE(head, elm, field) do { \ > QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \ > QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \ > QMD_TAILQ_CHECK_NEXT(elm, field); \ > QMD_TAILQ_CHECK_PREV(elm, field); \ > if ((TAILQ_NEXT((elm), field)) != NULL) \ > TAILQ_NEXT((elm), field)->field.tqe_prev = \ > (elm)->field.tqe_prev; \ > else { \ > (head)->tqh_last = (elm)->field.tqe_prev; \ > QMD_TRACE_HEAD(head); \ > } \ > *(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \ > TRASHIT(*oldnext); \ > TRASHIT(*oldprev); \ > QMD_TRACE_ELEM(&(elm)->field); \ >} while (0) > >#define TAILQ_SWAP(head1, head2, type, field) do { \ > struct type *swap_first = (head1)->tqh_first; \ > struct type **swap_last = (head1)->tqh_last; \ > (head1)->tqh_first = (head2)->tqh_first; \ > (head1)->tqh_last = (head2)->tqh_last; \ > (head2)->tqh_first = swap_first; \ > (head2)->tqh_last = swap_last; \ > if ((swap_first = (head1)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head1)->tqh_first; \ > else \ > (head1)->tqh_last = &(head1)->tqh_first; \ > if ((swap_first = (head2)->tqh_first) != NULL) \ > swap_first->field.tqe_prev = &(head2)->tqh_first; \ > else \ > (head2)->tqh_last = &(head2)->tqh_first; \ >} while (0) > >#endif /* !_SYS_QUEUE_H_ */ ># 695 "/usr/src/ifnet/sys/sys/queue.h" ># 42 "/usr/src/ifnet/sys/sys/_callout.h" 2 > >struct lock_object; > >LIST_HEAD(callout_list, callout); >SLIST_HEAD(callout_slist, callout); >TAILQ_HEAD(callout_tailq, callout); > >struct callout { > union { > LIST_ENTRY(callout) le; > SLIST_ENTRY(callout) sle; > TAILQ_ENTRY(callout) tqe; > } c_links; > sbintime_t c_time; /* ticks to the event */ > sbintime_t c_precision; /* delta allowed wrt opt */ > void *c_arg; /* function argument */ > void (*c_func)(void *); /* function to call */ > struct lock_object *c_lock; /* lock to handle */ > short c_flags; /* User State */ > short c_iflags; /* Internal State */ > volatile int c_cpu; /* CPU we're scheduled on */ >}; > >#endif ># 66 "/usr/src/ifnet/sys/sys/_callout.h" ># 42 "/usr/src/ifnet/sys/sys/callout.h" 2 > >#define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */ >#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */ >#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */ >#define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */ >#define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */ >#define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */ >#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */ >#define CALLOUT_PROCESSED 0x0080 /* callout in wheel or processing list? */ >#define CALLOUT_DIRECT 0x0100 /* allow exec from hw int context */ > >#define C_DIRECT_EXEC 0x0001 /* direct execution of callout */ >#define C_PRELBITS 7 >#define C_PRELRANGE ((1 << C_PRELBITS) - 1) >#define C_PREL(x) (((x) + 1) << 1) >#define C_PRELGET(x) (int)((((x) >> 1) & C_PRELRANGE) - 1) >#define C_HARDCLOCK 0x0100 /* align to hardclock() calls */ >#define C_ABSOLUTE 0x0200 /* event time is absolute. */ > >struct callout_handle { > struct callout *callout; >}; > >#ifdef _KERNEL >/* > * Note the flags field is actually *two* fields. The c_flags > * field is the one that caller operations that may, or may not have > * a lock touches i.e. callout_deactivate(). The other, the c_iflags, > * is the internal flags that *must* be kept correct on which the > * callout system depend on e.g. callout_pending(). > * The c_iflag is used internally by the callout system to determine which > * list the callout is on and track internal state. Callers *should not* > * use the c_flags field directly but should use the macros provided. > * > * The c_iflags field holds internal flags that are protected by internal > * locks of the callout subsystem. The c_flags field holds external flags. > * The caller must hold its own lock while manipulating or reading external > * flags via callout_active(), callout_deactivate(), callout_reset*(), or > * callout_stop() to avoid races. > */ >#define callout_active(c) ((c)->c_flags & CALLOUT_ACTIVE) >#define callout_deactivate(c) ((c)->c_flags &= ~CALLOUT_ACTIVE) >#define callout_drain(c) _callout_stop_safe(c, 1) >void callout_init(struct callout *, int); >void _callout_init_lock(struct callout *, struct lock_object *, int); >#define callout_init_mtx(c, mtx, flags) \ > _callout_init_lock((c), ((mtx) != NULL) ? &(mtx)->lock_object : \ > NULL, (flags)) >#define callout_init_rm(c, rm, flags) \ > _callout_init_lock((c), ((rm) != NULL) ? &(rm)->lock_object : \ > NULL, (flags)) >#define callout_init_rw(c, rw, flags) \ > _callout_init_lock((c), ((rw) != NULL) ? &(rw)->lock_object : \ > NULL, (flags)) >#define callout_pending(c) ((c)->c_iflags & CALLOUT_PENDING) >int callout_reset_sbt_on(struct callout *, sbintime_t, sbintime_t, > void (*)(void *), void *, int, int); >#define callout_reset_sbt(c, sbt, pr, fn, arg, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), -1, (flags)) >#define callout_reset_sbt_curcpu(c, sbt, pr, fn, arg, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (fn), (arg), PCPU_GET(cpuid),\ > (flags)) >#define callout_reset_on(c, to_ticks, fn, arg, cpu) \ > callout_reset_sbt_on((c), tick_sbt * (to_ticks), 0, (fn), (arg), \ > (cpu), C_HARDCLOCK) >#define callout_reset(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), -1) >#define callout_reset_curcpu(c, on_tick, fn, arg) \ > callout_reset_on((c), (on_tick), (fn), (arg), PCPU_GET(cpuid)) >#define callout_schedule_sbt_on(c, sbt, pr, cpu, flags) \ > callout_reset_sbt_on((c), (sbt), (pr), (c)->c_func, (c)->c_arg, \ > (cpu), (flags)) >#define callout_schedule_sbt(c, sbt, pr, flags) \ > callout_schedule_sbt_on((c), (sbt), (pr), -1, (flags)) >#define callout_schedule_sbt_curcpu(c, sbt, pr, flags) \ > callout_schedule_sbt_on((c), (sbt), (pr), PCPU_GET(cpuid), (flags)) >int callout_schedule(struct callout *, int); >int callout_schedule_on(struct callout *, int, int); >#define callout_schedule_curcpu(c, on_tick) \ > callout_schedule_on((c), (on_tick), PCPU_GET(cpuid)) >#define callout_stop(c) _callout_stop_safe(c, 0) >int _callout_stop_safe(struct callout *, int); >void callout_process(sbintime_t now); > >#endif ># 127 "/usr/src/ifnet/sys/sys/callout.h" > >#endif /* _SYS_CALLOUT_H_ */ ># 129 "/usr/src/ifnet/sys/sys/callout.h" ># 44 "/usr/src/ifnet/sys/sys/systm.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/sys/systm.h" ># 45 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/ifnet/sys/sys/systm.h" ># 46 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/stdint.h> /* for people using printf mainly */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/ifnet/sys/sys/systm.h" ># 1 "/usr/src/ifnet/sys/sys/stdint.h" 1 >/*- > * Copyright (c) 2001 Mike Barcroft <mike@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/stdint.h 237517 2012-06-24 04:15:58Z andrew $ > */ > >#ifndef _SYS_STDINT_H_ >#define _SYS_STDINT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/stdint.h" ># 33 "/usr/src/ifnet/sys/sys/stdint.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/ifnet/sys/sys/stdint.h" ># 34 "/usr/src/ifnet/sys/sys/stdint.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/stdint.h" ># 1 "./machine/_stdint.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/_stdint.h 232264 2012-02-28 18:38:33Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_stdint.h" ># 1 "./x86/_stdint.h" 1 >/*- > * Copyright (c) 2001, 2002 Mike Barcroft <mike@FreeBSD.org> > * Copyright (c) 2001 The NetBSD Foundation, Inc. > * All rights reserved. > * > * This code is derived from software contributed to The NetBSD Foundation > * by Klaus Klein. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by the NetBSD > * Foundation, Inc. and its contributors. > * 4. Neither the name of The NetBSD Foundation nor the names of its > * contributors may be used to endorse or promote products derived > * from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS > * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED > * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS > * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF > * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS > * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN > * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) > * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE > * POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/x86/include/_stdint.h 237517 2012-06-24 04:15:58Z andrew $ > */ > >#ifndef _MACHINE__STDINT_H_ >#define _MACHINE__STDINT_H_ > >#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) > >#define INT8_C(c) (c) >#define INT16_C(c) (c) >#define INT32_C(c) (c) > >#define UINT8_C(c) (c) >#define UINT16_C(c) (c) >#define UINT32_C(c) (c ## U) > >#ifdef __LP64__ >#define INT64_C(c) (c ## L) >#define UINT64_C(c) (c ## UL) >#else ># 57 "./x86/_stdint.h" >#define INT64_C(c) (c ## LL) >#define UINT64_C(c) (c ## ULL) >#endif ># 60 "./x86/_stdint.h" > >#define INTMAX_C(c) INT64_C(c) >#define UINTMAX_C(c) UINT64_C(c) > >#endif /* !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) */ ># 65 "./x86/_stdint.h" > >#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) > >/* > * ISO/IEC 9899:1999 > * 7.18.2.1 Limits of exact-width integer types > */ >#define INT8_MIN (-0x7f-1) >#define INT16_MIN (-0x7fff-1) >#define INT32_MIN (-0x7fffffff-1) > >#define INT8_MAX 0x7f >#define INT16_MAX 0x7fff >#define INT32_MAX 0x7fffffff > >#define UINT8_MAX 0xff >#define UINT16_MAX 0xffff >#define UINT32_MAX 0xffffffffU > >#ifdef __LP64__ >#define INT64_MIN (-0x7fffffffffffffff-1) >#define INT64_MAX 0x7fffffffffffffff >#define UINT64_MAX 0xffffffffffffffff >#else ># 89 "./x86/_stdint.h" >#define INT64_MIN (-0x7fffffffffffffffLL-1) >#define INT64_MAX 0x7fffffffffffffffLL >#define UINT64_MAX 0xffffffffffffffffULL >#endif ># 93 "./x86/_stdint.h" > >/* > * ISO/IEC 9899:1999 > * 7.18.2.2 Limits of minimum-width integer types > */ >/* Minimum values of minimum-width signed integer types. */ >#define INT_LEAST8_MIN INT8_MIN >#define INT_LEAST16_MIN INT16_MIN >#define INT_LEAST32_MIN INT32_MIN >#define INT_LEAST64_MIN INT64_MIN > >/* Maximum values of minimum-width signed integer types. */ >#define INT_LEAST8_MAX INT8_MAX >#define INT_LEAST16_MAX INT16_MAX >#define INT_LEAST32_MAX INT32_MAX >#define INT_LEAST64_MAX INT64_MAX > >/* Maximum values of minimum-width unsigned integer types. */ >#define UINT_LEAST8_MAX UINT8_MAX >#define UINT_LEAST16_MAX UINT16_MAX >#define UINT_LEAST32_MAX UINT32_MAX >#define UINT_LEAST64_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.2.3 Limits of fastest minimum-width integer types > */ >/* Minimum values of fastest minimum-width signed integer types. */ >#define INT_FAST8_MIN INT32_MIN >#define INT_FAST16_MIN INT32_MIN >#define INT_FAST32_MIN INT32_MIN >#define INT_FAST64_MIN INT64_MIN > >/* Maximum values of fastest minimum-width signed integer types. */ >#define INT_FAST8_MAX INT32_MAX >#define INT_FAST16_MAX INT32_MAX >#define INT_FAST32_MAX INT32_MAX >#define INT_FAST64_MAX INT64_MAX > >/* Maximum values of fastest minimum-width unsigned integer types. */ >#define UINT_FAST8_MAX UINT32_MAX >#define UINT_FAST16_MAX UINT32_MAX >#define UINT_FAST32_MAX UINT32_MAX >#define UINT_FAST64_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.2.4 Limits of integer types capable of holding object pointers > */ >#ifdef __LP64__ >#define INTPTR_MIN INT64_MIN >#define INTPTR_MAX INT64_MAX >#define UINTPTR_MAX UINT64_MAX >#else ># 147 "./x86/_stdint.h" >#define INTPTR_MIN INT32_MIN >#define INTPTR_MAX INT32_MAX >#define UINTPTR_MAX UINT32_MAX >#endif ># 151 "./x86/_stdint.h" > >/* > * ISO/IEC 9899:1999 > * 7.18.2.5 Limits of greatest-width integer types > */ >#define INTMAX_MIN INT64_MIN >#define INTMAX_MAX INT64_MAX >#define UINTMAX_MAX UINT64_MAX > >/* > * ISO/IEC 9899:1999 > * 7.18.3 Limits of other integer types > */ >#ifdef __LP64__ >/* Limits of ptrdiff_t. */ >#define PTRDIFF_MIN INT64_MIN >#define PTRDIFF_MAX INT64_MAX > >/* Limits of sig_atomic_t. */ >#define SIG_ATOMIC_MIN LONG_MIN >#define SIG_ATOMIC_MAX LONG_MAX > >/* Limit of size_t. */ >#define SIZE_MAX UINT64_MAX >#else ># 176 "./x86/_stdint.h" >#define PTRDIFF_MIN INT32_MIN >#define PTRDIFF_MAX INT32_MAX >#define SIG_ATOMIC_MIN INT32_MIN >#define SIG_ATOMIC_MAX INT32_MAX >#define SIZE_MAX UINT32_MAX >#endif ># 182 "./x86/_stdint.h" > >/* Limits of wint_t. */ >#define WINT_MIN INT32_MIN >#define WINT_MAX INT32_MAX > >#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ ># 188 "./x86/_stdint.h" > >#endif /* !_MACHINE__STDINT_H_ */ ># 190 "./x86/_stdint.h" ># 7 "./machine/_stdint.h" 2 ># 36 "/usr/src/ifnet/sys/sys/stdint.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_stdint.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/stdint.h" ># 37 "/usr/src/ifnet/sys/sys/stdint.h" > >typedef __int_least8_t int_least8_t; >typedef __int_least16_t int_least16_t; >typedef __int_least32_t int_least32_t; >typedef __int_least64_t int_least64_t; > >typedef __uint_least8_t uint_least8_t; >typedef __uint_least16_t uint_least16_t; >typedef __uint_least32_t uint_least32_t; >typedef __uint_least64_t uint_least64_t; > >typedef __int_fast8_t int_fast8_t; >typedef __int_fast16_t int_fast16_t; >typedef __int_fast32_t int_fast32_t; >typedef __int_fast64_t int_fast64_t; > >typedef __uint_fast8_t uint_fast8_t; >typedef __uint_fast16_t uint_fast16_t; >typedef __uint_fast32_t uint_fast32_t; >typedef __uint_fast64_t uint_fast64_t; > >#ifndef _INTMAX_T_DECLARED >typedef __intmax_t intmax_t; >#define _INTMAX_T_DECLARED >#endif ># 62 "/usr/src/ifnet/sys/sys/stdint.h" >#ifndef _UINTMAX_T_DECLARED >typedef __uintmax_t uintmax_t; >#define _UINTMAX_T_DECLARED >#endif ># 66 "/usr/src/ifnet/sys/sys/stdint.h" > >/* GNU and Darwin define this and people seem to think it's portable */ >#if defined(UINTPTR_MAX) && defined(UINT64_MAX) && (UINTPTR_MAX == UINT64_MAX) >#define __WORDSIZE 64 >#else ># 71 "/usr/src/ifnet/sys/sys/stdint.h" >#define __WORDSIZE 32 >#endif ># 73 "/usr/src/ifnet/sys/sys/stdint.h" > >/* Limits of wchar_t. */ >#define WCHAR_MIN __WCHAR_MIN >#define WCHAR_MAX __WCHAR_MAX > >#endif /* !_SYS_STDINT_H_ */ ># 79 "/usr/src/ifnet/sys/sys/stdint.h" ># 47 "/usr/src/ifnet/sys/sys/systm.h" 2 > >extern int cold; /* nonzero if we are doing a cold boot */ >extern int rebooting; /* kern_reboot() has been called. */ >extern const char *panicstr; /* panic message */ >extern char version[]; /* system version */ >extern char compiler_version[]; /* compiler version */ >extern char copyright[]; /* system copyright */ >extern int kstack_pages; /* number of kernel stack pages */ > >extern u_long pagesizes[]; /* supported page sizes */ >extern long physmem; /* physical memory */ >extern long realmem; /* 'real' memory */ > >extern char *rootdevnames[2]; /* names of possible root devices */ > >extern int boothowto; /* reboot flags, from console subsystem */ >extern int bootverbose; /* nonzero to print verbose messages */ > >extern int maxusers; /* system tune hint */ >extern int ngroups_max; /* max # of supplemental groups */ >extern int vm_guest; /* Running as virtual machine guest? */ > >/* > * Detected virtual machine guest types. The intention is to expand > * and/or add to the VM_GUEST_VM type if specific VM functionality is > * ever implemented (e.g. vendor-specific paravirtualization features). > * Keep in sync with vm_guest_sysctl_names[]. > */ >enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, > VM_GUEST_VMWARE, VM_LAST }; > >#if defined(WITNESS) || defined(INVARIANTS) >void kassert_panic(const char *fmt, ...) __printflike(1, 2); >#endif ># 81 "/usr/src/ifnet/sys/sys/systm.h" > >#ifdef INVARIANTS /* The option is always available */ >#define KASSERT(exp,msg) do { \ > if (__predict_false(!(exp))) \ > kassert_panic msg; \ >} while (0) >#define VNASSERT(exp, vp, msg) do { \ > if (__predict_false(!(exp))) { \ > vn_printf(vp, "VNASSERT failed\n"); \ > kassert_panic msg; \ > } \ >} while (0) >#else ># 94 "/usr/src/ifnet/sys/sys/systm.h" >#define KASSERT(exp,msg) do { \ >} while (0) > >#define VNASSERT(exp, vp, msg) do { \ >} while (0) >#endif ># 100 "/usr/src/ifnet/sys/sys/systm.h" > >#ifndef CTASSERT /* Allow lint to override */ >#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") >#endif ># 104 "/usr/src/ifnet/sys/sys/systm.h" > >/* > * Assert that a pointer can be loaded from memory atomically. > * > * This assertion enforces stronger alignment than necessary. For example, > * on some architectures, atomicity for unaligned loads will depend on > * whether or not the load spans multiple cache lines. > */ >#define ASSERT_ATOMIC_LOAD_PTR(var, msg) \ > KASSERT(sizeof(var) == sizeof(void *) && \ > ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) > >/* > * Assert that a thread is in critical(9) section. > */ >#define CRITICAL_ASSERT(td) \ > KASSERT((td)->td_critnest >= 1, ("Not in critical section")); > >/* > * If we have already panic'd and this is the thread that called > * panic(), then don't block on any mutexes but silently succeed. > * Otherwise, the kernel will deadlock since the scheduler isn't > * going to run the thread that holds any lock we need. > */ >#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) > >/* > * XXX the hints declarations are even more misplaced than most declarations > * in this file, since they are needed in one file (per arch) and only used > * in two files. > * XXX most of these variables should be const. > */ >extern int osreldate; >extern int envmode; >extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */ >extern int dynamic_kenv; >extern struct mtx kenv_lock; >extern char *kern_envp; >extern char static_env[]; >extern char static_hints[]; /* by config for now */ > >extern char **kenvp; > >extern const void *zero_region; /* address space maps to a zeroed page */ > >extern int unmapped_buf_allowed; >extern int iosize_max_clamp; >extern int devfs_iosize_max_clamp; >#define IOSIZE_MAX (iosize_max_clamp ? INT_MAX : SSIZE_MAX) >#define DEVFS_IOSIZE_MAX (devfs_iosize_max_clamp ? INT_MAX : SSIZE_MAX) > >/* > * General function declarations. > */ > >struct inpcb; >struct lock_object; >struct malloc_type; >struct mtx; >struct proc; >struct socket; >struct thread; >struct tty; >struct ucred; >struct uio; >struct _jmp_buf; >struct trapframe; >struct eventtimer; > >int setjmp(struct _jmp_buf *) __returns_twice; >void longjmp(struct _jmp_buf *, int) __dead2; >int dumpstatus(vm_offset_t addr, off_t count); >int nullop(void); >int eopnotsupp(void); >int ureadc(int, struct uio *); >void hashdestroy(void *, struct malloc_type *, u_long); >void *hashinit(int count, struct malloc_type *type, u_long *hashmask); >void *hashinit_flags(int count, struct malloc_type *type, > u_long *hashmask, int flags); >#define HASH_NOWAIT 0x00000001 >#define HASH_WAITOK 0x00000002 > >void *phashinit(int count, struct malloc_type *type, u_long *nentries); >void g_waitidle(void); > >void panic(const char *, ...) __dead2 __printflike(1, 2); > >void cpu_boot(int); >void cpu_flush_dcache(void *, size_t); >void cpu_rootconf(void); >void critical_enter(void); >void critical_exit(void); >void init_param1(void); >void init_param2(long physpages); >void init_static_kenv(char *, size_t); >void tablefull(const char *); >#ifdef EARLY_PRINTF >typedef void early_putc_t(int ch); >extern early_putc_t *early_putc; >#endif ># 204 "/usr/src/ifnet/sys/sys/systm.h" >int kvprintf(char const *, void (*)(int, void*), void *, int, > __va_list) __printflike(1, 0); >void log(int, const char *, ...) __printflike(2, 3); >void log_console(struct uio *); >int asprintf(char **ret, struct malloc_type *mtp, const char *format, > ...) __printflike(3, 4); >int printf(const char *, ...) __printflike(1, 2); >int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); >int sprintf(char *buf, const char *, ...) __printflike(2, 3); >int uprintf(const char *, ...) __printflike(1, 2); >int vprintf(const char *, __va_list) __printflike(1, 0); >int vasprintf(char **ret, struct malloc_type *mtp, const char *format, > __va_list ap) __printflike(3, 0); >int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0); >int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >long strtol(const char *, char **, int) __nonnull(1); >u_long strtoul(const char *, char **, int) __nonnull(1); >quad_t strtoq(const char *, char **, int) __nonnull(1); >u_quad_t strtouq(const char *, char **, int) __nonnull(1); >void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); >void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); >void hexdump(const void *ptr, int length, const char *hdr, int flags); >#define HD_COLUMN_MASK 0xff >#define HD_DELIM_MASK 0xff00 >#define HD_OMIT_COUNT (1 << 16) >#define HD_OMIT_HEX (1 << 17) >#define HD_OMIT_CHARS (1 << 18) > >#define ovbcopy(f, t, l) bcopy((f), (t), (l)) >void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2); >void bzero(void *buf, size_t len) __nonnull(1); >void explicit_bzero(void *, size_t) __nonnull(1);; > >void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2); >void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2); > >int copystr(const void * __restrict kfaddr, void * __restrict kdaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyin(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); > >int fubyte(volatile const void *base); >long fuword(volatile const void *base); >int fuword16(volatile const void *base); >int32_t fuword32(volatile const void *base); >int64_t fuword64(volatile const void *base); >int fueword(volatile const void *base, long *val); >int fueword32(volatile const void *base, int32_t *val); >int fueword64(volatile const void *base, int64_t *val); >int subyte(volatile void *base, int byte); >int suword(volatile void *base, long word); >int suword16(volatile void *base, int word); >int suword32(volatile void *base, int32_t word); >int suword64(volatile void *base, int64_t word); >uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); >u_long casuword(volatile u_long *p, u_long oldval, u_long newval); >int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, > uint32_t newval); >int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, > u_long newval); > >void realitexpire(void *); > >int sysbeep(int hertz, int period); > >void hardclock(int usermode, uintfptr_t pc); >void hardclock_cnt(int cnt, int usermode); >void hardclock_cpu(int usermode); >void hardclock_sync(int cpu); >void softclock(void *); >void statclock(int usermode); >void statclock_cnt(int cnt, int usermode); >void profclock(int usermode, uintfptr_t pc); >void profclock_cnt(int cnt, int usermode, uintfptr_t pc); > >int hardclockintr(void); > >void startprofclock(struct proc *); >void stopprofclock(struct proc *); >void cpu_startprofclock(void); >void cpu_stopprofclock(void); >sbintime_t cpu_idleclock(void); >void cpu_activeclock(void); >void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt); >void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq); >extern int cpu_deepest_sleep; >extern int cpu_disable_c2_sleep; >extern int cpu_disable_c3_sleep; > >int cr_cansee(struct ucred *u1, struct ucred *u2); >int cr_canseesocket(struct ucred *cred, struct socket *so); >int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); > >char *kern_getenv(const char *name); >void freeenv(char *env); >int getenv_int(const char *name, int *data); >int getenv_uint(const char *name, unsigned int *data); >int getenv_long(const char *name, long *data); >int getenv_ulong(const char *name, unsigned long *data); >int getenv_string(const char *name, char *data, int size); >int getenv_quad(const char *name, quad_t *data); >int kern_setenv(const char *name, const char *value); >int kern_unsetenv(const char *name); >int testenv(const char *name); > >typedef uint64_t (cpu_tick_f)(void); >void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); >extern cpu_tick_f *cpu_ticks; >uint64_t cpu_tickrate(void); >uint64_t cputick2usec(uint64_t tick); > >#ifdef APM_FIXUP_CALLTODO >struct timeval; >void adjust_timeout_calltodo(struct timeval *time_change); >#endif /* APM_FIXUP_CALLTODO */ ># 333 "/usr/src/ifnet/sys/sys/systm.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/libkern.h> >#endif /* expanded by -frewrite-includes */ ># 334 "/usr/src/ifnet/sys/sys/systm.h" ># 1 "/usr/src/ifnet/sys/sys/libkern.h" 1 >/*- > * Copyright (c) 1992, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)libkern.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: projects/ifnet/sys/sys/libkern.h 280281 2015-03-20 14:12:04Z glebius $ > */ > >#ifndef _SYS_LIBKERN_H_ >#define _SYS_LIBKERN_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/libkern.h" ># 37 "/usr/src/ifnet/sys/sys/libkern.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/libkern.h" ># 38 "/usr/src/ifnet/sys/sys/libkern.h" >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/libkern.h" ># 1 "/usr/src/ifnet/sys/sys/systm.h" 1 >/*- > * Copyright (c) 1982, 1988, 1991, 1993 > * The Regents of the University of California. All rights reserved. > * (c) UNIX System Laboratories, Inc. > * All or some portions of this file are derived from material licensed > * to the University of California by American Telephone and Telegraph > * Co. or Unix System Laboratories, Inc. and are reproduced herein with > * the permission of UNIX System Laboratories, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)systm.h 8.7 (Berkeley) 3/29/95 > * $FreeBSD: projects/ifnet/sys/sys/systm.h 280281 2015-03-20 14:12:04Z glebius $ > */ > >#ifndef _SYS_SYSTM_H_ >#define _SYS_SYSTM_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/systm.h" ># 42 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/systm.h" ># 43 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/callout.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/sys/systm.h" ># 44 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/sys/systm.h" ># 45 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/ifnet/sys/sys/systm.h" ># 46 "/usr/src/ifnet/sys/sys/systm.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/stdint.h> /* for people using printf mainly */ >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/ifnet/sys/sys/systm.h" ># 47 "/usr/src/ifnet/sys/sys/systm.h" > >extern int cold; /* nonzero if we are doing a cold boot */ >extern int rebooting; /* kern_reboot() has been called. */ >extern const char *panicstr; /* panic message */ >extern char version[]; /* system version */ >extern char compiler_version[]; /* compiler version */ >extern char copyright[]; /* system copyright */ >extern int kstack_pages; /* number of kernel stack pages */ > >extern u_long pagesizes[]; /* supported page sizes */ >extern long physmem; /* physical memory */ >extern long realmem; /* 'real' memory */ > >extern char *rootdevnames[2]; /* names of possible root devices */ > >extern int boothowto; /* reboot flags, from console subsystem */ >extern int bootverbose; /* nonzero to print verbose messages */ > >extern int maxusers; /* system tune hint */ >extern int ngroups_max; /* max # of supplemental groups */ >extern int vm_guest; /* Running as virtual machine guest? */ > >/* > * Detected virtual machine guest types. The intention is to expand > * and/or add to the VM_GUEST_VM type if specific VM functionality is > * ever implemented (e.g. vendor-specific paravirtualization features). > * Keep in sync with vm_guest_sysctl_names[]. > */ >enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, > VM_GUEST_VMWARE, VM_LAST }; > >#if defined(WITNESS) || defined(INVARIANTS) >void kassert_panic(const char *fmt, ...) __printflike(1, 2); >#endif ># 81 "/usr/src/ifnet/sys/sys/systm.h" > >#ifdef INVARIANTS /* The option is always available */ >#define KASSERT(exp,msg) do { \ > if (__predict_false(!(exp))) \ > kassert_panic msg; \ >} while (0) >#define VNASSERT(exp, vp, msg) do { \ > if (__predict_false(!(exp))) { \ > vn_printf(vp, "VNASSERT failed\n"); \ > kassert_panic msg; \ > } \ >} while (0) >#else ># 94 "/usr/src/ifnet/sys/sys/systm.h" >#define KASSERT(exp,msg) do { \ >} while (0) > >#define VNASSERT(exp, vp, msg) do { \ >} while (0) >#endif ># 100 "/usr/src/ifnet/sys/sys/systm.h" > >#ifndef CTASSERT /* Allow lint to override */ >#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed") >#endif ># 104 "/usr/src/ifnet/sys/sys/systm.h" > >/* > * Assert that a pointer can be loaded from memory atomically. > * > * This assertion enforces stronger alignment than necessary. For example, > * on some architectures, atomicity for unaligned loads will depend on > * whether or not the load spans multiple cache lines. > */ >#define ASSERT_ATOMIC_LOAD_PTR(var, msg) \ > KASSERT(sizeof(var) == sizeof(void *) && \ > ((uintptr_t)&(var) & (sizeof(void *) - 1)) == 0, msg) > >/* > * Assert that a thread is in critical(9) section. > */ >#define CRITICAL_ASSERT(td) \ > KASSERT((td)->td_critnest >= 1, ("Not in critical section")); > >/* > * If we have already panic'd and this is the thread that called > * panic(), then don't block on any mutexes but silently succeed. > * Otherwise, the kernel will deadlock since the scheduler isn't > * going to run the thread that holds any lock we need. > */ >#define SCHEDULER_STOPPED() __predict_false(curthread->td_stopsched) > >/* > * XXX the hints declarations are even more misplaced than most declarations > * in this file, since they are needed in one file (per arch) and only used > * in two files. > * XXX most of these variables should be const. > */ >extern int osreldate; >extern int envmode; >extern int hintmode; /* 0 = off. 1 = config, 2 = fallback */ >extern int dynamic_kenv; >extern struct mtx kenv_lock; >extern char *kern_envp; >extern char static_env[]; >extern char static_hints[]; /* by config for now */ > >extern char **kenvp; > >extern const void *zero_region; /* address space maps to a zeroed page */ > >extern int unmapped_buf_allowed; >extern int iosize_max_clamp; >extern int devfs_iosize_max_clamp; >#define IOSIZE_MAX (iosize_max_clamp ? INT_MAX : SSIZE_MAX) >#define DEVFS_IOSIZE_MAX (devfs_iosize_max_clamp ? INT_MAX : SSIZE_MAX) > >/* > * General function declarations. > */ > >struct inpcb; >struct lock_object; >struct malloc_type; >struct mtx; >struct proc; >struct socket; >struct thread; >struct tty; >struct ucred; >struct uio; >struct _jmp_buf; >struct trapframe; >struct eventtimer; > >int setjmp(struct _jmp_buf *) __returns_twice; >void longjmp(struct _jmp_buf *, int) __dead2; >int dumpstatus(vm_offset_t addr, off_t count); >int nullop(void); >int eopnotsupp(void); >int ureadc(int, struct uio *); >void hashdestroy(void *, struct malloc_type *, u_long); >void *hashinit(int count, struct malloc_type *type, u_long *hashmask); >void *hashinit_flags(int count, struct malloc_type *type, > u_long *hashmask, int flags); >#define HASH_NOWAIT 0x00000001 >#define HASH_WAITOK 0x00000002 > >void *phashinit(int count, struct malloc_type *type, u_long *nentries); >void g_waitidle(void); > >void panic(const char *, ...) __dead2 __printflike(1, 2); > >void cpu_boot(int); >void cpu_flush_dcache(void *, size_t); >void cpu_rootconf(void); >void critical_enter(void); >void critical_exit(void); >void init_param1(void); >void init_param2(long physpages); >void init_static_kenv(char *, size_t); >void tablefull(const char *); >#ifdef EARLY_PRINTF >typedef void early_putc_t(int ch); >extern early_putc_t *early_putc; >#endif ># 204 "/usr/src/ifnet/sys/sys/systm.h" >int kvprintf(char const *, void (*)(int, void*), void *, int, > __va_list) __printflike(1, 0); >void log(int, const char *, ...) __printflike(2, 3); >void log_console(struct uio *); >int asprintf(char **ret, struct malloc_type *mtp, const char *format, > ...) __printflike(3, 4); >int printf(const char *, ...) __printflike(1, 2); >int snprintf(char *, size_t, const char *, ...) __printflike(3, 4); >int sprintf(char *buf, const char *, ...) __printflike(2, 3); >int uprintf(const char *, ...) __printflike(1, 2); >int vprintf(const char *, __va_list) __printflike(1, 0); >int vasprintf(char **ret, struct malloc_type *mtp, const char *format, > __va_list ap) __printflike(3, 0); >int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0); >int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0); >int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0); >int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3); >int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2); >int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2); >long strtol(const char *, char **, int) __nonnull(1); >u_long strtoul(const char *, char **, int) __nonnull(1); >quad_t strtoq(const char *, char **, int) __nonnull(1); >u_quad_t strtouq(const char *, char **, int) __nonnull(1); >void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4); >void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0); >void hexdump(const void *ptr, int length, const char *hdr, int flags); >#define HD_COLUMN_MASK 0xff >#define HD_DELIM_MASK 0xff00 >#define HD_OMIT_COUNT (1 << 16) >#define HD_OMIT_HEX (1 << 17) >#define HD_OMIT_CHARS (1 << 18) > >#define ovbcopy(f, t, l) bcopy((f), (t), (l)) >void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2); >void bzero(void *buf, size_t len) __nonnull(1); >void explicit_bzero(void *, size_t) __nonnull(1);; > >void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2); >void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2); > >int copystr(const void * __restrict kfaddr, void * __restrict kdaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyinstr(const void * __restrict udaddr, void * __restrict kaddr, > size_t len, size_t * __restrict lencopied) > __nonnull(1) __nonnull(2); >int copyin(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); >int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr, > size_t len) __nonnull(1) __nonnull(2); > >int fubyte(volatile const void *base); >long fuword(volatile const void *base); >int fuword16(volatile const void *base); >int32_t fuword32(volatile const void *base); >int64_t fuword64(volatile const void *base); >int fueword(volatile const void *base, long *val); >int fueword32(volatile const void *base, int32_t *val); >int fueword64(volatile const void *base, int64_t *val); >int subyte(volatile void *base, int byte); >int suword(volatile void *base, long word); >int suword16(volatile void *base, int word); >int suword32(volatile void *base, int32_t word); >int suword64(volatile void *base, int64_t word); >uint32_t casuword32(volatile uint32_t *base, uint32_t oldval, uint32_t newval); >u_long casuword(volatile u_long *p, u_long oldval, u_long newval); >int casueword32(volatile uint32_t *base, uint32_t oldval, uint32_t *oldvalp, > uint32_t newval); >int casueword(volatile u_long *p, u_long oldval, u_long *oldvalp, > u_long newval); > >void realitexpire(void *); > >int sysbeep(int hertz, int period); > >void hardclock(int usermode, uintfptr_t pc); >void hardclock_cnt(int cnt, int usermode); >void hardclock_cpu(int usermode); >void hardclock_sync(int cpu); >void softclock(void *); >void statclock(int usermode); >void statclock_cnt(int cnt, int usermode); >void profclock(int usermode, uintfptr_t pc); >void profclock_cnt(int cnt, int usermode, uintfptr_t pc); > >int hardclockintr(void); > >void startprofclock(struct proc *); >void stopprofclock(struct proc *); >void cpu_startprofclock(void); >void cpu_stopprofclock(void); >sbintime_t cpu_idleclock(void); >void cpu_activeclock(void); >void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt); >void cpu_et_frequency(struct eventtimer *et, uint64_t newfreq); >extern int cpu_deepest_sleep; >extern int cpu_disable_c2_sleep; >extern int cpu_disable_c3_sleep; > >int cr_cansee(struct ucred *u1, struct ucred *u2); >int cr_canseesocket(struct ucred *cred, struct socket *so); >int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp); > >char *kern_getenv(const char *name); >void freeenv(char *env); >int getenv_int(const char *name, int *data); >int getenv_uint(const char *name, unsigned int *data); >int getenv_long(const char *name, long *data); >int getenv_ulong(const char *name, unsigned long *data); >int getenv_string(const char *name, char *data, int size); >int getenv_quad(const char *name, quad_t *data); >int kern_setenv(const char *name, const char *value); >int kern_unsetenv(const char *name); >int testenv(const char *name); > >typedef uint64_t (cpu_tick_f)(void); >void set_cputicker(cpu_tick_f *func, uint64_t freq, unsigned var); >extern cpu_tick_f *cpu_ticks; >uint64_t cpu_tickrate(void); >uint64_t cputick2usec(uint64_t tick); > >#ifdef APM_FIXUP_CALLTODO >struct timeval; >void adjust_timeout_calltodo(struct timeval *time_change); >#endif /* APM_FIXUP_CALLTODO */ ># 333 "/usr/src/ifnet/sys/sys/systm.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/libkern.h> >#endif /* expanded by -frewrite-includes */ ># 334 "/usr/src/ifnet/sys/sys/systm.h" ># 335 "/usr/src/ifnet/sys/sys/systm.h" > >/* Initialize the world */ >void consinit(void); >void cpu_initclocks(void); >void cpu_initclocks_bsp(void); >void cpu_initclocks_ap(void); >void usrinfoinit(void); > >/* Finalize the world */ >void kern_reboot(int) __dead2; >void shutdown_nice(int); > >/* Timeouts */ >typedef void timeout_t(void *); /* timeout function type */ >#define CALLOUT_HANDLE_INITIALIZER(handle) \ > { NULL } > >void callout_handle_init(struct callout_handle *); >struct callout_handle timeout(timeout_t *, void *, int); >void untimeout(timeout_t *, void *, struct callout_handle); > >/* Stubs for obsolete functions that used to be for interrupt management */ >static __inline intrmask_t splbio(void) { return 0; } >static __inline intrmask_t splcam(void) { return 0; } >static __inline intrmask_t splclock(void) { return 0; } >static __inline intrmask_t splhigh(void) { return 0; } >static __inline intrmask_t splimp(void) { return 0; } >static __inline intrmask_t splnet(void) { return 0; } >static __inline intrmask_t spltty(void) { return 0; } >static __inline void splx(intrmask_t ipl __unused) { return; } > >/* > * Common `proc' functions are declared here so that proc.h can be included > * less often. > */ >int _sleep(void *chan, struct lock_object *lock, int pri, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \ > (flags)) >int msleep_spin_sbt(void *chan, struct mtx *mtx, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep_spin(chan, mtx, wmesg, timo) \ > msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, > int flags); >#define pause(wmesg, timo) \ > pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) >#define tsleep(chan, pri, wmesg, timo) \ > _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >#define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \ > _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) >void wakeup(void *chan) __nonnull(1); >void wakeup_one(void *chan) __nonnull(1); > >/* > * Common `struct cdev *' stuff are declared here to avoid #include poisoning > */ > >struct cdev; >dev_t dev2udev(struct cdev *x); >const char *devtoname(struct cdev *cdev); > >int poll_no_poll(int events); > >/* XXX: Should be void nanodelay(u_int nsec); */ >void DELAY(int usec); > >/* Root mount holdback API */ >struct root_hold_token; > >struct root_hold_token *root_mount_hold(const char *identifier); >void root_mount_rel(struct root_hold_token *h); >void root_mount_wait(void); >int root_mounted(void); > > >/* > * Unit number allocation API. (kern/subr_unit.c) > */ >struct unrhdr; >struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); >void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); >void delete_unrhdr(struct unrhdr *uh); >void clean_unrhdr(struct unrhdr *uh); >void clean_unrhdrl(struct unrhdr *uh); >int alloc_unr(struct unrhdr *uh); >int alloc_unr_specific(struct unrhdr *uh, u_int item); >int alloc_unrl(struct unrhdr *uh); >void free_unr(struct unrhdr *uh, u_int item); > >void intr_prof_stack_use(struct thread *td, struct trapframe *frame); > >#endif /* !_SYS_SYSTM_H_ */ ># 434 "/usr/src/ifnet/sys/sys/systm.h" ># 40 "/usr/src/ifnet/sys/sys/libkern.h" 2 >#endif ># 41 "/usr/src/ifnet/sys/sys/libkern.h" > >#ifndef LIBKERN_INLINE >#define LIBKERN_INLINE static __inline >#define LIBKERN_BODY >#endif ># 46 "/usr/src/ifnet/sys/sys/libkern.h" > >/* BCD conversions. */ >extern u_char const bcd2bin_data[]; >extern u_char const bin2bcd_data[]; >extern char const hex2ascii_data[]; > >#define bcd2bin(bcd) (bcd2bin_data[bcd]) >#define bin2bcd(bin) (bin2bcd_data[bin]) >#define hex2ascii(hex) (hex2ascii_data[hex]) > >static __inline int imax(int a, int b) { return (a > b ? a : b); } >static __inline int imin(int a, int b) { return (a < b ? a : b); } >static __inline long lmax(long a, long b) { return (a > b ? a : b); } >static __inline long lmin(long a, long b) { return (a < b ? a : b); } >static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); } >static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); } >static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); } >static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); } >static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); } >static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); } >static __inline off_t omax(off_t a, off_t b) { return (a > b ? a : b); } >static __inline off_t omin(off_t a, off_t b) { return (a < b ? a : b); } > >static __inline int abs(int a) { return (a < 0 ? -a : a); } >static __inline long labs(long a) { return (a < 0 ? -a : a); } >static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); } > >#define ARC4_ENTR_NONE 0 /* Don't have entropy yet. */ >#define ARC4_ENTR_HAVE 1 /* Have entropy. */ >#define ARC4_ENTR_SEED 2 /* Reseeding. */ >extern int arc4rand_iniseed_state; > >/* Prototypes for non-quad routines. */ >struct malloc_type; >uint32_t arc4random(void); >void arc4rand(void *ptr, u_int len, int reseed); >int bcmp(const void *, const void *, size_t); >int timingsafe_bcmp(const void *, const void *, size_t); >void *bsearch(const void *, const void *, size_t, > size_t, int (*)(const void *, const void *)); >#ifndef HAVE_INLINE_FFS >int ffs(int); >#endif ># 89 "/usr/src/ifnet/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FFSL >int ffsl(long); >#endif ># 92 "/usr/src/ifnet/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLS >int fls(int); >#endif ># 95 "/usr/src/ifnet/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLSL >int flsl(long); >#endif ># 98 "/usr/src/ifnet/sys/sys/libkern.h" >#ifndef HAVE_INLINE_FLSLL >int flsll(long long); >#endif ># 101 "/usr/src/ifnet/sys/sys/libkern.h" >#define bitcount64(x) __bitcount64((uint64_t)(x)) >#define bitcount32(x) __bitcount32((uint32_t)(x)) >#define bitcount16(x) __bitcount16((uint16_t)(x)) >#define bitcountl(x) __bitcountl((u_long)(x)) >#define bitcount(x) __bitcount((u_int)(x)) > >int fnmatch(const char *, const char *, int); >int locc(int, char *, u_int); >void *memchr(const void *s, int c, size_t n); >void *memcchr(const void *s, int c, size_t n); >int memcmp(const void *b1, const void *b2, size_t len); >void *memmem(const void *l, size_t l_len, const void *s, size_t s_len); >void qsort(void *base, size_t nmemb, size_t size, > int (*compar)(const void *, const void *)); >void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, > int (*compar)(void *, const void *, const void *)); >u_long random(void); >int scanc(u_int, const u_char *, const u_char *, int); >void srandom(u_long); >int strcasecmp(const char *, const char *); >char *strcat(char * __restrict, const char * __restrict); >char *strchr(const char *, int); >int strcmp(const char *, const char *); >char *strcpy(char * __restrict, const char * __restrict); >size_t strcspn(const char * __restrict, const char * __restrict) __pure; >char *strdup(const char *__restrict, struct malloc_type *); >char *strndup(const char *__restrict, size_t, struct malloc_type *); >size_t strlcat(char *, const char *, size_t); >size_t strlcpy(char *, const char *, size_t); >size_t strlen(const char *); >int strncasecmp(const char *, const char *, size_t); >int strncmp(const char *, const char *, size_t); >char *strncpy(char * __restrict, const char * __restrict, size_t); >size_t strnlen(const char *, size_t); >char *strrchr(const char *, int); >char *strsep(char **, const char *delim); >size_t strspn(const char *, const char *); >char *strstr(const char *, const char *); >int strvalid(const char *, size_t); > >extern const uint32_t crc32_tab[]; > >static __inline uint32_t >crc32_raw(const void *buf, size_t size, uint32_t crc) >{ > const uint8_t *p = (const uint8_t *)buf; > > while (size--) > crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); > return (crc); >} > >static __inline uint32_t >crc32(const void *buf, size_t size) >{ > uint32_t crc; > > crc = crc32_raw(buf, size, ~0U); > return (crc ^ ~0U); >} > >uint32_t >calculate_crc32c(uint32_t crc32c, const unsigned char *buffer, > unsigned int length); > > >LIBKERN_INLINE void *memset(void *, int, size_t); >#ifdef LIBKERN_BODY >LIBKERN_INLINE void * >memset(void *b, int c, size_t len) >{ > char *bb; > > if (c == 0) > bzero(b, len); > else > for (bb = (char *)b; len--; ) > *bb++ = c; > return (b); >} >#endif ># 182 "/usr/src/ifnet/sys/sys/libkern.h" > >static __inline char * >index(const char *p, int ch) >{ > > return (strchr(p, ch)); >} > >static __inline char * >rindex(const char *p, int ch) >{ > > return (strrchr(p, ch)); >} > >/* fnmatch() return values. */ >#define FNM_NOMATCH 1 /* Match failed. */ > >/* fnmatch() flags. */ >#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ >#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ >#define FNM_PERIOD 0x04 /* Period must be matched by period. */ >#define FNM_LEADING_DIR 0x08 /* Ignore /<tail> after Imatch. */ >#define FNM_CASEFOLD 0x10 /* Case insensitive search. */ >#define FNM_IGNORECASE FNM_CASEFOLD >#define FNM_FILE_NAME FNM_PATHNAME > >#endif /* !_SYS_LIBKERN_H_ */ ># 210 "/usr/src/ifnet/sys/sys/libkern.h" ># 335 "/usr/src/ifnet/sys/sys/systm.h" 2 > >/* Initialize the world */ >void consinit(void); >void cpu_initclocks(void); >void cpu_initclocks_bsp(void); >void cpu_initclocks_ap(void); >void usrinfoinit(void); > >/* Finalize the world */ >void kern_reboot(int) __dead2; >void shutdown_nice(int); > >/* Timeouts */ >typedef void timeout_t(void *); /* timeout function type */ >#define CALLOUT_HANDLE_INITIALIZER(handle) \ > { NULL } > >void callout_handle_init(struct callout_handle *); >struct callout_handle timeout(timeout_t *, void *, int); >void untimeout(timeout_t *, void *, struct callout_handle); > >/* Stubs for obsolete functions that used to be for interrupt management */ >static __inline intrmask_t splbio(void) { return 0; } >static __inline intrmask_t splcam(void) { return 0; } >static __inline intrmask_t splclock(void) { return 0; } >static __inline intrmask_t splhigh(void) { return 0; } >static __inline intrmask_t splimp(void) { return 0; } >static __inline intrmask_t splnet(void) { return 0; } >static __inline intrmask_t spltty(void) { return 0; } >static __inline void splx(intrmask_t ipl __unused) { return; } > >/* > * Common `proc' functions are declared here so that proc.h can be included > * less often. > */ >int _sleep(void *chan, struct lock_object *lock, int pri, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) >#define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \ > (flags)) >int msleep_spin_sbt(void *chan, struct mtx *mtx, const char *wmesg, > sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1); >#define msleep_spin(chan, mtx, wmesg, timo) \ > msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, > int flags); >#define pause(wmesg, timo) \ > pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK) >#define tsleep(chan, pri, wmesg, timo) \ > _sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \ > 0, C_HARDCLOCK) >#define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \ > _sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags)) >void wakeup(void *chan) __nonnull(1); >void wakeup_one(void *chan) __nonnull(1); > >/* > * Common `struct cdev *' stuff are declared here to avoid #include poisoning > */ > >struct cdev; >dev_t dev2udev(struct cdev *x); >const char *devtoname(struct cdev *cdev); > >int poll_no_poll(int events); > >/* XXX: Should be void nanodelay(u_int nsec); */ >void DELAY(int usec); > >/* Root mount holdback API */ >struct root_hold_token; > >struct root_hold_token *root_mount_hold(const char *identifier); >void root_mount_rel(struct root_hold_token *h); >void root_mount_wait(void); >int root_mounted(void); > > >/* > * Unit number allocation API. (kern/subr_unit.c) > */ >struct unrhdr; >struct unrhdr *new_unrhdr(int low, int high, struct mtx *mutex); >void init_unrhdr(struct unrhdr *uh, int low, int high, struct mtx *mutex); >void delete_unrhdr(struct unrhdr *uh); >void clean_unrhdr(struct unrhdr *uh); >void clean_unrhdrl(struct unrhdr *uh); >int alloc_unr(struct unrhdr *uh); >int alloc_unr_specific(struct unrhdr *uh, u_int item); >int alloc_unrl(struct unrhdr *uh); >void free_unr(struct unrhdr *uh, u_int item); > >void intr_prof_stack_use(struct thread *td, struct trapframe *frame); > >#endif /* !_SYS_SYSTM_H_ */ ># 434 "/usr/src/ifnet/sys/sys/systm.h" ># 40 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/socket.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/socket.h" 1 >/*- > * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)socket.h 8.4 (Berkeley) 2/21/94 > * $FreeBSD: projects/ifnet/sys/sys/socket.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_SOCKET_H_ >#define _SYS_SOCKET_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/socket.h" ># 37 "/usr/src/ifnet/sys/sys/socket.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/socket.h" ># 38 "/usr/src/ifnet/sys/sys/socket.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_iovec.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/socket.h" ># 1 "/usr/src/ifnet/sys/sys/_iovec.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)uio.h 8.5 (Berkeley) 2/22/94 > * $FreeBSD: projects/ifnet/sys/sys/_iovec.h 139825 2005-01-07 02:29:27Z imp $ > */ > >#ifndef _SYS__IOVEC_H_ >#define _SYS__IOVEC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/_iovec.h" ># 37 "/usr/src/ifnet/sys/sys/_iovec.h" > >#ifndef _SIZE_T_DECLARED >typedef __size_t size_t; >#define _SIZE_T_DECLARED >#endif ># 42 "/usr/src/ifnet/sys/sys/_iovec.h" > >struct iovec { > void *iov_base; /* Base address. */ > size_t iov_len; /* Length. */ >}; > >#endif /* !_SYS__IOVEC_H_ */ ># 49 "/usr/src/ifnet/sys/sys/_iovec.h" ># 39 "/usr/src/ifnet/sys/sys/socket.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/_align.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/socket.h" ># 1 "./machine/_align.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/_align.h 215856 2010-11-26 10:59:20Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/_align.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/_align.h" ># 7 "./machine/_align.h" ># 40 "/usr/src/ifnet/sys/sys/socket.h" 2 > >/* > * Definitions related to sockets: types, address families, options. > */ > >/* > * Data types. > */ >#if __BSD_VISIBLE >#ifndef _GID_T_DECLARED >typedef __gid_t gid_t; >#define _GID_T_DECLARED >#endif ># 53 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _OFF_T_DECLARED >typedef __off_t off_t; >#define _OFF_T_DECLARED >#endif ># 58 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _PID_T_DECLARED >typedef __pid_t pid_t; >#define _PID_T_DECLARED >#endif ># 63 "/usr/src/ifnet/sys/sys/socket.h" >#endif ># 64 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _SA_FAMILY_T_DECLARED >typedef __sa_family_t sa_family_t; >#define _SA_FAMILY_T_DECLARED >#endif ># 69 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _SOCKLEN_T_DECLARED >typedef __socklen_t socklen_t; >#define _SOCKLEN_T_DECLARED >#endif ># 74 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _SSIZE_T_DECLARED >typedef __ssize_t ssize_t; >#define _SSIZE_T_DECLARED >#endif ># 79 "/usr/src/ifnet/sys/sys/socket.h" > >#if __BSD_VISIBLE >#ifndef _UID_T_DECLARED >typedef __uid_t uid_t; >#define _UID_T_DECLARED >#endif ># 85 "/usr/src/ifnet/sys/sys/socket.h" >#endif ># 86 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _UINT32_T_DECLARED >typedef __uint32_t uint32_t; >#define _UINT32_T_DECLARED >#endif ># 91 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _UINTPTR_T_DECLARED >typedef __uintptr_t uintptr_t; >#define _UINTPTR_T_DECLARED >#endif ># 96 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Types > */ >#define SOCK_STREAM 1 /* stream socket */ >#define SOCK_DGRAM 2 /* datagram socket */ >#define SOCK_RAW 3 /* raw-protocol interface */ >#if __BSD_VISIBLE >#define SOCK_RDM 4 /* reliably-delivered message */ >#endif ># 106 "/usr/src/ifnet/sys/sys/socket.h" >#define SOCK_SEQPACKET 5 /* sequenced packet stream */ > >#if __BSD_VISIBLE >/* > * Creation flags, OR'ed into socket() and socketpair() type argument. > */ >#define SOCK_CLOEXEC 0x10000000 >#define SOCK_NONBLOCK 0x20000000 >#endif ># 115 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Option flags per-socket. > */ >#define SO_DEBUG 0x0001 /* turn on debugging info recording */ >#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ >#define SO_REUSEADDR 0x0004 /* allow local address reuse */ >#define SO_KEEPALIVE 0x0008 /* keep connections alive */ >#define SO_DONTROUTE 0x0010 /* just use interface addresses */ >#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ >#if __BSD_VISIBLE >#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ >#endif ># 128 "/usr/src/ifnet/sys/sys/socket.h" >#define SO_LINGER 0x0080 /* linger on close if data present */ >#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ >#if __BSD_VISIBLE >#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ >#define SO_TIMESTAMP 0x0400 /* timestamp received dgram traffic */ >#define SO_NOSIGPIPE 0x0800 /* no SIGPIPE from EPIPE */ >#define SO_ACCEPTFILTER 0x1000 /* there is an accept filter */ >#define SO_BINTIME 0x2000 /* timestamp received dgram traffic */ >#endif ># 137 "/usr/src/ifnet/sys/sys/socket.h" >#define SO_NO_OFFLOAD 0x4000 /* socket cannot be offloaded */ >#define SO_NO_DDP 0x8000 /* disable direct data placement */ > >/* > * Additional options, not kept in so_options. > */ >#define SO_SNDBUF 0x1001 /* send buffer size */ >#define SO_RCVBUF 0x1002 /* receive buffer size */ >#define SO_SNDLOWAT 0x1003 /* send low-water mark */ >#define SO_RCVLOWAT 0x1004 /* receive low-water mark */ >#define SO_SNDTIMEO 0x1005 /* send timeout */ >#define SO_RCVTIMEO 0x1006 /* receive timeout */ >#define SO_ERROR 0x1007 /* get error status and clear */ >#define SO_TYPE 0x1008 /* get socket type */ >#if __BSD_VISIBLE >#define SO_LABEL 0x1009 /* socket's MAC label */ >#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */ >#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */ >#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */ >#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */ >#define SO_SETFIB 0x1014 /* use this FIB to route */ >#define SO_USER_COOKIE 0x1015 /* user cookie (dummynet etc.) */ >#define SO_PROTOCOL 0x1016 /* get socket protocol (Linux name) */ >#define SO_PROTOTYPE SO_PROTOCOL /* alias for SO_PROTOCOL (SunOS name) */ >#endif ># 162 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Space reserved for new socket options added by third-party vendors. > * This range applies to all socket option levels. New socket options > * in FreeBSD should always use an option value less than SO_VENDOR. > */ >#if __BSD_VISIBLE >#define SO_VENDOR 0x80000000 >#endif ># 171 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Structure used for manipulating linger option. > */ >struct linger { > int l_onoff; /* option on/off */ > int l_linger; /* linger time */ >}; > >#if __BSD_VISIBLE >struct accept_filter_arg { > char af_name[16]; > char af_arg[256-16]; >}; >#endif ># 186 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Level number for (get/set)sockopt() to apply to socket itself. > */ >#define SOL_SOCKET 0xffff /* options for socket level */ > >/* > * Address families. > */ >#define AF_UNSPEC 0 /* unspecified */ >#if __BSD_VISIBLE >#define AF_LOCAL AF_UNIX /* local to host (pipes, portals) */ >#endif ># 199 "/usr/src/ifnet/sys/sys/socket.h" >#define AF_UNIX 1 /* standardized name for AF_LOCAL */ >#define AF_INET 2 /* internetwork: UDP, TCP, etc. */ >#if __BSD_VISIBLE >#define AF_IMPLINK 3 /* arpanet imp addresses */ >#define AF_PUP 4 /* pup protocols: e.g. BSP */ >#define AF_CHAOS 5 /* mit CHAOS protocols */ >#define AF_NETBIOS 6 /* SMB protocols */ >#define AF_ISO 7 /* ISO protocols */ >#define AF_OSI AF_ISO >#define AF_ECMA 8 /* European computer manufacturers */ >#define AF_DATAKIT 9 /* datakit protocols */ >#define AF_CCITT 10 /* CCITT protocols, X.25 etc */ >#define AF_SNA 11 /* IBM SNA */ >#define AF_DECnet 12 /* DECnet */ >#define AF_DLI 13 /* DEC Direct data link interface */ >#define AF_LAT 14 /* LAT */ >#define AF_HYLINK 15 /* NSC Hyperchannel */ >#define AF_APPLETALK 16 /* Apple Talk */ >#define AF_ROUTE 17 /* Internal Routing Protocol */ >#define AF_LINK 18 /* Link layer interface */ >#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */ >#define AF_COIP 20 /* connection-oriented IP, aka ST II */ >#define AF_CNT 21 /* Computer Network Technology */ >#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */ >#define AF_IPX 23 /* Novell Internet Protocol */ >#define AF_SIP 24 /* Simple Internet Protocol */ >#define pseudo_AF_PIP 25 /* Help Identify PIP packets */ >#define AF_ISDN 26 /* Integrated Services Digital Network*/ >#define AF_E164 AF_ISDN /* CCITT E.164 recommendation */ >#define pseudo_AF_KEY 27 /* Internal key-management function */ >#endif ># 230 "/usr/src/ifnet/sys/sys/socket.h" >#define AF_INET6 28 /* IPv6 */ >#if __BSD_VISIBLE >#define AF_NATM 29 /* native ATM access */ >#define AF_ATM 30 /* ATM */ >#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers > * in interface output routine > */ >#define AF_NETGRAPH 32 /* Netgraph sockets */ >#define AF_SLOW 33 /* 802.3ad slow protocol */ >#define AF_SCLUSTER 34 /* Sitara cluster protocol */ >#define AF_ARP 35 >#define AF_BLUETOOTH 36 /* Bluetooth sockets */ >#define AF_IEEE80211 37 /* IEEE 802.11 protocol */ >#define AF_INET_SDP 40 /* OFED Socket Direct Protocol ipv4 */ >#define AF_INET6_SDP 42 /* OFED Socket Direct Protocol ipv6 */ >#define AF_MAX 42 >/* > * When allocating a new AF_ constant, please only allocate > * even numbered constants for FreeBSD until 134 as odd numbered AF_ > * constants 39-133 are now reserved for vendors. > */ >#define AF_VENDOR00 39 >#define AF_VENDOR01 41 >#define AF_VENDOR02 43 >#define AF_VENDOR03 45 >#define AF_VENDOR04 47 >#define AF_VENDOR05 49 >#define AF_VENDOR06 51 >#define AF_VENDOR07 53 >#define AF_VENDOR08 55 >#define AF_VENDOR09 57 >#define AF_VENDOR10 59 >#define AF_VENDOR11 61 >#define AF_VENDOR12 63 >#define AF_VENDOR13 65 >#define AF_VENDOR14 67 >#define AF_VENDOR15 69 >#define AF_VENDOR16 71 >#define AF_VENDOR17 73 >#define AF_VENDOR18 75 >#define AF_VENDOR19 77 >#define AF_VENDOR20 79 >#define AF_VENDOR21 81 >#define AF_VENDOR22 83 >#define AF_VENDOR23 85 >#define AF_VENDOR24 87 >#define AF_VENDOR25 89 >#define AF_VENDOR26 91 >#define AF_VENDOR27 93 >#define AF_VENDOR28 95 >#define AF_VENDOR29 97 >#define AF_VENDOR30 99 >#define AF_VENDOR31 101 >#define AF_VENDOR32 103 >#define AF_VENDOR33 105 >#define AF_VENDOR34 107 >#define AF_VENDOR35 109 >#define AF_VENDOR36 111 >#define AF_VENDOR37 113 >#define AF_VENDOR38 115 >#define AF_VENDOR39 117 >#define AF_VENDOR40 119 >#define AF_VENDOR41 121 >#define AF_VENDOR42 123 >#define AF_VENDOR43 125 >#define AF_VENDOR44 127 >#define AF_VENDOR45 129 >#define AF_VENDOR46 131 >#define AF_VENDOR47 133 >#endif ># 300 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Structure used by kernel to store most > * addresses. > */ >struct sockaddr { > unsigned char sa_len; /* total length */ > sa_family_t sa_family; /* address family */ > char sa_data[14]; /* actually longer; address value */ >}; >#if __BSD_VISIBLE >#define SOCK_MAXADDRLEN 255 /* longest possible addresses */ > >/* > * Structure used by kernel to pass protocol > * information in raw sockets. > */ >struct sockproto { > unsigned short sp_family; /* address family */ > unsigned short sp_protocol; /* protocol */ >}; >#endif ># 322 "/usr/src/ifnet/sys/sys/socket.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sockaddr_storage.h> >#endif /* expanded by -frewrite-includes */ ># 323 "/usr/src/ifnet/sys/sys/socket.h" ># 1 "/usr/src/ifnet/sys/sys/_sockaddr_storage.h" 1 >/*- > * Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)socket.h 8.4 (Berkeley) 2/21/94 > * $FreeBSD: projects/ifnet/sys/sys/_sockaddr_storage.h 196967 2009-09-08 10:39:38Z phk $ > */ > >#ifndef _SYS__SOCKADDR_STORAGE_H_ >#define _SYS__SOCKADDR_STORAGE_H_ > >/* > * RFC 2553: protocol-independent placeholder for socket addresses > */ >#define _SS_MAXSIZE 128U >#define _SS_ALIGNSIZE (sizeof(__int64_t)) >#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - \ > sizeof(sa_family_t)) >#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - \ > sizeof(sa_family_t) - _SS_PAD1SIZE - _SS_ALIGNSIZE) > >struct sockaddr_storage { > unsigned char ss_len; /* address length */ > sa_family_t ss_family; /* address family */ > char __ss_pad1[_SS_PAD1SIZE]; > __int64_t __ss_align; /* force desired struct alignment */ > char __ss_pad2[_SS_PAD2SIZE]; >}; > >#endif /* !_SYS__SOCKADDR_STORAGE_H_ */ ># 55 "/usr/src/ifnet/sys/sys/_sockaddr_storage.h" ># 324 "/usr/src/ifnet/sys/sys/socket.h" 2 > >#if __BSD_VISIBLE >/* > * Protocol families, same as address families for now. > */ >#define PF_UNSPEC AF_UNSPEC >#define PF_LOCAL AF_LOCAL >#define PF_UNIX PF_LOCAL /* backward compatibility */ >#define PF_INET AF_INET >#define PF_IMPLINK AF_IMPLINK >#define PF_PUP AF_PUP >#define PF_CHAOS AF_CHAOS >#define PF_NETBIOS AF_NETBIOS >#define PF_ISO AF_ISO >#define PF_OSI AF_ISO >#define PF_ECMA AF_ECMA >#define PF_DATAKIT AF_DATAKIT >#define PF_CCITT AF_CCITT >#define PF_SNA AF_SNA >#define PF_DECnet AF_DECnet >#define PF_DLI AF_DLI >#define PF_LAT AF_LAT >#define PF_HYLINK AF_HYLINK >#define PF_APPLETALK AF_APPLETALK >#define PF_ROUTE AF_ROUTE >#define PF_LINK AF_LINK >#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */ >#define PF_COIP AF_COIP >#define PF_CNT AF_CNT >#define PF_SIP AF_SIP >#define PF_IPX AF_IPX >#define PF_RTIP pseudo_AF_RTIP /* same format as AF_INET */ >#define PF_PIP pseudo_AF_PIP >#define PF_ISDN AF_ISDN >#define PF_KEY pseudo_AF_KEY >#define PF_INET6 AF_INET6 >#define PF_NATM AF_NATM >#define PF_ATM AF_ATM >#define PF_NETGRAPH AF_NETGRAPH >#define PF_SLOW AF_SLOW >#define PF_SCLUSTER AF_SCLUSTER >#define PF_ARP AF_ARP >#define PF_BLUETOOTH AF_BLUETOOTH >#define PF_IEEE80211 AF_IEEE80211 >#define PF_INET_SDP AF_INET_SDP >#define PF_INET6_SDP AF_INET6_SDP > >#define PF_MAX AF_MAX > >/* > * Definitions for network related sysctl, CTL_NET. > * > * Second level is protocol family. > * Third level is protocol number. > * > * Further levels are defined by the individual families. > */ > >/* > * PF_ROUTE - Routing table > * > * Three additional levels are defined: > * Fourth: address family, 0 is wildcard > * Fifth: type of info, defined below > * Sixth: flag(s) to mask with for NET_RT_FLAGS > */ >#define NET_RT_DUMP 1 /* dump; may limit to a.f. */ >#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ >#define NET_RT_IFLIST 3 /* survey interface list */ >#define NET_RT_IFMALIST 4 /* return multicast address list */ >#define NET_RT_IFLISTL 5 /* Survey interface list, using 'l'en > * versions of msghdr structs. */ >#endif /* __BSD_VISIBLE */ ># 397 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Maximum queue length specifiable by listen. > */ >#define SOMAXCONN 128 > >/* > * Message header for recvmsg and sendmsg calls. > * Used value-result for recvmsg, value only for sendmsg. > */ >struct msghdr { > void *msg_name; /* optional address */ > socklen_t msg_namelen; /* size of address */ > struct iovec *msg_iov; /* scatter/gather array */ > int msg_iovlen; /* # elements in msg_iov */ > void *msg_control; /* ancillary data, see below */ > socklen_t msg_controllen; /* ancillary data buffer len */ > int msg_flags; /* flags on received message */ >}; > >#define MSG_OOB 0x1 /* process out-of-band data */ >#define MSG_PEEK 0x2 /* peek at incoming message */ >#define MSG_DONTROUTE 0x4 /* send without using routing tables */ >#define MSG_EOR 0x8 /* data completes record */ >#define MSG_TRUNC 0x10 /* data discarded before delivery */ >#define MSG_CTRUNC 0x20 /* control data lost before delivery */ >#define MSG_WAITALL 0x40 /* wait for full request or error */ >#if __POSIX_VISIBLE >= 200809 >#define MSG_NOSIGNAL 0x20000 /* do not generate SIGPIPE on EOF */ >#endif ># 427 "/usr/src/ifnet/sys/sys/socket.h" >#if __BSD_VISIBLE >#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ >#define MSG_EOF 0x100 /* data completes connection */ >#define MSG_NOTIFICATION 0x2000 /* SCTP notification */ >#define MSG_NBIO 0x4000 /* FIONBIO mode, used by fifofs */ >#define MSG_COMPAT 0x8000 /* used in sendit() */ >#define MSG_CMSG_CLOEXEC 0x40000 /* make received fds close-on-exec */ >#endif ># 435 "/usr/src/ifnet/sys/sys/socket.h" >#ifdef _KERNEL >#define MSG_SOCALLBCK 0x10000 /* for use by socket callbacks - soreceive (TCP) */ >#endif ># 438 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * Header for ancillary data objects in msg_control buffer. > * Used for additional information with/about a datagram > * not expressible by flags. The format is a sequence > * of message elements headed by cmsghdr structures. > */ >struct cmsghdr { > socklen_t cmsg_len; /* data byte count, including hdr */ > int cmsg_level; /* originating protocol */ > int cmsg_type; /* protocol-specific type */ >/* followed by u_char cmsg_data[]; */ >}; > >#if __BSD_VISIBLE >/* > * While we may have more groups than this, the cmsgcred struct must > * be able to fit in an mbuf and we have historically supported a > * maximum of 16 groups. >*/ >#define CMGROUP_MAX 16 > >/* > * Credentials structure, used to verify the identity of a peer > * process that has sent us a message. This is allocated by the > * peer process but filled in by the kernel. This prevents the > * peer from lying about its identity. (Note that cmcred_groups[0] > * is the effective GID.) > */ >struct cmsgcred { > pid_t cmcred_pid; /* PID of sending process */ > uid_t cmcred_uid; /* real UID of sending process */ > uid_t cmcred_euid; /* effective UID of sending process */ > gid_t cmcred_gid; /* real GID of sending process */ > short cmcred_ngroups; /* number or groups */ > gid_t cmcred_groups[CMGROUP_MAX]; /* groups */ >}; > >/* > * Socket credentials. > */ >struct sockcred { > uid_t sc_uid; /* real user id */ > uid_t sc_euid; /* effective user id */ > gid_t sc_gid; /* real group id */ > gid_t sc_egid; /* effective group id */ > int sc_ngroups; /* number of supplemental groups */ > gid_t sc_groups[1]; /* variable length */ >}; > >/* > * Compute size of a sockcred structure with groups. > */ >#define SOCKCREDSIZE(ngrps) \ > (sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1))) > >#endif /* __BSD_VISIBLE */ ># 495 "/usr/src/ifnet/sys/sys/socket.h" > >/* given pointer to struct cmsghdr, return pointer to data */ >#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + \ > _ALIGN(sizeof(struct cmsghdr))) > >/* given pointer to struct cmsghdr, return pointer to next cmsghdr */ >#define CMSG_NXTHDR(mhdr, cmsg) \ > ((char *)(cmsg) == NULL ? CMSG_FIRSTHDR(mhdr) : \ > ((char *)(cmsg) + _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len) + \ > _ALIGN(sizeof(struct cmsghdr)) > \ > (char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ > (struct cmsghdr *)0 : \ > (struct cmsghdr *)(void *)((char *)(cmsg) + \ > _ALIGN(((struct cmsghdr *)(cmsg))->cmsg_len))) > >/* > * RFC 2292 requires to check msg_controllen, in case that the kernel returns > * an empty list for some reasons. > */ >#define CMSG_FIRSTHDR(mhdr) \ > ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ > (struct cmsghdr *)(mhdr)->msg_control : \ > (struct cmsghdr *)NULL) > >#if __BSD_VISIBLE >/* RFC 2292 additions */ >#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) >#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) >#endif ># 524 "/usr/src/ifnet/sys/sys/socket.h" > >#ifdef _KERNEL >#define CMSG_ALIGN(n) _ALIGN(n) >#endif ># 528 "/usr/src/ifnet/sys/sys/socket.h" > >/* "Socket"-level control message types: */ >#define SCM_RIGHTS 0x01 /* access rights (array of int) */ >#if __BSD_VISIBLE >#define SCM_TIMESTAMP 0x02 /* timestamp (struct timeval) */ >#define SCM_CREDS 0x03 /* process creds (struct cmsgcred) */ >#define SCM_BINTIME 0x04 /* timestamp (struct bintime) */ >#endif ># 536 "/usr/src/ifnet/sys/sys/socket.h" > >#if __BSD_VISIBLE >/* > * 4.3 compat sockaddr, move to compat file later > */ >struct osockaddr { > unsigned short sa_family; /* address family */ > char sa_data[14]; /* up to 14 bytes of direct address */ >}; > >/* > * 4.3-compat message header (move to compat file later). > */ >struct omsghdr { > char *msg_name; /* optional address */ > int msg_namelen; /* size of address */ > struct iovec *msg_iov; /* scatter/gather array */ > int msg_iovlen; /* # elements in msg_iov */ > char *msg_accrights; /* access rights sent/received */ > int msg_accrightslen; >}; >#endif ># 558 "/usr/src/ifnet/sys/sys/socket.h" > >/* > * howto arguments for shutdown(2), specified by Posix.1g. > */ >#define SHUT_RD 0 /* shut down the reading side */ >#define SHUT_WR 1 /* shut down the writing side */ >#define SHUT_RDWR 2 /* shut down both sides */ > >#if __BSD_VISIBLE >/* for SCTP */ >/* we cheat and use the SHUT_XX defines for these */ >#define PRU_FLUSH_RD SHUT_RD >#define PRU_FLUSH_WR SHUT_WR >#define PRU_FLUSH_RDWR SHUT_RDWR >#endif ># 573 "/usr/src/ifnet/sys/sys/socket.h" > > >#if __BSD_VISIBLE >/* > * sendfile(2) header/trailer struct > */ >struct sf_hdtr { > struct iovec *headers; /* pointer to an array of header struct iovec's */ > int hdr_cnt; /* number of header iovec's */ > struct iovec *trailers; /* pointer to an array of trailer struct iovec's */ > int trl_cnt; /* number of trailer iovec's */ >}; > >/* > * Sendfile-specific flag(s) > */ >#define SF_NODISKIO 0x00000001 >#define SF_MNOWAIT 0x00000002 >#define SF_SYNC 0x00000004 > >#ifdef _KERNEL >#define SFK_COMPAT 0x00000001 >#endif /* _KERNEL */ ># 596 "/usr/src/ifnet/sys/sys/socket.h" >#endif /* __BSD_VISIBLE */ ># 597 "/usr/src/ifnet/sys/sys/socket.h" > >#ifndef _KERNEL > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 600 "/usr/src/ifnet/sys/sys/socket.h" ># 601 "/usr/src/ifnet/sys/sys/socket.h" > >__BEGIN_DECLS >int accept(int, struct sockaddr * __restrict, socklen_t * __restrict); >int bind(int, const struct sockaddr *, socklen_t); >int connect(int, const struct sockaddr *, socklen_t); >#if __BSD_VISIBLE >int accept4(int, struct sockaddr * __restrict, socklen_t * __restrict, int); >int bindat(int, int, const struct sockaddr *, socklen_t); >int connectat(int, int, const struct sockaddr *, socklen_t); >#endif ># 611 "/usr/src/ifnet/sys/sys/socket.h" >int getpeername(int, struct sockaddr * __restrict, socklen_t * __restrict); >int getsockname(int, struct sockaddr * __restrict, socklen_t * __restrict); >int getsockopt(int, int, int, void * __restrict, socklen_t * __restrict); >int listen(int, int); >ssize_t recv(int, void *, size_t, int); >ssize_t recvfrom(int, void *, size_t, int, struct sockaddr * __restrict, socklen_t * __restrict); >ssize_t recvmsg(int, struct msghdr *, int); >ssize_t send(int, const void *, size_t, int); >ssize_t sendto(int, const void *, > size_t, int, const struct sockaddr *, socklen_t); >ssize_t sendmsg(int, const struct msghdr *, int); >#if __BSD_VISIBLE >int sendfile(int, int, off_t, size_t, struct sf_hdtr *, off_t *, int); >int setfib(int); >#endif ># 626 "/usr/src/ifnet/sys/sys/socket.h" >int setsockopt(int, int, int, const void *, socklen_t); >int shutdown(int, int); >int sockatmark(int); >int socket(int, int, int); >int socketpair(int, int, int, int *); >__END_DECLS > >#endif /* !_KERNEL */ ># 634 "/usr/src/ifnet/sys/sys/socket.h" > >#ifdef _KERNEL >struct socket; > >struct tcpcb *so_sototcpcb(struct socket *so); >struct inpcb *so_sotoinpcb(struct socket *so); >struct sockbuf *so_sockbuf_snd(struct socket *); >struct sockbuf *so_sockbuf_rcv(struct socket *); > >int so_state_get(const struct socket *); >void so_state_set(struct socket *, int); > >int so_options_get(const struct socket *); >void so_options_set(struct socket *, int); > >int so_error_get(const struct socket *); >void so_error_set(struct socket *, int); > >int so_linger_get(const struct socket *); >void so_linger_set(struct socket *, int); > >struct protosw *so_protosw_get(const struct socket *); >void so_protosw_set(struct socket *, struct protosw *); > >void so_sorwakeup_locked(struct socket *so); >void so_sowwakeup_locked(struct socket *so); > >void so_sorwakeup(struct socket *so); >void so_sowwakeup(struct socket *so); > >void so_lock(struct socket *so); >void so_unlock(struct socket *so); > >void so_listeners_apply_all(struct socket *so, void (*func)(struct socket *, void *), void *arg); > >#endif ># 670 "/usr/src/ifnet/sys/sys/socket.h" > > >#endif /* !_SYS_SOCKET_H_ */ ># 673 "/usr/src/ifnet/sys/sys/socket.h" ># 41 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sockio.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/sockio.h" 1 >/*- > * Copyright (c) 1982, 1986, 1990, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)sockio.h 8.1 (Berkeley) 3/28/94 > * $FreeBSD: projects/ifnet/sys/sys/sockio.h 281640 2015-04-17 05:55:07Z glebius $ > */ > >#ifndef _SYS_SOCKIO_H_ >#define _SYS_SOCKIO_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ioccom.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/sockio.h" ># 1 "/usr/src/ifnet/sys/sys/ioccom.h" 1 >/*- > * Copyright (c) 1982, 1986, 1990, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)ioccom.h 8.2 (Berkeley) 3/28/94 > * $FreeBSD: projects/ifnet/sys/sys/ioccom.h 206051 2010-04-01 16:21:35Z pjd $ > */ > >#ifndef _SYS_IOCCOM_H_ >#define _SYS_IOCCOM_H_ > >/* > * Ioctl's have the command encoded in the lower word, and the size of > * any in or out parameters in the upper word. The high 3 bits of the > * upper word are used to encode the in/out status of the parameter. > */ >#define IOCPARM_SHIFT 13 /* number of bits for ioctl size */ >#define IOCPARM_MASK ((1 << IOCPARM_SHIFT) - 1) /* parameter length mask */ >#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) >#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16)) >#define IOCGROUP(x) (((x) >> 8) & 0xff) > >#define IOCPARM_MAX (1 << IOCPARM_SHIFT) /* max size of ioctl */ >#define IOC_VOID 0x20000000 /* no parameters */ >#define IOC_OUT 0x40000000 /* copy out parameters */ >#define IOC_IN 0x80000000 /* copy in parameters */ >#define IOC_INOUT (IOC_IN|IOC_OUT) >#define IOC_DIRMASK (IOC_VOID|IOC_OUT|IOC_IN) > >#define _IOC(inout,group,num,len) ((unsigned long) \ > ((inout) | (((len) & IOCPARM_MASK) << 16) | ((group) << 8) | (num))) >#define _IO(g,n) _IOC(IOC_VOID, (g), (n), 0) >#define _IOWINT(g,n) _IOC(IOC_VOID, (g), (n), sizeof(int)) >#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t)) >#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t)) >/* this should be _IORW, but stdio got there first */ >#define _IOWR(g,n,t) _IOC(IOC_INOUT, (g), (n), sizeof(t)) > >#ifdef _KERNEL > >#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \ > defined(COMPAT_FREEBSD4) || defined(COMPAT_43) >#define IOCPARM_IVAL(x) ((int)(intptr_t)(void *)*(caddr_t *)(void *)(x)) >#endif ># 69 "/usr/src/ifnet/sys/sys/ioccom.h" > >#else ># 71 "/usr/src/ifnet/sys/sys/ioccom.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 72 "/usr/src/ifnet/sys/sys/ioccom.h" ># 73 "/usr/src/ifnet/sys/sys/ioccom.h" > >__BEGIN_DECLS >int ioctl(int, unsigned long, ...); >__END_DECLS > >#endif ># 79 "/usr/src/ifnet/sys/sys/ioccom.h" > >#endif /* !_SYS_IOCCOM_H_ */ ># 81 "/usr/src/ifnet/sys/sys/ioccom.h" ># 37 "/usr/src/ifnet/sys/sys/sockio.h" 2 > >/* Socket ioctl's. */ >#define SIOCSHIWAT _IOW('s', 0, int) /* set high watermark */ >#define SIOCGHIWAT _IOR('s', 1, int) /* get high watermark */ >#define SIOCSLOWAT _IOW('s', 2, int) /* set low watermark */ >#define SIOCGLOWAT _IOR('s', 3, int) /* get low watermark */ >#define SIOCATMARK _IOR('s', 7, int) /* at oob mark? */ >#define SIOCSPGRP _IOW('s', 8, int) /* set process group */ >#define SIOCGPGRP _IOR('s', 9, int) /* get process group */ > >/* SIOCADDRT _IOW('r', 10, struct ortentry) 4.3BSD */ >/* SIOCDELRT _IOW('r', 11, struct ortentry) 4.3BSD */ >#define SIOCGETVIFCNT _IOWR('r', 15, struct sioc_vif_req)/* get vif pkt cnt */ >#define SIOCGETSGCNT _IOWR('r', 16, struct sioc_sg_req) /* get s,g pkt cnt */ > >#define SIOCSIFADDR _IOW('i', 12, struct ifreq) /* set ifnet address */ >/* OSIOCGIFADDR _IOWR('i', 13, struct ifreq) 4.3BSD */ >#define SIOCGIFADDR _IOWR('i', 33, struct ifreq) /* get ifnet address */ >#define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ >/* OSIOCGIFDSTADDR _IOWR('i', 15, struct ifreq) 4.3BSD */ >#define SIOCGIFDSTADDR _IOWR('i', 34, struct ifreq) /* get p-p address */ >#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq) /* set ifnet flags */ >#define SIOCGIFFLAGS _IOWR('i', 17, struct ifreq) /* get ifnet flags */ >/* OSIOCGIFBRDADDR _IOWR('i', 18, struct ifreq) 4.3BSD */ >#define SIOCGIFBRDADDR _IOWR('i', 35, struct ifreq) /* get broadcast addr */ >#define SIOCSIFBRDADDR _IOW('i', 19, struct ifreq) /* set broadcast addr */ >/* OSIOCGIFCONF _IOWR('i', 20, struct ifconf) 4.3BSD */ >#define SIOCGIFCONF _IOWR('i', 36, struct ifconf) /* get ifnet list */ >/* OSIOCGIFNETMASK _IOWR('i', 21, struct ifreq) 4.3BSD */ >#define SIOCGIFNETMASK _IOWR('i', 37, struct ifreq) /* get net addr mask */ >#define SIOCSIFNETMASK _IOW('i', 22, struct ifreq) /* set net addr mask */ >#define SIOCGIFMETRIC _IOWR('i', 23, struct ifreq) /* get IF metric */ >#define SIOCSIFMETRIC _IOW('i', 24, struct ifreq) /* set IF metric */ >#define SIOCDIFADDR _IOW('i', 25, struct ifreq) /* delete IF addr */ >#define OSIOCAIFADDR _IOW('i', 26, struct oifaliasreq) /* FreeBSD 9.x */ >/* SIOCALIFADDR _IOW('i', 27, struct if_laddrreq) KAME */ >/* SIOCGLIFADDR _IOWR('i', 28, struct if_laddrreq) KAME */ >/* SIOCDLIFADDR _IOW('i', 29, struct if_laddrreq) KAME */ >#define SIOCSIFCAP _IOW('i', 30, struct ifreq) /* set IF features */ >#define SIOCGIFCAP _IOWR('i', 31, struct ifreq) /* get IF features */ >#define SIOCGIFINDEX _IOWR('i', 32, struct ifreq) /* get IF index */ >#define SIOCGIFMAC _IOWR('i', 38, struct ifreq) /* get IF MAC label */ >#define SIOCSIFMAC _IOW('i', 39, struct ifreq) /* set IF MAC label */ >#define SIOCSIFNAME _IOW('i', 40, struct ifreq) /* set IF name */ >#define SIOCSIFDESCR _IOW('i', 41, struct ifreq) /* set ifnet descr */ >#define SIOCGIFDESCR _IOWR('i', 42, struct ifreq) /* get ifnet descr */ >#define SIOCAIFADDR _IOW('i', 43, struct ifaliasreq)/* add/chg IF alias */ > >#define SIOCADDMULTI _IOW('i', 49, struct ifreq) /* add m'cast addr */ >#define SIOCDELMULTI _IOW('i', 50, struct ifreq) /* del m'cast addr */ >#define SIOCGIFMTU _IOWR('i', 51, struct ifreq) /* get IF mtu */ >#define SIOCSIFMTU _IOW('i', 52, struct ifreq) /* set IF mtu */ >#define SIOCGIFPHYS _IOWR('i', 53, struct ifreq) /* get IF wire */ >#define SIOCSIFPHYS _IOW('i', 54, struct ifreq) /* set IF wire */ >#define SIOCSIFMEDIA _IOWR('i', 55, struct ifreq) /* set net media */ >#define SIOCGIFMEDIA _IOWR('i', 56, struct ifmediareq) /* get net media */ > >#define SIOCSIFGENERIC _IOW('i', 57, struct ifreq) /* generic IF set op */ >#define SIOCGIFGENERIC _IOWR('i', 58, struct ifreq) /* generic IF get op */ > >#define SIOCGIFSTATUS _IOWR('i', 59, struct ifstat) /* get IF status */ >#define SIOCSIFLLADDR _IOW('i', 60, struct ifreq) /* set linklevel addr */ >#define SIOCGI2C _IOWR('i', 61, struct ifstat) /* get I2C data */ > >#define SIOCSIFPHYADDR _IOW('i', 70, struct ifaliasreq) /* set gif addres */ >#define SIOCGIFPSRCADDR _IOWR('i', 71, struct ifreq) /* get gif psrc addr */ >#define SIOCGIFPDSTADDR _IOWR('i', 72, struct ifreq) /* get gif pdst addr */ >#define SIOCDIFPHYADDR _IOW('i', 73, struct ifreq) /* delete gif addrs */ >/* SIOCSLIFPHYADDR _IOW('i', 74, struct if_laddrreq) KAME */ >/* SIOCGLIFPHYADDR _IOWR('i', 75, struct if_laddrreq) KAME */ > >#define SIOCGPRIVATE_0 _IOWR('i', 80, struct ifreq) /* device private 0 */ >#define SIOCGPRIVATE_1 _IOWR('i', 81, struct ifreq) /* device private 1 */ > >#define SIOCSIFVNET _IOWR('i', 90, struct ifreq) /* move IF jail/vnet */ >#define SIOCSIFRVNET _IOWR('i', 91, struct ifreq) /* reclaim vnet IF */ > >#define SIOCGIFFIB _IOWR('i', 92, struct ifreq) /* get IF fib */ >#define SIOCSIFFIB _IOW('i', 93, struct ifreq) /* set IF fib */ > >#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific > parameters */ >#define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific > parameters */ > >#define SIOCIFCREATE _IOWR('i', 122, struct ifreq) /* create clone if */ >#define SIOCIFCREATE2 _IOWR('i', 124, struct ifreq) /* create clone if */ >#define SIOCIFDESTROY _IOW('i', 121, struct ifreq) /* destroy clone if */ >#define SIOCIFGCLONERS _IOWR('i', 120, struct if_clonereq) /* get cloners */ > >#define SIOCAIFGROUP _IOW('i', 135, struct ifgroupreq) /* add an ifgroup */ >#define SIOCGIFGROUP _IOWR('i', 136, struct ifgroupreq) /* get ifgroups */ >#define SIOCDIFGROUP _IOW('i', 137, struct ifgroupreq) /* delete ifgroup */ >#define SIOCGIFGMEMB _IOWR('i', 138, struct ifgroupreq) /* get members */ >#define SIOCGIFXMEDIA _IOWR('i', 139, struct ifmediareq) /* get net xmedia */ > >#endif /* !_SYS_SOCKIO_H_ */ ># 134 "/usr/src/ifnet/sys/sys/sockio.h" ># 42 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/malloc.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/malloc.h" 1 >/*- > * Copyright (c) 1987, 1993 > * The Regents of the University of California. > * Copyright (c) 2005, 2009 Robert N. M. Watson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)malloc.h 8.5 (Berkeley) 5/3/95 > * $FreeBSD: projects/ifnet/sys/sys/malloc.h 281640 2015-04-17 05:55:07Z glebius $ > */ > >#ifndef _SYS_MALLOC_H_ >#define _SYS_MALLOC_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/malloc.h" ># 39 "/usr/src/ifnet/sys/sys/malloc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/malloc.h" ># 40 "/usr/src/ifnet/sys/sys/malloc.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/malloc.h" ># 1 "/usr/src/ifnet/sys/sys/_lock.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_lock.h 179025 2008-05-15 20:10:06Z attilio $ > */ > >#ifndef _SYS__LOCK_H_ >#define _SYS__LOCK_H_ > >struct lock_object { > const char *lo_name; /* Individual lock name. */ > u_int lo_flags; > u_int lo_data; /* General class specific data. */ > struct witness *lo_witness; /* Data for witness. */ >}; > >#endif /* !_SYS__LOCK_H_ */ ># 42 "/usr/src/ifnet/sys/sys/_lock.h" ># 41 "/usr/src/ifnet/sys/sys/malloc.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/malloc.h" ># 1 "/usr/src/ifnet/sys/sys/_mutex.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_mutex.h 242901 2012-11-11 23:25:47Z attilio $ > */ > >#ifndef _SYS__MUTEX_H_ >#define _SYS__MUTEX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/ifnet/sys/sys/_mutex.h" ># 35 "/usr/src/ifnet/sys/sys/_mutex.h" > >/* > * Sleep/spin mutex. > * > * All mutex implementations must always have a member called mtx_lock. > * Other locking primitive structures are not allowed to use this name > * for their members. > * If this rule needs to change, the bits in the mutex implementation must > * be modified appropriately. > */ >struct mtx { > struct lock_object lock_object; /* Common lock properties. */ > volatile uintptr_t mtx_lock; /* Owner and flags. */ >}; > >/* > * Members of struct mtx_padalign must mirror members of struct mtx. > * mtx_padalign mutexes can use the mtx(9) API transparently without > * modification. > * Pad-aligned mutexes used within structures should generally be the > * first member of the struct. Otherwise, the compiler can generate > * additional padding for the struct to keep a correct alignment for > * the mutex. > */ >struct mtx_padalign { > struct lock_object lock_object; /* Common lock properties. */ > volatile uintptr_t mtx_lock; /* Owner and flags. */ >} __aligned(CACHE_LINE_SIZE); > >#endif /* !_SYS__MUTEX_H_ */ ># 65 "/usr/src/ifnet/sys/sys/_mutex.h" ># 42 "/usr/src/ifnet/sys/sys/malloc.h" 2 > >#define MINALLOCSIZE UMA_SMALLEST_UNIT > >/* > * flags to malloc. > */ >#define M_NOWAIT 0x0001 /* do not block */ >#define M_WAITOK 0x0002 /* ok to block */ >#define M_ZERO 0x0100 /* bzero the allocation */ >#define M_NOVM 0x0200 /* don't ask VM for pages */ >#define M_USE_RESERVE 0x0400 /* can alloc out of reserve memory */ >#define M_NODUMP 0x0800 /* don't dump pages in this allocation */ >#define M_FIRSTFIT 0x1000 /* Only for vmem, fast fit. */ >#define M_BESTFIT 0x2000 /* Only for vmem, low fragmentation. */ > >#define M_MAGIC 877983977 /* time when first defined :-) */ > >/* > * Two malloc type structures are present: malloc_type, which is used by a > * type owner to declare the type, and malloc_type_internal, which holds > * malloc-owned statistics and other ABI-sensitive fields, such as the set of > * malloc statistics indexed by the compile-time MAXCPU constant. > * Applications should avoid introducing dependence on the allocator private > * data layout and size. > * > * The malloc_type ks_next field is protected by malloc_mtx. Other fields in > * malloc_type are static after initialization so unsynchronized. > * > * Statistics in malloc_type_stats are written only when holding a critical > * section and running on the CPU associated with the index into the stat > * array, but read lock-free resulting in possible (minor) races, which the > * monitoring app should take into account. > */ >struct malloc_type_stats { > uint64_t mts_memalloced; /* Bytes allocated on CPU. */ > uint64_t mts_memfreed; /* Bytes freed on CPU. */ > uint64_t mts_numallocs; /* Number of allocates on CPU. */ > uint64_t mts_numfrees; /* number of frees on CPU. */ > uint64_t mts_size; /* Bitmask of sizes allocated on CPU. */ > uint64_t _mts_reserved1; /* Reserved field. */ > uint64_t _mts_reserved2; /* Reserved field. */ > uint64_t _mts_reserved3; /* Reserved field. */ >}; > >/* > * Index definitions for the mti_probes[] array. > */ >#define DTMALLOC_PROBE_MALLOC 0 >#define DTMALLOC_PROBE_FREE 1 >#define DTMALLOC_PROBE_MAX 2 > >struct malloc_type_internal { > uint32_t mti_probes[DTMALLOC_PROBE_MAX]; > /* DTrace probe ID array. */ > u_char mti_zone; > struct malloc_type_stats mti_stats[MAXCPU]; >}; > >/* > * Public data structure describing a malloc type. Private data is hung off > * of ks_handle to avoid encoding internal malloc(9) data structures in > * modules, which will statically allocate struct malloc_type. > */ >struct malloc_type { > struct malloc_type *ks_next; /* Next in global chain. */ > u_long ks_magic; /* Detect programmer error. */ > const char *ks_shortdesc; /* Printable type name. */ > void *ks_handle; /* Priv. data, was lo_class. */ >}; > >/* > * Statistics structure headers for user space. The kern.malloc sysctl > * exposes a structure stream consisting of a stream header, then a series of > * malloc type headers and statistics structures (quantity maxcpus). For > * convenience, the kernel will provide the current value of maxcpus at the > * head of the stream. > */ >#define MALLOC_TYPE_STREAM_VERSION 0x00000001 >struct malloc_type_stream_header { > uint32_t mtsh_version; /* Stream format version. */ > uint32_t mtsh_maxcpus; /* Value of MAXCPU for stream. */ > uint32_t mtsh_count; /* Number of records. */ > uint32_t _mtsh_pad; /* Pad/reserved field. */ >}; > >#define MALLOC_MAX_NAME 32 >struct malloc_type_header { > char mth_name[MALLOC_MAX_NAME]; >}; > >#ifdef _KERNEL >#define MALLOC_DEFINE(type, shortdesc, longdesc) \ > struct malloc_type type[1] = { \ > { NULL, M_MAGIC, shortdesc, NULL } \ > }; \ > SYSINIT(type##_init, SI_SUB_KMEM, SI_ORDER_THIRD, malloc_init, \ > type); \ > SYSUNINIT(type##_uninit, SI_SUB_KMEM, SI_ORDER_ANY, \ > malloc_uninit, type) > >#define MALLOC_DECLARE(type) \ > extern struct malloc_type type[1] > >MALLOC_DECLARE(M_CACHE); >MALLOC_DECLARE(M_DEVBUF); >MALLOC_DECLARE(M_TEMP); > >MALLOC_DECLARE(M_IP6OPT); /* for INET6 */ >MALLOC_DECLARE(M_IP6NDP); /* for INET6 */ > >/* > * Deprecated macro versions of not-quite-malloc() and free(). > */ >#define MALLOC(space, cast, size, type, flags) \ > ((space) = (cast)malloc((u_long)(size), (type), (flags))) >#define FREE(addr, type) free((addr), (type)) > >/* > * XXX this should be declared in <sys/uio.h>, but that tends to fail > * because <sys/uio.h> is included in a header before the source file > * has a chance to include <sys/malloc.h> to get MALLOC_DECLARE() defined. > */ >MALLOC_DECLARE(M_IOV); > >extern struct mtx malloc_mtx; > >/* > * Function type used when iterating over the list of malloc types. > */ >typedef void malloc_type_list_func_t(struct malloc_type *, void *); > >void contigfree(void *addr, unsigned long size, struct malloc_type *type); >void *contigmalloc(unsigned long size, struct malloc_type *type, int flags, > vm_paddr_t low, vm_paddr_t high, unsigned long alignment, > vm_paddr_t boundary) __malloc_like __result_use_check > __alloc_size(1); >void free(void *addr, struct malloc_type *type); >void *malloc(unsigned long size, struct malloc_type *type, int flags) > __malloc_like __result_use_check __alloc_size(1); >void malloc_init(void *); >int malloc_last_fail(void); >void malloc_type_allocated(struct malloc_type *type, unsigned long size); >void malloc_type_freed(struct malloc_type *type, unsigned long size); >void malloc_type_list(malloc_type_list_func_t *, void *); >void malloc_uninit(void *); >void *realloc(void *addr, unsigned long size, struct malloc_type *type, > int flags) __result_use_check __alloc_size(2); >void *reallocf(void *addr, unsigned long size, struct malloc_type *type, > int flags) __alloc_size(2); > >struct malloc_type *malloc_desc2type(const char *desc); >#endif /* _KERNEL */ ># 194 "/usr/src/ifnet/sys/sys/malloc.h" > >#endif /* !_SYS_MALLOC_H_ */ ># 196 "/usr/src/ifnet/sys/sys/malloc.h" ># 43 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/module.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/module.h" 1 >/*- > * Copyright (c) 1997 Doug Rabson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/module.h 281640 2015-04-17 05:55:07Z glebius $ > */ > >#ifndef _SYS_MODULE_H_ >#define _SYS_MODULE_H_ > >/* > * Module metadata types > */ >#define MDT_DEPEND 1 /* argument is a module name */ >#define MDT_MODULE 2 /* module declaration */ >#define MDT_VERSION 3 /* module version(s) */ >#define MDT_PNP_INFO 4 /* Plug and play hints record */ > >#define MDT_STRUCT_VERSION 1 /* version of metadata structure */ >#define MDT_SETNAME "modmetadata_set" > >typedef enum modeventtype { > MOD_LOAD, > MOD_UNLOAD, > MOD_SHUTDOWN, > MOD_QUIESCE >} modeventtype_t; > >typedef struct module *module_t; >typedef int (*modeventhand_t)(module_t, int /* modeventtype_t */, void *); > >/* > * Struct for registering modules statically via SYSINIT. > */ >typedef struct moduledata { > const char *name; /* module name */ > modeventhand_t evhand; /* event handler */ > void *priv; /* extra data */ >} moduledata_t; > >/* > * A module can use this to report module specific data to the user via > * kldstat(2). > */ >typedef union modspecific { > int intval; > u_int uintval; > long longval; > u_long ulongval; >} modspecific_t; > >/* > * Module dependency declaration > */ >struct mod_depend { > int md_ver_minimum; > int md_ver_preferred; > int md_ver_maximum; >}; > >/* > * Module version declaration > */ >struct mod_version { > int mv_version; >}; > >struct mod_metadata { > int md_version; /* structure version MDTV_* */ > int md_type; /* type of entry MDT_* */ > void *md_data; /* specific data */ > const char *md_cval; /* common string label */ >}; > >#ifdef _KERNEL > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/linker_set.h> >#endif /* expanded by -frewrite-includes */ ># 98 "/usr/src/ifnet/sys/sys/module.h" ># 1 "/usr/src/ifnet/sys/sys/linker_set.h" 1 >/*- > * Copyright (c) 1999 John D. Polstra > * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/linker_set.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _SYS_LINKER_SET_H_ >#define _SYS_LINKER_SET_H_ > >#ifndef _SYS_CDEFS_H_ >#error this file needs sys/cdefs.h as a prerequisite >#endif ># 36 "/usr/src/ifnet/sys/sys/linker_set.h" > >/* > * The following macros are used to declare global sets of objects, which > * are collected by the linker into a `linker_set' as defined below. > * For ELF, this is done by constructing a separate segment for each set. > */ > >#if defined(__powerpc64__) >/* > * Move the symbol pointer from ".text" to ".data" segment, to make > * the GCC compiler happy: > */ >#define __MAKE_SET_CONST >#else ># 50 "/usr/src/ifnet/sys/sys/linker_set.h" >#define __MAKE_SET_CONST const >#endif ># 52 "/usr/src/ifnet/sys/sys/linker_set.h" > >/* > * Private macros, not to be used outside this header file. > */ >#ifdef __GNUCLIKE___SECTION >#define __MAKE_SET(set, sym) \ > __GLOBL(__CONCAT(__start_set_,set)); \ > __GLOBL(__CONCAT(__stop_set_,set)); \ > static void const * __MAKE_SET_CONST \ > __set_##set##_sym_##sym __section("set_" #set) \ > __used = &(sym) >#else /* !__GNUCLIKE___SECTION */ ># 64 "/usr/src/ifnet/sys/sys/linker_set.h" >#ifndef lint >#error this file needs to be ported to your compiler >#endif /* lint */ ># 67 "/usr/src/ifnet/sys/sys/linker_set.h" >#define __MAKE_SET(set, sym) extern void const * const (__set_##set##_sym_##sym) >#endif /* __GNUCLIKE___SECTION */ ># 69 "/usr/src/ifnet/sys/sys/linker_set.h" > >/* > * Public macros. > */ >#define TEXT_SET(set, sym) __MAKE_SET(set, sym) >#define DATA_SET(set, sym) __MAKE_SET(set, sym) >#define BSS_SET(set, sym) __MAKE_SET(set, sym) >#define ABS_SET(set, sym) __MAKE_SET(set, sym) >#define SET_ENTRY(set, sym) __MAKE_SET(set, sym) > >/* > * Initialize before referring to a given linker set. > */ >#define SET_DECLARE(set, ptype) \ > extern ptype __weak *__CONCAT(__start_set_,set); \ > extern ptype __weak *__CONCAT(__stop_set_,set) > >#define SET_BEGIN(set) \ > (&__CONCAT(__start_set_,set)) >#define SET_LIMIT(set) \ > (&__CONCAT(__stop_set_,set)) > >/* > * Iterate over all the elements of a set. > * > * Sets always contain addresses of things, and "pvar" points to words > * containing those addresses. Thus is must be declared as "type **pvar", > * and the address of each set item is obtained inside the loop by "*pvar". > */ >#define SET_FOREACH(pvar, set) \ > for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++) > >#define SET_ITEM(set, i) \ > ((SET_BEGIN(set))[i]) > >/* > * Provide a count of the items in a set. > */ >#define SET_COUNT(set) \ > (SET_LIMIT(set) - SET_BEGIN(set)) > >#endif /* _SYS_LINKER_SET_H_ */ ># 111 "/usr/src/ifnet/sys/sys/linker_set.h" ># 99 "/usr/src/ifnet/sys/sys/module.h" 2 > >#define MODULE_METADATA(uniquifier, type, data, cval) \ > static struct mod_metadata _mod_metadata##uniquifier = { \ > MDT_STRUCT_VERSION, \ > type, \ > data, \ > cval \ > }; \ > DATA_SET(modmetadata_set, _mod_metadata##uniquifier) > >#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \ > static struct mod_depend _##module##_depend_on_##mdepend = { \ > vmin, \ > vpref, \ > vmax \ > }; \ > MODULE_METADATA(_md_##module##_on_##mdepend, MDT_DEPEND, \ > &_##module##_depend_on_##mdepend, #mdepend) > >/* > * Every kernel has a 'kernel' module with the version set to > * __FreeBSD_version. We embed a MODULE_DEPEND() inside every module > * that depends on the 'kernel' module. It uses the current value of > * __FreeBSD_version as the minimum and preferred versions. For the > * maximum version it rounds the version up to the end of its branch > * (i.e. M99999 for M.x). This allows a module built on M.x to work > * on M.y systems where y >= x, but fail on M.z systems where z < x. > */ >#define MODULE_KERNEL_MAXVER (roundup(__FreeBSD_version, 100000) - 1) > >#define DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, maxver) \ > MODULE_DEPEND(name, kernel, __FreeBSD_version, \ > __FreeBSD_version, maxver); \ > MODULE_METADATA(_md_##name, MDT_MODULE, &data, #name); \ > SYSINIT(name##module, sub, order, module_register_init, &data); \ > struct __hack > >#define DECLARE_MODULE(name, data, sub, order) \ > DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, MODULE_KERNEL_MAXVER) > >/* > * The module declared with DECLARE_MODULE_TIED can only be loaded > * into the kernel with exactly the same __FreeBSD_version. > * > * Use it for modules that use kernel interfaces that are not stable > * even on STABLE/X branches. > */ >#define DECLARE_MODULE_TIED(name, data, sub, order) \ > DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version) > >#define MODULE_VERSION(module, version) \ > static struct mod_version _##module##_version = { \ > version \ > }; \ > MODULE_METADATA(_##module##_version, MDT_VERSION, \ > &_##module##_version, #module) > >extern struct sx modules_sx; > >#define MOD_XLOCK sx_xlock(&modules_sx) >#define MOD_SLOCK sx_slock(&modules_sx) >#define MOD_XUNLOCK sx_xunlock(&modules_sx) >#define MOD_SUNLOCK sx_sunlock(&modules_sx) >#define MOD_LOCK_ASSERT sx_assert(&modules_sx, SX_LOCKED) >#define MOD_XLOCK_ASSERT sx_assert(&modules_sx, SX_XLOCKED) > >struct linker_file; > >void module_register_init(const void *); >int module_register(const struct moduledata *, struct linker_file *); >module_t module_lookupbyname(const char *); >module_t module_lookupbyid(int); >int module_quiesce(module_t); >void module_reference(module_t); >void module_release(module_t); >int module_unload(module_t); >int module_getid(module_t); >module_t module_getfnext(module_t); >const char * module_getname(module_t); >void module_setspecific(module_t, modspecific_t *); >struct linker_file *module_file(module_t); > >#ifdef MOD_DEBUG >extern int mod_debug; >#define MOD_DEBUG_REFS 1 > >#define MOD_DPF(cat, args) do { \ > if (mod_debug & MOD_DEBUG_##cat) \ > printf(args); \ >} while (0) > >#else /* !MOD_DEBUG */ ># 191 "/usr/src/ifnet/sys/sys/module.h" > >#define MOD_DPF(cat, args) >#endif ># 194 "/usr/src/ifnet/sys/sys/module.h" >#endif /* _KERNEL */ ># 195 "/usr/src/ifnet/sys/sys/module.h" > >#define MAXMODNAME 32 > >struct module_stat { > int version; /* set to sizeof(struct module_stat) */ > char name[MAXMODNAME]; > int refs; > int id; > modspecific_t data; >}; > >#ifndef _KERNEL > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 208 "/usr/src/ifnet/sys/sys/module.h" ># 209 "/usr/src/ifnet/sys/sys/module.h" > >__BEGIN_DECLS >int modnext(int _modid); >int modfnext(int _modid); >int modstat(int _modid, struct module_stat *_stat); >int modfind(const char *_name); >__END_DECLS > >#endif ># 218 "/usr/src/ifnet/sys/sys/module.h" > >#endif /* !_SYS_MODULE_H_ */ ># 220 "/usr/src/ifnet/sys/sys/module.h" ># 44 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sysctl.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/sys/sysctl.h" 1 >/*- > * Copyright (c) 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * Mike Karels at Berkeley Software Design, Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)sysctl.h 8.1 (Berkeley) 6/2/93 > * $FreeBSD: projects/ifnet/sys/sys/sysctl.h 280170 2015-03-17 12:40:26Z glebius $ > */ > >#ifndef _SYS_SYSCTL_H_ >#define _SYS_SYSCTL_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/sysctl.h" ># 40 "/usr/src/ifnet/sys/sys/sysctl.h" > >struct thread; >/* > * Definitions for sysctl call. The sysctl call uses a hierarchical name > * for objects that can be examined or modified. The name is expressed as > * a sequence of integers. Like a file path name, the meaning of each > * component depends on its place in the hierarchy. The top-level and kern > * identifiers are defined here, and other identifiers are defined in the > * respective subsystem header files. > */ > >#define CTL_MAXNAME 24 /* largest number of components supported */ > >/* > * Each subsystem defined by sysctl defines a list of variables > * for that subsystem. Each name is either a node with further > * levels defined below it, or it is a leaf of some particular > * type given below. Each sysctl level defines a set of name/type > * pairs to be used by sysctl(8) in manipulating the subsystem. > */ >struct ctlname { > char *ctl_name; /* subsystem name */ > int ctl_type; /* type of name */ >}; > >#define CTLTYPE 0xf /* mask for the type */ >#define CTLTYPE_NODE 1 /* name is a node */ >#define CTLTYPE_INT 2 /* name describes an integer */ >#define CTLTYPE_STRING 3 /* name describes a string */ >#define CTLTYPE_S64 4 /* name describes a signed 64-bit number */ >#define CTLTYPE_OPAQUE 5 /* name describes a structure */ >#define CTLTYPE_STRUCT CTLTYPE_OPAQUE /* name describes a structure */ >#define CTLTYPE_UINT 6 /* name describes an unsigned integer */ >#define CTLTYPE_LONG 7 /* name describes a long */ >#define CTLTYPE_ULONG 8 /* name describes an unsigned long */ >#define CTLTYPE_U64 9 /* name describes an unsigned 64-bit number */ > >#define CTLFLAG_RD 0x80000000 /* Allow reads of variable */ >#define CTLFLAG_WR 0x40000000 /* Allow writes to the variable */ >#define CTLFLAG_RW (CTLFLAG_RD|CTLFLAG_WR) >#define CTLFLAG_ANYBODY 0x10000000 /* All users can set this var */ >#define CTLFLAG_SECURE 0x08000000 /* Permit set only if securelevel<=0 */ >#define CTLFLAG_PRISON 0x04000000 /* Prisoned roots can fiddle */ >#define CTLFLAG_DYN 0x02000000 /* Dynamic oid - can be freed */ >#define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ >#define CTLMASK_SECURE 0x00F00000 /* Secure level */ >#define CTLFLAG_TUN 0x00080000 /* Default value is loaded from getenv() */ >#define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) >#define CTLFLAG_RWTUN (CTLFLAG_RW|CTLFLAG_TUN) >#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ >#define CTLFLAG_VNET 0x00020000 /* Prisons with vnet can fiddle */ >#define CTLFLAG_DYING 0x00010000 /* Oid is being removed */ >#define CTLFLAG_CAPRD 0x00008000 /* Can be read in capability mode */ >#define CTLFLAG_CAPWR 0x00004000 /* Can be written in capability mode */ >#define CTLFLAG_STATS 0x00002000 /* Statistics, not a tuneable */ >#define CTLFLAG_NOFETCH 0x00001000 /* Don't fetch tunable from getenv() */ >#define CTLFLAG_CAPRW (CTLFLAG_CAPRD|CTLFLAG_CAPWR) > >/* > * Secure level. Note that CTLFLAG_SECURE == CTLFLAG_SECURE1. > * > * Secure when the securelevel is raised to at least N. > */ >#define CTLSHIFT_SECURE 20 >#define CTLFLAG_SECURE1 (CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE)) >#define CTLFLAG_SECURE2 (CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE)) >#define CTLFLAG_SECURE3 (CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE)) > >/* > * USE THIS instead of a hardwired number from the categories below > * to get dynamically assigned sysctl entries using the linker-set > * technology. This is the way nearly all new sysctl variables should > * be implemented. > * e.g. SYSCTL_INT(_parent, OID_AUTO, name, CTLFLAG_RW, &variable, 0, ""); > */ >#define OID_AUTO (-1) > >/* > * The starting number for dynamically-assigned entries. WARNING! > * ALL static sysctl entries should have numbers LESS than this! > */ >#define CTL_AUTO_START 0x100 > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/linker_set.h> >#endif /* expanded by -frewrite-includes */ ># 124 "/usr/src/ifnet/sys/sys/sysctl.h" ># 125 "/usr/src/ifnet/sys/sys/sysctl.h" > >#ifdef KLD_MODULE >/* XXX allow overspecification of type in external kernel modules */ >#define SYSCTL_CT_ASSERT_MASK CTLTYPE >#else ># 130 "/usr/src/ifnet/sys/sys/sysctl.h" >#define SYSCTL_CT_ASSERT_MASK 0 >#endif ># 132 "/usr/src/ifnet/sys/sys/sysctl.h" > >#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \ > intptr_t arg2, struct sysctl_req *req > >/* definitions for sysctl_req 'lock' member */ >#define REQ_UNWIRED 1 >#define REQ_WIRED 2 > >/* definitions for sysctl_req 'flags' member */ >#if defined(__amd64__) || defined(__powerpc64__) ||\ > (defined(__mips__) && defined(__mips_n64)) >#define SCTL_MASK32 1 /* 32 bit emulation */ >#endif ># 145 "/usr/src/ifnet/sys/sys/sysctl.h" > >/* > * This describes the access space for a sysctl request. This is needed > * so that we can use the interface from the kernel or from user-space. > */ >struct sysctl_req { > struct thread *td; /* used for access checking */ > int lock; /* wiring state */ > void *oldptr; > size_t oldlen; > size_t oldidx; > int (*oldfunc)(struct sysctl_req *, const void *, size_t); > void *newptr; > size_t newlen; > size_t newidx; > int (*newfunc)(struct sysctl_req *, void *, size_t); > size_t validlen; > int flags; >}; > >SLIST_HEAD(sysctl_oid_list, sysctl_oid); > >/* > * This describes one "oid" in the MIB tree. Potentially more nodes can > * be hidden behind it, expanded by the handler. > */ >struct sysctl_oid { > struct sysctl_oid_list oid_children; > struct sysctl_oid_list *oid_parent; > SLIST_ENTRY(sysctl_oid) oid_link; > int oid_number; > u_int oid_kind; > void *oid_arg1; > intptr_t oid_arg2; > const char *oid_name; > int (*oid_handler)(SYSCTL_HANDLER_ARGS); > const char *oid_fmt; > int oid_refcnt; > u_int oid_running; > const char *oid_descr; >}; > >#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l) >#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l) >#define SYSCTL_OUT_STR(r, p) (r->oldfunc)(r, p, strlen(p) + 1) > >int sysctl_handle_int(SYSCTL_HANDLER_ARGS); >int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS); >int sysctl_handle_long(SYSCTL_HANDLER_ARGS); >int sysctl_handle_64(SYSCTL_HANDLER_ARGS); >int sysctl_handle_string(SYSCTL_HANDLER_ARGS); >int sysctl_handle_opaque(SYSCTL_HANDLER_ARGS); >int sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS); > >int sysctl_handle_uma_zone_max(SYSCTL_HANDLER_ARGS); >int sysctl_handle_uma_zone_cur(SYSCTL_HANDLER_ARGS); > >int sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS); >int sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS); >int sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS); > >/* > * These functions are used to add/remove an oid from the mib. > */ >void sysctl_register_oid(struct sysctl_oid *oidp); >void sysctl_unregister_oid(struct sysctl_oid *oidp); > >/* Declare a static oid to allow child oids to be added to it. */ >#define SYSCTL_DECL(name) \ > extern struct sysctl_oid sysctl__##name > >/* Hide these in macros. */ >#define SYSCTL_CHILDREN(oid_ptr) (&(oid_ptr)->oid_children) >#define SYSCTL_PARENT(oid_ptr) \ > (((oid_ptr)->oid_parent != &sysctl__children) ? \ > __containerof((oid_ptr)->oid_parent, struct sysctl_oid, \ > oid_children) : (struct sysctl_oid *)NULL) >#define SYSCTL_STATIC_CHILDREN(oid_name) (&sysctl__##oid_name.oid_children) > >/* === Structs and macros related to context handling. === */ > >/* All dynamically created sysctls can be tracked in a context list. */ >struct sysctl_ctx_entry { > struct sysctl_oid *entry; > TAILQ_ENTRY(sysctl_ctx_entry) link; >}; > >TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); > >#define SYSCTL_NODE_CHILDREN(parent, name) \ > sysctl__##parent##_##name.oid_children > >#ifndef NO_SYSCTL_DESCR >#define __DESCR(d) d >#else ># 240 "/usr/src/ifnet/sys/sys/sysctl.h" >#define __DESCR(d) "" >#endif ># 242 "/usr/src/ifnet/sys/sys/sysctl.h" > >/* This macro is only for internal use */ >#define SYSCTL_OID_RAW(id, parent_child_head, nbr, name, kind, a1, a2, handler, fmt, descr) \ > struct sysctl_oid id = { \ > .oid_parent = (parent_child_head), \ > .oid_children = SLIST_HEAD_INITIALIZER(&id.oid_children), \ > .oid_number = (nbr), \ > .oid_kind = (kind), \ > .oid_arg1 = (a1), \ > .oid_arg2 = (a2), \ > .oid_name = (name), \ > .oid_handler = (handler), \ > .oid_fmt = (fmt), \ > .oid_descr = __DESCR(descr) \ > }; \ > DATA_SET(sysctl_set, id) > >/* This constructs a static "raw" MIB oid. */ >#define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > static SYSCTL_OID_RAW(sysctl__##parent##_##name, \ > SYSCTL_CHILDREN(&sysctl__##parent), \ > nbr, #name, kind, a1, a2, handler, fmt, descr) > >/* This constructs a global "raw" MIB oid. */ >#define SYSCTL_OID_GLOBAL(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > SYSCTL_OID_RAW(sysctl__##parent##_##name, \ > SYSCTL_CHILDREN(&sysctl__##parent), \ > nbr, #name, kind, a1, a2, handler, fmt, descr) > >#define SYSCTL_ADD_OID(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ > sysctl_add_oid(ctx, parent, nbr, name, kind, a1, a2, handler, fmt, __DESCR(descr)) > >/* This constructs a root node from which other nodes can hang. */ >#define SYSCTL_ROOT_NODE(nbr, name, access, handler, descr) \ > SYSCTL_OID_RAW(sysctl___##name, &sysctl__children, \ > nbr, #name, CTLTYPE_NODE|(access), NULL, 0, \ > handler, "N", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) > >/* This constructs a node from which other oids can hang. */ >#define SYSCTL_NODE(parent, nbr, name, access, handler, descr) \ > SYSCTL_OID_GLOBAL(parent, nbr, name, CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE) > >#define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", __DESCR(descr)); \ >}) > >#define SYSCTL_ADD_ROOT_NODE(ctx, nbr, name, access, handler, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_NODE); \ > sysctl_add_oid(ctx, &sysctl__children, nbr, name, \ > CTLTYPE_NODE|(access), \ > NULL, 0, handler, "N", __DESCR(descr)); \ >}) > >/* Oid for a string. len can be 0 to indicate '\0' termination. */ >#define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), \ > arg, len, sysctl_handle_string, "A", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING) > >#define SYSCTL_ADD_STRING(ctx, parent, nbr, name, access, arg, len, descr) \ >({ \ > char *__arg = (arg); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_STRING); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access), \ > __arg, len, sysctl_handle_string, "A", __DESCR(descr)); \ >}) > >/* Oid for an int. If ptr is SYSCTL_NULL_INT_PTR, val is returned. */ >#define SYSCTL_NULL_INT_PTR ((int *)NULL) >#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_int, "I", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) && \ > sizeof(int) == sizeof(*(ptr))) > >#define SYSCTL_ADD_INT(ctx, parent, nbr, name, access, ptr, val, descr) \ >({ \ > int *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > __ptr, val, sysctl_handle_int, "I", __DESCR(descr)); \ >}) > >/* Oid for an unsigned int. If ptr is NULL, val is returned. */ >#define SYSCTL_NULL_UINT_PTR ((unsigned *)NULL) >#define SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_int, "IU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT) && \ > sizeof(unsigned) == sizeof(*(ptr))) > >#define SYSCTL_ADD_UINT(ctx, parent, nbr, name, access, ptr, val, descr) \ >({ \ > unsigned *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_UINT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > __ptr, val, sysctl_handle_int, "IU", __DESCR(descr)); \ >}) > >/* Oid for a long. The pointer must be non NULL. */ >#define SYSCTL_NULL_LONG_PTR ((long *)NULL) >#define SYSCTL_LONG(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_long, "L", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG) && \ > sizeof(long) == sizeof(*(ptr))) > >#define SYSCTL_ADD_LONG(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > long *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_LONG); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_LONG | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_long, "L", __DESCR(descr)); \ >}) > >/* Oid for an unsigned long. The pointer must be non NULL. */ >#define SYSCTL_NULL_ULONG_PTR ((unsigned long *)NULL) >#define SYSCTL_ULONG(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_long, "LU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG) && \ > sizeof(unsigned long) == sizeof(*(ptr))) > >#define SYSCTL_ADD_ULONG(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > unsigned long *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_ULONG); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_ULONG | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_long, "LU", __DESCR(descr)); \ >}) > >/* Oid for a quad. The pointer must be non NULL. */ >#define SYSCTL_NULL_QUAD_PTR ((int64_t *)NULL) >#define SYSCTL_QUAD(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_64, "Q", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64) && \ > sizeof(int64_t) == sizeof(*(ptr))) > >#define SYSCTL_ADD_QUAD(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > int64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_S64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_64, "Q", __DESCR(descr)); \ >}) > >#define SYSCTL_NULL_UQUAD_PTR ((uint64_t *)NULL) >#define SYSCTL_UQUAD(parent, nbr, name, access, ptr, val, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > ptr, val, sysctl_handle_64, "QU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ > sizeof(uint64_t) == sizeof(*(ptr))) > >#define SYSCTL_ADD_UQUAD(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uint64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_64, "QU", __DESCR(descr)); \ >}) > >/* Oid for a CPU dependant variable */ >#define SYSCTL_ADD_UAUTO(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > struct sysctl_oid *__ret; \ > CTASSERT((sizeof(uint64_t) == sizeof(*(ptr)) || \ > sizeof(unsigned) == sizeof(*(ptr))) && \ > ((access) & CTLTYPE) == 0); \ > if (sizeof(uint64_t) == sizeof(*(ptr))) { \ > __ret = sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_64, "QU", \ > __DESCR(descr)); \ > } else { \ > __ret = sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_UINT | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_int, "IU", \ > __DESCR(descr)); \ > } \ > __ret; \ >}) > >/* Oid for a 64-bit unsigned counter(9). The pointer must be non NULL. */ >#define SYSCTL_COUNTER_U64(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_counter_u64, "QU", descr); \ > CTASSERT((((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64) && \ > sizeof(counter_u64_t) == sizeof(*(ptr)) && \ > sizeof(uint64_t) == sizeof(**(ptr))) > >#define SYSCTL_ADD_COUNTER_U64(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > counter_u64_t *__ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_U64); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_counter_u64, "QU", __DESCR(descr)); \ >}) > >/* Oid for an opaque object. Specified by a pointer and a length. */ >#define SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, len, sysctl_handle_opaque, fmt, descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) > >#define SYSCTL_ADD_OPAQUE(ctx, parent, nbr, name, access, ptr, len, fmt, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, len, sysctl_handle_opaque, fmt, __DESCR(descr)); \ >}) > >/* Oid for a struct. Specified by a pointer and a type. */ >#define SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr) \ > SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > ptr, sizeof(struct type), sysctl_handle_opaque, \ > "S," #type, descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE) > >#define SYSCTL_ADD_STRUCT(ctx, parent, nbr, name, access, ptr, type, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_OPAQUE); \ > sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_OPAQUE|(access), \ > (ptr), sizeof(struct type), \ > sysctl_handle_opaque, "S," #type, __DESCR(descr)); \ >}) > >/* Oid for a procedure. Specified by a pointer and an arg. */ >#define SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ > SYSCTL_OID(parent, nbr, name, (access), \ > ptr, arg, handler, fmt, descr); \ > CTASSERT(((access) & CTLTYPE) != 0) > >#define SYSCTL_ADD_PROC(ctx, parent, nbr, name, access, ptr, arg, handler, fmt, descr) \ >({ \ > CTASSERT(((access) & CTLTYPE) != 0); \ > sysctl_add_oid(ctx, parent, nbr, name, (access), \ > (ptr), (arg), (handler), (fmt), __DESCR(descr)); \ >}) > >/* Oid to handle limits on uma(9) zone specified by pointer. */ >#define SYSCTL_UMA_MAX(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > (ptr), 0, sysctl_handle_uma_zone_max, "I", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) > >#define SYSCTL_ADD_UMA_MAX(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uma_zone_t __ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | (access), \ > __ptr, 0, sysctl_handle_uma_zone_max, "I", __DESCR(descr)); \ >}) > >/* Oid to obtain current use of uma(9) zone specified by pointer. */ >#define SYSCTL_UMA_CUR(parent, nbr, name, access, ptr, descr) \ > SYSCTL_OID(parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ > (ptr), 0, sysctl_handle_uma_zone_cur, "I", descr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT) > >#define SYSCTL_ADD_UMA_CUR(ctx, parent, nbr, name, access, ptr, descr) \ >({ \ > uma_zone_t __ptr = (ptr); \ > CTASSERT(((access) & CTLTYPE) == 0 || \ > ((access) & SYSCTL_CT_ASSERT_MASK) == CTLTYPE_INT); \ > sysctl_add_oid(ctx, parent, nbr, name, \ > CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RD | (access), \ > __ptr, 0, sysctl_handle_uma_zone_cur, "I", __DESCR(descr)); \ >}) > >/* > * A macro to generate a read-only sysctl to indicate the presense of optional > * kernel features. > */ >#define FEATURE(name, desc) \ > SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD | CTLFLAG_CAPRD, \ > SYSCTL_NULL_INT_PTR, 1, desc) > >#endif /* _KERNEL */ ># 572 "/usr/src/ifnet/sys/sys/sysctl.h" > >/* > * Top-level identifiers > */ >#define CTL_UNSPEC 0 /* unused */ >#define CTL_KERN 1 /* "high kernel": proc, limits */ >#define CTL_VM 2 /* virtual memory */ >#define CTL_VFS 3 /* filesystem, mount type is next */ >#define CTL_NET 4 /* network, see socket.h */ >#define CTL_DEBUG 5 /* debugging parameters */ >#define CTL_HW 6 /* generic cpu/io */ >#define CTL_MACHDEP 7 /* machine dependent */ >#define CTL_USER 8 /* user-level */ >#define CTL_P1003_1B 9 /* POSIX 1003.1B */ > >/* > * CTL_KERN identifiers > */ >#define KERN_OSTYPE 1 /* string: system version */ >#define KERN_OSRELEASE 2 /* string: system release */ >#define KERN_OSREV 3 /* int: system revision */ >#define KERN_VERSION 4 /* string: compile time info */ >#define KERN_MAXVNODES 5 /* int: max vnodes */ >#define KERN_MAXPROC 6 /* int: max processes */ >#define KERN_MAXFILES 7 /* int: max open files */ >#define KERN_ARGMAX 8 /* int: max arguments to exec */ >#define KERN_SECURELVL 9 /* int: system security level */ >#define KERN_HOSTNAME 10 /* string: hostname */ >#define KERN_HOSTID 11 /* int: host identifier */ >#define KERN_CLOCKRATE 12 /* struct: struct clockrate */ >#define KERN_VNODE 13 /* struct: vnode structures */ >#define KERN_PROC 14 /* struct: process entries */ >#define KERN_FILE 15 /* struct: file entries */ >#define KERN_PROF 16 /* node: kernel profiling info */ >#define KERN_POSIX1 17 /* int: POSIX.1 version */ >#define KERN_NGROUPS 18 /* int: # of supplemental group ids */ >#define KERN_JOB_CONTROL 19 /* int: is job control available */ >#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */ >#define KERN_BOOTTIME 21 /* struct: time kernel was booted */ >#define KERN_NISDOMAINNAME 22 /* string: YP domain name */ >#define KERN_UPDATEINTERVAL 23 /* int: update process sleep time */ >#define KERN_OSRELDATE 24 /* int: kernel release date */ >#define KERN_NTP_PLL 25 /* node: NTP PLL control */ >#define KERN_BOOTFILE 26 /* string: name of booted kernel */ >#define KERN_MAXFILESPERPROC 27 /* int: max open files per proc */ >#define KERN_MAXPROCPERUID 28 /* int: max processes per uid */ >#define KERN_DUMPDEV 29 /* struct cdev *: device to dump on */ >#define KERN_IPC 30 /* node: anything related to IPC */ >#define KERN_DUMMY 31 /* unused */ >#define KERN_PS_STRINGS 32 /* int: address of PS_STRINGS */ >#define KERN_USRSTACK 33 /* int: address of USRSTACK */ >#define KERN_LOGSIGEXIT 34 /* int: do we log sigexit procs? */ >#define KERN_IOV_MAX 35 /* int: value of UIO_MAXIOV */ >#define KERN_HOSTUUID 36 /* string: host UUID identifier */ >#define KERN_ARND 37 /* int: from arc4rand() */ >/* > * KERN_PROC subtypes > */ >#define KERN_PROC_ALL 0 /* everything */ >#define KERN_PROC_PID 1 /* by process id */ >#define KERN_PROC_PGRP 2 /* by process group id */ >#define KERN_PROC_SESSION 3 /* by session of pid */ >#define KERN_PROC_TTY 4 /* by controlling tty */ >#define KERN_PROC_UID 5 /* by effective uid */ >#define KERN_PROC_RUID 6 /* by real uid */ >#define KERN_PROC_ARGS 7 /* get/set arguments/proctitle */ >#define KERN_PROC_PROC 8 /* only return procs */ >#define KERN_PROC_SV_NAME 9 /* get syscall vector name */ >#define KERN_PROC_RGID 10 /* by real group id */ >#define KERN_PROC_GID 11 /* by effective group id */ >#define KERN_PROC_PATHNAME 12 /* path to executable */ >#define KERN_PROC_OVMMAP 13 /* Old VM map entries for process */ >#define KERN_PROC_OFILEDESC 14 /* Old file descriptors for process */ >#define KERN_PROC_KSTACK 15 /* Kernel stacks for process */ >#define KERN_PROC_INC_THREAD 0x10 /* > * modifier for pid, pgrp, tty, > * uid, ruid, gid, rgid and proc > * This effectively uses 16-31 > */ >#define KERN_PROC_VMMAP 32 /* VM map entries for process */ >#define KERN_PROC_FILEDESC 33 /* File descriptors for process */ >#define KERN_PROC_GROUPS 34 /* process groups */ >#define KERN_PROC_ENV 35 /* get environment */ >#define KERN_PROC_AUXV 36 /* get ELF auxiliary vector */ >#define KERN_PROC_RLIMIT 37 /* process resource limits */ >#define KERN_PROC_PS_STRINGS 38 /* get ps_strings location */ >#define KERN_PROC_UMASK 39 /* process umask */ >#define KERN_PROC_OSREL 40 /* osreldate for process binary */ >#define KERN_PROC_SIGTRAMP 41 /* signal trampoline location */ >#define KERN_PROC_CWD 42 /* process current working directory */ > >/* > * KERN_IPC identifiers > */ >#define KIPC_MAXSOCKBUF 1 /* int: max size of a socket buffer */ >#define KIPC_SOCKBUF_WASTE 2 /* int: wastage factor in sockbuf */ >#define KIPC_SOMAXCONN 3 /* int: max length of connection q */ >#define KIPC_MAX_LINKHDR 4 /* int: max length of link header */ >#define KIPC_MAX_PROTOHDR 5 /* int: max length of network header */ >#define KIPC_MAX_HDR 6 /* int: max total length of headers */ >#define KIPC_MAX_DATALEN 7 /* int: max length of data? */ > >/* > * CTL_HW identifiers > */ >#define HW_MACHINE 1 /* string: machine class */ >#define HW_MODEL 2 /* string: specific machine model */ >#define HW_NCPU 3 /* int: number of cpus */ >#define HW_BYTEORDER 4 /* int: machine byte order */ >#define HW_PHYSMEM 5 /* int: total memory */ >#define HW_USERMEM 6 /* int: non-kernel memory */ >#define HW_PAGESIZE 7 /* int: software page size */ >#define HW_DISKNAMES 8 /* strings: disk drive names */ >#define HW_DISKSTATS 9 /* struct: diskstats[] */ >#define HW_FLOATINGPT 10 /* int: has HW floating point? */ >#define HW_MACHINE_ARCH 11 /* string: machine architecture */ >#define HW_REALMEM 12 /* int: 'real' memory */ > >/* > * CTL_USER definitions > */ >#define USER_CS_PATH 1 /* string: _CS_PATH */ >#define USER_BC_BASE_MAX 2 /* int: BC_BASE_MAX */ >#define USER_BC_DIM_MAX 3 /* int: BC_DIM_MAX */ >#define USER_BC_SCALE_MAX 4 /* int: BC_SCALE_MAX */ >#define USER_BC_STRING_MAX 5 /* int: BC_STRING_MAX */ >#define USER_COLL_WEIGHTS_MAX 6 /* int: COLL_WEIGHTS_MAX */ >#define USER_EXPR_NEST_MAX 7 /* int: EXPR_NEST_MAX */ >#define USER_LINE_MAX 8 /* int: LINE_MAX */ >#define USER_RE_DUP_MAX 9 /* int: RE_DUP_MAX */ >#define USER_POSIX2_VERSION 10 /* int: POSIX2_VERSION */ >#define USER_POSIX2_C_BIND 11 /* int: POSIX2_C_BIND */ >#define USER_POSIX2_C_DEV 12 /* int: POSIX2_C_DEV */ >#define USER_POSIX2_CHAR_TERM 13 /* int: POSIX2_CHAR_TERM */ >#define USER_POSIX2_FORT_DEV 14 /* int: POSIX2_FORT_DEV */ >#define USER_POSIX2_FORT_RUN 15 /* int: POSIX2_FORT_RUN */ >#define USER_POSIX2_LOCALEDEF 16 /* int: POSIX2_LOCALEDEF */ >#define USER_POSIX2_SW_DEV 17 /* int: POSIX2_SW_DEV */ >#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */ >#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */ >#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */ > >#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */ >#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */ >#define CTL_P1003_1B_MEMLOCK 3 /* boolean */ >#define CTL_P1003_1B_MEMLOCK_RANGE 4 /* boolean */ >#define CTL_P1003_1B_MEMORY_PROTECTION 5 /* boolean */ >#define CTL_P1003_1B_MESSAGE_PASSING 6 /* boolean */ >#define CTL_P1003_1B_PRIORITIZED_IO 7 /* boolean */ >#define CTL_P1003_1B_PRIORITY_SCHEDULING 8 /* boolean */ >#define CTL_P1003_1B_REALTIME_SIGNALS 9 /* boolean */ >#define CTL_P1003_1B_SEMAPHORES 10 /* boolean */ >#define CTL_P1003_1B_FSYNC 11 /* boolean */ >#define CTL_P1003_1B_SHARED_MEMORY_OBJECTS 12 /* boolean */ >#define CTL_P1003_1B_SYNCHRONIZED_IO 13 /* boolean */ >#define CTL_P1003_1B_TIMERS 14 /* boolean */ >#define CTL_P1003_1B_AIO_LISTIO_MAX 15 /* int */ >#define CTL_P1003_1B_AIO_MAX 16 /* int */ >#define CTL_P1003_1B_AIO_PRIO_DELTA_MAX 17 /* int */ >#define CTL_P1003_1B_DELAYTIMER_MAX 18 /* int */ >#define CTL_P1003_1B_MQ_OPEN_MAX 19 /* int */ >#define CTL_P1003_1B_PAGESIZE 20 /* int */ >#define CTL_P1003_1B_RTSIG_MAX 21 /* int */ >#define CTL_P1003_1B_SEM_NSEMS_MAX 22 /* int */ >#define CTL_P1003_1B_SEM_VALUE_MAX 23 /* int */ >#define CTL_P1003_1B_SIGQUEUE_MAX 24 /* int */ >#define CTL_P1003_1B_TIMER_MAX 25 /* int */ > >#define CTL_P1003_1B_MAXID 26 > >#ifdef _KERNEL > >/* > * Declare some common oids. > */ >extern struct sysctl_oid_list sysctl__children; >SYSCTL_DECL(_kern); >SYSCTL_DECL(_kern_features); >SYSCTL_DECL(_kern_ipc); >SYSCTL_DECL(_kern_proc); >SYSCTL_DECL(_kern_sched); >SYSCTL_DECL(_kern_sched_stats); >SYSCTL_DECL(_sysctl); >SYSCTL_DECL(_vm); >SYSCTL_DECL(_vm_stats); >SYSCTL_DECL(_vm_stats_misc); >SYSCTL_DECL(_vfs); >SYSCTL_DECL(_net); >SYSCTL_DECL(_debug); >SYSCTL_DECL(_debug_sizeof); >SYSCTL_DECL(_dev); >SYSCTL_DECL(_hw); >SYSCTL_DECL(_hw_bus); >SYSCTL_DECL(_hw_bus_devices); >SYSCTL_DECL(_hw_bus_info); >SYSCTL_DECL(_machdep); >SYSCTL_DECL(_user); >SYSCTL_DECL(_compat); >SYSCTL_DECL(_regression); >SYSCTL_DECL(_security); >SYSCTL_DECL(_security_bsd); > >extern char machine[]; >extern char osrelease[]; >extern char ostype[]; >extern char kern_ident[]; > >/* Dynamic oid handling */ >struct sysctl_oid *sysctl_add_oid(struct sysctl_ctx_list *clist, > struct sysctl_oid_list *parent, int nbr, const char *name, int kind, > void *arg1, intptr_t arg2, int (*handler)(SYSCTL_HANDLER_ARGS), > const char *fmt, const char *descr); >int sysctl_remove_name(struct sysctl_oid *parent, const char *name, int del, > int recurse); >void sysctl_rename_oid(struct sysctl_oid *oidp, const char *name); >int sysctl_move_oid(struct sysctl_oid *oidp, > struct sysctl_oid_list *parent); >int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse); >int sysctl_ctx_init(struct sysctl_ctx_list *clist); >int sysctl_ctx_free(struct sysctl_ctx_list *clist); >struct sysctl_ctx_entry *sysctl_ctx_entry_add(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); >struct sysctl_ctx_entry *sysctl_ctx_entry_find(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); >int sysctl_ctx_entry_del(struct sysctl_ctx_list *clist, > struct sysctl_oid *oidp); > >int kernel_sysctl(struct thread *td, int *name, u_int namelen, void *old, > size_t *oldlenp, void *new, size_t newlen, size_t *retval, > int flags); >int kernel_sysctlbyname(struct thread *td, char *name, void *old, > size_t *oldlenp, void *new, size_t newlen, size_t *retval, > int flags); >int userland_sysctl(struct thread *td, int *name, u_int namelen, void *old, > size_t *oldlenp, int inkernel, void *new, size_t newlen, > size_t *retval, int flags); >int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, > int *nindx, struct sysctl_req *req); >void sysctl_xlock(void); >void sysctl_xunlock(void); >int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); > >struct sbuf; >struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int, > struct sysctl_req *); >#else /* !_KERNEL */ ># 818 "/usr/src/ifnet/sys/sys/sysctl.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 818 "/usr/src/ifnet/sys/sys/sysctl.h" ># 819 "/usr/src/ifnet/sys/sys/sysctl.h" > >__BEGIN_DECLS >int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); >int sysctlbyname(const char *, void *, size_t *, const void *, size_t); >int sysctlnametomib(const char *, int *, size_t *); >__END_DECLS >#endif /* _KERNEL */ ># 826 "/usr/src/ifnet/sys/sys/sysctl.h" > >#endif /* !_SYS_SYSCTL_H_ */ ># 828 "/usr/src/ifnet/sys/sys/sysctl.h" ># 45 "/usr/src/ifnet/sys/net/if_media.c" 2 > >#if 0 /* expanded by -frewrite-includes */ >#include <net/if.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/net/if.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)if.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: projects/ifnet/sys/net/if.h 281653 2015-04-17 12:40:27Z glebius $ > */ > >#ifndef _NET_IF_H_ >#define _NET_IF_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/net/if.h" ># 37 "/usr/src/ifnet/sys/net/if.h" > >#if __BSD_VISIBLE >/* > * <net/if.h> does not depend on <sys/time.h> on most other systems. This > * helps userland compatibility. (struct timeval ifi_lastchange) > * The same holds for <sys/socket.h>. (struct sockaddr ifru_addr) > */ >#ifndef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/time.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/ifnet/sys/net/if.h" ># 46 "/usr/src/ifnet/sys/net/if.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/socket.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/ifnet/sys/net/if.h" ># 47 "/usr/src/ifnet/sys/net/if.h" >#endif ># 48 "/usr/src/ifnet/sys/net/if.h" >#endif ># 49 "/usr/src/ifnet/sys/net/if.h" > >/* > * Length of interface external name, including terminating '\0'. > * Note: this is the same size as a generic device's external name. > */ >#define IF_NAMESIZE 16 >#if __BSD_VISIBLE >#define IFNAMSIZ IF_NAMESIZE >#define IF_MAXUNIT 0x7fff /* historical value */ >#endif ># 59 "/usr/src/ifnet/sys/net/if.h" >#if __BSD_VISIBLE > >/* > * Structure used to query names of interface cloners. > */ > >struct if_clonereq { > int ifcr_total; /* total cloners (out) */ > int ifcr_count; /* room for this many in user buffer */ > char *ifcr_buffer; /* buffer for cloner names */ >}; > >/* > * Structure describing information about an interface > * which may be of interest to management entities. > */ >struct if_data { > /* generic interface information */ > uint8_t ifi_type; /* ethernet, tokenring, etc */ > uint8_t ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ > uint8_t ifi_addrlen; /* media address length */ > uint8_t ifi_hdrlen; /* media header length */ > uint8_t ifi_link_state; /* current link state */ > uint8_t ifi_vhid; /* carp vhid */ > uint16_t ifi_datalen; /* length of this data struct */ > uint32_t ifi_mtu; /* maximum transmission unit */ > uint32_t ifi_metric; /* routing metric (external only) */ > uint64_t ifi_baudrate; /* linespeed */ > /* volatile statistics */ > uint64_t ifi_ipackets; /* packets received on interface */ > uint64_t ifi_ierrors; /* input errors on interface */ > uint64_t ifi_opackets; /* packets sent on interface */ > uint64_t ifi_oerrors; /* output errors on interface */ > uint64_t ifi_collisions; /* collisions on csma interfaces */ > uint64_t ifi_ibytes; /* total number of octets received */ > uint64_t ifi_obytes; /* total number of octets sent */ > uint64_t ifi_imcasts; /* packets received via multicast */ > uint64_t ifi_omcasts; /* packets sent via multicast */ > uint64_t ifi_iqdrops; /* dropped on input */ > uint64_t ifi_oqdrops; /* dropped on output */ > uint64_t ifi_noproto; /* destined for unsupported protocol */ > uint64_t ifi_hwassist; /* HW offload capabilities, see IFCAP */ > > /* Unions are here to make sizes MI. */ > union { /* uptime at attach or stat reset */ > time_t tt; > uint64_t ph; > } __ifi_epoch; >#define ifi_epoch __ifi_epoch.tt > union { /* time of last administrative change */ > struct timeval tv; > struct { > uint64_t ph1; > uint64_t ph2; > } ph; > } __ifi_lastchange; >#define ifi_lastchange __ifi_lastchange.tv >}; > >/*- > * Interface flags are of two types: network stack owned flags, and driver > * owned flags. Historically, these values were stored in the same ifnet > * flags field, but with the advent of fine-grained locking, they have been > * broken out such that the network stack is responsible for synchronizing > * the stack-owned fields, and the device driver the device-owned fields. > * Both halves can perform lockless reads of the other half's field, subject > * to accepting the involved races. > * > * Both sets of flags come from the same number space, and should not be > * permitted to conflict, as they are exposed to user space via a single > * field. > * > * The following symbols identify read and write requirements for fields: > * > * (i) if_flags field set by device driver before attach, read-only there > * after. > * (n) if_flags field written only by the network stack, read by either the > * stack or driver. > * (o) obsoleted in FreeBSD, but third party applications may still > * require definitions. > */ >#define IFF_UP 0x1 /* (n) interface is up */ >#define IFF_BROADCAST 0x2 /* (i) broadcast address valid */ >#define IFF_DEBUG 0x4 /* (n) turn on debugging */ >#define IFF_LOOPBACK 0x8 /* (i) is a loopback net */ >#define IFF_POINTOPOINT 0x10 /* (i) is a point-to-point link */ >/* 0x20 was IFF_SMART */ >#define IFF_RUNNING 0x40 /* (o) resources allocated */ >#define IFF_NOARP 0x80 /* (n) no address resolution protocol */ >#define IFF_PROMISC 0x100 /* (n) receive all packets */ >#define IFF_ALLMULTI 0x200 /* (n) receive all multicast packets */ >#define IFF_OACTIVE 0x400 /* (o) tx hardware queue is full */ >#define IFF_SIMPLEX 0x800 /* (i) can't hear own transmissions */ >#define IFF_LINK0 0x1000 /* per link layer defined bit */ >#define IFF_LINK1 0x2000 /* per link layer defined bit */ >#define IFF_LINK2 0x4000 /* per link layer defined bit */ >#define IFF_ALTPHYS IFF_LINK2 /* use alternate physical connection */ >#define IFF_MULTICAST 0x8000 /* (i) supports multicast */ >#define IFF_CANTCONFIG 0x10000 /* (i) unconfigurable using ioctl(2) */ >#define IFF_PPROMISC 0x20000 /* (n) user-requested promisc mode */ >#define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ >#define IFF_STATICARP 0x80000 /* (n) static ARP */ >#define IFF_DYING 0x200000 /* (n) interface is winding down */ >#define IFF_RENAMING 0x400000 /* (n) interface is being renamed */ > >/* flags set internally only: */ >#define IFF_CANTCHANGE \ > (IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\ > IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC|\ > IFF_DYING|IFF_CANTCONFIG) > >/* > * Values for if_link_state. > */ >enum { > LINK_STATE_UNKNOWN = 0, /* link invalid/unknown */ > LINK_STATE_DOWN, /* link is down */ > LINK_STATE_UP, /* link is up */ >}; > >/* > * Some convenience macros used for setting ifi_baudrate. > * XXX 1000 vs. 1024? --thorpej@netbsd.org > */ >#define IF_Kbps(x) ((uintmax_t)(x) * 1000) /* kilobits/sec. */ >#define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */ >#define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* gigabits/sec. */ > >/* > * Capabilities that interfaces can advertise. > * > * struct ifnet.if_capabilities > * contains the optional features & capabilities a particular interface > * supports (not only the driver but also the detected hw revision). > * Capabilities are defined by IFCAP_* below. > * struct ifnet.if_capenable > * contains the enabled (either by default or through ifconfig) optional > * features & capabilities on this interface. > * Capabilities are defined by IFCAP_* below. > * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above > * contains the enabled optional feature & capabilites that can be used > * individually per packet and are specified in the mbuf pkthdr.csum_flags > * field. IFCAP_* and CSUM_* do not match one to one and CSUM_* may be > * more detailed or differenciated than IFCAP_*. > * Hwassist features are defined CSUM_* in sys/mbuf.h > * > * Capabilities that cannot be arbitrarily changed with ifconfig/ioctl > * are listed in IFCAP_CANTCHANGE, similar to IFF_CANTCHANGE. > * This is not strictly necessary because the common code never > * changes capabilities, and it is left to the individual driver > * to do the right thing. However, having the filter here > * avoids replication of the same code in all individual drivers. > */ >#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ >#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ >#define IFCAP_NETCONS 0x00004 /* can be a network console */ >#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */ >#define IFCAP_VLAN_HWTAGGING 0x00010 /* hardware VLAN tag support */ >#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */ >#define IFCAP_POLLING 0x00040 /* driver supports polling */ >#define IFCAP_VLAN_HWCSUM 0x00080 /* can do IFCAP_HWCSUM on VLANs */ >#define IFCAP_TSO4 0x00100 /* can do TCP Segmentation Offload */ >#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */ >#define IFCAP_LRO 0x00400 /* can do Large Receive Offload */ >#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */ >#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */ >#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */ >#define IFCAP_TOE4 0x04000 /* interface can offload TCP */ >#define IFCAP_TOE6 0x08000 /* interface can offload TCP6 */ >#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ >#define IFCAP_POLLING_NOCOUNT 0x20000 /* polling ticks cannot be fragmented */ >#define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ >#define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ >#define IFCAP_NETMAP 0x100000 /* netmap mode supported/enabled */ >#define IFCAP_RXCSUM_IPV6 0x200000 /* can offload checksum on IPv6 RX */ >#define IFCAP_TXCSUM_IPV6 0x400000 /* can offload checksum on IPv6 TX */ > >#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6) > >#define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) >#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) >#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) >#define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) > >#define IFCAP_CANTCHANGE (IFCAP_NETMAP) > >#define IFQ_MAXLEN 50 >#define IFNET_SLOWHZ 1 /* granularity is 1 second */ > >/* > * Message format for use in obtaining information about interfaces > * from getkerninfo and the routing socket > * For the new, extensible interface see struct if_msghdrl below. > */ >struct if_msghdr { > u_short ifm_msglen; /* to skip over non-understood messages */ > u_char ifm_version; /* future binary compatibility */ > u_char ifm_type; /* message type */ > int ifm_addrs; /* like rtm_addrs */ > int ifm_flags; /* value of if_flags */ > u_short ifm_index; /* index for associated ifp */ > struct if_data ifm_data;/* statistics and other data about if */ >}; > >/* > * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL. It is > * extensible after ifm_data_off or within ifm_data. Both the if_msghdr and > * if_data now have a member field detailing the struct length in addition to > * the routing message length. Macros are provided to find the start of > * ifm_data and the start of the socket address strucutres immediately following > * struct if_msghdrl given a pointer to struct if_msghdrl. > */ >#define IF_MSGHDRL_IFM_DATA(_l) \ > (struct if_data *)((char *)(_l) + (_l)->ifm_data_off) >#define IF_MSGHDRL_RTA(_l) \ > (void *)((uintptr_t)(_l) + (_l)->ifm_len) >struct if_msghdrl { > u_short ifm_msglen; /* to skip over non-understood messages */ > u_char ifm_version; /* future binary compatibility */ > u_char ifm_type; /* message type */ > int ifm_addrs; /* like rtm_addrs */ > int ifm_flags; /* value of if_flags */ > u_short ifm_index; /* index for associated ifp */ > u_short _ifm_spare1; /* spare space to grow if_index, see if_var.h */ > u_short ifm_len; /* length of if_msghdrl incl. if_data */ > u_short ifm_data_off; /* offset of if_data from beginning */ > struct if_data ifm_data;/* statistics and other data about if */ >}; > >/* > * Message format for use in obtaining information about interface addresses > * from getkerninfo and the routing socket > * For the new, extensible interface see struct ifa_msghdrl below. > */ >struct ifa_msghdr { > u_short ifam_msglen; /* to skip over non-understood messages */ > u_char ifam_version; /* future binary compatibility */ > u_char ifam_type; /* message type */ > int ifam_addrs; /* like rtm_addrs */ > int ifam_flags; /* value of ifa_flags */ > u_short ifam_index; /* index for associated ifp */ > int ifam_metric; /* value of ifa_ifp->if_metric */ >}; > >/* > * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL. It is > * extensible after ifam_metric or within ifam_data. Both the ifa_msghdrl and > * if_data now have a member field detailing the struct length in addition to > * the routing message length. Macros are provided to find the start of > * ifm_data and the start of the socket address strucutres immediately following > * struct ifa_msghdrl given a pointer to struct ifa_msghdrl. > */ >#define IFA_MSGHDRL_IFAM_DATA(_l) \ > (struct if_data *)((char *)(_l) + (_l)->ifam_data_off) >#define IFA_MSGHDRL_RTA(_l) \ > (void *)((uintptr_t)(_l) + (_l)->ifam_len) >struct ifa_msghdrl { > u_short ifam_msglen; /* to skip over non-understood messages */ > u_char ifam_version; /* future binary compatibility */ > u_char ifam_type; /* message type */ > int ifam_addrs; /* like rtm_addrs */ > int ifam_flags; /* value of ifa_flags */ > u_short ifam_index; /* index for associated ifp */ > u_short _ifam_spare1; /* spare space to grow if_index, see if_var.h */ > u_short ifam_len; /* length of ifa_msghdrl incl. if_data */ > u_short ifam_data_off; /* offset of if_data from beginning */ > int ifam_metric; /* value of ifa_ifp->if_metric */ > struct if_data ifam_data;/* statistics and other data about if or > * address */ >}; > >/* > * Message format for use in obtaining information about multicast addresses > * from the routing socket > */ >struct ifma_msghdr { > u_short ifmam_msglen; /* to skip over non-understood messages */ > u_char ifmam_version; /* future binary compatibility */ > u_char ifmam_type; /* message type */ > int ifmam_addrs; /* like rtm_addrs */ > int ifmam_flags; /* value of ifa_flags */ > u_short ifmam_index; /* index for associated ifp */ >}; > >/* > * Message format announcing the arrival or departure of a network interface. > */ >struct if_announcemsghdr { > u_short ifan_msglen; /* to skip over non-understood messages */ > u_char ifan_version; /* future binary compatibility */ > u_char ifan_type; /* message type */ > u_short ifan_index; /* index for associated ifp */ > char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > u_short ifan_what; /* what type of announcement */ >}; > >#define IFAN_ARRIVAL 0 /* interface arrival */ >#define IFAN_DEPARTURE 1 /* interface departure */ > >/* > * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests > */ >struct ifreq_buffer { > size_t length; > void *buffer; >}; > >/* > * Interface request structure used for socket > * ioctl's. All interface ioctl's must have parameter > * definitions which begin with ifr_name. The > * remainder may be interface specific. > */ >struct ifreq { > char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > union { > struct sockaddr ifru_addr; > struct sockaddr ifru_dstaddr; > struct sockaddr ifru_broadaddr; > struct ifreq_buffer ifru_buffer; > struct { > uint32_t ifrucap_reqcap; /* requested/returned */ > uint32_t ifrucap_curcap; /* current values */ > uint64_t ifrucap_hwassist; /* returned hwassist */ > } ifru_cap; > short ifru_flags[2]; > short ifru_index; > int ifru_jid; > int ifru_metric; > int ifru_mtu; > int ifru_phys; > int ifru_media; > caddr_t ifru_data; > u_int ifru_fib; > } ifr_ifru; >#define ifr_addr ifr_ifru.ifru_addr /* address */ >#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */ >#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ >#define ifr_buffer ifr_ifru.ifru_buffer /* user supplied buffer with its length */ >#define ifr_flags ifr_ifru.ifru_flags[0] /* flags (low 16 bits) */ >#define ifr_flagshigh ifr_ifru.ifru_flags[1] /* flags (high 16 bits) */ >#define ifr_jid ifr_ifru.ifru_jid /* jail/vnet */ >#define ifr_metric ifr_ifru.ifru_metric /* metric */ >#define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ >#define ifr_phys ifr_ifru.ifru_phys /* physical wire */ >#define ifr_media ifr_ifru.ifru_media /* physical media */ >#define ifr_data ifr_ifru.ifru_data /* for use by interface */ >#define ifr_reqcap ifr_ifru.ifru_cap.ifrucap_reqcap >#define ifr_curcap ifr_ifru.ifru_cap.ifrucap_curcap >#define ifr_hwassist ifr_ifru.ifru_cap.ifrucap_hwassist >#define ifr_index ifr_ifru.ifru_index /* interface index */ >#define ifr_fib ifr_ifru.ifru_fib /* interface fib */ >}; > >#define _SIZEOF_ADDR_IFREQ(ifr) \ > ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ > (sizeof(struct ifreq) - sizeof(struct sockaddr) + \ > (ifr).ifr_addr.sa_len) : sizeof(struct ifreq)) > >struct ifaliasreq { > char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > struct sockaddr ifra_addr; > struct sockaddr ifra_broadaddr; > struct sockaddr ifra_mask; > int ifra_vhid; >}; > >/* 9.x compat */ >struct oifaliasreq { > char ifra_name[IFNAMSIZ]; > struct sockaddr ifra_addr; > struct sockaddr ifra_broadaddr; > struct sockaddr ifra_mask; >}; > >/* > * Interface media description could be bigger than a 32-bit word, > * but a conservative decision was taken in r281236. > */ >typedef int if_media_t; > >struct ifmediareq { > char ifm_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > if_media_t ifm_current; /* current media options */ > if_media_t ifm_mask; /* don't care mask */ > if_media_t ifm_status; /* media status */ > if_media_t ifm_active; /* active options */ > int ifm_count; /* # entries in ifm_ulist array */ > if_media_t *ifm_ulist; /* media words */ >}; > >struct ifdrv { > char ifd_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > unsigned long ifd_cmd; > size_t ifd_len; > void *ifd_data; >}; > >/* > * Structure used to retrieve aux status data from interfaces. > * Kernel suppliers to this interface should respect the formatting > * needed by ifconfig(8): each line starts with a TAB and ends with > * a newline. The canonical example to copy and paste is in if_tun.c. > */ > >#define IFSTATMAX 800 /* 10 lines of text */ >struct ifstat { > char ifs_name[IFNAMSIZ]; /* if name, e.g. "en0" */ > char ascii[IFSTATMAX + 1]; >}; > >/* > * Structure used in SIOCGIFCONF request. > * Used to retrieve interface configuration > * for machine (useful for programs which > * must know all networks accessible). > */ >struct ifconf { > int ifc_len; /* size of associated buffer */ > union { > caddr_t ifcu_buf; > struct ifreq *ifcu_req; > } ifc_ifcu; >#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */ >#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */ >}; > >/* > * interface groups > */ > >#define IFG_ALL "all" /* group contains all interfaces */ >/* XXX: will we implement this? */ >#define IFG_EGRESS "egress" /* if(s) default route(s) point to */ > >struct ifg_req { > union { > char ifgrqu_group[IFNAMSIZ]; > char ifgrqu_member[IFNAMSIZ]; > } ifgrq_ifgrqu; >#define ifgrq_group ifgrq_ifgrqu.ifgrqu_group >#define ifgrq_member ifgrq_ifgrqu.ifgrqu_member >}; > >/* > * Used to lookup groups for an interface > */ >struct ifgroupreq { > char ifgr_name[IFNAMSIZ]; > u_int ifgr_len; > union { > char ifgru_group[IFNAMSIZ]; > struct ifg_req *ifgru_groups; > } ifgr_ifgru; >#define ifgr_group ifgr_ifgru.ifgru_group >#define ifgr_groups ifgr_ifgru.ifgru_groups >}; > >/* > * Structure used to request i2c data > * from interface transceivers. > */ >struct ifi2creq { > uint8_t dev_addr; /* i2c address (0xA0, 0xA2) */ > uint8_t offset; /* read offset */ > uint8_t len; /* read length */ > uint8_t spare0; > uint32_t spare1; > uint8_t data[8]; /* read buffer */ >}; > >#endif /* __BSD_VISIBLE */ ># 531 "/usr/src/ifnet/sys/net/if.h" > >#ifndef _KERNEL >struct if_nameindex { > unsigned int if_index; /* 1, 2, ... */ > char *if_name; /* null terminated name: "le0", ... */ >}; > >__BEGIN_DECLS >void if_freenameindex(struct if_nameindex *); >char *if_indextoname(unsigned int, char *); >struct if_nameindex *if_nameindex(void); >unsigned int if_nametoindex(const char *); >__END_DECLS >#endif ># 545 "/usr/src/ifnet/sys/net/if.h" > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <net/if_types.h> >#endif /* expanded by -frewrite-includes */ ># 547 "/usr/src/ifnet/sys/net/if.h" ># 1 "/usr/src/ifnet/sys/net/if_types.h" 1 >/*- > * Copyright (c) 1989, 1993, 1994 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)if_types.h 8.3 (Berkeley) 4/28/95 > * $FreeBSD: projects/ifnet/sys/net/if_types.h 281640 2015-04-17 05:55:07Z glebius $ > * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $ > */ > >#ifndef _NET_IF_TYPES_H_ >#define _NET_IF_TYPES_H_ > >/* > * Interface types for benefit of parsing media address headers. > * This list is derived from the SNMP list of ifTypes, originally > * documented in RFC1573, now maintained as: > * > * http://www.iana.org/assignments/smi-numbers > */ > >typedef enum { > IFT_OTHER = 0x1, /* none of the following */ > IFT_1822 = 0x2, /* old-style arpanet imp */ > IFT_HDH1822 = 0x3, /* HDH arpanet imp */ > IFT_X25DDN = 0x4, /* x25 to imp */ > IFT_X25 = 0x5, /* PDN X25 interface (RFC877) */ > IFT_ETHER = 0x6, /* Ethernet CSMA/CD */ > IFT_ISO88023 = 0x7, /* CMSA/CD */ > IFT_ISO88024 = 0x8, /* Token Bus */ > IFT_ISO88025 = 0x9, /* Token Ring */ > IFT_ISO88026 = 0xa, /* MAN */ > IFT_STARLAN = 0xb, > IFT_P10 = 0xc, /* Proteon 10MBit ring */ > IFT_P80 = 0xd, /* Proteon 80MBit ring */ > IFT_HY = 0xe, /* Hyperchannel */ > IFT_FDDI = 0xf, > IFT_LAPB = 0x10, > IFT_SDLC = 0x11, > IFT_T1 = 0x12, > IFT_CEPT = 0x13, /* E1 - european T1 */ > IFT_ISDNBASIC = 0x14, > IFT_ISDNPRIMARY = 0x15, > IFT_PTPSERIAL = 0x16, /* Proprietary PTP serial */ > IFT_PPP = 0x17, /* RFC 1331 */ > IFT_LOOP = 0x18, /* loopback */ > IFT_EON = 0x19, /* ISO over IP */ > IFT_XETHER = 0x1a, /* obsolete 3MB experimental ethernet */ > IFT_NSIP = 0x1b, /* XNS over IP */ > IFT_SLIP = 0x1c, /* IP over generic TTY */ > IFT_ULTRA = 0x1d, /* Ultra Technologies */ > IFT_DS3 = 0x1e, /* Generic T3 */ > IFT_SIP = 0x1f, /* SMDS */ > IFT_FRELAY = 0x20, /* Frame Relay DTE only */ > IFT_RS232 = 0x21, > IFT_PARA = 0x22, /* parallel-port */ > IFT_ARCNET = 0x23, > IFT_ARCNETPLUS = 0x24, > IFT_ATM = 0x25, /* ATM cells */ > IFT_MIOX25 = 0x26, > IFT_SONET = 0x27, /* SONET or SDH */ > IFT_X25PLE = 0x28, > IFT_ISO88022LLC = 0x29, > IFT_LOCALTALK = 0x2a, > IFT_SMDSDXI = 0x2b, > IFT_FRELAYDCE = 0x2c, /* Frame Relay DCE */ > IFT_V35 = 0x2d, > IFT_HSSI = 0x2e, > IFT_HIPPI = 0x2f, > IFT_MODEM = 0x30, /* Generic Modem */ > IFT_AAL5 = 0x31, /* AAL5 over ATM */ > IFT_SONETPATH = 0x32, > IFT_SONETVT = 0x33, > IFT_SMDSICIP = 0x34, /* SMDS InterCarrier Interface */ > IFT_PROPVIRTUAL = 0x35, /* Proprietary Virtual/internal */ > IFT_PROPMUX = 0x36, /* Proprietary Multiplexing */ > IFT_IEEE80212 = 0x37, /* 100BaseVG */ > IFT_FIBRECHANNEL = 0x38, /* Fibre Channel */ > IFT_HIPPIINTERFACE = 0x39, /* HIPPI interfaces */ > IFT_FRAMERELAYINTERCONNECT = 0x3a, /* Obsolete, use 0x20 either 0x2c */ > IFT_AFLANE8023 = 0x3b, /* ATM Emulated LAN for 802.3 */ > IFT_AFLANE8025 = 0x3c, /* ATM Emulated LAN for 802.5 */ > IFT_CCTEMUL = 0x3d, /* ATM Emulated circuit */ > IFT_FASTETHER = 0x3e, /* Fast Ethernet (100BaseT) */ > IFT_ISDN = 0x3f, /* ISDN and X.25 */ > IFT_V11 = 0x40, /* CCITT V.11/X.21 */ > IFT_V36 = 0x41, /* CCITT V.36 */ > IFT_G703AT64K = 0x42, /* CCITT G703 at 64Kbps */ > IFT_G703AT2MB = 0x43, /* Obsolete see DS1-MIB */ > IFT_QLLC = 0x44, /* SNA QLLC */ > IFT_FASTETHERFX = 0x45, /* Fast Ethernet (100BaseFX) */ > IFT_CHANNEL = 0x46, /* channel */ > IFT_IEEE80211 = 0x47, /* radio spread spectrum */ > IFT_IBM370PARCHAN = 0x48, /* IBM System 360/370 OEMI Channel */ > IFT_ESCON = 0x49, /* IBM Enterprise Systems Connection */ > IFT_DLSW = 0x4a, /* Data Link Switching */ > IFT_ISDNS = 0x4b, /* ISDN S/T interface */ > IFT_ISDNU = 0x4c, /* ISDN U interface */ > IFT_LAPD = 0x4d, /* Link Access Protocol D */ > IFT_IPSWITCH = 0x4e, /* IP Switching Objects */ > IFT_RSRB = 0x4f, /* Remote Source Route Bridging */ > IFT_ATMLOGICAL = 0x50, /* ATM Logical Port */ > IFT_DS0 = 0x51, /* Digital Signal Level 0 */ > IFT_DS0BUNDLE = 0x52, /* group of ds0s on the same ds1 */ > IFT_BSC = 0x53, /* Bisynchronous Protocol */ > IFT_ASYNC = 0x54, /* Asynchronous Protocol */ > IFT_CNR = 0x55, /* Combat Net Radio */ > IFT_ISO88025DTR = 0x56, /* ISO 802.5r DTR */ > IFT_EPLRS = 0x57, /* Ext Pos Loc Report Sys */ > IFT_ARAP = 0x58, /* Appletalk Remote Access Protocol */ > IFT_PROPCNLS = 0x59, /* Proprietary Connectionless Protocol*/ > IFT_HOSTPAD = 0x5a, /* CCITT-ITU X.29 PAD Protocol */ > IFT_TERMPAD = 0x5b, /* CCITT-ITU X.3 PAD Facility */ > IFT_FRAMERELAYMPI = 0x5c, /* Multiproto Interconnect over FR */ > IFT_X213 = 0x5d, /* CCITT-ITU X213 */ > IFT_ADSL = 0x5e, /* Asymmetric Digital Subscriber Loop */ > IFT_RADSL = 0x5f, /* Rate-Adapt. Digital Subscriber Loop*/ > IFT_SDSL = 0x60, /* Symmetric Digital Subscriber Loop */ > IFT_VDSL = 0x61, /* Very H-Speed Digital Subscrib. Loop*/ > IFT_ISO88025CRFPINT = 0x62, /* ISO 802.5 CRFP */ > IFT_MYRINET = 0x63, /* Myricom Myrinet */ > IFT_VOICEEM = 0x64, /* voice recEive and transMit */ > IFT_VOICEFXO = 0x65, /* voice Foreign Exchange Office */ > IFT_VOICEFXS = 0x66, /* voice Foreign Exchange Station */ > IFT_VOICEENCAP = 0x67, /* voice encapsulation */ > IFT_VOICEOVERIP = 0x68, /* voice over IP encapsulation */ > IFT_ATMDXI = 0x69, /* ATM DXI */ > IFT_ATMFUNI = 0x6a, /* ATM FUNI */ > IFT_ATMIMA = 0x6b, /* ATM IMA */ > IFT_PPPMULTILINKBUNDLE = 0x6c, /* PPP Multilink Bundle */ > IFT_IPOVERCDLC = 0x6d, /* IBM ipOverCdlc */ > IFT_IPOVERCLAW = 0x6e, /* IBM Common Link Access to Workstn */ > IFT_STACKTOSTACK = 0x6f, /* IBM stackToStack */ > IFT_VIRTUALIPADDRESS = 0x70, /* IBM VIPA */ > IFT_MPC = 0x71, /* IBM multi-protocol channel support */ > IFT_IPOVERATM = 0x72, /* IBM ipOverAtm */ > IFT_ISO88025FIBER = 0x73, /* ISO 802.5j Fiber Token Ring */ > IFT_TDLC = 0x74, /* IBM twinaxial data link control */ > IFT_GIGABITETHERNET = 0x75, /* Gigabit Ethernet */ > IFT_HDLC = 0x76, /* HDLC */ > IFT_LAPF = 0x77, /* LAP F */ > IFT_V37 = 0x78, /* V.37 */ > IFT_X25MLP = 0x79, /* Multi-Link Protocol */ > IFT_X25HUNTGROUP = 0x7a, /* X25 Hunt Group */ > IFT_TRANSPHDLC = 0x7b, /* Transp HDLC */ > IFT_INTERLEAVE = 0x7c, /* Interleave channel */ > IFT_FAST = 0x7d, /* Fast channel */ > IFT_IP = 0x7e, /* IP (for APPN HPR in IP networks) */ > IFT_DOCSCABLEMACLAYER = 0x7f, /* CATV Mac Layer */ > IFT_DOCSCABLEDOWNSTREAM = 0x80, /* CATV Downstream interface */ > IFT_DOCSCABLEUPSTREAM = 0x81, /* CATV Upstream interface */ > IFT_A12MPPSWITCH = 0x82, /* Avalon Parallel Processor */ > IFT_TUNNEL = 0x83, /* Encapsulation interface */ > IFT_COFFEE = 0x84, /* coffee pot */ > IFT_CES = 0x85, /* Circiut Emulation Service */ > IFT_ATMSUBINTERFACE = 0x86, /* (x) ATM Sub Interface */ > IFT_L2VLAN = 0x87, /* Layer 2 Virtual LAN using 802.1Q */ > IFT_L3IPVLAN = 0x88, /* Layer 3 Virtual LAN - IP Protocol */ > IFT_L3IPXVLAN = 0x89, /* Layer 3 Virtual LAN - IPX Prot. */ > IFT_DIGITALPOWERLINE = 0x8a, /* IP over Power Lines */ > IFT_MEDIAMAILOVERIP = 0x8b, /* (xxx) Multimedia Mail over IP */ > IFT_DTM = 0x8c, /* Dynamic synchronous Transfer Mode */ > IFT_DCN = 0x8d, /* Data Communications Network */ > IFT_IPFORWARD = 0x8e, /* IP Forwarding Interface */ > IFT_MSDSL = 0x8f, /* Multi-rate Symmetric DSL */ > IFT_IEEE1394 = 0x90, /* IEEE1394 High Performance SerialBus*/ > IFT_IFGSN = 0x91, /* HIPPI-6400 */ > IFT_DVBRCCMACLAYER = 0x92, /* DVB-RCC MAC Layer */ > IFT_DVBRCCDOWNSTREAM = 0x93, /* DVB-RCC Downstream Channel */ > IFT_DVBRCCUPSTREAM = 0x94, /* DVB-RCC Upstream Channel */ > IFT_ATMVIRTUAL = 0x95, /* ATM Virtual Interface */ > IFT_MPLSTUNNEL = 0x96, /* MPLS Tunnel Virtual Interface */ > IFT_SRP = 0x97, /* Spatial Reuse Protocol */ > IFT_VOICEOVERATM = 0x98, /* Voice over ATM */ > IFT_VOICEOVERFRAMERELAY = 0x99, /* Voice Over Frame Relay */ > IFT_IDSL = 0x9a, /* Digital Subscriber Loop over ISDN */ > IFT_COMPOSITELINK = 0x9b, /* Avici Composite Link Interface */ > IFT_SS7SIGLINK = 0x9c, /* SS7 Signaling Link */ > IFT_PROPWIRELESSP2P = 0x9d, /* Prop. P2P wireless interface */ > IFT_FRFORWARD = 0x9e, /* Frame forward Interface */ > IFT_RFC1483 = 0x9f, /* Multiprotocol over ATM AAL5 */ > IFT_USB = 0xa0, /* USB Interface */ > IFT_IEEE8023ADLAG = 0xa1, /* IEEE 802.3ad Link Aggregate*/ > IFT_BGPPOLICYACCOUNTING = 0xa2, /* BGP Policy Accounting */ > IFT_FRF16MFRBUNDLE = 0xa3, /* FRF.16 Multilik Frame Relay*/ > IFT_H323GATEKEEPER = 0xa4, /* H323 Gatekeeper */ > IFT_H323PROXY = 0xa5, /* H323 Voice and Video Proxy */ > IFT_MPLS = 0xa6, /* MPLS */ > IFT_MFSIGLINK = 0xa7, /* Multi-frequency signaling link */ > IFT_HDSL2 = 0xa8, /* High Bit-Rate DSL, 2nd gen. */ > IFT_SHDSL = 0xa9, /* Multirate HDSL2 */ > IFT_DS1FDL = 0xaa, /* Facility Data Link (4Kbps) on a DS1*/ > IFT_POS = 0xab, /* Packet over SONET/SDH Interface */ > IFT_DVBASILN = 0xac, /* DVB-ASI Input */ > IFT_DVBASIOUT = 0xad, /* DVB-ASI Output */ > IFT_PLC = 0xae, /* Power Line Communications */ > IFT_NFAS = 0xaf, /* Non-Facility Associated Signaling */ > IFT_TR008 = 0xb0, /* TROO8 */ > IFT_GR303RDT = 0xb1, /* Remote Digital Terminal */ > IFT_GR303IDT = 0xb2, /* Integrated Digital Terminal */ > IFT_ISUP = 0xb3, /* ISUP */ > IFT_PROPDOCSWIRELESSMACLAYER = 0xb4, /* prop/Wireless MAC Layer */ > IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5, /* prop/Wireless Downstream */ > IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6, /* prop/Wireless Upstream */ > IFT_HIPERLAN2 = 0xb7, /* HIPERLAN Type 2 Radio Interface */ > IFT_PROPBWAP2MP = 0xb8, /* PropBroadbandWirelessAccess P2MP*/ > IFT_SONETOVERHEADCHANNEL = 0xb9, /* SONET Overhead Channel */ > IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba, /* Digital Wrapper Overhead */ > IFT_AAL2 = 0xbb, /* ATM adaptation layer 2 */ > IFT_RADIOMAC = 0xbc, /* MAC layer over radio links */ > IFT_ATMRADIO = 0xbd, /* ATM over radio links */ > IFT_IMT = 0xbe, /* Inter-Machine Trunks */ > IFT_MVL = 0xbf, /* Multiple Virtual Lines DSL */ > IFT_REACHDSL = 0xc0, /* Long Reach DSL */ > IFT_FRDLCIENDPT = 0xc1, /* Frame Relay DLCI End Point */ > IFT_ATMVCIENDPT = 0xc2, /* ATM VCI End Point */ > IFT_OPTICALCHANNEL = 0xc3, /* Optical Channel */ > IFT_OPTICALTRANSPORT = 0xc4, /* Optical Transport */ > IFT_INFINIBAND = 0xc7, /* Infiniband */ > IFT_BRIDGE = 0xd1, /* Transparent bridge interface */ > IFT_STF = 0xd7, /* 6to4 interface */ > > /* > * Not based on IANA assignments. Conflicting with IANA assignments. > * We should make them negative probably. > * This requires changes to struct if_data. > */ > IFT_GIF = 0xf0, /* Generic tunnel interface */ > IFT_PVC = 0xf1, /* Unused */ > IFT_ENC = 0xf4, /* Encapsulating interface */ > IFT_PFLOG = 0xf6, /* PF packet filter logging */ > IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */ >} ifType; >#endif /* !_NET_IF_TYPES_H_ */ ># 258 "/usr/src/ifnet/sys/net/if_types.h" ># 548 "/usr/src/ifnet/sys/net/if.h" 2 >/* > * Under _KERNEL there live declarations from net/if.c, that are public > * and available to network device drivers. Declarations that are protected > * from drivers, but available to the stack live in if_var.h. > */ > >/* Some forward declarations are required. */ >struct mbuf; /* if_input, if_output, if_transmit */ >struct route; /* if_output */ >struct vnet; /* if_reassign */ > >#ifdef MALLOC_DECLARE >MALLOC_DECLARE(M_IFADDR); >MALLOC_DECLARE(M_IFMADDR); >#endif ># 563 "/usr/src/ifnet/sys/net/if.h" > >typedef enum { > IFCOUNTER_IPACKETS = 0, > IFCOUNTER_IERRORS, > IFCOUNTER_OPACKETS, > IFCOUNTER_OERRORS, > IFCOUNTER_COLLISIONS, > IFCOUNTER_IBYTES, > IFCOUNTER_OBYTES, > IFCOUNTER_IMCASTS, > IFCOUNTER_OMCASTS, > IFCOUNTER_IQDROPS, > IFCOUNTER_OQDROPS, > IFCOUNTER_NOPROTO, > IFCOUNTERS /* Array size (used internally). */ >} ift_counter; > >typedef enum { > IF_NO_SOFTC = 0, > IF_DRIVER_SOFTC, > IF_LLADDR, > IF_BPF, > IF_NAME, > /* > * Values do matter, since we want to avoid aliasing of frequently > * used features in if_sccache cache. > */ > IF_AF_INET = 100, > IF_AF_INET6, > IF_CARP, > IF_VLAN, > IF_TOEDEV, > /* > * Space above 99999 is split among different vendors. > * > * Chelsio 10000 - 10999 > */ > IF_CXGBE_PORT = 10000, >} ift_feature; > >typedef struct ifnet * if_t; > >typedef void (*if_input_t)(if_t, struct mbuf *); >typedef int (*if_transmit_t)(if_t, struct mbuf *); >typedef int (*if_output_t)(if_t, struct mbuf *, const struct sockaddr *, > struct route *); >typedef int (*if_ioctl_t)(if_t, u_long, void *, struct thread *); >typedef uint64_t (*if_get_counter_t)(if_t, ift_counter); >typedef void (*if_qflush_t)(if_t); >typedef int (*if_media_change_t)(if_t, struct ifreq *); >typedef void (*if_media_status_t)(if_t, struct ifmediareq *); >typedef int (*if_resolvemulti_t)(if_t, struct sockaddr **, > struct sockaddr *); >typedef void (*if_reassign_t)(if_t, struct vnet *); >typedef void (*if_vlan_event_t)(if_t, uint16_t, if_t); >enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS }; >typedef int (*if_poll_t)(if_t, enum poll_cmd, int); > >/* > * Interface methods. Usually stored in ifdriver definition, however > * some subsystems like lagg(4) or altq(4) may put a shim ifops before > * native ones. > */ >struct ifops { > if_input_t ifop_input; /* input routine (from h/w driver) */ > if_transmit_t ifop_transmit; /* initiate output routine */ > if_output_t ifop_output; > if_poll_t ifop_poll; > if_ioctl_t ifop_ioctl; /* ioctl routine */ > if_get_counter_t ifop_get_counter; /* get counter values */ > if_qflush_t ifop_qflush; /* flush any queue */ > if_media_change_t ifop_media_change; /* change media */ > if_media_status_t ifop_media_status; /* query media */ > if_resolvemulti_t ifop_resolvemulti; /* validate/resolve multicast */ > if_reassign_t ifop_reassign; /* reassign to vnet routine */ > if_vlan_event_t ifop_vlan_event;/* VLAN config/unconfig */ > struct ifops *ifop_next; > uint8_t ifop_origin; >}; >enum { > IFOP_ORIGIN_DRIVER = 1, > IFOP_ORIGIN_IFTYPE = 2, >}; > >/* > * Structure describing TSO properties of an interface. Known both to ifnet > * layer and TCP. Most interfaces point to a static tsomax in ifdriver > * definition. However, vlan(4) and lagg(4) require a dynamic tsomax. > */ >struct iftsomax { > uint32_t tsomax_bytes; /* TSO total burst length limit in bytes */ > uint32_t tsomax_segcount; /* TSO maximum segment count */ > uint32_t tsomax_segsize; /* TSO maximum segment size in bytes */ >}; > >/* > * Driver description. All instances of a driver share common properties > * that are stable during runtime. The stack can bless them, which > * means modify, when attaching the first instance of given > * driver. > */ >struct ifdriver { > struct ifops ifdrv_ops; > struct iftsomax *ifdrv_tsomax; > /* > * The ifdrv_name must be a pointer to storage which will last as > * long as any interface does. For physical devices, the result of > * device_get_name(dev) is a good choice and for pseudo-devices a > * static string works well. > */ > const char * ifdrv_name; > struct if_clone *ifdrv_clone; > ifType ifdrv_type; /* from if_types.h */ > uint8_t ifdrv_hdrlen; /* media header length */ > uint8_t ifdrv_addrlen; /* media address length */ > uint32_t ifdrv_dlt; /* from net/bpf.h */ > uint32_t ifdrv_dlt_hdrlen; > uint32_t ifdrv_maxqlen; /* max queue length for if_snd */ > /* > * Owned by stack. Drivers shouldn't initialize these! > */ > uint32_t __ifdrv_stack_owned; >}; > >/* > * Arguments for if_attach(). Usually stored on stack of device_attach > * function in driver. In future this structure will probably have > * different versions, so that we can support older ABIs for drivers. > */ >struct if_attach_args { > uint8_t ifat_version; /* must be IF_ATTACH_VERSION */ >#define IF_ATTACH_VERSION 1 > uint8_t ifat_spare8; > uint16_t ifat_spare16; > uint32_t ifat_spare32; > int ifat_error; /* Filled on return. */ > > struct ifdriver *ifat_drv; > void *ifat_softc; /* Driver private softc. */ > const uint8_t *ifat_lla; /* Link-level address. */ > int32_t ifat_dunit; /* Specific unit or a hint. */ >#define IFAT_DUNIT_NONE (-1) > char * ifat_name; /* If driver wants a specific name. */ > /* > * Capabilities can be different for two interfaces of the same > * driver, e.g. different chip revisions. > */ > uint64_t ifat_capabilities; > /* > * Pointer to static array of supported medias, current media > * word, and ignore mask for ifmedia_match(). > */ > if_media_t *ifat_medias; > if_media_t ifat_media; > if_media_t ifat_mediamask; > /* > * MTU, flags, capabilities at attach time. Driver > * can change them later. > */ > uint32_t ifat_mtu; > uint64_t ifat_flags; > uint64_t ifat_capenable; > uint64_t ifat_hwassist; > uint64_t ifat_baudrate; > /* > * If ifat_tsomax pointer is non-zero, then an interface will > * have dynamically allocated ifdrv_tsomax, that can be changed > * later. Otherwise it inherits static iftsomax from ifdriver. > */ > struct iftsomax *ifat_tsomax; >}; > >/* > * Interface manipulating functions that are available for drivers. > */ >if_t if_attach(struct if_attach_args *); >void if_detach(if_t); >void if_mtap(if_t, struct mbuf *, void *, u_int); >void if_inc_counter(if_t, ift_counter, int64_t); >void if_inc_txcounters(if_t, struct mbuf *); >void if_setbaudrate(if_t, uint64_t); >void if_link_state_change(if_t, int); >void * if_getsoftc(if_t, ift_feature); >int if_setsoftc(if_t, ift_feature, void *); >int if_printf(if_t, const char *, ...) __printflike(2, 3); >int if_drvioctl(if_t, u_long, void *, struct thread *); >uint64_t if_get_counter_default(if_t, ift_counter); > >/* > * Interface media manipulation by drivers. > */ >void if_media_set(if_t, if_media_t); > >/* > * Interface if_ops that are available for drivers. > */ >void if_input_noinline(if_t, struct mbuf *); >#define if_input(ifp, m) if_input_noinline(ifp, m) >int if_transmit_noinline(if_t, struct mbuf *); >#define if_transmit(ifp, m) if_transmit_noinline(ifp, m) > >/* > * Traversing through interface address lists. > */ >typedef void ifaddr_cb_t(void *, struct sockaddr *, struct sockaddr *, > struct sockaddr *); >typedef void ifmaddr_cb_t(void *, struct sockaddr *); >void if_foreach_addr(if_t, ifaddr_cb_t, void *); >void if_foreach_maddr(if_t, ifmaddr_cb_t, void *); > >/* > * Generic software send queue manipulation. > */ >int if_snd_len(if_t); >int if_snd_enqueue(if_t, struct mbuf *); >struct mbuf * if_snd_dequeue(if_t); >void if_snd_prepend(if_t, struct mbuf *); > >/* > * vlan(4) interfaces extra API. > */ >int if_vlanid(if_t, uint16_t *); >if_t if_vlandev(if_t, uint16_t); >if_t if_vlantrunk(if_t); > >/* > * Type-enforcing inliners over if_getsoftc(). > */ >static inline char * >if_lladdr(if_t ifp) >{ > > return ((char *)(if_getsoftc(ifp, IF_LLADDR))); >} > >static inline const char * >if_name(if_t ifp) >{ > > return ((char *)(if_getsoftc(ifp, IF_NAME))); >} >#endif /* _KERNEL */ ># 805 "/usr/src/ifnet/sys/net/if.h" >#endif /* !_NET_IF_H_ */ ># 806 "/usr/src/ifnet/sys/net/if.h" ># 47 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <net/if_var.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/net/if_var.h" 1 >/*- > * Copyright (c) 1982, 1986, 1989, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * From: @(#)if.h 8.1 (Berkeley) 6/10/93 > * $FreeBSD: projects/ifnet/sys/net/if_var.h 281653 2015-04-17 12:40:27Z glebius $ > */ > >#ifndef _NET_IF_VAR_H_ >#define _NET_IF_VAR_H_ >#ifndef _KERNEL >#ifdef BURN_BRIDGES >#error "no user-servicable parts inside" >#endif ># 39 "/usr/src/ifnet/sys/net/if_var.h" >#else ># 40 "/usr/src/ifnet/sys/net/if_var.h" > >struct rtentry; /* ifa_rtrequest */ >struct rt_addrinfo; /* ifa_rtrequest */ >struct socket; >struct carp_softc; >struct ifvlantrunk; >struct ifmedia; >struct netmap_adapter; > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mbuf.h> /* ifqueue only? */ >#endif /* expanded by -frewrite-includes */ ># 49 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/mbuf.h" 1 >/*- > * Copyright (c) 1982, 1986, 1988, 1993 > * The Regents of the University of California. > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)mbuf.h 8.5 (Berkeley) 2/19/95 > * $FreeBSD: projects/ifnet/sys/sys/mbuf.h 281144 2015-04-06 09:52:16Z glebius $ > */ > >#ifndef _SYS_MBUF_H_ >#define _SYS_MBUF_H_ > >/* XXX: These includes suck. Sorry! */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/mbuf.h" ># 39 "/usr/src/ifnet/sys/sys/mbuf.h" >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/systm.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/mbuf.h" ># 41 "/usr/src/ifnet/sys/sys/mbuf.h" >#if 0 /* expanded by -frewrite-includes */ >#include <vm/uma.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/mbuf.h" ># 1 "/usr/src/ifnet/sys/vm/uma.h" 1 >/*- > * Copyright (c) 2002, 2003, 2004, 2005 Jeffrey Roberson <jeff@FreeBSD.org> > * Copyright (c) 2004, 2005 Bosko Milekic <bmilekic@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/vm/uma.h 281023 2015-04-03 13:57:14Z glebius $ > * > */ > >/* > * uma.h - External definitions for the Universal Memory Allocator > * >*/ > >#ifndef _VM_UMA_H_ >#define _VM_UMA_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/param.h> /* For NULL */ >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/vm/uma.h" ># 40 "/usr/src/ifnet/sys/vm/uma.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/malloc.h> /* For M_* */ >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/vm/uma.h" ># 41 "/usr/src/ifnet/sys/vm/uma.h" > >/* User visible parameters */ >#define UMA_SMALLEST_UNIT (PAGE_SIZE / 256) /* Smallest item allocated */ > >/* Types and type defs */ > >struct uma_zone; >/* Opaque type used as a handle to the zone */ >typedef struct uma_zone * uma_zone_t; > >void zone_drain(uma_zone_t); > >/* > * Item constructor > * > * Arguments: > * item A pointer to the memory which has been allocated. > * arg The arg field passed to uma_zalloc_arg > * size The size of the allocated item > * flags See zalloc flags > * > * Returns: > * 0 on success > * errno on failure > * > * Discussion: > * The constructor is called just before the memory is returned > * to the user. It may block if necessary. > */ >typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags); > >/* > * Item destructor > * > * Arguments: > * item A pointer to the memory which has been allocated. > * size The size of the item being destructed. > * arg Argument passed through uma_zfree_arg > * > * Returns: > * Nothing > * > * Discussion: > * The destructor may perform operations that differ from those performed > * by the initializer, but it must leave the object in the same state. > * This IS type stable storage. This is called after EVERY zfree call. > */ >typedef void (*uma_dtor)(void *mem, int size, void *arg); > >/* > * Item initializer > * > * Arguments: > * item A pointer to the memory which has been allocated. > * size The size of the item being initialized. > * flags See zalloc flags > * > * Returns: > * 0 on success > * errno on failure > * > * Discussion: > * The initializer is called when the memory is cached in the uma zone. > * The initializer and the destructor should leave the object in the same > * state. > */ >typedef int (*uma_init)(void *mem, int size, int flags); > >/* > * Item discard function > * > * Arguments: > * item A pointer to memory which has been 'freed' but has not left the > * zone's cache. > * size The size of the item being discarded. > * > * Returns: > * Nothing > * > * Discussion: > * This routine is called when memory leaves a zone and is returned to the > * system for other uses. It is the counter-part to the init function. > */ >typedef void (*uma_fini)(void *mem, int size); > >/* > * Import new memory into a cache zone. > */ >typedef int (*uma_import)(void *arg, void **store, int count, int flags); > >/* > * Free memory from a cache zone. > */ >typedef void (*uma_release)(void *arg, void **store, int count); > >/* > * What's the difference between initializing and constructing? > * > * The item is initialized when it is cached, and this is the state that the > * object should be in when returned to the allocator. The purpose of this is > * to remove some code which would otherwise be called on each allocation by > * utilizing a known, stable state. This differs from the constructor which > * will be called on EVERY allocation. > * > * For example, in the initializer you may want to initialize embedded locks, > * NULL list pointers, set up initial states, magic numbers, etc. This way if > * the object is held in the allocator and re-used it won't be necessary to > * re-initialize it. > * > * The constructor may be used to lock a data structure, link it on to lists, > * bump reference counts or total counts of outstanding structures, etc. > * > */ > > >/* Function proto types */ > >/* > * Create a new uma zone > * > * Arguments: > * name The text name of the zone for debugging and stats. This memory > * should not be freed until the zone has been deallocated. > * size The size of the object that is being created. > * ctor The constructor that is called when the object is allocated. > * dtor The destructor that is called when the object is freed. > * init An initializer that sets up the initial state of the memory. > * fini A discard function that undoes initialization done by init. > * ctor/dtor/init/fini may all be null, see notes above. > * align A bitmask that corresponds to the requested alignment > * eg 4 would be 0x3 > * flags A set of parameters that control the behavior of the zone. > * > * Returns: > * A pointer to a structure which is intended to be opaque to users of > * the interface. The value may be null if the wait flag is not set. > */ >uma_zone_t uma_zcreate(const char *name, size_t size, uma_ctor ctor, > uma_dtor dtor, uma_init uminit, uma_fini fini, > int align, uint32_t flags); > >/* > * Create a secondary uma zone > * > * Arguments: > * name The text name of the zone for debugging and stats. This memory > * should not be freed until the zone has been deallocated. > * ctor The constructor that is called when the object is allocated. > * dtor The destructor that is called when the object is freed. > * zinit An initializer that sets up the initial state of the memory > * as the object passes from the Keg's slab to the Zone's cache. > * zfini A discard function that undoes initialization done by init > * as the object passes from the Zone's cache to the Keg's slab. > * > * ctor/dtor/zinit/zfini may all be null, see notes above. > * Note that the zinit and zfini specified here are NOT > * exactly the same as the init/fini specified to uma_zcreate() > * when creating a master zone. These zinit/zfini are called > * on the TRANSITION from keg to zone (and vice-versa). Once > * these are set, the primary zone may alter its init/fini > * (which are called when the object passes from VM to keg) > * using uma_zone_set_init/fini()) as well as its own > * zinit/zfini (unset by default for master zone) with > * uma_zone_set_zinit/zfini() (note subtle 'z' prefix). > * > * master A reference to this zone's Master Zone (Primary Zone), > * which contains the backing Keg for the Secondary Zone > * being added. > * > * Returns: > * A pointer to a structure which is intended to be opaque to users of > * the interface. The value may be null if the wait flag is not set. > */ >uma_zone_t uma_zsecond_create(char *name, uma_ctor ctor, uma_dtor dtor, > uma_init zinit, uma_fini zfini, uma_zone_t master); > >/* > * Add a second master to a secondary zone. This provides multiple data > * backends for objects with the same size. Both masters must have > * compatible allocation flags. Presently, UMA_ZONE_MALLOC type zones are > * the only supported. > * > * Returns: > * Error on failure, 0 on success. > */ >int uma_zsecond_add(uma_zone_t zone, uma_zone_t master); > >/* > * Create cache-only zones. > * > * This allows uma's per-cpu cache facilities to handle arbitrary > * pointers. Consumers must specify the import and release functions to > * fill and destroy caches. UMA does not allocate any memory for these > * zones. The 'arg' parameter is passed to import/release and is caller > * specific. > */ >uma_zone_t uma_zcache_create(char *name, int size, uma_ctor ctor, uma_dtor dtor, > uma_init zinit, uma_fini zfini, uma_import zimport, > uma_release zrelease, void *arg, int flags); > >/* > * Definitions for uma_zcreate flags > * > * These flags share space with UMA_ZFLAGs in uma_int.h. Be careful not to > * overlap when adding new features. 0xf0000000 is in use by uma_int.h. > */ >#define UMA_ZONE_PAGEABLE 0x0001 /* Return items not fully backed by > physical memory XXX Not yet */ >#define UMA_ZONE_ZINIT 0x0002 /* Initialize with zeros */ >#define UMA_ZONE_STATIC 0x0004 /* Statically sized zone */ >#define UMA_ZONE_OFFPAGE 0x0008 /* Force the slab structure allocation > off of the real memory */ >#define UMA_ZONE_MALLOC 0x0010 /* For use by malloc(9) only! */ >#define UMA_ZONE_NOFREE 0x0020 /* Do not free slabs of this type! */ >#define UMA_ZONE_MTXCLASS 0x0040 /* Create a new lock class */ >#define UMA_ZONE_VM 0x0080 /* > * Used for internal vm datastructures > * only. > */ >#define UMA_ZONE_HASH 0x0100 /* > * Use a hash table instead of caching > * information in the vm_page. > */ >#define UMA_ZONE_SECONDARY 0x0200 /* Zone is a Secondary Zone */ >#define UMA_ZONE_REFCNT 0x0400 /* Allocate refcnts in slabs */ >#define UMA_ZONE_MAXBUCKET 0x0800 /* Use largest buckets */ >#define UMA_ZONE_CACHESPREAD 0x1000 /* > * Spread memory start locations across > * all possible cache lines. May > * require many virtually contiguous > * backend pages and can fail early. > */ >#define UMA_ZONE_VTOSLAB 0x2000 /* Zone uses vtoslab for lookup. */ >#define UMA_ZONE_NODUMP 0x4000 /* > * Zone's pages will not be included in > * mini-dumps. > */ >#define UMA_ZONE_PCPU 0x8000 /* > * Allocates mp_ncpus slabs sized to > * sizeof(struct pcpu). > */ > >/* > * These flags are shared between the keg and zone. In zones wishing to add > * new kegs these flags must be compatible. Some are determined based on > * physical parameters of the request and may not be provided by the consumer. > */ >#define UMA_ZONE_INHERIT \ > (UMA_ZONE_OFFPAGE | UMA_ZONE_MALLOC | UMA_ZONE_NOFREE | \ > UMA_ZONE_HASH | UMA_ZONE_REFCNT | UMA_ZONE_VTOSLAB | UMA_ZONE_PCPU) > >/* Definitions for align */ >#define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */ >#define UMA_ALIGN_LONG (sizeof(long) - 1) /* "" long */ >#define UMA_ALIGN_INT (sizeof(int) - 1) /* "" int */ >#define UMA_ALIGN_SHORT (sizeof(short) - 1) /* "" short */ >#define UMA_ALIGN_CHAR (sizeof(char) - 1) /* "" char */ >#define UMA_ALIGN_CACHE (0 - 1) /* Cache line size align */ > >/* > * Destroys an empty uma zone. If the zone is not empty uma complains loudly. > * > * Arguments: > * zone The zone we want to destroy. > * > */ >void uma_zdestroy(uma_zone_t zone); > >/* > * Allocates an item out of a zone > * > * Arguments: > * zone The zone we are allocating from > * arg This data is passed to the ctor function > * flags See sys/malloc.h for available flags. > * > * Returns: > * A non-null pointer to an initialized element from the zone is > * guaranteed if the wait flag is M_WAITOK. Otherwise a null pointer > * may be returned if the zone is empty or the ctor failed. > */ > >void *uma_zalloc_arg(uma_zone_t zone, void *arg, int flags); > >/* > * Allocates an item out of a zone without supplying an argument > * > * This is just a wrapper for uma_zalloc_arg for convenience. > * > */ >static __inline void *uma_zalloc(uma_zone_t zone, int flags); > >static __inline void * >uma_zalloc(uma_zone_t zone, int flags) >{ > return uma_zalloc_arg(zone, NULL, flags); >} > >/* > * Frees an item back into the specified zone. > * > * Arguments: > * zone The zone the item was originally allocated out of. > * item The memory to be freed. > * arg Argument passed to the destructor > * > * Returns: > * Nothing. > */ > >void uma_zfree_arg(uma_zone_t zone, void *item, void *arg); > >/* > * Frees an item back to a zone without supplying an argument > * > * This is just a wrapper for uma_zfree_arg for convenience. > * > */ >static __inline void uma_zfree(uma_zone_t zone, void *item); > >static __inline void >uma_zfree(uma_zone_t zone, void *item) >{ > uma_zfree_arg(zone, item, NULL); >} > >/* > * XXX The rest of the prototypes in this header are h0h0 magic for the VM. > * If you think you need to use it for a normal zone you're probably incorrect. > */ > >/* > * Backend page supplier routines > * > * Arguments: > * zone The zone that is requesting pages. > * size The number of bytes being requested. > * pflag Flags for these memory pages, see below. > * wait Indicates our willingness to block. > * > * Returns: > * A pointer to the allocated memory or NULL on failure. > */ > >typedef void *(*uma_alloc)(uma_zone_t zone, vm_size_t size, uint8_t *pflag, > int wait); > >/* > * Backend page free routines > * > * Arguments: > * item A pointer to the previously allocated pages. > * size The original size of the allocation. > * pflag The flags for the slab. See UMA_SLAB_* below. > * > * Returns: > * None > */ >typedef void (*uma_free)(void *item, vm_size_t size, uint8_t pflag); > > > >/* > * Sets up the uma allocator. (Called by vm_mem_init) > * > * Arguments: > * bootmem A pointer to memory used to bootstrap the system. > * > * Returns: > * Nothing > * > * Discussion: > * This memory is used for zones which allocate things before the > * backend page supplier can give us pages. It should be > * UMA_SLAB_SIZE * boot_pages bytes. (see uma_int.h) > * > */ > >void uma_startup(void *bootmem, int boot_pages); > >/* > * Finishes starting up the allocator. This should > * be called when kva is ready for normal allocs. > * > * Arguments: > * None > * > * Returns: > * Nothing > * > * Discussion: > * uma_startup2 is called by kmeminit() to enable us of uma for malloc. > */ > >void uma_startup2(void); > >/* > * Reclaims unused memory for all zones > * > * Arguments: > * None > * Returns: > * None > * > * This should only be called by the page out daemon. > */ > >void uma_reclaim(void); > >/* > * Sets the alignment mask to be used for all zones requesting cache > * alignment. Should be called by MD boot code prior to starting VM/UMA. > * > * Arguments: > * align The alignment mask > * > * Returns: > * Nothing > */ >void uma_set_align(int align); > >/* > * Set a reserved number of items to hold for M_USE_RESERVE allocations. All > * other requests must allocate new backing pages. > */ >void uma_zone_reserve(uma_zone_t zone, int nitems); > >/* > * Reserves the maximum KVA space required by the zone and configures the zone > * to use a VM_ALLOC_NOOBJ-based backend allocator. > * > * Arguments: > * zone The zone to update. > * nitems The upper limit on the number of items that can be allocated. > * > * Returns: > * 0 if KVA space can not be allocated > * 1 if successful > * > * Discussion: > * When the machine supports a direct map and the zone's items are smaller > * than a page, the zone will use the direct map instead of allocating KVA > * space. > */ >int uma_zone_reserve_kva(uma_zone_t zone, int nitems); > >/* > * Sets a high limit on the number of items allowed in a zone > * > * Arguments: > * zone The zone to limit > * nitems The requested upper limit on the number of items allowed > * > * Returns: > * int The effective value of nitems after rounding up based on page size > */ >int uma_zone_set_max(uma_zone_t zone, int nitems); > >/* > * Obtains the effective limit on the number of items in a zone > * > * Arguments: > * zone The zone to obtain the effective limit from > * > * Return: > * 0 No limit > * int The effective limit of the zone > */ >int uma_zone_get_max(uma_zone_t zone); > >/* > * Sets a warning to be printed when limit is reached > * > * Arguments: > * zone The zone we will warn about > * warning Warning content > * > * Returns: > * Nothing > */ >void uma_zone_set_warning(uma_zone_t zone, const char *warning); > >/* > * Obtains the approximate current number of items allocated from a zone > * > * Arguments: > * zone The zone to obtain the current allocation count from > * > * Return: > * int The approximate current number of items allocated from the zone > */ >int uma_zone_get_cur(uma_zone_t zone); > >/* > * The following two routines (uma_zone_set_init/fini) > * are used to set the backend init/fini pair which acts on an > * object as it becomes allocated and is placed in a slab within > * the specified zone's backing keg. These should probably not > * be changed once allocations have already begun, but only be set > * immediately upon zone creation. > */ >void uma_zone_set_init(uma_zone_t zone, uma_init uminit); >void uma_zone_set_fini(uma_zone_t zone, uma_fini fini); > >/* > * The following two routines (uma_zone_set_zinit/zfini) are > * used to set the zinit/zfini pair which acts on an object as > * it passes from the backing Keg's slab cache to the > * specified Zone's bucket cache. These should probably not > * be changed once allocations have already begun, but only be set > * immediately upon zone creation. > */ >void uma_zone_set_zinit(uma_zone_t zone, uma_init zinit); >void uma_zone_set_zfini(uma_zone_t zone, uma_fini zfini); > >/* > * Replaces the standard backend allocator for this zone. > * > * Arguments: > * zone The zone whose backend allocator is being changed. > * allocf A pointer to the allocation function > * > * Returns: > * Nothing > * > * Discussion: > * This could be used to implement pageable allocation, or perhaps > * even DMA allocators if used in conjunction with the OFFPAGE > * zone flag. > */ > >void uma_zone_set_allocf(uma_zone_t zone, uma_alloc allocf); > >/* > * Used for freeing memory provided by the allocf above > * > * Arguments: > * zone The zone that intends to use this free routine. > * freef The page freeing routine. > * > * Returns: > * Nothing > */ > >void uma_zone_set_freef(uma_zone_t zone, uma_free freef); > >/* > * These flags are setable in the allocf and visible in the freef. > */ >#define UMA_SLAB_BOOT 0x01 /* Slab alloced from boot pages */ >#define UMA_SLAB_KMEM 0x02 /* Slab alloced from kmem_map */ >#define UMA_SLAB_KERNEL 0x04 /* Slab alloced from kernel_map */ >#define UMA_SLAB_PRIV 0x08 /* Slab alloced from priv allocator */ >#define UMA_SLAB_OFFP 0x10 /* Slab is managed separately */ >#define UMA_SLAB_MALLOC 0x20 /* Slab is a large malloc slab */ >/* 0x40 and 0x80 are available */ > >/* > * Used to pre-fill a zone with some number of items > * > * Arguments: > * zone The zone to fill > * itemcnt The number of items to reserve > * > * Returns: > * Nothing > * > * NOTE: This is blocking and should only be done at startup > */ >void uma_prealloc(uma_zone_t zone, int itemcnt); > >/* > * Used to lookup the reference counter allocated for an item > * from a UMA_ZONE_REFCNT zone. For UMA_ZONE_REFCNT zones, > * reference counters are allocated for items and stored in > * the underlying slab header. > * > * Arguments: > * zone The UMA_ZONE_REFCNT zone to which the item belongs. > * item The address of the item for which we want a refcnt. > * > * Returns: > * A pointer to a uint32_t reference counter. > */ >uint32_t *uma_find_refcnt(uma_zone_t zone, void *item); > >/* > * Used to determine if a fixed-size zone is exhausted. > * > * Arguments: > * zone The zone to check > * > * Returns: > * Non-zero if zone is exhausted. > */ >int uma_zone_exhausted(uma_zone_t zone); >int uma_zone_exhausted_nolock(uma_zone_t zone); > >/* > * Common UMA_ZONE_PCPU zones. > */ >extern uma_zone_t pcpu_zone_64; >extern uma_zone_t pcpu_zone_ptr; > >/* > * Exported statistics structures to be used by user space monitoring tools. > * Statistics stream consists of a uma_stream_header, followed by a series of > * alternative uma_type_header and uma_type_stat structures. > */ >#define UMA_STREAM_VERSION 0x00000001 >struct uma_stream_header { > uint32_t ush_version; /* Stream format version. */ > uint32_t ush_maxcpus; /* Value of MAXCPU for stream. */ > uint32_t ush_count; /* Number of records. */ > uint32_t _ush_pad; /* Pad/reserved field. */ >}; > >#define UTH_MAX_NAME 32 >#define UTH_ZONE_SECONDARY 0x00000001 >struct uma_type_header { > /* > * Static per-zone data, some extracted from the supporting keg. > */ > char uth_name[UTH_MAX_NAME]; > uint32_t uth_align; /* Keg: alignment. */ > uint32_t uth_size; /* Keg: requested size of item. */ > uint32_t uth_rsize; /* Keg: real size of item. */ > uint32_t uth_maxpages; /* Keg: maximum number of pages. */ > uint32_t uth_limit; /* Keg: max items to allocate. */ > > /* > * Current dynamic zone/keg-derived statistics. > */ > uint32_t uth_pages; /* Keg: pages allocated. */ > uint32_t uth_keg_free; /* Keg: items free. */ > uint32_t uth_zone_free; /* Zone: items free. */ > uint32_t uth_bucketsize; /* Zone: desired bucket size. */ > uint32_t uth_zone_flags; /* Zone: flags. */ > uint64_t uth_allocs; /* Zone: number of allocations. */ > uint64_t uth_frees; /* Zone: number of frees. */ > uint64_t uth_fails; /* Zone: number of alloc failures. */ > uint64_t uth_sleeps; /* Zone: number of alloc sleeps. */ > uint64_t _uth_reserved1[2]; /* Reserved. */ >}; > >struct uma_percpu_stat { > uint64_t ups_allocs; /* Cache: number of allocations. */ > uint64_t ups_frees; /* Cache: number of frees. */ > uint64_t ups_cache_free; /* Cache: free items in cache. */ > uint64_t _ups_reserved[5]; /* Reserved. */ >}; > >#endif /* _VM_UMA_H_ */ ># 694 "/usr/src/ifnet/sys/vm/uma.h" ># 42 "/usr/src/ifnet/sys/sys/mbuf.h" 2 >#ifdef WITNESS >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/sys/mbuf.h" ># 1 "/usr/src/ifnet/sys/sys/lock.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp > * $FreeBSD: projects/ifnet/sys/sys/lock.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_LOCK_H_ >#define _SYS_LOCK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/lock.h" ># 36 "/usr/src/ifnet/sys/sys/lock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/lock.h" ># 37 "/usr/src/ifnet/sys/sys/lock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/ktr_class.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/lock.h" ># 1 "/usr/src/ifnet/sys/sys/ktr_class.h" 1 >/*- > * Copyright (c) 1996 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI $Id: ktr.h,v 1.10.2.7 2000/03/16 21:44:42 cp Exp $ > * $FreeBSD: projects/ifnet/sys/sys/ktr_class.h 279670 2015-03-05 18:22:20Z glebius $ > */ > >#ifndef _SYS_KTR_CLASS_H_ >#define _SYS_KTR_CLASS_H_ > >/* > * KTR trace classes > * > * Two of the trace classes (KTR_DEV and KTR_SUBSYS) are special in that > * they are really placeholders so that indvidual drivers and subsystems > * can map their internal tracing to the general class when they wish to > * have tracing enabled and map it to 0 when they don't. > */ >#define KTR_GEN 0x00000001 /* General (TR) */ >#define KTR_NET 0x00000002 /* Network */ >#define KTR_DEV 0x00000004 /* Device driver */ >#define KTR_LOCK 0x00000008 /* MP locking */ >#define KTR_SMP 0x00000010 /* MP general */ >#define KTR_SUBSYS 0x00000020 /* Subsystem. */ >#define KTR_PMAP 0x00000040 /* Pmap tracing */ >#define KTR_MALLOC 0x00000080 /* Malloc tracing */ >#define KTR_TRAP 0x00000100 /* Trap processing */ >#define KTR_INTR 0x00000200 /* Interrupt tracing */ >#define KTR_SIG 0x00000400 /* Signal processing */ >#define KTR_SPARE2 0x00000800 /* cxgb, amd64, xen, clk, &c */ >#define KTR_PROC 0x00001000 /* Process scheduling */ >#define KTR_SYSC 0x00002000 /* System call */ >#define KTR_INIT 0x00004000 /* System initialization */ >#define KTR_SPARE3 0x00008000 /* cxgb, drm2, ntb */ >#define KTR_SPARE4 0x00010000 /* geom_sched */ >#define KTR_EVH 0x00020000 /* Eventhandler */ >#define KTR_VFS 0x00040000 /* VFS events */ >#define KTR_VOP 0x00080000 /* Auto-generated vop events */ >#define KTR_VM 0x00100000 /* The virtual memory system */ >#define KTR_INET 0x00200000 /* IPv4 stack */ >#define KTR_RUNQ 0x00400000 /* Run queue */ >#define KTR_CONTENTION 0x00800000 /* Lock contention */ >#define KTR_UMA 0x01000000 /* UMA slab allocator */ >#define KTR_CALLOUT 0x02000000 /* Callouts and timeouts */ >#define KTR_GEOM 0x04000000 /* GEOM I/O events */ >#define KTR_BUSDMA 0x08000000 /* busdma(9) events */ >#define KTR_INET6 0x10000000 /* IPv6 stack */ >#define KTR_SCHED 0x20000000 /* Machine parsed sched info. */ >#define KTR_BUF 0x40000000 /* Buffer cache */ >#define KTR_ALL 0x7fffffff > >/* KTR trace classes to compile in */ >#ifdef KTR >#ifndef KTR_COMPILE >#define KTR_COMPILE (KTR_ALL) >#endif ># 81 "/usr/src/ifnet/sys/sys/ktr_class.h" >#else /* !KTR */ ># 82 "/usr/src/ifnet/sys/sys/ktr_class.h" >#undef KTR_COMPILE >#define KTR_COMPILE 0 >#endif /* KTR */ ># 85 "/usr/src/ifnet/sys/sys/ktr_class.h" > >#endif /* !_SYS_KTR_CLASS_H_ */ ># 87 "/usr/src/ifnet/sys/sys/ktr_class.h" ># 38 "/usr/src/ifnet/sys/sys/lock.h" 2 > >struct lock_list_entry; >struct thread; > >/* > * Lock classes. Each lock has a class which describes characteristics > * common to all types of locks of a given class. > * > * Spin locks in general must always protect against preemption, as it is > * an error to perform any type of context switch while holding a spin lock. > * Also, for an individual lock to be recursable, its class must allow > * recursion and the lock itself must explicitly allow recursion. > * > * The 'lc_ddb_show' function pointer is used to dump class-specific > * data for the 'show lock' DDB command. The 'lc_lock' and > * 'lc_unlock' function pointers are used in sleep(9) and cv_wait(9) > * to lock and unlock locks while blocking on a sleep queue. The > * return value of 'lc_unlock' will be passed to 'lc_lock' on resume > * to allow communication of state between the two routines. > */ > >struct lock_class { > const char *lc_name; > u_int lc_flags; > void (*lc_assert)(const struct lock_object *lock, int what); > void (*lc_ddb_show)(const struct lock_object *lock); > void (*lc_lock)(struct lock_object *lock, uintptr_t how); > int (*lc_owner)(const struct lock_object *lock, > struct thread **owner); > uintptr_t (*lc_unlock)(struct lock_object *lock); >}; > >#define LC_SLEEPLOCK 0x00000001 /* Sleep lock. */ >#define LC_SPINLOCK 0x00000002 /* Spin lock. */ >#define LC_SLEEPABLE 0x00000004 /* Sleeping allowed with this lock. */ >#define LC_RECURSABLE 0x00000008 /* Locks of this type may recurse. */ >#define LC_UPGRADABLE 0x00000010 /* Upgrades and downgrades permitted. */ > >#define LO_CLASSFLAGS 0x0000ffff /* Class specific flags. */ >#define LO_INITIALIZED 0x00010000 /* Lock has been initialized. */ >#define LO_WITNESS 0x00020000 /* Should witness monitor this lock. */ >#define LO_QUIET 0x00040000 /* Don't log locking operations. */ >#define LO_RECURSABLE 0x00080000 /* Lock may recurse. */ >#define LO_SLEEPABLE 0x00100000 /* Lock may be held while sleeping. */ >#define LO_UPGRADABLE 0x00200000 /* Lock may be upgraded/downgraded. */ >#define LO_DUPOK 0x00400000 /* Don't check for duplicate acquires */ >#define LO_IS_VNODE 0x00800000 /* Tell WITNESS about a VNODE lock */ >#define LO_CLASSMASK 0x0f000000 /* Class index bitmask. */ >#define LO_NOPROFILE 0x10000000 /* Don't profile this lock */ >#define LO_NEW 0x20000000 /* Don't check for double-init */ > >/* > * Lock classes are statically assigned an index into the gobal lock_classes > * array. Debugging code looks up the lock class for a given lock object > * by indexing the array. > */ >#define LO_CLASSSHIFT 24 >#define LO_CLASSINDEX(lock) ((((lock)->lo_flags) & LO_CLASSMASK) >> LO_CLASSSHIFT) >#define LOCK_CLASS(lock) (lock_classes[LO_CLASSINDEX((lock))]) >#define LOCK_CLASS_MAX (LO_CLASSMASK >> LO_CLASSSHIFT) > >/* > * Option flags passed to lock operations that witness also needs to know > * about or that are generic across all locks. > */ >#define LOP_NEWORDER 0x00000001 /* Define a new lock order. */ >#define LOP_QUIET 0x00000002 /* Don't log locking operations. */ >#define LOP_TRYLOCK 0x00000004 /* Don't check lock order. */ >#define LOP_EXCLUSIVE 0x00000008 /* Exclusive lock. */ >#define LOP_DUPOK 0x00000010 /* Don't check for duplicate acquires */ > >/* Flags passed to witness_assert. */ >#define LA_MASKASSERT 0x000000ff /* Mask for witness defined asserts. */ >#define LA_UNLOCKED 0x00000000 /* Lock is unlocked. */ >#define LA_LOCKED 0x00000001 /* Lock is at least share locked. */ >#define LA_SLOCKED 0x00000002 /* Lock is exactly share locked. */ >#define LA_XLOCKED 0x00000004 /* Lock is exclusively locked. */ >#define LA_RECURSED 0x00000008 /* Lock is recursed. */ >#define LA_NOTRECURSED 0x00000010 /* Lock is not recursed. */ > >#ifdef _KERNEL >/* > * If any of WITNESS, INVARIANTS, or KTR_LOCK KTR tracing has been enabled, > * then turn on LOCK_DEBUG. When this option is on, extra debugging > * facilities such as tracking the file and line number of lock operations > * are enabled. Also, mutex locking operations are not inlined to avoid > * bloat from all the extra debugging code. We also have to turn on all the > * calling conventions for this debugging code in modules so that modules can > * work with both debug and non-debug kernels. > */ >#if defined(KLD_MODULE) || defined(WITNESS) || defined(INVARIANTS) || defined(INVARIANT_SUPPORT) || defined(LOCK_PROFILING) || (defined(KTR) && (KTR_COMPILE & KTR_LOCK)) >#define LOCK_DEBUG 1 >#else ># 131 "/usr/src/ifnet/sys/sys/lock.h" >#define LOCK_DEBUG 0 >#endif ># 133 "/usr/src/ifnet/sys/sys/lock.h" > >/* > * In the LOCK_DEBUG case, use the filename and line numbers for debugging > * operations. Otherwise, use default values to avoid the unneeded bloat. > */ >#if LOCK_DEBUG > 0 >#define LOCK_FILE __FILE__ >#define LOCK_LINE __LINE__ >#else ># 142 "/usr/src/ifnet/sys/sys/lock.h" >#define LOCK_FILE NULL >#define LOCK_LINE 0 >#endif ># 145 "/usr/src/ifnet/sys/sys/lock.h" > >/* > * Macros for KTR_LOCK tracing. > * > * opname - name of this operation (LOCK/UNLOCK/SLOCK, etc.) > * lo - struct lock_object * for this lock > * flags - flags passed to the lock operation > * recurse - this locks recursion level (or 0 if class is not recursable) > * result - result of a try lock operation > * file - file name > * line - line number > */ >#define LOCK_LOG_TEST(lo, flags) \ > (((flags) & LOP_QUIET) == 0 && ((lo)->lo_flags & LO_QUIET) == 0) > >#define LOCK_LOG_LOCK(opname, lo, flags, recurse, file, line) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR6(KTR_LOCK, opname " (%s) %s %p r = %d at %s:%d", \ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ > (lo), (u_int)(recurse), (file), (line)); \ >} while (0) > >#define LOCK_LOG_TRY(opname, lo, flags, result, file, line) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR6(KTR_LOCK, "TRY_" opname " (%s) %s %p result=%d at %s:%d",\ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name, \ > (lo), (u_int)(result), (file), (line)); \ >} while (0) > >#define LOCK_LOG_INIT(lo, flags) do { \ > if (LOCK_LOG_TEST((lo), (flags))) \ > CTR4(KTR_LOCK, "%s: %p (%s) %s", __func__, (lo), \ > LOCK_CLASS(lo)->lc_name, (lo)->lo_name); \ >} while (0) > >#define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) > >#define lock_initialized(lo) ((lo)->lo_flags & LO_INITIALIZED) > >/* > * Helpful macros for quickly coming up with assertions with informative > * panic messages. > */ >#define MPASS(ex) MPASS4(ex, #ex, __FILE__, __LINE__) >#define MPASS2(ex, what) MPASS4(ex, what, __FILE__, __LINE__) >#define MPASS3(ex, file, line) MPASS4(ex, #ex, file, line) >#define MPASS4(ex, what, file, line) \ > KASSERT((ex), ("Assertion %s failed at %s:%d", what, file, line)) > >extern struct lock_class lock_class_mtx_sleep; >extern struct lock_class lock_class_mtx_spin; >extern struct lock_class lock_class_sx; >extern struct lock_class lock_class_rw; >extern struct lock_class lock_class_rm; >extern struct lock_class lock_class_rm_sleepable; >extern struct lock_class lock_class_lockmgr; > >extern struct lock_class *lock_classes[]; > >void lock_init(struct lock_object *, struct lock_class *, > const char *, const char *, int); >void lock_destroy(struct lock_object *); >void spinlock_enter(void); >void spinlock_exit(void); >void witness_init(struct lock_object *, const char *); >void witness_destroy(struct lock_object *); >int witness_defineorder(struct lock_object *, struct lock_object *); >void witness_checkorder(struct lock_object *, int, const char *, int, > struct lock_object *); >void witness_lock(struct lock_object *, int, const char *, int); >void witness_upgrade(struct lock_object *, int, const char *, int); >void witness_downgrade(struct lock_object *, int, const char *, int); >void witness_unlock(struct lock_object *, int, const char *, int); >void witness_save(struct lock_object *, const char **, int *); >void witness_restore(struct lock_object *, const char *, int); >int witness_list_locks(struct lock_list_entry **, > int (*)(const char *, ...)); >int witness_warn(int, struct lock_object *, const char *, ...); >void witness_assert(const struct lock_object *, int, const char *, int); >void witness_display_spinlock(struct lock_object *, struct thread *, > int (*)(const char *, ...)); >int witness_line(struct lock_object *); >void witness_norelease(struct lock_object *); >void witness_releaseok(struct lock_object *); >const char *witness_file(struct lock_object *); >void witness_thread_exit(struct thread *); > >#ifdef WITNESS > >/* Flags for witness_warn(). */ >#define WARN_GIANTOK 0x01 /* Giant is exempt from this check. */ >#define WARN_PANIC 0x02 /* Panic if check fails. */ >#define WARN_SLEEPOK 0x04 /* Sleepable locks are exempt from check. */ > >#define WITNESS_INIT(lock, type) \ > witness_init((lock), (type)) > >#define WITNESS_DESTROY(lock) \ > witness_destroy(lock) > >#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) \ > witness_checkorder((lock), (flags), (file), (line), (interlock)) > >#define WITNESS_DEFINEORDER(lock1, lock2) \ > witness_defineorder((struct lock_object *)(lock1), \ > (struct lock_object *)(lock2)) > >#define WITNESS_LOCK(lock, flags, file, line) \ > witness_lock((lock), (flags), (file), (line)) > >#define WITNESS_UPGRADE(lock, flags, file, line) \ > witness_upgrade((lock), (flags), (file), (line)) > >#define WITNESS_DOWNGRADE(lock, flags, file, line) \ > witness_downgrade((lock), (flags), (file), (line)) > >#define WITNESS_UNLOCK(lock, flags, file, line) \ > witness_unlock((lock), (flags), (file), (line)) > >#define WITNESS_CHECK(flags, lock, fmt, ...) \ > witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) > >#define WITNESS_WARN(flags, lock, fmt, ...) \ > witness_warn((flags), (lock), (fmt), ## __VA_ARGS__) > >#define WITNESS_SAVE_DECL(n) \ > const char * __CONCAT(n, __wf); \ > int __CONCAT(n, __wl) > >#define WITNESS_SAVE(lock, n) \ > witness_save((lock), &__CONCAT(n, __wf), &__CONCAT(n, __wl)) > >#define WITNESS_RESTORE(lock, n) \ > witness_restore((lock), __CONCAT(n, __wf), __CONCAT(n, __wl)) > >#define WITNESS_NORELEASE(lock) \ > witness_norelease(&(lock)->lock_object) > >#define WITNESS_RELEASEOK(lock) \ > witness_releaseok(&(lock)->lock_object) > >#define WITNESS_FILE(lock) \ > witness_file(lock) > >#define WITNESS_LINE(lock) \ > witness_line(lock) > >#else /* WITNESS */ ># 293 "/usr/src/ifnet/sys/sys/lock.h" >#define WITNESS_INIT(lock, type) (void)0 >#define WITNESS_DESTROY(lock) (void)0 >#define WITNESS_DEFINEORDER(lock1, lock2) 0 >#define WITNESS_CHECKORDER(lock, flags, file, line, interlock) (void)0 >#define WITNESS_LOCK(lock, flags, file, line) (void)0 >#define WITNESS_UPGRADE(lock, flags, file, line) (void)0 >#define WITNESS_DOWNGRADE(lock, flags, file, line) (void)0 >#define WITNESS_UNLOCK(lock, flags, file, line) (void)0 >#define WITNESS_CHECK(flags, lock, fmt, ...) 0 >#define WITNESS_WARN(flags, lock, fmt, ...) (void)0 >#define WITNESS_SAVE_DECL(n) (void)0 >#define WITNESS_SAVE(lock, n) (void)0 >#define WITNESS_RESTORE(lock, n) (void)0 >#define WITNESS_NORELEASE(lock) (void)0 >#define WITNESS_RELEASEOK(lock) (void)0 >#define WITNESS_FILE(lock) ("?") >#define WITNESS_LINE(lock) (0) >#endif /* WITNESS */ ># 311 "/usr/src/ifnet/sys/sys/lock.h" > >#endif /* _KERNEL */ ># 313 "/usr/src/ifnet/sys/sys/lock.h" >#endif /* _SYS_LOCK_H_ */ ># 314 "/usr/src/ifnet/sys/sys/lock.h" ># 44 "/usr/src/ifnet/sys/sys/mbuf.h" 2 >#endif ># 45 "/usr/src/ifnet/sys/sys/mbuf.h" >#endif ># 46 "/usr/src/ifnet/sys/sys/mbuf.h" > >/* > * Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead. > * An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in > * sys/param.h), which has no additional overhead and is used instead of the > * internal data area; this is done when at least MINCLSIZE of data must be > * stored. Additionally, it is possible to allocate a separate buffer > * externally and attach it to the mbuf in a way similar to that of mbuf > * clusters. > * > * NB: These calculation do not take actual compiler-induced alignment and > * padding inside the complete struct mbuf into account. Appropriate > * attention is required when changing members of struct mbuf. > * > * MLEN is data length in a normal mbuf. > * MHLEN is data length in an mbuf with pktheader. > * MINCLSIZE is a smallest amount of data that should be put into cluster. > * > * Compile-time assertions in uipc_mbuf.c test these values to ensure that > * they are sensible. > */ >struct mbuf; >#define MHSIZE offsetof(struct mbuf, m_dat) >#define MPKTHSIZE offsetof(struct mbuf, m_pktdat) >#define MLEN ((int)(MSIZE - MHSIZE)) >#define MHLEN ((int)(MSIZE - MPKTHSIZE)) >#define MINCLSIZE (MHLEN + 1) > >#ifdef _KERNEL >/*- > * Macro for type conversion: convert mbuf pointer to data pointer of correct > * type: > * > * mtod(m, t) -- Convert mbuf pointer to data pointer of correct type. > * mtodo(m, o) -- Same as above but with offset 'o' into data. > */ >#define mtod(m, t) ((t)((m)->m_data)) >#define mtodo(m, o) ((void *)(((m)->m_data) + (o))) > >/* > * Argument structure passed to UMA routines during mbuf and packet > * allocations. > */ >struct mb_args { > int flags; /* Flags for mbuf being allocated */ > short type; /* Type of mbuf being allocated */ >}; >#endif /* _KERNEL */ ># 94 "/usr/src/ifnet/sys/sys/mbuf.h" > >/* > * Packet tag structure (see below for details). > */ >struct m_tag { > SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */ > u_int16_t m_tag_id; /* Tag ID */ > u_int16_t m_tag_len; /* Length of data */ > u_int32_t m_tag_cookie; /* ABI/Module ID */ > void (*m_tag_free)(struct m_tag *); >}; > >/* > * Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set. > * Size ILP32: 48 > * LP64: 56 > * Compile-time assertions in uipc_mbuf.c test these values to ensure that > * they are correct. > */ >struct pkthdr { > struct ifnet *rcvif; /* rcv interface */ > SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ > int32_t len; /* total packet length */ > > /* Layer crossing persistent information. */ > uint32_t flowid; /* packet's 4-tuple system */ > uint64_t csum_flags; /* checksum and offload features */ > uint16_t fibnum; /* this packet should use this fib */ > uint8_t cosqos; /* class/quality of service */ > uint8_t rsstype; /* hash type */ > uint8_t l2hlen; /* layer 2 header length */ > uint8_t l3hlen; /* layer 3 header length */ > uint8_t l4hlen; /* layer 4 header length */ > uint8_t l5hlen; /* layer 5 header length */ > union { > uint8_t eight[8]; > uint16_t sixteen[4]; > uint32_t thirtytwo[2]; > uint64_t sixtyfour[1]; > uintptr_t unintptr[1]; > void *ptr; > } PH_per; > > /* Layer specific non-persistent local storage for reassembly, etc. */ > union { > uint8_t eight[8]; > uint16_t sixteen[4]; > uint32_t thirtytwo[2]; > uint64_t sixtyfour[1]; > uintptr_t unintptr[1]; > void *ptr; > } PH_loc; >}; >#define ether_vtag PH_per.sixteen[0] >#define PH_vt PH_per >#define vt_nrecs sixteen[0] >#define tso_segsz PH_per.sixteen[1] >#define csum_phsum PH_per.sixteen[2] >#define csum_data PH_per.thirtytwo[1] >#define pkt_tcphdr PH_loc.ptr > >/* > * Description of external storage mapped into mbuf; valid only if M_EXT is > * set. > * Size ILP32: 28 > * LP64: 48 > * Compile-time assertions in uipc_mbuf.c test these values to ensure that > * they are correct. > */ >struct m_ext { > volatile u_int *ext_cnt; /* pointer to ref count info */ > caddr_t ext_buf; /* start of buffer */ > uint32_t ext_size; /* size of buffer, for ext_free */ > uint32_t ext_type:8, /* type of external storage */ > ext_flags:24; /* external storage mbuf flags */ > void (*ext_free) /* free routine if not the usual */ > (struct mbuf *, void *, void *); > void *ext_arg1; /* optional argument pointer */ > void *ext_arg2; /* optional argument pointer */ >}; > >/* > * The core of the mbuf object along with some shortcut defines for practical > * purposes. > */ >struct mbuf { > /* > * Header present at the beginning of every mbuf. > * Size ILP32: 24 > * LP64: 32 > * Compile-time assertions in uipc_mbuf.c test these values to ensure > * that they are correct. > */ > union { /* next buffer in chain */ > struct mbuf *m_next; > SLIST_ENTRY(mbuf) m_slist; > STAILQ_ENTRY(mbuf) m_stailq; > }; > union { /* next chain in queue/record */ > struct mbuf *m_nextpkt; > SLIST_ENTRY(mbuf) m_slistpkt; > STAILQ_ENTRY(mbuf) m_stailqpkt; > }; > caddr_t m_data; /* location of data */ > int32_t m_len; /* amount of data in this mbuf */ > uint32_t m_type:8, /* type of data in this mbuf */ > m_flags:24; /* flags; see below */ >#if !defined(__LP64__) > uint32_t m_pad; /* pad for 64bit alignment */ >#endif ># 204 "/usr/src/ifnet/sys/sys/mbuf.h" > > /* > * A set of optional headers (packet header, external storage header) > * and internal data storage. Historically, these arrays were sized > * to MHLEN (space left after a packet header) and MLEN (space left > * after only a regular mbuf header); they are now variable size in > * order to support future work on variable-size mbufs. > */ > union { > struct { > struct pkthdr m_pkthdr; /* M_PKTHDR set */ > union { > struct m_ext m_ext; /* M_EXT set */ > char m_pktdat[0]; > }; > }; > char m_dat[0]; /* !M_PKTHDR, !M_EXT */ > }; >}; > >/* > * mbuf flags of global significance and layer crossing. > * Those of only protocol/layer specific significance are to be mapped > * to M_PROTO[1-12] and cleared at layer handoff boundaries. > * NB: Limited to the lower 24 bits. > */ >#define M_EXT 0x00000001 /* has associated external storage */ >#define M_PKTHDR 0x00000002 /* start of record */ >#define M_EOR 0x00000004 /* end of record */ >#define M_RDONLY 0x00000008 /* associated data is marked read-only */ >#define M_BCAST 0x00000010 /* send/received as link-level broadcast */ >#define M_MCAST 0x00000020 /* send/received as link-level multicast */ >#define M_PROMISC 0x00000040 /* packet was not for us */ >#define M_VLANTAG 0x00000080 /* ether_vtag is valid */ >#define M_UNUSED_8 0x00000100 /* --available-- */ >#define M_NOFREE 0x00000200 /* do not free mbuf, embedded in cluster */ > >#define M_PROTO1 0x00001000 /* protocol-specific */ >#define M_PROTO2 0x00002000 /* protocol-specific */ >#define M_PROTO3 0x00004000 /* protocol-specific */ >#define M_PROTO4 0x00008000 /* protocol-specific */ >#define M_PROTO5 0x00010000 /* protocol-specific */ >#define M_PROTO6 0x00020000 /* protocol-specific */ >#define M_PROTO7 0x00040000 /* protocol-specific */ >#define M_PROTO8 0x00080000 /* protocol-specific */ >#define M_PROTO9 0x00100000 /* protocol-specific */ >#define M_PROTO10 0x00200000 /* protocol-specific */ >#define M_PROTO11 0x00400000 /* protocol-specific */ >#define M_PROTO12 0x00800000 /* protocol-specific */ > >/* > * Flags to purge when crossing layers. > */ >#define M_PROTOFLAGS \ > (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5|M_PROTO6|M_PROTO7|M_PROTO8|\ > M_PROTO9|M_PROTO10|M_PROTO11|M_PROTO12) > >/* > * Flags preserved when copying m_pkthdr. > */ >#define M_COPYFLAGS \ > (M_PKTHDR|M_EOR|M_RDONLY|M_BCAST|M_MCAST|M_PROMISC|M_VLANTAG| \ > M_PROTOFLAGS) > >/* > * Mbuf flag description for use with printf(9) %b identifier. > */ >#define M_FLAG_BITS \ > "\20\1M_EXT\2M_PKTHDR\3M_EOR\4M_RDONLY\5M_BCAST\6M_MCAST" \ > "\7M_PROMISC\10M_VLANTAG" >#define M_FLAG_PROTOBITS \ > "\15M_PROTO1\16M_PROTO2\17M_PROTO3\20M_PROTO4\21M_PROTO5" \ > "\22M_PROTO6\23M_PROTO7\24M_PROTO8\25M_PROTO9\26M_PROTO10" \ > "\27M_PROTO11\30M_PROTO12" >#define M_FLAG_PRINTF (M_FLAG_BITS M_FLAG_PROTOBITS) > >/* > * Network interface cards are able to hash protocol fields (such as IPv4 > * addresses and TCP port numbers) classify packets into flows. These flows > * can then be used to maintain ordering while delivering packets to the OS > * via parallel input queues, as well as to provide a stateless affinity > * model. NIC drivers can pass up the hash via m->m_pkthdr.flowid, and set > * m_flag fields to indicate how the hash should be interpreted by the > * network stack. > * > * Most NICs support RSS, which provides ordering and explicit affinity, and > * use the hash m_flag bits to indicate what header fields were covered by > * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations > * that provide an opaque flow identifier, allowing for ordering and > * distribution without explicit affinity. > */ >/* Microsoft RSS standard hash types */ >#define M_HASHTYPE_NONE 0 >#define M_HASHTYPE_RSS_IPV4 1 /* IPv4 2-tuple */ >#define M_HASHTYPE_RSS_TCP_IPV4 2 /* TCPv4 4-tuple */ >#define M_HASHTYPE_RSS_IPV6 3 /* IPv6 2-tuple */ >#define M_HASHTYPE_RSS_TCP_IPV6 4 /* TCPv6 4-tuple */ >#define M_HASHTYPE_RSS_IPV6_EX 5 /* IPv6 2-tuple + ext hdrs */ >#define M_HASHTYPE_RSS_TCP_IPV6_EX 6 /* TCPv6 4-tiple + ext hdrs */ >/* Non-standard RSS hash types */ >#define M_HASHTYPE_RSS_UDP_IPV4 7 /* IPv4 UDP 4-tuple */ >#define M_HASHTYPE_RSS_UDP_IPV4_EX 8 /* IPv4 UDP 4-tuple + ext hdrs */ >#define M_HASHTYPE_RSS_UDP_IPV6 9 /* IPv6 UDP 4-tuple */ >#define M_HASHTYPE_RSS_UDP_IPV6_EX 10 /* IPv6 UDP 4-tuple + ext hdrs */ > >#define M_HASHTYPE_OPAQUE 255 /* ordering, not affinity */ > >#define M_HASHTYPE_CLEAR(m) ((m)->m_pkthdr.rsstype = 0) >#define M_HASHTYPE_GET(m) ((m)->m_pkthdr.rsstype) >#define M_HASHTYPE_SET(m, v) ((m)->m_pkthdr.rsstype = (v)) >#define M_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) > >/* > * COS/QOS class and quality of service tags. > * It uses DSCP code points as base. > */ >#define QOS_DSCP_CS0 0x00 >#define QOS_DSCP_DEF QOS_DSCP_CS0 >#define QOS_DSCP_CS1 0x20 >#define QOS_DSCP_AF11 0x28 >#define QOS_DSCP_AF12 0x30 >#define QOS_DSCP_AF13 0x38 >#define QOS_DSCP_CS2 0x40 >#define QOS_DSCP_AF21 0x48 >#define QOS_DSCP_AF22 0x50 >#define QOS_DSCP_AF23 0x58 >#define QOS_DSCP_CS3 0x60 >#define QOS_DSCP_AF31 0x68 >#define QOS_DSCP_AF32 0x70 >#define QOS_DSCP_AF33 0x78 >#define QOS_DSCP_CS4 0x80 >#define QOS_DSCP_AF41 0x88 >#define QOS_DSCP_AF42 0x90 >#define QOS_DSCP_AF43 0x98 >#define QOS_DSCP_CS5 0xa0 >#define QOS_DSCP_EF 0xb8 >#define QOS_DSCP_CS6 0xc0 >#define QOS_DSCP_CS7 0xe0 > >/* > * External mbuf storage buffer types. > */ >#define EXT_CLUSTER 1 /* mbuf cluster */ >#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */ >#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */ >#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */ >#define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */ >#define EXT_PACKET 6 /* mbuf+cluster from packet zone */ >#define EXT_MBUF 7 /* external mbuf reference (M_IOVEC) */ > >#define EXT_VENDOR1 224 /* for vendor-internal use */ >#define EXT_VENDOR2 225 /* for vendor-internal use */ >#define EXT_VENDOR3 226 /* for vendor-internal use */ >#define EXT_VENDOR4 227 /* for vendor-internal use */ > >#define EXT_EXP1 244 /* for experimental use */ >#define EXT_EXP2 245 /* for experimental use */ >#define EXT_EXP3 246 /* for experimental use */ >#define EXT_EXP4 247 /* for experimental use */ > >#define EXT_NET_DRV 252 /* custom ext_buf provided by net driver(s) */ >#define EXT_MOD_TYPE 253 /* custom module's ext_buf type */ >#define EXT_DISPOSABLE 254 /* can throw this buffer away w/page flipping */ >#define EXT_EXTREF 255 /* has externally maintained ext_cnt ptr */ > >/* > * Flags for external mbuf buffer types. > * NB: limited to the lower 24 bits. > */ >#define EXT_FLAG_EMBREF 0x000001 /* embedded ext_cnt, notyet */ >#define EXT_FLAG_EXTREF 0x000002 /* external ext_cnt, notyet */ >#define EXT_FLAG_NOFREE 0x000010 /* don't free mbuf to pool, notyet */ > >#define EXT_FLAG_VENDOR1 0x010000 /* for vendor-internal use */ >#define EXT_FLAG_VENDOR2 0x020000 /* for vendor-internal use */ >#define EXT_FLAG_VENDOR3 0x040000 /* for vendor-internal use */ >#define EXT_FLAG_VENDOR4 0x080000 /* for vendor-internal use */ > >#define EXT_FLAG_EXP1 0x100000 /* for experimental use */ >#define EXT_FLAG_EXP2 0x200000 /* for experimental use */ >#define EXT_FLAG_EXP3 0x400000 /* for experimental use */ >#define EXT_FLAG_EXP4 0x800000 /* for experimental use */ > >/* > * EXT flag description for use with printf(9) %b identifier. > */ >#define EXT_FLAG_BITS \ > "\20\1EXT_FLAG_EMBREF\2EXT_FLAG_EXTREF\5EXT_FLAG_NOFREE" \ > "\21EXT_FLAG_VENDOR1\22EXT_FLAG_VENDOR2\23EXT_FLAG_VENDOR3" \ > "\24EXT_FLAG_VENDOR4\25EXT_FLAG_EXP1\26EXT_FLAG_EXP2\27EXT_FLAG_EXP3" \ > "\30EXT_FLAG_EXP4" > >/* > * External reference/free functions. > */ >void sf_ext_ref(void *, void *); >void sf_ext_free(void *, void *); > >/* > * Flags indicating checksum, segmentation and other offload work to be > * done, or already done, by hardware or lower layers. It is split into > * separate inbound and outbound flags. > * > * Outbound flags that are set by upper protocol layers requesting lower > * layers, or ideally the hardware, to perform these offloading tasks. > * For outbound packets this field and its flags can be directly tested > * against ifnet if_hwassist. > */ >#define CSUM_IP 0x00000001 /* IP header checksum offload */ >#define CSUM_IP_UDP 0x00000002 /* UDP checksum offload */ >#define CSUM_IP_TCP 0x00000004 /* TCP checksum offload */ >#define CSUM_IP_SCTP 0x00000008 /* SCTP checksum offload */ >#define CSUM_IP_TSO 0x00000010 /* TCP segmentation offload */ >#define CSUM_IP_ISCSI 0x00000020 /* iSCSI checksum offload */ > >#define CSUM_IP6_UDP 0x00000200 /* UDP checksum offload */ >#define CSUM_IP6_TCP 0x00000400 /* TCP checksum offload */ >#define CSUM_IP6_SCTP 0x00000800 /* SCTP checksum offload */ >#define CSUM_IP6_TSO 0x00001000 /* TCP segmentation offload */ >#define CSUM_IP6_ISCSI 0x00002000 /* iSCSI checksum offload */ > >/* Inbound checksum support where the checksum was verified by hardware. */ >#define CSUM_L3_CALC 0x01000000 /* calculated layer 3 csum */ >#define CSUM_L3_VALID 0x02000000 /* checksum is correct */ >#define CSUM_L4_CALC 0x04000000 /* calculated layer 4 csum */ >#define CSUM_L4_VALID 0x08000000 /* checksum is correct */ >#define CSUM_L5_CALC 0x10000000 /* calculated layer 5 csum */ >#define CSUM_L5_VALID 0x20000000 /* checksum is correct */ >#define CSUM_COALESED 0x40000000 /* contains merged segments */ > >/* > * CSUM flag description for use with printf(9) %b identifier. > */ >#define CSUM_BITS \ > "\20\1CSUM_IP\2CSUM_IP_UDP\3CSUM_IP_TCP\4CSUM_IP_SCTP\5CSUM_IP_TSO" \ > "\6CSUM_IP_ISCSI" \ > "\12CSUM_IP6_UDP\13CSUM_IP6_TCP\14CSUM_IP6_SCTP\15CSUM_IP6_TSO" \ > "\16CSUM_IP6_ISCSI" \ > "\31CSUM_L3_CALC\32CSUM_L3_VALID\33CSUM_L4_CALC\34CSUM_L4_VALID" \ > "\35CSUM_L5_CALC\36CSUM_L5_VALID\37CSUM_COALESED" > >/* CSUM flags compatibility mappings. */ >#define CSUM_IP_CHECKED CSUM_L3_CALC >#define CSUM_IP_VALID CSUM_L3_VALID >#define CSUM_DATA_VALID CSUM_L4_VALID >#define CSUM_PSEUDO_HDR CSUM_L4_CALC >#define CSUM_SCTP_VALID CSUM_L4_VALID >#define CSUM_DELAY_DATA (CSUM_TCP|CSUM_UDP) >#define CSUM_DELAY_IP CSUM_IP /* Only v4, no v6 IP hdr csum */ >#define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6|CSUM_UDP_IPV6) >#define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID >#define CSUM_TCP CSUM_IP_TCP >#define CSUM_UDP CSUM_IP_UDP >#define CSUM_SCTP CSUM_IP_SCTP >#define CSUM_TSO (CSUM_IP_TSO|CSUM_IP6_TSO) >#define CSUM_UDP_IPV6 CSUM_IP6_UDP >#define CSUM_TCP_IPV6 CSUM_IP6_TCP >#define CSUM_SCTP_IPV6 CSUM_IP6_SCTP > >/* > * mbuf types describing the content of the mbuf (including external storage). > */ >#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */ >#define MT_DATA 1 /* dynamic (data) allocation */ >#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */ > >#define MT_VENDOR1 4 /* for vendor-internal use */ >#define MT_VENDOR2 5 /* for vendor-internal use */ >#define MT_VENDOR3 6 /* for vendor-internal use */ >#define MT_VENDOR4 7 /* for vendor-internal use */ > >#define MT_SONAME 8 /* socket name */ > >#define MT_EXP1 9 /* for experimental use */ >#define MT_EXP2 10 /* for experimental use */ >#define MT_EXP3 11 /* for experimental use */ >#define MT_EXP4 12 /* for experimental use */ > >#define MT_CONTROL 14 /* extra-data protocol message */ >#define MT_OOBDATA 15 /* expedited data */ >#define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */ > >#define MT_NOINIT 255 /* Not a type but a flag to allocate > a non-initialized mbuf */ > >/* > * String names of mbuf-related UMA(9) and malloc(9) types. Exposed to > * !_KERNEL so that monitoring tools can look up the zones with > * libmemstat(3). > */ >#define MBUF_MEM_NAME "mbuf" >#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster" >#define MBUF_PACKET_MEM_NAME "mbuf_packet" >#define MBUF_JUMBOP_MEM_NAME "mbuf_jumbo_page" >#define MBUF_JUMBO9_MEM_NAME "mbuf_jumbo_9k" >#define MBUF_JUMBO16_MEM_NAME "mbuf_jumbo_16k" >#define MBUF_TAG_MEM_NAME "mbuf_tag" >#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt" > >#ifdef _KERNEL > >#ifdef WITNESS >#define MBUF_CHECKSLEEP(how) do { \ > if (how == M_WAITOK) \ > WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ > "Sleeping in \"%s\"", __func__); \ >} while (0) >#else ># 512 "/usr/src/ifnet/sys/sys/mbuf.h" >#define MBUF_CHECKSLEEP(how) >#endif ># 514 "/usr/src/ifnet/sys/sys/mbuf.h" > >/* > * Network buffer allocation API > * > * The rest of it is defined in kern/kern_mbuf.c > */ >extern uma_zone_t zone_mbuf; >extern uma_zone_t zone_clust; >extern uma_zone_t zone_pack; >extern uma_zone_t zone_jumbop; >extern uma_zone_t zone_jumbo9; >extern uma_zone_t zone_jumbo16; >extern uma_zone_t zone_ext_refcnt; > >void mb_free_ext(struct mbuf *); >int m_pkthdr_init(struct mbuf *, int); > >static __inline int >m_gettype(int size) >{ > int type; > > switch (size) { > case MSIZE: > type = EXT_MBUF; > break; > case MCLBYTES: > type = EXT_CLUSTER; > break; >#if MJUMPAGESIZE != MCLBYTES > case MJUMPAGESIZE: > type = EXT_JUMBOP; > break; >#endif ># 548 "/usr/src/ifnet/sys/sys/mbuf.h" > case MJUM9BYTES: > type = EXT_JUMBO9; > break; > case MJUM16BYTES: > type = EXT_JUMBO16; > break; > default: > panic("%s: invalid cluster size %d", __func__, size); > } > > return (type); >} > >/* > * Associated an external reference counted buffer with an mbuf. > */ >static __inline void >m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt, > void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2) >{ > > KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__)); > > atomic_add_int(ref_cnt, 1); > m->m_flags |= M_EXT; > m->m_ext.ext_buf = buf; > m->m_ext.ext_cnt = ref_cnt; > m->m_data = m->m_ext.ext_buf; > m->m_ext.ext_size = size; > m->m_ext.ext_free = freef; > m->m_ext.ext_arg1 = arg1; > m->m_ext.ext_arg2 = arg2; > m->m_ext.ext_type = EXT_EXTREF; > m->m_ext.ext_flags = 0; >} > >static __inline uma_zone_t >m_getzone(int size) >{ > uma_zone_t zone; > > switch (size) { > case MCLBYTES: > zone = zone_clust; > break; >#if MJUMPAGESIZE != MCLBYTES > case MJUMPAGESIZE: > zone = zone_jumbop; > break; >#endif ># 598 "/usr/src/ifnet/sys/sys/mbuf.h" > case MJUM9BYTES: > zone = zone_jumbo9; > break; > case MJUM16BYTES: > zone = zone_jumbo16; > break; > default: > panic("%s: invalid cluster size %d", __func__, size); > } > > return (zone); >} > >/* > * Initialize an mbuf with linear storage. > * > * Inline because the consumer text overhead will be roughly the same to > * initialize or call a function with this many parameters and M_PKTHDR > * should go away with constant propagation for !MGETHDR. > */ >static __inline int >m_init(struct mbuf *m, uma_zone_t zone, int size, int how, short type, > int flags) >{ > int error; > > m->m_next = NULL; > m->m_nextpkt = NULL; > m->m_data = m->m_dat; > m->m_len = 0; > m->m_flags = flags; > m->m_type = type; > if (flags & M_PKTHDR) { > if ((error = m_pkthdr_init(m, how)) != 0) > return (error); > } > > return (0); >} > >static __inline struct mbuf * >m_get(int how, short type) >{ > struct mb_args args; > > args.flags = 0; > args.type = type; > return (uma_zalloc_arg(zone_mbuf, &args, how)); >} > >/* > * XXX This should be deprecated, very little use. > */ >static __inline struct mbuf * >m_getclr(int how, short type) >{ > struct mbuf *m; > struct mb_args args; > > args.flags = 0; > args.type = type; > m = uma_zalloc_arg(zone_mbuf, &args, how); > if (m != NULL) > bzero(m->m_data, MLEN); > return (m); >} > >static __inline struct mbuf * >m_gethdr(int how, short type) >{ > struct mb_args args; > > args.flags = M_PKTHDR; > args.type = type; > return (uma_zalloc_arg(zone_mbuf, &args, how)); >} > >static __inline struct mbuf * >m_getcl(int how, short type, int flags) >{ > struct mb_args args; > > args.flags = flags; > args.type = type; > return (uma_zalloc_arg(zone_pack, &args, how)); >} > >static __inline int >m_clget(struct mbuf *m, int how) >{ > > KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT", > __func__, m)); > m->m_ext.ext_buf = (char *)NULL; > uma_zalloc_arg(zone_clust, m, how); > /* > * On a cluster allocation failure, drain the packet zone and retry, > * we might be able to loosen a few clusters up on the drain. > */ > if ((how & M_NOWAIT) && (m->m_ext.ext_buf == NULL)) { > zone_drain(zone_pack); > uma_zalloc_arg(zone_clust, m, how); > } > return (m->m_flags & M_EXT); >} > >/* > * m_cljget() is different from m_clget() as it can allocate clusters without > * attaching them to an mbuf. In that case the return value is the pointer > * to the cluster of the requested size. If an mbuf was specified, it gets > * the cluster attached to it and the return value can be safely ignored. > * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES. > */ >static __inline void * >m_cljget(struct mbuf *m, int how, int size) >{ > uma_zone_t zone; > > if (m != NULL) { > KASSERT((m->m_flags & M_EXT) == 0, ("%s: mbuf %p has M_EXT", > __func__, m)); > m->m_ext.ext_buf = NULL; > } > > zone = m_getzone(size); > return (uma_zalloc_arg(zone, m, how)); >} > >static __inline void >m_cljset(struct mbuf *m, void *cl, int type) >{ > uma_zone_t zone; > int size; > > switch (type) { > case EXT_CLUSTER: > size = MCLBYTES; > zone = zone_clust; > break; >#if MJUMPAGESIZE != MCLBYTES > case EXT_JUMBOP: > size = MJUMPAGESIZE; > zone = zone_jumbop; > break; >#endif ># 743 "/usr/src/ifnet/sys/sys/mbuf.h" > case EXT_JUMBO9: > size = MJUM9BYTES; > zone = zone_jumbo9; > break; > case EXT_JUMBO16: > size = MJUM16BYTES; > zone = zone_jumbo16; > break; > default: > panic("%s: unknown cluster type %d", __func__, type); > break; > } > > m->m_data = m->m_ext.ext_buf = cl; > m->m_ext.ext_free = m->m_ext.ext_arg1 = m->m_ext.ext_arg2 = NULL; > m->m_ext.ext_size = size; > m->m_ext.ext_type = type; > m->m_ext.ext_flags = 0; > m->m_ext.ext_cnt = uma_find_refcnt(zone, cl); > m->m_flags |= M_EXT; > >} > >static __inline void >m_chtype(struct mbuf *m, short new_type) >{ > > m->m_type = new_type; >} > >static __inline void >m_clrprotoflags(struct mbuf *m) >{ > > while (m) { > m->m_flags &= ~M_PROTOFLAGS; > m = m->m_next; > } >} > >static __inline struct mbuf * >m_last(struct mbuf *m) >{ > > while (m->m_next) > m = m->m_next; > return (m); >} > >/* > * mbuf, cluster, and external object allocation macros (for compatibility > * purposes). > */ >#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from)) >#define MGET(m, how, type) ((m) = m_get((how), (type))) >#define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type))) >#define MCLGET(m, how) m_clget((m), (how)) >#define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ > (void )m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2),\ > (flags), (type), M_NOWAIT) >#define m_getm(m, len, how, type) \ > m_getm2((m), (len), (how), (type), M_PKTHDR) > >/* > * Evaluate TRUE if it's safe to write to the mbuf m's data region (this can > * be both the local data payload, or an external buffer area, depending on > * whether M_EXT is set). > */ >#define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && \ > (!(((m)->m_flags & M_EXT)) || \ > (*((m)->m_ext.ext_cnt) == 1)) ) \ > >/* Check if the supplied mbuf has a packet header, or else panic. */ >#define M_ASSERTPKTHDR(m) \ > KASSERT((m) != NULL && (m)->m_flags & M_PKTHDR, \ > ("%s: no mbuf packet header!", __func__)) > >/* > * Ensure that the supplied mbuf is a valid, non-free mbuf. > * > * XXX: Broken at the moment. Need some UMA magic to make it work again. > */ >#define M_ASSERTVALID(m) \ > KASSERT((((struct mbuf *)m)->m_flags & 0) == 0, \ > ("%s: attempted use of a free mbuf!", __func__)) > >/* > * Return the address of the start of the buffer associated with an mbuf, > * handling external storage, packet-header mbufs, and regular data mbufs. > */ >#define M_START(m) \ > (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_buf : \ > ((m)->m_flags & M_PKTHDR) ? &(m)->m_pktdat[0] : \ > &(m)->m_dat[0]) > >/* > * Return the size of the buffer associated with an mbuf, handling external > * storage, packet-header mbufs, and regular data mbufs. > */ >#define M_SIZE(m) \ > (((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \ > ((m)->m_flags & M_PKTHDR) ? MHLEN : \ > MLEN) > >/* > * Set the m_data pointer of a newly allocated mbuf to place an object of the > * specified size at the end of the mbuf, longword aligned. > * > * NB: Historically, we had M_ALIGN(), MH_ALIGN(), and MEXT_ALIGN() as > * separate macros, each asserting that it was called at the proper moment. > * This required callers to themselves test the storage type and call the > * right one. Rather than require callers to be aware of those layout > * decisions, we centralize here. > */ >static __inline void >m_align(struct mbuf *m, int len) >{ >#ifdef INVARIANTS > const char *msg = "%s: not a virgin mbuf"; >#endif ># 863 "/usr/src/ifnet/sys/sys/mbuf.h" > int adjust; > > KASSERT(m->m_data == M_START(m), (msg, __func__)); > > adjust = M_SIZE(m) - len; > m->m_data += adjust &~ (sizeof(long)-1); >} > >#define M_ALIGN(m, len) m_align(m, len) >#define MH_ALIGN(m, len) m_align(m, len) >#define MEXT_ALIGN(m, len) m_align(m, len) > >/* > * Compute the amount of space available before the current start of data in > * an mbuf. > * > * The M_WRITABLE() is a temporary, conservative safety measure: the burden > * of checking writability of the mbuf data area rests solely with the caller. > * > * NB: In previous versions, M_LEADINGSPACE() would only check M_WRITABLE() > * for mbufs with external storage. We now allow mbuf-embedded data to be > * read-only as well. > */ >#define M_LEADINGSPACE(m) \ > (M_WRITABLE(m) ? ((m)->m_data - M_START(m)) : 0) > >/* > * Compute the amount of space available after the end of data in an mbuf. > * > * The M_WRITABLE() is a temporary, conservative safety measure: the burden > * of checking writability of the mbuf data area rests solely with the caller. > * > * NB: In previous versions, M_TRAILINGSPACE() would only check M_WRITABLE() > * for mbufs with external storage. We now allow mbuf-embedded data to be > * read-only as well. > */ >#define M_TRAILINGSPACE(m) \ > (M_WRITABLE(m) ? \ > ((M_START(m) + M_SIZE(m)) - ((m)->m_data + (m)->m_len)) : 0) > >/* > * Arrange to prepend space of size plen to mbuf m. If a new mbuf must be > * allocated, how specifies whether to wait. If the allocation fails, the > * original mbuf chain is freed and m is set to NULL. > */ >#define M_PREPEND(m, plen, how) do { \ > struct mbuf **_mmp = &(m); \ > struct mbuf *_mm = *_mmp; \ > int _mplen = (plen); \ > int __mhow = (how); \ > \ > MBUF_CHECKSLEEP(how); \ > if (M_LEADINGSPACE(_mm) >= _mplen) { \ > _mm->m_data -= _mplen; \ > _mm->m_len += _mplen; \ > } else \ > _mm = m_prepend(_mm, _mplen, __mhow); \ > if (_mm != NULL && _mm->m_flags & M_PKTHDR) \ > _mm->m_pkthdr.len += _mplen; \ > *_mmp = _mm; \ >} while (0) > >/* > * Change mbuf to new type. This is a relatively expensive operation and > * should be avoided. > */ >#define MCHTYPE(m, t) m_chtype((m), (t)) > >/* Length to m_copy to copy all. */ >#define M_COPYALL 1000000000 > >/* Compatibility with 4.3. */ >#define m_copy(m, o, l) m_copym((m), (o), (l), M_NOWAIT) > >extern int max_datalen; /* MHLEN - max_hdr */ >extern int max_hdr; /* Largest link + protocol header */ >extern int max_linkhdr; /* Largest link-level header */ >extern int max_protohdr; /* Largest protocol header */ >extern int nmbclusters; /* Maximum number of clusters */ > >struct uio; > >void m_adj(struct mbuf *, int); >int m_apply(struct mbuf *, int, int, > int (*)(void *, void *, u_int), void *); >int m_append(struct mbuf *, int, c_caddr_t); >void m_cat(struct mbuf *, struct mbuf *); >void m_catpkt(struct mbuf *, struct mbuf *); >int m_extadd(struct mbuf *, caddr_t, u_int, > void (*)(struct mbuf *, void *, void *), void *, void *, > int, int, int); >struct mbuf *m_collapse(struct mbuf *, int, int); >void m_copyback(struct mbuf *, int, int, c_caddr_t); >void m_copydata(const struct mbuf *, int, int, caddr_t); >struct mbuf *m_copym(struct mbuf *, int, int, int); >struct mbuf *m_copypacket(struct mbuf *, int); >void m_copy_pkthdr(struct mbuf *, struct mbuf *); >struct mbuf *m_copyup(struct mbuf *, int, int); >struct mbuf *m_defrag(struct mbuf *, int); >void m_demote(struct mbuf *, int, int); >struct mbuf *m_devget(char *, int, int, struct ifnet *, > void (*)(char *, caddr_t, u_int)); >struct mbuf *m_dup(struct mbuf *, int); >int m_dup_pkthdr(struct mbuf *, struct mbuf *, int); >u_int m_fixhdr(struct mbuf *); >struct mbuf *m_fragment(struct mbuf *, int, int); >void m_freem(struct mbuf *); >struct mbuf *m_get2(int, int, short, int); >struct mbuf *m_getjcl(int, short, int, int); >struct mbuf *m_getm2(struct mbuf *, int, int, short, int); >struct mbuf *m_getptr(struct mbuf *, int, int *); >u_int m_length(struct mbuf *, struct mbuf **); >int m_mbuftouio(struct uio *, struct mbuf *, int); >void m_move_pkthdr(struct mbuf *, struct mbuf *); >struct mbuf *m_prepend(struct mbuf *, int, int); >void m_print(const struct mbuf *, int); >struct mbuf *m_pulldown(struct mbuf *, int, int, int *); >struct mbuf *m_pullup(struct mbuf *, int); >int m_sanity(struct mbuf *, int); >struct mbuf *m_split(struct mbuf *, int, int); >struct mbuf *m_uiotombuf(struct uio *, int, int, int, int); >struct mbuf *m_unshare(struct mbuf *, int); > >/*- > * Network packets may have annotations attached by affixing a list of > * "packet tags" to the pkthdr structure. Packet tags are dynamically > * allocated semi-opaque data structures that have a fixed header > * (struct m_tag) that specifies the size of the memory block and a > * <cookie,type> pair that identifies it. The cookie is a 32-bit unique > * unsigned value used to identify a module or ABI. By convention this value > * is chosen as the date+time that the module is created, expressed as the > * number of seconds since the epoch (e.g., using date -u +'%s'). The type > * value is an ABI/module-specific value that identifies a particular > * annotation and is private to the module. For compatibility with systems > * like OpenBSD that define packet tags w/o an ABI/module cookie, the value > * PACKET_ABI_COMPAT is used to implement m_tag_get and m_tag_find > * compatibility shim functions and several tag types are defined below. > * Users that do not require compatibility should use a private cookie value > * so that packet tag-related definitions can be maintained privately. > * > * Note that the packet tag returned by m_tag_alloc has the default memory > * alignment implemented by malloc. To reference private data one can use a > * construct like: > * > * struct m_tag *mtag = m_tag_alloc(...); > * struct foo *p = (struct foo *)(mtag+1); > * > * if the alignment of struct m_tag is sufficient for referencing members of > * struct foo. Otherwise it is necessary to embed struct m_tag within the > * private data structure to insure proper alignment; e.g., > * > * struct foo { > * struct m_tag tag; > * ... > * }; > * struct foo *p = (struct foo *) m_tag_alloc(...); > * struct m_tag *mtag = &p->tag; > */ > >/* > * Persistent tags stay with an mbuf until the mbuf is reclaimed. Otherwise > * tags are expected to ``vanish'' when they pass through a network > * interface. For most interfaces this happens normally as the tags are > * reclaimed when the mbuf is free'd. However in some special cases > * reclaiming must be done manually. An example is packets that pass through > * the loopback interface. Also, one must be careful to do this when > * ``turning around'' packets (e.g., icmp_reflect). > * > * To mark a tag persistent bit-or this flag in when defining the tag id. > * The tag will then be treated as described above. > */ >#define MTAG_PERSISTENT 0x800 > >#define PACKET_TAG_NONE 0 /* Nadda */ > >/* Packet tags for use with PACKET_ABI_COMPAT. */ >#define PACKET_TAG_IPSEC_IN_DONE 1 /* IPsec applied, in */ >#define PACKET_TAG_IPSEC_OUT_DONE 2 /* IPsec applied, out */ >#define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 3 /* NIC IPsec crypto done */ >#define PACKET_TAG_IPSEC_OUT_CRYPTO_NEEDED 4 /* NIC IPsec crypto req'ed */ >#define PACKET_TAG_IPSEC_IN_COULD_DO_CRYPTO 5 /* NIC notifies IPsec */ >#define PACKET_TAG_IPSEC_PENDING_TDB 6 /* Reminder to do IPsec */ >#define PACKET_TAG_BRIDGE 7 /* Bridge processing done */ >#define PACKET_TAG_GIF 8 /* GIF processing done */ >#define PACKET_TAG_GRE 9 /* GRE processing done */ >#define PACKET_TAG_IN_PACKET_CHECKSUM 10 /* NIC checksumming done */ >#define PACKET_TAG_ENCAP 11 /* Encap. processing */ >#define PACKET_TAG_IPSEC_SOCKET 12 /* IPSEC socket ref */ >#define PACKET_TAG_IPSEC_HISTORY 13 /* IPSEC history */ >#define PACKET_TAG_IPV6_INPUT 14 /* IPV6 input processing */ >#define PACKET_TAG_DUMMYNET 15 /* dummynet info */ >#define PACKET_TAG_DIVERT 17 /* divert info */ >#define PACKET_TAG_IPFORWARD 18 /* ipforward info */ >#define PACKET_TAG_MACLABEL (19 | MTAG_PERSISTENT) /* MAC label */ >#define PACKET_TAG_PF (21 | MTAG_PERSISTENT) /* PF/ALTQ information */ >#define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ >#define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ >#define PACKET_TAG_CARP 28 /* CARP info */ >#define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */ >#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */ > >/* Specific cookies and tags. */ > >/* Packet tag routines. */ >struct m_tag *m_tag_alloc(u_int32_t, int, int, int); >void m_tag_delete(struct mbuf *, struct m_tag *); >void m_tag_delete_chain(struct mbuf *, struct m_tag *); >void m_tag_free_default(struct m_tag *); >struct m_tag *m_tag_locate(struct mbuf *, u_int32_t, int, struct m_tag *); >struct m_tag *m_tag_copy(struct m_tag *, int); >int m_tag_copy_chain(struct mbuf *, struct mbuf *, int); >void m_tag_delete_nonpersistent(struct mbuf *); > >/* > * Initialize the list of tags associated with an mbuf. > */ >static __inline void >m_tag_init(struct mbuf *m) >{ > > SLIST_INIT(&m->m_pkthdr.tags); >} > >/* > * Set up the contents of a tag. Note that this does not fill in the free > * method; the caller is expected to do that. > * > * XXX probably should be called m_tag_init, but that was already taken. > */ >static __inline void >m_tag_setup(struct m_tag *t, u_int32_t cookie, int type, int len) >{ > > t->m_tag_id = type; > t->m_tag_len = len; > t->m_tag_cookie = cookie; >} > >/* > * Reclaim resources associated with a tag. > */ >static __inline void >m_tag_free(struct m_tag *t) >{ > > (*t->m_tag_free)(t); >} > >/* > * Return the first tag associated with an mbuf. > */ >static __inline struct m_tag * >m_tag_first(struct mbuf *m) >{ > > return (SLIST_FIRST(&m->m_pkthdr.tags)); >} > >/* > * Return the next tag in the list of tags associated with an mbuf. > */ >static __inline struct m_tag * >m_tag_next(struct mbuf *m, struct m_tag *t) >{ > > return (SLIST_NEXT(t, m_tag_link)); >} > >/* > * Prepend a tag to the list of tags associated with an mbuf. > */ >static __inline void >m_tag_prepend(struct mbuf *m, struct m_tag *t) >{ > > SLIST_INSERT_HEAD(&m->m_pkthdr.tags, t, m_tag_link); >} > >/* > * Unlink a tag from the list of tags associated with an mbuf. > */ >static __inline void >m_tag_unlink(struct mbuf *m, struct m_tag *t) >{ > > SLIST_REMOVE(&m->m_pkthdr.tags, t, m_tag, m_tag_link); >} > >/* These are for OpenBSD compatibility. */ >#define MTAG_ABI_COMPAT 0 /* compatibility ABI */ > >static __inline struct m_tag * >m_tag_get(int type, int length, int wait) >{ > return (m_tag_alloc(MTAG_ABI_COMPAT, type, length, wait)); >} > >static __inline struct m_tag * >m_tag_find(struct mbuf *m, int type, struct m_tag *start) >{ > return (SLIST_EMPTY(&m->m_pkthdr.tags) ? (struct m_tag *)NULL : > m_tag_locate(m, MTAG_ABI_COMPAT, type, start)); >} > >static __inline struct mbuf * >m_free(struct mbuf *m) >{ > struct mbuf *n = m->m_next; > > if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE)) > m_tag_delete_chain(m, NULL); > if (m->m_flags & M_EXT) > mb_free_ext(m); > else if ((m->m_flags & M_NOFREE) == 0) > uma_zfree(zone_mbuf, m); > return (n); >} > >static int inline >rt_m_getfib(struct mbuf *m) >{ > KASSERT(m->m_flags & M_PKTHDR , ("Attempt to get FIB from non header mbuf.")); > return (m->m_pkthdr.fibnum); >} > >#define M_GETFIB(_m) rt_m_getfib(_m) > >#define M_SETFIB(_m, _fib) do { \ > KASSERT((_m)->m_flags & M_PKTHDR, ("Attempt to set FIB on non header mbuf.")); \ > ((_m)->m_pkthdr.fibnum) = (_fib); \ >} while (0) > >/* flags passed as first argument for "m_ether_tcpip_hash()" */ >#define MBUF_HASHFLAG_L2 (1 << 2) >#define MBUF_HASHFLAG_L3 (1 << 3) >#define MBUF_HASHFLAG_L4 (1 << 4) > >/* mbuf hashing helper routines */ >uint32_t m_ether_tcpip_hash_init(void); >uint32_t m_ether_tcpip_hash(const uint32_t, const struct mbuf *, const uint32_t); > >#ifdef MBUF_PROFILING > void m_profile(struct mbuf *m); > #define M_PROFILE(m) m_profile(m) >#else ># 1208 "/usr/src/ifnet/sys/sys/mbuf.h" > #define M_PROFILE(m) >#endif ># 1210 "/usr/src/ifnet/sys/sys/mbuf.h" > >struct mbufq { > STAILQ_HEAD(, mbuf) mq_head; > int mq_len; > int mq_maxlen; >}; > >static inline void >mbufq_init(struct mbufq *mq, int maxlen) >{ > > STAILQ_INIT(&mq->mq_head); > mq->mq_maxlen = maxlen; > mq->mq_len = 0; >} > >static inline struct mbuf * >mbufq_flush(struct mbufq *mq) >{ > struct mbuf *m; > > m = STAILQ_FIRST(&mq->mq_head); > STAILQ_INIT(&mq->mq_head); > mq->mq_len = 0; > return (m); >} > >static inline void >mbufq_drain(struct mbufq *mq) >{ > struct mbuf *m, *n; > > n = mbufq_flush(mq); > while ((m = n) != NULL) { > n = STAILQ_NEXT(m, m_stailqpkt); > m_freem(m); > } >} > >static inline struct mbuf * >mbufq_first(const struct mbufq *mq) >{ > > return (STAILQ_FIRST(&mq->mq_head)); >} > >static inline struct mbuf * >mbufq_last(const struct mbufq *mq) >{ > > return (STAILQ_LAST(&mq->mq_head, mbuf, m_stailqpkt)); >} > >static inline int >mbufq_full(const struct mbufq *mq) >{ > > return (mq->mq_len >= mq->mq_maxlen); >} > >static inline int >mbufq_len(const struct mbufq *mq) >{ > > return (mq->mq_len); >} > >static inline int >mbufq_enqueue(struct mbufq *mq, struct mbuf *m) >{ > > if (mbufq_full(mq)) > return (ENOBUFS); > STAILQ_INSERT_TAIL(&mq->mq_head, m, m_stailqpkt); > mq->mq_len++; > return (0); >} > >static inline struct mbuf * >mbufq_dequeue(struct mbufq *mq) >{ > struct mbuf *m; > > m = STAILQ_FIRST(&mq->mq_head); > if (m) { > STAILQ_REMOVE_HEAD(&mq->mq_head, m_stailqpkt); > m->m_nextpkt = NULL; > mq->mq_len--; > } > return (m); >} > >static inline void >mbufq_prepend(struct mbufq *mq, struct mbuf *m) >{ > > STAILQ_INSERT_HEAD(&mq->mq_head, m, m_stailqpkt); > mq->mq_len++; >} >#endif /* _KERNEL */ ># 1310 "/usr/src/ifnet/sys/sys/mbuf.h" >#endif /* !_SYS_MBUF_H_ */ ># 1311 "/usr/src/ifnet/sys/sys/mbuf.h" ># 50 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/buf_ring.h> >#endif /* expanded by -frewrite-includes */ ># 50 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/buf_ring.h" 1 >/*- > * Copyright (c) 2007-2009 Kip Macy <kmacy@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/buf_ring.h 273900 2014-10-31 10:25:31Z glebius $ > * > */ > >#ifndef _SYS_BUF_RING_H_ >#define _SYS_BUF_RING_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpu.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/ifnet/sys/sys/buf_ring.h" ># 1 "./machine/cpu.h" 1 >/*- > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 > * $FreeBSD: projects/ifnet/sys/amd64/include/cpu.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _MACHINE_CPU_H_ >#define _MACHINE_CPU_H_ > >/* > * Definitions unique to i386 cpu support. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <machine/psl.h> >#endif /* expanded by -frewrite-includes */ ># 42 "./machine/cpu.h" ># 1 "./machine/psl.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/psl.h 233204 2012-03-19 21:29:57Z tijl $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/psl.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/psl.h" ># 1 "./x86/psl.h" 1 >/*- > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)psl.h 5.2 (Berkeley) 1/18/91 > * $FreeBSD: projects/ifnet/sys/x86/include/psl.h 262773 2014-03-05 03:20:57Z glebius $ > */ > >#ifndef _MACHINE_PSL_H_ >#define _MACHINE_PSL_H_ > >/* > * 386 processor status longword. > */ >#define PSL_C 0x00000001 /* carry bit */ >#define PSL_PF 0x00000004 /* parity bit */ >#define PSL_AF 0x00000010 /* bcd carry bit */ >#define PSL_Z 0x00000040 /* zero bit */ >#define PSL_N 0x00000080 /* negative bit */ >#define PSL_T 0x00000100 /* trace enable bit */ >#define PSL_I 0x00000200 /* interrupt enable bit */ >#define PSL_D 0x00000400 /* string instruction direction bit */ >#define PSL_V 0x00000800 /* overflow bit */ >#define PSL_IOPL 0x00003000 /* i/o privilege level */ >#define PSL_NT 0x00004000 /* nested task bit */ >#define PSL_RF 0x00010000 /* resume flag bit */ >#define PSL_VM 0x00020000 /* virtual 8086 mode bit */ >#define PSL_AC 0x00040000 /* alignment checking */ >#define PSL_VIF 0x00080000 /* virtual interrupt enable */ >#define PSL_VIP 0x00100000 /* virtual interrupt pending */ >#define PSL_ID 0x00200000 /* identification bit */ > >/* > * The i486 manual says that we are not supposed to change reserved flags, > * but this is too much trouble since the reserved flags depend on the cpu > * and setting them to their historical values works in practice. > */ >#define PSL_RESERVED_DEFAULT 0x00000002 > >/* > * Initial flags for kernel and user mode. The kernel later inherits > * PSL_I and some other flags from user mode. > */ >#define PSL_KERNEL PSL_RESERVED_DEFAULT >#define PSL_USER (PSL_RESERVED_DEFAULT | PSL_I) > >/* > * Bits that can be changed in user mode on 486's. We allow these bits > * to be changed using ptrace(), sigreturn() and procfs. Setting PS_NT > * is undesirable but it may as well be allowed since users can inflict > * it on the kernel directly. Changes to PSL_AC are silently ignored on > * 386's. > * > * Users are allowed to change the privileged flag PSL_RF. The cpu sets PSL_RF > * in tf_eflags for faults. Debuggers should sometimes set it there too. > * tf_eflags is kept in the signal context during signal handling and there is > * no other place to remember it, so the PSL_RF bit may be corrupted by the > * signal handler without us knowing. Corruption of the PSL_RF bit at worst > * causes one more or one less debugger trap, so allowing it is fairly > * harmless. > */ >#define PSL_USERCHANGE (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_T \ > | PSL_D | PSL_V | PSL_NT | PSL_RF | PSL_AC | PSL_ID) > >#endif /* !_MACHINE_PSL_H_ */ ># 93 "./x86/psl.h" ># 7 "./machine/psl.h" 2 ># 43 "./machine/cpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/frame.h> >#endif /* expanded by -frewrite-includes */ ># 43 "./machine/cpu.h" ># 1 "./machine/frame.h" 1 >/*- > * This file is in the public domain. > */ >/* $FreeBSD: projects/ifnet/sys/amd64/include/frame.h 247047 2013-02-20 17:39:52Z kib $ */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/frame.h> >#endif /* expanded by -frewrite-includes */ ># 6 "./machine/frame.h" ># 1 "./x86/frame.h" 1 >/*- > * Copyright (c) 2003 Peter Wemm. > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)frame.h 5.2 (Berkeley) 1/18/91 > * $FreeBSD: projects/ifnet/sys/x86/include/frame.h 247047 2013-02-20 17:39:52Z kib $ > */ > >#ifndef _MACHINE_FRAME_H_ >#define _MACHINE_FRAME_H_ 1 > >/* > * System stack frames. > */ > >#ifdef __i386__ >/* > * Exception/Trap Stack Frame > */ > >struct trapframe { > int tf_fs; > int tf_es; > int tf_ds; > int tf_edi; > int tf_esi; > int tf_ebp; > int tf_isp; > int tf_ebx; > int tf_edx; > int tf_ecx; > int tf_eax; > int tf_trapno; > /* below portion defined in 386 hardware */ > int tf_err; > int tf_eip; > int tf_cs; > int tf_eflags; > /* below only when crossing rings (e.g. user to kernel) */ > int tf_esp; > int tf_ss; >}; > >/* Superset of trap frame, for traps from virtual-8086 mode */ > >struct trapframe_vm86 { > int tf_fs; > int tf_es; > int tf_ds; > int tf_edi; > int tf_esi; > int tf_ebp; > int tf_isp; > int tf_ebx; > int tf_edx; > int tf_ecx; > int tf_eax; > int tf_trapno; > /* below portion defined in 386 hardware */ > int tf_err; > int tf_eip; > int tf_cs; > int tf_eflags; > /* below only when crossing rings (e.g. user to kernel) */ > int tf_esp; > int tf_ss; > /* below only when switching out of VM86 mode */ > int tf_vm86_es; > int tf_vm86_ds; > int tf_vm86_fs; > int tf_vm86_gs; >}; >#endif /* __i386__ */ ># 102 "./x86/frame.h" > >#ifdef __amd64__ >/* > * Exception/Trap Stack Frame > * > * The ordering of this is specifically so that we can take first 6 > * the syscall arguments directly from the beginning of the frame. > */ > >struct trapframe { > register_t tf_rdi; > register_t tf_rsi; > register_t tf_rdx; > register_t tf_rcx; > register_t tf_r8; > register_t tf_r9; > register_t tf_rax; > register_t tf_rbx; > register_t tf_rbp; > register_t tf_r10; > register_t tf_r11; > register_t tf_r12; > register_t tf_r13; > register_t tf_r14; > register_t tf_r15; > uint32_t tf_trapno; > uint16_t tf_fs; > uint16_t tf_gs; > register_t tf_addr; > uint32_t tf_flags; > uint16_t tf_es; > uint16_t tf_ds; > /* below portion defined in hardware */ > register_t tf_err; > register_t tf_rip; > register_t tf_cs; > register_t tf_rflags; > register_t tf_rsp; > register_t tf_ss; >}; > >#define TF_HASSEGS 0x1 >#define TF_HASBASES 0x2 >#define TF_HASFPXSTATE 0x4 >#endif /* __amd64__ */ ># 147 "./x86/frame.h" > >#endif /* _MACHINE_FRAME_H_ */ ># 149 "./x86/frame.h" ># 7 "./machine/frame.h" 2 ># 44 "./machine/cpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/segments.h> >#endif /* expanded by -frewrite-includes */ ># 44 "./machine/cpu.h" ># 1 "./machine/segments.h" 1 >/*- > * Copyright (c) 1989, 1990 William F. Jolitz > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 > * $FreeBSD: projects/ifnet/sys/amd64/include/segments.h 262773 2014-03-05 03:20:57Z glebius $ > */ > >#ifndef _MACHINE_SEGMENTS_H_ >#define _MACHINE_SEGMENTS_H_ > >/* > * AMD64 Segmentation Data Structures and definitions > */ > >#if 0 /* expanded by -frewrite-includes */ >#include <x86/segments.h> >#endif /* expanded by -frewrite-includes */ ># 44 "./machine/segments.h" ># 1 "./x86/segments.h" 1 >/*- > * Copyright (c) 1989, 1990 William F. Jolitz > * Copyright (c) 1990 The Regents of the University of California. > * All rights reserved. > * > * This code is derived from software contributed to Berkeley by > * William Jolitz. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 > * $FreeBSD: projects/ifnet/sys/x86/include/segments.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _X86_SEGMENTS_H_ >#define _X86_SEGMENTS_H_ > >/* > * X86 Segmentation Data Structures and definitions > */ > >/* > * Selectors > */ >#define SEL_RPL_MASK 3 /* requester priv level */ >#define ISPL(s) ((s)&3) /* priority level of a selector */ >#ifdef XEN >#define SEL_KPL 1 /* kernel priority level */ >#else ># 52 "./x86/segments.h" >#define SEL_KPL 0 /* kernel priority level */ >#endif ># 54 "./x86/segments.h" >#define SEL_UPL 3 /* user priority level */ >#define ISLDT(s) ((s)&SEL_LDT) /* is it local or global */ >#define SEL_LDT 4 /* local descriptor table */ >#define IDXSEL(s) (((s)>>3) & 0x1fff) /* index of selector */ >#define LSEL(s,r) (((s)<<3) | SEL_LDT | r) /* a local selector */ >#define GSEL(s,r) (((s)<<3) | r) /* a global selector */ > >/* > * User segment descriptors (%cs, %ds etc for i386 apps. 64 bit wide) > * For long-mode apps, %cs only has the conforming bit in sd_type, the sd_dpl, > * sd_p, sd_l and sd_def32 which must be zero). %ds only has sd_p. > */ >struct segment_descriptor { > unsigned sd_lolimit:16; /* segment extent (lsb) */ > unsigned sd_lobase:24; /* segment base address (lsb) */ > unsigned sd_type:5; /* segment type */ > unsigned sd_dpl:2; /* segment descriptor priority level */ > unsigned sd_p:1; /* segment descriptor present */ > unsigned sd_hilimit:4; /* segment extent (msb) */ > unsigned sd_xx:2; /* unused */ > unsigned sd_def32:1; /* default 32 vs 16 bit size */ > unsigned sd_gran:1; /* limit granularity (byte/page units)*/ > unsigned sd_hibase:8; /* segment base address (msb) */ >} __packed; > >struct user_segment_descriptor { > unsigned sd_lolimit:16; /* segment extent (lsb) */ > unsigned sd_lobase:24; /* segment base address (lsb) */ > unsigned sd_type:5; /* segment type */ > unsigned sd_dpl:2; /* segment descriptor priority level */ > unsigned sd_p:1; /* segment descriptor present */ > unsigned sd_hilimit:4; /* segment extent (msb) */ > unsigned sd_xx:1; /* unused */ > unsigned sd_long:1; /* long mode (cs only) */ > unsigned sd_def32:1; /* default 32 vs 16 bit size */ > unsigned sd_gran:1; /* limit granularity (byte/page units)*/ > unsigned sd_hibase:8; /* segment base address (msb) */ >} __packed; > >#define USD_GETBASE(sd) (((sd)->sd_lobase) | (sd)->sd_hibase << 24) >#define USD_SETBASE(sd, b) (sd)->sd_lobase = (b); \ > (sd)->sd_hibase = ((b) >> 24); >#define USD_GETLIMIT(sd) (((sd)->sd_lolimit) | (sd)->sd_hilimit << 16) >#define USD_SETLIMIT(sd, l) (sd)->sd_lolimit = (l); \ > (sd)->sd_hilimit = ((l) >> 16); > >#ifdef __i386__ >/* > * Gate descriptors (e.g. indirect descriptors) > */ >struct gate_descriptor { > unsigned gd_looffset:16; /* gate offset (lsb) */ > unsigned gd_selector:16; /* gate segment selector */ > unsigned gd_stkcpy:5; /* number of stack wds to cpy */ > unsigned gd_xx:3; /* unused */ > unsigned gd_type:5; /* segment type */ > unsigned gd_dpl:2; /* segment descriptor priority level */ > unsigned gd_p:1; /* segment descriptor present */ > unsigned gd_hioffset:16; /* gate offset (msb) */ >} __packed; > >/* > * Generic descriptor > */ >union descriptor { > struct segment_descriptor sd; > struct gate_descriptor gd; >}; >#else ># 123 "./x86/segments.h" >/* > * Gate descriptors (e.g. indirect descriptors, trap, interrupt etc. 128 bit) > * Only interrupt and trap gates have gd_ist. > */ >struct gate_descriptor { > uint64_t gd_looffset:16; /* gate offset (lsb) */ > uint64_t gd_selector:16; /* gate segment selector */ > uint64_t gd_ist:3; /* IST table index */ > uint64_t gd_xx:5; /* unused */ > uint64_t gd_type:5; /* segment type */ > uint64_t gd_dpl:2; /* segment descriptor priority level */ > uint64_t gd_p:1; /* segment descriptor present */ > uint64_t gd_hioffset:48; /* gate offset (msb) */ > uint64_t sd_xx1:32; >} __packed; > >/* > * Generic descriptor > */ >union descriptor { > struct user_segment_descriptor sd; > struct gate_descriptor gd; >}; >#endif ># 147 "./x86/segments.h" > > /* system segments and gate types */ >#define SDT_SYSNULL 0 /* system null */ >#define SDT_SYS286TSS 1 /* system 286 TSS available */ >#define SDT_SYSLDT 2 /* system local descriptor table */ >#define SDT_SYS286BSY 3 /* system 286 TSS busy */ >#define SDT_SYS286CGT 4 /* system 286 call gate */ >#define SDT_SYSTASKGT 5 /* system task gate */ >#define SDT_SYS286IGT 6 /* system 286 interrupt gate */ >#define SDT_SYS286TGT 7 /* system 286 trap gate */ >#define SDT_SYSNULL2 8 /* system null again */ >#define SDT_SYS386TSS 9 /* system 386 TSS available */ >#define SDT_SYSTSS 9 /* system available 64 bit TSS */ >#define SDT_SYSNULL3 10 /* system null again */ >#define SDT_SYS386BSY 11 /* system 386 TSS busy */ >#define SDT_SYSBSY 11 /* system busy 64 bit TSS */ >#define SDT_SYS386CGT 12 /* system 386 call gate */ >#define SDT_SYSCGT 12 /* system 64 bit call gate */ >#define SDT_SYSNULL4 13 /* system null again */ >#define SDT_SYS386IGT 14 /* system 386 interrupt gate */ >#define SDT_SYSIGT 14 /* system 64 bit interrupt gate */ >#define SDT_SYS386TGT 15 /* system 386 trap gate */ >#define SDT_SYSTGT 15 /* system 64 bit trap gate */ > > /* memory segment types */ >#define SDT_MEMRO 16 /* memory read only */ >#define SDT_MEMROA 17 /* memory read only accessed */ >#define SDT_MEMRW 18 /* memory read write */ >#define SDT_MEMRWA 19 /* memory read write accessed */ >#define SDT_MEMROD 20 /* memory read only expand dwn limit */ >#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */ >#define SDT_MEMRWD 22 /* memory read write expand dwn limit */ >#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed*/ >#define SDT_MEME 24 /* memory execute only */ >#define SDT_MEMEA 25 /* memory execute only accessed */ >#define SDT_MEMER 26 /* memory execute read */ >#define SDT_MEMERA 27 /* memory execute read accessed */ >#define SDT_MEMEC 28 /* memory execute only conforming */ >#define SDT_MEMEAC 29 /* memory execute only accessed conforming */ >#define SDT_MEMERC 30 /* memory execute read conforming */ >#define SDT_MEMERAC 31 /* memory execute read accessed conforming */ > >/* > * Size of IDT table > */ >#define NIDT 256 /* 32 reserved, 0x80 syscall, most are h/w */ >#define NRSVIDT 32 /* reserved entries for cpu exceptions */ > >/* > * Entries in the Interrupt Descriptor Table (IDT) > */ >#define IDT_DE 0 /* #DE: Divide Error */ >#define IDT_DB 1 /* #DB: Debug */ >#define IDT_NMI 2 /* Nonmaskable External Interrupt */ >#define IDT_BP 3 /* #BP: Breakpoint */ >#define IDT_OF 4 /* #OF: Overflow */ >#define IDT_BR 5 /* #BR: Bound Range Exceeded */ >#define IDT_UD 6 /* #UD: Undefined/Invalid Opcode */ >#define IDT_NM 7 /* #NM: No Math Coprocessor */ >#define IDT_DF 8 /* #DF: Double Fault */ >#define IDT_FPUGP 9 /* Coprocessor Segment Overrun */ >#define IDT_TS 10 /* #TS: Invalid TSS */ >#define IDT_NP 11 /* #NP: Segment Not Present */ >#define IDT_SS 12 /* #SS: Stack Segment Fault */ >#define IDT_GP 13 /* #GP: General Protection Fault */ >#define IDT_PF 14 /* #PF: Page Fault */ >#define IDT_MF 16 /* #MF: FPU Floating-Point Error */ >#define IDT_AC 17 /* #AC: Alignment Check */ >#define IDT_MC 18 /* #MC: Machine Check */ >#define IDT_XF 19 /* #XF: SIMD Floating-Point Exception */ >#define IDT_IO_INTS NRSVIDT /* Base of IDT entries for I/O interrupts. */ >#define IDT_SYSCALL 0x80 /* System Call Interrupt Vector */ >#define IDT_DTRACE_RET 0x92 /* DTrace pid provider Interrupt Vector */ >#define IDT_EVTCHN 0x93 /* Xen HVM Event Channel Interrupt Vector */ > >#if defined(__i386__) >/* > * Entries in the Global Descriptor Table (GDT) > * Note that each 4 entries share a single 32 byte L1 cache line. > * Some of the fast syscall instructions require a specific order here. > */ >#define GNULL_SEL 0 /* Null Descriptor */ >#define GPRIV_SEL 1 /* SMP Per-Processor Private Data */ >#define GUFS_SEL 2 /* User %fs Descriptor (order critical: 1) */ >#define GUGS_SEL 3 /* User %gs Descriptor (order critical: 2) */ >#define GCODE_SEL 4 /* Kernel Code Descriptor (order critical: 1) */ >#define GDATA_SEL 5 /* Kernel Data Descriptor (order critical: 2) */ >#define GUCODE_SEL 6 /* User Code Descriptor (order critical: 3) */ >#define GUDATA_SEL 7 /* User Data Descriptor (order critical: 4) */ >#define GBIOSLOWMEM_SEL 8 /* BIOS low memory access (must be entry 8) */ >#define GPROC0_SEL 9 /* Task state process slot zero and up */ >#define GLDT_SEL 10 /* Default User LDT */ >#define GUSERLDT_SEL 11 /* User LDT */ >#define GPANIC_SEL 12 /* Task state to consider panic from */ >#define GBIOSCODE32_SEL 13 /* BIOS interface (32bit Code) */ >#define GBIOSCODE16_SEL 14 /* BIOS interface (16bit Code) */ >#define GBIOSDATA_SEL 15 /* BIOS interface (Data) */ >#define GBIOSUTIL_SEL 16 /* BIOS interface (Utility) */ >#define GBIOSARGS_SEL 17 /* BIOS interface (Arguments) */ >#define GNDIS_SEL 18 /* For the NDIS layer */ >#ifdef XEN >#define NGDT 9 >#else ># 250 "./x86/segments.h" >#define NGDT 19 >#endif ># 252 "./x86/segments.h" > >/* > * Entries in the Local Descriptor Table (LDT) > */ >#define LSYS5CALLS_SEL 0 /* forced by intel BCS */ >#define LSYS5SIGR_SEL 1 >#define L43BSDCALLS_SEL 2 /* notyet */ >#define LUCODE_SEL 3 >#define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */ >#define LUDATA_SEL 5 >/* separate stack, es,fs,gs sels ? */ >/* #define LPOSIXCALLS_SEL 5*/ /* notyet */ >#define LBSDICALLS_SEL 16 /* BSDI system call gate */ >#define NLDT (LBSDICALLS_SEL + 1) > >#else /* !__i386__ */ ># 268 "./x86/segments.h" >/* > * Entries in the Global Descriptor Table (GDT) > */ >#define GNULL_SEL 0 /* Null Descriptor */ >#define GNULL2_SEL 1 /* Null Descriptor */ >#define GUFS32_SEL 2 /* User 32 bit %fs Descriptor */ >#define GUGS32_SEL 3 /* User 32 bit %gs Descriptor */ >#define GCODE_SEL 4 /* Kernel Code Descriptor */ >#define GDATA_SEL 5 /* Kernel Data Descriptor */ >#define GUCODE32_SEL 6 /* User 32 bit code Descriptor */ >#define GUDATA_SEL 7 /* User 32/64 bit Data Descriptor */ >#define GUCODE_SEL 8 /* User 64 bit Code Descriptor */ >#define GPROC0_SEL 9 /* TSS for entering kernel etc */ >/* slot 10 is second half of GPROC0_SEL */ >#define GUSERLDT_SEL 11 /* LDT */ >/* slot 12 is second half of GUSERLDT_SEL */ >#define NGDT 13 >#endif /* __i386__ */ ># 286 "./x86/segments.h" > >#endif /* !_X86_SEGMENTS_H_ */ ># 288 "./x86/segments.h" ># 45 "./machine/segments.h" 2 > >/* > * System segment descriptors (128 bit wide) > */ >struct system_segment_descriptor { > u_int64_t sd_lolimit:16; /* segment extent (lsb) */ > u_int64_t sd_lobase:24; /* segment base address (lsb) */ > u_int64_t sd_type:5; /* segment type */ > u_int64_t sd_dpl:2; /* segment descriptor priority level */ > u_int64_t sd_p:1; /* segment descriptor present */ > u_int64_t sd_hilimit:4; /* segment extent (msb) */ > u_int64_t sd_xx0:3; /* unused */ > u_int64_t sd_gran:1; /* limit granularity (byte/page units)*/ > u_int64_t sd_hibase:40 __packed;/* segment base address (msb) */ > u_int64_t sd_xx1:8; > u_int64_t sd_mbz:5; /* MUST be zero */ > u_int64_t sd_xx2:19; >} __packed; > >/* > * Software definitions are in this convenient format, > * which are translated into inconvenient segment descriptors > * when needed to be used by the 386 hardware > */ > >struct soft_segment_descriptor { > unsigned long ssd_base; /* segment base address */ > unsigned long ssd_limit; /* segment extent */ > unsigned long ssd_type:5; /* segment type */ > unsigned long ssd_dpl:2; /* segment descriptor priority level */ > unsigned long ssd_p:1; /* segment descriptor present */ > unsigned long ssd_long:1; /* long mode (for %cs) */ > unsigned long ssd_def32:1; /* default 32 vs 16 bit size */ > unsigned long ssd_gran:1; /* limit granularity (byte/page units)*/ >} __packed; > >/* > * region descriptors, used to load gdt/idt tables before segments yet exist. > */ >struct region_descriptor { > uint64_t rd_limit:16; /* segment extent */ > uint64_t rd_base:64 __packed; /* base address */ >} __packed; > >#ifdef _KERNEL >extern struct user_segment_descriptor gdt[]; >extern struct soft_segment_descriptor gdt_segs[]; >extern struct gate_descriptor *idt; >extern struct region_descriptor r_gdt, r_idt; > >void lgdt(struct region_descriptor *rdp); >void sdtossd(struct user_segment_descriptor *sdp, > struct soft_segment_descriptor *ssdp); >void ssdtosd(struct soft_segment_descriptor *ssdp, > struct user_segment_descriptor *sdp); >void ssdtosyssd(struct soft_segment_descriptor *ssdp, > struct system_segment_descriptor *sdp); >void update_gdt_gsbase(struct thread *td, uint32_t base); >void update_gdt_fsbase(struct thread *td, uint32_t base); >#endif /* _KERNEL */ ># 105 "./machine/segments.h" > >#endif /* !_MACHINE_SEGMENTS_H_ */ ># 107 "./machine/segments.h" ># 45 "./machine/cpu.h" 2 > >#define cpu_exec(p) /* nothing */ >#define cpu_swapin(p) /* nothing */ >#define cpu_getstack(td) ((td)->td_frame->tf_rsp) >#define cpu_setstack(td, ap) ((td)->td_frame->tf_rsp = (ap)) >#define cpu_spinwait() ia32_pause() > >#define TRAPF_USERMODE(framep) \ > (ISPL((framep)->tf_cs) == SEL_UPL) >#define TRAPF_PC(framep) ((framep)->tf_rip) > >#ifdef _KERNEL >/* > * Struct containing pointers to CPU management functions whose > * implementation is run time selectable. Selection can be made, > * for example, based on detection of a particular CPU variant or > * hypervisor environment. > */ >struct cpu_ops { > void (*cpu_init)(void); > void (*cpu_resume)(void); >}; > >extern struct cpu_ops cpu_ops; >extern char btext[]; >extern char etext[]; > >/* Resume hook for VMM. */ >extern void (*vmm_resume_p)(void); > >void cpu_halt(void); >void cpu_reset(void); >void fork_trampoline(void); >void swi_vm(void *); > >/* > * Return contents of in-cpu fast counter as a sort of "bogo-time" > * for random-harvesting purposes. > */ >static __inline u_int64_t >get_cyclecount(void) >{ > > return (rdtsc()); >} > >#endif ># 92 "./machine/cpu.h" > >#endif /* !_MACHINE_CPU_H_ */ ># 94 "./machine/cpu.h" ># 34 "/usr/src/ifnet/sys/sys/buf_ring.h" 2 > >#if defined(INVARIANTS) && !defined(DEBUG_BUFRING) >#define DEBUG_BUFRING 1 >#endif ># 38 "/usr/src/ifnet/sys/sys/buf_ring.h" > >#ifdef DEBUG_BUFRING >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/buf_ring.h" ># 41 "/usr/src/ifnet/sys/sys/buf_ring.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/buf_ring.h" ># 1 "/usr/src/ifnet/sys/sys/mutex.h" 1 >/*- > * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Berkeley Software Design Inc's name may not be used to endorse or > * promote products derived from this software without specific prior > * written permission. > * > * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN INC ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN INC BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * from BSDI $Id: mutex.h,v 2.7.2.35 2000/04/27 03:10:26 cp Exp $ > * $FreeBSD: projects/ifnet/sys/sys/mutex.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_MUTEX_H_ >#define _SYS_MUTEX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/mutex.h" ># 36 "/usr/src/ifnet/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/mutex.h" ># 37 "/usr/src/ifnet/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/mutex.h" ># 38 "/usr/src/ifnet/sys/sys/mutex.h" > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/mutex.h" ># 1 "/usr/src/ifnet/sys/sys/pcpu.h" 1 >/*- > * Copyright (c) 2001 Wind River Systems, Inc. > * All rights reserved. > * Written by: John Baldwin <jhb@FreeBSD.org> > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the author nor the names of any co-contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/pcpu.h 262773 2014-03-05 03:20:57Z glebius $ > */ > >#ifndef _SYS_PCPU_H_ >#define _SYS_PCPU_H_ > >#ifdef LOCORE >#error "no assembler-serviceable parts inside" >#endif ># 39 "/usr/src/ifnet/sys/sys/pcpu.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_cpuset.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "/usr/src/ifnet/sys/sys/_cpuset.h" 1 >/*- > * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> > * All rights reserved. > * > * Copyright (c) 2008 Nokia Corporation > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_cpuset.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _SYS__CPUSET_H_ >#define _SYS__CPUSET_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_bitset.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/_cpuset.h" ># 1 "/usr/src/ifnet/sys/sys/_bitset.h" 1 >/*- > * Copyright (c) 2008, Jeffrey Roberson <jeff@freebsd.org> > * All rights reserved. > * > * Copyright (c) 2008 Nokia Corporation > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice unmodified, this list of conditions, and the following > * disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, > * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY > * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_bitset.h 250395 2013-05-09 00:04:59Z attilio $ > */ > >#ifndef _SYS__BITSET_H_ >#define _SYS__BITSET_H_ > >/* > * Macros addressing word and bit within it, tuned to make compiler > * optimize cases when SETSIZE fits into single machine word. > */ >#define _BITSET_BITS (sizeof(long) * NBBY) > >#define __bitset_words(_s) (howmany(_s, _BITSET_BITS)) > >#define __bitset_mask(_s, n) \ > (1L << ((__bitset_words((_s)) == 1) ? \ > (__size_t)(n) : ((n) % _BITSET_BITS))) > >#define __bitset_word(_s, n) \ > ((__bitset_words((_s)) == 1) ? 0 : ((n) / _BITSET_BITS)) > >#define BITSET_DEFINE(t, _s) \ >struct t { \ > long __bits[__bitset_words((_s))]; \ >}; > >#define BITSET_T_INITIALIZER(x) \ > { .__bits = { x } } > >#define BITSET_FSET(n) \ > [ 0 ... ((n) - 1) ] = (-1L) > >#endif /* !_SYS__BITSET_H_ */ ># 62 "/usr/src/ifnet/sys/sys/_bitset.h" ># 36 "/usr/src/ifnet/sys/sys/_cpuset.h" 2 > >#ifdef _KERNEL >#define CPU_SETSIZE MAXCPU >#endif ># 40 "/usr/src/ifnet/sys/sys/_cpuset.h" > >#define CPU_MAXSIZE 256 > >#ifndef CPU_SETSIZE >#define CPU_SETSIZE CPU_MAXSIZE >#endif ># 46 "/usr/src/ifnet/sys/sys/_cpuset.h" > >#define _NCPUBITS _BITSET_BITS >#define _NCPUWORDS __bitset_words(CPU_SETSIZE) > >BITSET_DEFINE(_cpuset, CPU_SETSIZE); >typedef struct _cpuset cpuset_t; > >#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) >#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER > >#endif /* !_SYS__CPUSET_H_ */ ># 57 "/usr/src/ifnet/sys/sys/_cpuset.h" ># 41 "/usr/src/ifnet/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/pcpu.h" ># 42 "/usr/src/ifnet/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_mutex.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/pcpu.h" ># 43 "/usr/src/ifnet/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sx.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "/usr/src/ifnet/sys/sys/_sx.h" 1 >/*- > * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_sx.h 179025 2008-05-15 20:10:06Z attilio $ > */ > >#ifndef _SYS__SX_H_ >#define _SYS__SX_H_ > >/* > * Shared/exclusive lock main structure definition. > */ >struct sx { > struct lock_object lock_object; > volatile uintptr_t sx_lock; >}; > >#endif /* !_SYS__SX_H_ */ ># 43 "/usr/src/ifnet/sys/sys/_sx.h" ># 44 "/usr/src/ifnet/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/sys/pcpu.h" ># 45 "/usr/src/ifnet/sys/sys/pcpu.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_rmlock.h> >#endif /* expanded by -frewrite-includes */ ># 45 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "/usr/src/ifnet/sys/sys/_rmlock.h" 1 >/*- > * Copyright (c) 2007 Stephan Uphoff <ups@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. Neither the name of the author nor the names of any co-contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_rmlock.h 252209 2013-06-25 18:44:15Z jhb $ > */ > >#ifndef _SYS__RMLOCK_H_ >#define _SYS__RMLOCK_H_ > >/* > * Mostly reader/occasional writer lock. > */ > >LIST_HEAD(rmpriolist,rm_priotracker); > >struct rm_queue { > struct rm_queue *volatile rmq_next; > struct rm_queue *volatile rmq_prev; >}; > >struct rmlock { > struct lock_object lock_object; > volatile cpuset_t rm_writecpus; > LIST_HEAD(,rm_priotracker) rm_activeReaders; > union { > struct lock_object _rm_wlock_object; > struct mtx _rm_lock_mtx; > struct sx _rm_lock_sx; > } _rm_lock; >}; > >#define rm_wlock_object _rm_lock._rm_wlock_object >#define rm_lock_mtx _rm_lock._rm_lock_mtx >#define rm_lock_sx _rm_lock._rm_lock_sx > >struct rm_priotracker { > struct rm_queue rmp_cpuQueue; /* Must be first */ > struct rmlock *rmp_rmlock; > struct thread *rmp_thread; > int rmp_flags; > LIST_ENTRY(rm_priotracker) rmp_qentry; >}; > >#endif /* !_SYS__RMLOCK_H_ */ ># 70 "/usr/src/ifnet/sys/sys/_rmlock.h" ># 46 "/usr/src/ifnet/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/vmmeter.h> >#endif /* expanded by -frewrite-includes */ ># 46 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "/usr/src/ifnet/sys/sys/vmmeter.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 > * $FreeBSD: projects/ifnet/sys/sys/vmmeter.h 272251 2014-09-28 12:18:21Z glebius $ > */ > >#ifndef _SYS_VMMETER_H_ >#define _SYS_VMMETER_H_ > >/* > * This value is used by ps(1) to change sleep state flag from 'S' to > * 'I' and by the sched process to set the alarm clock. > */ >#define MAXSLP 20 > >/* > * System wide statistics counters. > * Locking: > * a - locked by atomic operations > * c - constant after initialization > * f - locked by vm_page_queue_free_mtx > * p - locked by being in the PCPU and atomicity respect to interrupts > * q - changes are synchronized by the corresponding vm_pagequeue lock > */ >struct vmmeter { > /* > * General system activity. > */ > u_int v_swtch; /* (p) context switches */ > u_int v_trap; /* (p) calls to trap */ > u_int v_syscall; /* (p) calls to syscall() */ > u_int v_intr; /* (p) device interrupts */ > u_int v_soft; /* (p) software interrupts */ > /* > * Virtual memory activity. > */ > u_int v_vm_faults; /* (p) address memory faults */ > u_int v_io_faults; /* (p) page faults requiring I/O */ > u_int v_cow_faults; /* (p) copy-on-writes faults */ > u_int v_cow_optim; /* (p) optimized copy-on-writes faults */ > u_int v_zfod; /* (p) pages zero filled on demand */ > u_int v_ozfod; /* (p) optimized zero fill pages */ > u_int v_swapin; /* (p) swap pager pageins */ > u_int v_swapout; /* (p) swap pager pageouts */ > u_int v_swappgsin; /* (p) swap pager pages paged in */ > u_int v_swappgsout; /* (p) swap pager pages paged out */ > u_int v_vnodein; /* (p) vnode pager pageins */ > u_int v_vnodeout; /* (p) vnode pager pageouts */ > u_int v_vnodepgsin; /* (p) vnode_pager pages paged in */ > u_int v_vnodepgsout; /* (p) vnode pager pages paged out */ > u_int v_intrans; /* (p) intransit blocking page faults */ > u_int v_reactivated; /* (f) pages reactivated from free list */ > u_int v_pdwakeups; /* (f) times daemon has awaken from sleep */ > u_int v_pdpages; /* (p) pages analyzed by daemon */ > > u_int v_tcached; /* (p) total pages cached */ > u_int v_dfree; /* (p) pages freed by daemon */ > u_int v_pfree; /* (p) pages freed by exiting processes */ > u_int v_tfree; /* (p) total pages freed */ > /* > * Distribution of page usages. > */ > u_int v_page_size; /* (c) page size in bytes */ > u_int v_page_count; /* (c) total number of pages in system */ > u_int v_free_reserved; /* (c) pages reserved for deadlock */ > u_int v_free_target; /* (c) pages desired free */ > u_int v_free_min; /* (c) pages desired free */ > u_int v_free_count; /* (f) pages free */ > u_int v_wire_count; /* (a) pages wired down */ > u_int v_active_count; /* (q) pages active */ > u_int v_inactive_target; /* (c) pages desired inactive */ > u_int v_inactive_count; /* (q) pages inactive */ > u_int v_cache_count; /* (f) pages on cache queue */ > u_int v_cache_min; /* (c) min pages desired on cache queue */ > u_int v_cache_max; /* (c) max pages in cached obj (unused) */ > u_int v_pageout_free_min; /* (c) min pages reserved for kernel */ > u_int v_interrupt_free_min; /* (c) reserved pages for int code */ > u_int v_free_severe; /* (c) severe page depletion point */ > /* > * Fork/vfork/rfork activity. > */ > u_int v_forks; /* (p) fork() calls */ > u_int v_vforks; /* (p) vfork() calls */ > u_int v_rforks; /* (p) rfork() calls */ > u_int v_kthreads; /* (p) fork() calls by kernel */ > u_int v_forkpages; /* (p) VM pages affected by fork() */ > u_int v_vforkpages; /* (p) VM pages affected by vfork() */ > u_int v_rforkpages; /* (p) VM pages affected by rfork() */ > u_int v_kthreadpages; /* (p) VM pages affected by fork() by kernel */ >}; >#ifdef _KERNEL > >extern struct vmmeter vm_cnt; > >extern int vm_pageout_wakeup_thresh; > >/* > * Return TRUE if we are under our severe low-free-pages threshold > * > * This routine is typically used at the user<->system interface to determine > * whether we need to block in order to avoid a low memory deadlock. > */ > >static __inline >int >vm_page_count_severe(void) >{ > return (vm_cnt.v_free_severe > (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Return TRUE if we are under our minimum low-free-pages threshold. > * > * This routine is typically used within the system to determine whether > * we can execute potentially very expensive code in terms of memory. It > * is also used by the pageout daemon to calculate when to sleep, when > * to wake waiters up, and when (after making a pass) to become more > * desparate. > */ > >static __inline >int >vm_page_count_min(void) >{ > return (vm_cnt.v_free_min > (vm_cnt.v_free_count + vm_cnt.v_cache_count)); >} > >/* > * Return TRUE if we have not reached our free page target during > * free page recovery operations. > */ > >static __inline >int >vm_page_count_target(void) >{ > return (vm_cnt.v_free_target > (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Return the number of pages we need to free-up or cache > * A positive number indicates that we do not have enough free pages. > */ > >static __inline >int >vm_paging_target(void) >{ > return (vm_cnt.v_free_target - (vm_cnt.v_free_count + > vm_cnt.v_cache_count)); >} > >/* > * Returns TRUE if the pagedaemon needs to be woken up. > */ > >static __inline >int >vm_paging_needed(void) >{ > return (vm_cnt.v_free_count + vm_cnt.v_cache_count < > vm_pageout_wakeup_thresh); >} > >#endif ># 194 "/usr/src/ifnet/sys/sys/vmmeter.h" > >/* systemwide totals computed every five seconds */ >struct vmtotal { > int16_t t_rq; /* length of the run queue */ > int16_t t_dw; /* jobs in ``disk wait'' (neg priority) */ > int16_t t_pw; /* jobs in page wait */ > int16_t t_sl; /* jobs sleeping in core */ > int16_t t_sw; /* swapped out runnable/short block jobs */ > int32_t t_vm; /* total virtual memory */ > int32_t t_avm; /* active virtual memory */ > int32_t t_rm; /* total real memory in use */ > int32_t t_arm; /* active real memory */ > int32_t t_vmshr; /* shared virtual memory */ > int32_t t_avmshr; /* active shared virtual memory */ > int32_t t_rmshr; /* shared real memory */ > int32_t t_armshr; /* active shared real memory */ > int32_t t_free; /* free memory pages */ >}; > >#endif ># 214 "/usr/src/ifnet/sys/sys/vmmeter.h" ># 47 "/usr/src/ifnet/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/resource.h> >#endif /* expanded by -frewrite-includes */ ># 47 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "/usr/src/ifnet/sys/sys/resource.h" 1 >/*- > * Copyright (c) 1982, 1986, 1993 > * The Regents of the University of California. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 4. Neither the name of the University nor the names of its contributors > * may be used to endorse or promote products derived from this software > * without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * @(#)resource.h 8.4 (Berkeley) 1/9/95 > * $FreeBSD: projects/ifnet/sys/sys/resource.h 257046 2013-10-24 10:18:08Z glebius $ > */ > >#ifndef _SYS_RESOURCE_H_ >#define _SYS_RESOURCE_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/resource.h" ># 37 "/usr/src/ifnet/sys/sys/resource.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_timeval.h> >#endif /* expanded by -frewrite-includes */ ># 37 "/usr/src/ifnet/sys/sys/resource.h" ># 38 "/usr/src/ifnet/sys/sys/resource.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_types.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/resource.h" ># 39 "/usr/src/ifnet/sys/sys/resource.h" > >/* > * Process priority specifications to get/setpriority. > */ >#define PRIO_MIN -20 >#define PRIO_MAX 20 > >#define PRIO_PROCESS 0 >#define PRIO_PGRP 1 >#define PRIO_USER 2 > >/* > * Resource utilization information. > * > * All fields are only modified by curthread and > * no locks are required to read. > */ > >#define RUSAGE_SELF 0 >#define RUSAGE_CHILDREN -1 >#define RUSAGE_THREAD 1 > >struct rusage { > struct timeval ru_utime; /* user time used */ > struct timeval ru_stime; /* system time used */ > long ru_maxrss; /* max resident set size */ >#define ru_first ru_ixrss > long ru_ixrss; /* integral shared memory size */ > long ru_idrss; /* integral unshared data " */ > long ru_isrss; /* integral unshared stack " */ > long ru_minflt; /* page reclaims */ > long ru_majflt; /* page faults */ > long ru_nswap; /* swaps */ > long ru_inblock; /* block input operations */ > long ru_oublock; /* block output operations */ > long ru_msgsnd; /* messages sent */ > long ru_msgrcv; /* messages received */ > long ru_nsignals; /* signals received */ > long ru_nvcsw; /* voluntary context switches */ > long ru_nivcsw; /* involuntary " */ >#define ru_last ru_nivcsw >}; > >#if __BSD_VISIBLE >struct __wrusage { > struct rusage wru_self; > struct rusage wru_children; >}; >#endif ># 88 "/usr/src/ifnet/sys/sys/resource.h" > >/* > * Resource limits > */ >#define RLIMIT_CPU 0 /* maximum cpu time in seconds */ >#define RLIMIT_FSIZE 1 /* maximum file size */ >#define RLIMIT_DATA 2 /* data size */ >#define RLIMIT_STACK 3 /* stack size */ >#define RLIMIT_CORE 4 /* core file size */ >#define RLIMIT_RSS 5 /* resident set size */ >#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ >#define RLIMIT_NPROC 7 /* number of processes */ >#define RLIMIT_NOFILE 8 /* number of open files */ >#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ >#define RLIMIT_VMEM 10 /* virtual process size (incl. mmap) */ >#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ >#define RLIMIT_NPTS 11 /* pseudo-terminals */ >#define RLIMIT_SWAP 12 /* swap used */ >#define RLIMIT_KQUEUES 13 /* kqueues allocated */ > >#define RLIM_NLIMITS 14 /* number of resource limits */ > >#define RLIM_INFINITY ((rlim_t)(((uint64_t)1 << 63) - 1)) >/* XXX Missing: RLIM_SAVED_MAX, RLIM_SAVED_CUR */ > > >/* > * Resource limit string identifiers > */ > >#ifdef _RLIMIT_IDENT >static const char *rlimit_ident[RLIM_NLIMITS] = { > "cpu", > "fsize", > "data", > "stack", > "core", > "rss", > "memlock", > "nproc", > "nofile", > "sbsize", > "vmem", > "npts", > "swap", > "kqueues", >}; >#endif ># 136 "/usr/src/ifnet/sys/sys/resource.h" > >#ifndef _RLIM_T_DECLARED >typedef __rlim_t rlim_t; >#define _RLIM_T_DECLARED >#endif ># 141 "/usr/src/ifnet/sys/sys/resource.h" > >struct rlimit { > rlim_t rlim_cur; /* current (soft) limit */ > rlim_t rlim_max; /* maximum value for rlim_cur */ >}; > >#if __BSD_VISIBLE > >struct orlimit { > __int32_t rlim_cur; /* current (soft) limit */ > __int32_t rlim_max; /* maximum value for rlim_cur */ >}; > >struct loadavg { > __fixpt_t ldavg[3]; > long fscale; >}; > >#define CP_USER 0 >#define CP_NICE 1 >#define CP_SYS 2 >#define CP_INTR 3 >#define CP_IDLE 4 >#define CPUSTATES 5 > >#endif /* __BSD_VISIBLE */ ># 167 "/usr/src/ifnet/sys/sys/resource.h" > >#ifdef _KERNEL > >extern struct loadavg averunnable; >void read_cpu_time(long *cp_time); /* Writes array of CPUSTATES */ > >#else ># 174 "/usr/src/ifnet/sys/sys/resource.h" > >__BEGIN_DECLS >/* XXX 2nd arg to [gs]etpriority() should be an id_t */ >int getpriority(int, int); >int getrlimit(int, struct rlimit *); >int getrusage(int, struct rusage *); >int setpriority(int, int, int); >int setrlimit(int, const struct rlimit *); >__END_DECLS > >#endif /* _KERNEL */ ># 185 "/usr/src/ifnet/sys/sys/resource.h" >#endif /* !_SYS_RESOURCE_H_ */ ># 186 "/usr/src/ifnet/sys/sys/resource.h" ># 48 "/usr/src/ifnet/sys/sys/pcpu.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/ifnet/sys/sys/pcpu.h" ># 1 "./machine/pcpu.h" 1 >/*- > * Copyright (c) Peter Wemm <peter@netplex.com.au> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/amd64/include/pcpu.h 256073 2013-10-05 23:11:01Z gibbs $ > */ > >#ifndef _MACHINE_PCPU_H_ >#define _MACHINE_PCPU_H_ > >#ifndef _SYS_CDEFS_H_ >#error "sys/cdefs.h is a prerequisite for this file" >#endif ># 35 "./machine/pcpu.h" > >/* > * The SMP parts are setup in pmap.c and locore.s for the BSP, and > * mp_machdep.c sets up the data for the AP's to "see" when they awake. > * The reason for doing it via a struct is so that an array of pointers > * to each CPU's data can be set up for things like "check curproc on all > * other processors" > */ >#define PCPU_MD_FIELDS \ > char pc_monitorbuf[128] __aligned(128); /* cache line */ \ > struct pcpu *pc_prvspace; /* Self-reference */ \ > struct pmap *pc_curpmap; \ > struct amd64tss *pc_tssp; /* TSS segment active on CPU */ \ > struct amd64tss *pc_commontssp;/* Common TSS for the CPU */ \ > register_t pc_rsp0; \ > register_t pc_scratch_rsp; /* User %rsp in syscall */ \ > u_int pc_apic_id; \ > u_int pc_acpi_id; /* ACPI CPU id */ \ > /* Pointer to the CPU %fs descriptor */ \ > struct user_segment_descriptor *pc_fs32p; \ > /* Pointer to the CPU %gs descriptor */ \ > struct user_segment_descriptor *pc_gs32p; \ > /* Pointer to the CPU LDT descriptor */ \ > struct system_segment_descriptor *pc_ldt; \ > /* Pointer to the CPU TSS descriptor */ \ > struct system_segment_descriptor *pc_tss; \ > uint64_t pc_pm_save_cnt; \ > u_int pc_cmci_mask; /* MCx banks for CMCI */ \ > uint64_t pc_dbreg[16]; /* ddb debugging regs */ \ > int pc_dbreg_cmd; /* ddb debugging reg cmd */ \ > u_int pc_vcpu_id; /* Xen vCPU ID */ \ > char __pad[157] /* be divisor of PAGE_SIZE \ > after cache alignment */ > >#define PC_DBREG_CMD_NONE 0 >#define PC_DBREG_CMD_LOAD 1 > >#ifdef _KERNEL > >#ifdef lint > >extern struct pcpu *pcpup; > >#define PCPU_GET(member) (pcpup->pc_ ## member) >#define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) >#define PCPU_INC(member) PCPU_ADD(member, 1) >#define PCPU_PTR(member) (&pcpup->pc_ ## member) >#define PCPU_SET(member, val) (pcpup->pc_ ## member = (val)) > >#elif defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) ># 85 "./machine/pcpu.h" > >/* > * Evaluates to the byte offset of the per-cpu variable name. > */ >#define __pcpu_offset(name) \ > __offsetof(struct pcpu, name) > >/* > * Evaluates to the type of the per-cpu variable name. > */ >#define __pcpu_type(name) \ > __typeof(((struct pcpu *)0)->name) > >/* > * Evaluates to the address of the per-cpu variable name. > */ >#define __PCPU_PTR(name) __extension__ ({ \ > __pcpu_type(name) *__p; \ > \ > __asm __volatile("movq %%gs:%1,%0; addq %2,%0" \ > : "=r" (__p) \ > : "m" (*(struct pcpu *)(__pcpu_offset(pc_prvspace))), \ > "i" (__pcpu_offset(name))); \ > \ > __p; \ >}) > >/* > * Evaluates to the value of the per-cpu variable name. > */ >#define __PCPU_GET(name) __extension__ ({ \ > __pcpu_type(name) __res; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > if (sizeof(__res) == 1 || sizeof(__res) == 2 || \ > sizeof(__res) == 4 || sizeof(__res) == 8) { \ > __asm __volatile("mov %%gs:%1,%0" \ > : "=r" (__s) \ > : "m" (*(struct __s *)(__pcpu_offset(name)))); \ > *(struct __s *)(void *)&__res = __s; \ > } else { \ > __res = *__PCPU_PTR(name); \ > } \ > __res; \ >}) > >/* > * Adds the value to the per-cpu counter name. The implementation > * must be atomic with respect to interrupts. > */ >#define __PCPU_ADD(name, val) do { \ > __pcpu_type(name) __val; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > __val = (val); \ > if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ > sizeof(__val) == 4 || sizeof(__val) == 8) { \ > __s = *(struct __s *)(void *)&__val; \ > __asm __volatile("add %1,%%gs:%0" \ > : "=m" (*(struct __s *)(__pcpu_offset(name))) \ > : "r" (__s)); \ > } else \ > *__PCPU_PTR(name) += __val; \ >} while (0) > >/* > * Increments the value of the per-cpu counter name. The implementation > * must be atomic with respect to interrupts. > */ >#define __PCPU_INC(name) do { \ > CTASSERT(sizeof(__pcpu_type(name)) == 1 || \ > sizeof(__pcpu_type(name)) == 2 || \ > sizeof(__pcpu_type(name)) == 4 || \ > sizeof(__pcpu_type(name)) == 8); \ > if (sizeof(__pcpu_type(name)) == 1) { \ > __asm __volatile("incb %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 2) { \ > __asm __volatile("incw %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 4) { \ > __asm __volatile("incl %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } else if (sizeof(__pcpu_type(name)) == 8) { \ > __asm __volatile("incq %%gs:%0" \ > : "=m" (*(__pcpu_type(name) *)(__pcpu_offset(name)))\ > : "m" (*(__pcpu_type(name) *)(__pcpu_offset(name))));\ > } \ >} while (0) > >/* > * Sets the value of the per-cpu variable name to value val. > */ >#define __PCPU_SET(name, val) { \ > __pcpu_type(name) __val; \ > struct __s { \ > u_char __b[MIN(sizeof(__pcpu_type(name)), 8)]; \ > } __s; \ > \ > __val = (val); \ > if (sizeof(__val) == 1 || sizeof(__val) == 2 || \ > sizeof(__val) == 4 || sizeof(__val) == 8) { \ > __s = *(struct __s *)(void *)&__val; \ > __asm __volatile("mov %1,%%gs:%0" \ > : "=m" (*(struct __s *)(__pcpu_offset(name))) \ > : "r" (__s)); \ > } else { \ > *__PCPU_PTR(name) = __val; \ > } \ >} > >#define PCPU_GET(member) __PCPU_GET(pc_ ## member) >#define PCPU_ADD(member, val) __PCPU_ADD(pc_ ## member, val) >#define PCPU_INC(member) __PCPU_INC(pc_ ## member) >#define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) >#define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) > >#define OFFSETOF_CURTHREAD 0 >#ifdef __clang__ >#pragma clang diagnostic push >#pragma clang diagnostic ignored "-Wnull-dereference" >#endif ># 214 "./machine/pcpu.h" >static __inline __pure2 struct thread * >__curthread(void) >{ > struct thread *td; > > __asm("movq %%gs:%1,%0" : "=r" (td) > : "m" (*(char *)OFFSETOF_CURTHREAD)); > return (td); >} >#ifdef __clang__ >#pragma clang diagnostic pop >#endif ># 226 "./machine/pcpu.h" >#define curthread (__curthread()) > >#define OFFSETOF_CURPCB 32 >static __inline __pure2 struct pcb * >__curpcb(void) >{ > struct pcb *pcb; > > __asm("movq %%gs:%1,%0" : "=r" (pcb) : "m" (*(char *)OFFSETOF_CURPCB)); > return (pcb); >} >#define curpcb (__curpcb()) > >#define IS_BSP() (PCPU_GET(cpuid) == 0) > >#else /* !lint || defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */ ># 242 "./machine/pcpu.h" > >#error "this file needs to be ported to your compiler" > >#endif /* lint, etc. */ ># 246 "./machine/pcpu.h" > >#endif /* _KERNEL */ ># 248 "./machine/pcpu.h" > >#endif /* !_MACHINE_PCPU_H_ */ ># 250 "./machine/pcpu.h" ># 49 "/usr/src/ifnet/sys/sys/pcpu.h" 2 > >#define DPCPU_SETNAME "set_pcpu" >#define DPCPU_SYMPREFIX "pcpu_entry_" > >#ifdef _KERNEL > >/* > * Define a set for pcpu data. > */ >extern uintptr_t *__start_set_pcpu; >__GLOBL(__start_set_pcpu); >extern uintptr_t *__stop_set_pcpu; >__GLOBL(__stop_set_pcpu); > >/* > * Array of dynamic pcpu base offsets. Indexed by id. > */ >extern uintptr_t dpcpu_off[]; > >/* > * Convenience defines. > */ >#define DPCPU_START ((uintptr_t)&__start_set_pcpu) >#define DPCPU_STOP ((uintptr_t)&__stop_set_pcpu) >#define DPCPU_BYTES (DPCPU_STOP - DPCPU_START) >#define DPCPU_MODMIN 2048 >#define DPCPU_SIZE roundup2(DPCPU_BYTES, PAGE_SIZE) >#define DPCPU_MODSIZE (DPCPU_SIZE - (DPCPU_BYTES - DPCPU_MODMIN)) > >/* > * Declaration and definition. > */ >#define DPCPU_NAME(n) pcpu_entry_##n >#define DPCPU_DECLARE(t, n) extern t DPCPU_NAME(n) >#define DPCPU_DEFINE(t, n) t DPCPU_NAME(n) __section(DPCPU_SETNAME) __used > >/* > * Accessors with a given base. > */ >#define _DPCPU_PTR(b, n) \ > (__typeof(DPCPU_NAME(n))*)((b) + (uintptr_t)&DPCPU_NAME(n)) >#define _DPCPU_GET(b, n) (*_DPCPU_PTR(b, n)) >#define _DPCPU_SET(b, n, v) (*_DPCPU_PTR(b, n) = v) > >/* > * Accessors for the current cpu. > */ >#define DPCPU_PTR(n) _DPCPU_PTR(PCPU_GET(dynamic), n) >#define DPCPU_GET(n) (*DPCPU_PTR(n)) >#define DPCPU_SET(n, v) (*DPCPU_PTR(n) = v) > >/* > * Accessors for remote cpus. > */ >#define DPCPU_ID_PTR(i, n) _DPCPU_PTR(dpcpu_off[(i)], n) >#define DPCPU_ID_GET(i, n) (*DPCPU_ID_PTR(i, n)) >#define DPCPU_ID_SET(i, n, v) (*DPCPU_ID_PTR(i, n) = v) > >/* > * Utility macros. > */ >#define DPCPU_SUM(n) __extension__ \ >({ \ > u_int _i; \ > __typeof(*DPCPU_PTR(n)) sum; \ > \ > sum = 0; \ > CPU_FOREACH(_i) { \ > sum += *DPCPU_ID_PTR(_i, n); \ > } \ > sum; \ >}) > >#define DPCPU_VARSUM(n, var) __extension__ \ >({ \ > u_int _i; \ > __typeof((DPCPU_PTR(n))->var) sum; \ > \ > sum = 0; \ > CPU_FOREACH(_i) { \ > sum += (DPCPU_ID_PTR(_i, n))->var; \ > } \ > sum; \ >}) > >#define DPCPU_ZERO(n) do { \ > u_int _i; \ > \ > CPU_FOREACH(_i) { \ > bzero(DPCPU_ID_PTR(_i, n), sizeof(*DPCPU_PTR(n))); \ > } \ >} while(0) > >#endif /* _KERNEL */ ># 143 "/usr/src/ifnet/sys/sys/pcpu.h" > >/* > * This structure maps out the global data that needs to be kept on a > * per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR > * macros defined in <machine/pcpu.h>. Machine dependent fields are > * defined in the PCPU_MD_FIELDS macro defined in <machine/pcpu.h>. > */ >struct pcpu { > struct thread *pc_curthread; /* Current thread */ > struct thread *pc_idlethread; /* Idle thread */ > struct thread *pc_fpcurthread; /* Fp state owner */ > struct thread *pc_deadthread; /* Zombie thread or NULL */ > struct pcb *pc_curpcb; /* Current pcb */ > uint64_t pc_switchtime; /* cpu_ticks() at last csw */ > int pc_switchticks; /* `ticks' at last csw */ > u_int pc_cpuid; /* This cpu number */ > STAILQ_ENTRY(pcpu) pc_allcpu; > struct lock_list_entry *pc_spinlocks; > struct vmmeter pc_cnt; /* VM stats counters */ > long pc_cp_time[CPUSTATES]; /* statclock ticks */ > struct device *pc_device; > void *pc_netisr; /* netisr SWI cookie */ > int pc_dnweight; /* vm_page_dontneed() */ > int pc_domain; /* Memory domain. */ > struct rm_queue pc_rm_queue; /* rmlock list of trackers */ > uintptr_t pc_dynamic; /* Dynamic per-cpu data area */ > > /* > * Keep MD fields last, so that CPU-specific variations on a > * single architecture don't result in offset variations of > * the machine-independent fields of the pcpu. Even though > * the pcpu structure is private to the kernel, some ports > * (e.g., lsof, part of gtop) define _KERNEL and include this > * header. While strictly speaking this is wrong, there's no > * reason not to keep the offsets of the MI fields constant > * if only to make kernel debugging easier. > */ > PCPU_MD_FIELDS; >} __aligned(CACHE_LINE_SIZE); > >#ifdef CTASSERT >/* > * To minimize memory waste in per-cpu UMA zones, size of struct pcpu > * should be denominator of PAGE_SIZE. > */ >CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE); >#endif ># 190 "/usr/src/ifnet/sys/sys/pcpu.h" > >#ifdef _KERNEL > >STAILQ_HEAD(cpuhead, pcpu); > >extern struct cpuhead cpuhead; >extern struct pcpu *cpuid_to_pcpu[]; > >#define curcpu PCPU_GET(cpuid) >#define curproc (curthread->td_proc) >#ifndef curthread >#define curthread PCPU_GET(curthread) >#endif ># 203 "/usr/src/ifnet/sys/sys/pcpu.h" >#define curvidata PCPU_GET(vidata) > >/* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ >static inline void * >zpcpu_get(void *base) >{ > > return ((char *)(base) + sizeof(struct pcpu) * curcpu); >} > >static inline void * >zpcpu_get_cpu(void *base, int cpu) >{ > > return ((char *)(base) + sizeof(struct pcpu) * cpu); >} > >/* > * Machine dependent callouts. cpu_pcpu_init() is responsible for > * initializing machine dependent fields of struct pcpu, and > * db_show_mdpcpu() is responsible for handling machine dependent > * fields for the DDB 'show pcpu' command. > */ >void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); >void db_show_mdpcpu(struct pcpu *pcpu); > >void *dpcpu_alloc(int size); >void dpcpu_copy(void *s, int size); >void dpcpu_free(void *s, int size); >void dpcpu_init(void *dpcpu, int cpuid); >void pcpu_destroy(struct pcpu *pcpu); >struct pcpu *pcpu_find(u_int cpuid); >void pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); > >#endif /* _KERNEL */ ># 238 "/usr/src/ifnet/sys/sys/pcpu.h" > >#endif /* !_SYS_PCPU_H_ */ ># 240 "/usr/src/ifnet/sys/sys/pcpu.h" ># 41 "/usr/src/ifnet/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/mutex.h" ># 1 "/usr/src/ifnet/sys/sys/lock_profile.h" 1 >/*- > * Copyright (c) 2006 Kip Macy kmacy@FreeBSD.org > * Copyright (c) 2006 Kris Kennaway kris@FreeBSD.org > * Copyright (c) 2006 Dag-Erling Smorgrav des@des.no > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHAL THE AUTHORS BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/lock_profile.h 194578 2009-06-21 09:01:12Z rdivacky $ > */ > > >#ifndef _SYS_LOCK_PROFILE_H_ >#define _SYS_LOCK_PROFILE_H_ > >struct lock_profile_object; >LIST_HEAD(lpohead, lock_profile_object); > >#ifdef _KERNEL >#ifdef LOCK_PROFILING >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/lock_profile.h" ># 40 "/usr/src/ifnet/sys/sys/lock_profile.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/lock_profile.h" ># 41 "/usr/src/ifnet/sys/sys/lock_profile.h" > >#ifndef USE_CPU_NANOSECONDS >u_int64_t nanoseconds(void); >#endif ># 45 "/usr/src/ifnet/sys/sys/lock_profile.h" > >extern volatile int lock_prof_enable; > >void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, > uint64_t waittime, const char *file, int line); >void lock_profile_release_lock(struct lock_object *lo); >void lock_profile_thread_exit(struct thread *td); > > >static inline void >lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, > uint64_t *waittime) >{ > if (!lock_prof_enable || (lo->lo_flags & LO_NOPROFILE) || *contested) > return; > *waittime = nanoseconds(); > *contested = 1; >} > >#else /* !LOCK_PROFILING */ ># 65 "/usr/src/ifnet/sys/sys/lock_profile.h" > >#define lock_profile_release_lock(lo) (void)0 >#define lock_profile_obtain_lock_failed(lo, contested, waittime) (void)0 >#define lock_profile_obtain_lock_success(lo, contested, waittime, file, line) (void)0 >#define lock_profile_thread_exit(td) (void)0 > >#endif /* !LOCK_PROFILING */ ># 72 "/usr/src/ifnet/sys/sys/lock_profile.h" > >#endif /* _KERNEL */ ># 74 "/usr/src/ifnet/sys/sys/lock_profile.h" > >#endif /* _SYS_LOCK_PROFILE_H_ */ ># 76 "/usr/src/ifnet/sys/sys/lock_profile.h" ># 42 "/usr/src/ifnet/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockstat.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/mutex.h" ># 1 "/usr/src/ifnet/sys/sys/lockstat.h" 1 >/*- > * Copyright (c) 2008-2009 Stacey Son <sson@FreeBSD.org> > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/lockstat.h 228448 2011-12-12 23:29:32Z attilio $ > */ > >/* > * DTrace lockstat provider definitions > * > */ > >#ifndef _SYS_LOCKSTAT_H >#define _SYS_LOCKSTAT_H > >#ifdef _KERNEL > >/* > * Spin Locks > */ >#define LS_MTX_SPIN_LOCK_ACQUIRE 0 >#define LS_MTX_SPIN_UNLOCK_RELEASE 1 >#define LS_MTX_SPIN_LOCK_SPIN 2 > >/* > * Adaptive Locks > */ >#define LS_MTX_LOCK_ACQUIRE 3 >#define LS_MTX_UNLOCK_RELEASE 4 >#define LS_MTX_LOCK_SPIN 5 >#define LS_MTX_LOCK_BLOCK 6 >#define LS_MTX_TRYLOCK_ACQUIRE 7 > >/* > * Reader/Writer Locks > */ >#define LS_RW_RLOCK_ACQUIRE 8 >#define LS_RW_RUNLOCK_RELEASE 9 >#define LS_RW_WLOCK_ACQUIRE 10 >#define LS_RW_WUNLOCK_RELEASE 11 >#define LS_RW_RLOCK_SPIN 12 >#define LS_RW_RLOCK_BLOCK 13 >#define LS_RW_WLOCK_SPIN 14 >#define LS_RW_WLOCK_BLOCK 15 >#define LS_RW_TRYUPGRADE_UPGRADE 16 >#define LS_RW_DOWNGRADE_DOWNGRADE 17 > >/* > * Shared/Exclusive Locks > */ >#define LS_SX_SLOCK_ACQUIRE 18 >#define LS_SX_SUNLOCK_RELEASE 19 >#define LS_SX_XLOCK_ACQUIRE 20 >#define LS_SX_XUNLOCK_RELEASE 21 >#define LS_SX_SLOCK_SPIN 22 >#define LS_SX_SLOCK_BLOCK 23 >#define LS_SX_XLOCK_SPIN 24 >#define LS_SX_XLOCK_BLOCK 25 >#define LS_SX_TRYUPGRADE_UPGRADE 26 >#define LS_SX_DOWNGRADE_DOWNGRADE 27 > >/* > * Thread Locks > */ >#define LS_THREAD_LOCK_SPIN 28 > >/* > * Lockmanager Locks > * According to locking(9) Lockmgr locks are "Largely deprecated" > * so no support for these have been added in the lockstat provider. > */ > >#define LS_NPROBES 29 > >#define LS_MTX_LOCK "mtx_lock" >#define LS_MTX_UNLOCK "mtx_unlock" >#define LS_MTX_SPIN_LOCK "mtx_lock_spin" >#define LS_MTX_SPIN_UNLOCK "mtx_unlock_spin" >#define LS_MTX_TRYLOCK "mtx_trylock" >#define LS_RW_RLOCK "rw_rlock" >#define LS_RW_WLOCK "rw_wlock" >#define LS_RW_RUNLOCK "rw_runlock" >#define LS_RW_WUNLOCK "rw_wunlock" >#define LS_RW_TRYUPGRADE "rw_try_upgrade" >#define LS_RW_DOWNGRADE "rw_downgrade" >#define LS_SX_SLOCK "sx_slock" >#define LS_SX_XLOCK "sx_xlock" >#define LS_SX_SUNLOCK "sx_sunlock" >#define LS_SX_XUNLOCK "sx_xunlock" >#define LS_SX_TRYUPGRADE "sx_try_upgrade" >#define LS_SX_DOWNGRADE "sx_downgrade" >#define LS_THREAD_LOCK "thread_lock" > >#define LS_ACQUIRE "acquire" >#define LS_RELEASE "release" >#define LS_SPIN "spin" >#define LS_BLOCK "block" >#define LS_UPGRADE "upgrade" >#define LS_DOWNGRADE "downgrade" > >#define LS_TYPE_ADAPTIVE "adaptive" >#define LS_TYPE_SPIN "spin" >#define LS_TYPE_THREAD "thread" >#define LS_TYPE_RW "rw" >#define LS_TYPE_SX "sx" > >#define LSA_ACQUIRE (LS_TYPE_ADAPTIVE "-" LS_ACQUIRE) >#define LSA_RELEASE (LS_TYPE_ADAPTIVE "-" LS_RELEASE) >#define LSA_SPIN (LS_TYPE_ADAPTIVE "-" LS_SPIN) >#define LSA_BLOCK (LS_TYPE_ADAPTIVE "-" LS_BLOCK) >#define LSS_ACQUIRE (LS_TYPE_SPIN "-" LS_ACQUIRE) >#define LSS_RELEASE (LS_TYPE_SPIN "-" LS_RELEASE) >#define LSS_SPIN (LS_TYPE_SPIN "-" LS_SPIN) >#define LSR_ACQUIRE (LS_TYPE_RW "-" LS_ACQUIRE) >#define LSR_RELEASE (LS_TYPE_RW "-" LS_RELEASE) >#define LSR_BLOCK (LS_TYPE_RW "-" LS_BLOCK) >#define LSR_SPIN (LS_TYPE_RW "-" LS_SPIN) >#define LSR_UPGRADE (LS_TYPE_RW "-" LS_UPGRADE) >#define LSR_DOWNGRADE (LS_TYPE_RW "-" LS_DOWNGRADE) >#define LSX_ACQUIRE (LS_TYPE_SX "-" LS_ACQUIRE) >#define LSX_RELEASE (LS_TYPE_SX "-" LS_RELEASE) >#define LSX_BLOCK (LS_TYPE_SX "-" LS_BLOCK) >#define LSX_SPIN (LS_TYPE_SX "-" LS_SPIN) >#define LSX_UPGRADE (LS_TYPE_SX "-" LS_UPGRADE) >#define LSX_DOWNGRADE (LS_TYPE_SX "-" LS_DOWNGRADE) >#define LST_SPIN (LS_TYPE_THREAD "-" LS_SPIN) > >/* > * The following must match the type definition of dtrace_probe. It is > * defined this way to avoid having to rely on CDDL code. > */ >extern uint32_t lockstat_probemap[LS_NPROBES]; >typedef void (*lockstat_probe_func_t)(uint32_t, uintptr_t arg0, uintptr_t arg1, > uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); >extern lockstat_probe_func_t lockstat_probe_func; >extern uint64_t lockstat_nsecs(void); > >#ifdef KDTRACE_HOOKS >/* > * Macros to record lockstat probes. > */ >#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) do { \ > uint32_t id; \ > \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), (arg1), (arg2), \ > (arg3), (arg4)); \ >} while (0) > >#define LOCKSTAT_RECORD(probe, lp, arg1) \ > LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) > >#define LOCKSTAT_RECORD0(probe, lp) \ > LOCKSTAT_RECORD4(probe, lp, 0, 0, 0, 0) > >#define LOCKSTAT_RECORD1(probe, lp, arg1) \ > LOCKSTAT_RECORD4(probe, lp, arg1, 0, 0, 0) > >#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) \ > LOCKSTAT_RECORD4(probe, lp, arg1, arg2, 0, 0) > >#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) \ > LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, 0) > >#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) do { \ > uint32_t id; \ > \ > lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l); \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ >} while (0) > >#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) do { \ > uint32_t id; \ > \ > lock_profile_release_lock(&(lp)->lock_object); \ > if ((id = lockstat_probemap[(probe)])) \ > (*lockstat_probe_func)(id, (uintptr_t)(lp), 0, 0, 0, 0); \ >} while (0) > >#else /* !KDTRACE_HOOKS */ ># 202 "/usr/src/ifnet/sys/sys/lockstat.h" > >#define LOCKSTAT_RECORD(probe, lp, arg1) >#define LOCKSTAT_RECORD0(probe, lp) >#define LOCKSTAT_RECORD1(probe, lp, arg1) >#define LOCKSTAT_RECORD2(probe, lp, arg1, arg2) >#define LOCKSTAT_RECORD3(probe, lp, arg1, arg2, arg3) >#define LOCKSTAT_RECORD4(probe, lp, arg1, arg2, arg3, arg4) > >#define LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(probe, lp, c, wt, f, l) \ > lock_profile_obtain_lock_success(&(lp)->lock_object, c, wt, f, l) > >#define LOCKSTAT_PROFILE_RELEASE_LOCK(probe, lp) \ > lock_profile_release_lock(&(lp)->lock_object) > >#endif /* !KDTRACE_HOOKS */ ># 217 "/usr/src/ifnet/sys/sys/lockstat.h" > >#endif /* _KERNEL */ ># 219 "/usr/src/ifnet/sys/sys/lockstat.h" > >#endif /* _SYS_LOCKSTAT_H */ ># 221 "/usr/src/ifnet/sys/sys/lockstat.h" ># 43 "/usr/src/ifnet/sys/sys/mutex.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 43 "/usr/src/ifnet/sys/sys/mutex.h" ># 44 "/usr/src/ifnet/sys/sys/mutex.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/cpufunc.h> >#endif /* expanded by -frewrite-includes */ ># 44 "/usr/src/ifnet/sys/sys/mutex.h" ># 45 "/usr/src/ifnet/sys/sys/mutex.h" > >/* > * Mutex types and options passed to mtx_init(). MTX_QUIET and MTX_DUPOK > * can also be passed in. > */ >#define MTX_DEF 0x00000000 /* DEFAULT (sleep) lock */ >#define MTX_SPIN 0x00000001 /* Spin lock (disables interrupts) */ >#define MTX_RECURSE 0x00000004 /* Option: lock allowed to recurse */ >#define MTX_NOWITNESS 0x00000008 /* Don't do any witness checking. */ >#define MTX_NOPROFILE 0x00000020 /* Don't profile this lock */ >#define MTX_NEW 0x00000040 /* Don't check for double-init */ > >/* > * Option flags passed to certain lock/unlock routines, through the use > * of corresponding mtx_{lock,unlock}_flags() interface macros. > */ >#define MTX_QUIET LOP_QUIET /* Don't log a mutex event */ >#define MTX_DUPOK LOP_DUPOK /* Don't log a duplicate acquire */ > >/* > * State bits kept in mutex->mtx_lock, for the DEFAULT lock type. None of this, > * with the exception of MTX_UNOWNED, applies to spin locks. > */ >#define MTX_RECURSED 0x00000001 /* lock recursed (for MTX_DEF only) */ >#define MTX_CONTESTED 0x00000002 /* lock contested (for MTX_DEF only) */ >#define MTX_UNOWNED 0x00000004 /* Cookie for free mutex */ >#define MTX_FLAGMASK (MTX_RECURSED | MTX_CONTESTED | MTX_UNOWNED) > >/* > * Value stored in mutex->mtx_lock to denote a destroyed mutex. > */ >#define MTX_DESTROYED (MTX_CONTESTED | MTX_UNOWNED) > >/* > * Prototypes > * > * NOTE: Functions prepended with `_' (underscore) are exported to other parts > * of the kernel via macros, thus allowing us to use the cpp LOCK_FILE > * and LOCK_LINE or for hiding the lock cookie crunching to the > * consumers. These functions should not be called directly by any > * code using the API. Their macros cover their functionality. > * Functions with a `_' suffix are the entrypoint for the common > * KPI covering both compat shims and fast path case. These can be > * used by consumers willing to pass options, file and line > * informations, in an option-independent way. > * > * [See below for descriptions] > * > */ >void _mtx_init(volatile uintptr_t *c, const char *name, const char *type, > int opts); >void _mtx_destroy(volatile uintptr_t *c); >void mtx_sysinit(void *arg); >int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file, > int line); >void mutex_init(void); >void __mtx_lock_sleep(volatile uintptr_t *c, uintptr_t tid, int opts, > const char *file, int line); >void __mtx_unlock_sleep(volatile uintptr_t *c, int opts, const char *file, > int line); >#ifdef SMP >void _mtx_lock_spin_cookie(volatile uintptr_t *c, uintptr_t tid, int opts, > const char *file, int line); >#endif ># 109 "/usr/src/ifnet/sys/sys/mutex.h" >void __mtx_lock_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_unlock_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_lock_spin_flags(volatile uintptr_t *c, int opts, const char *file, > int line); >void __mtx_unlock_spin_flags(volatile uintptr_t *c, int opts, > const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void __mtx_assert(const volatile uintptr_t *c, int what, const char *file, > int line); >#endif ># 121 "/usr/src/ifnet/sys/sys/mutex.h" >void thread_lock_flags_(struct thread *, int, const char *, int); > >#define thread_lock(tdp) \ > thread_lock_flags_((tdp), 0, __FILE__, __LINE__) >#define thread_lock_flags(tdp, opt) \ > thread_lock_flags_((tdp), (opt), __FILE__, __LINE__) >#define thread_unlock(tdp) \ > mtx_unlock_spin((tdp)->td_lock) > >/* > * Top-level macros to provide lock cookie once the actual mtx is passed. > * They will also prevent passing a malformed object to the mtx KPI by > * failing compilation as the mtx_lock reserved member will not be found. > */ >#define mtx_init(m, n, t, o) \ > _mtx_init(&(m)->mtx_lock, n, t, o) >#define mtx_destroy(m) \ > _mtx_destroy(&(m)->mtx_lock) >#define mtx_trylock_flags_(m, o, f, l) \ > _mtx_trylock_flags_(&(m)->mtx_lock, o, f, l) >#define _mtx_lock_sleep(m, t, o, f, l) \ > __mtx_lock_sleep(&(m)->mtx_lock, t, o, f, l) >#define _mtx_unlock_sleep(m, o, f, l) \ > __mtx_unlock_sleep(&(m)->mtx_lock, o, f, l) >#ifdef SMP >#define _mtx_lock_spin(m, t, o, f, l) \ > _mtx_lock_spin_cookie(&(m)->mtx_lock, t, o, f, l) >#endif ># 149 "/usr/src/ifnet/sys/sys/mutex.h" >#define _mtx_lock_flags(m, o, f, l) \ > __mtx_lock_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_unlock_flags(m, o, f, l) \ > __mtx_unlock_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_lock_spin_flags(m, o, f, l) \ > __mtx_lock_spin_flags(&(m)->mtx_lock, o, f, l) >#define _mtx_unlock_spin_flags(m, o, f, l) \ > __mtx_unlock_spin_flags(&(m)->mtx_lock, o, f, l) >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define _mtx_assert(m, w, f, l) \ > __mtx_assert(&(m)->mtx_lock, w, f, l) >#endif ># 161 "/usr/src/ifnet/sys/sys/mutex.h" > >#define mtx_recurse lock_object.lo_data > >/* Very simple operations on mtx_lock. */ > >/* Try to obtain mtx_lock once. */ >#define _mtx_obtain_lock(mp, tid) \ > atomic_cmpset_acq_ptr(&(mp)->mtx_lock, MTX_UNOWNED, (tid)) > >/* Try to release mtx_lock if it is unrecursed and uncontested. */ >#define _mtx_release_lock(mp, tid) \ > atomic_cmpset_rel_ptr(&(mp)->mtx_lock, (tid), MTX_UNOWNED) > >/* Release mtx_lock quickly, assuming we own it. */ >#define _mtx_release_lock_quick(mp) \ > atomic_store_rel_ptr(&(mp)->mtx_lock, MTX_UNOWNED) > >/* > * Full lock operations that are suitable to be inlined in non-debug > * kernels. If the lock cannot be acquired or released trivially then > * the work is deferred to another function. > */ > >/* Lock a normal mutex. */ >#define __mtx_lock(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if (!_mtx_obtain_lock((mp), _tid)) \ > _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ > else \ > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_LOCK_ACQUIRE, \ > mp, 0, 0, (file), (line)); \ >} while (0) > >/* > * Lock a spin mutex. For spinlocks, we handle recursion inline (it > * turns out that function calls can be significantly expensive on > * some architectures). Since spin locks are not _too_ common, > * inlining this code is not too big a deal. > */ >#ifdef SMP >#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > spinlock_enter(); \ > if (!_mtx_obtain_lock((mp), _tid)) { \ > if ((mp)->mtx_lock == _tid) \ > (mp)->mtx_recurse++; \ > else \ > _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ > } else \ > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, \ > mp, 0, 0, (file), (line)); \ >} while (0) >#else /* SMP */ ># 216 "/usr/src/ifnet/sys/sys/mutex.h" >#define __mtx_lock_spin(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > spinlock_enter(); \ > if ((mp)->mtx_lock == _tid) \ > (mp)->mtx_recurse++; \ > else { \ > KASSERT((mp)->mtx_lock == MTX_UNOWNED, ("corrupt spinlock")); \ > (mp)->mtx_lock = _tid; \ > } \ >} while (0) >#endif /* SMP */ ># 228 "/usr/src/ifnet/sys/sys/mutex.h" > >/* Unlock a normal mutex. */ >#define __mtx_unlock(mp, tid, opts, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if ((mp)->mtx_recurse == 0) \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_UNLOCK_RELEASE, \ > (mp)); \ > if (!_mtx_release_lock((mp), _tid)) \ > _mtx_unlock_sleep((mp), (opts), (file), (line)); \ >} while (0) > >/* > * Unlock a spin mutex. For spinlocks, we can handle everything > * inline, as it's pretty simple and a function call would be too > * expensive (at least on some architectures). Since spin locks are > * not _too_ common, inlining this code is not too big a deal. > * > * Since we always perform a spinlock_enter() when attempting to acquire a > * spin lock, we need to always perform a matching spinlock_exit() when > * releasing a spin lock. This includes the recursion cases. > */ >#ifdef SMP >#define __mtx_unlock_spin(mp) do { \ > if (mtx_recursed((mp))) \ > (mp)->mtx_recurse--; \ > else { \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ > mp); \ > _mtx_release_lock_quick((mp)); \ > } \ > spinlock_exit(); \ >} while (0) >#else /* SMP */ ># 262 "/usr/src/ifnet/sys/sys/mutex.h" >#define __mtx_unlock_spin(mp) do { \ > if (mtx_recursed((mp))) \ > (mp)->mtx_recurse--; \ > else { \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_MTX_SPIN_UNLOCK_RELEASE, \ > mp); \ > (mp)->mtx_lock = MTX_UNOWNED; \ > } \ > spinlock_exit(); \ >} while (0) >#endif /* SMP */ ># 273 "/usr/src/ifnet/sys/sys/mutex.h" > >/* > * Exported lock manipulation interface. > * > * mtx_lock(m) locks MTX_DEF mutex `m' > * > * mtx_lock_spin(m) locks MTX_SPIN mutex `m' > * > * mtx_unlock(m) unlocks MTX_DEF mutex `m' > * > * mtx_unlock_spin(m) unlocks MTX_SPIN mutex `m' > * > * mtx_lock_spin_flags(m, opts) and mtx_lock_flags(m, opts) locks mutex `m' > * and passes option flags `opts' to the "hard" function, if required. > * With these routines, it is possible to pass flags such as MTX_QUIET > * to the appropriate lock manipulation routines. > * > * mtx_trylock(m) attempts to acquire MTX_DEF mutex `m' but doesn't sleep if > * it cannot. Rather, it returns 0 on failure and non-zero on success. > * It does NOT handle recursion as we assume that if a caller is properly > * using this part of the interface, he will know that the lock in question > * is _not_ recursed. > * > * mtx_trylock_flags(m, opts) is used the same way as mtx_trylock() but accepts > * relevant option flags `opts.' > * > * mtx_initialized(m) returns non-zero if the lock `m' has been initialized. > * > * mtx_owned(m) returns non-zero if the current thread owns the lock `m' > * > * mtx_recursed(m) returns non-zero if the lock `m' is presently recursed. > */ >#define mtx_lock(m) mtx_lock_flags((m), 0) >#define mtx_lock_spin(m) mtx_lock_spin_flags((m), 0) >#define mtx_trylock(m) mtx_trylock_flags((m), 0) >#define mtx_unlock(m) mtx_unlock_flags((m), 0) >#define mtx_unlock_spin(m) mtx_unlock_spin_flags((m), 0) > >struct mtx_pool; > >struct mtx_pool *mtx_pool_create(const char *mtx_name, int pool_size, int opts); >void mtx_pool_destroy(struct mtx_pool **poolp); >struct mtx *mtx_pool_find(struct mtx_pool *pool, void *ptr); >struct mtx *mtx_pool_alloc(struct mtx_pool *pool); >#define mtx_pool_lock(pool, ptr) \ > mtx_lock(mtx_pool_find((pool), (ptr))) >#define mtx_pool_lock_spin(pool, ptr) \ > mtx_lock_spin(mtx_pool_find((pool), (ptr))) >#define mtx_pool_unlock(pool, ptr) \ > mtx_unlock(mtx_pool_find((pool), (ptr))) >#define mtx_pool_unlock_spin(pool, ptr) \ > mtx_unlock_spin(mtx_pool_find((pool), (ptr))) > >/* > * mtxpool_sleep is a general purpose pool of sleep mutexes. > */ >extern struct mtx_pool *mtxpool_sleep; > >#ifndef LOCK_DEBUG >#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/mutex.h> >#endif ># 334 "/usr/src/ifnet/sys/sys/mutex.h" >#if LOCK_DEBUG > 0 || defined(MUTEX_NOINLINE) >#define mtx_lock_flags_(m, opts, file, line) \ > _mtx_lock_flags((m), (opts), (file), (line)) >#define mtx_unlock_flags_(m, opts, file, line) \ > _mtx_unlock_flags((m), (opts), (file), (line)) >#define mtx_lock_spin_flags_(m, opts, file, line) \ > _mtx_lock_spin_flags((m), (opts), (file), (line)) >#define mtx_unlock_spin_flags_(m, opts, file, line) \ > _mtx_unlock_spin_flags((m), (opts), (file), (line)) >#else /* LOCK_DEBUG == 0 && !MUTEX_NOINLINE */ ># 344 "/usr/src/ifnet/sys/sys/mutex.h" >#define mtx_lock_flags_(m, opts, file, line) \ > __mtx_lock((m), curthread, (opts), (file), (line)) >#define mtx_unlock_flags_(m, opts, file, line) \ > __mtx_unlock((m), curthread, (opts), (file), (line)) >#define mtx_lock_spin_flags_(m, opts, file, line) \ > __mtx_lock_spin((m), curthread, (opts), (file), (line)) >#define mtx_unlock_spin_flags_(m, opts, file, line) \ > __mtx_unlock_spin((m)) >#endif /* LOCK_DEBUG > 0 || MUTEX_NOINLINE */ ># 353 "/usr/src/ifnet/sys/sys/mutex.h" > >#ifdef INVARIANTS >#define mtx_assert_(m, what, file, line) \ > _mtx_assert((m), (what), (file), (line)) > >#define GIANT_REQUIRED mtx_assert_(&Giant, MA_OWNED, __FILE__, __LINE__) > >#else /* INVARIANTS */ ># 361 "/usr/src/ifnet/sys/sys/mutex.h" >#define mtx_assert_(m, what, file, line) (void)0 >#define GIANT_REQUIRED >#endif /* INVARIANTS */ ># 364 "/usr/src/ifnet/sys/sys/mutex.h" > >#define mtx_lock_flags(m, opts) \ > mtx_lock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_unlock_flags(m, opts) \ > mtx_unlock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_lock_spin_flags(m, opts) \ > mtx_lock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_unlock_spin_flags(m, opts) \ > mtx_unlock_spin_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_trylock_flags(m, opts) \ > mtx_trylock_flags_((m), (opts), LOCK_FILE, LOCK_LINE) >#define mtx_assert(m, what) \ > mtx_assert_((m), (what), __FILE__, __LINE__) > >#define mtx_sleep(chan, mtx, pri, wmesg, timo) \ > _sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) > >#define mtx_initialized(m) lock_initialized(&(m)->lock_object) > >#define mtx_owned(m) (((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread) > >#define mtx_recursed(m) ((m)->mtx_recurse != 0) > >#define mtx_name(m) ((m)->lock_object.lo_name) > >/* > * Global locks. > */ >extern struct mtx Giant; >extern struct mtx blocked_lock; > >/* > * Giant lock manipulation and clean exit macros. > * Used to replace return with an exit Giant and return. > * > * Note that DROP_GIANT*() needs to be paired with PICKUP_GIANT() > * The #ifndef is to allow lint-like tools to redefine DROP_GIANT. > */ >#ifndef DROP_GIANT >#define DROP_GIANT() \ >do { \ > int _giantcnt = 0; \ > WITNESS_SAVE_DECL(Giant); \ > \ > if (mtx_owned(&Giant)) { \ > WITNESS_SAVE(&Giant.lock_object, Giant); \ > for (_giantcnt = 0; mtx_owned(&Giant) && \ > !SCHEDULER_STOPPED(); _giantcnt++) \ > mtx_unlock(&Giant); \ > } > >#define PICKUP_GIANT() \ > PARTIAL_PICKUP_GIANT(); \ >} while (0) > >#define PARTIAL_PICKUP_GIANT() \ > mtx_assert(&Giant, MA_NOTOWNED); \ > if (_giantcnt > 0) { \ > while (_giantcnt--) \ > mtx_lock(&Giant); \ > WITNESS_RESTORE(&Giant.lock_object, Giant); \ > } >#endif ># 428 "/usr/src/ifnet/sys/sys/mutex.h" > >struct mtx_args { > void *ma_mtx; > const char *ma_desc; > int ma_opts; >}; > >#define MTX_SYSINIT(name, mtx, desc, opts) \ > static struct mtx_args name##_args = { \ > (mtx), \ > (desc), \ > (opts) \ > }; \ > SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > mtx_sysinit, &name##_args); \ > SYSUNINIT(name##_mtx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > _mtx_destroy, __DEVOLATILE(void *, &(mtx)->mtx_lock)) > >/* > * The INVARIANTS-enabled mtx_assert() functionality. > * > * The constants need to be defined for INVARIANT_SUPPORT infrastructure > * support as _mtx_assert() itself uses them and the latter implies that > * _mtx_assert() must build. > */ >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define MA_OWNED LA_XLOCKED >#define MA_NOTOWNED LA_UNLOCKED >#define MA_RECURSED LA_RECURSED >#define MA_NOTRECURSED LA_NOTRECURSED >#endif ># 459 "/usr/src/ifnet/sys/sys/mutex.h" > >/* > * Common lock type names. > */ >#define MTX_NETWORK_LOCK "network driver" > >#endif /* _KERNEL */ ># 466 "/usr/src/ifnet/sys/sys/mutex.h" >#endif /* _SYS_MUTEX_H_ */ ># 467 "/usr/src/ifnet/sys/sys/mutex.h" ># 42 "/usr/src/ifnet/sys/sys/buf_ring.h" 2 >#endif ># 43 "/usr/src/ifnet/sys/sys/buf_ring.h" > >struct buf_ring { > volatile uint32_t br_prod_head; > volatile uint32_t br_prod_tail; > int br_prod_size; > int br_prod_mask; > uint64_t br_drops; > volatile uint32_t br_cons_head __aligned(CACHE_LINE_SIZE); > volatile uint32_t br_cons_tail; > int br_cons_size; > int br_cons_mask; >#ifdef DEBUG_BUFRING > struct mtx *br_lock; >#endif ># 57 "/usr/src/ifnet/sys/sys/buf_ring.h" > void *br_ring[0] __aligned(CACHE_LINE_SIZE); >}; > >/* > * multi-producer safe lock-free ring buffer enqueue > * > */ >static __inline int >buf_ring_enqueue(struct buf_ring *br, void *buf) >{ > uint32_t prod_head, prod_next, cons_tail; >#ifdef DEBUG_BUFRING > int i; > for (i = br->br_cons_head; i != br->br_prod_head; > i = ((i + 1) & br->br_cons_mask)) > if(br->br_ring[i] == buf) > panic("buf=%p already enqueue at %d prod=%d cons=%d", > buf, i, br->br_prod_tail, br->br_cons_tail); >#endif ># 76 "/usr/src/ifnet/sys/sys/buf_ring.h" > critical_enter(); > do { > prod_head = br->br_prod_head; > prod_next = (prod_head + 1) & br->br_prod_mask; > cons_tail = br->br_cons_tail; > > if (prod_next == cons_tail) { > rmb(); > if (prod_head == br->br_prod_head && > cons_tail == br->br_cons_tail) { > br->br_drops++; > critical_exit(); > return (ENOBUFS); > } > continue; > } > } while (!atomic_cmpset_acq_int(&br->br_prod_head, prod_head, prod_next)); >#ifdef DEBUG_BUFRING > if (br->br_ring[prod_head] != NULL) > panic("dangling value in enqueue"); >#endif ># 97 "/usr/src/ifnet/sys/sys/buf_ring.h" > br->br_ring[prod_head] = buf; > > /* > * If there are other enqueues in progress > * that preceeded us, we need to wait for them > * to complete > */ > while (br->br_prod_tail != prod_head) > cpu_spinwait(); > atomic_store_rel_int(&br->br_prod_tail, prod_next); > critical_exit(); > return (0); >} > >/* > * multi-consumer safe dequeue > * > */ >static __inline void * >buf_ring_dequeue_mc(struct buf_ring *br) >{ > uint32_t cons_head, cons_next; > void *buf; > > critical_enter(); > do { > cons_head = br->br_cons_head; > cons_next = (cons_head + 1) & br->br_cons_mask; > > if (cons_head == br->br_prod_tail) { > critical_exit(); > return (NULL); > } > } while (!atomic_cmpset_acq_int(&br->br_cons_head, cons_head, cons_next)); > > buf = br->br_ring[cons_head]; >#ifdef DEBUG_BUFRING > br->br_ring[cons_head] = NULL; >#endif ># 136 "/usr/src/ifnet/sys/sys/buf_ring.h" > /* > * If there are other dequeues in progress > * that preceeded us, we need to wait for them > * to complete > */ > while (br->br_cons_tail != cons_head) > cpu_spinwait(); > > atomic_store_rel_int(&br->br_cons_tail, cons_next); > critical_exit(); > > return (buf); >} > >/* > * single-consumer dequeue > * use where dequeue is protected by a lock > * e.g. a network driver's tx queue lock > */ >static __inline void * >buf_ring_dequeue_sc(struct buf_ring *br) >{ > uint32_t cons_head, cons_next; >#ifdef PREFETCH_DEFINED > uint32_t cons_next_next; >#endif ># 162 "/usr/src/ifnet/sys/sys/buf_ring.h" > uint32_t prod_tail; > void *buf; > > cons_head = br->br_cons_head; > prod_tail = br->br_prod_tail; > > cons_next = (cons_head + 1) & br->br_cons_mask; >#ifdef PREFETCH_DEFINED > cons_next_next = (cons_head + 2) & br->br_cons_mask; >#endif ># 172 "/usr/src/ifnet/sys/sys/buf_ring.h" > > if (cons_head == prod_tail) > return (NULL); > >#ifdef PREFETCH_DEFINED > if (cons_next != prod_tail) { > prefetch(br->br_ring[cons_next]); > if (cons_next_next != prod_tail) > prefetch(br->br_ring[cons_next_next]); > } >#endif ># 183 "/usr/src/ifnet/sys/sys/buf_ring.h" > br->br_cons_head = cons_next; > buf = br->br_ring[cons_head]; > >#ifdef DEBUG_BUFRING > br->br_ring[cons_head] = NULL; > if (!mtx_owned(br->br_lock)) > panic("lock not held on single consumer dequeue"); > if (br->br_cons_tail != cons_head) > panic("inconsistent list cons_tail=%d cons_head=%d", > br->br_cons_tail, cons_head); >#endif ># 194 "/usr/src/ifnet/sys/sys/buf_ring.h" > br->br_cons_tail = cons_next; > return (buf); >} > >/* > * single-consumer advance after a peek > * use where it is protected by a lock > * e.g. a network driver's tx queue lock > */ >static __inline void >buf_ring_advance_sc(struct buf_ring *br) >{ > uint32_t cons_head, cons_next; > uint32_t prod_tail; > > cons_head = br->br_cons_head; > prod_tail = br->br_prod_tail; > > cons_next = (cons_head + 1) & br->br_cons_mask; > if (cons_head == prod_tail) > return; > br->br_cons_head = cons_next; >#ifdef DEBUG_BUFRING > br->br_ring[cons_head] = NULL; >#endif ># 219 "/usr/src/ifnet/sys/sys/buf_ring.h" > br->br_cons_tail = cons_next; >} > >/* > * Used to return a buffer (most likely already there) > * to the top od the ring. The caller should *not* > * have used any dequeue to pull it out of the ring > * but instead should have used the peek() function. > * This is normally used where the transmit queue > * of a driver is full, and an mubf must be returned. > * Most likely whats in the ring-buffer is what > * is being put back (since it was not removed), but > * sometimes the lower transmit function may have > * done a pullup or other function that will have > * changed it. As an optimzation we always put it > * back (since jhb says the store is probably cheaper), > * if we have to do a multi-queue version we will need > * the compare and an atomic. > */ >static __inline void >buf_ring_putback_sc(struct buf_ring *br, void *new) >{ > KASSERT(br->br_cons_head != br->br_prod_tail, > ("Buf-Ring has none in putback")) ; > br->br_ring[br->br_cons_head] = new; >} > >/* > * return a pointer to the first entry in the ring > * without modifying it, or NULL if the ring is empty > * race-prone if not protected by a lock > */ >static __inline void * >buf_ring_peek(struct buf_ring *br) >{ > >#ifdef DEBUG_BUFRING > if ((br->br_lock != NULL) && !mtx_owned(br->br_lock)) > panic("lock not held on single consumer dequeue"); >#endif ># 259 "/usr/src/ifnet/sys/sys/buf_ring.h" > /* > * I believe it is safe to not have a memory barrier > * here because we control cons and tail is worst case > * a lagging indicator so we worst case we might > * return NULL immediately after a buffer has been enqueued > */ > if (br->br_cons_head == br->br_prod_tail) > return (NULL); > > return (br->br_ring[br->br_cons_head]); >} > >static __inline int >buf_ring_full(struct buf_ring *br) >{ > > return (((br->br_prod_head + 1) & br->br_prod_mask) == br->br_cons_tail); >} > >static __inline int >buf_ring_empty(struct buf_ring *br) >{ > > return (br->br_cons_head == br->br_prod_tail); >} > >static __inline int >buf_ring_count(struct buf_ring *br) >{ > > return ((br->br_prod_size + br->br_prod_tail - br->br_cons_tail) > & br->br_prod_mask); >} > >struct buf_ring *buf_ring_alloc(int count, struct malloc_type *type, int flags, > struct mtx *); >void buf_ring_free(struct buf_ring *br, struct malloc_type *type); > > > >#endif ># 300 "/usr/src/ifnet/sys/sys/buf_ring.h" ># 51 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <net/vnet.h> >#endif /* expanded by -frewrite-includes */ ># 51 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/net/vnet.h" 1 >/*- > * Copyright (c) 2006-2009 University of Zagreb > * Copyright (c) 2006-2009 FreeBSD Foundation > * All rights reserved. > * > * This software was developed by the University of Zagreb and the > * FreeBSD Foundation under sponsorship by the Stichting NLnet and the > * FreeBSD Foundation. > * > * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org> > * Copyright (c) 2009 Robert N. M. Watson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/net/vnet.h 274229 2014-11-07 12:00:32Z glebius $ > */ > >/*- > * This header file defines several sets of interfaces supporting virtualized > * network stacks: > * > * - Definition of 'struct vnet' and functions and macros to allocate/free/ > * manipulate it. > * > * - A virtual network stack memory allocator, which provides support for > * virtualized global variables via a special linker set, set_vnet. > * > * - Virtualized sysinits/sysuninits, which allow constructors and > * destructors to be run for each network stack subsystem as virtual > * instances are created and destroyed. > * > * If VIMAGE isn't compiled into the kernel, virtualized global variables > * compile to normal global variables, and virtualized sysinits to regular > * sysinits. > */ > >#ifndef _NET_VNET_H_ >#define _NET_VNET_H_ > >/* > * struct vnet describes a virtualized network stack, and is primarily a > * pointer to storage for virtualized global variables. Expose to userspace > * as required for libkvm. > */ >#if defined(_KERNEL) || defined(_WANT_VNET) >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 66 "/usr/src/ifnet/sys/net/vnet.h" ># 67 "/usr/src/ifnet/sys/net/vnet.h" > >struct vnet { > LIST_ENTRY(vnet) vnet_le; /* all vnets list */ > u_int vnet_magic_n; > u_int vnet_ifcnt; > u_int vnet_sockcnt; > void *vnet_data_mem; > uintptr_t vnet_data_base; >}; >#define VNET_MAGIC_N 0x3e0d8f29 > >/* > * These two virtual network stack allocator definitions are also required > * for libkvm so that it can evaluate virtualized global variables. > */ >#define VNET_SETNAME "set_vnet" >#define VNET_SYMPREFIX "vnet_entry_" >#endif ># 85 "/usr/src/ifnet/sys/net/vnet.h" > >#ifdef _KERNEL > >#define VNET_PCPUSTAT_DECLARE(type, name) \ > VNET_DECLARE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)]) > >#define VNET_PCPUSTAT_DEFINE(type, name) \ > VNET_DEFINE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)]) > >#define VNET_PCPUSTAT_ALLOC(name, wait) \ > COUNTER_ARRAY_ALLOC(VNET(name), \ > sizeof(VNET(name)) / sizeof(counter_u64_t), (wait)) > >#define VNET_PCPUSTAT_FREE(name) \ > COUNTER_ARRAY_FREE(VNET(name), sizeof(VNET(name)) / sizeof(counter_u64_t)) > >#define VNET_PCPUSTAT_ADD(type, name, f, v) \ > counter_u64_add(VNET(name)[offsetof(type, f) / sizeof(uint64_t)], (v)) > >#define VNET_PCPUSTAT_SYSINIT(name) \ >static void \ >vnet_##name##_init(const void *unused) \ >{ \ > VNET_PCPUSTAT_ALLOC(name, M_WAITOK); \ >} \ >VNET_SYSINIT(vnet_ ## name ## _init, SI_SUB_PROTO_IFATTACHDOMAIN, \ > SI_ORDER_ANY, vnet_ ## name ## _init, NULL) > >#define VNET_PCPUSTAT_SYSUNINIT(name) \ >static void \ >vnet_##name##_uninit(const void *unused) \ >{ \ > VNET_PCPUSTAT_FREE(name); \ >} \ >VNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_PROTO_IFATTACHDOMAIN, \ > SI_ORDER_ANY, vnet_ ## name ## _uninit, NULL) > >#ifdef SYSCTL_OID >#define SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc) \ >static int \ >array##_sysctl(SYSCTL_HANDLER_ARGS) \ >{ \ > type s; \ > CTASSERT((sizeof(type) / sizeof(uint64_t)) == \ > (sizeof(VNET(array)) / sizeof(counter_u64_t))); \ > COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\ > if (req->newptr) \ > COUNTER_ARRAY_ZERO(VNET(array), \ > sizeof(type) / sizeof(uint64_t)); \ > return (SYSCTL_OUT(req, &s, sizeof(type))); \ >} \ >SYSCTL_PROC(parent, nbr, name, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RW, \ > NULL, 0, array ## _sysctl, "I", desc) >#endif /* SYSCTL_OID */ ># 139 "/usr/src/ifnet/sys/net/vnet.h" > >#ifdef VIMAGE >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> >#endif /* expanded by -frewrite-includes */ ># 141 "/usr/src/ifnet/sys/net/vnet.h" ># 142 "/usr/src/ifnet/sys/net/vnet.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/proc.h> /* for struct thread */ >#endif /* expanded by -frewrite-includes */ ># 142 "/usr/src/ifnet/sys/net/vnet.h" ># 143 "/usr/src/ifnet/sys/net/vnet.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/rwlock.h> >#endif /* expanded by -frewrite-includes */ ># 143 "/usr/src/ifnet/sys/net/vnet.h" ># 144 "/usr/src/ifnet/sys/net/vnet.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sx.h> >#endif /* expanded by -frewrite-includes */ ># 144 "/usr/src/ifnet/sys/net/vnet.h" ># 145 "/usr/src/ifnet/sys/net/vnet.h" > >/* > * Location of the kernel's 'set_vnet' linker set. > */ >extern uintptr_t *__start_set_vnet; >__GLOBL(__start_set_vnet); >extern uintptr_t *__stop_set_vnet; >__GLOBL(__stop_set_vnet); > >#define VNET_START (uintptr_t)&__start_set_vnet >#define VNET_STOP (uintptr_t)&__stop_set_vnet > >/* > * Functions to allocate and destroy virtual network stacks. > */ >struct vnet *vnet_alloc(void); >void vnet_destroy(struct vnet *vnet); > >/* > * The current virtual network stack -- we may wish to move this to struct > * pcpu in the future. > */ >#define curvnet curthread->td_vnet > >/* > * Various macros -- get and set the current network stack, but also > * assertions. > */ >#if defined(INVARIANTS) || defined(VNET_DEBUG) >#define VNET_ASSERT(exp, msg) do { \ > if (!(exp)) \ > panic msg; \ >} while (0) >#else ># 179 "/usr/src/ifnet/sys/net/vnet.h" >#define VNET_ASSERT(exp, msg) do { \ >} while (0) >#endif ># 182 "/usr/src/ifnet/sys/net/vnet.h" > >#ifdef VNET_DEBUG >void vnet_log_recursion(struct vnet *, const char *, int); > >#define CURVNET_SET_QUIET(arg) \ > VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \ > ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p", \ > __FILE__, __LINE__, __func__, curvnet, (arg))); \ > struct vnet *saved_vnet = curvnet; \ > const char *saved_vnet_lpush = curthread->td_vnet_lpush; \ > curvnet = arg; \ > curthread->td_vnet_lpush = __func__; > >#define CURVNET_SET_VERBOSE(arg) \ > CURVNET_SET_QUIET(arg) \ > if (saved_vnet) \ > vnet_log_recursion(saved_vnet, saved_vnet_lpush, __LINE__); > >#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) > >#define CURVNET_RESTORE() \ > VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL || \ > saved_vnet->vnet_magic_n == VNET_MAGIC_N), \ > ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p", \ > __FILE__, __LINE__, __func__, curvnet, saved_vnet)); \ > curvnet = saved_vnet; \ > curthread->td_vnet_lpush = saved_vnet_lpush; >#else /* !VNET_DEBUG */ ># 210 "/usr/src/ifnet/sys/net/vnet.h" > >#define CURVNET_SET_QUIET(arg) \ > VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \ > ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p", \ > __FILE__, __LINE__, __func__, curvnet, (arg))); \ > struct vnet *saved_vnet = curvnet; \ > curvnet = arg; > >#define CURVNET_SET_VERBOSE(arg) \ > CURVNET_SET_QUIET(arg) > >#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) > >#define CURVNET_RESTORE() \ > VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL || \ > saved_vnet->vnet_magic_n == VNET_MAGIC_N), \ > ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p", \ > __FILE__, __LINE__, __func__, curvnet, saved_vnet)); \ > curvnet = saved_vnet; >#endif /* VNET_DEBUG */ ># 230 "/usr/src/ifnet/sys/net/vnet.h" > >extern struct vnet *vnet0; >#define IS_DEFAULT_VNET(arg) ((arg) == vnet0) > >#define CRED_TO_VNET(cr) (cr)->cr_prison->pr_vnet >#define TD_TO_VNET(td) CRED_TO_VNET((td)->td_ucred) >#define P_TO_VNET(p) CRED_TO_VNET((p)->p_ucred) > >/* > * Global linked list of all virtual network stacks, along with read locks to > * access it. If a caller may sleep while accessing the list, it must use > * the sleepable lock macros. > */ >LIST_HEAD(vnet_list_head, vnet); >extern struct vnet_list_head vnet_head; >extern struct rwlock vnet_rwlock; >extern struct sx vnet_sxlock; > >#define VNET_LIST_RLOCK() sx_slock(&vnet_sxlock) >#define VNET_LIST_RLOCK_NOSLEEP() rw_rlock(&vnet_rwlock) >#define VNET_LIST_RUNLOCK() sx_sunlock(&vnet_sxlock) >#define VNET_LIST_RUNLOCK_NOSLEEP() rw_runlock(&vnet_rwlock) > >/* > * Iteration macros to walk the global list of virtual network stacks. > */ >#define VNET_ITERATOR_DECL(arg) struct vnet *arg >#define VNET_FOREACH(arg) LIST_FOREACH((arg), &vnet_head, vnet_le) > >/* > * Virtual network stack memory allocator, which allows global variables to > * be automatically instantiated for each network stack instance. > */ >#define VNET_NAME(n) vnet_entry_##n >#define VNET_DECLARE(t, n) extern t VNET_NAME(n) >#define VNET_DEFINE(t, n) t VNET_NAME(n) __section(VNET_SETNAME) __used >#define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \ > ((b) + (uintptr_t)&VNET_NAME(n)) > >#define _VNET(b, n) (*_VNET_PTR(b, n)) > >/* > * Virtualized global variable accessor macros. > */ >#define VNET_VNET_PTR(vnet, n) _VNET_PTR((vnet)->vnet_data_base, n) >#define VNET_VNET(vnet, n) (*VNET_VNET_PTR((vnet), n)) > >#define VNET_PTR(n) VNET_VNET_PTR(curvnet, n) >#define VNET(n) VNET_VNET(curvnet, n) > >/* > * Virtual network stack allocator interfaces from the kernel linker. > */ >void *vnet_data_alloc(int size); >void vnet_data_copy(void *start, int size); >void vnet_data_free(void *start_arg, int size); > >/* > * Virtual sysinit mechanism, allowing network stack components to declare > * startup and shutdown methods to be run when virtual network stack > * instances are created and destroyed. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/kernel.h> >#endif /* expanded by -frewrite-includes */ ># 292 "/usr/src/ifnet/sys/net/vnet.h" ># 293 "/usr/src/ifnet/sys/net/vnet.h" > >/* > * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and > * destructors. > */ >struct vnet_sysinit { > enum sysinit_sub_id subsystem; > enum sysinit_elem_order order; > sysinit_cfunc_t func; > const void *arg; > TAILQ_ENTRY(vnet_sysinit) link; >}; > >#define VNET_SYSINIT(ident, subsystem, order, func, arg) \ > static struct vnet_sysinit ident ## _vnet_init = { \ > subsystem, \ > order, \ > (sysinit_cfunc_t)(sysinit_nfunc_t)func, \ > (arg) \ > }; \ > SYSINIT(vnet_init_ ## ident, subsystem, order, \ > vnet_register_sysinit, &ident ## _vnet_init); \ > SYSUNINIT(vnet_init_ ## ident, subsystem, order, \ > vnet_deregister_sysinit, &ident ## _vnet_init) > >#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ > static struct vnet_sysinit ident ## _vnet_uninit = { \ > subsystem, \ > order, \ > (sysinit_cfunc_t)(sysinit_nfunc_t)func, \ > (arg) \ > }; \ > SYSINIT(vnet_uninit_ ## ident, subsystem, order, \ > vnet_register_sysuninit, &ident ## _vnet_uninit); \ > SYSUNINIT(vnet_uninit_ ## ident, subsystem, order, \ > vnet_deregister_sysuninit, &ident ## _vnet_uninit) > >/* > * Run per-vnet sysinits or sysuninits during vnet creation/destruction. > */ >void vnet_sysinit(void); >void vnet_sysuninit(void); > >/* > * Interfaces for managing per-vnet constructors and destructors. > */ >void vnet_register_sysinit(void *arg); >void vnet_register_sysuninit(void *arg); >void vnet_deregister_sysinit(void *arg); >void vnet_deregister_sysuninit(void *arg); > >/* > * EVENTHANDLER(9) extensions. > */ >#if 0 /* expanded by -frewrite-includes */ >#include <sys/eventhandler.h> >#endif /* expanded by -frewrite-includes */ ># 347 "/usr/src/ifnet/sys/net/vnet.h" ># 348 "/usr/src/ifnet/sys/net/vnet.h" > >void vnet_global_eventhandler_iterator_func(void *, ...); >#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ >do { \ > if (IS_DEFAULT_VNET(curvnet)) { \ > (tag) = vimage_eventhandler_register(NULL, #name, func, \ > arg, priority, \ > vnet_global_eventhandler_iterator_func); \ > } \ >} while(0) >#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \ >do { \ > if (IS_DEFAULT_VNET(curvnet)) { \ > vimage_eventhandler_register(NULL, #name, func, \ > arg, priority, \ > vnet_global_eventhandler_iterator_func); \ > } \ >} while(0) > >#else /* !VIMAGE */ ># 368 "/usr/src/ifnet/sys/net/vnet.h" > >/* > * Various virtual network stack macros compile to no-ops without VIMAGE. > */ >#define curvnet NULL > >#define VNET_ASSERT(exp, msg) >#define CURVNET_SET(arg) >#define CURVNET_SET_QUIET(arg) >#define CURVNET_RESTORE() > >#define VNET_LIST_RLOCK() >#define VNET_LIST_RLOCK_NOSLEEP() >#define VNET_LIST_RUNLOCK() >#define VNET_LIST_RUNLOCK_NOSLEEP() >#define VNET_ITERATOR_DECL(arg) >#define VNET_FOREACH(arg) > >#define IS_DEFAULT_VNET(arg) 1 >#define CRED_TO_VNET(cr) NULL >#define TD_TO_VNET(td) NULL >#define P_TO_VNET(p) NULL > >/* > * Versions of the VNET macros that compile to normal global variables and > * standard sysctl definitions. > */ >#define VNET_NAME(n) n >#define VNET_DECLARE(t, n) extern t n >#define VNET_DEFINE(t, n) t n >#define _VNET_PTR(b, n) &VNET_NAME(n) > >/* > * Virtualized global variable accessor macros. > */ >#define VNET_VNET_PTR(vnet, n) (&(n)) >#define VNET_VNET(vnet, n) (n) > >#define VNET_PTR(n) (&(n)) >#define VNET(n) (n) > >/* > * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT > * map into normal sysinits, which have the same ordering properties. > */ >#define VNET_SYSINIT(ident, subsystem, order, func, arg) \ > SYSINIT(ident, subsystem, order, func, arg) >#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ > SYSUNINIT(ident, subsystem, order, func, arg) > >/* > * Without VIMAGE revert to the default implementation. > */ >#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ > (tag) = eventhandler_register(NULL, #name, func, arg, priority) >#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \ > eventhandler_register(NULL, #name, func, arg, priority) >#endif /* VIMAGE */ ># 426 "/usr/src/ifnet/sys/net/vnet.h" >#endif /* _KERNEL */ ># 427 "/usr/src/ifnet/sys/net/vnet.h" > >#endif /* !_NET_VNET_H_ */ ># 429 "/usr/src/ifnet/sys/net/vnet.h" ># 52 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/counter.h> >#endif /* expanded by -frewrite-includes */ ># 52 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/counter.h" 1 >/*- > * Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/counter.h 257046 2013-10-24 10:18:08Z glebius $ > */ > >#ifndef __SYS_COUNTER_H__ >#define __SYS_COUNTER_H__ > >typedef uint64_t *counter_u64_t; > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <machine/counter.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/counter.h" ># 1 "./machine/counter.h" 1 >/*- > * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/amd64/include/counter.h 252434 2013-07-01 02:48:27Z kib $ > */ > >#ifndef __MACHINE_COUNTER_H__ >#define __MACHINE_COUNTER_H__ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 32 "./machine/counter.h" ># 33 "./machine/counter.h" > >extern struct pcpu __pcpu[1]; > >#define counter_enter() do {} while (0) >#define counter_exit() do {} while (0) > >#ifdef IN_SUBR_COUNTER_C >static inline uint64_t >counter_u64_read_one(uint64_t *p, int cpu) >{ > > return (*(uint64_t *)((char *)p + sizeof(struct pcpu) * cpu)); >} > >static inline uint64_t >counter_u64_fetch_inline(uint64_t *p) >{ > uint64_t r; > int i; > > r = 0; > for (i = 0; i < mp_ncpus; i++) > r += counter_u64_read_one((uint64_t *)p, i); > > return (r); >} > >static void >counter_u64_zero_one_cpu(void *arg) >{ > > *((uint64_t *)((char *)arg + sizeof(struct pcpu) * > PCPU_GET(cpuid))) = 0; >} > >static inline void >counter_u64_zero_inline(counter_u64_t c) >{ > > smp_rendezvous(smp_no_rendevous_barrier, counter_u64_zero_one_cpu, > smp_no_rendevous_barrier, c); >} >#endif ># 76 "./machine/counter.h" > >#define counter_u64_add_protected(c, i) counter_u64_add(c, i) > >static inline void >counter_u64_add(counter_u64_t c, int64_t inc) >{ > > __asm __volatile("addq\t%1,%%gs:(%0)" > : > : "r" ((char *)c - (char *)&__pcpu[0]), "ri" (inc) > : "memory", "cc"); >} > >#endif /* ! __MACHINE_COUNTER_H__ */ ># 90 "./machine/counter.h" ># 36 "/usr/src/ifnet/sys/sys/counter.h" 2 > >counter_u64_t counter_u64_alloc(int); >void counter_u64_free(counter_u64_t); > >void counter_u64_zero(counter_u64_t); >uint64_t counter_u64_fetch(counter_u64_t); > >#define COUNTER_ARRAY_ALLOC(a, n, wait) do { \ > for (int i = 0; i < (n); i++) \ > (a)[i] = counter_u64_alloc(wait); \ >} while (0) > >#define COUNTER_ARRAY_FREE(a, n) do { \ > for (int i = 0; i < (n); i++) \ > counter_u64_free((a)[i]); \ >} while (0) > >#define COUNTER_ARRAY_COPY(a, dstp, n) do { \ > for (int i = 0; i < (n); i++) \ > ((uint64_t *)(dstp))[i] = counter_u64_fetch((a)[i]);\ >} while (0) > >#define COUNTER_ARRAY_ZERO(a, n) do { \ > for (int i = 0; i < (n); i++) \ > counter_u64_zero((a)[i]); \ >} while (0) >#endif /* _KERNEL */ ># 63 "/usr/src/ifnet/sys/sys/counter.h" >#endif /* ! __SYS_COUNTER_H__ */ ># 64 "/usr/src/ifnet/sys/sys/counter.h" ># 53 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 53 "/usr/src/ifnet/sys/net/if_var.h" ># 54 "/usr/src/ifnet/sys/net/if_var.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> /* struct ifqueue */ >#endif /* expanded by -frewrite-includes */ ># 54 "/usr/src/ifnet/sys/net/if_var.h" ># 55 "/usr/src/ifnet/sys/net/if_var.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/rwlock.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 55 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/rwlock.h" 1 >/*- > * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/rwlock.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_RWLOCK_H_ >#define _SYS_RWLOCK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/rwlock.h" ># 33 "/usr/src/ifnet/sys/sys/rwlock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_rwlock.h> >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/ifnet/sys/sys/rwlock.h" ># 1 "/usr/src/ifnet/sys/sys/_rwlock.h" 1 >/*- > * Copyright (c) 2006 John Baldwin <jhb@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_rwlock.h 262773 2014-03-05 03:20:57Z glebius $ > */ > >#ifndef _SYS__RWLOCK_H_ >#define _SYS__RWLOCK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <machine/param.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/_rwlock.h" ># 33 "/usr/src/ifnet/sys/sys/_rwlock.h" > >/* > * Reader/writer lock. > * > * All reader/writer lock implementations must always have a member > * called rw_lock. Other locking primitive structures are not allowed to > * use this name for their members. > * If this rule needs to change, the bits in the reader/writer lock > * implementation must be modified appropriately. > */ >struct rwlock { > struct lock_object lock_object; > volatile uintptr_t rw_lock; >}; > >/* > * Members of struct rwlock_padalign must mirror members of struct rwlock. > * rwlock_padalign rwlocks can use the rwlock(9) API transparently without > * modification. > * Pad-aligned rwlocks used within structures should generally be the > * first member of the struct. Otherwise, the compiler can generate > * additional padding for the struct to keep a correct alignment for > * the rwlock. > */ >struct rwlock_padalign { > struct lock_object lock_object; > volatile uintptr_t rw_lock; >} __aligned(CACHE_LINE_SIZE); > >#endif /* !_SYS__RWLOCK_H_ */ ># 63 "/usr/src/ifnet/sys/sys/_rwlock.h" ># 34 "/usr/src/ifnet/sys/sys/rwlock.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/ifnet/sys/sys/rwlock.h" ># 35 "/usr/src/ifnet/sys/sys/rwlock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockstat.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/rwlock.h" ># 36 "/usr/src/ifnet/sys/sys/rwlock.h" > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 38 "/usr/src/ifnet/sys/sys/rwlock.h" ># 39 "/usr/src/ifnet/sys/sys/rwlock.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/rwlock.h" ># 40 "/usr/src/ifnet/sys/sys/rwlock.h" >#endif ># 41 "/usr/src/ifnet/sys/sys/rwlock.h" > >/* > * The rw_lock field consists of several fields. The low bit indicates > * if the lock is locked with a read (shared) or write (exclusive) lock. > * A value of 0 indicates a write lock, and a value of 1 indicates a read > * lock. Bit 1 is a boolean indicating if there are any threads waiting > * for a read lock. Bit 2 is a boolean indicating if there are any threads > * waiting for a write lock. The rest of the variable's definition is > * dependent on the value of the first bit. For a write lock, it is a > * pointer to the thread holding the lock, similar to the mtx_lock field of > * mutexes. For read locks, it is a count of read locks that are held. > * > * When the lock is not locked by any thread, it is encoded as a read lock > * with zero waiters. > */ > >#define RW_LOCK_READ 0x01 >#define RW_LOCK_READ_WAITERS 0x02 >#define RW_LOCK_WRITE_WAITERS 0x04 >#define RW_LOCK_WRITE_SPINNER 0x08 >#define RW_LOCK_FLAGMASK \ > (RW_LOCK_READ | RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS | \ > RW_LOCK_WRITE_SPINNER) >#define RW_LOCK_WAITERS (RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS) > >#define RW_OWNER(x) ((x) & ~RW_LOCK_FLAGMASK) >#define RW_READERS_SHIFT 4 >#define RW_READERS(x) (RW_OWNER((x)) >> RW_READERS_SHIFT) >#define RW_READERS_LOCK(x) ((x) << RW_READERS_SHIFT | RW_LOCK_READ) >#define RW_ONE_READER (1 << RW_READERS_SHIFT) > >#define RW_UNLOCKED RW_READERS_LOCK(0) >#define RW_DESTROYED (RW_LOCK_READ_WAITERS | RW_LOCK_WRITE_WAITERS) > >#ifdef _KERNEL > >#define rw_recurse lock_object.lo_data > >/* Very simple operations on rw_lock. */ > >/* Try to obtain a write lock once. */ >#define _rw_write_lock(rw, tid) \ > atomic_cmpset_acq_ptr(&(rw)->rw_lock, RW_UNLOCKED, (tid)) > >/* Release a write lock quickly if there are no waiters. */ >#define _rw_write_unlock(rw, tid) \ > atomic_cmpset_rel_ptr(&(rw)->rw_lock, (tid), RW_UNLOCKED) > >/* > * Full lock operations that are suitable to be inlined in non-debug > * kernels. If the lock cannot be acquired or released trivially then > * the work is deferred to another function. > */ > >/* Acquire a write lock. */ >#define __rw_wlock(rw, tid, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if (!_rw_write_lock((rw), _tid)) \ > _rw_wlock_hard((rw), _tid, (file), (line)); \ > else \ > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_RW_WLOCK_ACQUIRE, \ > rw, 0, 0, (file), (line)); \ >} while (0) > >/* Release a write lock. */ >#define __rw_wunlock(rw, tid, file, line) do { \ > uintptr_t _tid = (uintptr_t)(tid); \ > \ > if ((rw)->rw_recurse) \ > (rw)->rw_recurse--; \ > else { \ > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_RW_WUNLOCK_RELEASE, \ > (rw)); \ > if (!_rw_write_unlock((rw), _tid)) \ > _rw_wunlock_hard((rw), _tid, (file), (line)); \ > } \ >} while (0) > >/* > * Function prototypes. Routines that start with _ are not part of the > * external API and should not be called directly. Wrapper macros should > * be used instead. > */ >void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts); >void _rw_destroy(volatile uintptr_t *c); >void rw_sysinit(void *arg); >void rw_sysinit_flags(void *arg); >int _rw_wowned(const volatile uintptr_t *c); >void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line); >int __rw_try_wlock(volatile uintptr_t *c, const char *file, int line); >void _rw_wunlock_cookie(volatile uintptr_t *c, const char *file, int line); >void __rw_rlock(volatile uintptr_t *c, const char *file, int line); >int __rw_try_rlock(volatile uintptr_t *c, const char *file, int line); >void _rw_runlock_cookie(volatile uintptr_t *c, const char *file, int line); >void __rw_wlock_hard(volatile uintptr_t *c, uintptr_t tid, const char *file, > int line); >void __rw_wunlock_hard(volatile uintptr_t *c, uintptr_t tid, > const char *file, int line); >int __rw_try_upgrade(volatile uintptr_t *c, const char *file, int line); >void __rw_downgrade(volatile uintptr_t *c, const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void __rw_assert(const volatile uintptr_t *c, int what, const char *file, > int line); >#endif ># 146 "/usr/src/ifnet/sys/sys/rwlock.h" > >/* > * Top-level macros to provide lock cookie once the actual rwlock is passed. > * They will also prevent passing a malformed object to the rwlock KPI by > * failing compilation as the rw_lock reserved member will not be found. > */ >#define rw_init(rw, n) \ > _rw_init_flags(&(rw)->rw_lock, n, 0) >#define rw_init_flags(rw, n, o) \ > _rw_init_flags(&(rw)->rw_lock, n, o) >#define rw_destroy(rw) \ > _rw_destroy(&(rw)->rw_lock) >#define rw_wowned(rw) \ > _rw_wowned(&(rw)->rw_lock) >#define _rw_wlock(rw, f, l) \ > _rw_wlock_cookie(&(rw)->rw_lock, f, l) >#define _rw_try_wlock(rw, f, l) \ > __rw_try_wlock(&(rw)->rw_lock, f, l) >#define _rw_wunlock(rw, f, l) \ > _rw_wunlock_cookie(&(rw)->rw_lock, f, l) >#define _rw_rlock(rw, f, l) \ > __rw_rlock(&(rw)->rw_lock, f, l) >#define _rw_try_rlock(rw, f, l) \ > __rw_try_rlock(&(rw)->rw_lock, f, l) >#define _rw_runlock(rw, f, l) \ > _rw_runlock_cookie(&(rw)->rw_lock, f, l) >#define _rw_wlock_hard(rw, t, f, l) \ > __rw_wlock_hard(&(rw)->rw_lock, t, f, l) >#define _rw_wunlock_hard(rw, t, f, l) \ > __rw_wunlock_hard(&(rw)->rw_lock, t, f, l) >#define _rw_try_upgrade(rw, f, l) \ > __rw_try_upgrade(&(rw)->rw_lock, f, l) >#define _rw_downgrade(rw, f, l) \ > __rw_downgrade(&(rw)->rw_lock, f, l) >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define _rw_assert(rw, w, f, l) \ > __rw_assert(&(rw)->rw_lock, w, f, l) >#endif ># 184 "/usr/src/ifnet/sys/sys/rwlock.h" > > >/* > * Public interface for lock operations. > */ > >#ifndef LOCK_DEBUG >#error LOCK_DEBUG not defined, include <sys/lock.h> before <sys/rwlock.h> >#endif ># 193 "/usr/src/ifnet/sys/sys/rwlock.h" >#if LOCK_DEBUG > 0 || defined(RWLOCK_NOINLINE) >#define rw_wlock(rw) _rw_wlock((rw), LOCK_FILE, LOCK_LINE) >#define rw_wunlock(rw) _rw_wunlock((rw), LOCK_FILE, LOCK_LINE) >#else ># 197 "/usr/src/ifnet/sys/sys/rwlock.h" >#define rw_wlock(rw) \ > __rw_wlock((rw), curthread, LOCK_FILE, LOCK_LINE) >#define rw_wunlock(rw) \ > __rw_wunlock((rw), curthread, LOCK_FILE, LOCK_LINE) >#endif ># 202 "/usr/src/ifnet/sys/sys/rwlock.h" >#define rw_rlock(rw) _rw_rlock((rw), LOCK_FILE, LOCK_LINE) >#define rw_runlock(rw) _rw_runlock((rw), LOCK_FILE, LOCK_LINE) >#define rw_try_rlock(rw) _rw_try_rlock((rw), LOCK_FILE, LOCK_LINE) >#define rw_try_upgrade(rw) _rw_try_upgrade((rw), LOCK_FILE, LOCK_LINE) >#define rw_try_wlock(rw) _rw_try_wlock((rw), LOCK_FILE, LOCK_LINE) >#define rw_downgrade(rw) _rw_downgrade((rw), LOCK_FILE, LOCK_LINE) >#define rw_unlock(rw) do { \ > if (rw_wowned(rw)) \ > rw_wunlock(rw); \ > else \ > rw_runlock(rw); \ >} while (0) >#define rw_sleep(chan, rw, pri, wmesg, timo) \ > _sleep((chan), &(rw)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) > >#define rw_initialized(rw) lock_initialized(&(rw)->lock_object) > >struct rw_args { > void *ra_rw; > const char *ra_desc; >}; > >struct rw_args_flags { > void *ra_rw; > const char *ra_desc; > int ra_flags; >}; > >#define RW_SYSINIT(name, rw, desc) \ > static struct rw_args name##_args = { \ > (rw), \ > (desc), \ > }; \ > SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > rw_sysinit, &name##_args); \ > SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > _rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock)) > > >#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \ > static struct rw_args_flags name##_args = { \ > (rw), \ > (desc), \ > (flags), \ > }; \ > SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > rw_sysinit_flags, &name##_args); \ > SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > _rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock)) > >/* > * Options passed to rw_init_flags(). > */ >#define RW_DUPOK 0x01 >#define RW_NOPROFILE 0x02 >#define RW_NOWITNESS 0x04 >#define RW_QUIET 0x08 >#define RW_RECURSE 0x10 >#define RW_NEW 0x20 > >/* > * The INVARIANTS-enabled rw_assert() functionality. > * > * The constants need to be defined for INVARIANT_SUPPORT infrastructure > * support as _rw_assert() itself uses them and the latter implies that > * _rw_assert() must build. > */ >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define RA_LOCKED LA_LOCKED >#define RA_RLOCKED LA_SLOCKED >#define RA_WLOCKED LA_XLOCKED >#define RA_UNLOCKED LA_UNLOCKED >#define RA_RECURSED LA_RECURSED >#define RA_NOTRECURSED LA_NOTRECURSED >#endif ># 278 "/usr/src/ifnet/sys/sys/rwlock.h" > >#ifdef INVARIANTS >#define rw_assert(rw, what) _rw_assert((rw), (what), LOCK_FILE, LOCK_LINE) >#else ># 282 "/usr/src/ifnet/sys/sys/rwlock.h" >#define rw_assert(rw, what) >#endif ># 284 "/usr/src/ifnet/sys/sys/rwlock.h" > >#endif /* _KERNEL */ ># 286 "/usr/src/ifnet/sys/sys/rwlock.h" >#endif /* !_SYS_RWLOCK_H_ */ ># 287 "/usr/src/ifnet/sys/sys/rwlock.h" ># 56 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/sx.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 56 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/sx.h" 1 >/*- > * Copyright (c) 2007 Attilio Rao <attilio@freebsd.org> > * Copyright (c) 2001 Jason Evans <jasone@freebsd.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice(s), this list of conditions and the following disclaimer as > * the first lines of this file unmodified other than the possible > * addition of one or more copyright notices. > * 2. Redistributions in binary form must reproduce the above copyright > * notice(s), this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY > * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED > * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY > * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES > * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR > * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER > * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > * DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/sx.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_SX_H_ >#define _SYS_SX_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_lock.h> >#endif /* expanded by -frewrite-includes */ ># 35 "/usr/src/ifnet/sys/sys/sx.h" ># 36 "/usr/src/ifnet/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_sx.h> >#endif /* expanded by -frewrite-includes */ ># 36 "/usr/src/ifnet/sys/sys/sx.h" ># 37 "/usr/src/ifnet/sys/sys/sx.h" > >#ifdef _KERNEL >#if 0 /* expanded by -frewrite-includes */ >#include <sys/pcpu.h> >#endif /* expanded by -frewrite-includes */ ># 39 "/usr/src/ifnet/sys/sys/sx.h" ># 40 "/usr/src/ifnet/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock_profile.h> >#endif /* expanded by -frewrite-includes */ ># 40 "/usr/src/ifnet/sys/sys/sx.h" ># 41 "/usr/src/ifnet/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lockstat.h> >#endif /* expanded by -frewrite-includes */ ># 41 "/usr/src/ifnet/sys/sys/sx.h" ># 42 "/usr/src/ifnet/sys/sys/sx.h" >#if 0 /* expanded by -frewrite-includes */ >#include <machine/atomic.h> >#endif /* expanded by -frewrite-includes */ ># 42 "/usr/src/ifnet/sys/sys/sx.h" ># 43 "/usr/src/ifnet/sys/sys/sx.h" >#endif ># 44 "/usr/src/ifnet/sys/sys/sx.h" > >/* > * In general, the sx locks and rwlocks use very similar algorithms. > * The main difference in the implementations is how threads are > * blocked when a lock is unavailable. For this, sx locks use sleep > * queues which do not support priority propagation, and rwlocks use > * turnstiles which do. > * > * The sx_lock field consists of several fields. The low bit > * indicates if the lock is locked with a shared or exclusive lock. A > * value of 0 indicates an exclusive lock, and a value of 1 indicates > * a shared lock. Bit 1 is a boolean indicating if there are any > * threads waiting for a shared lock. Bit 2 is a boolean indicating > * if there are any threads waiting for an exclusive lock. Bit 3 is a > * boolean indicating if an exclusive lock is recursively held. The > * rest of the variable's definition is dependent on the value of the > * first bit. For an exclusive lock, it is a pointer to the thread > * holding the lock, similar to the mtx_lock field of mutexes. For > * shared locks, it is a count of read locks that are held. > * > * When the lock is not locked by any thread, it is encoded as a > * shared lock with zero waiters. > */ > >#define SX_LOCK_SHARED 0x01 >#define SX_LOCK_SHARED_WAITERS 0x02 >#define SX_LOCK_EXCLUSIVE_WAITERS 0x04 >#define SX_LOCK_RECURSED 0x08 >#define SX_LOCK_FLAGMASK \ > (SX_LOCK_SHARED | SX_LOCK_SHARED_WAITERS | \ > SX_LOCK_EXCLUSIVE_WAITERS | SX_LOCK_RECURSED) > >#define SX_OWNER(x) ((x) & ~SX_LOCK_FLAGMASK) >#define SX_SHARERS_SHIFT 4 >#define SX_SHARERS(x) (SX_OWNER(x) >> SX_SHARERS_SHIFT) >#define SX_SHARERS_LOCK(x) \ > ((x) << SX_SHARERS_SHIFT | SX_LOCK_SHARED) >#define SX_ONE_SHARER (1 << SX_SHARERS_SHIFT) > >#define SX_LOCK_UNLOCKED SX_SHARERS_LOCK(0) >#define SX_LOCK_DESTROYED \ > (SX_LOCK_SHARED_WAITERS | SX_LOCK_EXCLUSIVE_WAITERS) > >#ifdef _KERNEL > >#define sx_recurse lock_object.lo_data > >/* > * Function prototipes. Routines that start with an underscore are not part > * of the public interface and are wrappered with a macro. > */ >void sx_sysinit(void *arg); >#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0) >void sx_init_flags(struct sx *sx, const char *description, int opts); >void sx_destroy(struct sx *sx); >int sx_try_slock_(struct sx *sx, const char *file, int line); >int sx_try_xlock_(struct sx *sx, const char *file, int line); >int sx_try_upgrade_(struct sx *sx, const char *file, int line); >void sx_downgrade_(struct sx *sx, const char *file, int line); >int _sx_slock(struct sx *sx, int opts, const char *file, int line); >int _sx_xlock(struct sx *sx, int opts, const char *file, int line); >void _sx_sunlock(struct sx *sx, const char *file, int line); >void _sx_xunlock(struct sx *sx, const char *file, int line); >int _sx_xlock_hard(struct sx *sx, uintptr_t tid, int opts, > const char *file, int line); >int _sx_slock_hard(struct sx *sx, int opts, const char *file, int line); >void _sx_xunlock_hard(struct sx *sx, uintptr_t tid, const char *file, int > line); >void _sx_sunlock_hard(struct sx *sx, const char *file, int line); >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >void _sx_assert(const struct sx *sx, int what, const char *file, int line); >#endif ># 116 "/usr/src/ifnet/sys/sys/sx.h" >#ifdef DDB >int sx_chain(struct thread *td, struct thread **ownerp); >#endif ># 119 "/usr/src/ifnet/sys/sys/sx.h" > >struct sx_args { > struct sx *sa_sx; > const char *sa_desc; > int sa_flags; >}; > >#define SX_SYSINIT_FLAGS(name, sxa, desc, flags) \ > static struct sx_args name##_args = { \ > (sxa), \ > (desc), \ > (flags) \ > }; \ > SYSINIT(name##_sx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > sx_sysinit, &name##_args); \ > SYSUNINIT(name##_sx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ > sx_destroy, (sxa)) > >#define SX_SYSINIT(name, sxa, desc) SX_SYSINIT_FLAGS(name, sxa, desc, 0) > >/* > * Full lock operations that are suitable to be inlined in non-debug kernels. > * If the lock can't be acquired or released trivially then the work is > * deferred to 'tougher' functions. > */ > >/* Acquire an exclusive lock. */ >static __inline int >__sx_xlock(struct sx *sx, struct thread *td, int opts, const char *file, > int line) >{ > uintptr_t tid = (uintptr_t)td; > int error = 0; > > if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) > error = _sx_xlock_hard(sx, tid, opts, file, line); > else > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_XLOCK_ACQUIRE, > sx, 0, 0, file, line); > > return (error); >} > >/* Release an exclusive lock. */ >static __inline void >__sx_xunlock(struct sx *sx, struct thread *td, const char *file, int line) >{ > uintptr_t tid = (uintptr_t)td; > > if (sx->sx_recurse == 0) > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_XUNLOCK_RELEASE, sx); > if (!atomic_cmpset_rel_ptr(&sx->sx_lock, tid, SX_LOCK_UNLOCKED)) > _sx_xunlock_hard(sx, tid, file, line); >} > >/* Acquire a shared lock. */ >static __inline int >__sx_slock(struct sx *sx, int opts, const char *file, int line) >{ > uintptr_t x = sx->sx_lock; > int error = 0; > > if (!(x & SX_LOCK_SHARED) || > !atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER)) > error = _sx_slock_hard(sx, opts, file, line); > else > LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_SX_SLOCK_ACQUIRE, sx, 0, > 0, file, line); > > return (error); >} > >/* > * Release a shared lock. We can just drop a single shared lock so > * long as we aren't trying to drop the last shared lock when other > * threads are waiting for an exclusive lock. This takes advantage of > * the fact that an unlocked lock is encoded as a shared lock with a > * count of 0. > */ >static __inline void >__sx_sunlock(struct sx *sx, const char *file, int line) >{ > uintptr_t x = sx->sx_lock; > > LOCKSTAT_PROFILE_RELEASE_LOCK(LS_SX_SUNLOCK_RELEASE, sx); > if (x == (SX_SHARERS_LOCK(1) | SX_LOCK_EXCLUSIVE_WAITERS) || > !atomic_cmpset_rel_ptr(&sx->sx_lock, x, x - SX_ONE_SHARER)) > _sx_sunlock_hard(sx, file, line); >} > >/* > * Public interface for lock operations. > */ >#ifndef LOCK_DEBUG >#error "LOCK_DEBUG not defined, include <sys/lock.h> before <sys/sx.h>" >#endif ># 215 "/usr/src/ifnet/sys/sys/sx.h" >#if (LOCK_DEBUG > 0) || defined(SX_NOINLINE) >#define sx_xlock_(sx, file, line) \ > (void)_sx_xlock((sx), 0, (file), (line)) >#define sx_xlock_sig_(sx, file, line) \ > _sx_xlock((sx), SX_INTERRUPTIBLE, (file), (line)) >#define sx_xunlock_(sx, file, line) \ > _sx_xunlock((sx), (file), (line)) >#define sx_slock_(sx, file, line) \ > (void)_sx_slock((sx), 0, (file), (line)) >#define sx_slock_sig_(sx, file, line) \ > _sx_slock((sx), SX_INTERRUPTIBLE, (file) , (line)) >#define sx_sunlock_(sx, file, line) \ > _sx_sunlock((sx), (file), (line)) >#else ># 229 "/usr/src/ifnet/sys/sys/sx.h" >#define sx_xlock_(sx, file, line) \ > (void)__sx_xlock((sx), curthread, 0, (file), (line)) >#define sx_xlock_sig_(sx, file, line) \ > __sx_xlock((sx), curthread, SX_INTERRUPTIBLE, (file), (line)) >#define sx_xunlock_(sx, file, line) \ > __sx_xunlock((sx), curthread, (file), (line)) >#define sx_slock_(sx, file, line) \ > (void)__sx_slock((sx), 0, (file), (line)) >#define sx_slock_sig_(sx, file, line) \ > __sx_slock((sx), SX_INTERRUPTIBLE, (file), (line)) >#define sx_sunlock_(sx, file, line) \ > __sx_sunlock((sx), (file), (line)) >#endif /* LOCK_DEBUG > 0 || SX_NOINLINE */ ># 242 "/usr/src/ifnet/sys/sys/sx.h" >#define sx_try_slock(sx) sx_try_slock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_try_xlock(sx) sx_try_xlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_try_upgrade(sx) sx_try_upgrade_((sx), LOCK_FILE, LOCK_LINE) >#define sx_downgrade(sx) sx_downgrade_((sx), LOCK_FILE, LOCK_LINE) >#ifdef INVARIANTS >#define sx_assert_(sx, what, file, line) \ > _sx_assert((sx), (what), (file), (line)) >#else ># 250 "/usr/src/ifnet/sys/sys/sx.h" >#define sx_assert_(sx, what, file, line) (void)0 >#endif ># 252 "/usr/src/ifnet/sys/sys/sx.h" > >#define sx_xlock(sx) sx_xlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_xlock_sig(sx) sx_xlock_sig_((sx), LOCK_FILE, LOCK_LINE) >#define sx_xunlock(sx) sx_xunlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_slock(sx) sx_slock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_slock_sig(sx) sx_slock_sig_((sx), LOCK_FILE, LOCK_LINE) >#define sx_sunlock(sx) sx_sunlock_((sx), LOCK_FILE, LOCK_LINE) >#define sx_assert(sx, what) sx_assert_((sx), (what), __FILE__, __LINE__) > >/* > * Return a pointer to the owning thread if the lock is exclusively > * locked. > */ >#define sx_xholder(sx) \ > ((sx)->sx_lock & SX_LOCK_SHARED ? NULL : \ > (struct thread *)SX_OWNER((sx)->sx_lock)) > >#define sx_xlocked(sx) \ > (((sx)->sx_lock & ~(SX_LOCK_FLAGMASK & ~SX_LOCK_SHARED)) == \ > (uintptr_t)curthread) > >#define sx_unlock_(sx, file, line) do { \ > if (sx_xlocked(sx)) \ > sx_xunlock_(sx, file, line); \ > else \ > sx_sunlock_(sx, file, line); \ >} while (0) > >#define sx_unlock(sx) sx_unlock_((sx), LOCK_FILE, LOCK_LINE) > >#define sx_sleep(chan, sx, pri, wmesg, timo) \ > _sleep((chan), &(sx)->lock_object, (pri), (wmesg), \ > tick_sbt * (timo), 0, C_HARDCLOCK) > >/* > * Options passed to sx_init_flags(). > */ >#define SX_DUPOK 0x01 >#define SX_NOPROFILE 0x02 >#define SX_NOWITNESS 0x04 >#define SX_QUIET 0x08 >#define SX_NOADAPTIVE 0x10 >#define SX_RECURSE 0x20 >#define SX_NEW 0x40 > >/* > * Options passed to sx_*lock_hard(). > */ >#define SX_INTERRUPTIBLE 0x40 > >#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) >#define SA_LOCKED LA_LOCKED >#define SA_SLOCKED LA_SLOCKED >#define SA_XLOCKED LA_XLOCKED >#define SA_UNLOCKED LA_UNLOCKED >#define SA_RECURSED LA_RECURSED >#define SA_NOTRECURSED LA_NOTRECURSED > >/* Backwards compatability. */ >#define SX_LOCKED LA_LOCKED >#define SX_SLOCKED LA_SLOCKED >#define SX_XLOCKED LA_XLOCKED >#define SX_UNLOCKED LA_UNLOCKED >#define SX_RECURSED LA_RECURSED >#define SX_NOTRECURSED LA_NOTRECURSED >#endif ># 318 "/usr/src/ifnet/sys/sys/sx.h" > >#endif /* _KERNEL */ ># 320 "/usr/src/ifnet/sys/sys/sx.h" > >#endif /* !_SYS_SX_H_ */ ># 322 "/usr/src/ifnet/sys/sys/sx.h" ># 57 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <sys/_task.h> /* if_link_task */ >#endif /* expanded by -frewrite-includes */ ># 57 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/sys/_task.h" 1 >/*- > * Copyright (c) 2000 Doug Rabson > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/_task.h 213813 2010-10-13 22:59:04Z mdf $ > */ > >#ifndef _SYS__TASK_H_ >#define _SYS__TASK_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/_task.h" ># 33 "/usr/src/ifnet/sys/sys/_task.h" > >/* > * Each task includes a function which is called from > * taskqueue_run(). The first argument is taken from the 'ta_context' > * field of struct task and the second argument is a count of how many > * times the task was enqueued before the call to taskqueue_run(). > * > * List of locks > * (c) const after init > * (q) taskqueue lock > */ >typedef void task_fn_t(void *context, int pending); > >struct task { > STAILQ_ENTRY(task) ta_link; /* (q) link for queue */ > u_short ta_pending; /* (q) count times queued */ > u_short ta_priority; /* (c) Priority */ > task_fn_t *ta_func; /* (c) task handler */ > void *ta_context; /* (c) argument for handler */ >}; > >#endif /* !_SYS__TASK_H_ */ ># 55 "/usr/src/ifnet/sys/sys/_task.h" ># 58 "/usr/src/ifnet/sys/net/if_var.h" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <net/altq/if_altq.h> >#endif /* expanded by -frewrite-includes */ ># 58 "/usr/src/ifnet/sys/net/if_var.h" ># 1 "/usr/src/ifnet/sys/net/altq/if_altq.h" 1 >/*- > * Copyright (C) 1997-2003 > * Sony Computer Science Laboratories Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $KAME: if_altq.h,v 1.12 2005/04/13 03:44:25 suz Exp $ > * $FreeBSD: projects/ifnet/sys/net/altq/if_altq.h 281650 2015-04-17 12:10:00Z glebius $ > */ >#ifndef _ALTQ_IF_ALTQ_H_ >#define _ALTQ_IF_ALTQ_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/lock.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/net/altq/if_altq.h" ># 33 "/usr/src/ifnet/sys/net/altq/if_altq.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/mutex.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 33 "/usr/src/ifnet/sys/net/altq/if_altq.h" ># 34 "/usr/src/ifnet/sys/net/altq/if_altq.h" >#if 0 /* expanded by -frewrite-includes */ >#include <sys/event.h> /* XXX */ >#endif /* expanded by -frewrite-includes */ ># 34 "/usr/src/ifnet/sys/net/altq/if_altq.h" ># 1 "/usr/src/ifnet/sys/sys/event.h" 1 >/*- > * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * > * $FreeBSD: projects/ifnet/sys/sys/event.h 276379 2014-12-29 21:38:00Z glebius $ > */ > >#ifndef _SYS_EVENT_H_ >#define _SYS_EVENT_H_ > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/queue.h> >#endif /* expanded by -frewrite-includes */ ># 32 "/usr/src/ifnet/sys/sys/event.h" ># 33 "/usr/src/ifnet/sys/sys/event.h" > >#define EVFILT_READ (-1) >#define EVFILT_WRITE (-2) >#define EVFILT_AIO (-3) /* attached to aio requests */ >#define EVFILT_VNODE (-4) /* attached to vnodes */ >#define EVFILT_PROC (-5) /* attached to struct proc */ >#define EVFILT_SIGNAL (-6) /* attached to struct proc */ >#define EVFILT_TIMER (-7) /* timers */ >#define EVFILT_PROCDESC (-8) /* attached to process descriptors */ >#define EVFILT_FS (-9) /* filesystem events */ >#define EVFILT_LIO (-10) /* attached to lio requests */ >#define EVFILT_USER (-11) /* User events */ >#define EVFILT_SENDFILE (-12) /* attached to sendfile requests */ >#define EVFILT_SYSCOUNT 12 > >#define EV_SET(kevp_, a, b, c, d, e, f) do { \ > struct kevent *kevp = (kevp_); \ > (kevp)->ident = (a); \ > (kevp)->filter = (b); \ > (kevp)->flags = (c); \ > (kevp)->fflags = (d); \ > (kevp)->data = (e); \ > (kevp)->udata = (f); \ >} while(0) > >struct kevent { > uintptr_t ident; /* identifier for this event */ > short filter; /* filter for event */ > u_short flags; > u_int fflags; > intptr_t data; > void *udata; /* opaque user data identifier */ >}; > >/* actions */ >#define EV_ADD 0x0001 /* add event to kq (implies enable) */ >#define EV_DELETE 0x0002 /* delete event from kq */ >#define EV_ENABLE 0x0004 /* enable event */ >#define EV_DISABLE 0x0008 /* disable event (not reported) */ >#define EV_FORCEONESHOT 0x0100 /* enable _ONESHOT and force trigger */ > >/* flags */ >#define EV_ONESHOT 0x0010 /* only report one occurrence */ >#define EV_CLEAR 0x0020 /* clear event state after reporting */ >#define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */ >#define EV_DISPATCH 0x0080 /* disable event after reporting */ > >#define EV_SYSFLAGS 0xF000 /* reserved by system */ >#define EV_DROP 0x1000 /* note should be dropped */ >#define EV_FLAG1 0x2000 /* filter-specific flag */ > >/* returned values */ >#define EV_EOF 0x8000 /* EOF detected */ >#define EV_ERROR 0x4000 /* error, data contains errno */ > > /* > * data/hint flags/masks for EVFILT_USER, shared with userspace > * > * On input, the top two bits of fflags specifies how the lower twenty four > * bits should be applied to the stored value of fflags. > * > * On output, the top two bits will always be set to NOTE_FFNOP and the > * remaining twenty four bits will contain the stored fflags value. > */ >#define NOTE_FFNOP 0x00000000 /* ignore input fflags */ >#define NOTE_FFAND 0x40000000 /* AND fflags */ >#define NOTE_FFOR 0x80000000 /* OR fflags */ >#define NOTE_FFCOPY 0xc0000000 /* copy fflags */ >#define NOTE_FFCTRLMASK 0xc0000000 /* masks for operations */ >#define NOTE_FFLAGSMASK 0x00ffffff > >#define NOTE_TRIGGER 0x01000000 /* Cause the event to be > triggered for output. */ > >/* > * data/hint flags for EVFILT_{READ|WRITE}, shared with userspace > */ >#define NOTE_LOWAT 0x0001 /* low water mark */ > >/* > * data/hint flags for EVFILT_VNODE, shared with userspace > */ >#define NOTE_DELETE 0x0001 /* vnode was removed */ >#define NOTE_WRITE 0x0002 /* data contents changed */ >#define NOTE_EXTEND 0x0004 /* size increased */ >#define NOTE_ATTRIB 0x0008 /* attributes changed */ >#define NOTE_LINK 0x0010 /* link count changed */ >#define NOTE_RENAME 0x0020 /* vnode was renamed */ >#define NOTE_REVOKE 0x0040 /* vnode access was revoked */ > >/* > * data/hint flags for EVFILT_PROC and EVFILT_PROCDESC, shared with userspace > */ >#define NOTE_EXIT 0x80000000 /* process exited */ >#define NOTE_FORK 0x40000000 /* process forked */ >#define NOTE_EXEC 0x20000000 /* process exec'd */ >#define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */ >#define NOTE_PDATAMASK 0x000fffff /* mask for pid */ > >/* additional flags for EVFILT_PROC */ >#define NOTE_TRACK 0x00000001 /* follow across forks */ >#define NOTE_TRACKERR 0x00000002 /* could not track child */ >#define NOTE_CHILD 0x00000004 /* am a child process */ > >/* additional flags for EVFILT_TIMER */ >#define NOTE_SECONDS 0x00000001 /* data is seconds */ >#define NOTE_MSECONDS 0x00000002 /* data is milliseconds */ >#define NOTE_USECONDS 0x00000004 /* data is microseconds */ >#define NOTE_NSECONDS 0x00000008 /* data is nanoseconds */ > >struct knote; >SLIST_HEAD(klist, knote); >struct kqueue; >TAILQ_HEAD(kqlist, kqueue); >struct knlist { > struct klist kl_list; > void (*kl_lock)(void *); /* lock function */ > void (*kl_unlock)(void *); > void (*kl_assert_locked)(void *); > void (*kl_assert_unlocked)(void *); > void *kl_lockarg; /* argument passed to kl_lockf() */ >}; > > >#ifdef _KERNEL > >/* > * Flags for knote call > */ >#define KNF_LISTLOCKED 0x0001 /* knlist is locked */ >#define KNF_NOKQLOCK 0x0002 /* do not keep KQ_LOCK */ > >#define KNOTE(list, hist, flags) knote(list, hist, flags) >#define KNOTE_LOCKED(list, hint) knote(list, hint, KNF_LISTLOCKED) >#define KNOTE_UNLOCKED(list, hint) knote(list, hint, 0) > >#define KNLIST_EMPTY(list) SLIST_EMPTY(&(list)->kl_list) > >/* > * Flag indicating hint is a signal. Used by EVFILT_SIGNAL, and also > * shared by EVFILT_PROC (all knotes attached to p->p_klist) > */ >#define NOTE_SIGNAL 0x08000000 > >/* > * Hint values for the optional f_touch event filter. If f_touch is not set > * to NULL and f_isfd is zero the f_touch filter will be called with the type > * argument set to EVENT_REGISTER during a kevent() system call. It is also > * called under the same conditions with the type argument set to EVENT_PROCESS > * when the event has been triggered. > */ >#define EVENT_REGISTER 1 >#define EVENT_PROCESS 2 > >struct filterops { > int f_isfd; /* true if ident == filedescriptor */ > int (*f_attach)(struct knote *kn); > void (*f_detach)(struct knote *kn); > int (*f_event)(struct knote *kn, long hint); > void (*f_touch)(struct knote *kn, struct kevent *kev, u_long type); >}; > >/* > * Setting the KN_INFLUX flag enables you to unlock the kq that this knote > * is on, and modify kn_status as if you had the KQ lock. > * > * kn_sfflags, kn_sdata, and kn_kevent are protected by the knlist lock. > */ >struct knote { > SLIST_ENTRY(knote) kn_link; /* for kq */ > SLIST_ENTRY(knote) kn_selnext; /* for struct selinfo */ > struct knlist *kn_knlist; /* f_attach populated */ > TAILQ_ENTRY(knote) kn_tqe; > struct kqueue *kn_kq; /* which queue we are on */ > struct kevent kn_kevent; > int kn_status; /* protected by kq lock */ >#define KN_ACTIVE 0x01 /* event has been triggered */ >#define KN_QUEUED 0x02 /* event is on queue */ >#define KN_DISABLED 0x04 /* event is disabled */ >#define KN_DETACHED 0x08 /* knote is detached */ >#define KN_INFLUX 0x10 /* knote is in flux */ >#define KN_MARKER 0x20 /* ignore this knote */ >#define KN_KQUEUE 0x40 /* this knote belongs to a kq */ >#define KN_HASKQLOCK 0x80 /* for _inevent */ >#define KN_SCAN 0x100 /* flux set in kqueue_scan() */ > int kn_sfflags; /* saved filter flags */ > intptr_t kn_sdata; /* saved data field */ > union { > struct file *p_fp; /* file data pointer */ > struct proc *p_proc; /* proc pointer */ > struct aiocblist *p_aio; /* AIO job pointer */ > struct aioliojob *p_lio; /* LIO job pointer */ > sbintime_t *p_nexttime; /* next timer event fires at */ > void *p_v; /* generic other pointer */ > } kn_ptr; > struct filterops *kn_fop; > void *kn_hook; > int kn_hookid; > >#define kn_id kn_kevent.ident >#define kn_filter kn_kevent.filter >#define kn_flags kn_kevent.flags >#define kn_fflags kn_kevent.fflags >#define kn_data kn_kevent.data >#define kn_fp kn_ptr.p_fp >}; >struct kevent_copyops { > void *arg; > int (*k_copyout)(void *arg, struct kevent *kevp, int count); > int (*k_copyin)(void *arg, struct kevent *kevp, int count); >}; > >struct thread; >struct proc; >struct knlist; >struct mtx; >struct rwlock; > >extern void knote(struct knlist *list, long hint, int lockflags); >extern void knote_fork(struct knlist *list, int pid); >extern void knlist_add(struct knlist *knl, struct knote *kn, int islocked); >extern void knlist_remove(struct knlist *knl, struct knote *kn, int islocked); >extern void knlist_remove_inevent(struct knlist *knl, struct knote *kn); >extern int knlist_empty(struct knlist *knl); >extern void knlist_init(struct knlist *knl, void *lock, > void (*kl_lock)(void *), void (*kl_unlock)(void *), > void (*kl_assert_locked)(void *), void (*kl_assert_unlocked)(void *)); >extern void knlist_init_mtx(struct knlist *knl, struct mtx *lock); >extern void knlist_init_rw_reader(struct knlist *knl, struct rwlock *lock); >extern void knlist_destroy(struct knlist *knl); >extern void knlist_cleardel(struct knlist *knl, struct thread *td, > int islocked, int killkn); >#define knlist_clear(knl, islocked) \ > knlist_cleardel((knl), NULL, (islocked), 0) >#define knlist_delete(knl, td, islocked) \ > knlist_cleardel((knl), (td), (islocked), 1) >extern void knote_fdclose(struct thread *p, int fd); >extern int kqfd_register(int fd, struct kevent *kev, struct thread *p, > int waitok); >extern int kqueue_add_filteropts(int filt, struct filterops *filtops); >extern int kqueue_del_filteropts(int filt); > >#else /* !_KERNEL */ ># 276 "/usr/src/ifnet/sys/sys/event.h" > >#if 0 /* expanded by -frewrite-includes */ >#include <sys/cdefs.h> >#endif /* expanded by -frewrite-includes */ ># 277 "/usr/src/ifnet/sys/sys/event.h" ># 278 "/usr/src/ifnet/sys/sys/event.h" >struct timespec; > >__BEGIN_DECLS >int kqueue(void); >int kevent(int kq, const struct kevent *changelist, int nchanges, > struct kevent *eventlist, int nevents, > const struct timespec *timeout); >__END_DECLS > >#endif /* !_KERNEL */ ># 288 "/usr/src/ifnet/sys/sys/event.h" > >#endif /* !_SYS_EVENT_H_ */ ># 290 "/usr/src/ifnet/sys/sys/event.h" ># 35 "/usr/src/ifnet/sys/net/altq/if_altq.h" 2 > >struct altq_pktattr; struct tb_regulator; struct top_cdnr; > >/* > * Structure defining a queue for a network interface. > */ >struct ifaltq { > /* fields compatible with struct ifqueue */ > struct mbuf *ifq_head; > struct mbuf *ifq_tail; > int ifq_len; > int ifq_maxlen; > struct mtx ifq_mtx; > > /* driver owned queue (used for bulk dequeue and prepend) UNLOCKED */ > struct mbuf *ifq_drv_head; > struct mbuf *ifq_drv_tail; > int ifq_drv_len; > int ifq_drv_maxlen; > > /* alternate queueing related fields */ > int altq_type; /* discipline type */ > int altq_flags; /* flags (e.g. ready, in-use) */ > void *altq_disc; /* for discipline-specific use */ > struct ifnet *altq_ifp; /* back pointer to interface */ > > int (*altq_enqueue)(struct ifaltq *, struct mbuf *, > struct altq_pktattr *); > struct mbuf *(*altq_dequeue)(struct ifaltq *, int); > int (*altq_request)(struct ifaltq *, int, void *); > > /* classifier fields */ > void *altq_clfier; /* classifier-specific use */ > void *(*altq_classify)(void *, struct mbuf *, int); > > /* token bucket regulator */ > struct tb_regulator *altq_tbr; > > /* input traffic conditioner (doesn't belong to the output queue...) */ > struct top_cdnr *altq_cdnr; >}; > > >#ifdef _KERNEL > >/* > * packet attributes used by queueing disciplines. > * pattr_class is a discipline-dependent scheduling class that is > * set by a classifier. > * pattr_hdr and pattr_af may be used by a discipline to access > * the header within a mbuf. (e.g. ECN needs to update the CE bit) > * note that pattr_hdr could be stale after m_pullup, though link > * layer output routines usually don't use m_pullup. link-level > * compression also invalidates these fields. thus, pattr_hdr needs > * to be verified when a discipline touches the header. > */ >struct altq_pktattr { > void *pattr_class; /* sched class set by classifier */ > int pattr_af; /* address family */ > caddr_t pattr_hdr; /* saved header position in mbuf */ >}; > >/* > * mbuf tag to carry a queue id (and hints for ECN). > */ >struct altq_tag { > u_int32_t qid; /* queue id */ > /* hints for ecn */ > int af; /* address family */ > void *hdr; /* saved header position in mbuf */ >}; > >/* > * a token-bucket regulator limits the rate that a network driver can > * dequeue packets from the output queue. > * modern cards are able to buffer a large amount of packets and dequeue > * too many packets at a time. this bursty dequeue behavior makes it > * impossible to schedule packets by queueing disciplines. > * a token-bucket is used to control the burst size in a device > * independent manner. > */ >struct tb_regulator { > int64_t tbr_rate; /* (scaled) token bucket rate */ > int64_t tbr_depth; /* (scaled) token bucket depth */ > > int64_t tbr_token; /* (scaled) current token */ > int64_t tbr_filluptime; /* (scaled) time to fill up bucket */ > u_int64_t tbr_last; /* last time token was updated */ > > int tbr_lastop; /* last dequeue operation type > needed for poll-and-dequeue */ >}; > >/* if_altqflags */ >#define ALTQF_READY 0x01 /* driver supports alternate queueing */ >#define ALTQF_ENABLED 0x02 /* altq is in use */ >#define ALTQF_CLASSIFY 0x04 /* classify packets */ >#define ALTQF_CNDTNING 0x08 /* altq traffic conditioning is enabled */ >#define ALTQF_DRIVER1 0x40 /* driver specific */ > >/* if_altqflags set internally only: */ >#define ALTQF_CANTCHANGE (ALTQF_READY) > >/* altq_dequeue 2nd arg */ >#define ALTDQ_REMOVE 1 /* dequeue mbuf from the queue */ >#define ALTDQ_POLL 2 /* don't dequeue mbuf from the queue */ > >/* altq request types (currently only purge is defined) */ >#define ALTRQ_PURGE 1 /* purge all packets */ > >#define ALTQ_IS_READY(ifq) ((ifq)->altq_flags & ALTQF_READY) >#define ALTQ_IS_ENABLED(ifq) ((ifq)->altq_flags & ALTQF_ENABLED) >#define ALTQ_NEEDS_CLASSIFY(ifq) ((ifq)->altq_flags & ALTQF_CLASSIFY) >#define ALTQ_IS_CNDTNING(ifq) ((ifq)->altq_flags & ALTQF_CNDTNING) > >#define ALTQ_SET_CNDTNING(ifq) ((ifq)->altq_flags |= ALTQF_CNDTNING) >#define ALTQ_CLEAR_CNDTNING(ifq) ((ifq)->altq_flags &= ~ALTQF_CNDTNING) >#define ALTQ_IS_ATTACHED(ifq) ((ifq)->altq_disc != NULL) > >#define ALTQ_ENQUEUE(ifq, m, pa, err) \ > (err) = (*(ifq)->altq_enqueue)((ifq),(m),(pa)) >#define ALTQ_DEQUEUE(ifq, m) \ > (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_REMOVE) >#define ALTQ_POLL(ifq, m) \ > (m) = (*(ifq)->altq_dequeue)((ifq), ALTDQ_POLL) >#define ALTQ_PURGE(ifq) \ > (void)(*(ifq)->altq_request)((ifq), ALTRQ_PURGE, (void *)0) >#define ALTQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) >#define TBR_IS_ENABLED(ifq) ((ifq)->altq_tbr != NULL) > >extern int altq_attach(struct ifaltq *, int, void *, > int (*)(struct ifaltq *, struct mbuf *, > struct altq_pktattr *), > struct mbuf *(*)(struct ifaltq *, int), > int (*)(struct ifaltq *, int, void *), > void *, > void *(*)(void *, struct mbuf *, int)); >extern int altq_detach(struct ifaltq *); >extern int altq_enable(struct ifaltq *); >extern int altq_disable(struct ifaltq *); >extern struct mbuf *(*tbr_dequeue_ptr)(struct ifaltq *, int); >extern int (*altq_input)(struct mbuf *, int); >#if 0 /* ALTQ3_CLFIER_COMPAT */ >void altq_etherclassify(struct ifaltq *, struct mbuf *, struct altq_pktattr *); >#endif ># 180 "/usr/src/ifnet/sys/net/altq/if_altq.h" >#endif /* _KERNEL */ ># 181 "/usr/src/ifnet/sys/net/altq/if_altq.h" > >#endif /* _ALTQ_IF_ALTQ_H_ */ ># 183 "/usr/src/ifnet/sys/net/altq/if_altq.h" ># 59 "/usr/src/ifnet/sys/net/if_var.h" 2 > >TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */ >TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */ >TAILQ_HEAD(ifmultihead, ifmultiaddr); >TAILQ_HEAD(ifgrouphead, ifg_group); > >VNET_DECLARE(struct pfil_head, link_pfil_hook); /* packet filter hooks */ >#define V_link_pfil_hook VNET(link_pfil_hook) > >typedef void (*iftype_attach_t)(if_t ifp, struct if_attach_args *args); >typedef void (*iftype_detach_t)(if_t ifp); >struct iftype { > const ifType ift_type; > SLIST_ENTRY(iftype) ift_next; > iftype_attach_t ift_attach; > iftype_detach_t ift_detach; > uint8_t ift_hdrlen; > uint8_t ift_addrlen; > uint32_t ift_dlt; > uint32_t ift_dlt_hdrlen; > struct ifops ift_ops; >}; > >/* > * Many network stack modules want to store their software context associated > * with an interface. We used to give a pointer for everyone, but that yield > * to sizeof(struct ifnet) growing and permanent need for new pointers added > * to the struct. Now we keep a tiny cache of recently used features and > * dynamically allocated store for them. > * Note: this could be generalized with kobj(9). > */ >#define SOFTC_CACHE_SIZE 4 >struct ifsoftc { > ift_feature ifsc_desc; > void *ifsc_ptr; >}; > >/* > * Structure defining a network interface. > * > * (Would like to call this struct ``if'', but C isn't PL/1.) > */ >struct ifnet { > struct ifops *if_ops; /* driver ops (or overridden) */ > void *if_softc; /* driver software context */ > struct ifdriver *if_drv; /* driver static definition */ > struct ifsoftc *if_sccache[SOFTC_CACHE_SIZE]; /* cache of softcs */ > struct iftsomax *if_tsomax; /* TSO limits */ > struct iftype *if_type; /* if type static def (optional)*/ > > struct rwlock if_lock; /* lock to protect the ifnet */ > > struct ifsoftc *if_scstore; /* store of different softcs */ > TAILQ_ENTRY(ifnet) if_link; /* on global list */ > LIST_ENTRY(ifnet) if_clones; /* on if_cloner list */ > TAILQ_HEAD(, ifg_list) if_groups; /* groups of this ifnet */ > > void *if_l2com; /* pointer to protocol bits */ > uint32_t if_nsoftcs; /* elements in if_scstore */ > int if_dunit; /* unit or IF_DUNIT_NONE */ > u_short if_index; /* numeric abbreviation for this if */ > short if_index_reserved; /* spare space to grow if_index */ > char if_xname[IFNAMSIZ]; /* external name (name + unit) */ > char *if_description; /* interface description */ > > /* Supported medias (can be NULL), current media and ignore mask. */ > if_media_t *if_medias; > if_media_t if_media; > if_media_t if_mediamask; > > /* Variable fields that are touched by the stack . */ > uint32_t if_flags; /* up/down, broadcast, etc. */ > uint32_t if_capabilities;/* interface features & capabilities */ > uint32_t if_capenable; /* enabled features & capabilities */ > void *if_linkmib; /* link-type-specific MIB data */ > size_t if_linkmiblen; /* length of above data */ > u_int if_refcount; /* reference count */ > u_int if_fib; /* interface FIB */ > > uint8_t if_link_state; /* current link state */ > uint32_t if_mtu; /* maximum transmission unit */ > uint32_t if_metric; /* routing metric (external only) */ > uint64_t if_baudrate; /* linespeed */ > uint64_t if_hwassist; /* HW offload capabilities, see IFCAP */ > time_t if_epoch; /* uptime at attach or stat reset */ > struct timeval if_lastchange; /* time of last administrative change */ > > struct task if_linktask; /* task for link change events */ > > /* Addresses of different protocol families assigned to this if. */ > /* > * if_addrhead is the list of all addresses associated to > * an interface. > * Some code in the kernel assumes that first element > * of the list has type AF_LINK, and contains sockaddr_dl > * addresses which store the link-level address and the name > * of the interface. > * However, access to the AF_LINK address through this > * field is deprecated. Use if_addr or ifaddr_byindex() instead. > */ > struct ifaddrhead if_addrhead; /* linked list of addresses per if */ > struct ifmultihead if_multiaddrs; /* multicast addresses configured */ > int if_amcount; /* number of all-multicast requests */ > struct ifaddr *if_addr; /* pointer to link-level address */ > const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ > struct rwlock if_afdata_lock; > void *if_afdata[AF_MAX]; > int if_afdata_initialized; > > /* Additional features hung off the interface. */ > struct ifqueue *if_snd; /* software send queue */ > struct vnet *if_vnet; /* pointer to network stack instance */ > struct vnet *if_home_vnet; /* where this ifnet originates from */ > struct ifvlantrunk *if_vlantrunk; /* pointer to 802.1q data */ > struct bpf_if *if_bpf; /* packet filter structure */ > int if_pcount; /* number of promiscuous listeners */ > void *if_bridge; /* bridge glue */ > void *if_lagg; /* lagg glue */ > void *if_pf_kif; /* pf glue */ > struct label *if_label; /* interface MAC label */ > struct netmap_adapter *if_netmap; /* netmap(4) softc */ > > counter_u64_t if_counters[IFCOUNTERS]; /* Statistics */ > > /* > * Spare fields to be added before branching a stable branch, so > * that structure can be enhanced without changing the kernel > * binary interface. > */ >}; > >/* > * Modyfing interface requires synchronisation. > */ >#define IF_WLOCK(ifp) rw_wlock(&(ifp)->if_lock) >#define IF_WUNLOCK(if) rw_wunlock(&(ifp)->if_lock) >#define IF_RLOCK(ifp) rw_rlock(&(ifp)->if_lock) >#define IF_RUNLOCK(ifp) rw_runlock(&(ifp)->if_lock) >#define IF_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_lock, RA_LOCKED) >#define IF_WLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_lock, RA_WLOCKED) >/* > * Originally only address lists were locked, so we keep these macros > * for compatibility, until they are cleaned up from kernel. > */ >#define IF_ADDR_WLOCK(ifp) IF_WLOCK(ifp) >#define IF_ADDR_WUNLOCK(ifp) IF_WUNLOCK(ifp) >#define IF_ADDR_RLOCK(ifp) IF_RLOCK(ifp) >#define IF_ADDR_RUNLOCK(ifp) IF_RUNLOCK(ifp) >#define IF_ADDR_LOCK_ASSERT(ifp) IF_LOCK_ASSERT(ifp) >#define IF_ADDR_WLOCK_ASSERT(ifp) IF_WLOCK_ASSERT(ifp) > >#ifdef _SYS_EVENTHANDLER_H_ >/* interface link layer address change event */ >typedef void (*iflladdr_event_handler_t)(void *, struct ifnet *); >EVENTHANDLER_DECLARE(iflladdr_event, iflladdr_event_handler_t); >/* interface address change event */ >typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *); >EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t); >/* new interface arrival event */ >typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *); >EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t); >/* interface departure event */ >typedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *); >EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); >/* Interface link state change event */ >typedef void (*ifnet_link_event_handler_t)(void *, struct ifnet *, int); >EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_event_handler_t); >#endif /* _SYS_EVENTHANDLER_H_ */ ># 227 "/usr/src/ifnet/sys/net/if_var.h" > >/* > * interface groups > */ >struct ifg_group { > char ifg_group[IFNAMSIZ]; > u_int ifg_refcnt; > void *ifg_pf_kif; > TAILQ_HEAD(, ifg_member) ifg_members; > TAILQ_ENTRY(ifg_group) ifg_next; >}; > >struct ifg_member { > TAILQ_ENTRY(ifg_member) ifgm_next; > struct ifnet *ifgm_ifp; >}; > >struct ifg_list { > struct ifg_group *ifgl_group; > TAILQ_ENTRY(ifg_list) ifgl_next; >}; > >#ifdef _SYS_EVENTHANDLER_H_ >/* group attach event */ >typedef void (*group_attach_event_handler_t)(void *, struct ifg_group *); >EVENTHANDLER_DECLARE(group_attach_event, group_attach_event_handler_t); >/* group detach event */ >typedef void (*group_detach_event_handler_t)(void *, struct ifg_group *); >EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t); >/* group change event */ >typedef void (*group_change_event_handler_t)(void *, const char *); >EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t); >#endif /* _SYS_EVENTHANDLER_H_ */ ># 260 "/usr/src/ifnet/sys/net/if_var.h" > >#define IF_AFDATA_LOCK_INIT(ifp) \ > rw_init(&(ifp)->if_afdata_lock, "if_afdata") > >#define IF_AFDATA_WLOCK(ifp) rw_wlock(&(ifp)->if_afdata_lock) >#define IF_AFDATA_RLOCK(ifp) rw_rlock(&(ifp)->if_afdata_lock) >#define IF_AFDATA_WUNLOCK(ifp) rw_wunlock(&(ifp)->if_afdata_lock) >#define IF_AFDATA_RUNLOCK(ifp) rw_runlock(&(ifp)->if_afdata_lock) >#define IF_AFDATA_LOCK(ifp) IF_AFDATA_WLOCK(ifp) >#define IF_AFDATA_UNLOCK(ifp) IF_AFDATA_WUNLOCK(ifp) >#define IF_AFDATA_TRYLOCK(ifp) rw_try_wlock(&(ifp)->if_afdata_lock) >#define IF_AFDATA_DESTROY(ifp) rw_destroy(&(ifp)->if_afdata_lock) > >#define IF_AFDATA_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED) >#define IF_AFDATA_RLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_RLOCKED) >#define IF_AFDATA_WLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_WLOCKED) >#define IF_AFDATA_UNLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED) > >/* > * 72 was chosen below because it is the size of a TCP/IP > * header (40) + the minimum mss (32). > */ >#define IF_MINMTU 72 >#define IF_MAXMTU 65535 > >/* > * The ifaddr structure contains information about one address > * of an interface. They are maintained by the different address families, > * are allocated and attached when an address is set, and are linked > * together so all addresses for an interface can be located. > * > * NOTE: a 'struct ifaddr' is always at the beginning of a larger > * chunk of malloc'ed memory, where we store the three addresses > * (ifa_addr, ifa_dstaddr and ifa_netmask) referenced here. > */ >struct ifaddr { > struct sockaddr *ifa_addr; /* address of interface */ > struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ >#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ > struct sockaddr *ifa_netmask; /* used to determine subnet */ > struct ifnet *ifa_ifp; /* back-pointer to interface */ > struct carp_softc *ifa_carp; /* pointer to CARP data */ > TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ > void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ > (int, struct rtentry *, struct rt_addrinfo *); > u_short ifa_flags; /* mostly rt_flags for cloning */ >#define IFA_ROUTE RTF_UP /* route installed */ >#define IFA_RTSELF RTF_HOST /* loopback route to self installed */ > u_int ifa_refcnt; /* references to this structure */ > > counter_u64_t ifa_ipackets; > counter_u64_t ifa_opackets; > counter_u64_t ifa_ibytes; > counter_u64_t ifa_obytes; >}; > >/* For compatibility with other BSDs. SCTP uses it. */ >#define ifa_list ifa_link > >struct ifaddr * ifa_alloc(size_t size, int flags); >void ifa_free(struct ifaddr *ifa); >void ifa_ref(struct ifaddr *ifa); > >/* > * Multicast address structure. This is analogous to the ifaddr > * structure except that it keeps track of multicast addresses. > */ >struct ifmultiaddr { > TAILQ_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ > struct sockaddr *ifma_addr; /* address this membership is for */ > struct sockaddr *ifma_lladdr; /* link-layer translation, if any */ > struct ifnet *ifma_ifp; /* back-pointer to interface */ > u_int ifma_refcount; /* reference count */ > void *ifma_protospec; /* protocol-specific state, if any */ > struct ifmultiaddr *ifma_llifma; /* pointer to ifma for ifma_lladdr */ >}; > >extern struct rwlock ifnet_rwlock; >extern struct sx ifnet_sxlock; > >#define IFNET_WLOCK() do { \ > sx_xlock(&ifnet_sxlock); \ > rw_wlock(&ifnet_rwlock); \ >} while (0) > >#define IFNET_WUNLOCK() do { \ > rw_wunlock(&ifnet_rwlock); \ > sx_xunlock(&ifnet_sxlock); \ >} while (0) > >/* > * To assert the ifnet lock, you must know not only whether it's for read or > * write, but also whether it was acquired with sleep support or not. > */ >#define IFNET_RLOCK_ASSERT() sx_assert(&ifnet_sxlock, SA_SLOCKED) >#define IFNET_RLOCK_NOSLEEP_ASSERT() rw_assert(&ifnet_rwlock, RA_RLOCKED) >#define IFNET_WLOCK_ASSERT() do { \ > sx_assert(&ifnet_sxlock, SA_XLOCKED); \ > rw_assert(&ifnet_rwlock, RA_WLOCKED); \ >} while (0) > >#define IFNET_RLOCK() sx_slock(&ifnet_sxlock) >#define IFNET_RLOCK_NOSLEEP() rw_rlock(&ifnet_rwlock) >#define IFNET_RUNLOCK() sx_sunlock(&ifnet_sxlock) >#define IFNET_RUNLOCK_NOSLEEP() rw_runlock(&ifnet_rwlock) > >/* > * Look up an ifnet given its index; the _ref variant also acquires a > * reference that must be freed using if_rele(). It is almost always a bug > * to call ifnet_byindex() instead if ifnet_byindex_ref(). > */ >struct ifnet *ifnet_byindex(u_short idx); >struct ifnet *ifnet_byindex_locked(u_short idx); >struct ifnet *ifnet_byindex_ref(u_short idx); > >/* > * Given the index, ifaddr_byindex() returns the one and only > * link-level ifaddr for the interface. You are not supposed to use > * it to traverse the list of addresses associated to the interface. > */ >struct ifaddr *ifaddr_byindex(u_short idx); > >VNET_DECLARE(struct ifnethead, ifnet); >VNET_DECLARE(struct ifgrouphead, ifg_head); >VNET_DECLARE(int, if_index); >VNET_DECLARE(struct ifnet *, loif); /* first loopback interface */ > >#define V_ifnet VNET(ifnet) >#define V_ifg_head VNET(ifg_head) >#define V_if_index VNET(if_index) >#define V_loif VNET(loif) > >int if_addgroup(struct ifnet *, const char *); >int if_delgroup(struct ifnet *, const char *); >int if_addmulti(struct ifnet *, struct sockaddr *, struct ifmultiaddr **); >int if_allmulti(struct ifnet *, int); >int if_delmulti(struct ifnet *, struct sockaddr *); >void if_delmulti_ifma(struct ifmultiaddr *); >void if_vmove(struct ifnet *, struct vnet *); >void if_purgeaddrs(struct ifnet *); >void if_delallmulti(struct ifnet *); >void if_down(struct ifnet *); >struct ifmultiaddr * > if_findmulti(struct ifnet *, struct sockaddr *); >void if_ref(struct ifnet *); >void if_rele(struct ifnet *); >int if_setlladdr(struct ifnet *, const u_char *, int); >void if_up(struct ifnet *); >int ifioctl(struct socket *, u_long, caddr_t, struct thread *); >int ifpromisc(struct ifnet *, int); >struct ifnet *ifunit(const char *); >struct ifnet *ifunit_ref(const char *); >uint8_t if_addrlen(const if_t); > >void iftype_register(struct iftype *); >void iftype_unregister(struct iftype *); > >int ifa_add_loopback_route(struct ifaddr *, struct sockaddr *); >int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *); >int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *, int fib); > >struct ifaddr *ifa_ifwithaddr(struct sockaddr *); >int ifa_ifwithaddr_check(struct sockaddr *); >struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *, int); >struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, int); >struct ifaddr *ifa_ifwithnet(struct sockaddr *, int, int); >struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *, u_int); >struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); >int ifa_preferred(struct ifaddr *, struct ifaddr *); > >int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen); > >void if_data_copy(struct ifnet *, struct if_data *); >int if_getmtu_family(if_t ifp, int family); > >int if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max); >int if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max); >int if_multiaddr_count(if_t ifp, int max); > >/* TSO */ >void if_tsomax_common(const struct iftsomax *, struct iftsomax *); >int if_tsomax_update(if_t ifp, const struct iftsomax *); > >#ifdef DEVICE_POLLING >void if_poll_register(struct ifnet *ifp); >void if_poll_deregister(struct ifnet *ifp); >#endif ># 447 "/usr/src/ifnet/sys/net/if_var.h" > >/* > * Wrappers around ifops. Some ops are optional and can be NULL, > * others are mandatory. Those wrappers that driver can invoke > * theirselves are not inlined, but implemented in if.c. > */ >#undef if_input >static inline void >if_input(if_t ifp, struct mbuf *m) >{ > > return (ifp->if_ops->ifop_input(ifp, m)); >} > >#undef if_transmit >static inline int >if_transmit(if_t ifp, struct mbuf *m) >{ > int error; > > error = ifp->if_ops->ifop_transmit(ifp, m); > if (error) > m_freem(m); > return (error); >} > >static inline void >if_qflush(if_t ifp) >{ > > if (ifp->if_ops->ifop_qflush != NULL) > ifp->if_ops->ifop_qflush(ifp); >} > >static inline int >if_output(if_t ifp, struct mbuf *m, const struct sockaddr *dst, > struct route *ro) >{ > > return (ifp->if_ops->ifop_output(ifp, m, dst, ro)); >} > >static inline int >if_ioctl(if_t ifp, u_long cmd, void *data, struct thread *td) >{ > int error = EOPNOTSUPP; > > if (ifp->if_ops->ifop_ioctl != NULL) > error = ifp->if_ops->ifop_ioctl(ifp, cmd, data, td); > > if (error == EOPNOTSUPP && ifp->if_type != NULL && > ifp->if_type->ift_ops.ifop_ioctl != NULL) > error = ifp->if_type->ift_ops.ifop_ioctl(ifp, cmd, data, td); > > return (error); >} > >static inline uint64_t >if_get_counter(const if_t ifp, ift_counter cnt) >{ > > return (ifp->if_ops->ifop_get_counter(ifp, cnt)); >} > >static inline int >if_resolvemulti(if_t ifp, struct sockaddr **llsa, struct sockaddr *sa) >{ > > if (ifp->if_ops->ifop_resolvemulti != NULL) > return (ifp->if_ops->ifop_resolvemulti(ifp, llsa, sa)); > else > return (EOPNOTSUPP); >} > >static inline void >if_reassign(if_t ifp, struct vnet *new) >{ > > return (ifp->if_ops->ifop_reassign(ifp, new)); >} > >static inline void >if_vlan_event(if_t ifp, uint16_t vid, if_t vifp) >{ > > if (ifp->if_ops->ifop_vlan_event != NULL) > ifp->if_ops->ifop_vlan_event(ifp, vid, vifp); >} > >#ifdef DEVICE_POLLING >static inline int >if_poll(if_t ifp, enum poll_cmd cmd, int count) >{ > > return (ifp->if_ops->ifop_poll(ifp, cmd, count)); >} >#endif ># 544 "/usr/src/ifnet/sys/net/if_var.h" > >/* > * Inliners to shorten code, and make protocols more ifnet-agnostic. > */ >static inline ifType >if_type(const if_t ifp) >{ > > return (ifp->if_drv->ifdrv_type); >} >#endif /* _KERNEL */ ># 555 "/usr/src/ifnet/sys/net/if_var.h" >#endif /* !_NET_IF_VAR_H_ */ ># 556 "/usr/src/ifnet/sys/net/if_var.h" ># 48 "/usr/src/ifnet/sys/net/if_media.c" 2 >#if 0 /* expanded by -frewrite-includes */ >#include <net/if_media.h> >#endif /* expanded by -frewrite-includes */ ># 48 "/usr/src/ifnet/sys/net/if_media.c" ># 1 "/usr/src/ifnet/sys/net/if_media.h" 1 >/* $NetBSD: if_media.h,v 1.3 1997/03/26 01:19:27 thorpej Exp $ */ >/* $FreeBSD: projects/ifnet/sys/net/if_media.h 281640 2015-04-17 05:55:07Z glebius $ */ > >/*- > * Copyright (c) 1997 > * Jonathan Stone and Jason R. Thorpe. All rights reserved. > * > * This software is derived from information provided by Matt Thomas. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in the > * documentation and/or other materials provided with the distribution. > * 3. All advertising materials mentioning features or use of this software > * must display the following acknowledgement: > * This product includes software developed by Jonathan Stone > * and Jason R. Thorpe for the NetBSD Project. > * 4. The names of the authors may not be used to endorse or promote products > * derived from this software without specific prior written permission. > * > * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR > * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. > * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, > * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, > * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; > * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > */ > >#ifndef _NET_IF_MEDIA_H_ >#define _NET_IF_MEDIA_H_ > >/* > * if_media Options word: > * Bits Use > * ---- ------- > * 0-4 Media variant > * 5-7 Media type > * 8-15 Type specific options (includes added variant bits on Ethernet) > * 16-18 Mode (for multi-mode devices) > * 19 RFU > * 20-27 Shared (global) options > * 28-31 Instance > */ > >/* > * Ethernet > * In order to use more than 31 subtypes, Ethernet uses some of the option > * bits as part of the subtype field. See the options section below for > * relevant definitions > */ >#define IFM_ETHER 0x00000020 >#define IFM_ETHER_SUBTYPE(x) (((x) & IFM_TMASK) | \ > (((x) & (IFM_ETH_XTYPE >> IFM_ETH_XSHIFT)) << IFM_ETH_XSHIFT)) >#define IFM_X(x) IFM_ETHER_SUBTYPE(x) /* internal shorthand */ >#define IFM_ETHER_SUBTYPE_SET(x) (IFM_ETHER_SUBTYPE(x) | IFM_ETHER) >#define IFM_ETHER_SUBTYPE_GET(x) ((x) & (IFM_TMASK|IFM_ETH_XTYPE)) >#define IFM_ETHER_IS_EXTENDED(x) ((x) & IFM_ETH_XTYPE) > >#define IFM_10_T 3 /* 10BaseT - RJ45 */ >#define IFM_10_2 4 /* 10Base2 - Thinnet */ >#define IFM_10_5 5 /* 10Base5 - AUI */ >#define IFM_100_TX 6 /* 100BaseTX - RJ45 */ >#define IFM_100_FX 7 /* 100BaseFX - Fiber */ >#define IFM_100_T4 8 /* 100BaseT4 - 4 pair cat 3 */ >#define IFM_100_VG 9 /* 100VG-AnyLAN */ >#define IFM_100_T2 10 /* 100BaseT2 */ >#define IFM_1000_SX 11 /* 1000BaseSX - multi-mode fiber */ >#define IFM_10_STP 12 /* 10BaseT over shielded TP */ >#define IFM_10_FL 13 /* 10BaseFL - Fiber */ >#define IFM_1000_LX 14 /* 1000baseLX - single-mode fiber */ >#define IFM_1000_CX 15 /* 1000baseCX - 150ohm STP */ >#define IFM_1000_T 16 /* 1000baseT - 4 pair cat 5 */ >#define IFM_HPNA_1 17 /* HomePNA 1.0 (1Mb/s) */ >#define IFM_10G_LR 18 /* 10GBase-LR 1310nm Single-mode */ >#define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ >#define IFM_10G_CX4 20 /* 10GBase CX4 copper */ >#define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ >#define IFM_10G_TWINAX 22 /* 10GBase Twinax copper */ >#define IFM_10G_TWINAX_LONG 23 /* 10GBase Twinax Long copper */ >#define IFM_10G_LRM 24 /* 10GBase-LRM 850nm Multi-mode */ >#define IFM_UNKNOWN 25 /* media types not defined yet */ >#define IFM_10G_T 26 /* 10GBase-T - RJ45 */ >#define IFM_40G_CR4 27 /* 40GBase-CR4 */ >#define IFM_40G_SR4 28 /* 40GBase-SR4 */ >#define IFM_40G_LR4 29 /* 40GBase-LR4 */ >#define IFM_1000_KX 30 /* 1000Base-KX backplane */ >#define IFM_OTHER 31 /* Other: one of the following */ > >/* following types are not visible to old binaries using only IFM_TMASK */ >#define IFM_10G_KX4 IFM_X(32) /* 10GBase-KX4 backplane */ >#define IFM_10G_KR IFM_X(33) /* 10GBase-KR backplane */ >#define IFM_10G_CR1 IFM_X(34) /* 10GBase-CR1 Twinax splitter */ >#define IFM_20G_KR2 IFM_X(35) /* 20GBase-KR2 backplane */ >#define IFM_2500_KX IFM_X(36) /* 2500Base-KX backplane */ >#define IFM_2500_T IFM_X(37) /* 2500Base-T - RJ45 (NBaseT) */ >#define IFM_5000_T IFM_X(38) /* 5000Base-T - RJ45 (NBaseT) */ >#define IFM_50G_PCIE IFM_X(39) /* 50G Ethernet over PCIE */ >#define IFM_25G_PCIE IFM_X(40) /* 25G Ethernet over PCIE */ >#define IFM_1000_SGMII IFM_X(41) /* 1G media interface */ >#define IFM_10G_SFI IFM_X(42) /* 10G media interface */ >#define IFM_40G_XLPPI IFM_X(43) /* 40G media interface */ >#define IFM_1000_CX_SGMII IFM_X(44) /* 1000Base-CX-SGMII */ >#define IFM_40G_KR4 IFM_X(45) /* 40GBase-KR4 */ >#define IFM_10G_ER IFM_X(46) /* 10GBase-ER */ >#define IFM_100G_CR4 IFM_X(47) /* 100GBase-CR4 */ >#define IFM_100G_SR4 IFM_X(48) /* 100GBase-SR4 */ >#define IFM_100G_KR4 IFM_X(49) /* 100GBase-KR4 */ >#define IFM_100G_LR4 IFM_X(50) /* 100GBase-LR4 */ >#define IFM_56G_R4 IFM_X(51) /* 56GBase-R4 */ >#define IFM_100_T IFM_X(52) /* 100BaseT - RJ45 */ >#define IFM_25G_CR IFM_X(53) /* 25GBase-CR */ >#define IFM_25G_KR IFM_X(54) /* 25GBase-KR */ >#define IFM_25G_SR IFM_X(55) /* 25GBase-SR */ >#define IFM_50G_CR2 IFM_X(56) /* 50GBase-CR2 */ >#define IFM_50G_KR2 IFM_X(57) /* 50GBase-KR2 */ > >/* > * Please update ieee8023ad_lacp.c:lacp_compose_key() > * after adding new Ethernet media types. > */ >/* Note IFM_X(511) is the max! */ > >/* Ethernet option values; includes bits used for extended variant field */ >#define IFM_ETH_MASTER 0x00000100 /* master mode (1000baseT) */ >#define IFM_ETH_RXPAUSE 0x00000200 /* receive PAUSE frames */ >#define IFM_ETH_TXPAUSE 0x00000400 /* transmit PAUSE frames */ >#define IFM_ETH_XTYPE 0x00007800 /* extended media variants */ >#define IFM_ETH_XSHIFT 6 /* shift XTYPE next to TMASK */ > >/* > * Token ring > */ >#define IFM_TOKEN 0x00000040 >#define IFM_TOK_STP4 3 /* Shielded twisted pair 4m - DB9 */ >#define IFM_TOK_STP16 4 /* Shielded twisted pair 16m - DB9 */ >#define IFM_TOK_UTP4 5 /* Unshielded twisted pair 4m - RJ45 */ >#define IFM_TOK_UTP16 6 /* Unshielded twisted pair 16m - RJ45 */ >#define IFM_TOK_STP100 7 /* Shielded twisted pair 100m - DB9 */ >#define IFM_TOK_UTP100 8 /* Unshielded twisted pair 100m - RJ45 */ >#define IFM_TOK_ETR 0x00000200 /* Early token release */ >#define IFM_TOK_SRCRT 0x00000400 /* Enable source routing features */ >#define IFM_TOK_ALLR 0x00000800 /* All routes / Single route bcast */ >#define IFM_TOK_DTR 0x00002000 /* Dedicated token ring */ >#define IFM_TOK_CLASSIC 0x00004000 /* Classic token ring */ >#define IFM_TOK_AUTO 0x00008000 /* Automatic Dedicate/Classic token ring */ > >/* > * FDDI > */ >#define IFM_FDDI 0x00000060 >#define IFM_FDDI_SMF 3 /* Single-mode fiber */ >#define IFM_FDDI_MMF 4 /* Multi-mode fiber */ >#define IFM_FDDI_UTP 5 /* CDDI / UTP */ >#define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */ > >/* > * IEEE 802.11 Wireless > */ >#define IFM_IEEE80211 0x00000080 >/* NB: 0,1,2 are auto, manual, none defined below */ >#define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */ >#define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */ >#define IFM_IEEE80211_DS1 5 /* Direct Sequence 1Mbps */ >#define IFM_IEEE80211_DS2 6 /* Direct Sequence 2Mbps */ >#define IFM_IEEE80211_DS5 7 /* Direct Sequence 5.5Mbps */ >#define IFM_IEEE80211_DS11 8 /* Direct Sequence 11Mbps */ >#define IFM_IEEE80211_DS22 9 /* Direct Sequence 22Mbps */ >#define IFM_IEEE80211_OFDM6 10 /* OFDM 6Mbps */ >#define IFM_IEEE80211_OFDM9 11 /* OFDM 9Mbps */ >#define IFM_IEEE80211_OFDM12 12 /* OFDM 12Mbps */ >#define IFM_IEEE80211_OFDM18 13 /* OFDM 18Mbps */ >#define IFM_IEEE80211_OFDM24 14 /* OFDM 24Mbps */ >#define IFM_IEEE80211_OFDM36 15 /* OFDM 36Mbps */ >#define IFM_IEEE80211_OFDM48 16 /* OFDM 48Mbps */ >#define IFM_IEEE80211_OFDM54 17 /* OFDM 54Mbps */ >#define IFM_IEEE80211_OFDM72 18 /* OFDM 72Mbps */ >#define IFM_IEEE80211_DS354k 19 /* Direct Sequence 354Kbps */ >#define IFM_IEEE80211_DS512k 20 /* Direct Sequence 512Kbps */ >#define IFM_IEEE80211_OFDM3 21 /* OFDM 3Mbps */ >#define IFM_IEEE80211_OFDM4 22 /* OFDM 4.5Mbps */ >#define IFM_IEEE80211_OFDM27 23 /* OFDM 27Mbps */ >/* NB: not enough bits to express MCS fully */ >#define IFM_IEEE80211_MCS 24 /* HT MCS rate */ > >#define IFM_IEEE80211_ADHOC 0x00000100 /* Operate in Adhoc mode */ >#define IFM_IEEE80211_HOSTAP 0x00000200 /* Operate in Host AP mode */ >#define IFM_IEEE80211_IBSS 0x00000400 /* Operate in IBSS mode */ >#define IFM_IEEE80211_WDS 0x00000800 /* Operate in WDS mode */ >#define IFM_IEEE80211_TURBO 0x00001000 /* Operate in turbo mode */ >#define IFM_IEEE80211_MONITOR 0x00002000 /* Operate in monitor mode */ >#define IFM_IEEE80211_MBSS 0x00004000 /* Operate in MBSS mode */ > >/* operating mode for multi-mode devices */ >#define IFM_IEEE80211_11A 0x00010000 /* 5Ghz, OFDM mode */ >#define IFM_IEEE80211_11B 0x00020000 /* Direct Sequence mode */ >#define IFM_IEEE80211_11G 0x00030000 /* 2Ghz, CCK mode */ >#define IFM_IEEE80211_FH 0x00040000 /* 2Ghz, GFSK mode */ >#define IFM_IEEE80211_11NA 0x00050000 /* 5Ghz, HT mode */ >#define IFM_IEEE80211_11NG 0x00060000 /* 2Ghz, HT mode */ > >/* > * ATM > */ >#define IFM_ATM 0x000000a0 >#define IFM_ATM_UNKNOWN 3 >#define IFM_ATM_UTP_25 4 >#define IFM_ATM_TAXI_100 5 >#define IFM_ATM_TAXI_140 6 >#define IFM_ATM_MM_155 7 >#define IFM_ATM_SM_155 8 >#define IFM_ATM_UTP_155 9 >#define IFM_ATM_MM_622 10 >#define IFM_ATM_SM_622 11 >#define IFM_ATM_VIRTUAL 12 >#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ >#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ >#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ > >/* > * Shared media sub-types > */ >#define IFM_AUTO 0 /* Autoselect best media */ >#define IFM_MANUAL 1 /* Jumper/dipswitch selects media */ >#define IFM_NONE 2 /* Deselect all media */ > >/* > * Shared options > */ >#define IFM_FDX 0x00100000 /* Force full duplex */ >#define IFM_HDX 0x00200000 /* Force half duplex */ >#define IFM_FLOW 0x00400000 /* enable hardware flow control */ >#define IFM_FLAG0 0x01000000 /* Driver defined flag */ >#define IFM_FLAG1 0x02000000 /* Driver defined flag */ >#define IFM_FLAG2 0x04000000 /* Driver defined flag */ >#define IFM_LOOP 0x08000000 /* Put hardware in loopback */ > >/* > * Masks > */ >#define IFM_NMASK 0x000000e0 /* Network type */ >#define IFM_TMASK 0x0000001f /* Media sub-type */ >#define IFM_IMASK 0xf0000000 /* Instance */ >#define IFM_ISHIFT 28 /* Instance shift */ >#define IFM_OMASK 0x0000ff00 /* Type specific options */ >#define IFM_MMASK 0x00070000 /* Mode */ >#define IFM_MSHIFT 16 /* Mode shift */ >#define IFM_GMASK 0x0ff00000 /* Global options */ > >/* Ethernet flow control mask */ >#define IFM_ETH_FMASK (IFM_FLOW | IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE) > >/* > * Status bits > */ >#define IFM_AVALID 0x00000001 /* Active bit valid */ >#define IFM_ACTIVE 0x00000002 /* Interface attached to working net */ > >/* Mask of "status valid" bits, for ifconfig(8). */ >#define IFM_STATUS_VALID IFM_AVALID > >/* List of "status valid" bits, for ifconfig(8). */ >#define IFM_STATUS_VALID_LIST { \ > IFM_AVALID, \ > 0 \ >} > >/* > * Macros to extract various bits of information from the media word. > */ >#define IFM_TYPE(x) ((x) & IFM_NMASK) >#define IFM_SUBTYPE(x) \ > (IFM_TYPE(x) == IFM_ETHER ? IFM_ETHER_SUBTYPE_GET(x) : ((x) & IFM_TMASK)) >#define IFM_TYPE_MATCH(x,y) \ > (IFM_TYPE(x) == IFM_TYPE(y) && IFM_SUBTYPE(x) == IFM_SUBTYPE(y)) >#define IFM_TYPE_OPTIONS(x) ((x) & IFM_OMASK) >#define IFM_INST(x) (((x) & IFM_IMASK) >> IFM_ISHIFT) >#define IFM_OPTIONS(x) ((x) & (IFM_OMASK | IFM_GMASK)) >#define IFM_MODE(x) ((x) & IFM_MMASK) > >#define IFM_INST_MAX IFM_INST(IFM_IMASK) > >/* > * Macro to create a media word. > */ >#define IFM_MAKEWORD(type, subtype, options, instance) \ > ((type) | (subtype) | (options) | ((instance) << IFM_ISHIFT)) >#define IFM_MAKEMODE(mode) \ > (((mode) << IFM_MSHIFT) & IFM_MMASK) > >/* > * NetBSD extension not defined in the BSDI API. This is used in various > * places to get the canonical description for a given type/subtype. > * > * NOTE: all but the top-level type descriptions must contain NO whitespace! > * Otherwise, parsing these in ifconfig(8) would be a nightmare. > */ >struct ifmedia_description { > int ifmt_word; /* word value; may be masked */ > const char *ifmt_string; /* description */ >}; > >#define IFM_TYPE_DESCRIPTIONS { \ > { IFM_ETHER, "Ethernet" }, \ > { IFM_TOKEN, "Token ring" }, \ > { IFM_FDDI, "FDDI" }, \ > { IFM_IEEE80211, "IEEE 802.11 Wireless Ethernet" }, \ > { IFM_ATM, "ATM" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ETHERNET_DESCRIPTIONS { \ > { IFM_10_T, "10baseT/UTP" }, \ > { IFM_10_2, "10base2/BNC" }, \ > { IFM_10_5, "10base5/AUI" }, \ > { IFM_100_TX, "100baseTX" }, \ > { IFM_100_FX, "100baseFX" }, \ > { IFM_100_T4, "100baseT4" }, \ > { IFM_100_VG, "100baseVG" }, \ > { IFM_100_T2, "100baseT2" }, \ > { IFM_10_STP, "10baseSTP" }, \ > { IFM_10_FL, "10baseFL" }, \ > { IFM_1000_SX, "1000baseSX" }, \ > { IFM_1000_LX, "1000baseLX" }, \ > { IFM_1000_CX, "1000baseCX" }, \ > { IFM_1000_T, "1000baseT" }, \ > { IFM_HPNA_1, "homePNA" }, \ > { IFM_10G_LR, "10Gbase-LR" }, \ > { IFM_10G_SR, "10Gbase-SR" }, \ > { IFM_10G_CX4, "10Gbase-CX4" }, \ > { IFM_2500_SX, "2500BaseSX" }, \ > { IFM_10G_LRM, "10Gbase-LRM" }, \ > { IFM_10G_TWINAX, "10Gbase-Twinax" }, \ > { IFM_10G_TWINAX_LONG, "10Gbase-Twinax-Long" }, \ > { IFM_UNKNOWN, "Unknown" }, \ > { IFM_10G_T, "10Gbase-T" }, \ > { IFM_40G_CR4, "40Gbase-CR4" }, \ > { IFM_40G_SR4, "40Gbase-SR4" }, \ > { IFM_40G_LR4, "40Gbase-LR4" }, \ > { IFM_1000_KX, "1000Base-KX" }, \ > { IFM_OTHER, "Other" }, \ > { IFM_10G_KX4, "10GBase-KX4" }, \ > { IFM_10G_KR, "10GBase-KR" }, \ > { IFM_10G_CR1, "10GBase-CR1" }, \ > { IFM_20G_KR2, "20GBase-KR2" }, \ > { IFM_2500_KX, "2500Base-KX" }, \ > { IFM_2500_T, "2500Base-T" }, \ > { IFM_5000_T, "5000Base-T" }, \ > { IFM_50G_PCIE, "PCIExpress-50G" }, \ > { IFM_25G_PCIE, "PCIExpress-25G" }, \ > { IFM_1000_SGMII, "1000Base-SGMII" }, \ > { IFM_10G_SFI, "10GBase-SFI" }, \ > { IFM_40G_XLPPI, "40GBase-XLPPI" }, \ > { IFM_1000_CX_SGMII, "1000Base-CX-SGMII" }, \ > { IFM_40G_KR4, "40GBase-KR4" }, \ > { IFM_10G_ER, "10GBase-ER" }, \ > { IFM_100G_CR4, "100GBase-CR4" }, \ > { IFM_100G_SR4, "100GBase-SR4" }, \ > { IFM_100G_KR4, "100GBase-KR4" }, \ > { IFM_100G_LR4, "100GBase-LR4" }, \ > { IFM_56G_R4, "56GBase-R4" }, \ > { IFM_100_T, "100BaseT" }, \ > { IFM_25G_CR, "25GBase-CR" }, \ > { IFM_25G_KR, "25GBase-KR" }, \ > { IFM_25G_SR, "25GBase-SR" }, \ > { IFM_50G_CR2, "50GBase-CR2" }, \ > { IFM_50G_KR2, "50GBase-KR2" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ETHERNET_ALIASES { \ > { IFM_10_T, "10baseT" }, \ > { IFM_10_T, "UTP" }, \ > { IFM_10_T, "10UTP" }, \ > { IFM_10_2, "BNC" }, \ > { IFM_10_2, "10BNC" }, \ > { IFM_10_5, "AUI" }, \ > { IFM_10_5, "10AUI" }, \ > { IFM_100_TX, "100TX" }, \ > { IFM_100_T4, "100T4" }, \ > { IFM_100_VG, "100VG" }, \ > { IFM_100_T2, "100T2" }, \ > { IFM_10_STP, "10STP" }, \ > { IFM_10_FL, "10FL" }, \ > { IFM_1000_SX, "1000SX" }, \ > { IFM_1000_LX, "1000LX" }, \ > { IFM_1000_CX, "1000CX" }, \ > { IFM_1000_T, "1000baseTX" }, \ > { IFM_1000_T, "1000TX" }, \ > { IFM_1000_T, "1000T" }, \ > { IFM_2500_SX, "2500SX" }, \ > \ > /* \ > * Shorthands for common media+option combinations as announced \ > * by miibus(4) \ > */ \ > { IFM_10_T | IFM_FDX, "10baseT-FDX" }, \ > { IFM_10_T | IFM_FDX | IFM_FLOW, "10baseT-FDX-flow" }, \ > { IFM_100_TX | IFM_FDX, "100baseTX-FDX" }, \ > { IFM_100_TX | IFM_FDX | IFM_FLOW, "100baseTX-FDX-flow" }, \ > { IFM_1000_T | IFM_FDX, "1000baseT-FDX" }, \ > { IFM_1000_T | IFM_FDX | IFM_FLOW, "1000baseT-FDX-flow" }, \ > { IFM_1000_T | IFM_FDX | IFM_FLOW | IFM_ETH_MASTER, \ > "1000baseT-FDX-flow-master" }, \ > { IFM_1000_T | IFM_FDX | IFM_ETH_MASTER, \ > "1000baseT-FDX-master" }, \ > { IFM_1000_T | IFM_ETH_MASTER, "1000baseT-master" }, \ > \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS { \ > { IFM_ETH_MASTER, "master" }, \ > { IFM_ETH_RXPAUSE, "rxpause" }, \ > { IFM_ETH_TXPAUSE, "txpause" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_TOKENRING_DESCRIPTIONS { \ > { IFM_TOK_STP4, "DB9/4Mbit" }, \ > { IFM_TOK_STP16, "DB9/16Mbit" }, \ > { IFM_TOK_UTP4, "UTP/4Mbit" }, \ > { IFM_TOK_UTP16, "UTP/16Mbit" }, \ > { IFM_TOK_STP100, "STP/100Mbit" }, \ > { IFM_TOK_UTP100, "UTP/100Mbit" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_TOKENRING_ALIASES { \ > { IFM_TOK_STP4, "4STP" }, \ > { IFM_TOK_STP16, "16STP" }, \ > { IFM_TOK_UTP4, "4UTP" }, \ > { IFM_TOK_UTP16, "16UTP" }, \ > { IFM_TOK_STP100, "100STP" }, \ > { IFM_TOK_UTP100, "100UTP" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS { \ > { IFM_TOK_ETR, "EarlyTokenRelease" }, \ > { IFM_TOK_SRCRT, "SourceRouting" }, \ > { IFM_TOK_ALLR, "AllRoutes" }, \ > { IFM_TOK_DTR, "Dedicated" }, \ > { IFM_TOK_CLASSIC,"Classic" }, \ > { IFM_TOK_AUTO, " " }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_FDDI_DESCRIPTIONS { \ > { IFM_FDDI_SMF, "Single-mode" }, \ > { IFM_FDDI_MMF, "Multi-mode" }, \ > { IFM_FDDI_UTP, "UTP" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_FDDI_ALIASES { \ > { IFM_FDDI_SMF, "SMF" }, \ > { IFM_FDDI_MMF, "MMF" }, \ > { IFM_FDDI_UTP, "CDDI" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS { \ > { IFM_FDDI_DA, "Dual-attach" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_IEEE80211_DESCRIPTIONS { \ > { IFM_IEEE80211_FH1, "FH/1Mbps" }, \ > { IFM_IEEE80211_FH2, "FH/2Mbps" }, \ > { IFM_IEEE80211_DS1, "DS/1Mbps" }, \ > { IFM_IEEE80211_DS2, "DS/2Mbps" }, \ > { IFM_IEEE80211_DS5, "DS/5.5Mbps" }, \ > { IFM_IEEE80211_DS11, "DS/11Mbps" }, \ > { IFM_IEEE80211_DS22, "DS/22Mbps" }, \ > { IFM_IEEE80211_OFDM6, "OFDM/6Mbps" }, \ > { IFM_IEEE80211_OFDM9, "OFDM/9Mbps" }, \ > { IFM_IEEE80211_OFDM12, "OFDM/12Mbps" }, \ > { IFM_IEEE80211_OFDM18, "OFDM/18Mbps" }, \ > { IFM_IEEE80211_OFDM24, "OFDM/24Mbps" }, \ > { IFM_IEEE80211_OFDM36, "OFDM/36Mbps" }, \ > { IFM_IEEE80211_OFDM48, "OFDM/48Mbps" }, \ > { IFM_IEEE80211_OFDM54, "OFDM/54Mbps" }, \ > { IFM_IEEE80211_OFDM72, "OFDM/72Mbps" }, \ > { IFM_IEEE80211_DS354k, "DS/354Kbps" }, \ > { IFM_IEEE80211_DS512k, "DS/512Kbps" }, \ > { IFM_IEEE80211_OFDM3, "OFDM/3Mbps" }, \ > { IFM_IEEE80211_OFDM4, "OFDM/4.5Mbps" }, \ > { IFM_IEEE80211_OFDM27, "OFDM/27Mbps" }, \ > { IFM_IEEE80211_MCS, "MCS" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_IEEE80211_ALIASES { \ > { IFM_IEEE80211_FH1, "FH1" }, \ > { IFM_IEEE80211_FH2, "FH2" }, \ > { IFM_IEEE80211_FH1, "FrequencyHopping/1Mbps" }, \ > { IFM_IEEE80211_FH2, "FrequencyHopping/2Mbps" }, \ > { IFM_IEEE80211_DS1, "DS1" }, \ > { IFM_IEEE80211_DS2, "DS2" }, \ > { IFM_IEEE80211_DS5, "DS5.5" }, \ > { IFM_IEEE80211_DS11, "DS11" }, \ > { IFM_IEEE80211_DS22, "DS22" }, \ > { IFM_IEEE80211_DS1, "DirectSequence/1Mbps" }, \ > { IFM_IEEE80211_DS2, "DirectSequence/2Mbps" }, \ > { IFM_IEEE80211_DS5, "DirectSequence/5.5Mbps" }, \ > { IFM_IEEE80211_DS11, "DirectSequence/11Mbps" }, \ > { IFM_IEEE80211_DS22, "DirectSequence/22Mbps" }, \ > { IFM_IEEE80211_OFDM6, "OFDM6" }, \ > { IFM_IEEE80211_OFDM9, "OFDM9" }, \ > { IFM_IEEE80211_OFDM12, "OFDM12" }, \ > { IFM_IEEE80211_OFDM18, "OFDM18" }, \ > { IFM_IEEE80211_OFDM24, "OFDM24" }, \ > { IFM_IEEE80211_OFDM36, "OFDM36" }, \ > { IFM_IEEE80211_OFDM48, "OFDM48" }, \ > { IFM_IEEE80211_OFDM54, "OFDM54" }, \ > { IFM_IEEE80211_OFDM72, "OFDM72" }, \ > { IFM_IEEE80211_DS1, "CCK1" }, \ > { IFM_IEEE80211_DS2, "CCK2" }, \ > { IFM_IEEE80211_DS5, "CCK5.5" }, \ > { IFM_IEEE80211_DS11, "CCK11" }, \ > { IFM_IEEE80211_DS354k, "DS354K" }, \ > { IFM_IEEE80211_DS354k, "DirectSequence/354Kbps" }, \ > { IFM_IEEE80211_DS512k, "DS512K" }, \ > { IFM_IEEE80211_DS512k, "DirectSequence/512Kbps" }, \ > { IFM_IEEE80211_OFDM3, "OFDM3" }, \ > { IFM_IEEE80211_OFDM4, "OFDM4.5" }, \ > { IFM_IEEE80211_OFDM27, "OFDM27" }, \ > { IFM_IEEE80211_MCS, "MCS" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS { \ > { IFM_IEEE80211_ADHOC, "adhoc" }, \ > { IFM_IEEE80211_HOSTAP, "hostap" }, \ > { IFM_IEEE80211_IBSS, "ibss" }, \ > { IFM_IEEE80211_WDS, "wds" }, \ > { IFM_IEEE80211_TURBO, "turbo" }, \ > { IFM_IEEE80211_MONITOR, "monitor" }, \ > { IFM_IEEE80211_MBSS, "mesh" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS { \ > { IFM_AUTO, "autoselect" }, \ > { IFM_IEEE80211_11A, "11a" }, \ > { IFM_IEEE80211_11B, "11b" }, \ > { IFM_IEEE80211_11G, "11g" }, \ > { IFM_IEEE80211_FH, "fh" }, \ > { IFM_IEEE80211_11NA, "11na" }, \ > { IFM_IEEE80211_11NG, "11ng" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_IEEE80211_MODE_ALIASES { \ > { IFM_AUTO, "auto" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ > { IFM_ATM_UNKNOWN, "Unknown" }, \ > { IFM_ATM_UTP_25, "UTP/25.6MBit" }, \ > { IFM_ATM_TAXI_100, "Taxi/100MBit" }, \ > { IFM_ATM_TAXI_140, "Taxi/140MBit" }, \ > { IFM_ATM_MM_155, "Multi-mode/155MBit" }, \ > { IFM_ATM_SM_155, "Single-mode/155MBit" }, \ > { IFM_ATM_UTP_155, "UTP/155MBit" }, \ > { IFM_ATM_MM_622, "Multi-mode/622MBit" }, \ > { IFM_ATM_SM_622, "Single-mode/622MBit" }, \ > { IFM_ATM_VIRTUAL, "Virtual" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ATM_ALIASES { \ > { IFM_ATM_UNKNOWN, "UNKNOWN" }, \ > { IFM_ATM_UTP_25, "UTP-25" }, \ > { IFM_ATM_TAXI_100, "TAXI-100" }, \ > { IFM_ATM_TAXI_140, "TAXI-140" }, \ > { IFM_ATM_MM_155, "MM-155" }, \ > { IFM_ATM_SM_155, "SM-155" }, \ > { IFM_ATM_UTP_155, "UTP-155" }, \ > { IFM_ATM_MM_622, "MM-622" }, \ > { IFM_ATM_SM_622, "SM-622" }, \ > { IFM_ATM_VIRTUAL, "VIRTUAL" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS { \ > { IFM_ATM_SDH, "SDH" }, \ > { IFM_ATM_NOSCRAMB, "Noscramb" }, \ > { IFM_ATM_UNASSIGNED, "Unassigned" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \ > { IFM_AUTO, "autoselect" }, \ > { IFM_MANUAL, "manual" }, \ > { IFM_NONE, "none" }, \ > { 0, NULL }, \ >} > >#define IFM_SUBTYPE_SHARED_ALIASES { \ > { IFM_AUTO, "auto" }, \ > \ > /* \ > * Shorthands for common media+option combinations as announced \ > * by miibus(4) \ > */ \ > { IFM_AUTO | IFM_FLOW, "auto-flow" }, \ > \ > { 0, NULL }, \ >} > >#define IFM_SHARED_OPTION_DESCRIPTIONS { \ > { IFM_FDX, "full-duplex" }, \ > { IFM_HDX, "half-duplex" }, \ > { IFM_FLOW, "flowcontrol" }, \ > { IFM_FLAG0, "flag0" }, \ > { IFM_FLAG1, "flag1" }, \ > { IFM_FLAG2, "flag2" }, \ > { IFM_LOOP, "hw-loopback" }, \ > { 0, NULL }, \ >} > >#define IFM_SHARED_OPTION_ALIASES { \ > { IFM_FDX, "fdx" }, \ > { IFM_HDX, "hdx" }, \ > { IFM_FLOW, "flow" }, \ > { IFM_LOOP, "loop" }, \ > { IFM_LOOP, "loopback" }, \ > { 0, NULL }, \ >} > >/* > * Baudrate descriptions for the various media types. > */ >struct ifmedia_baudrate { > int ifmb_word; /* media word */ > uint64_t ifmb_baudrate; /* corresponding baudrate */ >}; > >#define IFM_BAUDRATE_DESCRIPTIONS { \ > { IFM_ETHER | IFM_10_T, IF_Mbps(10) }, \ > { IFM_ETHER | IFM_10_2, IF_Mbps(10) }, \ > { IFM_ETHER | IFM_10_5, IF_Mbps(10) }, \ > { IFM_ETHER | IFM_100_TX, IF_Mbps(100) }, \ > { IFM_ETHER | IFM_100_FX, IF_Mbps(100) }, \ > { IFM_ETHER | IFM_100_T4, IF_Mbps(100) }, \ > { IFM_ETHER | IFM_100_VG, IF_Mbps(100) }, \ > { IFM_ETHER | IFM_100_T2, IF_Mbps(100) }, \ > { IFM_ETHER | IFM_1000_SX, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_10_STP, IF_Mbps(10) }, \ > { IFM_ETHER | IFM_10_FL, IF_Mbps(10) }, \ > { IFM_ETHER | IFM_1000_LX, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_1000_CX, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_1000_T, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_HPNA_1, IF_Mbps(1) }, \ > { IFM_ETHER | IFM_10G_LR, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_SR, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_CX4, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_2500_SX, IF_Mbps(2500ULL) }, \ > { IFM_ETHER | IFM_10G_TWINAX, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_TWINAX_LONG, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_LRM, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_T, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_40G_CR4, IF_Gbps(40ULL) }, \ > { IFM_ETHER | IFM_40G_SR4, IF_Gbps(40ULL) }, \ > { IFM_ETHER | IFM_40G_LR4, IF_Gbps(40ULL) }, \ > { IFM_ETHER | IFM_1000_KX, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_10G_KX4, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_KR, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_10G_CR1, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_20G_KR2, IF_Gbps(20ULL) }, \ > { IFM_ETHER | IFM_2500_KX, IF_Mbps(2500) }, \ > { IFM_ETHER | IFM_2500_T, IF_Mbps(2500) }, \ > { IFM_ETHER | IFM_5000_T, IF_Mbps(5000) }, \ > { IFM_ETHER | IFM_50G_PCIE, IF_Gbps(50ULL) }, \ > { IFM_ETHER | IFM_25G_PCIE, IF_Gbps(25ULL) }, \ > { IFM_ETHER | IFM_1000_SGMII, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_10G_SFI, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_40G_XLPPI, IF_Gbps(40ULL) }, \ > { IFM_ETHER | IFM_1000_CX_SGMII, IF_Mbps(1000) }, \ > { IFM_ETHER | IFM_40G_KR4, IF_Gbps(40ULL) }, \ > { IFM_ETHER | IFM_10G_ER, IF_Gbps(10ULL) }, \ > { IFM_ETHER | IFM_100G_CR4, IF_Gbps(100ULL) }, \ > { IFM_ETHER | IFM_100G_SR4, IF_Gbps(100ULL) }, \ > { IFM_ETHER | IFM_100G_KR4, IF_Gbps(100ULL) }, \ > { IFM_ETHER | IFM_100G_LR4, IF_Gbps(100ULL) }, \ > { IFM_ETHER | IFM_56G_R4, IF_Gbps(56ULL) }, \ > { IFM_ETHER | IFM_100_T, IF_Mbps(100ULL) }, \ > { IFM_ETHER | IFM_25G_CR, IF_Gbps(25ULL) }, \ > { IFM_ETHER | IFM_25G_KR, IF_Gbps(25ULL) }, \ > { IFM_ETHER | IFM_25G_SR, IF_Gbps(25ULL) }, \ > { IFM_ETHER | IFM_50G_CR2, IF_Gbps(50ULL) }, \ > { IFM_ETHER | IFM_50G_KR2, IF_Gbps(50ULL) }, \ > \ > { IFM_TOKEN | IFM_TOK_STP4, IF_Mbps(4) }, \ > { IFM_TOKEN | IFM_TOK_STP16, IF_Mbps(16) }, \ > { IFM_TOKEN | IFM_TOK_UTP4, IF_Mbps(4) }, \ > { IFM_TOKEN | IFM_TOK_UTP16, IF_Mbps(16) }, \ > \ > { IFM_FDDI | IFM_FDDI_SMF, IF_Mbps(100) }, \ > { IFM_FDDI | IFM_FDDI_MMF, IF_Mbps(100) }, \ > { IFM_FDDI | IFM_FDDI_UTP, IF_Mbps(100) }, \ > \ > { IFM_IEEE80211 | IFM_IEEE80211_FH1, IF_Mbps(1) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_FH2, IF_Mbps(2) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_DS2, IF_Mbps(2) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_DS5, IF_Kbps(5500) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_DS11, IF_Mbps(11) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_DS1, IF_Mbps(1) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_DS22, IF_Mbps(22) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM6, IF_Mbps(6) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM9, IF_Mbps(9) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM12, IF_Mbps(12) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM18, IF_Mbps(18) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM24, IF_Mbps(24) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM36, IF_Mbps(36) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM48, IF_Mbps(48) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM54, IF_Mbps(54) }, \ > { IFM_IEEE80211 | IFM_IEEE80211_OFDM72, IF_Mbps(72) }, \ > \ > { 0, 0 }, \ >} > >/* > * Status descriptions for the various media types. > */ >struct ifmedia_status_description { > int ifms_type; > int ifms_valid; > int ifms_bit; > const char *ifms_string[2]; >}; > >#define IFM_STATUS_DESC(ifms, bit) \ > (ifms)->ifms_string[((ifms)->ifms_bit & (bit)) ? 1 : 0] > >#define IFM_STATUS_DESCRIPTIONS { \ > { IFM_ETHER, IFM_AVALID, IFM_ACTIVE, \ > { "no carrier", "active" } }, \ > { IFM_FDDI, IFM_AVALID, IFM_ACTIVE, \ > { "no ring", "inserted" } }, \ > { IFM_TOKEN, IFM_AVALID, IFM_ACTIVE, \ > { "no ring", "inserted" } }, \ > { IFM_IEEE80211, IFM_AVALID, IFM_ACTIVE, \ > { "no network", "active" } }, \ > { IFM_ATM, IFM_AVALID, IFM_ACTIVE, \ > { "no network", "active" } }, \ > { 0, 0, 0, \ > { NULL, NULL } } \ >} >#endif /* _NET_IF_MEDIA_H_ */ ># 762 "/usr/src/ifnet/sys/net/if_media.h" ># 49 "/usr/src/ifnet/sys/net/if_media.c" 2 > >/* > * Compile-time options: > * IFMEDIA_DEBUG: > * turn on implementation-level debug printfs. > * Useful for debugging newly-ported drivers. > */ > >#ifdef IFMEDIA_DEBUG >int ifmedia_debug = 0; >SYSCTL_INT(_debug, OID_AUTO, ifmedia, CTLFLAG_RW, &ifmedia_debug, > 0, "if_media debugging msgs"); >static void ifmedia_printword(int); >#endif ># 63 "/usr/src/ifnet/sys/net/if_media.c" > >static if_media_t * ifmedia_match(struct ifnet *, if_media_t); >static if_media_t ifmedia_compat(if_media_t media); > >/* > * Set the default active media. > * > * Called by device-specific code which is assumed to have already > * selected the default media in hardware. We do _not_ call the > * media-change callback. > */ >void >if_media_set(struct ifnet *ifp, if_media_t target) >{ > if_media_t *match; > > match = ifmedia_match(ifp, target); > KASSERT(match != NULL, ("%s: ifp %p no match for 0x%x/0x%x\n", > __func__, ifp, target, ~ifp->if_mediamask)); > ifp->if_media = *match; > >#ifdef IFMEDIA_DEBUG > if (ifmedia_debug) { > printf("ifmedia_set: target "); > ifmedia_printword(target); > printf("ifmedia_set: setting to "); > ifmedia_printword(ifm->ifm_cur->ifm_media); > } >#endif ># 92 "/usr/src/ifnet/sys/net/if_media.c" >} > >/* > * Device-independent media ioctl support function. > */ >int >ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, u_long cmd) >{ > struct ifmedia_entry *match; > struct ifmediareq *ifmr = (struct ifmediareq *) ifr; > int error = 0; > > switch (cmd) { > case SIOCSIFMEDIA: > { > struct ifmedia_entry *oldentry; > int oldmedia; > int newmedia = ifr->ifr_media; > > match = ifmedia_match(ifm, newmedia, ifm->ifm_mask); > if (match == NULL) { >#ifdef IFMEDIA_DEBUG > if (ifmedia_debug) { > printf( > "ifmedia_ioctl: no media found for 0x%x\n", > newmedia); > } >#endif ># 120 "/usr/src/ifnet/sys/net/if_media.c" > return (ENXIO); > } > > /* > * If no change, we're done. > * XXX Automedia may involve software intervention. > * Keep going in case the connected media changed. > * Similarly, if best match changed (kernel debugger?). > */ > if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) && > (newmedia == ifm->ifm_media) && > (match == ifm->ifm_cur)) > return 0; > > /* > * We found a match, now make the driver switch to it. > * Make sure to preserve our old media type in case the > * driver can't switch. > */ >#ifdef IFMEDIA_DEBUG > if (ifmedia_debug) { > printf("ifmedia_ioctl: switching %s to ", > ifp->if_xname); > ifmedia_printword(match->ifm_media); > } >#endif ># 146 "/usr/src/ifnet/sys/net/if_media.c" > oldentry = ifm->ifm_cur; > oldmedia = ifm->ifm_media; > ifm->ifm_cur = match; > ifm->ifm_media = newmedia; > error = (*ifm->ifm_change)(ifp); > if (error) { > ifm->ifm_cur = oldentry; > ifm->ifm_media = oldmedia; > } > break; > } > > /* > * Get list of available media and current media on interface. > */ > case SIOCGIFMEDIA: > case SIOCGIFXMEDIA: > { > struct ifmedia_entry *ep; > int i; > > if (ifmr->ifm_count < 0) > return (EINVAL); > > if (cmd == SIOCGIFMEDIA) { > ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ? > compat_media(ifm->ifm_cur->ifm_media) : IFM_NONE; > } else { > ifmr->ifm_active = ifmr->ifm_current = ifm->ifm_cur ? > ifm->ifm_cur->ifm_media : IFM_NONE; > } > ifmr->ifm_mask = ifm->ifm_mask; > ifmr->ifm_status = 0; > (*ifm->ifm_status)(ifp, ifmr); > > /* > * If there are more interfaces on the list, count > * them. This allows the caller to set ifmr->ifm_count > * to 0 on the first call to know how much space to > * allocate. > */ > i = 0; > LIST_FOREACH(ep, &ifm->ifm_list, ifm_list) > if (i++ < ifmr->ifm_count) { > error = copyout(&ep->ifm_media, > ifmr->ifm_ulist + i - 1, sizeof(int)); > if (error) > break; > } > if (error == 0 && i > ifmr->ifm_count) > error = ifmr->ifm_count ? E2BIG : 0; > ifmr->ifm_count = i; > break; > } > > default: > return (EINVAL); > } > > return (error); >} > >/* > * Find media entry index matching a given ifm word. > */ >static if_media_t * >ifmedia_match(struct ifnet *ifp, if_media_t target) >{ > if_media_t *match, mask; > > mask = ~ifp->if_mediamask; > match = NULL; > > for (int i = 0; ifp->if_medias[i] != 0; i++) > if ((ifp->if_medias[i] & mask) == (target & mask)) { >#if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC) > if (match != NULL) > printf("%s: ifp %p multiple match for " > "0x%x/0x%x\n", __func__, ifp, target, mask); >#endif ># 226 "/usr/src/ifnet/sys/net/if_media.c" > match = &ifp->if_medias[i]; > } > > return (match); >} > >/* > * Given a media word, return one suitable for an application > * using the original encoding. > */ >static if_media_t >ifmedia_compat(if_media_t media) >{ > > if (IFM_TYPE(media) == IFM_ETHER && IFM_SUBTYPE(media) > IFM_OTHER) { > media &= ~(IFM_ETH_XTYPE|IFM_TMASK); > media |= IFM_OTHER; > } > return (media); >} > >/* > * Compute the interface `baudrate' from the media, for the interface > * metrics (used by routing daemons). > */ >static const struct ifmedia_baudrate ifmedia_baudrate_descriptions[] = > IFM_BAUDRATE_DESCRIPTIONS; > >uint64_t >ifmedia_baudrate(int mword) >{ > int i; > > for (i = 0; ifmedia_baudrate_descriptions[i].ifmb_word != 0; i++) { > if (IFM_TYPE_MATCH(mword, ifmedia_baudrate_descriptions[i].ifmb_word)) > return (ifmedia_baudrate_descriptions[i].ifmb_baudrate); > } > > /* Not known. */ > return (0); >} > >int >ifmedia_link_state(u_int mstatus) >{ > > if (mstatus & IFM_AVALID) { > if (mstatus & IFM_ACTIVE) > return (LINK_STATE_UP); > else > return (LINK_STATE_DOWN); > } else > return (LINK_STATE_UNKNOWN); >} > >#ifdef IFMEDIA_DEBUG >struct ifmedia_description ifm_type_descriptions[] = > IFM_TYPE_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_ethernet_descriptions[] = > IFM_SUBTYPE_ETHERNET_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_ethernet_option_descriptions[] = > IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_tokenring_descriptions[] = > IFM_SUBTYPE_TOKENRING_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_tokenring_option_descriptions[] = > IFM_SUBTYPE_TOKENRING_OPTION_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_fddi_descriptions[] = > IFM_SUBTYPE_FDDI_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_fddi_option_descriptions[] = > IFM_SUBTYPE_FDDI_OPTION_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_ieee80211_descriptions[] = > IFM_SUBTYPE_IEEE80211_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] = > IFM_SUBTYPE_IEEE80211_OPTION_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] = > IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_atm_descriptions[] = > IFM_SUBTYPE_ATM_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_atm_option_descriptions[] = > IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS; > >struct ifmedia_description ifm_subtype_shared_descriptions[] = > IFM_SUBTYPE_SHARED_DESCRIPTIONS; > >struct ifmedia_description ifm_shared_option_descriptions[] = > IFM_SHARED_OPTION_DESCRIPTIONS; > >struct ifmedia_type_to_subtype { > struct ifmedia_description *subtypes; > struct ifmedia_description *options; > struct ifmedia_description *modes; >}; > >/* must be in the same order as IFM_TYPE_DESCRIPTIONS */ >struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = { > { > &ifm_subtype_ethernet_descriptions[0], > &ifm_subtype_ethernet_option_descriptions[0], > NULL, > }, > { > &ifm_subtype_tokenring_descriptions[0], > &ifm_subtype_tokenring_option_descriptions[0], > NULL, > }, > { > &ifm_subtype_fddi_descriptions[0], > &ifm_subtype_fddi_option_descriptions[0], > NULL, > }, > { > &ifm_subtype_ieee80211_descriptions[0], > &ifm_subtype_ieee80211_option_descriptions[0], > &ifm_subtype_ieee80211_mode_descriptions[0] > }, > { > &ifm_subtype_atm_descriptions[0], > &ifm_subtype_atm_option_descriptions[0], > NULL, > }, >}; > >/* > * print a media word. > */ >static void >ifmedia_printword(ifmw) > int ifmw; >{ > struct ifmedia_description *desc; > struct ifmedia_type_to_subtype *ttos; > int seen_option = 0; > > /* Find the top-level interface type. */ > for (desc = ifm_type_descriptions, ttos = ifmedia_types_to_subtypes; > desc->ifmt_string != NULL; desc++, ttos++) > if (IFM_TYPE(ifmw) == desc->ifmt_word) > break; > if (desc->ifmt_string == NULL) { > printf("<unknown type>\n"); > return; > } > printf("%s", desc->ifmt_string); > > /* Any mode. */ > for (desc = ttos->modes; desc && desc->ifmt_string != NULL; desc++) > if (IFM_MODE(ifmw) == desc->ifmt_word) { > if (desc->ifmt_string != NULL) > printf(" mode %s", desc->ifmt_string); > break; > } > > /* > * Check for the shared subtype descriptions first, then the > * type-specific ones. > */ > for (desc = ifm_subtype_shared_descriptions; > desc->ifmt_string != NULL; desc++) > if (IFM_SUBTYPE(ifmw) == desc->ifmt_word) > goto got_subtype; > > for (desc = ttos->subtypes; desc->ifmt_string != NULL; desc++) > if (IFM_SUBTYPE(ifmw) == desc->ifmt_word) > break; > if (desc->ifmt_string == NULL) { > printf(" <unknown subtype>\n"); > return; > } > > got_subtype: > printf(" %s", desc->ifmt_string); > > /* > * Look for shared options. > */ > for (desc = ifm_shared_option_descriptions; > desc->ifmt_string != NULL; desc++) { > if (ifmw & desc->ifmt_word) { > if (seen_option == 0) > printf(" <"); > printf("%s%s", seen_option++ ? "," : "", > desc->ifmt_string); > } > } > > /* > * Look for subtype-specific options. > */ > for (desc = ttos->options; desc->ifmt_string != NULL; desc++) { > if (ifmw & desc->ifmt_word) { > if (seen_option == 0) > printf(" <"); > printf("%s%s", seen_option++ ? "," : "", > desc->ifmt_string); > } > } > printf("%s\n", seen_option ? ">" : ""); >} >#endif /* IFMEDIA_DEBUG */ ># 436 "/usr/src/ifnet/sys/net/if_media.c"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 199538
: 155723 |
155724