1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2015 Intel Corporation 3 */ 4 5 #ifndef _VIRTIO_ETHDEV_H_ 6 #define _VIRTIO_ETHDEV_H_ 7 8 #include <stdint.h> 9 10 #include "virtio_pci.h" 11 12 #define SPEED_10 10 13 #define SPEED_100 100 14 #define SPEED_1000 1000 15 #define SPEED_10G 10000 16 17 #ifndef PAGE_SIZE 18 #define PAGE_SIZE 4096 19 #endif 20 21 #define VIRTIO_MAX_RX_QUEUES 128U 22 #define VIRTIO_MAX_TX_QUEUES 128U 23 #define VIRTIO_MAX_MAC_ADDRS 64 24 #define VIRTIO_MIN_RX_BUFSIZE 64 25 #define VIRTIO_MAX_RX_PKTLEN 9728U 26 27 /* Features desired/implemented by this driver. */ 28 #define VIRTIO_PMD_DEFAULT_GUEST_FEATURES \ 29 (1u << VIRTIO_NET_F_MAC | \ 30 1u << VIRTIO_NET_F_STATUS | \ 31 1u << VIRTIO_NET_F_MQ | \ 32 1u << VIRTIO_NET_F_CTRL_MAC_ADDR | \ 33 1u << VIRTIO_NET_F_CTRL_VQ | \ 34 1u << VIRTIO_NET_F_CTRL_RX | \ 35 1u << VIRTIO_NET_F_CTRL_VLAN | \ 36 1u << VIRTIO_NET_F_CSUM | \ 37 1u << VIRTIO_NET_F_HOST_TSO4 | \ 38 1u << VIRTIO_NET_F_HOST_TSO6 | \ 39 1u << VIRTIO_NET_F_MRG_RXBUF | \ 40 1u << VIRTIO_NET_F_MTU | \ 41 1u << VIRTIO_RING_F_INDIRECT_DESC | \ 42 1ULL << VIRTIO_F_VERSION_1 | \ 43 1ULL << VIRTIO_F_IOMMU_PLATFORM) 44 45 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ 46 (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \ 47 1u << VIRTIO_NET_F_GUEST_CSUM | \ 48 1u << VIRTIO_NET_F_GUEST_TSO4 | \ 49 1u << VIRTIO_NET_F_GUEST_TSO6) 50 /* 51 * CQ function prototype 52 */ 53 void virtio_dev_cq_start(struct rte_eth_dev *dev); 54 55 /* 56 * RX/TX function prototypes 57 */ 58 59 int virtio_dev_rx_queue_done(void *rxq, uint16_t offset); 60 61 int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id, 62 uint16_t nb_rx_desc, unsigned int socket_id, 63 const struct rte_eth_rxconf *rx_conf, 64 struct rte_mempool *mb_pool); 65 66 int virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, 67 uint16_t rx_queue_id); 68 69 int virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, 70 uint16_t nb_tx_desc, unsigned int socket_id, 71 const struct rte_eth_txconf *tx_conf); 72 73 int virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev, 74 uint16_t tx_queue_id); 75 76 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 77 uint16_t nb_pkts); 78 79 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 80 uint16_t nb_pkts); 81 82 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, 83 uint16_t nb_pkts); 84 85 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, 86 uint16_t nb_pkts); 87 88 uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, 89 uint16_t nb_pkts); 90 91 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); 92 93 void virtio_interrupt_handler(void *param); 94 95 #endif /* _VIRTIO_ETHDEV_H_ */ 96