ng_car.h revision 169577
1228072Sbapt/*- 2228072Sbapt * Copyright (c) 2005 Nuno Antunes <nuno.antunes@gmail.com> 3228072Sbapt * Copyright (c) 2007 Alexander Motin <mav@freebsd.org> 4228072Sbapt * All rights reserved. 5228072Sbapt * 6228072Sbapt * Redistribution and use in source and binary forms, with or without 7228072Sbapt * modification, are permitted provided that the following conditions 8228072Sbapt * are met: 9228072Sbapt * 1. Redistributions of source code must retain the above copyright 10228072Sbapt * notice, this list of conditions and the following disclaimer. 11228072Sbapt * 2. Redistributions in binary form must reproduce the above copyright 12228072Sbapt * notice, this list of conditions and the following disclaimer in the 13228072Sbapt * documentation and/or other materials provided with the distribution. 14228072Sbapt * 15228072Sbapt * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16228072Sbapt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17228072Sbapt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18228072Sbapt * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 19228072Sbapt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20228072Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21228072Sbapt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22228072Sbapt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23228072Sbapt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24228072Sbapt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25228072Sbapt * SUCH DAMAGE. 26228072Sbapt * 27228072Sbapt * $FreeBSD: head/sys/netgraph/ng_car.h 169577 2007-05-15 16:09:23Z mav $ 28228072Sbapt */ 29228072Sbapt 30228072Sbapt#ifndef _NETGRAPH_NG_CAR_H_ 31228072Sbapt#define _NETGRAPH_NG_CAR_H_ 32228072Sbapt 33228072Sbapt#define NG_CAR_NODE_TYPE "car" 34228072Sbapt#define NGM_CAR_COOKIE 1173648034 35228072Sbapt 36228072Sbapt/* Hook names */ 37228072Sbapt#define NG_CAR_HOOK_UPPER "upper" 38228072Sbapt#define NG_CAR_HOOK_LOWER "lower" 39228072Sbapt 40228072Sbapt/* Per hook statistics counters */ 41228072Sbaptstruct ng_car_hookstats { 42228072Sbapt u_int64_t passed_pkts; /* Counter for passed packets */ 43228072Sbapt u_int64_t droped_pkts; /* Counter for droped packets */ 44228072Sbapt u_int64_t green_pkts; /* Counter for green packets */ 45228072Sbapt u_int64_t yellow_pkts; /* Counter for yellow packets */ 46228072Sbapt u_int64_t red_pkts; /* Counter for red packets */ 47228072Sbapt u_int64_t errors; /* Counter for operation errors */ 48228072Sbapt}; 49228072Sbapt#define NG_CAR_HOOKSTATS { \ 50228072Sbapt { "passed", &ng_parse_uint64_type }, \ 51228072Sbapt { "droped", &ng_parse_uint64_type }, \ 52228072Sbapt { "green", &ng_parse_uint64_type }, \ 53228072Sbapt { "yellow", &ng_parse_uint64_type }, \ 54228072Sbapt { "red", &ng_parse_uint64_type }, \ 55228072Sbapt { "errors", &ng_parse_uint64_type }, \ 56228072Sbapt { NULL } \ 57228072Sbapt} 58228072Sbapt 59228072Sbapt/* Bulk statistics */ 60250125Sjkimstruct ng_car_bulkstats { 61228072Sbapt struct ng_car_hookstats upstream; 62228072Sbapt struct ng_car_hookstats downstream; 63228072Sbapt}; 64228072Sbapt#define NG_CAR_BULKSTATS(hstatstype) { \ 65228072Sbapt { "upstream", (hstatstype) }, \ 66228072Sbapt { "downstream", (hstatstype) }, \ 67228072Sbapt { NULL } \ 68228072Sbapt} 69228072Sbapt 70228072Sbapt/* Per hook configuration */ 71228072Sbaptstruct ng_car_hookconf { 72228072Sbapt u_int64_t cbs; /* Commited burst size (bytes) */ 73228072Sbapt u_int64_t ebs; /* Exceeded/Peak burst size (bytes) */ 74228072Sbapt u_int64_t cir; /* Commited information rate (bits/s) */ 75228072Sbapt u_int64_t pir; /* Peak information rate (bits/s) */ 76228072Sbapt u_int8_t green_action; /* Action for green packets */ 77228072Sbapt u_int8_t yellow_action; /* Action for yellow packets */ 78228072Sbapt u_int8_t red_action; /* Action for red packets */ 79228072Sbapt u_int8_t mode; /* single/double rate, ... */ 80228072Sbapt u_int8_t opt; /* color-aware or color-blind */ 81228072Sbapt}; 82228072Sbapt/* Keep this definition in sync with the above structure */ 83228072Sbapt#define NG_CAR_HOOKCONF { \ 84228072Sbapt { "cbs", &ng_parse_uint64_type }, \ 85228072Sbapt { "ebs", &ng_parse_uint64_type }, \ 86228072Sbapt { "cir", &ng_parse_uint64_type }, \ 87228072Sbapt { "pir", &ng_parse_uint64_type }, \ 88228072Sbapt { "greenAction", &ng_parse_uint8_type }, \ 89228072Sbapt { "yellowAction", &ng_parse_uint8_type }, \ 90228072Sbapt { "redAction", &ng_parse_uint8_type }, \ 91228072Sbapt { "mode", &ng_parse_uint8_type }, \ 92228072Sbapt { "opt", &ng_parse_uint8_type }, \ 93228072Sbapt { NULL } \ 94228072Sbapt} 95228072Sbapt 96228072Sbapt#define NG_CAR_CBS_MIN 8192 97228072Sbapt#define NG_CAR_EBS_MIN 8192 98228072Sbapt#define NG_CAR_CIR_DFLT 10240 99228072Sbapt 100228072Sbapt/* possible actions (...Action) */ 101228072Sbaptenum { 102228072Sbapt NG_CAR_ACTION_FORWARD = 1, 103228072Sbapt NG_CAR_ACTION_DROP, 104228072Sbapt NG_CAR_ACTION_MARK, 105228072Sbapt NG_CAR_ACTION_SET_TOS 106228072Sbapt}; 107228072Sbapt 108228072Sbapt/* operation modes (mode) */ 109228072Sbaptenum { 110228072Sbapt NG_CAR_SINGLE_RATE = 0, 111228072Sbapt NG_CAR_DOUBLE_RATE, 112228072Sbapt NG_CAR_RED, 113228072Sbapt NG_CAR_SHAPE 114228072Sbapt}; 115228072Sbapt 116228072Sbapt/* mode options (opt) */ 117228072Sbapt#define NG_CAR_COLOR_AWARE 1 118228072Sbapt 119228072Sbapt/* Bulk config */ 120228072Sbaptstruct ng_car_bulkconf { 121228072Sbapt struct ng_car_hookconf upstream; 122228072Sbapt struct ng_car_hookconf downstream; 123228072Sbapt}; 124228072Sbapt#define NG_CAR_BULKCONF(hconftype) { \ 125228072Sbapt { "upstream", (hconftype) }, \ 126228072Sbapt { "downstream", (hconftype) }, \ 127228072Sbapt { NULL } \ 128228072Sbapt} 129228072Sbapt 130228072Sbapt/* Commands */ 131228072Sbaptenum { 132228072Sbapt NGM_CAR_GET_STATS = 1, /* Get statistics */ 133228072Sbapt NGM_CAR_CLR_STATS, /* Clear statistics */ 134228072Sbapt NGM_CAR_GETCLR_STATS, /* Get and clear statistics */ 135228072Sbapt NGM_CAR_GET_CONF, /* Get bulk configuration */ 136228072Sbapt NGM_CAR_SET_CONF, /* Set bulk configuration */ 137228072Sbapt}; 138228072Sbapt 139228072Sbapt#endif /* _NETGRAPH_NG_CAR_H_ */ 140228072Sbapt