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;
109 .name =
"VMXNET3 interface",
143 vmxnet3_shared *shared;
152 sizeof (*vd->
dma), 512);
158 q = &vd->
dma->queues;
161 q->tx.cfg.num_desc = txq->
size;
162 q->tx.cfg.num_comp = txq->
size;
167 q->rx.cfg.num_desc[rid] = rxq->
size;
170 q->rx.cfg.num_comp = rxq->
size;
172 shared = &vd->
dma->shared;
175 if (
sizeof (
void *) == 4)
183 shared->misc.queue_desc_len =
sizeof (*q);
187 shared->interrupt.num_intrs = vd->
num_intrs;
188 shared->interrupt.event_intr_index = 1;
190 shared->rx_filter.mode = VMXNET3_RXMODE_UCAST | VMXNET3_RXMODE_BCAST |
191 VMXNET3_RXMODE_ALL_MULTI;
204 vmxnet3_shared *shared = &vd->
dma->shared;
215 vmxnet3_shared *shared = &vd->
dma->shared;
232 memset (rxq, 0,
sizeof (*rxq));
238 &error, qsz * sizeof (*rxq->
rx_desc[rid]),
277 vd->
flags |= VMXNET3_DEVICE_F_SHARED_TXQ_LOCK;
283 memset (txq, 0,
sizeof (*txq));
361 vd->
flags |= VMXNET3_DEVICE_F_LINK_UP;
366 vd->
flags &= ~VMXNET3_DEVICE_F_LINK_UP;
423 vd->
flags |= VMXNET3_DEVICE_F_INITIALIZED;
456 vd->
flags |= VMXNET3_DEVICE_F_LINK_UP;
463 vd->
flags &= ~VMXNET3_DEVICE_F_LINK_UP;
471 if (qsz < 64 || qsz > 4096)
495 args->
rv = VNET_API_ERROR_INVALID_VALUE;
498 "queue size must be <= 4096, >= 64, " 499 "and multiples of 64");
502 "queue size must be <= 4096, >= 64, and multiples of 64");
508 if (vd->pci_addr.as_u32 == args->addr.as_u32)
510 args->rv = VNET_API_ERROR_INVALID_VALUE;
512 clib_error_return (error,
"PCI address in use");
513 vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default,
"%U: %s",
514 format_vlib_pci_addr, &args->addr,
"pci address in use");
521 vd->dev_instance = vd - vmxm->devices;
522 vd->per_interface_next_index = ~0;
523 vd->pci_addr = args->addr;
525 if (args->enable_elog)
526 vd->flags |= VMXNET3_DEVICE_F_ELOG;
532 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
536 vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default,
"%U: %s",
538 "error encountered on pci device open");
546 vd->pci_dev_handle =
h;
571 "error encountered on pci register msix handler 0");
579 "error encountered on pci register msix handler 1");
603 vd->dev_instance, vd->mac_addr,
609 "error encountered on ethernet register interface");
622 if (vd->flags & VMXNET3_DEVICE_F_LINK_UP)
631 args->rv = VNET_API_ERROR_INVALID_INTERFACE;
670 desc_idx = (ring->
consume + 1) & mask;
690 while (desc_idx != end_idx)
708 memset (vd, 0,
sizeof (*vd));
static char * vmxnet3_tx_func_error_strings[]
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.
#define VLIB_PHYSMEM_F_INIT_MHEAP
vlib_physmem_region_index_t physmem_region
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
format_function_t format_vmxnet3_device_name
#define VMXNET3_GOS_BITS_32
#define VLIB_PHYSMEM_F_HUGETLB
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
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
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define foreach_vmxnet3_tx_func_error
static clib_error_t * vlib_physmem_region_alloc(vlib_main_t *vm, char *name, u32 size, u8 numa_node, u32 flags, vlib_physmem_region_index_t *idx)
vmxnet3_main_t vmxnet3_main
#define VMXNET3_NUM_TX_DESC
void vmxnet3_create_if(vlib_main_t *vm, vmxnet3_create_if_args_t *args)
static void vmxnet3_irq_1_handler(vlib_pci_dev_handle_t h, u16 line)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static void * vlib_physmem_alloc_aligned(vlib_main_t *vm, vlib_physmem_region_index_t idx, clib_error_t **error, uword n_bytes, uword 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)
clib_error_t * vlib_pci_register_msix_handler(vlib_pci_dev_handle_t h, u32 start, u32 count, pci_msix_handler_function_t *msix_handler)
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)
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
vnet_hw_interface_rx_mode
memset(h->entries, 0, sizeof(h->entries[0])*entries)
#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)
#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 void vmxnet3_irq_0_handler(vlib_pci_dev_handle_t h, u16 line)
clib_error_t * vlib_pci_device_open(vlib_pci_addr_t *addr, pci_device_id_t ids[], vlib_pci_dev_handle_t *handle)
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
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
#define VNET_HW_INTERFACE_FLAG_SUPPORTS_INT_MODE
static clib_error_t * vlib_pci_bus_master_enable(vlib_pci_dev_handle_t h)
#define VMXNET3_VERSION_MAGIC
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)
#define vec_free(V)
Free vector's memory (no header).
#define clib_memcpy(a, b, c)
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,)
static clib_error_t * vmxnet3_device_init(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_create_if_args_t *args)
void vlib_pci_device_close(vlib_pci_dev_handle_t h)
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
static void vlib_physmem_free(vlib_main_t *vm, vlib_physmem_region_index_t idx, void *mem)
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
uword vlib_pci_get_private_data(vlib_pci_dev_handle_t h)
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)
void vlib_pci_set_private_data(vlib_pci_dev_handle_t h, uword private_data)
vmxnet3_rx_comp * rx_comp
#define clib_error_free(e)
vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]
clib_error_t * vlib_pci_map_region(vlib_pci_dev_handle_t h, u32 resource, void **result)
int vnet_hw_interface_unassign_rx_thread(vnet_main_t *vnm, u32 hw_if_index, u16 queue_id)
clib_error_t * vlib_pci_enable_msix_irq(vlib_pci_dev_handle_t h, u16 start, u16 count)
static clib_error_t * vlib_pci_intr_enable(vlib_pci_dev_handle_t h)
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
#define CLIB_CACHE_LINE_BYTES
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)