kni: fix large stack frame size
[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 #define MBUF_BURST_SZ 32
43
44 /**
45  * A structure describing the private information for a kni device.
46  */
47 struct kni_dev {
48         /* kni list */
49         struct list_head list;
50
51         struct net_device_stats stats;
52         int status;
53         uint16_t group_id;           /* Group ID of a group of KNI devices */
54         unsigned core_id;            /* Core ID to bind */
55         char name[RTE_KNI_NAMESIZE]; /* Network device name */
56         struct task_struct *pthread;
57
58         /* wait queue for req/resp */
59         wait_queue_head_t wq;
60         struct mutex sync_lock;
61
62         /* PCI device id */
63         uint16_t device_id;
64
65         /* kni device */
66         struct net_device *net_dev;
67         struct net_device *lad_dev;
68         struct pci_dev *pci_dev;
69
70         /* queue for packets to be sent out */
71         void *tx_q;
72
73         /* queue for the packets received */
74         void *rx_q;
75
76         /* queue for the allocated mbufs those can be used to save sk buffs */
77         void *alloc_q;
78
79         /* free queue for the mbufs to be freed */
80         void *free_q;
81
82         /* request queue */
83         void *req_q;
84
85         /* response queue */
86         void *resp_q;
87
88         void * sync_kva;
89         void *sync_va;
90
91         void *mbuf_kva;
92         void *mbuf_va;
93
94         /* mbuf size */
95         unsigned mbuf_size;
96
97         /* synchro for request processing */
98         unsigned long synchro;
99
100 #ifdef RTE_KNI_VHOST
101         struct kni_vhost_queue* vhost_queue;
102         volatile enum {
103                 BE_STOP = 0x1,
104                 BE_START = 0x2,
105                 BE_FINISH = 0x4,
106         }vq_status;
107 #endif
108         /* buffers */
109         void *pa[MBUF_BURST_SZ];
110         void *va[MBUF_BURST_SZ];
111         void *alloc_pa[MBUF_BURST_SZ];
112         void *alloc_va[MBUF_BURST_SZ];
113 };
114
115 #define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args)
116 #define KNI_PRINT(args...) printk(KERN_DEBUG "KNI: " args)
117 #ifdef RTE_KNI_KO_DEBUG
118         #define KNI_DBG(args...) printk(KERN_DEBUG "KNI: " args)
119 #else
120         #define KNI_DBG(args...)
121 #endif
122
123 #ifdef RTE_KNI_VHOST
124 unsigned int
125 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
126 int kni_chk_vhost_rx(struct kni_dev *kni);
127 int kni_vhost_init(struct kni_dev *kni);
128 int kni_vhost_backend_release(struct kni_dev *kni);
129
130 struct kni_vhost_queue {
131         struct sock sk;
132         struct socket *sock;
133         int vnet_hdr_sz;
134         struct kni_dev *kni;
135         int sockfd;
136         unsigned int flags;
137         struct sk_buff* cache;
138         struct rte_kni_fifo* fifo;
139 };
140
141 #endif
142
143 #ifdef RTE_KNI_VHOST_DEBUG_RX
144         #define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
145 #else
146         #define KNI_DBG_RX(args...)
147 #endif
148
149 #ifdef RTE_KNI_VHOST_DEBUG_TX
150         #define KNI_DBG_TX(args...) printk(KERN_DEBUG "KNI TX: " args)
151 #else
152         #define KNI_DBG_TX(args...)
153 #endif
154
155 #endif