FD.io VPP  v16.09
Vector Packet Processing
interface.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * ethernet_interface.c: ethernet interfaces
17  *
18  * Copyright (c) 2008 Eliot Dresselhaus
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining
21  * a copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be
29  * included in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 #include <vnet/vnet.h>
41 #include <vnet/ip/ip.h>
42 #include <vnet/pg/pg.h>
43 #include <vnet/ethernet/ethernet.h>
44 #include <vnet/l2/l2_input.h>
45 
46 /**
47  * @file
48  * @brief Loopback Interfaces.
49  *
50  * This file contains code to manage loopback interfaces.
51  */
52 
53 static uword
55  u32 sw_if_index,
56  u32 l3_type,
57  void *dst_address,
58  void *rewrite, uword max_rewrite_bytes)
59 {
60  vnet_sw_interface_t *sub_sw = vnet_get_sw_interface (vnm, sw_if_index);
61  vnet_sw_interface_t *sup_sw = vnet_get_sup_sw_interface (vnm, sw_if_index);
62  vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
65  ethernet_header_t *h = rewrite;
67  uword n_bytes = sizeof (h[0]);
68 
69  if (sub_sw != sup_sw)
70  {
71  if (sub_sw->sub.eth.flags.one_tag)
72  {
73  n_bytes += sizeof (ethernet_vlan_header_t);
74  }
75  else if (sub_sw->sub.eth.flags.two_tags)
76  {
77  n_bytes += 2 * (sizeof (ethernet_vlan_header_t));
78  }
79  // Check for encaps that are not supported for L3 interfaces
80  if (!(sub_sw->sub.eth.flags.exact_match) ||
81  (sub_sw->sub.eth.flags.default_sub) ||
82  (sub_sw->sub.eth.flags.outer_vlan_id_any) ||
83  (sub_sw->sub.eth.flags.inner_vlan_id_any))
84  {
85  return 0;
86  }
87  }
88 
89  if (n_bytes > max_rewrite_bytes)
90  return 0;
91 
92  switch (l3_type)
93  {
94 #define _(a,b) case VNET_L3_PACKET_TYPE_##a: type = ETHERNET_TYPE_##b; break
95  _(IP4, IP4);
96  _(IP6, IP6);
97  _(MPLS_UNICAST, MPLS_UNICAST);
98  _(MPLS_MULTICAST, MPLS_MULTICAST);
99  _(ARP, ARP);
100 #undef _
101  default:
102  return 0;
103  }
104 
105  ei = pool_elt_at_index (em->interfaces, hw->hw_instance);
106  clib_memcpy (h->src_address, ei->address, sizeof (h->src_address));
107  if (dst_address)
108  clib_memcpy (h->dst_address, dst_address, sizeof (h->dst_address));
109  else
110  memset (h->dst_address, ~0, sizeof (h->dst_address)); /* broadcast */
111 
112  if (sub_sw->sub.eth.flags.one_tag)
113  {
114  ethernet_vlan_header_t *outer = (void *) (h + 1);
115 
116  h->type = sub_sw->sub.eth.flags.dot1ad ?
117  clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
118  clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
119  outer->priority_cfi_and_id =
120  clib_host_to_net_u16 (sub_sw->sub.eth.outer_vlan_id);
121  outer->type = clib_host_to_net_u16 (type);
122 
123  }
124  else if (sub_sw->sub.eth.flags.two_tags)
125  {
126  ethernet_vlan_header_t *outer = (void *) (h + 1);
127  ethernet_vlan_header_t *inner = (void *) (outer + 1);
128 
129  h->type = sub_sw->sub.eth.flags.dot1ad ?
130  clib_host_to_net_u16 (ETHERNET_TYPE_DOT1AD) :
131  clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
132  outer->priority_cfi_and_id =
133  clib_host_to_net_u16 (sub_sw->sub.eth.outer_vlan_id);
134  outer->type = clib_host_to_net_u16 (ETHERNET_TYPE_VLAN);
135  inner->priority_cfi_and_id =
136  clib_host_to_net_u16 (sub_sw->sub.eth.inner_vlan_id);
137  inner->type = clib_host_to_net_u16 (type);
138 
139  }
140  else
141  {
142  h->type = clib_host_to_net_u16 (type);
143  }
144 
145  return n_bytes;
146 }
147 
148 /* *INDENT-OFF* */
150  .name = "Ethernet",
151  .format_address = format_ethernet_address,
152  .format_header = format_ethernet_header_with_length,
153  .unformat_hw_address = unformat_ethernet_address,
154  .unformat_header = unformat_ethernet_header,
155  .set_rewrite = ethernet_set_rewrite,
156 };
157 /* *INDENT-ON* */
158 
159 uword
161 {
162  vnet_main_t *vnm = va_arg (*args, vnet_main_t *);
163  u32 *result = va_arg (*args, u32 *);
164  u32 hw_if_index;
167 
168  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
169  return 0;
170 
171  eif = ethernet_get_interface (em, hw_if_index);
172  if (eif)
173  {
174  *result = hw_if_index;
175  return 1;
176  }
177  return 0;
178 }
179 
180 clib_error_t *
182  u32 dev_class_index,
183  u32 dev_instance,
184  u8 * address,
185  u32 * hw_if_index_return,
187 {
191  clib_error_t *error = 0;
192  u32 hw_if_index;
193 
194  pool_get (em->interfaces, ei);
195  ei->flag_change = flag_change;
196 
197  hw_if_index = vnet_register_interface
198  (vnm,
199  dev_class_index, dev_instance,
200  ethernet_hw_interface_class.index, ei - em->interfaces);
201  *hw_if_index_return = hw_if_index;
202 
203  hi = vnet_get_hw_interface (vnm, hw_if_index);
204 
206 
212  /* preamble */ 8 + /* inter frame gap */ 12;
213 
214  /* Standard default ethernet MTU. */
216 
217  clib_memcpy (ei->address, address, sizeof (ei->address));
218  vec_free (hi->hw_address);
219  vec_add (hi->hw_address, address, sizeof (ei->address));
220 
221  if (error)
222  {
223  pool_put (em->interfaces, ei);
224  return error;
225  }
226  return error;
227 }
228 
229 void
231 {
235  main_intf_t *main_intf;
236  vlan_table_t *vlan_table;
237  u32 idx;
238 
239  hi = vnet_get_hw_interface (vnm, hw_if_index);
240  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
241 
242  /* Delete vlan mapping table for dot1q and dot1ad. */
243  main_intf = vec_elt_at_index (em->main_intfs, hi->hw_if_index);
244  if (main_intf->dot1q_vlans)
245  {
246  vlan_table = vec_elt_at_index (em->vlan_pool, main_intf->dot1q_vlans);
247  for (idx = 0; idx < ETHERNET_N_VLAN; idx++)
248  {
249  if (vlan_table->vlans[idx].qinqs)
250  {
251  pool_put_index (em->qinq_pool, vlan_table->vlans[idx].qinqs);
252  }
253  }
254  pool_put_index (em->vlan_pool, main_intf->dot1q_vlans);
255  }
256  if (main_intf->dot1ad_vlans)
257  {
258  vlan_table = vec_elt_at_index (em->vlan_pool, main_intf->dot1ad_vlans);
259  for (idx = 0; idx < ETHERNET_N_VLAN; idx++)
260  {
261  if (vlan_table->vlans[idx].qinqs)
262  {
263  pool_put_index (em->qinq_pool, vlan_table->vlans[idx].qinqs);
264  }
265  }
266  pool_put_index (em->vlan_pool, main_intf->dot1ad_vlans);
267  }
268 
269  vnet_delete_hw_interface (vnm, hw_if_index);
270  pool_put (em->interfaces, ei);
271 }
272 
273 u32
275 {
279 
280  hi = vnet_get_hw_interface (vnm, hw_if_index);
281 
283 
284  ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
285  if (ei->flag_change)
286  return ei->flag_change (vnm, hi, flags);
287  return (u32) ~ 0;
288 }
289 
290 /* Echo packets back to ethernet/l2-input. */
291 static uword
293  vlib_node_runtime_t * node,
294  vlib_frame_t * frame)
295 {
296  u32 n_left_from, n_left_to_next, n_copy, *from, *to_next;
298  u32 i, next_node_index, bvi_flag, sw_if_index;
299  u32 n_pkts = 0, n_bytes = 0;
300  u32 cpu_index = vm->cpu_index;
301  vnet_main_t *vnm = vnet_get_main ();
303  vlib_node_main_t *nm = &vm->node_main;
304  vlib_node_t *loop_node;
305  vlib_buffer_t *b;
306 
307  // check tx node index, it is ethernet-input on loopback create
308  // but can be changed to l2-input if loopback is configured as
309  // BVI of a BD (Bridge Domain).
310  loop_node = vec_elt (nm->nodes, node->node_index);
311  next_node_index = loop_node->next_nodes[next_index];
312  bvi_flag = (next_node_index == l2input_node.index) ? 1 : 0;
313 
314  n_left_from = frame->n_vectors;
315  from = vlib_frame_args (frame);
316 
317  while (n_left_from > 0)
318  {
319  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
320 
321  n_copy = clib_min (n_left_from, n_left_to_next);
322 
323  clib_memcpy (to_next, from, n_copy * sizeof (from[0]));
324  n_left_to_next -= n_copy;
325  n_left_from -= n_copy;
326  i = 0;
327  b = vlib_get_buffer (vm, from[i]);
328  sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_TX];
329  while (1)
330  {
331  // Set up RX and TX indices as if received from a real driver
332  // unless loopback is used as a BVI. For BVI case, leave TX index
333  // and update l2_len in packet as required for l2 forwarding path
334  vnet_buffer (b)->sw_if_index[VLIB_RX] = sw_if_index;
335  if (bvi_flag)
336  vnet_update_l2_len (b);
337  else
338  vnet_buffer (b)->sw_if_index[VLIB_TX] = (u32) ~ 0;
339 
340  i++;
341  n_pkts++;
342  n_bytes += vlib_buffer_length_in_chain (vm, b);
343 
344  if (i < n_copy)
345  b = vlib_get_buffer (vm, from[i]);
346  else
347  break;
348  }
349 
350  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
351 
352  /* increment TX interface stat */
354  VNET_INTERFACE_COUNTER_TX, cpu_index,
355  sw_if_index, n_pkts, n_bytes);
356  }
357 
358  return n_left_from;
359 }
360 
361 static u8 *
362 format_simulated_ethernet_name (u8 * s, va_list * args)
363 {
364  u32 dev_instance = va_arg (*args, u32);
365  return format (s, "loop%d", dev_instance);
366 }
367 
368 static clib_error_t *
370  u32 flags)
371 {
372  u32 hw_flags = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
374  vnet_hw_interface_set_flags (vnm, hw_if_index, hw_flags);
375  return 0;
376 }
377 
378 /* *INDENT-OFF* */
379 VNET_DEVICE_CLASS (ethernet_simulated_device_class) = {
380  .name = "Loopback",
381  .format_device_name = format_simulated_ethernet_name,
382  .tx_function = simulated_ethernet_interface_tx,
383  .admin_up_down_function = simulated_ethernet_admin_up_down,
384  .no_flatten_output_chains = 1,
385 };
386 /* *INDENT-ON* */
387 
388 int
389 vnet_create_loopback_interface (u32 * sw_if_indexp, u8 * mac_address)
390 {
391  vnet_main_t *vnm = vnet_get_main ();
392  vlib_main_t *vm = vlib_get_main ();
393  clib_error_t *error;
394  static u32 instance;
395  u8 address[6];
396  u32 hw_if_index;
397  vnet_hw_interface_t *hw_if;
398  u32 slot;
399  int rv = 0;
400 
401  ASSERT (sw_if_indexp);
402 
403  *sw_if_indexp = (u32) ~ 0;
404 
405  memset (address, 0, sizeof (address));
406 
407  /*
408  * Default MAC address (dead:0000:0000 + instance) is allocated
409  * if zero mac_address is configured. Otherwise, user-configurable MAC
410  * address is programmed on the loopback interface.
411  */
412  if (memcmp (address, mac_address, sizeof (address)))
413  clib_memcpy (address, mac_address, sizeof (address));
414  else
415  {
416  address[0] = 0xde;
417  address[1] = 0xad;
418  address[5] = instance;
419  }
420 
422  (vnm,
423  ethernet_simulated_device_class.index, instance++, address, &hw_if_index,
424  /* flag change */ 0);
425 
426  if (error)
427  {
428  rv = VNET_API_ERROR_INVALID_REGISTRATION;
429  clib_error_report (error);
430  return rv;
431  }
432 
433  hw_if = vnet_get_hw_interface (vnm, hw_if_index);
435  (vm, hw_if->tx_node_index,
438 
439  {
440  vnet_sw_interface_t *si = vnet_get_hw_sw_interface (vnm, hw_if_index);
441  *sw_if_indexp = si->sw_if_index;
442  }
443 
444  return 0;
445 }
446 
447 static clib_error_t *
449  unformat_input_t * input,
450  vlib_cli_command_t * cmd)
451 {
452  int rv;
453  u32 sw_if_index;
454  u8 mac_address[6];
455 
456  memset (mac_address, 0, sizeof (mac_address));
457 
459  {
460  if (unformat (input, "mac %U", unformat_ethernet_address, mac_address))
461  ;
462  else
463  break;
464  }
465 
466  rv = vnet_create_loopback_interface (&sw_if_index, mac_address);
467 
468  if (rv)
469  return clib_error_return (0, "vnet_create_loopback_interface failed");
470 
472  sw_if_index);
473  return 0;
474 }
475 
476 /*?
477  * Create a loopback interface. Optionally, a MAC Address can be
478  * provided. If not provided, de:ad:00:00:00:<loopId> will be used.
479  *
480  * @cliexpar
481  * The following two command syntaxes are equivalent:
482  * @cliexcmd{loopback create-interface [mac <mac-addr>]}
483  * @cliexcmd{create loopback interface [mac <mac-addr>]}
484  * Example of how to create a loopback interface:
485  * @cliexcmd{loopback create-interface}
486 ?*/
487 /* *INDENT-OFF* */
488 VLIB_CLI_COMMAND (create_simulated_ethernet_interface_command, static) = {
489  .path = "loopback create-interface",
490  .short_help = "loopback create-interface [mac <mac-addr>]",
492 };
493 /* *INDENT-ON* */
494 
495 /*?
496  * Create a loopback interface. Optionally, a MAC Address can be
497  * provided. If not provided, de:ad:00:00:00:<loopId> will be used.
498  *
499  * @cliexpar
500  * The following two command syntaxes are equivalent:
501  * @cliexcmd{loopback create-interface [mac <mac-addr>]}
502  * @cliexcmd{create loopback interface [mac <mac-addr>]}
503  * Example of how to create a loopback interface:
504  * @cliexcmd{create loopback interface}
505 ?*/
506 /* *INDENT-OFF* */
507 VLIB_CLI_COMMAND (create_loopback_interface_command, static) = {
508  .path = "create loopback interface",
509  .short_help = "create loopback interface [mac <mac-addr>]",
511 };
512 /* *INDENT-ON* */
513 
516 {
518  vnet_get_hw_interface (vnet_get_main (), hw_if_index);
519  return (i->hw_class_index ==
521  index ? pool_elt_at_index (em->interfaces, i->hw_instance) : 0);
522 }
523 
524 int
526 {
527  vnet_main_t *vnm = vnet_get_main ();
529 
530  if (pool_is_free_index (vnm->interface_main.sw_interfaces, sw_if_index))
531  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
532 
533  si = vnet_get_sw_interface (vnm, sw_if_index);
535 
536  return 0;
537 }
538 
539 static clib_error_t *
541  unformat_input_t * input,
542  vlib_cli_command_t * cmd)
543 {
544  int rv;
545  u32 sw_if_index = ~0;
546  vnet_main_t *vnm = vnet_get_main ();
547 
549  {
550  if (unformat (input, "intfc %U",
551  unformat_vnet_sw_interface, vnm, &sw_if_index))
552  ;
553  else
554  break;
555  }
556 
557  if (sw_if_index == ~0)
558  return clib_error_return (0, "interface not specified");
559 
560  rv = vnet_delete_loopback_interface (sw_if_index);
561 
562  if (rv)
563  return clib_error_return (0, "vnet_delete_loopback_interface failed");
564 
565  return 0;
566 }
567 
568 /*?
569  * Delete a loopback interface.
570  *
571  * @cliexpar
572  * The following two command syntaxes are equivalent:
573  * @cliexcmd{loopback delete-interface intfc <interface>}
574  * @cliexcmd{delete loopback interface intfc <interface>}
575  * Example of how to delete a loopback interface:
576  * @cliexcmd{loopback delete-interface intfc loop0}
577 ?*/
578 /* *INDENT-OFF* */
579 VLIB_CLI_COMMAND (delete_simulated_ethernet_interface_command, static) = {
580  .path = "loopback delete-interface",
581  .short_help = "loopback delete-interface intfc <interface>",
583 };
584 /* *INDENT-ON* */
585 
586 /*?
587  * Delete a loopback interface.
588  *
589  * @cliexpar
590  * The following two command syntaxes are equivalent:
591  * @cliexcmd{loopback delete-interface intfc <interface>}
592  * @cliexcmd{delete loopback interface intfc <interface>}
593  * Example of how to delete a loopback interface:
594  * @cliexcmd{delete loopback interface intfc loop0}
595 ?*/
596 /* *INDENT-OFF* */
597 VLIB_CLI_COMMAND (delete_loopback_interface_command, static) = {
598  .path = "delete loopback interface",
599  .short_help = "delete loopback interface intfc <interface>",
601 };
602 /* *INDENT-ON* */
603 
604 /*
605  * fd.io coding-style-patch-verification: ON
606  *
607  * Local Variables:
608  * eval: (c-set-style "gnu")
609  * End:
610  */
unformat_function_t unformat_vnet_hw_interface
u32 * next_nodes
Definition: node.h:288
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:457
vmrglw vmrglh hi
int vnet_delete_loopback_interface(u32 sw_if_index)
Definition: interface.c:525
#define ETHERNET_N_VLAN
Definition: packet.h:88
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:343
#define clib_min(x, y)
Definition: clib.h:326
static clib_error_t * delete_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface.c:540
uword unformat(unformat_input_t *i, char *fmt,...)
Definition: unformat.c:966
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:513
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
Definition: vnet.h:64
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
ethernet_type_t
Definition: packet.h:43
static uword ethernet_set_rewrite(vnet_main_t *vnm, u32 sw_if_index, u32 l3_type, void *dst_address, void *rewrite, uword max_rewrite_bytes)
Definition: interface.c:54
u8 src_address[6]
Definition: packet.h:54
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
vlib_node_registration_t l2input_node
(constructor) VLIB_REGISTER_NODE (l2input_node)
Definition: l2_input.c:439
struct vnet_sub_interface_t::@120::@121::@123 flags
main_intf_t * main_intfs
Definition: ethernet.h:225
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
#define clib_error_report(e)
Definition: error.h:125
#define VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:273
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:112
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:200
format_function_t format_vnet_sw_if_index_name
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:559
ethernet_main_t ethernet_main
Definition: ethernet.h:241
vnet_main_t * vnet_get_main(void)
Definition: misc.c:45
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:501
u8 dst_address[6]
Definition: packet.h:53
vlib_node_t ** nodes
Definition: node.h:633
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vnet_sw_interface_t * vnet_get_sup_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
u32 cpu_index
Definition: main.h:159
ethernet_flag_change_function_t * flag_change
Definition: ethernet.h:95
static clib_error_t * simulated_ethernet_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:369
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:977
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
Definition: interface.c:650
u32 max_supported_packet_bytes
Definition: interface.h:331
u16 dot1q_vlans
Definition: ethernet.h:158
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
vnet_sub_interface_t sub
Definition: interface.h:447
vlib_main_t * vlib_main
Definition: vnet.h:80
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:214
u16 dot1ad_vlans
Definition: ethernet.h:159
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:348
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:575
vnet_hw_interface_class_t ethernet_hw_interface_class
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
Definition: interface.c:160
static clib_error_t * create_simulated_ethernet_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface.c:448
u8 * format_ethernet_header_with_length(u8 *s, va_list *args)
Definition: format.c:91
VNET_HW_INTERFACE_CLASS(ethernet_hw_interface_class)
u16 n_vectors
Definition: node.h:344
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
#define clib_memcpy(a, b, c)
Definition: string.h:63
#define VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:211
int vnet_create_loopback_interface(u32 *sw_if_indexp, u8 *mac_address)
Definition: interface.c:389
struct vnet_sub_interface_t::@120 eth
static u8 * format_simulated_ethernet_name(u8 *s, va_list *args)
Definition: interface.c:362
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:230
static uword simulated_ethernet_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: interface.c:292
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:415
u32 max_l3_packet_bytes[VLIB_N_RX_TX]
Definition: interface.h:345
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
Definition: format.c:206
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 cpu_index, u32 index, u32 packet_increment, u32 byte_increment)
Increment a combined counter.
Definition: counter.h:241
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:228
vlan_table_t * vlan_pool
Definition: ethernet.h:228
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:335
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:181
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
u32( ethernet_flag_change_function_t)(vnet_main_t *vnm, struct vnet_hw_interface_t *hi, u32 flags)
Definition: ethernet.h:75
static void * vlib_frame_args(vlib_frame_t *f)
Get pointer to frame scalar data.
Definition: node_funcs.h:268
vlan_intf_t vlans[ETHERNET_N_VLAN]
Definition: ethernet.h:171
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:827
u64 uword
Definition: types.h:112
#define vec_elt(v, i)
Get vector value at index i.
Definition: defs.h:47
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
unsigned char u8
Definition: types.h:56
static void vnet_update_l2_len(vlib_buffer_t *b)
Definition: l2_input.h:230
vlib_node_main_t node_main
Definition: main.h:115
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:492
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:274
Definition: lisp_types.h:24
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u32 min_supported_packet_bytes
Definition: interface.h:328
qinq_table_t * qinq_pool
Definition: ethernet.h:231
#define ETHERNET_MAX_PACKET_BYTES
Definition: ethernet.h:78
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:515
u32 per_packet_overhead_bytes
Definition: interface.h:342
#define clib_error_return(e, args...)
Definition: error.h:111
VNET_DEVICE_CLASS(ethernet_simulated_device_class)
struct _unformat_input_t unformat_input_t
uword vlib_node_add_named_next_with_slot(vlib_main_t *vm, uword node, char *name, uword slot)
Definition: node.c:213
u32 flags
Definition: vhost-user.h:76
Definition: lisp_types.h:25
ethernet_interface_t * interfaces
Definition: ethernet.h:216
#define ETHERNET_MIN_PACKET_BYTES
Definition: ethernet.h:77
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69
static void ethernet_setup_node(vlib_main_t *vm, u32 node_index)
Definition: ethernet.h:302
Definition: defs.h:46
uword unformat_ethernet_header(unformat_input_t *input, va_list *args)
Definition: format.c:256