remove trailing whitespaces
[dpdk.git] / lib / librte_pmd_virtio / virtio_ethdev.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
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
16  *       distribution.
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.
20  *
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.
32  */
33
34 #ifndef _VIRTIO_ETHDEV_H_
35 #define _VIRTIO_ETHDEV_H_
36
37 #include <stdint.h>
38
39 #include "virtio_pci.h"
40
41 #define SPEED_10        10
42 #define SPEED_100       100
43 #define SPEED_1000      1000
44 #define SPEED_10G       10000
45 #define HALF_DUPLEX     1
46 #define FULL_DUPLEX     2
47
48 #ifndef PAGE_SIZE
49 #define PAGE_SIZE 4096
50 #endif
51
52 #define VIRTIO_MAX_RX_QUEUES 128
53 #define VIRTIO_MAX_TX_QUEUES 128
54 #define VIRTIO_MAX_MAC_ADDRS 1
55 #define VIRTIO_MIN_RX_BUFSIZE 64
56 #define VIRTIO_MAX_RX_PKTLEN  1518
57
58 /* Features desired/implemented by this driver. */
59 #define VTNET_FEATURES \
60         (VIRTIO_NET_F_MAC       | \
61         VIRTIO_NET_F_STATUS     | \
62         VIRTIO_NET_F_MQ         | \
63         VIRTIO_NET_F_CTRL_VQ    | \
64         VIRTIO_NET_F_CTRL_RX    | \
65         VIRTIO_NET_F_CTRL_VLAN  | \
66         VIRTIO_NET_F_CSUM       | \
67         VIRTIO_NET_F_HOST_TSO4  | \
68         VIRTIO_NET_F_HOST_TSO6  | \
69         VIRTIO_NET_F_HOST_ECN   | \
70         VIRTIO_NET_F_GUEST_CSUM | \
71         VIRTIO_NET_F_GUEST_TSO4 | \
72         VIRTIO_NET_F_GUEST_TSO6 | \
73         VIRTIO_NET_F_GUEST_ECN  | \
74         VIRTIO_NET_F_MRG_RXBUF  | \
75         VIRTIO_RING_F_INDIRECT_DESC)
76
77 /*
78  * CQ function prototype
79  */
80 void virtio_dev_cq_start(struct rte_eth_dev *dev);
81
82 /*
83  * RX/TX function prototypes
84  */
85 void virtio_dev_rxtx_start(struct rte_eth_dev *dev);
86
87 int virtio_dev_queue_setup(struct rte_eth_dev *dev,
88                         int queue_type,
89                         uint16_t queue_idx,
90                         uint8_t  vtpci_queue_idx,
91                         uint16_t nb_desc,
92                         unsigned int socket_id,
93                         struct virtqueue **pvq);
94
95 int  virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
96                 uint16_t nb_rx_desc, unsigned int socket_id,
97                 const struct rte_eth_rxconf *rx_conf,
98                 struct rte_mempool *mb_pool);
99
100 int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
101                 uint16_t nb_tx_desc, unsigned int socket_id,
102                 const struct rte_eth_txconf *tx_conf);
103
104 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
105                 uint16_t nb_pkts);
106
107 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
108                 uint16_t nb_pkts);
109
110 /*
111  * Structure to store private data for each driver instance (for each port).
112  */
113 struct virtio_adapter {
114         struct virtio_hw hw;
115 };
116
117 #define VIRTIO_DEV_PRIVATE_TO_HW(adapter)\
118         (&((struct virtio_adapter *)adapter)->hw)
119
120 /*
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
123  * via tcp_lro_rx().
124  */
125 #define VTNET_LRO_FEATURES (VIRTIO_NET_F_GUEST_TSO4 | \
126     VIRTIO_NET_F_GUEST_TSO6 | VIRTIO_NET_F_GUEST_ECN)
127
128
129 #endif /* _VIRTIO_ETHDEV_H_ */