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