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, 60 #define foreach_vmxnet3_feature_flags \ 61 _(0, RXCSUM, "rx checksum") \ 63 _(2, RXVLAN, "rx VLAN") \ 68 #define _(a, b, c) VMXNET3_F_##b = (1 << a), 73 #define foreach_vmxnet3_rss_hash_type \ 75 _(1, TCP_IPV4, "tcp ipv4") \ 77 _(3, TCP_IPV6, "tcp ipv6") 81 #define _(a, b, c) VMXNET3_RSS_HASH_TYPE_##b = (1 << a), 86 #define VMXNET3_RSS_HASH_FUNC_TOEPLITZ 1 87 #define VMXNET3_RSS_MAX_KEY_SZ 40 88 #define VMXNET3_RSS_MAX_IND_TABLE_SZ 128 90 #define VMXNET3_TXQ_MAX 8 91 #define VMXNET3_RXQ_MAX 16 92 #define VMXNET3_TX_START(vd) ((vd)->queues) 93 #define VMXNET3_RX_START(vd) \ 94 ((vd)->queues + (vd)->num_tx_queues * sizeof (vmxnet3_tx_queue)) 97 #define VMXNET3_REG_IMR 0x0000 98 #define VMXNET3_REG_TXPROD 0x0600 99 #define VMXNET3_REG_RXPROD 0x0800 100 #define VMXNET3_REG_RXPROD2 0x0A00 104 #define VMXNET3_REG_VRRS 0x0000 105 #define VMXNET3_REG_UVRS 0x0008 106 #define VMXNET3_REG_DSAL 0x0010 107 #define VMXNET3_REG_DSAH 0x0018 108 #define VMXNET3_REG_CMD 0x0020 109 #define VMXNET3_REG_MACL 0x0028 110 #define VMXNET3_REG_MACH 0x0030 111 #define VMXNET3_REG_ICR 0x0038 112 #define VMXNET3_REG_ECR 0x0040 114 #define VMXNET3_VLAN_LEN 4 115 #define VMXNET3_FCS_LEN 4 116 #define VMXNET3_MTU (1514 + VMXNET3_VLAN_LEN + VMXNET3_FCS_LEN) 118 #define VMXNET3_RXF_BTYPE (1 << 14) 119 #define VMXNET3_RXF_GEN (1 << 31) 121 #define VMXNET3_RXCF_CKSUM_MASK (0xFFFF) 122 #define VMXNET3_RXCF_TUC (1 << 16) 123 #define VMXNET3_RXCF_UDP (1 << 17) 124 #define VMXNET3_RXCF_TCP (1 << 18) 125 #define VMXNET3_RXCF_IPC (1 << 19) 126 #define VMXNET3_RXCF_IP6 (1 << 20) 127 #define VMXNET3_RXCF_IP4 (1 << 21) 128 #define VMXNET3_RXCF_CT (0x7F << 24) 129 #define VMXNET3_RXCF_GEN (1 << 31) 131 #define VMXNET3_RXC_INDEX (0xFFF) 133 #define foreach_vmxnet3_offload \ 135 _(2, CSUM, "checksum") \ 140 #define _(a, b, c) VMXNET3_OM_##b = (a), 146 #define VMXNET3_TXF_GEN (1 << 14) 149 #define VMXNET3_TXF_OM(x) ((x) << 10) 150 #define VMXNET3_TXF_MSSCOF(x) ((x) << 18) 151 #define VMXNET3_TXF_EOP (1 << 12) 152 #define VMXNET3_TXF_CQ (1 << 13) 155 #define VMXNET3_TXCF_GEN (1 << 31) 156 #define VMXNET3_TXC_INDEX (0xFFF) 158 #define VMXNET3_RX_RING_SIZE 2 159 #define VMXNET3_INPUT_REFILL_THRESHOLD 32 160 #define VMXNET3_NUM_TX_DESC 1024 161 #define VMXNET3_NUM_TX_COMP VMXNET3_NUM_TX_DESC 162 #define VMXNET3_NUM_RX_DESC 1024 163 #define VMXNET3_NUM_RX_COMP VMXNET3_NUM_RX_DESC 165 #define VMXNET3_VERSION_MAGIC 0x69505845 166 #define VMXNET3_SHARED_MAGIC 0xbabefee1 167 #define VMXNET3_VERSION_SELECT 1 168 #define VMXNET3_UPT_VERSION_SELECT 1 169 #define VMXNET3_MAX_INTRS 25 170 #define VMXNET3_IC_DISABLE_ALL 0x1 172 #define VMXNET3_GOS_BITS_32 (1 << 0) 173 #define VMXNET3_GOS_BITS_64 (2 << 0) 174 #define VMXNET3_GOS_TYPE_LINUX (1 << 2) 175 #define VMXNET3_RXCL_LEN_MASK (0x3FFF) // 14 bits 176 #define VMXNET3_RXCL_ERROR (1 << 14) 178 #define VMXNET3_RXCI_EOP (1 << 14) 179 #define VMXNET3_RXCI_SOP (1 << 15) 180 #define VMXNET3_RXCI_CNC (1 << 30) 182 #define VMXNET3_RXCOMP_TYPE (3 << 24) 183 #define VMXNET3_RXCOMP_TYPE_LRO (4 << 24) 185 #define VMXNET3_RXECF_MSS_MASK (0xFFFF) // 16 bits 187 #define foreach_vmxnet3_device_flags \ 188 _(0, INITIALIZED, "initialized") \ 189 _(1, ERROR, "error") \ 190 _(2, ADMIN_UP, "admin-up") \ 192 _(4, LINK_UP, "link-up") \ 193 _(5, SHARED_TXQ_LOCK, "shared-txq-lock") \ 198 #define _(a, b, c) VMXNET3_DEVICE_F_##b = (1 << a), 203 #define foreach_vmxnet3_set_cmds \ 204 _(0, ACTIVATE_DEV, "activate device") \ 205 _(1, QUIESCE_DEV, "quiesce device") \ 206 _(2, RESET_DEV, "reset device") \ 207 _(3, UPDATE_RX_MODE, "update rx mode") \ 208 _(4, UPDATE_MAC_FILTERS, "update mac filters") \ 209 _(5, UPDATE_VLAN_FILTERS, "update vlan filters") \ 210 _(6, UPDATE_RSSIDT, "update rss idt") \ 211 _(7, UPDATE_IML, "update iml") \ 212 _(8, UPDATE_PMCFG, "update pm cfg") \ 213 _(9, UPDATE_FEATURE, "update feature") \ 214 _(10, STOP_EMULATION, "stop emulation") \ 215 _(11, LOAD_PLUGIN, "load plugin") \ 216 _(12, ACTIVATE_VF, "activate vf") \ 217 _(13, RESERVED3, "reserved 3") \ 218 _(14, RESERVED4, "reservced 4") \ 219 _(15, REGISTER_MEMREGS, "register mem regs") 223 #define _(a, b, c) VMXNET3_CMD_##b = (a + 0xCAFE0000), 228 #define foreach_vmxnet3_get_cmds \ 229 _(0, GET_QUEUE_STATUS, "get queue status") \ 230 _(1, GET_STATS, "get stats") \ 231 _(2, GET_LINK, "get link") \ 232 _(3, GET_PERM_MAC_LO, "get perm mac lo") \ 233 _(4, GET_PERM_MAC_HI, "get perm mac hi") \ 234 _(5, GET_DID_LO, "get did lo") \ 235 _(6, GET_DID_HI, "get did hi") \ 236 _(7, GET_DEV_EXTRA_INFO, "get dev extra info") \ 237 _(8, GET_CONF_INTR, "get conf intr") \ 238 _(9, GET_ADAPTIVE_RING_INFO, "get adaptive ring info") \ 239 _(10, GET_TXDATA_DESC_SIZE, "get txdata desc size") \ 240 _(11, RESERVED5, "reserved5") 244 #define _(a, b, c) VMXNET3_CMD_##b = (a + 0xF00D0000), 252 u32 upt_version_support;
u64 upt_features;
253 u64 driver_data_address;
u64 queue_desc_address;
254 u32 driver_data_len;
u32 queue_desc_len;
256 u16 max_num_rx_sg;
u8 num_tx_queues;
u8 num_rx_queues;
258 }) vmxnet3_misc_config;
267 }) vmxnet3_interrupt_config;
272 u64 multicast_address;
u8 vlan_filter[512];
273 }) vmxnet3_rx_filter_config;
279 }) vmxnet3_variable_config;
285 vmxnet3_misc_config misc;
286 vmxnet3_interrupt_config interrupt;
287 vmxnet3_rx_filter_config rx_filter;
288 vmxnet3_variable_config rss;
289 vmxnet3_variable_config pattern;
290 vmxnet3_variable_config plugin;
u32 ecr;
299 }) vmxnet3_queue_status;
303 u32 num_deferred;
u32 threshold;
305 }) vmxnet3_tx_queue_control;
313 u32 num_data;
u32 num_comp;
u32 driver_data_len;
315 u8 pad1;
u16 data_address_size;
u8 pad2[4];
316 }) vmxnet3_tx_queue_config;
322 u64 ucast_pkts;
u64 ucast_bytes;
u64 mcast_pkts;
324 u64 bcast_pkts;
u64 bcast_bytes;
u64 error_pkts;
330 vmxnet3_tx_queue_control ctrl;
331 vmxnet3_tx_queue_config cfg;
332 vmxnet3_queue_status status; vmxnet3_tx_stats stats;
340 }) vmxnet3_rx_queue_control;
345 u64 comp_address;
u64 driver_data_address;
346 u64 data_address;
u32 num_desc[2];
348 u32 driver_data_len;
u8 intr_index;
u8 pad1;
349 u16 data_address_size;
u8 pad2[4];
350 }) vmxnet3_rx_queue_config;
356 u64 ucast_pkts;
u64 ucast_bytes;
u64 mcast_pkts;
358 u64 bcast_pkts;
u64 bcast_bytes;
u64 nobuf_pkts;
364 vmxnet3_rx_queue_control ctrl;
365 vmxnet3_rx_queue_config cfg;
366 vmxnet3_queue_status status; vmxnet3_rx_stats stats;
441 u8 seg_cnt;
u8 dup_ack_cnt;
u16 ts_delta;
u32 dword2;
443 }) vmxnet3_rx_comp_ext;
493 }) vmxnet3_rss_shared;
634 #define vmxnet3_log_debug(dev, f, ...) \ 635 vlib_log (VLIB_LOG_LEVEL_DEBUG, vmxnet3_main.log_default, "%U: " f, \ 636 format_vlib_pci_addr, &dev->pci_addr, \ 639 #define vmxnet3_log_error(dev, f, ...) \ 640 vlib_log (VLIB_LOG_LEVEL_ERR, vmxnet3_main.log_default, "%U: " f, \ 641 format_vlib_pci_addr, &dev->pci_addr, \ 663 val = *(
volatile u32 *) (vd->
bar[bar] + addr);
691 vmxnet3_rx_desc *rxd;
692 u16 n_refill, n_alloc;
694 vmxnet3_rx_queue *rx;
737 vmxnet3_rx_desc *rxd;
738 u16 n_refill, n_alloc;
740 vmxnet3_rx_queue *rx;
#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
#define foreach_vmxnet3_rss_hash_type
#define foreach_vmxnet3_tx_func_error
#define VMXNET3_RX_START(vd)
#define vmxnet3_log_debug(dev, f,...)
vmxnet3_tx_stats * tx_stats
void vmxnet3_delete_if(vlib_main_t *vm, vmxnet3_device_t *ad)
static u32 vlib_buffer_alloc_to_ring_from_pool(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers, u8 buffer_pool_index)
Allocate buffers into ring from specific buffer pool.
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...)
#define VMXNET3_RSS_MAX_KEY_SZ
vmxnet3_shared * driver_shared
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
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 vlib_pci_dev_handle_t
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
u32 per_interface_next_index
#define foreach_vmxnet3_feature_flags
vl_api_vxlan_gbp_api_tunnel_mode_t mode
#define VMXNET3_REG_RXPROD
format_function_t format_vmxnet3_device
vmxnet3_rx_stats * rx_stats
#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_always_inline void vmxnet3_rx_ring_advance_produce(vmxnet3_rxq_t *rxq, vmxnet3_rx_ring *ring)
VLIB buffer representation.
vmxnet3_tx_desc * tx_desc
#define VMXNET3_RSS_MAX_IND_TABLE_SZ
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_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.
#define foreach_vmxnet3_offload
static_always_inline void vmxnet3_reg_write_inline(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)