1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2015 Intel Corporation
5 #ifndef _VIRTIO_ETHDEV_H_
6 #define _VIRTIO_ETHDEV_H_
10 #include <ethdev_driver.h>
15 #define PAGE_SIZE 4096
18 #define VIRTIO_MAX_RX_QUEUES 128U
19 #define VIRTIO_MAX_TX_QUEUES 128U
20 #define VIRTIO_MAX_MAC_ADDRS 64
21 #define VIRTIO_MIN_RX_BUFSIZE 64
22 #define VIRTIO_MAX_RX_PKTLEN 9728U
24 /* Features desired/implemented by this driver. */
25 #define VIRTIO_PMD_DEFAULT_GUEST_FEATURES \
26 (1u << VIRTIO_NET_F_MAC | \
27 1u << VIRTIO_NET_F_STATUS | \
28 1u << VIRTIO_NET_F_MQ | \
29 1u << VIRTIO_NET_F_CTRL_MAC_ADDR | \
30 1u << VIRTIO_NET_F_CTRL_VQ | \
31 1u << VIRTIO_NET_F_CTRL_RX | \
32 1u << VIRTIO_NET_F_CTRL_VLAN | \
33 1u << VIRTIO_NET_F_MRG_RXBUF | \
34 1u << VIRTIO_NET_F_MTU | \
35 1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE | \
36 1u << VIRTIO_RING_F_INDIRECT_DESC | \
37 1ULL << VIRTIO_F_VERSION_1 | \
38 1ULL << VIRTIO_F_IN_ORDER | \
39 1ULL << VIRTIO_F_RING_PACKED | \
40 1ULL << VIRTIO_F_IOMMU_PLATFORM | \
41 1ULL << VIRTIO_F_ORDER_PLATFORM | \
42 1ULL << VIRTIO_F_NOTIFICATION_DATA | \
43 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)
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 1u << VIRTIO_NET_F_CSUM | \
51 1u << VIRTIO_NET_F_HOST_TSO4 | \
52 1u << VIRTIO_NET_F_HOST_TSO6)
54 extern const struct eth_dev_ops virtio_user_secondary_eth_dev_ops;
57 * CQ function prototype
59 void virtio_dev_cq_start(struct rte_eth_dev *dev);
62 * RX/TX function prototypes
65 int virtio_dev_rx_queue_done(void *rxq, uint16_t offset);
67 int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
68 uint16_t nb_rx_desc, unsigned int socket_id,
69 const struct rte_eth_rxconf *rx_conf,
70 struct rte_mempool *mb_pool);
72 int virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev,
73 uint16_t rx_queue_id);
75 int virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
76 uint16_t nb_tx_desc, unsigned int socket_id,
77 const struct rte_eth_txconf *tx_conf);
79 int virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
80 uint16_t tx_queue_id);
82 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
84 uint16_t virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
87 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
90 uint16_t virtio_recv_mergeable_pkts_packed(void *rx_queue,
91 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
93 uint16_t virtio_recv_pkts_inorder(void *rx_queue,
94 struct rte_mbuf **rx_pkts, uint16_t nb_pkts);
96 uint16_t virtio_xmit_pkts_prepare(void *tx_queue, struct rte_mbuf **tx_pkts,
99 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
101 uint16_t virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
104 uint16_t virtio_xmit_pkts_inorder(void *tx_queue, struct rte_mbuf **tx_pkts,
107 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
110 uint16_t virtio_recv_pkts_packed_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
113 uint16_t virtio_xmit_pkts_packed_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
116 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
118 void virtio_interrupt_handler(void *param);
120 int virtio_dev_pause(struct rte_eth_dev *dev);
121 void virtio_dev_resume(struct rte_eth_dev *dev);
122 int virtio_dev_stop(struct rte_eth_dev *dev);
123 int virtio_dev_close(struct rte_eth_dev *dev);
124 int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts,
127 #endif /* _VIRTIO_ETHDEV_H_ */