summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-04-27 18:23:20 +0200
committerBeno�t Ganne <bganne@cisco.com>2021-05-03 13:38:09 +0000
commit94b80770ffd35c20beb303bc2a6e81b2c6163ba6 (patch)
tree785054469f52033e4e6f2c8c60de477734fc4f9c /src/plugins
parenteee099e9579083fbce665e8c4a3617b9f0e5ea2f (diff)
rdma: avoid unnencessary inlining
Type: fix Change-Id: Ifc4b30675365ebb5d69c018a34fd17a5090b30e1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/rdma/output.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/plugins/rdma/output.c b/src/plugins/rdma/output.c
index 8c267a6fb25..afc48451137 100644
--- a/src/plugins/rdma/output.c
+++ b/src/plugins/rdma/output.c
@@ -526,24 +526,12 @@ rdma_device_output_tx_try (vlib_main_t * vm, const vlib_node_runtime_t * node,
}
static_always_inline uword
-rdma_device_output_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame, rdma_device_t * rd,
- int is_mlx5dv)
+rdma_device_output_tx (vlib_main_t *vm, vlib_node_runtime_t *node,
+ rdma_device_t *rd, rdma_txq_t *txq, u32 *from,
+ u32 n_left_from, int is_mlx5dv)
{
- u32 thread_index = vm->thread_index;
- rdma_txq_t *txq =
- vec_elt_at_index (rd->txqs, thread_index % vec_len (rd->txqs));
- u32 *from;
- u32 n_left_from;
int i;
- ASSERT (RDMA_TXQ_BUF_SZ (txq) >= VLIB_FRAME_SIZE);
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
-
- clib_spinlock_lock_if_init (&txq->lock);
-
for (i = 0; i < RDMA_TX_RETRIES && n_left_from > 0; i++)
{
u32 n_enq;
@@ -555,16 +543,7 @@ rdma_device_output_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
from += n_enq;
}
- clib_spinlock_unlock_if_init (&txq->lock);
-
- if (PREDICT_FALSE (n_left_from))
- {
- vlib_buffer_free (vm, from, n_left_from);
- vlib_error_count (vm, node->node_index,
- RDMA_TX_ERROR_NO_FREE_SLOTS, n_left_from);
- }
-
- return frame->n_vectors - n_left_from;
+ return n_left_from;
}
VNET_DEVICE_CLASS_TX_FN (rdma_device_class) (vlib_main_t * vm,
@@ -574,11 +553,34 @@ VNET_DEVICE_CLASS_TX_FN (rdma_device_class) (vlib_main_t * vm,
rdma_main_t *rm = &rdma_main;
vnet_interface_output_runtime_t *ord = (void *) node->runtime_data;
rdma_device_t *rd = pool_elt_at_index (rm->devices, ord->dev_instance);
+ rdma_txq_t *txq =
+ vec_elt_at_index (rd->txqs, vm->thread_index % vec_len (rd->txqs));
+ u32 *from, n_buffers, n_left;
+
+ ASSERT (RDMA_TXQ_BUF_SZ (txq) >= VLIB_FRAME_SIZE);
+
+ from = vlib_frame_vector_args (frame);
+ n_buffers = frame->n_vectors;
+
+ clib_spinlock_lock_if_init (&txq->lock);
if (PREDICT_TRUE (rd->flags & RDMA_DEVICE_F_MLX5DV))
- return rdma_device_output_tx (vm, node, frame, rd, 1 /* is_mlx5dv */ );
+ n_left = rdma_device_output_tx (vm, node, rd, txq, from, n_buffers,
+ 1 /* is_mlx5dv */);
+ else
+ n_left = rdma_device_output_tx (vm, node, rd, txq, from, n_buffers,
+ 0 /* is_mlx5dv */);
+
+ clib_spinlock_unlock_if_init (&txq->lock);
+
+ if (PREDICT_FALSE (n_left))
+ {
+ vlib_buffer_free (vm, from + n_buffers - n_left, n_left);
+ vlib_error_count (vm, node->node_index, RDMA_TX_ERROR_NO_FREE_SLOTS,
+ n_left);
+ }
- return rdma_device_output_tx (vm, node, frame, rd, 0 /* is_mlx5dv */ );
+ return n_buffers - n_left;
}
/*
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.
 */

/**
 * @brief Handle IPv4 header options in the data-path
 */

#include <vnet/ip/ip.h>

typedef enum ip4_options_next_t_
{
  IP4_OPTIONS_NEXT_PUNT,
  IP4_OPTIONS_NEXT_LOCAL,
  IP4_OPTIONS_N_NEXT,
} ip4_options_next_t;

typedef struct ip4_options_trace_t_
{
  u8 option[4];
} ip4_options_trace_t;

VLIB_NODE_FN (ip4_options_node) (vlib_main_t * vm,
				 vlib_node_runtime_t * node,
				 vlib_frame_t * frame)
{
  uword n_left_from, n_left_to_next, next_index;
  u32 *from, *to_next;

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

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

      /*
       * IP options packets, when properly used, are very low rate,
       * so this code is not dual-looped for extra performance.
       */
      while (n_left_from > 0 && n_left_to_next > 0)
	{
	  ip4_options_next_t next;
	  ip4_header_t *ip4;
	  vlib_buffer_t *b;
	  u8 *options;
	  u32 bi;

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

	  b = vlib_get_buffer (vm, bi);
	  ip4 = vlib_buffer_get_current (b);
	  next = IP4_OPTIONS_NEXT_PUNT;

	  options = (u8 *) (ip4 + 1);

	  /*
	   * mask out the copy flag to leave the option type
	   */
	  switch (options[0] & 0x7f)
	    {
	    case IP4_ROUTER_ALERT_OPTION:
	      /*
	       * if it's an IGMP packet, pass up the local stack
	       */
	      if (IP_PROTOCOL_IGMP == ip4->protocol)
		{
		  next = IP4_OPTIONS_NEXT_LOCAL;
		}
	      break;
	    default:
	      break;
	    }

	  if (b->flags & VLIB_BUFFER_IS_TRACED)
	    {
	      ip4_options_trace_t *t =
		vlib_add_trace (vm, node, b, sizeof (*t));

	      clib_memcpy_fast (t->option, options, 4);
	    }
	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
					   n_left_to_next, bi, next);

	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
    }
  return frame->n_vectors;
}

u8 *
format_ip4_options_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 *);
  ip4_options_trace_t *t = va_arg (*args, ip4_options_trace_t *);
  u32 indent = format_get_indent (s);

  s = format (s, "%Uoption:[0x%x,0x%x,0x%x,0x%x]",
	      format_white_space, indent,
	      t->option[0], t->option[1], t->option[2], t->option[3]);
  return s;
}

/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip4_options_node) = {
  .name = "ip4-options",
  .vector_size = sizeof (u32),

  .n_next_nodes = IP4_OPTIONS_N_NEXT,
  .next_nodes = {
    [IP4_OPTIONS_NEXT_PUNT] = "ip4-punt",
    [IP4_OPTIONS_NEXT_LOCAL] = "ip4-local",
  },
  .format_buffer = format_ip4_header,
  .format_trace = format_ip4_options_trace,
};
/* *INDENT-ON* */

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