altq_priq.h revision 298133
1/* $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $ */ 2/* 3 * Copyright (C) 2000-2003 4 * Sony Computer Science Laboratories Inc. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#ifndef _ALTQ_ALTQ_PRIQ_H_ 29#define _ALTQ_ALTQ_PRIQ_H_ 30 31#include <altq/altq.h> 32#include <altq/altq_classq.h> 33#include <altq/altq_codel.h> 34#include <altq/altq_red.h> 35#include <altq/altq_rio.h> 36 37#ifdef __cplusplus 38extern "C" { 39#endif 40 41#define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ 42 43#ifdef ALTQ3_COMPAT 44struct priq_interface { 45 char ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ 46 u_long arg; /* request-specific argument */ 47}; 48 49struct priq_add_class { 50 struct priq_interface iface; 51 int pri; /* priority (0 is the lowest) */ 52 int qlimit; /* queue size limit */ 53 int flags; /* misc flags (see below) */ 54 55 u_int32_t class_handle; /* return value */ 56}; 57#endif /* ALTQ3_COMPAT */ 58 59/* priq class flags */ 60#define PRCF_RED 0x0001 /* use RED */ 61#define PRCF_ECN 0x0002 /* use RED/ECN */ 62#define PRCF_RIO 0x0004 /* use RIO */ 63#define PRCF_CODEL 0x0008 /* use CoDel */ 64#define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 65#define PRCF_DEFAULTCLASS 0x1000 /* default class */ 66 67/* special class handles */ 68#define PRIQ_NULLCLASS_HANDLE 0 69 70#ifdef ALTQ3_COMPAT 71struct priq_delete_class { 72 struct priq_interface iface; 73 u_int32_t class_handle; 74}; 75 76struct priq_modify_class { 77 struct priq_interface iface; 78 u_int32_t class_handle; 79 int pri; 80 int qlimit; 81 int flags; 82}; 83 84struct priq_add_filter { 85 struct priq_interface iface; 86 u_int32_t class_handle; 87 struct flow_filter filter; 88 89 u_long filter_handle; /* return value */ 90}; 91 92struct priq_delete_filter { 93 struct priq_interface iface; 94 u_long filter_handle; 95}; 96#endif /* ALTQ3_COMPAT */ 97 98struct priq_classstats { 99 u_int32_t class_handle; 100 101 u_int qlength; 102 u_int qlimit; 103 u_int period; 104 struct pktcntr xmitcnt; /* transmitted packet counter */ 105 struct pktcntr dropcnt; /* dropped packet counter */ 106 107 /* codel, red and rio related info */ 108 int qtype; 109 struct redstats red[3]; /* rio has 3 red stats */ 110 struct codel_stats codel; 111}; 112 113#ifdef ALTQ3_COMPAT 114struct priq_class_stats { 115 struct priq_interface iface; 116 int maxpri; /* in/out */ 117 118 struct priq_classstats *stats; /* pointer to stats array */ 119}; 120 121#define PRIQ_IF_ATTACH _IOW('Q', 1, struct priq_interface) 122#define PRIQ_IF_DETACH _IOW('Q', 2, struct priq_interface) 123#define PRIQ_ENABLE _IOW('Q', 3, struct priq_interface) 124#define PRIQ_DISABLE _IOW('Q', 4, struct priq_interface) 125#define PRIQ_CLEAR _IOW('Q', 5, struct priq_interface) 126#define PRIQ_ADD_CLASS _IOWR('Q', 7, struct priq_add_class) 127#define PRIQ_DEL_CLASS _IOW('Q', 8, struct priq_delete_class) 128#define PRIQ_MOD_CLASS _IOW('Q', 9, struct priq_modify_class) 129#define PRIQ_ADD_FILTER _IOWR('Q', 10, struct priq_add_filter) 130#define PRIQ_DEL_FILTER _IOW('Q', 11, struct priq_delete_filter) 131#define PRIQ_GETSTATS _IOWR('Q', 12, struct priq_class_stats) 132 133#endif /* ALTQ3_COMPAT */ 134 135#ifdef _KERNEL 136 137struct priq_class { 138 u_int32_t cl_handle; /* class handle */ 139 class_queue_t *cl_q; /* class queue structure */ 140 union { 141 struct red *cl_red; /* RED state */ 142 struct codel *cl_codel; /* CoDel state */ 143 } cl_aqm; 144#define cl_red cl_aqm.cl_red 145#define cl_codel cl_aqm.cl_codel 146 int cl_pri; /* priority */ 147 int cl_flags; /* class flags */ 148 struct priq_if *cl_pif; /* back pointer to pif */ 149 struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ 150 151 /* statistics */ 152 u_int cl_period; /* backlog period */ 153 struct pktcntr cl_xmitcnt; /* transmitted packet counter */ 154 struct pktcntr cl_dropcnt; /* dropped packet counter */ 155}; 156 157/* 158 * priq interface state 159 */ 160struct priq_if { 161 struct priq_if *pif_next; /* interface state list */ 162 struct ifaltq *pif_ifq; /* backpointer to ifaltq */ 163 u_int pif_bandwidth; /* link bandwidth in bps */ 164 int pif_maxpri; /* max priority in use */ 165 struct priq_class *pif_default; /* default class */ 166 struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */ 167#ifdef ALTQ3_CLFIER_COMPAT 168 struct acc_classifier pif_classifier; /* classifier */ 169#endif 170}; 171 172#endif /* _KERNEL */ 173 174#ifdef __cplusplus 175} 176#endif 177 178#endif /* _ALTQ_ALTQ_PRIQ_H_ */ 179