summaryrefslogtreecommitdiffstats
path: root/src/vnet/dev/cli.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2023-11-22 16:25:55 +0000
committerDamjan Marion <damarion@cisco.com>2023-11-25 12:39:25 +0000
commitddf6cec37027547ff7cc61e15bb8080664d41514 (patch)
tree6896d6e6a050a43344a22d0c4bc080db092c9caf /src/vnet/dev/cli.c
parent07a62cc236978a0f01ec8be70bdd1d3e8fa27f71 (diff)
dev: initial set of APIs
Type: improvement Change-Id: I9ecbf705d460a1744f36c7005b08097dc58d9522 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/dev/cli.c')
-rw-r--r--src/vnet/dev/cli.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/vnet/dev/cli.c b/src/vnet/dev/cli.c
index d478f1d233c..53be4483183 100644
--- a/src/vnet/dev/cli.c
+++ b/src/vnet/dev/cli.c
@@ -56,17 +56,26 @@ static clib_error_t *
device_detach_cmd_fn (vlib_main_t *vm, unformat_input_t *input,
vlib_cli_command_t *cmd)
{
- vnet_dev_api_detach_args_t a = {};
vnet_dev_rv_t rv;
+ vnet_dev_device_id_t device_id = {};
+ vnet_dev_t *dev;
- if (!unformat_user (input, unformat_c_string_array, a.device_id,
- sizeof (a.device_id)))
+ if (!unformat_user (input, unformat_c_string_array, device_id,
+ sizeof (device_id)))
return clib_error_return (0, "please specify valid device id");
- rv = vnet_dev_api_detach (vm, &a);
+ dev = vnet_dev_by_id (device_id);
+
+ if (dev)
+ {
+ vnet_dev_api_detach_args_t a = { .dev_index = dev->index };
+ rv = vnet_dev_api_detach (vm, &a);
+ }
+ else
+ rv = VNET_DEV_ERR_UNKNOWN_DEVICE;
if (rv != VNET_DEV_OK)
- return clib_error_return (0, "unable to detach '%s': %U", a.device_id,
+ return clib_error_return (0, "unable to detach '%s': %U", device_id,
format_vnet_dev_rv, rv);
return 0;
@@ -112,12 +121,19 @@ device_create_if_cmd_fn (vlib_main_t *vm, unformat_input_t *input,
{
vnet_dev_api_create_port_if_args_t a = {};
vnet_dev_rv_t rv;
+ vnet_dev_device_id_t device_id = {};
+ vnet_dev_t *dev = 0;
u32 n;
- if (!unformat_user (input, unformat_c_string_array, a.device_id,
- sizeof (a.device_id)))
+ if (unformat_user (input, unformat_c_string_array, device_id,
+ sizeof (device_id)))
+ dev = vnet_dev_by_id (device_id);
+
+ if (!dev)
return clib_error_return (0, "please specify valid device id");
+ a.dev_index = dev->index;
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (!a.intf_name[0] &&
@@ -153,7 +169,7 @@ device_create_if_cmd_fn (vlib_main_t *vm, unformat_input_t *input,
vec_free (a.args);
if (rv != VNET_DEV_OK)
- return clib_error_return (0, "unable to create_if '%s': %U", a.device_id,
+ return clib_error_return (0, "unable to create_if '%s': %U", device_id,
format_vnet_dev_rv, rv);
return 0;