Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/altq/altq_hfsc.c
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | hfsc_pfattach(struct pf_altq *a) | ||||
s = splnet(); | s = splnet(); | ||||
error = altq_attach(&ifp->if_snd, ALTQT_HFSC, a->altq_disc, | error = altq_attach(&ifp->if_snd, ALTQT_HFSC, a->altq_disc, | ||||
hfsc_enqueue, hfsc_dequeue, hfsc_request, NULL, NULL); | hfsc_enqueue, hfsc_dequeue, hfsc_request, NULL, NULL); | ||||
splx(s); | splx(s); | ||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
hfsc_add_altq(struct pf_altq *a) | hfsc_add_altq(struct ifnet *ifp, struct pf_altq *a) | ||||
{ | { | ||||
struct hfsc_if *hif; | struct hfsc_if *hif; | ||||
struct ifnet *ifp; | |||||
if ((ifp = ifunit(a->ifname)) == NULL) | if (ifp == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
if (!ALTQ_IS_READY(&ifp->if_snd)) | if (!ALTQ_IS_READY(&ifp->if_snd)) | ||||
return (ENODEV); | return (ENODEV); | ||||
hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_NOWAIT | M_ZERO); | hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_NOWAIT | M_ZERO); | ||||
if (hif == NULL) | if (hif == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | for (i = 0; i < HFSC_MAX_CLASSES; i++) | ||||
break; | break; | ||||
} | } | ||||
if (i == HFSC_MAX_CLASSES) { | if (i == HFSC_MAX_CLASSES) { | ||||
IFQ_UNLOCK(hif->hif_ifq); | IFQ_UNLOCK(hif->hif_ifq); | ||||
splx(s); | splx(s); | ||||
goto err_ret; | goto err_ret; | ||||
} | } | ||||
} | } | ||||
cl->cl_slot = i; | |||||
if (flags & HFCF_DEFAULTCLASS) | if (flags & HFCF_DEFAULTCLASS) | ||||
hif->hif_defaultclass = cl; | hif->hif_defaultclass = cl; | ||||
if (parent == NULL) { | if (parent == NULL) { | ||||
/* this is root class */ | /* this is root class */ | ||||
hif->hif_rootclass = cl; | hif->hif_rootclass = cl; | ||||
} else { | } else { | ||||
Show All 36 Lines | if (cl->cl_q != NULL) | ||||
free(cl->cl_q, M_DEVBUF); | free(cl->cl_q, M_DEVBUF); | ||||
free(cl, M_DEVBUF); | free(cl, M_DEVBUF); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static int | static int | ||||
hfsc_class_destroy(struct hfsc_class *cl) | hfsc_class_destroy(struct hfsc_class *cl) | ||||
{ | { | ||||
int i, s; | int s; | ||||
if (cl == NULL) | if (cl == NULL) | ||||
return (0); | return (0); | ||||
if (is_a_parent_class(cl)) | if (is_a_parent_class(cl)) | ||||
return (EBUSY); | return (EBUSY); | ||||
s = splnet(); | s = splnet(); | ||||
Show All 14 Lines | else do { | ||||
if (p->cl_siblings == cl) { | if (p->cl_siblings == cl) { | ||||
p->cl_siblings = cl->cl_siblings; | p->cl_siblings = cl->cl_siblings; | ||||
break; | break; | ||||
} | } | ||||
} while ((p = p->cl_siblings) != NULL); | } while ((p = p->cl_siblings) != NULL); | ||||
ASSERT(p != NULL); | ASSERT(p != NULL); | ||||
} | } | ||||
for (i = 0; i < HFSC_MAX_CLASSES; i++) | cl->cl_hif->hif_class_tbl[cl->cl_slot] = NULL; | ||||
if (cl->cl_hif->hif_class_tbl[i] == cl) { | |||||
cl->cl_hif->hif_class_tbl[i] = NULL; | |||||
break; | |||||
} | |||||
cl->cl_hif->hif_classes--; | cl->cl_hif->hif_classes--; | ||||
IFQ_UNLOCK(cl->cl_hif->hif_ifq); | IFQ_UNLOCK(cl->cl_hif->hif_ifq); | ||||
splx(s); | splx(s); | ||||
if (cl->cl_red != NULL) { | if (cl->cl_red != NULL) { | ||||
#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); | ||||
▲ Show 20 Lines • Show All 1,146 Lines • Show Last 20 Lines |