summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/devices/virtio/cli.c8
-rw-r--r--src/vnet/devices/virtio/pci.c18
-rw-r--r--src/vnet/devices/virtio/pci.h8
3 files changed, 32 insertions, 2 deletions
diff --git a/src/vnet/devices/virtio/cli.c b/src/vnet/devices/virtio/cli.c
index a78336997e2..2457e9b686e 100644
--- a/src/vnet/devices/virtio/cli.c
+++ b/src/vnet/devices/virtio/cli.c
@@ -55,6 +55,10 @@ virtio_pci_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
else if (unformat (line_input, "packed"))
args.virtio_flags |= VIRTIO_FLAG_PACKED;
+ else if (unformat (line_input, "bind force"))
+ args.bind = VIRTIO_BIND_FORCE;
+ else if (unformat (line_input, "bind"))
+ args.bind = VIRTIO_BIND_DEFAULT;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
@@ -70,8 +74,8 @@ virtio_pci_create_command_fn (vlib_main_t * vm, unformat_input_t * input,
VLIB_CLI_COMMAND (virtio_pci_create_command, static) = {
.path = "create interface virtio",
.short_help = "create interface virtio <pci-address> "
- "[feature-mask <hex-mask>] [gso-enabled] [csum-enabled] "
- "[buffering [size <buffering-szie>]] [packed]",
+ "[feature-mask <hex-mask>] [gso-enabled] [csum-enabled] "
+ "[buffering [size <buffering-szie>]] [packed] [bind [force]]",
.function = virtio_pci_create_command_fn,
};
/* *INDENT-ON* */
diff --git a/src/vnet/devices/virtio/pci.c b/src/vnet/devices/virtio/pci.c
index f678c3960bf..cb177b3e469 100644
--- a/src/vnet/devices/virtio/pci.c
+++ b/src/vnet/devices/virtio/pci.c
@@ -1343,6 +1343,24 @@ virtio_pci_create_if (vlib_main_t * vm, virtio_pci_create_if_args_t * args)
}
/* *INDENT-ON* */
+ if (args->bind)
+ {
+ vlib_pci_addr_t pci = { .as_u32 = args->addr };
+ error = vlib_pci_bind_to_uio (vm, &pci, (char *) "auto",
+ VIRTIO_BIND_FORCE == args->bind);
+ if (error)
+ {
+ args->rv = VNET_API_ERROR_INVALID_INTERFACE;
+ args->error =
+ clib_error_return (error, "%U: %s", format_vlib_pci_addr, &pci,
+ "error encountered on binding pci device");
+ vlib_log (VLIB_LOG_LEVEL_ERR, vim->log_default, "%U: %s",
+ format_vlib_pci_addr, &pci,
+ "error encountered on binding pci devicee");
+ return;
+ }
+ }
+
pool_get (vim->interfaces, vif);
vif->dev_instance = vif - vim->interfaces;
vif->per_interface_next_index = ~0;
diff --git a/src/vnet/devices/virtio/pci.h b/src/vnet/devices/virtio/pci.h
index db20537bc3f..0cada61d9b8 100644
--- a/src/vnet/devices/virtio/pci.h
+++ b/src/vnet/devices/virtio/pci.h
@@ -227,6 +227,13 @@ typedef enum
#undef _
} virtio_flag_t;
+typedef enum
+{
+ VIRTIO_BIND_NONE = 0,
+ VIRTIO_BIND_DEFAULT = 1,
+ VIRTIO_BIND_FORCE = 2,
+} __clib_packed virtio_bind_t;
+
typedef struct
{
u32 addr;
@@ -238,6 +245,7 @@ typedef struct
u64 features;
u8 gso_enabled;
u8 checksum_offload_enabled;
+ virtio_bind_t bind;
u32 buffering_size;
u32 virtio_flags;
clib_error_t *error;