summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2011-07-03 22:39:13 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2011-07-03 22:39:13 +0000
commitbfe42b0e352d175e512cf96ba2f9f9222d047243 (patch)
tree64c876aabf9605b6d5a36314627aca69b7b46d30 /sys
parent8a98468078b8fff6450f125d5943a7ee1c840120 (diff)
cdnr and rio disciplines are not being used or supported, clear a path
for new code. ok henning
Diffstat (limited to 'sys')
-rw-r--r--sys/altq/altq_cbq.h3
-rw-r--r--sys/altq/altq_cdnr.c1168
-rw-r--r--sys/altq/altq_cdnr.h302
-rw-r--r--sys/altq/altq_hfsc.h3
-rw-r--r--sys/altq/altq_priq.h3
-rw-r--r--sys/altq/altq_rio.c435
-rw-r--r--sys/altq/altq_rio.h128
-rw-r--r--sys/altq/altq_rmclass.c3
-rw-r--r--sys/altq/if_altq.h7
-rw-r--r--sys/conf/files4
10 files changed, 7 insertions, 2049 deletions
diff --git a/sys/altq/altq_cbq.h b/sys/altq/altq_cbq.h
index efb4b1da4af..a4534c6da92 100644
--- a/sys/altq/altq_cbq.h
+++ b/sys/altq/altq_cbq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_cbq.h,v 1.10 2004/01/14 08:42:23 kjc Exp $ */
+/* $OpenBSD: altq_cbq.h,v 1.11 2011/07/03 22:39:12 tedu Exp $ */
/* $KAME: altq_cbq.h,v 1.5 2000/12/02 13:44:40 kjc Exp $ */
/*
@@ -37,7 +37,6 @@
#include <altq/altq.h>
#include <altq/altq_rmclass.h>
#include <altq/altq_red.h>
-#include <altq/altq_rio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/sys/altq/altq_cdnr.c b/sys/altq/altq_cdnr.c
deleted file mode 100644
index 2bf83f7c474..00000000000
--- a/sys/altq/altq_cdnr.c
+++ /dev/null
@@ -1,1168 +0,0 @@
-/* $OpenBSD: altq_cdnr.c,v 1.10 2008/05/08 15:22:02 chl Exp $ */
-/* $KAME: altq_cdnr.c,v 1.8 2000/12/14 08:12:45 thorpej Exp $ */
-
-/*
- * Copyright (C) 1999-2000
- * Sony Computer Science Laboratories Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/errno.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
-#include <altq/altq.h>
-#include <altq/altq_cdnr.h>
-
-/*
- * diffserv traffic conditioning module
- */
-
-int altq_cdnr_enabled = 0;
-
-/* cdnr_list keeps all cdnr's allocated. */
-static LIST_HEAD(, top_cdnr) tcb_list;
-
-static int altq_cdnr_input(struct mbuf *, int);
-static struct top_cdnr *tcb_lookup(char *ifname);
-static struct cdnr_block *cdnr_handle2cb(u_long);
-static u_long cdnr_cb2handle(struct cdnr_block *);
-static void *cdnr_cballoc(struct top_cdnr *, int,
- struct tc_action *(*)(struct cdnr_block *, struct cdnr_pktinfo *));
-static void cdnr_cbdestroy(void *);
-static int tca_verify_action(struct tc_action *);
-static void tca_import_action(struct tc_action *, struct tc_action *);
-static void tca_invalidate_action(struct tc_action *);
-
-static int generic_element_destroy(struct cdnr_block *);
-static struct top_cdnr *top_create(struct ifaltq *);
-static int top_destroy(struct top_cdnr *);
-static struct cdnr_block *element_create(struct top_cdnr *,
- struct tc_action *);
-static int element_destroy(struct cdnr_block *);
-static void tb_import_profile(struct tbe *, struct tb_profile *);
-static struct tbmeter *tbm_create(struct top_cdnr *, struct tb_profile *,
- struct tc_action *, struct tc_action *);
-static int tbm_destroy(struct tbmeter *);
-static struct tc_action *tbm_input(struct cdnr_block *,
- struct cdnr_pktinfo *);
-static struct trtcm *trtcm_create(struct top_cdnr *,
- struct tb_profile *, struct tb_profile *,
- struct tc_action *, struct tc_action *, struct tc_action *,
- int);
-static int trtcm_destroy(struct trtcm *);
-static struct tc_action *trtcm_input(struct cdnr_block *,
- struct cdnr_pktinfo *);
-static struct tswtcm *tswtcm_create(struct top_cdnr *,
- u_int32_t, u_int32_t, u_int32_t,
- struct tc_action *, struct tc_action *, struct tc_action *);
-static int tswtcm_destroy(struct tswtcm *);
-static struct tc_action *tswtcm_input(struct cdnr_block *,
- struct cdnr_pktinfo *);
-
-static int cdnrcmd_if_attach(char *);
-static int cdnrcmd_if_detach(char *);
-static int cdnrcmd_add_element(struct cdnr_add_element *);
-static int cdnrcmd_delete_element(struct cdnr_delete_element *);
-static int cdnrcmd_add_tbm(struct cdnr_add_tbmeter *);
-static int cdnrcmd_modify_tbm(struct cdnr_modify_tbmeter *);
-static int cdnrcmd_tbm_stats(struct cdnr_tbmeter_stats *);
-static int cdnrcmd_add_trtcm(struct cdnr_add_trtcm *);
-static int cdnrcmd_modify_trtcm(struct cdnr_modify_trtcm *);
-static int cdnrcmd_tcm_stats(struct cdnr_tcm_stats *);
-static int cdnrcmd_add_tswtcm(struct cdnr_add_tswtcm *);
-static int cdnrcmd_modify_tswtcm(struct cdnr_modify_tswtcm *);
-static int cdnrcmd_get_stats(struct cdnr_get_stats *);
-
-#if 1
-/* dummy */
-int cdnr_dummy(void);
-
-int cdnr_dummy(void)
-{
- altq_cdnr_input(NULL, 0);
-
- cdnrcmd_if_attach(NULL);
- cdnrcmd_if_detach(NULL);
- cdnrcmd_add_element(NULL);
- cdnrcmd_delete_element(NULL);
- cdnrcmd_add_tbm(NULL);
- cdnrcmd_modify_tbm(NULL);
- cdnrcmd_tbm_stats(NULL);
- cdnrcmd_add_trtcm(NULL);
- cdnrcmd_modify_trtcm(NULL);
- cdnrcmd_tcm_stats(NULL);
- cdnrcmd_add_tswtcm(NULL);
- cdnrcmd_modify_tswtcm(NULL);
- cdnrcmd_get_stats(NULL);
- return (0);
-}
-
-#endif
-
-/*
- * top level input function called from ip_input.
- * should be called before converting header fields to host-byte-order.
- */
-int
-altq_cdnr_input(m, af)
- struct mbuf *m;
- int af; /* address family */
-{
- struct ifnet *ifp;
- struct ip *ip;
- struct top_cdnr *top;
- struct tc_action *tca;
- struct cdnr_block *cb;
- struct cdnr_pktinfo pktinfo;
-
- ifp = m->m_pkthdr.rcvif;
- if (!ALTQ_IS_CNDTNING(&ifp->if_snd))
- /* traffic conditioner is not enabled on this interface */
- return (1);
-
- top = ifp->if_snd.altq_cdnr;
-
- ip = mtod(m, struct ip *);
-#ifdef INET6
- if (af == AF_INET6) {
- u_int32_t flowlabel;
-
- flowlabel = ((struct ip6_hdr *)ip)->ip6_flow;
- pktinfo.pkt_dscp = (ntohl(flowlabel) >> 20) & DSCP_MASK;
- } else
-#endif
- pktinfo.pkt_dscp = ip->ip_tos & DSCP_MASK;
- pktinfo.pkt_len = m_pktlen(m);
-
- tca = NULL;
-
-#if 0
- cb = acc_classify(&top->tc_classifier, m, af);
-#endif
- if (cb != NULL)
- tca = &cb->cb_action;
-
- if (tca == NULL)
- tca = &top->tc_block.cb_action;
-
- while (1) {
- PKTCNTR_ADD(&top->tc_cnts[tca->tca_code], pktinfo.pkt_len);
-
- switch (tca->tca_code) {
- case TCACODE_PASS:
- return (1);
- case TCACODE_DROP:
- m_freem(m);
- return (0);
- case TCACODE_RETURN:
- return (0);
- case TCACODE_MARK:
-#ifdef INET6
- if (af == AF_INET6) {
- struct ip6_hdr *ip6 = (struct ip6_hdr *)ip;
- u_int32_t flowlabel;
-
- flowlabel = ntohl(ip6->ip6_flow);
- flowlabel = (tca->tca_dscp << 20) |
- (flowlabel & ~(DSCP_MASK << 20));
- ip6->ip6_flow = htonl(flowlabel);
- } else
-#endif
- ip->ip_tos = tca->tca_dscp |
- (ip->ip_tos & DSCP_CUMASK);
- return (1);
- case TCACODE_NEXT:
- cb = tca->tca_next;
- tca = (*cb->cb_input)(cb, &pktinfo);
- break;
- case TCACODE_NONE:
- default:
- return (1);
- }
- }
-}
-
-static struct top_cdnr *
-tcb_lookup(ifname)
- char *ifname;
-{
- struct top_cdnr *top;
- struct ifnet *ifp;
-
- if ((ifp = ifunit(ifname)) != NULL)
- LIST_FOREACH(top, &tcb_list, tc_next)
- if (top->tc_ifq->altq_ifp == ifp)
- return (top);
- return (NULL);
-}
-
-static struct cdnr_block *
-cdnr_handle2cb(handle)
- u_long handle;
-{
- struct cdnr_block *cb;
-
- cb = (struct cdnr_block *)handle;
- if (handle != ALIGN(cb))
- return (NULL);
-
- if (cb == NULL || cb->cb_handle != handle)
- return (NULL);
- return (cb);
-}
-
-static u_long
-cdnr_cb2handle(cb)
- struct cdnr_block *cb;
-{
- return (cb->cb_handle);
-}
-
-static void *
-cdnr_cballoc(top, type, input_func)
- struct top_cdnr *top;
- int type;
- struct tc_action *(*input_func)(struct cdnr_block *,
- struct cdnr_pktinfo *);
-{
- struct cdnr_block *cb;
- int size;
-
- switch (type) {
- case TCETYPE_TOP:
- size = sizeof(struct top_cdnr);
- break;
- case TCETYPE_ELEMENT:
- size = sizeof(struct cdnr_block);
- break;
- case TCETYPE_TBMETER:
- size = sizeof(struct tbmeter);
- break;
- case TCETYPE_TRTCM:
- size = sizeof(struct trtcm);
- break;
- case TCETYPE_TSWTCM:
- size = sizeof(struct tswtcm);
- break;
- default:
- return (NULL);
- }
-
- cb = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
-
- cb->cb_len = size;
- cb->cb_type = type;
- cb->cb_ref = 0;
- cb->cb_handle = (u_long)cb;
- if (top == NULL)
- cb->cb_top = (struct top_cdnr *)cb;
- else
- cb->cb_top = top;
-
- if (input_func != NULL) {
- /*
- * if this cdnr has an action function,
- * make tc_action to call itself.
- */
- cb->cb_action.tca_code = TCACODE_NEXT;
- cb->cb_action.tca_next = cb;
- cb->cb_input = input_func;
- } else
- cb->cb_action.tca_code = TCACODE_NONE;
-
- /* if this isn't top, register the element to the top level cdnr */
- if (top != NULL)
- LIST_INSERT_HEAD(&top->tc_elements, cb, cb_next);
-
- return ((void *)cb);
-}
-
-static void
-cdnr_cbdestroy(cblock)
- void *cblock;
-{
- struct cdnr_block *cb = cblock;
-
- /* remove from the top level cdnr */
- if (cb->cb_top != cblock)
- LIST_REMOVE(cb, cb_next);
-
- free(cb, M_DEVBUF);
-}
-
-/*
- * conditioner common destroy routine
- */
-static int
-generic_element_destroy(cb)
- struct cdnr_block *cb;
-{
- int error = 0;
-
- switch (cb->cb_type) {
- case TCETYPE_TOP:
- error = top_destroy((struct top_cdnr *)cb);
- break;
- case TCETYPE_ELEMENT:
- error = element_destroy(cb);
- break;
- case TCETYPE_TBMETER:
- error = tbm_destroy((struct tbmeter *)cb);
- break;
- case TCETYPE_TRTCM:
- error = trtcm_destroy((struct trtcm *)cb);
- break;
- case TCETYPE_TSWTCM:
- error = tswtcm_destroy((struct tswtcm *)cb);
- break;
- default:
- error = EINVAL;
- }
- return (error);
-}
-
-static int
-tca_verify_action(utca)
- struct tc_action *utca;
-{
- switch (utca->tca_code) {
- case TCACODE_PASS:
- case TCACODE_DROP:
- case TCACODE_MARK:
- /* these are ok */
- break;
-
- case TCACODE_HANDLE:
- /* verify handle value */
- if (cdnr_handle2cb(utca->tca_handle) == NULL)
- return (-1);
- break;
-
- case TCACODE_NONE:
- case TCACODE_RETURN:
- case TCACODE_NEXT:
- default:
- /* should not be passed from a user */
- return (-1);
- }
- return (0);
-}
-
-static void
-tca_import_action(ktca, utca)
- struct tc_action *ktca, *utca;
-{
- struct cdnr_block *cb;
-
- *ktca = *utca;
- if (ktca->tca_code == TCACODE_HANDLE) {
- cb = cdnr_handle2cb(ktca->tca_handle);
- if (cb == NULL) {
- ktca->tca_code = TCACODE_NONE;
- return;
- }
- ktca->tca_code = TCACODE_NEXT;
- ktca->tca_next = cb;
- cb->cb_ref++;
- } else if (ktca->tca_code == TCACODE_MARK) {
- ktca->tca_dscp &= DSCP_MASK;
- }
- return;
-}
-
-static void
-tca_invalidate_action(tca)
- struct tc_action *tca;
-{
- struct cdnr_block *cb;
-
- if (tca->tca_code == TCACODE_NEXT) {
- cb = tca->tca_next;
- if (cb == NULL)
- return;
- cb->cb_ref--;
- }
- tca->tca_code = TCACODE_NONE;
-}
-
-/*
- * top level traffic conditioner
- */
-static struct top_cdnr *
-top_create(ifq)
- struct ifaltq *ifq;
-{
- struct top_cdnr *top;
-
- if ((top = cdnr_cballoc(NULL, TCETYPE_TOP, NULL)) == NULL)
- return (NULL);
-
- top->tc_ifq = ifq;
- /* set default action for the top level conditioner */
- top->tc_block.cb_action.tca_code = TCACODE_PASS;
-
- LIST_INSERT_HEAD(&tcb_list, top, tc_next);
-
- ifq->altq_cdnr = top;
-
- return (top);
-}
-
-static int
-top_destroy(top)
- struct top_cdnr *top;
-{
- struct cdnr_block *cb;
-
- if (ALTQ_IS_CNDTNING(top->tc_ifq))
- ALTQ_CLEAR_CNDTNING(top->tc_ifq);
- top->tc_ifq->altq_cdnr = NULL;
-
- /*
- * destroy all the conditioner elements belonging to this interface
- */
- while ((cb = LIST_FIRST(&top->tc_elements)) != NULL) {
- while (cb != NULL && cb->cb_ref > 0)
- cb = LIST_NEXT(cb, cb_next);
- if (cb != NULL)
- generic_element_destroy(cb);
- }
-
- LIST_REMOVE(top, tc_next);
-
- cdnr_cbdestroy(top);
-
- /* if there is no active conditioner, remove the input hook */
- if (altq_input != NULL) {
- LIST_FOREACH(top, &tcb_list, tc_next)
- if (ALTQ_IS_CNDTNING(top->tc_ifq))
- break;
- if (top == NULL)
- altq_input = NULL;
- }
-
- return (0);
-}
-
-/*
- * simple tc elements without input function (e.g., dropper and makers).
- */
-static struct cdnr_block *
-element_create(top, action)
- struct top_cdnr *top;
- struct tc_action *action;
-{
- struct cdnr_block *cb;
-
- if (tca_verify_action(action) < 0)
- return (NULL);
-
- if ((cb = cdnr_cballoc(top, TCETYPE_ELEMENT, NULL)) == NULL)
- return (NULL);
-
- tca_import_action(&cb->cb_action, action);
-
- return (cb);
-}
-
-static int
-element_destroy(cb)
- struct cdnr_block *cb;
-{
- if (cb->cb_ref > 0)
- return (EBUSY);
-
- tca_invalidate_action(&cb->cb_action);
-
- cdnr_cbdestroy(cb);
- return (0);
-}
-
-/*
- * internal representation of token bucket parameters
- * rate: byte_per_unittime << 32
- * (((bits_per_sec) / 8) << 32) / machclk_freq
- * depth: byte << 32
- *
- */
-#define TB_SHIFT 32
-#define TB_SCALE(x) ((u_int64_t)(x) << TB_SHIFT)
-#define TB_UNSCALE(x) ((x) >> TB_SHIFT)
-
-static void
-tb_import_profile(tb, profile)
- struct tbe *tb;
- struct tb_profile *profile;
-{
- tb->rate = TB_SCALE(profile->rate / 8) / machclk_freq;
- tb->depth = TB_SCALE(profile->depth);
- if (tb->rate > 0)
- tb->filluptime = tb->depth / tb->rate;
- else
- tb->filluptime = 0xffffffffffffffffLL;
- tb->token = tb->depth;
- tb->last = read_machclk();
-}
-
-/*
- * simple token bucket meter
- */
-static struct tbmeter *
-tbm_create(top, profile, in_action, out_action)
- struct top_cdnr *top;
- struct tb_profile *profile;
- struct tc_action *in_action, *out_action;
-{
- struct tbmeter *tbm = NULL;
-
- if (tca_verify_action(in_action) < 0
- || tca_verify_action(out_action) < 0)
- return (NULL);
-
- if ((tbm = cdnr_cballoc(top, TCETYPE_TBMETER,
- tbm_input)) == NULL)
- return (NULL);
-
- tb_import_profile(&tbm->tb, profile);
-
- tca_import_action(&tbm->in_action, in_action);
- tca_import_action(&tbm->out_action, out_action);
-
- return (tbm);
-}
-
-static int
-tbm_destroy(tbm)
- struct tbmeter *tbm;
-{
- if (tbm->cdnrblk.cb_ref > 0)
- return (EBUSY);
-
- tca_invalidate_action(&tbm->in_action);
- tca_invalidate_action(&tbm->out_action);
-
- cdnr_cbdestroy(tbm);
- return (0);
-}
-
-static struct tc_action *
-tbm_input(cb, pktinfo)
- struct cdnr_block *cb;
- struct cdnr_pktinfo *pktinfo;
-{
- struct tbmeter *tbm = (struct tbmeter *)cb;
- u_int64_t len;
- u_int64_t interval, now;
-
- len = TB_SCALE(pktinfo->pkt_len);
-
- if (tbm->tb.token < len) {
- now = read_machclk();
- interval = now - tbm->tb.last;
- if (interval >= tbm->tb.filluptime)
- tbm->tb.token = tbm->tb.depth;
- else {
- tbm->tb.token += interval * tbm->tb.rate;
- if (tbm->tb.token > tbm->tb.depth)
- tbm->tb.token = tbm->tb.depth;
- }
- tbm->tb.last = now;
- }
-
- if (tbm->tb.token < len) {
- PKTCNTR_ADD(&tbm->out_cnt, pktinfo->pkt_len);
- return (&tbm->out_action);
- }
-
- tbm->tb.token -= len;
- PKTCNTR_ADD(&tbm->in_cnt, pktinfo->pkt_len);
- return (&tbm->in_action);
-}
-
-/*
- * two rate three color marker
- * as described in draft-heinanen-diffserv-trtcm-01.txt
- */
-static struct trtcm *
-trtcm_create(top, cmtd_profile, peak_profile,
- green_action, yellow_action, red_action, coloraware)
- struct top_cdnr *top;
- struct tb_profile *cmtd_profile, *peak_profile;
- struct tc_action *green_action, *yellow_action, *red_action;
- int coloraware;
-{
- struct trtcm *tcm = NULL;
-
- if (tca_verify_action(green_action) < 0
- || tca_verify_action(yellow_action) < 0
- || tca_verify_action(red_action) < 0)
- return (NULL);
-
- if ((tcm = cdnr_cballoc(top, TCETYPE_TRTCM,
- trtcm_input)) == NULL)
- return (NULL);
-
- tb_import_profile(&tcm->cmtd_tb, cmtd_profile);
- tb_import_profile(&tcm->peak_tb, peak_profile);
-
- tca_import_action(&tcm->green_action, green_action);
- tca_import_action(&tcm->yellow_action, yellow_action);
- tca_import_action(&tcm->red_action, red_action);
-
- /* set dscps to use */
- if (tcm->green_action.tca_code == TCACODE_MARK)
- tcm->green_dscp = tcm->green_action.tca_dscp & DSCP_MASK;
- else
- tcm->green_dscp = DSCP_AF11;
- if (tcm->yellow_action.tca_code == TCACODE_MARK)
- tcm->yellow_dscp = tcm->yellow_action.tca_dscp & DSCP_MASK;
- else
- tcm->yellow_dscp = DSCP_AF12;
- if (tcm->red_action.tca_code == TCACODE_MARK)
- tcm->red_dscp = tcm->red_action.tca_dscp & DSCP_MASK;
- else
- tcm->red_dscp = DSCP_AF13;
-
- tcm->coloraware = coloraware;
-
- return (tcm);
-}
-
-static int
-trtcm_destroy(tcm)
- struct trtcm *tcm;
-{
- if (tcm->cdnrblk.cb_ref > 0)
- return (EBUSY);
-
- tca_invalidate_action(&tcm->green_action);
- tca_invalidate_action(&tcm->yellow_action);
- tca_invalidate_action(&tcm->red_action);
-
- cdnr_cbdestroy(tcm);
- return (0);
-}
-
-static struct tc_action *
-trtcm_input(cb, pktinfo)
- struct cdnr_block *cb;
- struct cdnr_pktinfo *pktinfo;
-{
- struct trtcm *tcm = (struct trtcm *)cb;
- u_int64_t len;
- u_int64_t interval, now;
- u_int8_t color;
-
- len = TB_SCALE(pktinfo->pkt_len);
- if (tcm->coloraware) {
- color = pktinfo->pkt_dscp;
- if (color != tcm->yellow_dscp && color != tcm->red_dscp)
- color = tcm->green_dscp;
- } else {
- /* if color-blind, precolor it as green */
- color = tcm->green_dscp;
- }
-
- now = read_machclk();
- if (tcm->cmtd_tb.token < len) {
- interval = now - tcm->cmtd_tb.last;
- if (interval >= tcm->cmtd_tb.filluptime)
- tcm->cmtd_tb.token = tcm->cmtd_tb.depth;
- else {
- tcm->cmtd_tb.token += interval * tcm->cmtd_tb.rate;
- if (tcm->cmtd_tb.token > tcm->cmtd_tb.depth)
- tcm->cmtd_tb.token = tcm->cmtd_tb.depth;
- }
- tcm->cmtd_tb.last = now;
- }
- if (tcm->peak_tb.token < len) {
- interval = now - tcm->peak_tb.last;
- if (interval >= tcm->peak_tb.filluptime)
- tcm->peak_tb.token = tcm->peak_tb.depth;
- else {
- tcm->peak_tb.token += interval * tcm->peak_tb.rate;
- if (tcm->peak_tb.token > tcm->peak_tb.depth)
- tcm->peak_tb.token = tcm->peak_tb.depth;
- }
- tcm->peak_tb.last = now;
- }
-
- if (color == tcm->red_dscp || tcm->peak_tb.token < len) {
- pktinfo->pkt_dscp = tcm->red_dscp;
- PKTCNTR_ADD(&tcm->red_cnt, pktinfo->pkt_len);
- return (&tcm->red_action);
- }
-
- if (color == tcm->yellow_dscp || tcm->cmtd_tb.token < len) {
- pktinfo->pkt_dscp = tcm->yellow_dscp;
- tcm->peak_tb.token -= len;
- PKTCNTR_ADD(&tcm->yellow_cnt, pktinfo->pkt_len);
- return (&tcm->yellow_action);
- }
-
- pktinfo->pkt_dscp = tcm->green_dscp;
- tcm->cmtd_tb.token -= len;
- tcm->peak_tb.token -= len;
- PKTCNTR_ADD(&tcm->green_cnt, pktinfo->pkt_len);
- return (&tcm->green_action);
-}
-
-/*
- * time sliding window three color marker
- * as described in draft-fang-diffserv-tc-tswtcm-00.txt
- */
-static struct tswtcm *
-tswtcm_create(top, cmtd_rate, peak_rate, avg_interval,
- green_action, yellow_action, red_action)
- struct top_cdnr *top;
- u_int32_t cmtd_rate, peak_rate, avg_interval;
- struct tc_action *green_action, *yellow_action, *red_action;
-{
- struct tswtcm *tsw;
-
- if (tca_verify_action(green_action) < 0
- || tca_verify_action(yellow_action) < 0
- || tca_verify_action(red_action) < 0)
- return (NULL);
-
- if ((tsw = cdnr_cballoc(top, TCETYPE_TSWTCM,
- tswtcm_input)) == NULL)
- return (NULL);
-
- tca_import_action(&tsw->green_action, green_action);
- tca_import_action(&tsw->yellow_action, yellow_action);
- tca_import_action(&tsw->red_action, red_action);
-
- /* set dscps to use */
- if (tsw->green_action.tca_code == TCACODE_MARK)
- tsw->green_dscp = tsw->green_action.tca_dscp & DSCP_MASK;
- else
- tsw->green_dscp = DSCP_AF11;
- if (tsw->yellow_action.tca_code == TCACODE_MARK)
- tsw->yellow_dscp = tsw->yellow_action.tca_dscp & DSCP_MASK;
- else
- tsw->yellow_dscp = DSCP_AF12;
- if (tsw->red_action.tca_code == TCACODE_MARK)
- tsw->red_dscp = tsw->red_action.tca_dscp & DSCP_MASK;
- else
- tsw->red_dscp = DSCP_AF13;
-
- /* convert rates from bits/sec to bytes/sec */
- tsw->cmtd_rate = cmtd_rate / 8;
- tsw->peak_rate = peak_rate / 8;
- tsw->avg_rate = 0;
-
- /* timewin is converted from msec to machine clock unit */
- tsw->timewin = (u_int64_t)machclk_freq * avg_interval / 1000;
-
- return (tsw);
-}
-
-static int
-tswtcm_destroy(tsw)
- struct tswtcm *tsw;
-{
- if (tsw->cdnrblk.cb_ref > 0)
- return (EBUSY);
-
- tca_invalidate_action(&tsw->green_action);
- tca_invalidate_action(&tsw->yellow_action);
- tca_invalidate_action(&tsw->red_action);
-
- cdnr_cbdestroy(tsw);
- return (0);
-}
-
-static struct tc_action *
-tswtcm_input(cb, pktinfo)
- struct cdnr_block *cb;
- struct cdnr_pktinfo *pktinfo;
-{
- struct tswtcm *tsw = (struct tswtcm *)cb;
- int len;
- u_int32_t avg_rate;
- u_int64_t interval, now, tmp;
-
- /*
- * rate estimator
- */
- len = pktinfo->pkt_len;
- now = read_machclk();
-
- interval = now - tsw->t_front;
- /*
- * calculate average rate:
- * avg = (avg * timewin + pkt_len)/(timewin + interval)
- * pkt_len needs to be multiplied by machclk_freq in order to
- * get (bytes/sec).
- * note: when avg_rate (bytes/sec) and timewin (machclk unit) are
- * less than 32 bits, the following 64-bit operation has enough
- * precision.
- */
- tmp = ((u_int64_t)tsw->avg_rate * tsw->timewin
- + (u_int64_t)len * machclk_freq) / (tsw->timewin + interval);
- tsw->avg_rate = avg_rate = (u_int32_t)tmp;
- tsw->t_front = now;
-
- /*
- * marker
- */
- if (avg_rate > tsw->cmtd_rate) {
- u_int32_t randval = arc4random_uniform(avg_rate);
-
- if (avg_rate > tsw->peak_rate) {
- if (randval < avg_rate - tsw->peak_rate) {
- /* mark red */
- pktinfo->pkt_dscp = tsw->red_dscp;
- PKTCNTR_ADD(&tsw->red_cnt, len);
- return (&tsw->red_action);
- } else if (randval < avg_rate - tsw->cmtd_rate)
- goto mark_yellow;
- } else {
- /* peak_rate >= avg_rate > cmtd_rate */
- if (randval < avg_rate - tsw->cmtd_rate) {
- mark_yellow:
- pktinfo->pkt_dscp = tsw->yellow_dscp;
- PKTCNTR_ADD(&tsw->yellow_cnt, len);
- return (&tsw->yellow_action);
- }
- }
- }
-
- /* mark green */
- pktinfo->pkt_dscp = tsw->green_dscp;
- PKTCNTR_ADD(&tsw->green_cnt, len);
- return (&tsw->green_action);
-}
-
-/*
- * ioctl requests
- */
-static int
-cdnrcmd_if_attach(ifname)
- char *ifname;
-{
- struct ifnet *ifp;
- struct top_cdnr *top;
-
- if ((ifp = ifunit(ifname)) == NULL)
- return (EBADF);
-
- if (ifp->if_snd.altq_cdnr != NULL)
- return (EBUSY);
-
- if ((top = top_create(&ifp->if_snd)) == NULL)
- return (ENOMEM);
- return (0);
-}
-
-static int
-cdnrcmd_if_detach(ifname)
- char *ifname;
-{
- struct top_cdnr *top;
-
- if ((top = tcb_lookup(ifname)) == NULL)
- return (EBADF);
-
- return top_destroy(top);
-}
-
-static int
-cdnrcmd_add_element(ap)
- struct cdnr_add_element *ap;
-{
- struct top_cdnr *top;
- struct cdnr_block *cb;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- cb = element_create(top, &ap->action);
- if (cb == NULL)
- return (EINVAL);
- /* return a class handle to the user */
- ap->cdnr_handle = cdnr_cb2handle(cb);
- return (0);
-}
-
-static int
-cdnrcmd_delete_element(ap)
- struct cdnr_delete_element *ap;
-{
- struct top_cdnr *top;
- struct cdnr_block *cb;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- if ((cb = cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- if (cb->cb_type != TCETYPE_ELEMENT)
- return generic_element_destroy(cb);
-
- return element_destroy(cb);
-}
-
-static int
-cdnrcmd_add_tbm(ap)
- struct cdnr_add_tbmeter *ap;
-{
- struct top_cdnr *top;
- struct tbmeter *tbm;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- tbm = tbm_create(top, &ap->profile, &ap->in_action, &ap->out_action);
- if (tbm == NULL)
- return (EINVAL);
- /* return a class handle to the user */
- ap->cdnr_handle = cdnr_cb2handle(&tbm->cdnrblk);
- return (0);
-}
-
-static int
-cdnrcmd_modify_tbm(ap)
- struct cdnr_modify_tbmeter *ap;
-{
- struct tbmeter *tbm;
-
- if ((tbm = (struct tbmeter *)cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- tb_import_profile(&tbm->tb, &ap->profile);
-
- return (0);
-}
-
-static int
-cdnrcmd_tbm_stats(ap)
- struct cdnr_tbmeter_stats *ap;
-{
- struct tbmeter *tbm;
-
- if ((tbm = (struct tbmeter *)cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- ap->in_cnt = tbm->in_cnt;
- ap->out_cnt = tbm->out_cnt;
-
- return (0);
-}
-
-static int
-cdnrcmd_add_trtcm(ap)
- struct cdnr_add_trtcm *ap;
-{
- struct top_cdnr *top;
- struct trtcm *tcm;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- tcm = trtcm_create(top, &ap->cmtd_profile, &ap->peak_profile,
- &ap->green_action, &ap->yellow_action,
- &ap->red_action, ap->coloraware);
- if (tcm == NULL)
- return (EINVAL);
-
- /* return a class handle to the user */
- ap->cdnr_handle = cdnr_cb2handle(&tcm->cdnrblk);
- return (0);
-}
-
-static int
-cdnrcmd_modify_trtcm(ap)
- struct cdnr_modify_trtcm *ap;
-{
- struct trtcm *tcm;
-
- if ((tcm = (struct trtcm *)cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- tb_import_profile(&tcm->cmtd_tb, &ap->cmtd_profile);
- tb_import_profile(&tcm->peak_tb, &ap->peak_profile);
-
- return (0);
-}
-
-static int
-cdnrcmd_tcm_stats(ap)
- struct cdnr_tcm_stats *ap;
-{
- struct cdnr_block *cb;
-
- if ((cb = cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- if (cb->cb_type == TCETYPE_TRTCM) {
- struct trtcm *tcm = (struct trtcm *)cb;
-
- ap->green_cnt = tcm->green_cnt;
- ap->yellow_cnt = tcm->yellow_cnt;
- ap->red_cnt = tcm->red_cnt;
- } else if (cb->cb_type == TCETYPE_TSWTCM) {
- struct tswtcm *tsw = (struct tswtcm *)cb;
-
- ap->green_cnt = tsw->green_cnt;
- ap->yellow_cnt = tsw->yellow_cnt;
- ap->red_cnt = tsw->red_cnt;
- } else
- return (EINVAL);
-
- return (0);
-}
-
-static int
-cdnrcmd_add_tswtcm(ap)
- struct cdnr_add_tswtcm *ap;
-{
- struct top_cdnr *top;
- struct tswtcm *tsw;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- if (ap->cmtd_rate > ap->peak_rate)
- return (EINVAL);
-
- tsw = tswtcm_create(top, ap->cmtd_rate, ap->peak_rate,
- ap->avg_interval, &ap->green_action,
- &ap->yellow_action, &ap->red_action);
- if (tsw == NULL)
- return (EINVAL);
-
- /* return a class handle to the user */
- ap->cdnr_handle = cdnr_cb2handle(&tsw->cdnrblk);
- return (0);
-}
-
-static int
-cdnrcmd_modify_tswtcm(ap)
- struct cdnr_modify_tswtcm *ap;
-{
- struct tswtcm *tsw;
-
- if ((tsw = (struct tswtcm *)cdnr_handle2cb(ap->cdnr_handle)) == NULL)
- return (EINVAL);
-
- if (ap->cmtd_rate > ap->peak_rate)
- return (EINVAL);
-
- /* convert rates from bits/sec to bytes/sec */
- tsw->cmtd_rate = ap->cmtd_rate / 8;
- tsw->peak_rate = ap->peak_rate / 8;
- tsw->avg_rate = 0;
-
- /* timewin is converted from msec to machine clock unit */
- tsw->timewin = (u_int64_t)machclk_freq * ap->avg_interval / 1000;
-
- return (0);
-}
-
-static int
-cdnrcmd_get_stats(ap)
- struct cdnr_get_stats *ap;
-{
- struct top_cdnr *top;
- struct cdnr_block *cb;
- struct tbmeter *tbm;
- struct trtcm *tcm;
- struct tswtcm *tsw;
- struct tce_stats tce, *usp;
- int error, n, nskip, nelements;
-
- if ((top = tcb_lookup(ap->iface.cdnr_ifname)) == NULL)
- return (EBADF);
-
- /* copy action stats */
- bcopy(top->tc_cnts, ap->cnts, sizeof(ap->cnts));
-
- /* stats for each element */
- nelements = ap->nelements;
- usp = ap->tce_stats;
- if (nelements <= 0 || usp == NULL)
- return (0);
-
- nskip = ap->nskip;
- n = 0;
- LIST_FOREACH(cb, &top->tc_elements, cb_next) {
- if (nskip > 0) {
- nskip--;
- continue;
- }
-
- bzero(&tce, sizeof(tce));
- tce.tce_handle = cb->cb_handle;
- tce.tce_type = cb->cb_type;
- switch (cb->cb_type) {
- case TCETYPE_TBMETER:
- tbm = (struct tbmeter *)cb;
- tce.tce_cnts[0] = tbm->in_cnt;
- tce.tce_cnts[1] = tbm->out_cnt;
- break;
- case TCETYPE_TRTCM:
- tcm = (struct trtcm *)cb;
- tce.tce_cnts[0] = tcm->green_cnt;
- tce.tce_cnts[1] = tcm->yellow_cnt;
- tce.tce_cnts[2] = tcm->red_cnt;
- break;
- case TCETYPE_TSWTCM:
- tsw = (struct tswtcm *)cb;
- tce.tce_cnts[0] = tsw->green_cnt;
- tce.tce_cnts[1] = tsw->yellow_cnt;
- tce.tce_cnts[2] = tsw->red_cnt;
- break;
- default:
- continue;
- }
-
- if ((error = copyout((caddr_t)&tce, (caddr_t)usp++,
- sizeof(tce))) != 0)
- return (error);
-
- if (++n == nelements)
- break;
- }
- ap->nelements = n;
-
- return (0);
-}
diff --git a/sys/altq/altq_cdnr.h b/sys/altq/altq_cdnr.h
deleted file mode 100644
index c15d8033f31..00000000000
--- a/sys/altq/altq_cdnr.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/* $OpenBSD: altq_cdnr.h,v 1.4 2002/12/16 17:27:20 henning Exp $ */
-/* $KAME: altq_cdnr.h,v 1.6 2000/12/14 08:12:45 thorpej Exp $ */
-
-/*
- * Copyright (C) 1999-2000
- * Sony Computer Science Laboratories Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ALTQ_ALTQ_CDNR_H_
-#define _ALTQ_ALTQ_CDNR_H_
-
-#include <altq/altq.h>
-
-/*
- * traffic conditioner element types
- */
-#define TCETYPE_NONE 0
-#define TCETYPE_TOP 1 /* top level conditioner */
-#define TCETYPE_ELEMENT 2 /* a simple tc element */
-#define TCETYPE_TBMETER 3 /* token bucket meter */
-#define TCETYPE_TRTCM 4 /* (two-rate) three color marker */
-#define TCETYPE_TSWTCM 5 /* time sliding window 3-color maker */
-
-/*
- * traffic conditioner action
- */
-struct cdnr_block;
-
-struct tc_action {
- int tca_code; /* e.g., TCACODE_PASS */
- /* tca_code dependent variable */
- union {
- u_long un_value; /* template */
- u_int8_t un_dscp; /* diffserv code point */
- u_long un_handle; /* tc action handle */
- struct cdnr_block *un_next; /* next tc element block */
- } tca_un;
-};
-#define tca_value tca_un.un_value
-#define tca_dscp tca_un.un_dscp
-#define tca_handle tca_un.un_handle
-#define tca_next tca_un.un_next
-
-#define TCACODE_NONE 0 /* action is not set */
-#define TCACODE_PASS 1 /* pass this packet */
-#define TCACODE_DROP 2 /* discard this packet */
-#define TCACODE_RETURN 3 /* do not process this packet */
-#define TCACODE_MARK 4 /* mark dscp */
-#define TCACODE_HANDLE 5 /* take action specified by handle */
-#define TCACODE_NEXT 6 /* take action in the next tc element */
-#define TCACODE_MAX 6
-
-#define CDNR_NULL_HANDLE 0
-
-struct cdnr_interface {
- char cdnr_ifname[IFNAMSIZ]; /* interface name (e.g., fxp0) */
-};
-
-/* simple element operations */
-struct cdnr_add_element {
- struct cdnr_interface iface;
- struct tc_action action;
-
- u_long cdnr_handle; /* return value */
-};
-
-struct cdnr_delete_element {
- struct cdnr_interface iface;
- u_long cdnr_handle;
-};
-
-/* token-bucket meter operations */
-struct cdnr_add_tbmeter {
- struct cdnr_interface iface;
- struct tb_profile profile;
- struct tc_action in_action;
- struct tc_action out_action;
-
- u_long cdnr_handle; /* return value */
-};
-
-struct cdnr_modify_tbmeter {
- struct cdnr_interface iface;
- u_long cdnr_handle;
- struct tb_profile profile;
-};
-
-struct cdnr_tbmeter_stats {
- struct cdnr_interface iface;
- u_long cdnr_handle;
- struct pktcntr in_cnt;
- struct pktcntr out_cnt;
-};
-
-/* two-rate three-color marker operations */
-struct cdnr_add_trtcm {
- struct cdnr_interface iface;
- struct tb_profile cmtd_profile; /* profile for committed tb */
- struct tb_profile peak_profile; /* profile for peak tb */
- struct tc_action green_action; /* action for green packets */
- struct tc_action yellow_action; /* action for yellow packets */
- struct tc_action red_action; /* action for red packets */
- int coloraware; /* color-aware/color-blind */
-
- u_long cdnr_handle; /* return value */
-};
-
-struct cdnr_modify_trtcm {
- struct cdnr_interface iface;
- u_long cdnr_handle;
- struct tb_profile cmtd_profile; /* profile for committed tb */
- struct tb_profile peak_profile; /* profile for peak tb */
- int coloraware; /* color-aware/color-blind */
-};
-
-struct cdnr_tcm_stats {
- struct cdnr_interface iface;
- u_long cdnr_handle;
- struct pktcntr green_cnt;
- struct pktcntr yellow_cnt;
- struct pktcntr red_cnt;
-};
-
-/* time sliding window three-color marker operations */
-struct cdnr_add_tswtcm {
- struct cdnr_interface iface;
- u_int32_t cmtd_rate; /* committed rate (bits/sec) */
- u_int32_t peak_rate; /* peak rate (bits/sec) */
- u_int32_t avg_interval; /* averaging interval (msec) */
- struct tc_action green_action; /* action for green packets */
- struct tc_action yellow_action; /* action for yellow packets */
- struct tc_action red_action; /* action for red packets */
-
- u_long cdnr_handle; /* return value */
-};
-
-struct cdnr_modify_tswtcm {
- struct cdnr_interface iface;
- u_long cdnr_handle;
- u_int32_t cmtd_rate; /* committed rate (bits/sec) */
- u_int32_t peak_rate; /* peak rate (bits/sec) */
- u_int32_t avg_interval; /* averaging interval (msec) */
-};
-
-struct tce_stats {
- u_long tce_handle; /* tc element handle */
- int tce_type; /* e.g., TCETYPE_ELEMENT */
- struct pktcntr tce_cnts[3]; /* tcm returns 3 counters */
-};
-
-struct cdnr_get_stats {
- struct cdnr_interface iface;
- struct pktcntr cnts[TCACODE_MAX+1];
-
- /* element stats */
- int nskip; /* skip # of elements */
- int nelements; /* # of element stats (WR) */
- struct tce_stats *tce_stats; /* pointer to stats array */
-};
-
-#ifndef DSCP_EF
-/* diffserve code points */
-#define DSCP_MASK 0xfc
-#define DSCP_CUMASK 0x03
-#define DSCP_EF 0xb8
-#define DSCP_AF11 0x28
-#define DSCP_AF12 0x30
-#define DSCP_AF13 0x38
-#define DSCP_AF21 0x48
-#define DSCP_AF22 0x50
-#define DSCP_AF23 0x58
-#define DSCP_AF31 0x68
-#define DSCP_AF32 0x70
-#define DSCP_AF33 0x78
-#define DSCP_AF41 0x88
-#define DSCP_AF42 0x90
-#define DSCP_AF43 0x98
-#define AF_CLASSMASK 0xe0
-#define AF_DROPPRECMASK 0x18
-#endif
-
-#ifdef _KERNEL
-
-/*
- * packet information passed to the input function of tc elements
- */
-struct cdnr_pktinfo {
- int pkt_len; /* packet length */
- u_int8_t pkt_dscp; /* diffserv code point */
-};
-
-/*
- * traffic conditioner control block common to all types of tc elements
- */
-struct cdnr_block {
- LIST_ENTRY(cdnr_block) cb_next;
- int cb_len; /* size of this tc element */
- int cb_type; /* cdnr block type */
- int cb_ref; /* reference count of this element */
- u_long cb_handle; /* handle of this tc element */
- struct top_cdnr *cb_top; /* back pointer to top */
- struct tc_action cb_action; /* top level action for this tcb */
- struct tc_action *(*cb_input)(struct cdnr_block *,
- struct cdnr_pktinfo *);
-};
-
-/*
- * top level traffic conditioner structure for an interface
- */
-struct top_cdnr {
- struct cdnr_block tc_block;
-
- LIST_ENTRY(top_cdnr) tc_next;
- struct ifaltq *tc_ifq;
-
- LIST_HEAD(, cdnr_block) tc_elements;
-
- struct pktcntr tc_cnts[TCACODE_MAX+1];
-};
-
-/* token bucket element */
-struct tbe {
- u_int64_t rate;
- u_int64_t depth;
-
- u_int64_t token;
- u_int64_t filluptime;
- u_int64_t last;
-};
-
-/* token bucket meter structure */
-struct tbmeter {
- struct cdnr_block cdnrblk; /* conditioner block */
- struct tbe tb; /* token bucket */
- struct tc_action in_action; /* actions for IN/OUT */
- struct tc_action out_action; /* actions for IN/OUT */
- struct pktcntr in_cnt; /* statistics for IN/OUT */
- struct pktcntr out_cnt; /* statistics for IN/OUT */
-};
-
-/* two-rate three-color marker structure */
-struct trtcm {
- struct cdnr_block cdnrblk; /* conditioner block */
- struct tbe cmtd_tb; /* committed tb profile */
- struct tbe peak_tb; /* peak tb profile */
- struct tc_action green_action;
- struct tc_action yellow_action;
- struct tc_action red_action;
- int coloraware;
- u_int8_t green_dscp;
- u_int8_t yellow_dscp;
- u_int8_t red_dscp;
- struct pktcntr green_cnt;
- struct pktcntr yellow_cnt;
- struct pktcntr red_cnt;
-};
-
-/* time sliding window three-color marker structure */
-struct tswtcm {
- struct cdnr_block cdnrblk; /* conditioner block */
-
- u_int32_t avg_rate; /* average rate (bytes/sec) */
- u_int64_t t_front; /* timestamp of last update */
-
- u_int64_t timewin; /* average interval */
- u_int32_t cmtd_rate; /* committed target rate */
- u_int32_t peak_rate; /* peak target rate */
- struct tc_action green_action;
- struct tc_action yellow_action;
- struct tc_action red_action;
- u_int8_t green_dscp;
- u_int8_t yellow_dscp;
- u_int8_t red_dscp;
- struct pktcntr green_cnt;
- struct pktcntr yellow_cnt;
- struct pktcntr red_cnt;
-};
-
-#endif /* _KERNEL */
-
-#endif /* _ALTQ_ALTQ_CDNR_H_ */
diff --git a/sys/altq/altq_hfsc.h b/sys/altq/altq_hfsc.h
index 85d5f20afb0..101980bf587 100644
--- a/sys/altq/altq_hfsc.h
+++ b/sys/altq/altq_hfsc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_hfsc.h,v 1.6 2004/01/14 08:42:23 kjc Exp $ */
+/* $OpenBSD: altq_hfsc.h,v 1.7 2011/07/03 22:39:12 tedu Exp $ */
/* $KAME: altq_hfsc.h,v 1.8 2002/11/29 04:36:23 kjc Exp $ */
/*
@@ -36,7 +36,6 @@
#include <altq/altq.h>
#include <altq/altq_classq.h>
#include <altq/altq_red.h>
-#include <altq/altq_rio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/sys/altq/altq_priq.h b/sys/altq/altq_priq.h
index 776ab52ca00..14f5f4b9f84 100644
--- a/sys/altq/altq_priq.h
+++ b/sys/altq/altq_priq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_priq.h,v 1.6 2004/01/14 08:42:23 kjc Exp $ */
+/* $OpenBSD: altq_priq.h,v 1.7 2011/07/03 22:39:12 tedu Exp $ */
/* $KAME: altq_priq.h,v 1.1 2000/10/18 09:15:23 kjc Exp $ */
/*
* Copyright (C) 2000-2002
@@ -32,7 +32,6 @@
#include <altq/altq.h>
#include <altq/altq_classq.h>
#include <altq/altq_red.h>
-#include <altq/altq_rio.h>
#ifdef __cplusplus
extern "C" {
diff --git a/sys/altq/altq_rio.c b/sys/altq/altq_rio.c
deleted file mode 100644
index e3d4207a0c9..00000000000
--- a/sys/altq/altq_rio.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* $OpenBSD: altq_rio.c,v 1.12 2008/05/08 15:22:02 chl Exp $ */
-/* $KAME: altq_rio.c,v 1.8 2000/12/14 08:12:46 thorpej Exp $ */
-
-/*
- * Copyright (C) 1998-2000
- * Sony Computer Science Laboratories Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/*
- * Copyright (c) 1990-1994 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Computer Systems
- * Engineering Group at Lawrence Berkeley Laboratory.
- * 4. Neither the name of the University nor of the Laboratory may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/systm.h>
-#include <sys/errno.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-
-#include <net/pfvar.h>
-#include <altq/altq.h>
-#include <altq/altq_cdnr.h>
-#include <altq/altq_red.h>
-#include <altq/altq_rio.h>
-
-/*
- * RIO: RED with IN/OUT bit
- * described in
- * "Explicit Allocation of Best Effort Packet Delivery Service"
- * David D. Clark and Wenjia Fang, MIT Lab for Computer Science
- * http://diffserv.lcs.mit.edu/Papers/exp-alloc-ddc-wf.{ps,pdf}
- *
- * this implementation is extended to support more than 2 drop precedence
- * values as described in RFC2597 (Assured Forwarding PHB Group).
- *
- */
-/*
- * AF DS (differentiated service) codepoints.
- * (classes can be mapped to CBQ or H-FSC classes.)
- *
- * 0 1 2 3 4 5 6 7
- * +---+---+---+---+---+---+---+---+
- * | CLASS |DropPre| 0 | CU |
- * +---+---+---+---+---+---+---+---+
- *
- * class 1: 001
- * class 2: 010
- * class 3: 011
- * class 4: 100
- *
- * low drop prec: 01
- * medium drop prec: 10
- * high drop prec: 01
- */
-
-/* normal red parameters */
-#define W_WEIGHT 512 /* inverse of weight of EWMA (511/512) */
- /* q_weight = 0.00195 */
-
-/* red parameters for a slow link */
-#define W_WEIGHT_1 128 /* inverse of weight of EWMA (127/128) */
- /* q_weight = 0.0078125 */
-
-/* red parameters for a very slow link (e.g., dialup) */
-#define W_WEIGHT_2 64 /* inverse of weight of EWMA (63/64) */
- /* q_weight = 0.015625 */
-
-/* fixed-point uses 12-bit decimal places */
-#define FP_SHIFT 12 /* fixed-point shift */
-
-/* red parameters for drop probability */
-#define INV_P_MAX 10 /* inverse of max drop probability */
-#define TH_MIN 5 /* min threshold */
-#define TH_MAX 15 /* max threshold */
-
-#define RIO_LIMIT 60 /* default max queue length */
-#define RIO_STATS /* collect statistics */
-
-#define TV_DELTA(a, b, delta) { \
- int xxs; \
- \
- delta = (a)->tv_usec - (b)->tv_usec; \
- if ((xxs = (a)->tv_sec - (b)->tv_sec) != 0) { \
- if (xxs < 0) { \
- delta = 60000000; \
- } else if (xxs > 4) { \
- if (xxs > 60) \
- delta = 60000000; \
- else \
- delta += xxs * 1000000; \
- } else while (xxs > 0) { \
- delta += 1000000; \
- xxs--; \
- } \
- } \
-}
-
-/* default rio parameter values */
-static struct redparams default_rio_params[RIO_NDROPPREC] = {
- /* th_min, th_max, inv_pmax */
- { TH_MAX * 2 + TH_MIN, TH_MAX * 3, INV_P_MAX }, /* low drop precedence */
- { TH_MAX + TH_MIN, TH_MAX * 2, INV_P_MAX }, /* medium drop precedence */
- { TH_MIN, TH_MAX, INV_P_MAX } /* high drop precedence */
-};
-
-/* internal function prototypes */
-static int dscp2index(u_int8_t);
-
-rio_t *
-rio_alloc(int weight, struct redparams *params, int flags, int pkttime)
-{
- rio_t *rp;
- int w, i;
- int npkts_per_sec;
-
- rp = malloc(sizeof(rio_t), M_DEVBUF, M_WAITOK|M_ZERO);
-
- rp->rio_flags = flags;
- if (pkttime == 0)
- /* default packet time: 1000 bytes / 10Mbps * 8 * 1000000 */
- rp->rio_pkttime = 800;
- else
- rp->rio_pkttime = pkttime;
-
- if (weight != 0)
- rp->rio_weight = weight;
- else {
- /* use default */
- rp->rio_weight = W_WEIGHT;
-
- /* when the link is very slow, adjust red parameters */
- npkts_per_sec = 1000000 / rp->rio_pkttime;
- if (npkts_per_sec < 50) {
- /* up to about 400Kbps */
- rp->rio_weight = W_WEIGHT_2;
- } else if (npkts_per_sec < 300) {
- /* up to about 2.4Mbps */
- rp->rio_weight = W_WEIGHT_1;
- }
- }
-
- /* calculate wshift. weight must be power of 2 */
- w = rp->rio_weight;
- for (i = 0; w > 1; i++)
- w = w >> 1;
- rp->rio_wshift = i;
- w = 1 << rp->rio_wshift;
- if (w != rp->rio_weight) {
- printf("invalid weight value %d for red! use %d\n",
- rp->rio_weight, w);
- rp->rio_weight = w;
- }
-
- /* allocate weight table */
- rp->rio_wtab = wtab_alloc(rp->rio_weight);
-
- for (i = 0; i < RIO_NDROPPREC; i++) {
- struct dropprec_state *prec = &rp->rio_precstate[i];
-
- prec->avg = 0;
- prec->idle = 1;
-
- if (params == NULL || params[i].inv_pmax == 0)
- prec->inv_pmax = default_rio_params[i].inv_pmax;
- else
- prec->inv_pmax = params[i].inv_pmax;
- if (params == NULL || params[i].th_min == 0)
- prec->th_min = default_rio_params[i].th_min;
- else
- prec->th_min = params[i].th_min;
- if (params == NULL || params[i].th_max == 0)
- prec->th_max = default_rio_params[i].th_max;
- else
- prec->th_max = params[i].th_max;
-
- /*
- * th_min_s and th_max_s are scaled versions of th_min
- * and th_max to be compared with avg.
- */
- prec->th_min_s = prec->th_min << (rp->rio_wshift + FP_SHIFT);
- prec->th_max_s = prec->th_max << (rp->rio_wshift + FP_SHIFT);
-
- /*
- * precompute probability denominator
- * probd = (2 * (TH_MAX-TH_MIN) / pmax) in fixed-point
- */
- prec->probd = (2 * (prec->th_max - prec->th_min)
- * prec->inv_pmax) << FP_SHIFT;
-
- microtime(&prec->last);
- }
-
- return (rp);
-}
-
-void
-rio_destroy(rio_t *rp)
-{
- wtab_destroy(rp->rio_wtab);
- free(rp, M_DEVBUF);
-}
-
-void
-rio_getstats(rio_t *rp, struct redstats *sp)
-{
- int i;
-
- for (i = 0; i < RIO_NDROPPREC; i++) {
- bcopy(&rp->q_stats[i], sp, sizeof(struct redstats));
- sp->q_avg = rp->rio_precstate[i].avg >> rp->rio_wshift;
- sp++;
- }
-}
-
-#if (RIO_NDROPPREC == 3)
-/*
- * internally, a drop precedence value is converted to an index
- * starting from 0.
- */
-static int
-dscp2index(u_int8_t dscp)
-{
- int dpindex = dscp & AF_DROPPRECMASK;
-
- if (dpindex == 0)
- return (0);
- return ((dpindex >> 3) - 1);
-}
-#endif
-
-#if 1
-/*
- * kludge: when a packet is dequeued, we need to know its drop precedence
- * in order to keep the queue length of each drop precedence.
- * use m_pkthdr.rcvif to pass this info.
- */
-#define RIOM_SET_PRECINDEX(m, idx) \
- do { (m)->m_pkthdr.rcvif = (struct ifnet *)((long)(idx)); } while (0)
-#define RIOM_GET_PRECINDEX(m) \
- ({ long idx; idx = (long)((m)->m_pkthdr.rcvif); \
- (m)->m_pkthdr.rcvif = NULL; idx; })
-#endif
-
-int
-rio_addq(rio_t *rp, class_queue_t *q, struct mbuf *m,
- struct altq_pktattr *pktattr)
-{
- int avg, droptype;
- u_int8_t dsfield, odsfield;
- int dpindex, i, n, t;
- struct timeval now;
- struct dropprec_state *prec;
-
- dsfield = odsfield = read_dsfield(m, pktattr);
- dpindex = dscp2index(dsfield);
-
- /*
- * update avg of the precedence states whose drop precedence
- * is larger than or equal to the drop precedence of the packet
- */
- now.tv_sec = 0;
- for (i = dpindex; i < RIO_NDROPPREC; i++) {
- prec = &rp->rio_precstate[i];
- avg = prec->avg;
- if (prec->idle) {
- prec->idle = 0;
- if (now.tv_sec == 0)
- microtime(&now);
- t = (now.tv_sec - prec->last.tv_sec);
- if (t > 60)
- avg = 0;
- else {
- t = t * 1000000 +
- (now.tv_usec - prec->last.tv_usec);
- n = t / rp->rio_pkttime;
- /* calculate (avg = (1 - Wq)^n * avg) */
- if (n > 0)
- avg = (avg >> FP_SHIFT) *
- pow_w(rp->rio_wtab, n);
- }
- }
-
- /* run estimator. (avg is scaled by WEIGHT in fixed-point) */
- avg += (prec->qlen << FP_SHIFT) - (avg >> rp->rio_wshift);
- prec->avg = avg; /* save the new value */
- /*
- * count keeps a tally of arriving traffic that has not
- * been dropped.
- */
- prec->count++;
- }
-
- prec = &rp->rio_precstate[dpindex];
- avg = prec->avg;
-
- /* see if we drop early */
- droptype = DTYPE_NODROP;
- if (avg >= prec->th_min_s && prec->qlen > 1) {
- if (avg >= prec->th_max_s) {
- /* avg >= th_max: forced drop */
- droptype = DTYPE_FORCED;
- } else if (prec->old == 0) {
- /* first exceeds th_min */
- prec->count = 1;
- prec->old = 1;
- } else if (drop_early((avg - prec->th_min_s) >> rp->rio_wshift,
- prec->probd, prec->count)) {
- /* unforced drop by red */
- droptype = DTYPE_EARLY;
- }
- } else {
- /* avg < th_min */
- prec->old = 0;
- }
-
- /*
- * if the queue length hits the hard limit, it's a forced drop.
- */
- if (droptype == DTYPE_NODROP && qlen(q) >= qlimit(q))
- droptype = DTYPE_FORCED;
-
- if (droptype != DTYPE_NODROP) {
- /* always drop incoming packet (as opposed to randomdrop) */
- for (i = dpindex; i < RIO_NDROPPREC; i++)
- rp->rio_precstate[i].count = 0;
-#ifdef RIO_STATS
- if (droptype == DTYPE_EARLY)
- rp->q_stats[dpindex].drop_unforced++;
- else
- rp->q_stats[dpindex].drop_forced++;
- PKTCNTR_ADD(&rp->q_stats[dpindex].drop_cnt, m_pktlen(m));
-#endif
- m_freem(m);
- return (-1);
- }
-
- for (i = dpindex; i < RIO_NDROPPREC; i++)
- rp->rio_precstate[i].qlen++;
-
- /* save drop precedence index in mbuf hdr */
- RIOM_SET_PRECINDEX(m, dpindex);
-
- if (rp->rio_flags & RIOF_CLEARDSCP)
- dsfield &= ~DSCP_MASK;
-
- if (dsfield != odsfield)
- write_dsfield(m, pktattr, dsfield);
-
- _addq(q, m);
-
-#ifdef RIO_STATS
- PKTCNTR_ADD(&rp->q_stats[dpindex].xmit_cnt, m_pktlen(m));
-#endif
- return (0);
-}
-
-struct mbuf *
-rio_getq(rio_t *rp, class_queue_t *q)
-{
- struct mbuf *m;
- int dpindex, i;
-
- if ((m = _getq(q)) == NULL)
- return NULL;
-
- dpindex = RIOM_GET_PRECINDEX(m);
- for (i = dpindex; i < RIO_NDROPPREC; i++) {
- if (--rp->rio_precstate[i].qlen == 0) {
- if (rp->rio_precstate[i].idle == 0) {
- rp->rio_precstate[i].idle = 1;
- microtime(&rp->rio_precstate[i].last);
- }
- }
- }
- return (m);
-}
diff --git a/sys/altq/altq_rio.h b/sys/altq/altq_rio.h
deleted file mode 100644
index da3835e5ec6..00000000000
--- a/sys/altq/altq_rio.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* $OpenBSD: altq_rio.h,v 1.6 2003/03/13 16:33:46 kjc Exp $ */
-/* $KAME: altq_rio.h,v 1.5 2000/12/14 08:12:46 thorpej Exp $ */
-
-/*
- * Copyright (C) 1998-2000
- * Sony Computer Science Laboratories Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef _ALTQ_ALTQ_RIO_H_
-#define _ALTQ_ALTQ_RIO_H_
-
-#include <altq/altq_classq.h>
-
-/*
- * RIO: RED with IN/OUT bit
- * (extended to support more than 2 drop precedence values)
- */
-#define RIO_NDROPPREC 3 /* number of drop precedence values */
-
-struct rio_interface {
- char rio_ifname[IFNAMSIZ];
-};
-
-struct rio_stats {
- struct rio_interface iface;
- int q_len[RIO_NDROPPREC];
- struct redstats q_stats[RIO_NDROPPREC];
-
- /* static red parameters */
- int q_limit;
- int weight;
- int flags;
- struct redparams q_params[RIO_NDROPPREC];
-};
-
-struct rio_conf {
- struct rio_interface iface;
- struct redparams q_params[RIO_NDROPPREC];
- int rio_weight; /* weight for EWMA */
- int rio_limit; /* max queue length */
- int rio_pkttime; /* avg packet time in usec */
- int rio_flags; /* see below */
-};
-
-/* rio flags */
-#define RIOF_ECN4 0x01 /* use packet marking for IPv4 packets */
-#define RIOF_ECN6 0x02 /* use packet marking for IPv6 packets */
-#define RIOF_ECN (RIOF_ECN4 | RIOF_ECN6)
-#define RIOF_CLEARDSCP 0x200 /* clear diffserv codepoint */
-
-#ifdef _KERNEL
-
-typedef struct rio {
- /* per drop precedence structure */
- struct dropprec_state {
- /* red parameters */
- int inv_pmax; /* inverse of max drop probability */
- int th_min; /* red min threshold */
- int th_max; /* red max threshold */
-
- /* variables for internal use */
- int th_min_s; /* th_min scaled by avgshift */
- int th_max_s; /* th_max scaled by avgshift */
- int probd; /* drop probability denominator */
-
- int qlen; /* queue length */
- int avg; /* (scaled) queue length average */
- int count; /* packet count since the last dropped/
- marked packet */
- int idle; /* queue was empty */
- int old; /* avg is above th_min */
- struct timeval last; /* timestamp when queue becomes idle */
- } rio_precstate[RIO_NDROPPREC];
-
- int rio_wshift; /* log(red_weight) */
- int rio_weight; /* weight for EWMA */
- struct wtab *rio_wtab; /* weight table */
-
- int rio_pkttime; /* average packet time in micro sec
- used for idle calibration */
- int rio_flags; /* rio flags */
-
- u_int8_t rio_codepoint; /* codepoint value to tag packets */
- u_int8_t rio_codepointmask; /* codepoint mask bits */
-
- struct redstats q_stats[RIO_NDROPPREC]; /* statistics */
-} rio_t;
-
-typedef struct rio_queue {
- struct rio_queue *rq_next; /* next red_state in the list */
- struct ifaltq *rq_ifq; /* backpointer to ifaltq */
-
- class_queue_t *rq_q;
-
- rio_t *rq_rio;
-} rio_queue_t;
-
-extern rio_t *rio_alloc(int, struct redparams *, int, int);
-extern void rio_destroy(rio_t *);
-extern void rio_getstats(rio_t *, struct redstats *);
-extern int rio_addq(rio_t *, class_queue_t *, struct mbuf *,
- struct altq_pktattr *);
-extern struct mbuf *rio_getq(rio_t *, class_queue_t *);
-
-#endif /* _KERNEL */
-
-#endif /* _ALTQ_ALTQ_RIO_H_ */
diff --git a/sys/altq/altq_rmclass.c b/sys/altq/altq_rmclass.c
index 45a7e8d36c8..7efaaa46108 100644
--- a/sys/altq/altq_rmclass.c
+++ b/sys/altq/altq_rmclass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: altq_rmclass.c,v 1.15 2008/05/08 15:22:02 chl Exp $ */
+/* $OpenBSD: altq_rmclass.c,v 1.16 2011/07/03 22:39:12 tedu Exp $ */
/* $KAME: altq_rmclass.c,v 1.10 2001/02/09 07:20:40 kjc Exp $ */
/*
@@ -51,7 +51,6 @@
#include <altq/altq_rmclass.h>
#include <altq/altq_rmclass_debug.h>
#include <altq/altq_red.h>
-#include <altq/altq_rio.h>
/*
* Local Macros
diff --git a/sys/altq/if_altq.h b/sys/altq/if_altq.h
index 7c221bb64ae..f32849e9211 100644
--- a/sys/altq/if_altq.h
+++ b/sys/altq/if_altq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_altq.h,v 1.12 2009/05/31 19:15:59 claudio Exp $ */
+/* $OpenBSD: if_altq.h,v 1.13 2011/07/03 22:39:12 tedu Exp $ */
/* $KAME: if_altq.h,v 1.6 2001/01/29 19:59:09 itojun Exp $ */
/*
@@ -29,7 +29,7 @@
#ifndef _ALTQ_IF_ALTQ_H_
#define _ALTQ_IF_ALTQ_H_
-struct altq_pktattr; struct tb_regulator; struct top_cdnr;
+struct altq_pktattr; struct tb_regulator;
/*
* Structure defining a queue for a network interface.
@@ -60,9 +60,6 @@ struct ifaltq {
/* token bucket regulator */
struct tb_regulator *altq_tbr;
-
- /* input traffic conditioner (doesn't belong to the output queue...) */
- struct top_cdnr *altq_cdnr;
};
diff --git a/sys/conf/files b/sys/conf/files
index b0141851c26..b76634a3a62 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.515 2011/06/30 13:43:14 tedu Exp $
+# $OpenBSD: files,v 1.516 2011/07/03 22:39:12 tedu Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -558,10 +558,8 @@ file altq/altq_subr.c altq
file altq/altq_red.c altq
file altq/altq_cbq.c altq
file altq/altq_rmclass.c altq
-file altq/altq_cdnr.c altq_cdnr
file altq/altq_hfsc.c altq
file altq/altq_priq.c altq
-file altq/altq_rio.c altq_rio
file ddb/db_access.c ddb | kgdb
file ddb/db_aout.c ddb
file ddb/db_break.c ddb