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