NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
entry.h
Go to the documentation of this file.
1#ifndef NDNDPDK_HRLOG_ENTRY_H
2#define NDNDPDK_HRLOG_ENTRY_H
3
5
6#include "../core/common.h"
7#include <rte_lcore.h>
8#include <rte_ring.h>
9#include <urcu-pointer.h>
10
12typedef enum __rte_packed_begin HrlogAction {
13 HRLOG_OI = 1, // Interest TX since RX
14 HRLOG_OD = 2, // retrieved Data TX since RX
15 HRLOG_OC = 4, // cached Data TX since Interest RX
17
19typedef uint64_t HrlogEntry;
20static_assert(sizeof(HrlogEntry) == sizeof(void*), "");
21
22static inline HrlogEntry
23HrlogEntry_New(HrlogAction act, uint64_t value) {
24 uint8_t lcore = rte_lcore_id();
25 return (value << 16) | ((uint64_t)lcore << 8) | ((uint8_t)act);
26}
27
29typedef struct HrlogHeader {
30 uint32_t magic;
31 uint32_t version;
32 uint64_t tschz;
34static_assert(sizeof(HrlogHeader) == 16, "");
35
36#define HRLOG_HEADER_MAGIC 0x35f0498a
37#define HRLOG_HEADER_VERSION 2
38
40typedef struct HrlogRingRef {
41 struct rte_ring* r;
43
45
51static __rte_always_inline struct rte_ring*
52HrlogRing_Get() {
53 return rcu_dereference(theHrlogRing.r);
54}
55
57__attribute__((nonnull)) static __rte_always_inline void
58HrlogRing_Post(struct rte_ring* r, HrlogEntry* entries, uint16_t count) {
59 if (count > 0) {
60 rte_ring_enqueue_burst(r, (void**)entries, count, NULL);
61 }
62}
63
68static __rte_always_inline void
69Hrlog_Post(HrlogEntry* entries, uint16_t count) {
70 if (count == 0) {
71 return;
72 }
73
74 struct rte_ring* r = HrlogRing_Get();
75 if (r != NULL) {
76 HrlogRing_Post(r, entries, count);
77 }
78}
79
80#endif // NDNDPDK_HRLOG_ENTRY_H
struct __rte_packed_begin vlanhdr __rte_packed_end
uint64_t HrlogEntry
A high resolution log entry.
Definition entry.h:19
HRLOG_OC
Definition entry.h:15
enum __rte_packed_begin HrlogAction HrlogAction
Action identifier in high resolution log.
Definition entry.h:12
HrlogRingRef theHrlogRing
Definition writer.c:5
HRLOG_OD
Definition entry.h:14
HRLOG_OI
Definition entry.h:13
A high resolution log file header.
Definition entry.h:29
uint64_t tschz
Definition entry.h:32
uint32_t magic
Definition entry.h:30
uint32_t version
Definition entry.h:31
RCU-protected pointer to hrlog collector queue.
Definition entry.h:40
struct rte_ring * r
Definition entry.h:41