summaryrefslogtreecommitdiffstats
path: root/build-root/vagrant/Vagrantfile
AgeCommit message (Expand)AuthorFilesLines
2017-04-20Move vagrant stuff to extras/Damjan Marion1-113/+0
2017-02-02Update default Vagrant box to Ubuntu 16.04, VPP-616Dave Wallace1-6/+15
2017-01-17vagrant: stop rsync from wiping changes from /vppPadraig Connolly1-15/+18
2016-12-21vagrant: updated Vagrantfile to use rsyncRay Kinsella1-4/+16
2016-09-02VPP-373: stop building from /vpp mountEd Warnicke1-3/+7
2016-08-02Fix for broken vagrant installs when using Vagrant 1.8.5.Thomas F Herbert1-0/+1
2016-07-21build-root/vagrant: Fix SSE4.x for VBRay1-0/+4
2016-06-25Vagrantfile RAM default is too small.Keith Burns (alagalah)1-1/+1
2016-06-21Vagrantfile syntax error correction - requires string input instead of integer.Srivatsa Sangli1-1/+1
2016-06-20Using env.sh file for Vagrantfile inputs, but assume some defaultsKeith Burns (alagalah)1-12/+13
2016-06-01vagrant: disable automatic update on startThomas Monjalon1-0/+1
2016-05-07Small improvement to vagrant fileEd Warnicke1-5/+5
2016-05-02Break out install.sh from build.shEd Warnicke1-0/+1
2016-05-02VPP-32 Increase # cpus to 2, leave RAM at 4G for virtualbox vagrant usersKeith Burns (alagalah)1-1/+3
2016-04-25Break boostrap.sh into piecesEd Warnicke1-3/+6
2016-04-11vagrant: libvirt configuration.Jeff Shaw1-2/+6
2016-03-25Fix vagrant centos flavor to work with top level make fileEd Warnicke1-1/+1
2016-02-03Switched vagrant for ~/git/vpp to /vppEd Warnicke1-0/+16
2016-01-18build - Vagrant template to get more emulated PCI NICsVincent JARDIN1-0/+9
2015-12-14Fix to make it easy to use http proxy with VagrantEd Warnicke1-0/+7
2015-12-08Initial commit of vpp code.v1.0.0Ed Warnicke1-0/+36
ant */ .highlight .nd { color: #a6e22e } /* Name.Decorator */ .highlight .ni { color: #f8f8f2 } /* Name.Entity */ .highlight .ne { color: #a6e22e } /* Name.Exception */ .highlight .nf { color: #a6e22e } /* Name.Function */ .highlight .nl { color: #f8f8f2 } /* Name.Label */ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */ .highlight .nx { color: #a6e22e } /* Name.Other */ .highlight .py { color: #f8f8f2 } /* Name.Property */ .highlight .nt { color: #f92672 } /* Name.Tag */ .highlight .nv { color: #f8f8f2 } /* Name.Variable */ .highlight .ow { color: #f92672 } /* Operator.Word */ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * node.c - skeleton vpp engine plug-in dual-loop node skeleton
 *
 * Copyright (c) <current-year> <your-organization>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vppinfra/error.h>
#include <nsim/nsim.h>

typedef struct
{
  f64 expires;
  u32 tx_sw_if_index;
  int is_drop;
  int is_lost;
} nsim_trace_t;

#ifndef CLIB_MARCH_VARIANT

/* packet trace format function */
static u8 *
format_nsim_trace (u8 * s, va_list * args)
{
  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
  nsim_trace_t *t = va_arg (*args, nsim_trace_t *);

  if (t->is_drop)
    s = format (s, "NSIM: dropped, %s", t->is_lost ?
		"simulated network loss" : "no space in ring");
  else
    s = format (s, "NSIM: tx time %.6f sw_if_index %d",
		t->expires, t->tx_sw_if_index);

  return s;
}

vlib_node_registration_t nsim_node;
#endif /* CLIB_MARCH_VARIANT */

#define foreach_nsim_error                              \
_(BUFFERED, "Packets buffered")                         \
_(DROPPED, "Packets dropped due to lack of space")	\
_(LOSS, "Network loss simulation drop packets")		\
_(REORDERED, "Packets reordered")

typedef enum
{
#define _(sym,str) NSIM_ERROR_##sym,
  foreach_nsim_error
#undef _
    NSIM_N_ERROR,
} nsim_error_t;

#ifndef CLIB_MARCH_VARIANT
static char *nsim_error_strings[] = {
#define _(sym,string) string,
  foreach_nsim_error
#undef _
};
#endif /* CLIB_MARCH_VARIANT */

typedef enum
{
  NSIM_NEXT_DROP,
  NSIM_N_NEXT,
} nsim_next_t;

static void
nsim_set_actions (nsim_main_t * nsm, vlib_buffer_t ** b,
		  nsim_node_ctx_t * ctx, u32 n_actions)
{
  int i;

  memset (ctx->action, 0, n_actions * sizeof (ctx->action[0]));

  if (PREDICT_FALSE (nsm->drop_fraction != 0.0))
    {
      for (i = 0; i < n_actions; i++)
	if (random_f64 (&nsm->seed) <= nsm->drop_fraction)
	  ctx->action[i] |= NSIM_ACTION_DROP;
    }

  if (PREDICT_FALSE (nsm->reorder_fraction != 0.0))
    {
      for (i = 0; i < n_actions; i++)
	if (random_f64 (&nsm->seed) <= nsm->reorder_fraction)
	  ctx->action[i] |= NSIM_ACTION_REORDER;
    }
}

static void
nsim_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
		   vlib_buffer_t * b, nsim_node_ctx_t * ctx, u32 is_drop)
{
  if (b->flags & VLIB_BUFFER_IS_TRACED)
    {
      nsim_trace_t *t = vlib_add_trace (vm, node, b, sizeof (*t));
      t->expires = ctx->expires;
      t->is_drop = is_drop;
      t->is_lost = ctx->action[0] & NSIM_ACTION_DROP;
      t->tx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
    }
}

always_inline void
nsim_buffer_fwd_lookup (nsim_main_t * nsm, vlib_buffer_t * b,
			u32 * next, u8 is_cross_connect)
{
  if (is_cross_connect)
    {
      vnet_buffer (b)->sw_if_index[VLIB_TX] =
	(vnet_buffer (b)->sw_if_index[VLIB_RX] == nsm->sw_if_index0) ?
	nsm->sw_if_index1 : nsm->sw_if_index0;
      *next =
	(vnet_buffer (b)->sw_if_index[VLIB_TX] == nsm->sw_if_index0) ?
	nsm->output_next_index0 : nsm->output_next_index1;
    }
  else				/* output feature, even easier... */
    {
      u32 sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
      *next = nsm->output_next_index_by_sw_if_index[sw_if_index];
    }
}

always_inline void
nsim_dispatch_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
		      nsim_main_t * nsm, nsim_wheel_t * wp, vlib_buffer_t * b,
		      u32 bi, nsim_node_ctx_t * ctx, u8 is_cross_connect,
		      u8 is_trace)
{
  if (PREDICT_TRUE (!(ctx->action[0] & NSIM_ACTION_DROP)))
    {
      if (PREDICT_FALSE (ctx->action[0] & NSIM_ACTION_REORDER))
	{
	  u32 next;
	  ctx->reord[0] = bi;
	  vnet_get_config_data (&ctx->fcm->config_main,
				&b->current_config_index, &next, 0);
	  ctx->reord_nexts[0] = next;
	  ctx->reord += 1;
	  ctx->reord_nexts += 1;
	  goto trace;
	}

      nsim_wheel_entry_t *ep = wp->entries + wp->tail;
      wp->tail++;
      if (wp->tail == wp->wheel_size)
	wp->tail = 0;
      wp->cursize++;

      ep->tx_time = ctx->expires;
      ep->rx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
      nsim_buffer_fwd_lookup (nsm, b, &ep->output_next_index,
			      is_cross_connect);
      ep->tx_sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
      ep->buffer_index = bi;
      ctx->n_buffered += 1;
    }
  else
    {
      ctx->n_loss += 1;
      ctx->drop[0] = bi;
      ctx->drop += 1;
    }

trace:

  if (PREDICT_FALSE (is_trace))
    nsim_trace_buffer (vm, node, b, ctx, 0);

  ctx->action += 1;
}

always_inline uword
nsim_inline (vlib_main_t * vm,
	     vlib_node_runtime_t * node, vlib_frame_t * frame, int is_trace,
	     int is_cross_connect)
{
  nsim_main_t *nsm = &nsim_main;
  u32 n_left_from, *from, drops[VLIB_FRAME_SIZE], reorders[VLIB_FRAME_SIZE];
  nsim_wheel_t *wp = nsm->wheel_by_thread[vm->thread_index];
  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
  u16 reorders_nexts[VLIB_FRAME_SIZE];
  u8 actions[VLIB_FRAME_SIZE];
  nsim_node_ctx_t ctx;

  ASSERT (wp);

  from = vlib_frame_vector_args (frame);
  n_left_from = frame->n_vectors;

  vlib_get_buffers (vm, from, bufs, n_left_from);
  b = bufs;

  ctx.fcm = vnet_feature_get_config_main (nsm->arc_index);
  ctx.n_loss = 0;
  ctx.n_buffered = 0;
  ctx.drop = drops;
  ctx.reord = reorders;
  ctx.reord_nexts = reorders_nexts;
  ctx.action = actions;
  ctx.expires = vlib_time_now (vm) + nsm->delay;

  nsim_set_actions (nsm, b, &ctx, n_left_from);

  while (n_left_from >= 8)
    {
      vlib_prefetch_buffer_header (b[4], STORE);
      vlib_prefetch_buffer_header (b[5], STORE);
      vlib_prefetch_buffer_header (b[6], STORE);
      vlib_prefetch_buffer_header (b[7], STORE);

      if (PREDICT_FALSE (wp->cursize + 4 >= wp->wheel_size))
	goto slow_path;

      nsim_dispatch_buffer (vm, node, nsm, wp, b[0], from[0], &ctx,
			    is_cross_connect, is_trace);
      nsim_dispatch_buffer (vm, node, nsm, wp, b[1], from[1], &ctx,
			    is_cross_connect, is_trace);
      nsim_dispatch_buffer (vm, node, nsm, wp, b[2], from[2], &ctx,
			    is_cross_connect, is_trace);
      nsim_dispatch_buffer (vm, node, nsm, wp, b[3], from[3], &ctx,
			    is_cross_connect, is_trace);

      b += 4;
      from += 4;
      n_left_from -= 4;
    }

slow_path:

  while (n_left_from > 0)
    {
      /* Drop if out of wheel space and not drop or reorder */
      if (PREDICT_TRUE (wp->cursize < wp->wheel_size
			|| (ctx.action[0] & NSIM_ACTION_DROP)
			|| (ctx.action[0] & NSIM_ACTION_REORDER)))
	{
	  nsim_dispatch_buffer (vm, node, nsm, wp, b[0], from[0], &ctx,
				is_cross_connect, is_trace);
	}
      else
	{
	  ctx.drop[0] = from[0];
	  ctx.drop += 1;
	  if (PREDICT_FALSE (is_trace))
	    nsim_trace_buffer (vm, node, b[0], &ctx, 1);
	  ctx.action += 1;
	}

      b += 1;
      from += 1;
      n_left_from -= 1;
    }

  if (PREDICT_FALSE (ctx.drop > drops))
    {
      u32 n_left_to_drop = ctx.drop - drops;
      vlib_buffer_free (vm, drops, n_left_to_drop);
      vlib_node_increment_counter (vm, node->node_index, NSIM_ERROR_LOSS,
				   ctx.n_loss);
      vlib_node_increment_counter (vm, node->node_index, NSIM_ERROR_DROPPED,
				   n_left_to_drop - ctx.n_loss);
    }
  if (PREDICT_FALSE (ctx.reord > reorders))
    {
      u32 n_reordered = ctx.reord - reorders;
      vlib_buffer_enqueue_to_next (vm, node, reorders, reorders_nexts,
				   n_reordered);
      vlib_node_increment_counter (vm, node->node_index, NSIM_ERROR_REORDERED,
				   n_reordered);
    }
  vlib_node_increment_counter (vm, node->node_index,
			       NSIM_ERROR_BUFFERED, ctx.n_buffered);
  return frame->n_vectors;
}

VLIB_NODE_FN (nsim_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
			  vlib_frame_t * frame)
{
  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
    return nsim_inline (vm, node, frame,
			1 /* is_trace */ , 1 /* is_cross_connect */ );
  else
    return nsim_inline (vm, node, frame,
			0 /* is_trace */ , 1 /* is_cross_connect */ );
}

/* *INDENT-OFF* */
#ifndef CLIB_MARCH_VARIANT
VLIB_REGISTER_NODE (nsim_node) =
{
  .name = "nsim",
  .vector_size = sizeof (u32),
  .format_trace = format_nsim_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,

  .n_errors = ARRAY_LEN(nsim_error_strings),
  .error_strings = nsim_error_strings,

  .n_next_nodes = NSIM_N_NEXT,

  /* edit / add dispositions here */
  .next_nodes = {
        [NSIM_NEXT_DROP] = "error-drop",
  },
};
#endif /* CLIB_MARCH_VARIANT */
/* *INDENT-ON* */

VLIB_NODE_FN (nsim_feature_node) (vlib_main_t * vm,
				  vlib_node_runtime_t * node,
				  vlib_frame_t * frame)
{
  if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
    return nsim_inline (vm, node, frame,
			1 /* is_trace */ , 0 /* is_cross_connect */ );
  else
    return nsim_inline (vm, node, frame,
			0 /* is_trace */ , 0 /* is_cross_connect */ );
}

/* *INDENT-OFF* */
#ifndef CLIB_MARCH_VARIANT
VLIB_REGISTER_NODE (nsim_feature_node) =
{
  .name = "nsim-output-feature",
  .vector_size = sizeof (u32),
  .format_trace = format_nsim_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,

  .n_errors = ARRAY_LEN(nsim_error_strings),
  .error_strings = nsim_error_strings,

  .n_next_nodes = NSIM_N_NEXT,

  /* edit / add dispositions here */
  .next_nodes = {
        [NSIM_NEXT_DROP] = "error-drop",
  },
};
#endif /* CLIB_MARCH_VARIANT */
/* *INDENT-ON* */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */