NDN-DPDK
High-Speed Named Data Networking Forwarder
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1#ifndef NDNDPDK_STRATEGYAPI_API_H
2#define NDNDPDK_STRATEGYAPI_API_H
3
5
7#include "fib.h"
8#include "packet.h"
9#include "pit.h"
10
12typedef struct SgGlobal {
13 uint64_t tscHz;
15
24
54
57SgTscFromMillis(SgCtx* ctx, uint64_t millis) {
58 return millis * ctx->global->tscHz / 1000;
59}
60
65SUBROUTINE void
69
71#define SgCtx_FibScratchT(ctx, T) \
72 __extension__({ \
73 static_assert(sizeof(T) <= FibScratchSize, ""); \
74 (T*)(ctx)->fibEntryDyn->scratch; \
75 })
76
78#define SgCtx_PitScratchT(ctx, T) \
79 __extension__({ \
80 static_assert(sizeof(T) <= PitScratchSize, ""); \
81 (T*)(ctx)->pitEntry->scratch; \
82 })
83
89__attribute__((nonnull)) uint32_t
90SgRandInt(SgCtx* ctx, uint32_t max);
91
101__attribute__((nonnull)) bool
102SgSetTimer(SgCtx* ctx, TscDuration after);
103
112
117__attribute__((nonnull)) SgForwardInterestResult
119
124__attribute__((nonnull)) void
125SgReturnNacks(SgCtx* ctx, NackReason reason);
126
133__attribute__((section(SGSEC_MAIN), used, nonnull)) uint64_t
134SgMain(SgCtx* ctx);
135
136enum {
139};
140
152__attribute__((nonnull)) bool
153SgGetJSON(SgCtx* ctx, const char* path, int index, int64_t* dst);
154
161#define SgGetJSONScalar(ctx, path, dflt) \
162 __extension__({ \
163 int64_t value = (dflt); \
164 char pathA[] = (path); \
165 SgGetJSON((ctx), pathA, SGJSON_SCALAR, &value); \
166 value; \
167 })
168
176#define SgGetJSONSlice(dst, ctx, path, dflt) \
177 __extension__({ \
178 int64_t length = (0); \
179 char pathA[] = (path); \
180 SgGetJSON((ctx), pathA, SGJSON_LEN, &length); \
181 for (int64_t i = 0; i < RTE_DIM((dst)); ++i) { \
182 int64_t value = (dflt); \
183 if (i < length) { \
184 SgGetJSON((ctx), pathA, i, &value); \
185 } \
186 (dst)[i] = value; \
187 } \
188 length; \
189 })
190
199__attribute__((section(SGSEC_INIT), used, nonnull)) uint64_t
200SgInit(SgCtx* ctx);
201
208#define SGINIT_SCHEMA(...) \
209 char SgJSONSchema[] __attribute__((section(SGSEC_SCHEMA), used)) = #__VA_ARGS__;
210
211#endif // NDNDPDK_STRATEGYAPI_API_H
struct __rte_packed_begin vlanhdr __rte_packed_end
SGEVT_NACK
Nack arrives.
Definition api.h:21
SUBROUTINE TscDuration SgTscFromMillis(SgCtx *ctx, uint64_t millis)
Convert milliseconds to TscDuration.
Definition api.h:57
SgForwardInterestResult SgForwardInterest(SgCtx *ctx, FaceID nh)
Forward an Interest to a nexthop.
Definition fwd-interest.c:186
SGEVT_NONE
Definition api.h:18
SGFWDI_HOPZERO
HopLimit has become zero.
Definition api.h:110
uint64_t SgMain(SgCtx *ctx)
The strategy dataplane program.
Definition delay.c:32
SGEVT_DATA
Data arrives.
Definition api.h:20
void SgReturnNacks(SgCtx *ctx, NackReason reason)
Return Nacks downstream and erase PIT entry.
Definition fwd-nack.c:49
SGFWDI_ALLOCERR
allocation error
Definition api.h:107
SGFWDI_NONONCE
upstream has rejected all nonces
Definition api.h:108
SGFWDI_OK
success
Definition api.h:105
uint64_t SgInit(SgCtx *ctx)
The strategy initialization procedure.
Definition delay.c:44
SGEVT_INTEREST
Interest arrives.
Definition api.h:19
enum __rte_packed_begin SgForwardInterestResult SgForwardInterestResult
Definition api.h:104
uint32_t SgRandInt(SgCtx *ctx, uint32_t max)
Generate a random integer.
Definition strategy.c:8
bool SgGetJSON(SgCtx *ctx, const char *path, int index, int64_t *dst)
Retrieve JSON parameter integer value.
Definition strategy-code.c:28
SGFWDI_SUPPRESSED
forwarding is suppressed
Definition api.h:109
SGFWDI_BADFACE
face is down or FaceID is invalid
Definition api.h:106
SGEVT_TIMER
timer expires
Definition api.h:22
enum __rte_packed_begin SgEvent SgEvent
Indicate why the strategy program is invoked.
Definition api.h:17
@ SGJSON_SCALAR
Definition api.h:137
@ SGJSON_LEN
Definition api.h:138
bool SgSetTimer(SgCtx *ctx, TscDuration after)
Set a timer to invoke strategy after a duration.
Definition strategy.c:43
SUBROUTINE void SgFibNexthopIt_InitCtx(SgFibNexthopIt *it, const SgCtx *ctx)
Iterate over FIB nexthops passing ctx->nhFlt.
Definition api.h:66
uint16_t FaceID
Numeric face identifier.
Definition faceid.h:13
NackReason
Definition an.h:69
#define SGSEC_INIT
Definition sec.h:7
#define SGSEC_MAIN
Definition sec.h:6
#define SUBROUTINE
Indicate that a function is a subroutine.
Definition common.h:20
uint32_t SgFibNexthopFilter
Definition fib.h:23
SUBROUTINE void SgFibNexthopIt_Init(SgFibNexthopIt *it, const SgFibEntry *entry, SgFibNexthopFilter filter)
Definition fib.h:69
Context of strategy invocation.
Definition api.h:26
SgFibNexthopFilter nhFlt
A bitmask filter on which FIB nexthops should be used.
Definition api.h:37
const SgGlobal * global
Global static parameters.
Definition api.h:28
const SgPacket * pkt
Incoming packet.
Definition api.h:43
SgFibEntryDyn * fibEntryDyn
FIB entry dynamic area.
Definition api.h:49
TscTime now
Packet arrival time or current time.
Definition api.h:31
SgPitEntry * pitEntry
PIT entry.
Definition api.h:52
SgEvent eventKind
Why strategy is triggered.
Definition api.h:34
const SgFibEntry * fibEntry
FIB entry.
Definition api.h:46
Definition fib.h:10
Definition fib.h:16
Iterator of FIB nexthops passing a filter.
Definition fib.h:44
Global static parameters.
Definition api.h:12
uint64_t tscHz
Definition api.h:13
Definition packet.h:9
Definition pit.h:28
int64_t TscDuration
Duration in TscTime unit.
Definition tsc.h:12
uint64_t TscTime
TSC clock time point.
Definition tsc.h:9