aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vmxnet3/vmxnet3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/vmxnet3/vmxnet3.c')
-rw-r--r--src/plugins/vmxnet3/vmxnet3.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/src/plugins/vmxnet3/vmxnet3.c b/src/plugins/vmxnet3/vmxnet3.c
index 16d7d86fb3a..e64e0d135d6 100644
--- a/src/plugins/vmxnet3/vmxnet3.c
+++ b/src/plugins/vmxnet3/vmxnet3.c
@@ -145,7 +145,6 @@ static char *vmxnet3_tx_func_error_strings[] = {
#undef _
};
-/* *INDENT-OFF* */
VNET_DEVICE_CLASS (vmxnet3_device_class,) =
{
.name = "VMXNET3 interface",
@@ -158,7 +157,6 @@ VNET_DEVICE_CLASS (vmxnet3_device_class,) =
.tx_function_n_errors = VMXNET3_TX_N_ERROR,
.tx_function_error_strings = vmxnet3_tx_func_error_strings,
};
-/* *INDENT-ON* */
static u32
vmxnet3_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags)
@@ -572,8 +570,9 @@ vmxnet3_event_irq_handler (vlib_main_t * vm, vlib_pci_dev_handle_t h,
{
vd->flags |= VMXNET3_DEVICE_F_LINK_UP;
vd->link_speed = ret >> 16;
- vnet_hw_interface_set_link_speed (vnm, vd->hw_if_index,
- vd->link_speed * 1000);
+ vnet_hw_interface_set_link_speed (
+ vnm, vd->hw_if_index,
+ (vd->link_speed == UINT32_MAX) ? UINT32_MAX : vd->link_speed * 1000);
vnet_hw_interface_set_flags (vnm, vd->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
}
@@ -617,8 +616,11 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
{
vnet_main_t *vnm = vnet_get_main ();
vmxnet3_main_t *vmxm = &vmxnet3_main;
+ vnet_eth_interface_registration_t eir = {};
+
vmxnet3_device_t *vd;
vlib_pci_dev_handle_t h;
+ vnet_hw_if_caps_change_t cc = {};
clib_error_t *error = 0;
u16 qid;
u32 num_intr;
@@ -671,7 +673,6 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
return;
}
- /* *INDENT-OFF* */
pool_foreach (vd, vmxm->devices) {
if (vd->pci_addr.as_u32 == args->addr.as_u32)
{
@@ -684,11 +685,11 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
return;
}
}
- /* *INDENT-ON* */
if (args->bind)
{
- error = vlib_pci_bind_to_uio (vm, &args->addr, (char *) "auto");
+ error = vlib_pci_bind_to_uio (vm, &args->addr, (char *) "auto",
+ VMXNET3_BIND_FORCE == args->bind);
if (error)
{
args->rv = VNET_API_ERROR_INVALID_INTERFACE;
@@ -802,29 +803,24 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
}
/* create interface */
- error = ethernet_register_interface (vnm, vmxnet3_device_class.index,
- vd->dev_instance, vd->mac_addr,
- &vd->hw_if_index, vmxnet3_flag_change);
-
- if (error)
- {
- vmxnet3_log_error (vd,
- "error encountered on ethernet register interface");
- goto error;
- }
+ eir.dev_class_index = vmxnet3_device_class.index;
+ eir.dev_instance = vd->dev_instance;
+ eir.address = vd->mac_addr;
+ eir.cb.flag_change = vmxnet3_flag_change;
+ vd->hw_if_index = vnet_eth_register_interface (vnm, &eir);
vnet_sw_interface_t *sw = vnet_get_hw_sw_interface (vnm, vd->hw_if_index);
vd->sw_if_index = sw->sw_if_index;
args->sw_if_index = sw->sw_if_index;
- vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, vd->hw_if_index);
- hw->caps |= VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE;
+ cc.mask = VNET_HW_IF_CAP_INT_MODE | VNET_HW_IF_CAP_TCP_GSO |
+ VNET_HW_IF_CAP_TX_TCP_CKSUM | VNET_HW_IF_CAP_TX_UDP_CKSUM;
if (vd->gso_enable)
- {
- hw->caps |= (VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM |
- VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM);
- }
+ cc.val = cc.mask;
+ else
+ cc.val = VNET_HW_IF_CAP_INT_MODE;
+
+ vnet_hw_if_change_caps (vnm, vd->hw_if_index, &cc);
vnet_hw_if_set_input_node (vnm, vd->hw_if_index, vmxnet3_input_node.index);
/* Disable interrupts */
@@ -869,8 +865,9 @@ vmxnet3_create_if (vlib_main_t * vm, vmxnet3_create_if_args_t * args)
vd->flags |= VMXNET3_DEVICE_F_INITIALIZED;
vmxnet3_enable_interrupt (vd);
- vnet_hw_interface_set_link_speed (vnm, vd->hw_if_index,
- vd->link_speed * 1000);
+ vnet_hw_interface_set_link_speed (
+ vnm, vd->hw_if_index,
+ (vd->link_speed == UINT32_MAX) ? UINT32_MAX : vd->link_speed * 1000);
if (vd->flags & VMXNET3_DEVICE_F_LINK_UP)
vnet_hw_interface_set_flags (vnm, vd->hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
@@ -906,7 +903,6 @@ vmxnet3_delete_if (vlib_main_t * vm, vmxnet3_device_t * vd)
vlib_pci_device_close (vm, vd->pci_dev_handle);
- /* *INDENT-OFF* */
vec_foreach_index (i, vd->rxqs)
{
vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, i);
@@ -933,11 +929,9 @@ vmxnet3_delete_if (vlib_main_t * vm, vmxnet3_device_t * vd)
}
vlib_physmem_free (vm, rxq->rx_comp);
}
- /* *INDENT-ON* */
vec_free (vd->rxqs);
vec_free (vd->rx_stats);
- /* *INDENT-OFF* */
vec_foreach_index (i, vd->txqs)
{
vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, i);
@@ -958,7 +952,6 @@ vmxnet3_delete_if (vlib_main_t * vm, vmxnet3_device_t * vd)
vlib_physmem_free (vm, txq->tx_desc);
vlib_physmem_free (vm, txq->tx_comp);
}
- /* *INDENT-ON* */
vec_free (vd->txqs);
vec_free (vd->tx_stats);