X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fvirtio%2Fvirtio.h;h=525e2dad4cf998dfda31f6bdbd8d94d0a26c31c0;hb=b37ed6def36798342172f298516c5fc6d0d8e070;hp=cdfee5d1828b0e3543c4ae25e14a9fcc3865cb61;hpb=b4f9a45affd26ddfdb373b79e4ebd78fe2da1383;p=dpdk.git diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h index cdfee5d182..525e2dad4c 100644 --- a/drivers/net/virtio/virtio.h +++ b/drivers/net/virtio/virtio.h @@ -88,6 +88,78 @@ #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ +/* + * Each virtqueue indirect descriptor list must be physically contiguous. + * To allow us to malloc(9) each list individually, limit the number + * supported to what will fit in one page. With 4KB pages, this is a limit + * of 256 descriptors. If there is ever a need for more, we can switch to + * contigmalloc(9) for the larger allocations, similar to what + * bus_dmamem_alloc(9) does. + * + * Note the sizeof(struct vring_desc) is 16 bytes. + */ +#define VIRTIO_MAX_INDIRECT ((int)(rte_mem_page_size() / 16)) + +/* + * Maximum number of virtqueues per device. + */ +#define VIRTIO_MAX_VIRTQUEUE_PAIRS 8 +#define VIRTIO_MAX_VIRTQUEUES (VIRTIO_MAX_VIRTQUEUE_PAIRS * 2 + 1) + +/* VirtIO device IDs. */ +#define VIRTIO_ID_NETWORK 0x01 +#define VIRTIO_ID_BLOCK 0x02 +#define VIRTIO_ID_CONSOLE 0x03 +#define VIRTIO_ID_ENTROPY 0x04 +#define VIRTIO_ID_BALLOON 0x05 +#define VIRTIO_ID_IOMEMORY 0x06 +#define VIRTIO_ID_9P 0x09 + +/* Status byte for guest to report progress. */ +#define VIRTIO_CONFIG_STATUS_RESET 0x00 +#define VIRTIO_CONFIG_STATUS_ACK 0x01 +#define VIRTIO_CONFIG_STATUS_DRIVER 0x02 +#define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04 +#define VIRTIO_CONFIG_STATUS_FEATURES_OK 0x08 +#define VIRTIO_CONFIG_STATUS_DEV_NEED_RESET 0x40 +#define VIRTIO_CONFIG_STATUS_FAILED 0x80 + +/* The bit of the ISR which indicates a device has an interrupt. */ +#define VIRTIO_ISR_INTR 0x1 +/* The bit of the ISR which indicates a device configuration change. */ +#define VIRTIO_ISR_CONFIG 0x2 +/* Vector value used to disable MSI for queue. */ +#define VIRTIO_MSI_NO_VECTOR 0xFFFF + +/* The alignment to use between consumer and producer parts of vring. */ +#define VIRTIO_VRING_ALIGN 4096 + +/* + * This structure is just a reference to read net device specific + * config space; it is just a shadow structure. + * + */ +struct virtio_net_config { + /* The config defining mac address (if VIRTIO_NET_F_MAC) */ + uint8_t mac[RTE_ETHER_ADDR_LEN]; + /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ + uint16_t status; + uint16_t max_virtqueue_pairs; + uint16_t mtu; + /* + * speed, in units of 1Mb. All values 0 to INT_MAX are legal. + * Any other value stands for unknown. + */ + uint32_t speed; + /* + * 0x00 - half duplex + * 0x01 - full duplex + * Any other value stands for unknown. + */ + uint8_t duplex; + +} __rte_packed; + struct virtio_hw { struct virtqueue **vqs; uint64_t guest_features; @@ -95,6 +167,7 @@ struct virtio_hw { uint8_t started; uint8_t weak_barriers; uint8_t vlan_strip; + bool rx_ol_scatter; uint8_t has_tx_offload; uint8_t has_rx_offload; uint8_t use_vec_rx; @@ -106,8 +179,9 @@ struct virtio_hw { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; uint32_t speed; /* link speed in MB */ uint8_t duplex; - uint8_t use_msix; + uint8_t intr_lsc; uint16_t max_mtu; + size_t max_rx_pkt_len; /* * App management thread and virtio interrupt handler thread * both can change device state, this lock is meant to avoid @@ -164,5 +238,11 @@ virtio_with_packed_queue(struct virtio_hw *hw) } uint64_t virtio_negotiate_features(struct virtio_hw *hw, uint64_t host_features); - +uint8_t virtio_get_status(struct virtio_hw *hw); +void virtio_set_status(struct virtio_hw *hw, uint8_t status); +void virtio_write_dev_config(struct virtio_hw *hw, size_t offset, const void *src, int length); +void virtio_read_dev_config(struct virtio_hw *hw, size_t offset, void *dst, int length); +void virtio_reset(struct virtio_hw *hw); +void virtio_reinit_complete(struct virtio_hw *hw); +uint8_t virtio_get_isr(struct virtio_hw *hw); #endif /* _VIRTIO_H_ */