1c97bf8c3SAlexander Motin /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3fe267a55SPedro F. Giffuni * 4c97bf8c3SAlexander Motin * Copyright (c) 2005 Nuno Antunes <nuno.antunes@gmail.com> 5c97bf8c3SAlexander Motin * Copyright (c) 2007 Alexander Motin <mav@freebsd.org> 6c97bf8c3SAlexander Motin * All rights reserved. 7c97bf8c3SAlexander Motin * 8c97bf8c3SAlexander Motin * Redistribution and use in source and binary forms, with or without 9c97bf8c3SAlexander Motin * modification, are permitted provided that the following conditions 10c97bf8c3SAlexander Motin * are met: 11c97bf8c3SAlexander Motin * 1. Redistributions of source code must retain the above copyright 12c97bf8c3SAlexander Motin * notice, this list of conditions and the following disclaimer. 13c97bf8c3SAlexander Motin * 2. Redistributions in binary form must reproduce the above copyright 14c97bf8c3SAlexander Motin * notice, this list of conditions and the following disclaimer in the 15c97bf8c3SAlexander Motin * documentation and/or other materials provided with the distribution. 16c97bf8c3SAlexander Motin * 17c97bf8c3SAlexander Motin * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18c97bf8c3SAlexander Motin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19c97bf8c3SAlexander Motin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20c97bf8c3SAlexander Motin * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 21c97bf8c3SAlexander Motin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22c97bf8c3SAlexander Motin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23c97bf8c3SAlexander Motin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24c97bf8c3SAlexander Motin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25c97bf8c3SAlexander Motin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26c97bf8c3SAlexander Motin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27c97bf8c3SAlexander Motin * SUCH DAMAGE. 28c97bf8c3SAlexander Motin */ 29c97bf8c3SAlexander Motin 30c97bf8c3SAlexander Motin #ifndef _NETGRAPH_NG_CAR_H_ 31c97bf8c3SAlexander Motin #define _NETGRAPH_NG_CAR_H_ 32c97bf8c3SAlexander Motin 33c97bf8c3SAlexander Motin #define NG_CAR_NODE_TYPE "car" 34c97bf8c3SAlexander Motin #define NGM_CAR_COOKIE 1173648034 35c97bf8c3SAlexander Motin 36c97bf8c3SAlexander Motin /* Hook names */ 37c97bf8c3SAlexander Motin #define NG_CAR_HOOK_UPPER "upper" 38c97bf8c3SAlexander Motin #define NG_CAR_HOOK_LOWER "lower" 39c97bf8c3SAlexander Motin 40c97bf8c3SAlexander Motin /* Per hook statistics counters */ 41c97bf8c3SAlexander Motin struct ng_car_hookstats { 42c97bf8c3SAlexander Motin u_int64_t passed_pkts; /* Counter for passed packets */ 43def4e701SGleb Smirnoff u_int64_t dropped_pkts; /* Counter for dropped packets */ 44c97bf8c3SAlexander Motin u_int64_t green_pkts; /* Counter for green packets */ 45c97bf8c3SAlexander Motin u_int64_t yellow_pkts; /* Counter for yellow packets */ 46c97bf8c3SAlexander Motin u_int64_t red_pkts; /* Counter for red packets */ 47c97bf8c3SAlexander Motin u_int64_t errors; /* Counter for operation errors */ 48c97bf8c3SAlexander Motin }; 49c97bf8c3SAlexander Motin #define NG_CAR_HOOKSTATS { \ 50c97bf8c3SAlexander Motin { "passed", &ng_parse_uint64_type }, \ 51def4e701SGleb Smirnoff { "dropped", &ng_parse_uint64_type }, \ 52c97bf8c3SAlexander Motin { "green", &ng_parse_uint64_type }, \ 53c97bf8c3SAlexander Motin { "yellow", &ng_parse_uint64_type }, \ 54c97bf8c3SAlexander Motin { "red", &ng_parse_uint64_type }, \ 55c97bf8c3SAlexander Motin { "errors", &ng_parse_uint64_type }, \ 56c97bf8c3SAlexander Motin { NULL } \ 57c97bf8c3SAlexander Motin } 58c97bf8c3SAlexander Motin 59c97bf8c3SAlexander Motin /* Bulk statistics */ 60c97bf8c3SAlexander Motin struct ng_car_bulkstats { 61c97bf8c3SAlexander Motin struct ng_car_hookstats upstream; 62c97bf8c3SAlexander Motin struct ng_car_hookstats downstream; 63c97bf8c3SAlexander Motin }; 64c97bf8c3SAlexander Motin #define NG_CAR_BULKSTATS(hstatstype) { \ 65c97bf8c3SAlexander Motin { "upstream", (hstatstype) }, \ 66c97bf8c3SAlexander Motin { "downstream", (hstatstype) }, \ 67c97bf8c3SAlexander Motin { NULL } \ 68c97bf8c3SAlexander Motin } 69c97bf8c3SAlexander Motin 70c97bf8c3SAlexander Motin /* Per hook configuration */ 71c97bf8c3SAlexander Motin struct ng_car_hookconf { 72053359b7SPedro F. Giffuni u_int64_t cbs; /* Committed burst size (bytes) */ 73c97bf8c3SAlexander Motin u_int64_t ebs; /* Exceeded/Peak burst size (bytes) */ 74053359b7SPedro F. Giffuni u_int64_t cir; /* Committed information rate (bits/s) */ 75c97bf8c3SAlexander Motin u_int64_t pir; /* Peak information rate (bits/s) */ 76c97bf8c3SAlexander Motin u_int8_t green_action; /* Action for green packets */ 77c97bf8c3SAlexander Motin u_int8_t yellow_action; /* Action for yellow packets */ 78c97bf8c3SAlexander Motin u_int8_t red_action; /* Action for red packets */ 79c97bf8c3SAlexander Motin u_int8_t mode; /* single/double rate, ... */ 80c97bf8c3SAlexander Motin u_int8_t opt; /* color-aware or color-blind */ 81c97bf8c3SAlexander Motin }; 82c97bf8c3SAlexander Motin /* Keep this definition in sync with the above structure */ 83c97bf8c3SAlexander Motin #define NG_CAR_HOOKCONF { \ 84c97bf8c3SAlexander Motin { "cbs", &ng_parse_uint64_type }, \ 85c97bf8c3SAlexander Motin { "ebs", &ng_parse_uint64_type }, \ 86c97bf8c3SAlexander Motin { "cir", &ng_parse_uint64_type }, \ 87c97bf8c3SAlexander Motin { "pir", &ng_parse_uint64_type }, \ 88c97bf8c3SAlexander Motin { "greenAction", &ng_parse_uint8_type }, \ 89c97bf8c3SAlexander Motin { "yellowAction", &ng_parse_uint8_type }, \ 90c97bf8c3SAlexander Motin { "redAction", &ng_parse_uint8_type }, \ 91c97bf8c3SAlexander Motin { "mode", &ng_parse_uint8_type }, \ 92c97bf8c3SAlexander Motin { "opt", &ng_parse_uint8_type }, \ 93c97bf8c3SAlexander Motin { NULL } \ 94c97bf8c3SAlexander Motin } 95c97bf8c3SAlexander Motin 96c97bf8c3SAlexander Motin #define NG_CAR_CBS_MIN 8192 97c97bf8c3SAlexander Motin #define NG_CAR_EBS_MIN 8192 98c97bf8c3SAlexander Motin #define NG_CAR_CIR_DFLT 10240 99c97bf8c3SAlexander Motin 100c97bf8c3SAlexander Motin /* possible actions (...Action) */ 101c97bf8c3SAlexander Motin enum { 102c97bf8c3SAlexander Motin NG_CAR_ACTION_FORWARD = 1, 103c97bf8c3SAlexander Motin NG_CAR_ACTION_DROP, 104d0d2e523SLutz Donnerhacke NG_CAR_ACTION_MARK 105c97bf8c3SAlexander Motin }; 106c97bf8c3SAlexander Motin 107c97bf8c3SAlexander Motin /* operation modes (mode) */ 108c97bf8c3SAlexander Motin enum { 109c97bf8c3SAlexander Motin NG_CAR_SINGLE_RATE = 0, 110c97bf8c3SAlexander Motin NG_CAR_DOUBLE_RATE, 111c97bf8c3SAlexander Motin NG_CAR_RED, 112c97bf8c3SAlexander Motin NG_CAR_SHAPE 113c97bf8c3SAlexander Motin }; 114c97bf8c3SAlexander Motin 115d0d2e523SLutz Donnerhacke /* mode options (bits in opt) */ 116c97bf8c3SAlexander Motin #define NG_CAR_COLOR_AWARE 1 117673f5a8bSAlexander Motin #define NG_CAR_COUNT_PACKETS 2 118c97bf8c3SAlexander Motin 119c97bf8c3SAlexander Motin /* Bulk config */ 120c97bf8c3SAlexander Motin struct ng_car_bulkconf { 121c97bf8c3SAlexander Motin struct ng_car_hookconf upstream; 122c97bf8c3SAlexander Motin struct ng_car_hookconf downstream; 123c97bf8c3SAlexander Motin }; 124c97bf8c3SAlexander Motin #define NG_CAR_BULKCONF(hconftype) { \ 125c97bf8c3SAlexander Motin { "upstream", (hconftype) }, \ 126c97bf8c3SAlexander Motin { "downstream", (hconftype) }, \ 127c97bf8c3SAlexander Motin { NULL } \ 128c97bf8c3SAlexander Motin } 129c97bf8c3SAlexander Motin 130c97bf8c3SAlexander Motin /* Commands */ 131c97bf8c3SAlexander Motin enum { 132c97bf8c3SAlexander Motin NGM_CAR_GET_STATS = 1, /* Get statistics */ 133c97bf8c3SAlexander Motin NGM_CAR_CLR_STATS, /* Clear statistics */ 134c97bf8c3SAlexander Motin NGM_CAR_GETCLR_STATS, /* Get and clear statistics */ 135c97bf8c3SAlexander Motin NGM_CAR_GET_CONF, /* Get bulk configuration */ 136c97bf8c3SAlexander Motin NGM_CAR_SET_CONF, /* Set bulk configuration */ 137c97bf8c3SAlexander Motin }; 138c97bf8c3SAlexander Motin 139c97bf8c3SAlexander Motin #endif /* _NETGRAPH_NG_CAR_H_ */ 140