svn commit: r202555 - user/luigi/ipfw3-head/sys/netinet/ipfw
Luigi Rizzo
luigi at FreeBSD.org
Mon Jan 18 09:41:54 UTC 2010
Author: luigi
Date: Mon Jan 18 09:41:54 2010
New Revision: 202555
URL: http://svn.freebsd.org/changeset/base/202555
Log:
make wf2q compile;
move div64 to ip_dn_private.h
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Mon Jan 18 09:13:47 2010 (r202554)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_wf2q.c Mon Jan 18 09:41:54 2010 (r202555)
@@ -87,12 +87,12 @@ struct wf2qp_queue {
* from the idle heap.
*/
static void
-idle_check(struct wf2qp_si *siwfq, int n)
+idle_check(struct wf2qp_si *si, int n)
{
struct dn_heap *h = si->idle_heap;
while (n-- > 0 && h->elements > 0 &&
DN_KEY_LT(HEAP_TOP(h)->key, si->V)) {
- struct dn_queue *q = HEAP_TOP(h)->object;
+ struct new_queue *q = HEAP_TOP(h)->object;
struct wf2qp_queue *alg_fq = (struct wf2qp_queue *)(q+1);
heap_extract(h, NULL);
@@ -113,7 +113,7 @@ wf2qp_enqueue(struct new_sch_inst *_si,
uint64_t len = m->m_pkthdr.len;
int q_was_idle;
- q_was_idle = (q->mq.head == NULL)
+ q_was_idle = (q->mq.head == NULL);
if (dn_enqueue(q, m, 0)) /* packet was dropped */
return 1;
@@ -160,69 +160,74 @@ wf2qp_enqueue(struct new_sch_inst *_si,
return 0;
}
-/* XXX invariant: sch > 0 || neh == 0 */
+/* XXX invariant: sch > 0 || V >= min(S in neh) */
static struct mbuf *
wf2qp_dequeue(struct new_sch_inst *_si)
{
- /* Access scheduler instance private data */
- struct wf2qp_si *si = (struct wf2qp_si *)(_si + 1);
- struct mbuf *pkt = NULL;
- struct new_queue *qq, *q1, *q = NULL;
- struct dn_heap *sch = si->sch_heap;
- struct dn_heap *neh = si->ne_heap;
- struct wf2qp_queue *alg_fq = NULL;
- uint64_t len;
-
- if (sch->elements == 0 && neh->elements == 0) {
- /* we have nothing to do. We could kill the idle heap
- * altogether and reset V
+ /* Access scheduler instance private data */
+ struct wf2qp_si *si = (struct wf2qp_si *)(_si + 1);
+ struct mbuf *pkt;
+ struct new_queue *q;
+ struct dn_heap *sch = si->sch_heap;
+ struct dn_heap *neh = si->ne_heap;
+ struct wf2qp_queue *alg_fq;
+
+ if (sch->elements == 0 && neh->elements == 0) {
+ /* we have nothing to do. We could kill the idle heap
+ * altogether and reset V
+ */
+ idle_check(si, 0x7fffffff);
+ si->V = 0;
+ si->sum = 0; /* should be set already */
+ return NULL; /* quick return if nothing to do */
+ }
+ idle_check(si, 1); /* drain something from the idle heap */
+
+ /* make sure at least one element is eligible, bumping V
+ * and moving entries that have become eligible
*/
- idle_check(si, 0x7fffffff);
- si->V = 0;
- si->sum = 0; /* should be set already */
- return NULL; /* quick return if nothing to
- }
- idle_check(si, 1); /* drain something from the idle heap */
- if (sch->elements > 0) {
- /* Have some eligible pkts to send out. */
- q = HEAP_TOP(sch)->object;
- alg_fq = (struct wf2qp_queue *)(q + 1);
- pkt = q->mq.head;
- heap_extract(sch, NULL); /* Remove queue from heap. */
- si->V += div64(pkt->m_pkthdr.len << MY_M, si->sum);
- alg_fq->S = alg_fq->F; /* Update start time. */
-
- if (q->ni.length == 1) { /* not backlogged any more. */
- heap_insert(si->idle_heap, alg_fq->F, q);
- } else { /* Still backlogged. */
- /* Update F, store in neh or sch */
- len = pkt->m_nextpkt->m_pkthdr.len;
- alg_fq->F += div64(len << MY_M, q->fs->fs.weight);
- if (DN_KEY_LEQ(alg_fq->S, si->V)) {
- heap_insert(sch, alg_fq->F, q);
- } else {
- heap_insert(neh, alg_fq->S, q);
- }
- }
- }
- /*
- * Now compute V = max(V, min(S_i)). Remember that all elements
- * in sch have by definition S_i <= V so if sch is not empty,
- * V is surely the max and we must not update it. Conversely,
- * if sch is empty we only need to look at neh.
- */
- if (sch->elements == 0 && neh->elements > 0)
- si->V = MAX64(si->V, HEAP_TOP(neh)->key);
- /* Move from neh to sch any packets that have become eligible */
- while (neh->elements > 0 && DN_KEY_LEQ(HEAP_TOP(neh)->key, si->V)) {
- qq = HEAP_TOP(neh)->object;
- alg_fq = (struct wf2qp_queue *)qq;
- heap_extract(neh, NULL);
- heap_insert(sch, alg_fq->F, qq);
- }
- if (pkt != NULL)
- return dn_dequeue(q);
- return NULL;
+ if (sch->elements == 0 && neh->elements > 0)
+ si->V = MAX64(si->V, HEAP_TOP(neh)->key);
+ while (neh->elements > 0 &&
+ DN_KEY_LEQ(HEAP_TOP(neh)->key, si->V)) {
+ q = HEAP_TOP(neh)->object;
+ alg_fq = (struct wf2qp_queue *)q;
+ heap_extract(neh, NULL);
+ heap_insert(sch, alg_fq->F, q);
+ }
+
+ /* ok we have at least one eligible pkt */
+ q = HEAP_TOP(sch)->object;
+ alg_fq = (struct wf2qp_queue *)(q + 1);
+ pkt = dn_dequeue(q);
+ heap_extract(sch, NULL); /* Remove queue from heap. */
+ si->V += div64(pkt->m_pkthdr.len << MY_M, si->sum);
+ alg_fq->S = alg_fq->F; /* Update start time. */
+
+ if (q->mq.head == 0) { /* not backlogged any more. */
+ heap_insert(si->idle_heap, alg_fq->F, q);
+ } else { /* Still backlogged. */
+ /* Update F, store in neh or sch */
+ uint64_t len = q->mq.head->m_pkthdr.len;
+ alg_fq->F += div64(len << MY_M, q->fs->fs.weight);
+ if (DN_KEY_LEQ(alg_fq->S, si->V)) {
+ heap_insert(sch, alg_fq->F, q);
+ } else {
+ heap_insert(neh, alg_fq->S, q);
+ }
+ }
+
+ /*
+ * Now compute V = max(V, min(S_i)). Remember that all elements
+ * in sch have by definition S_i <= V so if sch is not empty,
+ * V is surely the max and we must not update it. Conversely,
+ * if sch is empty we only need to look at neh.
+ * We don't need to move the queues, as it will be done at the
+ * next enqueue
+ */
+ if (sch->elements == 0 && neh->elements > 0)
+ si->V = MAX64(si->V, HEAP_TOP(neh)->key);
+ return pkt;
}
static int
@@ -258,12 +263,12 @@ wf2qp_free_sched(struct new_sch_inst *_s
static int
wf2qp_new_queue(struct new_queue *_q)
{
- struct wf2qp_queue *q = (struct wf2qp_queue *)(_q + 1);
+ struct wf2qp_queue *q = (struct wf2qp_queue *)(_q + 1);
- _q->ni.oid.subtype = DN_SCHED_WF2QP;
- q->F = 0; /* not strictly necessary */
- q->S = q->F + 1; /* mark timestamp as invalid. */
- return 0;
+ _q->ni.oid.subtype = DN_SCHED_WF2QP;
+ q->F = 0; /* not strictly necessary */
+ q->S = q->F + 1; /* mark timestamp as invalid. */
+ return 0;
}
static int
@@ -285,21 +290,21 @@ wf2qp_free_queue(struct new_queue *q)
* structures and function pointers.
*/
static struct dn_sched wf2qp_desc = {
- .type = DN_SCHED_WF2QP,
- .name = "WF2Q+",
- .flags = DN_MULTIQUEUE,
+ .type = DN_SCHED_WF2QP,
+ .name = "WF2Q+",
+ .flags = DN_MULTIQUEUE,
- .sch_inst_len = sizeof(struct wf2qp_si),
- .queue_len = sizeof(struct wf2qp_queue),
+ .sch_inst_len = sizeof(struct wf2qp_si),
+ .queue_len = sizeof(struct wf2qp_queue),
- .enqueue = wf2qp_enqueue,
- .dequeue = wf2qp_dequeue,
+ .enqueue = wf2qp_enqueue,
+ .dequeue = wf2qp_dequeue,
- .new_sched = wf2qp_new_sched,
- .free_sched = wf2qp_free_sched,
+ .new_sched = wf2qp_new_sched,
+ .free_sched = wf2qp_free_sched,
- .new_queue = wf2qp_new_queue,
- .free_queue = wf2qp_free_queue,
+ .new_queue = wf2qp_new_queue,
+ .free_queue = wf2qp_free_queue,
};
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Mon Jan 18 09:13:47 2010 (r202554)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_io.c Mon Jan 18 09:41:54 2010 (r202555)
@@ -278,8 +278,6 @@ transmit_event(struct mq *q, struct dela
}
}
-#define div64(a, b) ((int64_t)(a) / (int64_t)(b))
-
/*
* Convert the additional MAC overheads/delays into an equivalent
* number of bits for the given data rate. The samples are
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Mon Jan 18 09:13:47 2010 (r202554)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/ip_dn_private.h Mon Jan 18 09:41:54 2010 (r202555)
@@ -36,6 +36,7 @@ MALLOC_DECLARE(M_DUMMYNET);
#ifndef FREE_PKT
#define FREE_PKT(m) m_freem(m)
#endif
+#define div64(a, b) ((int64_t)(a) / (int64_t)(b))
extern struct mtx dummynet_mtx;
#define DUMMYNET_LOCK_INIT() \
More information about the svn-src-user
mailing list