1126385Smlaier/* $FreeBSD$ */ 2126385Smlaier/* $KAME: altq_priq.h,v 1.5 2003/07/10 12:07:48 kjc Exp $ */ 3126385Smlaier/* 4126385Smlaier * Copyright (C) 2000-2003 5126385Smlaier * Sony Computer Science Laboratories Inc. All rights reserved. 6126385Smlaier * 7126385Smlaier * Redistribution and use in source and binary forms, with or without 8126385Smlaier * modification, are permitted provided that the following conditions 9126385Smlaier * are met: 10126385Smlaier * 1. Redistributions of source code must retain the above copyright 11126385Smlaier * notice, this list of conditions and the following disclaimer. 12126385Smlaier * 2. Redistributions in binary form must reproduce the above copyright 13126385Smlaier * notice, this list of conditions and the following disclaimer in the 14126385Smlaier * documentation and/or other materials provided with the distribution. 15126385Smlaier * 16126385Smlaier * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND 17126385Smlaier * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18126385Smlaier * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19126385Smlaier * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE 20126385Smlaier * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21126385Smlaier * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22126385Smlaier * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23126385Smlaier * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24126385Smlaier * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25126385Smlaier * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26126385Smlaier * SUCH DAMAGE. 27126385Smlaier */ 28126385Smlaier 29126385Smlaier#ifndef _ALTQ_ALTQ_PRIQ_H_ 30126385Smlaier#define _ALTQ_ALTQ_PRIQ_H_ 31126385Smlaier 32126385Smlaier#include <altq/altq.h> 33126385Smlaier#include <altq/altq_classq.h> 34126385Smlaier#include <altq/altq_red.h> 35126385Smlaier#include <altq/altq_rio.h> 36126385Smlaier 37126385Smlaier#ifdef __cplusplus 38126385Smlaierextern "C" { 39126385Smlaier#endif 40126385Smlaier 41126385Smlaier#define PRIQ_MAXPRI 16 /* upper limit of the number of priorities */ 42126385Smlaier#define PRIQ_MAXQID 256 /* upper limit of queues */ 43126385Smlaier 44126385Smlaier#ifdef ALTQ3_COMPAT 45126385Smlaierstruct priq_interface { 46126385Smlaier char ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */ 47126385Smlaier u_long arg; /* request-specific argument */ 48126385Smlaier}; 49126385Smlaier 50126385Smlaierstruct priq_add_class { 51126385Smlaier struct priq_interface iface; 52126385Smlaier int pri; /* priority (0 is the lowest) */ 53126385Smlaier int qlimit; /* queue size limit */ 54126385Smlaier int flags; /* misc flags (see below) */ 55126385Smlaier 56126385Smlaier u_int32_t class_handle; /* return value */ 57126385Smlaier}; 58126385Smlaier#endif /* ALTQ3_COMPAT */ 59126385Smlaier 60126385Smlaier/* priq class flags */ 61126385Smlaier#define PRCF_RED 0x0001 /* use RED */ 62126385Smlaier#define PRCF_ECN 0x0002 /* use RED/ECN */ 63126385Smlaier#define PRCF_RIO 0x0004 /* use RIO */ 64126385Smlaier#define PRCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */ 65126385Smlaier#define PRCF_DEFAULTCLASS 0x1000 /* default class */ 66126385Smlaier 67126385Smlaier/* special class handles */ 68126385Smlaier#define PRIQ_NULLCLASS_HANDLE 0 69126385Smlaier 70126385Smlaier#ifdef ALTQ3_COMPAT 71126385Smlaierstruct priq_delete_class { 72126385Smlaier struct priq_interface iface; 73126385Smlaier u_int32_t class_handle; 74126385Smlaier}; 75126385Smlaier 76126385Smlaierstruct priq_modify_class { 77126385Smlaier struct priq_interface iface; 78126385Smlaier u_int32_t class_handle; 79126385Smlaier int pri; 80126385Smlaier int qlimit; 81126385Smlaier int flags; 82126385Smlaier}; 83126385Smlaier 84126385Smlaierstruct priq_add_filter { 85126385Smlaier struct priq_interface iface; 86126385Smlaier u_int32_t class_handle; 87126385Smlaier struct flow_filter filter; 88126385Smlaier 89126385Smlaier u_long filter_handle; /* return value */ 90126385Smlaier}; 91126385Smlaier 92126385Smlaierstruct priq_delete_filter { 93126385Smlaier struct priq_interface iface; 94126385Smlaier u_long filter_handle; 95126385Smlaier}; 96126385Smlaier#endif /* ALTQ3_COMPAT */ 97126385Smlaier 98126385Smlaierstruct priq_classstats { 99126385Smlaier u_int32_t class_handle; 100126385Smlaier 101126385Smlaier u_int qlength; 102126385Smlaier u_int qlimit; 103126385Smlaier u_int period; 104126385Smlaier struct pktcntr xmitcnt; /* transmitted packet counter */ 105126385Smlaier struct pktcntr dropcnt; /* dropped packet counter */ 106126385Smlaier 107126385Smlaier /* red and rio related info */ 108126385Smlaier int qtype; 109126385Smlaier struct redstats red[3]; /* rio has 3 red stats */ 110126385Smlaier}; 111126385Smlaier 112126385Smlaier#ifdef ALTQ3_COMPAT 113126385Smlaierstruct priq_class_stats { 114126385Smlaier struct priq_interface iface; 115126385Smlaier int maxpri; /* in/out */ 116126385Smlaier 117126385Smlaier struct priq_classstats *stats; /* pointer to stats array */ 118126385Smlaier}; 119126385Smlaier 120126385Smlaier#define PRIQ_IF_ATTACH _IOW('Q', 1, struct priq_interface) 121126385Smlaier#define PRIQ_IF_DETACH _IOW('Q', 2, struct priq_interface) 122126385Smlaier#define PRIQ_ENABLE _IOW('Q', 3, struct priq_interface) 123126385Smlaier#define PRIQ_DISABLE _IOW('Q', 4, struct priq_interface) 124126385Smlaier#define PRIQ_CLEAR _IOW('Q', 5, struct priq_interface) 125126385Smlaier#define PRIQ_ADD_CLASS _IOWR('Q', 7, struct priq_add_class) 126126385Smlaier#define PRIQ_DEL_CLASS _IOW('Q', 8, struct priq_delete_class) 127126385Smlaier#define PRIQ_MOD_CLASS _IOW('Q', 9, struct priq_modify_class) 128126385Smlaier#define PRIQ_ADD_FILTER _IOWR('Q', 10, struct priq_add_filter) 129126385Smlaier#define PRIQ_DEL_FILTER _IOW('Q', 11, struct priq_delete_filter) 130126385Smlaier#define PRIQ_GETSTATS _IOWR('Q', 12, struct priq_class_stats) 131126385Smlaier 132126385Smlaier#endif /* ALTQ3_COMPAT */ 133126385Smlaier 134126385Smlaier#ifdef _KERNEL 135126385Smlaier 136126385Smlaierstruct priq_class { 137126385Smlaier u_int32_t cl_handle; /* class handle */ 138126385Smlaier class_queue_t *cl_q; /* class queue structure */ 139126385Smlaier struct red *cl_red; /* RED state */ 140126385Smlaier int cl_pri; /* priority */ 141126385Smlaier int cl_flags; /* class flags */ 142126385Smlaier struct priq_if *cl_pif; /* back pointer to pif */ 143126385Smlaier struct altq_pktattr *cl_pktattr; /* saved header used by ECN */ 144126385Smlaier 145126385Smlaier /* statistics */ 146126385Smlaier u_int cl_period; /* backlog period */ 147126385Smlaier struct pktcntr cl_xmitcnt; /* transmitted packet counter */ 148126385Smlaier struct pktcntr cl_dropcnt; /* dropped packet counter */ 149126385Smlaier}; 150126385Smlaier 151126385Smlaier/* 152126385Smlaier * priq interface state 153126385Smlaier */ 154126385Smlaierstruct priq_if { 155126385Smlaier struct priq_if *pif_next; /* interface state list */ 156126385Smlaier struct ifaltq *pif_ifq; /* backpointer to ifaltq */ 157126385Smlaier u_int pif_bandwidth; /* link bandwidth in bps */ 158126385Smlaier int pif_maxpri; /* max priority in use */ 159126385Smlaier struct priq_class *pif_default; /* default class */ 160126385Smlaier struct priq_class *pif_classes[PRIQ_MAXPRI]; /* classes */ 161126385Smlaier#ifdef ALTQ3_CLFIER_COMPAT 162126385Smlaier struct acc_classifier pif_classifier; /* classifier */ 163126385Smlaier#endif 164126385Smlaier}; 165126385Smlaier 166126385Smlaier#endif /* _KERNEL */ 167126385Smlaier 168126385Smlaier#ifdef __cplusplus 169126385Smlaier} 170126385Smlaier#endif 171126385Smlaier 172126385Smlaier#endif /* _ALTQ_ALTQ_PRIQ_H_ */ 173