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