NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
pcc-entry.h
Go to the documentation of this file.
1#ifndef NDNDPDK_PCCT_PCC_ENTRY_H
2#define NDNDPDK_PCCT_PCC_ENTRY_H
3
5
6#include "../vendor/uthash-handle.h"
7#include "cs-entry.h"
8#include "pcc-key.h"
9#include "pit-entry.h"
10
11enum {
14 PccTokenMask = ((uint64_t)1 << PccTokenBits) - 1,
15};
16
17typedef struct PccEntry PccEntry;
18
24typedef union PccSlot {
25 struct {
26 uint64_t a_[2];
28 };
32
34typedef enum __rte_packed_begin PccSlotIndex {
40
50
56struct PccEntry {
58 UT_hash_handle hh;
59
60 RTE_MARKER a_;
61 union {
62 struct __rte_packed_begin {
63 bool hasToken : 1;
64 int : 1;
68 int : 8;
69 uint64_t token : PccTokenBits;
71 struct __rte_packed_begin {
72 int : 2;
73 const int hasPitEntry0 : 2;
74 const int hasPitEntry1 : 2;
75 const int hasCsEntry : 2;
76 uint64_t : 56;
78 struct __rte_packed_begin {
79 int : 2;
80 const int hasPitEntries : 4;
81 uint64_t : 58;
83 struct __rte_packed_begin {
84 int : 2;
85 const int hasEntries : 6;
86 uint64_t : 56;
88 uint64_t tokenQword;
89 };
90 RTE_MARKER b_;
91
94};
95static_assert(offsetof(PccEntry, b_) - offsetof(PccEntry, a_) == sizeof(uint64_t), "");
96
97__attribute__((nonnull)) static __rte_always_inline PccSlot*
98PccEntry_GetSlot_(PccEntry* entry, PccSlotIndex slot) {
99 switch (slot) {
100 case PCC_SLOT1:
101 return &entry->slot1;
102 case PCC_SLOT2:
103 NDNDPDK_ASSERT(entry->ext != NULL);
104 return &entry->ext->slot2;
105 case PCC_SLOT3:
106 NDNDPDK_ASSERT(entry->ext != NULL);
107 return &entry->ext->slot3;
108 default:
109 NDNDPDK_ASSERT(false);
110 return NULL;
111 }
112}
113
114__attribute__((nonnull)) PccSlotIndex
116
117__attribute__((nonnull)) PccSlotIndex
119
124__attribute__((nonnull, returns_nonnull)) static inline PitEntry*
125PccEntry_GetPitEntry0(PccEntry* entry) {
126 return &PccEntry_GetSlot_(entry, entry->pitEntry0Slot)->pitEntry;
127}
128
134__attribute__((nonnull)) static inline PitEntry*
135PccEntry_AddPitEntry0(PccEntry* entry) {
136 if (entry->hasPitEntry0) {
137 return PccEntry_GetPitEntry0(entry);
138 }
139 PccSlot* slot = NULL;
140 entry->pitEntry0Slot = PccEntry_AllocateSlot_(entry, &slot);
141 if (unlikely(slot == NULL)) {
142 return NULL;
143 }
144 return &slot->pitEntry;
145}
146
148__attribute__((nonnull)) static inline void
149PccEntry_RemovePitEntry0(PccEntry* entry) {
150 entry->pitEntry0Slot = PccEntry_ClearSlot_(entry, entry->pitEntry0Slot);
151}
152
157__attribute__((nonnull, returns_nonnull)) static inline PitEntry*
158PccEntry_GetPitEntry1(PccEntry* entry) {
159 return &PccEntry_GetSlot_(entry, entry->pitEntry1Slot)->pitEntry;
160}
161
167__attribute__((nonnull)) static inline PitEntry*
168PccEntry_AddPitEntry1(PccEntry* entry) {
169 if (entry->hasPitEntry1) {
170 return PccEntry_GetPitEntry1(entry);
171 }
172 PccSlot* slot = NULL;
173 entry->pitEntry1Slot = PccEntry_AllocateSlot_(entry, &slot);
174 if (unlikely(slot == NULL)) {
175 return NULL;
176 }
177 return &slot->pitEntry;
178}
179
181__attribute__((nonnull)) static inline void
182PccEntry_RemovePitEntry1(PccEntry* entry) {
183 entry->pitEntry1Slot = PccEntry_ClearSlot_(entry, entry->pitEntry1Slot);
184}
185
190__attribute__((nonnull, returns_nonnull)) static inline CsEntry*
191PccEntry_GetCsEntry(PccEntry* entry) {
192 return &PccEntry_GetSlot_(entry, entry->csEntrySlot)->csEntry;
193}
194
200__attribute__((nonnull)) static inline CsEntry*
201PccEntry_AddCsEntry(PccEntry* entry) {
202 if (entry->hasCsEntry) {
203 return PccEntry_GetCsEntry(entry);
204 }
205 PccSlot* slot = NULL;
206 entry->csEntrySlot = PccEntry_AllocateSlot_(entry, &slot);
207 if (unlikely(slot == NULL)) {
208 return NULL;
209 }
210 return &slot->csEntry;
211}
212
214__attribute__((nonnull)) static inline void
215PccEntry_RemoveCsEntry(PccEntry* entry) {
216 entry->csEntrySlot = PccEntry_ClearSlot_(entry, entry->csEntrySlot);
217}
218
219#endif // NDNDPDK_PCCT_PCC_ENTRY_H
struct __rte_packed_begin vlanhdr __rte_packed_end
#define NDNDPDK_ASSERT(x)
Definition common.h:60
PCC_SLOT_NONE
Definition pcc-entry.h:35
enum __rte_packed_begin PccSlotIndex PccSlotIndex
Identify a PCC entry slot.
Definition pcc-entry.h:34
PccSlotIndex PccEntry_ClearSlot_(PccEntry *entry, PccSlotIndex slot)
Definition pcc-entry.c:49
@ PccTokenBits
Definition pcc-entry.h:13
@ PccTokenSize
Definition pcc-entry.h:12
@ PccTokenMask
Definition pcc-entry.h:14
PCC_SLOT2
Definition pcc-entry.h:37
PCC_SLOT3
Definition pcc-entry.h:38
PccSlotIndex PccEntry_AllocateSlot_(PccEntry *entry, PccSlot **slot)
Definition pcc-entry.c:8
PCC_SLOT1
Definition pcc-entry.h:36
A CS entry.
Definition cs-entry.h:22
PCC entry extension.
Definition pcc-entry.h:46
PccSlot slot3
Definition pcc-entry.h:48
PccSlot slot2
Definition pcc-entry.h:47
PIT-CS composite entry.
Definition pcc-entry.h:56
const int hasPitEntries
Definition pcc-entry.h:80
PccSlotIndex pitEntry1Slot
Definition pcc-entry.h:66
bool hasToken
Definition pcc-entry.h:63
const int hasPitEntry1
Definition pcc-entry.h:74
UT_hash_handle hh
Definition pcc-entry.h:58
PccSlot slot1
Definition pcc-entry.h:92
const int hasPitEntry0
Definition pcc-entry.h:73
uint64_t token
Definition pcc-entry.h:69
RTE_MARKER b_
Definition pcc-entry.h:90
const int hasEntries
Definition pcc-entry.h:85
PccKey key
Definition pcc-entry.h:57
PccSlotIndex pitEntry0Slot
Definition pcc-entry.h:65
RTE_MARKER a_
Definition pcc-entry.h:60
PccEntryExt * ext
Definition pcc-entry.h:93
const int hasCsEntry
Definition pcc-entry.h:75
PccSlotIndex csEntrySlot
Definition pcc-entry.h:67
uint64_t tokenQword
Definition pcc-entry.h:88
Hash key stored in PccEntry .
Definition pcc-key.h:50
A PIT entry.
Definition pit-entry.h:24
PCC entry slot.
Definition pcc-entry.h:24
PitEntry pitEntry
Definition pcc-entry.h:29
PccEntry * pccEntry
NULL indicates unoccupied slot.
Definition pcc-entry.h:27
uint64_t a_[2]
Definition pcc-entry.h:26
CsEntry csEntry
Definition pcc-entry.h:30