4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
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.
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.
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.
21 * Contact Information:
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>
39 #include <exec-env/rte_kni_common.h>
40 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */
42 #define MBUF_BURST_SZ 32
45 * A structure describing the private information for a kni device.
49 struct list_head list;
51 struct net_device_stats stats;
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;
58 /* wait queue for req/resp */
60 struct mutex sync_lock;
66 struct net_device *net_dev;
67 struct net_device *lad_dev;
68 struct pci_dev *pci_dev;
70 /* queue for packets to be sent out */
73 /* queue for the packets received */
76 /* queue for the allocated mbufs those can be used to save sk buffs */
79 /* free queue for the mbufs to be freed */
97 /* synchro for request processing */
98 unsigned long synchro;
101 struct kni_vhost_queue* vhost_queue;
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];
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)
120 #define KNI_DBG(args...)
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);
130 struct kni_vhost_queue {
137 struct sk_buff* cache;
138 struct rte_kni_fifo* fifo;
143 void kni_net_rx(struct kni_dev *kni);
144 void kni_net_init(struct net_device *dev);
145 void kni_net_config_lo_mode(char *lo_str);
146 void kni_net_poll_resp(struct kni_dev *kni);
147 void kni_set_ethtool_ops(struct net_device *netdev);
149 int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
150 void ixgbe_kni_remove(struct pci_dev *pdev);
151 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
152 void igb_kni_remove(struct pci_dev *pdev);
154 #ifdef RTE_KNI_VHOST_DEBUG_RX
155 #define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
157 #define KNI_DBG_RX(args...)
160 #ifdef RTE_KNI_VHOST_DEBUG_TX
161 #define KNI_DBG_TX(args...) printk(KERN_DEBUG "KNI TX: " args)
163 #define KNI_DBG_TX(args...)