Skip to content

Commit

Permalink
Use enum based annotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
leeopop committed Mar 3, 2016
1 parent 5a4d1e6 commit b1ef785
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
37 changes: 27 additions & 10 deletions include/nba/element/annotation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@

#include <cstdint>
#include <nba/framework/config.hh>
#include <cassert>

namespace nba {

/* Predefined per-packet annotations */
#define NBA_ANNO_IFACE_IN (0)
#define NBA_ANNO_IFACE_OUT (1)
#define NBA_ANNO_TIMESTAMP (2)
#define NBA_ANNO_BATCH_ID (3)
#define NBA_ANNO_IPSEC_FLOW_ID (4)
#define NBA_ANNO_IPSEC_IV1 (5)
#define NBA_ANNO_IPSEC_IV2 (6)
enum PacketAnnotationKind
{
NBA_ANNO_IFACE_IN = 0,
NBA_ANNO_IFACE_OUT,
NBA_ANNO_TIMESTAMP,
NBA_ANNO_BATCH_ID,
NBA_ANNO_IPSEC_FLOW_ID,
NBA_ANNO_IPSEC_IV1,
NBA_ANNO_IPSEC_IV2,

//End of PacketAnnotationKind
NBA_MAX_ANNOTATION_SET_SIZE
};

/* Predefined per-batch annotations */
#define NBA_BANNO_LB_DECISION (0)
enum BatchAnnotationKind
{
NBA_BANNO_LB_DECISION = 0,

//End of PacketAnnotationKind
NBA_MAX_BANNOTATION_SET_SIZE
};

struct annotation_set {
uint64_t bitmask;
Expand All @@ -33,7 +45,12 @@ static inline void anno_set(struct annotation_set *anno_item,
anno_item->values[anno_id] = value;
}

#define anno_get(anno_item, anno_id) ((anno_item)->values[anno_id])
static inline int64_t anno_get(struct annotation_set *anno_item,
unsigned anno_id)
{
assert(anno_item->bitmask & (1 << anno_id));
return anno_item->values[anno_id];
}

// TODO: implement custom annotation mapping

Expand Down
1 change: 0 additions & 1 deletion include/nba/framework/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#define NBA_MAX_BATCHPOOL_SIZE (2048u)
#define NBA_MAX_IO_BASES (1)

#define NBA_MAX_ANNOTATION_SET_SIZE (7)
#define NBA_MAX_NODELOCALSTORAGE_ENTRIES (16)
#define NBA_MAX_KERNEL_OVERLAP (8)
#define NBA_MAX_DATABLOCKS (12) // If too large (e.g., 64), batch_pool can not be allocated.
Expand Down

0 comments on commit b1ef785

Please sign in to comment.