DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup
@ 2016-09-15 15:46 Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 01/19] kni: move externs to the header file Ferruh Yigit
                   ` (39 more replies)
  0 siblings, 40 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
Only functional change is related logging, switched to kernel dynamic
logging and compile time KNI debug options removed, some log message
levels updated.

Ferruh Yigit (19):
  kni: move externs to the header file
  kni: uninitialize global variables
  kni: make static struct const
  kni: whitespace, indentation, long line corrections
  kni: prefer unsigned int to unsigned
  kni: remove useless return
  kni: comparisons should place the constant on the right
  kni: trailing statements should be on next line
  kni: do not use assignment in if condition
  kni: macros with complex values should be enclosed in parentheses
  kni: prefer min_t to min
  kni: prefer ether_addr_copy to memcpy
  kni: update kernel logging
  kni: remove unnecessary 'out of memory' message
  kni: move functions to eliminate function declarations
  kni: remove compile time debug configuration
  kni: updated log messages
  kni: prefer uint32_t to unsigned int
  kni: move kernel version ifdefs to compat header

 config/common_base                        |   3 -
 lib/librte_eal/linuxapp/kni/compat.h      |  18 +-
 lib/librte_eal/linuxapp/kni/kni_dev.h     |  55 ++---
 lib/librte_eal/linuxapp/kni/kni_ethtool.c |  39 ++-
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  24 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 398 ++++++++++++++----------------
 lib/librte_eal/linuxapp/kni/kni_net.c     | 365 +++++++++++++--------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 199 +++++++--------
 8 files changed, 538 insertions(+), 563 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 01/19] kni: move externs to the header file
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 02/19] kni: uninitialize global variables Ferruh Yigit
                   ` (38 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 13 +++++++++++++
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 13 -------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 11 +----------
 3 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index a0e5cb6..48e4562 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -134,6 +134,19 @@ struct kni_vhost_queue {
 
 #endif
 
+void kni_net_rx(struct kni_dev *kni);
+void kni_net_init(struct net_device *dev);
+void kni_net_config_lo_mode(char *lo_str);
+void kni_net_poll_resp(struct kni_dev *kni);
+void kni_set_ethtool_ops(struct net_device *netdev);
+
+int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void ixgbe_kni_remove(struct pci_dev *pdev);
+extern struct pci_device_id *ixgbe_pci_tbl;
+int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+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)
 #else
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 3501dc1..a046142 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -47,19 +47,6 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 
 #define KNI_MAX_DEVICES 32
 
-extern void kni_net_rx(struct kni_dev *kni);
-extern void kni_net_init(struct net_device *dev);
-extern void kni_net_config_lo_mode(char *lo_str);
-extern void kni_net_poll_resp(struct kni_dev *kni);
-extern void kni_set_ethtool_ops(struct net_device *netdev);
-
-extern int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void ixgbe_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id ixgbe_pci_tbl[];
-extern int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void igb_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id igb_pci_tbl[];
-
 static int kni_open(struct inode *inode, struct file *file);
 static int kni_release(struct inode *inode, struct file *file);
 static int kni_ioctl(struct inode *inode, unsigned int ioctl_num,
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index a3ca849..7aed96e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/if_tun.h>
 #include <linux/version.h>
+#include <linux/file.h>
 
 #include "compat.h"
 #include "kni_dev.h"
@@ -39,17 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-extern void put_unused_fd(unsigned int fd);
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
-extern struct file*
-sock_alloc_file(struct socket *sock,
-		int flags, const char *dname);
-
-extern int get_unused_fd_flags(unsigned flags);
-
-extern void fd_install(unsigned int fd, struct file *file);
-
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 02/19] kni: uninitialize global variables
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 01/19] kni: move externs to the header file Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 03/19] kni: make static struct const Ferruh Yigit
                   ` (37 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index a046142..c8a2ef1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -77,11 +77,11 @@ static struct miscdevice kni_misc = {
 };
 
 /* loopback mode */
-static char *lo_mode = NULL;
+static char *lo_mode;
 
 /* Kernel thread mode */
-static char *kthread_mode = NULL;
-static unsigned multiple_kthread_on = 0;
+static char *kthread_mode;
+static unsigned int multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 03/19] kni: make static struct const
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 01/19] kni: move externs to the header file Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 02/19] kni: uninitialize global variables Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
                   ` (36 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index c8a2ef1..551e7de 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -62,7 +62,7 @@ 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 = {
+static const struct file_operations kni_fops = {
 	.owner = THIS_MODULE,
 	.open = kni_open,
 	.release = kni_release,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 04/19] kni: whitespace, indentation, long line corrections
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (2 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 03/19] kni: make static struct const Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
                   ` (35 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h     | 11 +++---
 lib/librte_eal/linuxapp/kni/kni_ethtool.c | 39 +++++++++++++++-----
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  2 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 18 +++++-----
 lib/librte_eal/linuxapp/kni/kni_net.c     | 17 +++++----
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 60 ++++++++++++++++---------------
 6 files changed, 88 insertions(+), 59 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 48e4562..059defc 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -84,7 +84,7 @@ struct kni_dev {
 	/* response queue */
 	void *resp_q;
 
-	void * sync_kva;
+	void *sync_kva;
 	void *sync_va;
 
 	void *mbuf_kva;
@@ -97,12 +97,13 @@ struct kni_dev {
 	unsigned long synchro;
 
 #ifdef RTE_KNI_VHOST
-	struct kni_vhost_queue* vhost_queue;
+	struct kni_vhost_queue *vhost_queue;
+
 	volatile enum {
 		BE_STOP = 0x1,
 		BE_START = 0x2,
 		BE_FINISH = 0x4,
-	}vq_status;
+	} vq_status;
 #endif
 };
 
@@ -128,8 +129,8 @@ struct kni_vhost_queue {
 	struct kni_dev *kni;
 	int sockfd;
 	unsigned int flags;
-	struct sk_buff* cache;
-	struct rte_kni_fifo* fifo;
+	struct sk_buff *cache;
+	struct rte_kni_fifo *fifo;
 };
 
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_ethtool.c b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
index 06b6d46..0c88589 100644
--- a/lib/librte_eal/linuxapp/kni/kni_ethtool.c
+++ b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
@@ -31,6 +31,7 @@ static int
 kni_check_if_running(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	if (priv->lad_dev)
 		return 0;
 	else
@@ -41,6 +42,7 @@ static void
 kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
 }
 
@@ -48,6 +50,7 @@ static int
 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
 }
 
@@ -55,6 +58,7 @@ static int
 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
 }
 
@@ -62,6 +66,7 @@ static void
 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
 }
 
@@ -69,6 +74,7 @@ static int
 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
 }
 
@@ -76,6 +82,7 @@ static int
 kni_nway_reset(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
 }
 
@@ -83,6 +90,7 @@ static int
 kni_get_eeprom_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
 }
 
@@ -91,6 +99,7 @@ kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -100,6 +109,7 @@ kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -108,6 +118,7 @@ static void
 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
 }
 
@@ -115,6 +126,7 @@ static int
 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
 }
 
@@ -122,6 +134,7 @@ static void
 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
 }
 
@@ -129,6 +142,7 @@ static int
 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
 								pause);
 }
@@ -137,6 +151,7 @@ static u32
 kni_get_msglevel(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
 }
 
@@ -144,6 +159,7 @@ static void
 kni_set_msglevel(struct net_device *dev, u32 data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
 }
 
@@ -151,6 +167,7 @@ static int
 kni_get_regs_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
 }
 
@@ -158,6 +175,7 @@ static void
 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
 }
 
@@ -165,6 +183,7 @@ static void
 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
 								data);
 }
@@ -173,6 +192,7 @@ static int
 kni_get_sset_count(struct net_device *dev, int sset)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
 }
 
@@ -181,24 +201,25 @@ kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
 								u64 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
 								data);
 }
 
 struct ethtool_ops kni_ethtool_ops = {
-	.begin 				= kni_check_if_running,
+	.begin			= kni_check_if_running,
 	.get_drvinfo		= kni_get_drvinfo,
 	.get_settings		= kni_get_settings,
 	.set_settings		= kni_set_settings,
 	.get_regs_len		= kni_get_regs_len,
-	.get_regs			= kni_get_regs,
-	.get_wol			= kni_get_wol,
-	.set_wol			= kni_set_wol,
-	.nway_reset			= kni_nway_reset,
-	.get_link			= ethtool_op_get_link,
+	.get_regs		= kni_get_regs,
+	.get_wol		= kni_get_wol,
+	.set_wol		= kni_set_wol,
+	.nway_reset		= kni_nway_reset,
+	.get_link		= ethtool_op_get_link,
 	.get_eeprom_len		= kni_get_eeprom_len,
-	.get_eeprom			= kni_get_eeprom,
-	.set_eeprom			= kni_set_eeprom,
+	.get_eeprom		= kni_get_eeprom,
+	.set_eeprom		= kni_set_eeprom,
 	.get_ringparam		= kni_get_ringparam,
 	.set_ringparam		= kni_set_ringparam,
 	.get_pauseparam		= kni_get_pauseparam,
@@ -207,7 +228,7 @@ struct ethtool_ops kni_ethtool_ops = {
 	.set_msglevel		= kni_set_msglevel,
 	.get_strings		= kni_get_strings,
 	.get_sset_count		= kni_get_sset_count,
-	.get_ethtool_stats  = kni_get_ethtool_stats,
+	.get_ethtool_stats	= kni_get_ethtool_stats,
 };
 
 void
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 3ea750e..4006b1f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -79,7 +79,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
 static inline unsigned
 kni_fifo_count(struct rte_kni_fifo *fifo)
 {
-	return (fifo->len + fifo->write - fifo->read) & ( fifo->len - 1);
+	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
 }
 
 /**
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 551e7de..0cbc499 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -94,7 +94,8 @@ struct kni_net {
 	struct list_head kni_list_head;
 };
 
-static int __net_init kni_init_net(struct net *net)
+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);
@@ -126,7 +127,8 @@ static int __net_init kni_init_net(struct net *net)
 #endif
 }
 
-static void __net_exit kni_exit_net(struct net *net)
+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);
@@ -304,8 +306,8 @@ kni_thread_single(void *data)
 		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));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -328,8 +330,8 @@ kni_thread_multiple(void *param)
 			kni_net_poll_resp(dev);
 		}
 #ifdef RTE_KNI_PREEMPT_DEFAULT
-		schedule_timeout_interruptible(usecs_to_jiffies( \
-				KNI_KTHREAD_RESCHEDULE_INTERVAL));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -484,7 +486,7 @@ kni_ioctl_create(struct net *net,
 
 	/* Support Ethtool */
 	while (pci) {
-		KNI_PRINT("pci_bus: %02x:%02x:%02x \n",
+		KNI_PRINT("pci_bus: %02x:%02x:%02x\n",
 					pci->bus->number,
 					PCI_SLOT(pci->devfn),
 					PCI_FUNC(pci->devfn));
@@ -576,7 +578,7 @@ kni_ioctl_release(struct net *net,
 	struct rte_kni_device_info dev_info;
 
 	if (_IOC_SIZE(ioctl_num) > sizeof(dev_info))
-			return -EINVAL;
+		return -EINVAL;
 
 	ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info));
 	if (ret) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index fc82193..aa17f2c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -126,7 +126,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	unsigned i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
@@ -214,7 +214,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct rte_kni_mbuf *alloc_kva;
 	struct rte_kni_mbuf *alloc_va[MBUF_BURST_SZ];
@@ -303,7 +303,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 	unsigned i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
@@ -503,7 +503,7 @@ drop:
  * Deal with a transmit timeout.
  */
 static void
-kni_net_tx_timeout (struct net_device *dev)
+kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
@@ -617,6 +617,7 @@ static struct net_device_stats *
 kni_net_stats(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
+
 	return &kni->stats;
 }
 
@@ -637,7 +638,6 @@ kni_net_header(struct sk_buff *skb, struct net_device *dev,
 	return dev->hard_header_len;
 }
 
-
 /*
  * Re-fill the eth header
  */
@@ -662,9 +662,11 @@ kni_net_rebuild_header(struct sk_buff *skb)
  *
  * Returns 0 on success, negative on failure
  **/
-static int kni_net_set_mac(struct net_device *netdev, void *p)
+static int
+kni_net_set_mac(struct net_device *netdev, void *p)
 {
 	struct sockaddr *addr = p;
+
 	if (!is_valid_ether_addr((unsigned char *)(addr->sa_data)))
 		return -EADDRNOTAVAIL;
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
@@ -672,7 +674,8 @@ static int kni_net_set_mac(struct net_device *netdev, void *p)
 }
 
 #ifdef HAVE_CHANGE_CARRIER_CB
-static int kni_net_change_carrier(struct net_device *dev, bool new_carrier)
+static int
+kni_net_change_carrier(struct net_device *dev, bool new_carrier)
 {
 	if (new_carrier)
 		netif_carrier_on(dev);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 7aed96e..b4d91ca 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,11 +40,12 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
 	int fd = get_unused_fd_flags(0);
+
 	if (fd < 0)
 		return fd;
 
@@ -101,7 +102,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 
 		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
 		data_kva = pkt_kva->buf_addr + pkt_kva->data_off
-		           - kni->mbuf_va + kni->mbuf_kva;
+			- kni->mbuf_va + kni->mbuf_kva;
 
 #ifdef HAVE_IOV_ITER_MSGHDR
 		copy_from_iter(data_kva, len, &m->msg_iter);
@@ -149,7 +150,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va;
-	void * data_kva;
+	void *data_kva;
 	struct sk_buff *skb;
 	struct kni_vhost_queue *q = kni->vhost_queue;
 
@@ -164,7 +165,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(skb == NULL))
 		return 0;
 
-	kva = (struct rte_kni_mbuf*)skb->data;
+	kva = (struct rte_kni_mbuf *)skb->data;
 
 	/* free skb to cache */
 	skb->data = NULL;
@@ -213,7 +214,7 @@ drop:
 }
 
 static unsigned int
-kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
+kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
@@ -224,7 +225,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
@@ -232,7 +233,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	poll_wait(file, &sock->wq->wait, wait);
 #else
 	poll_wait(file, &sock->wait, wait);
@@ -260,7 +261,7 @@ kni_vhost_enqueue(struct kni_dev *kni, struct kni_vhost_queue *q,
 	struct rte_kni_mbuf *kva;
 
 	kva = (void *)(va) - kni->mbuf_va + kni->mbuf_kva;
-	(skb)->data = (unsigned char*)kva;
+	(skb)->data = (unsigned char *)kva;
 	(skb)->len = kva->data_len;
 	skb_queue_tail(&q->sk.sk_receive_queue, skb);
 }
@@ -270,6 +271,7 @@ kni_vhost_enqueue_burst(struct kni_dev *kni, struct kni_vhost_queue *q,
 	  struct sk_buff **skb, struct rte_kni_mbuf **va)
 {
 	int i;
+
 	for (i = 0; i < RX_BURST_SZ; skb++, va++, i++)
 		kni_vhost_enqueue(kni, q, *skb, *va);
 }
@@ -341,7 +343,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");
+	KNI_ERR("Fail to enqueue fifo, it shouldn't happen\n");
 	BUG_ON(1);
 
 	return 0;
@@ -482,8 +484,8 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 			return -ENOLINK;
 
 		ret = 0;
-		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ) ||
-		    put_user(q->flags, &ifr->ifr_flags))
+		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ)
+				|| put_user(q->flags, &ifr->ifr_flags))
 			ret = -EFAULT;
 		dev_put(kni->net_dev);
 		return ret;
@@ -552,10 +554,10 @@ kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 #define KNI_VHOST_WAIT_WQ_SAFE()                        \
-do {		                                	\
+do {							\
 	while ((BE_FINISH | BE_STOP) == kni->vq_status) \
-		msleep(1);                              \
-}while(0)                                               \
+		msleep(1);				\
+} while (0)						\
 
 
 static int
@@ -589,12 +591,11 @@ kni_sock_release(struct socket *sock)
 }
 
 int
-kni_sock_getname (struct socket *sock,
-		  struct sockaddr *addr,
-		  int *sockaddr_len, int peer)
+kni_sock_getname(struct socket *sock, struct sockaddr *addr,
+		int *sockaddr_len, int peer)
 {
 	KNI_DBG("dummy sock getname\n");
-	((struct sockaddr_ll*)addr)->sll_family = AF_PACKET;
+	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
 
@@ -637,7 +638,7 @@ kni_sk_destruct(struct sock *sk)
 
 	/* make sure there's no packet in buffer */
 	while (skb_dequeue(&sk->sk_receive_queue) != NULL)
-	       ;
+		;
 
 	mb();
 
@@ -685,8 +686,9 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	}
 
 	/* cache init */
-	q->cache = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
-			   GFP_KERNEL);
+	q->cache = kzalloc(
+		RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
+		GFP_KERNEL);
 	if (!q->cache)
 		goto free_fd;
 
@@ -699,7 +701,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	for (i = 0; i < RTE_KNI_VHOST_MAX_CACHE_SIZE; i++) {
 		elem = &q->cache[i];
-		kni_fifo_put(fifo, (void**)&elem, 1);
+		kni_fifo_put(fifo, (void **)&elem, 1);
 	}
 	q->fifo = fifo;
 
@@ -729,14 +731,12 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,"
-		  "sk->sk_wq=0x%16llx",
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,"
-		  "sk->sk_sleep=0x%16llx",
+	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -759,7 +759,7 @@ free_sock:
 	q->sock = NULL;
 
 free_sk:
-	sk_free((struct sock*)q);
+	sk_free((struct sock *)q);
 
 	return err;
 }
@@ -772,6 +772,7 @@ show_sock_fd(struct device *dev, struct device_attribute *attr,
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
 	int sockfd = -1;
+
 	if (kni->vhost_queue != NULL)
 		sockfd = kni->vhost_queue->sockfd;
 	return snprintf(buf, 10, "%d\n", sockfd);
@@ -783,6 +784,7 @@ show_sock_en(struct device *dev, struct device_attribute *attr,
 {
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
+
 	return snprintf(buf, 10, "%u\n", (kni->vhost_queue == NULL ? 0 : 1));
 }
 
@@ -809,7 +811,7 @@ static DEVICE_ATTR(sock_en, S_IRUGO | S_IWUSR, show_sock_en, set_sock_en);
 static struct attribute *dev_attrs[] = {
 	&dev_attr_sock_fd.attr,
 	&dev_attr_sock_en.attr,
-        NULL,
+	NULL,
 };
 
 static const struct attribute_group dev_attr_grp = {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 05/19] kni: prefer unsigned int to unsigned
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (3 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 06/19] kni: remove useless return Ferruh Yigit
                   ` (34 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  4 ++--
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 ++++++------
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 059defc..d30d7ab 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -50,7 +50,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned core_id;            /* Core ID to bind */
+	unsigned int core_id;        /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -91,7 +91,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned mbuf_size;
+	unsigned int mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 4006b1f..71bc2a9 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned fifo_write = fifo->write;
-	unsigned fifo_read = fifo->read;
-	unsigned new_write = fifo_write;
+	unsigned int i = 0;
+	unsigned int fifo_write = fifo->write;
+	unsigned int fifo_read = fifo->read;
+	unsigned int new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned new_read = fifo->read;
-	unsigned fifo_write = fifo->write;
+	unsigned int i = 0;
+	unsigned int new_read = fifo->read;
+	unsigned int fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned
+static inline unsigned int
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
+kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index aa17f2c..f4afd83 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -121,9 +121,9 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rx, num_fq;
+	unsigned int i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
+	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -209,9 +209,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
+	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -298,9 +298,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rq, num_fq, num;
+	unsigned int i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -316,7 +316,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -423,7 +423,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned ret;
+	unsigned int ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -569,7 +569,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned num;
+	unsigned int num;
 	int ret_val;
 
 	if (!kni || !req) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index b4d91ca..f1345c3 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -280,9 +280,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned nb_in, nb_mbuf, nb_skb;
-	const unsigned BURST_MASK = RX_BURST_SZ - 1;
-	unsigned nb_burst, nb_backlog, i;
+	unsigned int nb_in, nb_mbuf, nb_skb;
+	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
+	unsigned int nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -298,7 +298,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned)RX_BURST_SZ);
+	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 06/19] kni: remove useless return
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (4 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
                   ` (33 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index f4afd83..81d139e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -512,7 +512,6 @@ kni_net_tx_timeout(struct net_device *dev)
 
 	kni->stats.tx_errors++;
 	netif_wake_queue(dev);
-	return;
 }
 
 /*
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 07/19] kni: comparisons should place the constant on the right
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (5 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 06/19] kni: remove useless return Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 08/19] kni: trailing statements should be on next line Ferruh Yigit
                   ` (32 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f1345c3..ec39538 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -169,7 +169,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 
 	/* free skb to cache */
 	skb->data = NULL;
-	if (unlikely(1 != kni_fifo_put(q->fifo, (void **)&skb, 1)))
+	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");
 
@@ -197,8 +197,8 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	kni->stats.rx_packets++;
 
 	/* enqueue mbufs into free_q */
-	va = (void*)kva - kni->mbuf_kva + kni->mbuf_va;
-	if (unlikely(1 != kni_fifo_put(kni->free_q, (void **)&va, 1)))
+	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");
 
@@ -303,15 +303,13 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_backlog = (nb_in & BURST_MASK);
 
 	/* enqueue skb_queue per BURST_SIZE bulk */
-	if (0 != nb_burst) {
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     kni->rx_q, (void **)&va,
-				     RX_BURST_SZ)))
+	if (nb_burst != 0) {
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     q->fifo, (void **)&skb,
-				     RX_BURST_SZ)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
 		kni_vhost_enqueue_burst(kni, q, skb, va);
@@ -319,12 +317,10 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 
 	/* all leftover, do one by one */
 	for (i = 0; i < nb_backlog; ++i) {
-		if (unlikely(1 != kni_fifo_get(
-				     kni->rx_q,(void **)&va, 1)))
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, 1) != 1))
 			goto except;
 
-		if (unlikely(1 != kni_fifo_get(
-				     q->fifo, (void **)&skb, 1)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, 1) != 1))
 			goto except;
 
 		kni_vhost_enqueue(kni, q, *skb, *va);
@@ -797,7 +793,7 @@ set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != kstrtoul(buf, 0, &en))
+	if (kstrtoul(buf, 0, &en) != 0)
 		return -EINVAL;
 
 	if (en)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 08/19] kni: trailing statements should be on next line
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (6 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 09/19] kni: do not use assignment in if condition Ferruh Yigit
                   ` (31 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index ec39538..bef4889 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -244,11 +244,12 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	if (sock_writeable(&q->sk) ||
 #ifdef SOCKWQ_ASYNC_NOSPACE
-	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #else
-	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #endif
-	     sock_writeable(&q->sk)))
 		mask |= POLLOUT | POLLWRNORM;
 
 	return mask;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 09/19] kni: do not use assignment in if condition
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (7 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 08/19] kni: trailing statements should be on next line Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
                   ` (30 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index bef4889..eacfe3f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -410,13 +410,14 @@ kni_sock_rcvmsg(struct socket *sock,
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 	if (likely(q->flags & IFF_VNET_HDR)) {
 		vnet_hdr_len = q->vnet_hdr_sz;
-		if ((len -= vnet_hdr_len) < 0)
+		len -= vnet_hdr_len;
+		if (len < 0)
 			return -EINVAL;
 	}
 #endif
 
-	if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni,
-		m, vnet_hdr_len, len))))
+	pkt_len = kni_vhost_net_rx(q->kni, m, vnet_hdr_len, len);
+	if (unlikely(pkt_len == 0))
 		return 0;
 
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
@@ -567,7 +568,8 @@ kni_sock_release(struct socket *sock)
 	if (q == NULL)
 		return 0;
 
-	if (NULL != (kni = q->kni)) {
+	kni = q->kni;
+	if (kni != NULL) {
 		kni->vq_status = BE_STOP;
 		KNI_VHOST_WAIT_WQ_SAFE();
 		kni->vhost_queue = NULL;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 10/19] kni: macros with complex values should be enclosed in parentheses
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (8 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 09/19] kni: do not use assignment in if condition Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 11/19] kni: prefer min_t to min Ferruh Yigit
                   ` (29 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 962a4e7..d79d626 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -19,7 +19,7 @@
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
-#define sk_sleep(s) (s)->sk_sleep
+#define sk_sleep(s) ((s)->sk_sleep)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 11/19] kni: prefer min_t to min
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (9 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
                   ` (28 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c   | 6 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 81d139e..a6458fa 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
+	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -316,7 +316,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index eacfe3f..e460dd6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
+	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 12/19] kni: prefer ether_addr_copy to memcpy
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (10 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 11/19] kni: prefer min_t to min Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 13/19] kni: update kernel logging Ferruh Yigit
                   ` (27 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h   | 4 ++++
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index d79d626..9ae50a7 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -26,6 +26,10 @@
 #define HAVE_CHANGE_CARRIER_CB
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+#define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
 #define HAVE_IOV_ITER_MSGHDR
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 0cbc499..6dc8f6e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -524,7 +524,7 @@ kni_ioctl_create(struct net *net,
 		pci_dev_put(pci);
 
 	if (kni->lad_dev)
-		memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
+		ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr);
 	else
 		/*
 		 * Generate random mac address. eth_random_addr() is the newer
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 13/19] kni: update kernel logging
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (11 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
                   ` (26 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

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 <ferruh.yigit@intel.com>
---
 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 <linux/if.h>
 #include <linux/wait.h>
 #include <linux/sched.h>
@@ -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

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 14/19] kni: remove unnecessary 'out of memory' message
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (12 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 13/19] kni: update kernel logging Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
                   ` (25 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 1dca5f0..9585879 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -156,7 +156,6 @@ kni_net_rx_normal(struct kni_dev *kni)
 
 		skb = dev_alloc_skb(len + 2);
 		if (!skb) {
-			pr_err("Out of mem, dropping pkts\n");
 			/* Update statistics */
 			kni->stats.rx_dropped++;
 			continue;
@@ -335,9 +334,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 				kni->mbuf_kva;
 
 		skb = dev_alloc_skb(len + 2);
-		if (skb == NULL)
-			pr_err("Out of mem, dropping pkts\n");
-		else {
+		if (skb) {
 			/* Align IP on 16B boundary */
 			skb_reserve(skb, 2);
 			memcpy(skb_put(skb, len), data_kva, len);
@@ -349,7 +346,6 @@ 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) {
-			pr_err("Out of mem, dropping pkts\n");
 			kni->stats.rx_dropped++;
 			continue;
 		}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 15/19] kni: move functions to eliminate function declarations
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (13 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 16/19] kni: remove compile time debug configuration Ferruh Yigit
                   ` (24 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Function implementations kept same.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 301 ++++++++++++++++-----------------
 lib/librte_eal/linuxapp/kni/kni_net.c  | 293 ++++++++++++++++----------------
 2 files changed, 287 insertions(+), 307 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 1941c26..64e20c1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -47,35 +47,6 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 
 #define KNI_MAX_DEVICES 32
 
-static int kni_open(struct inode *inode, struct file *file);
-static int kni_release(struct inode *inode, struct file *file);
-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 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 const struct file_operations kni_fops = {
-	.owner = THIS_MODULE,
-	.open = kni_open,
-	.release = kni_release,
-	.unlocked_ioctl = (void *)kni_ioctl,
-	.compat_ioctl = (void *)kni_compat_ioctl,
-};
-
-static struct miscdevice kni_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = KNI_DEVICE,
-	.fops = &kni_fops,
-};
-
 /* loopback mode */
 static char *lo_mode;
 
@@ -146,72 +117,56 @@ static struct pernet_operations kni_net_ops = {
 #endif
 };
 
-static int __init
-kni_init(void)
+static int
+kni_thread_single(void *data)
 {
-	int rc;
-
-	pr_debug("######## DPDK kni module loading ########\n");
-
-	if (kni_parse_kthread_mode() < 0) {
-		pr_err("Invalid parameter for kthread_mode\n");
-		return -EINVAL;
-	}
+	struct kni_net *knet = data;
+	int j;
+	struct kni_dev *dev;
 
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	rc = register_pernet_subsys(&kni_net_ops);
+	while (!kthread_should_stop()) {
+		down_read(&knet->kni_list_lock);
+		for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
+			list_for_each_entry(dev, &knet->kni_list_head, list) {
+#ifdef RTE_KNI_VHOST
+				kni_chk_vhost_rx(dev);
 #else
-	rc = register_pernet_gen_subsys(&kni_net_id, &kni_net_ops);
+				kni_net_rx(dev);
+#endif
+				kni_net_poll_resp(dev);
+			}
+		}
+		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
-	if (rc)
-		return -EPERM;
-
-	rc = misc_register(&kni_misc);
-	if (rc != 0) {
-		pr_err("Misc registration failed\n");
-		goto out;
 	}
 
-	/* Configure the lo mode according to the input parameter */
-	kni_net_config_lo_mode(lo_mode);
-
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
 	return 0;
-
-out:
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	unregister_pernet_subsys(&kni_net_ops);
-#else
-	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
-#endif
-	return rc;
 }
 
-static void __exit
-kni_exit(void)
+static int
+kni_thread_multiple(void *param)
 {
-	misc_deregister(&kni_misc);
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	unregister_pernet_subsys(&kni_net_ops);
+	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
-	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
+			kni_net_rx(dev);
 #endif
-	pr_debug("####### 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;
+			kni_net_poll_resp(dev);
+		}
+#ifdef RTE_KNI_PREEMPT_DEFAULT
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
+#endif
+	}
 
 	return 0;
 }
@@ -246,6 +201,27 @@ kni_open(struct inode *inode, struct file *file)
 }
 
 static int
+kni_dev_remove(struct kni_dev *dev)
+{
+	if (!dev)
+		return -ENODEV;
+
+	if (dev->pci_dev) {
+		if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
+			ixgbe_kni_remove(dev->pci_dev);
+		else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
+			igb_kni_remove(dev->pci_dev);
+	}
+
+	if (dev->net_dev) {
+		unregister_netdev(dev->net_dev);
+		free_netdev(dev->net_dev);
+	}
+
+	return 0;
+}
+
+static int
 kni_release(struct inode *inode, struct file *file)
 {
 	struct net *net = file->private_data;
@@ -285,81 +261,6 @@ kni_release(struct inode *inode, struct file *file)
 }
 
 static int
-kni_thread_single(void *data)
-{
-	struct kni_net *knet = data;
-	int j;
-	struct kni_dev *dev;
-
-	while (!kthread_should_stop()) {
-		down_read(&knet->kni_list_lock);
-		for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
-			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(&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
-	}
-
-	return 0;
-}
-
-static int
-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;
-
-	if (dev->pci_dev) {
-		if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
-			ixgbe_kni_remove(dev->pci_dev);
-		else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
-			igb_kni_remove(dev->pci_dev);
-	}
-
-	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)
@@ -657,6 +558,90 @@ kni_compat_ioctl(struct inode *inode,
 	return -EINVAL;
 }
 
+static const struct file_operations kni_fops = {
+	.owner = THIS_MODULE,
+	.open = kni_open,
+	.release = kni_release,
+	.unlocked_ioctl = (void *)kni_ioctl,
+	.compat_ioctl = (void *)kni_compat_ioctl,
+};
+
+static struct miscdevice kni_misc = {
+	.minor = MISC_DYNAMIC_MINOR,
+	.name = KNI_DEVICE,
+	.fops = &kni_fops,
+};
+
+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 __init
+kni_init(void)
+{
+	int rc;
+
+	pr_debug("######## DPDK kni module loading ########\n");
+
+	if (kni_parse_kthread_mode() < 0) {
+		pr_err("Invalid parameter for kthread_mode\n");
+		return -EINVAL;
+	}
+
+#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) {
+		pr_err("Misc registration failed\n");
+		goto out;
+	}
+
+	/* Configure the lo mode according to the input parameter */
+	kni_net_config_lo_mode(lo_mode);
+
+	pr_debug("######## DPDK kni module loaded  ########\n");
+
+	return 0;
+
+out:
+#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
+	unregister_pernet_subsys(&kni_net_ops);
+#else
+	unregister_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
+	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
+#endif
+	pr_debug("####### DPDK kni module unloaded  #######\n");
+}
+
 module_init(kni_init);
 module_exit(kni_exit);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 9585879..a732cbd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -51,17 +51,61 @@
 /* typedef for rx function */
 typedef void (*kni_net_rx_t)(struct kni_dev *kni);
 
-static int kni_net_tx(struct sk_buff *skb, struct net_device *dev);
 static void kni_net_rx_normal(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo_skb(struct kni_dev *kni);
-static int kni_net_process_request(struct kni_dev *kni,
-			struct rte_kni_request *req);
 
 /* kni rx function pointer, with default to normal rx */
 static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal;
 
 /*
+ * It can be called to process the request.
+ */
+static int
+kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
+{
+	int ret = -1;
+	void *resp_va;
+	unsigned int num;
+	int ret_val;
+
+	if (!kni || !req) {
+		pr_err("No kni instance or request\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&kni->sync_lock);
+
+	/* Construct data */
+	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
+	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
+	if (num < 1) {
+		pr_err("Cannot send to req_q\n");
+		ret = -EBUSY;
+		goto fail;
+	}
+
+	ret_val = wait_event_interruptible_timeout(kni->wq,
+			kni_fifo_count(kni->resp_q), 3 * HZ);
+	if (signal_pending(current) || ret_val <= 0) {
+		ret = -ETIME;
+		goto fail;
+	}
+	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
+	if (num != 1 || resp_va != kni->sync_va) {
+		/* This should never happen */
+		pr_err("No data in resp_q\n");
+		ret = -ENODATA;
+		goto fail;
+	}
+
+	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
+	ret = 0;
+
+fail:
+	mutex_unlock(&kni->sync_lock);
+	return ret;
+}
+
+/*
  * Open and close
  */
 static int
@@ -116,6 +160,101 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 }
 
 /*
+ * Transmit a packet (called by the kernel)
+ */
+#ifdef RTE_KNI_VHOST
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	struct kni_dev *kni = netdev_priv(dev);
+
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#else
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	int len = 0;
+	unsigned int ret;
+	struct kni_dev *kni = netdev_priv(dev);
+	struct rte_kni_mbuf *pkt_kva = NULL;
+	struct rte_kni_mbuf *pkt_va = NULL;
+
+	/* save the timestamp */
+#ifdef HAVE_TRANS_START_HELPER
+	netif_trans_update(dev);
+#else
+	dev->trans_start = jiffies;
+#endif
+
+	/* Check if the length of skb is less than mbuf size */
+	if (skb->len > kni->mbuf_size)
+		goto drop;
+
+	/**
+	 * Check if it has at least one free entry in tx_q and
+	 * one entry in alloc_q.
+	 */
+	if (kni_fifo_free_count(kni->tx_q) == 0 ||
+			kni_fifo_count(kni->alloc_q) == 0) {
+		/**
+		 * If no free entry in tx_q or no entry in alloc_q,
+		 * drops skb and goes out.
+		 */
+		goto drop;
+	}
+
+	/* dequeue a mbuf from alloc_q */
+	ret = kni_fifo_get(kni->alloc_q, (void **)&pkt_va, 1);
+	if (likely(ret == 1)) {
+		void *data_kva;
+
+		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
+		data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va
+				+ kni->mbuf_kva;
+
+		len = skb->len;
+		memcpy(data_kva, skb->data, len);
+		if (unlikely(len < ETH_ZLEN)) {
+			memset(data_kva + len, 0, ETH_ZLEN - len);
+			len = ETH_ZLEN;
+		}
+		pkt_kva->pkt_len = len;
+		pkt_kva->data_len = len;
+
+		/* enqueue mbuf into tx_q */
+		ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1);
+		if (unlikely(ret != 1)) {
+			/* Failing should not happen */
+			pr_err("Fail to enqueue mbuf into tx_q\n");
+			goto drop;
+		}
+	} else {
+		/* Failing should not happen */
+		pr_err("Fail to dequeue mbuf from alloc_q\n");
+		goto drop;
+	}
+
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_bytes += len;
+	kni->stats.tx_packets++;
+
+	return NETDEV_TX_OK;
+
+drop:
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#endif
+
+/*
  * RX: normal working mode
  */
 static void
@@ -401,101 +540,6 @@ kni_net_rx(struct kni_dev *kni)
 }
 
 /*
- * Transmit a packet (called by the kernel)
- */
-#ifdef RTE_KNI_VHOST
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	struct kni_dev *kni = netdev_priv(dev);
-
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#else
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	int len = 0;
-	unsigned int ret;
-	struct kni_dev *kni = netdev_priv(dev);
-	struct rte_kni_mbuf *pkt_kva = NULL;
-	struct rte_kni_mbuf *pkt_va = NULL;
-
-	/* save the timestamp */
-#ifdef HAVE_TRANS_START_HELPER
-	netif_trans_update(dev);
-#else
-	dev->trans_start = jiffies;
-#endif
-
-	/* Check if the length of skb is less than mbuf size */
-	if (skb->len > kni->mbuf_size)
-		goto drop;
-
-	/**
-	 * Check if it has at least one free entry in tx_q and
-	 * one entry in alloc_q.
-	 */
-	if (kni_fifo_free_count(kni->tx_q) == 0 ||
-			kni_fifo_count(kni->alloc_q) == 0) {
-		/**
-		 * If no free entry in tx_q or no entry in alloc_q,
-		 * drops skb and goes out.
-		 */
-		goto drop;
-	}
-
-	/* dequeue a mbuf from alloc_q */
-	ret = kni_fifo_get(kni->alloc_q, (void **)&pkt_va, 1);
-	if (likely(ret == 1)) {
-		void *data_kva;
-
-		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
-		data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va
-				+ kni->mbuf_kva;
-
-		len = skb->len;
-		memcpy(data_kva, skb->data, len);
-		if (unlikely(len < ETH_ZLEN)) {
-			memset(data_kva + len, 0, ETH_ZLEN - len);
-			len = ETH_ZLEN;
-		}
-		pkt_kva->pkt_len = len;
-		pkt_kva->data_len = len;
-
-		/* enqueue mbuf into tx_q */
-		ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1);
-		if (unlikely(ret != 1)) {
-			/* Failing should not happen */
-			pr_err("Fail to enqueue mbuf into tx_q\n");
-			goto drop;
-		}
-	} else {
-		/* Failing should not happen */
-		pr_err("Fail to dequeue mbuf from alloc_q\n");
-		goto drop;
-	}
-
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_bytes += len;
-	kni->stats.tx_packets++;
-
-	return NETDEV_TX_OK;
-
-drop:
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#endif
-
-/*
  * Deal with a transmit timeout.
  */
 static void
@@ -557,55 +601,6 @@ kni_net_poll_resp(struct kni_dev *kni)
 }
 
 /*
- * It can be called to process the request.
- */
-static int
-kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
-{
-	int ret = -1;
-	void *resp_va;
-	unsigned int num;
-	int ret_val;
-
-	if (!kni || !req) {
-		pr_err("No kni instance or request\n");
-		return -EINVAL;
-	}
-
-	mutex_lock(&kni->sync_lock);
-
-	/* Construct data */
-	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
-	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
-	if (num < 1) {
-		pr_err("Cannot send to req_q\n");
-		ret = -EBUSY;
-		goto fail;
-	}
-
-	ret_val = wait_event_interruptible_timeout(kni->wq,
-			kni_fifo_count(kni->resp_q), 3 * HZ);
-	if (signal_pending(current) || ret_val <= 0) {
-		ret = -ETIME;
-		goto fail;
-	}
-	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
-	if (num != 1 || resp_va != kni->sync_va) {
-		/* This should never happen */
-		pr_err("No data in resp_q\n");
-		ret = -ENODATA;
-		goto fail;
-	}
-
-	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
-	ret = 0;
-
-fail:
-	mutex_unlock(&kni->sync_lock);
-	return ret;
-}
-
-/*
  * Return statistics to the caller
  */
 static struct net_device_stats *
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 16/19] kni: remove compile time debug configuration
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (14 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 17/19] kni: updated log messages Ferruh Yigit
                   ` (23 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Since switched to kernel dynamic debugging it is possible to remove
compile time debug log configuration.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 config/common_base                      |  3 ---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 18 -------------
 lib/librte_eal/linuxapp/kni/kni_misc.c  |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_net.c   |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 46 ++++++++++++++++-----------------
 5 files changed, 31 insertions(+), 52 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7830535..4a9e5b0 100644
--- a/config/common_base
+++ b/config/common_base
@@ -533,12 +533,9 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_KNI=n
 CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_KNI_PREEMPT_DEFAULT=y
-CONFIG_RTE_KNI_KO_DEBUG=n
 CONFIG_RTE_KNI_VHOST=n
 CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024
 CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n
-CONFIG_RTE_KNI_VHOST_DEBUG_RX=n
-CONFIG_RTE_KNI_VHOST_DEBUG_TX=n
 
 #
 # Compile the pdump library
diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 10e760e..3693760 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -112,12 +112,6 @@ struct kni_dev {
 #endif
 };
 
-#ifdef RTE_KNI_KO_DEBUG
-	#define KNI_DBG(args...) pr_debug(args)
-#else
-	#define KNI_DBG(args...)
-#endif
-
 #ifdef RTE_KNI_VHOST
 unsigned int
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
@@ -151,16 +145,4 @@ int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 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...) pr_debug(args)
-#else
-	#define KNI_DBG_RX(args...)
-#endif
-
-#ifdef RTE_KNI_VHOST_DEBUG_TX
-	#define KNI_DBG_TX(args...) pr_debug(args)
-#else
-	#define KNI_DBG_TX(args...)
-#endif
-
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 64e20c1..1bcb3db 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -376,7 +376,7 @@ kni_ioctl_create(struct net *net,
 	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",
+	pr_debug("PCI: %02x:%02x.%02x %04x:%04x\n",
 					dev_info.bus,
 					dev_info.devid,
 					dev_info.function,
@@ -404,7 +404,7 @@ kni_ioctl_create(struct net *net,
 			else
 				ret = -1;
 
-			KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n",
+			pr_debug("PCI found: pci=0x%p, lad_dev=0x%p\n",
 							pci, lad_dev);
 			if (ret == 0) {
 				kni->lad_dev = lad_dev;
@@ -524,7 +524,7 @@ kni_ioctl(struct inode *inode,
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
 
-	KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
+	pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
 
 	/*
 	 * Switch according to the ioctl called
@@ -540,7 +540,7 @@ kni_ioctl(struct inode *inode,
 		ret = kni_ioctl_release(net, ioctl_num, ioctl_param);
 		break;
 	default:
-		KNI_DBG("IOCTL default\n");
+		pr_debug("IOCTL default\n");
 		break;
 	}
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index a732cbd..12dd89f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -547,7 +547,7 @@ kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("Transmit timeout at %ld, latency %ld\n", jiffies,
+	pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
 			jiffies - dev->trans_start);
 
 	kni->stats.tx_errors++;
@@ -560,7 +560,7 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	KNI_DBG("kni_net_ioctl %d\n",
+	pr_debug("kni_net_ioctl %d\n",
 		((struct kni_dev *)netdev_priv(dev))->group_id);
 
 	return 0;
@@ -578,7 +578,7 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu)
 	struct rte_kni_request req;
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
+	pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
 
 	memset(&req, 0, sizeof(req));
 	req.req_id = RTE_KNI_REQ_CHANGE_MTU;
@@ -704,7 +704,7 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_init\n");
+	pr_debug("kni_net_init\n");
 
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f4f6f10..947341e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -75,7 +75,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 	struct rte_kni_mbuf *pkt_va = NULL;
 	int ret;
 
-	KNI_DBG_TX("tx offset=%d, len=%d, iovlen=%d\n",
+	pr_debug("tx offset=%d, len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -177,7 +177,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(pkt_len > len))
 		goto drop;
 
-	KNI_DBG_RX("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
+	pr_debug("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, pkt_len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -202,7 +202,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 		/* Failing should not happen */
 		pr_err("Fail to enqueue entries into free_q\n");
 
-	KNI_DBG_RX("receive done %d\n", pkt_len);
+	pr_debug("receive done %d\n", pkt_len);
 
 	return pkt_len;
 
@@ -226,10 +226,10 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	kni = q->kni;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
-	KNI_DBG("start kni_poll on group %d, wait at 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
@@ -332,7 +332,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	    ((nb_mbuf < RX_BURST_SZ) && (nb_mbuf != 0))) {
 		wake_up_interruptible_poll(sk_sleep(&q->sk),
 				   POLLIN | POLLRDNORM | POLLRDBAND);
-		KNI_DBG_RX("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
+		pr_debug("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
 			   nb_mbuf, nb_skb, nb_in);
 	}
 
@@ -363,7 +363,7 @@ kni_sock_sndmsg(struct socket *sock,
 	if (unlikely(q == NULL || q->kni == NULL))
 		return 0;
 
-	KNI_DBG_TX("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
+	pr_debug("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   len, q->flags, (int)m->msg_iter.iov->iov_len);
 #else
@@ -431,7 +431,7 @@ kni_sock_rcvmsg(struct socket *sock,
 #endif /* HAVE_IOV_ITER_MSGHDR */
 		return -EFAULT;
 #endif /* RTE_KNI_VHOST_VNET_HDR_EN */
-	KNI_DBG_RX("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
+	pr_debug("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
 		   (unsigned long)len, q->flags, pkt_len);
 
 	return pkt_len + vnet_hdr_len;
@@ -453,11 +453,11 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 	int s;
 	int ret;
 
-	KNI_DBG("tap ioctl cmd 0x%08x\n", cmd);
+	pr_debug("tap ioctl cmd 0x%08x\n", cmd);
 
 	switch (cmd) {
 	case TUNSETIFF:
-		KNI_DBG("TUNSETIFF\n");
+		pr_debug("TUNSETIFF\n");
 		/* ignore the name, just look at flags */
 		if (get_user(u, &ifr->ifr_flags))
 			return -EFAULT;
@@ -471,7 +471,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETIFF:
-		KNI_DBG("TUNGETIFF\n");
+		pr_debug("TUNGETIFF\n");
 		rcu_read_lock_bh();
 		kni = rcu_dereference_bh(q->kni);
 		if (kni)
@@ -489,7 +489,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETFEATURES:
-		KNI_DBG("TUNGETFEATURES\n");
+		pr_debug("TUNGETFEATURES\n");
 		u = IFF_TAP | IFF_NO_PI;
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		u |= IFF_VNET_HDR;
@@ -499,7 +499,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return 0;
 
 	case TUNSETSNDBUF:
-		KNI_DBG("TUNSETSNDBUF\n");
+		pr_debug("TUNSETSNDBUF\n");
 		if (get_user(u, up))
 			return -EFAULT;
 
@@ -510,7 +510,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		s = q->vnet_hdr_sz;
 		if (put_user(s, sp))
 			return -EFAULT;
-		KNI_DBG("TUNGETVNETHDRSZ %d\n", s);
+		pr_debug("TUNGETVNETHDRSZ %d\n", s);
 		return 0;
 
 	case TUNSETVNETHDRSZ:
@@ -519,12 +519,12 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		if (s < (int)sizeof(struct virtio_net_hdr))
 			return -EINVAL;
 
-		KNI_DBG("TUNSETVNETHDRSZ %d\n", s);
+		pr_debug("TUNSETVNETHDRSZ %d\n", s);
 		q->vnet_hdr_sz = s;
 		return 0;
 
 	case TUNSETOFFLOAD:
-		KNI_DBG("TUNSETOFFLOAD %lx\n", arg);
+		pr_debug("TUNSETOFFLOAD %lx\n", arg);
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		/* not support any offload yet */
 		if (!(q->flags & IFF_VNET_HDR))
@@ -536,7 +536,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 #endif
 
 	default:
-		KNI_DBG("NOT SUPPORT\n");
+		pr_debug("NOT SUPPORT\n");
 		return -EINVAL;
 	}
 }
@@ -584,7 +584,7 @@ kni_sock_release(struct socket *sock)
 
 	sock_put(&q->sk);
 
-	KNI_DBG("dummy sock release done\n");
+	pr_debug("dummy sock release done\n");
 
 	return 0;
 }
@@ -593,7 +593,7 @@ int
 kni_sock_getname(struct socket *sock, struct sockaddr *addr,
 		int *sockaddr_len, int peer)
 {
-	KNI_DBG("dummy sock getname\n");
+	pr_debug("dummy sock getname\n");
 	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
@@ -731,11 +731,11 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	kni->vq_status = BE_START;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -828,7 +828,7 @@ kni_vhost_backend_release(struct kni_dev *kni)
 	/* dettach from kni */
 	q->kni = NULL;
 
-	KNI_DBG("release backend done\n");
+	pr_debug("release backend done\n");
 
 	return 0;
 }
@@ -843,7 +843,7 @@ kni_vhost_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_STOP;
 
-	KNI_DBG("kni_vhost_init done\n");
+	pr_debug("kni_vhost_init done\n");
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 17/19] kni: updated log messages
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (15 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 16/19] kni: remove compile time debug configuration Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
                   ` (22 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Remove some function entrance logs and changed log level of some logs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 9 ++-------
 lib/librte_eal/linuxapp/kni/kni_net.c  | 6 ++----
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 1bcb3db..e036a98 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -183,7 +183,7 @@ kni_open(struct inode *inode, struct file *file)
 
 	/* Create kernel thread for single mode */
 	if (multiple_kthread_on == 0) {
-		pr_debug("Single kernel thread for all KNI devices\n");
+		pr_info("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");
@@ -192,7 +192,7 @@ kni_open(struct inode *inode, struct file *file)
 			return PTR_ERR(knet->kni_kthread);
 		}
 	} else
-		pr_debug("Multiple kernel thread mode enabled\n");
+		pr_info("Multiple kernel thread mode enabled\n");
 
 	file->private_data = get_net(net);
 	pr_debug("/dev/kni opened\n");
@@ -593,8 +593,6 @@ kni_init(void)
 {
 	int rc;
 
-	pr_debug("######## DPDK kni module loading ########\n");
-
 	if (kni_parse_kthread_mode() < 0) {
 		pr_err("Invalid parameter for kthread_mode\n");
 		return -EINVAL;
@@ -617,8 +615,6 @@ kni_init(void)
 	/* Configure the lo mode according to the input parameter */
 	kni_net_config_lo_mode(lo_mode);
 
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
 	return 0;
 
 out:
@@ -639,7 +635,6 @@ kni_exit(void)
 #else
 	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
 #endif
-	pr_debug("####### DPDK kni module unloaded  #######\n");
 }
 
 module_init(kni_init);
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 12dd89f..7c3e30b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -560,8 +560,8 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	pr_debug("kni_net_ioctl %d\n",
-		((struct kni_dev *)netdev_priv(dev))->group_id);
+	pr_debug("kni_net_ioctl group:%d cmd:%d\n",
+		((struct kni_dev *)netdev_priv(dev))->group_id, cmd);
 
 	return 0;
 }
@@ -704,8 +704,6 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	pr_debug("kni_net_init\n");
-
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 18/19] kni: prefer uint32_t to unsigned int
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (16 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 17/19] kni: updated log messages Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
                   ` (21 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  8 ++++----
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 17 +++++++----------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 24 ++++++++++++------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 25 ++++++++++++-------------
 5 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 3693760..48f8dad 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -55,7 +55,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned int core_id;        /* Core ID to bind */
+	uint32_t core_id;            /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -96,7 +96,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned int mbuf_size;
+	uint32_t mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
@@ -113,7 +113,7 @@ struct kni_dev {
 };
 
 #ifdef RTE_KNI_VHOST
-unsigned int
+uint32_t
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
 int kni_chk_vhost_rx(struct kni_dev *kni);
 int kni_vhost_init(struct kni_dev *kni);
@@ -125,7 +125,7 @@ struct kni_vhost_queue {
 	int vnet_hdr_sz;
 	struct kni_dev *kni;
 	int sockfd;
-	unsigned int flags;
+	uint32_t flags;
 	struct sk_buff *cache;
 	struct rte_kni_fifo *fifo;
 };
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 71bc2a9..77048a1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int fifo_write = fifo->write;
-	unsigned int fifo_read = fifo->read;
-	unsigned int new_write = fifo_write;
+	uint32_t i = 0;
+	uint32_t fifo_write = fifo->write;
+	uint32_t fifo_read = fifo->read;
+	uint32_t new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int new_read = fifo->read;
-	unsigned int fifo_write = fifo->write;
+	uint32_t i = 0;
+	uint32_t new_read = fifo->read;
+	uint32_t fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned int
+static inline uint32_t
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
+kni_fifo_init(struct rte_kni_fifo *fifo, uint32_t size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index e036a98..f0d76a3 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -52,7 +52,7 @@ static char *lo_mode;
 
 /* Kernel thread mode */
 static char *kthread_mode;
-static unsigned int multiple_kthread_on;
+static uint32_t multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
@@ -276,8 +276,8 @@ kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev)
 }
 
 static int
-kni_ioctl_create(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_create(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret;
@@ -470,8 +470,8 @@ kni_ioctl_create(struct net *net,
 }
 
 static int
-kni_ioctl_release(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_release(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret = -EINVAL;
@@ -517,9 +517,7 @@ kni_ioctl_release(struct net *net,
 }
 
 static int
-kni_ioctl(struct inode *inode,
-	unsigned int ioctl_num,
-	unsigned long ioctl_param)
+kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
 {
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
@@ -548,8 +546,7 @@ kni_ioctl(struct inode *inode,
 }
 
 static int
-kni_compat_ioctl(struct inode *inode,
-		unsigned int ioctl_num,
+kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
 		unsigned long ioctl_param)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 7c3e30b..430f158 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -64,7 +64,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned int num;
+	uint32_t num;
 	int ret_val;
 
 	if (!kni || !req) {
@@ -178,7 +178,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned int ret;
+	uint32_t ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -260,9 +260,9 @@ drop:
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rx, num_fq;
+	uint32_t i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -278,7 +278,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
+	num_rx = min_t(uint32_t, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -347,9 +347,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
+	uint32_t i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -374,7 +374,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -436,9 +436,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rq, num_fq, num;
+	uint32_t i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -454,7 +454,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -617,7 +617,7 @@ kni_net_stats(struct net_device *dev)
 static int
 kni_net_header(struct sk_buff *skb, struct net_device *dev,
 		unsigned short type, const void *daddr,
-		const void *saddr, unsigned int len)
+		const void *saddr, uint32_t len)
 {
 	struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 947341e..3ba0c57 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -213,13 +213,13 @@ drop:
 	return 0;
 }
 
-static unsigned int
+static uint32_t
 kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int mask = 0;
+	uint32_t mask = 0;
 
 	if (unlikely(q == NULL || q->kni == NULL))
 		return POLLERR;
@@ -281,9 +281,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned int nb_in, nb_mbuf, nb_skb;
-	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
-	unsigned int nb_burst, nb_backlog, i;
+	uint32_t nb_in, nb_mbuf, nb_skb;
+	const uint32_t BURST_MASK = RX_BURST_SZ - 1;
+	uint32_t nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
+	nb_in = min_t(uint32_t, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
@@ -439,16 +439,15 @@ kni_sock_rcvmsg(struct socket *sock,
 
 /* dummy tap like ioctl */
 static int
-kni_sock_ioctl(struct socket *sock, unsigned int cmd,
-	      unsigned long arg)
+kni_sock_ioctl(struct socket *sock, uint32_t cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	struct ifreq __user *ifr = argp;
-	unsigned int __user *up = argp;
+	uint32_t __user *up = argp;
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int u;
+	uint32_t u;
 	int __user *sp = argp;
 	int s;
 	int ret;
@@ -542,7 +541,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 static int
-kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
+kni_sock_compat_ioctl(struct socket *sock, uint32_t cmd,
 		     unsigned long arg)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH 19/19] kni: move kernel version ifdefs to compat header
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (17 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
@ 2016-09-15 15:46 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (20 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-15 15:46 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h    | 12 ++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 16 +++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 9ae50a7..78da08e 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -20,6 +20,14 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
 #define sk_sleep(s) ((s)->sk_sleep)
+#else
+#define HAVE_SOCKET_WQ
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#define HAVE_STATIC_SOCK_MAP_FD
+#else
+#define kni_sock_map_fd(s) sock_map_fd(s, 0)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
@@ -39,6 +47,10 @@
 #define HAVE_REBUILD_HEADER
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#define HAVE_SK_ALLOC_KERN_PARAM
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
 #define HAVE_TRANS_START_HELPER
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 3ba0c57..f54c34b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,7 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#ifdef HAVE_STATIC_SOCK_MAP_FD
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
@@ -57,8 +57,6 @@ static int kni_sock_map_fd(struct socket *sock)
 	fd_install(fd, file);
 	return fd;
 }
-#else
-#define kni_sock_map_fd(s)             sock_map_fd(s, 0)
 #endif
 
 static struct proto kni_raw_proto = {
@@ -225,17 +223,13 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
+	poll_wait(file, &sock->wq->wait, wait);
 #else
 	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	poll_wait(file, &sock->wq->wait, wait);
-#else
 	poll_wait(file, &sock->wait, wait);
 #endif
 
@@ -663,7 +657,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	if (kni->vhost_queue != NULL)
 		return -1;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#ifdef HAVE_SK_ALLOC_KERN_PARAM
 	q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
 			&kni_raw_proto, 0);
 #else
@@ -729,7 +723,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (18 preceding siblings ...)
  2016-09-15 15:46 ` [dpdk-dev] [PATCH 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 01/19] kni: move externs to the header file Ferruh Yigit
                   ` (19 subsequent siblings)
  39 siblings, 1 reply; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
Only functional change is related logging, switched to kernel dynamic
logging and compile time KNI debug options removed, some log message
levels updated.

v2:
keep variable externs in .c file

Ferruh Yigit (19):
  kni: move externs to the header file
  kni: uninitialize global variables
  kni: make static struct const
  kni: whitespace, indentation, long line corrections
  kni: prefer unsigned int to unsigned
  kni: remove useless return
  kni: comparisons should place the constant on the right
  kni: trailing statements should be on next line
  kni: do not use assignment in if condition
  kni: macros with complex values should be enclosed in parentheses
  kni: prefer min_t to min
  kni: prefer ether_addr_copy to memcpy
  kni: update kernel logging
  kni: remove unnecessary 'out of memory' message
  kni: move functions to eliminate function declarations
  kni: remove compile time debug configuration
  kni: updated log messages
  kni: prefer uint32_t to unsigned int
  kni: move kernel version ifdefs to compat header

 config/common_base                        |   3 -
 lib/librte_eal/linuxapp/kni/compat.h      |  18 +-
 lib/librte_eal/linuxapp/kni/kni_dev.h     |  51 ++--
 lib/librte_eal/linuxapp/kni/kni_ethtool.c |  39 ++-
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  24 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 399 ++++++++++++++----------------
 lib/librte_eal/linuxapp/kni/kni_net.c     | 365 +++++++++++++--------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 199 +++++++--------
 8 files changed, 537 insertions(+), 561 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 01/19] kni: move externs to the header file
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (19 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 02/19] kni: uninitialize global variables Ferruh Yigit
                   ` (18 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---

v2:
keep variable externs in .c file
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 11 +++++++++++
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 14 ++------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 11 +----------
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index a0e5cb6..918a40c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -134,6 +134,17 @@ struct kni_vhost_queue {
 
 #endif
 
+void kni_net_rx(struct kni_dev *kni);
+void kni_net_init(struct net_device *dev);
+void kni_net_config_lo_mode(char *lo_str);
+void kni_net_poll_resp(struct kni_dev *kni);
+void kni_set_ethtool_ops(struct net_device *netdev);
+
+int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void ixgbe_kni_remove(struct pci_dev *pdev);
+int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void igb_kni_remove(struct pci_dev *pdev);
+
 #ifdef RTE_KNI_VHOST_DEBUG_RX
 	#define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
 #else
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 3501dc1..f52ef68 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -47,18 +47,8 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 
 #define KNI_MAX_DEVICES 32
 
-extern void kni_net_rx(struct kni_dev *kni);
-extern void kni_net_init(struct net_device *dev);
-extern void kni_net_config_lo_mode(char *lo_str);
-extern void kni_net_poll_resp(struct kni_dev *kni);
-extern void kni_set_ethtool_ops(struct net_device *netdev);
-
-extern int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void ixgbe_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id ixgbe_pci_tbl[];
-extern int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void igb_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id igb_pci_tbl[];
+extern const struct pci_device_id ixgbe_pci_tbl[];
+extern const struct pci_device_id igb_pci_tbl[];
 
 static int kni_open(struct inode *inode, struct file *file);
 static int kni_release(struct inode *inode, struct file *file);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index a3ca849..7aed96e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/if_tun.h>
 #include <linux/version.h>
+#include <linux/file.h>
 
 #include "compat.h"
 #include "kni_dev.h"
@@ -39,17 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-extern void put_unused_fd(unsigned int fd);
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
-extern struct file*
-sock_alloc_file(struct socket *sock,
-		int flags, const char *dname);
-
-extern int get_unused_fd_flags(unsigned flags);
-
-extern void fd_install(unsigned int fd, struct file *file);
-
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 02/19] kni: uninitialize global variables
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (20 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 01/19] kni: move externs to the header file Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 03/19] kni: make static struct const Ferruh Yigit
                   ` (17 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index f52ef68..cbb934d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -80,11 +80,11 @@ static struct miscdevice kni_misc = {
 };
 
 /* loopback mode */
-static char *lo_mode = NULL;
+static char *lo_mode;
 
 /* Kernel thread mode */
-static char *kthread_mode = NULL;
-static unsigned multiple_kthread_on = 0;
+static char *kthread_mode;
+static unsigned int multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 03/19] kni: make static struct const
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (21 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 02/19] kni: uninitialize global variables Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
                   ` (16 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index cbb934d..4e09da4 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -65,7 +65,7 @@ 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 = {
+static const struct file_operations kni_fops = {
 	.owner = THIS_MODULE,
 	.open = kni_open,
 	.release = kni_release,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 04/19] kni: whitespace, indentation, long line corrections
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (22 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 03/19] kni: make static struct const Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
                   ` (15 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h     | 11 +++---
 lib/librte_eal/linuxapp/kni/kni_ethtool.c | 39 +++++++++++++++-----
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  2 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 18 +++++-----
 lib/librte_eal/linuxapp/kni/kni_net.c     | 17 +++++----
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 60 ++++++++++++++++---------------
 6 files changed, 88 insertions(+), 59 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 918a40c..faef2db 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -84,7 +84,7 @@ struct kni_dev {
 	/* response queue */
 	void *resp_q;
 
-	void * sync_kva;
+	void *sync_kva;
 	void *sync_va;
 
 	void *mbuf_kva;
@@ -97,12 +97,13 @@ struct kni_dev {
 	unsigned long synchro;
 
 #ifdef RTE_KNI_VHOST
-	struct kni_vhost_queue* vhost_queue;
+	struct kni_vhost_queue *vhost_queue;
+
 	volatile enum {
 		BE_STOP = 0x1,
 		BE_START = 0x2,
 		BE_FINISH = 0x4,
-	}vq_status;
+	} vq_status;
 #endif
 };
 
@@ -128,8 +129,8 @@ struct kni_vhost_queue {
 	struct kni_dev *kni;
 	int sockfd;
 	unsigned int flags;
-	struct sk_buff* cache;
-	struct rte_kni_fifo* fifo;
+	struct sk_buff *cache;
+	struct rte_kni_fifo *fifo;
 };
 
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_ethtool.c b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
index 06b6d46..0c88589 100644
--- a/lib/librte_eal/linuxapp/kni/kni_ethtool.c
+++ b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
@@ -31,6 +31,7 @@ static int
 kni_check_if_running(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	if (priv->lad_dev)
 		return 0;
 	else
@@ -41,6 +42,7 @@ static void
 kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
 }
 
@@ -48,6 +50,7 @@ static int
 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
 }
 
@@ -55,6 +58,7 @@ static int
 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
 }
 
@@ -62,6 +66,7 @@ static void
 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
 }
 
@@ -69,6 +74,7 @@ static int
 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
 }
 
@@ -76,6 +82,7 @@ static int
 kni_nway_reset(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
 }
 
@@ -83,6 +90,7 @@ static int
 kni_get_eeprom_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
 }
 
@@ -91,6 +99,7 @@ kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -100,6 +109,7 @@ kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -108,6 +118,7 @@ static void
 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
 }
 
@@ -115,6 +126,7 @@ static int
 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
 }
 
@@ -122,6 +134,7 @@ static void
 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
 }
 
@@ -129,6 +142,7 @@ static int
 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
 								pause);
 }
@@ -137,6 +151,7 @@ static u32
 kni_get_msglevel(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
 }
 
@@ -144,6 +159,7 @@ static void
 kni_set_msglevel(struct net_device *dev, u32 data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
 }
 
@@ -151,6 +167,7 @@ static int
 kni_get_regs_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
 }
 
@@ -158,6 +175,7 @@ static void
 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
 }
 
@@ -165,6 +183,7 @@ static void
 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
 								data);
 }
@@ -173,6 +192,7 @@ static int
 kni_get_sset_count(struct net_device *dev, int sset)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
 }
 
@@ -181,24 +201,25 @@ kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
 								u64 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
 								data);
 }
 
 struct ethtool_ops kni_ethtool_ops = {
-	.begin 				= kni_check_if_running,
+	.begin			= kni_check_if_running,
 	.get_drvinfo		= kni_get_drvinfo,
 	.get_settings		= kni_get_settings,
 	.set_settings		= kni_set_settings,
 	.get_regs_len		= kni_get_regs_len,
-	.get_regs			= kni_get_regs,
-	.get_wol			= kni_get_wol,
-	.set_wol			= kni_set_wol,
-	.nway_reset			= kni_nway_reset,
-	.get_link			= ethtool_op_get_link,
+	.get_regs		= kni_get_regs,
+	.get_wol		= kni_get_wol,
+	.set_wol		= kni_set_wol,
+	.nway_reset		= kni_nway_reset,
+	.get_link		= ethtool_op_get_link,
 	.get_eeprom_len		= kni_get_eeprom_len,
-	.get_eeprom			= kni_get_eeprom,
-	.set_eeprom			= kni_set_eeprom,
+	.get_eeprom		= kni_get_eeprom,
+	.set_eeprom		= kni_set_eeprom,
 	.get_ringparam		= kni_get_ringparam,
 	.set_ringparam		= kni_set_ringparam,
 	.get_pauseparam		= kni_get_pauseparam,
@@ -207,7 +228,7 @@ struct ethtool_ops kni_ethtool_ops = {
 	.set_msglevel		= kni_set_msglevel,
 	.get_strings		= kni_get_strings,
 	.get_sset_count		= kni_get_sset_count,
-	.get_ethtool_stats  = kni_get_ethtool_stats,
+	.get_ethtool_stats	= kni_get_ethtool_stats,
 };
 
 void
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 3ea750e..4006b1f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -79,7 +79,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
 static inline unsigned
 kni_fifo_count(struct rte_kni_fifo *fifo)
 {
-	return (fifo->len + fifo->write - fifo->read) & ( fifo->len - 1);
+	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
 }
 
 /**
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 4e09da4..61a387e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -97,7 +97,8 @@ struct kni_net {
 	struct list_head kni_list_head;
 };
 
-static int __net_init kni_init_net(struct net *net)
+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);
@@ -129,7 +130,8 @@ static int __net_init kni_init_net(struct net *net)
 #endif
 }
 
-static void __net_exit kni_exit_net(struct net *net)
+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);
@@ -307,8 +309,8 @@ kni_thread_single(void *data)
 		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));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -331,8 +333,8 @@ kni_thread_multiple(void *param)
 			kni_net_poll_resp(dev);
 		}
 #ifdef RTE_KNI_PREEMPT_DEFAULT
-		schedule_timeout_interruptible(usecs_to_jiffies( \
-				KNI_KTHREAD_RESCHEDULE_INTERVAL));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -487,7 +489,7 @@ kni_ioctl_create(struct net *net,
 
 	/* Support Ethtool */
 	while (pci) {
-		KNI_PRINT("pci_bus: %02x:%02x:%02x \n",
+		KNI_PRINT("pci_bus: %02x:%02x:%02x\n",
 					pci->bus->number,
 					PCI_SLOT(pci->devfn),
 					PCI_FUNC(pci->devfn));
@@ -579,7 +581,7 @@ kni_ioctl_release(struct net *net,
 	struct rte_kni_device_info dev_info;
 
 	if (_IOC_SIZE(ioctl_num) > sizeof(dev_info))
-			return -EINVAL;
+		return -EINVAL;
 
 	ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info));
 	if (ret) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index fc82193..aa17f2c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -126,7 +126,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	unsigned i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
@@ -214,7 +214,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct rte_kni_mbuf *alloc_kva;
 	struct rte_kni_mbuf *alloc_va[MBUF_BURST_SZ];
@@ -303,7 +303,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 	unsigned i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
-	void * data_kva;
+	void *data_kva;
 
 	struct sk_buff *skb;
 	struct net_device *dev = kni->net_dev;
@@ -503,7 +503,7 @@ drop:
  * Deal with a transmit timeout.
  */
 static void
-kni_net_tx_timeout (struct net_device *dev)
+kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
@@ -617,6 +617,7 @@ static struct net_device_stats *
 kni_net_stats(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
+
 	return &kni->stats;
 }
 
@@ -637,7 +638,6 @@ kni_net_header(struct sk_buff *skb, struct net_device *dev,
 	return dev->hard_header_len;
 }
 
-
 /*
  * Re-fill the eth header
  */
@@ -662,9 +662,11 @@ kni_net_rebuild_header(struct sk_buff *skb)
  *
  * Returns 0 on success, negative on failure
  **/
-static int kni_net_set_mac(struct net_device *netdev, void *p)
+static int
+kni_net_set_mac(struct net_device *netdev, void *p)
 {
 	struct sockaddr *addr = p;
+
 	if (!is_valid_ether_addr((unsigned char *)(addr->sa_data)))
 		return -EADDRNOTAVAIL;
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
@@ -672,7 +674,8 @@ static int kni_net_set_mac(struct net_device *netdev, void *p)
 }
 
 #ifdef HAVE_CHANGE_CARRIER_CB
-static int kni_net_change_carrier(struct net_device *dev, bool new_carrier)
+static int
+kni_net_change_carrier(struct net_device *dev, bool new_carrier)
 {
 	if (new_carrier)
 		netif_carrier_on(dev);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 7aed96e..b4d91ca 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,11 +40,12 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
 	int fd = get_unused_fd_flags(0);
+
 	if (fd < 0)
 		return fd;
 
@@ -101,7 +102,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 
 		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
 		data_kva = pkt_kva->buf_addr + pkt_kva->data_off
-		           - kni->mbuf_va + kni->mbuf_kva;
+			- kni->mbuf_va + kni->mbuf_kva;
 
 #ifdef HAVE_IOV_ITER_MSGHDR
 		copy_from_iter(data_kva, len, &m->msg_iter);
@@ -149,7 +150,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va;
-	void * data_kva;
+	void *data_kva;
 	struct sk_buff *skb;
 	struct kni_vhost_queue *q = kni->vhost_queue;
 
@@ -164,7 +165,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(skb == NULL))
 		return 0;
 
-	kva = (struct rte_kni_mbuf*)skb->data;
+	kva = (struct rte_kni_mbuf *)skb->data;
 
 	/* free skb to cache */
 	skb->data = NULL;
@@ -213,7 +214,7 @@ drop:
 }
 
 static unsigned int
-kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
+kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
@@ -224,7 +225,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
@@ -232,7 +233,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	poll_wait(file, &sock->wq->wait, wait);
 #else
 	poll_wait(file, &sock->wait, wait);
@@ -260,7 +261,7 @@ kni_vhost_enqueue(struct kni_dev *kni, struct kni_vhost_queue *q,
 	struct rte_kni_mbuf *kva;
 
 	kva = (void *)(va) - kni->mbuf_va + kni->mbuf_kva;
-	(skb)->data = (unsigned char*)kva;
+	(skb)->data = (unsigned char *)kva;
 	(skb)->len = kva->data_len;
 	skb_queue_tail(&q->sk.sk_receive_queue, skb);
 }
@@ -270,6 +271,7 @@ kni_vhost_enqueue_burst(struct kni_dev *kni, struct kni_vhost_queue *q,
 	  struct sk_buff **skb, struct rte_kni_mbuf **va)
 {
 	int i;
+
 	for (i = 0; i < RX_BURST_SZ; skb++, va++, i++)
 		kni_vhost_enqueue(kni, q, *skb, *va);
 }
@@ -341,7 +343,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");
+	KNI_ERR("Fail to enqueue fifo, it shouldn't happen\n");
 	BUG_ON(1);
 
 	return 0;
@@ -482,8 +484,8 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 			return -ENOLINK;
 
 		ret = 0;
-		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ) ||
-		    put_user(q->flags, &ifr->ifr_flags))
+		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ)
+				|| put_user(q->flags, &ifr->ifr_flags))
 			ret = -EFAULT;
 		dev_put(kni->net_dev);
 		return ret;
@@ -552,10 +554,10 @@ kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 #define KNI_VHOST_WAIT_WQ_SAFE()                        \
-do {		                                	\
+do {							\
 	while ((BE_FINISH | BE_STOP) == kni->vq_status) \
-		msleep(1);                              \
-}while(0)                                               \
+		msleep(1);				\
+} while (0)						\
 
 
 static int
@@ -589,12 +591,11 @@ kni_sock_release(struct socket *sock)
 }
 
 int
-kni_sock_getname (struct socket *sock,
-		  struct sockaddr *addr,
-		  int *sockaddr_len, int peer)
+kni_sock_getname(struct socket *sock, struct sockaddr *addr,
+		int *sockaddr_len, int peer)
 {
 	KNI_DBG("dummy sock getname\n");
-	((struct sockaddr_ll*)addr)->sll_family = AF_PACKET;
+	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
 
@@ -637,7 +638,7 @@ kni_sk_destruct(struct sock *sk)
 
 	/* make sure there's no packet in buffer */
 	while (skb_dequeue(&sk->sk_receive_queue) != NULL)
-	       ;
+		;
 
 	mb();
 
@@ -685,8 +686,9 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	}
 
 	/* cache init */
-	q->cache = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
-			   GFP_KERNEL);
+	q->cache = kzalloc(
+		RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
+		GFP_KERNEL);
 	if (!q->cache)
 		goto free_fd;
 
@@ -699,7 +701,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	for (i = 0; i < RTE_KNI_VHOST_MAX_CACHE_SIZE; i++) {
 		elem = &q->cache[i];
-		kni_fifo_put(fifo, (void**)&elem, 1);
+		kni_fifo_put(fifo, (void **)&elem, 1);
 	}
 	q->fifo = fifo;
 
@@ -729,14 +731,12 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,"
-		  "sk->sk_wq=0x%16llx",
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,"
-		  "sk->sk_sleep=0x%16llx",
+	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -759,7 +759,7 @@ free_sock:
 	q->sock = NULL;
 
 free_sk:
-	sk_free((struct sock*)q);
+	sk_free((struct sock *)q);
 
 	return err;
 }
@@ -772,6 +772,7 @@ show_sock_fd(struct device *dev, struct device_attribute *attr,
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
 	int sockfd = -1;
+
 	if (kni->vhost_queue != NULL)
 		sockfd = kni->vhost_queue->sockfd;
 	return snprintf(buf, 10, "%d\n", sockfd);
@@ -783,6 +784,7 @@ show_sock_en(struct device *dev, struct device_attribute *attr,
 {
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
+
 	return snprintf(buf, 10, "%u\n", (kni->vhost_queue == NULL ? 0 : 1));
 }
 
@@ -809,7 +811,7 @@ static DEVICE_ATTR(sock_en, S_IRUGO | S_IWUSR, show_sock_en, set_sock_en);
 static struct attribute *dev_attrs[] = {
 	&dev_attr_sock_fd.attr,
 	&dev_attr_sock_en.attr,
-        NULL,
+	NULL,
 };
 
 static const struct attribute_group dev_attr_grp = {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 05/19] kni: prefer unsigned int to unsigned
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (23 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 06/19] kni: remove useless return Ferruh Yigit
                   ` (14 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  4 ++--
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 ++++++------
 4 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index faef2db..643df4b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -50,7 +50,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned core_id;            /* Core ID to bind */
+	unsigned int core_id;        /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -91,7 +91,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned mbuf_size;
+	unsigned int mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 4006b1f..71bc2a9 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned fifo_write = fifo->write;
-	unsigned fifo_read = fifo->read;
-	unsigned new_write = fifo_write;
+	unsigned int i = 0;
+	unsigned int fifo_write = fifo->write;
+	unsigned int fifo_read = fifo->read;
+	unsigned int new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned new_read = fifo->read;
-	unsigned fifo_write = fifo->write;
+	unsigned int i = 0;
+	unsigned int new_read = fifo->read;
+	unsigned int fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned
+static inline unsigned int
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
+kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index aa17f2c..f4afd83 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -121,9 +121,9 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rx, num_fq;
+	unsigned int i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
+	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -209,9 +209,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
+	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -298,9 +298,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rq, num_fq, num;
+	unsigned int i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -316,7 +316,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -423,7 +423,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned ret;
+	unsigned int ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -569,7 +569,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned num;
+	unsigned int num;
 	int ret_val;
 
 	if (!kni || !req) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index b4d91ca..f1345c3 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -280,9 +280,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned nb_in, nb_mbuf, nb_skb;
-	const unsigned BURST_MASK = RX_BURST_SZ - 1;
-	unsigned nb_burst, nb_backlog, i;
+	unsigned int nb_in, nb_mbuf, nb_skb;
+	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
+	unsigned int nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -298,7 +298,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned)RX_BURST_SZ);
+	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 06/19] kni: remove useless return
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (24 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
                   ` (13 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index f4afd83..81d139e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -512,7 +512,6 @@ kni_net_tx_timeout(struct net_device *dev)
 
 	kni->stats.tx_errors++;
 	netif_wake_queue(dev);
-	return;
 }
 
 /*
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 07/19] kni: comparisons should place the constant on the right
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (25 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 06/19] kni: remove useless return Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 08/19] kni: trailing statements should be on next line Ferruh Yigit
                   ` (12 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f1345c3..ec39538 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -169,7 +169,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 
 	/* free skb to cache */
 	skb->data = NULL;
-	if (unlikely(1 != kni_fifo_put(q->fifo, (void **)&skb, 1)))
+	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");
 
@@ -197,8 +197,8 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	kni->stats.rx_packets++;
 
 	/* enqueue mbufs into free_q */
-	va = (void*)kva - kni->mbuf_kva + kni->mbuf_va;
-	if (unlikely(1 != kni_fifo_put(kni->free_q, (void **)&va, 1)))
+	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");
 
@@ -303,15 +303,13 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_backlog = (nb_in & BURST_MASK);
 
 	/* enqueue skb_queue per BURST_SIZE bulk */
-	if (0 != nb_burst) {
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     kni->rx_q, (void **)&va,
-				     RX_BURST_SZ)))
+	if (nb_burst != 0) {
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     q->fifo, (void **)&skb,
-				     RX_BURST_SZ)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
 		kni_vhost_enqueue_burst(kni, q, skb, va);
@@ -319,12 +317,10 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 
 	/* all leftover, do one by one */
 	for (i = 0; i < nb_backlog; ++i) {
-		if (unlikely(1 != kni_fifo_get(
-				     kni->rx_q,(void **)&va, 1)))
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, 1) != 1))
 			goto except;
 
-		if (unlikely(1 != kni_fifo_get(
-				     q->fifo, (void **)&skb, 1)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, 1) != 1))
 			goto except;
 
 		kni_vhost_enqueue(kni, q, *skb, *va);
@@ -797,7 +793,7 @@ set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != kstrtoul(buf, 0, &en))
+	if (kstrtoul(buf, 0, &en) != 0)
 		return -EINVAL;
 
 	if (en)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 08/19] kni: trailing statements should be on next line
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (26 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 09/19] kni: do not use assignment in if condition Ferruh Yigit
                   ` (11 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index ec39538..bef4889 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -244,11 +244,12 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	if (sock_writeable(&q->sk) ||
 #ifdef SOCKWQ_ASYNC_NOSPACE
-	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #else
-	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #endif
-	     sock_writeable(&q->sk)))
 		mask |= POLLOUT | POLLWRNORM;
 
 	return mask;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 09/19] kni: do not use assignment in if condition
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (27 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 08/19] kni: trailing statements should be on next line Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
                   ` (10 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index bef4889..eacfe3f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -410,13 +410,14 @@ kni_sock_rcvmsg(struct socket *sock,
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 	if (likely(q->flags & IFF_VNET_HDR)) {
 		vnet_hdr_len = q->vnet_hdr_sz;
-		if ((len -= vnet_hdr_len) < 0)
+		len -= vnet_hdr_len;
+		if (len < 0)
 			return -EINVAL;
 	}
 #endif
 
-	if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni,
-		m, vnet_hdr_len, len))))
+	pkt_len = kni_vhost_net_rx(q->kni, m, vnet_hdr_len, len);
+	if (unlikely(pkt_len == 0))
 		return 0;
 
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
@@ -567,7 +568,8 @@ kni_sock_release(struct socket *sock)
 	if (q == NULL)
 		return 0;
 
-	if (NULL != (kni = q->kni)) {
+	kni = q->kni;
+	if (kni != NULL) {
 		kni->vq_status = BE_STOP;
 		KNI_VHOST_WAIT_WQ_SAFE();
 		kni->vhost_queue = NULL;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 10/19] kni: macros with complex values should be enclosed in parentheses
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (28 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 09/19] kni: do not use assignment in if condition Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 11/19] kni: prefer min_t to min Ferruh Yigit
                   ` (9 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 962a4e7..d79d626 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -19,7 +19,7 @@
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
-#define sk_sleep(s) (s)->sk_sleep
+#define sk_sleep(s) ((s)->sk_sleep)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 11/19] kni: prefer min_t to min
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (29 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
                   ` (8 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c   | 6 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 81d139e..a6458fa 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -139,7 +139,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
+	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -236,7 +236,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -316,7 +316,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index eacfe3f..e460dd6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
+	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 12/19] kni: prefer ether_addr_copy to memcpy
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (30 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 11/19] kni: prefer min_t to min Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 13/19] kni: update kernel logging Ferruh Yigit
                   ` (7 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h   | 4 ++++
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index d79d626..9ae50a7 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -26,6 +26,10 @@
 #define HAVE_CHANGE_CARRIER_CB
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+#define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
 #define HAVE_IOV_ITER_MSGHDR
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 61a387e..53f2dfd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -527,7 +527,7 @@ kni_ioctl_create(struct net *net,
 		pci_dev_put(pci);
 
 	if (kni->lad_dev)
-		memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
+		ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr);
 	else
 		/*
 		 * Generate random mac address. eth_random_addr() is the newer
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 13/19] kni: update kernel logging
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (31 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
                   ` (6 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

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 <ferruh.yigit@intel.com>
---
 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 643df4b..7e48203 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 <linux/if.h>
 #include <linux/wait.h>
 #include <linux/sched.h>
@@ -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
@@ -147,13 +150,13 @@ int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);
 
 #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 53f2dfd..6947483 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -154,10 +154,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;
 	}
 
@@ -171,14 +171,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;
 
@@ -200,7 +200,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
@@ -231,19 +231,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;
 }
@@ -282,7 +282,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;
 }
@@ -370,7 +370,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;
 	}
 
@@ -390,7 +390,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;
@@ -398,7 +398,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;
 	}
 
@@ -408,7 +408,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;
 	}
 
@@ -428,7 +428,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;
 	}
 
@@ -461,22 +461,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,
@@ -489,7 +489,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));
@@ -512,7 +512,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;
 			}
 
@@ -537,7 +537,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;
@@ -585,7 +585,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;
 	}
 
@@ -612,7 +612,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;
@@ -655,7 +655,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

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 14/19] kni: remove unnecessary 'out of memory' message
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (32 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 13/19] kni: update kernel logging Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
                   ` (5 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 1dca5f0..9585879 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -156,7 +156,6 @@ kni_net_rx_normal(struct kni_dev *kni)
 
 		skb = dev_alloc_skb(len + 2);
 		if (!skb) {
-			pr_err("Out of mem, dropping pkts\n");
 			/* Update statistics */
 			kni->stats.rx_dropped++;
 			continue;
@@ -335,9 +334,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 				kni->mbuf_kva;
 
 		skb = dev_alloc_skb(len + 2);
-		if (skb == NULL)
-			pr_err("Out of mem, dropping pkts\n");
-		else {
+		if (skb) {
 			/* Align IP on 16B boundary */
 			skb_reserve(skb, 2);
 			memcpy(skb_put(skb, len), data_kva, len);
@@ -349,7 +346,6 @@ 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) {
-			pr_err("Out of mem, dropping pkts\n");
 			kni->stats.rx_dropped++;
 			continue;
 		}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 15/19] kni: move functions to eliminate function declarations
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (33 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 16/19] kni: remove compile time debug configuration Ferruh Yigit
                   ` (4 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Function implementations kept same.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 301 ++++++++++++++++-----------------
 lib/librte_eal/linuxapp/kni/kni_net.c  | 293 ++++++++++++++++----------------
 2 files changed, 287 insertions(+), 307 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 6947483..235ce1a 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -50,35 +50,6 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 extern const struct pci_device_id ixgbe_pci_tbl[];
 extern const struct pci_device_id igb_pci_tbl[];
 
-static int kni_open(struct inode *inode, struct file *file);
-static int kni_release(struct inode *inode, struct file *file);
-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 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 const struct file_operations kni_fops = {
-	.owner = THIS_MODULE,
-	.open = kni_open,
-	.release = kni_release,
-	.unlocked_ioctl = (void *)kni_ioctl,
-	.compat_ioctl = (void *)kni_compat_ioctl,
-};
-
-static struct miscdevice kni_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = KNI_DEVICE,
-	.fops = &kni_fops,
-};
-
 /* loopback mode */
 static char *lo_mode;
 
@@ -149,72 +120,56 @@ static struct pernet_operations kni_net_ops = {
 #endif
 };
 
-static int __init
-kni_init(void)
+static int
+kni_thread_single(void *data)
 {
-	int rc;
-
-	pr_debug("######## DPDK kni module loading ########\n");
-
-	if (kni_parse_kthread_mode() < 0) {
-		pr_err("Invalid parameter for kthread_mode\n");
-		return -EINVAL;
-	}
+	struct kni_net *knet = data;
+	int j;
+	struct kni_dev *dev;
 
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	rc = register_pernet_subsys(&kni_net_ops);
+	while (!kthread_should_stop()) {
+		down_read(&knet->kni_list_lock);
+		for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
+			list_for_each_entry(dev, &knet->kni_list_head, list) {
+#ifdef RTE_KNI_VHOST
+				kni_chk_vhost_rx(dev);
 #else
-	rc = register_pernet_gen_subsys(&kni_net_id, &kni_net_ops);
+				kni_net_rx(dev);
+#endif
+				kni_net_poll_resp(dev);
+			}
+		}
+		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
-	if (rc)
-		return -EPERM;
-
-	rc = misc_register(&kni_misc);
-	if (rc != 0) {
-		pr_err("Misc registration failed\n");
-		goto out;
 	}
 
-	/* Configure the lo mode according to the input parameter */
-	kni_net_config_lo_mode(lo_mode);
-
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
 	return 0;
-
-out:
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	unregister_pernet_subsys(&kni_net_ops);
-#else
-	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
-#endif
-	return rc;
 }
 
-static void __exit
-kni_exit(void)
+static int
+kni_thread_multiple(void *param)
 {
-	misc_deregister(&kni_misc);
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	unregister_pernet_subsys(&kni_net_ops);
+	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
-	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
+			kni_net_rx(dev);
 #endif
-	pr_debug("####### 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;
+			kni_net_poll_resp(dev);
+		}
+#ifdef RTE_KNI_PREEMPT_DEFAULT
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
+#endif
+	}
 
 	return 0;
 }
@@ -249,6 +204,27 @@ kni_open(struct inode *inode, struct file *file)
 }
 
 static int
+kni_dev_remove(struct kni_dev *dev)
+{
+	if (!dev)
+		return -ENODEV;
+
+	if (dev->pci_dev) {
+		if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
+			ixgbe_kni_remove(dev->pci_dev);
+		else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
+			igb_kni_remove(dev->pci_dev);
+	}
+
+	if (dev->net_dev) {
+		unregister_netdev(dev->net_dev);
+		free_netdev(dev->net_dev);
+	}
+
+	return 0;
+}
+
+static int
 kni_release(struct inode *inode, struct file *file)
 {
 	struct net *net = file->private_data;
@@ -288,81 +264,6 @@ kni_release(struct inode *inode, struct file *file)
 }
 
 static int
-kni_thread_single(void *data)
-{
-	struct kni_net *knet = data;
-	int j;
-	struct kni_dev *dev;
-
-	while (!kthread_should_stop()) {
-		down_read(&knet->kni_list_lock);
-		for (j = 0; j < KNI_RX_LOOP_NUM; j++) {
-			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(&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
-	}
-
-	return 0;
-}
-
-static int
-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;
-
-	if (dev->pci_dev) {
-		if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
-			ixgbe_kni_remove(dev->pci_dev);
-		else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
-			igb_kni_remove(dev->pci_dev);
-	}
-
-	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)
@@ -660,6 +561,90 @@ kni_compat_ioctl(struct inode *inode,
 	return -EINVAL;
 }
 
+static const struct file_operations kni_fops = {
+	.owner = THIS_MODULE,
+	.open = kni_open,
+	.release = kni_release,
+	.unlocked_ioctl = (void *)kni_ioctl,
+	.compat_ioctl = (void *)kni_compat_ioctl,
+};
+
+static struct miscdevice kni_misc = {
+	.minor = MISC_DYNAMIC_MINOR,
+	.name = KNI_DEVICE,
+	.fops = &kni_fops,
+};
+
+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 __init
+kni_init(void)
+{
+	int rc;
+
+	pr_debug("######## DPDK kni module loading ########\n");
+
+	if (kni_parse_kthread_mode() < 0) {
+		pr_err("Invalid parameter for kthread_mode\n");
+		return -EINVAL;
+	}
+
+#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) {
+		pr_err("Misc registration failed\n");
+		goto out;
+	}
+
+	/* Configure the lo mode according to the input parameter */
+	kni_net_config_lo_mode(lo_mode);
+
+	pr_debug("######## DPDK kni module loaded  ########\n");
+
+	return 0;
+
+out:
+#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
+	unregister_pernet_subsys(&kni_net_ops);
+#else
+	unregister_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
+	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
+#endif
+	pr_debug("####### DPDK kni module unloaded  #######\n");
+}
+
 module_init(kni_init);
 module_exit(kni_exit);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 9585879..a732cbd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -51,17 +51,61 @@
 /* typedef for rx function */
 typedef void (*kni_net_rx_t)(struct kni_dev *kni);
 
-static int kni_net_tx(struct sk_buff *skb, struct net_device *dev);
 static void kni_net_rx_normal(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo_skb(struct kni_dev *kni);
-static int kni_net_process_request(struct kni_dev *kni,
-			struct rte_kni_request *req);
 
 /* kni rx function pointer, with default to normal rx */
 static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal;
 
 /*
+ * It can be called to process the request.
+ */
+static int
+kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
+{
+	int ret = -1;
+	void *resp_va;
+	unsigned int num;
+	int ret_val;
+
+	if (!kni || !req) {
+		pr_err("No kni instance or request\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&kni->sync_lock);
+
+	/* Construct data */
+	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
+	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
+	if (num < 1) {
+		pr_err("Cannot send to req_q\n");
+		ret = -EBUSY;
+		goto fail;
+	}
+
+	ret_val = wait_event_interruptible_timeout(kni->wq,
+			kni_fifo_count(kni->resp_q), 3 * HZ);
+	if (signal_pending(current) || ret_val <= 0) {
+		ret = -ETIME;
+		goto fail;
+	}
+	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
+	if (num != 1 || resp_va != kni->sync_va) {
+		/* This should never happen */
+		pr_err("No data in resp_q\n");
+		ret = -ENODATA;
+		goto fail;
+	}
+
+	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
+	ret = 0;
+
+fail:
+	mutex_unlock(&kni->sync_lock);
+	return ret;
+}
+
+/*
  * Open and close
  */
 static int
@@ -116,6 +160,101 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 }
 
 /*
+ * Transmit a packet (called by the kernel)
+ */
+#ifdef RTE_KNI_VHOST
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	struct kni_dev *kni = netdev_priv(dev);
+
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#else
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	int len = 0;
+	unsigned int ret;
+	struct kni_dev *kni = netdev_priv(dev);
+	struct rte_kni_mbuf *pkt_kva = NULL;
+	struct rte_kni_mbuf *pkt_va = NULL;
+
+	/* save the timestamp */
+#ifdef HAVE_TRANS_START_HELPER
+	netif_trans_update(dev);
+#else
+	dev->trans_start = jiffies;
+#endif
+
+	/* Check if the length of skb is less than mbuf size */
+	if (skb->len > kni->mbuf_size)
+		goto drop;
+
+	/**
+	 * Check if it has at least one free entry in tx_q and
+	 * one entry in alloc_q.
+	 */
+	if (kni_fifo_free_count(kni->tx_q) == 0 ||
+			kni_fifo_count(kni->alloc_q) == 0) {
+		/**
+		 * If no free entry in tx_q or no entry in alloc_q,
+		 * drops skb and goes out.
+		 */
+		goto drop;
+	}
+
+	/* dequeue a mbuf from alloc_q */
+	ret = kni_fifo_get(kni->alloc_q, (void **)&pkt_va, 1);
+	if (likely(ret == 1)) {
+		void *data_kva;
+
+		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
+		data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va
+				+ kni->mbuf_kva;
+
+		len = skb->len;
+		memcpy(data_kva, skb->data, len);
+		if (unlikely(len < ETH_ZLEN)) {
+			memset(data_kva + len, 0, ETH_ZLEN - len);
+			len = ETH_ZLEN;
+		}
+		pkt_kva->pkt_len = len;
+		pkt_kva->data_len = len;
+
+		/* enqueue mbuf into tx_q */
+		ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1);
+		if (unlikely(ret != 1)) {
+			/* Failing should not happen */
+			pr_err("Fail to enqueue mbuf into tx_q\n");
+			goto drop;
+		}
+	} else {
+		/* Failing should not happen */
+		pr_err("Fail to dequeue mbuf from alloc_q\n");
+		goto drop;
+	}
+
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_bytes += len;
+	kni->stats.tx_packets++;
+
+	return NETDEV_TX_OK;
+
+drop:
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#endif
+
+/*
  * RX: normal working mode
  */
 static void
@@ -401,101 +540,6 @@ kni_net_rx(struct kni_dev *kni)
 }
 
 /*
- * Transmit a packet (called by the kernel)
- */
-#ifdef RTE_KNI_VHOST
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	struct kni_dev *kni = netdev_priv(dev);
-
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#else
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	int len = 0;
-	unsigned int ret;
-	struct kni_dev *kni = netdev_priv(dev);
-	struct rte_kni_mbuf *pkt_kva = NULL;
-	struct rte_kni_mbuf *pkt_va = NULL;
-
-	/* save the timestamp */
-#ifdef HAVE_TRANS_START_HELPER
-	netif_trans_update(dev);
-#else
-	dev->trans_start = jiffies;
-#endif
-
-	/* Check if the length of skb is less than mbuf size */
-	if (skb->len > kni->mbuf_size)
-		goto drop;
-
-	/**
-	 * Check if it has at least one free entry in tx_q and
-	 * one entry in alloc_q.
-	 */
-	if (kni_fifo_free_count(kni->tx_q) == 0 ||
-			kni_fifo_count(kni->alloc_q) == 0) {
-		/**
-		 * If no free entry in tx_q or no entry in alloc_q,
-		 * drops skb and goes out.
-		 */
-		goto drop;
-	}
-
-	/* dequeue a mbuf from alloc_q */
-	ret = kni_fifo_get(kni->alloc_q, (void **)&pkt_va, 1);
-	if (likely(ret == 1)) {
-		void *data_kva;
-
-		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
-		data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va
-				+ kni->mbuf_kva;
-
-		len = skb->len;
-		memcpy(data_kva, skb->data, len);
-		if (unlikely(len < ETH_ZLEN)) {
-			memset(data_kva + len, 0, ETH_ZLEN - len);
-			len = ETH_ZLEN;
-		}
-		pkt_kva->pkt_len = len;
-		pkt_kva->data_len = len;
-
-		/* enqueue mbuf into tx_q */
-		ret = kni_fifo_put(kni->tx_q, (void **)&pkt_va, 1);
-		if (unlikely(ret != 1)) {
-			/* Failing should not happen */
-			pr_err("Fail to enqueue mbuf into tx_q\n");
-			goto drop;
-		}
-	} else {
-		/* Failing should not happen */
-		pr_err("Fail to dequeue mbuf from alloc_q\n");
-		goto drop;
-	}
-
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_bytes += len;
-	kni->stats.tx_packets++;
-
-	return NETDEV_TX_OK;
-
-drop:
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#endif
-
-/*
  * Deal with a transmit timeout.
  */
 static void
@@ -557,55 +601,6 @@ kni_net_poll_resp(struct kni_dev *kni)
 }
 
 /*
- * It can be called to process the request.
- */
-static int
-kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
-{
-	int ret = -1;
-	void *resp_va;
-	unsigned int num;
-	int ret_val;
-
-	if (!kni || !req) {
-		pr_err("No kni instance or request\n");
-		return -EINVAL;
-	}
-
-	mutex_lock(&kni->sync_lock);
-
-	/* Construct data */
-	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
-	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
-	if (num < 1) {
-		pr_err("Cannot send to req_q\n");
-		ret = -EBUSY;
-		goto fail;
-	}
-
-	ret_val = wait_event_interruptible_timeout(kni->wq,
-			kni_fifo_count(kni->resp_q), 3 * HZ);
-	if (signal_pending(current) || ret_val <= 0) {
-		ret = -ETIME;
-		goto fail;
-	}
-	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
-	if (num != 1 || resp_va != kni->sync_va) {
-		/* This should never happen */
-		pr_err("No data in resp_q\n");
-		ret = -ENODATA;
-		goto fail;
-	}
-
-	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
-	ret = 0;
-
-fail:
-	mutex_unlock(&kni->sync_lock);
-	return ret;
-}
-
-/*
  * Return statistics to the caller
  */
 static struct net_device_stats *
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 16/19] kni: remove compile time debug configuration
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (34 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 17/19] kni: updated log messages Ferruh Yigit
                   ` (3 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Since switched to kernel dynamic debugging it is possible to remove
compile time debug log configuration.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 config/common_base                      |  3 ---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 18 -------------
 lib/librte_eal/linuxapp/kni/kni_misc.c  |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_net.c   |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 46 ++++++++++++++++-----------------
 5 files changed, 31 insertions(+), 52 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7830535..4a9e5b0 100644
--- a/config/common_base
+++ b/config/common_base
@@ -533,12 +533,9 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_KNI=n
 CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_KNI_PREEMPT_DEFAULT=y
-CONFIG_RTE_KNI_KO_DEBUG=n
 CONFIG_RTE_KNI_VHOST=n
 CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024
 CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n
-CONFIG_RTE_KNI_VHOST_DEBUG_RX=n
-CONFIG_RTE_KNI_VHOST_DEBUG_TX=n
 
 #
 # Compile the pdump library
diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 7e48203..fa9901d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -112,12 +112,6 @@ struct kni_dev {
 #endif
 };
 
-#ifdef RTE_KNI_KO_DEBUG
-	#define KNI_DBG(args...) pr_debug(args)
-#else
-	#define KNI_DBG(args...)
-#endif
-
 #ifdef RTE_KNI_VHOST
 unsigned int
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
@@ -149,16 +143,4 @@ void ixgbe_kni_remove(struct pci_dev *pdev);
 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);
 
-#ifdef RTE_KNI_VHOST_DEBUG_RX
-	#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...) pr_debug(args)
-#else
-	#define KNI_DBG_TX(args...)
-#endif
-
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 235ce1a..17299da 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -379,7 +379,7 @@ kni_ioctl_create(struct net *net,
 	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",
+	pr_debug("PCI: %02x:%02x.%02x %04x:%04x\n",
 					dev_info.bus,
 					dev_info.devid,
 					dev_info.function,
@@ -407,7 +407,7 @@ kni_ioctl_create(struct net *net,
 			else
 				ret = -1;
 
-			KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n",
+			pr_debug("PCI found: pci=0x%p, lad_dev=0x%p\n",
 							pci, lad_dev);
 			if (ret == 0) {
 				kni->lad_dev = lad_dev;
@@ -527,7 +527,7 @@ kni_ioctl(struct inode *inode,
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
 
-	KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
+	pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
 
 	/*
 	 * Switch according to the ioctl called
@@ -543,7 +543,7 @@ kni_ioctl(struct inode *inode,
 		ret = kni_ioctl_release(net, ioctl_num, ioctl_param);
 		break;
 	default:
-		KNI_DBG("IOCTL default\n");
+		pr_debug("IOCTL default\n");
 		break;
 	}
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index a732cbd..12dd89f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -547,7 +547,7 @@ kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("Transmit timeout at %ld, latency %ld\n", jiffies,
+	pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
 			jiffies - dev->trans_start);
 
 	kni->stats.tx_errors++;
@@ -560,7 +560,7 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	KNI_DBG("kni_net_ioctl %d\n",
+	pr_debug("kni_net_ioctl %d\n",
 		((struct kni_dev *)netdev_priv(dev))->group_id);
 
 	return 0;
@@ -578,7 +578,7 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu)
 	struct rte_kni_request req;
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
+	pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
 
 	memset(&req, 0, sizeof(req));
 	req.req_id = RTE_KNI_REQ_CHANGE_MTU;
@@ -704,7 +704,7 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_init\n");
+	pr_debug("kni_net_init\n");
 
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f4f6f10..947341e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -75,7 +75,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 	struct rte_kni_mbuf *pkt_va = NULL;
 	int ret;
 
-	KNI_DBG_TX("tx offset=%d, len=%d, iovlen=%d\n",
+	pr_debug("tx offset=%d, len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -177,7 +177,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(pkt_len > len))
 		goto drop;
 
-	KNI_DBG_RX("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
+	pr_debug("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, pkt_len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -202,7 +202,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 		/* Failing should not happen */
 		pr_err("Fail to enqueue entries into free_q\n");
 
-	KNI_DBG_RX("receive done %d\n", pkt_len);
+	pr_debug("receive done %d\n", pkt_len);
 
 	return pkt_len;
 
@@ -226,10 +226,10 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	kni = q->kni;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
-	KNI_DBG("start kni_poll on group %d, wait at 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
@@ -332,7 +332,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	    ((nb_mbuf < RX_BURST_SZ) && (nb_mbuf != 0))) {
 		wake_up_interruptible_poll(sk_sleep(&q->sk),
 				   POLLIN | POLLRDNORM | POLLRDBAND);
-		KNI_DBG_RX("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
+		pr_debug("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
 			   nb_mbuf, nb_skb, nb_in);
 	}
 
@@ -363,7 +363,7 @@ kni_sock_sndmsg(struct socket *sock,
 	if (unlikely(q == NULL || q->kni == NULL))
 		return 0;
 
-	KNI_DBG_TX("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
+	pr_debug("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   len, q->flags, (int)m->msg_iter.iov->iov_len);
 #else
@@ -431,7 +431,7 @@ kni_sock_rcvmsg(struct socket *sock,
 #endif /* HAVE_IOV_ITER_MSGHDR */
 		return -EFAULT;
 #endif /* RTE_KNI_VHOST_VNET_HDR_EN */
-	KNI_DBG_RX("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
+	pr_debug("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
 		   (unsigned long)len, q->flags, pkt_len);
 
 	return pkt_len + vnet_hdr_len;
@@ -453,11 +453,11 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 	int s;
 	int ret;
 
-	KNI_DBG("tap ioctl cmd 0x%08x\n", cmd);
+	pr_debug("tap ioctl cmd 0x%08x\n", cmd);
 
 	switch (cmd) {
 	case TUNSETIFF:
-		KNI_DBG("TUNSETIFF\n");
+		pr_debug("TUNSETIFF\n");
 		/* ignore the name, just look at flags */
 		if (get_user(u, &ifr->ifr_flags))
 			return -EFAULT;
@@ -471,7 +471,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETIFF:
-		KNI_DBG("TUNGETIFF\n");
+		pr_debug("TUNGETIFF\n");
 		rcu_read_lock_bh();
 		kni = rcu_dereference_bh(q->kni);
 		if (kni)
@@ -489,7 +489,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETFEATURES:
-		KNI_DBG("TUNGETFEATURES\n");
+		pr_debug("TUNGETFEATURES\n");
 		u = IFF_TAP | IFF_NO_PI;
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		u |= IFF_VNET_HDR;
@@ -499,7 +499,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return 0;
 
 	case TUNSETSNDBUF:
-		KNI_DBG("TUNSETSNDBUF\n");
+		pr_debug("TUNSETSNDBUF\n");
 		if (get_user(u, up))
 			return -EFAULT;
 
@@ -510,7 +510,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		s = q->vnet_hdr_sz;
 		if (put_user(s, sp))
 			return -EFAULT;
-		KNI_DBG("TUNGETVNETHDRSZ %d\n", s);
+		pr_debug("TUNGETVNETHDRSZ %d\n", s);
 		return 0;
 
 	case TUNSETVNETHDRSZ:
@@ -519,12 +519,12 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		if (s < (int)sizeof(struct virtio_net_hdr))
 			return -EINVAL;
 
-		KNI_DBG("TUNSETVNETHDRSZ %d\n", s);
+		pr_debug("TUNSETVNETHDRSZ %d\n", s);
 		q->vnet_hdr_sz = s;
 		return 0;
 
 	case TUNSETOFFLOAD:
-		KNI_DBG("TUNSETOFFLOAD %lx\n", arg);
+		pr_debug("TUNSETOFFLOAD %lx\n", arg);
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		/* not support any offload yet */
 		if (!(q->flags & IFF_VNET_HDR))
@@ -536,7 +536,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 #endif
 
 	default:
-		KNI_DBG("NOT SUPPORT\n");
+		pr_debug("NOT SUPPORT\n");
 		return -EINVAL;
 	}
 }
@@ -584,7 +584,7 @@ kni_sock_release(struct socket *sock)
 
 	sock_put(&q->sk);
 
-	KNI_DBG("dummy sock release done\n");
+	pr_debug("dummy sock release done\n");
 
 	return 0;
 }
@@ -593,7 +593,7 @@ int
 kni_sock_getname(struct socket *sock, struct sockaddr *addr,
 		int *sockaddr_len, int peer)
 {
-	KNI_DBG("dummy sock getname\n");
+	pr_debug("dummy sock getname\n");
 	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
@@ -731,11 +731,11 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	kni->vq_status = BE_START;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -828,7 +828,7 @@ kni_vhost_backend_release(struct kni_dev *kni)
 	/* dettach from kni */
 	q->kni = NULL;
 
-	KNI_DBG("release backend done\n");
+	pr_debug("release backend done\n");
 
 	return 0;
 }
@@ -843,7 +843,7 @@ kni_vhost_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_STOP;
 
-	KNI_DBG("kni_vhost_init done\n");
+	pr_debug("kni_vhost_init done\n");
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 17/19] kni: updated log messages
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (35 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 16/19] kni: remove compile time debug configuration Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
                   ` (2 subsequent siblings)
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Remove some function entrance logs and changed log level of some logs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 9 ++-------
 lib/librte_eal/linuxapp/kni/kni_net.c  | 6 ++----
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 17299da..e012b50 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -186,7 +186,7 @@ kni_open(struct inode *inode, struct file *file)
 
 	/* Create kernel thread for single mode */
 	if (multiple_kthread_on == 0) {
-		pr_debug("Single kernel thread for all KNI devices\n");
+		pr_info("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");
@@ -195,7 +195,7 @@ kni_open(struct inode *inode, struct file *file)
 			return PTR_ERR(knet->kni_kthread);
 		}
 	} else
-		pr_debug("Multiple kernel thread mode enabled\n");
+		pr_info("Multiple kernel thread mode enabled\n");
 
 	file->private_data = get_net(net);
 	pr_debug("/dev/kni opened\n");
@@ -596,8 +596,6 @@ kni_init(void)
 {
 	int rc;
 
-	pr_debug("######## DPDK kni module loading ########\n");
-
 	if (kni_parse_kthread_mode() < 0) {
 		pr_err("Invalid parameter for kthread_mode\n");
 		return -EINVAL;
@@ -620,8 +618,6 @@ kni_init(void)
 	/* Configure the lo mode according to the input parameter */
 	kni_net_config_lo_mode(lo_mode);
 
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
 	return 0;
 
 out:
@@ -642,7 +638,6 @@ kni_exit(void)
 #else
 	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
 #endif
-	pr_debug("####### DPDK kni module unloaded  #######\n");
 }
 
 module_init(kni_init);
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 12dd89f..7c3e30b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -560,8 +560,8 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	pr_debug("kni_net_ioctl %d\n",
-		((struct kni_dev *)netdev_priv(dev))->group_id);
+	pr_debug("kni_net_ioctl group:%d cmd:%d\n",
+		((struct kni_dev *)netdev_priv(dev))->group_id, cmd);
 
 	return 0;
 }
@@ -704,8 +704,6 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	pr_debug("kni_net_init\n");
-
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 18/19] kni: prefer uint32_t to unsigned int
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (36 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 17/19] kni: updated log messages Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
  2016-10-05 10:38 ` [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Pattan, Reshma
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  8 ++++----
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 17 +++++++----------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 24 ++++++++++++------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 25 ++++++++++++-------------
 5 files changed, 46 insertions(+), 50 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index fa9901d..f5a72cd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -55,7 +55,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned int core_id;        /* Core ID to bind */
+	uint32_t core_id;            /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -96,7 +96,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned int mbuf_size;
+	uint32_t mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
@@ -113,7 +113,7 @@ struct kni_dev {
 };
 
 #ifdef RTE_KNI_VHOST
-unsigned int
+uint32_t
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
 int kni_chk_vhost_rx(struct kni_dev *kni);
 int kni_vhost_init(struct kni_dev *kni);
@@ -125,7 +125,7 @@ struct kni_vhost_queue {
 	int vnet_hdr_sz;
 	struct kni_dev *kni;
 	int sockfd;
-	unsigned int flags;
+	uint32_t flags;
 	struct sk_buff *cache;
 	struct rte_kni_fifo *fifo;
 };
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 71bc2a9..77048a1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -31,12 +31,12 @@
  * Adds num elements into the fifo. Return the number actually written
  */
 static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int fifo_write = fifo->write;
-	unsigned int fifo_read = fifo->read;
-	unsigned int new_write = fifo_write;
+	uint32_t i = 0;
+	uint32_t fifo_write = fifo->write;
+	uint32_t fifo_read = fifo->read;
+	uint32_t new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -55,11 +55,11 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
  * Get up to num elements from the fifo. Return the number actully read
  */
 static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int new_read = fifo->read;
-	unsigned int fifo_write = fifo->write;
+	uint32_t i = 0;
+	uint32_t new_read = fifo->read;
+	uint32_t fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned int
+static inline uint32_t
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
+kni_fifo_init(struct rte_kni_fifo *fifo, uint32_t size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index e012b50..95272cc 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -55,7 +55,7 @@ static char *lo_mode;
 
 /* Kernel thread mode */
 static char *kthread_mode;
-static unsigned int multiple_kthread_on;
+static uint32_t multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
@@ -279,8 +279,8 @@ kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev)
 }
 
 static int
-kni_ioctl_create(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_create(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret;
@@ -473,8 +473,8 @@ kni_ioctl_create(struct net *net,
 }
 
 static int
-kni_ioctl_release(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_release(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret = -EINVAL;
@@ -520,9 +520,7 @@ kni_ioctl_release(struct net *net,
 }
 
 static int
-kni_ioctl(struct inode *inode,
-	unsigned int ioctl_num,
-	unsigned long ioctl_param)
+kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
 {
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
@@ -551,8 +549,7 @@ kni_ioctl(struct inode *inode,
 }
 
 static int
-kni_compat_ioctl(struct inode *inode,
-		unsigned int ioctl_num,
+kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
 		unsigned long ioctl_param)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 7c3e30b..430f158 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -64,7 +64,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned int num;
+	uint32_t num;
 	int ret_val;
 
 	if (!kni || !req) {
@@ -178,7 +178,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned int ret;
+	uint32_t ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -260,9 +260,9 @@ drop:
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rx, num_fq;
+	uint32_t i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -278,7 +278,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
+	num_rx = min_t(uint32_t, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, (void **)va, num_rx);
@@ -347,9 +347,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
+	uint32_t i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -374,7 +374,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -436,9 +436,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rq, num_fq, num;
+	uint32_t i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va[MBUF_BURST_SZ];
 	void *data_kva;
@@ -454,7 +454,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -617,7 +617,7 @@ kni_net_stats(struct net_device *dev)
 static int
 kni_net_header(struct sk_buff *skb, struct net_device *dev,
 		unsigned short type, const void *daddr,
-		const void *saddr, unsigned int len)
+		const void *saddr, uint32_t len)
 {
 	struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 947341e..3ba0c57 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -213,13 +213,13 @@ drop:
 	return 0;
 }
 
-static unsigned int
+static uint32_t
 kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int mask = 0;
+	uint32_t mask = 0;
 
 	if (unlikely(q == NULL || q->kni == NULL))
 		return POLLERR;
@@ -281,9 +281,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned int nb_in, nb_mbuf, nb_skb;
-	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
-	unsigned int nb_burst, nb_backlog, i;
+	uint32_t nb_in, nb_mbuf, nb_skb;
+	const uint32_t BURST_MASK = RX_BURST_SZ - 1;
+	uint32_t nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
+	nb_in = min_t(uint32_t, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
@@ -439,16 +439,15 @@ kni_sock_rcvmsg(struct socket *sock,
 
 /* dummy tap like ioctl */
 static int
-kni_sock_ioctl(struct socket *sock, unsigned int cmd,
-	      unsigned long arg)
+kni_sock_ioctl(struct socket *sock, uint32_t cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	struct ifreq __user *ifr = argp;
-	unsigned int __user *up = argp;
+	uint32_t __user *up = argp;
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int u;
+	uint32_t u;
 	int __user *sp = argp;
 	int s;
 	int ret;
@@ -542,7 +541,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 static int
-kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
+kni_sock_compat_ioctl(struct socket *sock, uint32_t cmd,
 		     unsigned long arg)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v2 19/19] kni: move kernel version ifdefs to compat header
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (37 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
@ 2016-09-16 16:26 ` Ferruh Yigit
  2016-10-05 10:38 ` [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Pattan, Reshma
  39 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-16 16:26 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h    | 12 ++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 16 +++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 9ae50a7..78da08e 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -20,6 +20,14 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
 #define sk_sleep(s) ((s)->sk_sleep)
+#else
+#define HAVE_SOCKET_WQ
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#define HAVE_STATIC_SOCK_MAP_FD
+#else
+#define kni_sock_map_fd(s) sock_map_fd(s, 0)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
@@ -39,6 +47,10 @@
 #define HAVE_REBUILD_HEADER
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#define HAVE_SK_ALLOC_KERN_PARAM
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
 #define HAVE_TRANS_START_HELPER
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 3ba0c57..f54c34b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,7 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#ifdef HAVE_STATIC_SOCK_MAP_FD
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
@@ -57,8 +57,6 @@ static int kni_sock_map_fd(struct socket *sock)
 	fd_install(fd, file);
 	return fd;
 }
-#else
-#define kni_sock_map_fd(s)             sock_map_fd(s, 0)
 #endif
 
 static struct proto kni_raw_proto = {
@@ -225,17 +223,13 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
+	poll_wait(file, &sock->wq->wait, wait);
 #else
 	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	poll_wait(file, &sock->wq->wait, wait);
-#else
 	poll_wait(file, &sock->wait, wait);
 #endif
 
@@ -663,7 +657,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	if (kni->vhost_queue != NULL)
 		return -1;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#ifdef HAVE_SK_ALLOC_KERN_PARAM
 	q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
 			&kni_raw_proto, 0);
 #else
@@ -729,7 +723,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 00/19] KNI checkpatch cleanup
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup Ferruh Yigit
@ 2016-09-26 15:39   ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 01/19] kni: move externs to the header file Ferruh Yigit
                       ` (19 more replies)
  0 siblings, 20 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
Only functional change is related logging, switched to kernel dynamic
logging and compile time KNI debug options removed, some log message
levels updated.

v3:
rebased on latest master
depends on http://dpdk.org/dev/patchwork/patch/16060/

v2:
keep variable externs in .c file

Ferruh Yigit (19):
  kni: move externs to the header file
  kni: uninitialize global variables
  kni: make static struct const
  kni: whitespace, indentation, long line corrections
  kni: prefer unsigned int to unsigned
  kni: remove useless return
  kni: comparisons should place the constant on the right
  kni: trailing statements should be on next line
  kni: do not use assignment in if condition
  kni: macros with complex values should be enclosed in parentheses
  kni: prefer min_t to min
  kni: prefer ether_addr_copy to memcpy
  kni: update kernel logging
  kni: remove unnecessary 'out of memory' message
  kni: move functions to eliminate function declarations
  kni: remove compile time debug configuration
  kni: updated log messages
  kni: prefer uint32_t to unsigned int
  kni: move kernel version ifdefs to compat header

 config/common_base                        |   3 -
 lib/librte_eal/linuxapp/kni/compat.h      |  18 +-
 lib/librte_eal/linuxapp/kni/kni_dev.h     |  51 ++--
 lib/librte_eal/linuxapp/kni/kni_ethtool.c |  39 ++-
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  30 +--
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 401 ++++++++++++++----------------
 lib/librte_eal/linuxapp/kni/kni_net.c     | 363 +++++++++++++--------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 199 +++++++--------
 8 files changed, 541 insertions(+), 563 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 01/19] kni: move externs to the header file
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 02/19] kni: uninitialize global variables Ferruh Yigit
                       ` (18 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---

v2:
keep variable externs in .c file
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 11 +++++++++++
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 14 ++------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 11 +----------
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 4a4a8e1..9128523 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -140,6 +140,17 @@ struct kni_vhost_queue {
 
 #endif
 
+void kni_net_rx(struct kni_dev *kni);
+void kni_net_init(struct net_device *dev);
+void kni_net_config_lo_mode(char *lo_str);
+void kni_net_poll_resp(struct kni_dev *kni);
+void kni_set_ethtool_ops(struct net_device *netdev);
+
+int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void ixgbe_kni_remove(struct pci_dev *pdev);
+int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
+void igb_kni_remove(struct pci_dev *pdev);
+
 #ifdef RTE_KNI_VHOST_DEBUG_RX
 	#define KNI_DBG_RX(args...) printk(KERN_DEBUG "KNI RX: " args)
 #else
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 47b730c..113fc20 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -48,18 +48,8 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 
 #define KNI_MAX_DEVICES 32
 
-extern void kni_net_rx(struct kni_dev *kni);
-extern void kni_net_init(struct net_device *dev);
-extern void kni_net_config_lo_mode(char *lo_str);
-extern void kni_net_poll_resp(struct kni_dev *kni);
-extern void kni_set_ethtool_ops(struct net_device *netdev);
-
-extern int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void ixgbe_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id ixgbe_pci_tbl[];
-extern int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
-extern void igb_kni_remove(struct pci_dev *pdev);
-extern struct pci_device_id igb_pci_tbl[];
+extern const struct pci_device_id ixgbe_pci_tbl[];
+extern const struct pci_device_id igb_pci_tbl[];
 
 static int kni_open(struct inode *inode, struct file *file);
 static int kni_release(struct inode *inode, struct file *file);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index a3ca849..7aed96e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/if_tun.h>
 #include <linux/version.h>
+#include <linux/file.h>
 
 #include "compat.h"
 #include "kni_dev.h"
@@ -39,17 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-extern void put_unused_fd(unsigned int fd);
-
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
-extern struct file*
-sock_alloc_file(struct socket *sock,
-		int flags, const char *dname);
-
-extern int get_unused_fd_flags(unsigned flags);
-
-extern void fd_install(unsigned int fd, struct file *file);
-
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 02/19] kni: uninitialize global variables
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 01/19] kni: move externs to the header file Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 03/19] kni: make static struct const Ferruh Yigit
                       ` (17 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 113fc20..f051595 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -81,11 +81,11 @@ static struct miscdevice kni_misc = {
 };
 
 /* loopback mode */
-static char *lo_mode = NULL;
+static char *lo_mode;
 
 /* Kernel thread mode */
-static char *kthread_mode = NULL;
-static unsigned multiple_kthread_on = 0;
+static char *kthread_mode;
+static unsigned int multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 03/19] kni: make static struct const
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 01/19] kni: move externs to the header file Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 02/19] kni: uninitialize global variables Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
                       ` (16 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index f051595..37e9295 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -66,7 +66,7 @@ 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 = {
+static const struct file_operations kni_fops = {
 	.owner = THIS_MODULE,
 	.open = kni_open,
 	.release = kni_release,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 04/19] kni: whitespace, indentation, long line corrections
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (2 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 03/19] kni: make static struct const Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
                       ` (15 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h     | 11 +++---
 lib/librte_eal/linuxapp/kni/kni_ethtool.c | 39 +++++++++++++++-----
 lib/librte_eal/linuxapp/kni/kni_fifo.h    |  2 +-
 lib/librte_eal/linuxapp/kni/kni_misc.c    | 20 ++++++-----
 lib/librte_eal/linuxapp/kni/kni_net.c     | 13 ++++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c   | 60 ++++++++++++++++---------------
 6 files changed, 88 insertions(+), 57 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 9128523..e1c79b1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -85,7 +85,7 @@ struct kni_dev {
 	/* response queue */
 	void *resp_q;
 
-	void * sync_kva;
+	void *sync_kva;
 	void *sync_va;
 
 	void *mbuf_kva;
@@ -98,12 +98,13 @@ struct kni_dev {
 	unsigned long synchro;
 
 #ifdef RTE_KNI_VHOST
-	struct kni_vhost_queue* vhost_queue;
+	struct kni_vhost_queue *vhost_queue;
+
 	volatile enum {
 		BE_STOP = 0x1,
 		BE_START = 0x2,
 		BE_FINISH = 0x4,
-	}vq_status;
+	} vq_status;
 #endif
 	/* buffers */
 	void *pa[MBUF_BURST_SZ];
@@ -134,8 +135,8 @@ struct kni_vhost_queue {
 	struct kni_dev *kni;
 	int sockfd;
 	unsigned int flags;
-	struct sk_buff* cache;
-	struct rte_kni_fifo* fifo;
+	struct sk_buff *cache;
+	struct rte_kni_fifo *fifo;
 };
 
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_ethtool.c b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
index 06b6d46..0c88589 100644
--- a/lib/librte_eal/linuxapp/kni/kni_ethtool.c
+++ b/lib/librte_eal/linuxapp/kni/kni_ethtool.c
@@ -31,6 +31,7 @@ static int
 kni_check_if_running(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	if (priv->lad_dev)
 		return 0;
 	else
@@ -41,6 +42,7 @@ static void
 kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_drvinfo(priv->lad_dev, info);
 }
 
@@ -48,6 +50,7 @@ static int
 kni_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_settings(priv->lad_dev, ecmd);
 }
 
@@ -55,6 +58,7 @@ static int
 kni_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_settings(priv->lad_dev, ecmd);
 }
 
@@ -62,6 +66,7 @@ static void
 kni_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_wol(priv->lad_dev, wol);
 }
 
@@ -69,6 +74,7 @@ static int
 kni_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_wol(priv->lad_dev, wol);
 }
 
@@ -76,6 +82,7 @@ static int
 kni_nway_reset(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->nway_reset(priv->lad_dev);
 }
 
@@ -83,6 +90,7 @@ static int
 kni_get_eeprom_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom_len(priv->lad_dev);
 }
 
@@ -91,6 +99,7 @@ kni_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -100,6 +109,7 @@ kni_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 							u8 *bytes)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_eeprom(priv->lad_dev, eeprom,
 								bytes);
 }
@@ -108,6 +118,7 @@ static void
 kni_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ringparam(priv->lad_dev, ring);
 }
 
@@ -115,6 +126,7 @@ static int
 kni_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_ringparam(priv->lad_dev, ring);
 }
 
@@ -122,6 +134,7 @@ static void
 kni_get_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_pauseparam(priv->lad_dev, pause);
 }
 
@@ -129,6 +142,7 @@ static int
 kni_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam *pause)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->set_pauseparam(priv->lad_dev,
 								pause);
 }
@@ -137,6 +151,7 @@ static u32
 kni_get_msglevel(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_msglevel(priv->lad_dev);
 }
 
@@ -144,6 +159,7 @@ static void
 kni_set_msglevel(struct net_device *dev, u32 data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->set_msglevel(priv->lad_dev, data);
 }
 
@@ -151,6 +167,7 @@ static int
 kni_get_regs_len(struct net_device *dev)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_regs_len(priv->lad_dev);
 }
 
@@ -158,6 +175,7 @@ static void
 kni_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_regs(priv->lad_dev, regs, p);
 }
 
@@ -165,6 +183,7 @@ static void
 kni_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_strings(priv->lad_dev, stringset,
 								data);
 }
@@ -173,6 +192,7 @@ static int
 kni_get_sset_count(struct net_device *dev, int sset)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	return priv->lad_dev->ethtool_ops->get_sset_count(priv->lad_dev, sset);
 }
 
@@ -181,24 +201,25 @@ kni_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats,
 								u64 *data)
 {
 	struct kni_dev *priv = netdev_priv(dev);
+
 	priv->lad_dev->ethtool_ops->get_ethtool_stats(priv->lad_dev, stats,
 								data);
 }
 
 struct ethtool_ops kni_ethtool_ops = {
-	.begin 				= kni_check_if_running,
+	.begin			= kni_check_if_running,
 	.get_drvinfo		= kni_get_drvinfo,
 	.get_settings		= kni_get_settings,
 	.set_settings		= kni_set_settings,
 	.get_regs_len		= kni_get_regs_len,
-	.get_regs			= kni_get_regs,
-	.get_wol			= kni_get_wol,
-	.set_wol			= kni_set_wol,
-	.nway_reset			= kni_nway_reset,
-	.get_link			= ethtool_op_get_link,
+	.get_regs		= kni_get_regs,
+	.get_wol		= kni_get_wol,
+	.set_wol		= kni_set_wol,
+	.nway_reset		= kni_nway_reset,
+	.get_link		= ethtool_op_get_link,
 	.get_eeprom_len		= kni_get_eeprom_len,
-	.get_eeprom			= kni_get_eeprom,
-	.set_eeprom			= kni_set_eeprom,
+	.get_eeprom		= kni_get_eeprom,
+	.set_eeprom		= kni_set_eeprom,
 	.get_ringparam		= kni_get_ringparam,
 	.set_ringparam		= kni_set_ringparam,
 	.get_pauseparam		= kni_get_pauseparam,
@@ -207,7 +228,7 @@ struct ethtool_ops kni_ethtool_ops = {
 	.set_msglevel		= kni_set_msglevel,
 	.get_strings		= kni_get_strings,
 	.get_sset_count		= kni_get_sset_count,
-	.get_ethtool_stats  = kni_get_ethtool_stats,
+	.get_ethtool_stats	= kni_get_ethtool_stats,
 };
 
 void
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 3ea750e..4006b1f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -79,7 +79,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
 static inline unsigned
 kni_fifo_count(struct rte_kni_fifo *fifo)
 {
-	return (fifo->len + fifo->write - fifo->read) & ( fifo->len - 1);
+	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
 }
 
 /**
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 37e9295..4145886 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -99,10 +99,12 @@ struct kni_net {
 	struct list_head kni_list_head;
 };
 
-static int __net_init kni_init_net(struct net *net)
+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);
+
 	memset(knet, 0, sizeof(*knet));
 #else
 	struct kni_net *knet;
@@ -134,9 +136,11 @@ static int __net_init kni_init_net(struct net *net)
 #endif
 }
 
-static void __net_exit kni_exit_net(struct net *net)
+static void __net_exit
+kni_exit_net(struct net *net)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
+
 	mutex_destroy(&knet->kni_kthread_lock);
 #ifndef HAVE_SIMPLIFIED_PERNET_OPERATIONS
 	kfree(knet);
@@ -308,8 +312,8 @@ kni_thread_single(void *data)
 		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));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -332,8 +336,8 @@ kni_thread_multiple(void *param)
 			kni_net_poll_resp(dev);
 		}
 #ifdef RTE_KNI_PREEMPT_DEFAULT
-		schedule_timeout_interruptible(usecs_to_jiffies( \
-				KNI_KTHREAD_RESCHEDULE_INTERVAL));
+		schedule_timeout_interruptible(
+			usecs_to_jiffies(KNI_KTHREAD_RESCHEDULE_INTERVAL));
 #endif
 	}
 
@@ -521,7 +525,7 @@ kni_ioctl_create(struct net *net,
 
 	/* Support Ethtool */
 	while (pci) {
-		KNI_PRINT("pci_bus: %02x:%02x:%02x \n",
+		KNI_PRINT("pci_bus: %02x:%02x:%02x\n",
 					pci->bus->number,
 					PCI_SLOT(pci->devfn),
 					PCI_FUNC(pci->devfn));
@@ -602,7 +606,7 @@ kni_ioctl_release(struct net *net,
 	struct rte_kni_device_info dev_info;
 
 	if (_IOC_SIZE(ioctl_num) > sizeof(dev_info))
-			return -EINVAL;
+		return -EINVAL;
 
 	ret = copy_from_user(&dev_info, (void *)ioctl_param, sizeof(dev_info));
 	if (ret) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 5d8711c..138297f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -245,7 +245,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	uint32_t len;
 	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
-	void * data_kva;
+	void *data_kva;
 	struct rte_kni_mbuf *alloc_kva;
 	void *alloc_data_kva;
 
@@ -529,7 +529,7 @@ drop:
  * Deal with a transmit timeout.
  */
 static void
-kni_net_tx_timeout (struct net_device *dev)
+kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
@@ -643,6 +643,7 @@ static struct net_device_stats *
 kni_net_stats(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
+
 	return &kni->stats;
 }
 
@@ -663,7 +664,6 @@ kni_net_header(struct sk_buff *skb, struct net_device *dev,
 	return dev->hard_header_len;
 }
 
-
 /*
  * Re-fill the eth header
  */
@@ -688,9 +688,11 @@ kni_net_rebuild_header(struct sk_buff *skb)
  *
  * Returns 0 on success, negative on failure
  **/
-static int kni_net_set_mac(struct net_device *netdev, void *p)
+static int
+kni_net_set_mac(struct net_device *netdev, void *p)
 {
 	struct sockaddr *addr = p;
+
 	if (!is_valid_ether_addr((unsigned char *)(addr->sa_data)))
 		return -EADDRNOTAVAIL;
 	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
@@ -698,7 +700,8 @@ static int kni_net_set_mac(struct net_device *netdev, void *p)
 }
 
 #ifdef HAVE_CHANGE_CARRIER_CB
-static int kni_net_change_carrier(struct net_device *dev, bool new_carrier)
+static int
+kni_net_change_carrier(struct net_device *dev, bool new_carrier)
 {
 	if (new_carrier)
 		netif_carrier_on(dev);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 7aed96e..b4d91ca 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,11 +40,12 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
 	int fd = get_unused_fd_flags(0);
+
 	if (fd < 0)
 		return fd;
 
@@ -101,7 +102,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 
 		pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva;
 		data_kva = pkt_kva->buf_addr + pkt_kva->data_off
-		           - kni->mbuf_va + kni->mbuf_kva;
+			- kni->mbuf_va + kni->mbuf_kva;
 
 #ifdef HAVE_IOV_ITER_MSGHDR
 		copy_from_iter(data_kva, len, &m->msg_iter);
@@ -149,7 +150,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
 	struct rte_kni_mbuf *va;
-	void * data_kva;
+	void *data_kva;
 	struct sk_buff *skb;
 	struct kni_vhost_queue *q = kni->vhost_queue;
 
@@ -164,7 +165,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(skb == NULL))
 		return 0;
 
-	kva = (struct rte_kni_mbuf*)skb->data;
+	kva = (struct rte_kni_mbuf *)skb->data;
 
 	/* free skb to cache */
 	skb->data = NULL;
@@ -213,7 +214,7 @@ drop:
 }
 
 static unsigned int
-kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
+kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
@@ -224,7 +225,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
@@ -232,7 +233,7 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait)
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
 	poll_wait(file, &sock->wq->wait, wait);
 #else
 	poll_wait(file, &sock->wait, wait);
@@ -260,7 +261,7 @@ kni_vhost_enqueue(struct kni_dev *kni, struct kni_vhost_queue *q,
 	struct rte_kni_mbuf *kva;
 
 	kva = (void *)(va) - kni->mbuf_va + kni->mbuf_kva;
-	(skb)->data = (unsigned char*)kva;
+	(skb)->data = (unsigned char *)kva;
 	(skb)->len = kva->data_len;
 	skb_queue_tail(&q->sk.sk_receive_queue, skb);
 }
@@ -270,6 +271,7 @@ kni_vhost_enqueue_burst(struct kni_dev *kni, struct kni_vhost_queue *q,
 	  struct sk_buff **skb, struct rte_kni_mbuf **va)
 {
 	int i;
+
 	for (i = 0; i < RX_BURST_SZ; skb++, va++, i++)
 		kni_vhost_enqueue(kni, q, *skb, *va);
 }
@@ -341,7 +343,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");
+	KNI_ERR("Fail to enqueue fifo, it shouldn't happen\n");
 	BUG_ON(1);
 
 	return 0;
@@ -482,8 +484,8 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 			return -ENOLINK;
 
 		ret = 0;
-		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ) ||
-		    put_user(q->flags, &ifr->ifr_flags))
+		if (copy_to_user(&ifr->ifr_name, kni->net_dev->name, IFNAMSIZ)
+				|| put_user(q->flags, &ifr->ifr_flags))
 			ret = -EFAULT;
 		dev_put(kni->net_dev);
 		return ret;
@@ -552,10 +554,10 @@ kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 #define KNI_VHOST_WAIT_WQ_SAFE()                        \
-do {		                                	\
+do {							\
 	while ((BE_FINISH | BE_STOP) == kni->vq_status) \
-		msleep(1);                              \
-}while(0)                                               \
+		msleep(1);				\
+} while (0)						\
 
 
 static int
@@ -589,12 +591,11 @@ kni_sock_release(struct socket *sock)
 }
 
 int
-kni_sock_getname (struct socket *sock,
-		  struct sockaddr *addr,
-		  int *sockaddr_len, int peer)
+kni_sock_getname(struct socket *sock, struct sockaddr *addr,
+		int *sockaddr_len, int peer)
 {
 	KNI_DBG("dummy sock getname\n");
-	((struct sockaddr_ll*)addr)->sll_family = AF_PACKET;
+	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
 
@@ -637,7 +638,7 @@ kni_sk_destruct(struct sock *sk)
 
 	/* make sure there's no packet in buffer */
 	while (skb_dequeue(&sk->sk_receive_queue) != NULL)
-	       ;
+		;
 
 	mb();
 
@@ -685,8 +686,9 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	}
 
 	/* cache init */
-	q->cache = kzalloc(RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
-			   GFP_KERNEL);
+	q->cache = kzalloc(
+		RTE_KNI_VHOST_MAX_CACHE_SIZE * sizeof(struct sk_buff),
+		GFP_KERNEL);
 	if (!q->cache)
 		goto free_fd;
 
@@ -699,7 +701,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	for (i = 0; i < RTE_KNI_VHOST_MAX_CACHE_SIZE; i++) {
 		elem = &q->cache[i];
-		kni_fifo_put(fifo, (void**)&elem, 1);
+		kni_fifo_put(fifo, (void **)&elem, 1);
 	}
 	q->fifo = fifo;
 
@@ -729,14 +731,12 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,"
-		  "sk->sk_wq=0x%16llx",
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,"
-		  "sk->sk_sleep=0x%16llx",
+	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -759,7 +759,7 @@ free_sock:
 	q->sock = NULL;
 
 free_sk:
-	sk_free((struct sock*)q);
+	sk_free((struct sock *)q);
 
 	return err;
 }
@@ -772,6 +772,7 @@ show_sock_fd(struct device *dev, struct device_attribute *attr,
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
 	int sockfd = -1;
+
 	if (kni->vhost_queue != NULL)
 		sockfd = kni->vhost_queue->sockfd;
 	return snprintf(buf, 10, "%d\n", sockfd);
@@ -783,6 +784,7 @@ show_sock_en(struct device *dev, struct device_attribute *attr,
 {
 	struct net_device *net_dev = container_of(dev, struct net_device, dev);
 	struct kni_dev *kni = netdev_priv(net_dev);
+
 	return snprintf(buf, 10, "%u\n", (kni->vhost_queue == NULL ? 0 : 1));
 }
 
@@ -809,7 +811,7 @@ static DEVICE_ATTR(sock_en, S_IRUGO | S_IWUSR, show_sock_en, set_sock_en);
 static struct attribute *dev_attrs[] = {
 	&dev_attr_sock_fd.attr,
 	&dev_attr_sock_en.attr,
-        NULL,
+	NULL,
 };
 
 static const struct attribute_group dev_attr_grp = {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 05/19] kni: prefer unsigned int to unsigned
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (3 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 06/19] kni: remove useless return Ferruh Yigit
                       ` (14 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  4 ++--
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 28 ++++++++++++++--------------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 22 +++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 ++++++------
 4 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index e1c79b1..1d01fb1 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -51,7 +51,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned core_id;            /* Core ID to bind */
+	unsigned int core_id;        /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -92,7 +92,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned mbuf_size;
+	unsigned int mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 4006b1f..94a7f9d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -30,13 +30,13 @@
 /**
  * Adds num elements into the fifo. Return the number actually written
  */
-static inline unsigned
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
+static inline unsigned int
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned fifo_write = fifo->write;
-	unsigned fifo_read = fifo->read;
-	unsigned new_write = fifo_write;
+	unsigned int i = 0;
+	unsigned int fifo_write = fifo->write;
+	unsigned int fifo_read = fifo->read;
+	unsigned int new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -54,12 +54,12 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned num)
 /**
  * Get up to num elements from the fifo. Return the number actully read
  */
-static inline unsigned
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
+static inline unsigned int
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 {
-	unsigned i = 0;
-	unsigned new_read = fifo->read;
-	unsigned fifo_write = fifo->write;
+	unsigned int i = 0;
+	unsigned int new_read = fifo->read;
+	unsigned int fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -76,7 +76,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned num)
 /**
  * Get the num of elements in the fifo
  */
-static inline unsigned
+static inline unsigned int
 kni_fifo_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned
+static inline unsigned int
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned size)
+kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 138297f..937dd09 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -157,9 +157,9 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rx, num_fq;
+	unsigned int i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct sk_buff *skb;
@@ -173,7 +173,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned)MBUF_BURST_SZ);
+	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx);
@@ -241,9 +241,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num, num_rq, num_tq, num_aq, num_fq;
+	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct rte_kni_mbuf *alloc_kva;
@@ -265,7 +265,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -326,9 +326,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned ret;
+	unsigned int ret;
 	uint32_t len;
-	unsigned i, num_rq, num_fq, num;
+	unsigned int i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct sk_buff *skb;
@@ -342,7 +342,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned)MBUF_BURST_SZ);
+	num = min(num, (unsigned int)MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -448,7 +448,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned ret;
+	unsigned int ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	void *pkt_pa = NULL;
@@ -595,7 +595,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned num;
+	unsigned int num;
 	int ret_val;
 
 	if (!kni || !req) {
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index b4d91ca..f1345c3 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned offset, unsigned len)
+		 unsigned int offset, unsigned int len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -280,9 +280,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned nb_in, nb_mbuf, nb_skb;
-	const unsigned BURST_MASK = RX_BURST_SZ - 1;
-	unsigned nb_burst, nb_backlog, i;
+	unsigned int nb_in, nb_mbuf, nb_skb;
+	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
+	unsigned int nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -298,7 +298,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned)RX_BURST_SZ);
+	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 06/19] kni: remove useless return
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (4 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
                       ` (13 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 937dd09..bae81e6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -538,7 +538,6 @@ kni_net_tx_timeout(struct net_device *dev)
 
 	kni->stats.tx_errors++;
 	netif_wake_queue(dev);
-	return;
 }
 
 /*
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 07/19] kni: comparisons should place the constant on the right
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (5 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 06/19] kni: remove useless return Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 08/19] kni: trailing statements should be on next line Ferruh Yigit
                       ` (12 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f1345c3..ec39538 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -169,7 +169,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 
 	/* free skb to cache */
 	skb->data = NULL;
-	if (unlikely(1 != kni_fifo_put(q->fifo, (void **)&skb, 1)))
+	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");
 
@@ -197,8 +197,8 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	kni->stats.rx_packets++;
 
 	/* enqueue mbufs into free_q */
-	va = (void*)kva - kni->mbuf_kva + kni->mbuf_va;
-	if (unlikely(1 != kni_fifo_put(kni->free_q, (void **)&va, 1)))
+	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");
 
@@ -303,15 +303,13 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_backlog = (nb_in & BURST_MASK);
 
 	/* enqueue skb_queue per BURST_SIZE bulk */
-	if (0 != nb_burst) {
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     kni->rx_q, (void **)&va,
-				     RX_BURST_SZ)))
+	if (nb_burst != 0) {
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
-		if (unlikely(RX_BURST_SZ != kni_fifo_get(
-				     q->fifo, (void **)&skb,
-				     RX_BURST_SZ)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, RX_BURST_SZ)
+				!= RX_BURST_SZ))
 			goto except;
 
 		kni_vhost_enqueue_burst(kni, q, skb, va);
@@ -319,12 +317,10 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 
 	/* all leftover, do one by one */
 	for (i = 0; i < nb_backlog; ++i) {
-		if (unlikely(1 != kni_fifo_get(
-				     kni->rx_q,(void **)&va, 1)))
+		if (unlikely(kni_fifo_get(kni->rx_q, (void **)&va, 1) != 1))
 			goto except;
 
-		if (unlikely(1 != kni_fifo_get(
-				     q->fifo, (void **)&skb, 1)))
+		if (unlikely(kni_fifo_get(q->fifo, (void **)&skb, 1) != 1))
 			goto except;
 
 		kni_vhost_enqueue(kni, q, *skb, *va);
@@ -797,7 +793,7 @@ set_sock_en(struct device *dev, struct device_attribute *attr,
 	unsigned long en;
 	int err = 0;
 
-	if (0 != kstrtoul(buf, 0, &en))
+	if (kstrtoul(buf, 0, &en) != 0)
 		return -EINVAL;
 
 	if (en)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 08/19] kni: trailing statements should be on next line
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (6 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 09/19] kni: do not use assignment in if condition Ferruh Yigit
                       ` (11 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index ec39538..bef4889 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -244,11 +244,12 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	if (sock_writeable(&q->sk) ||
 #ifdef SOCKWQ_ASYNC_NOSPACE
-	    (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #else
-	    (!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+		(!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock->flags) &&
+			sock_writeable(&q->sk)))
 #endif
-	     sock_writeable(&q->sk)))
 		mask |= POLLOUT | POLLWRNORM;
 
 	return mask;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 09/19] kni: do not use assignment in if condition
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (7 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 08/19] kni: trailing statements should be on next line Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
                       ` (10 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index bef4889..eacfe3f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -410,13 +410,14 @@ kni_sock_rcvmsg(struct socket *sock,
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 	if (likely(q->flags & IFF_VNET_HDR)) {
 		vnet_hdr_len = q->vnet_hdr_sz;
-		if ((len -= vnet_hdr_len) < 0)
+		len -= vnet_hdr_len;
+		if (len < 0)
 			return -EINVAL;
 	}
 #endif
 
-	if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni,
-		m, vnet_hdr_len, len))))
+	pkt_len = kni_vhost_net_rx(q->kni, m, vnet_hdr_len, len);
+	if (unlikely(pkt_len == 0))
 		return 0;
 
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
@@ -567,7 +568,8 @@ kni_sock_release(struct socket *sock)
 	if (q == NULL)
 		return 0;
 
-	if (NULL != (kni = q->kni)) {
+	kni = q->kni;
+	if (kni != NULL) {
 		kni->vq_status = BE_STOP;
 		KNI_VHOST_WAIT_WQ_SAFE();
 		kni->vhost_queue = NULL;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 10/19] kni: macros with complex values should be enclosed in parentheses
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (8 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 09/19] kni: do not use assignment in if condition Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 11/19] kni: prefer min_t to min Ferruh Yigit
                       ` (9 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 962a4e7..d79d626 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -19,7 +19,7 @@
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
-#define sk_sleep(s) (s)->sk_sleep
+#define sk_sleep(s) ((s)->sk_sleep)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 11/19] kni: prefer min_t to min
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (9 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
                       ` (8 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c   | 6 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index bae81e6..04a3d63 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -173,7 +173,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min(num_fq, (unsigned int)MBUF_BURST_SZ);
+	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx);
@@ -265,7 +265,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -342,7 +342,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min(num, (unsigned int)MBUF_BURST_SZ);
+	num = min_t(unsigned int, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index eacfe3f..e460dd6 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min(nb_in, (unsigned int)RX_BURST_SZ);
+	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 12/19] kni: prefer ether_addr_copy to memcpy
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (10 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 11/19] kni: prefer min_t to min Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 13/19] kni: update kernel logging Ferruh Yigit
                       ` (7 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h   | 4 ++++
 lib/librte_eal/linuxapp/kni/kni_misc.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index d79d626..9ae50a7 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -26,6 +26,10 @@
 #define HAVE_CHANGE_CARRIER_CB
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+#define ether_addr_copy(dst, src) memcpy(dst, src, ETH_ALEN)
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
 #define HAVE_IOV_ITER_MSGHDR
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 4145886..d7d4d4e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -563,7 +563,7 @@ kni_ioctl_create(struct net *net,
 		pci_dev_put(pci);
 
 	if (kni->lad_dev)
-		memcpy(net_dev->dev_addr, kni->lad_dev->dev_addr, ETH_ALEN);
+		ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr);
 	else
 		/*
 		 * Generate random mac address. eth_random_addr() is the newer
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 13/19] kni: update kernel logging
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (11 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
                       ` (6 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

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 <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 13 +++++---
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 54 ++++++++++++++++-----------------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 34 ++++++++++-----------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 12 ++++----
 4 files changed, 58 insertions(+), 55 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 1d01fb1..f48c228 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 <linux/if.h>
 #include <linux/wait.h>
 #include <linux/sched.h>
@@ -113,10 +118,8 @@ struct kni_dev {
 	void *alloc_va[MBUF_BURST_SZ];
 };
 
-#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
@@ -153,13 +156,13 @@ int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);
 
 #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 d7d4d4e..fc5a88d 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -161,17 +161,17 @@ 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;
 	}
 
 	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");
 	else
-		KNI_PRINT("Multiple kernel thread mode enabled\n");
+		pr_debug("Multiple kernel thread mode enabled\n");
 
 #ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
 	rc = register_pernet_subsys(&kni_net_ops);
@@ -183,14 +183,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;
 
@@ -212,7 +212,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
@@ -242,7 +242,7 @@ kni_open(struct inode *inode, struct file *file)
 		return -EBUSY;
 
 	file->private_data = get_net(net);
-	KNI_PRINT("/dev/kni opened\n");
+	pr_debug("/dev/kni opened\n");
 
 	return 0;
 }
@@ -285,7 +285,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;
 }
@@ -373,7 +373,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;
 	}
 
@@ -434,7 +434,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;
@@ -442,7 +442,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;
 	}
 
@@ -450,7 +450,7 @@ kni_ioctl_create(struct net *net,
 	 * Check if the cpu core id is valid for binding.
 	 */
 	if (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;
 	}
 
@@ -470,7 +470,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;
 	}
 
@@ -500,19 +500,19 @@ 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_size:    %u\n", kni->mbuf_size);
+	pr_debug("mbuf_size:    %u\n", kni->mbuf_size);
 
 	KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n",
 					dev_info.bus,
@@ -525,7 +525,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));
@@ -548,7 +548,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;
 			}
 
@@ -573,7 +573,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->net_dev = NULL;
 		kni_dev_remove(kni);
@@ -610,7 +610,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;
 	}
 
@@ -637,7 +637,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;
@@ -680,7 +680,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 04a3d63..6328e1e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -189,7 +189,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;
@@ -232,7 +232,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	ret = kni_fifo_put(kni->free_q, kni->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");
 }
 
 /*
@@ -303,14 +303,14 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 		ret = kni_fifo_put(kni->tx_q, kni->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, kni->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,
@@ -362,7 +362,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);
@@ -375,7 +375,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;
 		}
@@ -415,7 +415,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 	ret = kni_fifo_put(kni->free_q, kni->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 */
@@ -500,12 +500,12 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 		ret = kni_fifo_put(kni->tx_q, &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;
 	}
 
@@ -598,7 +598,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;
 	}
 
@@ -608,7 +608,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;
 	}
@@ -622,7 +622,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;
 	}
@@ -754,18 +754,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

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 14/19] kni: remove unnecessary 'out of memory' message
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (12 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 13/19] kni: update kernel logging Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
                       ` (5 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_net.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 6328e1e..5182b2f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -189,7 +189,6 @@ kni_net_rx_normal(struct kni_dev *kni)
 
 		skb = dev_alloc_skb(len + 2);
 		if (!skb) {
-			pr_err("Out of mem, dropping pkts\n");
 			/* Update statistics */
 			kni->stats.rx_dropped++;
 			continue;
@@ -361,9 +360,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 		kni->va[i] = pa2va(kni->pa[i], kva);
 
 		skb = dev_alloc_skb(len + 2);
-		if (skb == NULL)
-			pr_err("Out of mem, dropping pkts\n");
-		else {
+		if (skb) {
 			/* Align IP on 16B boundary */
 			skb_reserve(skb, 2);
 			memcpy(skb_put(skb, len), data_kva, len);
@@ -375,7 +372,6 @@ 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) {
-			pr_err("Out of mem, dropping pkts\n");
 			kni->stats.rx_dropped++;
 			continue;
 		}
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 15/19] kni: move functions to eliminate function declarations
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (13 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 16/19] kni: remove compile time debug configuration Ferruh Yigit
                       ` (4 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Function implementations kept same.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 311 ++++++++++++++++-----------------
 lib/librte_eal/linuxapp/kni/kni_net.c  | 295 +++++++++++++++----------------
 2 files changed, 293 insertions(+), 313 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index fc5a88d..9296a8e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -51,35 +51,6 @@ MODULE_DESCRIPTION("Kernel Module for managing kni devices");
 extern const struct pci_device_id ixgbe_pci_tbl[];
 extern const struct pci_device_id igb_pci_tbl[];
 
-static int kni_open(struct inode *inode, struct file *file);
-static int kni_release(struct inode *inode, struct file *file);
-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 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 const struct file_operations kni_fops = {
-	.owner = THIS_MODULE,
-	.open = kni_open,
-	.release = kni_release,
-	.unlocked_ioctl = (void *)kni_ioctl,
-	.compat_ioctl = (void *)kni_compat_ioctl,
-};
-
-static struct miscdevice kni_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = KNI_DEVICE,
-	.fops = &kni_fops,
-};
-
 /* loopback mode */
 static char *lo_mode;
 
@@ -156,140 +127,6 @@ static struct pernet_operations kni_net_ops = {
 #endif
 };
 
-static int __init
-kni_init(void)
-{
-	int rc;
-
-	pr_debug("######## DPDK kni module loading ########\n");
-
-	if (kni_parse_kthread_mode() < 0) {
-		pr_err("Invalid parameter for kthread_mode\n");
-		return -EINVAL;
-	}
-
-	if (multiple_kthread_on == 0)
-		pr_debug("Single kernel thread for all KNI devices\n");
-	else
-		pr_debug("Multiple kernel thread mode enabled\n");
-
-#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) {
-		pr_err("Misc registration failed\n");
-		goto out;
-	}
-
-	/* Configure the lo mode according to the input parameter */
-	kni_net_config_lo_mode(lo_mode);
-
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
-	return 0;
-
-out:
-#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
-	unregister_pernet_subsys(&kni_net_ops);
-#else
-	unregister_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
-	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
-#endif
-	pr_debug("####### 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)
-{
-	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;
-
-	file->private_data = get_net(net);
-	pr_debug("/dev/kni opened\n");
-
-	return 0;
-}
-
-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;
-
-	/* Stop kernel thread for single mode */
-	if (multiple_kthread_on == 0) {
-		mutex_lock(&knet->kni_kthread_lock);
-		/* Stop kernel thread */
-		if (knet->kni_kthread != NULL) {
-			kthread_stop(knet->kni_kthread);
-			knet->kni_kthread = NULL;
-		}
-		mutex_unlock(&knet->kni_kthread_lock);
-	}
-
-	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;
-		}
-
-#ifdef RTE_KNI_VHOST
-		kni_vhost_backend_release(dev);
-#endif
-		kni_dev_remove(dev);
-		list_del(&dev->list);
-	}
-	up_write(&knet->kni_list_lock);
-
-	/* Clear the bit of device in use */
-	clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use);
-
-	put_net(net);
-	pr_debug("/dev/kni closed\n");
-
-	return 0;
-}
-
 static int
 kni_thread_single(void *data)
 {
@@ -345,6 +182,22 @@ kni_thread_multiple(void *param)
 }
 
 static int
+kni_open(struct inode *inode, struct file *file)
+{
+	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;
+
+	file->private_data = get_net(net);
+	pr_debug("/dev/kni opened\n");
+
+	return 0;
+}
+
+static int
 kni_dev_remove(struct kni_dev *dev)
 {
 	if (!dev)
@@ -366,6 +219,49 @@ kni_dev_remove(struct kni_dev *dev)
 }
 
 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;
+
+	/* Stop kernel thread for single mode */
+	if (multiple_kthread_on == 0) {
+		mutex_lock(&knet->kni_kthread_lock);
+		/* Stop kernel thread */
+		if (knet->kni_kthread != NULL) {
+			kthread_stop(knet->kni_kthread);
+			knet->kni_kthread = NULL;
+		}
+		mutex_unlock(&knet->kni_kthread_lock);
+	}
+
+	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;
+		}
+
+#ifdef RTE_KNI_VHOST
+		kni_vhost_backend_release(dev);
+#endif
+		kni_dev_remove(dev);
+		list_del(&dev->list);
+	}
+	up_write(&knet->kni_list_lock);
+
+	/* Clear the bit of device in use */
+	clear_bit(KNI_DEV_IN_USE_BIT_NUM, &knet->device_in_use);
+
+	put_net(net);
+	pr_debug("/dev/kni closed\n");
+
+	return 0;
+}
+
+static int
 kni_check_param(struct kni_dev *kni, struct rte_kni_device_info *dev)
 {
 	if (!kni || !dev)
@@ -685,6 +581,95 @@ kni_compat_ioctl(struct inode *inode,
 	return -EINVAL;
 }
 
+static const struct file_operations kni_fops = {
+	.owner = THIS_MODULE,
+	.open = kni_open,
+	.release = kni_release,
+	.unlocked_ioctl = (void *)kni_ioctl,
+	.compat_ioctl = (void *)kni_compat_ioctl,
+};
+
+static struct miscdevice kni_misc = {
+	.minor = MISC_DYNAMIC_MINOR,
+	.name = KNI_DEVICE,
+	.fops = &kni_fops,
+};
+
+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 __init
+kni_init(void)
+{
+	int rc;
+
+	pr_debug("######## DPDK kni module loading ########\n");
+
+	if (kni_parse_kthread_mode() < 0) {
+		pr_err("Invalid parameter for kthread_mode\n");
+		return -EINVAL;
+	}
+
+	if (multiple_kthread_on == 0)
+		pr_debug("Single kernel thread for all KNI devices\n");
+	else
+		pr_debug("Multiple kernel thread mode enabled\n");
+
+#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) {
+		pr_err("Misc registration failed\n");
+		goto out;
+	}
+
+	/* Configure the lo mode according to the input parameter */
+	kni_net_config_lo_mode(lo_mode);
+
+	pr_debug("######## DPDK kni module loaded  ########\n");
+
+	return 0;
+
+out:
+#ifdef HAVE_SIMPLIFIED_PERNET_OPERATIONS
+	unregister_pernet_subsys(&kni_net_ops);
+#else
+	unregister_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
+	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
+#endif
+	pr_debug("####### DPDK kni module unloaded  #######\n");
+}
+
 module_init(kni_init);
 module_exit(kni_exit);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index 5182b2f..d447d3a 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -49,12 +49,7 @@
 /* typedef for rx function */
 typedef void (*kni_net_rx_t)(struct kni_dev *kni);
 
-static int kni_net_tx(struct sk_buff *skb, struct net_device *dev);
 static void kni_net_rx_normal(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo(struct kni_dev *kni);
-static void kni_net_rx_lo_fifo_skb(struct kni_dev *kni);
-static int kni_net_process_request(struct kni_dev *kni,
-			struct rte_kni_request *req);
 
 /* kni rx function pointer, with default to normal rx */
 static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal;
@@ -98,6 +93,55 @@ va2pa(void *va, struct rte_kni_mbuf *m)
 }
 
 /*
+ * It can be called to process the request.
+ */
+static int
+kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
+{
+	int ret = -1;
+	void *resp_va;
+	unsigned int num;
+	int ret_val;
+
+	if (!kni || !req) {
+		pr_err("No kni instance or request\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&kni->sync_lock);
+
+	/* Construct data */
+	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
+	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
+	if (num < 1) {
+		pr_err("Cannot send to req_q\n");
+		ret = -EBUSY;
+		goto fail;
+	}
+
+	ret_val = wait_event_interruptible_timeout(kni->wq,
+			kni_fifo_count(kni->resp_q), 3 * HZ);
+	if (signal_pending(current) || ret_val <= 0) {
+		ret = -ETIME;
+		goto fail;
+	}
+	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
+	if (num != 1 || resp_va != kni->sync_va) {
+		/* This should never happen */
+		pr_err("No data in resp_q\n");
+		ret = -ENODATA;
+		goto fail;
+	}
+
+	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
+	ret = 0;
+
+fail:
+	mutex_unlock(&kni->sync_lock);
+	return ret;
+}
+
+/*
  * Open and close
  */
 static int
@@ -152,6 +196,102 @@ kni_net_config(struct net_device *dev, struct ifmap *map)
 }
 
 /*
+ * Transmit a packet (called by the kernel)
+ */
+#ifdef RTE_KNI_VHOST
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	struct kni_dev *kni = netdev_priv(dev);
+
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#else
+static int
+kni_net_tx(struct sk_buff *skb, struct net_device *dev)
+{
+	int len = 0;
+	unsigned int ret;
+	struct kni_dev *kni = netdev_priv(dev);
+	struct rte_kni_mbuf *pkt_kva = NULL;
+	void *pkt_pa = NULL;
+	void *pkt_va = NULL;
+
+	/* save the timestamp */
+#ifdef HAVE_TRANS_START_HELPER
+	netif_trans_update(dev);
+#else
+	dev->trans_start = jiffies;
+#endif
+
+	/* Check if the length of skb is less than mbuf size */
+	if (skb->len > kni->mbuf_size)
+		goto drop;
+
+	/**
+	 * Check if it has at least one free entry in tx_q and
+	 * one entry in alloc_q.
+	 */
+	if (kni_fifo_free_count(kni->tx_q) == 0 ||
+			kni_fifo_count(kni->alloc_q) == 0) {
+		/**
+		 * If no free entry in tx_q or no entry in alloc_q,
+		 * drops skb and goes out.
+		 */
+		goto drop;
+	}
+
+	/* dequeue a mbuf from alloc_q */
+	ret = kni_fifo_get(kni->alloc_q, &pkt_pa, 1);
+	if (likely(ret == 1)) {
+		void *data_kva;
+
+		pkt_kva = pa2kva(pkt_pa);
+		data_kva = kva2data_kva(pkt_kva);
+		pkt_va = pa2va(pkt_pa, pkt_kva);
+
+		len = skb->len;
+		memcpy(data_kva, skb->data, len);
+		if (unlikely(len < ETH_ZLEN)) {
+			memset(data_kva + len, 0, ETH_ZLEN - len);
+			len = ETH_ZLEN;
+		}
+		pkt_kva->pkt_len = len;
+		pkt_kva->data_len = len;
+
+		/* enqueue mbuf into tx_q */
+		ret = kni_fifo_put(kni->tx_q, &pkt_va, 1);
+		if (unlikely(ret != 1)) {
+			/* Failing should not happen */
+			pr_err("Fail to enqueue mbuf into tx_q\n");
+			goto drop;
+		}
+	} else {
+		/* Failing should not happen */
+		pr_err("Fail to dequeue mbuf from alloc_q\n");
+		goto drop;
+	}
+
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_bytes += len;
+	kni->stats.tx_packets++;
+
+	return NETDEV_TX_OK;
+
+drop:
+	/* Free skb and update statistics */
+	dev_kfree_skb(skb);
+	kni->stats.tx_dropped++;
+
+	return NETDEV_TX_OK;
+}
+#endif
+
+/*
  * RX: normal working mode
  */
 static void
@@ -426,102 +566,6 @@ kni_net_rx(struct kni_dev *kni)
 }
 
 /*
- * Transmit a packet (called by the kernel)
- */
-#ifdef RTE_KNI_VHOST
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	struct kni_dev *kni = netdev_priv(dev);
-
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#else
-static int
-kni_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
-	int len = 0;
-	unsigned int ret;
-	struct kni_dev *kni = netdev_priv(dev);
-	struct rte_kni_mbuf *pkt_kva = NULL;
-	void *pkt_pa = NULL;
-	void *pkt_va = NULL;
-
-	/* save the timestamp */
-#ifdef HAVE_TRANS_START_HELPER
-	netif_trans_update(dev);
-#else
-	dev->trans_start = jiffies;
-#endif
-
-	/* Check if the length of skb is less than mbuf size */
-	if (skb->len > kni->mbuf_size)
-		goto drop;
-
-	/**
-	 * Check if it has at least one free entry in tx_q and
-	 * one entry in alloc_q.
-	 */
-	if (kni_fifo_free_count(kni->tx_q) == 0 ||
-			kni_fifo_count(kni->alloc_q) == 0) {
-		/**
-		 * If no free entry in tx_q or no entry in alloc_q,
-		 * drops skb and goes out.
-		 */
-		goto drop;
-	}
-
-	/* dequeue a mbuf from alloc_q */
-	ret = kni_fifo_get(kni->alloc_q, &pkt_pa, 1);
-	if (likely(ret == 1)) {
-		void *data_kva;
-
-		pkt_kva = pa2kva(pkt_pa);
-		data_kva = kva2data_kva(pkt_kva);
-		pkt_va = pa2va(pkt_pa, pkt_kva);
-
-		len = skb->len;
-		memcpy(data_kva, skb->data, len);
-		if (unlikely(len < ETH_ZLEN)) {
-			memset(data_kva + len, 0, ETH_ZLEN - len);
-			len = ETH_ZLEN;
-		}
-		pkt_kva->pkt_len = len;
-		pkt_kva->data_len = len;
-
-		/* enqueue mbuf into tx_q */
-		ret = kni_fifo_put(kni->tx_q, &pkt_va, 1);
-		if (unlikely(ret != 1)) {
-			/* Failing should not happen */
-			pr_err("Fail to enqueue mbuf into tx_q\n");
-			goto drop;
-		}
-	} else {
-		/* Failing should not happen */
-		pr_err("Fail to dequeue mbuf from alloc_q\n");
-		goto drop;
-	}
-
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_bytes += len;
-	kni->stats.tx_packets++;
-
-	return NETDEV_TX_OK;
-
-drop:
-	/* Free skb and update statistics */
-	dev_kfree_skb(skb);
-	kni->stats.tx_dropped++;
-
-	return NETDEV_TX_OK;
-}
-#endif
-
-/*
  * Deal with a transmit timeout.
  */
 static void
@@ -583,55 +627,6 @@ kni_net_poll_resp(struct kni_dev *kni)
 }
 
 /*
- * It can be called to process the request.
- */
-static int
-kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
-{
-	int ret = -1;
-	void *resp_va;
-	unsigned int num;
-	int ret_val;
-
-	if (!kni || !req) {
-		pr_err("No kni instance or request\n");
-		return -EINVAL;
-	}
-
-	mutex_lock(&kni->sync_lock);
-
-	/* Construct data */
-	memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
-	num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
-	if (num < 1) {
-		pr_err("Cannot send to req_q\n");
-		ret = -EBUSY;
-		goto fail;
-	}
-
-	ret_val = wait_event_interruptible_timeout(kni->wq,
-			kni_fifo_count(kni->resp_q), 3 * HZ);
-	if (signal_pending(current) || ret_val <= 0) {
-		ret = -ETIME;
-		goto fail;
-	}
-	num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
-	if (num != 1 || resp_va != kni->sync_va) {
-		/* This should never happen */
-		pr_err("No data in resp_q\n");
-		ret = -ENODATA;
-		goto fail;
-	}
-
-	memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
-	ret = 0;
-
-fail:
-	mutex_unlock(&kni->sync_lock);
-	return ret;
-}
-
-/*
  * Return statistics to the caller
  */
 static struct net_device_stats *
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 16/19] kni: remove compile time debug configuration
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (14 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 17/19] kni: updated log messages Ferruh Yigit
                       ` (3 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Since switched to kernel dynamic debugging it is possible to remove
compile time debug log configuration.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 config/common_base                      |  3 ---
 lib/librte_eal/linuxapp/kni/kni_dev.h   | 18 -------------
 lib/librte_eal/linuxapp/kni/kni_misc.c  |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_net.c   |  8 +++---
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 46 ++++++++++++++++-----------------
 5 files changed, 31 insertions(+), 52 deletions(-)

diff --git a/config/common_base b/config/common_base
index 7830535..4a9e5b0 100644
--- a/config/common_base
+++ b/config/common_base
@@ -533,12 +533,9 @@ CONFIG_RTE_PIPELINE_STATS_COLLECT=n
 CONFIG_RTE_LIBRTE_KNI=n
 CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_KNI_PREEMPT_DEFAULT=y
-CONFIG_RTE_KNI_KO_DEBUG=n
 CONFIG_RTE_KNI_VHOST=n
 CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024
 CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=n
-CONFIG_RTE_KNI_VHOST_DEBUG_RX=n
-CONFIG_RTE_KNI_VHOST_DEBUG_TX=n
 
 #
 # Compile the pdump library
diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index f48c228..2771138 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -118,12 +118,6 @@ struct kni_dev {
 	void *alloc_va[MBUF_BURST_SZ];
 };
 
-#ifdef RTE_KNI_KO_DEBUG
-	#define KNI_DBG(args...) pr_debug(args)
-#else
-	#define KNI_DBG(args...)
-#endif
-
 #ifdef RTE_KNI_VHOST
 unsigned int
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
@@ -155,16 +149,4 @@ void ixgbe_kni_remove(struct pci_dev *pdev);
 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev);
 void igb_kni_remove(struct pci_dev *pdev);
 
-#ifdef RTE_KNI_VHOST_DEBUG_RX
-	#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...) pr_debug(args)
-#else
-	#define KNI_DBG_TX(args...)
-#endif
-
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index 9296a8e..bc43e5f 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -410,7 +410,7 @@ kni_ioctl_create(struct net *net,
 		(unsigned long long) dev_info.resp_phys, kni->resp_q);
 	pr_debug("mbuf_size:    %u\n", kni->mbuf_size);
 
-	KNI_DBG("PCI: %02x:%02x.%02x %04x:%04x\n",
+	pr_debug("PCI: %02x:%02x.%02x %04x:%04x\n",
 					dev_info.bus,
 					dev_info.devid,
 					dev_info.function,
@@ -438,7 +438,7 @@ kni_ioctl_create(struct net *net,
 			else
 				ret = -1;
 
-			KNI_DBG("PCI found: pci=0x%p, lad_dev=0x%p\n",
+			pr_debug("PCI found: pci=0x%p, lad_dev=0x%p\n",
 							pci, lad_dev);
 			if (ret == 0) {
 				kni->lad_dev = lad_dev;
@@ -547,7 +547,7 @@ kni_ioctl(struct inode *inode,
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
 
-	KNI_DBG("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
+	pr_debug("IOCTL num=0x%0x param=0x%0lx\n", ioctl_num, ioctl_param);
 
 	/*
 	 * Switch according to the ioctl called
@@ -563,7 +563,7 @@ kni_ioctl(struct inode *inode,
 		ret = kni_ioctl_release(net, ioctl_num, ioctl_param);
 		break;
 	default:
-		KNI_DBG("IOCTL default\n");
+		pr_debug("IOCTL default\n");
 		break;
 	}
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index d447d3a..dfc6b37 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -573,7 +573,7 @@ kni_net_tx_timeout(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("Transmit timeout at %ld, latency %ld\n", jiffies,
+	pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
 			jiffies - dev_trans_start(dev));
 
 	kni->stats.tx_errors++;
@@ -586,7 +586,7 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	KNI_DBG("kni_net_ioctl %d\n",
+	pr_debug("kni_net_ioctl %d\n",
 		((struct kni_dev *)netdev_priv(dev))->group_id);
 
 	return 0;
@@ -604,7 +604,7 @@ kni_net_change_mtu(struct net_device *dev, int new_mtu)
 	struct rte_kni_request req;
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
+	pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
 
 	memset(&req, 0, sizeof(req));
 	req.req_id = RTE_KNI_REQ_CHANGE_MTU;
@@ -730,7 +730,7 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	KNI_DBG("kni_net_init\n");
+	pr_debug("kni_net_init\n");
 
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index f4f6f10..947341e 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -75,7 +75,7 @@ kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
 	struct rte_kni_mbuf *pkt_va = NULL;
 	int ret;
 
-	KNI_DBG_TX("tx offset=%d, len=%d, iovlen=%d\n",
+	pr_debug("tx offset=%d, len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -177,7 +177,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 	if (unlikely(pkt_len > len))
 		goto drop;
 
-	KNI_DBG_RX("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
+	pr_debug("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   offset, len, pkt_len, (int)m->msg_iter.iov->iov_len);
 #else
@@ -202,7 +202,7 @@ kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
 		/* Failing should not happen */
 		pr_err("Fail to enqueue entries into free_q\n");
 
-	KNI_DBG_RX("receive done %d\n", pkt_len);
+	pr_debug("receive done %d\n", pkt_len);
 
 	return pkt_len;
 
@@ -226,10 +226,10 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 
 	kni = q->kni;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
 #else
-	KNI_DBG("start kni_poll on group %d, wait at 0x%16llx\n",
+	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
 #endif
 
@@ -332,7 +332,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	    ((nb_mbuf < RX_BURST_SZ) && (nb_mbuf != 0))) {
 		wake_up_interruptible_poll(sk_sleep(&q->sk),
 				   POLLIN | POLLRDNORM | POLLRDBAND);
-		KNI_DBG_RX("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
+		pr_debug("RX CHK KICK nb_mbuf %d, nb_skb %d, nb_in %d\n",
 			   nb_mbuf, nb_skb, nb_in);
 	}
 
@@ -363,7 +363,7 @@ kni_sock_sndmsg(struct socket *sock,
 	if (unlikely(q == NULL || q->kni == NULL))
 		return 0;
 
-	KNI_DBG_TX("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
+	pr_debug("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n",
 #ifdef HAVE_IOV_ITER_MSGHDR
 		   len, q->flags, (int)m->msg_iter.iov->iov_len);
 #else
@@ -431,7 +431,7 @@ kni_sock_rcvmsg(struct socket *sock,
 #endif /* HAVE_IOV_ITER_MSGHDR */
 		return -EFAULT;
 #endif /* RTE_KNI_VHOST_VNET_HDR_EN */
-	KNI_DBG_RX("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
+	pr_debug("kni_rcvmsg expect_len %ld, flags 0x%08x, pkt_len %d\n",
 		   (unsigned long)len, q->flags, pkt_len);
 
 	return pkt_len + vnet_hdr_len;
@@ -453,11 +453,11 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 	int s;
 	int ret;
 
-	KNI_DBG("tap ioctl cmd 0x%08x\n", cmd);
+	pr_debug("tap ioctl cmd 0x%08x\n", cmd);
 
 	switch (cmd) {
 	case TUNSETIFF:
-		KNI_DBG("TUNSETIFF\n");
+		pr_debug("TUNSETIFF\n");
 		/* ignore the name, just look at flags */
 		if (get_user(u, &ifr->ifr_flags))
 			return -EFAULT;
@@ -471,7 +471,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETIFF:
-		KNI_DBG("TUNGETIFF\n");
+		pr_debug("TUNGETIFF\n");
 		rcu_read_lock_bh();
 		kni = rcu_dereference_bh(q->kni);
 		if (kni)
@@ -489,7 +489,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return ret;
 
 	case TUNGETFEATURES:
-		KNI_DBG("TUNGETFEATURES\n");
+		pr_debug("TUNGETFEATURES\n");
 		u = IFF_TAP | IFF_NO_PI;
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		u |= IFF_VNET_HDR;
@@ -499,7 +499,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		return 0;
 
 	case TUNSETSNDBUF:
-		KNI_DBG("TUNSETSNDBUF\n");
+		pr_debug("TUNSETSNDBUF\n");
 		if (get_user(u, up))
 			return -EFAULT;
 
@@ -510,7 +510,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		s = q->vnet_hdr_sz;
 		if (put_user(s, sp))
 			return -EFAULT;
-		KNI_DBG("TUNGETVNETHDRSZ %d\n", s);
+		pr_debug("TUNGETVNETHDRSZ %d\n", s);
 		return 0;
 
 	case TUNSETVNETHDRSZ:
@@ -519,12 +519,12 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 		if (s < (int)sizeof(struct virtio_net_hdr))
 			return -EINVAL;
 
-		KNI_DBG("TUNSETVNETHDRSZ %d\n", s);
+		pr_debug("TUNSETVNETHDRSZ %d\n", s);
 		q->vnet_hdr_sz = s;
 		return 0;
 
 	case TUNSETOFFLOAD:
-		KNI_DBG("TUNSETOFFLOAD %lx\n", arg);
+		pr_debug("TUNSETOFFLOAD %lx\n", arg);
 #ifdef RTE_KNI_VHOST_VNET_HDR_EN
 		/* not support any offload yet */
 		if (!(q->flags & IFF_VNET_HDR))
@@ -536,7 +536,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 #endif
 
 	default:
-		KNI_DBG("NOT SUPPORT\n");
+		pr_debug("NOT SUPPORT\n");
 		return -EINVAL;
 	}
 }
@@ -584,7 +584,7 @@ kni_sock_release(struct socket *sock)
 
 	sock_put(&q->sk);
 
-	KNI_DBG("dummy sock release done\n");
+	pr_debug("dummy sock release done\n");
 
 	return 0;
 }
@@ -593,7 +593,7 @@ int
 kni_sock_getname(struct socket *sock, struct sockaddr *addr,
 		int *sockaddr_len, int peer)
 {
-	KNI_DBG("dummy sock getname\n");
+	pr_debug("dummy sock getname\n");
 	((struct sockaddr_ll *)addr)->sll_family = AF_PACKET;
 	return 0;
 }
@@ -731,11 +731,11 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	kni->vq_status = BE_START;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
 #else
-	KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
+	pr_debug("backend init sockfd=%d, sock->wait at 0x%16llx,sk->sk_sleep=0x%16llx",
 		  q->sockfd, (uint64_t)&q->sock->wait,
 		  (uint64_t)q->sk.sk_sleep);
 #endif
@@ -828,7 +828,7 @@ kni_vhost_backend_release(struct kni_dev *kni)
 	/* dettach from kni */
 	q->kni = NULL;
 
-	KNI_DBG("release backend done\n");
+	pr_debug("release backend done\n");
 
 	return 0;
 }
@@ -843,7 +843,7 @@ kni_vhost_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_STOP;
 
-	KNI_DBG("kni_vhost_init done\n");
+	pr_debug("kni_vhost_init done\n");
 
 	return 0;
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 17/19] kni: updated log messages
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (15 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 16/19] kni: remove compile time debug configuration Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
                       ` (2 subsequent siblings)
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Remove some function entrance logs and changed log level of some logs.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_misc.c | 5 -----
 lib/librte_eal/linuxapp/kni/kni_net.c  | 6 ++----
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index bc43e5f..a0b8199 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -616,8 +616,6 @@ kni_init(void)
 {
 	int rc;
 
-	pr_debug("######## DPDK kni module loading ########\n");
-
 	if (kni_parse_kthread_mode() < 0) {
 		pr_err("Invalid parameter for kthread_mode\n");
 		return -EINVAL;
@@ -645,8 +643,6 @@ kni_init(void)
 	/* Configure the lo mode according to the input parameter */
 	kni_net_config_lo_mode(lo_mode);
 
-	pr_debug("######## DPDK kni module loaded  ########\n");
-
 	return 0;
 
 out:
@@ -667,7 +663,6 @@ kni_exit(void)
 #else
 	unregister_pernet_gen_subsys(kni_net_id, &kni_net_ops);
 #endif
-	pr_debug("####### DPDK kni module unloaded  #######\n");
 }
 
 module_init(kni_init);
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index dfc6b37..e9df9ec 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -586,8 +586,8 @@ kni_net_tx_timeout(struct net_device *dev)
 static int
 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-	pr_debug("kni_net_ioctl %d\n",
-		((struct kni_dev *)netdev_priv(dev))->group_id);
+	pr_debug("kni_net_ioctl group:%d cmd:%d\n",
+		((struct kni_dev *)netdev_priv(dev))->group_id, cmd);
 
 	return 0;
 }
@@ -730,8 +730,6 @@ kni_net_init(struct net_device *dev)
 {
 	struct kni_dev *kni = netdev_priv(dev);
 
-	pr_debug("kni_net_init\n");
-
 	init_waitqueue_head(&kni->wq);
 	mutex_init(&kni->sync_lock);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 18/19] kni: prefer uint32_t to unsigned int
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (16 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 17/19] kni: updated log messages Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
  2016-10-13 21:15     ` [dpdk-dev] [PATCH v3 00/19] KNI checkpatch cleanup Thomas Monjalon
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/kni_dev.h   |  8 ++++----
 lib/librte_eal/linuxapp/kni/kni_fifo.h  | 28 ++++++++++++++--------------
 lib/librte_eal/linuxapp/kni/kni_misc.c  | 17 +++++++----------
 lib/librte_eal/linuxapp/kni/kni_net.c   | 24 ++++++++++++------------
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 25 ++++++++++++-------------
 5 files changed, 49 insertions(+), 53 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/kni_dev.h b/lib/librte_eal/linuxapp/kni/kni_dev.h
index 2771138..58cbadd 100644
--- a/lib/librte_eal/linuxapp/kni/kni_dev.h
+++ b/lib/librte_eal/linuxapp/kni/kni_dev.h
@@ -56,7 +56,7 @@ struct kni_dev {
 	struct net_device_stats stats;
 	int status;
 	uint16_t group_id;           /* Group ID of a group of KNI devices */
-	unsigned int core_id;        /* Core ID to bind */
+	uint32_t core_id;            /* Core ID to bind */
 	char name[RTE_KNI_NAMESIZE]; /* Network device name */
 	struct task_struct *pthread;
 
@@ -97,7 +97,7 @@ struct kni_dev {
 	void *mbuf_va;
 
 	/* mbuf size */
-	unsigned int mbuf_size;
+	uint32_t mbuf_size;
 
 	/* synchro for request processing */
 	unsigned long synchro;
@@ -119,7 +119,7 @@ struct kni_dev {
 };
 
 #ifdef RTE_KNI_VHOST
-unsigned int
+uint32_t
 kni_poll(struct file *file, struct socket *sock, poll_table * wait);
 int kni_chk_vhost_rx(struct kni_dev *kni);
 int kni_vhost_init(struct kni_dev *kni);
@@ -131,7 +131,7 @@ struct kni_vhost_queue {
 	int vnet_hdr_sz;
 	struct kni_dev *kni;
 	int sockfd;
-	unsigned int flags;
+	uint32_t flags;
 	struct sk_buff *cache;
 	struct rte_kni_fifo *fifo;
 };
diff --git a/lib/librte_eal/linuxapp/kni/kni_fifo.h b/lib/librte_eal/linuxapp/kni/kni_fifo.h
index 94a7f9d..025ec1c 100644
--- a/lib/librte_eal/linuxapp/kni/kni_fifo.h
+++ b/lib/librte_eal/linuxapp/kni/kni_fifo.h
@@ -30,13 +30,13 @@
 /**
  * Adds num elements into the fifo. Return the number actually written
  */
-static inline unsigned int
-kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+static inline uint32_t
+kni_fifo_put(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int fifo_write = fifo->write;
-	unsigned int fifo_read = fifo->read;
-	unsigned int new_write = fifo_write;
+	uint32_t i = 0;
+	uint32_t fifo_write = fifo->write;
+	uint32_t fifo_read = fifo->read;
+	uint32_t new_write = fifo_write;
 
 	for (i = 0; i < num; i++) {
 		new_write = (new_write + 1) & (fifo->len - 1);
@@ -54,12 +54,12 @@ kni_fifo_put(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 /**
  * Get up to num elements from the fifo. Return the number actully read
  */
-static inline unsigned int
-kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
+static inline uint32_t
+kni_fifo_get(struct rte_kni_fifo *fifo, void **data, uint32_t num)
 {
-	unsigned int i = 0;
-	unsigned int new_read = fifo->read;
-	unsigned int fifo_write = fifo->write;
+	uint32_t i = 0;
+	uint32_t new_read = fifo->read;
+	uint32_t fifo_write = fifo->write;
 
 	for (i = 0; i < num; i++) {
 		if (new_read == fifo_write)
@@ -76,7 +76,7 @@ kni_fifo_get(struct rte_kni_fifo *fifo, void **data, unsigned int num)
 /**
  * Get the num of elements in the fifo
  */
-static inline unsigned int
+static inline uint32_t
 kni_fifo_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
@@ -85,7 +85,7 @@ kni_fifo_count(struct rte_kni_fifo *fifo)
 /**
  * Get the num of available elements in the fifo
  */
-static inline unsigned int
+static inline uint32_t
 kni_fifo_free_count(struct rte_kni_fifo *fifo)
 {
 	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
@@ -96,7 +96,7 @@ kni_fifo_free_count(struct rte_kni_fifo *fifo)
  * Initializes the kni fifo structure
  */
 static inline void
-kni_fifo_init(struct rte_kni_fifo *fifo, unsigned int size)
+kni_fifo_init(struct rte_kni_fifo *fifo, uint32_t size)
 {
 	fifo->write = 0;
 	fifo->read = 0;
diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c
index a0b8199..3303d9b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_misc.c
+++ b/lib/librte_eal/linuxapp/kni/kni_misc.c
@@ -56,7 +56,7 @@ static char *lo_mode;
 
 /* Kernel thread mode */
 static char *kthread_mode;
-static unsigned int multiple_kthread_on;
+static uint32_t multiple_kthread_on;
 
 #define KNI_DEV_IN_USE_BIT_NUM 0 /* Bit number for device in use */
 
@@ -318,8 +318,8 @@ kni_run_thread(struct kni_net *knet, struct kni_dev *kni, uint8_t force_bind)
 }
 
 static int
-kni_ioctl_create(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_create(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret;
@@ -493,8 +493,8 @@ kni_ioctl_create(struct net *net,
 }
 
 static int
-kni_ioctl_release(struct net *net,
-		unsigned int ioctl_num, unsigned long ioctl_param)
+kni_ioctl_release(struct net *net, uint32_t ioctl_num,
+		unsigned long ioctl_param)
 {
 	struct kni_net *knet = net_generic(net, kni_net_id);
 	int ret = -EINVAL;
@@ -540,9 +540,7 @@ kni_ioctl_release(struct net *net,
 }
 
 static int
-kni_ioctl(struct inode *inode,
-	unsigned int ioctl_num,
-	unsigned long ioctl_param)
+kni_ioctl(struct inode *inode, uint32_t ioctl_num, unsigned long ioctl_param)
 {
 	int ret = -EINVAL;
 	struct net *net = current->nsproxy->net_ns;
@@ -571,8 +569,7 @@ kni_ioctl(struct inode *inode,
 }
 
 static int
-kni_compat_ioctl(struct inode *inode,
-		unsigned int ioctl_num,
+kni_compat_ioctl(struct inode *inode, uint32_t ioctl_num,
 		unsigned long ioctl_param)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c
index e9df9ec..4ac99cf 100644
--- a/lib/librte_eal/linuxapp/kni/kni_net.c
+++ b/lib/librte_eal/linuxapp/kni/kni_net.c
@@ -100,7 +100,7 @@ kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
 {
 	int ret = -1;
 	void *resp_va;
-	unsigned int num;
+	uint32_t num;
 	int ret_val;
 
 	if (!kni || !req) {
@@ -214,7 +214,7 @@ static int
 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 {
 	int len = 0;
-	unsigned int ret;
+	uint32_t ret;
 	struct kni_dev *kni = netdev_priv(dev);
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	void *pkt_pa = NULL;
@@ -297,9 +297,9 @@ drop:
 static void
 kni_net_rx_normal(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rx, num_fq;
+	uint32_t i, num_rx, num_fq;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct sk_buff *skb;
@@ -313,7 +313,7 @@ kni_net_rx_normal(struct kni_dev *kni)
 	}
 
 	/* Calculate the number of entries to dequeue from rx_q */
-	num_rx = min_t(unsigned int, num_fq, MBUF_BURST_SZ);
+	num_rx = min_t(uint32_t, num_fq, MBUF_BURST_SZ);
 
 	/* Burst dequeue from rx_q */
 	num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx);
@@ -380,9 +380,9 @@ kni_net_rx_normal(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num, num_rq, num_tq, num_aq, num_fq;
+	uint32_t i, num, num_rq, num_tq, num_aq, num_fq;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct rte_kni_mbuf *alloc_kva;
@@ -404,7 +404,7 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 	num = min(num_rq, num_tq);
 	num = min(num, num_aq);
 	num = min(num, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -465,9 +465,9 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
 static void
 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 {
-	unsigned int ret;
+	uint32_t ret;
 	uint32_t len;
-	unsigned int i, num_rq, num_fq, num;
+	uint32_t i, num_rq, num_fq, num;
 	struct rte_kni_mbuf *kva;
 	void *data_kva;
 	struct sk_buff *skb;
@@ -481,7 +481,7 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
 
 	/* Calculate the number of entries to dequeue from rx_q */
 	num = min(num_rq, num_fq);
-	num = min_t(unsigned int, num, MBUF_BURST_SZ);
+	num = min_t(uint32_t, num, MBUF_BURST_SZ);
 
 	/* Return if no entry to dequeue from rx_q */
 	if (num == 0)
@@ -643,7 +643,7 @@ kni_net_stats(struct net_device *dev)
 static int
 kni_net_header(struct sk_buff *skb, struct net_device *dev,
 		unsigned short type, const void *daddr,
-		const void *saddr, unsigned int len)
+		const void *saddr, uint32_t len)
 {
 	struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
 
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 947341e..3ba0c57 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -69,7 +69,7 @@ static struct proto kni_raw_proto = {
 
 static inline int
 kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	struct rte_kni_mbuf *pkt_kva = NULL;
 	struct rte_kni_mbuf *pkt_va = NULL;
@@ -145,7 +145,7 @@ drop:
 
 static inline int
 kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m,
-		 unsigned int offset, unsigned int len)
+		 uint32_t offset, uint32_t len)
 {
 	uint32_t pkt_len;
 	struct rte_kni_mbuf *kva;
@@ -213,13 +213,13 @@ drop:
 	return 0;
 }
 
-static unsigned int
+static uint32_t
 kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 {
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int mask = 0;
+	uint32_t mask = 0;
 
 	if (unlikely(q == NULL || q->kni == NULL))
 		return POLLERR;
@@ -281,9 +281,9 @@ int
 kni_chk_vhost_rx(struct kni_dev *kni)
 {
 	struct kni_vhost_queue *q = kni->vhost_queue;
-	unsigned int nb_in, nb_mbuf, nb_skb;
-	const unsigned int BURST_MASK = RX_BURST_SZ - 1;
-	unsigned int nb_burst, nb_backlog, i;
+	uint32_t nb_in, nb_mbuf, nb_skb;
+	const uint32_t BURST_MASK = RX_BURST_SZ - 1;
+	uint32_t nb_burst, nb_backlog, i;
 	struct sk_buff *skb[RX_BURST_SZ];
 	struct rte_kni_mbuf *va[RX_BURST_SZ];
 
@@ -299,7 +299,7 @@ kni_chk_vhost_rx(struct kni_dev *kni)
 	nb_mbuf = kni_fifo_count(kni->rx_q);
 
 	nb_in = min(nb_mbuf, nb_skb);
-	nb_in = min_t(unsigned int, nb_in, RX_BURST_SZ);
+	nb_in = min_t(uint32_t, nb_in, RX_BURST_SZ);
 	nb_burst   = (nb_in & ~BURST_MASK);
 	nb_backlog = (nb_in & BURST_MASK);
 
@@ -439,16 +439,15 @@ kni_sock_rcvmsg(struct socket *sock,
 
 /* dummy tap like ioctl */
 static int
-kni_sock_ioctl(struct socket *sock, unsigned int cmd,
-	      unsigned long arg)
+kni_sock_ioctl(struct socket *sock, uint32_t cmd, unsigned long arg)
 {
 	void __user *argp = (void __user *)arg;
 	struct ifreq __user *ifr = argp;
-	unsigned int __user *up = argp;
+	uint32_t __user *up = argp;
 	struct kni_vhost_queue *q =
 		container_of(sock->sk, struct kni_vhost_queue, sk);
 	struct kni_dev *kni;
-	unsigned int u;
+	uint32_t u;
 	int __user *sp = argp;
 	int s;
 	int ret;
@@ -542,7 +541,7 @@ kni_sock_ioctl(struct socket *sock, unsigned int cmd,
 }
 
 static int
-kni_sock_compat_ioctl(struct socket *sock, unsigned int cmd,
+kni_sock_compat_ioctl(struct socket *sock, uint32_t cmd,
 		     unsigned long arg)
 {
 	/* 32 bits app on 64 bits OS to be supported later */
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* [dpdk-dev] [PATCH v3 19/19] kni: move kernel version ifdefs to compat header
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (17 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
@ 2016-09-26 15:39     ` Ferruh Yigit
  2016-10-13 21:15     ` [dpdk-dev] [PATCH v3 00/19] KNI checkpatch cleanup Thomas Monjalon
  19 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-09-26 15:39 UTC (permalink / raw)
  To: dev; +Cc: Ferruh Yigit

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_eal/linuxapp/kni/compat.h    | 12 ++++++++++++
 lib/librte_eal/linuxapp/kni/kni_vhost.c | 16 +++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h
index 9ae50a7..78da08e 100644
--- a/lib/librte_eal/linuxapp/kni/compat.h
+++ b/lib/librte_eal/linuxapp/kni/compat.h
@@ -20,6 +20,14 @@
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
 #define sk_sleep(s) ((s)->sk_sleep)
+#else
+#define HAVE_SOCKET_WQ
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#define HAVE_STATIC_SOCK_MAP_FD
+#else
+#define kni_sock_map_fd(s) sock_map_fd(s, 0)
 #endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
@@ -39,6 +47,10 @@
 #define HAVE_REBUILD_HEADER
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#define HAVE_SK_ALLOC_KERN_PARAM
+#endif
+
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
 #define HAVE_TRANS_START_HELPER
 #endif
diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c
index 3ba0c57..f54c34b 100644
--- a/lib/librte_eal/linuxapp/kni/kni_vhost.c
+++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c
@@ -40,7 +40,7 @@
 
 #define RX_BURST_SZ 4
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+#ifdef HAVE_STATIC_SOCK_MAP_FD
 static int kni_sock_map_fd(struct socket *sock)
 {
 	struct file *file;
@@ -57,8 +57,6 @@ static int kni_sock_map_fd(struct socket *sock)
 	fd_install(fd, file);
 	return fd;
 }
-#else
-#define kni_sock_map_fd(s)             sock_map_fd(s, 0)
 #endif
 
 static struct proto kni_raw_proto = {
@@ -225,17 +223,13 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table *wait)
 		return POLLERR;
 
 	kni = q->kni;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("start kni_poll on group %d, wq 0x%16llx\n",
 		  kni->group_id, (uint64_t)sock->wq);
+	poll_wait(file, &sock->wq->wait, wait);
 #else
 	pr_debug("start kni_poll on group %d, wait at 0x%16llx\n",
 		  kni->group_id, (uint64_t)&sock->wait);
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
-	poll_wait(file, &sock->wq->wait, wait);
-#else
 	poll_wait(file, &sock->wait, wait);
 #endif
 
@@ -663,7 +657,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 	if (kni->vhost_queue != NULL)
 		return -1;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+#ifdef HAVE_SK_ALLOC_KERN_PARAM
 	q = (struct kni_vhost_queue *)sk_alloc(net, AF_UNSPEC, GFP_KERNEL,
 			&kni_raw_proto, 0);
 #else
@@ -729,7 +723,7 @@ kni_vhost_backend_init(struct kni_dev *kni)
 
 	kni->vq_status = BE_START;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+#ifdef HAVE_SOCKET_WQ
 	pr_debug("backend init sockfd=%d, sock->wq=0x%16llx,sk->sk_wq=0x%16llx",
 		  q->sockfd, (uint64_t)q->sock->wq,
 		  (uint64_t)q->sk.sk_wq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup
  2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
                   ` (38 preceding siblings ...)
  2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
@ 2016-10-05 10:38 ` Pattan, Reshma
  2016-10-10 12:37   ` Ferruh Yigit
  39 siblings, 1 reply; 63+ messages in thread
From: Pattan, Reshma @ 2016-10-05 10:38 UTC (permalink / raw)
  To: Yigit, Ferruh, dev; +Cc: Stephen Hemminger, Ferruh Yigit

Hi Ferruh,


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
> Sent: Thursday, September 15, 2016 4:46 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Ferruh Yigit
> <ferruh.yigit@itnel.com>
> Subject: [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup
> 
> KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
> Only functional change is related logging, switched to kernel dynamic logging
> and compile time KNI debug options removed, some log message levels
> updated.
> 
> Ferruh Yigit (19):
>   kni: move externs to the header file
>   kni: uninitialize global variables
>   kni: make static struct const
>   kni: whitespace, indentation, long line corrections
>   kni: prefer unsigned int to unsigned
>   kni: remove useless return
>   kni: comparisons should place the constant on the right
>   kni: trailing statements should be on next line
>   kni: do not use assignment in if condition
>   kni: macros with complex values should be enclosed in parentheses
>   kni: prefer min_t to min
>   kni: prefer ether_addr_copy to memcpy
>   kni: update kernel logging
>   kni: remove unnecessary 'out of memory' message
>   kni: move functions to eliminate function declarations
>   kni: remove compile time debug configuration
>   kni: updated log messages
>   kni: prefer uint32_t to unsigned int
>   kni: move kernel version ifdefs to compat header
> 

Patches 4,5,11 and 13-19 are failed to apply.

Thanks,
Reshma

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup
  2016-10-05 10:38 ` [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Pattan, Reshma
@ 2016-10-10 12:37   ` Ferruh Yigit
  0 siblings, 0 replies; 63+ messages in thread
From: Ferruh Yigit @ 2016-10-10 12:37 UTC (permalink / raw)
  To: Pattan, Reshma, dev; +Cc: Stephen Hemminger, Ferruh Yigit

Hi Pattan,

On 10/5/2016 11:38 AM, Pattan, Reshma wrote:
> Hi Ferruh,
> 
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit
>> Sent: Thursday, September 15, 2016 4:46 PM
>> To: dev@dpdk.org
>> Cc: Stephen Hemminger <stephen@networkplumber.org>; Ferruh Yigit
>> <ferruh.yigit@itnel.com>
>> Subject: [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup
>>
>> KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
>> Only functional change is related logging, switched to kernel dynamic logging
>> and compile time KNI debug options removed, some log message levels
>> updated.
>>
>> Ferruh Yigit (19):
>>   kni: move externs to the header file
>>   kni: uninitialize global variables
>>   kni: make static struct const
>>   kni: whitespace, indentation, long line corrections
>>   kni: prefer unsigned int to unsigned
>>   kni: remove useless return
>>   kni: comparisons should place the constant on the right
>>   kni: trailing statements should be on next line
>>   kni: do not use assignment in if condition
>>   kni: macros with complex values should be enclosed in parentheses
>>   kni: prefer min_t to min
>>   kni: prefer ether_addr_copy to memcpy
>>   kni: update kernel logging
>>   kni: remove unnecessary 'out of memory' message
>>   kni: move functions to eliminate function declarations
>>   kni: remove compile time debug configuration
>>   kni: updated log messages
>>   kni: prefer uint32_t to unsigned int
>>   kni: move kernel version ifdefs to compat header
>>
> 
> Patches 4,5,11 and 13-19 are failed to apply.
> 

The patchset v3 has a dependency, mentioned in cover letter, I tested
with that patch and patches applied well for me,
would you mind trying again with that dependent patch applied please?

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 63+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/19] KNI checkpatch cleanup
  2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
                       ` (18 preceding siblings ...)
  2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
@ 2016-10-13 21:15     ` Thomas Monjalon
  19 siblings, 0 replies; 63+ messages in thread
From: Thomas Monjalon @ 2016-10-13 21:15 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

2016-09-26 16:39, Ferruh Yigit:
> KNI checkpatch cleanup, mostly non-functional but cosmetic modifications.
> Only functional change is related logging, switched to kernel dynamic
> logging and compile time KNI debug options removed, some log message
> levels updated.

Applied, thanks

Note that it is generally preferred to fix coding style when working
on code changes and avoid mass cleanup.

^ permalink raw reply	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2016-10-13 21:15 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 15:46 [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 01/19] kni: move externs to the header file Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 02/19] kni: uninitialize global variables Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 03/19] kni: make static struct const Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 06/19] kni: remove useless return Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 08/19] kni: trailing statements should be on next line Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 09/19] kni: do not use assignment in if condition Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 11/19] kni: prefer min_t to min Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 13/19] kni: update kernel logging Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 16/19] kni: remove compile time debug configuration Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 17/19] kni: updated log messages Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
2016-09-15 15:46 ` [dpdk-dev] [PATCH 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 00/19] KNI checkpatch cleanup Ferruh Yigit
2016-09-26 15:39   ` [dpdk-dev] [PATCH v3 " Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 01/19] kni: move externs to the header file Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 02/19] kni: uninitialize global variables Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 03/19] kni: make static struct const Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 06/19] kni: remove useless return Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 08/19] kni: trailing statements should be on next line Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 09/19] kni: do not use assignment in if condition Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 11/19] kni: prefer min_t to min Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 13/19] kni: update kernel logging Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 16/19] kni: remove compile time debug configuration Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 17/19] kni: updated log messages Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
2016-09-26 15:39     ` [dpdk-dev] [PATCH v3 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
2016-10-13 21:15     ` [dpdk-dev] [PATCH v3 00/19] KNI checkpatch cleanup Thomas Monjalon
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 01/19] kni: move externs to the header file Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 02/19] kni: uninitialize global variables Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 03/19] kni: make static struct const Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 04/19] kni: whitespace, indentation, long line corrections Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 05/19] kni: prefer unsigned int to unsigned Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 06/19] kni: remove useless return Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 07/19] kni: comparisons should place the constant on the right Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 08/19] kni: trailing statements should be on next line Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 09/19] kni: do not use assignment in if condition Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 10/19] kni: macros with complex values should be enclosed in parentheses Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 11/19] kni: prefer min_t to min Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 12/19] kni: prefer ether_addr_copy to memcpy Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 13/19] kni: update kernel logging Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 14/19] kni: remove unnecessary 'out of memory' message Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 15/19] kni: move functions to eliminate function declarations Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 16/19] kni: remove compile time debug configuration Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 17/19] kni: updated log messages Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 18/19] kni: prefer uint32_t to unsigned int Ferruh Yigit
2016-09-16 16:26 ` [dpdk-dev] [PATCH v2 19/19] kni: move kernel version ifdefs to compat header Ferruh Yigit
2016-10-05 10:38 ` [dpdk-dev] [PATCH 00/19] KNI checkpatch cleanup Pattan, Reshma
2016-10-10 12:37   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).