add a counter on the struct mq (a queue of mbufs),

and add a block for userspace compiling.
This commit is contained in:
Luigi Rizzo 2013-11-22 05:02:37 +00:00
parent f783a35ced
commit 41d10f903d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=258467
3 changed files with 32 additions and 0 deletions

View file

@ -166,6 +166,7 @@ dn_dequeue(struct dn_queue *q)
if (m == NULL)
return NULL;
q->mq.head = m->m_nextpkt;
q->mq.count--;
/* Update stats for the queue */
q->ni.length--;

View file

@ -260,10 +260,39 @@ dn_tag_get(struct mbuf *m)
static inline void
mq_append(struct mq *q, struct mbuf *m)
{
#ifdef USERSPACE
// buffers from netmap need to be copied
// XXX note that the routine is not expected to fail
ND("append %p to %p", m, q);
if (m->m_flags & M_STACK) {
struct mbuf *m_new;
void *p;
int l, ofs;
ofs = m->m_data - m->__m_extbuf;
// XXX allocate
MGETHDR(m_new, M_NOWAIT, MT_DATA);
ND("*** WARNING, volatile buf %p ext %p %d dofs %d m_new %p",
m, m->__m_extbuf, m->__m_extlen, ofs, m_new);
p = m_new->__m_extbuf; /* new pointer */
l = m_new->__m_extlen; /* new len */
if (l <= m->__m_extlen) {
panic("extlen too large");
}
*m_new = *m; // copy
m_new->m_flags &= ~M_STACK;
m_new->__m_extbuf = p; // point to new buffer
pkt_copy(m->__m_extbuf, p, m->__m_extlen);
m_new->m_data = p + ofs;
m = m_new;
}
#endif /* USERSPACE */
if (q->head == NULL)
q->head = m;
else
q->tail->m_nextpkt = m;
q->count++;
q->tail = m;
m->m_nextpkt = NULL;
}
@ -455,6 +484,7 @@ transmit_event(struct mq *q, struct delay_line *dline, uint64_t now)
if (!DN_KEY_LEQ(pkt->output_time, now))
break;
dline->mq.head = m->m_nextpkt;
dline->mq.count--;
mq_append(q, m);
}
if (m != NULL) {

View file

@ -83,6 +83,7 @@ SLIST_HEAD(dn_alg_head, dn_alg);
struct mq { /* a basic queue of packets*/
struct mbuf *head, *tail;
int count;
};
static inline void