Changeset View
Changeset View
Standalone View
Standalone View
sys/net/altq/altq_rmclass.c
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
#ifdef ALTQ3_COMPAT | #ifdef ALTQ3_COMPAT | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/in_systm.h> | #include <netinet/in_systm.h> | ||||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||||
#endif | #endif | ||||
#include <net/altq/if_altq.h> | #include <net/altq/if_altq.h> | ||||
#include <net/altq/altq.h> | #include <net/altq/altq.h> | ||||
#include <net/altq/altq_codel.h> | |||||
#include <net/altq/altq_rmclass.h> | #include <net/altq/altq_rmclass.h> | ||||
#include <net/altq/altq_rmclass_debug.h> | #include <net/altq/altq_rmclass_debug.h> | ||||
#include <net/altq/altq_red.h> | #include <net/altq/altq_red.h> | ||||
#include <net/altq/altq_rio.h> | #include <net/altq/altq_rio.h> | ||||
/* | /* | ||||
* Local Macros | * Local Macros | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
#ifndef ALTQ_RIO | #ifndef ALTQ_RIO | ||||
if (flags & RMCF_RIO) { | if (flags & RMCF_RIO) { | ||||
#ifdef ALTQ_DEBUG | #ifdef ALTQ_DEBUG | ||||
printf("rmc_newclass: RIO not configured for CBQ!\n"); | printf("rmc_newclass: RIO not configured for CBQ!\n"); | ||||
#endif | #endif | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
#endif | #endif | ||||
#ifndef ALTQ_CODEL | |||||
if (flags & RMCF_CODEL) { | |||||
#ifdef ALTQ_DEBUG | |||||
printf("rmc_newclass: CODEL not configured for CBQ!\n"); | |||||
#endif | |||||
return (NULL); | |||||
} | |||||
#endif | |||||
cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_NOWAIT | M_ZERO); | cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (cl == NULL) | if (cl == NULL) | ||||
return (NULL); | return (NULL); | ||||
CALLOUT_INIT(&cl->callout_); | CALLOUT_INIT(&cl->callout_); | ||||
cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO); | cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (cl->q_ == NULL) { | if (cl->q_ == NULL) { | ||||
free(cl, M_DEVBUF); | free(cl, M_DEVBUF); | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | else { | ||||
cl->red_ = (red_t *)rio_alloc(0, NULL, | cl->red_ = (red_t *)rio_alloc(0, NULL, | ||||
red_flags, red_pkttime); | red_flags, red_pkttime); | ||||
if (cl->red_ != NULL) | if (cl->red_ != NULL) | ||||
qtype(cl->q_) = Q_RIO; | qtype(cl->q_) = Q_RIO; | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
#endif /* ALTQ_RED */ | #endif /* ALTQ_RED */ | ||||
#ifdef ALTQ_CODEL | |||||
if (flags & RMCF_CODEL) { | |||||
cl->codel_ = codel_alloc(5, 100, 0); | |||||
if (cl->codel_ != NULL) | |||||
qtype(cl->q_) = Q_CODEL; | |||||
} | |||||
#endif | |||||
/* | /* | ||||
* put the class into the class tree | * put the class into the class tree | ||||
*/ | */ | ||||
s = splnet(); | s = splnet(); | ||||
IFQ_LOCK(ifd->ifq_); | IFQ_LOCK(ifd->ifq_); | ||||
if ((peer = ifd->active_[pri]) != NULL) { | if ((peer = ifd->active_[pri]) != NULL) { | ||||
/* find the last class at this pri */ | /* find the last class at this pri */ | ||||
▲ Show 20 Lines • Show All 322 Lines • ▼ Show 20 Lines | |||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->q_)) | if (q_is_rio(cl->q_)) | ||||
rio_destroy((rio_t *)cl->red_); | rio_destroy((rio_t *)cl->red_); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->q_)) | if (q_is_red(cl->q_)) | ||||
red_destroy(cl->red_); | red_destroy(cl->red_); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->q_)) | |||||
codel_destroy(cl->codel_); | |||||
#endif | |||||
} | } | ||||
free(cl->q_, M_DEVBUF); | free(cl->q_, M_DEVBUF); | ||||
free(cl, M_DEVBUF); | free(cl, M_DEVBUF); | ||||
} | } | ||||
/* | /* | ||||
* void | * void | ||||
▲ Show 20 Lines • Show All 941 Lines • ▼ Show 20 Lines | |||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->q_)) | if (q_is_rio(cl->q_)) | ||||
return rio_addq((rio_t *)cl->red_, cl->q_, m, cl->pktattr_); | return rio_addq((rio_t *)cl->red_, cl->q_, m, cl->pktattr_); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->q_)) | if (q_is_red(cl->q_)) | ||||
return red_addq(cl->red_, cl->q_, m, cl->pktattr_); | return red_addq(cl->red_, cl->q_, m, cl->pktattr_); | ||||
#endif /* ALTQ_RED */ | #endif /* ALTQ_RED */ | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->q_)) | |||||
return codel_addq(cl->codel_, cl->q_, m); | |||||
#endif | |||||
if (cl->flags_ & RMCF_CLEARDSCP) | if (cl->flags_ & RMCF_CLEARDSCP) | ||||
write_dsfield(m, cl->pktattr_, 0); | write_dsfield(m, cl->pktattr_, 0); | ||||
_addq(cl->q_, m); | _addq(cl->q_, m); | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 13 Lines | |||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->q_)) | if (q_is_rio(cl->q_)) | ||||
return rio_getq((rio_t *)cl->red_, cl->q_); | return rio_getq((rio_t *)cl->red_, cl->q_); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->q_)) | if (q_is_red(cl->q_)) | ||||
return red_getq(cl->red_, cl->q_); | return red_getq(cl->red_, cl->q_); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->q_)) | |||||
return codel_getq(cl->codel_, cl->q_); | |||||
#endif | |||||
return _getq(cl->q_); | return _getq(cl->q_); | ||||
} | } | ||||
static mbuf_t * | static mbuf_t * | ||||
_rmc_pollq(rm_class_t *cl) | _rmc_pollq(rm_class_t *cl) | ||||
{ | { | ||||
return qhead(cl->q_); | return qhead(cl->q_); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | for (i=0; i<20; i++) { | ||||
if (p >= (int *)&cbqtrace_buffer[NCBQTRACE]) | if (p >= (int *)&cbqtrace_buffer[NCBQTRACE]) | ||||
p = (int *)cbqtrace_buffer; | p = (int *)cbqtrace_buffer; | ||||
} | } | ||||
} | } | ||||
#endif /* CBQ_TRACE */ | #endif /* CBQ_TRACE */ | ||||
#endif /* ALTQ_CBQ */ | #endif /* ALTQ_CBQ */ | ||||
#if defined(ALTQ_CBQ) || defined(ALTQ_RED) || defined(ALTQ_RIO) || defined(ALTQ_HFSC) || defined(ALTQ_PRIQ) | #if defined(ALTQ_CBQ) || defined(ALTQ_RED) || defined(ALTQ_RIO) || \ | ||||
defined(ALTQ_HFSC) || defined(ALTQ_PRIQ) || defined(ALTQ_CODEL) | |||||
#if !defined(__GNUC__) || defined(ALTQ_DEBUG) | #if !defined(__GNUC__) || defined(ALTQ_DEBUG) | ||||
void | void | ||||
_addq(class_queue_t *q, mbuf_t *m) | _addq(class_queue_t *q, mbuf_t *m) | ||||
{ | { | ||||
mbuf_t *m0; | mbuf_t *m0; | ||||
if ((m0 = qtail(q)) != NULL) | if ((m0 = qtail(q)) != NULL) | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |