kni: fix build with kernel 2.6.32
[dpdk.git] / lib / librte_eal / linuxapp / kni / kni_misc.c
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 #include <linux/version.h>
26 #include <linux/module.h>
27 #include <linux/miscdevice.h>
28 #include <linux/netdevice.h>
29 #include <linux/pci.h>
30 #include <linux/kthread.h>
31 #include <linux/rwsem.h>
32 #include <linux/nsproxy.h>
33 #include <net/net_namespace.h>
34 #include <net/netns/generic.h>
35
36 #include <exec-env/rte_kni_common.h>
37 #include "kni_dev.h"
38 #include <rte_config.h>
39
40 MODULE_LICENSE("Dual BSD/GPL");
41 MODULE_AUTHOR("Intel Corporation");
42 MODULE_DESCRIPTION("Kernel Module for managing kni devices");
43
44 #define KNI_RX_LOOP_NUM 1000
45
46 #define KNI_MAX_DEVICES 32
47
48 extern void kni_net_rx(struct kni_dev *kni);
49 extern void kni_net_init(struct net_device *dev);
50 extern void kni_net_config_lo_mode(char *lo_str);
51 extern void kni_net_poll_resp(struct kni_dev *kni);
52 extern void kni_set_ethtool_ops(struct net_device *netdev);
53
54 extern int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
55 extern void ixgbe_kni_remove(struct pci_dev *pdev);
56 extern int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
57 extern void igb_kni_remove(struct pci_dev *pdev);
58
59 static int kni_open(struct inode *inode, struct file *file);
60 static int kni_release(struct inode *inode, struct file *file);
61 static int kni_ioctl(struct inode *inode, unsigned int ioctl_num,
62                                         unsigned long ioctl_param);
63 static int kni_compat_ioctl(struct inode *inode, unsigned int ioctl_num,
64                                                 unsigned long ioctl_param);
65 static int kni_dev_remove(struct kni_dev *dev);
66
67 static int __init kni_parse_kthread_mode(void);
68
69 /* KNI processing for single kernel thread mode */
70 static int kni_thread_single(void *unused);
71 /* KNI processing for multiple kernel thread mode */
72 static int kni_thread_multiple(void *param);
73
74 static struct file_operations kni_fops = {
75         .owner = THIS_MODULE,
76         .open = kni_open,
77         .release = kni_release,
78         .unlocked_ioctl = (void *)kni_ioctl,
79         .compat_ioctl = (void *)kni_compat_ioctl,
80 };
81
82 static struct miscdevice kni_misc = {
83         .minor = MISC_DYNAMIC_MINOR,
84         .name = KNI_DEVICE,
85         .fops = &kni_fops,
86 };
87
88 /* loopback mode */
89 static char *lo_mode = NULL;
90
91 /* Kernel thread mode */
92 static char *kthread_mode = NULL;
93 static unsigned multiple_kthread_on = 0;
94
95 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
96
97 static int kni_net_id;
98
99 struct kni_net {
100         unsigned long device_in_use; /* device in use flag */
101         struct task_struct *kni_kthread;
102         struct rw_semaphore kni_list_lock;
103         struct list_head kni_list_head;
104 };
105
106 static int __net_init kni_init_net(struct net *net)
107 {
108 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
109         struct kni_net *knet = net_generic(net, kni_net_id);
110 #else
111         struct kni_net *knet;
112         int ret;
113
114         knet = kmalloc(sizeof(struct kni_net), GFP_KERNEL);
115         if (!knet) {
116                 ret = -ENOMEM;
117                 return ret;
118         }
119 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
120
121         /* Clear the bit of device in use */
122         clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use);
123
124         init_rwsem(&knet->kni_list_lock);
125         INIT_LIST_HEAD(&knet->kni_list_head);
126
127 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
128         return 0;
129 #else
130         ret = net_assign_generic(net, kni_net_id, knet);
131         if (ret < 0)
132                 kfree(knet);
133
134         return ret;
135 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
136 }
137
138 static void __net_exit kni_exit_net(struct net *net)
139 {
140 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32)
141         struct kni_net *knet = net_generic(net, kni_net_id);
142
143         kfree(knet);
144 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
145 }
146
147 static struct pernet_operations kni_net_ops = {
148         .init = kni_init_net,
149         .exit = kni_exit_net,
150 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
151         .id   = &kni_net_id,
152         .size = sizeof(struct kni_net),
153 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
154 };
155
156 static int __init
157 kni_init(void)
158 {
159         int rc;
160
161         KNI_PRINT("######## DPDK kni module loading ########\n");
162
163         if (kni_parse_kthread_mode() < 0) {
164                 KNI_ERR("Invalid parameter for kthread_mode\n");
165                 return -EINVAL;
166         }
167
168 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
169         rc = register_pernet_subsys(&kni_net_ops);
170 #else
171         rc = register_pernet_gen_subsys(&kni_net_id, &kni_net_ops);
172 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
173         if (rc)
174                 return -EPERM;
175
176         rc = misc_register(&kni_misc);
177         if (rc != 0) {
178                 KNI_ERR("Misc registration failed\n");
179                 goto out;
180         }
181
182         /* Configure the lo mode according to the input parameter */
183         kni_net_config_lo_mode(lo_mode);
184
185         KNI_PRINT("######## DPDK kni module loaded  ########\n");
186
187         return 0;
188
189 out:
190 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
191         unregister_pernet_subsys(&kni_net_ops);
192 #else
193         register_pernet_gen_subsys(&kni_net_id, &kni_net_ops);
194 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
195         return rc;
196 }
197
198 static void __exit
199 kni_exit(void)
200 {
201         misc_deregister(&kni_misc);
202 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
203         unregister_pernet_subsys(&kni_net_ops);
204 #else
205         register_pernet_gen_subsys(&kni_net_id, &kni_net_ops);
206 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32) */
207         KNI_PRINT("####### DPDK kni module unloaded  #######\n");
208 }
209
210 static int __init
211 kni_parse_kthread_mode(void)
212 {
213         if (!kthread_mode)
214                 return 0;
215
216         if (strcmp(kthread_mode, "single") == 0)
217                 return 0;
218         else if (strcmp(kthread_mode, "multiple") == 0)
219                 multiple_kthread_on = 1;
220         else
221                 return -1;
222
223         return 0;
224 }
225
226 static int
227 kni_open(struct inode *inode, struct file *file)
228 {
229         struct net *net = current->nsproxy->net_ns;
230         struct kni_net *knet = net_generic(net, kni_net_id);
231
232         /* kni device can be opened by one user only per netns */
233         if (test_and_set_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use))
234                 return -EBUSY;
235
236         /* Create kernel thread for single mode */
237         if (multiple_kthread_on == 0) {
238                 KNI_PRINT("Single kernel thread for all KNI devices\n");
239                 /* Create kernel thread for RX */
240                 knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet,
241                                                 "kni_single");
242                 if (IS_ERR(knet->kni_kthread)) {
243                         KNI_ERR("Unable to create kernel threaed\n");
244                         return PTR_ERR(knet->kni_kthread);
245                 }
246         } else
247                 KNI_PRINT("Multiple kernel thread mode enabled\n");
248
249         file->private_data = get_net(net);
250         KNI_PRINT("/dev/kni opened\n");
251
252         return 0;
253 }
254
255 static int
256 kni_release(struct inode *inode, struct file *file)
257 {
258         struct net *net = file->private_data;
259         struct kni_net *knet = net_generic(net, kni_net_id);
260         struct kni_dev *dev, *n;
261
262         /* Stop kernel thread for single mode */
263         if (multiple_kthread_on == 0) {
264                 /* Stop kernel thread */
265                 kthread_stop(knet->kni_kthread);
266                 knet->kni_kthread = NULL;
267         }
268
269         down_write(&knet->kni_list_lock);
270         list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) {
271                 /* Stop kernel thread for multiple mode */
272                 if (multiple_kthread_on && dev->pthread != NULL) {
273                         kthread_stop(dev->pthread);
274                         dev->pthread = NULL;
275                 }
276
277 #ifdef RTE_KNI_VHOST
278                 kni_vhost_backend_release(dev);
279 #endif
280                 kni_dev_remove(dev);
281                 list_del(&dev->list);
282         }
283         up_write(&knet->kni_list_lock);
284
285         /* Clear the bit of device in use */
286         clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use);
287
288         put_net(net);
289         KNI_PRINT("/dev/kni closed\n");
290
291         return 0;
292 }
293
294 static int
295 kni_thread_single(void *data)
296 {
297         struct kni_net *knet = data;
298         int j;
299         struct kni_dev *dev;
300
301         while (!kthread_should_stop()) {
302                 down_read(&knet->kni_list_lock);
303                 for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
304                         list_for_each_entry(dev, &knet->kni_list_head, list) {
305 #ifdef RTE_KNI_VHOST
306                                 kni_chk_vhost_rx(dev);
307 #else
308                                 kni_net_rx(dev);
309 #endif
310                                 kni_net_poll_resp(dev);
311                         }
312                 }
313                 up_read(&knet->kni_list_lock);
314 #ifdef RTE_KNI_PREEMPT_DEFAULT
315                 /* reschedule out for a while */
316                 schedule_timeout_interruptible(usecs_to_jiffies( \
317                                 KNI_KTHREAD_RESCHEDULE_INTERVAL));
318 #endif
319         }
320
321         return 0;
322 }
323
324 static int
325 kni_thread_multiple(void *param)
326 {
327         int j;
328         struct kni_dev *dev = (struct kni_dev *)param;
329
330         while (!kthread_should_stop()) {
331                 for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
332 #ifdef RTE_KNI_VHOST
333                         kni_chk_vhost_rx(dev);
334 #else
335                         kni_net_rx(dev);
336 #endif
337                         kni_net_poll_resp(dev);
338                 }
339 #ifdef RTE_KNI_PREEMPT_DEFAULT
340                 schedule_timeout_interruptible(usecs_to_jiffies( \
341                                 KNI_KTHREAD_RESCHEDULE_INTERVAL));
342 #endif
343         }
344
345         return 0;
346 }
347
348 static int
349 kni_dev_remove(struct kni_dev *dev)
350 {
351         if (!dev)
352                 return -ENODEV;
353
354         switch (dev->device_id) {
355         #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev):
356         #include <rte_pci_dev_ids.h>
357                 igb_kni_remove(dev->pci_dev);
358                 break;
359         #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) case (dev):
360         #include <rte_pci_dev_ids.h>
361                 ixgbe_kni_remove(dev->pci_dev);
362                 break;
363         default:
364                 break;
365         }
366
367         if (dev->net_dev) {
368                 unregister_netdev(dev->net_dev);
369                 free_netdev(dev->net_dev);
370         }
371
372         return 0;
373 }
374
375 static int
376 kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev)
377 {
378         if (!kni || !dev)
379                 return -1;
380
381         /* Check if network name has been used */
382         if (!strncmp(kni->name, dev->name, RTE_KNI_NAMESIZE)) {
383                 KNI_ERR("KNI name %s duplicated\n", dev->name);
384                 return -1;
385         }
386
387         return 0;
388 }
389
390 static int
391 kni_ioctl_create(struct net *net,
392                 unsigned int ioctl_num, unsigned long ioctl_param)
393 {
394         struct kni_net *knet = net_generic(net, kni_net_id);
395         int ret;
396         struct rte_kni_device_info dev_info;
397         struct pci_dev *pci = NULL;
398         struct pci_dev *found_pci = NULL;
399         struct net_device *net_dev = NULL;
400         struct net_device *lad_dev = NULL;
401         struct kni_dev *kni, *dev, *n;
402
403         printk(KERN_INFO "KNI: Creating kni...\n");
404         /* Check the buffer size, to avoid warning */
405         if (_IOC_SIZE(ioctl_num) > sizeof(dev_info))
406                 return -EINVAL;
407
408         /* Copy kni info from user space */
409         ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info));
410         if (ret) {
411                 KNI_ERR("copy_from_user in kni_ioctl_create");
412                 return -EIO;
413         }
414
415         /**
416          * Check if the cpu core id is valid for binding,
417          * for multiple kernel thread mode.
418          */
419         if (multiple_kthread_on && dev_info.force_bind &&
420                                 !cpu_online(dev_info.core_id)) {
421                 KNI_ERR("cpu %u is not online\n", dev_info.core_id);
422                 return -EINVAL;
423         }
424
425         /* Check if it has been created */
426         down_read(&knet->kni_list_lock);
427         list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) {
428                 if (kni_check_param(dev, &dev_info) < 0) {
429                         up_read(&knet->kni_list_lock);
430                         return -EINVAL;
431                 }
432         }
433         up_read(&knet->kni_list_lock);
434
435         net_dev = alloc_netdev(sizeof(struct kni_dev), dev_info.name,
436 #ifdef NET_NAME_UNKNOWN
437                                                         NET_NAME_UNKNOWN,
438 #endif
439                                                         kni_net_init);
440         if (net_dev == NULL) {
441                 KNI_ERR("error allocating device \"%s\"\n", dev_info.name);
442                 return -EBUSY;
443         }
444
445         dev_net_set(net_dev, net);
446
447         kni = netdev_priv(net_dev);
448
449         kni->net_dev = net_dev;
450         kni->group_id = dev_info.group_id;
451         kni->core_id = dev_info.core_id;
452         strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE);
453
454         /* Translate user space info into kernel space info */
455         kni->tx_q = phys_to_virt(dev_info.tx_phys);
456         kni->rx_q = phys_to_virt(dev_info.rx_phys);
457         kni->alloc_q = phys_to_virt(dev_info.alloc_phys);
458         kni->free_q = phys_to_virt(dev_info.free_phys);
459
460         kni->req_q = phys_to_virt(dev_info.req_phys);
461         kni->resp_q = phys_to_virt(dev_info.resp_phys);
462         kni->sync_va = dev_info.sync_va;
463         kni->sync_kva = phys_to_virt(dev_info.sync_phys);
464
465         kni->mbuf_kva = phys_to_virt(dev_info.mbuf_phys);
466         kni->mbuf_va = dev_info.mbuf_va;
467
468 #ifdef RTE_KNI_VHOST
469         kni->vhost_queue = NULL;
470         kni->vq_status = BE_STOP;
471 #endif
472         kni->mbuf_size = dev_info.mbuf_size;
473
474         KNI_PRINT("tx_phys:      0x%016llx, tx_q addr:      0x%p\n",
475                 (unsigned long long) dev_info.tx_phys, kni->tx_q);
476         KNI_PRINT("rx_phys:      0x%016llx, rx_q addr:      0x%p\n",
477                 (unsigned long long) dev_info.rx_phys, kni->rx_q);
478         KNI_PRINT("alloc_phys:   0x%016llx, alloc_q addr:   0x%p\n",
479                 (unsigned long long) dev_info.alloc_phys, kni->alloc_q);
480         KNI_PRINT("free_phys:    0x%016llx, free_q addr:    0x%p\n",
481                 (unsigned long long) dev_info.free_phys, kni->free_q);
482         KNI_PRINT("req_phys:     0x%016llx, req_q addr:     0x%p\n",
483                 (unsigned long long) dev_info.req_phys, kni->req_q);
484         KNI_PRINT("resp_phys:    0x%016llx, resp_q addr:    0x%p\n",
485                 (unsigned long long) dev_info.resp_phys, kni->resp_q);
486         KNI_PRINT("mbuf_phys:    0x%016llx, mbuf_kva:       0x%p\n",
487                 (unsigned long long) dev_info.mbuf_phys, kni->mbuf_kva);
488         KNI_PRINT("mbuf_va:      0x%p\n", dev_info.mbuf_va);
489         KNI_PRINT("mbuf_size:    %u\n", kni->mbuf_size);
490
491         KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n",
492                                         dev_info.bus,
493                                         dev_info.devid,
494                                         dev_info.function,
495                                         dev_info.vendor_id,
496                                         dev_info.device_id);
497
498         pci = pci_get_device(dev_info.vendor_id, dev_info.device_id, NULL);
499
500         /* Support Ethtool */
501         while (pci) {
502                 KNI_PRINT("pci_bus: %02x:%02x:%02x \n",
503                                         pci->bus->number,
504                                         PCI_SLOT(pci->devfn),
505                                         PCI_FUNC(pci->devfn));
506
507                 if ((pci->bus->number == dev_info.bus) &&
508                         (PCI_SLOT(pci->devfn) == dev_info.devid) &&
509                         (PCI_FUNC(pci->devfn) == dev_info.function)) {
510                         found_pci = pci;
511                         switch (dev_info.device_id) {
512                         #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev):
513                         #include <rte_pci_dev_ids.h>
514                                 ret = igb_kni_probe(found_pci, &lad_dev);
515                                 break;
516                         #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) \
517                                                         case (dev):
518                         #include <rte_pci_dev_ids.h>
519                                 ret = ixgbe_kni_probe(found_pci, &lad_dev);
520                                 break;
521                         default:
522                                 ret = -1;
523                                 break;
524                         }
525
526                         KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n",
527                                                         pci, lad_dev);
528                         if (ret == 0) {
529                                 kni->lad_dev = lad_dev;
530                                 kni_set_ethtool_ops(kni->net_dev);
531                         } else {
532                                 KNI_ERR("Device not supported by ethtool");
533                                 kni->lad_dev = NULL;
534                         }
535
536                         kni->pci_dev = found_pci;
537                         kni->device_id = dev_info.device_id;
538                         break;
539                 }
540                 pci = pci_get_device(dev_info.vendor_id,
541                                 dev_info.device_id, pci);
542         }
543         if (pci)
544                 pci_dev_put(pci);
545
546         ret = register_netdev(net_dev);
547         if (ret) {
548                 KNI_ERR("error %i registering device \"%s\"\n",
549                                         ret, dev_info.name);
550                 kni_dev_remove(kni);
551                 return -ENODEV;
552         }
553
554 #ifdef RTE_KNI_VHOST
555         kni_vhost_init(kni);
556 #endif
557
558         /**
559          * Create a new kernel thread for multiple mode, set its core affinity,
560          * and finally wake it up.
561          */
562         if (multiple_kthread_on) {
563                 kni->pthread = kthread_create(kni_thread_multiple,
564                                               (void *)kni,
565                                               "kni_%s", kni->name);
566                 if (IS_ERR(kni->pthread)) {
567                         kni_dev_remove(kni);
568                         return -ECANCELED;
569                 }
570                 if (dev_info.force_bind)
571                         kthread_bind(kni->pthread, kni->core_id);
572                 wake_up_process(kni->pthread);
573         }
574
575         down_write(&knet->kni_list_lock);
576         list_add(&kni->list, &knet->kni_list_head);
577         up_write(&knet->kni_list_lock);
578
579         return 0;
580 }
581
582 static int
583 kni_ioctl_release(struct net *net,
584                 unsigned int ioctl_num, unsigned long ioctl_param)
585 {
586         struct kni_net *knet = net_generic(net, kni_net_id);
587         int ret = -EINVAL;
588         struct kni_dev *dev, *n;
589         struct rte_kni_device_info dev_info;
590
591         if (_IOC_SIZE(ioctl_num) > sizeof(dev_info))
592                         return -EINVAL;
593
594         ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info));
595         if (ret) {
596                 KNI_ERR("copy_from_user in kni_ioctl_release");
597                 return -EIO;
598         }
599
600         /* Release the network device according to its name */
601         if (strlen(dev_info.name) == 0)
602                 return ret;
603
604         down_write(&knet->kni_list_lock);
605         list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) {
606                 if (strncmp(dev->name, dev_info.name, RTE_KNI_NAMESIZE) != 0)
607                         continue;
608
609                 if (multiple_kthread_on && dev->pthread != NULL) {
610                         kthread_stop(dev->pthread);
611                         dev->pthread = NULL;
612                 }
613
614 #ifdef RTE_KNI_VHOST
615                 kni_vhost_backend_release(dev);
616 #endif
617                 kni_dev_remove(dev);
618                 list_del(&dev->list);
619                 ret = 0;
620                 break;
621         }
622         up_write(&knet->kni_list_lock);
623         printk(KERN_INFO "KNI: %s release kni named %s\n",
624                 (ret == 0 ? "Successfully" : "Unsuccessfully"), dev_info.name);
625
626         return ret;
627 }
628
629 static int
630 kni_ioctl(struct inode *inode,
631         unsigned int ioctl_num,
632         unsigned long ioctl_param)
633 {
634         int ret = -EINVAL;
635         struct net *net = current->nsproxy->net_ns;
636
637         KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
638
639         /*
640          * Switch according to the ioctl called
641          */
642         switch (_IOC_NR(ioctl_num)) {
643         case _IOC_NR(RTE_KNI_IOCTL_TEST):
644                 /* For test only, not used */
645                 break;
646         case _IOC_NR(RTE_KNI_IOCTL_CREATE):
647                 ret = kni_ioctl_create(net, ioctl_num, ioctl_param);
648                 break;
649         case _IOC_NR(RTE_KNI_IOCTL_RELEASE):
650                 ret = kni_ioctl_release(net, ioctl_num, ioctl_param);
651                 break;
652         default:
653                 KNI_DBG("IOCTL default\n");
654                 break;
655         }
656
657         return ret;
658 }
659
660 static int
661 kni_compat_ioctl(struct inode *inode,
662                 unsigned int ioctl_num,
663                 unsigned long ioctl_param)
664 {
665         /* 32 bits app on 64 bits OS to be supported later */
666         KNI_PRINT("Not implemented.\n");
667
668         return -EINVAL;
669 }
670
671 module_init(kni_init);
672 module_exit(kni_exit);
673
674 module_param(lo_mode, charp, S_IRUGO | S_IWUSR);
675 MODULE_PARM_DESC(lo_mode,
676 "KNI loopback mode (default=lo_mode_none):\n"
677 "    lo_mode_none        Kernel loopback disabled\n"
678 "    lo_mode_fifo        Enable kernel loopback with fifo\n"
679 "    lo_mode_fifo_skb    Enable kernel loopback with fifo and skb buffer\n"
680 "\n"
681 );
682
683 module_param(kthread_mode, charp, S_IRUGO);
684 MODULE_PARM_DESC(kthread_mode,
685 "Kernel thread mode (default=single):\n"
686 "    single    Single kernel thread mode enabled.\n"
687 "    multiple  Multiple kernel thread mode enabled.\n"
688 "\n"
689 );