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 };
36 /* Get a line of input. */
37 if (!unformat_user (input, unformat_line_input, line_input))
40 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
42 if (unformat (line_input, "name %s", &args.name))
44 else if (unformat (line_input, "rx-queue-size %u", &val))
46 else if (unformat (line_input, "tx-queue-size %u", &val))
49 return clib_error_return (0, "unknown input `%U'",
50 format_unformat_error, input);
52 unformat_free (line_input);
55 mrvl_pp2_create_if (&args);
63 VLIB_CLI_COMMAND (mrvl_pp2_create_command, static) = {
64 .path = "create interface marvell pp2",
65 .short_help = "create interface marvell pp2 [name <ifname>] [rx-queue-size slots] [tx-queue-size slots]",
66 .function = mrvl_pp2_create_command_fn,
71 mrvl_pp2_delete_command_fn (vlib_main_t * vm, unformat_input_t * input,
72 vlib_cli_command_t * cmd)
74 unformat_input_t _line_input, *line_input = &_line_input;
76 vnet_hw_interface_t *hw;
77 mrvl_pp2_main_t *mm = &mrvl_pp2_main;
79 vnet_main_t *vnm = vnet_get_main ();
81 /* Get a line of input. */
82 if (!unformat_user (input, unformat_line_input, line_input))
85 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
87 if (unformat (line_input, "sw_if_index %d", &sw_if_index))
89 else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
93 return clib_error_return (0, "unknown input `%U'",
94 format_unformat_error, input);
96 unformat_free (line_input);
98 if (sw_if_index == ~0)
99 return clib_error_return (0,
100 "please specify interface name or sw_if_index");
102 hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
103 if (hw == NULL || mrvl_pp2_device_class.index != hw->dev_class_index)
104 return clib_error_return (0, "not a Marvell PP2 interface");
106 dif = pool_elt_at_index (mm->interfaces, hw->dev_instance);
108 mrvl_pp2_delete_if (dif);
114 VLIB_CLI_COMMAND (mrvl_pp2_delete_command, static) = {
115 .path = "delete interface marvell pp2",
116 .short_help = "delete interface marvell pp2 "
117 "{<interface> | sw_if_index <sw_idx>}",
118 .function = mrvl_pp2_delete_command_fn,
123 mrvl_pp2_cli_init (vlib_main_t * vm)
125 /* initialize binary API */
126 mrvl_pp2_plugin_api_hookup (vm);
131 VLIB_INIT_FUNCTION (mrvl_pp2_cli_init);
134 * fd.io coding-style-patch-verification: ON
137 * eval: (c-set-style "gnu")