From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 9269B6CC9 for ; Thu, 15 Sep 2016 17:48:48 +0200 (CEST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 15 Sep 2016 08:48:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,339,1470726000"; d="scan'208";a="8961149" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by fmsmga006.fm.intel.com with ESMTP; 15 Sep 2016 08:48:46 -0700 From: Ferruh Yigit To: dev@dpdk.org Cc: Stephen Hemminger , Ferruh Yigit Date: Thu, 15 Sep 2016 16:46:39 +0100 Message-Id: <1473954405-7150-14-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1473954405-7150-1-git-send-email-ferruh.yigit@intel.com> References: <1473954405-7150-1-git-send-email-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 13/19] kni: update kernel logging X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2016 15:48:49 -0000 Switch to dynamic logging functions. Depending kernel configuration this may cause previously visible logs disappear. How to enable dynamic logging: https://www.kernel.org/doc/Documentation/dynamic-debug-howto.txt Signed-off-by: Ferruh Yigit --- lib/librte_eal/linuxapp/kni/kni_dev.h | 13 ++++--- lib/librte_eal/linuxapp/kni/kni_misc.c | 60 ++++++++++++++++----------------- lib/librte_eal/linuxapp/kni/kni_net.c | 34 +++++++++---------- lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 +++---- 4 files changed, 61 insertions(+), 58 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h index d30d7ab..10e760e 100644 --- a/lib/librte_eal/linuxapp/kni/kni_dev.h +++ b/lib/librte_eal/linuxapp/kni/kni_dev.h @@ -25,6 +25,11 @@ #ifndef _KNI_DEV_H_ #define _KNI_DEV_H_ +#ifdef pr_fmt +#undef pr_fmt +#endif +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -107,10 +112,8 @@ struct kni_dev { #endif }; -#define KNI_ERR(args...) printk(KERN_DEBUG "KNI: Error: " args) -#define KNI_PRINT(args...) printk(KERN_DEBUG "KNI: " args) #ifdef RTE_KNI_KO_DEBUG - #define KNI_DBG(args...) printk(KERN_DEBUG "KNI: " args) + #define KNI_DBG(args...) pr_debug(args) #else #define KNI_DBG(args...) #endif @@ -149,13 +152,13 @@ void igb_kni_remove(struct pci_dev *pdev); extern struct pci_device_id *igb_pci_tbl; #ifdef RTE_KNI_VHOST_DEBUG_RX - #define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args) + #define KNI_DBG_RX(args...) pr_debug(args) #else #define KNI_DBG_RX(args...) #endif #ifdef RTE_KNI_VHOST_DEBUG_TX - #define KNI_DBG_TX(args...) printk(KERN_DEBUG "KNI TX: " args) + #define KNI_DBG_TX(args...) pr_debug(args) #else #define KNI_DBG_TX(args...) #endif diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 6dc8f6e..1941c26 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -151,10 +151,10 @@ kni_init(void) { int rc; - KNI_PRINT("######## DPDK kni module loading ########\n"); + pr_debug("######## DPDK kni module loading ########\n"); if (kni_parse_kthread_mode() < 0) { - KNI_ERR("Invalid parameter for kthread_mode\n"); + pr_err("Invalid parameter for kthread_mode\n"); return -EINVAL; } @@ -168,14 +168,14 @@ kni_init(void) rc = misc_register(&kni_misc); if (rc != 0) { - KNI_ERR("Misc registration failed\n"); + pr_err("Misc registration failed\n"); goto out; } /* Configure the lo mode according to the input parameter */ kni_net_config_lo_mode(lo_mode); - KNI_PRINT("######## DPDK kni module loaded ########\n"); + pr_debug("######## DPDK kni module loaded ########\n"); return 0; @@ -197,7 +197,7 @@ kni_exit(void) #else unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops); #endif - KNI_PRINT("####### DPDK kni module unloaded #######\n"); + pr_debug("####### DPDK kni module unloaded #######\n"); } static int __init @@ -228,19 +228,19 @@ kni_open(struct inode *inode, struct file *file) /* Create kernel thread for single mode */ if (multiple_kthread_on == 0) { - KNI_PRINT("Single kernel thread for all KNI devices\n"); + pr_debug("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"); + pr_err("Unable to create kernel threaed\n"); return PTR_ERR(knet->kni_kthread); } } else - KNI_PRINT("Multiple kernel thread mode enabled\n"); + pr_debug("Multiple kernel thread mode enabled\n"); file->private_data = get_net(net); - KNI_PRINT("/dev/kni opened\n"); + pr_debug("/dev/kni opened\n"); return 0; } @@ -279,7 +279,7 @@ kni_release(struct inode *inode, struct file *file) clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use); put_net(net); - KNI_PRINT("/dev/kni closed\n"); + pr_debug("/dev/kni closed\n"); return 0; } @@ -367,7 +367,7 @@ kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev) /* 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); + pr_err("KNI name %s duplicated\n", dev->name); return -1; } @@ -387,7 +387,7 @@ kni_ioctl_create(struct net *net, struct net_device *lad_dev = NULL; struct kni_dev *kni, *dev, *n; - printk(KERN_INFO "KNI: Creating kni...\n"); + pr_info("Creating kni...\n"); /* Check the buffer size, to avoid warning */ if (_IOC_SIZE(ioctl_num) > sizeof(dev_info)) return -EINVAL; @@ -395,7 +395,7 @@ kni_ioctl_create(struct net *net, /* Copy kni info from user space */ ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info)); if (ret) { - KNI_ERR("copy_from_user in kni_ioctl_create"); + pr_err("copy_from_user in kni_ioctl_create"); return -EIO; } @@ -405,7 +405,7 @@ kni_ioctl_create(struct net *net, */ 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); + pr_err("cpu %u is not online\n", dev_info.core_id); return -EINVAL; } @@ -425,7 +425,7 @@ kni_ioctl_create(struct net *net, #endif kni_net_init); if (net_dev == NULL) { - KNI_ERR("error allocating device \"%s\"\n", dev_info.name); + pr_err("error allocating device \"%s\"\n", dev_info.name); return -EBUSY; } @@ -458,22 +458,22 @@ kni_ioctl_create(struct net *net, #endif kni->mbuf_size = dev_info.mbuf_size; - KNI_PRINT("tx_phys: 0x%016llx, tx_q addr: 0x%p\n", + pr_debug("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", + pr_debug("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", + pr_debug("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", + pr_debug("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", + pr_debug("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", + pr_debug("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", + pr_debug("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); + pr_debug("mbuf_va: 0x%p\n", dev_info.mbuf_va); + pr_debug("mbuf_size: %u\n", kni->mbuf_size); KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n", dev_info.bus, @@ -486,7 +486,7 @@ kni_ioctl_create(struct net *net, /* Support Ethtool */ while (pci) { - KNI_PRINT("pci_bus: %02x:%02x:%02x\n", + pr_debug("pci_bus: %02x:%02x:%02x\n", pci->bus->number, PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn)); @@ -509,7 +509,7 @@ kni_ioctl_create(struct net *net, kni->lad_dev = lad_dev; kni_set_ethtool_ops(kni->net_dev); } else { - KNI_ERR("Device not supported by ethtool"); + pr_err("Device not supported by ethtool"); kni->lad_dev = NULL; } @@ -534,7 +534,7 @@ kni_ioctl_create(struct net *net, ret = register_netdev(net_dev); if (ret) { - KNI_ERR("error %i registering device \"%s\"\n", + pr_err("error %i registering device \"%s\"\n", ret, dev_info.name); kni_dev_remove(kni); return -ENODEV; @@ -582,7 +582,7 @@ kni_ioctl_release(struct net *net, ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info)); if (ret) { - KNI_ERR("copy_from_user in kni_ioctl_release"); + pr_err("copy_from_user in kni_ioctl_release"); return -EIO; } @@ -609,7 +609,7 @@ kni_ioctl_release(struct net *net, break; } up_write(&knet->kni_list_lock); - printk(KERN_INFO "KNI: %s release kni named %s\n", + pr_info("%s release kni named %s\n", (ret == 0 ? "Successfully" : "Unsuccessfully"), dev_info.name); return ret; @@ -652,7 +652,7 @@ kni_compat_ioctl(struct inode *inode, unsigned long ioctl_param) { /* 32 bits app on 64 bits OS to be supported later */ - KNI_PRINT("Not implemented.\n"); + pr_debug("Not implemented.\n"); return -EINVAL; } diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index a6458fa..1dca5f0 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -156,7 +156,7 @@ kni_net_rx_normal(struct kni_dev *kni) skb = dev_alloc_skb(len + 2); if (!skb) { - KNI_ERR("Out of mem, dropping pkts\n"); + pr_err("Out of mem, dropping pkts\n"); /* Update statistics */ kni->stats.rx_dropped++; continue; @@ -200,7 +200,7 @@ kni_net_rx_normal(struct kni_dev *kni) ret = kni_fifo_put(kni->free_q, (void **)va, num_rx); if (ret != num_rx) /* Failing should not happen */ - KNI_ERR("Fail to enqueue entries into free_q\n"); + pr_err("Fail to enqueue entries into free_q\n"); } /* @@ -275,14 +275,14 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) ret = kni_fifo_put(kni->tx_q, (void **)alloc_va, num); if (ret != num) /* Failing should not happen */ - KNI_ERR("Fail to enqueue mbufs into tx_q\n"); + pr_err("Fail to enqueue mbufs into tx_q\n"); } /* Burst enqueue mbufs into free_q */ ret = kni_fifo_put(kni->free_q, (void **)va, num); if (ret != num) /* Failing should not happen */ - KNI_ERR("Fail to enqueue mbufs into free_q\n"); + pr_err("Fail to enqueue mbufs into free_q\n"); /** * Update statistic, and enqueue/dequeue failure is impossible, @@ -336,7 +336,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) skb = dev_alloc_skb(len + 2); if (skb == NULL) - KNI_ERR("Out of mem, dropping pkts\n"); + pr_err("Out of mem, dropping pkts\n"); else { /* Align IP on 16B boundary */ skb_reserve(skb, 2); @@ -349,7 +349,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) /* Simulate real usage, allocate/copy skb twice */ skb = dev_alloc_skb(len + 2); if (skb == NULL) { - KNI_ERR("Out of mem, dropping pkts\n"); + pr_err("Out of mem, dropping pkts\n"); kni->stats.rx_dropped++; continue; } @@ -390,7 +390,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) ret = kni_fifo_put(kni->free_q, (void **)&va, num); if (ret != num) /* Failing should not happen */ - KNI_ERR("Fail to enqueue mbufs into free_q\n"); + pr_err("Fail to enqueue mbufs into free_q\n"); } /* rx interface */ @@ -474,12 +474,12 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1); if (unlikely(ret != 1)) { /* Failing should not happen */ - KNI_ERR("Fail to enqueue mbuf into tx_q\n"); + pr_err("Fail to enqueue mbuf into tx_q\n"); goto drop; } } else { /* Failing should not happen */ - KNI_ERR("Fail to dequeue mbuf from alloc_q\n"); + pr_err("Fail to dequeue mbuf from alloc_q\n"); goto drop; } @@ -572,7 +572,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req) int ret_val; if (!kni || !req) { - KNI_ERR("No kni instance or request\n"); + pr_err("No kni instance or request\n"); return -EINVAL; } @@ -582,7 +582,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req) memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request)); num = kni_fifo_put(kni->req_q, &kni->sync_va, 1); if (num < 1) { - KNI_ERR("Cannot send to req_q\n"); + pr_err("Cannot send to req_q\n"); ret = -EBUSY; goto fail; } @@ -596,7 +596,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req) num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1); if (num != 1 || resp_va != kni->sync_va) { /* This should never happen */ - KNI_ERR("No data in resp_q\n"); + pr_err("No data in resp_q\n"); ret = -ENODATA; goto fail; } @@ -728,18 +728,18 @@ void kni_net_config_lo_mode(char *lo_str) { if (!lo_str) { - KNI_PRINT("loopback disabled"); + pr_debug("loopback disabled"); return; } if (!strcmp(lo_str, "lo_mode_none")) - KNI_PRINT("loopback disabled"); + pr_debug("loopback disabled"); else if (!strcmp(lo_str, "lo_mode_fifo")) { - KNI_PRINT("loopback mode=lo_mode_fifo enabled"); + pr_debug("loopback mode=lo_mode_fifo enabled"); kni_net_rx_func = kni_net_rx_lo_fifo; } else if (!strcmp(lo_str, "lo_mode_fifo_skb")) { - KNI_PRINT("loopback mode=lo_mode_fifo_skb enabled"); + pr_debug("loopback mode=lo_mode_fifo_skb enabled"); kni_net_rx_func = kni_net_rx_lo_fifo_skb; } else - KNI_PRINT("Incognizant parameter, loopback disabled"); + pr_debug("Incognizant parameter, loopback disabled"); } diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c index e460dd6..f4f6f10 100644 --- a/lib/librte_eal/linuxapp/kni/kni_vhost.c +++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c @@ -121,12 +121,12 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m, ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1); if (unlikely(ret != 1)) { /* Failing should not happen */ - KNI_ERR("Fail to enqueue mbuf into tx_q\n"); + pr_err("Fail to enqueue mbuf into tx_q\n"); goto drop; } } else { /* Failing should not happen */ - KNI_ERR("Fail to dequeue mbuf from alloc_q\n"); + pr_err("Fail to dequeue mbuf from alloc_q\n"); goto drop; } @@ -171,7 +171,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m, skb->data = NULL; if (unlikely(kni_fifo_put(q->fifo, (void **)&skb, 1) != 1)) /* Failing should not happen */ - KNI_ERR("Fail to enqueue entries into rx cache fifo\n"); + pr_err("Fail to enqueue entries into rx cache fifo\n"); pkt_len = kva->data_len; if (unlikely(pkt_len > len)) @@ -200,7 +200,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m, va = (void *)kva - kni->mbuf_kva + kni->mbuf_va; if (unlikely(kni_fifo_put(kni->free_q, (void **)&va, 1) != 1)) /* Failing should not happen */ - KNI_ERR("Fail to enqueue entries into free_q\n"); + pr_err("Fail to enqueue entries into free_q\n"); KNI_DBG_RX("receive done %d\n", pkt_len); @@ -340,7 +340,7 @@ kni_chk_vhost_rx(struct kni_dev *kni) except: /* Failing should not happen */ - KNI_ERR("Fail to enqueue fifo, it shouldn't happen\n"); + pr_err("Fail to enqueue fifo, it shouldn't happen\n"); BUG_ON(1); return 0; @@ -546,7 +546,7 @@ kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { /* 32 bits app on 64 bits OS to be supported later */ - KNI_PRINT("Not implemented.\n"); + pr_debug("Not implemented.\n"); return -EINVAL; } -- 2.7.4