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