1 #ifndef NDNDPDK_STRATEGYAPI_API_H
2 #define NDNDPDK_STRATEGYAPI_API_H
6 #include "../strategycode/sec.h"
71 #define SgCtx_FibScratchT(ctx, T) \
73 static_assert(sizeof(T) <= FibScratchSize, ""); \
74 (T*)(ctx)->fibEntryDyn->scratch; \
78 #define SgCtx_PitScratchT(ctx, T) \
80 static_assert(sizeof(T) <= PitScratchSize, ""); \
81 (T*)(ctx)->pitEntry->scratch; \
89 __attribute__((nonnull)) uint32_t
101 __attribute__((nonnull))
bool
124 __attribute__((nonnull))
void
133 __attribute__((section(
SGSEC_MAIN), used, nonnull)) uint64_t
152 __attribute__((nonnull))
bool
161 #define SgGetJSONScalar(ctx, path, dflt) \
163 int64_t value = (dflt); \
164 char pathA[] = (path); \
165 SgGetJSON((ctx), pathA, SGJSON_SCALAR, &value); \
176 #define SgGetJSONSlice(dst, ctx, path, dflt) \
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); \
184 SgGetJSON((ctx), pathA, i, &value); \
199 __attribute__((section(
SGSEC_INIT), used, nonnull)) uint64_t
208 #define SGINIT_SCHEMA(...) \
209 char SgJSONSchema[] __attribute__((section(SGSEC_SCHEMA), used)) = #__VA_ARGS__;
struct vlanhdr __rte_packed
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
uint64_t SgMain(SgCtx *ctx)
The strategy dataplane program.
Definition: delay.c:32
void SgReturnNacks(SgCtx *ctx, NackReason reason)
Return Nacks downstream and erase PIT entry.
Definition: fwd-nack.c:49
SgEvent
Indicate why the strategy program is invoked.
Definition: api.h:17
@ SGEVT_TIMER
timer expires
Definition: api.h:22
@ SGEVT_NACK
Nack arrives.
Definition: api.h:21
@ SGEVT_DATA
Data arrives.
Definition: api.h:20
@ SGEVT_NONE
Definition: api.h:18
@ SGEVT_INTEREST
Interest arrives.
Definition: api.h:19
uint64_t SgInit(SgCtx *ctx)
The strategy initialization procedure.
Definition: delay.c:44
uint32_t SgRandInt(SgCtx *ctx, uint32_t max)
Generate a random integer.
Definition: strategy.c:8
struct SgGlobal SgGlobal
Global static parameters.
bool SgGetJSON(SgCtx *ctx, const char *path, int index, int64_t *dst)
Retrieve JSON parameter integer value.
Definition: strategy-code.c:28
bool SgSetTimer(SgCtx *ctx, TscDuration after)
Set a timer to invoke strategy after a duration.
Definition: strategy.c:43
struct SgCtx SgCtx
Context of strategy invocation.
SgForwardInterestResult
Definition: api.h:104
@ SGFWDI_HOPZERO
HopLimit has become zero.
Definition: api.h:110
@ SGFWDI_ALLOCERR
allocation error
Definition: api.h:107
@ SGFWDI_OK
success
Definition: api.h:105
@ SGFWDI_SUPPRESSED
forwarding is suppressed
Definition: api.h:109
@ SGFWDI_NONONCE
upstream has rejected all nonces
Definition: api.h:108
@ SGFWDI_BADFACE
face is down or FaceID is invalid
Definition: api.h:106
@ SGJSON_SCALAR
Definition: api.h:137
@ SGJSON_LEN
Definition: api.h:138
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
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
int64_t TscDuration
Duration in TscTime unit.
Definition: tsc.h:12
uint64_t TscTime
TSC clock time point.
Definition: tsc.h:9