update Intel copyright years to 2014
[dpdk.git] / lib / librte_eal / linuxapp / kni / kni_dev.h
1 /*-
2  * GPL LICENSE SUMMARY
3  * 
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * 
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of version 2 of the GNU General Public License as
8  *   published by the Free Software Foundation.
9  * 
10  *   This program is distributed in the hope that it will be useful, but
11  *   WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *   General Public License for more details.
14  * 
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18  *   The full GNU General Public License is included in this distribution
19  *   in the file called LICENSE.GPL.
20  * 
21  *   Contact Information:
22  *   Intel Corporation
23  */
24
25 #ifndef _KNI_DEV_H_
26 #define _KNI_DEV_H_
27
28 #include <linux/if.h>
29 #include <linux/wait.h>
30 #include <linux/sched.h>
31 #include <linux/netdevice.h>
32 #include <linux/spinlock.h>
33 #include <linux/list.h>
34
35 #ifdef RTE_KNI_VHOST
36 #include <net/sock.h>
37 #endif
38
39 #include <exec-env/rte_kni_common.h>
40 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */
41
42 /**
43  * A structure describing the private information for a kni device.
44  */
45
46 struct kni_dev {
47         /* kni list */
48         struct list_head list;
49
50         struct net_device_stats stats;
51         int status;
52         uint16_t group_id;           /* Group ID of a group of KNI devices */
53         unsigned core_id;            /* Core ID to bind */
54         char name[RTE_KNI_NAMESIZE]; /* Network device name */
55         struct task_struct *pthread;
56
57         /* wait queue for req/resp */
58         wait_queue_head_t wq;
59         struct mutex sync_lock;
60
61         /* PCI device id */
62         uint16_t device_id;
63
64         /* kni device */
65         struct net_device *net_dev;
66         struct net_device *lad_dev;
67         struct pci_dev *pci_dev;
68
69         /* queue for packets to be sent out */
70         void *tx_q;
71
72         /* queue for the packets received */
73         void *rx_q;
74
75         /* queue for the allocated mbufs those can be used to save sk buffs */
76         void *alloc_q;
77
78         /* free queue for the mbufs to be freed */
79         void *free_q;
80
81         /* request queue */
82         void *req_q;
83
84         /* response queue */
85         void *resp_q;
86
87         void * sync_kva;
88         void *sync_va;
89
90         void *mbuf_kva;
91         void *mbuf_va;
92
93         /* mbuf size */
94         unsigned mbuf_size;
95
96         /* synchro for request processing */
97         unsigned long synchro;
98
99 #ifdef RTE_KNI_VHOST
100         struct kni_vhost_queue* vhost_queue;
101         volatile enum {
102                 BE_STOP = 0x1,
103                 BE_START = 0x2,
104                 BE_FINISH = 0x4,
105         }vq_status;
106 #endif
107 };
108
109 #define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args)
110 #define KNI_PRINT(args...) printk(KERN_DEBUG "KNI: " args)
111 #ifdef RTE_KNI_KO_DEBUG
112         #define KNI_DBG(args...) printk(KERN_DEBUG "KNI: " args)
113 #else
114         #define KNI_DBG(args...)
115 #endif
116
117 #ifdef RTE_KNI_VHOST
118 unsigned int 
119 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
120 int kni_chk_vhost_rx(struct kni_dev *kni);
121 int kni_vhost_init(struct kni_dev *kni);
122 int kni_vhost_backend_release(struct kni_dev *kni);
123
124 struct kni_vhost_queue {
125         struct sock sk;
126         struct socket *sock;
127         int vnet_hdr_sz;
128         struct kni_dev *kni;
129         int sockfd;
130         unsigned int flags;
131         struct sk_buff* cache;
132         struct rte_kni_fifo* fifo;
133 };
134
135 #endif
136
137 #ifdef RTE_KNI_VHOST_DEBUG_RX
138         #define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
139 #else
140         #define KNI_DBG_RX(args...)
141 #endif
142
143 #ifdef RTE_KNI_VHOST_DEBUG_TX
144         #define KNI_DBG_TX(args...) printk(KERN_DEBUG "KNI TX: " args)
145 #else
146         #define KNI_DBG_TX(args...)
147 #endif
148
149 #endif
150