svn commit: r203373 - user/luigi/ipfw3-head/sys/netinet/ipfw
Luigi Rizzo
luigi at FreeBSD.org
Tue Feb 2 10:42:15 UTC 2010
Author: luigi
Date: Tue Feb 2 10:42:15 2010
New Revision: 203373
URL: http://svn.freebsd.org/changeset/base/203373
Log:
compat fixes
Modified:
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_qfq.c
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Tue Feb 2 10:32:08 2010 (r203372)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c Tue Feb 2 10:42:15 2010 (r203373)
@@ -36,7 +36,9 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <netinet/ipfw/dn_heap.h>
+#ifndef log
#define log(x, arg...)
+#endif
#else /* !_KERNEL */
Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_qfq.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_qfq.c Tue Feb 2 10:32:08 2010 (r203372)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_sched_qfq.c Tue Feb 2 10:42:15 2010 (r203373)
@@ -51,10 +51,9 @@ static void dump_sched(struct qfq_sched
#define NO(x)
#endif
#define DN_SCHED_QFQ 4 // XXX Where?
-typedef uint64_t u64;
-typedef unsigned int bitmap;
+typedef unsigned long bitmap;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD__ /* actually, only linux X86 */
static inline unsigned long __fls(unsigned long word)
{
asm("bsr %1,%0"
@@ -69,6 +68,7 @@ static inline unsigned long __fls(unsign
}
#endif
+#if !defined(__linux__)
#ifdef QFQ_DEBUG
int test_bit(int ix, bitmap *p)
{
@@ -94,6 +94,8 @@ void __clear_bit(int ix, bitmap *p)
#define __set_bit(ix, pData) (*pData) |= (1<<(ix))
#define __clear_bit(ix, pData) (*pData) &= ~(1<<(ix))
#endif /* !QFQ_DEBUG */
+#endif /* !__linux__ */
+
/*-------------------------------------------*/
/*
@@ -201,12 +203,7 @@ struct qfq_group {
unsigned int slot_shift; /* Slot shift. */
unsigned int index; /* Group index. */
unsigned int front; /* Index of the front slot. */
-
- /*
- * Bitmap with non-empty slots. Using unsigned long as most
- * bitops in Linux use it (i'd rather use u32 or u64 XXX)
- */
- bitmap full_slots;
+ bitmap full_slots; /* non-empty slots */
/* Array of lists of active classes. */
struct qfq_class *slots[QFQ_MAX_SLOTS];
@@ -226,13 +223,13 @@ struct qfq_sched {
/*---- support functions ----------------------------*/
/* Generic comparison function, handling wraparound. */
-static inline int qfq_gt(u64 a, u64 b)
+static inline int qfq_gt(uint64_t a, uint64_t b)
{
return (int64_t)(a - b) > 0;
}
/* Round a precise timestamp to its slotted value. */
-static inline u64 qfq_round_down(u64 ts, unsigned int shift)
+static inline uint64_t qfq_round_down(uint64_t ts, unsigned int shift)
{
return ts & ~((1ULL << shift) - 1);
}
@@ -252,7 +249,7 @@ static inline struct qfq_group *qfq_ffs(
*/
static int qfq_calc_index(uint32_t inv_w, unsigned int maxlen)
{
- u64 slot_size = (u64)maxlen *inv_w;
+ uint64_t slot_size = (uint64_t)maxlen *inv_w;
unsigned long size_map;
int index = 0;
@@ -362,7 +359,7 @@ qfq_move_groups(struct qfq_sched *q, uns
}
static inline void
-qfq_unblock_groups(struct qfq_sched *q, int index, u64 old_finish)
+qfq_unblock_groups(struct qfq_sched *q, int index, uint64_t old_finish)
{
unsigned long mask = mask_from(q->bitmaps[ER], index + 1);
struct qfq_group *next;
@@ -389,7 +386,7 @@ qfq_unblock_groups(struct qfq_sched *q,
*
*/
static inline void
-qfq_make_eligible(struct qfq_sched *q, u64 old_V)
+qfq_make_eligible(struct qfq_sched *q, uint64_t old_V)
{
unsigned long mask, vslot, old_vslot;
@@ -409,9 +406,9 @@ qfq_make_eligible(struct qfq_sched *q, u
* roundedS is always cl->S rounded on grp->slot_shift bits.
*/
static inline void
-qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl, u64 roundedS)
+qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl, uint64_t roundedS)
{
- u64 slot = (roundedS - grp->S) >> grp->slot_shift;
+ uint64_t slot = (roundedS - grp->S) >> grp->slot_shift;
unsigned int i = (grp->front + slot) % QFQ_MAX_SLOTS;
cl->next = grp->slots[i];
@@ -465,7 +462,7 @@ qfq_slot_scan(struct qfq_group *grp)
* Here too we should make sure that i is less than 32
*/
static inline void
-qfq_slot_rotate(struct qfq_sched *q, struct qfq_group *grp, u64 roundedS)
+qfq_slot_rotate(struct qfq_sched *q, struct qfq_group *grp, uint64_t roundedS)
{
unsigned int i = (grp->S - roundedS) >> grp->slot_shift;
@@ -475,7 +472,7 @@ qfq_slot_rotate(struct qfq_sched *q, str
static inline void
-qfq_update_eligible(struct qfq_sched *q, u64 old_V)
+qfq_update_eligible(struct qfq_sched *q, uint64_t old_V)
{
bitmap ineligible;
@@ -504,10 +501,10 @@ qfq_update_class(struct qfq_sched *q, st
qfq_front_slot_remove(grp);
} else {
unsigned int len;
- u64 roundedS;
+ uint64_t roundedS;
len = cl->_q.mq.head->m_pkthdr.len;
- cl->F = cl->S + (u64)len * cl->inv_w;
+ cl->F = cl->S + (uint64_t)len * cl->inv_w;
roundedS = qfq_round_down(cl->S, grp->slot_shift);
if (roundedS == grp->S)
return 0;
@@ -525,7 +522,7 @@ qfq_dequeue(struct dn_sch_inst *si)
struct qfq_group *grp;
struct qfq_class *cl;
struct mbuf *m;
- u64 old_V;
+ uint64_t old_V;
NO(q->loops++;)
if (!q->bitmaps[ER]) {
@@ -546,17 +543,17 @@ qfq_dequeue(struct dn_sch_inst *si)
}
NO(q->queued--;)
old_V = q->V;
- q->V += (u64)m->m_pkthdr.len * IWSUM;
+ q->V += (uint64_t)m->m_pkthdr.len * IWSUM;
ND("m is %p F 0x%llx V now 0x%llx", m, cl->F, q->V);
if (qfq_update_class(q, grp, cl)) {
- u64 old_F = grp->F;
+ uint64_t old_F = grp->F;
cl = qfq_slot_scan(grp);
if (!cl) { /* group gone, remove from ER */
__clear_bit(grp->index, &q->bitmaps[ER]);
// grp->S = grp->F + 1; // XXX debugging only
} else {
- u64 roundedS = qfq_round_down(cl->S, grp->slot_shift);
+ uint64_t roundedS = qfq_round_down(cl->S, grp->slot_shift);
unsigned int s;
if (grp->S == roundedS)
@@ -625,7 +622,7 @@ qfq_enqueue(struct dn_sch_inst *si, stru
struct qfq_sched *q = (struct qfq_sched *)(si + 1);
struct qfq_group *grp;
struct qfq_class *cl = (struct qfq_class *)_q;
- u64 roundedS;
+ uint64_t roundedS;
int s;
NO(q->loops++;)
@@ -643,7 +640,7 @@ qfq_enqueue(struct dn_sch_inst *si, stru
grp = cl->grp;
qfq_update_start(q, cl); /* adjust start time */
/* compute new finish time and rounded start. */
- cl->F = cl->S + (u64)(m->m_pkthdr.len) * cl->inv_w;
+ cl->F = cl->S + (uint64_t)(m->m_pkthdr.len) * cl->inv_w;
roundedS = qfq_round_down(cl->S, grp->slot_shift);
/*
@@ -685,7 +682,7 @@ qfq_slot_remove(struct qfq_sched *q, str
struct qfq_class *cl, struct qfq_class **pprev)
{
unsigned int i, offset;
- u64 roundedS;
+ uint64_t roundedS;
roundedS = qfq_round_down(cl->S, grp->slot_shift);
offset = (roundedS - grp->S) >> grp->slot_shift;
@@ -718,7 +715,7 @@ qfq_deactivate_class(struct qfq_sched *q
{
struct qfq_group *grp = &q->groups[cl->index];
unsigned long mask;
- u64 roundedS;
+ uint64_t roundedS;
int s;
cl->F = cl->S; // not needed if the class goes away.
More information about the svn-src-user
mailing list