NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
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
5
6#include "cs-entry.h"
7
8__attribute__((nonnull)) void
10
11static __rte_always_inline void
12CsList_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
20static __rte_always_inline void
21CsList_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
32CsList_Append(CsList* csl, CsEntry* entry) {
33 CsList_AppendNode_(csl, (CsNode*)entry);
34 ++csl->count;
35}
36
38__attribute__((nonnull)) static __rte_always_inline void
39CsList_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*
47CsList_GetFront(CsList* csl) {
48 NDNDPDK_ASSERT(csl->count > 0);
49 return (CsEntry*)csl->next;
50}
51
53__attribute__((nonnull)) static __rte_always_inline void
54CsList_MoveToLast(CsList* csl, CsEntry* entry) {
55 CsList_RemoveNode_(csl, (CsNode*)entry);
56 CsList_AppendNode_(csl, (CsNode*)entry);
57}
58
59typedef void (*CsList_EvictCb)(CsEntry* entry, uintptr_t ctx);
60
65__attribute__((nonnull)) uint32_t
66CsList_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