remove trailing whitespaces
[dpdk.git] / examples / vhost / vhost-net-cdev.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 _VHOST_NET_CDEV_H_
35 #define _VHOST_NET_CDEV_H_
36
37 #include <linux/vhost.h>
38
39 struct vhost_memory;
40 struct vhost_vring_state;
41 struct vhost_vring_addr;
42 struct vhost_vring_file;
43
44 /*
45  * Structure used to identify device context.
46  */
47 struct vhost_device_ctx
48 {
49         pid_t           pid;    /* PID of process calling the IOCTL. */
50         uint64_t        fh;             /* Populated with fi->fh to track the device index. */
51 };
52
53 /*
54  * Structure contains function pointers to be defined in virtio-net.c. These
55  * functions are called in CUSE context and are used to configure devices.
56  */
57 struct vhost_net_device_ops {
58         int (* new_device)              (struct vhost_device_ctx);
59         void (* destroy_device) (struct vhost_device_ctx);
60
61         int (* get_features)    (struct vhost_device_ctx, uint64_t *);
62         int (* set_features)    (struct vhost_device_ctx, uint64_t *);
63
64         int (* set_mem_table)   (struct vhost_device_ctx, const void *, uint32_t);
65
66         int (* set_vring_num)   (struct vhost_device_ctx, struct vhost_vring_state *);
67         int (* set_vring_addr)  (struct vhost_device_ctx, struct vhost_vring_addr *);
68         int (* set_vring_base)  (struct vhost_device_ctx, struct vhost_vring_state *);
69         int (* get_vring_base)  (struct vhost_device_ctx, uint32_t, struct vhost_vring_state *);
70
71         int (* set_vring_kick)  (struct vhost_device_ctx, struct vhost_vring_file *);
72         int (* set_vring_call)  (struct vhost_device_ctx, struct vhost_vring_file *);
73
74         int (* set_backend)     (struct vhost_device_ctx, struct vhost_vring_file *);
75
76         int (* set_owner)               (struct vhost_device_ctx);
77         int (* reset_owner)     (struct vhost_device_ctx);
78 };
79
80 int register_cuse_device(const char *base_name, int index, struct vhost_net_device_ops const * const);
81 int start_cuse_session_loop(void);
82
83 #endif /* _VHOST_NET_CDEV_H_ */