Changeset View
Changeset View
Standalone View
Standalone View
sys/net/altq/altq_hfsc.c
Show First 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | |||||
#ifndef ALTQ_RED | #ifndef ALTQ_RED | ||||
if (flags & HFCF_RED) { | if (flags & HFCF_RED) { | ||||
#ifdef ALTQ_DEBUG | #ifdef ALTQ_DEBUG | ||||
printf("hfsc_class_create: RED not configured for HFSC!\n"); | printf("hfsc_class_create: RED not configured for HFSC!\n"); | ||||
#endif | #endif | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
#endif | #endif | ||||
#ifndef ALTQ_CODEL | |||||
if (flags & HFCF_CODEL) { | |||||
#ifdef ALTQ_DEBUG | |||||
printf("hfsc_class_create: CODEL not configured for HFSC!\n"); | |||||
#endif | |||||
return (NULL); | |||||
} | |||||
#endif | |||||
cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_NOWAIT | M_ZERO); | cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (cl == NULL) | if (cl == NULL) | ||||
return (NULL); | return (NULL); | ||||
cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO); | cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (cl->cl_q == NULL) | if (cl->cl_q == NULL) | ||||
goto err_ret; | goto err_ret; | ||||
TAILQ_INIT(&cl->cl_actc); | TAILQ_INIT(&cl->cl_actc); | ||||
if (qlimit == 0) | if (qlimit == 0) | ||||
qlimit = 50; /* use default */ | qlimit = 50; /* use default */ | ||||
qlimit(cl->cl_q) = qlimit; | qlimit(cl->cl_q) = qlimit; | ||||
qtype(cl->cl_q) = Q_DROPTAIL; | qtype(cl->cl_q) = Q_DROPTAIL; | ||||
qlen(cl->cl_q) = 0; | qlen(cl->cl_q) = 0; | ||||
qsize(cl->cl_q) = 0; | |||||
cl->cl_flags = flags; | cl->cl_flags = flags; | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (flags & (HFCF_RED|HFCF_RIO)) { | if (flags & (HFCF_RED|HFCF_RIO)) { | ||||
int red_flags, red_pkttime; | int red_flags, red_pkttime; | ||||
u_int m2; | u_int m2; | ||||
m2 = 0; | m2 = 0; | ||||
if (rsc != NULL && rsc->m2 > m2) | if (rsc != NULL && rsc->m2 > m2) | ||||
Show All 28 Lines | else { | ||||
cl->cl_red = (red_t *)rio_alloc(0, NULL, | cl->cl_red = (red_t *)rio_alloc(0, NULL, | ||||
red_flags, red_pkttime); | red_flags, red_pkttime); | ||||
if (cl->cl_red != NULL) | if (cl->cl_red != NULL) | ||||
qtype(cl->cl_q) = Q_RIO; | qtype(cl->cl_q) = Q_RIO; | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
#endif /* ALTQ_RED */ | #endif /* ALTQ_RED */ | ||||
#ifdef ALTQ_CODEL | |||||
if (flags & HFCF_CODEL) { | |||||
cl->cl_codel = codel_alloc(5, 100, 0); | |||||
if (cl->cl_codel != NULL) | |||||
qtype(cl->cl_q) = Q_CODEL; | |||||
} | |||||
#endif | |||||
if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) { | if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) { | ||||
cl->cl_rsc = malloc(sizeof(struct internal_sc), | cl->cl_rsc = malloc(sizeof(struct internal_sc), | ||||
M_DEVBUF, M_NOWAIT); | M_DEVBUF, M_NOWAIT); | ||||
if (cl->cl_rsc == NULL) | if (cl->cl_rsc == NULL) | ||||
goto err_ret; | goto err_ret; | ||||
sc2isc(rsc, cl->cl_rsc); | sc2isc(rsc, cl->cl_rsc); | ||||
rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0); | rtsc_init(&cl->cl_deadline, cl->cl_rsc, 0, 0); | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->cl_q)) | if (q_is_rio(cl->cl_q)) | ||||
rio_destroy((rio_t *)cl->cl_red); | rio_destroy((rio_t *)cl->cl_red); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->cl_q)) | if (q_is_red(cl->cl_q)) | ||||
red_destroy(cl->cl_red); | red_destroy(cl->cl_red); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->cl_q)) | |||||
codel_destroy(cl->cl_codel); | |||||
#endif | |||||
} | } | ||||
if (cl->cl_fsc != NULL) | if (cl->cl_fsc != NULL) | ||||
free(cl->cl_fsc, M_DEVBUF); | free(cl->cl_fsc, M_DEVBUF); | ||||
if (cl->cl_rsc != NULL) | if (cl->cl_rsc != NULL) | ||||
free(cl->cl_rsc, M_DEVBUF); | free(cl->cl_rsc, M_DEVBUF); | ||||
if (cl->cl_usc != NULL) | if (cl->cl_usc != NULL) | ||||
free(cl->cl_usc, M_DEVBUF); | free(cl->cl_usc, M_DEVBUF); | ||||
if (cl->cl_q != NULL) | if (cl->cl_q != NULL) | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->cl_q)) | if (q_is_rio(cl->cl_q)) | ||||
rio_destroy((rio_t *)cl->cl_red); | rio_destroy((rio_t *)cl->cl_red); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->cl_q)) | if (q_is_red(cl->cl_q)) | ||||
red_destroy(cl->cl_red); | red_destroy(cl->cl_red); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->cl_q)) | |||||
codel_destroy(cl->cl_codel); | |||||
#endif | |||||
} | } | ||||
IFQ_LOCK(cl->cl_hif->hif_ifq); | IFQ_LOCK(cl->cl_hif->hif_ifq); | ||||
if (cl == cl->cl_hif->hif_rootclass) | if (cl == cl->cl_hif->hif_rootclass) | ||||
cl->cl_hif->hif_rootclass = NULL; | cl->cl_hif->hif_rootclass = NULL; | ||||
if (cl == cl->cl_hif->hif_defaultclass) | if (cl == cl->cl_hif->hif_defaultclass) | ||||
cl->cl_hif->hif_defaultclass = NULL; | cl->cl_hif->hif_defaultclass = NULL; | ||||
IFQ_UNLOCK(cl->cl_hif->hif_ifq); | IFQ_UNLOCK(cl->cl_hif->hif_ifq); | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->cl_q)) | if (q_is_rio(cl->cl_q)) | ||||
return rio_addq((rio_t *)cl->cl_red, cl->cl_q, | return rio_addq((rio_t *)cl->cl_red, cl->cl_q, | ||||
m, cl->cl_pktattr); | m, cl->cl_pktattr); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->cl_q)) | if (q_is_red(cl->cl_q)) | ||||
return red_addq(cl->cl_red, cl->cl_q, m, cl->cl_pktattr); | return red_addq(cl->cl_red, cl->cl_q, m, cl->cl_pktattr); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->cl_q)) | |||||
return codel_addq(cl->cl_codel, cl->cl_q, m); | |||||
#endif | |||||
if (qlen(cl->cl_q) >= qlimit(cl->cl_q)) { | if (qlen(cl->cl_q) >= qlimit(cl->cl_q)) { | ||||
m_freem(m); | m_freem(m); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
if (cl->cl_flags & HFCF_CLEARDSCP) | if (cl->cl_flags & HFCF_CLEARDSCP) | ||||
write_dsfield(m, cl->cl_pktattr, 0); | write_dsfield(m, cl->cl_pktattr, 0); | ||||
_addq(cl->cl_q, m); | _addq(cl->cl_q, m); | ||||
return (0); | return (0); | ||||
} | } | ||||
static struct mbuf * | static struct mbuf * | ||||
hfsc_getq(struct hfsc_class *cl) | hfsc_getq(struct hfsc_class *cl) | ||||
{ | { | ||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->cl_q)) | if (q_is_rio(cl->cl_q)) | ||||
return rio_getq((rio_t *)cl->cl_red, cl->cl_q); | return rio_getq((rio_t *)cl->cl_red, cl->cl_q); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->cl_q)) | if (q_is_red(cl->cl_q)) | ||||
return red_getq(cl->cl_red, cl->cl_q); | return red_getq(cl->cl_red, cl->cl_q); | ||||
#endif | #endif | ||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->cl_q)) | |||||
return codel_getq(cl->cl_codel, cl->cl_q); | |||||
#endif | |||||
return _getq(cl->cl_q); | return _getq(cl->cl_q); | ||||
} | } | ||||
static struct mbuf * | static struct mbuf * | ||||
hfsc_pollq(struct hfsc_class *cl) | hfsc_pollq(struct hfsc_class *cl) | ||||
{ | { | ||||
return qhead(cl->cl_q); | return qhead(cl->cl_q); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 767 Lines • ▼ Show 20 Lines | get_class_stats(struct hfsc_classstats *sp, struct hfsc_class *cl) | ||||
sp->qtype = qtype(cl->cl_q); | sp->qtype = qtype(cl->cl_q); | ||||
#ifdef ALTQ_RED | #ifdef ALTQ_RED | ||||
if (q_is_red(cl->cl_q)) | if (q_is_red(cl->cl_q)) | ||||
red_getstats(cl->cl_red, &sp->red[0]); | red_getstats(cl->cl_red, &sp->red[0]); | ||||
#endif | #endif | ||||
#ifdef ALTQ_RIO | #ifdef ALTQ_RIO | ||||
if (q_is_rio(cl->cl_q)) | if (q_is_rio(cl->cl_q)) | ||||
rio_getstats((rio_t *)cl->cl_red, &sp->red[0]); | rio_getstats((rio_t *)cl->cl_red, &sp->red[0]); | ||||
#endif | |||||
#ifdef ALTQ_CODEL | |||||
if (q_is_codel(cl->cl_q)) | |||||
codel_getstats(cl->cl_codel, &sp->codel); | |||||
#endif | #endif | ||||
} | } | ||||
/* convert a class handle to the corresponding class pointer */ | /* convert a class handle to the corresponding class pointer */ | ||||
static struct hfsc_class * | static struct hfsc_class * | ||||
clh_to_clp(struct hfsc_if *hif, u_int32_t chandle) | clh_to_clp(struct hfsc_if *hif, u_int32_t chandle) | ||||
{ | { | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 557 Lines • Show Last 20 Lines |