altq_priq.h revision 130365
128219Smsmith/* $KAME: altq_priq.h,v 1.7 2003/10/03 05:05:15 kjc Exp $ */ 255939Snsouch/* 328219Smsmith * Copyright (C) 2000-2003 428219Smsmith * Sony Computer Science Laboratories Inc. All rights reserved. 528219Smsmith * 628219Smsmith * Redistribution and use in source and binary forms, with or without 728219Smsmith * modification, are permitted provided that the following conditions 828219Smsmith * are met: 928219Smsmith * 1. Redistributions of source code must retain the above copyright 1028219Smsmith * notice, this list of conditions and the following disclaimer. 1128219Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1228219Smsmith * notice, this list of conditions and the following disclaimer in the 1328219Smsmith * documentation and/or other materials provided with the distribution. 1428219Smsmith * 1528219Smsmith * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND 1628219Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1728219Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1828219Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE 1928219Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2028219Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2128219Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2228219Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2328219Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2428219Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2528219Smsmith * SUCH DAMAGE. 2628219Smsmith */ 2728219Smsmith 28119418Sobrien#ifndef _ALTQ_ALTQ_PRIQ_H_ 29119418Sobrien#define _ALTQ_ALTQ_PRIQ_H_ 30119418Sobrien 3155939Snsouch#include <altq/altq.h> 3255939Snsouch#include <altq/altq_classq.h> 3328219Smsmith#include <altq/altq_red.h> 3428219Smsmith#include <altq/altq_rio.h> 3555939Snsouch 3655939Snsouch#ifdef __cplusplus 3728219Smsmithextern "C" { 3828219Smsmith#endif 3942475Snsouch 4032178Smsmith#define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ 4128219Smsmith 4255939Snsouch#ifdef ALTQ3_COMPAT 4355939Snsouchstruct priq_interface { 4455939Snsouch char ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ 4542475Snsouch u_long arg; /* request-specific argument */ 4628219Smsmith}; 4742475Snsouch 4842475Snsouchstruct priq_add_class { 4942475Snsouch struct priq_interface iface; 5042475Snsouch int pri; /* priority (0 is the lowest) */ 5142475Snsouch int qlimit; /* queue size limit */ 5242475Snsouch int flags; /* misc flags (see below) */ 5332178Smsmith 5428219Smsmith u_int32_t class_handle; /* return value */ 5555939Snsouch}; 5655939Snsouch#endif /* ALTQ3_COMPAT */ 5755939Snsouch 5855939Snsouch/* priq class flags */ 5942475Snsouch#define PRCF_RED 0x0001 /* use RED */ 6032178Smsmith#define PRCF_ECN 0x0002 /* use RED/ECN */ 6128257Smsmith#define PRCF_RIO 0x0004 /* use RIO */ 6228257Smsmith#define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 6332178Smsmith#define PRCF_DEFAULTCLASS 0x1000 /* default class */ 6432178Smsmith 6532178Smsmith/* special class handles */ 6642475Snsouch#define PRIQ_NULLCLASS_HANDLE 0 6728257Smsmith 6842475Snsouch#ifdef ALTQ3_COMPAT 6942475Snsouchstruct priq_delete_class { 7042475Snsouch struct priq_interface iface; 7142475Snsouch u_int32_t class_handle; 7260194Sn_hibma}; 7355939Snsouch 7455939Snsouchstruct priq_modify_class { 7560194Sn_hibma struct priq_interface iface; 7628257Smsmith u_int32_t class_handle; 7728257Smsmith int pri; 7855939Snsouch int qlimit; 7955939Snsouch int flags; 8055939Snsouch}; 8155939Snsouch 8255939Snsouchstruct priq_add_filter { 8355939Snsouch struct priq_interface iface; 8428219Smsmith u_int32_t class_handle; 8555939Snsouch struct flow_filter filter; 8628219Smsmith 8728219Smsmith u_long filter_handle; /* return value */ 8828219Smsmith}; 8928219Smsmith 9042475Snsouchstruct priq_delete_filter { 9142475Snsouch struct priq_interface iface; 9228219Smsmith u_long filter_handle; 9328261Smsmith}; 9447625Sphk#endif /* ALTQ3_COMPAT */ 95111815Sphk 96111815Sphkstruct priq_classstats { 97111815Sphk u_int32_t class_handle; 98111815Sphk 99111815Sphk u_int qlength; 100111815Sphk u_int qlimit; 101111815Sphk u_int period; 10247625Sphk struct pktcntr xmitcnt; /* transmitted packet counter */ 10328219Smsmith struct pktcntr dropcnt; /* dropped packet counter */ 10442475Snsouch 10542475Snsouch /* red and rio related info */ 10642475Snsouch int qtype; 10755939Snsouch struct redstats red[3]; /* rio has 3 red stats */ 10842475Snsouch}; 10942475Snsouch 11055939Snsouch#ifdef ALTQ3_COMPAT 11142475Snsouchstruct priq_class_stats { 11255939Snsouch struct priq_interface iface; 11355939Snsouch int maxpri; /* in/out */ 11442475Snsouch 11542475Snsouch struct priq_classstats *stats; /* pointer to stats array */ 11642475Snsouch}; 11742475Snsouch 11842475Snsouch#define PRIQ_IF_ATTACH _IOW('Q', 1, struct priq_interface) 11955939Snsouch#define PRIQ_IF_DETACH _IOW('Q', 2, struct priq_interface) 12042475Snsouch#define PRIQ_ENABLE _IOW('Q', 3, struct priq_interface) 12142475Snsouch#define PRIQ_DISABLE _IOW('Q', 4, struct priq_interface) 12255939Snsouch#define PRIQ_CLEAR _IOW('Q', 5, struct priq_interface) 12342475Snsouch#define PRIQ_ADD_CLASS _IOWR('Q', 7, struct priq_add_class) 12455939Snsouch#define PRIQ_DEL_CLASS _IOW('Q', 8, struct priq_delete_class) 12555939Snsouch#define PRIQ_MOD_CLASS _IOW('Q', 9, struct priq_modify_class) 12642475Snsouch#define PRIQ_ADD_FILTER _IOWR('Q', 10, struct priq_add_filter) 12742475Snsouch#define PRIQ_DEL_FILTER _IOW('Q', 11, struct priq_delete_filter) 12842475Snsouch#define PRIQ_GETSTATS _IOWR('Q', 12, struct priq_class_stats) 12942475Snsouch 13042475Snsouch#endif /* ALTQ3_COMPAT */ 13142475Snsouch 13256455Speter#ifdef _KERNEL 13356455Speter 13456455Speterstruct priq_class { 13556455Speter u_int32_t cl_handle; /* class handle */ 13694154Sticso class_queue_t *cl_q; /* class queue structure */ 13756455Speter struct red *cl_red; /* RED state */ 13856455Speter int cl_pri; /* priority */ 13928219Smsmith int cl_flags; /* class flags */ 14055939Snsouch struct priq_if *cl_pif; /* back pointer to pif */ 14128219Smsmith struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ 14255939Snsouch 14355939Snsouch /* statistics */ 14428219Smsmith u_int cl_period; /* backlog period */ 14528219Smsmith struct pktcntr cl_xmitcnt; /* transmitted packet counter */ 14628219Smsmith struct pktcntr cl_dropcnt; /* dropped packet counter */ 14755939Snsouch}; 14855939Snsouch 14955939Snsouch/* 15055939Snsouch * priq interface state 15128219Smsmith */ 15228219Smsmithstruct priq_if { 15355939Snsouch struct priq_if *pif_next; /* interface state list */ 15455939Snsouch struct ifaltq *pif_ifq; /* backpointer to ifaltq */ 15528219Smsmith u_int pif_bandwidth; /* link bandwidth in bps */ 15655939Snsouch int pif_maxpri; /* max priority in use */ 15755939Snsouch struct priq_class *pif_default; /* default class */ 15855939Snsouch struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */ 15955939Snsouch#ifdef ALTQ3_CLFIER_COMPAT 16055939Snsouch struct acc_classifier pif_classifier; /* classifier */ 16155939Snsouch#endif 16260194Sn_hibma}; 16355939Snsouch 16455939Snsouch#endif /* _KERNEL */ 16555939Snsouch 16628219Smsmith#ifdef __cplusplus 16755939Snsouch} 16855939Snsouch#endif 16928219Smsmith 17055939Snsouch#endif /* _ALTQ_ALTQ_PRIQ_H_ */ 17155939Snsouch