MAP: Use explicit address/prefix types in API
[vpp.git] / src / plugins / ioam / lib-trace / trace_util.h
index 556f07e..61f18d9 100644 (file)
@@ -62,7 +62,6 @@ typedef struct
   vnet_main_t *vnet_main;
 } trace_main_t;
 
-extern trace_main_t trace_main;
 
 /*
  * Initialize Trace profile
@@ -70,25 +69,21 @@ extern trace_main_t trace_main;
 int trace_util_init (void);
 
 
-/*
- * Find a trace profile
- */
-
-always_inline trace_profile *
-trace_profile_find (void)
-{
-  trace_main_t *sm = &trace_main;
-
-  return (&(sm->profile));
-}
-
-
 /* setup and clean up profile */
 int trace_profile_create (trace_profile * profile, u8 trace_type, u8 num_elts,
                          u32 trace_tsp, u32 node_id, u32 app_data);
 
 void clear_trace_profiles (void);
 
+/* *INDENT-OFF* */
+typedef CLIB_PACKED (struct
+{
+  u8 ioam_trace_type;
+  u8 data_list_elts_left;
+  u32 elts[0]; /* Variable type. So keep it generic */
+}) ioam_trace_hdr_t;
+/* *INDENT-ON* */
+
 
 
 #define    BIT_TTL_NODEID       (1<<0)
@@ -96,7 +91,11 @@ void clear_trace_profiles (void);
 #define    BIT_EGR_INTERFACE    (1<<2)
 #define    BIT_TIMESTAMP        (1<<3)
 #define    BIT_APPDATA          (1<<4)
-#define    TRACE_TYPE_MASK      0x1F   /* Mask of all above bits */
+#define    BIT_LOOPBACK         (1<<5)
+#define    BIT_LOOPBACK_REPLY   (1<<6)
+#define    TRACE_TYPE_MASK      0x7F   /* Mask of all above bits */
+
+#define    TRACE_TYPE_IF_TS_APP_LOOP    0x3F
 
 /*
      0x00011111  iOAM-trace-type is 0x00011111 then the format of node
@@ -206,27 +205,37 @@ typedef struct
   u32 app_data;
 } ioam_trace_ts_app_t;
 
-
-
 static inline u8
-fetch_trace_data_size (u8 trace_type)
+fetch_trace_data_size (u16 trace_type)
 {
   u8 trace_data_size = 0;
 
-  if (trace_type == TRACE_TYPE_IF_TS_APP)
+  if ((trace_type & TRACE_TYPE_IF_TS_APP) == TRACE_TYPE_IF_TS_APP)
     trace_data_size = sizeof (ioam_trace_if_ts_app_t);
-  else if (trace_type == TRACE_TYPE_IF)
+  else if ((trace_type & TRACE_TYPE_IF) == TRACE_TYPE_IF)
     trace_data_size = sizeof (ioam_trace_if_t);
-  else if (trace_type == TRACE_TYPE_TS)
+  else if ((trace_type & TRACE_TYPE_TS) == TRACE_TYPE_TS)
     trace_data_size = sizeof (ioam_trace_ts_t);
-  else if (trace_type == TRACE_TYPE_APP)
+  else if ((trace_type & TRACE_TYPE_APP) == TRACE_TYPE_APP)
     trace_data_size = sizeof (ioam_trace_app_t);
-  else if (trace_type == TRACE_TYPE_TS_APP)
+  else if ((trace_type & TRACE_TYPE_TS_APP) == TRACE_TYPE_TS_APP)
     trace_data_size = sizeof (ioam_trace_ts_app_t);
 
   return trace_data_size;
 }
 
+always_inline void
+ioam_trace_set_bit (ioam_trace_hdr_t * trace_hdr, u8 trace_bit)
+{
+  trace_hdr->ioam_trace_type |= trace_bit;
+}
+
+always_inline void
+ioam_trace_reset_bit (ioam_trace_hdr_t * trace_hdr, u8 trace_bit)
+{
+  trace_hdr->ioam_trace_type &= (~trace_bit);
+}
+
 int ioam_trace_get_sizeof_handler (u32 * result);
 int ip6_trace_profile_setup (void);
 int ip6_trace_profile_cleanup (void);