diff options
Diffstat (limited to 'sys/dev/netmap/netmap_mbq.c')
-rw-r--r-- | sys/dev/netmap/netmap_mbq.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/dev/netmap/netmap_mbq.c b/sys/dev/netmap/netmap_mbq.c index c8e581b69fe5..2606b13d48dc 100644 --- a/sys/dev/netmap/netmap_mbq.c +++ b/sys/dev/netmap/netmap_mbq.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Vincenzo Maffione. All rights reserved. + * Copyright (C) 2013-2014 Vincenzo Maffione. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,17 +47,20 @@ static inline void __mbq_init(struct mbq *q) q->count = 0; } + void mbq_safe_init(struct mbq *q) { mtx_init(&q->lock, "mbq", NULL, MTX_SPIN); __mbq_init(q); } + void mbq_init(struct mbq *q) { __mbq_init(q); } + static inline void __mbq_enqueue(struct mbq *q, struct mbuf *m) { m->m_nextpkt = NULL; @@ -70,6 +73,7 @@ static inline void __mbq_enqueue(struct mbq *q, struct mbuf *m) q->count++; } + void mbq_safe_enqueue(struct mbq *q, struct mbuf *m) { mtx_lock(&q->lock); @@ -77,11 +81,13 @@ void mbq_safe_enqueue(struct mbq *q, struct mbuf *m) mtx_unlock(&q->lock); } + void mbq_enqueue(struct mbq *q, struct mbuf *m) { __mbq_enqueue(q, m); } + static inline struct mbuf *__mbq_dequeue(struct mbq *q) { struct mbuf *ret = NULL; @@ -99,6 +105,7 @@ static inline struct mbuf *__mbq_dequeue(struct mbq *q) return ret; } + struct mbuf *mbq_safe_dequeue(struct mbq *q) { struct mbuf *ret; @@ -110,11 +117,13 @@ struct mbuf *mbq_safe_dequeue(struct mbq *q) return ret; } + struct mbuf *mbq_dequeue(struct mbq *q) { return __mbq_dequeue(q); } + /* XXX seems pointless to have a generic purge */ static void __mbq_purge(struct mbq *q, int safe) { @@ -130,16 +139,19 @@ static void __mbq_purge(struct mbq *q, int safe) } } + void mbq_purge(struct mbq *q) { __mbq_purge(q, 0); } + void mbq_safe_purge(struct mbq *q) { __mbq_purge(q, 1); } + void mbq_safe_destroy(struct mbq *q) { mtx_destroy(&q->lock); @@ -149,4 +161,3 @@ void mbq_safe_destroy(struct mbq *q) void mbq_destroy(struct mbq *q) { } - |