mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
merge in 2 buf_ring helper routines for enqueueing and freeing buf_rings
This commit is contained in:
parent
096f3ce0c9
commit
1635d9171c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186207
@ -77,6 +77,7 @@ struct ifvlantrunk;
|
||||
#ifdef _KERNEL
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/buf_ring.h>
|
||||
#endif /* _KERNEL */
|
||||
#include <sys/lock.h> /* XXX */
|
||||
#include <sys/mutex.h> /* XXX */
|
||||
@ -548,6 +549,32 @@ do { \
|
||||
IFQ_PURGE(ifq); \
|
||||
} while (0)
|
||||
|
||||
#ifdef _KERNEL
|
||||
static __inline int
|
||||
drbr_enqueue(struct buf_ring *br, struct mbuf *m)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) {
|
||||
br->br_drops++;
|
||||
m_freem(m);
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
drbr_free(struct buf_ring *br, struct malloc_type *type)
|
||||
{
|
||||
struct mbuf *m;
|
||||
|
||||
while ((m = buf_ring_dequeue_sc(br)) != NULL)
|
||||
m_freem(m);
|
||||
|
||||
buf_ring_free(br, type);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 72 was chosen below because it is the size of a TCP/IP
|
||||
* header (40) + the minimum mss (32).
|
||||
|
@ -48,10 +48,11 @@ struct buf_ring {
|
||||
volatile uint32_t br_prod_tail;
|
||||
int br_prod_size;
|
||||
int br_prod_mask;
|
||||
uint64_t br_drops;
|
||||
/*
|
||||
* Pad out to next L2 cache line
|
||||
*/
|
||||
uint64_t _pad0[14];
|
||||
uint64_t _pad0[13];
|
||||
|
||||
volatile uint32_t br_cons_head;
|
||||
volatile uint32_t br_cons_tail;
|
||||
|
Loading…
Reference in New Issue
Block a user