1130365Smlaier/* $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $ */ 2130365Smlaier/* 3130365Smlaier * Copyright (C) 2000-2003 4130365Smlaier * Sony Computer Science Laboratories Inc. All rights reserved. 5130365Smlaier * 6130365Smlaier * Redistribution and use in source and binary forms, with or without 7130365Smlaier * modification, are permitted provided that the following conditions 8130365Smlaier * are met: 9130365Smlaier * 1. Redistributions of source code must retain the above copyright 10130365Smlaier * notice, this list of conditions and the following disclaimer. 11130365Smlaier * 2. Redistributions in binary form must reproduce the above copyright 12130365Smlaier * notice, this list of conditions and the following disclaimer in the 13130365Smlaier * documentation and/or other materials provided with the distribution. 14130365Smlaier * 15130365Smlaier * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND 16130365Smlaier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17130365Smlaier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18130365Smlaier * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE 19130365Smlaier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20130365Smlaier * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21130365Smlaier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22130365Smlaier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23130365Smlaier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24130365Smlaier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25130365Smlaier * SUCH DAMAGE. 26130365Smlaier */ 27130365Smlaier 28130365Smlaier#ifndef _ALTQ_ALTQ_PRIQ_H_ 29130365Smlaier#define _ALTQ_ALTQ_PRIQ_H_ 30130365Smlaier 31130365Smlaier#include <altq/altq.h> 32130365Smlaier#include <altq/altq_classq.h> 33130365Smlaier#include <altq/altq_red.h> 34130365Smlaier#include <altq/altq_rio.h> 35130365Smlaier 36130365Smlaier#ifdef __cplusplus 37130365Smlaierextern "C" { 38130365Smlaier#endif 39130365Smlaier 40130365Smlaier#define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ 41130365Smlaier 42130365Smlaier#ifdef ALTQ3_COMPAT 43130365Smlaierstruct priq_interface { 44130365Smlaier char ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ 45130365Smlaier u_long arg; /* request-specific argument */ 46130365Smlaier}; 47130365Smlaier 48130365Smlaierstruct priq_add_class { 49130365Smlaier struct priq_interface iface; 50130365Smlaier int pri; /* priority (0 is the lowest) */ 51130365Smlaier int qlimit; /* queue size limit */ 52130365Smlaier int flags; /* misc flags (see below) */ 53130365Smlaier 54130365Smlaier u_int32_t class_handle; /* return value */ 55130365Smlaier}; 56130365Smlaier#endif /* ALTQ3_COMPAT */ 57130365Smlaier 58130365Smlaier/* priq class flags */ 59130365Smlaier#define PRCF_RED 0x0001 /* use RED */ 60130365Smlaier#define PRCF_ECN 0x0002 /* use RED/ECN */ 61130365Smlaier#define PRCF_RIO 0x0004 /* use RIO */ 62130365Smlaier#define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 63130365Smlaier#define PRCF_DEFAULTCLASS 0x1000 /* default class */ 64130365Smlaier 65130365Smlaier/* special class handles */ 66130365Smlaier#define PRIQ_NULLCLASS_HANDLE 0 67130365Smlaier 68130365Smlaier#ifdef ALTQ3_COMPAT 69130365Smlaierstruct priq_delete_class { 70130365Smlaier struct priq_interface iface; 71130365Smlaier u_int32_t class_handle; 72130365Smlaier}; 73130365Smlaier 74130365Smlaierstruct priq_modify_class { 75130365Smlaier struct priq_interface iface; 76130365Smlaier u_int32_t class_handle; 77130365Smlaier int pri; 78130365Smlaier int qlimit; 79130365Smlaier int flags; 80130365Smlaier}; 81130365Smlaier 82130365Smlaierstruct priq_add_filter { 83130365Smlaier struct priq_interface iface; 84130365Smlaier u_int32_t class_handle; 85130365Smlaier struct flow_filter filter; 86130365Smlaier 87130365Smlaier u_long filter_handle; /* return value */ 88130365Smlaier}; 89130365Smlaier 90130365Smlaierstruct priq_delete_filter { 91130365Smlaier struct priq_interface iface; 92130365Smlaier u_long filter_handle; 93130365Smlaier}; 94130365Smlaier#endif /* ALTQ3_COMPAT */ 95130365Smlaier 96130365Smlaierstruct priq_classstats { 97130365Smlaier u_int32_t class_handle; 98130365Smlaier 99130365Smlaier u_int qlength; 100130365Smlaier u_int qlimit; 101130365Smlaier u_int period; 102130365Smlaier struct pktcntr xmitcnt; /* transmitted packet counter */ 103130365Smlaier struct pktcntr dropcnt; /* dropped packet counter */ 104130365Smlaier 105130365Smlaier /* red and rio related info */ 106130365Smlaier int qtype; 107130365Smlaier struct redstats red[3]; /* rio has 3 red stats */ 108130365Smlaier}; 109130365Smlaier 110130365Smlaier#ifdef ALTQ3_COMPAT 111130365Smlaierstruct priq_class_stats { 112130365Smlaier struct priq_interface iface; 113130365Smlaier int maxpri; /* in/out */ 114130365Smlaier 115130365Smlaier struct priq_classstats *stats; /* pointer to stats array */ 116130365Smlaier}; 117130365Smlaier 118130365Smlaier#define PRIQ_IF_ATTACH _IOW('Q', 1, struct priq_interface) 119130365Smlaier#define PRIQ_IF_DETACH _IOW('Q', 2, struct priq_interface) 120130365Smlaier#define PRIQ_ENABLE _IOW('Q', 3, struct priq_interface) 121130365Smlaier#define PRIQ_DISABLE _IOW('Q', 4, struct priq_interface) 122130365Smlaier#define PRIQ_CLEAR _IOW('Q', 5, struct priq_interface) 123130365Smlaier#define PRIQ_ADD_CLASS _IOWR('Q', 7, struct priq_add_class) 124130365Smlaier#define PRIQ_DEL_CLASS _IOW('Q', 8, struct priq_delete_class) 125130365Smlaier#define PRIQ_MOD_CLASS _IOW('Q', 9, struct priq_modify_class) 126130365Smlaier#define PRIQ_ADD_FILTER _IOWR('Q', 10, struct priq_add_filter) 127130365Smlaier#define PRIQ_DEL_FILTER _IOW('Q', 11, struct priq_delete_filter) 128130365Smlaier#define PRIQ_GETSTATS _IOWR('Q', 12, struct priq_class_stats) 129130365Smlaier 130130365Smlaier#endif /* ALTQ3_COMPAT */ 131130365Smlaier 132130365Smlaier#ifdef _KERNEL 133130365Smlaier 134130365Smlaierstruct priq_class { 135130365Smlaier u_int32_t cl_handle; /* class handle */ 136130365Smlaier class_queue_t *cl_q; /* class queue structure */ 137130365Smlaier struct red *cl_red; /* RED state */ 138130365Smlaier int cl_pri; /* priority */ 139130365Smlaier int cl_flags; /* class flags */ 140130365Smlaier struct priq_if *cl_pif; /* back pointer to pif */ 141130365Smlaier struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ 142130365Smlaier 143130365Smlaier /* statistics */ 144130365Smlaier u_int cl_period; /* backlog period */ 145130365Smlaier struct pktcntr cl_xmitcnt; /* transmitted packet counter */ 146130365Smlaier struct pktcntr cl_dropcnt; /* dropped packet counter */ 147130365Smlaier}; 148130365Smlaier 149130365Smlaier/* 150130365Smlaier * priq interface state 151130365Smlaier */ 152130365Smlaierstruct priq_if { 153130365Smlaier struct priq_if *pif_next; /* interface state list */ 154130365Smlaier struct ifaltq *pif_ifq; /* backpointer to ifaltq */ 155130365Smlaier u_int pif_bandwidth; /* link bandwidth in bps */ 156130365Smlaier int pif_maxpri; /* max priority in use */ 157130365Smlaier struct priq_class *pif_default; /* default class */ 158130365Smlaier struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */ 159130365Smlaier#ifdef ALTQ3_CLFIER_COMPAT 160130365Smlaier struct acc_classifier pif_classifier; /* classifier */ 161130365Smlaier#endif 162130365Smlaier}; 163130365Smlaier 164130365Smlaier#endif /* _KERNEL */ 165130365Smlaier 166130365Smlaier#ifdef __cplusplus 167130365Smlaier} 168130365Smlaier#endif 169130365Smlaier 170130365Smlaier#endif /* _ALTQ_ALTQ_PRIQ_H_ */ 171