1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2004-2008 University of Zagreb 5 * Copyright (c) 2007-2008 FreeBSD Foundation 6 * 7 * This software was developed by the University of Zagreb and the 8 * FreeBSD Foundation under sponsorship by the Stichting NLnet and the 9 * FreeBSD Foundation. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * $FreeBSD$ 33 */ 34 35 #ifndef _NETGRAPH_PIPE_H_ 36 #define _NETGRAPH_PIPE_H_ 37 38 /* Node type name and magic cookie */ 39 #define NG_PIPE_NODE_TYPE "pipe" 40 #define NGM_PIPE_COOKIE 200708191 41 42 /* Hook names */ 43 #define NG_PIPE_HOOK_UPPER "upper" 44 #define NG_PIPE_HOOK_LOWER "lower" 45 46 #define MAX_FSIZE 16384 /* Largest supported frame size, in bytes, for BER */ 47 #define MAX_OHSIZE 256 /* Largest supported dummy-framing size, in bytes */ 48 49 /* Statistics structure for one hook */ 50 struct ng_pipe_hookstat { 51 u_int64_t fwd_octets; 52 u_int64_t fwd_frames; 53 u_int64_t in_disc_octets; 54 u_int64_t in_disc_frames; 55 u_int64_t out_disc_octets; 56 u_int64_t out_disc_frames; 57 }; 58 59 /* Keep this in sync with the above structure definition */ 60 #define NG_PIPE_HOOKSTAT_INFO { \ 61 { "FwdOctets", &ng_parse_uint64_type }, \ 62 { "FwdFrames", &ng_parse_uint64_type }, \ 63 { "queueDropOctets", &ng_parse_uint64_type }, \ 64 { "queueDropFrames", &ng_parse_uint64_type }, \ 65 { "delayDropOctets", &ng_parse_uint64_type }, \ 66 { "delayDropFrames", &ng_parse_uint64_type }, \ 67 { NULL }, \ 68 } 69 70 /* Statistics structure returned by NGM_PIPE_GET_STATS */ 71 struct ng_pipe_stats { 72 struct ng_pipe_hookstat downstream; 73 struct ng_pipe_hookstat upstream; 74 }; 75 76 /* Keep this in sync with the above structure definition */ 77 #define NG_PIPE_STATS_INFO(hstype) { \ 78 { "downstream", (hstype) }, \ 79 { "upstream", (hstype) }, \ 80 { NULL }, \ 81 } 82 83 /* Runtime structure for one hook */ 84 struct ng_pipe_hookrun { 85 u_int32_t fifo_queues; 86 u_int32_t qin_octets; 87 u_int32_t qin_frames; 88 u_int32_t qout_octets; 89 u_int32_t qout_frames; 90 }; 91 92 /* Keep this in sync with the above structure definition */ 93 #define NG_PIPE_HOOKRUN_INFO { \ 94 { "queues", &ng_parse_uint32_type }, \ 95 { "queuedOctets", &ng_parse_uint32_type }, \ 96 { "queuedFrames", &ng_parse_uint32_type }, \ 97 { "delayedOctets", &ng_parse_uint32_type }, \ 98 { "delayedFrames", &ng_parse_uint32_type }, \ 99 { NULL }, \ 100 } 101 102 /* Runtime structure returned by NGM_PIPE_GET_RUN */ 103 struct ng_pipe_run { 104 struct ng_pipe_hookrun downstream; 105 struct ng_pipe_hookrun upstream; 106 }; 107 108 /* Keep this in sync with the above structure definition */ 109 #define NG_PIPE_RUN_INFO(hstype) { \ 110 { "downstream", (hstype) }, \ 111 { "upstream", (hstype) }, \ 112 { NULL }, \ 113 } 114 115 /* Config structure for one hook */ 116 struct ng_pipe_hookcfg { 117 u_int64_t bandwidth; 118 u_int64_t ber; 119 u_int32_t qin_size_limit; 120 u_int32_t qout_size_limit; 121 u_int32_t duplicate; 122 u_int32_t fifo; 123 u_int32_t drr; 124 u_int32_t wfq; 125 u_int32_t droptail; 126 u_int32_t drophead; 127 }; 128 129 /* Keep this in sync with the above structure definition */ 130 #define NG_PIPE_HOOKCFG_INFO { \ 131 { "bandwidth", &ng_parse_uint64_type }, \ 132 { "BER", &ng_parse_uint64_type }, \ 133 { "queuelen", &ng_parse_uint32_type }, \ 134 { "delaylen", &ng_parse_uint32_type }, \ 135 { "duplicate", &ng_parse_uint32_type }, \ 136 { "fifo", &ng_parse_uint32_type }, \ 137 { "drr", &ng_parse_uint32_type }, \ 138 { "wfq", &ng_parse_uint32_type }, \ 139 { "droptail", &ng_parse_uint32_type }, \ 140 { "drophead", &ng_parse_uint32_type }, \ 141 { NULL }, \ 142 } 143 144 /* Config structure returned by NGM_PIPE_GET_CFG */ 145 struct ng_pipe_cfg { 146 u_int64_t bandwidth; 147 u_int64_t delay; 148 u_int32_t header_offset; 149 u_int32_t overhead; 150 struct ng_pipe_hookcfg downstream; 151 struct ng_pipe_hookcfg upstream; 152 }; 153 154 /* Keep this in sync with the above structure definition */ 155 #define NG_PIPE_CFG_INFO(hstype) { \ 156 { "bandwidth", &ng_parse_uint64_type }, \ 157 { "delay", &ng_parse_uint64_type }, \ 158 { "header_offset", &ng_parse_uint32_type }, \ 159 { "overhead", &ng_parse_uint32_type }, \ 160 { "downstream", (hstype) }, \ 161 { "upstream", (hstype) }, \ 162 { NULL }, \ 163 } 164 165 /* Netgraph commands */ 166 enum { 167 NGM_PIPE_GET_STATS=1, /* get stats */ 168 NGM_PIPE_CLR_STATS, /* clear stats */ 169 NGM_PIPE_GETCLR_STATS, /* atomically get and clear stats */ 170 NGM_PIPE_GET_RUN, /* get current runtime status */ 171 NGM_PIPE_GET_CFG, /* get configurable parameters */ 172 NGM_PIPE_SET_CFG, /* set configurable parameters */ 173 }; 174 175 #endif /* _NETGRAPH_PIPE_H_ */ 176