ac3949dd10e263ec72413c7dd885c92608fdc7cc
[dpdk.git] / lib / librte_eal / linuxapp / kni / kni_dev.h
1 /*-
2  * GPL LICENSE SUMMARY
3  * 
4  *   Copyright(c) 2010-2013 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
26 #ifndef _KNI_DEV_H_
27 #define _KNI_DEV_H_
28
29 #include <linux/if.h>
30 #include <linux/wait.h>
31 #include <linux/sched.h>
32 #include <linux/netdevice.h>
33 #include <linux/spinlock.h>
34 #include <linux/list.h>
35
36 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 10 /* us */
37
38 /**
39  * A structure describing the private information for a kni device.
40  */
41 struct kni_dev {
42         /* kni list */
43         struct list_head list;
44
45         struct net_device_stats stats;
46         int status;
47         int port_id;
48
49         /* wait queue for req/resp */
50         wait_queue_head_t wq;
51         struct mutex sync_lock;
52
53         /* PCI device id */
54         uint16_t device_id;
55
56         /* kni device */
57         struct net_device *net_dev;
58         struct net_device *lad_dev;
59         struct pci_dev *pci_dev;
60
61         /* queue for packets to be sent out */
62         void *tx_q;
63
64         /* queue for the packets received */
65         void *rx_q;
66
67         /* queue for the allocated mbufs those can be used to save sk buffs */
68         void *alloc_q;
69
70         /* free queue for the mbufs to be freed */
71         void *free_q;
72
73         /* request queue */
74         void *req_q;
75
76         /* response queue */
77         void *resp_q;
78
79         void * sync_kva;
80         void *sync_va;
81
82         void *mbuf_kva;
83         void *mbuf_va;
84
85         /* mbuf size */
86         unsigned mbuf_size;
87
88         /* synchro for request processing */
89         unsigned long synchro;
90 };
91
92 #define DEBUG_KNI
93
94 #define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args)
95 #define KNI_PRINT(args...) printk(KERN_DEBUG "KNI: " args)
96 #ifdef DEBUG_KNI
97         #define KNI_DBG(args...) printk(KERN_DEBUG "KNI: " args)
98 #else
99         #define KNI_DBG(args...)
100 #endif
101
102 #endif