diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-11-21 01:08:51 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-11-21 01:08:51 +0000 |
commit | 396dabeb7ce241df4031167a9c5863c4b5e49bc3 (patch) | |
tree | 9dfc3f9a658addc3216663e58047c4873d4331c7 /sys/net | |
parent | eed854e3a932557f06299da03922a2d53b346e5f (diff) |
simplify ifq_deq_rollback by only having it unlock.
hfsc needed a rollback ifqop to requeue the mbuf because it used
ml_dequeue in the begin op. now it uses MBUF_LIST_FIRST to get a
ref to the first mbuf in deq_begin.
now the disciplines dont need a rollback op, so ifq_deq_rollback
can be simplified to just releasing the mutex.
based on a discussion with kenjiro cho
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/hfsc.c | 21 | ||||
-rw-r--r-- | sys/net/if.c | 18 | ||||
-rw-r--r-- | sys/net/if_var.h | 4 |
3 files changed, 10 insertions, 33 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c index 05cd4f9e978..969138b33b5 100644 --- a/sys/net/hfsc.c +++ b/sys/net/hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hfsc.c,v 1.31 2015/11/20 03:35:23 dlg Exp $ */ +/* $OpenBSD: hfsc.c,v 1.32 2015/11/21 01:08:49 dlg Exp $ */ /* * Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org> @@ -264,7 +264,6 @@ void hfsc_free(void *); int hfsc_enq(struct ifqueue *, struct mbuf *); struct mbuf *hfsc_deq_begin(struct ifqueue *, void **); void hfsc_deq_commit(struct ifqueue *, struct mbuf *, void *); -void hfsc_deq_rollback(struct ifqueue *, struct mbuf *, void *); void hfsc_purge(struct ifqueue *, struct mbuf_list *); const struct ifq_ops hfsc_ops = { @@ -273,7 +272,6 @@ const struct ifq_ops hfsc_ops = { hfsc_enq, hfsc_deq_begin, hfsc_deq_commit, - hfsc_deq_rollback, hfsc_purge, }; @@ -711,7 +709,7 @@ hfsc_deq_begin(struct ifqueue *ifq, void **cookiep) return (NULL); } - m = ml_dequeue(&cl->cl_q.q); + m = MBUF_LIST_FIRST(&cl->cl_q.q); KASSERT(m != NULL); hif->hif_microtime = cur_time; @@ -724,6 +722,7 @@ hfsc_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie) { struct hfsc_if *hif = ifq->ifq_q; struct hfsc_class *cl = cookie; + struct mbuf *m0; int next_len, realtime = 0; u_int64_t cur_time = hif->hif_microtime; @@ -731,6 +730,9 @@ hfsc_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie) if (cl->cl_rsc != NULL) realtime = (cl->cl_e <= cur_time); + m0 = ml_dequeue(&cl->cl_q.q); + KASSERT(m == m0); + PKTCNTR_INC(&cl->cl_stats.xmit_cnt, m->m_pkthdr.len); hfsc_update_vf(cl, m->m_pkthdr.len, cur_time); @@ -740,7 +742,8 @@ hfsc_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie) if (ml_len(&cl->cl_q.q) > 0) { if (cl->cl_rsc != NULL) { /* update ed */ - next_len = cl->cl_q.q.ml_head->m_pkthdr.len; + m0 = MBUF_LIST_FIRST(&cl->cl_q.q); + next_len = m0->m_pkthdr.len; if (realtime) hfsc_update_ed(hif, cl, next_len); @@ -754,14 +757,6 @@ hfsc_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie) } void -hfsc_deq_rollback(struct ifqueue *ifq, struct mbuf *m, void *cookie) -{ - struct hfsc_class *cl = cookie; - - ml_requeue(&cl->cl_q.q, m); -} - -void hfsc_deferred(void *arg) { struct ifnet *ifp = arg; diff --git a/sys/net/if.c b/sys/net/if.c index 47532fbbf15..e54741aaa43 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.411 2015/11/20 12:27:42 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.412 2015/11/21 01:08:49 dlg Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2734,7 +2734,6 @@ void priq_free(void *); int priq_enq(struct ifqueue *, struct mbuf *); struct mbuf *priq_deq_begin(struct ifqueue *, void **); void priq_deq_commit(struct ifqueue *, struct mbuf *, void *); -void priq_deq_rollback(struct ifqueue *, struct mbuf *, void *); void priq_purge(struct ifqueue *, struct mbuf_list *); const struct ifq_ops priq_ops = { @@ -2743,7 +2742,6 @@ const struct ifq_ops priq_ops = { priq_enq, priq_deq_begin, priq_deq_commit, - priq_deq_rollback, priq_purge, }; @@ -2828,16 +2826,6 @@ priq_deq_commit(struct ifqueue *ifq, struct mbuf *m, void *cookie) } void -priq_deq_rollback(struct ifqueue *ifq, struct mbuf *m, void *cookie) -{ -#ifdef DIAGNOSTIC - struct priq_list *pl = cookie; - - KASSERT(pl->head == m); -#endif -} - -void priq_purge(struct ifqueue *ifq, struct mbuf_list *ml) { struct priq *pq = ifq->ifq_q; @@ -2919,12 +2907,8 @@ ifq_deq_commit(struct ifqueue *ifq, struct mbuf *m) void ifq_deq_rollback(struct ifqueue *ifq, struct mbuf *m) { - void *cookie; - KASSERT(m != NULL); - cookie = m->m_pkthdr.ph_cookie; - ifq->ifq_ops->ifqop_deq_rollback(ifq, m, cookie); mtx_leave(&ifq->ifq_mtx); } diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 2739ac8a9a5..4c17520ae41 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.55 2015/11/20 11:15:07 dlg Exp $ */ +/* $OpenBSD: if_var.h,v 1.56 2015/11/21 01:08:50 dlg Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -110,8 +110,6 @@ struct ifq_ops { struct mbuf *(*ifqop_deq_begin)(struct ifqueue *, void **); void (*ifqop_deq_commit)(struct ifqueue *, struct mbuf *, void *); - void (*ifqop_deq_rollback)(struct ifqueue *, - struct mbuf *, void *); void (*ifqop_purge)(struct ifqueue *, struct mbuf_list *); }; |