#include <vppinfra/hash.h>
#include <vppinfra/error.h>
-#define WHEEL_ENTRY_DATA_SIZE 1536 /* an even multiple of 64, pls */
+#define NSIM_MAX_TX_BURST 32 /**< max packets in a tx burst */
typedef struct
{
f64 tx_time;
+ u32 rx_sw_if_index;
u32 tx_sw_if_index;
- u32 current_length;
- CLIB_CACHE_LINE_ALIGN_MARK (pad);
- u8 data[WHEEL_ENTRY_DATA_SIZE];
+ u32 output_next_index;
+ u32 buffer_index;
+ u32 pad; /* pad to 32-bytes */
} nsim_wheel_entry_t;
typedef struct
CLIB_CACHE_LINE_ALIGN_MARK (pad);
} nsim_wheel_t;
+typedef struct nsim_node_ctx
+{
+ vnet_feature_config_main_t *fcm;
+ f64 expires;
+ u32 *drop;
+ u32 *reord;
+ u16 *reord_nexts;
+ u8 *action;
+ u64 n_buffered;
+ u64 n_loss;
+} nsim_node_ctx_t;
+
+#define foreach_nsm_action \
+ _(DROP, "Packet loss") \
+ _(REORDER, "Packet reorder")
+
+enum nsm_action_bit
+{
+#define _(sym, str) NSIM_ACTION_##sym##_BIT,
+ foreach_nsm_action
+#undef _
+};
+
+typedef enum nsm_action
+{
+#define _(sym, str) NSIM_ACTION_##sym = 1 << NSIM_ACTION_##sym##_BIT,
+ foreach_nsm_action
+#undef _
+} nsm_action_e;
+
typedef struct
{
/* API message ID base */
u16 msg_id_base;
+ /* output feature arc index */
+ u16 arc_index;
+
/* Two interfaces, cross-connected with delay */
u32 sw_if_index0, sw_if_index1;
u32 output_next_index0, output_next_index1;
- /* Per-thread buffer / scheduler wheels */
+ /* N interfaces, using the output feature */
+ u32 *output_next_index_by_sw_if_index;
+
+ /* Random seed for loss-rate simulation */
+ u32 seed;
+
+ /* Per-thread scheduler wheels */
nsim_wheel_t **wheel_by_thread;
- u32 **buffer_indices_by_thread;
/* Config parameters */
f64 delay;
f64 bandwidth;
- f64 packet_size;
+ f64 drop_fraction;
+ f64 reorder_fraction;
+ u32 packet_size;
+ u32 wheel_slots_per_wrk;
+ u32 poll_main_thread;
u64 mmap_size;