2 *------------------------------------------------------------------
3 * Copyright (c) 2018 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *------------------------------------------------------------------
19 #include <sys/ioctl.h>
22 #include <vlib/vlib.h>
23 #include <vlib/unix/unix.h>
24 #include <vnet/ethernet/ethernet.h>
26 #include <marvell/pp2/pp2.h>
29 mrvl_pp2_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
30 vlib_cli_command_t * cmd)
32 unformat_input_t _line_input, *line_input = &_line_input;
33 mrvl_pp2_create_if_args_t args = { 0 };
35 /* Get a line of input. */
36 if (!unformat_user (input, unformat_line_input, line_input))
39 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
41 if (unformat (line_input, "name %s", &args.name))
44 return clib_error_return (0, "unknown input `%U'",
45 format_unformat_error, input);
47 unformat_free (line_input);
50 mrvl_pp2_create_if (&args);
58 VLIB_CLI_COMMAND (mrvl_pp2_create_command, static) = {
59 .path = "create interface marvell pp2",
60 .short_help = "create interface marvell pp2 [name <ifname>]",
61 .function = mrvl_pp2_create_command_fn,
66 mrvl_pp2_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
67 vlib_cli_command_t * cmd)
69 unformat_input_t _line_input, *line_input = &_line_input;
71 vnet_hw_interface_t *hw;
72 mrvl_pp2_main_t *mm = &mrvl_pp2_main;
74 vnet_main_t *vnm = vnet_get_main ();
76 /* Get a line of input. */
77 if (!unformat_user (input, unformat_line_input, line_input))
80 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
82 if (unformat (line_input, "sw_if_index %d", &sw_if_index))
84 else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
88 return clib_error_return (0, "unknown input `%U'",
89 format_unformat_error, input);
91 unformat_free (line_input);
93 if (sw_if_index == ~0)
94 return clib_error_return (0,
95 "please specify interface name or sw_if_index");
97 hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
98 if (hw == NULL || mrvl_pp2_device_class.index != hw->dev_class_index)
99 return clib_error_return (0, "not a Marvell PP2 interface");
101 dif = pool_elt_at_index (mm->interfaces, hw->dev_instance);
103 mrvl_pp2_delete_if (dif);
109 VLIB_CLI_COMMAND (mrvl_pp2_delete_command, static) = {
110 .path = "delete interface marvell pp2",
111 .short_help = "delete interface marvell pp2 "
112 "{<interface> | sw_if_index <sw_idx>}",
113 .function = mrvl_pp2_delete_command_fn,
118 mrvl_pp2_cli_init (vlib_main_t * vm)
123 VLIB_INIT_FUNCTION (mrvl_pp2_cli_init);
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")