iPXE
vmxnet3.h
Go to the documentation of this file.
1 #ifndef _VMXNET3_H
2 #define _VMXNET3_H
3 
4 /*
5  * Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA.
21  *
22  * You can also choose to distribute this program under the terms of
23  * the Unmodified Binary Distribution Licence (as given in the file
24  * COPYING.UBDL), provided that you have satisfied its requirements.
25  */
26 
27 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
28 FILE_SECBOOT ( PERMITTED );
29 
30 /**
31  * @file
32  *
33  * VMware vmxnet3 virtual NIC driver
34  *
35  */
36 
37 #include <ipxe/pci.h>
38 
39 /** Maximum number of TX queues */
40 #define VMXNET3_MAX_TX_QUEUES 8
41 
42 /** Maximum number of RX queues */
43 #define VMXNET3_MAX_RX_QUEUES 16
44 
45 /** Maximum number of interrupts */
46 #define VMXNET3_MAX_INTRS 25
47 
48 /** Maximum packet size */
49 #define VMXNET3_MAX_PACKET_LEN 0x4000
50 
51 /** "PT" PCI BAR address */
52 #define VMXNET3_PT_BAR PCI_BASE_ADDRESS_0
53 
54 /** "PT" PCI BAR size */
55 #define VMXNET3_PT_LEN 0x1000
56 
57 /** Interrupt Mask Register */
58 #define VMXNET3_PT_IMR 0x0
59 
60 /** Transmit producer index */
61 #define VMXNET3_PT_TXPROD 0x600
62 
63 /** Rx producer index for ring 1 */
64 #define VMXNET3_PT_RXPROD 0x800
65 
66 /** Rx producer index for ring 2 */
67 #define VMXNET3_PT_RXPROD2 0xa00
68 
69 /** "VD" PCI BAR address */
70 #define VMXNET3_VD_BAR PCI_BASE_ADDRESS_1
71 
72 /** "VD" PCI BAR size */
73 #define VMXNET3_VD_LEN 0x1000
74 
75 /** vmxnet3 Revision Report Selection */
76 #define VMXNET3_VD_VRRS 0x0
77 
78 /** UPT Version Report Selection */
79 #define VMXNET3_VD_UVRS 0x8
80 
81 /** Driver Shared Address Low */
82 #define VMXNET3_VD_DSAL 0x10
83 
84 /** Driver Shared Address High */
85 #define VMXNET3_VD_DSAH 0x18
86 
87 /** Command */
88 #define VMXNET3_VD_CMD 0x20
89 
90 /** MAC Address Low */
91 #define VMXNET3_VD_MACL 0x28
92 
93 /** MAC Address High */
94 #define VMXNET3_VD_MACH 0x30
95 
96 /** Interrupt Cause Register */
97 #define VMXNET3_VD_ICR 0x38
98 
99 /** Event Cause Register */
100 #define VMXNET3_VD_ECR 0x40
101 
102 /** Commands */
104  VMXNET3_CMD_FIRST_SET = 0xcafe0000,
116 
117  VMXNET3_CMD_FIRST_GET = 0xf00d0000,
127 };
128 
129 /** Events */
131  VMXNET3_ECR_RQERR = 0x00000001,
132  VMXNET3_ECR_TQERR = 0x00000002,
133  VMXNET3_ECR_LINK = 0x00000004,
134  VMXNET3_ECR_DIC = 0x00000008,
135  VMXNET3_ECR_DEBUG = 0x00000010,
136 };
137 
138 /** Miscellaneous configuration descriptor */
140  /** Driver version */
142  /** Guest information */
144  /** Version supported */
146  /** UPT version supported */
148  /** UPT features supported */
150  /** Driver-private data address */
152  /** Queue descriptors data address */
154  /** Driver-private data length */
156  /** Queue descriptors data length */
158  /** Maximum transmission unit */
160  /** Maximum number of RX scatter-gather */
162  /** Number of TX queues */
164  /** Number of RX queues */
166  /** Reserved */
168 } __attribute__ (( packed ));
169 
170 /** Driver version magic */
171 #define VMXNET3_VERSION_MAGIC 0x69505845
172 
173 /** Interrupt configuration */
181 } __attribute__ (( packed ));
182 
183 /** Interrupt control - disable all interrupts */
184 #define VMXNET3_IC_DISABLE_ALL 0x1
185 
186 /** Receive filter configuration */
188  /** Receive filter mode */
190  /** Multicast filter table length */
192  /** Reserved */
194  /** Multicast filter table address */
196  /** VLAN filter table (one bit per possible VLAN) */
198 } __attribute__ (( packed ));
199 
200 /** Receive filter mode */
202  VMXNET3_RXM_UCAST = 0x01, /**< Unicast only */
203  VMXNET3_RXM_MCAST = 0x02, /**< Multicast passing the filters */
204  VMXNET3_RXM_BCAST = 0x04, /**< Broadcast only */
205  VMXNET3_RXM_ALL_MULTI = 0x08, /**< All multicast */
206  VMXNET3_RXM_PROMISC = 0x10, /**< Promiscuous */
207 };
208 
209 /** Variable-length configuration descriptor */
214 } __attribute__ (( packed ));
215 
216 /** Driver shared area */
218  /** Magic signature */
220  /** Reserved */
222  /** Miscellaneous configuration */
224  /** Interrupt configuration */
226  /** Receive filter configuration */
228  /** RSS configuration */
230  /** Pattern-matching configuration */
232  /** Plugin configuration */
234  /** Event notifications */
236  /** Reserved */
238 } __attribute__ (( packed ));
239 
240 /** Alignment of driver shared area */
241 #define VMXNET3_SHARED_ALIGN 8
242 
243 /** Driver shared area magic */
244 #define VMXNET3_SHARED_MAGIC 0xbabefee1
245 
246 /** Transmit descriptor */
248  /** Address */
250  /** Flags */
252 } __attribute__ (( packed ));
253 
254 /** Transmit generation flag */
255 #define VMXNET3_TXF_GEN 0x00004000UL
256 
257 /** Transmit end-of-packet flag */
258 #define VMXNET3_TXF_EOP 0x000001000UL
259 
260 /** Transmit completion request flag */
261 #define VMXNET3_TXF_CQ 0x000002000UL
262 
263 /** Transmit completion descriptor */
265  /** Index of the end-of-packet descriptor */
267  /** Reserved */
269  /** Flags */
271 } __attribute__ (( packed ));
272 
273 /** Transmit completion generation flag */
274 #define VMXNET3_TXCF_GEN 0x80000000UL
275 
276 /** Transmit queue control */
281 } __attribute__ (( packed ));
282 
283 /** Transmit queue configuration */
285  /** Descriptor ring address */
287  /** Data ring address */
289  /** Completion ring address */
291  /** Driver-private data address */
293  /** Reserved */
295  /** Number of descriptors */
297  /** Number of data descriptors */
299  /** Number of completion descriptors */
301  /** Driver-private data length */
303  /** Interrupt index */
305  /** Reserved */
307 } __attribute__ (( packed ));
308 
309 /** Transmit queue statistics */
311  /** Reserved */
313 } __attribute__ (( packed ));
314 
315 /** Receive descriptor */
317  /** Address */
319  /** Flags */
321  /** Reserved */
323 } __attribute__ (( packed ));
324 
325 /** Receive generation flag */
326 #define VMXNET3_RXF_GEN 0x80000000UL
327 
328 /** Receive completion descriptor */
330  /** Descriptor index */
332  /** RSS hash value */
334  /** Length */
336  /** Flags */
338 } __attribute__ (( packed ));
339 
340 /** Receive completion generation flag */
341 #define VMXNET3_RXCF_GEN 0x80000000UL
342 
343 /** Receive queue control */
348 } __attribute__ (( packed ));
349 
350 /** Receive queue configuration */
352  /** Descriptor ring addresses */
354  /** Completion ring address */
356  /** Driver-private data address */
358  /** Reserved */
360  /** Number of descriptors */
362  /** Number of completion descriptors */
364  /** Driver-private data length */
366  /** Interrupt index */
368  /** Reserved */
370 } __attribute__ (( packed ));
371 
372 /** Receive queue statistics */
374  /** Reserved */
376 } __attribute__ (( packed ));
377 
378 /** Queue status */
383 } __attribute__ (( packed ));
384 
385 /** Transmit queue descriptor */
392 } __attribute__ (( packed ));
393 
394 /** Receive queue descriptor */
401 } __attribute__ (( packed ));
402 
403 /**
404  * Queue descriptor set
405  *
406  * We use only a single TX and RX queue
407  */
409  /** Transmit queue descriptor(s) */
411  /** Receive queue descriptor(s) */
413 } __attribute__ (( packed ));
414 
415 /** Alignment of queue descriptor set */
416 #define VMXNET3_QUEUES_ALIGN 128
417 
418 /** Alignment of rings */
419 #define VMXNET3_RING_ALIGN 512
420 
421 /** Number of TX descriptors */
422 #define VMXNET3_NUM_TX_DESC 32
423 
424 /** Number of TX completion descriptors */
425 #define VMXNET3_NUM_TX_COMP 32
426 
427 /** Number of RX descriptors */
428 #define VMXNET3_NUM_RX_DESC 32
429 
430 /** Number of RX completion descriptors */
431 #define VMXNET3_NUM_RX_COMP 32
432 
433 /**
434  * DMA areas
435  *
436  * These are arranged in order of decreasing alignment, to allow for a
437  * single allocation
438  */
439 struct vmxnet3_dma {
440  /** TX descriptor ring */
442  /** TX completion ring */
444  /** RX descriptor ring */
446  /** RX completion ring */
448  /** Queue descriptors */
450  /** Shared area */
452 } __attribute__ (( packed ));
453 
454 /** DMA area alignment */
455 #define VMXNET3_DMA_ALIGN 512
456 
457 /** Producer and consumer counters */
459  /** Transmit producer counter */
460  unsigned int tx_prod;
461  /** Transmit completion consumer counter */
462  unsigned int tx_cons;
463  /** Receive producer counter */
464  unsigned int rx_prod;
465  /** Receive fill level */
466  unsigned int rx_fill;
467  /** Receive consumer counter */
468  unsigned int rx_cons;
469 };
470 
471 /** A vmxnet3 NIC */
472 struct vmxnet3_nic {
473  /** "PT" register base address */
474  void *pt;
475  /** "VD" register base address */
476  void *vd;
477 
478  /** DMA area */
479  struct vmxnet3_dma *dma;
480  /** Producer and consumer counters */
482  /** Transmit I/O buffers */
484  /** Receive I/O buffers */
486 };
487 
488 /** vmxnet3 version that we support */
489 #define VMXNET3_VERSION_SELECT 1
490 
491 /** UPT version that we support */
492 #define VMXNET3_UPT_VERSION_SELECT 1
493 
494 /** MTU size */
495 #define VMXNET3_MTU ( ETH_FRAME_LEN + 4 /* VLAN */ + 4 /* FCS */ )
496 
497 /** Transmit ring maximum fill level */
498 #define VMXNET3_TX_FILL ( VMXNET3_NUM_TX_DESC - 1 )
499 
500 /** Receive ring maximum fill level */
501 #define VMXNET3_RX_FILL 8
502 
503 /** Received packet alignment padding */
504 #define NET_IP_ALIGN 2
505 
506 #endif /* _VMXNET3_H */
uint64_t upt_features
UPT features supported.
Definition: vmxnet3.h:149
vmxnet3_event
Events.
Definition: vmxnet3.h:130
struct vmxnet3_tx_queue_config cfg
Definition: vmxnet3.h:388
struct vmxnet3_rx_queue_config cfg
Definition: vmxnet3.h:397
uint32_t driver_data_len
Driver-private data length.
Definition: vmxnet3.h:365
Receive queue configuration.
Definition: vmxnet3.h:351
uint32_t driver_data_len
Driver-private data length.
Definition: vmxnet3.h:302
#define __attribute__(x)
Definition: compiler.h:10
Driver shared area.
Definition: vmxnet3.h:217
unsigned short uint16_t
Definition: stdint.h:11
uint16_t max_num_rx_sg
Maximum number of RX scatter-gather.
Definition: vmxnet3.h:161
vmxnet3_rx_filter_mode
Receive filter mode.
Definition: vmxnet3.h:201
Broadcast only.
Definition: vmxnet3.h:204
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
void * vd
"VD" register base address
Definition: vmxnet3.h:476
Transmit descriptor.
Definition: vmxnet3.h:247
struct vmxnet3_rx_queue_control ctrl
Definition: vmxnet3.h:396
uint8_t intr_index
Interrupt index.
Definition: vmxnet3.h:367
uint64_t driver_data_address
Driver-private data address.
Definition: vmxnet3.h:292
#define VMXNET3_MAX_INTRS
Maximum number of interrupts.
Definition: vmxnet3.h:46
uint32_t version_support
Version supported.
Definition: vmxnet3.h:145
Queue status.
Definition: vmxnet3.h:379
Receive filter configuration.
Definition: vmxnet3.h:187
uint64_t desc_address
Descriptor ring address.
Definition: vmxnet3.h:286
Receive queue statistics.
Definition: vmxnet3.h:373
Transmit queue statistics.
Definition: vmxnet3.h:310
uint8_t moderation_level[VMXNET3_MAX_INTRS]
Definition: vmxnet3.h:178
struct vmxnet3_rx_comp rx_comp[VMXNET3_NUM_RX_COMP]
RX completion ring.
Definition: vmxnet3.h:447
Receive descriptor.
Definition: vmxnet3.h:316
Unicast only.
Definition: vmxnet3.h:202
uint8_t num_rx_queues
Number of RX queues.
Definition: vmxnet3.h:165
struct vmxnet3_interrupt_config interrupt
Interrupt configuration.
Definition: vmxnet3.h:225
unsigned int rx_fill
Receive fill level.
Definition: vmxnet3.h:466
#define VMXNET3_NUM_TX_DESC
Number of TX descriptors.
Definition: vmxnet3.h:422
unsigned int tx_prod
Transmit producer counter.
Definition: vmxnet3.h:460
unsigned long long uint64_t
Definition: stdint.h:13
struct vmxnet3_dma * dma
DMA area.
Definition: vmxnet3.h:479
uint32_t reserved0
Reserved.
Definition: vmxnet3.h:322
uint32_t flags
Flags.
Definition: vmxnet3.h:270
struct vmxnet3_tx_stats state
Definition: vmxnet3.h:390
Producer and consumer counters.
Definition: vmxnet3.h:458
uint64_t reserved0
Reserved.
Definition: vmxnet3.h:359
uint32_t num_desc
Number of descriptors.
Definition: vmxnet3.h:296
uint16_t reserved0
Reserved.
Definition: vmxnet3.h:193
Interrupt configuration.
Definition: vmxnet3.h:174
uint8_t vlan_filter[512]
VLAN filter table (one bit per possible VLAN)
Definition: vmxnet3.h:197
uint32_t index
Index of the end-of-packet descriptor.
Definition: vmxnet3.h:266
uint32_t reserved0
Reserved.
Definition: vmxnet3.h:221
Miscellaneous configuration descriptor.
Definition: vmxnet3.h:139
uint32_t upt_version_support
UPT version supported.
Definition: vmxnet3.h:147
uint32_t mtu
Maximum transmission unit.
Definition: vmxnet3.h:159
uint32_t reserved1[5]
Reserved.
Definition: vmxnet3.h:237
uint32_t reserved0[2]
Definition: vmxnet3.h:180
#define VMXNET3_NUM_TX_COMP
Number of TX completion descriptors.
Definition: vmxnet3.h:425
uint64_t reserved0
Reserved.
Definition: vmxnet3.h:294
uint32_t rss
RSS hash value.
Definition: vmxnet3.h:333
uint8_t reserved0[7]
Definition: vmxnet3.h:346
uint64_t queue_desc_address
Queue descriptors data address.
Definition: vmxnet3.h:153
uint32_t queue_desc_len
Queue descriptors data length.
Definition: vmxnet3.h:157
uint8_t reserved0[3]
Definition: vmxnet3.h:381
uint32_t flags[2]
Flags.
Definition: vmxnet3.h:251
struct vmxnet3_variable_config rss
RSS configuration.
Definition: vmxnet3.h:229
struct io_buffer * tx_iobuf[VMXNET3_NUM_TX_DESC]
Transmit I/O buffers.
Definition: vmxnet3.h:483
Transmit queue control.
Definition: vmxnet3.h:277
uint32_t guest_info
Guest information.
Definition: vmxnet3.h:143
All multicast.
Definition: vmxnet3.h:205
struct vmxnet3_queues queues
Queue descriptors.
Definition: vmxnet3.h:449
uint32_t num_desc[2]
Number of descriptors.
Definition: vmxnet3.h:361
uint32_t mode
Receive filter mode.
Definition: vmxnet3.h:189
struct vmxnet3_queue_status status
Definition: vmxnet3.h:398
Promiscuous.
Definition: vmxnet3.h:206
vmxnet3_command
Commands.
Definition: vmxnet3.h:103
struct vmxnet3_rx_filter_config rx_filter
Receive filter configuration.
Definition: vmxnet3.h:227
Receive queue control.
Definition: vmxnet3.h:344
uint16_t multicast_len
Multicast filter table length.
Definition: vmxnet3.h:191
Receive queue descriptor.
Definition: vmxnet3.h:395
uint8_t reserved[7]
Reserved.
Definition: vmxnet3.h:369
Transmit queue descriptor.
Definition: vmxnet3.h:386
DMA areas.
Definition: vmxnet3.h:439
PCI bus.
struct vmxnet3_queue_status status
Definition: vmxnet3.h:389
uint32_t num_comp
Number of completion descriptors.
Definition: vmxnet3.h:300
unsigned char uint8_t
Definition: stdint.h:10
Transmit queue configuration.
Definition: vmxnet3.h:284
uint64_t comp_address
Completion ring address.
Definition: vmxnet3.h:290
unsigned int uint32_t
Definition: stdint.h:12
uint32_t flags
Flags.
Definition: vmxnet3.h:337
#define VMXNET3_NUM_RX_COMP
Number of RX completion descriptors.
Definition: vmxnet3.h:431
struct vmxnet3_tx_queue_control ctrl
Definition: vmxnet3.h:387
uint64_t immediate_address
Data ring address.
Definition: vmxnet3.h:288
Definition: dmfe.c:137
struct vmxnet3_rx_queue rx
Receive queue descriptor(s)
Definition: vmxnet3.h:412
uint64_t desc_address[2]
Descriptor ring addresses.
Definition: vmxnet3.h:353
uint64_t address
Address.
Definition: vmxnet3.h:318
uint32_t reserved0[4]
Reserved.
Definition: vmxnet3.h:167
uint32_t reserved0[2]
Reserved.
Definition: vmxnet3.h:268
unsigned int rx_cons
Receive consumer counter.
Definition: vmxnet3.h:468
void * pt
"PT" register base address
Definition: vmxnet3.h:474
struct vmxnet3_rx_stats stats
Definition: vmxnet3.h:399
Queue descriptor set.
Definition: vmxnet3.h:408
struct vmxnet3_variable_config plugin
Plugin configuration.
Definition: vmxnet3.h:233
struct io_buffer * rx_iobuf[VMXNET3_NUM_RX_DESC]
Receive I/O buffers.
Definition: vmxnet3.h:485
unsigned int rx_prod
Receive producer counter.
Definition: vmxnet3.h:464
uint64_t driver_data_address
Driver-private data address.
Definition: vmxnet3.h:151
struct vmxnet3_tx_queue tx
Transmit queue descriptor(s)
Definition: vmxnet3.h:410
uint8_t intr_index
Interrupt index.
Definition: vmxnet3.h:304
struct vmxnet3_misc_config misc
Miscellaneous configuration.
Definition: vmxnet3.h:223
uint32_t flags
Flags.
Definition: vmxnet3.h:320
uint32_t index
Descriptor index.
Definition: vmxnet3.h:331
uint64_t reserved[10]
Reserved.
Definition: vmxnet3.h:312
Definition: dmfe.c:143
FILE_SECBOOT(PERMITTED)
uint64_t reserved[10]
Reserved.
Definition: vmxnet3.h:375
Variable-length configuration descriptor.
Definition: vmxnet3.h:210
uint64_t address
Address.
Definition: vmxnet3.h:249
uint8_t num_tx_queues
Number of TX queues.
Definition: vmxnet3.h:163
unsigned int tx_cons
Transmit completion consumer counter.
Definition: vmxnet3.h:462
uint8_t reserved[88]
Definition: vmxnet3.h:391
struct vmxnet3_tx_comp tx_comp[VMXNET3_NUM_TX_COMP]
TX completion ring.
Definition: vmxnet3.h:443
uint32_t magic
Magic signature.
Definition: vmxnet3.h:219
uint8_t reserved[7]
Reserved.
Definition: vmxnet3.h:306
uint8_t reserved[88]
Definition: vmxnet3.h:400
Transmit completion descriptor.
Definition: vmxnet3.h:264
uint64_t driver_data_address
Driver-private data address.
Definition: vmxnet3.h:357
uint64_t multicast_address
Multicast filter table address.
Definition: vmxnet3.h:195
struct vmxnet3_counters count
Producer and consumer counters.
Definition: vmxnet3.h:481
#define VMXNET3_NUM_RX_DESC
Number of RX descriptors.
Definition: vmxnet3.h:428
uint32_t driver_data_len
Driver-private data length.
Definition: vmxnet3.h:155
struct vmxnet3_shared shared
Shared area.
Definition: vmxnet3.h:451
uint32_t num_immediate
Number of data descriptors.
Definition: vmxnet3.h:298
Multicast passing the filters.
Definition: vmxnet3.h:203
uint32_t ecr
Event notifications.
Definition: vmxnet3.h:235
A vmxnet3 NIC.
Definition: vmxnet3.h:472
uint32_t len
Length.
Definition: vmxnet3.h:335
Receive completion descriptor.
Definition: vmxnet3.h:329
uint32_t num_comp
Number of completion descriptors.
Definition: vmxnet3.h:363
struct vmxnet3_variable_config pattern
Pattern-matching configuration.
Definition: vmxnet3.h:231
uint32_t version
Driver version.
Definition: vmxnet3.h:141
uint64_t comp_address
Completion ring address.
Definition: vmxnet3.h:355
A persistent I/O buffer.
Definition: iobuf.h:38