mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 05:58:57 +00:00
introduce mbq_lock() and mbq_unlock() for the mbq,
so it is easier to buil the same code on linux (this generalizes the change in svn 267142) MFC after: 3 days
This commit is contained in:
parent
a845d42777
commit
997b054cf1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=267177
@ -1050,7 +1050,7 @@ netmap_rxsync_from_host(struct netmap_adapter *na, struct thread *td, void *pwai
|
||||
(void)pwait; /* disable unused warnings */
|
||||
(void)td;
|
||||
|
||||
mtx_lock_spin(&q->lock);
|
||||
mbq_lock(q);
|
||||
|
||||
/* First part: import newly received packets */
|
||||
n = mbq_len(q);
|
||||
@ -1092,7 +1092,7 @@ netmap_rxsync_from_host(struct netmap_adapter *na, struct thread *td, void *pwai
|
||||
if (kring->rcur == kring->rtail && td) /* no bufs available */
|
||||
selrecord(td, &kring->si);
|
||||
|
||||
mtx_unlock_spin(&q->lock);
|
||||
mbq_unlock(q);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2459,7 +2459,7 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
* not possible on Linux).
|
||||
* Also avoid overflowing the queue.
|
||||
*/
|
||||
mtx_lock_spin(&q->lock);
|
||||
mbq_lock(q);
|
||||
|
||||
space = kring->nr_hwtail - kring->nr_hwcur;
|
||||
if (space < 0)
|
||||
@ -2476,7 +2476,7 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
m = NULL;
|
||||
error = 0;
|
||||
}
|
||||
mtx_unlock_spin(&q->lock);
|
||||
mbq_unlock(q);
|
||||
|
||||
done:
|
||||
if (m)
|
||||
|
@ -76,9 +76,9 @@ static inline void __mbq_enqueue(struct mbq *q, struct mbuf *m)
|
||||
|
||||
void mbq_safe_enqueue(struct mbq *q, struct mbuf *m)
|
||||
{
|
||||
mtx_lock_spin(&q->lock);
|
||||
mbq_lock(q);
|
||||
__mbq_enqueue(q, m);
|
||||
mtx_unlock_spin(&q->lock);
|
||||
mbq_unlock(q);
|
||||
}
|
||||
|
||||
|
||||
@ -110,9 +110,9 @@ struct mbuf *mbq_safe_dequeue(struct mbq *q)
|
||||
{
|
||||
struct mbuf *ret;
|
||||
|
||||
mtx_lock_spin(&q->lock);
|
||||
mbq_lock(q);
|
||||
ret = __mbq_dequeue(q);
|
||||
mtx_unlock_spin(&q->lock);
|
||||
mbq_unlock(q);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -62,7 +62,17 @@ void mbq_enqueue(struct mbq *q, struct mbuf *m);
|
||||
struct mbuf *mbq_dequeue(struct mbq *q);
|
||||
void mbq_purge(struct mbq *q);
|
||||
|
||||
/* XXX missing mbq_lock() and mbq_unlock */
|
||||
static inline void
|
||||
mbq_lock(struct mbq *q)
|
||||
{
|
||||
mtx_lock_spin(&q->lock);
|
||||
}
|
||||
|
||||
static inline void
|
||||
mbq_unlock(struct mbq *q)
|
||||
{
|
||||
mtx_unlock_spin(&q->lock);
|
||||
}
|
||||
|
||||
void mbq_safe_init(struct mbq *q);
|
||||
void mbq_safe_destroy(struct mbq *q);
|
||||
|
Loading…
Reference in New Issue
Block a user