summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorpelikan <pelikan@cvs.openbsd.org>2013-10-31 08:52:45 +0000
committerpelikan <pelikan@cvs.openbsd.org>2013-10-31 08:52:45 +0000
commit35d0986418b88266db39a46b310d2a765abfc48e (patch)
tree58868ced00c11aa0f990371208ae3b599bf57b3e /sys
parentb185504beefc8f11678cdf02e630b2ecc8039183 (diff)
push the queues every 1/HZ using timeout(9)
This is a modified version of oldtbr_timeout() with a timeout for each HFSC enabled interface. ok henning claudio
Diffstat (limited to 'sys')
-rw-r--r--sys/net/hfsc.c23
-rw-r--r--sys/net/hfsc.h5
2 files changed, 26 insertions, 2 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c
index 243c5dad373..f11a3b5654c 100644
--- a/sys/net/hfsc.c
+++ b/sys/net/hfsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hfsc.c,v 1.1 2013/10/12 11:39:17 henning Exp $ */
+/* $OpenBSD: hfsc.c,v 1.2 2013/10/31 08:52:44 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
@@ -74,6 +74,7 @@ int hfsc_addq(struct hfsc_class *, struct mbuf *);
struct mbuf *hfsc_getq(struct hfsc_class *);
struct mbuf *hfsc_pollq(struct hfsc_class *);
void hfsc_purgeq(struct hfsc_class *);
+void hfsc_deferred(void *);
void hfsc_update_cfmin(struct hfsc_class *);
void hfsc_set_active(struct hfsc_class *, int);
void hfsc_set_passive(struct hfsc_class *);
@@ -140,6 +141,9 @@ hfsc_attach(struct ifnet *ifp)
hif->hif_eligible = hfsc_ellist_alloc();
hif->hif_ifq = (struct ifqueue *)&ifp->if_snd; /* XXX cast temp */
ifp->if_snd.ifq_hfsc = hif;
+ timeout_set(&hif->hif_defer, hfsc_deferred, ifp);
+ /* XXX HRTIMER don't schedule it yet, only when some packets wait. */
+ timeout_add(&hif->hif_defer, 1);
return (0);
}
@@ -147,6 +151,7 @@ hfsc_attach(struct ifnet *ifp)
int
hfsc_detach(struct ifnet *ifp)
{
+ timeout_del(&ifp->if_snd.ifq_hfsc->hif_defer);
free(ifp->if_snd.ifq_hfsc, M_DEVBUF);
ifp->if_snd.ifq_hfsc = NULL;
@@ -557,6 +562,7 @@ hfsc_dequeue(struct ifqueue *ifq, int remove)
cl = tcl;
}
+ /* XXX HRTIMER plan hfsc_deferred precisely here. */
if (cl == NULL)
return (NULL);
}
@@ -603,6 +609,21 @@ hfsc_dequeue(struct ifqueue *ifq, int remove)
return (m);
}
+void
+hfsc_deferred(void *arg)
+{
+ struct ifnet *ifp = arg;
+ int s;
+
+ s = splnet();
+ if (HFSC_ENABLED(&ifp->if_snd) && !IFQ_IS_EMPTY(&ifp->if_snd))
+ if_start(ifp);
+ splx(s);
+
+ /* XXX HRTIMER nearest virtual/fit time is likely less than 1/HZ. */
+ timeout_add(&ifp->if_snd.ifq_hfsc->hif_defer, 1);
+}
+
int
hfsc_addq(struct hfsc_class *cl, struct mbuf *m)
{
diff --git a/sys/net/hfsc.h b/sys/net/hfsc.h
index 92c1c980ede..ae362bda6ca 100644
--- a/sys/net/hfsc.h
+++ b/sys/net/hfsc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hfsc.h,v 1.1 2013/10/12 11:39:17 henning Exp $ */
+/* $OpenBSD: hfsc.h,v 1.2 2013/10/31 08:52:44 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
@@ -33,6 +33,8 @@
#ifndef _HFSC_H_
#define _HFSC_H_
+#include <sys/timeout.h>
+
/* hfsc class flags */
#define HFSC_RED 0x0001 /* use RED */
#define HFSC_ECN 0x0002 /* use RED/ECN */
@@ -242,6 +244,7 @@ struct hfsc_if {
u_int hif_classid; /* class id sequence number */
hfsc_ellist_t *hif_eligible; /* eligible list */
+ struct timeout hif_defer; /* for queues that weren't ready */
};
#define HFSC_CLK_SHIFT 8