suricata
tmqh-packetpool.h
Go to the documentation of this file.
1/* Copyright (C) 2007-2014 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 */
23
24#ifndef SURICATA_TMQH_PACKETPOOL_H
25#define SURICATA_TMQH_PACKETPOOL_H
26
27#include "decode.h"
28#include "threads.h"
29
30 /* Return stack, onto which other threads free packets. */
31typedef struct PktPoolLockedStack_{
32 /* linked list of free packets. */
35 /** number of packets in needed to trigger a sync during
36 * the return to pool logic. Updated by pool owner based
37 * on how full the pool is. */
38 SC_ATOMIC_DECLARE(uint32_t, return_threshold);
39 uint32_t cnt;
41} __attribute__((aligned(CLS))) PktPoolLockedStack;
42
43typedef struct PktPool_ {
44 /* link listed of free packets local to this thread.
45 * No mutex is needed.
46 */
48 uint32_t cnt;
49
50 /* Packets waiting (pending) to be returned to the given Packet
51 * Pool. Accumulate packets for the same pool until a threshold is
52 * reached, then return them all at once. Keep the head and tail
53 * to fast insertion of the entire list onto a return stack.
54 */
58 uint32_t pending_count;
59
60#ifdef DEBUG_VALIDATION
61 int initialized;
62 int destroyed;
63#endif /* DEBUG_VALIDATION */
64
65 /* All members above this point are accessed locally by only one thread, so
66 * these should live on their own cache line.
67 */
68
69 /* Return stack, where other threads put packets that they free that belong
70 * to this thread.
71 */
72 PktPoolLockedStack return_stack;
74
78void TmqhPacketpoolRegister(void);
80void PacketPoolWait(void);
82void PacketPoolInit(void);
83void PacketPoolDestroy(void);
84void PacketPoolPostRunmodes(void);
85
86#endif /* SURICATA_TMQH_PACKETPOOL_H */
struct PrefilterEngineFlowbits __attribute__
DNP3 application header.
simple fifo queue for packets with mutex and cond Calling the mutex or triggering the cond is respons...
SC_ATOMIC_DECLARE(uint32_t, return_threshold)
PktPoolLockedStack return_stack
uint32_t cnt
Packet * pending_tail
Packet * head
Packet * pending_head
struct PktPool_ * pending_pool
uint32_t pending_count
Per thread variable structure.
Definition threadvars.h:58
#define CLS
#define SCCondT
#define SCMutex
void PacketPoolWait(void)
void PacketPoolDestroy(void)
Packet * PacketPoolGetPacket(void)
Get a new packet from the packet pool.
void PacketPoolInit(void)
void TmqhPacketpoolRegister(void)
TmqhPacketpoolRegister \initonly.
struct PktPool_ PktPool
Packet * TmqhInputPacketpool(ThreadVars *)
void TmqhReleasePacketsToPacketPool(PacketQueue *)
Release all the packets in the queue back to the packetpool. Mainly used by threads that have failed,...
void PacketPoolPostRunmodes(void)
Set the max_pending_return_packets value.
void TmqhOutputPacketpool(ThreadVars *, Packet *)
void PacketPoolReturnPacket(Packet *p)
Return packet to Packet pool.