NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cs-list.h
Go to the documentation of this file.
1 #ifndef NDNDPDK_PCCT_CS_LIST_H
2 #define NDNDPDK_PCCT_CS_LIST_H
3 
6 #include "cs-entry.h"
7 
8 __attribute__((nonnull)) void
9 CsList_Init(CsList* csl);
10 
11 static __rte_always_inline void
12 CsList_AppendNode_(CsList* csl, CsNode* node) {
13  CsNode* last = csl->prev;
14  node->prev = last;
15  node->next = (CsNode*)csl;
16  last->next = node;
17  csl->prev = node;
18 }
19 
20 static __rte_always_inline void
21 CsList_RemoveNode_(CsList* csl, CsNode* node) {
22  CsNode* prev = node->prev;
23  CsNode* next = node->next;
24  NDNDPDK_ASSERT(prev->next == node);
25  NDNDPDK_ASSERT(next->prev == node);
26  prev->next = next;
27  next->prev = prev;
28 }
29 
31 __attribute__((nonnull)) static __rte_always_inline void
32 CsList_Append(CsList* csl, CsEntry* entry) {
33  CsList_AppendNode_(csl, (CsNode*)entry);
34  ++csl->count;
35 }
36 
38 __attribute__((nonnull)) static __rte_always_inline void
39 CsList_Remove(CsList* csl, CsEntry* entry) {
40  NDNDPDK_ASSERT(csl->count > 0);
41  CsList_RemoveNode_(csl, (CsNode*)entry);
42  --csl->count;
43 }
44 
46 __attribute__((nonnull, returns_nonnull)) static __rte_always_inline CsEntry*
47 CsList_GetFront(CsList* csl) {
48  NDNDPDK_ASSERT(csl->count > 0);
49  return (CsEntry*)csl->next;
50 }
51 
53 __attribute__((nonnull)) static __rte_always_inline void
54 CsList_MoveToLast(CsList* csl, CsEntry* entry) {
55  CsList_RemoveNode_(csl, (CsNode*)entry);
56  CsList_AppendNode_(csl, (CsNode*)entry);
57 }
58 
59 typedef void (*CsList_EvictCb)(CsEntry* entry, uintptr_t ctx);
60 
65 __attribute__((nonnull)) uint32_t
66 CsList_EvictBulk(CsList* csl, uint32_t max, CsList_EvictCb cb, uintptr_t ctx);
67 
68 #endif // NDNDPDK_PCCT_CS_LIST_H
#define NDNDPDK_ASSERT(x)
Definition: common.h:60
void CsList_Init(CsList *csl)
Definition: cs-list.c:9
uint32_t CsList_EvictBulk(CsList *csl, uint32_t max, CsList_EvictCb cb, uintptr_t ctx)
Evict up to max entries from front of list.
Definition: cs-list.c:16
void(* CsList_EvictCb)(CsEntry *entry, uintptr_t ctx)
Definition: cs-list.h:59
A CS entry.
Definition: cs-entry.h:22
A doubly linked list within CS.
Definition: cs-struct.h:18
uint32_t count
number of entries
Definition: cs-struct.h:21
CsNode * next
front pointer, self if list is empty
Definition: cs-struct.h:20
CsNode * prev
back pointer, self if list is empty
Definition: cs-struct.h:19
The prev-next pointers common in CsEntry and CsList.
Definition: cs-struct.h:12
CsNode * prev
Definition: cs-struct.h:13
CsNode * next
Definition: cs-struct.h:14