DPDK  16.11.11
rte_virtio_net.h
Go to the documentation of this file.
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_NET_H_
35 #define _VIRTIO_NET_H_
36 
42 #include <stdint.h>
43 #include <linux/vhost.h>
44 #include <linux/virtio_ring.h>
45 #include <linux/virtio_net.h>
46 #include <sys/eventfd.h>
47 #include <sys/socket.h>
48 #include <linux/if.h>
49 
50 #include <rte_memory.h>
51 #include <rte_mempool.h>
52 #include <rte_ether.h>
53 
54 #define RTE_VHOST_USER_CLIENT (1ULL << 0)
55 #define RTE_VHOST_USER_NO_RECONNECT (1ULL << 1)
56 #define RTE_VHOST_USER_DEQUEUE_ZERO_COPY (1ULL << 2)
57 
58 /* Enum for virtqueue management. */
59 enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
60 
65  int (*new_device)(int vid);
66  void (*destroy_device)(int vid);
68  int (*vring_state_changed)(int vid, uint16_t queue_id, int enable);
70  void *reserved[5];
71 };
72 
76 int rte_vhost_feature_disable(uint64_t feature_mask);
77 
81 int rte_vhost_feature_enable(uint64_t feature_mask);
82 
83 /* Returns currently supported vhost features */
84 uint64_t rte_vhost_feature_get(void);
85 
86 int rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable);
87 
92 int rte_vhost_driver_register(const char *path, uint64_t flags);
93 
94 /* Unregister vhost driver. This is only meaningful to vhost user. */
95 int rte_vhost_driver_unregister(const char *path);
96 
97 /* Register callbacks. */
98 int rte_vhost_driver_callback_register(struct virtio_net_device_ops const * const);
99 /* Start vhost driver session blocking loop. */
100 int rte_vhost_driver_session_start(void);
101 
112 int rte_vhost_get_numa_node(int vid);
113 
123 uint32_t rte_vhost_get_queue_num(int vid);
124 
139 int rte_vhost_get_ifname(int vid, char *buf, size_t len);
140 
152 uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id);
153 
170 uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
171  struct rte_mbuf **pkts, uint16_t count);
172 
190 uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
191  struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count);
192 
193 #endif /* _VIRTIO_NET_H_ */
void(* destroy_device)(int vid)
uint16_t rte_vhost_enqueue_burst(int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count)
int(* vring_state_changed)(int vid, uint16_t queue_id, int enable)
int(* new_device)(int vid)
uint16_t rte_vhost_avail_entries(int vid, uint16_t queue_id)
int rte_vhost_get_ifname(int vid, char *buf, size_t len)
int rte_vhost_feature_disable(uint64_t feature_mask)
uint16_t rte_vhost_dequeue_burst(int vid, uint16_t queue_id, struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
uint32_t rte_vhost_get_queue_num(int vid)
int rte_vhost_feature_enable(uint64_t feature_mask)
int rte_vhost_driver_register(const char *path, uint64_t flags)
int rte_vhost_get_numa_node(int vid)