aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vmxnet3/vmxnet3.c
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2019-03-14 09:57:09 -0700
committerDamjan Marion <dmarion@me.com>2019-03-18 11:11:50 +0000
commitee8ba6877efb916b88255821f94ef33437724f75 (patch)
treeaeb507c38ba53a60791c7084f6f47d540608971f /src/plugins/vmxnet3/vmxnet3.c
parenta990a2e4930014f025338d8ce186abfa12ec09ff (diff)
vmxnet3: auto bind support
For creating the vmxnet3 interface, add the bind option to automatically bind the pci to vfio-pci module which removes the need for manual bind. Manual bind still works, should people prefer to go that route. Change-Id: Ife75926f8755d754a08dd0ecff0f1de326ad5ba1 Signed-off-by: Steven Luong <sluong@cisco.com>
Diffstat (limited to 'src/plugins/vmxnet3/vmxnet3.c')
-rw-r--r--src/plugins/vmxnet3/vmxnet3.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c
index 43f9cbed793..de1002381b6 100644
--- a/src/plugins/vmxnet3/vmxnet3.c
+++ b/src/plugins/vmxnet3/vmxnet3.c
@@ -658,9 +658,10 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
pool_foreach (vd, vmxm->devices, ({
if (vd->pci_addr.as_u32 == args->addr.as_u32)
{
- args->rv = VNET_API_ERROR_INVALID_VALUE;
+ args->rv = VNET_API_ERROR_ADDRESS_IN_USE;
args->error =
- clib_error_return (error, "PCI address in use");
+ clib_error_return (error, "%U: %s", format_vlib_pci_addr,
+ &args->addr, "pci address in use");
vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
format_vlib_pci_addr, &args->addr, "pci address in use");
return;
@@ -668,24 +669,31 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
}));
/* *INDENT-ON* */
- pool_get (vmxm->devices, vd);
- vd->num_tx_queues = args->txq_num;
- vd->num_rx_queues = args->rxq_num;
- vd->dev_instance = vd - vmxm->devices;
- vd->per_interface_next_index = ~0;
- vd->pci_addr = args->addr;
-
- if (args->enable_elog)
- vd->flags |= VMXNET3_DEVICE_F_ELOG;
+ if (args->bind)
+ {
+ error = vlib_pci_bind_to_uio (vm, &args->addr, (char *) "auto");
+ if (error)
+ {
+ args->rv = VNET_API_ERROR_INVALID_INTERFACE;
+ args->error =
+ clib_error_return (error, "%U: %s", format_vlib_pci_addr,
+ &args->addr,
+ "error encountered on binding pci device");
+ vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
+ format_vlib_pci_addr, &args->addr,
+ "error encountered on binding pci devicee");
+ return;
+ }
+ }
if ((error =
vlib_pci_device_open (vm, &args->addr, vmxnet3_pci_device_ids, &h)))
{
- pool_put (vmxm->devices, vd);
args->rv = VNET_API_ERROR_INVALID_INTERFACE;
args->error =
- clib_error_return (error, "pci-addr %U", format_vlib_pci_addr,
- &args->addr);
+ clib_error_return (error, "%U: %s", format_vlib_pci_addr,
+ &args->addr,
+ "error encountered on pci device open");
vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
format_vlib_pci_addr, &args->addr,
"error encountered on pci device open");
@@ -696,6 +704,16 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
* Do not use vmxnet3_log_error prior to this line since the macro
* references vd->pci_dev_handle
*/
+ pool_get (vmxm->devices, vd);
+ vd->num_tx_queues = args->txq_num;
+ vd->num_rx_queues = args->rxq_num;
+ vd->dev_instance = vd - vmxm->devices;
+ vd->per_interface_next_index = ~0;
+ vd->pci_addr = args->addr;
+
+ if (args->enable_elog)
+ vd->flags |= VMXNET3_DEVICE_F_ELOG;
+
vd->pci_dev_handle = h;
vd->numa_node = vlib_pci_get_numa_node (vm, h);
vd->num_intrs = vd->num_rx_queues + 1; // +1 for the event interrupt