|
iPXE
|
Google Virtual Ethernet network driver. More...
#include <stdint.h>#include <ipxe/dma.h>#include <ipxe/pci.h>#include <ipxe/pcimsix.h>#include <ipxe/in.h>#include <ipxe/process.h>#include <ipxe/retry.h>Go to the source code of this file.
Data Structures | |
| struct | google_mac |
| A Google Cloud MAC address. More... | |
| struct | gve_admin_header |
| Admin queue entry header. More... | |
| struct | gve_admin_simple |
| Simple admin command. More... | |
| struct | gve_admin_describe |
| Describe device command. More... | |
| struct | gve_device_descriptor |
| Device descriptor. More... | |
| struct | gve_option |
| Device option header. More... | |
| struct | gve_admin_configure |
| Configure device resources command. More... | |
| struct | gve_admin_register |
| Register page list command. More... | |
| struct | gve_pages |
| Page list. More... | |
| struct | gve_admin_create_tx |
| Create transmit queue command. More... | |
| struct | gve_admin_create_rx |
| Create receive queue command. More... | |
| union | gve_admin_command |
| An admin queue command. More... | |
| struct | gve_admin |
| Admin queue. More... | |
| struct | gve_scratch |
| Scratch buffer for admin queue commands. More... | |
| struct | gve_event |
| An event counter. More... | |
| struct | gve_events |
| Event counter array. More... | |
| struct | gve_irq |
| An interrupt channel. More... | |
| struct | gve_irqs |
| Interrupt channel array. More... | |
| struct | gve_resources |
| Queue resources. More... | |
| struct | gve_qpl |
| Queue page list. More... | |
| struct | gve_buffer |
| A transmit or receive buffer descriptor. More... | |
| struct | gve_gqi_tx_descriptor |
| An in-order transmit descriptor. More... | |
| struct | gve_dqo_tx_tag |
| An out-of-order transmit tag. More... | |
| struct | gve_dqo_tx_descriptor |
| An out-of-order transmit descriptor. More... | |
| struct | gve_dqo_tx_completion |
| An out-of-order transmit completion. More... | |
| struct | gve_gqi_rx_descriptor |
| An in-order receive descriptor. More... | |
| struct | gve_gqi_rx_completion |
| An in-order receive completion descriptor. More... | |
| struct | gve_dqo_rx_descriptor |
| An out-of-order receive descriptor. More... | |
| struct | gve_dqo_rx_completion |
| An out-of-order receive completion. More... | |
| struct | gve_queue_stride |
| Queue strides. More... | |
| struct | gve_queue |
| A descriptor queue. More... | |
| struct | gve_queue_type |
| A descriptor queue type. More... | |
| struct | gve_nic |
| A Google Virtual Ethernet NIC. More... | |
Macros | |
| #define | GVE_PAGE_SIZE 0x1000 |
| Page size. | |
| #define | GVE_ALIGN GVE_PAGE_SIZE |
| Address alignment. | |
| #define | GVE_CFG_BAR PCI_BASE_ADDRESS_0 |
| Configuration BAR. | |
| #define | GVE_CFG_SIZE 0x1000 |
| Configuration BAR size. | |
| #define | GVE_CFG_DEVSTAT 0x0000 |
| Device status. | |
| #define | GVE_CFG_DEVSTAT_RESET 0x00000010UL |
| Device is reset. | |
| #define | GVE_CFG_DRVSTAT 0x0004 |
| Driver status. | |
| #define | GVE_CFG_DRVSTAT_RUN 0x00000001UL |
| Run admin queue. | |
| #define | GVE_RESET_MAX_WAIT_MS 500 |
| Maximum time to wait for reset. | |
| #define | GVE_CFG_ADMIN_PFN 0x0010 |
| Admin queue page frame number (for older devices) | |
| #define | GVE_CFG_ADMIN_DB 0x0014 |
| Admin queue doorbell. | |
| #define | GVE_CFG_ADMIN_EVT 0x0018 |
| Admin queue event counter. | |
| #define | GVE_CFG_VERSION 0x001f |
| Driver version (8-bit register) | |
| #define | GVE_CFG_ADMIN_BASE_HI 0x0020 |
| Admin queue base address high 32 bits. | |
| #define | GVE_CFG_ADMIN_BASE_LO 0x0024 |
| Admin queue base address low 32 bits. | |
| #define | GVE_CFG_ADMIN_LEN 0x0028 |
| Admin queue base address length (16-bit register) | |
| #define | GVE_DB_BAR PCI_BASE_ADDRESS_2 |
| Doorbell BAR. | |
| #define | GVE_ADMIN_STATUS_OK 0x00000001 |
| Command succeeded. | |
| #define | GVE_ADMIN_DESCRIBE 0x0001 |
| Describe device command. | |
| #define | GVE_ADMIN_DESCRIBE_VER 1 |
| Device descriptor version. | |
| #define | GVE_OPT_GQI_RDA 0x02 |
| In-order descriptor queues with raw DMA addressing. | |
| #define | GVE_OPT_GQI_QPL 0x03 |
| In-order descriptor queues with queue page list addressing. | |
| #define | GVE_OPT_DQO_RDA 0x04 |
| Out-of-order descriptor queues with raw DMA addressing. | |
| #define | GVE_OPT_DQO_QPL 0x07 |
| Out-of-order descriptor queues with queue page list addressing. | |
| #define | GVE_ADMIN_CONFIGURE 0x0002 |
| Configure device resources command. | |
| #define | GVE_FORMAT(mode) |
| Descriptor queue format. | |
| #define | GVE_ADMIN_REGISTER 0x0003 |
| Register page list command. | |
| #define | GVE_QPL_MAX 32 |
| Maximum number of pages per queue. | |
| #define | GVE_ADMIN_UNREGISTER 0x0004 |
| Unregister page list command. | |
| #define | GVE_ADMIN_CREATE_TX 0x0005 |
| Create transmit queue command. | |
| #define | GVE_ADMIN_CREATE_RX 0x0006 |
| Create receive queue command. | |
| #define | GVE_ADMIN_DESTROY_TX 0x0007 |
| Destroy transmit queue command. | |
| #define | GVE_ADMIN_DESTROY_RX 0x0008 |
| Destroy receive queue command. | |
| #define | GVE_ADMIN_DECONFIGURE 0x0009 |
| Deconfigure device resources command. | |
| #define | GVE_ADMIN_COUNT ( GVE_PAGE_SIZE / sizeof ( union gve_admin_command ) ) |
| Number of admin queue commands. | |
| #define | GVE_IRQ_COUNT 2 |
| Number of interrupt channels. | |
| #define | GVE_GQI_IRQ_DISABLE 0x40000000UL |
| Disable in-order queue interrupt. | |
| #define | GVE_DQO_IRQ_REARM 0x00000019UL |
| Rearm out-of-order queue interrupt. | |
| #define | GVE_BUF_SIZE ( GVE_PAGE_SIZE / 2 ) |
| Queue data buffer size. | |
| #define | GVE_BUF_PER_PAGE ( GVE_PAGE_SIZE / GVE_BUF_SIZE ) |
| Number of data buffers per page. | |
| #define | GVE_RAW_QPL 0xffffffff |
| Raw DMA addressing queue page list ID. | |
| #define | GVE_TX_FILL 8 |
| Maximum number of transmit buffers. | |
| #define | GVE_TX_QPL 0x18ae5458 |
| Transmit queue page list ID. | |
| #define | GVE_TX_IRQ 0 |
| Tranmsit queue interrupt channel. | |
| #define | GVE_GQI_TX_TYPE_START 0x00 |
| Start of packet transmit descriptor type. | |
| #define | GVE_GQI_TX_TYPE_CONT 0x20 |
| Continuation of packet transmit descriptor type. | |
| #define | GVE_DQO_TX_TYPE_PACKET 0x0c |
| Normal packet transmit descriptor type. | |
| #define | GVE_DQO_TX_TYPE_LAST 0x20 |
| Last transmit descriptor in a packet. | |
| #define | GVE_DQO_TXF_PKT 0x10 |
| Transmit completion packet flag. | |
| #define | GVE_DQO_TXF_GEN 0x80 |
| Transmit completion generation flag. | |
| #define | GVE_RX_FILL 64 |
| Maximum number of receive buffers. | |
| #define | GVE_RX_QPL 0x18ae5258 |
| Receive queue page list ID. | |
| #define | GVE_RX_IRQ 1 |
| Receive queue interrupt channel. | |
| #define | GVE_GQI_RXF_ERROR 0x08 |
| Receive error. | |
| #define | GVE_GQI_RXF_MORE 0x20 |
| Receive packet continues into next descriptor. | |
| #define | GVE_GQI_RX_SEQ_MASK 0x07 |
| Receive sequence number mask. | |
| #define | GVE_GQI_RX_PAD 2 |
| Padding at the start of all received packets. | |
| #define | GVE_DQO_RXS_ERROR 0x04 |
| Receive error. | |
| #define | GVE_DQO_RXL_GEN 0x4000 |
| Receive completion generation flag. | |
| #define | GVE_DQO_RXF_LAST 0x02 |
| Last receive descriptor in a packet. | |
| #define | GVE_MODE_QPL 0x01 |
| Operating mode. | |
| #define | GVE_MODE_DQO 0x02 |
| Use out-of-order queues. | |
| #define | GVE_ADMIN_MAX_WAIT_MS 500 |
| Maximum time to wait for admin queue commands. | |
| #define | GVE_RESET_MAX_RETRY 5 |
| Maximum number of times to reattempt device reset. | |
| #define | GVE_WATCHDOG_TIMEOUT ( 1 * TICKS_PER_SEC ) |
| Time between reset recovery checks. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
Google Virtual Ethernet network driver.
The Google Virtual Ethernet NIC (GVE or gVNIC) is found only in Google Cloud instances. There is essentially zero documentation available beyond the mostly uncommented source code in the Linux kernel.
Definition in file gve.h.
| #define GVE_PAGE_SIZE 0x1000 |
Page size.
Definition at line 42 of file gve.h.
Referenced by gve_admin_enable(), gve_alloc_qpl(), gve_free_qpl(), and gve_register().
| #define GVE_ALIGN GVE_PAGE_SIZE |
Address alignment.
All DMA data structure base addresses seem to need to be aligned to a page boundary. (This is not documented anywhere, but is inferred from existing source code and experimentation.)
Definition at line 51 of file gve.h.
Referenced by gve_admin_alloc(), gve_alloc_qpl(), gve_alloc_queue(), and gve_alloc_shared().
| #define GVE_CFG_BAR PCI_BASE_ADDRESS_0 |
| #define GVE_CFG_SIZE 0x1000 |
Configuration BAR size.
All registers within the configuration BAR are big-endian.
Definition at line 61 of file gve.h.
Referenced by gve_probe().
| #define GVE_CFG_DEVSTAT 0x0000 |
Device status.
Definition at line 64 of file gve.h.
Referenced by gve_admin_wait(), and gve_reset().
| #define GVE_CFG_DRVSTAT 0x0004 |
| #define GVE_CFG_DRVSTAT_RUN 0x00000001UL |
| #define GVE_RESET_MAX_WAIT_MS 500 |
| #define GVE_CFG_ADMIN_PFN 0x0010 |
Admin queue page frame number (for older devices)
Definition at line 75 of file gve.h.
Referenced by gve_admin_enable(), gve_admin_wait(), gve_reset(), and gve_watchdog().
| #define GVE_CFG_ADMIN_DB 0x0014 |
| #define GVE_CFG_ADMIN_EVT 0x0018 |
| #define GVE_CFG_ADMIN_BASE_HI 0x0020 |
Admin queue base address high 32 bits.
Definition at line 87 of file gve.h.
Referenced by gve_admin_enable().
| #define GVE_CFG_ADMIN_BASE_LO 0x0024 |
Admin queue base address low 32 bits.
Definition at line 90 of file gve.h.
Referenced by gve_admin_enable().
| #define GVE_CFG_ADMIN_LEN 0x0028 |
Admin queue base address length (16-bit register)
Definition at line 93 of file gve.h.
Referenced by gve_admin_enable().
| #define GVE_DB_BAR PCI_BASE_ADDRESS_2 |
| #define GVE_ADMIN_STATUS_OK 0x00000001 |
| #define GVE_ADMIN_DESCRIBE 0x0001 |
| #define GVE_ADMIN_DESCRIBE_VER 1 |
| #define GVE_OPT_GQI_RDA 0x02 |
In-order descriptor queues with raw DMA addressing.
Definition at line 190 of file gve.h.
Referenced by gve_describe().
| #define GVE_OPT_GQI_QPL 0x03 |
In-order descriptor queues with queue page list addressing.
Definition at line 193 of file gve.h.
Referenced by gve_describe().
| #define GVE_OPT_DQO_RDA 0x04 |
Out-of-order descriptor queues with raw DMA addressing.
Definition at line 196 of file gve.h.
Referenced by gve_describe().
| #define GVE_OPT_DQO_QPL 0x07 |
Out-of-order descriptor queues with queue page list addressing.
Definition at line 199 of file gve.h.
Referenced by gve_describe().
| #define GVE_ADMIN_CONFIGURE 0x0002 |
Configure device resources command.
Definition at line 202 of file gve.h.
Referenced by gve_configure().
| #define GVE_FORMAT | ( | mode | ) |
| #define GVE_ADMIN_REGISTER 0x0003 |
| #define GVE_QPL_MAX 32 |
Maximum number of pages per queue.
This is a policy decision. Must be sufficient to allow for both the transmit and receive queue fill levels.
Definition at line 252 of file gve.h.
Referenced by gve_alloc_qpl().
| #define GVE_ADMIN_UNREGISTER 0x0004 |
| #define GVE_ADMIN_CREATE_TX 0x0005 |
| #define GVE_ADMIN_CREATE_RX 0x0006 |
| #define GVE_ADMIN_DESTROY_TX 0x0007 |
| #define GVE_ADMIN_DESTROY_RX 0x0008 |
| #define GVE_ADMIN_DECONFIGURE 0x0009 |
Deconfigure device resources command.
Definition at line 332 of file gve.h.
Referenced by gve_deconfigure().
| #define GVE_ADMIN_COUNT ( GVE_PAGE_SIZE / sizeof ( union gve_admin_command ) ) |
Number of admin queue commands.
This is theoretically a policy decision. However, older revisions of the hardware seem to have only the "admin queue page frame number" register and no "admin queue length" register, with the implication that the admin queue must be exactly one page in length.
Choose to use a one page (4kB) admin queue for both older and newer versions of the hardware, to minimise variability.
Definition at line 366 of file gve.h.
Referenced by gve_admin(), gve_admin_alloc(), gve_admin_command(), gve_admin_enable(), and gve_admin_free().
| #define GVE_IRQ_COUNT 2 |
Number of interrupt channels.
We tell the device how many interrupt channels we have provided via the "configure device resources" admin queue command. The device will accept being given zero interrupt channels, but will subsequently fail to create more than a single queue (either transmit or receive).
There is, of course, no documentation indicating how may interrupt channels actually need to be provided. In the absence of evidence to the contrary, assume that two channels (one for transmit, one for receive) will be sufficient.
Definition at line 435 of file gve.h.
Referenced by gve_alloc_shared(), gve_configure(), and gve_free_shared().
| #define GVE_GQI_IRQ_DISABLE 0x40000000UL |
Disable in-order queue interrupt.
Definition at line 448 of file gve.h.
Referenced by gve_configure().
| #define GVE_DQO_IRQ_REARM 0x00000019UL |
Rearm out-of-order queue interrupt.
Definition at line 451 of file gve.h.
Referenced by gve_create_queue(), and gve_poll().
| #define GVE_BUF_SIZE ( GVE_PAGE_SIZE / 2 ) |
Queue data buffer size.
In theory, we may specify the size of receive buffers. However, the original version of the device seems not to have a parameter for this, and assumes the use of half-page (2kB) buffers. Choose to use this as the buffer size, on the assumption that older devices will not support any other buffer size.
Definition at line 483 of file gve.h.
Referenced by gve_alloc_qpl(), gve_create_rx_param(), gve_offset(), gve_poll_rx(), and gve_transmit().
| #define GVE_BUF_PER_PAGE ( GVE_PAGE_SIZE / GVE_BUF_SIZE ) |
Number of data buffers per page.
Definition at line 486 of file gve.h.
Referenced by gve_alloc_qpl().
| #define GVE_RAW_QPL 0xffffffff |
Raw DMA addressing queue page list ID.
Definition at line 542 of file gve.h.
Referenced by gve_create_queue().
| #define GVE_TX_FILL 8 |
Maximum number of transmit buffers.
This is a policy decision.
Definition at line 549 of file gve.h.
Referenced by gve_poll_tx(), and gve_transmit().
| #define GVE_TX_IRQ 0 |
| #define GVE_GQI_TX_TYPE_START 0x00 |
Start of packet transmit descriptor type.
Definition at line 580 of file gve.h.
Referenced by gve_transmit().
| #define GVE_GQI_TX_TYPE_CONT 0x20 |
Continuation of packet transmit descriptor type.
Definition at line 583 of file gve.h.
Referenced by gve_transmit().
| #define GVE_DQO_TX_TYPE_PACKET 0x0c |
Normal packet transmit descriptor type.
Definition at line 618 of file gve.h.
Referenced by gve_transmit().
| #define GVE_DQO_TX_TYPE_LAST 0x20 |
Last transmit descriptor in a packet.
Definition at line 621 of file gve.h.
Referenced by gve_transmit().
| #define GVE_DQO_TXF_PKT 0x10 |
| #define GVE_DQO_TXF_GEN 0x80 |
Transmit completion generation flag.
Definition at line 639 of file gve.h.
Referenced by gve_poll_tx().
| #define GVE_RX_FILL 64 |
Maximum number of receive buffers.
This is a policy decision. Experiments suggest that using fewer than 64 receive buffers leads to excessive packet drop rates on some instance types.
Definition at line 648 of file gve.h.
Referenced by gve_poll_rx(), and gve_refill_rx().
| #define GVE_RX_IRQ 1 |
| #define GVE_GQI_RXF_ERROR 0x08 |
| #define GVE_GQI_RXF_MORE 0x20 |
Receive packet continues into next descriptor.
Definition at line 666 of file gve.h.
Referenced by gve_poll_rx().
| #define GVE_GQI_RX_SEQ_MASK 0x07 |
Receive sequence number mask.
Definition at line 669 of file gve.h.
Referenced by gve_next(), and gve_poll_rx().
| #define GVE_GQI_RX_PAD 2 |
Padding at the start of all received packets.
Definition at line 684 of file gve.h.
Referenced by gve_poll_rx().
| #define GVE_DQO_RXS_ERROR 0x04 |
| #define GVE_DQO_RXL_GEN 0x4000 |
Receive completion generation flag.
Definition at line 724 of file gve.h.
Referenced by gve_poll_rx().
| #define GVE_DQO_RXF_LAST 0x02 |
Last receive descriptor in a packet.
Definition at line 727 of file gve.h.
Referenced by gve_poll_rx().
| #define GVE_MODE_QPL 0x01 |
Operating mode.
These values are chosen to allow for easy transformation to a queue format identifier as used for the "Configure device resources" command. Use registered queue pages
Definition at line 903 of file gve.h.
Referenced by gve_alloc_qpl(), gve_create_queue(), gve_describe(), gve_mode_name(), gve_register(), and gve_unregister().
| #define GVE_MODE_DQO 0x02 |
Use out-of-order queues.
Definition at line 904 of file gve.h.
Referenced by gve_alloc_queue(), gve_configure(), gve_create_queue(), gve_describe(), gve_mode_name(), gve_poll(), gve_poll_rx(), gve_poll_tx(), gve_refill_rx(), and gve_transmit().
| #define GVE_ADMIN_MAX_WAIT_MS 500 |
Maximum time to wait for admin queue commands.
Definition at line 907 of file gve.h.
Referenced by gve_admin_wait().
| #define GVE_RESET_MAX_RETRY 5 |
Maximum number of times to reattempt device reset.
Definition at line 910 of file gve.h.
Referenced by gve_setup(), and gve_startup().
| #define GVE_WATCHDOG_TIMEOUT ( 1 * TICKS_PER_SEC ) |
Time between reset recovery checks.
Definition at line 913 of file gve.h.
Referenced by gve_open(), and gve_watchdog().
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |