NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
source.h
Go to the documentation of this file.
1#ifndef NDNDPDK_PDUMP_SOURCE_H
2#define NDNDPDK_PDUMP_SOURCE_H
3
5
6#include "../core/urcu.h"
7#include "../iface/faceid.h"
8#include "../vendor/pcg_basic.h"
9#include "enum.h"
10#include <urcu-pointer.h>
11
12typedef struct PdumpSource PdumpSource;
13
14typedef bool (*PdumpSource_Filter)(PdumpSource* s, struct rte_mbuf* pkt);
15
18 struct rte_mempool* directMp;
19 struct rte_ring* queue;
21 uint32_t mbufType;
22 uint16_t mbufPort;
24};
25
27__attribute__((nonnull)) void
28PdumpSource_Process(PdumpSource* s, struct rte_mbuf** pkts, uint16_t count);
29
34
39__attribute__((nonnull(1))) PdumpSource*
41
47__attribute__((nonnull)) static __rte_always_inline PdumpSource*
48PdumpSourceRef_Get(PdumpSourceRef* ref) {
49 return rcu_dereference(ref->s);
50}
51
56__attribute__((nonnull)) static __rte_always_inline bool
57PdumpSourceRef_Process(PdumpSourceRef* ref, struct rte_mbuf** pkts, uint16_t count) {
58 PdumpSource* s = PdumpSourceRef_Get(ref);
59 if (s == NULL) {
60 return false;
61 }
62 PdumpSource_Process(s, pkts, count);
63 return true;
64}
65
74
80__attribute__((nonnull)) bool
81PdumpFaceSource_Filter(PdumpSource* s, struct rte_mbuf* pkt);
82
83extern PdumpSourceRef gPdumpEthPortSources[RTE_MAX_ETHPORTS];
84
91
96static __rte_always_inline void
97PdumpEthPortUnmatchedCtx_Init(PdumpEthPortUnmatchedCtx* ctx, uint16_t port) {
99 ctx->source = PdumpSourceRef_Get(ref);
100 ctx->count = 0;
101 POISON(ctx->pkts);
102}
103
110static __rte_always_inline bool
111PdumpEthPortUnmatchedCtx_Append(PdumpEthPortUnmatchedCtx* ctx, struct rte_mbuf* pkt) {
112 if (ctx->source == NULL) {
113 return false;
114 }
115 ctx->pkts[ctx->count++] = pkt;
116 return true;
117}
118
120static __rte_always_inline void
121PdumpEthPortUnmatchedCtx_Process(PdumpEthPortUnmatchedCtx* ctx) {
122 if (ctx->source == NULL || ctx->count == 0) {
123 return;
124 }
125 PdumpSource_Process(ctx->source, ctx->pkts, ctx->count);
126 NULLize(ctx->source);
127 POISON(ctx->pkts);
128}
129
130#endif // NDNDPDK_PDUMP_SOURCE_H
#define POISON(...)
Write junk to memory region to expose memory access bugs.
Definition common.h:104
#define NULLize(x)
Set x to NULL to expose memory access bugs.
Definition common.h:79
@ MaxBurstSize
Definition enum.h:7
@ NameMaxLength
Definition enum.h:10
@ PdumpMaxNames
Definition enum.h:7
PdumpSourceRef gPdumpEthPortSources[RTE_MAX_ETHPORTS]
Definition source.c:58
PdumpSource * PdumpSourceRef_Set(PdumpSourceRef *ref, PdumpSource *s)
Assign or clear PdumpSource in PdumpSourceRef.
Definition source.c:31
void PdumpSource_Process(PdumpSource *s, struct rte_mbuf **pkts, uint16_t count)
Submit packets for potential dumping.
Definition source.c:5
bool PdumpFaceSource_Filter(PdumpSource *s, struct rte_mbuf *pkt)
Perform name filtering to determine whether to capture a packet.
Definition source.c:51
bool(* PdumpSource_Filter)(PdumpSource *s, struct rte_mbuf *pkt)
Definition source.h:14
Packet dump for unmatched frames on an Ethernet port, contextual information.
Definition source.h:86
uint16_t count
Definition source.h:88
PdumpSource * source
Definition source.h:87
struct rte_mbuf * pkts[MaxBurstSize]
Definition source.h:89
Packet dump from a face on RX or TX direction.
Definition source.h:67
pcg32_random_t rng
Definition source.h:69
uint16_t nameL[PdumpMaxNames]
Definition source.h:71
uint32_t sample[PdumpMaxNames]
Definition source.h:70
uint8_t nameV[PdumpMaxNames *NameMaxLength]
Definition source.h:72
PdumpSource base
Definition source.h:68
RCU-protected pointer to PdumpSource.
Definition source.h:31
PdumpSource * s
Definition source.h:32
Packet dump source.
Definition source.h:17
PdumpSource_Filter filter
Definition source.h:20
uint32_t mbufType
Definition source.h:21
uint16_t mbufPort
Definition source.h:22
struct rte_mempool * directMp
Definition source.h:18
struct rte_ring * queue
Definition source.h:19
bool mbufCopy
Definition source.h:23