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:
31 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
36 #include <linux/wait.h>
37 #ifdef HAVE_SIGNAL_FUNCTIONS_OWN_HEADER
38 #include <linux/sched/signal.h>
40 #include <linux/sched.h>
42 #include <linux/netdevice.h>
43 #include <linux/spinlock.h>
44 #include <linux/list.h>
50 #include <exec-env/rte_kni_common.h>
51 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */
53 #define MBUF_BURST_SZ 32
56 * A structure describing the private information for a kni device.
60 struct list_head list;
62 struct net_device_stats stats;
64 uint16_t group_id; /* Group ID of a group of KNI devices */
65 uint32_t core_id; /* Core ID to bind */
66 char name[RTE_KNI_NAMESIZE]; /* Network device name */
67 struct task_struct *pthread;
69 /* wait queue for req/resp */
71 struct mutex sync_lock;
77 struct net_device *net_dev;
78 struct net_device *lad_dev;
79 struct pci_dev *pci_dev;
81 /* queue for packets to be sent out */
84 /* queue for the packets received */
87 /* queue for the allocated mbufs those can be used to save sk buffs */
90 /* free queue for the mbufs to be freed */
108 /* synchro for request processing */
109 unsigned long synchro;
112 struct kni_vhost_queue *vhost_queue;
121 void *pa[MBUF_BURST_SZ];
122 void *va[MBUF_BURST_SZ];
123 void *alloc_pa[MBUF_BURST_SZ];
124 void *alloc_va[MBUF_BURST_SZ];
129 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
130 int kni_chk_vhost_rx(struct kni_dev *kni);
131 int kni_vhost_init(struct kni_dev *kni);
132 int kni_vhost_backend_release(struct kni_dev *kni);
134 struct kni_vhost_queue {
141 struct sk_buff *cache;
142 struct rte_kni_fifo *fifo;
147 void kni_net_rx(struct kni_dev *kni);
148 void kni_net_init(struct net_device *dev);
149 void kni_net_config_lo_mode(char *lo_str);
150 void kni_net_poll_resp(struct kni_dev *kni);
151 void kni_set_ethtool_ops(struct net_device *netdev);
153 int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
154 void ixgbe_kni_remove(struct pci_dev *pdev);
155 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
156 void igb_kni_remove(struct pci_dev *pdev);