NDN-DPDK
High-Speed Named Data Networking Forwarder
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
window.h
Go to the documentation of this file.
1 #ifndef NDNDPDK_FETCH_WINDOW_H
2 #define NDNDPDK_FETCH_WINDOW_H
3 
6 #include "../core/mintmr.h"
7 
8 enum {
10  FetchSegTxTimeMask = ((uint64_t)1 << FetchSegTxTimeBits) - 1,
11 };
12 static_assert(FetchSegTxTimeBits + 1 + 1 <= 64, "");
13 
15 typedef struct FetchSeg {
16  uint64_t segNum;
17  struct {
19  bool hasRetx : 1;
20  bool inRetxQ : 1;
22  union {
24  struct cds_list_head retxNode;
25  };
27 
28 __attribute__((nonnull)) static inline void
29 FetchSeg_Init(FetchSeg* seg, uint64_t segNum) {
30  *seg = (FetchSeg){.segNum = segNum};
31 }
32 
34 typedef struct FetchWindow {
36  uint64_t* deleted;
37  uint32_t capacityMask;
38  uint64_t loSegNum;
39  uint64_t hiSegNum;
41 
46 __attribute__((nonnull)) void
47 FetchWindow_Init(FetchWindow* win, uint32_t capacity, int numaSocket);
48 
50 __attribute__((nonnull)) void
52 
54 __attribute__((nonnull)) void
55 FetchWindow_Reset(FetchWindow* win, uint64_t firstSegNum);
56 
64 __attribute__((nonnull)) static __rte_always_inline void
65 FetchWindow_Pos_(FetchWindow* win, uint64_t segNum, FetchSeg** seg, uint64_t** deletedSlab,
66  uint64_t* deletedBit) {
67  uint64_t pos = segNum & win->capacityMask;
68  *seg = &win->array[pos];
69  *deletedSlab = &win->deleted[pos >> 6];
70  *deletedBit = RTE_BIT64(pos & 0x3F);
71 }
72 
74 __attribute__((nonnull)) void
76 
77 __attribute__((nonnull)) static __rte_always_inline FetchSeg*
78 FetchWindow_GetOrDelete_(FetchWindow* win, uint64_t segNum, bool isDelete) {
79  if (unlikely(segNum < win->loSegNum || segNum >= win->hiSegNum)) {
80  return NULL;
81  }
82 
83  FetchSeg* seg = NULL;
84  uint64_t* deletedSlab = NULL;
85  uint64_t deletedBit = 0;
86  FetchWindow_Pos_(win, segNum, &seg, &deletedSlab, &deletedBit);
87  if (unlikely((*deletedSlab & deletedBit) != 0)) {
88  return NULL;
89  }
90 
91  if (isDelete) {
92  *deletedSlab |= deletedBit;
93  if (segNum == win->loSegNum) {
95  }
96  }
97 
98  return seg;
99 }
100 
105 __attribute__((nonnull)) static inline FetchSeg*
106 FetchWindow_Get(FetchWindow* win, uint64_t segNum) {
107  return FetchWindow_GetOrDelete_(win, segNum, false);
108 }
109 
114 __attribute__((nonnull)) static inline FetchSeg*
115 FetchWindow_Append(FetchWindow* win) {
116  uint64_t segNum = win->hiSegNum;
117  if (unlikely(segNum - win->loSegNum > win->capacityMask)) {
118  return NULL;
119  }
120  ++win->hiSegNum;
121 
122  FetchSeg* seg = NULL;
123  uint64_t* deletedSlab = NULL;
124  uint64_t deletedBit = 0;
125  FetchWindow_Pos_(win, segNum, &seg, &deletedSlab, &deletedBit);
126  *deletedSlab &= ~deletedBit;
127  FetchSeg_Init(seg, segNum);
128  return seg;
129 }
130 
132 __attribute__((nonnull)) static inline void
133 FetchWindow_Delete(FetchWindow* win, uint64_t segNum) {
134  FetchWindow_GetOrDelete_(win, segNum, true);
135 }
136 
137 #endif // NDNDPDK_FETCH_WINDOW_H
Per-segment state.
Definition: window.h:15
bool hasRetx
whether Interest has been retransmitted at least once
Definition: window.h:19
MinTmr rtoExpiry
RTO expiration timer, valid if inRetxQ==false.
Definition: window.h:23
bool inRetxQ
Definition: window.h:20
uint64_t segNum
segment number
Definition: window.h:16
uint64_t txTime
TscTime last Interest tx time.
Definition: window.h:18
struct cds_list_head retxNode
retxQ node, valid if inRetxQ==true
Definition: window.h:24
struct FetchSeg::@40 __rte_packed
Window of segment states.
Definition: window.h:34
uint64_t hiSegNum
exclusive upper bound of segment numbers
Definition: window.h:39
uint32_t capacityMask
array capacity minus one
Definition: window.h:37
FetchSeg * array
segment records
Definition: window.h:35
uint64_t loSegNum
inclusive lower bound of segment numbers
Definition: window.h:38
uint64_t * deleted
deleted flag bit vector
Definition: window.h:36
Timer on minute scheduler.
Definition: mintmr.h:9
@ FetchSegTxTimeMask
Definition: window.h:10
@ FetchSegTxTimeBits
Definition: window.h:9
void FetchWindow_Advance_(FetchWindow *win)
Move loPos and loSegNum after some segment states have been deleted.
Definition: window.c:36
void FetchWindow_Reset(FetchWindow *win, uint64_t firstSegNum)
Delete all records and set first segment number.
Definition: window.c:30
void FetchWindow_Init(FetchWindow *win, uint32_t capacity, int numaSocket)
Initialize FetchWindow.
Definition: window.c:4
struct FetchWindow FetchWindow
Window of segment states.
void FetchWindow_Free(FetchWindow *win)
Deallocated memory.
Definition: window.c:23
struct FetchSeg FetchSeg
Per-segment state.