NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
entry.h
Go to the documentation of this file.
1 #ifndef NDNDPDK_HRLOG_ENTRY_H
2 #define NDNDPDK_HRLOG_ENTRY_H
3 
6 #include "../core/common.h"
7 #include <rte_lcore.h>
8 #include <rte_ring.h>
9 #include <urcu-pointer.h>
10 
12 typedef enum 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 
19 typedef uint64_t HrlogEntry;
20 static_assert(sizeof(HrlogEntry) == sizeof(void*), "");
21 
22 static inline HrlogEntry
23 HrlogEntry_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 
29 typedef struct HrlogHeader {
30  uint32_t magic;
31  uint32_t version;
32  uint64_t tschz;
34 static_assert(sizeof(HrlogHeader) == 16, "");
35 
36 #define HRLOG_HEADER_MAGIC 0x35f0498a
37 #define HRLOG_HEADER_VERSION 2
38 
40 typedef struct HrlogRingRef {
41  struct rte_ring* r;
43 
45 
51 static __rte_always_inline struct rte_ring*
52 HrlogRing_Get() {
53  return rcu_dereference(theHrlogRing.r);
54 }
55 
57 __attribute__((nonnull)) static __rte_always_inline void
58 HrlogRing_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 
68 static __rte_always_inline void
69 Hrlog_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 vlanhdr __rte_packed
uint64_t HrlogEntry
A high resolution log entry.
Definition: entry.h:19
HrlogRingRef theHrlogRing
Definition: writer.c:5
struct HrlogHeader HrlogHeader
A high resolution log file header.
struct HrlogRingRef HrlogRingRef
RCU-protected pointer to hrlog collector queue.
HrlogAction
Action identifier in high resolution log.
Definition: entry.h:12
@ HRLOG_OD
Definition: entry.h:14
@ HRLOG_OI
Definition: entry.h:13
@ HRLOG_OC
Definition: entry.h:15
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