From a7a2281732b926df139b0fd946a084299d813654 Mon Sep 17 00:00:00 2001 From: Mohsin Kazmi Date: Mon, 31 Aug 2020 17:17:16 +0200 Subject: virtio: remove kernel virtio header dependencies Type: refactor tap, virtio and vhost use virtio/vhost header files from linux kernel. Different features are supported on different kernel versions, making it difficult to use those in VPP. This patch removes virtio/vhost based header dependencies to local header files. Change-Id: I064a8adb5cd9753c986b6f224bb075200b3856af Signed-off-by: Mohsin Kazmi --- src/vnet/devices/virtio/pci.h | 99 +++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 66 deletions(-) (limited to 'src/vnet/devices/virtio/pci.h') diff --git a/src/vnet/devices/virtio/pci.h b/src/vnet/devices/virtio/pci.h index 47c74ab2ec6..ab5c6f15ec2 100644 --- a/src/vnet/devices/virtio/pci.h +++ b/src/vnet/devices/virtio/pci.h @@ -19,20 +19,20 @@ /* VirtIO ABI version, this must match exactly. */ #define VIRTIO_PCI_ABI_VERSION 0 +/* VirtIO device IDs. */ +#define VIRTIO_ID_NETWORK 0x01 + /* * Vector value used to disable MSI for queue. * define in include/linux/virtio_pci.h - * #define VIRTIO_MSI_NO_VECTOR 0xFFFF */ +#define VIRTIO_MSI_NO_VECTOR 0xFFFF /* The bit of the ISR which indicates a device has an interrupt. */ #define VIRTIO_PCI_ISR_INTR 0x1 /* The bit of the ISR which indicates a device configuration change. */ #define VIRTIO_PCI_ISR_CONFIG 0x2 -/* VirtIO device IDs. */ -#define VIRTIO_ID_NETWORK 0x01 - /* Status byte for guest to report progress. */ #define foreach_virtio_config_status_flags \ _ (VIRTIO_CONFIG_STATUS_RESET, 0x00) \ @@ -50,46 +50,19 @@ typedef enum #undef _ } virtio_config_status_flags_t; -#define foreach_virtio_net_feature_flags \ - _ (VIRTIO_NET_F_CSUM, 0) /* Host handles pkts w/ partial csum */ \ - _ (VIRTIO_NET_F_GUEST_CSUM, 1) /* Guest handles pkts w/ partial csum */ \ - _ (VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, 2) /* Dynamic offload configuration. */ \ - _ (VIRTIO_NET_F_MTU, 3) /* Initial MTU advice. */ \ - _ (VIRTIO_NET_F_MAC, 5) /* Host has given MAC address. */ \ - _ (VIRTIO_NET_F_GSO, 6) /* Host handles pkts w/ any GSO. */ \ - _ (VIRTIO_NET_F_GUEST_TSO4, 7) /* Guest can handle TSOv4 in. */ \ - _ (VIRTIO_NET_F_GUEST_TSO6, 8) /* Guest can handle TSOv6 in. */ \ - _ (VIRTIO_NET_F_GUEST_ECN, 9) /* Guest can handle TSO[6] w/ ECN in. */ \ - _ (VIRTIO_NET_F_GUEST_UFO, 10) /* Guest can handle UFO in. */ \ - _ (VIRTIO_NET_F_HOST_TSO4, 11) /* Host can handle TSOv4 in. */ \ - _ (VIRTIO_NET_F_HOST_TSO6, 12) /* Host can handle TSOv6 in. */ \ - _ (VIRTIO_NET_F_HOST_ECN, 13) /* Host can handle TSO[6] w/ ECN in. */ \ - _ (VIRTIO_NET_F_HOST_UFO, 14) /* Host can handle UFO in. */ \ - _ (VIRTIO_NET_F_MRG_RXBUF, 15) /* Host can merge receive buffers. */ \ - _ (VIRTIO_NET_F_STATUS, 16) /* virtio_net_config.status available */ \ - _ (VIRTIO_NET_F_CTRL_VQ, 17) /* Control channel available */ \ - _ (VIRTIO_NET_F_CTRL_RX, 18) /* Control channel RX mode support */ \ - _ (VIRTIO_NET_F_CTRL_VLAN, 19) /* Control channel VLAN filtering */ \ - _ (VIRTIO_NET_F_CTRL_RX_EXTRA, 20) /* Extra RX mode control support */ \ - _ (VIRTIO_NET_F_GUEST_ANNOUNCE, 21) /* Guest can announce device on the network */ \ - _ (VIRTIO_NET_F_MQ, 22) /* Device supports Receive Flow Steering */ \ - _ (VIRTIO_NET_F_CTRL_MAC_ADDR, 23) /* Set MAC address */ \ - _ (VIRTIO_F_NOTIFY_ON_EMPTY, 24) \ - _ (VHOST_F_LOG_ALL, 26) /* Log all write descriptors */ \ - _ (VIRTIO_F_ANY_LAYOUT, 27) /* Can the device handle any descripor layout */ \ - _ (VIRTIO_RING_F_INDIRECT_DESC, 28) /* Support indirect buffer descriptors */ \ - _ (VIRTIO_RING_F_EVENT_IDX, 29) /* The Guest publishes the used index for which it expects an interrupt \ - * at the end of the avail ring. Host should ignore the avail->flags field. */ \ -/* The Host publishes the avail index for which it expects a kick \ - * at the end of the used ring. Guest should ignore the used->flags field. */ \ - _ (VHOST_USER_F_PROTOCOL_FEATURES, 30) \ - _ (VIRTIO_F_VERSION_1, 32) \ - -#define VIRTIO_NET_F_CTRL_GUEST_OFFLOADS 2 -#define VIRTIO_NET_F_MTU 3 + #define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ #define VIRTIO_NET_S_ANNOUNCE 2 /* Announcement is needed */ +#define VIRTIO_NET_OK 0 +#define VIRTIO_NET_ERR 1 + +/* If multiqueue is provided by host, then we support it. */ +#define VIRTIO_NET_CTRL_MQ 4 +#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET 0 +#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN 1 +#define VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX 0x8000 + /* * Control network offloads * Reconfigures the network offloads that Guest can handle. @@ -138,7 +111,7 @@ typedef struct typedef struct { - struct virtio_pci_cap cap; + virtio_pci_cap_t cap; u32 notify_off_multiplier; /* Multiplier for queue_notify_off. */ } virtio_pci_notify_cap_t; @@ -174,35 +147,29 @@ typedef struct u16 mtu; } virtio_net_config_t; -typedef struct -{ - u64 addr; - u32 len; - u16 flags; - u16 next; -} vring_desc_t; - -typedef struct +/* + * Control virtqueue data structures + * + * The control virtqueue expects a header in the first sg entry + * and an ack/status response in the last entry. Data for the + * command goes in between. + */ +/* *INDENT-OFF* */ +typedef CLIB_PACKED (struct { - u16 flags; - u16 idx; - u16 ring[0]; - /* u16 used_event; */ -} vring_avail_t; + u8 class; + u8 cmd; +}) virtio_net_ctrl_hdr_t; +/* *INDENT-ON* */ -typedef struct -{ - u32 id; - u32 len; -} vring_used_elem_t; +typedef u8 virtio_net_ctrl_ack_t; typedef struct { - u16 flags; - u16 idx; - vring_used_elem_t ring[0]; - /* u16 avail_event; */ -} vring_used_t; + virtio_net_ctrl_hdr_t ctrl; + virtio_net_ctrl_ack_t status; + u8 data[1024]; +} virtio_ctrl_msg_t; typedef struct _virtio_pci_func { -- cgit 1.2.3-korg