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