21 #include <vpp/app/version.h> 25 #define PCI_VENDOR_ID_VMWARE 0x15ad 26 #define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07b0 46 if (vd->
flags & VMXNET3_DEVICE_F_ERROR)
53 vd->
flags |= VMXNET3_DEVICE_F_ADMIN_UP;
58 vd->
flags &= ~VMXNET3_DEVICE_F_ADMIN_UP;
105 vmxnet3_queues *q = &vd->
dma->queues;
126 .name =
"VMXNET3 interface",
160 vmxnet3_shared *shared;
174 q = &vd->
dma->queues;
177 q->tx.cfg.num_desc = txq->
size;
178 q->tx.cfg.num_comp = txq->
size;
183 q->rx.cfg.num_desc[rid] = rxq->
size;
186 q->rx.cfg.num_comp = rxq->
size;
188 shared = &vd->
dma->shared;
191 if (
sizeof (
void *) == 4)
199 shared->misc.queue_desc_len =
sizeof (*q);
203 shared->interrupt.num_intrs = vd->
num_intrs;
204 shared->interrupt.event_intr_index = 1;
206 shared->rx_filter.mode = VMXNET3_RXMODE_UCAST | VMXNET3_RXMODE_BCAST |
207 VMXNET3_RXMODE_ALL_MULTI | VMXNET3_RXMODE_PROMISC;
220 vmxnet3_shared *shared = &vd->
dma->shared;
231 vmxnet3_shared *shared = &vd->
dma->shared;
290 vd->
flags |= VMXNET3_DEVICE_F_SHARED_TXQ_LOCK;
377 vd->
flags |= VMXNET3_DEVICE_F_LINK_UP;
382 vd->
flags &= ~VMXNET3_DEVICE_F_LINK_UP;
428 vd->
flags |= VMXNET3_DEVICE_F_INITIALIZED;
461 vd->
flags |= VMXNET3_DEVICE_F_LINK_UP;
470 vd->
flags &= ~VMXNET3_DEVICE_F_LINK_UP;
478 if (qsz < 64 || qsz > 4096)
502 args->
rv = VNET_API_ERROR_INVALID_VALUE;
505 "queue size must be <= 4096, >= 64, " 506 "and multiples of 64");
509 "queue size must be <= 4096, >= 64, and multiples of 64");
515 if (vd->pci_addr.as_u32 == args->addr.as_u32)
517 args->rv = VNET_API_ERROR_INVALID_VALUE;
519 clib_error_return (error,
"PCI address in use");
520 vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default,
"%U: %s",
521 format_vlib_pci_addr, &args->addr,
"pci address in use");
528 vd->dev_instance = vd - vmxm->devices;
529 vd->per_interface_next_index = ~0;
530 vd->pci_addr = args->addr;
532 if (args->enable_elog)
533 vd->flags |= VMXNET3_DEVICE_F_ELOG;
539 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
543 vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default,
"%U: %s",
545 "error encountered on pci device open");
553 vd->pci_dev_handle =
h;
579 "error encountered on pci register msix handler 0");
587 "error encountered on pci register msix handler 1");
611 vd->dev_instance, vd->mac_addr,
617 "error encountered on ethernet register interface");
631 vd->link_speed * 1000);
632 if (vd->flags & VMXNET3_DEVICE_F_LINK_UP)
641 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
680 desc_idx = (ring->
consume + 1) & mask;
700 while (desc_idx != end_idx)
static char * vmxnet3_tx_func_error_strings[]
clib_error_t * vlib_pci_device_open(vlib_main_t *vm, vlib_pci_addr_t *addr, pci_device_id_t ids[], vlib_pci_dev_handle_t *handle)
static_always_inline clib_error_t * vmxnet3_rxq_refill_ring0(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_rxq_t *rxq)
void vmxnet3_delete_if(vlib_main_t *vm, vmxnet3_device_t *vd)
format_function_t format_vlib_pci_addr
#define vec_foreach_index(var, v)
Iterate over vector indices.
static void * vlib_physmem_alloc_aligned_on_numa(vlib_main_t *vm, uword n_bytes, uword alignment, u32 numa_node)
format_function_t format_vmxnet3_device_name
#define VMXNET3_GOS_BITS_32
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
static clib_error_t * vlib_pci_bus_master_enable(vlib_main_t *vm, vlib_pci_dev_handle_t h)
vnet_main_t * vnet_get_main(void)
#define count_leading_zeros(x)
vmxnet3_rx_desc * rx_desc[VMXNET3_RX_RING_SIZE]
static_always_inline uword vmxnet3_dma_addr(vlib_main_t *vm, vmxnet3_device_t *vd, void *p)
vlib_pci_dev_handle_t pci_dev_handle
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vmxnet3_tx_stats tx_stats
static clib_error_t * vlib_physmem_last_error(struct vlib_main_t *vm)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define foreach_vmxnet3_tx_func_error
vmxnet3_main_t vmxnet3_main
#define VMXNET3_NUM_TX_DESC
void vmxnet3_create_if(vlib_main_t *vm, vmxnet3_create_if_args_t *args)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static clib_error_t * vmxnet3_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static void vmxnet3_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static_always_inline void vmxnet3_reg_write(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)
static void clib_spinlock_free(clib_spinlock_t *p)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
static_always_inline u32 vmxnet3_reg_read(vmxnet3_device_t *vd, u8 bar, u32 addr)
#define VMXNET3_VERSION_SELECT
vlib_log_class_t log_default
static void vmxnet3_clear_hw_interface_counters(u32 instance)
vnet_hw_interface_rx_mode
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static_always_inline void vnet_device_input_set_interrupt_pending(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
vnet_hw_interface_flags_t flags
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static clib_error_t * vmxnet3_rxq_init(vlib_main_t *vm, vmxnet3_device_t *vd, u16 qid, u16 qsz)
static void clib_spinlock_init(clib_spinlock_t *p)
static void vlib_buffer_free_from_ring(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers)
Free buffers from ring.
static clib_error_t * vmxnet3_interface_rx_mode_change(vnet_main_t *vnm, u32 hw_if_index, u32 qid, vnet_hw_interface_rx_mode mode)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vmxnet3_write_mac(vmxnet3_device_t *vd)
static u8 vmxnet3_queue_size_valid(u16 qsz)
#define VMXNET3_GOS_TYPE_LINUX
#define VMXNET3_GOS_BITS_64
vmxnet3_rx_comp_ring rx_comp_ring
uword vlib_pci_get_private_data(vlib_main_t *vm, vlib_pci_dev_handle_t h)
u32 vlib_pci_dev_handle_t
vmxnet3_tx_comp_ring tx_comp_ring
#define VMXNET3_UPT_VERSION_SELECT
#define VMXNET3_RX_RING_SIZE
#define pool_put(P, E)
Free an object E in pool P.
vmxnet3_tx_comp * tx_comp
static void vmxnet3_irq_0_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
#define VMXNET3_VERSION_MAGIC
clib_error_t * vlib_pci_enable_msix_irq(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 start, u16 count)
clib_error_t * vlib_pci_map_region(vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 resource, void **result)
static void vmxnet3_enable_interrupt(vmxnet3_device_t *vd)
#define VMXNET3_IC_DISABLE_ALL
static void vlib_buffer_free_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers, does not free the buffer chain for each buffer.
static void vmxnet3_disable_interrupt(vmxnet3_device_t *vd)
static void vlib_physmem_free(vlib_main_t *vm, void *p)
#define vec_free(V)
Free vector's memory (no header).
u32 vlib_pci_get_numa_node(vlib_main_t *vm, vlib_pci_dev_handle_t h)
void vlib_log(vlib_log_level_t level, vlib_log_class_t class, char *fmt,...)
#define PCI_VENDOR_ID_VMWARE
u32 per_interface_next_index
VNET_DEVICE_CLASS(vmxnet3_device_class,)
clib_error_t * vlib_pci_register_msix_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 start, u32 count, pci_msix_handler_function_t *msix_handler)
static clib_error_t * vmxnet3_device_init(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_create_if_args_t *args)
void vnet_hw_interface_assign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id, uword thread_index)
format_function_t format_vmxnet3_device
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
static vlib_main_t * vlib_get_main(void)
static clib_error_t * vmxnet3_provision_driver_shared(vlib_main_t *vm, vmxnet3_device_t *vd)
#define VMXNET3_SHARED_MAGIC
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define PCI_DEVICE_ID_VMWARE_VMXNET3
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
vmxnet3_tx_desc * tx_desc
vnet_device_class_t vmxnet3_device_class
static u32 vmxnet3_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hw, u32 flags)
static void vmxnet3_irq_1_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
vmxnet3_rx_comp * rx_comp
#define clib_error_free(e)
vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]
int vnet_hw_interface_unassign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
vmxnet3_rx_stats rx_stats
vl_api_gbp_vxlan_tunnel_mode_t mode
static vlib_thread_main_t * vlib_get_thread_main()
vmxnet3_device_t * devices
static_always_inline clib_error_t * vmxnet3_rxq_refill_ring1(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_rxq_t *rxq)
#define vmxnet3_log_error(dev, f,...)
#define VMXNET3_NUM_RX_DESC
static clib_error_t * vlib_pci_intr_enable(vlib_main_t *vm, vlib_pci_dev_handle_t h)
#define CLIB_CACHE_LINE_BYTES
void vlib_pci_set_private_data(vlib_main_t *vm, vlib_pci_dev_handle_t h, uword private_data)
static void vnet_hw_interface_set_link_speed(vnet_main_t *vnm, u32 hw_if_index, u32 link_speed)
static void vnet_hw_interface_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
static clib_error_t * vmxnet3_txq_init(vlib_main_t *vm, vmxnet3_device_t *vd, u16 qid, u16 qsz)
void vlib_pci_device_close(vlib_main_t *vm, vlib_pci_dev_handle_t h)