NDN-DPDK
High-Speed Named Data Networking Forwarder
|
Go to the source code of this file.
Data Structures | |
struct | SgGlobal |
Global static parameters. More... | |
struct | SgCtx |
Context of strategy invocation. More... | |
Macros | |
#define | SgCtx_FibScratchT(ctx, T) |
Access FIB entry scratch area as T* type. More... | |
#define | SgCtx_PitScratchT(ctx, T) |
Access PIT entry scratch area as T* type. More... | |
#define | SgGetJSONScalar(ctx, path, dflt) |
Retrieve JSON parameter integer scalar value. More... | |
#define | SgGetJSONSlice(dst, ctx, path, dflt) |
Retrieve JSON parameter integer array. More... | |
#define | SGINIT_SCHEMA(...) char SgJSONSchema[] __attribute__((section(SGSEC_SCHEMA), used)) = #__VA_ARGS__; |
Declare JSON schema. More... | |
Typedefs | |
typedef struct SgGlobal | SgGlobal |
Global static parameters. More... | |
typedef enum SgEvent | SgEvent |
Indicate why the strategy program is invoked. More... | |
typedef struct SgCtx | SgCtx |
Context of strategy invocation. More... | |
typedef enum SgForwardInterestResult | SgForwardInterestResult |
Enumerations | |
enum | SgEvent { SGEVT_NONE , SGEVT_INTEREST , SGEVT_DATA , SGEVT_NACK , SGEVT_TIMER } |
Indicate why the strategy program is invoked. More... | |
enum | SgForwardInterestResult { SGFWDI_OK , SGFWDI_BADFACE , SGFWDI_ALLOCERR , SGFWDI_NONONCE , SGFWDI_SUPPRESSED , SGFWDI_HOPZERO } |
enum | { SGJSON_SCALAR = -1 , SGJSON_LEN = -2 } |
Functions | |
SUBROUTINE TscDuration | SgTscFromMillis (SgCtx *ctx, uint64_t millis) |
Convert milliseconds to TscDuration. More... | |
SUBROUTINE void | SgFibNexthopIt_InitCtx (SgFibNexthopIt *it, const SgCtx *ctx) |
Iterate over FIB nexthops passing ctx->nhFlt. More... | |
uint32_t | SgRandInt (SgCtx *ctx, uint32_t max) |
Generate a random integer. More... | |
bool | SgSetTimer (SgCtx *ctx, TscDuration after) |
Set a timer to invoke strategy after a duration. More... | |
SgForwardInterestResult | SgForwardInterest (SgCtx *ctx, FaceID nh) |
Forward an Interest to a nexthop. More... | |
void | SgReturnNacks (SgCtx *ctx, NackReason reason) |
Return Nacks downstream and erase PIT entry. More... | |
uint64_t | SgMain (SgCtx *ctx) |
The strategy dataplane program. More... | |
bool | SgGetJSON (SgCtx *ctx, const char *path, int index, int64_t *dst) |
Retrieve JSON parameter integer value. More... | |
uint64_t | SgInit (SgCtx *ctx) |
The strategy initialization procedure. More... | |
#define SgCtx_FibScratchT | ( | ctx, | |
T | |||
) |
Access FIB entry scratch area as T* type.
#define SgCtx_PitScratchT | ( | ctx, | |
T | |||
) |
Access PIT entry scratch area as T* type.
#define SgGetJSONScalar | ( | ctx, | |
path, | |||
dflt | |||
) |
Retrieve JSON parameter integer scalar value.
path | JSON property path, using '.' separator for nested path. |
dflt | default value. |
#define SgGetJSONSlice | ( | dst, | |
ctx, | |||
path, | |||
dflt | |||
) |
Retrieve JSON parameter integer array.
dst | destination array. |
path | JSON property path, using '.' separator for nested path. |
dflt | default value. |
#define SGINIT_SCHEMA | ( | ... | ) | char SgJSONSchema[] __attribute__((section(SGSEC_SCHEMA), used)) = #__VA_ARGS__; |
Declare JSON schema.
A strategy should provide a JSON schema if it accepts parameters. Input parameters are validated against this schema prior to calling SgInit
.
typedef enum SgForwardInterestResult SgForwardInterestResult |
enum SgEvent |
SUBROUTINE void SgFibNexthopIt_InitCtx | ( | SgFibNexthopIt * | it, |
const SgCtx * | ctx | ||
) |
Iterate over FIB nexthops passing ctx->nhFlt.
SgForwardInterestResult SgForwardInterest | ( | SgCtx * | ctx, |
FaceID | nh | ||
) |
Forward an Interest to a nexthop.
SGEVT_DATA
. bool SgGetJSON | ( | SgCtx * | ctx, |
const char * | path, | ||
int | index, | ||
int64_t * | dst | ||
) |
Retrieve JSON parameter integer value.
path | JSON property path, using '.' separator for nested path. Due to eBPF loader limitation, this string should be written as a mutable char[] allocated on stack. A string literal may cause "resolve_xsym(.L.str) error -2". |
index | index into JSON array, or SGJSON_SCALAR to retrieve scalar value, or SGJSON_LEN to retrieve array length. |
dst | destination pointer. |
SgInit
. uint64_t SgInit | ( | SgCtx * | ctx | ) |
The strategy initialization procedure.
A strategy should implement this function if it accepts parameters. This is called when a strategy is activated on a FIB entry. It should populate FIB entry scratch area according to JSON parameters.
uint64_t SgMain | ( | SgCtx * | ctx | ) |
The strategy dataplane program.
Every strategy must implement this function.
uint32_t SgRandInt | ( | SgCtx * | ctx, |
uint32_t | max | ||
) |
Generate a random integer.
max | exclusive maximum. |
void SgReturnNacks | ( | SgCtx * | ctx, |
NackReason | reason | ||
) |
Return Nacks downstream and erase PIT entry.
SGEVT_INTEREST
. bool SgSetTimer | ( | SgCtx * | ctx, |
TscDuration | after | ||
) |
Set a timer to invoke strategy after a duration.
after | duration in TSC unit, cannot exceed PIT entry expiration time. |
SGEVT_DATA
.Strategy program will be invoked again with SGEVT_TIMER
after after
. However, the timer would be cancelled if strategy program is invoked for any other event, a different timer is set, or the strategy choice has been changed.
SUBROUTINE TscDuration SgTscFromMillis | ( | SgCtx * | ctx, |
uint64_t | millis | ||
) |
Convert milliseconds to TscDuration.