summaryrefslogtreecommitdiffstats
path: root/src/vnet/l2/l2_bvi_node.c
blob: dd7e1df46ced0335a3ef4d641b57467c775b6cc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * l2_bvi.c : layer 2 Bridged Virtual Interface
 *
 * Copyright (c) 2013 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 <vnet/l2/l2_bvi.h>

/**
 * send packets to l2-input.
 */
VNET_DEVICE_CLASS_TX_FN (bvi_device_class) (vlib_main_t * vm,
					    vlib_node_runtime_t * node,
					    vlib_frame_t * frame)
{
  u32 sw_if_indices[VLIB_FRAME_SIZE], *sw_if_index;
  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
  u16 nexts[VLIB_FRAME_SIZE];
  u32 n_left, *from;

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

  vlib_get_buffers (vm, from, bufs, n_left);

  b = bufs;
  sw_if_index = sw_if_indices;

  /* It's all going to l2-input */
  clib_memset_u16 (nexts, 0, VLIB_FRAME_SIZE);

  /*
   * For each packet:
   *  - fixup the L2 length of the packet
   *  - set the RX interface (which the bridge will use) to the
   *    TX interface (which routing has chosen)
   *  - Set the TX interface to the special ID so the DP knows this is a BVI
   * Don't counts packets and bytes, that's done in the bviX-output node
   */
  while (n_left >= 4)
    {
      /* Prefetch next iteration. */
      if (PREDICT_TRUE (n_left >= 8))
	{
	  /* LOAD pre-fetch since meta and packet data is read */
	  vlib_prefetch_buffer_header (b[4], LOAD);
	  vlib_prefetch_buffer_header (b[5], LOAD);
	  vlib_prefetch_buffer_header (b[6], LOAD);
	  vlib_prefetch_buffer_header (b[7], LOAD);

	  vlib_prefetch_buffer_data (b[4], LOAD);
	  vlib_prefetch_buffer_data (b[5], LOAD);
	  vlib_prefetch_buffer_data (b[6], LOAD);
	  vlib_prefetch_buffer_data (b[7], LOAD);
	}

      vnet_update_l2_len (b[0]);
      vnet_update_l2_len (b[1]);
      vnet_update_l2_len (b[2]);
      vnet_update_l2_len (b[3]);

      sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
      sw_if_index[1] = vnet_buffer (b[1])->sw_if_index[VLIB_TX];
      sw_if_index[2] = vnet_buffer (b[2])->sw_if_index[VLIB_TX];
      sw_if_index[3] = vnet_buffer (b[3])->sw_if_index[VLIB_TX];

      vnet_buffer (b[0])->sw_if_index[VLIB_TX] = L2INPUT_BVI;
      vnet_buffer (b[1])->sw_if_index[VLIB_TX] = L2INPUT_BVI;
      vnet_buffer (b[2])->sw_if_index[VLIB_TX] = L2INPUT_BVI;
      vnet_buffer (b[3])->sw_if_index[VLIB_TX] = L2INPUT_BVI;

      vnet_buffer (b[0])->sw_if_index[VLIB_RX] = sw_if_index[0];
      vnet_buffer (b[1])->sw_if_index[VLIB_RX] = sw_if_index[1];
      vnet_buffer (b[2])->sw_if_index[VLIB_RX] = sw_if_index[2];
      vnet_buffer (b[3])->sw_if_index[VLIB_RX] = sw_if_index[3];

      b += 4;
      n_left -= 4;
      sw_if_index += 4;
    }
  while (n_left)
    {
      sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
      vnet_buffer (b[0])->sw_if_index[VLIB_TX] = L2INPUT_BVI;
      vnet_buffer (b[0])->sw_if_index[VLIB_RX] = sw_if_index[0];

      vnet_update_l2_len (b[0]);

      b += 1;
      n_left -= 1;
      sw_if_index += 1;
    }

  vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);

  return frame->n_vectors;
}

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
">nic_name}= | Intel-X710 | ${nic_driver}= | vfio-pci | ${nic_rxq_size}= | 0 | ${nic_txq_size}= | 0 | ${nic_pfs}= | 2 | ${nic_vfs}= | 0 | ${osi_layer}= | L3 | ${overhead}= | ${54} | ${tg_if1_ip4}= | 192.168.10.2 | ${dut1_if1_ip4}= | 192.168.10.1 | ${dut1_if2_ip4}= | 100.0.0.1 | ${dut2_if1_ip4}= | 200.0.0.2 | ${dut2_if2_ip4}= | 192.168.20.1 | ${tg_if2_ip4}= | 192.168.20.2 | ${raddr_ip4}= | 20.0.0.0 | ${laddr_ip4}= | 10.0.0.0 | ${addr_range}= | ${24} | ${n_tunnels}= | ${5000} | ${n_added_tunnels}= | ${1} # Traffic profile: | ${traffic_profile}= | trex-stl-3n-ethip4-ip4dst${n_tunnels} *** Keywords *** | Local Template | | [Documentation] | | ... | [Cfg] DUT runs IPSec tunneling AES_128_GCM config.\ | | ... | Each DUT uses ${phy_cores} physical core(s) for worker threads. | | ... | [Ver] Measure packet loss during reconfig at NDR load.\ | | | | ... | *Arguments:* | | ... | - frame_size - Framesize in Bytes in integer or string (IMIX_v4_1). | | ... | Type: integer, string | | ... | - phy_cores - Number of physical cores. Type: integer | | ... | - rxq - Number of RX queues, default value: ${None}. Type: integer | | | | [Arguments] | ${frame_size} | ${phy_cores} | ${rxq}=${None} | | | | Set Test Variable | \${frame_size} | | | | # These are enums (not strings) so they cannot be in Variables table. | | ${encr_alg}= | Crypto Alg AES GCM 128 | | ${auth_alg}= | Set Variable | ${NONE} | | ${ipsec_proto} = | IPsec Proto ESP | | | | ${n_total_tunnels} = | Evaluate | ${n_tunnels} + ${n_added_tunnels} | | Given Set Max Rate And Jumbo | | And Add worker threads to all DUTs | ${phy_cores} | ${rxq} | | And Pre-initialize layer driver | ${nic_driver} | | And Apply startup configuration on all VPP DUTs | | When Initialize layer driver | ${nic_driver} | | And Initialize layer interface | | And Initialize IPSec in 3-node circular topology | | And VPP IPsec Create Tunnel Interfaces | | ... | ${nodes} | ${dut1_if2_ip4} | ${dut2_if1_ip4} | ${DUT1_${int}2}[0] | | ... | ${DUT2_${int}1}[0] | ${n_tunnels} | ${encr_alg} | ${auth_alg} | | ... | ${laddr_ip4} | ${raddr_ip4} | ${addr_range} | | ${bidirectional_throughput}= | Find Throughput Using MLRsearch | | ${unidirectional_throughput}= | Evaluate | ${bidirectional_throughput} / 2.0 | | Start Traffic on Background | ${unidirectional_throughput} | | And VPP IPsec Create Tunnel Interfaces | | ... | ${nodes} | ${dut1_if2_ip4} | ${dut2_if1_ip4} | ${DUT1_${int}2}[0] | | ... | ${DUT2_${int}1}[0] | ${n_total_tunnels} | ${encr_alg} | ${auth_alg} | | ... | ${laddr_ip4} | ${raddr_ip4} | ${addr_range} | ${n_tunnels} | | ${result}= | Stop Running Traffic | | Display Reconfig Test Message | ${result} *** Test Cases *** | 64B-1c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 64B | 1C | | frame_size=${64} | phy_cores=${1} | 64B-2c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 64B | 2C | | frame_size=${64} | phy_cores=${2} | 64B-4c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 64B | 4C | | frame_size=${64} | phy_cores=${4} | 1518B-1c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 1518B | 1C | | frame_size=${1518} | phy_cores=${1} | 1518B-2c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 1518B | 2C | | frame_size=${1518} | phy_cores=${2} | 1518B-4c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | 1518B | 4C | | frame_size=${1518} | phy_cores=${4} | IMIX-1c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | IMIX | 1C | | frame_size=IMIX_v4_1 | phy_cores=${1} | IMIX-2c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | IMIX | 2C | | frame_size=IMIX_v4_1 | phy_cores=${2} | IMIX-4c-ethip4ipsec5000tnlsw-1atnl-ip4base-int-aes128gcm-reconf | | [Tags] | IMIX | 4C | | frame_size=IMIX_v4_1 | phy_cores=${4}