16 #ifndef __included_vmnet_vmnet_h__ 17 #define __included_vmnet_vmnet_h__ 19 #define foreach_vmxnet3_tx_func_error \ 20 _(ERROR_PACKETS, "error packets") \ 21 _(LINK_DOWN, "link down") \ 22 _(NO_FREE_SLOTS, "no free tx slots") 26 #define _(f,s) VMXNET3_TX_ERROR_##f, 32 #define foreach_vmxnet3_rxmode_flags \ 33 _(0, UCAST, "unicast") \ 34 _(1, MCAST, "multicast") \ 35 _(2, BCAST, "broadcast") \ 36 _(3, ALL_MULTI, "all multicast") \ 37 _(4, PROMISC, "promiscuous") 41 #define _(a, b, c) VMXNET3_RXMODE_##b = (1 << a), 46 #define foreach_vmxnet3_show_entry \ 47 _(RX_COMP, "rx comp") \ 48 _(RX_DESC0, "rx desc 0") \ 49 _(RX_DESC1, "rx desc 1") \ 50 _(TX_COMP, "tx comp") \ 55 #define _(a, b) VMXNET3_SHOW_##a, 61 #define VMXNET3_REG_IMR 0x0000 62 #define VMXNET3_REG_TXPROD 0x0600 63 #define VMXNET3_REG_RXPROD 0x0800 64 #define VMXNET3_REG_RXPROD2 0x0A00 68 #define VMXNET3_REG_VRRS 0x0000 69 #define VMXNET3_REG_UVRS 0x0008 70 #define VMXNET3_REG_DSAL 0x0010 71 #define VMXNET3_REG_DSAH 0x0018 72 #define VMXNET3_REG_CMD 0x0020 73 #define VMXNET3_REG_MACL 0x0028 74 #define VMXNET3_REG_MACH 0x0030 75 #define VMXNET3_REG_ICR 0x0038 76 #define VMXNET3_REG_ECR 0x0040 78 #define VMXNET3_VLAN_LEN 4 79 #define VMXNET3_FCS_LEN 4 80 #define VMXNET3_MTU (1514 + VMXNET3_VLAN_LEN + VMXNET3_FCS_LEN) 82 #define VMXNET3_RXF_BTYPE (1 << 14) 83 #define VMXNET3_RXF_GEN (1 << 31) 84 #define VMXNET3_RXCF_IP6 (1 << 20) 85 #define VMXNET3_RXCF_IP4 (1 << 21) 86 #define VMXNET3_RXCF_GEN (1 << 31) 87 #define VMXNET3_RXC_INDEX (0xFFF) 89 #define VMXNET3_TXF_GEN (1 << 14) 90 #define VMXNET3_TXF_EOP (1 << 12) 91 #define VMXNET3_TXF_CQ (1 << 13) 92 #define VMXNET3_TXCF_GEN (1 << 31) 93 #define VMXNET3_TXC_INDEX (0xFFF) 95 #define VMXNET3_RX_RING_SIZE 2 96 #define VMXNET3_INPUT_REFILL_THRESHOLD 32 97 #define VMXNET3_NUM_TX_DESC 1024 98 #define VMXNET3_NUM_TX_COMP VMXNET3_NUM_TX_DESC 99 #define VMXNET3_NUM_RX_DESC 1024 100 #define VMXNET3_NUM_RX_COMP VMXNET3_NUM_RX_DESC 102 #define VMXNET3_VERSION_MAGIC 0x69505845 103 #define VMXNET3_SHARED_MAGIC 0xbabefee1 104 #define VMXNET3_VERSION_SELECT 1 105 #define VMXNET3_UPT_VERSION_SELECT 1 106 #define VMXNET3_MAX_INTRS 25 107 #define VMXNET3_IC_DISABLE_ALL 0x1 109 #define VMXNET3_GOS_BITS_32 (1 << 0) 110 #define VMXNET3_GOS_BITS_64 (2 << 0) 111 #define VMXNET3_GOS_TYPE_LINUX (1 << 2) 112 #define VMXNET3_RXCL_LEN_MASK (0x3FFF) // 14 bits 113 #define VMXNET3_RXCL_ERROR (1 << 14) 114 #define VMXNET3_RXCI_EOP (1 << 14) 115 #define VMXNET3_RXCI_SOP (1 << 15) 117 #define foreach_vmxnet3_device_flags \ 118 _(0, INITIALIZED, "initialized") \ 119 _(1, ERROR, "error") \ 120 _(2, ADMIN_UP, "admin-up") \ 122 _(4, LINK_UP, "link-up") \ 123 _(5, SHARED_TXQ_LOCK, "shared-txq-lock") \ 128 #define _(a, b, c) VMXNET3_DEVICE_F_##b = (1 << a), 133 #define foreach_vmxnet3_set_cmds \ 134 _(0, ACTIVATE_DEV, "activate device") \ 135 _(1, QUIESCE_DEV, "quiesce device") \ 136 _(2, RESET_DEV, "reset device") \ 137 _(3, UPDATE_RX_MODE, "update rx mode") \ 138 _(4, UPDATE_MAC_FILTERS, "update mac filters") \ 139 _(5, UPDATE_VLAN_FILTERS, "update vlan filters") \ 140 _(6, UPDATE_RSSIDT, "update rss idt") \ 141 _(7, UPDATE_IML, "update iml") \ 142 _(8, UPDATE_PMCFG, "update pm cfg") \ 143 _(9, UPDATE_FEATURE, "update feature") \ 144 _(10, STOP_EMULATION, "stop emulation") \ 145 _(11, LOAD_PLUGIN, "load plugin") \ 146 _(12, ACTIVATE_VF, "activate vf") \ 147 _(13, RESERVED3, "reserved 3") \ 148 _(14, RESERVED4, "reservced 4") \ 149 _(15, REGISTER_MEMREGS, "register mem regs") 153 #define _(a, b, c) VMXNET3_CMD_##b = (a + 0xCAFE0000), 158 #define foreach_vmxnet3_get_cmds \ 159 _(0, GET_QUEUE_STATUS, "get queue status") \ 160 _(1, GET_STATS, "get stats") \ 161 _(2, GET_LINK, "get link") \ 162 _(3, GET_PERM_MAC_LO, "get perm mac lo") \ 163 _(4, GET_PERM_MAC_HI, "get perm mac hi") \ 164 _(5, GET_DID_LO, "get did lo") \ 165 _(6, GET_DID_HI, "get did hi") \ 166 _(7, GET_DEV_EXTRA_INFO, "get dev extra info") \ 167 _(8, GET_CONF_INTR, "get conf intr") \ 168 _(9, GET_ADAPTIVE_RING_INFO, "get adaptive ring info") \ 169 _(10, GET_TXDATA_DESC_SIZE, "get txdata desc size") \ 170 _(11, RESERVED5, "reserved5") 174 #define _(a, b, c) VMXNET3_CMD_##b = (a + 0xF00D0000), 182 u32 upt_version_support;
u64 upt_features;
183 u64 driver_data_address;
u64 queue_desc_address;
184 u32 driver_data_len;
u32 queue_desc_len;
186 u16 max_num_rx_sg;
u8 num_tx_queues;
u8 num_rx_queues;
188 }) vmxnet3_misc_config;
197 }) vmxnet3_interrupt_config;
203 u16 pad;
u64 multicast_address;
u8 vlan_filter[512];
204 }) vmxnet3_rx_filter_config;
210 }) vmxnet3_variable_config;
216 vmxnet3_misc_config misc;
217 vmxnet3_interrupt_config interrupt;
218 vmxnet3_rx_filter_config rx_filter;
219 vmxnet3_variable_config rss;
220 vmxnet3_variable_config pattern;
221 vmxnet3_variable_config plugin;
u32 ecr;
230 }) vmxnet3_queue_status;
234 u32 num_deferred;
u32 threshold;
236 }) vmxnet3_tx_queue_control;
245 u32 num_comp;
u32 driver_data_len;
u8 intr_index;
247 }) vmxnet3_tx_queue_config;
253 u64 ucast_pkts;
u64 ucast_bytes;
u64 mcast_pkts;
255 u64 bcast_pkts;
u64 bcast_bytes;
u64 error_pkts;
261 vmxnet3_tx_queue_control ctrl;
262 vmxnet3_tx_queue_config cfg;
263 vmxnet3_queue_status status; vmxnet3_tx_stats stats;
271 }) vmxnet3_rx_queue_control;
278 u32 num_comp;
u32 driver_data_len;
u8 intr_index;
280 }) vmxnet3_rx_queue_config;
286 u64 ucast_pkts;
u64 ucast_bytes;
u64 mcast_pkts;
288 u64 bcast_pkts;
u64 bcast_bytes;
u64 nobuf_pkts;
294 vmxnet3_rx_queue_control ctrl;
295 vmxnet3_rx_queue_config cfg;
296 vmxnet3_queue_status status; vmxnet3_rx_stats stats;
302 vmxnet3_tx_queue tx; vmxnet3_rx_queue rx;
458 vmxnet3_queues queues; vmxnet3_shared shared;
536 #define vmxnet3_log_debug(dev, f, ...) \ 537 vlib_log (VLIB_LOG_LEVEL_DEBUG, vmxnet3_main.log_default, "%U: " f, \ 538 format_vlib_pci_addr, &dev->pci_addr, \ 541 #define vmxnet3_log_error(dev, f, ...) \ 542 vlib_log (VLIB_LOG_LEVEL_ERR, vmxnet3_main.log_default, "%U: " f, \ 543 format_vlib_pci_addr, &dev->pci_addr, \ 565 val = *(
volatile u32 *) (vd->
bar[bar] + addr);
593 vmxnet3_rx_desc *rxd;
594 u16 n_refill, n_alloc;
627 q = &vd->
dma->queues;
638 vmxnet3_rx_desc *rxd;
639 u16 n_refill, n_alloc;
672 q = &vd->
dma->queues;
#define foreach_vmxnet3_device_flags
#define foreach_vmxnet3_show_entry
static_always_inline clib_error_t * vmxnet3_rxq_refill_ring0(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_rxq_t *rxq)
#define foreach_vmxnet3_set_cmds
u8 pad[3]
log2 (size of the packing page block)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
format_function_t format_vmxnet3_device_name
#define VMXNET3_MAX_INTRS
vmxnet3_rx_desc * rx_desc[VMXNET3_RX_RING_SIZE]
static uword vlib_buffer_get_pa(vlib_main_t *vm, vlib_buffer_t *b)
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
vmxnet3_main_t vmxnet3_main
vmxnet3_tx_stats tx_stats
#define foreach_vmxnet3_tx_func_error
#define vmxnet3_log_debug(dev, f,...)
void vmxnet3_delete_if(vlib_main_t *vm, vmxnet3_device_t *ad)
struct _vnet_device_class vnet_device_class_t
static_always_inline void vmxnet3_reg_write(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)
static_always_inline u32 vmxnet3_reg_read(vmxnet3_device_t *vd, u8 bar, u32 addr)
vlib_log_class_t log_default
#define static_always_inline
#define foreach_vmxnet3_get_cmds
#define clib_error_return(e, args...)
clib_error_t * vmxnet3_plugin_api_hookup(vlib_main_t *vm)
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.
void vmxnet3_create_if(vlib_main_t *vm, vmxnet3_create_if_args_t *args)
vmxnet3_rx_comp_ring rx_comp_ring
u32 vlib_pci_dev_handle_t
typedef CLIB_PACKED(struct{u32 version;u32 guest_info;u32 version_support;u32 upt_version_support;u64 upt_features;u64 driver_data_address;u64 queue_desc_address;u32 driver_data_len;u32 queue_desc_len;u32 mtu;u16 max_num_rx_sg;u8 num_tx_queues;u8 num_rx_queues;u32 pad[4];}) vmxnet3_misc_config
vmxnet3_tx_comp_ring tx_comp_ring
#define VMXNET3_RX_RING_SIZE
vmxnet3_tx_comp * tx_comp
u32 per_interface_next_index
#define VLIB_BUFFER_DATA_SIZE
#define VMXNET3_REG_RXPROD
format_function_t format_vmxnet3_device
#define foreach_vmxnet3_rxmode_flags
static uword pointer_to_uword(const void *p)
struct _vlib_node_registration vlib_node_registration_t
static u64 vlib_physmem_get_pa(vlib_main_t *vm, void *mem)
static u32 vlib_buffer_alloc_to_ring(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers)
Allocate buffers into ring.
static_always_inline void vmxnet3_rx_ring_advance_produce(vmxnet3_rxq_t *rxq, vmxnet3_rx_ring *ring)
vmxnet3_tx_desc * tx_desc
vnet_device_class_t vmxnet3_device_class
#define VMXNET3_RXF_BTYPE
vmxnet3_rx_comp * rx_comp
vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]
format_function_t format_vmxnet3_input_trace
vmxnet3_rx_stats rx_stats
vl_api_gbp_vxlan_tunnel_mode_t mode
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_REG_RXPROD2
vlib_node_registration_t vmxnet3_input_node
(constructor) VLIB_REGISTER_NODE (vmxnet3_input_node)
#define VMXNET3_INPUT_REFILL_THRESHOLD
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static_always_inline void vmxnet3_reg_write_inline(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)