summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface.api
AgeCommit message (Expand)AuthorFilesLines
2018-07-20IP directed broadcastNeale Ranns1-0/+14
2018-06-11MTU: Software interface / Per-protocol MTU supportOle Troan1-3/+17
2018-04-13Revert "MTU: Setting of MTU on software interface (instead of hardware interf...Damjan Marion1-2/+2
2018-04-13MTU: Setting of MTU on software interface (instead of hardware interface)Ole Troan1-2/+2
2018-03-21Detailed Interface stats API takes sw_if_indexNeale Ranns1-1/+4
2018-03-19Interface Unicast, Multicast and Broadcast stats on the APINeale Ranns1-4/+40
2018-03-16IPv6 ND Router discovery control plane (VPP-1095)Juraj Sloboda1-1/+25
2018-03-06API: Add service definitions for events and singleton messages (second attempt)Marek Gradzki1-60/+5
2018-03-05Revert "API: Add service definitions for events and singleton messages."Ole Trøan1-5/+60
2018-03-05API: Add service definitions for events and singleton messages.Ole Troan1-60/+5
2018-01-23VPPAPIGEN: vppapigen replacement in Python PLY.Ole Troan1-1/+1
2017-11-10Break up vpe.apiNeale Ranns1-0/+137
2017-10-29devices: Add binary API for set interface <interface> rx-modeSteven1-0/+20
2017-10-09vppapigen: support per-file (major,minor,patch) version stampsDave Barach1-0/+2
2017-09-14Stats refactorKeith Burns (alagalah)1-2/+74
2017-08-16No context in SW interface eventNeale Ranns1-2/+4
2017-08-11Dedicated SW Interface EventNeale Ranns1-3/+16
2017-05-15Fix vnet_interface_counters API definitionAloys Augustin1-7/+28
2017-04-25"autoreply" flag: autogenerate standard xxx_reply_t messagesDave Barach1-99/+9
2017-04-03Add an API call to set interface MAC addresses.Jon Loeliger1-1/+25
2017-02-21VPP-540 : pbb tag rewrite detailsPavel Kotucek1-2/+17
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+339
t-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 */ }
/*
 * Copyright (c) 2018 Cisco and/or its affiliates.
 * 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 <plugins/gbp/gbp.h>
#include <plugins/gbp/gbp_fwd_dpo.h>

#include <vnet/ethernet/ethernet.h>

/**
 * The 'DB' of GBP FWD DPOs.
 * There is one per-proto
 */
static index_t gbp_fwd_dpo_db[DPO_PROTO_NUM] = { INDEX_INVALID };

/**
 * DPO type registered for these GBP FWD
 */
static dpo_type_t gbp_fwd_dpo_type;

/**
 * @brief pool of all interface DPOs
 */
gbp_fwd_dpo_t *gbp_fwd_dpo_pool;

static gbp_fwd_dpo_t *
gbp_fwd_dpo_alloc (void)
{
  gbp_fwd_dpo_t *gfd;

  pool_get (gbp_fwd_dpo_pool, gfd);

  return (gfd);
}

static inline gbp_fwd_dpo_t *
gbp_fwd_dpo_get_from_dpo (const dpo_id_t * dpo)
{
  ASSERT (gbp_fwd_dpo_type == dpo->dpoi_type);

  return (gbp_fwd_dpo_get (dpo->dpoi_index));
}

static inline index_t
gbp_fwd_dpo_get_index (gbp_fwd_dpo_t * gfd)
{
  return (gfd - gbp_fwd_dpo_pool);
}

static void
gbp_fwd_dpo_lock (dpo_id_t * dpo)
{
  gbp_fwd_dpo_t *gfd;

  gfd = gbp_fwd_dpo_get_from_dpo (dpo);
  gfd->gfd_locks++;
}

static void
gbp_fwd_dpo_unlock (dpo_id_t * dpo)
{
  gbp_fwd_dpo_t *gfd;

  gfd = gbp_fwd_dpo_get_from_dpo (dpo);
  gfd->gfd_locks--;

  if (0 == gfd->gfd_locks)
    {
      gbp_fwd_dpo_db[gfd->gfd_proto] = INDEX_INVALID;
      pool_put (gbp_fwd_dpo_pool, gfd);
    }
}

void
gbp_fwd_dpo_add_or_lock (dpo_proto_t dproto, dpo_id_t * dpo)
{
  gbp_fwd_dpo_t *gfd;

  if (INDEX_INVALID == gbp_fwd_dpo_db[dproto])
    {
      gfd = gbp_fwd_dpo_alloc ();

      gfd->gfd_proto = dproto;

      gbp_fwd_dpo_db[dproto] = gbp_fwd_dpo_get_index (gfd);
    }
  else
    {
      gfd = gbp_fwd_dpo_get (gbp_fwd_dpo_db[dproto]);
    }

  dpo_set (dpo, gbp_fwd_dpo_type, dproto, gbp_fwd_dpo_get_index (gfd));
}

u8 *
format_gbp_fwd_dpo (u8 * s, va_list * ap)
{
  index_t index = va_arg (*ap, index_t);
  CLIB_UNUSED (u32 indent) = va_arg (*ap, u32);
  gbp_fwd_dpo_t *gfd = gbp_fwd_dpo_get (index);

  return (format (s, "gbp-fwd-dpo: %U", format_dpo_proto, gfd->gfd_proto));
}

const static dpo_vft_t gbp_fwd_dpo_vft = {
  .dv_lock = gbp_fwd_dpo_lock,
  .dv_unlock = gbp_fwd_dpo_unlock,
  .dv_format = format_gbp_fwd_dpo,
};

/**
 * @brief The per-protocol VLIB graph nodes that are assigned to a glean
 *        object.
 *
 * this means that these graph nodes are ones from which a glean is the
 * parent object in the DPO-graph.
 */
const static char *const gbp_fwd_dpo_ip4_nodes[] = {
  "ip4-gbp-fwd-dpo",
  NULL,
};

const static char *const gbp_fwd_dpo_ip6_nodes[] = {
  "ip6-gbp-fwd-dpo",
  NULL,
};

const static char *const *const gbp_fwd_dpo_nodes[DPO_PROTO_NUM] = {
  [DPO_PROTO_IP4] = gbp_fwd_dpo_ip4_nodes,
  [DPO_PROTO_IP6] = gbp_fwd_dpo_ip6_nodes,
};

dpo_type_t
gbp_fwd_dpo_get_type (void)
{
  return (gbp_fwd_dpo_type);
}

static clib_error_t *
gbp_fwd_dpo_module_init (vlib_main_t * vm)
{
  dpo_proto_t dproto;

  FOR_EACH_DPO_PROTO (dproto)
  {
    gbp_fwd_dpo_db[dproto] = INDEX_INVALID;
  }

  gbp_fwd_dpo_type = dpo_register_new_type (&gbp_fwd_dpo_vft,
					    gbp_fwd_dpo_nodes);

  return (NULL);
}

VLIB_INIT_FUNCTION (gbp_fwd_dpo_module_init);

typedef struct gbp_fwd_dpo_trace_t_
{
  u32 src_epg;
  u32 dpo_index;
} gbp_fwd_dpo_trace_t;

typedef enum
{
  GBP_FWD_DROP,
  GBP_FWD_FWD,
  GBP_FWD_N_NEXT,
} gbp_fwd_next_t;

always_inline uword
gbp_fwd_dpo_inline (vlib_main_t * vm,
		    vlib_node_runtime_t * node,
		    vlib_frame_t * from_frame, fib_protocol_t fproto)
{
  u32 n_left_from, next_index, *from, *to_next;

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

  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      u32 n_left_to_next;

      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      while (n_left_from > 0 && n_left_to_next > 0)
	{
	  const dpo_id_t *next_dpo0;
	  vlib_buffer_t *b0;
	  epg_id_t src_epg0;
	  u32 bi0, next0;

	  bi0 = from[0];
	  to_next[0] = bi0;
	  from += 1;
	  to_next += 1;
	  n_left_from -= 1;
	  n_left_to_next -= 1;

	  b0 = vlib_get_buffer (vm, bi0);

	  src_epg0 = vnet_buffer2 (b0)->gbp.src_epg;
	  next_dpo0 = gbp_epg_dpo_lookup (src_epg0, fproto);

	  if (PREDICT_TRUE (NULL != next_dpo0))
	    {
	      vnet_buffer (b0)->ip.adj_index[VLIB_TX] = next_dpo0->dpoi_index;
	      next0 = GBP_FWD_FWD;
	    }
	  else
	    {
	      next0 = GBP_FWD_DROP;
	    }

	  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
	    {
	      gbp_fwd_dpo_trace_t *tr;

	      tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
	      tr->src_epg = src_epg0;
	      tr->dpo_index = (NULL != next_dpo0 ?
			       next_dpo0->dpoi_index : ~0);
	    }

	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
					   n_left_to_next, bi0, next0);
	}
      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
    }
  return from_frame->n_vectors;
}

static u8 *
format_gbp_fwd_dpo_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 *);
  gbp_fwd_dpo_trace_t *t = va_arg (*args, gbp_fwd_dpo_trace_t *);

  s = format (s, " epg:%d dpo:%d", t->src_epg, t->dpo_index);

  return s;
}

static uword
ip4_gbp_fwd_dpo (vlib_main_t * vm,
		 vlib_node_runtime_t * node, vlib_frame_t * from_frame)
{
  return (gbp_fwd_dpo_inline (vm, node, from_frame, FIB_PROTOCOL_IP4));
}

static uword
ip6_gbp_fwd_dpo (vlib_main_t * vm,
		 vlib_node_runtime_t * node, vlib_frame_t * from_frame)
{
  return (gbp_fwd_dpo_inline (vm, node, from_frame, FIB_PROTOCOL_IP6));
}

/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip4_gbp_fwd_dpo_node) = {
    .function = ip4_gbp_fwd_dpo,
    .name = "ip4-gbp-fwd-dpo",
    .vector_size = sizeof (u32),
    .format_trace = format_gbp_fwd_dpo_trace,
    .n_next_nodes = GBP_FWD_N_NEXT,
    .next_nodes =
    {
        [GBP_FWD_DROP] = "ip4-drop",
        [GBP_FWD_FWD] = "ip4-dvr-dpo",
    }
};
VLIB_REGISTER_NODE (ip6_gbp_fwd_dpo_node) = {
    .function = ip6_gbp_fwd_dpo,
    .name = "ip6-gbp-fwd-dpo",
    .vector_size = sizeof (u32),
    .format_trace = format_gbp_fwd_dpo_trace,
    .n_next_nodes = GBP_FWD_N_NEXT,
    .next_nodes =
    {
        [GBP_FWD_DROP] = "ip6-drop",
        [GBP_FWD_FWD] = "ip6-dvr-dpo",
    }
};

VLIB_NODE_FUNCTION_MULTIARCH (ip4_gbp_fwd_dpo_node, ip4_gbp_fwd_dpo)
VLIB_NODE_FUNCTION_MULTIARCH (ip6_gbp_fwd_dpo_node, ip6_gbp_fwd_dpo)
/* *INDENT-ON* */

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