4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _VIRTIO_ETHDEV_H_
35 #define _VIRTIO_ETHDEV_H_
39 #include "virtio_pci.h"
43 #define SPEED_1000 1000
44 #define SPEED_10G 10000
47 #define PAGE_SIZE 4096
50 #define VIRTIO_MAX_RX_QUEUES 128U
51 #define VIRTIO_MAX_TX_QUEUES 128U
52 #define VIRTIO_MAX_MAC_ADDRS 64
53 #define VIRTIO_MIN_RX_BUFSIZE 64
54 #define VIRTIO_MAX_RX_PKTLEN 9728
56 /* Features desired/implemented by this driver. */
57 #define VIRTIO_PMD_DEFAULT_GUEST_FEATURES \
58 (1u << VIRTIO_NET_F_MAC | \
59 1u << VIRTIO_NET_F_STATUS | \
60 1u << VIRTIO_NET_F_MQ | \
61 1u << VIRTIO_NET_F_CTRL_MAC_ADDR | \
62 1u << VIRTIO_NET_F_CTRL_VQ | \
63 1u << VIRTIO_NET_F_CTRL_RX | \
64 1u << VIRTIO_NET_F_CTRL_VLAN | \
65 1u << VIRTIO_NET_F_MRG_RXBUF | \
66 1u << VIRTIO_RING_F_INDIRECT_DESC | \
67 1ULL << VIRTIO_F_VERSION_1 | \
68 1ULL << VIRTIO_F_IOMMU_PLATFORM)
71 * CQ function prototype
73 void virtio_dev_cq_start(struct rte_eth_dev *dev);
76 * RX/TX function prototypes
78 void virtio_dev_rxtx_start(struct rte_eth_dev *dev);
80 int virtio_dev_queue_setup(struct rte_eth_dev *dev,
83 uint16_t vtpci_queue_idx,
85 unsigned int socket_id,
88 void virtio_dev_queue_release(struct virtqueue *vq);
90 int virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
91 uint16_t nb_rx_desc, unsigned int socket_id,
92 const struct rte_eth_rxconf *rx_conf,
93 struct rte_mempool *mb_pool);
95 void virtio_dev_rx_queue_release(void *rxq);
97 int virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
98 uint16_t nb_tx_desc, unsigned int socket_id,
99 const struct rte_eth_txconf *tx_conf);
101 void virtio_dev_tx_queue_release(void *txq);
103 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
106 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
109 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
112 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
115 uint16_t virtio_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,
118 int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
121 * The VIRTIO_NET_F_GUEST_TSO[46] features permit the host to send us
122 * frames larger than 1514 bytes. We do not yet support software LRO
125 #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \
126 VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN)
129 #endif /* _VIRTIO_ETHDEV_H_ */