aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/avf
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-10-22 13:38:57 +0200
committerDave Barach <openvpp@barachs.net>2018-10-22 16:10:26 +0000
commit2322798bea16ff4092e2361423af6fd451fd1669 (patch)
treebeec5b680365a31c40bb9ff8ea656e8323aca734 /src/plugins/avf
parenta26373bda8aa66cebf03ac092c20fdf4b0a0f625 (diff)
vlib: pci improvements
- logging - pass vlib_main_t to all APIs - open vfio container only when needed Change-Id: I897e53e0af3f91c3a99f0c827401d1c0ec2e478a Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/avf')
-rw-r--r--src/plugins/avf/device.c31
-rw-r--r--src/plugins/avf/format.c3
2 files changed, 18 insertions, 16 deletions
diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c
index c23746be1b2..e71b74ec8fc 100644
--- a/src/plugins/avf/device.c
+++ b/src/plugins/avf/device.c
@@ -1036,11 +1036,10 @@ VLIB_REGISTER_NODE (avf_process_node, static) = {
/* *INDENT-ON* */
static void
-avf_irq_0_handler (vlib_pci_dev_handle_t h, u16 line)
+avf_irq_0_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h, u16 line)
{
- vlib_main_t *vm = vlib_get_main ();
avf_main_t *am = &avf_main;
- uword pd = vlib_pci_get_private_data (h);
+ uword pd = vlib_pci_get_private_data (vm, h);
avf_device_t *ad = pool_elt_at_index (am->devices, pd);
u32 icr0;
@@ -1075,12 +1074,11 @@ avf_irq_0_handler (vlib_pci_dev_handle_t h, u16 line)
}
static void
-avf_irq_n_handler (vlib_pci_dev_handle_t h, u16 line)
+avf_irq_n_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h, u16 line)
{
vnet_main_t *vnm = vnet_get_main ();
- vlib_main_t *vm = vlib_get_main ();
avf_main_t *am = &avf_main;
- uword pd = vlib_pci_get_private_data (h);
+ uword pd = vlib_pci_get_private_data (vm, h);
avf_device_t *ad = pool_elt_at_index (am->devices, pd);
u16 qid;
int i;
@@ -1126,7 +1124,7 @@ avf_delete_if (vlib_main_t * vm, avf_device_t * ad)
ethernet_delete_interface (vnm, ad->hw_if_index);
}
- vlib_pci_device_close (ad->pci_dev_handle);
+ vlib_pci_device_close (vm, ad->pci_dev_handle);
vlib_physmem_free (vm, am->physmem_region, ad->atq);
vlib_physmem_free (vm, am->physmem_region, ad->arq);
@@ -1197,7 +1195,8 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
if (args->enable_elog)
ad->flags |= AVF_DEVICE_F_ELOG;
- if ((error = vlib_pci_device_open (&args->addr, avf_pci_device_ids, &h)))
+ if ((error = vlib_pci_device_open (vm, &args->addr, avf_pci_device_ids,
+ &h)))
{
pool_put (am->devices, ad);
args->rv = VNET_API_ERROR_INVALID_INTERFACE;
@@ -1208,21 +1207,23 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
}
ad->pci_dev_handle = h;
- vlib_pci_set_private_data (h, ad->dev_instance);
+ vlib_pci_set_private_data (vm, h, ad->dev_instance);
- if ((error = vlib_pci_bus_master_enable (h)))
+ if ((error = vlib_pci_bus_master_enable (vm, h)))
goto error;
- if ((error = vlib_pci_map_region (h, 0, &ad->bar0)))
+ if ((error = vlib_pci_map_region (vm, h, 0, &ad->bar0)))
goto error;
- if ((error = vlib_pci_register_msix_handler (h, 0, 1, &avf_irq_0_handler)))
+ if ((error = vlib_pci_register_msix_handler (vm, h, 0, 1,
+ &avf_irq_0_handler)))
goto error;
- if ((error = vlib_pci_register_msix_handler (h, 1, 1, &avf_irq_n_handler)))
+ if ((error = vlib_pci_register_msix_handler (vm, h, 1, 1,
+ &avf_irq_n_handler)))
goto error;
- if ((error = vlib_pci_enable_msix_irq (h, 0, 2)))
+ if ((error = vlib_pci_enable_msix_irq (vm, h, 0, 2)))
goto error;
if (am->physmem_region_alloc == 0)
@@ -1258,7 +1259,7 @@ avf_create_if (vlib_main_t * vm, avf_create_if_args_t * args)
if (error)
goto error;
- if ((error = vlib_pci_intr_enable (h)))
+ if ((error = vlib_pci_intr_enable (vm, h)))
goto error;
/* FIXME detect */
diff --git a/src/plugins/avf/format.c b/src/plugins/avf/format.c
index 4eab3198766..3a1e1ff7f44 100644
--- a/src/plugins/avf/format.c
+++ b/src/plugins/avf/format.c
@@ -25,10 +25,11 @@
u8 *
format_avf_device_name (u8 * s, va_list * args)
{
+ vlib_main_t *vm = vlib_get_main ();
u32 i = va_arg (*args, u32);
avf_main_t *am = &avf_main;
avf_device_t *ad = vec_elt_at_index (am->devices, i);
- vlib_pci_addr_t *addr = vlib_pci_get_addr (ad->pci_dev_handle);
+ vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, ad->pci_dev_handle);
s = format (s, "avf-%x/%x/%x/%x",
addr->domain, addr->bus, addr->slot, addr->function);