FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
interface_cli.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  * interface_cli.c: interface CLI
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 /**
41  * @file
42  * @brief Interface CLI.
43  *
44  * Source code for several CLI interface commands.
45  *
46  */
47 
48 #include <vnet/vnet.h>
49 #include <vnet/ip/ip.h>
50 #include <vppinfra/bitmap.h>
51 #include <vnet/fib/ip4_fib.h>
52 #include <vnet/fib/ip6_fib.h>
53 #include <vnet/l2/l2_output.h>
54 #include <vnet/l2/l2_input.h>
55 
56 static int
57 compare_interface_names (void *a1, void *a2)
58 {
59  u32 *hi1 = a1;
60  u32 *hi2 = a2;
61 
62  return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
63 }
64 
65 static clib_error_t *
67  unformat_input_t * input,
68  vlib_cli_command_t * cmd)
69 {
70  clib_error_t *error = 0;
71  vnet_main_t *vnm = vnet_get_main ();
74  u32 hw_if_index, *hw_if_indices = 0;
75  int i, verbose = -1, is_show, show_bond = 0;
76 
77  is_show = strstr (cmd->path, "show") != 0;
79  {
80  /* See if user wants to show a specific interface. */
81  if (unformat
82  (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
83  vec_add1 (hw_if_indices, hw_if_index);
84 
85  /* See if user wants to show an interface with a specific hw_if_index. */
86  else if (unformat (input, "%u", &hw_if_index))
87  vec_add1 (hw_if_indices, hw_if_index);
88 
89  else if (unformat (input, "verbose"))
90  verbose = 1; /* this is also the default */
91 
92  else if (unformat (input, "detail"))
93  verbose = 2;
94 
95  else if (unformat (input, "brief"))
96  verbose = 0;
97 
98  else if (unformat (input, "bond"))
99  {
100  show_bond = 1;
101  if (verbose < 0)
102  verbose = 0; /* default to brief for link bonding */
103  }
104 
105  else
106  {
107  error = clib_error_return (0, "unknown input `%U'",
108  format_unformat_error, input);
109  goto done;
110  }
111  }
112 
113  /* Gather interfaces. */
114  if (vec_len (hw_if_indices) == 0)
115  pool_foreach (hi, im->hw_interfaces,
116  vec_add1 (hw_if_indices, hi - im->hw_interfaces));
117 
118  if (verbose < 0)
119  verbose = 1; /* default to verbose (except bond) */
120 
121  if (is_show)
122  {
123  /* Sort by name. */
125 
126  vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm, 0, verbose);
127  for (i = 0; i < vec_len (hw_if_indices); i++)
128  {
129  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
130  if (show_bond == 0) /* show all interfaces */
131  vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
132  hi, verbose);
133  else if ((hi->bond_info) &&
135  { /* show only bonded interface and all its slave interfaces */
136  int hw_idx;
137  vnet_hw_interface_t *shi;
138  vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
139  hi, verbose);
140 
141  /* *INDENT-OFF* */
142  clib_bitmap_foreach (hw_idx, hi->bond_info,
143  ({
144  shi = vnet_get_hw_interface(vnm, hw_idx);
145  vlib_cli_output (vm, "%U\n",
146  format_vnet_hw_interface, vnm, shi, verbose);
147  }));
148  /* *INDENT-ON* */
149  }
150  }
151  }
152  else
153  {
154  for (i = 0; i < vec_len (hw_if_indices); i++)
155  {
157 
158  hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
160 
161  if (dc->clear_counters)
162  dc->clear_counters (hi->dev_instance);
163  }
164  }
165 
166 done:
167  vec_free (hw_if_indices);
168  return error;
169 }
170 
171 /*?
172  * Display more detailed information about all or a list of given interfaces.
173  * The verboseness of the output can be controlled by the following optional
174  * parameters:
175  * - brief: Only show name, index and state (default for bonded interfaces).
176  * - verbose: Also display additional attributes (default for all other interfaces).
177  * - detail: Also display all remaining attributes and extended statistics.
178  *
179  * To limit the output of the command to bonded interfaces and their slave
180  * interfaces, use the '<em>bond</em>' optional parameter.
181  *
182  * @cliexpar
183  * Example of how to display default data for all interfaces:
184  * @cliexstart{show hardware-interfaces}
185  * Name Idx Link Hardware
186  * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
187  * Ethernet address ec:f4:bb:c0:bc:fc
188  * Intel e1000
189  * carrier up full duplex speed 1000 mtu 9216
190  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
191  * cpu socket 0
192  * GigabitEthernet7/0/1 2 up GigabitEthernet7/0/1
193  * Ethernet address ec:f4:bb:c0:bc:fd
194  * Intel e1000
195  * carrier up full duplex speed 1000 mtu 9216
196  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
197  * cpu socket 0
198  * VirtualEthernet0/0/0 3 up VirtualEthernet0/0/0
199  * Ethernet address 02:fe:a5:a9:8b:8e
200  * VirtualEthernet0/0/1 4 up VirtualEthernet0/0/1
201  * Ethernet address 02:fe:c0:4e:3b:b0
202  * VirtualEthernet0/0/2 5 up VirtualEthernet0/0/2
203  * Ethernet address 02:fe:1f:73:92:81
204  * VirtualEthernet0/0/3 6 up VirtualEthernet0/0/3
205  * Ethernet address 02:fe:f2:25:c4:68
206  * local0 0 down local0
207  * local
208  * @cliexend
209  * Example of how to display '<em>verbose</em>' data for an interface by name and
210  * software index (where 2 is the software index):
211  * @cliexstart{show hardware-interfaces GigabitEthernet7/0/0 2 verbose}
212  * Name Idx Link Hardware
213  * GigabitEthernet7/0/0 1 up GigabitEthernet7/0/0
214  * Ethernet address ec:f4:bb:c0:bc:fc
215  * Intel e1000
216  * carrier up full duplex speed 1000 mtu 9216
217  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
218  * cpu socket 0
219  * GigabitEthernet7/0/1 2 down GigabitEthernet7/0/1
220  * Ethernet address ec:f4:bb:c0:bc:fd
221  * Intel e1000
222  * carrier up full duplex speed 1000 mtu 9216
223  * rx queues 1, rx desc 1024, tx queues 3, tx desc 1024
224  * cpu socket 0
225  * @cliexend
226  ?*/
227 /* *INDENT-OFF* */
228 VLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
229  .path = "show hardware-interfaces",
230  .short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
231  "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
232  .function = show_or_clear_hw_interfaces,
233 };
234 /* *INDENT-ON* */
235 
236 
237 /*?
238  * Clear the extended statistics for all or a list of given interfaces
239  * (statistics associated with the '<em>show hardware-interfaces</em>' command).
240  *
241  * @cliexpar
242  * Example of how to clear the extended statistics for all interfaces:
243  * @cliexcmd{clear hardware-interfaces}
244  * Example of how to clear the extended statistics for an interface by
245  * name and software index (where 2 is the software index):
246  * @cliexcmd{clear hardware-interfaces GigabitEthernet7/0/0 2}
247  ?*/
248 /* *INDENT-OFF* */
249 VLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
250  .path = "clear hardware-interfaces",
251  .short_help = "clear hardware-interfaces "
252  "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
253  .function = show_or_clear_hw_interfaces,
254 };
255 /* *INDENT-ON* */
256 
257 static int
258 sw_interface_name_compare (void *a1, void *a2)
259 {
260  vnet_sw_interface_t *si1 = a1;
261  vnet_sw_interface_t *si2 = a2;
262 
264  si1->sw_if_index, si2->sw_if_index);
265 }
266 
267 static clib_error_t *
269  unformat_input_t * input, vlib_cli_command_t * cmd)
270 {
271  clib_error_t *error = 0;
272  vnet_main_t *vnm = vnet_get_main ();
274  vnet_sw_interface_t *si, *sorted_sis = 0;
275  u32 sw_if_index = ~(u32) 0;
276  u8 show_addresses = 0;
277  u8 show_features = 0;
278  u8 show_tag = 0;
279 
281  {
282  /* See if user wants to show specific interface */
283  if (unformat
284  (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
285  {
286  si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
287  vec_add1 (sorted_sis, si[0]);
288  }
289  else if (unformat (input, "address") || unformat (input, "addr"))
290  show_addresses = 1;
291  else if (unformat (input, "features") || unformat (input, "feat"))
292  show_features = 1;
293  else if (unformat (input, "tag"))
294  show_tag = 1;
295  else
296  {
297  error = clib_error_return (0, "unknown input `%U'",
298  format_unformat_error, input);
299  goto done;
300  }
301  }
302 
303  if (show_features || show_tag)
304  {
305  if (sw_if_index == ~(u32) 0)
306  return clib_error_return (0, "Interface not specified...");
307  }
308 
309  if (show_features)
310  {
311  vnet_interface_features_show (vm, sw_if_index);
312 
313  l2_input_config_t *l2_input = l2input_intf_config (sw_if_index);
314  u32 fb = l2_input->feature_bitmap;
315  /* intf input features are masked by bridge domain */
316  if (l2_input->bridge)
317  fb &= l2input_bd_config (l2_input->bd_index)->feature_bitmap;
318  vlib_cli_output (vm, "\nl2-input:\n%U", format_l2_input_features, fb);
319 
320  l2_output_config_t *l2_output = l2output_intf_config (sw_if_index);
321  vlib_cli_output (vm, "\nl2-output:");
322  if (l2_output->out_vtr_flag)
323  vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
325  l2_output->feature_bitmap);
326  return 0;
327  }
328  if (show_tag)
329  {
330  u8 *tag;
331  tag = vnet_get_sw_interface_tag (vnm, sw_if_index);
332  vlib_cli_output (vm, "%U: %s",
333  format_vnet_sw_if_index_name, vnm, sw_if_index,
334  tag ? (char *) tag : "(none)");
335  return 0;
336  }
337 
338  if (!show_addresses)
339  vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
340 
341  if (vec_len (sorted_sis) == 0) /* Get all interfaces */
342  {
343  /* Gather interfaces. */
344  sorted_sis =
346  _vec_len (sorted_sis) = 0;
347  pool_foreach (si, im->sw_interfaces, (
348  {
349  int visible =
350  vnet_swif_is_api_visible (si);
351  if (visible)
352  vec_add1 (sorted_sis, si[0]);}
353  ));
354 
355  /* Sort by name. */
357  }
358 
359  if (show_addresses)
360  {
361  vec_foreach (si, sorted_sis)
362  {
363  ip4_main_t *im4 = &ip4_main;
364  ip6_main_t *im6 = &ip6_main;
365  ip_lookup_main_t *lm4 = &im4->lookup_main;
366  ip_lookup_main_t *lm6 = &im6->lookup_main;
367  ip_interface_address_t *ia = 0;
368  u32 fib_index4 = 0, fib_index6 = 0;
369 
371  fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
372  si->sw_if_index);
373 
375  fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
376  si->sw_if_index);
377 
378  ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
379  ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
380 
383  (vm, "%U (%s): \n unnumbered, use %U",
385  (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
387  else
389  (vm, "%U (%s):",
391  (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
392 
393  /* Display any L2 info */
395  if (l2_input->bridge)
396  {
397  bd_main_t *bdm = &bd_main;
398  u32 bd_id = l2input_main.bd_configs[l2_input->bd_index].bd_id;
399  vlib_cli_output (vm, " L2 bridge bd-id %d idx %d shg %d %s",
400  bd_id, bd_find_index (bdm, bd_id), l2_input->shg,
401  l2_input->bvi ? "bvi" : " ");
402  }
403  else if (l2_input->xconnect)
404  vlib_cli_output (vm, " L2 xconnect %U",
406  l2_input->output_sw_if_index);
407 
408  /* *INDENT-OFF* */
409  /* Display any IP4 addressing info */
411  1 /* honor unnumbered */,
412  ({
413  ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
414  if (fib4->table_id)
415  vlib_cli_output (vm, " L3 %U/%d ip4 table-id %d fib-idx %d",
416  format_ip4_address, r4, ia->address_length,
417  fib4->table_id,
418  ip4_fib_index_from_table_id (fib4->table_id));
419  else
420  vlib_cli_output (vm, " L3 %U/%d",
421  format_ip4_address, r4, ia->address_length);
422  }));
423  /* *INDENT-ON* */
424 
425  /* *INDENT-OFF* */
426  /* Display any IP6 addressing info */
428  1 /* honor unnumbered */,
429  ({
430  ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
431  if (fib6->table_id)
432  vlib_cli_output (vm, " L3 %U/%d ip6 table-id %d fib-idx %d",
433  format_ip6_address, r6, ia->address_length,
434  fib6->table_id,
435  ip6_fib_index_from_table_id (fib6->table_id));
436  else
437  vlib_cli_output (vm, " L3 %U/%d",
438  format_ip6_address, r6, ia->address_length);
439  }));
440  /* *INDENT-ON* */
441  }
442  }
443  else
444  {
445  vec_foreach (si, sorted_sis)
446  {
447  vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
448  }
449  }
450 
451 done:
452  vec_free (sorted_sis);
453  return error;
454 }
455 
456 /* *INDENT-OFF* */
457 VLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
458  .path = "show interface",
459  .short_help = "show interface [address|addr|features|feat] [<interface> [<interface> [..]]]",
460  .function = show_sw_interfaces,
461 };
462 /* *INDENT-ON* */
463 
464 /* Root of all interface commands. */
465 /* *INDENT-OFF* */
466 VLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
467  .path = "interface",
468  .short_help = "Interface commands",
469 };
470 /* *INDENT-ON* */
471 
472 /* *INDENT-OFF* */
473 VLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
474  .path = "set interface",
475  .short_help = "Interface commands",
476 };
477 /* *INDENT-ON* */
478 
479 static clib_error_t *
481  unformat_input_t * input, vlib_cli_command_t * cmd)
482 {
483  vnet_main_t *vnm = vnet_get_main ();
487  static vnet_main_t **my_vnet_mains;
488  int i, j, n_counters;
489 
490  vec_reset_length (my_vnet_mains);
491 
492  for (i = 0; i < vec_len (vnet_mains); i++)
493  {
494  if (vnet_mains[i])
495  vec_add1 (my_vnet_mains, vnet_mains[i]);
496  }
497 
498  if (vec_len (vnet_mains) == 0)
499  vec_add1 (my_vnet_mains, vnm);
500 
501  n_counters = vec_len (im->combined_sw_if_counters);
502 
503  for (j = 0; j < n_counters; j++)
504  {
505  for (i = 0; i < vec_len (my_vnet_mains); i++)
506  {
507  im = &my_vnet_mains[i]->interface_main;
508  cm = im->combined_sw_if_counters + j;
510  }
511  }
512 
513  n_counters = vec_len (im->sw_if_counters);
514 
515  for (j = 0; j < n_counters; j++)
516  {
517  for (i = 0; i < vec_len (my_vnet_mains); i++)
518  {
519  im = &my_vnet_mains[i]->interface_main;
520  sm = im->sw_if_counters + j;
522  }
523  }
524 
525  return 0;
526 }
527 
528 /*?
529  * Clear the statistics for all interfaces (statistics associated with the
530  * '<em>show interface</em>' command).
531  *
532  * @cliexpar
533  * Example of how to clear the statistics for all interfaces:
534  * @cliexcmd{clear interfaces}
535  ?*/
536 /* *INDENT-OFF* */
537 VLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
538  .path = "clear interfaces",
539  .short_help = "clear interfaces",
540  .function = clear_interface_counters,
541 };
542 /* *INDENT-ON* */
543 
544 /**
545  * Parse subinterface names.
546  *
547  * The following subinterface syntax is supported. The first two are for
548  * backwards compatability:
549  *
550  * <intf-name> <id>
551  * - a subinterface with the name <intf-name>.<id>. The subinterface
552  * is a single dot1q vlan with vlan id <id> and exact-match semantics.
553  *
554  * <intf-name> <min_id>-<max_id>
555  * - a set of the above subinterfaces, repeating for each id
556  * in the range <min_id> to <max_id>
557  *
558  * In the following, exact-match semantics (i.e. the number of vlan tags on the
559  * packet must match the number of tags in the configuration) are used only if
560  * the keyword exact-match is present. Non-exact match is the default.
561  *
562  * <intf-name> <id> dot1q <outer_id> [exact-match]
563  * - a subinterface with the name <intf-name>.<id>. The subinterface
564  * is a single dot1q vlan with vlan id <outer_id>.
565  *
566  * <intf-name> <id> dot1q any [exact-match]
567  * - a subinterface with the name <intf-name>.<id>. The subinterface
568  * is a single dot1q vlan with any vlan id.
569  *
570  * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
571  * - a subinterface with the name <intf-name>.<id>. The subinterface
572  * is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
573  * <inner_id>.
574  *
575  * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
576  * - a subinterface with the name <intf-name>.<id>. The subinterface
577  * is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
578  *
579  * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
580  *
581  * - a subinterface with the name <intf-name>.<id>. The subinterface
582  * is a double dot1q vlan with any outer vlan id and any inner vlan id.
583  *
584  * For each of the above CLI, there is a duplicate that uses the keyword
585  * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
586  * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
587  * tagged packets the inner ethertype is always 0x8100. Also note that
588  * the dot1q and dot1ad naming spaces are independent, so it is legal to
589  * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
590  *
591  * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
592  * - a subinterface with the name <intf-name>.<id>. The subinterface
593  * is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
594  * id <inner_id>.
595  *
596  * <intf-name> <id> untagged
597  * - a subinterface with the name <intf-name>.<id>. The subinterface
598  * has no vlan tags. Only one can be specified per interface.
599  *
600  * <intf-name> <id> default
601  * - a subinterface with the name <intf-name>.<id>. This is associated
602  * with a packet that did not match any other configured subinterface
603  * on this interface. Only one can be specified per interface.
604  */
605 
606 static clib_error_t *
608  vnet_sw_interface_t * template)
609 {
610  clib_error_t *error = 0;
611  u32 inner_vlan, outer_vlan;
612 
613  if (unformat (input, "any inner-dot1q any"))
614  {
615  template->sub.eth.flags.two_tags = 1;
616  template->sub.eth.flags.outer_vlan_id_any = 1;
617  template->sub.eth.flags.inner_vlan_id_any = 1;
618  }
619  else if (unformat (input, "any"))
620  {
621  template->sub.eth.flags.one_tag = 1;
622  template->sub.eth.flags.outer_vlan_id_any = 1;
623  }
624  else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
625  {
626  template->sub.eth.flags.two_tags = 1;
627  template->sub.eth.flags.inner_vlan_id_any = 1;
628  template->sub.eth.outer_vlan_id = outer_vlan;
629  }
630  else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
631  {
632  template->sub.eth.flags.two_tags = 1;
633  template->sub.eth.outer_vlan_id = outer_vlan;
634  template->sub.eth.inner_vlan_id = inner_vlan;
635  }
636  else if (unformat (input, "%d", &outer_vlan))
637  {
638  template->sub.eth.flags.one_tag = 1;
639  template->sub.eth.outer_vlan_id = outer_vlan;
640  }
641  else
642  {
643  error = clib_error_return (0, "expected dot1q config, got `%U'",
644  format_unformat_error, input);
645  goto done;
646  }
647 
649  {
650  if (unformat (input, "exact-match"))
651  {
652  template->sub.eth.flags.exact_match = 1;
653  }
654  }
655 
656 done:
657  return error;
658 }
659 
660 static clib_error_t *
662  unformat_input_t * input, vlib_cli_command_t * cmd)
663 {
664  vnet_main_t *vnm = vnet_get_main ();
665  clib_error_t *error = 0;
666  u32 hw_if_index, sw_if_index;
668  u32 id, id_min, id_max;
669  vnet_sw_interface_t template;
670 
671  hw_if_index = ~0;
672  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
673  {
674  error = clib_error_return (0, "unknown interface `%U'",
675  format_unformat_error, input);
676  goto done;
677  }
678 
679  memset (&template, 0, sizeof (template));
680  template.sub.eth.raw_flags = 0;
681 
682  if (unformat (input, "%d default", &id_min))
683  {
684  id_max = id_min;
685  template.sub.eth.flags.default_sub = 1;
686  }
687  else if (unformat (input, "%d untagged", &id_min))
688  {
689  id_max = id_min;
690  template.sub.eth.flags.no_tags = 1;
691  template.sub.eth.flags.exact_match = 1;
692  }
693  else if (unformat (input, "%d dot1q", &id_min))
694  {
695  /* parse dot1q config */
696  id_max = id_min;
697  error = parse_vlan_sub_interfaces (input, &template);
698  if (error)
699  goto done;
700  }
701  else if (unformat (input, "%d dot1ad", &id_min))
702  {
703  /* parse dot1ad config */
704  id_max = id_min;
705  template.sub.eth.flags.dot1ad = 1;
706  error = parse_vlan_sub_interfaces (input, &template);
707  if (error)
708  goto done;
709  }
710  else if (unformat (input, "%d-%d", &id_min, &id_max))
711  {
712  template.sub.eth.flags.one_tag = 1;
713  template.sub.eth.flags.exact_match = 1;
714  if (id_min > id_max)
715  goto id_error;
716  }
717  else if (unformat (input, "%d", &id_min))
718  {
719  id_max = id_min;
720  template.sub.eth.flags.one_tag = 1;
721  template.sub.eth.outer_vlan_id = id_min;
722  template.sub.eth.flags.exact_match = 1;
723  }
724  else
725  {
726  id_error:
727  error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
728  format_unformat_error, input);
729  goto done;
730  }
731 
732  hi = vnet_get_hw_interface (vnm, hw_if_index);
733 
735  {
736  error =
738  "not allowed as %v belong to a BondEthernet interface",
739  hi->name);
740  goto done;
741  }
742 
743  for (id = id_min; id <= id_max; id++)
744  {
745  uword *p;
747  u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
748  u64 *kp;
749 
750  p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
751  if (p)
752  {
753  if (CLIB_DEBUG > 0)
754  clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
755  hi->sw_if_index, id);
756  continue;
757  }
758 
759  kp = clib_mem_alloc (sizeof (*kp));
760  *kp = sup_and_sub_key;
761 
762  template.type = VNET_SW_INTERFACE_TYPE_SUB;
763  template.flood_class = VNET_FLOOD_CLASS_NORMAL;
764  template.sup_sw_if_index = hi->sw_if_index;
765  template.sub.id = id;
766  if (id_min < id_max)
767  template.sub.eth.outer_vlan_id = id;
768 
769  error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
770  if (error)
771  goto done;
772 
773  hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
774  hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
776  vnet_get_main (), sw_if_index);
777  }
778 
779 done:
780  return error;
781 }
782 
783 /*?
784  * This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
785  * The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
786  * (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
787  * assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
788  * but this is not recommended.
789  *
790  * This command has several variations:
791  * - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
792  * process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
793  *
794  * - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
795  * '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
796  * match any other subinterfaces should be sent to this subinterface.
797  *
798  * - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
799  * '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
800  * to this subinterface.
801  *
802  * - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
803  * subinterfaces to handle a range of VLAN IDs.
804  *
805  * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
806  * Use this command to specify the outer VLAN ID, to either be explicited or to make the
807  * VLAN ID different from the '<em>subId</em>'.
808  *
809  * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
810  * <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
811  * the innner VLAN ID.
812  *
813  * When '<em>dot1q</em>' or '<em>dot1ad</em>' is explictly entered, subinterfaces
814  * can be configured as either exact-match or non-exact match. Non-exact match is the CLI
815  * default. If '<em>exact-match</em>' is specified, packets must have the same number of
816  * VLAN tags as the configuration. For non-exact-match, packets must at least that number
817  * of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
818  * typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
819  * entered, then the default behavior is exact-match.
820  *
821  * Use the '<em>show interface</em>' command to display all subinterfaces.
822  *
823  * @cliexpar
824  * @parblock
825  * Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
826  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
827  *
828  * The previous example is shorthand and is equivalent to:
829  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
830  *
831  *
832  * Example of how to create a subinterface number that is different from the VLAN ID:
833  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
834  *
835  *
836  * Examples of how to create q-in-q and q-in-any subinterfaces:
837  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
838  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
839  *
840  * Examples of how to create dot1ad interfaces:
841  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
842  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
843  *
844  *
845  * Examples of '<em>exact-match</em>' versus non-exact match. A packet with
846  * outer VLAN 100 and inner VLAN 200 would match this interface, because the default
847  * is non-exact match:
848  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
849  *
850  * However, the same packet would NOT match this interface because '<em>exact-match</em>'
851  * is specified and only one VLAN is configured, but packet contains two VLANs:
852  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
853  *
854  *
855  * Example of how to created a subinterface to process untagged packets:
856  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
857  *
858  * Example of how to created a subinterface to process any packet with a VLAN ID that
859  * does not match any other subinterface:
860  * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
861  *
862  * When subinterfaces are created, they are in the down state. Example of how to
863  * enable a newly created subinterface:
864  * @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
865  * @endparblock
866  ?*/
867 /* *INDENT-OFF* */
868 VLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
869  .path = "create sub-interfaces",
870  .short_help = "create sub-interfaces <interface> "
871  "{<subId> [default|untagged]} | "
872  "{<subId>-<subId>} | "
873  "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
874  .function = create_sub_interfaces,
875 };
876 /* *INDENT-ON* */
877 
878 static clib_error_t *
880  unformat_input_t * input, vlib_cli_command_t * cmd)
881 {
882  vnet_main_t *vnm = vnet_get_main ();
883  clib_error_t *error;
884  u32 sw_if_index, flags;
885 
886  sw_if_index = ~0;
887  if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
888  {
889  error = clib_error_return (0, "unknown interface `%U'",
890  format_unformat_error, input);
891  goto done;
892  }
893 
894  if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
895  {
896  error = clib_error_return (0, "unknown flags `%U'",
897  format_unformat_error, input);
898  goto done;
899  }
900 
901  error = vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
902  if (error)
903  goto done;
904 
905 done:
906  return error;
907 }
908 
909 
910 /*?
911  * This command is used to change the admin state (up/down) of an interface.
912  *
913  * If an interface is down, the optional '<em>punt</em>' flag can also be set.
914  * The '<em>punt</em>' flag implies the interface is disabled for forwarding
915  * but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
916  * '<em>punt</em>' flag (interface is still down).
917  *
918  * @cliexpar
919  * Example of how to configure the admin state of an interface to '<em>up</em?':
920  * @cliexcmd{set interface state GigabitEthernet2/0/0 up}
921  * Example of how to configure the admin state of an interface to '<em>down</em?':
922  * @cliexcmd{set interface state GigabitEthernet2/0/0 down}
923  ?*/
924 /* *INDENT-OFF* */
925 VLIB_CLI_COMMAND (set_state_command, static) = {
926  .path = "set interface state",
927  .short_help = "set interface state <interface> [up|down|punt|enable]",
928  .function = set_state,
929 };
930 /* *INDENT-ON* */
931 
932 static clib_error_t *
934  unformat_input_t * input, vlib_cli_command_t * cmd)
935 {
936  vnet_main_t *vnm = vnet_get_main ();
937  u32 unnumbered_sw_if_index = ~0;
938  u32 inherit_from_sw_if_index = ~0;
939  int enable = 1;
940 
941  if (unformat (input, "%U use %U",
942  unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
943  unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
944  enable = 1;
945  else if (unformat (input, "del %U",
947  &unnumbered_sw_if_index))
948  enable = 0;
949  else
950  return clib_error_return (0, "parse error '%U'",
951  format_unformat_error, input);
952 
953  if (~0 == unnumbered_sw_if_index)
954  return clib_error_return (0, "Specify the unnumbered interface");
955  if (enable && ~0 == inherit_from_sw_if_index)
956  return clib_error_return (0, "When enabling unnumberered specify the"
957  " IP enabled interface that it uses");
958 
959  vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
960  inherit_from_sw_if_index, enable);
961 
962  return (NULL);
963 }
964 
965 /* *INDENT-OFF* */
966 VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
967  .path = "set interface unnumbered",
968  .short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
969  .function = set_unnumbered,
970 };
971 /* *INDENT-ON* */
972 
973 
974 
975 static clib_error_t *
977  unformat_input_t * input, vlib_cli_command_t * cmd)
978 {
979  vnet_main_t *vnm = vnet_get_main ();
981  clib_error_t *error;
982  u32 hw_if_index, hw_class_index;
983 
984  hw_if_index = ~0;
985  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
986  {
987  error = clib_error_return (0, "unknown hardware interface `%U'",
988  format_unformat_error, input);
989  goto done;
990  }
991 
992  if (!unformat_user (input, unformat_hash_string,
993  im->hw_interface_class_by_name, &hw_class_index))
994  {
995  error = clib_error_return (0, "unknown hardware class `%U'",
996  format_unformat_error, input);
997  goto done;
998  }
999 
1000  error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
1001  if (error)
1002  goto done;
1003 
1004 done:
1005  return error;
1006 }
1007 
1008 /* *INDENT-OFF* */
1009 VLIB_CLI_COMMAND (set_hw_class_command, static) = {
1010  .path = "set interface hw-class",
1011  .short_help = "Set interface hardware class",
1012  .function = set_hw_class,
1013 };
1014 /* *INDENT-ON* */
1015 
1016 static clib_error_t *
1018 {
1019  return 0;
1020 }
1021 
1023 
1024 static clib_error_t *
1026  unformat_input_t * input,
1027  vlib_cli_command_t * cmd)
1028 {
1029  u32 hw_if_index;
1030  u32 new_dev_instance;
1031  vnet_main_t *vnm = vnet_get_main ();
1032  int rv;
1033 
1034  if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
1035  return clib_error_return (0, "unknown hardware interface `%U'",
1036  format_unformat_error, input);
1037 
1038  if (!unformat (input, "%d", &new_dev_instance))
1039  return clib_error_return (0, "new dev instance missing");
1040 
1041  rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
1042 
1043  switch (rv)
1044  {
1045  case 0:
1046  break;
1047 
1048  default:
1049  return clib_error_return (0, "vnet_interface_name_renumber returned %d",
1050  rv);
1051 
1052  }
1053 
1054  return 0;
1055 }
1056 
1057 
1058 /* *INDENT-OFF* */
1059 VLIB_CLI_COMMAND (renumber_interface_command, static) = {
1060  .path = "renumber interface",
1061  .short_help = "renumber interface <interface> <new-dev-instance>",
1062  .function = renumber_interface_command_fn,
1063 };
1064 /* *INDENT-ON* */
1065 
1066 static clib_error_t *
1068  unformat_input_t * input, vlib_cli_command_t * cmd)
1069 {
1070  vnet_main_t *vnm = vnet_get_main ();
1071  u32 hw_if_index;
1074  ethernet_interface_t *eif;
1075 
1076  if (unformat (input, "on %U",
1077  unformat_vnet_hw_interface, vnm, &hw_if_index))
1078  ;
1079  else if (unformat (input, "off %U",
1080  unformat_ethernet_interface, vnm, &hw_if_index))
1081  flags = 0;
1082  else
1083  return clib_error_return (0, "unknown input `%U'",
1084  format_unformat_error, input);
1085 
1086  eif = ethernet_get_interface (em, hw_if_index);
1087  if (!eif)
1088  return clib_error_return (0, "not supported");
1089 
1090  ethernet_set_flags (vnm, hw_if_index, flags);
1091  return 0;
1092 }
1093 
1094 /* *INDENT-OFF* */
1095 VLIB_CLI_COMMAND (set_interface_promiscuous_cmd, static) = {
1096  .path = "set interface promiscuous",
1097  .short_help = "set interface promiscuous [on|off] <interface>",
1098  .function = promiscuous_cmd,
1099 };
1100 /* *INDENT-ON* */
1101 
1102 static clib_error_t *
1104 {
1105  vnet_main_t *vnm = vnet_get_main ();
1106  u32 hw_if_index, mtu;
1108 
1109  if (unformat (input, "%d %U", &mtu,
1110  unformat_vnet_hw_interface, vnm, &hw_if_index))
1111  {
1112  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1113  ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
1114 
1115  if (!eif)
1116  return clib_error_return (0, "not supported");
1117 
1118  if (mtu < hi->min_supported_packet_bytes)
1119  return clib_error_return (0, "Invalid mtu (%d): "
1120  "must be >= min pkt bytes (%d)", mtu,
1122 
1123  if (mtu > hi->max_supported_packet_bytes)
1124  return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
1126 
1127  vnet_hw_interface_set_mtu (vnm, hw_if_index, mtu);
1128  }
1129  else
1130  return clib_error_return (0, "unknown input `%U'",
1131  format_unformat_error, input);
1132  return 0;
1133 }
1134 
1135 /* *INDENT-OFF* */
1136 VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
1137  .path = "set interface mtu",
1138  .short_help = "set interface mtu <value> <interface>",
1139  .function = mtu_cmd,
1140 };
1141 /* *INDENT-ON* */
1142 
1143 static clib_error_t *
1145  vlib_cli_command_t * cmd)
1146 {
1147  vnet_main_t *vnm = vnet_get_main ();
1148  vnet_sw_interface_t *si = NULL;
1149  clib_error_t *error = 0;
1150  u32 sw_if_index = ~0;
1151  u8 mac[6] = { 0 };
1152 
1153  if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
1154  {
1155  error = clib_error_return (0, "unknown interface `%U'",
1156  format_unformat_error, input);
1157  goto done;
1158  }
1159  if (!unformat_user (input, unformat_ethernet_address, mac))
1160  {
1161  error = clib_error_return (0, "expected mac address `%U'",
1162  format_unformat_error, input);
1163  goto done;
1164  }
1165  si = vnet_get_sw_interface (vnm, sw_if_index);
1166  error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, mac);
1167 done:
1168  return error;
1169 }
1170 
1171 /*?
1172  * The '<em>set interface mac address </em>' command allows to set MAC address of given interface.
1173  * In case of NIC interfaces the one has to support MAC address change. A side effect of MAC address
1174  * change are changes of MAC addresses in FIB tables (ipv4 and ipv6).
1175  *
1176  * @cliexpar
1177  * @parblock
1178  * Example of how to change MAC Address of interface:
1179  * @cliexcmd{set interface mac address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01}
1180  * @cliexcmd{set interface mac address host-vpp0 aa:bb:cc:dd:ee:02}
1181  * @cliexcmd{set interface mac address tap-0 aa:bb:cc:dd:ee:03}
1182  * @cliexcmd{set interface mac address pg0 aa:bb:cc:dd:ee:04}
1183  * @endparblock
1184 ?*/
1185 /* *INDENT-OFF* */
1186 VLIB_CLI_COMMAND (set_interface_mac_address_cmd, static) = {
1187  .path = "set interface mac address",
1188  .short_help = "set interface mac address <interface> <mac-address>",
1189  .function = set_interface_mac_address,
1190 };
1191 /* *INDENT-ON* */
1192 
1193 static clib_error_t *
1195 {
1196  vnet_main_t *vnm = vnet_get_main ();
1197  u32 sw_if_index = ~0;
1198  u8 *tag = 0;
1199 
1200  if (!unformat (input, "%U %s", unformat_vnet_sw_interface,
1201  vnm, &sw_if_index, &tag))
1202  return clib_error_return (0, "unknown input `%U'",
1203  format_unformat_error, input);
1204 
1205  vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
1206 
1207  return 0;
1208 }
1209 
1210 /* *INDENT-OFF* */
1211 VLIB_CLI_COMMAND (set_tag_command, static) = {
1212  .path = "set interface tag",
1213  .short_help = "set interface tag <interface> <tag>",
1214  .function = set_tag,
1215 };
1216 /* *INDENT-ON* */
1217 
1218 static clib_error_t *
1220  vlib_cli_command_t * cmd)
1221 {
1222  vnet_main_t *vnm = vnet_get_main ();
1223  u32 sw_if_index = ~0;
1224 
1225  if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1226  return clib_error_return (0, "unknown input `%U'",
1227  format_unformat_error, input);
1228 
1229  vnet_clear_sw_interface_tag (vnm, sw_if_index);
1230 
1231  return 0;
1232 }
1233 
1234 /* *INDENT-OFF* */
1235 VLIB_CLI_COMMAND (clear_tag_command, static) = {
1236  .path = "clear interface tag",
1237  .short_help = "clear interface tag <interface>",
1238  .function = clear_tag,
1239 };
1240 /* *INDENT-ON* */
1241 
1242 static clib_error_t *
1244  u32 queue_id, vnet_hw_interface_rx_mode mode)
1245 {
1246  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
1247  vnet_device_class_t *dev_class =
1249  clib_error_t *error;
1250  vnet_hw_interface_rx_mode old_mode;
1251  int rv;
1252 
1254  mode = hw->default_rx_mode;
1255 
1256  rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &old_mode);
1257  switch (rv)
1258  {
1259  case 0:
1260  if (old_mode == mode)
1261  return 0; /* same rx-mode, no change */
1262  break;
1263  case VNET_API_ERROR_INVALID_INTERFACE:
1264  return clib_error_return (0, "invalid interface");
1265  case VNET_API_ERROR_INVALID_QUEUE:
1266  return clib_error_return (0, "invalid queue");
1267  default:
1268  return clib_error_return (0, "unknown error");
1269  }
1270 
1271  if (dev_class->rx_mode_change_function)
1272  {
1273  error = dev_class->rx_mode_change_function (vnm, hw_if_index, queue_id,
1274  mode);
1275  if (error)
1276  return (error);
1277  }
1278 
1279  rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1280  switch (rv)
1281  {
1282  case 0:
1283  break;
1284  case VNET_API_ERROR_UNSUPPORTED:
1285  return clib_error_return (0, "unsupported");
1286  case VNET_API_ERROR_INVALID_INTERFACE:
1287  return clib_error_return (0, "invalid interface");
1288  case VNET_API_ERROR_INVALID_QUEUE:
1289  return clib_error_return (0, "invalid queue");
1290  default:
1291  return clib_error_return (0, "unknown error");
1292  }
1293 
1294  return 0;
1295 }
1296 
1297 clib_error_t *
1299  u8 queue_id_valid, u32 queue_id,
1301 {
1302  clib_error_t *error = 0;
1303  vnet_hw_interface_t *hw;
1304  int i;
1305 
1306  hw = vnet_get_hw_interface (vnm, hw_if_index);
1307 
1308  if (queue_id_valid == 0)
1309  {
1310  for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
1311  {
1312  error = set_hw_interface_rx_mode (vnm, hw_if_index, i, mode);
1313  if (error)
1314  break;
1315  }
1316  hw->default_rx_mode = mode;
1317  }
1318  else
1319  error = set_hw_interface_rx_mode (vnm, hw_if_index, queue_id, mode);
1320 
1321  return (error);
1322 }
1323 
1324 static clib_error_t *
1326  vlib_cli_command_t * cmd)
1327 {
1328  clib_error_t *error = 0;
1329  unformat_input_t _line_input, *line_input = &_line_input;
1330  vnet_main_t *vnm = vnet_get_main ();
1331  u32 hw_if_index = (u32) ~ 0;
1332  u32 queue_id = (u32) ~ 0;
1334  u8 queue_id_valid = 0;
1335 
1336  if (!unformat_user (input, unformat_line_input, line_input))
1337  return 0;
1338 
1339  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1340  {
1341  if (unformat
1342  (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1343  ;
1344  else if (unformat (line_input, "queue %d", &queue_id))
1345  queue_id_valid = 1;
1346  else if (unformat (line_input, "polling"))
1348  else if (unformat (line_input, "interrupt"))
1350  else if (unformat (line_input, "adaptive"))
1352  else
1353  {
1354  error = clib_error_return (0, "parse error: '%U'",
1355  format_unformat_error, line_input);
1356  unformat_free (line_input);
1357  return error;
1358  }
1359  }
1360 
1361  unformat_free (line_input);
1362 
1363  if (hw_if_index == (u32) ~ 0)
1364  return clib_error_return (0, "please specify valid interface name");
1365 
1367  return clib_error_return (0, "please specify valid rx-mode");
1368 
1369  error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
1370  queue_id, mode);
1371 
1372  return (error);
1373 }
1374 
1375 /*?
1376  * This command is used to assign the RX packet processing mode (polling,
1377  * interrupt, adaptive) of the a given interface, and optionally a
1378  * given queue. If the '<em>queue</em>' is not provided, the '<em>mode</em>'
1379  * is applied to all queues of the interface. Not all interfaces support
1380  * all modes. To display the current rx-mode use the command
1381  * '<em>show interface rx-placement</em>'.
1382  *
1383  * @cliexpar
1384  * Example of how to assign rx-mode to all queues on an interface:
1385  * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 polling}
1386  * Example of how to assign rx-mode to one queue of an interface:
1387  * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 queue 0 interrupt}
1388  * Example of how to display the rx-mode of all interfaces:
1389  * @cliexstart{show interface rx-placement}
1390  * Thread 1 (vpp_wk_0):
1391  * node dpdk-input:
1392  * GigabitEthernet7/0/0 queue 0 (polling)
1393  * node vhost-user-input:
1394  * VirtualEthernet0/0/12 queue 0 (interrupt)
1395  * VirtualEthernet0/0/12 queue 2 (polling)
1396  * VirtualEthernet0/0/13 queue 0 (polling)
1397  * VirtualEthernet0/0/13 queue 2 (polling)
1398  * Thread 2 (vpp_wk_1):
1399  * node dpdk-input:
1400  * GigabitEthernet7/0/1 queue 0 (polling)
1401  * node vhost-user-input:
1402  * VirtualEthernet0/0/12 queue 1 (polling)
1403  * VirtualEthernet0/0/12 queue 3 (polling)
1404  * VirtualEthernet0/0/13 queue 1 (polling)
1405  * VirtualEthernet0/0/13 queue 3 (polling)
1406  * @cliexend
1407 ?*/
1408 /* *INDENT-OFF* */
1409 VLIB_CLI_COMMAND (cmd_set_if_rx_mode,static) = {
1410  .path = "set interface rx-mode",
1411  .short_help = "set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
1412  .function = set_interface_rx_mode,
1413 };
1414 /* *INDENT-ON* */
1415 
1416 static clib_error_t *
1418  vlib_cli_command_t * cmd)
1419 {
1420  u8 *s = 0;
1421  vnet_main_t *vnm = vnet_get_main ();
1424  vlib_node_t *pn = vlib_get_node_by_name (vm, (u8 *) "device-input");
1425  uword si;
1426  int index = 0;
1427 
1428  /* *INDENT-OFF* */
1429  foreach_vlib_main (({
1431  ({
1432  rt = vlib_node_get_runtime_data (this_vlib_main, si);
1433 
1434  if (vec_len (rt->devices_and_queues))
1435  s = format (s, " node %U:\n", format_vlib_node_name, vm, si);
1436 
1437  vec_foreach (dq, rt->devices_and_queues)
1438  {
1439  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm,
1440  dq->hw_if_index);
1441  s = format (s, " %U queue %u (%U)\n",
1442  format_vnet_sw_if_index_name, vnm, hi->sw_if_index,
1443  dq->queue_id,
1444  format_vnet_hw_interface_rx_mode, dq->mode);
1445  }
1446  }));
1447  if (vec_len (s) > 0)
1448  {
1449  vlib_cli_output(vm, "Thread %u (%v):\n%v", index,
1450  vlib_worker_threads[index].name, s);
1451  vec_reset_length (s);
1452  }
1453  index++;
1454  }));
1455  /* *INDENT-ON* */
1456 
1457  vec_free (s);
1458  return 0;
1459 }
1460 
1461 /*?
1462  * This command is used to display the interface and queue worker
1463  * thread placement.
1464  *
1465  * @cliexpar
1466  * Example of how to display the interface placement:
1467  * @cliexstart{show interface rx-placement}
1468  * Thread 1 (vpp_wk_0):
1469  * node dpdk-input:
1470  * GigabitEthernet7/0/0 queue 0 (polling)
1471  * node vhost-user-input:
1472  * VirtualEthernet0/0/12 queue 0 (polling)
1473  * VirtualEthernet0/0/12 queue 2 (polling)
1474  * VirtualEthernet0/0/13 queue 0 (polling)
1475  * VirtualEthernet0/0/13 queue 2 (polling)
1476  * Thread 2 (vpp_wk_1):
1477  * node dpdk-input:
1478  * GigabitEthernet7/0/1 queue 0 (polling)
1479  * node vhost-user-input:
1480  * VirtualEthernet0/0/12 queue 1 (polling)
1481  * VirtualEthernet0/0/12 queue 3 (polling)
1482  * VirtualEthernet0/0/13 queue 1 (polling)
1483  * VirtualEthernet0/0/13 queue 3 (polling)
1484  * @cliexend
1485 ?*/
1486 /* *INDENT-OFF* */
1487 VLIB_CLI_COMMAND (show_interface_rx_placement, static) = {
1488  .path = "show interface rx-placement",
1489  .short_help = "show interface rx-placement",
1490  .function = show_interface_rx_placement_fn,
1491 };
1492 /* *INDENT-ON* */
1493 
1494 static clib_error_t *
1496  vlib_cli_command_t * cmd)
1497 {
1498  clib_error_t *error = 0;
1499  unformat_input_t _line_input, *line_input = &_line_input;
1500  vnet_main_t *vnm = vnet_get_main ();
1503  u32 hw_if_index = (u32) ~ 0;
1504  u32 queue_id = (u32) 0;
1505  u32 thread_index = (u32) ~ 0;
1506  int rv;
1507 
1508  if (!unformat_user (input, unformat_line_input, line_input))
1509  return 0;
1510 
1511  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1512  {
1513  if (unformat
1514  (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1515  ;
1516  else if (unformat (line_input, "queue %d", &queue_id))
1517  ;
1518  else if (unformat (line_input, "main", &thread_index))
1519  thread_index = 0;
1520  else if (unformat (line_input, "worker %d", &thread_index))
1521  thread_index += vdm->first_worker_thread_index;
1522  else
1523  {
1524  error = clib_error_return (0, "parse error: '%U'",
1525  format_unformat_error, line_input);
1526  unformat_free (line_input);
1527  return error;
1528  }
1529  }
1530 
1531  unformat_free (line_input);
1532 
1533  if (hw_if_index == (u32) ~ 0)
1534  return clib_error_return (0, "please specify valid interface name");
1535 
1536  if (thread_index > vdm->last_worker_thread_index)
1537  return clib_error_return (0,
1538  "please specify valid worker thread or main");
1539 
1540  rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &mode);
1541 
1542  if (rv)
1543  return clib_error_return (0, "not found");
1544 
1545  rv = vnet_hw_interface_unassign_rx_thread (vnm, hw_if_index, queue_id);
1546 
1547  if (rv)
1548  return clib_error_return (0, "not found");
1549 
1550  vnet_hw_interface_assign_rx_thread (vnm, hw_if_index, queue_id,
1551  thread_index);
1552  vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1553 
1554  return 0;
1555 }
1556 
1557 /*?
1558  * This command is used to assign a given interface, and optionally a
1559  * given queue, to a different thread. If the '<em>queue</em>' is not provided,
1560  * it defaults to 0. The '<em>worker</em>' parameter is zero based and the index
1561  * in the thread name, for example, 0 in the thread name '<em>vpp_wk_0</em>'.
1562  *
1563  * @cliexpar
1564  * Example of how to display the interface placement:
1565  * @cliexstart{show interface rx-placement}
1566  * Thread 1 (vpp_wk_0):
1567  * node dpdk-input:
1568  * GigabitEthernet7/0/0 queue 0 (polling)
1569  * node vhost-user-input:
1570  * VirtualEthernet0/0/12 queue 0 (polling)
1571  * VirtualEthernet0/0/12 queue 2 (polling)
1572  * VirtualEthernet0/0/13 queue 0 (polling)
1573  * VirtualEthernet0/0/13 queue 2 (polling)
1574  * Thread 2 (vpp_wk_1):
1575  * node dpdk-input:
1576  * GigabitEthernet7/0/1 queue 0 (polling)
1577  * node vhost-user-input:
1578  * VirtualEthernet0/0/12 queue 1 (polling)
1579  * VirtualEthernet0/0/12 queue 3 (polling)
1580  * VirtualEthernet0/0/13 queue 1 (polling)
1581  * VirtualEthernet0/0/13 queue 3 (polling)
1582  * @cliexend
1583  * Example of how to assign a interface and queue to a worker thread:
1584  * @cliexcmd{set interface rx-placement VirtualEthernet0/0/12 queue 1 worker 0}
1585  * Example of how to display the interface placement:
1586  * @cliexstart{show interface rx-placement}
1587  * Thread 1 (vpp_wk_0):
1588  * node dpdk-input:
1589  * GigabitEthernet7/0/0 queue 0 (polling)
1590  * node vhost-user-input:
1591  * VirtualEthernet0/0/12 queue 0 (polling)
1592  * VirtualEthernet0/0/12 queue 1 (polling)
1593  * VirtualEthernet0/0/12 queue 2 (polling)
1594  * VirtualEthernet0/0/13 queue 0 (polling)
1595  * VirtualEthernet0/0/13 queue 2 (polling)
1596  * Thread 2 (vpp_wk_1):
1597  * node dpdk-input:
1598  * GigabitEthernet7/0/1 queue 0 (polling)
1599  * node vhost-user-input:
1600  * VirtualEthernet0/0/12 queue 3 (polling)
1601  * VirtualEthernet0/0/13 queue 1 (polling)
1602  * VirtualEthernet0/0/13 queue 3 (polling)
1603  * @cliexend
1604 ?*/
1605 /* *INDENT-OFF* */
1606 VLIB_CLI_COMMAND (cmd_set_if_rx_placement,static) = {
1607  .path = "set interface rx-placement",
1608  .short_help = "set interface rx-placement <interface> [queue <n>] "
1609  "[worker <n> | main]",
1610  .function = set_interface_rx_placement,
1611  .is_mp_safe = 1,
1612 };
1613 /* *INDENT-ON* */
1614 /*
1615  * fd.io coding-style-patch-verification: ON
1616  *
1617  * Local Variables:
1618  * eval: (c-set-style "gnu")
1619  * End:
1620  */
uword * sibling_bitmap
Definition: node.h:294
unformat_function_t unformat_vnet_hw_interface
#define foreach_ip_interface_address(lm, a, sw_if_index, loop, body)
Definition: lookup.h:179
static clib_error_t * clear_interface_counters(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_l2_input_features(u8 *s, va_list *args)
Definition: l2_input.c:66
#define VNET_SW_INTERFACE_FLAG_UNNUMBERED
Definition: interface.h:595
vmrglw vmrglh hi
format_function_t format_vnet_sw_interface
static clib_error_t * create_sub_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define hash_set(h, key, value)
Definition: hash.h:254
static clib_error_t * promiscuous_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_hw_class(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int sw_interface_name_compare(void *a1, void *a2)
static clib_error_t * set_state(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword first_worker_thread_index
Definition: devices.h:53
static ip6_fib_t * ip6_fib_get(fib_node_index_t index)
Definition: ip6_fib.h:166
static clib_error_t * set_interface_mac_address(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
u8 * format_l2_output_features(u8 *s, va_list *args)
Definition: l2_output.c:44
unformat_function_t unformat_hash_string
Definition: hash.h:704
vnet_interface_main_t interface_main
Definition: vnet.h:56
l2_input_config_t * l2input_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
Definition: l2_input.c:509
#define NULL
Definition: clib.h:55
vnet_main_t ** vnet_mains
Definition: misc.c:44
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:520
word vnet_sw_interface_compare(vnet_main_t *vnm, uword sw_if_index0, uword sw_if_index1)
Definition: interface.c:1161
int vnet_interface_name_renumber(u32 sw_if_index, u32 new_show_dev_instance)
Definition: interface.c:1317
static void vnet_clear_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * set_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int i
static clib_error_t * renumber_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
#define hash_set_mem(h, key, value)
Definition: hash.h:274
ip_lookup_main_t lookup_main
Definition: ip4.h:97
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
uword * sub_interface_sw_if_index_by_id
Definition: interface.h:483
u32 * fib_index_by_sw_if_index
Table index indexed by software interface.
Definition: ip4.h:111
unformat_function_t unformat_vnet_sw_interface
struct _vnet_device_class vnet_device_class_t
uword * dq_runtime_index_by_queue
Definition: interface.h:507
format_function_t format_vnet_sw_if_index_name
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
ethernet_main_t ethernet_main
Definition: init.c:45
vnet_hw_interface_rx_mode
Definition: interface.h:51
format_function_t format_vnet_hw_interface
uword flags
Definition: clib_error.h:29
void vlib_clear_combined_counters(vlib_combined_counter_main_t *cm)
Clear a collection of combined counters.
Definition: counter.c:60
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:440
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
u32 output_sw_if_index
Definition: l2_input.h:35
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:306
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:718
static clib_error_t * parse_vlan_sub_interfaces(unformat_input_t *input, vnet_sw_interface_t *template)
Parse subinterface names.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
Definition: error.h:99
unsigned long u64
Definition: types.h:89
static clib_error_t * set_unnumbered(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
A collection of simple counters.
Definition: counter.h:58
static clib_error_t * mtu_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_line_input
Definition: format.h:281
u32 max_supported_packet_bytes
Definition: interface.h:466
vnet_hw_interface_t * hw_interfaces
Definition: interface.h:695
vlib_worker_thread_t * vlib_worker_threads
Definition: threads.c:35
#define clib_bitmap_foreach(i, ai, body)
Macro to iterate across set bits in a bitmap.
Definition: bitmap.h:361
l2_output_config_t * l2output_intf_config(u32 sw_if_index)
Get a pointer to the config for the given interface.
Definition: l2_output.c:676
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:461
struct _unformat_input_t unformat_input_t
int vnet_hw_interface_get_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode *mode)
Definition: devices.c:312
uword * sw_if_index_by_sup_and_sub
Definition: interface.h:712
clib_error_t * set_hw_interface_change_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u8 queue_id_valid, u32 queue_id, vnet_hw_interface_rx_mode mode)
static clib_error_t * show_sw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:717
word vnet_hw_interface_compare(vnet_main_t *vnm, uword hw_if_index0, uword hw_if_index1)
Definition: interface.c:1175
static clib_error_t * set_interface_rx_placement(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vnet_sw_interface_update_unnumbered(u32 unnumbered_sw_if_index, u32 ip_sw_if_index, u8 enable)
Definition: interface.c:1434
#define foreach_vlib_main(body)
Definition: threads.h:244
static int compare_interface_names(void *a1, void *a2)
Definition: interface_cli.c:57
uword * hw_interface_class_by_name
Definition: interface.h:705
The IPv4 FIB.
Definition: ip4_fib.h:39
#define VNET_HW_INTERFACE_BOND_INFO_SLAVE
Definition: interface.h:494
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
void vnet_interface_features_show(vlib_main_t *vm, u32 sw_if_index)
Display the set of driver features configured on a specific interface Called by "show interface" hand...
Definition: feature.c:309
vlib_main_t * vm
Definition: buffer.c:294
static clib_error_t * clear_tag(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
static ip4_fib_t * ip4_fib_get(u32 index)
Get the FIB at the given index.
Definition: ip4_fib.h:117
Definition: ip6.h:67
#define clib_warning(format, args...)
Definition: error.h:59
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, u8 *mac_address)
Definition: interface.c:1425
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:147
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static_always_inline l2_bridge_domain_t * l2input_bd_config(u32 bd_index)
Definition: l2_input.h:90
static void show_bond(vlib_main_t *vm)
Definition: cli.c:637
static clib_error_t * show_or_clear_hw_interfaces(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: interface_cli.c:66
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
#define VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:588
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
Definition: format.c:227
unsigned int u32
Definition: types.h:88
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
Definition: devices.c:138
ip6_main_t ip6_main
Definition: ip6_forward.c:2750
ip_lookup_main_t lookup_main
Definition: ip6.h:161
IPv4 main type.
Definition: ip4.h:95
static void vnet_set_sw_interface_tag(vnet_main_t *vnm, u8 *tag, u32 sw_if_index)
Bitmaps built as vectors of machine words.
char * path
Definition: cli.h:95
static u8 * vnet_get_sw_interface_tag(vnet_main_t *vnm, u32 sw_if_index)
static void * clib_mem_alloc(uword size)
Definition: mem.h:112
uword unformat_ethernet_interface(unformat_input_t *input, va_list *args)
Definition: interface.c:252
u64 uword
Definition: types.h:112
#define vec_elt(v, i)
Get vector value at index i.
void vnet_hw_interface_set_mtu(vnet_main_t *vnm, u32 hw_if_index, u32 mtu)
Definition: interface.c:126
l2input_main_t l2input_main
Definition: l2_input.c:113
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
Definition: interface.c:705
u32 feature_bitmap
Definition: l2_bd.h:56
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
unformat_function_t unformat_vnet_sw_interface_flags
static clib_error_t * vnet_interface_cli_init(vlib_main_t *vm)
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:958
static void unformat_free(unformat_input_t *i)
Definition: format.h:161
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:709
static clib_error_t * set_hw_interface_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, vnet_hw_interface_rx_mode mode)
l2_bridge_domain_t * bd_configs
Definition: l2_input.h:69
A collection of combined counters.
Definition: counter.h:180
#define hash_get_mem(h, key)
Definition: hash.h:268
int vnet_hw_interface_unassign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
Definition: devices.c:187
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
u32 min_supported_packet_bytes
Definition: interface.h:463
void vlib_clear_simple_counters(vlib_simple_counter_main_t *cm)
Clear a collection of simple counters.
Definition: counter.c:43
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:818
#define vec_foreach(var, vec)
Vector iterator.
vnet_hw_interface_rx_mode default_rx_mode
Definition: interface.h:504
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Definition: interface.c:562
vnet_device_class_t * device_classes
Definition: interface.h:702
u32 bd_find_index(bd_main_t *bdm, u32 bd_id)
Get a bridge domain.
Definition: l2_bd.c:67
int vnet_hw_interface_set_rx_mode(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, vnet_hw_interface_rx_mode mode)
Definition: devices.c:252
static clib_error_t * set_interface_rx_mode(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_error_t * vnet_create_sw_interface(vnet_main_t *vnm, vnet_sw_interface_t *template, u32 *sw_if_index)
Definition: interface.c:614
u32 flags
Definition: vhost-user.h:77
bd_main_t bd_main
Definition: l2_bd.c:44
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
u32 * fib_index_by_sw_if_index
Definition: ip6.h:176
static clib_error_t * show_interface_rx_placement_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_device_main_t vnet_device_main
Definition: devices.c:22
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:367
clib_error_t * vnet_hw_interface_set_class(vnet_main_t *vnm, u32 hw_if_index, u32 hw_class_index)
Definition: interface.c:1120
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128