On Wed, Mar 01, 2017 at 09:43:16PM +0100, Mike Belopuhov wrote: > This convers hand rolled lists into exactly the same mbuf_lists. > I need this because of the next diff that uses the ml_len packet > counter that mbuf_lists have. Otherwise there's no functional > change.
> void * > priq_alloc(unsigned int idx, void *null) > { > - return (malloc(sizeof(struct priq), M_DEVBUF, M_WAITOK | M_ZERO)); > + struct priq *pq; > + int i; > + > + pq = malloc(sizeof(struct priq), M_DEVBUF, M_WAITOK | M_ZERO); You don't need M_ZERO as you call ml_init() afterwards. > + for (i = 0; i < IFQ_NQUEUES; i++) > + ml_init(&pq->pq_lists[i]); > + return (pq); > } > void > priq_purge(struct ifqueue *ifq, struct mbuf_list *ml) > { > struct priq *pq = ifq->ifq_q; > - struct priq_list *pl; > + struct mbuf_list *pl; > unsigned int prio = nitems(pq->pq_lists); > - struct mbuf *m, *n; > + struct mbuf *m; > > do { > pl = &pq->pq_lists[--prio]; > > - for (m = pl->head; m != NULL; m = n) { > - n = m->m_nextpkt; > + while ((m = ml_dequeue(pl)) != NULL) > ml_enqueue(ml, m); This is equivalent to ml_enlist(ml, pl) which avoids the loop. > - } > - > - pl->head = pl->tail = NULL; > } while (prio > 0); > } with that OK bluhm@