Go to the documentation of this file.
54 #define MAX_PENDING_RETURN_PACKETS 32
59 static inline PktPool *GetThreadPacketPool(
void)
75 static int PacketPoolIsEmpty(
PktPool *pool)
86 PktPool *my_pool = GetThreadPacketPool();
88 if (PacketPoolIsEmpty(my_pool)) {
95 while(PacketPoolIsEmpty(my_pool))
115 PktPool *my_pool = GetThreadPacketPool();
123 pp = p = my_pool->
head;
159 static void PacketPoolStorePacket(
Packet *p)
164 p->
pool = GetThreadPacketPool();
169 static void PacketPoolGetReturnedPackets(
PktPool *pool)
187 PktPool *pool = GetThreadPacketPool();
188 #ifdef DEBUG_VALIDATION
189 BUG_ON(pool->initialized == 0);
190 BUG_ON(pool->destroyed == 1);
203 PacketPoolGetReturnedPackets(pool);
227 PktPool *my_pool = GetThreadPacketPool();
236 #ifdef DEBUG_VALIDATION
237 BUG_ON(pool->initialized == 0);
238 BUG_ON(pool->destroyed == 1);
239 BUG_ON(my_pool->initialized == 0);
240 BUG_ON(my_pool->destroyed == 1);
243 if (pool == my_pool) {
249 if (pending_pool == NULL) {
256 }
else if (pending_pool == pool) {
289 PktPool *my_pool = GetThreadPacketPool();
291 #ifdef DEBUG_VALIDATION
292 BUG_ON(my_pool->initialized);
293 my_pool->initialized = 1;
294 my_pool->destroyed = 0;
306 PktPool *my_pool = GetThreadPacketPool();
308 #ifdef DEBUG_VALIDATION
309 BUG_ON(my_pool->initialized);
310 my_pool->initialized = 1;
311 my_pool->destroyed = 0;
319 SCLogDebug(
"preallocating packets... packet size %" PRIuMAX
"",
326 "Fatal error encountered while allocating a packet. Exiting...");
328 PacketPoolStorePacket(p);
338 PktPool *my_pool = GetThreadPacketPool();
340 #ifdef DEBUG_VALIDATION
341 BUG_ON(my_pool && my_pool->destroyed);
352 #ifdef DEBUG_VALIDATION
364 #ifdef DEBUG_VALIDATION
365 my_pool->initialized = 0;
366 my_pool->destroyed = 1;
383 SCLogDebug(
"Packet %p is a tunnel packet: %s",
384 p,p->
root ?
"upper layer" :
"tunnel root");
393 SCLogDebug(
"root pkt: outstanding %u", outstanding);
394 if (outstanding == 0) {
395 SCLogDebug(
"no tunnel packets outstanding, no more tunnel "
396 "packet(s) depending on this root");
402 SCLogDebug(
"tunnel root Packet %p: outstanding > 0, so "
403 "packets are still depending on this root, setting "
404 "SET_TUNNEL_PKT_VERDICTED", p);
416 SCLogDebug(
"NOT IS_TUNNEL_ROOT_PKT, so tunnel pkt");
420 SCLogDebug(
"tunnel pkt: outstanding %u", outstanding);
424 if (outstanding == 0 &&
427 SCLogDebug(
"root verdicted == true && no outstanding");
430 SCLogDebug(
"setting proot = 1 for root pkt, p->root %p "
431 "(tunnel packet %p)", p->
root, p);
440 SCLogDebug(
"NOT IS_TUNNEL_PKT_VERDICTED (%s) || "
441 "outstanding > 0 (%u)",
450 SCLogDebug(
"tunnel stuff done, move on (proot %d)", proot);
497 #define RESERVED_PACKETS 10
524 uint32_t packets = (pending_packets / threads) - 1;
525 if (packets < max_pending_return_packets)
526 max_pending_return_packets = packets;
532 SCLogDebug(
"detect threads %u, max packets %u, max_pending_return_packets %u",
533 threads, packets, max_pending_return_packets);
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.
#define PACKET_REINIT(p)
Recycle a packet structure for reuse.
#define TM_FLAG_DETECT_TM
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
#define SC_ATOMIC_ADD(name, val)
add a value to our atomic variable
void(* OutHandler)(ThreadVars *, Packet *)
#define IS_TUNNEL_ROOT_PKT(p)
uint32_t TmThreadCountThreadsByTmmFlags(uint8_t flags)
returns a count of all the threads that match the flag
void PacketPoolPostRunmodes(void)
Set the max_pending_return_packets value.
#define MAX_PENDING_RETURN_PACKETS
void TmqhOutputPacketpool(ThreadVars *t, Packet *p)
thread_local PktPool thread_pkt_pool
void TmqhReleasePacketsToPacketPool(PacketQueue *pq)
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed,...
void PacketPoolInit(void)
Packet *(* InHandler)(ThreadVars *)
#define TUNNEL_PKT_TPR(p)
#define SCMutexUnlock(mut)
#define IS_TUNNEL_PKT_VERDICTED(p)
void PacketPoolWaitForN(int n)
Wait until we have the requested amount of packets in the pool.
Per thread variable structure.
void PacketFree(Packet *p)
Return a malloced packet.
Packet * TmqhInputPacketpool(ThreadVars *tv)
@ SC_ERR_INVALID_ARGUMENT
void PacketPoolWait(void)
#define SET_TUNNEL_PKT_VERDICTED(p)
#define SCMutexInit(mut, mutattrs)
PktPoolLockedStack return_stack
void TmqhPacketpoolRegister(void)
TmqhPacketpoolRegister \initonly.
void(* ReleasePacket)(struct Packet_ *)
#define FatalError(x,...)
Tmqh tmqh_table[TMQH_SIZE]
#define SC_ATOMIC_RESET(name)
wrapper for reinitializing an atomic variable.
Packet * PacketDequeue(PacketQueue *q)
Packet * PacketGetFromAlloc(void)
Get a malloced packet.
#define TUNNEL_PKT_RTV(p)
#define PACKET_RELEASE_REFS(p)
#define TUNNEL_INCR_PKT_RTV_NOLOCK(p)
#define PACKET_PROFILING_END(p)
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
void PacketPoolInitEmpty(void)
struct PktPool_ * pending_pool
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
void PacketPoolDestroy(void)