X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Fkni%2Fkni_misc.c;h=59d15ca6eb94a22ac8c24bb0aeacb61bd9e60e5e;hb=73983b2bdae8a285c3cca3bbd18a7e965c3f1cca;hp=dca1ba56a168c5b190f5023dddbcdf3b56e03cee;hpb=f2e7592c474cf096266b02c71b292a696d19099e;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c old mode 100755 new mode 100644 index dca1ba56a1..59d15ca6eb --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -1,38 +1,43 @@ /*- * GPL LICENSE SUMMARY - * - * Copyright(c) 2010-2013 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution + * The full GNU General Public License is included in this distribution * in the file called LICENSE.GPL. - * + * * Contact Information: * Intel Corporation - * */ +#include #include #include #include +#include #include #include #include +#include +#include +#include #include + +#include "compat.h" #include "kni_dev.h" -#include MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Intel Corporation"); @@ -59,9 +64,14 @@ static int kni_ioctl(struct inode *inode, unsigned int ioctl_num, unsigned long ioctl_param); static int kni_compat_ioctl(struct inode *inode, unsigned int ioctl_num, unsigned long ioctl_param); +static int kni_dev_remove(struct kni_dev *dev); + +static int __init kni_parse_kthread_mode(void); -/* kni kernel thread for rx */ -static int kni_thread(void *unused); +/* KNI processing for single kernel thread mode */ +static int kni_thread_single(void *unused); +/* KNI processing for multiple kernel thread mode */ +static int kni_thread_multiple(void *param); static struct file_operations kni_fops = { .owner = THIS_MODULE, @@ -80,29 +90,96 @@ static struct miscdevice kni_misc = { /* loopback mode */ static char *lo_mode = NULL; +/* Kernel thread mode */ +static char *kthread_mode = NULL; +static unsigned multiple_kthread_on = 0; + #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */ -static volatile unsigned long device_in_use; /* device in use flag */ -static struct task_struct *kni_kthread; +static int kni_net_id; + +struct kni_net { + unsigned long device_in_use; /* device in use flag */ + struct task_struct *kni_kthread; + struct rw_semaphore kni_list_lock; + struct list_head kni_list_head; +}; -/* kni list lock */ -static DECLARE_RWSEM(kni_list_lock); +static int __net_init kni_init_net(struct net *net) +{ +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + struct kni_net *knet = net_generic(net, kni_net_id); +#else + struct kni_net *knet; + int ret; -/* kni list */ -static struct list_head kni_list_head = LIST_HEAD_INIT(kni_list_head); + knet = kmalloc(sizeof(struct kni_net), GFP_KERNEL); + if (!knet) { + ret = -ENOMEM; + return ret; + } +#endif + + /* Clear the bit of device in use */ + clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); + + init_rwsem(&knet->kni_list_lock); + INIT_LIST_HEAD(&knet->kni_list_head); + +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + return 0; +#else + ret = net_assign_generic(net, kni_net_id, knet); + if (ret < 0) + kfree(knet); + + return ret; +#endif +} + +static void __net_exit kni_exit_net(struct net *net) +{ +#ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS + struct kni_net *knet = net_generic(net, kni_net_id); + + kfree(knet); +#endif +} + +static struct pernet_operations kni_net_ops = { + .init = kni_init_net, + .exit = kni_exit_net, +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + .id = &kni_net_id, + .size = sizeof(struct kni_net), +#endif +}; static int __init kni_init(void) { + int rc; + KNI_PRINT("######## DPDK kni module loading ########\n"); - if (misc_register(&kni_misc) != 0) { - KNI_ERR("Misc registration failed\n"); - return 1; + if (kni_parse_kthread_mode() < 0) { + KNI_ERR("Invalid parameter for kthread_mode\n"); + return -EINVAL; } - /* Clear the bit of device in use */ - clear_bit(KNI_DEV_IN_USE_BIT_NUM, &device_in_use); +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + rc = register_pernet_subsys(&kni_net_ops); +#else + rc = register_pernet_gen_subsys(&kni_net_id, &kni_net_ops); +#endif + if (rc) + return -EPERM; + + rc = misc_register(&kni_misc); + if (rc != 0) { + KNI_ERR("Misc registration failed\n"); + goto out; + } /* Configure the lo mode according to the input parameter */ kni_net_config_lo_mode(lo_mode); @@ -110,29 +187,68 @@ kni_init(void) KNI_PRINT("######## DPDK kni module loaded ########\n"); return 0; + +out: +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + unregister_pernet_subsys(&kni_net_ops); +#else + register_pernet_gen_subsys(&kni_net_id, &kni_net_ops); +#endif + return rc; } static void __exit kni_exit(void) { misc_deregister(&kni_misc); +#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS + unregister_pernet_subsys(&kni_net_ops); +#else + register_pernet_gen_subsys(&kni_net_id, &kni_net_ops); +#endif KNI_PRINT("####### DPDK kni module unloaded #######\n"); } +static int __init +kni_parse_kthread_mode(void) +{ + if (!kthread_mode) + return 0; + + if (strcmp(kthread_mode, "single") == 0) + return 0; + else if (strcmp(kthread_mode, "multiple") == 0) + multiple_kthread_on = 1; + else + return -1; + + return 0; +} + static int kni_open(struct inode *inode, struct file *file) { - /* kni device can be opened by one user only, test and set bit */ - if (test_and_set_bit(KNI_DEV_IN_USE_BIT_NUM, &device_in_use)) + struct net *net = current->nsproxy->net_ns; + struct kni_net *knet = net_generic(net, kni_net_id); + + /* kni device can be opened by one user only per netns */ + if (test_and_set_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use)) return -EBUSY; - /* Create kernel thread for RX */ - kni_kthread = kthread_run(kni_thread, NULL, "kni_thread"); - if (IS_ERR(kni_kthread)) { - KNI_ERR("Unable to create kernel threaed\n"); - return PTR_ERR(kni_kthread); - } + /* Create kernel thread for single mode */ + if (multiple_kthread_on == 0) { + KNI_PRINT("Single kernel thread for all KNI devices\n"); + /* Create kernel thread for RX */ + knet->kni_kthread = kthread_run(kni_thread_single, (void *)knet, + "kni_single"); + if (IS_ERR(knet->kni_kthread)) { + KNI_ERR("Unable to create kernel threaed\n"); + return PTR_ERR(knet->kni_kthread); + } + } else + KNI_PRINT("Multiple kernel thread mode enabled\n"); + file->private_data = get_net(net); KNI_PRINT("/dev/kni opened\n"); return 0; @@ -141,72 +257,143 @@ kni_open(struct inode *inode, struct file *file) static int kni_release(struct inode *inode, struct file *file) { + struct net *net = file->private_data; + struct kni_net *knet = net_generic(net, kni_net_id); struct kni_dev *dev, *n; - KNI_PRINT("Stopping KNI thread..."); - - /* Stop kernel thread */ - kthread_stop(kni_kthread); - kni_kthread = NULL; + /* Stop kernel thread for single mode */ + if (multiple_kthread_on == 0) { + /* Stop kernel thread */ + kthread_stop(knet->kni_kthread); + knet->kni_kthread = NULL; + } - down_write(&kni_list_lock); - list_for_each_entry_safe(dev, n, &kni_list_head, list) { - /* Call the remove part to restore pci dev */ - switch (dev->device_id) { - #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev): - #include - igb_kni_remove(dev->pci_dev); - break; - #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) case (dev): - #include - ixgbe_kni_remove(dev->pci_dev); - break; - default: - break; + down_write(&knet->kni_list_lock); + list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { + /* Stop kernel thread for multiple mode */ + if (multiple_kthread_on && dev->pthread != NULL) { + kthread_stop(dev->pthread); + dev->pthread = NULL; } - unregister_netdev(dev->net_dev); - free_netdev(dev->net_dev); + +#ifdef RTE_KNI_VHOST + kni_vhost_backend_release(dev); +#endif + kni_dev_remove(dev); list_del(&dev->list); } - up_write(&kni_list_lock); + up_write(&knet->kni_list_lock); /* Clear the bit of device in use */ - clear_bit(KNI_DEV_IN_USE_BIT_NUM, &device_in_use); + clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); + put_net(net); KNI_PRINT("/dev/kni closed\n"); return 0; } static int -kni_thread(void *unused) +kni_thread_single(void *data) { + struct kni_net *knet = data; int j; - struct kni_dev *dev, *n; + struct kni_dev *dev; - KNI_PRINT("Kernel thread for KNI started\n"); while (!kthread_should_stop()) { - down_read(&kni_list_lock); + down_read(&knet->kni_list_lock); for (j = 0; j < KNI_RX_LOOP_NUM; j++) { - list_for_each_entry_safe(dev, n, - &kni_list_head, list) { + list_for_each_entry(dev, &knet->kni_list_head, list) { +#ifdef RTE_KNI_VHOST + kni_chk_vhost_rx(dev); +#else kni_net_rx(dev); +#endif kni_net_poll_resp(dev); } } - up_read(&kni_list_lock); + up_read(&knet->kni_list_lock); +#ifdef RTE_KNI_PREEMPT_DEFAULT /* reschedule out for a while */ schedule_timeout_interruptible(usecs_to_jiffies( \ KNI_KTHREAD_RESCHEDULE_INTERVAL)); +#endif } - KNI_PRINT("Kernel thread for KNI stopped\n"); return 0; } static int -kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) +kni_thread_multiple(void *param) { + int j; + struct kni_dev *dev = (struct kni_dev *)param; + + while (!kthread_should_stop()) { + for (j = 0; j < KNI_RX_LOOP_NUM; j++) { +#ifdef RTE_KNI_VHOST + kni_chk_vhost_rx(dev); +#else + kni_net_rx(dev); +#endif + kni_net_poll_resp(dev); + } +#ifdef RTE_KNI_PREEMPT_DEFAULT + schedule_timeout_interruptible(usecs_to_jiffies( \ + KNI_KTHREAD_RESCHEDULE_INTERVAL)); +#endif + } + + return 0; +} + +static int +kni_dev_remove(struct kni_dev *dev) +{ + if (!dev) + return -ENODEV; + + switch (dev->device_id) { + #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev): + #include + igb_kni_remove(dev->pci_dev); + break; + #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) case (dev): + #include + ixgbe_kni_remove(dev->pci_dev); + break; + default: + break; + } + + if (dev->net_dev) { + unregister_netdev(dev->net_dev); + free_netdev(dev->net_dev); + } + + return 0; +} + +static int +kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev) +{ + if (!kni || !dev) + return -1; + + /* Check if network name has been used */ + if (!strncmp(kni->name, dev->name, RTE_KNI_NAMESIZE)) { + KNI_ERR("KNI name %s duplicated\n", dev->name); + return -1; + } + + return 0; +} + +static int +kni_ioctl_create(struct net *net, + unsigned int ioctl_num, unsigned long ioctl_param) +{ + struct kni_net *knet = net_generic(net, kni_net_id); int ret; struct rte_kni_device_info dev_info; struct pci_dev *pci = NULL; @@ -227,29 +414,44 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) return -EIO; } + /** + * Check if the cpu core id is valid for binding, + * for multiple kernel thread mode. + */ + if (multiple_kthread_on && dev_info.force_bind && + !cpu_online(dev_info.core_id)) { + KNI_ERR("cpu %u is not online\n", dev_info.core_id); + return -EINVAL; + } + /* Check if it has been created */ - down_read(&kni_list_lock); - list_for_each_entry_safe(dev, n, &kni_list_head, list) { - if (dev->port_id == dev_info.port_id) { - up_read(&kni_list_lock); - KNI_ERR("Port %d has already been created\n", - dev_info.port_id); + down_read(&knet->kni_list_lock); + list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { + if (kni_check_param(dev, &dev_info) < 0) { + up_read(&knet->kni_list_lock); return -EINVAL; } } - up_read(&kni_list_lock); + up_read(&knet->kni_list_lock); net_dev = alloc_netdev(sizeof(struct kni_dev), dev_info.name, +#ifdef NET_NAME_UNKNOWN + NET_NAME_UNKNOWN, +#endif kni_net_init); if (net_dev == NULL) { KNI_ERR("error allocating device \"%s\"\n", dev_info.name); return -EBUSY; } + dev_net_set(net_dev, net); + kni = netdev_priv(net_dev); kni->net_dev = net_dev; - kni->port_id = dev_info.port_id; + kni->group_id = dev_info.group_id; + kni->core_id = dev_info.core_id; + strncpy(kni->name, dev_info.name, RTE_KNI_NAMESIZE); /* Translate user space info into kernel space info */ kni->tx_q = phys_to_virt(dev_info.tx_phys); @@ -259,53 +461,62 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) kni->req_q = phys_to_virt(dev_info.req_phys); kni->resp_q = phys_to_virt(dev_info.resp_phys); - kni->sync_va = dev_info.sync_va; kni->sync_kva = phys_to_virt(dev_info.sync_phys); kni->mbuf_kva = phys_to_virt(dev_info.mbuf_phys); kni->mbuf_va = dev_info.mbuf_va; +#ifdef RTE_KNI_VHOST + kni->vhost_queue = NULL; + kni->vq_status = BE_STOP; +#endif kni->mbuf_size = dev_info.mbuf_size; - KNI_PRINT("tx_phys: 0x%016llx, tx_q addr: 0x%p\n", - (unsigned long long) dev_info.tx_phys, kni->tx_q); - KNI_PRINT("rx_phys: 0x%016llx, rx_q addr: 0x%p\n", - (unsigned long long) dev_info.rx_phys, kni->rx_q); - KNI_PRINT("alloc_phys: 0x%016llx, alloc_q addr: 0x%p\n", - (unsigned long long) dev_info.alloc_phys, kni->alloc_q); - KNI_PRINT("free_phys: 0x%016llx, free_q addr: 0x%p\n", - (unsigned long long) dev_info.free_phys, kni->free_q); - KNI_PRINT("req_phys: 0x%016llx, req_q addr: 0x%p\n", - (unsigned long long) dev_info.req_phys, kni->req_q); - KNI_PRINT("resp_phys: 0x%016llx, resp_q addr: 0x%p\n", - (unsigned long long) dev_info.resp_phys, kni->resp_q); - KNI_PRINT("mbuf_phys: 0x%016llx, mbuf_kva: 0x%p\n", - (unsigned long long) dev_info.mbuf_phys, kni->mbuf_kva); - KNI_PRINT("mbuf_va: 0x%p\n", dev_info.mbuf_va); - KNI_PRINT("mbuf_size: %u\n", kni->mbuf_size); - - KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n", dev_info.bus, dev_info.devid, - dev_info.function, dev_info.vendor_id, dev_info.device_id); + KNI_PRINT("tx_phys: 0x%016llx, tx_q addr: 0x%p\n", + (unsigned long long) dev_info.tx_phys, kni->tx_q); + KNI_PRINT("rx_phys: 0x%016llx, rx_q addr: 0x%p\n", + (unsigned long long) dev_info.rx_phys, kni->rx_q); + KNI_PRINT("alloc_phys: 0x%016llx, alloc_q addr: 0x%p\n", + (unsigned long long) dev_info.alloc_phys, kni->alloc_q); + KNI_PRINT("free_phys: 0x%016llx, free_q addr: 0x%p\n", + (unsigned long long) dev_info.free_phys, kni->free_q); + KNI_PRINT("req_phys: 0x%016llx, req_q addr: 0x%p\n", + (unsigned long long) dev_info.req_phys, kni->req_q); + KNI_PRINT("resp_phys: 0x%016llx, resp_q addr: 0x%p\n", + (unsigned long long) dev_info.resp_phys, kni->resp_q); + KNI_PRINT("mbuf_phys: 0x%016llx, mbuf_kva: 0x%p\n", + (unsigned long long) dev_info.mbuf_phys, kni->mbuf_kva); + KNI_PRINT("mbuf_va: 0x%p\n", dev_info.mbuf_va); + KNI_PRINT("mbuf_size: %u\n", kni->mbuf_size); + + KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n", + dev_info.bus, + dev_info.devid, + dev_info.function, + dev_info.vendor_id, + dev_info.device_id); pci = pci_get_device(dev_info.vendor_id, dev_info.device_id, NULL); /* Support Ethtool */ while (pci) { - KNI_PRINT("pci_bus: %02x:%02x:%02x \n", pci->bus->number, - PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn)); + KNI_PRINT("pci_bus: %02x:%02x:%02x \n", + pci->bus->number, + PCI_SLOT(pci->devfn), + PCI_FUNC(pci->devfn)); if ((pci->bus->number == dev_info.bus) && (PCI_SLOT(pci->devfn) == dev_info.devid) && (PCI_FUNC(pci->devfn) == dev_info.function)) { found_pci = pci; - switch (dev_info.device_id) { #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev): #include ret = igb_kni_probe(found_pci, &lad_dev); break; - #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) case (dev): + #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) \ + case (dev): #include ret = ixgbe_kni_probe(found_pci, &lad_dev); break; @@ -314,12 +525,12 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) break; } - KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n", pci, lad_dev); + KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n", + pci, lad_dev); if (ret == 0) { kni->lad_dev = lad_dev; kni_set_ethtool_ops(kni->net_dev); - } - else { + } else { KNI_ERR("Device not supported by ethtool"); kni->lad_dev = NULL; } @@ -328,72 +539,100 @@ kni_ioctl_create(unsigned int ioctl_num, unsigned long ioctl_param) kni->device_id = dev_info.device_id; break; } - pci = pci_get_device(dev_info.vendor_id, dev_info.device_id, - pci); + pci = pci_get_device(dev_info.vendor_id, + dev_info.device_id, pci); } - if (pci) pci_dev_put(pci); + if (kni->lad_dev) + memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN); + else + /* + * Generate random mac address. eth_random_addr() is the newer + * version of generating mac address in linux kernel. + */ + random_ether_addr(net_dev->dev_addr); + ret = register_netdev(net_dev); if (ret) { - KNI_ERR("error %i registering device \"%s\"\n", ret, - dev_info.name); - free_netdev(net_dev); + KNI_ERR("error %i registering device \"%s\"\n", + ret, dev_info.name); + kni_dev_remove(kni); return -ENODEV; } - down_write(&kni_list_lock); - list_add(&kni->list, &kni_list_head); - up_write(&kni_list_lock); - printk(KERN_INFO "KNI: Successfully create kni for port %d\n", - dev_info.port_id); +#ifdef RTE_KNI_VHOST + kni_vhost_init(kni); +#endif + + /** + * Create a new kernel thread for multiple mode, set its core affinity, + * and finally wake it up. + */ + if (multiple_kthread_on) { + kni->pthread = kthread_create(kni_thread_multiple, + (void *)kni, + "kni_%s", kni->name); + if (IS_ERR(kni->pthread)) { + kni_dev_remove(kni); + return -ECANCELED; + } + if (dev_info.force_bind) + kthread_bind(kni->pthread, kni->core_id); + wake_up_process(kni->pthread); + } + + down_write(&knet->kni_list_lock); + list_add(&kni->list, &knet->kni_list_head); + up_write(&knet->kni_list_lock); return 0; } static int -kni_ioctl_release(unsigned int ioctl_num, unsigned long ioctl_param) +kni_ioctl_release(struct net *net, + unsigned int ioctl_num, unsigned long ioctl_param) { + struct kni_net *knet = net_generic(net, kni_net_id); int ret = -EINVAL; - uint8_t port_id; struct kni_dev *dev, *n; + struct rte_kni_device_info dev_info; - if (_IOC_SIZE(ioctl_num) > sizeof(port_id)) + if (_IOC_SIZE(ioctl_num) > sizeof(dev_info)) return -EINVAL; - ret = copy_from_user(&port_id, (void *)ioctl_param, sizeof(port_id)); + ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info)); if (ret) { KNI_ERR("copy_from_user in kni_ioctl_release"); return -EIO; } - down_write(&kni_list_lock); - list_for_each_entry_safe(dev, n, &kni_list_head, list) { - if (dev->port_id != port_id) + /* Release the network device according to its name */ + if (strlen(dev_info.name) == 0) + return ret; + + down_write(&knet->kni_list_lock); + list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { + if (strncmp(dev->name, dev_info.name, RTE_KNI_NAMESIZE) != 0) continue; - switch (dev->device_id) { - #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) case (dev): - #include - igb_kni_remove(dev->pci_dev); - break; - #define RTE_PCI_DEV_ID_DECL_IXGBE(vend, dev) case (dev): - #include - ixgbe_kni_remove(dev->pci_dev); - break; - default: - break; + if (multiple_kthread_on && dev->pthread != NULL) { + kthread_stop(dev->pthread); + dev->pthread = NULL; } - unregister_netdev(dev->net_dev); - free_netdev(dev->net_dev); + +#ifdef RTE_KNI_VHOST + kni_vhost_backend_release(dev); +#endif + kni_dev_remove(dev); list_del(&dev->list); ret = 0; break; } - up_write(&kni_list_lock); - printk(KERN_INFO "KNI: %s release kni for port %d\n", - (ret == 0 ? "Successfully" : "Unsuccessfully"), port_id); + up_write(&knet->kni_list_lock); + printk(KERN_INFO "KNI: %s release kni named %s\n", + (ret == 0 ? "Successfully" : "Unsuccessfully"), dev_info.name); return ret; } @@ -404,8 +643,9 @@ kni_ioctl(struct inode *inode, unsigned long ioctl_param) { int ret = -EINVAL; + struct net *net = current->nsproxy->net_ns; - KNI_DBG("IOCTL num=0x%0x param=0x%0lx \n", ioctl_num, ioctl_param); + KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param); /* * Switch according to the ioctl called @@ -415,13 +655,13 @@ kni_ioctl(struct inode *inode, /* For test only, not used */ break; case _IOC_NR(RTE_KNI_IOCTL_CREATE): - ret = kni_ioctl_create(ioctl_num, ioctl_param); + ret = kni_ioctl_create(net, ioctl_num, ioctl_param); break; case _IOC_NR(RTE_KNI_IOCTL_RELEASE): - ret = kni_ioctl_release(ioctl_num, ioctl_param); + ret = kni_ioctl_release(net, ioctl_num, ioctl_param); break; default: - KNI_DBG("IOCTL default \n"); + KNI_DBG("IOCTL default\n"); break; } @@ -451,3 +691,10 @@ MODULE_PARM_DESC(lo_mode, "\n" ); +module_param(kthread_mode, charp, S_IRUGO); +MODULE_PARM_DESC(kthread_mode, +"Kernel thread mode (default=single):\n" +" single Single kernel thread mode enabled.\n" +" multiple Multiple kernel thread mode enabled.\n" +"\n" +);