xref: /dpdk/drivers/net/virtio/virtio_ethdev.h (revision 250c9eb3ca895127f21a729caf4a928eb2f04d2c)
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_MRG_RXBUF	  |	\
32 	 1u << VIRTIO_NET_F_MTU	| \
33 	 1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE |	\
34 	 1u << VIRTIO_RING_F_INDIRECT_DESC |    \
35 	 1ULL << VIRTIO_F_VERSION_1       |	\
36 	 1ULL << VIRTIO_F_IN_ORDER        |	\
37 	 1ULL << VIRTIO_F_IOMMU_PLATFORM)
38 
39 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
40 	(VIRTIO_PMD_DEFAULT_GUEST_FEATURES |	\
41 	 1u << VIRTIO_NET_F_GUEST_CSUM	   |	\
42 	 1u << VIRTIO_NET_F_GUEST_TSO4     |	\
43 	 1u << VIRTIO_NET_F_GUEST_TSO6)
44 
45 #define VIRTIO_PMD_PER_DEVICE_RX_OFFLOADS	\
46 	(DEV_RX_OFFLOAD_TCP_CKSUM |		\
47 	 DEV_RX_OFFLOAD_UDP_CKSUM |		\
48 	 DEV_RX_OFFLOAD_TCP_LRO |		\
49 	 DEV_RX_OFFLOAD_VLAN_FILTER |		\
50 	 DEV_RX_OFFLOAD_VLAN_STRIP)
51 
52 /*
53  * CQ function prototype
54  */
55 void virtio_dev_cq_start(struct rte_eth_dev *dev);
56 
57 /*
58  * RX/TX function prototypes
59  */
60 
61 int virtio_dev_rx_queue_done(void *rxq, uint16_t offset);
62 
63 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
64 		uint16_t nb_rx_desc, unsigned int socket_id,
65 		const struct rte_eth_rxconf *rx_conf,
66 		struct rte_mempool *mb_pool);
67 
68 int virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev,
69 				uint16_t rx_queue_id);
70 
71 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
72 		uint16_t nb_tx_desc, unsigned int socket_id,
73 		const struct rte_eth_txconf *tx_conf);
74 
75 int virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
76 				uint16_t tx_queue_id);
77 
78 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
79 		uint16_t nb_pkts);
80 
81 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
82 		uint16_t nb_pkts);
83 
84 uint16_t virtio_recv_mergeable_pkts_inorder(void *rx_queue,
85 		struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
86 
87 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
88 		uint16_t nb_pkts);
89 
90 uint16_t virtio_xmit_pkts_inorder(void *tx_queue, struct rte_mbuf **tx_pkts,
91 		uint16_t nb_pkts);
92 
93 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
94 		uint16_t nb_pkts);
95 
96 uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
97 		uint16_t nb_pkts);
98 
99 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
100 
101 void virtio_interrupt_handler(void *param);
102 
103 int virtio_dev_pause(struct rte_eth_dev *dev);
104 void virtio_dev_resume(struct rte_eth_dev *dev);
105 int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts,
106 		int nb_pkts);
107 
108 #endif /* _VIRTIO_ETHDEV_H_ */
109