blob: b15d283fe4918f4323de29d5cbc66c0d647a8464 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
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
Chris Luke16bcf7d2016-09-01 14:31:46 -040040/**
41 * @file
Billy McFalle9bac692017-08-11 14:05:11 -040042 * @brief Interface CLI.
43 *
44 * Source code for several CLI interface commands.
45 *
Chris Luke16bcf7d2016-09-01 14:31:46 -040046 */
47
Ed Warnickecb9cada2015-12-08 15:45:58 -070048#include <vnet/vnet.h>
49#include <vnet/ip/ip.h>
John Lobcebbb92016-04-05 15:47:43 -040050#include <vppinfra/bitmap.h>
Neale Ranns0bfe5d82016-08-25 15:29:12 +010051#include <vnet/fib/ip4_fib.h>
52#include <vnet/fib/ip6_fib.h>
Eyal Bari942402b2017-07-26 11:57:04 +030053#include <vnet/l2/l2_output.h>
54#include <vnet/l2/l2_input.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070055
Dave Barachba868bb2016-08-08 09:51:21 -040056static int
57compare_interface_names (void *a1, void *a2)
Ed Warnickecb9cada2015-12-08 15:45:58 -070058{
Dave Barachba868bb2016-08-08 09:51:21 -040059 u32 *hi1 = a1;
60 u32 *hi2 = a2;
Ed Warnickecb9cada2015-12-08 15:45:58 -070061
Dave Barachba868bb2016-08-08 09:51:21 -040062 return vnet_hw_interface_compare (vnet_get_main (), *hi1, *hi2);
Ed Warnickecb9cada2015-12-08 15:45:58 -070063}
64
65static clib_error_t *
66show_or_clear_hw_interfaces (vlib_main_t * vm,
67 unformat_input_t * input,
68 vlib_cli_command_t * cmd)
69{
Dave Barachba868bb2016-08-08 09:51:21 -040070 clib_error_t *error = 0;
71 vnet_main_t *vnm = vnet_get_main ();
72 vnet_interface_main_t *im = &vnm->interface_main;
73 vnet_hw_interface_t *hi;
74 u32 hw_if_index, *hw_if_indices = 0;
John Lobcebbb92016-04-05 15:47:43 -040075 int i, verbose = -1, is_show, show_bond = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -070076
77 is_show = strstr (cmd->path, "show") != 0;
78 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
79 {
80 /* See if user wants to show a specific interface. */
Dave Barachba868bb2016-08-08 09:51:21 -040081 if (unformat
82 (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
83 vec_add1 (hw_if_indices, hw_if_index);
John Lobcebbb92016-04-05 15:47:43 -040084
Sean Hope679ea792016-02-22 15:12:01 -050085 /* See if user wants to show an interface with a specific hw_if_index. */
86 else if (unformat (input, "%u", &hw_if_index))
Dave Barachba868bb2016-08-08 09:51:21 -040087 vec_add1 (hw_if_indices, hw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -070088
89 else if (unformat (input, "verbose"))
Dave Barachba868bb2016-08-08 09:51:21 -040090 verbose = 1; /* this is also the default */
Ed Warnickecb9cada2015-12-08 15:45:58 -070091
92 else if (unformat (input, "detail"))
93 verbose = 2;
94
95 else if (unformat (input, "brief"))
96 verbose = 0;
97
John Lobcebbb92016-04-05 15:47:43 -040098 else if (unformat (input, "bond"))
Dave Barachba868bb2016-08-08 09:51:21 -040099 {
100 show_bond = 1;
101 if (verbose < 0)
102 verbose = 0; /* default to brief for link bonding */
103 }
John Lobcebbb92016-04-05 15:47:43 -0400104
Ed Warnickecb9cada2015-12-08 15:45:58 -0700105 else
106 {
107 error = clib_error_return (0, "unknown input `%U'",
108 format_unformat_error, input);
109 goto done;
110 }
111 }
Dave Barachba868bb2016-08-08 09:51:21 -0400112
Ed Warnickecb9cada2015-12-08 15:45:58 -0700113 /* 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
Dave Barachba868bb2016-08-08 09:51:21 -0400118 if (verbose < 0)
119 verbose = 1; /* default to verbose (except bond) */
John Lobcebbb92016-04-05 15:47:43 -0400120
Ed Warnickecb9cada2015-12-08 15:45:58 -0700121 if (is_show)
122 {
123 /* Sort by name. */
124 vec_sort_with_function (hw_if_indices, compare_interface_names);
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]);
Dave Barachba868bb2016-08-08 09:51:21 -0400130 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) &&
John Lobcebbb92016-04-05 15:47:43 -0400134 (hi->bond_info != VNET_HW_INTERFACE_BOND_INFO_SLAVE))
Dave Barachba868bb2016-08-08 09:51:21 -0400135 { /* show only bonded interface and all its slave interfaces */
John Lobcebbb92016-04-05 15:47:43 -0400136 int hw_idx;
Dave Barachba868bb2016-08-08 09:51:21 -0400137 vnet_hw_interface_t *shi;
138 vlib_cli_output (vm, "%U\n", format_vnet_hw_interface, vnm,
John Lobcebbb92016-04-05 15:47:43 -0400139 hi, verbose);
Dave Barachba868bb2016-08-08 09:51:21 -0400140
141 /* *INDENT-OFF* */
John Lobcebbb92016-04-05 15:47:43 -0400142 clib_bitmap_foreach (hw_idx, hi->bond_info,
Dave Barachba868bb2016-08-08 09:51:21 -0400143 ({
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* */
John Lobcebbb92016-04-05 15:47:43 -0400149 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700150 }
151 }
152 else
153 {
154 for (i = 0; i < vec_len (hw_if_indices); i++)
155 {
Dave Barachba868bb2016-08-08 09:51:21 -0400156 vnet_device_class_t *dc;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700157
158 hi = vnet_get_hw_interface (vnm, hw_if_indices[i]);
159 dc = vec_elt_at_index (im->device_classes, hi->dev_class_index);
Dave Barachba868bb2016-08-08 09:51:21 -0400160
Ed Warnickecb9cada2015-12-08 15:45:58 -0700161 if (dc->clear_counters)
162 dc->clear_counters (hi->dev_instance);
163 }
164 }
165
Dave Barachba868bb2016-08-08 09:51:21 -0400166done:
Ed Warnickecb9cada2015-12-08 15:45:58 -0700167 vec_free (hw_if_indices);
168 return error;
169}
170
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700171/*?
Billy McFalle9bac692017-08-11 14:05:11 -0400172 * 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.
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700181 *
182 * @cliexpar
Billy McFalle9bac692017-08-11 14:05:11 -0400183 * 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
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700225 * @cliexend
226 ?*/
Billy McFalle9bac692017-08-11 14:05:11 -0400227/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700228VLIB_CLI_COMMAND (show_hw_interfaces_command, static) = {
229 .path = "show hardware-interfaces",
Billy McFalle9bac692017-08-11 14:05:11 -0400230 .short_help = "show hardware-interfaces [brief|verbose|detail] [bond] "
231 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700232 .function = show_or_clear_hw_interfaces,
233};
Dave Barachba868bb2016-08-08 09:51:21 -0400234/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700235
Billy McFalle9bac692017-08-11 14:05:11 -0400236
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 ?*/
Dave Barachba868bb2016-08-08 09:51:21 -0400248/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700249VLIB_CLI_COMMAND (clear_hw_interface_counters_command, static) = {
250 .path = "clear hardware-interfaces",
Billy McFalle9bac692017-08-11 14:05:11 -0400251 .short_help = "clear hardware-interfaces "
252 "[<interface> [<interface> [..]]] [<sw_idx> [<sw_idx> [..]]]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700253 .function = show_or_clear_hw_interfaces,
254};
Dave Barachba868bb2016-08-08 09:51:21 -0400255/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700256
Dave Barachba868bb2016-08-08 09:51:21 -0400257static int
258sw_interface_name_compare (void *a1, void *a2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700259{
260 vnet_sw_interface_t *si1 = a1;
261 vnet_sw_interface_t *si2 = a2;
262
Dave Barachba868bb2016-08-08 09:51:21 -0400263 return vnet_sw_interface_compare (vnet_get_main (),
264 si1->sw_if_index, si2->sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700265}
266
267static clib_error_t *
268show_sw_interfaces (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400269 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700270{
Dave Barachba868bb2016-08-08 09:51:21 -0400271 clib_error_t *error = 0;
272 vnet_main_t *vnm = vnet_get_main ();
Dave Barach525c9d02018-05-26 10:48:55 -0400273 unformat_input_t _linput, *linput = &_linput;
Dave Barachba868bb2016-08-08 09:51:21 -0400274 vnet_interface_main_t *im = &vnm->interface_main;
275 vnet_sw_interface_t *si, *sorted_sis = 0;
Damjan Marion22311502016-10-28 20:30:15 +0200276 u32 sw_if_index = ~(u32) 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700277 u8 show_addresses = 0;
Damjan Marion22311502016-10-28 20:30:15 +0200278 u8 show_features = 0;
Dave Barach7be864a2016-11-28 11:41:35 -0500279 u8 show_tag = 0;
Dave Barach525c9d02018-05-26 10:48:55 -0400280 int verbose = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700281
Dave Barach525c9d02018-05-26 10:48:55 -0400282 /*
283 * Get a line of input. Won't work if the user typed
284 * "show interface" and nothing more.
285 */
286 if (unformat_user (input, unformat_line_input, linput))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700287 {
Dave Barach525c9d02018-05-26 10:48:55 -0400288 while (unformat_check_input (linput) != UNFORMAT_END_OF_INPUT)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700289 {
Dave Barach525c9d02018-05-26 10:48:55 -0400290 /* See if user wants to show specific interface */
291 if (unformat
292 (linput, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
293 {
294 si = pool_elt_at_index (im->sw_interfaces, sw_if_index);
295 vec_add1 (sorted_sis, si[0]);
296 }
297 else if (unformat (linput, "address") || unformat (linput, "addr"))
298 show_addresses = 1;
299 else if (unformat (linput, "features") || unformat (linput, "feat"))
300 show_features = 1;
301 else if (unformat (linput, "tag"))
302 show_tag = 1;
303 else if (unformat (linput, "verbose"))
304 verbose = 1;
305 else
306 {
307 error = clib_error_return (0, "unknown input `%U'",
308 format_unformat_error, linput);
309 goto done;
310 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700311 }
Dave Barach525c9d02018-05-26 10:48:55 -0400312 unformat_free (linput);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700313 }
Dave Barach7be864a2016-11-28 11:41:35 -0500314 if (show_features || show_tag)
Damjan Marion22311502016-10-28 20:30:15 +0200315 {
316 if (sw_if_index == ~(u32) 0)
317 return clib_error_return (0, "Interface not specified...");
Dave Barach7be864a2016-11-28 11:41:35 -0500318 }
Damjan Marion22311502016-10-28 20:30:15 +0200319
Dave Barach7be864a2016-11-28 11:41:35 -0500320 if (show_features)
321 {
Dave Barach525c9d02018-05-26 10:48:55 -0400322 vnet_interface_features_show (vm, sw_if_index, verbose);
Eyal Bari942402b2017-07-26 11:57:04 +0300323
324 l2_input_config_t *l2_input = l2input_intf_config (sw_if_index);
325 u32 fb = l2_input->feature_bitmap;
326 /* intf input features are masked by bridge domain */
327 if (l2_input->bridge)
328 fb &= l2input_bd_config (l2_input->bd_index)->feature_bitmap;
Neale Ranns5d9df1d2018-11-09 08:19:27 -0800329 vlib_cli_output (vm, "\nl2-input:\n%U", format_l2_input_features, fb,
330 1);
Eyal Bari942402b2017-07-26 11:57:04 +0300331
332 l2_output_config_t *l2_output = l2output_intf_config (sw_if_index);
333 vlib_cli_output (vm, "\nl2-output:");
334 if (l2_output->out_vtr_flag)
335 vlib_cli_output (vm, "%10s (%s)", "VTR", "--internal--");
336 vlib_cli_output (vm, "%U", format_l2_output_features,
Neale Ranns5d9df1d2018-11-09 08:19:27 -0800337 l2_output->feature_bitmap, 1);
Damjan Marion22311502016-10-28 20:30:15 +0200338 return 0;
339 }
Dave Barach7be864a2016-11-28 11:41:35 -0500340 if (show_tag)
341 {
342 u8 *tag;
343 tag = vnet_get_sw_interface_tag (vnm, sw_if_index);
344 vlib_cli_output (vm, "%U: %s",
345 format_vnet_sw_if_index_name, vnm, sw_if_index,
346 tag ? (char *) tag : "(none)");
347 return 0;
348 }
Damjan Marion22311502016-10-28 20:30:15 +0200349
Ed Warnickecb9cada2015-12-08 15:45:58 -0700350 if (!show_addresses)
Dave Barachba868bb2016-08-08 09:51:21 -0400351 vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700352
Dave Barachba868bb2016-08-08 09:51:21 -0400353 if (vec_len (sorted_sis) == 0) /* Get all interfaces */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700354 {
355 /* Gather interfaces. */
Dave Barachba868bb2016-08-08 09:51:21 -0400356 sorted_sis =
357 vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700358 _vec_len (sorted_sis) = 0;
Dave Barach525c9d02018-05-26 10:48:55 -0400359 /* *INDENT-OFF* */
360 pool_foreach (si, im->sw_interfaces,
361 ({
362 int visible = vnet_swif_is_api_visible (si);
363 if (visible)
364 vec_add1 (sorted_sis, si[0]);}
365 ));
Ole Troand7231612018-06-07 10:17:57 +0200366 /* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700367 /* Sort by name. */
368 vec_sort_with_function (sorted_sis, sw_interface_name_compare);
369 }
370
371 if (show_addresses)
372 {
373 vec_foreach (si, sorted_sis)
Dave Barachba868bb2016-08-08 09:51:21 -0400374 {
Dave Barachba868bb2016-08-08 09:51:21 -0400375 ip4_main_t *im4 = &ip4_main;
376 ip6_main_t *im6 = &ip6_main;
377 ip_lookup_main_t *lm4 = &im4->lookup_main;
378 ip_lookup_main_t *lm6 = &im6->lookup_main;
379 ip_interface_address_t *ia = 0;
Dave Barachba868bb2016-08-08 09:51:21 -0400380 u32 fib_index4 = 0, fib_index6 = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700381
Dave Barachba868bb2016-08-08 09:51:21 -0400382 if (vec_len (im4->fib_index_by_sw_if_index) > si->sw_if_index)
383 fib_index4 = vec_elt (im4->fib_index_by_sw_if_index,
384 si->sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700385
Dave Barachba868bb2016-08-08 09:51:21 -0400386 if (vec_len (im6->fib_index_by_sw_if_index) > si->sw_if_index)
387 fib_index6 = vec_elt (im6->fib_index_by_sw_if_index,
388 si->sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700389
John Lo4478d8e2018-01-12 17:15:25 -0500390 ip4_fib_t *fib4 = ip4_fib_get (fib_index4);
391 ip6_fib_t *fib6 = ip6_fib_get (fib_index6);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700392
Dave Barachba868bb2016-08-08 09:51:21 -0400393 if (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED)
394 vlib_cli_output
395 (vm, "%U (%s): \n unnumbered, use %U",
John Lo4478d8e2018-01-12 17:15:25 -0500396 format_vnet_sw_if_index_name, vnm, si->sw_if_index,
Dave Barachba868bb2016-08-08 09:51:21 -0400397 (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn",
398 format_vnet_sw_if_index_name, vnm, si->unnumbered_sw_if_index);
Dave Barachba868bb2016-08-08 09:51:21 -0400399 else
John Lo4478d8e2018-01-12 17:15:25 -0500400 vlib_cli_output
401 (vm, "%U (%s):",
402 format_vnet_sw_if_index_name, vnm, si->sw_if_index,
403 (si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? "up" : "dn");
Ed Warnickecb9cada2015-12-08 15:45:58 -0700404
Eyal Bari942402b2017-07-26 11:57:04 +0300405 /* Display any L2 info */
406 l2_input_config_t *l2_input = l2input_intf_config (si->sw_if_index);
407 if (l2_input->bridge)
Dave Barachba868bb2016-08-08 09:51:21 -0400408 {
John Lo4478d8e2018-01-12 17:15:25 -0500409 bd_main_t *bdm = &bd_main;
Eyal Bari942402b2017-07-26 11:57:04 +0300410 u32 bd_id = l2input_main.bd_configs[l2_input->bd_index].bd_id;
John Lo4478d8e2018-01-12 17:15:25 -0500411 vlib_cli_output (vm, " L2 bridge bd-id %d idx %d shg %d %s",
412 bd_id, bd_find_index (bdm, bd_id), l2_input->shg,
413 l2_input->bvi ? "bvi" : " ");
Dave Barachba868bb2016-08-08 09:51:21 -0400414 }
Eyal Bari942402b2017-07-26 11:57:04 +0300415 else if (l2_input->xconnect)
John Lo4478d8e2018-01-12 17:15:25 -0500416 vlib_cli_output (vm, " L2 xconnect %U",
417 format_vnet_sw_if_index_name, vnm,
418 l2_input->output_sw_if_index);
Dave Barachba868bb2016-08-08 09:51:21 -0400419
John Lo4478d8e2018-01-12 17:15:25 -0500420 /* *INDENT-OFF* */
Dave Barachba868bb2016-08-08 09:51:21 -0400421 /* Display any IP4 addressing info */
John Lo4478d8e2018-01-12 17:15:25 -0500422 foreach_ip_interface_address (lm4, ia, si->sw_if_index,
423 1 /* honor unnumbered */,
424 ({
425 ip4_address_t *r4 = ip_interface_address_get_address (lm4, ia);
426 if (fib4->table_id)
427 vlib_cli_output (vm, " L3 %U/%d ip4 table-id %d fib-idx %d",
428 format_ip4_address, r4, ia->address_length,
429 fib4->table_id,
430 ip4_fib_index_from_table_id (fib4->table_id));
431 else
432 vlib_cli_output (vm, " L3 %U/%d",
433 format_ip4_address, r4, ia->address_length);
434 }));
435 /* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700436
John Lo4478d8e2018-01-12 17:15:25 -0500437 /* *INDENT-OFF* */
Dave Barachba868bb2016-08-08 09:51:21 -0400438 /* Display any IP6 addressing info */
John Lo4478d8e2018-01-12 17:15:25 -0500439 foreach_ip_interface_address (lm6, ia, si->sw_if_index,
440 1 /* honor unnumbered */,
441 ({
442 ip6_address_t *r6 = ip_interface_address_get_address (lm6, ia);
443 if (fib6->table_id)
444 vlib_cli_output (vm, " L3 %U/%d ip6 table-id %d fib-idx %d",
445 format_ip6_address, r6, ia->address_length,
446 fib6->table_id,
447 ip6_fib_index_from_table_id (fib6->table_id));
448 else
449 vlib_cli_output (vm, " L3 %U/%d",
450 format_ip6_address, r6, ia->address_length);
451 }));
452 /* *INDENT-ON* */
Ole Troand7231612018-06-07 10:17:57 +0200453 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700454 }
Ole Troand7231612018-06-07 10:17:57 +0200455 else
456 {
457 vec_foreach (si, sorted_sis)
458 {
459 vlib_cli_output (vm, "%U\n", format_vnet_sw_interface, vnm, si);
460 }
461 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700462
Dave Barachba868bb2016-08-08 09:51:21 -0400463done:
Ole Troand7231612018-06-07 10:17:57 +0200464 vec_free (sorted_sis);
465 return error;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700466}
467
Dave Barachba868bb2016-08-08 09:51:21 -0400468/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700469VLIB_CLI_COMMAND (show_sw_interfaces_command, static) = {
Dave Barach13ad1f02017-03-26 19:36:18 -0400470 .path = "show interface",
Dave Barach525c9d02018-05-26 10:48:55 -0400471 .short_help = "show interface [address|addr|features|feat] [<interface> [<interface> [..]]] [verbose]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700472 .function = show_sw_interfaces,
473};
Dave Barachba868bb2016-08-08 09:51:21 -0400474/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700475
476/* Root of all interface commands. */
Dave Barachba868bb2016-08-08 09:51:21 -0400477/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700478VLIB_CLI_COMMAND (vnet_cli_interface_command, static) = {
479 .path = "interface",
480 .short_help = "Interface commands",
481};
Dave Barachba868bb2016-08-08 09:51:21 -0400482/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700483
Dave Barachba868bb2016-08-08 09:51:21 -0400484/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700485VLIB_CLI_COMMAND (vnet_cli_set_interface_command, static) = {
486 .path = "set interface",
487 .short_help = "Interface commands",
488};
Dave Barachba868bb2016-08-08 09:51:21 -0400489/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700490
491static clib_error_t *
492clear_interface_counters (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400493 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700494{
Dave Barachba868bb2016-08-08 09:51:21 -0400495 vnet_main_t *vnm = vnet_get_main ();
496 vnet_interface_main_t *im = &vnm->interface_main;
497 vlib_simple_counter_main_t *sm;
498 vlib_combined_counter_main_t *cm;
499 static vnet_main_t **my_vnet_mains;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700500 int i, j, n_counters;
501
502 vec_reset_length (my_vnet_mains);
Dave Barachba868bb2016-08-08 09:51:21 -0400503
Ed Warnickecb9cada2015-12-08 15:45:58 -0700504 for (i = 0; i < vec_len (vnet_mains); i++)
505 {
506 if (vnet_mains[i])
Dave Barachba868bb2016-08-08 09:51:21 -0400507 vec_add1 (my_vnet_mains, vnet_mains[i]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700508 }
509
510 if (vec_len (vnet_mains) == 0)
511 vec_add1 (my_vnet_mains, vnm);
512
513 n_counters = vec_len (im->combined_sw_if_counters);
514
515 for (j = 0; j < n_counters; j++)
516 {
Dave Barachba868bb2016-08-08 09:51:21 -0400517 for (i = 0; i < vec_len (my_vnet_mains); i++)
518 {
519 im = &my_vnet_mains[i]->interface_main;
520 cm = im->combined_sw_if_counters + j;
521 vlib_clear_combined_counters (cm);
522 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700523 }
524
525 n_counters = vec_len (im->sw_if_counters);
526
527 for (j = 0; j < n_counters; j++)
528 {
Dave Barachba868bb2016-08-08 09:51:21 -0400529 for (i = 0; i < vec_len (my_vnet_mains); i++)
530 {
531 im = &my_vnet_mains[i]->interface_main;
532 sm = im->sw_if_counters + j;
533 vlib_clear_simple_counters (sm);
534 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700535 }
536
537 return 0;
538}
539
Billy McFalle9bac692017-08-11 14:05:11 -0400540/*?
541 * Clear the statistics for all interfaces (statistics associated with the
542 * '<em>show interface</em>' command).
543 *
544 * @cliexpar
545 * Example of how to clear the statistics for all interfaces:
546 * @cliexcmd{clear interfaces}
547 ?*/
Dave Barachba868bb2016-08-08 09:51:21 -0400548/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700549VLIB_CLI_COMMAND (clear_interface_counters_command, static) = {
550 .path = "clear interfaces",
Billy McFalle9bac692017-08-11 14:05:11 -0400551 .short_help = "clear interfaces",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700552 .function = clear_interface_counters,
553};
Dave Barachba868bb2016-08-08 09:51:21 -0400554/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700555
Chris Luke16bcf7d2016-09-01 14:31:46 -0400556/**
557 * Parse subinterface names.
558 *
Dave Barachba868bb2016-08-08 09:51:21 -0400559 * The following subinterface syntax is supported. The first two are for
560 * backwards compatability:
561 *
562 * <intf-name> <id>
563 * - a subinterface with the name <intf-name>.<id>. The subinterface
564 * is a single dot1q vlan with vlan id <id> and exact-match semantics.
565 *
566 * <intf-name> <min_id>-<max_id>
567 * - a set of the above subinterfaces, repeating for each id
568 * in the range <min_id> to <max_id>
569 *
570 * In the following, exact-match semantics (i.e. the number of vlan tags on the
571 * packet must match the number of tags in the configuration) are used only if
572 * the keyword exact-match is present. Non-exact match is the default.
573 *
574 * <intf-name> <id> dot1q <outer_id> [exact-match]
575 * - a subinterface with the name <intf-name>.<id>. The subinterface
576 * is a single dot1q vlan with vlan id <outer_id>.
577 *
578 * <intf-name> <id> dot1q any [exact-match]
579 * - a subinterface with the name <intf-name>.<id>. The subinterface
580 * is a single dot1q vlan with any vlan id.
581 *
582 * <intf-name> <id> dot1q <outer_id> inner-dot1q <inner_id> [exact-match]
583 * - a subinterface with the name <intf-name>.<id>. The subinterface
584 * is a double dot1q vlan with outer vlan id <outer_id> and inner vlan id
585 * <inner_id>.
586 *
587 * <intf-name> <id> dot1q <outer_id> inner-dot1q any [exact-match]
588 * - a subinterface with the name <intf-name>.<id>. The subinterface
589 * is a double dot1q vlan with outer vlan id <id> and any inner vlan id.
590 *
591 * <intf-name> <id> dot1q any inner-dot1q any [exact-match]
592 *
593 * - a subinterface with the name <intf-name>.<id>. The subinterface
594 * is a double dot1q vlan with any outer vlan id and any inner vlan id.
595 *
596 * For each of the above CLI, there is a duplicate that uses the keyword
597 * "dot1ad" in place of the first "dot1q". These interfaces use ethertype
598 * 0x88ad in place of 0x8100 for the outer ethertype. Note that for double-
599 * tagged packets the inner ethertype is always 0x8100. Also note that
600 * the dot1q and dot1ad naming spaces are independent, so it is legal to
601 * have both "Gig3/0/0.1 dot1q 100" and "Gig3/0/0.2 dot1ad 100". For example:
602 *
603 * <intf-name> <id> dot1ad <outer_id> inner-dot1q <inner_id> [exact-match]
604 * - a subinterface with the name <intf-name>.<id>. The subinterface
605 * is a double dot1ad vlan with outer vlan id <outer_id> and inner vlan
606 * id <inner_id>.
607 *
608 * <intf-name> <id> untagged
609 * - a subinterface with the name <intf-name>.<id>. The subinterface
610 * has no vlan tags. Only one can be specified per interface.
611 *
612 * <intf-name> <id> default
613 * - a subinterface with the name <intf-name>.<id>. This is associated
614 * with a packet that did not match any other configured subinterface
615 * on this interface. Only one can be specified per interface.
616 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700617
618static clib_error_t *
Dave Barachba868bb2016-08-08 09:51:21 -0400619parse_vlan_sub_interfaces (unformat_input_t * input,
620 vnet_sw_interface_t * template)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700621{
Dave Barachba868bb2016-08-08 09:51:21 -0400622 clib_error_t *error = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700623 u32 inner_vlan, outer_vlan;
624
Dave Barachba868bb2016-08-08 09:51:21 -0400625 if (unformat (input, "any inner-dot1q any"))
626 {
627 template->sub.eth.flags.two_tags = 1;
628 template->sub.eth.flags.outer_vlan_id_any = 1;
629 template->sub.eth.flags.inner_vlan_id_any = 1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700630 }
Dave Barachba868bb2016-08-08 09:51:21 -0400631 else if (unformat (input, "any"))
632 {
633 template->sub.eth.flags.one_tag = 1;
634 template->sub.eth.flags.outer_vlan_id_any = 1;
635 }
636 else if (unformat (input, "%d inner-dot1q any", &outer_vlan))
637 {
638 template->sub.eth.flags.two_tags = 1;
639 template->sub.eth.flags.inner_vlan_id_any = 1;
640 template->sub.eth.outer_vlan_id = outer_vlan;
641 }
642 else if (unformat (input, "%d inner-dot1q %d", &outer_vlan, &inner_vlan))
643 {
644 template->sub.eth.flags.two_tags = 1;
645 template->sub.eth.outer_vlan_id = outer_vlan;
646 template->sub.eth.inner_vlan_id = inner_vlan;
647 }
648 else if (unformat (input, "%d", &outer_vlan))
649 {
650 template->sub.eth.flags.one_tag = 1;
651 template->sub.eth.outer_vlan_id = outer_vlan;
652 }
653 else
654 {
655 error = clib_error_return (0, "expected dot1q config, got `%U'",
656 format_unformat_error, input);
657 goto done;
658 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700659
Dave Barachba868bb2016-08-08 09:51:21 -0400660 if (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
661 {
662 if (unformat (input, "exact-match"))
663 {
664 template->sub.eth.flags.exact_match = 1;
665 }
666 }
667
668done:
Ed Warnickecb9cada2015-12-08 15:45:58 -0700669 return error;
670}
671
672static clib_error_t *
673create_sub_interfaces (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400674 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700675{
Dave Barachba868bb2016-08-08 09:51:21 -0400676 vnet_main_t *vnm = vnet_get_main ();
677 clib_error_t *error = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700678 u32 hw_if_index, sw_if_index;
Dave Barachba868bb2016-08-08 09:51:21 -0400679 vnet_hw_interface_t *hi;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700680 u32 id, id_min, id_max;
681 vnet_sw_interface_t template;
682
683 hw_if_index = ~0;
Dave Barachba868bb2016-08-08 09:51:21 -0400684 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700685 {
686 error = clib_error_return (0, "unknown interface `%U'",
687 format_unformat_error, input);
688 goto done;
689 }
690
Dave Barachb7b92992018-10-17 10:38:51 -0400691 clib_memset (&template, 0, sizeof (template));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700692 template.sub.eth.raw_flags = 0;
693
Dave Barachba868bb2016-08-08 09:51:21 -0400694 if (unformat (input, "%d default", &id_min))
695 {
696 id_max = id_min;
697 template.sub.eth.flags.default_sub = 1;
698 }
699 else if (unformat (input, "%d untagged", &id_min))
700 {
701 id_max = id_min;
702 template.sub.eth.flags.no_tags = 1;
703 template.sub.eth.flags.exact_match = 1;
704 }
705 else if (unformat (input, "%d dot1q", &id_min))
706 {
707 /* parse dot1q config */
708 id_max = id_min;
709 error = parse_vlan_sub_interfaces (input, &template);
710 if (error)
711 goto done;
712 }
713 else if (unformat (input, "%d dot1ad", &id_min))
714 {
715 /* parse dot1ad config */
716 id_max = id_min;
717 template.sub.eth.flags.dot1ad = 1;
718 error = parse_vlan_sub_interfaces (input, &template);
719 if (error)
720 goto done;
721 }
722 else if (unformat (input, "%d-%d", &id_min, &id_max))
723 {
724 template.sub.eth.flags.one_tag = 1;
Dave Barachba868bb2016-08-08 09:51:21 -0400725 template.sub.eth.flags.exact_match = 1;
726 if (id_min > id_max)
727 goto id_error;
728 }
729 else if (unformat (input, "%d", &id_min))
730 {
731 id_max = id_min;
732 template.sub.eth.flags.one_tag = 1;
733 template.sub.eth.outer_vlan_id = id_min;
734 template.sub.eth.flags.exact_match = 1;
735 }
736 else
737 {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700738 id_error:
739 error = clib_error_return (0, "expected ID or ID MIN-MAX, got `%U'",
740 format_unformat_error, input);
741 goto done;
Dave Barachba868bb2016-08-08 09:51:21 -0400742 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700743
744 hi = vnet_get_hw_interface (vnm, hw_if_index);
John Lobcebbb92016-04-05 15:47:43 -0400745
Dave Barachba868bb2016-08-08 09:51:21 -0400746 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
747 {
748 error =
749 clib_error_return (0,
750 "not allowed as %v belong to a BondEthernet interface",
751 hi->name);
752 goto done;
753 }
John Lobcebbb92016-04-05 15:47:43 -0400754
Ed Warnickecb9cada2015-12-08 15:45:58 -0700755 for (id = id_min; id <= id_max; id++)
756 {
Dave Barachba868bb2016-08-08 09:51:21 -0400757 uword *p;
758 vnet_interface_main_t *im = &vnm->interface_main;
759 u64 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
760 u64 *kp;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700761
762 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
763 if (p)
Dave Barachba868bb2016-08-08 09:51:21 -0400764 {
765 if (CLIB_DEBUG > 0)
766 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
767 hi->sw_if_index, id);
768 continue;
769 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700770
771 kp = clib_mem_alloc (sizeof (*kp));
772 *kp = sup_and_sub_key;
773
774 template.type = VNET_SW_INTERFACE_TYPE_SUB;
Eyal Baric5b13602016-11-24 19:42:43 +0200775 template.flood_class = VNET_FLOOD_CLASS_NORMAL;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700776 template.sup_sw_if_index = hi->sw_if_index;
777 template.sub.id = id;
Eyal Baria4509cf2016-09-26 09:24:09 +0300778 if (id_min < id_max)
779 template.sub.eth.outer_vlan_id = id;
780
Ed Warnickecb9cada2015-12-08 15:45:58 -0700781 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
Dave Barachba868bb2016-08-08 09:51:21 -0400782 if (error)
783 goto done;
Dave Barach16ad6ae2016-07-28 17:55:30 -0400784
Ed Warnickecb9cada2015-12-08 15:45:58 -0700785 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
786 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
Dave Barachba868bb2016-08-08 09:51:21 -0400787 vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name,
788 vnet_get_main (), sw_if_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700789 }
790
Dave Barachba868bb2016-08-08 09:51:21 -0400791done:
Ed Warnickecb9cada2015-12-08 15:45:58 -0700792 return error;
793}
794
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700795/*?
Billy McFalle9bac692017-08-11 14:05:11 -0400796 * This command is used to add VLAN IDs to interfaces, also known as subinterfaces.
797 * The primary input to this command is the '<em>interface</em>' and '<em>subId</em>'
798 * (subinterface Id) parameters. If no additional VLAN ID is provide, the VLAN ID is
799 * assumed to be the '<em>subId</em>'. The VLAN ID and '<em>subId</em>' can be different,
800 * but this is not recommended.
801 *
802 * This command has several variations:
803 * - <b>create sub-interfaces <interface> <subId></b> - Create a subinterface to
804 * process packets with a given 802.1q VLAN ID (same value as the '<em>subId</em>').
805 *
806 * - <b>create sub-interfaces <interface> <subId> default</b> - Adding the
807 * '<em>default</em>' parameter indicates that packets with VLAN IDs that do not
808 * match any other subinterfaces should be sent to this subinterface.
809 *
810 * - <b>create sub-interfaces <interface> <subId> untagged</b> - Adding the
811 * '<em>untagged</em>' parameter indicates that packets no VLAN IDs should be sent
812 * to this subinterface.
813 *
814 * - <b>create sub-interfaces <interface> <subId>-<subId></b> - Create a range of
815 * subinterfaces to handle a range of VLAN IDs.
816 *
817 * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any [exact-match]</b> -
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700818 * Use this command to specify the outer VLAN ID, to either be explicit or to make the
Billy McFalle9bac692017-08-11 14:05:11 -0400819 * VLAN ID different from the '<em>subId</em>'.
820 *
821 * - <b>create sub-interfaces <interface> <subId> dot1q|dot1ad <vlanId>|any inner-dot1q
822 * <vlanId>|any [exact-match]</b> - Use this command to specify the outer VLAN ID and
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700823 * the inner VLAN ID.
Billy McFalle9bac692017-08-11 14:05:11 -0400824 *
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700825 * When '<em>dot1q</em>' or '<em>dot1ad</em>' is explicitly entered, subinterfaces
Billy McFalle9bac692017-08-11 14:05:11 -0400826 * can be configured as either exact-match or non-exact match. Non-exact match is the CLI
827 * default. If '<em>exact-match</em>' is specified, packets must have the same number of
828 * VLAN tags as the configuration. For non-exact-match, packets must at least that number
829 * of tags. L3 (routed) interfaces must be configured as exact-match. L2 interfaces are
830 * typically configured as non-exact-match. If '<em>dot1q</em>' or '<em>dot1ad</em>' is NOT
831 * entered, then the default behavior is exact-match.
832 *
833 * Use the '<em>show interface</em>' command to display all subinterfaces.
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700834 *
835 * @cliexpar
Billy McFalle9bac692017-08-11 14:05:11 -0400836 * @parblock
837 * Example of how to create a VLAN subinterface 11 to process packets on 802.1q VLAN ID 11:
838 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700839 *
Billy McFalle9bac692017-08-11 14:05:11 -0400840 * The previous example is shorthand and is equivalent to:
841 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 11 exact-match}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700842 *
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700843 *
Billy McFalle9bac692017-08-11 14:05:11 -0400844 * Example of how to create a subinterface number that is different from the VLAN ID:
845 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700846 *
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700847 *
Billy McFalle9bac692017-08-11 14:05:11 -0400848 * Examples of how to create q-in-q and q-in-any subinterfaces:
849 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1q 100 inner-dot1q 200}
850 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1q 100 inner-dot1q any}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700851 *
Billy McFalle9bac692017-08-11 14:05:11 -0400852 * Examples of how to create dot1ad interfaces:
853 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 11 dot1ad 11}
854 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 12 dot1ad 100 inner-dot1q 200}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700855 *
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700856 *
Billy McFalle9bac692017-08-11 14:05:11 -0400857 * Examples of '<em>exact-match</em>' versus non-exact match. A packet with
858 * outer VLAN 100 and inner VLAN 200 would match this interface, because the default
859 * is non-exact match:
860 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700861 *
Billy McFalle9bac692017-08-11 14:05:11 -0400862 * However, the same packet would NOT match this interface because '<em>exact-match</em>'
863 * is specified and only one VLAN is configured, but packet contains two VLANs:
864 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 dot1q 100 exact-match}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700865 *
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700866 *
Billy McFalle9bac692017-08-11 14:05:11 -0400867 * Example of how to created a subinterface to process untagged packets:
868 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 5 untagged}
869 *
870 * Example of how to created a subinterface to process any packet with a VLAN ID that
871 * does not match any other subinterface:
872 * @cliexcmd{create sub-interfaces GigabitEthernet2/0/0 7 default}
873 *
874 * When subinterfaces are created, they are in the down state. Example of how to
875 * enable a newly created subinterface:
876 * @cliexcmd{set interface GigabitEthernet2/0/0.7 up}
877 * @endparblock
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700878 ?*/
Billy McFalle9bac692017-08-11 14:05:11 -0400879/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700880VLIB_CLI_COMMAND (create_sub_interfaces_command, static) = {
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700881 .path = "create sub-interfaces",
Billy McFalle9bac692017-08-11 14:05:11 -0400882 .short_help = "create sub-interfaces <interface> "
883 "{<subId> [default|untagged]} | "
884 "{<subId>-<subId>} | "
885 "{<subId> dot1q|dot1ad <vlanId>|any [inner-dot1q <vlanId>|any] [exact-match]}",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700886 .function = create_sub_interfaces,
887};
Dave Barachba868bb2016-08-08 09:51:21 -0400888/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700889
890static clib_error_t *
891set_state (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400892 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700893{
Dave Barachba868bb2016-08-08 09:51:21 -0400894 vnet_main_t *vnm = vnet_get_main ();
895 clib_error_t *error;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700896 u32 sw_if_index, flags;
897
898 sw_if_index = ~0;
Dave Barachba868bb2016-08-08 09:51:21 -0400899 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700900 {
901 error = clib_error_return (0, "unknown interface `%U'",
902 format_unformat_error, input);
903 goto done;
904 }
905
Dave Barachba868bb2016-08-08 09:51:21 -0400906 if (!unformat (input, "%U", unformat_vnet_sw_interface_flags, &flags))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700907 {
908 error = clib_error_return (0, "unknown flags `%U'",
909 format_unformat_error, input);
910 goto done;
911 }
912
913 error = vnet_sw_interface_set_flags (vnm, sw_if_index, flags);
914 if (error)
915 goto done;
916
Dave Barachba868bb2016-08-08 09:51:21 -0400917done:
Ed Warnickecb9cada2015-12-08 15:45:58 -0700918 return error;
919}
920
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700921
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700922/*?
Billy McFalle9bac692017-08-11 14:05:11 -0400923 * This command is used to change the admin state (up/down) of an interface.
924 *
925 * If an interface is down, the optional '<em>punt</em>' flag can also be set.
926 * The '<em>punt</em>' flag implies the interface is disabled for forwarding
927 * but punt all traffic to slow-path. Use the '<em>enable</em>' flag to clear
928 * '<em>punt</em>' flag (interface is still down).
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700929 *
930 * @cliexpar
Billy McFalle9bac692017-08-11 14:05:11 -0400931 * Example of how to configure the admin state of an interface to '<em>up</em?':
932 * @cliexcmd{set interface state GigabitEthernet2/0/0 up}
933 * Example of how to configure the admin state of an interface to '<em>down</em?':
934 * @cliexcmd{set interface state GigabitEthernet2/0/0 down}
Keith Burns (alagalah)6ef7bb92016-09-10 14:55:04 -0700935 ?*/
Billy McFalle9bac692017-08-11 14:05:11 -0400936/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700937VLIB_CLI_COMMAND (set_state_command, static) = {
938 .path = "set interface state",
Billy McFalle9bac692017-08-11 14:05:11 -0400939 .short_help = "set interface state <interface> [up|down|punt|enable]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700940 .function = set_state,
941};
Dave Barachba868bb2016-08-08 09:51:21 -0400942/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700943
944static clib_error_t *
945set_unnumbered (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400946 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700947{
Dave Barachba868bb2016-08-08 09:51:21 -0400948 vnet_main_t *vnm = vnet_get_main ();
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700949 u32 unnumbered_sw_if_index = ~0;
950 u32 inherit_from_sw_if_index = ~0;
951 int enable = 1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700952
Igor Mikhailov (imichail)ab3e42b2016-09-25 15:11:53 -0700953 if (unformat (input, "%U use %U",
954 unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
955 unformat_vnet_sw_interface, vnm, &inherit_from_sw_if_index))
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700956 enable = 1;
Igor Mikhailov (imichail)ab3e42b2016-09-25 15:11:53 -0700957 else if (unformat (input, "del %U",
958 unformat_vnet_sw_interface, vnm,
959 &unnumbered_sw_if_index))
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700960 enable = 0;
Igor Mikhailov (imichail)ab3e42b2016-09-25 15:11:53 -0700961 else
962 return clib_error_return (0, "parse error '%U'",
963 format_unformat_error, input);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700964
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700965 if (~0 == unnumbered_sw_if_index)
966 return clib_error_return (0, "Specify the unnumbered interface");
967 if (enable && ~0 == inherit_from_sw_if_index)
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700968 return clib_error_return (0, "When enabling unnumbered specify the"
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700969 " IP enabled interface that it uses");
Neale Ranns898273f2017-03-18 02:57:38 -0700970
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700971 vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
972 inherit_from_sw_if_index, enable);
Neale Ranns898273f2017-03-18 02:57:38 -0700973
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700974 return (NULL);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700975}
976
Dave Barachba868bb2016-08-08 09:51:21 -0400977/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700978VLIB_CLI_COMMAND (set_unnumbered_command, static) = {
979 .path = "set interface unnumbered",
Billy McFalle9bac692017-08-11 14:05:11 -0400980 .short_help = "set interface unnumbered [<interface> use <interface> | del <interface>]",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700981 .function = set_unnumbered,
982};
Dave Barachba868bb2016-08-08 09:51:21 -0400983/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700984
985
986
987static clib_error_t *
988set_hw_class (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -0400989 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700990{
Dave Barachba868bb2016-08-08 09:51:21 -0400991 vnet_main_t *vnm = vnet_get_main ();
992 vnet_interface_main_t *im = &vnm->interface_main;
993 clib_error_t *error;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700994 u32 hw_if_index, hw_class_index;
995
996 hw_if_index = ~0;
Dave Barachba868bb2016-08-08 09:51:21 -0400997 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700998 {
999 error = clib_error_return (0, "unknown hardware interface `%U'",
1000 format_unformat_error, input);
1001 goto done;
1002 }
1003
Dave Barachba868bb2016-08-08 09:51:21 -04001004 if (!unformat_user (input, unformat_hash_string,
1005 im->hw_interface_class_by_name, &hw_class_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -07001006 {
1007 error = clib_error_return (0, "unknown hardware class `%U'",
1008 format_unformat_error, input);
1009 goto done;
1010 }
1011
1012 error = vnet_hw_interface_set_class (vnm, hw_if_index, hw_class_index);
1013 if (error)
1014 goto done;
1015
Dave Barachba868bb2016-08-08 09:51:21 -04001016done:
Ed Warnickecb9cada2015-12-08 15:45:58 -07001017 return error;
1018}
1019
Dave Barachba868bb2016-08-08 09:51:21 -04001020/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -07001021VLIB_CLI_COMMAND (set_hw_class_command, static) = {
1022 .path = "set interface hw-class",
1023 .short_help = "Set interface hardware class",
1024 .function = set_hw_class,
1025};
Dave Barachba868bb2016-08-08 09:51:21 -04001026/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -07001027
Dave Barachba868bb2016-08-08 09:51:21 -04001028static clib_error_t *
1029vnet_interface_cli_init (vlib_main_t * vm)
1030{
1031 return 0;
1032}
Ed Warnickecb9cada2015-12-08 15:45:58 -07001033
1034VLIB_INIT_FUNCTION (vnet_interface_cli_init);
1035
Dave Barachba868bb2016-08-08 09:51:21 -04001036static clib_error_t *
Ed Warnickecb9cada2015-12-08 15:45:58 -07001037renumber_interface_command_fn (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -04001038 unformat_input_t * input,
1039 vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -07001040{
1041 u32 hw_if_index;
1042 u32 new_dev_instance;
Dave Barachba868bb2016-08-08 09:51:21 -04001043 vnet_main_t *vnm = vnet_get_main ();
Ed Warnickecb9cada2015-12-08 15:45:58 -07001044 int rv;
1045
Dave Barachba868bb2016-08-08 09:51:21 -04001046 if (!unformat_user (input, unformat_vnet_hw_interface, vnm, &hw_if_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -07001047 return clib_error_return (0, "unknown hardware interface `%U'",
Dave Barachba868bb2016-08-08 09:51:21 -04001048 format_unformat_error, input);
Ed Warnickecb9cada2015-12-08 15:45:58 -07001049
Dave Barachba868bb2016-08-08 09:51:21 -04001050 if (!unformat (input, "%d", &new_dev_instance))
Ed Warnickecb9cada2015-12-08 15:45:58 -07001051 return clib_error_return (0, "new dev instance missing");
1052
1053 rv = vnet_interface_name_renumber (hw_if_index, new_dev_instance);
1054
1055 switch (rv)
1056 {
1057 case 0:
1058 break;
1059
1060 default:
1061 return clib_error_return (0, "vnet_interface_name_renumber returned %d",
Dave Barachba868bb2016-08-08 09:51:21 -04001062 rv);
Ed Warnickecb9cada2015-12-08 15:45:58 -07001063
1064 }
1065
1066 return 0;
1067}
1068
1069
Dave Barachba868bb2016-08-08 09:51:21 -04001070/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -07001071VLIB_CLI_COMMAND (renumber_interface_command, static) = {
1072 .path = "renumber interface",
Billy McFalle9bac692017-08-11 14:05:11 -04001073 .short_help = "renumber interface <interface> <new-dev-instance>",
Ed Warnickecb9cada2015-12-08 15:45:58 -07001074 .function = renumber_interface_command_fn,
1075};
Dave Barachba868bb2016-08-08 09:51:21 -04001076/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -07001077
Damjan Marion8358ff92016-04-15 14:26:00 +02001078static clib_error_t *
1079promiscuous_cmd (vlib_main_t * vm,
Dave Barachba868bb2016-08-08 09:51:21 -04001080 unformat_input_t * input, vlib_cli_command_t * cmd)
Damjan Marion8358ff92016-04-15 14:26:00 +02001081{
Dave Barachba868bb2016-08-08 09:51:21 -04001082 vnet_main_t *vnm = vnet_get_main ();
Damjan Marion8358ff92016-04-15 14:26:00 +02001083 u32 hw_if_index;
1084 u32 flags = ETHERNET_INTERFACE_FLAG_ACCEPT_ALL;
Dave Barachba868bb2016-08-08 09:51:21 -04001085 ethernet_main_t *em = &ethernet_main;
1086 ethernet_interface_t *eif;
Damjan Marion8358ff92016-04-15 14:26:00 +02001087
1088 if (unformat (input, "on %U",
Dave Barachba868bb2016-08-08 09:51:21 -04001089 unformat_vnet_hw_interface, vnm, &hw_if_index))
Damjan Marion8358ff92016-04-15 14:26:00 +02001090 ;
1091 else if (unformat (input, "off %U",
Dave Barachba868bb2016-08-08 09:51:21 -04001092 unformat_ethernet_interface, vnm, &hw_if_index))
Damjan Marion8358ff92016-04-15 14:26:00 +02001093 flags = 0;
1094 else
1095 return clib_error_return (0, "unknown input `%U'",
Dave Barachba868bb2016-08-08 09:51:21 -04001096 format_unformat_error, input);
Damjan Marion8358ff92016-04-15 14:26:00 +02001097
1098 eif = ethernet_get_interface (em, hw_if_index);
1099 if (!eif)
1100 return clib_error_return (0, "not supported");
1101
1102 ethernet_set_flags (vnm, hw_if_index, flags);
1103 return 0;
1104}
1105
Dave Barachba868bb2016-08-08 09:51:21 -04001106/* *INDENT-OFF* */
Damjan Marion8358ff92016-04-15 14:26:00 +02001107VLIB_CLI_COMMAND (set_interface_promiscuous_cmd, static) = {
1108 .path = "set interface promiscuous",
Billy McFalle9bac692017-08-11 14:05:11 -04001109 .short_help = "set interface promiscuous [on|off] <interface>",
Damjan Marion8358ff92016-04-15 14:26:00 +02001110 .function = promiscuous_cmd,
1111};
Dave Barachba868bb2016-08-08 09:51:21 -04001112/* *INDENT-ON* */
Damjan Marion8358ff92016-04-15 14:26:00 +02001113
1114static clib_error_t *
1115mtu_cmd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
1116{
Dave Barachba868bb2016-08-08 09:51:21 -04001117 vnet_main_t *vnm = vnet_get_main ();
Ole Troand7231612018-06-07 10:17:57 +02001118 u32 hw_if_index, sw_if_index, mtu;
Damjan Marionfe7d4a22018-04-13 19:43:39 +02001119 ethernet_main_t *em = &ethernet_main;
Ole Troand7231612018-06-07 10:17:57 +02001120 u32 mtus[VNET_N_MTU] = { 0, 0, 0, 0 };
Damjan Marion8358ff92016-04-15 14:26:00 +02001121
Damjan Marionfe7d4a22018-04-13 19:43:39 +02001122 if (unformat (input, "%d %U", &mtu,
1123 unformat_vnet_hw_interface, vnm, &hw_if_index))
Damjan Marion8358ff92016-04-15 14:26:00 +02001124 {
Ole Troand7231612018-06-07 10:17:57 +02001125 /*
1126 * Change physical MTU on interface. Only supported for Ethernet
1127 * interfaces
1128 */
Damjan Marionfe7d4a22018-04-13 19:43:39 +02001129 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1130 ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index);
1131
1132 if (!eif)
1133 return clib_error_return (0, "not supported");
1134
1135 if (mtu < hi->min_supported_packet_bytes)
1136 return clib_error_return (0, "Invalid mtu (%d): "
1137 "must be >= min pkt bytes (%d)", mtu,
1138 hi->min_supported_packet_bytes);
1139
1140 if (mtu > hi->max_supported_packet_bytes)
1141 return clib_error_return (0, "Invalid mtu (%d): must be <= (%d)", mtu,
1142 hi->max_supported_packet_bytes);
1143
1144 vnet_hw_interface_set_mtu (vnm, hw_if_index, mtu);
Ole Troand7231612018-06-07 10:17:57 +02001145 goto done;
Damjan Marion8358ff92016-04-15 14:26:00 +02001146 }
Ole Troand7231612018-06-07 10:17:57 +02001147 else if (unformat (input, "packet %d %U", &mtu,
1148 unformat_vnet_sw_interface, vnm, &sw_if_index))
1149 /* Set default packet MTU (including L3 header */
1150 mtus[VNET_MTU_L3] = mtu;
1151 else if (unformat (input, "ip4 %d %U", &mtu,
1152 unformat_vnet_sw_interface, vnm, &sw_if_index))
1153 mtus[VNET_MTU_IP4] = mtu;
1154 else if (unformat (input, "ip6 %d %U", &mtu,
1155 unformat_vnet_sw_interface, vnm, &sw_if_index))
1156 mtus[VNET_MTU_IP6] = mtu;
1157 else if (unformat (input, "mpls %d %U", &mtu,
1158 unformat_vnet_sw_interface, vnm, &sw_if_index))
1159 mtus[VNET_MTU_MPLS] = mtu;
Damjan Marion8358ff92016-04-15 14:26:00 +02001160 else
Damjan Marionfe7d4a22018-04-13 19:43:39 +02001161 return clib_error_return (0, "unknown input `%U'",
1162 format_unformat_error, input);
Ole Troand7231612018-06-07 10:17:57 +02001163
1164 vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, mtus);
1165
1166done:
Damjan Marion8358ff92016-04-15 14:26:00 +02001167 return 0;
1168}
1169
Dave Barachba868bb2016-08-08 09:51:21 -04001170/* *INDENT-OFF* */
Damjan Marion8358ff92016-04-15 14:26:00 +02001171VLIB_CLI_COMMAND (set_interface_mtu_cmd, static) = {
1172 .path = "set interface mtu",
Ole Troand7231612018-06-07 10:17:57 +02001173 .short_help = "set interface mtu [packet|ip4|ip6|mpls] <value> <interface>",
Damjan Marion8358ff92016-04-15 14:26:00 +02001174 .function = mtu_cmd,
1175};
Dave Barachba868bb2016-08-08 09:51:21 -04001176/* *INDENT-ON* */
Damjan Marion8358ff92016-04-15 14:26:00 +02001177
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001178static clib_error_t *
1179set_interface_mac_address (vlib_main_t * vm, unformat_input_t * input,
1180 vlib_cli_command_t * cmd)
1181{
1182 vnet_main_t *vnm = vnet_get_main ();
Neale Rannsd867a7c2017-10-04 02:29:07 -07001183 vnet_sw_interface_t *si = NULL;
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001184 clib_error_t *error = 0;
1185 u32 sw_if_index = ~0;
John Lo62fcc0a2017-10-31 14:31:10 -04001186 u8 mac[6] = { 0 };
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001187
1188 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
1189 {
1190 error = clib_error_return (0, "unknown interface `%U'",
1191 format_unformat_error, input);
1192 goto done;
1193 }
John Lo62fcc0a2017-10-31 14:31:10 -04001194 if (!unformat_user (input, unformat_ethernet_address, mac))
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001195 {
1196 error = clib_error_return (0, "expected mac address `%U'",
1197 format_unformat_error, input);
1198 goto done;
1199 }
Neale Rannsd867a7c2017-10-04 02:29:07 -07001200 si = vnet_get_sw_interface (vnm, sw_if_index);
1201 error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, mac);
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001202done:
1203 return error;
1204}
1205
1206/*?
1207 * The '<em>set interface mac address </em>' command allows to set MAC address of given interface.
1208 * In case of NIC interfaces the one has to support MAC address change. A side effect of MAC address
1209 * change are changes of MAC addresses in FIB tables (ipv4 and ipv6).
1210 *
1211 * @cliexpar
1212 * @parblock
1213 * Example of how to change MAC Address of interface:
1214 * @cliexcmd{set interface mac address GigabitEthernet0/8/0 aa:bb:cc:dd:ee:01}
1215 * @cliexcmd{set interface mac address host-vpp0 aa:bb:cc:dd:ee:02}
1216 * @cliexcmd{set interface mac address tap-0 aa:bb:cc:dd:ee:03}
1217 * @cliexcmd{set interface mac address pg0 aa:bb:cc:dd:ee:04}
1218 * @endparblock
1219?*/
1220/* *INDENT-OFF* */
1221VLIB_CLI_COMMAND (set_interface_mac_address_cmd, static) = {
1222 .path = "set interface mac address",
Billy McFalle9bac692017-08-11 14:05:11 -04001223 .short_help = "set interface mac address <interface> <mac-address>",
Pavel Kotucekc631f2d2016-09-26 10:40:02 +02001224 .function = set_interface_mac_address,
1225};
1226/* *INDENT-ON* */
1227
Dave Barach7be864a2016-11-28 11:41:35 -05001228static clib_error_t *
1229set_tag (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd)
1230{
1231 vnet_main_t *vnm = vnet_get_main ();
1232 u32 sw_if_index = ~0;
1233 u8 *tag = 0;
1234
1235 if (!unformat (input, "%U %s", unformat_vnet_sw_interface,
1236 vnm, &sw_if_index, &tag))
1237 return clib_error_return (0, "unknown input `%U'",
1238 format_unformat_error, input);
1239
1240 vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
1241
1242 return 0;
1243}
1244
1245/* *INDENT-OFF* */
1246VLIB_CLI_COMMAND (set_tag_command, static) = {
1247 .path = "set interface tag",
Billy McFalle9bac692017-08-11 14:05:11 -04001248 .short_help = "set interface tag <interface> <tag>",
Dave Barach7be864a2016-11-28 11:41:35 -05001249 .function = set_tag,
1250};
1251/* *INDENT-ON* */
1252
1253static clib_error_t *
1254clear_tag (vlib_main_t * vm, unformat_input_t * input,
1255 vlib_cli_command_t * cmd)
1256{
1257 vnet_main_t *vnm = vnet_get_main ();
1258 u32 sw_if_index = ~0;
1259
1260 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1261 return clib_error_return (0, "unknown input `%U'",
1262 format_unformat_error, input);
1263
1264 vnet_clear_sw_interface_tag (vnm, sw_if_index);
1265
1266 return 0;
1267}
1268
1269/* *INDENT-OFF* */
1270VLIB_CLI_COMMAND (clear_tag_command, static) = {
1271 .path = "clear interface tag",
Billy McFalle9bac692017-08-11 14:05:11 -04001272 .short_help = "clear interface tag <interface>",
Dave Barach7be864a2016-11-28 11:41:35 -05001273 .function = clear_tag,
1274};
1275/* *INDENT-ON* */
1276
Damjan Marion44036902017-04-28 12:29:15 +02001277static clib_error_t *
Neale Ranns1855b8e2018-07-11 10:31:26 -07001278set_ip_directed_broadcast (vlib_main_t * vm,
1279 unformat_input_t * input, vlib_cli_command_t * cmd)
1280{
1281 vnet_main_t *vnm = vnet_get_main ();
1282 u32 sw_if_index = ~0;
1283 u8 enable = 0;
1284
1285 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
1286 else if (unformat (input, "enable"))
1287 enable = 1;
1288 else if (unformat (input, "disable"))
1289 enable = 0;
1290 else
1291 return clib_error_return (0, "unknown input: `%U'",
1292 format_unformat_error, input);
1293
1294 if (~0 == sw_if_index)
1295 return clib_error_return (0, "specify an interface: `%U'",
1296 format_unformat_error, input);
1297
1298 vnet_sw_interface_ip_directed_broadcast (vnm, sw_if_index, enable);
1299
1300 return 0;
1301}
1302
1303/*?
1304 * This command is used to enable/disable IP directed broadcast
1305 * If directed broadcast is enabled a packet sent to the interface's
1306 * subnet broadcast address will be sent L2 broadcast on the interface,
1307 * otherwise it is dropped.
1308 ?*/
1309/* *INDENT-OFF* */
1310VLIB_CLI_COMMAND (set_ip_directed_broadcast_command, static) = {
1311 .path = "set interface ip directed-broadcast",
1312 .short_help = "set interface enable <interface> <enable|disable>",
1313 .function = set_ip_directed_broadcast,
1314};
1315/* *INDENT-ON* */
1316
1317static clib_error_t *
Stevene3a395c2017-05-09 16:19:50 -07001318set_hw_interface_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
1319 u32 queue_id, vnet_hw_interface_rx_mode mode)
1320{
1321 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
1322 vnet_device_class_t *dev_class =
1323 vnet_get_device_class (vnm, hw->dev_class_index);
1324 clib_error_t *error;
1325 vnet_hw_interface_rx_mode old_mode;
1326 int rv;
1327
Damjan Marion4e53a0d2017-06-21 14:29:44 +02001328 if (mode == VNET_HW_INTERFACE_RX_MODE_DEFAULT)
1329 mode = hw->default_rx_mode;
1330
Stevene3a395c2017-05-09 16:19:50 -07001331 rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &old_mode);
1332 switch (rv)
1333 {
1334 case 0:
1335 if (old_mode == mode)
1336 return 0; /* same rx-mode, no change */
1337 break;
1338 case VNET_API_ERROR_INVALID_INTERFACE:
1339 return clib_error_return (0, "invalid interface");
Stevenbd8a6112017-07-30 10:29:26 -07001340 case VNET_API_ERROR_INVALID_QUEUE:
1341 return clib_error_return (0, "invalid queue");
Stevene3a395c2017-05-09 16:19:50 -07001342 default:
1343 return clib_error_return (0, "unknown error");
1344 }
1345
1346 if (dev_class->rx_mode_change_function)
1347 {
1348 error = dev_class->rx_mode_change_function (vnm, hw_if_index, queue_id,
1349 mode);
1350 if (error)
1351 return (error);
1352 }
1353
1354 rv = vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1355 switch (rv)
1356 {
1357 case 0:
1358 break;
1359 case VNET_API_ERROR_UNSUPPORTED:
1360 return clib_error_return (0, "unsupported");
1361 case VNET_API_ERROR_INVALID_INTERFACE:
1362 return clib_error_return (0, "invalid interface");
Stevenbd8a6112017-07-30 10:29:26 -07001363 case VNET_API_ERROR_INVALID_QUEUE:
1364 return clib_error_return (0, "invalid queue");
Stevene3a395c2017-05-09 16:19:50 -07001365 default:
1366 return clib_error_return (0, "unknown error");
1367 }
1368
1369 return 0;
1370}
1371
Stevenad8015b2017-10-29 22:10:46 -07001372clib_error_t *
1373set_hw_interface_change_rx_mode (vnet_main_t * vnm, u32 hw_if_index,
1374 u8 queue_id_valid, u32 queue_id,
1375 vnet_hw_interface_rx_mode mode)
1376{
1377 clib_error_t *error = 0;
1378 vnet_hw_interface_t *hw;
1379 int i;
1380
1381 hw = vnet_get_hw_interface (vnm, hw_if_index);
1382
1383 if (queue_id_valid == 0)
1384 {
1385 for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
1386 {
1387 error = set_hw_interface_rx_mode (vnm, hw_if_index, i, mode);
1388 if (error)
1389 break;
1390 }
1391 hw->default_rx_mode = mode;
1392 }
1393 else
1394 error = set_hw_interface_rx_mode (vnm, hw_if_index, queue_id, mode);
1395
1396 return (error);
1397}
1398
Stevene3a395c2017-05-09 16:19:50 -07001399static clib_error_t *
Damjan Marion44036902017-04-28 12:29:15 +02001400set_interface_rx_mode (vlib_main_t * vm, unformat_input_t * input,
1401 vlib_cli_command_t * cmd)
1402{
1403 clib_error_t *error = 0;
1404 unformat_input_t _line_input, *line_input = &_line_input;
1405 vnet_main_t *vnm = vnet_get_main ();
Damjan Marion44036902017-04-28 12:29:15 +02001406 u32 hw_if_index = (u32) ~ 0;
1407 u32 queue_id = (u32) ~ 0;
1408 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
Stevenad8015b2017-10-29 22:10:46 -07001409 u8 queue_id_valid = 0;
Dave Barach7be864a2016-11-28 11:41:35 -05001410
Damjan Marion44036902017-04-28 12:29:15 +02001411 if (!unformat_user (input, unformat_line_input, line_input))
1412 return 0;
1413
1414 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1415 {
1416 if (unformat
1417 (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1418 ;
1419 else if (unformat (line_input, "queue %d", &queue_id))
Stevenad8015b2017-10-29 22:10:46 -07001420 queue_id_valid = 1;
Damjan Marion44036902017-04-28 12:29:15 +02001421 else if (unformat (line_input, "polling"))
1422 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
1423 else if (unformat (line_input, "interrupt"))
1424 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
1425 else if (unformat (line_input, "adaptive"))
1426 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
1427 else
1428 {
1429 error = clib_error_return (0, "parse error: '%U'",
1430 format_unformat_error, line_input);
1431 unformat_free (line_input);
1432 return error;
1433 }
1434 }
1435
1436 unformat_free (line_input);
1437
1438 if (hw_if_index == (u32) ~ 0)
1439 return clib_error_return (0, "please specify valid interface name");
1440
1441 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
1442 return clib_error_return (0, "please specify valid rx-mode");
1443
Stevenad8015b2017-10-29 22:10:46 -07001444 error = set_hw_interface_change_rx_mode (vnm, hw_if_index, queue_id_valid,
1445 queue_id, mode);
Damjan Marion44036902017-04-28 12:29:15 +02001446
Stevene3a395c2017-05-09 16:19:50 -07001447 return (error);
Damjan Marion44036902017-04-28 12:29:15 +02001448}
1449
1450/*?
Billy McFalle9bac692017-08-11 14:05:11 -04001451 * This command is used to assign the RX packet processing mode (polling,
1452 * interrupt, adaptive) of the a given interface, and optionally a
1453 * given queue. If the '<em>queue</em>' is not provided, the '<em>mode</em>'
1454 * is applied to all queues of the interface. Not all interfaces support
1455 * all modes. To display the current rx-mode use the command
1456 * '<em>show interface rx-placement</em>'.
Damjan Marion44036902017-04-28 12:29:15 +02001457 *
1458 * @cliexpar
Billy McFalle9bac692017-08-11 14:05:11 -04001459 * Example of how to assign rx-mode to all queues on an interface:
1460 * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 polling}
1461 * Example of how to assign rx-mode to one queue of an interface:
1462 * @cliexcmd{set interface rx-mode VirtualEthernet0/0/12 queue 0 interrupt}
1463 * Example of how to display the rx-mode of all interfaces:
Damjan Marion44036902017-04-28 12:29:15 +02001464 * @cliexstart{show interface rx-placement}
1465 * Thread 1 (vpp_wk_0):
Billy McFalle9bac692017-08-11 14:05:11 -04001466 * node dpdk-input:
1467 * GigabitEthernet7/0/0 queue 0 (polling)
1468 * node vhost-user-input:
1469 * VirtualEthernet0/0/12 queue 0 (interrupt)
1470 * VirtualEthernet0/0/12 queue 2 (polling)
1471 * VirtualEthernet0/0/13 queue 0 (polling)
1472 * VirtualEthernet0/0/13 queue 2 (polling)
Damjan Marion44036902017-04-28 12:29:15 +02001473 * Thread 2 (vpp_wk_1):
Billy McFalle9bac692017-08-11 14:05:11 -04001474 * node dpdk-input:
1475 * GigabitEthernet7/0/1 queue 0 (polling)
1476 * node vhost-user-input:
1477 * VirtualEthernet0/0/12 queue 1 (polling)
1478 * VirtualEthernet0/0/12 queue 3 (polling)
1479 * VirtualEthernet0/0/13 queue 1 (polling)
1480 * VirtualEthernet0/0/13 queue 3 (polling)
Damjan Marion44036902017-04-28 12:29:15 +02001481 * @cliexend
Damjan Marion44036902017-04-28 12:29:15 +02001482?*/
1483/* *INDENT-OFF* */
Damjan Marionfe7d4a22018-04-13 19:43:39 +02001484VLIB_CLI_COMMAND (cmd_set_if_rx_mode,static) = {
Damjan Marion44036902017-04-28 12:29:15 +02001485 .path = "set interface rx-mode",
1486 .short_help = "set interface rx-mode <interface> [queue <n>] [polling | interrupt | adaptive]",
1487 .function = set_interface_rx_mode,
1488};
1489/* *INDENT-ON* */
1490
1491static clib_error_t *
1492show_interface_rx_placement_fn (vlib_main_t * vm, unformat_input_t * input,
1493 vlib_cli_command_t * cmd)
1494{
1495 u8 *s = 0;
1496 vnet_main_t *vnm = vnet_get_main ();
1497 vnet_device_input_runtime_t *rt;
1498 vnet_device_and_queue_t *dq;
1499 vlib_node_t *pn = vlib_get_node_by_name (vm, (u8 *) "device-input");
1500 uword si;
1501 int index = 0;
1502
1503 /* *INDENT-OFF* */
1504 foreach_vlib_main (({
1505 clib_bitmap_foreach (si, pn->sibling_bitmap,
1506 ({
1507 rt = vlib_node_get_runtime_data (this_vlib_main, si);
1508
1509 if (vec_len (rt->devices_and_queues))
1510 s = format (s, " node %U:\n", format_vlib_node_name, vm, si);
1511
1512 vec_foreach (dq, rt->devices_and_queues)
1513 {
Steven9d6d9892017-06-30 07:15:02 -07001514 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm,
1515 dq->hw_if_index);
Damjan Marion44036902017-04-28 12:29:15 +02001516 s = format (s, " %U queue %u (%U)\n",
Steven9d6d9892017-06-30 07:15:02 -07001517 format_vnet_sw_if_index_name, vnm, hi->sw_if_index,
Damjan Marion44036902017-04-28 12:29:15 +02001518 dq->queue_id,
1519 format_vnet_hw_interface_rx_mode, dq->mode);
1520 }
1521 }));
1522 if (vec_len (s) > 0)
1523 {
Steven84f36cb2018-09-26 10:44:54 -07001524 vlib_cli_output(vm, "Thread %u (%s):\n%v", index,
Damjan Marion44036902017-04-28 12:29:15 +02001525 vlib_worker_threads[index].name, s);
1526 vec_reset_length (s);
1527 }
1528 index++;
1529 }));
1530 /* *INDENT-ON* */
1531
1532 vec_free (s);
1533 return 0;
1534}
1535
Billy McFalle9bac692017-08-11 14:05:11 -04001536/*?
1537 * This command is used to display the interface and queue worker
1538 * thread placement.
1539 *
1540 * @cliexpar
1541 * Example of how to display the interface placement:
1542 * @cliexstart{show interface rx-placement}
1543 * Thread 1 (vpp_wk_0):
1544 * node dpdk-input:
1545 * GigabitEthernet7/0/0 queue 0 (polling)
1546 * node vhost-user-input:
1547 * VirtualEthernet0/0/12 queue 0 (polling)
1548 * VirtualEthernet0/0/12 queue 2 (polling)
1549 * VirtualEthernet0/0/13 queue 0 (polling)
1550 * VirtualEthernet0/0/13 queue 2 (polling)
1551 * Thread 2 (vpp_wk_1):
1552 * node dpdk-input:
1553 * GigabitEthernet7/0/1 queue 0 (polling)
1554 * node vhost-user-input:
1555 * VirtualEthernet0/0/12 queue 1 (polling)
1556 * VirtualEthernet0/0/12 queue 3 (polling)
1557 * VirtualEthernet0/0/13 queue 1 (polling)
1558 * VirtualEthernet0/0/13 queue 3 (polling)
1559 * @cliexend
1560?*/
Damjan Marion44036902017-04-28 12:29:15 +02001561/* *INDENT-OFF* */
1562VLIB_CLI_COMMAND (show_interface_rx_placement, static) = {
1563 .path = "show interface rx-placement",
1564 .short_help = "show interface rx-placement",
1565 .function = show_interface_rx_placement_fn,
1566};
1567/* *INDENT-ON* */
1568
Mohsin Kazmi54f7c512018-08-23 18:28:11 +02001569clib_error_t *
1570set_hw_interface_rx_placement (u32 hw_if_index, u32 queue_id,
1571 u32 thread_index, u8 is_main)
Damjan Marion44036902017-04-28 12:29:15 +02001572{
Damjan Marion44036902017-04-28 12:29:15 +02001573 vnet_main_t *vnm = vnet_get_main ();
1574 vnet_device_main_t *vdm = &vnet_device_main;
Mohsin Kazmi54f7c512018-08-23 18:28:11 +02001575 clib_error_t *error = 0;
1576 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
Damjan Marion44036902017-04-28 12:29:15 +02001577 int rv;
1578
Mohsin Kazmi54f7c512018-08-23 18:28:11 +02001579 if (is_main)
1580 thread_index = 0;
1581 else
1582 thread_index += vdm->first_worker_thread_index;
Damjan Marion44036902017-04-28 12:29:15 +02001583
1584 if (thread_index > vdm->last_worker_thread_index)
1585 return clib_error_return (0,
1586 "please specify valid worker thread or main");
1587
1588 rv = vnet_hw_interface_get_rx_mode (vnm, hw_if_index, queue_id, &mode);
1589
1590 if (rv)
1591 return clib_error_return (0, "not found");
1592
1593 rv = vnet_hw_interface_unassign_rx_thread (vnm, hw_if_index, queue_id);
1594
1595 if (rv)
1596 return clib_error_return (0, "not found");
1597
1598 vnet_hw_interface_assign_rx_thread (vnm, hw_if_index, queue_id,
1599 thread_index);
1600 vnet_hw_interface_set_rx_mode (vnm, hw_if_index, queue_id, mode);
1601
Mohsin Kazmi54f7c512018-08-23 18:28:11 +02001602 return (error);
1603}
1604
1605static clib_error_t *
1606set_interface_rx_placement (vlib_main_t * vm, unformat_input_t * input,
1607 vlib_cli_command_t * cmd)
1608{
1609 clib_error_t *error = 0;
1610 unformat_input_t _line_input, *line_input = &_line_input;
1611 vnet_main_t *vnm = vnet_get_main ();
1612 u32 hw_if_index = (u32) ~ 0;
1613 u32 queue_id = (u32) 0;
1614 u32 thread_index = (u32) ~ 0;
1615 u8 is_main = 0;
1616
1617 if (!unformat_user (input, unformat_line_input, line_input))
1618 return 0;
1619
1620 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
1621 {
1622 if (unformat
1623 (line_input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
1624 ;
1625 else if (unformat (line_input, "queue %d", &queue_id))
1626 ;
1627 else if (unformat (line_input, "main", &thread_index))
1628 is_main = 1;
1629 else if (unformat (line_input, "worker %d", &thread_index))
1630 ;
1631 else
1632 {
1633 error = clib_error_return (0, "parse error: '%U'",
1634 format_unformat_error, line_input);
1635 unformat_free (line_input);
1636 return error;
1637 }
1638 }
1639
1640 unformat_free (line_input);
1641
1642 if (hw_if_index == (u32) ~ 0)
1643 return clib_error_return (0, "please specify valid interface name");
1644
1645 error = set_hw_interface_rx_placement (hw_if_index, queue_id, thread_index,
1646 is_main);
1647
1648 return (error);
Damjan Marion44036902017-04-28 12:29:15 +02001649}
1650
1651/*?
1652 * This command is used to assign a given interface, and optionally a
1653 * given queue, to a different thread. If the '<em>queue</em>' is not provided,
Billy McFalle9bac692017-08-11 14:05:11 -04001654 * it defaults to 0. The '<em>worker</em>' parameter is zero based and the index
1655 * in the thread name, for example, 0 in the thread name '<em>vpp_wk_0</em>'.
Damjan Marion44036902017-04-28 12:29:15 +02001656 *
1657 * @cliexpar
1658 * Example of how to display the interface placement:
Billy McFalle9bac692017-08-11 14:05:11 -04001659 * @cliexstart{show interface rx-placement}
Damjan Marion44036902017-04-28 12:29:15 +02001660 * Thread 1 (vpp_wk_0):
Billy McFalle9bac692017-08-11 14:05:11 -04001661 * node dpdk-input:
1662 * GigabitEthernet7/0/0 queue 0 (polling)
1663 * node vhost-user-input:
1664 * VirtualEthernet0/0/12 queue 0 (polling)
1665 * VirtualEthernet0/0/12 queue 2 (polling)
1666 * VirtualEthernet0/0/13 queue 0 (polling)
1667 * VirtualEthernet0/0/13 queue 2 (polling)
Damjan Marion44036902017-04-28 12:29:15 +02001668 * Thread 2 (vpp_wk_1):
Billy McFalle9bac692017-08-11 14:05:11 -04001669 * node dpdk-input:
1670 * GigabitEthernet7/0/1 queue 0 (polling)
1671 * node vhost-user-input:
1672 * VirtualEthernet0/0/12 queue 1 (polling)
1673 * VirtualEthernet0/0/12 queue 3 (polling)
1674 * VirtualEthernet0/0/13 queue 1 (polling)
1675 * VirtualEthernet0/0/13 queue 3 (polling)
Damjan Marion44036902017-04-28 12:29:15 +02001676 * @cliexend
Billy McFalle9bac692017-08-11 14:05:11 -04001677 * Example of how to assign a interface and queue to a worker thread:
1678 * @cliexcmd{set interface rx-placement VirtualEthernet0/0/12 queue 1 worker 0}
1679 * Example of how to display the interface placement:
1680 * @cliexstart{show interface rx-placement}
1681 * Thread 1 (vpp_wk_0):
1682 * node dpdk-input:
1683 * GigabitEthernet7/0/0 queue 0 (polling)
1684 * node vhost-user-input:
1685 * VirtualEthernet0/0/12 queue 0 (polling)
1686 * VirtualEthernet0/0/12 queue 1 (polling)
1687 * VirtualEthernet0/0/12 queue 2 (polling)
1688 * VirtualEthernet0/0/13 queue 0 (polling)
1689 * VirtualEthernet0/0/13 queue 2 (polling)
1690 * Thread 2 (vpp_wk_1):
1691 * node dpdk-input:
1692 * GigabitEthernet7/0/1 queue 0 (polling)
1693 * node vhost-user-input:
1694 * VirtualEthernet0/0/12 queue 3 (polling)
1695 * VirtualEthernet0/0/13 queue 1 (polling)
1696 * VirtualEthernet0/0/13 queue 3 (polling)
1697 * @cliexend
Damjan Marion44036902017-04-28 12:29:15 +02001698?*/
1699/* *INDENT-OFF* */
1700VLIB_CLI_COMMAND (cmd_set_if_rx_placement,static) = {
1701 .path = "set interface rx-placement",
Billy McFalle9bac692017-08-11 14:05:11 -04001702 .short_help = "set interface rx-placement <interface> [queue <n>] "
Damjan Marion6f9ac652017-06-15 19:01:31 +02001703 "[worker <n> | main]",
Damjan Marion44036902017-04-28 12:29:15 +02001704 .function = set_interface_rx_placement,
Damjan Marion6f9ac652017-06-15 19:01:31 +02001705 .is_mp_safe = 1,
Damjan Marion44036902017-04-28 12:29:15 +02001706};
Damjan Marion44036902017-04-28 12:29:15 +02001707/* *INDENT-ON* */
Dave Barachba868bb2016-08-08 09:51:21 -04001708/*
1709 * fd.io coding-style-patch-verification: ON
1710 *
1711 * Local Variables:
1712 * eval: (c-set-style "gnu")
1713 * End:
1714 */