summaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp.c
AgeCommit message (Expand)AuthorFilesLines
2020-01-16udp: fix ipv6 listen port registrationFlorin Coras1-1/+1
2020-01-02session: fix listener global endpoint lookupFlorin Coras1-0/+3
2019-10-01session: fix use-after-freeBenoƮt Ganne1-1/+2
2019-07-22udp: support close with dataFlorin Coras1-13/+30
2019-07-12quic: fix show session verboseAloys Augustin1-3/+3
2019-07-12session: add thread index to all formattersAloys Augustin1-0/+2
2019-07-09udp: UDPC handle open failNathan Skrzypczak1-6/+9
2019-06-28session: add half_open_has_fifos for UDPCNathan Skrzypczak1-0/+1
2019-06-27session: Add transport vft protocol optionsNathan Skrzypczak1-7/+14
2019-05-22fix show session verbose crash with udp transportDave Wallace1-0/+2
2019-05-16init / exit function orderingDave Barach1-10/+9
2019-05-14Unregister UDPC port only when ownedNathan Skrzypczak1-2/+5
2019-05-03Add packet headers in UDPC fifosAloys Augustin1-1/+1
2019-04-24UDPC: Fix open segfault with multiple workersAloys Augustin1-1/+3
2019-04-08host stack: update stale copyrightFlorin Coras1-1/+1
2019-03-06udp: migrate old MULTIARCH macros to VLIB_NODE_FNFilip Tehlar1-0/+2
2019-02-06transport: cleanupFlorin Coras1-6/+6
2018-12-28session: free session after transport and app confirmFlorin Coras1-1/+1
2018-12-07VPP-1506: dump local punts and registered punt socketsPavel Kotucek1-0/+60
2018-10-28session: extend connect api for internal appsFlorin Coras1-2/+2
2018-10-23c11 safe string handling supportDave Barach1-3/+3
2018-07-11avoid using thread local storage for thread indexDamjan Marion1-1/+1
2018-06-11udp: fix for multiple workers and add testFlorin Coras1-4/+12
2018-04-18udp/session: refactor to support dgram modeFlorin Coras1-3/+53
2018-03-02session: first approximation implementation of tlsFlorin Coras1-1/+3
2017-12-11session: generalize handling of network transportsFlorin Coras1-3/+4
2017-11-02session/udp: init rw locksFlorin Coras1-0/+8
2017-10-16udp: refactor udp codeFlorin Coras1-177/+216
2017-09-20session: store tep port in net orderFlorin Coras1-5/+5
2017-07-30Make tcp active open data structures thread safeFlorin Coras1-4/+4
2017-07-25Cleanup/refactor session layer codeFlorin Coras1-12/+10
2017-03-13VPP-659 Improve tcp/session debugging and testingFlorin Coras1-4/+6
2017-03-01VPP-598: tcp stack initial commitDave Barach1-0/+342
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 */ }
/*
 * vnet/pipeline.h: software pipeline
 *
 * Copyright (c) 2012 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.
 */

/*
 * Usage example.
 *
 * #define NSTAGES 3 or whatever
 *
 * <Define pipeline stages>
 *
 * #include <vnet/pipeline.h>
 *
 * static uword my_node_fn (vlib_main_t * vm,
 *                               vlib_node_runtime_t * node,
 *                               vlib_frame_t * frame)
 * {
 *     return dispatch_pipeline (vm, node, frame);
 * }
 *
 */

#ifndef NSTAGES
#error files which #include <vnet/pipeline.h> must define NSTAGES
#endif

#ifndef STAGE_INLINE
#define STAGE_INLINE inline
#endif

/*
 * A prefetch stride of 2 is quasi-equivalent to doubling the number
 * of stages with every other pipeline stage empty.
 */

/*
 * This is a typical first pipeline stage, which prefetches
 * buffer metadata and the first line of pkt data.
 * To use it:
 *  #define stage0 generic_stage0
 */
static STAGE_INLINE void
generic_stage0 (vlib_main_t * vm,
		vlib_node_runtime_t * node, u32 buffer_index)
{
  /* generic default stage 0 here */
  vlib_buffer_t *b = vlib_get_buffer (vm, buffer_index);
  vlib_prefetch_buffer_header (b, STORE);
  CLIB_PREFETCH (b->data, CLIB_CACHE_LINE_BYTES, STORE);
}

#if NSTAGES == 2

static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
		   vlib_node_runtime_t * node, vlib_frame_t * frame)
{
  u32 *from = vlib_frame_vector_args (frame);
  u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
  int pi, pi_limit;

  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      pi_limit = clib_min (n_left_from, n_left_to_next);

      for (pi = 0; pi < NSTAGES - 1; pi++)
	{
	  if (pi == pi_limit)
	    break;
	  stage0 (vm, node, from[pi]);
	}

      for (; pi < pi_limit; pi++)
	{
	  stage0 (vm, node, from[pi]);
	  to_next[0] = from[pi - 1];
	  to_next++;
	  n_left_to_next--;
	  next0 = last_stage (vm, node, from[pi - 1]);
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   from[pi - 1], next0);
	  n_left_from--;
	  if ((int) n_left_to_next < 0 && n_left_from > 0)
	    vlib_get_next_frame (vm, node, next_index, to_next,
				 n_left_to_next);
	}

      for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
	{
	  if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
	    {
	      to_next[0] = from[pi - 1];
	      to_next++;
	      n_left_to_next--;
	      next0 = last_stage (vm, node, from[pi - 1]);
	      vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					       to_next, n_left_to_next,
					       from[pi - 1], next0);
	      n_left_from--;
	      if ((int) n_left_to_next < 0 && n_left_from > 0)
		vlib_get_next_frame (vm, node, next_index, to_next,
				     n_left_to_next);
	    }
	}
      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      from += pi_limit;
    }
  return frame->n_vectors;
}
#endif

#if NSTAGES == 3
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
		   vlib_node_runtime_t * node, vlib_frame_t * frame)
{
  u32 *from = vlib_frame_vector_args (frame);
  u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
  int pi, pi_limit;

  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      pi_limit = clib_min (n_left_from, n_left_to_next);

      for (pi = 0; pi < NSTAGES - 1; pi++)
	{
	  if (pi == pi_limit)
	    break;
	  stage0 (vm, node, from[pi]);
	  if (pi - 1 >= 0)
	    stage1 (vm, node, from[pi - 1]);
	}

      for (; pi < pi_limit; pi++)
	{
	  stage0 (vm, node, from[pi]);
	  stage1 (vm, node, from[pi - 1]);
	  to_next[0] = from[pi - 2];
	  to_next++;
	  n_left_to_next--;
	  next0 = last_stage (vm, node, from[pi - 2]);
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   from[pi - 2], next0);
	  n_left_from--;
	  if ((int) n_left_to_next < 0 && n_left_from > 0)
	    vlib_get_next_frame (vm, node, next_index, to_next,
				 n_left_to_next);
	}


      for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
	{
	  if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
	    stage1 (vm, node, from[pi - 1]);
	  if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
	    {
	      to_next[0] = from[pi - 2];
	      to_next++;
	      n_left_to_next--;
	      next0 = last_stage (vm, node, from[pi - 2]);
	      vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					       to_next, n_left_to_next,
					       from[pi - 2], next0);
	      n_left_from--;
	      if ((int) n_left_to_next < 0 && n_left_from > 0)
		vlib_get_next_frame (vm, node, next_index, to_next,
				     n_left_to_next);
	    }
	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      from += pi_limit;
    }
  return frame->n_vectors;
}
#endif

#if NSTAGES == 4
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
		   vlib_node_runtime_t * node, vlib_frame_t * frame)
{
  u32 *from = vlib_frame_vector_args (frame);
  u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
  int pi, pi_limit;

  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      pi_limit = clib_min (n_left_from, n_left_to_next);

      for (pi = 0; pi < NSTAGES - 1; pi++)
	{
	  if (pi == pi_limit)
	    break;
	  stage0 (vm, node, from[pi]);
	  if (pi - 1 >= 0)
	    stage1 (vm, node, from[pi - 1]);
	  if (pi - 2 >= 0)
	    stage2 (vm, node, from[pi - 2]);
	}

      for (; pi < pi_limit; pi++)
	{
	  stage0 (vm, node, from[pi]);
	  stage1 (vm, node, from[pi - 1]);
	  stage2 (vm, node, from[pi - 2]);
	  to_next[0] = from[pi - 3];
	  to_next++;
	  n_left_to_next--;
	  next0 = last_stage (vm, node, from[pi - 3]);
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   from[pi - 3], next0);
	  n_left_from--;
	  if ((int) n_left_to_next < 0 && n_left_from > 0)
	    vlib_get_next_frame (vm, node, next_index, to_next,
				 n_left_to_next);
	}


      for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
	{
	  if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
	    stage1 (vm, node, from[pi - 1]);
	  if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
	    stage2 (vm, node, from[pi - 2]);
	  if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
	    {
	      to_next[0] = from[pi - 3];
	      to_next++;
	      n_left_to_next--;
	      next0 = last_stage (vm, node, from[pi - 3]);
	      vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					       to_next, n_left_to_next,
					       from[pi - 3], next0);
	      n_left_from--;
	      if ((int) n_left_to_next < 0 && n_left_from > 0)
		vlib_get_next_frame (vm, node, next_index, to_next,
				     n_left_to_next);
	    }
	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      from += pi_limit;
    }
  return frame->n_vectors;
}
#endif


#if NSTAGES == 5
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
		   vlib_node_runtime_t * node, vlib_frame_t * frame)
{
  u32 *from = vlib_frame_vector_args (frame);
  u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
  int pi, pi_limit;

  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      pi_limit = clib_min (n_left_from, n_left_to_next);

      for (pi = 0; pi < NSTAGES - 1; pi++)
	{
	  if (pi == pi_limit)
	    break;
	  stage0 (vm, node, from[pi]);
	  if (pi - 1 >= 0)
	    stage1 (vm, node, from[pi - 1]);
	  if (pi - 2 >= 0)
	    stage2 (vm, node, from[pi - 2]);
	  if (pi - 3 >= 0)
	    stage3 (vm, node, from[pi - 3]);
	}

      for (; pi < pi_limit; pi++)
	{
	  stage0 (vm, node, from[pi]);
	  stage1 (vm, node, from[pi - 1]);
	  stage2 (vm, node, from[pi - 2]);
	  stage3 (vm, node, from[pi - 3]);
	  to_next[0] = from[pi - 4];
	  to_next++;
	  n_left_to_next--;
	  next0 = last_stage (vm, node, from[pi - 4]);
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   from[pi - 4], next0);
	  n_left_from--;
	  if ((int) n_left_to_next < 0 && n_left_from > 0)
	    vlib_get_next_frame (vm, node, next_index, to_next,
				 n_left_to_next);
	}


      for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
	{
	  if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
	    stage1 (vm, node, from[pi - 1]);
	  if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
	    stage2 (vm, node, from[pi - 2]);
	  if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
	    stage3 (vm, node, from[pi - 3]);
	  if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
	    {
	      to_next[0] = from[pi - 4];
	      to_next++;
	      n_left_to_next--;
	      next0 = last_stage (vm, node, from[pi - 4]);
	      vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					       to_next, n_left_to_next,
					       from[pi - 4], next0);
	      n_left_from--;
	      if ((int) n_left_to_next < 0 && n_left_from > 0)
		vlib_get_next_frame (vm, node, next_index, to_next,
				     n_left_to_next);
	    }
	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      from += pi_limit;
    }
  return frame->n_vectors;
}
#endif

#if NSTAGES == 6
static STAGE_INLINE uword
dispatch_pipeline (vlib_main_t * vm,
		   vlib_node_runtime_t * node, vlib_frame_t * frame)
{
  u32 *from = vlib_frame_vector_args (frame);
  u32 n_left_from, n_left_to_next, *to_next, next_index, next0;
  int pi, pi_limit;

  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  while (n_left_from > 0)
    {
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      pi_limit = clib_min (n_left_from, n_left_to_next);

      for (pi = 0; pi < NSTAGES - 1; pi++)
	{
	  if (pi == pi_limit)
	    break;
	  stage0 (vm, node, from[pi]);
	  if (pi - 1 >= 0)
	    stage1 (vm, node, from[pi - 1]);
	  if (pi - 2 >= 0)
	    stage2 (vm, node, from[pi - 2]);
	  if (pi - 3 >= 0)
	    stage3 (vm, node, from[pi - 3]);
	  if (pi - 4 >= 0)
	    stage4 (vm, node, from[pi - 4]);
	}

      for (; pi < pi_limit; pi++)
	{
	  stage0 (vm, node, from[pi]);
	  stage1 (vm, node, from[pi - 1]);
	  stage2 (vm, node, from[pi - 2]);
	  stage3 (vm, node, from[pi - 3]);
	  stage4 (vm, node, from[pi - 4]);
	  to_next[0] = from[pi - 5];
	  to_next++;
	  n_left_to_next--;
	  next0 = last_stage (vm, node, from[pi - 5]);
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   from[pi - 5], next0);
	  n_left_from--;
	  if ((int) n_left_to_next < 0 && n_left_from > 0)
	    vlib_get_next_frame (vm, node, next_index, to_next,
				 n_left_to_next);
	}


      for (; pi < (pi_limit + (NSTAGES - 1)); pi++)
	{
	  if (((pi - 1) >= 0) && ((pi - 1) < pi_limit))
	    stage1 (vm, node, from[pi - 1]);
	  if (((pi - 2) >= 0) && ((pi - 2) < pi_limit))
	    stage2 (vm, node, from[pi - 2]);
	  if (((pi - 3) >= 0) && ((pi - 3) < pi_limit))
	    stage3 (vm, node, from[pi - 3]);
	  if (((pi - 4) >= 0) && ((pi - 4) < pi_limit))
	    stage4 (vm, node, from[pi - 4]);
	  if (((pi - 5) >= 0) && ((pi - 5) < pi_limit))
	    {
	      to_next[0] = from[pi - 5];
	      to_next++;
	      n_left_to_next--;
	      next0 = last_stage (vm, node, from[pi - 5]);
	      vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					       to_next, n_left_to_next,
					       from[pi - 5], next0);
	      n_left_from--;
	      if ((int) n_left_to_next < 0 && n_left_from > 0)
		vlib_get_next_frame (vm, node, next_index, to_next,
				     n_left_to_next);
	    }
	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      from += pi_limit;
    }
  return frame->n_vectors;
}
#endif

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