2 *------------------------------------------------------------------
3 * Copyright (c) 2023 Intel 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 *------------------------------------------------------------------
17 #include <idpf/idpf.h>
20 idpf_create_command_fn (vlib_main_t *vm, unformat_input_t *input,
21 vlib_cli_command_t *cmd)
23 unformat_input_t _line_input, *line_input = &_line_input;
24 idpf_create_if_args_t args;
27 clib_memset (&args, 0, sizeof (idpf_create_if_args_t));
29 /* Get a line of input. */
30 if (!unformat_user (input, unformat_line_input, line_input))
33 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
35 if (unformat (line_input, "%U", unformat_vlib_pci_addr, &args.addr))
37 else if (unformat (line_input, "rx-single %u", &tmp))
39 else if (unformat (line_input, "tx-single %u", &tmp))
41 else if (unformat (line_input, "rxq-num %u", &tmp))
43 else if (unformat (line_input, "txq-num %u", &tmp))
45 else if (unformat (line_input, "rxq-size %u", &tmp))
47 else if (unformat (line_input, "txq-size %u", &tmp))
49 else if (unformat (line_input, "vport-num %u", &tmp))
50 args.req_vport_nb = tmp;
51 else if (unformat (line_input, "name %s", &args.name))
54 return clib_error_return (0, "unknown input `%U'",
55 format_unformat_error, input);
57 unformat_free (line_input);
59 idpf_create_if (vm, &args);
66 VLIB_CLI_COMMAND (idpf_create_command, static) = {
67 .path = "create interface idpf",
68 .short_help = "create interface idpf <pci-address> "
69 "[vport <size>] [rx-single <size>] [tx-single <size>]",
70 .function = idpf_create_command_fn,
74 idpf_delete_command_fn (vlib_main_t *vm, unformat_input_t *input,
75 vlib_cli_command_t *cmd)
77 unformat_input_t _line_input, *line_input = &_line_input;
79 vnet_hw_interface_t *hw;
80 vnet_main_t *vnm = vnet_get_main ();
82 /* Get a line of input. */
83 if (!unformat_user (input, unformat_line_input, line_input))
86 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
88 if (unformat (line_input, "sw_if_index %d", &sw_if_index))
90 else if (unformat (line_input, "%U", unformat_vnet_sw_interface, vnm,
94 return clib_error_return (0, "unknown input `%U'",
95 format_unformat_error, input);
97 unformat_free (line_input);
99 if (sw_if_index == ~0)
100 return clib_error_return (0,
101 "please specify interface name or sw_if_index");
103 hw = vnet_get_sup_hw_interface_api_visible_or_null (vnm, sw_if_index);
104 if (hw == NULL || idpf_device_class.index != hw->dev_class_index)
105 return clib_error_return (0, "not an IDPF interface");
107 vlib_process_signal_event (vm, idpf_process_node.index,
108 IDPF_PROCESS_EVENT_DELETE_IF, hw->dev_instance);
113 VLIB_CLI_COMMAND (idpf_delete_command, static) = {
114 .path = "delete interface idpf",
115 .short_help = "delete interface idpf "
116 "{<interface> | sw_if_index <sw_idx>}",
117 .function = idpf_delete_command_fn,
122 idpf_cli_init (vlib_main_t *vm)
127 VLIB_INIT_FUNCTION (idpf_cli_init);
130 * fd.io coding-style-patch-verification: ON
133 * eval: (c-set-style "gnu")