Skip to contentSkip to conversation

net/ixgbe: avoid multpile definitions of 'bool'

PATCH Superseded Dharmik Thakkar 5 participants 24 messages Oct 3, 2019 – Jan 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/ixgbe: avoid multpile definitions of 'bool'

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

   ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                           ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
 drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
 drivers/net/ixgbe/ixgbe_ethdev.c     | 7 ++++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +4 -3
index 7eb3d0567b58..2c5d2e5f9295 100644
@@ -2589,7 +2589,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3958,7 +3959,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 
 static int
 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
 {
 	struct ixgbe_adapter *adapter = container_of(hw,
 						     struct ixgbe_adapter, hw);
@@ -4089,7 +4090,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 
Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 2 lines · Dharmik Thakkar

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Which compiler would trigger this compilation issue? And we have several "typedef int bool" in multiple drivers,

drivers/net/bnx2x/bnx2x_ethdev.h:50:typedef int bool;
drivers/net/cxgbe/cxgbe_compat.h:89:typedef int bool;
drivers/net/e1000/base/e1000_osdep.h:61:typedef int bool;
drivers/net/fm10k/base/fm10k_osdep.h:50:typedef int bool;
drivers/net/ixgbe/base/ixgbe_osdep.h:86:typedef int bool;
drivers/net/qede/base/bcm_osal.h:74:typedef int bool;
drivers/net/vmxnet3/base/vmxnet3_osdep.h:12:typedef int bool;

Do you need to change them all?

Thanks,
Xiaolong

Quoted 77 lines

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

  ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                          ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
drivers/net/ixgbe/ixgbe_ethdev.c | 7 ++++---

2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 7eb3d0567b58..2c5d2e5f9295 100644
@@ -2589,7 +2589,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3958,7 +3959,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 

static int
ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
{
	struct ixgbe_adapter *adapter = container_of(hw,
						     struct ixgbe_adapter, hw);
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -4089,7 +4090,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 
Signature · 1 line
2.17.1
#2 lore raw

Hi Ye,
Thank you for the comments!

Quoted 9 lines · Ye Xiaolong

Hi,

Quoted 2 lines · Dharmik Thakkar

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Which compiler would trigger this compilation issue?

gcc version 7.4.0
Compilation issue arises when ’stdbool.h’ gets included along with one of the header files with 'typedef int bool;’, thereby leading to multiple definitions of ‘bool’.
I faced this issue while working on 'https://patches.dpdk.org/patch/58333/‘ wherein I included ‘rte_rcu_qsbr.h’ (which includes ’stdbool.h’) in ‘rte_hash.h’.
Now, ‘ixgbe_ethdev.c’ includes ’stdbool.h’ (<- rte_rcu_qsbr.h <- rte_hash.h) along with ‘ixgbe_osdep.h’ (<- ixgbe_type.h <- ixgbe_api.h <- ixgbe_ethdev.h) which has 'typedef int bool;’

Quoted 11 lines

And we have several "typedef int bool" in multiple drivers,

drivers/net/bnx2x/bnx2x_ethdev.h:50:typedef int bool;
drivers/net/cxgbe/cxgbe_compat.h:89:typedef int bool;
drivers/net/e1000/base/e1000_osdep.h:61:typedef int bool;
drivers/net/fm10k/base/fm10k_osdep.h:50:typedef int bool;
drivers/net/ixgbe/base/ixgbe_osdep.h:86:typedef int bool;
drivers/net/qede/base/bcm_osal.h:74:typedef int bool;
drivers/net/vmxnet3/base/vmxnet3_osdep.h:12:typedef int bool;

Do you need to change them all?

Yes, I will fix these and submit a patch series.

Quoted 81 lines

Thanks,
Xiaolong

Quoted 77 lines

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

 ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                         ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
drivers/net/ixgbe/ixgbe_ethdev.c | 7 ++++---

2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 7eb3d0567b58..2c5d2e5f9295 100644
@@ -2589,7 +2589,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3958,7 +3959,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 

static int
ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
{
	struct ixgbe_adapter *adapter = container_of(hw,
						     struct ixgbe_adapter, hw);
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -4089,7 +4090,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 
Signature · 1 line
2.17.1
#3 lore raw

v2 cover remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' Thus, avoid future compilation problems when 'stdbool.h' gets included in these files.

---
v2:
- Remove 'typedef int bool' from other drivers
---

Dharmik Thakkar (7):
net/ixgbe: avoid multpile definitions of 'bool'
net/cxgbe: remove 'typedef int bool'
net/vmxnet3: remove 'typedef int bool'
net/bnx2x: remove 'typedef int bool'
net/e1000: remove 'typedef int bool'
net/fm10k: remove 'typedef int bool'
net/qede: remove 'typedef int bool'

 drivers/net/bnx2x/bnx2x_ethdev.h         |  4 +--
 drivers/net/bnx2x/ecore_sp.c             | 46 ++++++++++++------------
 drivers/net/cxgbe/cxgbe_compat.h         |  4 +--
 drivers/net/cxgbe/cxgbe_main.c           | 13 +++----
 drivers/net/e1000/base/e1000_osdep.h     |  5 +--
 drivers/net/fm10k/base/fm10k_osdep.h     |  8 +----
 drivers/net/fm10k/fm10k_ethdev.c         |  6 ++--
 drivers/net/ixgbe/base/ixgbe_osdep.h     |  4 +--
 drivers/net/ixgbe/ixgbe_ethdev.c         |  7 ++--
 drivers/net/qede/base/bcm_osal.h         |  5 +--
 drivers/net/qede/base/ecore_vf.c         |  2 +-
 drivers/net/qede/qede_ethdev.c           |  2 +-
 drivers/net/vmxnet3/base/vmxnet3_defs.h  |  6 ++--
 drivers/net/vmxnet3/base/vmxnet3_osdep.h |  4 +--
 14 files changed, 50 insertions(+), 66 deletions(-)
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 1/7 net/ixgbe: avoid multpile definitions of 'bool'

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

   ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                           ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
 drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
 drivers/net/ixgbe/ixgbe_ethdev.c     | 7 ++++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +4 -3
index 2c6fd0f13128..6cbd783e3a21 100644
@@ -2544,7 +2544,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3993,7 +3994,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 
 static int
 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
 {
 	struct ixgbe_adapter *adapter = container_of(hw,
 						     struct ixgbe_adapter, hw);
@@ -4124,7 +4125,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 	u32 esdp_reg;
Signature · 1 line
2.17.1
#5 lore raw
Quoted 70 lines · Dharmik Thakkar

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

   ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                           ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
 drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
 drivers/net/ixgbe/ixgbe_ethdev.c     | 7 ++++---
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +3 -2
index 2c6fd0f13128..6cbd783e3a21 100644
@@ -2544,7 +2544,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3993,7 +3994,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 
 static int
 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
 {
 	struct ixgbe_adapter *adapter = container_of(hw,
 						     struct ixgbe_adapter, hw);

drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4131

Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -4124,7 +4125,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 	u32 esdp_reg;

Can you please rebase the patchset on of next-net, getting following build error
[1] because of a commit in next-net [2], the fix should be trivial [3].

CI seems not able to catch this, Cc'ed Aaron, Ali & Zhaoyan & Jeremy if they want to investigate the issue.

[1]
.../drivers/net/ixgbe/ixgbe_ethdev.c:4137:38: error: incompatible pointer types passing 'int *' to parameter of type 'bool *' [-Werror,-Wincompatible-pointer-types]

                err = ixgbe_check_link(hw, &speed, &link_up, 0);
                                                   ^~~~~~~~
.../drivers/net/ixgbe/base/ixgbe_api.h:62:14: note: passing argument to
parameter 'link_up' here
                     bool *link_up, bool link_up_wait_to_complete);
                           ^

[2]
commit 2f2639c872c8 ("net/ixgbe: fix port can not link up in FreeBSD")

[3]
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 414b73c97..4f1704e79 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -4130,7 +4130,8 @@ ixgbe_wait_for_link_up(struct ixgbe_hw *hw)

  #else
         const int nb_iter = 0;
  #endif
 -       int err, i, link_up = 0;
 +       int err, i = 0;
 +       bool link_up = false;
         uint32_t speed = 0;

         for (i = 0; i < nb_iter; i++) {
#6 lore raw

Hi Ferruh,
Thank you for the comments!

I have rebased the patches on dpdk-next-net and fixed the issue. I have put out the patch.

Quoted 119 lines · Ferruh Yigit
Quoted 70 lines · Dharmik Thakkar

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

  ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                          ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
drivers/net/ixgbe/base/ixgbe_osdep.h | 4 +---
drivers/net/ixgbe/ixgbe_ethdev.c | 7 ++++---

2 files changed, 5 insertions(+), 6 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 2c6fd0f13128..6cbd783e3a21 100644
@@ -2544,7 +2544,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = 0, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3993,7 +3994,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 

static int
ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,

drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
{
	struct ixgbe_adapter *adapter = container_of(hw,
						     struct ixgbe_adapter, hw);

drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_dev_link_update_share(struct rte_eth_dev *dev, · line 4131

Quoted 8 lines
drivers/net/ixgbe/ixgbe_ethdev.c +1 -1
@@ -4124,7 +4125,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 	u32 esdp_reg;

Can you please rebase the patchset on of next-net, getting following build error
[1] because of a commit in next-net [2], the fix should be trivial [3].

CI seems not able to catch this, Cc'ed Aaron, Ali & Zhaoyan & Jeremy if they want to investigate the issue.

[1]
.../drivers/net/ixgbe/ixgbe_ethdev.c:4137:38: error: incompatible pointer types passing 'int *' to parameter of type 'bool *' [-Werror,-Wincompatible-pointer-types]

               err = ixgbe_check_link(hw, &speed, &link_up, 0);
                                                  ^~~~~~~~
.../drivers/net/ixgbe/base/ixgbe_api.h:62:14: note: passing argument to
parameter 'link_up' here
                    bool *link_up, bool link_up_wait_to_complete);
                          ^

[2]
commit 2f2639c872c8 ("net/ixgbe: fix port can not link up in FreeBSD")

[3]

drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 414b73c97..4f1704e79 100644
@@ -4130,7 +4130,8 @@ ixgbe_wait_for_link_up(struct ixgbe_hw *hw)
 #else
        const int nb_iter = 0;
 #endif
-       int err, i, link_up = 0;
+       int err, i = 0;
+       bool link_up = false;
        uint32_t speed = 0;
 
        for (i = 0; i < nb_iter; i++) {
#7 lore raw

PATCH v2 2/7 net/cxgbe: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/cxgbe/cxgbe_compat.h |  4 +---
 drivers/net/cxgbe/cxgbe_main.c   | 13 +++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/cxgbe/cxgbe_compat.h +1 -3
index 20e4f8af20ee..83ae1c2e5a83 100644
@@ -10,6 +10,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 
 #include <rte_common.h>
 #include <rte_memcpy.h>
@@ -86,7 +87,6 @@ typedef uint16_t  u16;
 typedef uint32_t  u32;
 typedef int32_t   s32;
 typedef uint64_t  u64;
-typedef int       bool;
 typedef uint64_t  dma_addr_t;
 
 #ifndef __le16
@@ -122,8 +122,6 @@ typedef uint64_t  dma_addr_t;
 
 #define FALSE	0
 #define TRUE	1
-#define false	0
-#define true	1
 
 #ifndef min
 #define min(a, b) RTE_MIN(a, b)
drivers/net/cxgbe/cxgbe_main.c +7 -6
index cc5f4df3acbf..0d0827c0e159 100644
@@ -709,11 +709,12 @@ static int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key,
 	return ret;
 }
 
-static void cxgbe_get_devargs_int(struct adapter *adap, int *dst,
-				  const char *key, int default_value)
+static void cxgbe_get_devargs_int(struct adapter *adap, bool *dst,
+				  const char *key, bool default_value)
 {
 	struct rte_pci_device *pdev = adap->pdev;
-	int ret, devarg_value = default_value;
+	int ret;
+	bool devarg_value = default_value;
 
 	*dst = default_value;
 	if (!pdev)
@@ -729,11 +730,11 @@ static void cxgbe_get_devargs_int(struct adapter *adap, int *dst,
 void cxgbe_process_devargs(struct adapter *adap)
 {
 	cxgbe_get_devargs_int(adap, &adap->devargs.keep_ovlan,
-			      CXGBE_DEVARG_CMN_KEEP_OVLAN, 0);
+			      CXGBE_DEVARG_CMN_KEEP_OVLAN, false);
 	cxgbe_get_devargs_int(adap, &adap->devargs.tx_mode_latency,
-			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY, 0);
+			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY, false);
 	cxgbe_get_devargs_int(adap, &adap->devargs.force_link_up,
-			      CXGBE_DEVARG_VF_FORCE_LINK_UP, 0);
+			      CXGBE_DEVARG_VF_FORCE_LINK_UP, false);
 }
 
 static void configure_vlan_types(struct adapter *adapter)
Signature · 1 line
2.17.1
#8 lore raw

PATCH v2 3/7 net/vmxnet3: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.
Remove 'typedef char Bool' and use 'bool' instead.

---
 drivers/net/vmxnet3/base/vmxnet3_defs.h  | 6 +++---
 drivers/net/vmxnet3/base/vmxnet3_osdep.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/vmxnet3/base/vmxnet3_defs.h +3 -3
index 296d7e54c330..8d62b3e116e6 100644
@@ -577,7 +577,7 @@ enum vmxnet3_intr_type {
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_IntrConf {
-   Bool   autoMask;
+   bool   autoMask;
    uint8  numIntrs;      /* # of interrupts */
    uint8  eventIntrIdx;
    uint8  modLevels[VMXNET3_MAX_INTRS]; /* moderation level for each intr */
@@ -593,7 +593,7 @@ Vmxnet3_IntrConf;
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_QueueStatus {
-   Bool    stopped;
+   bool    stopped;
    uint8   _pad[3];
    __le32  error;
 }
@@ -613,7 +613,7 @@ Vmxnet3_TxQueueCtrl;
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_RxQueueCtrl {
-   Bool    updateRxProd;
+   bool    updateRxProd;
    uint8   _pad[7];
    __le64  reserved;
 }
drivers/net/vmxnet3/base/vmxnet3_osdep.h +2 -2
index c9b92b049fe7..381a68db6957 100644
@@ -5,12 +5,12 @@
 #ifndef _VMXNET3_OSDEP_H
 #define _VMXNET3_OSDEP_H
 
+#include <stdbool.h>
+
 typedef uint64_t	uint64;
 typedef uint32_t	uint32;
 typedef uint16_t	uint16;
 typedef uint8_t		uint8;
-typedef int		bool;
-typedef char		Bool;
 
 #ifndef UNLIKELY
 #define UNLIKELY(x)  __builtin_expect((x),0)
Signature · 1 line
2.17.1
Reviewed-by Phil Yang Reviewed-by Ruifeng Wang Acked-by on v2 3/7
#9 lore raw

Re: [dpdk-dev] [PATCH v2 3/7] net/vmxnet3: remove 'typedef int bool'

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Date: Thursday, January 2, 2020 at 9:49 AM
To: Yong Wang <[email protected]>
Cc: "[email protected]" <[email protected]>, Dharmik Thakkar <[email protected]>
Subject: [PATCH v2 3/7] net/vmxnet3: remove 'typedef int bool'

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.
Remove 'typedef char Bool' and use 'bool' instead.

---

     drivers/net/vmxnet3/base/vmxnet3_defs.h  | 6 +++---
     drivers/net/vmxnet3/base/vmxnet3_osdep.h | 4 ++--
     2 files changed, 5 insertions(+), 5 deletions(-)
    diff --git a/drivers/net/vmxnet3/base/vmxnet3_defs.h b/drivers/net/vmxnet3/base/vmxnet3_defs.h
    index 296d7e54c330..8d62b3e116e6 100644
    --- a/drivers/net/vmxnet3/base/vmxnet3_defs.h
    +++ b/drivers/net/vmxnet3/base/vmxnet3_defs.h
    @@ -577,7 +577,7 @@ enum vmxnet3_intr_type {
     typedef
     #include "vmware_pack_begin.h"
     struct Vmxnet3_IntrConf {
    -   Bool   autoMask;
    +   bool   autoMask;
        uint8  numIntrs;      /* # of interrupts */
        uint8  eventIntrIdx;
        uint8  modLevels[VMXNET3_MAX_INTRS]; /* moderation level for each intr */
    @@ -593,7 +593,7 @@ Vmxnet3_IntrConf;
     typedef
     #include "vmware_pack_begin.h"
     struct Vmxnet3_QueueStatus {
    -   Bool    stopped;
    +   bool    stopped;
        uint8   _pad[3];
        __le32  error;
     }
    @@ -613,7 +613,7 @@ Vmxnet3_TxQueueCtrl;
     typedef
     #include "vmware_pack_begin.h"
     struct Vmxnet3_RxQueueCtrl {
    -   Bool    updateRxProd;
    +   bool    updateRxProd;
        uint8   _pad[7];
        __le64  reserved;
     }
    diff --git a/drivers/net/vmxnet3/base/vmxnet3_osdep.h b/drivers/net/vmxnet3/base/vmxnet3_osdep.h
    index c9b92b049fe7..381a68db6957 100644
    --- a/drivers/net/vmxnet3/base/vmxnet3_osdep.h
    +++ b/drivers/net/vmxnet3/base/vmxnet3_osdep.h
    @@ -5,12 +5,12 @@
     #ifndef _VMXNET3_OSDEP_H
     #define _VMXNET3_OSDEP_H
     
    +#include <stdbool.h>
    +
     typedef uint64_t	uint64;
     typedef uint32_t	uint32;
     typedef uint16_t	uint16;
     typedef uint8_t		uint8;
    -typedef int		bool;
    -typedef char		Bool;
     
     #ifndef UNLIKELY
     #define UNLIKELY(x)  __builtin_expect((x),0)
    -- 
    2.17.1
#10 lore raw

PATCH v2 4/7 net/bnx2x: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/bnx2x/bnx2x_ethdev.h |  4 +--
 drivers/net/bnx2x/ecore_sp.c     | 46 ++++++++++++++++----------------
 2 files changed, 24 insertions(+), 26 deletions(-)
drivers/net/bnx2x/bnx2x_ethdev.h +1 -3
index bd3ef143b63d..f712bb3e84c6 100644
@@ -15,6 +15,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdint.h>
 #include <string.h>
@@ -47,9 +48,6 @@
 #define FALSE               0
 #define TRUE                1
 
-typedef int bool;
-#define false               0
-#define true                1
 #define min(a,b)        RTE_MIN(a,b)
 
 #define mb()    rte_mb()
drivers/net/bnx2x/ecore_sp.c +23 -23

172 lines not on this page · raw message

Signature · 1 line
2.17.1
#11 lore raw

PATCH v2 5/7 net/e1000: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/e1000/base/e1000_osdep.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/e1000/base/e1000_osdep.h +1 -4
index fd22c7e41fcf..94a49f340446 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <string.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -58,7 +59,6 @@ typedef int64_t		s64;
 typedef int32_t		s32;
 typedef int16_t		s16;
 typedef int8_t		s8;
-typedef int		bool;
 
 #define __le16		u16
 #define __le32		u32
@@ -163,7 +163,4 @@ static inline uint16_t e1000_read_addr16(volatile void *addr)
 #define ETH_ADDR_LEN                  6
 #endif
 
-#define false                         FALSE
-#define true                          TRUE
-
 #endif /* _E1000_OSDEP_H_ */
Signature · 1 line
2.17.1
#12 lore raw

PATCH v2 6/7 net/fm10k: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/fm10k/base/fm10k_osdep.h | 8 +-------
 drivers/net/fm10k/fm10k_ethdev.c     | 6 +++---
 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/net/fm10k/base/fm10k_osdep.h +1 -7
index 3b6298010da5..019fba5e2534 100644
@@ -6,6 +6,7 @@
 #define _FM10K_OSDEP_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <rte_atomic.h>
 #include <rte_byteorder.h>
@@ -32,12 +33,6 @@
 
 #define FALSE      0
 #define TRUE       1
-#ifndef false
-#define false      FALSE
-#endif
-#ifndef true
-#define true       TRUE
-#endif
 
 typedef uint8_t    u8;
 typedef int8_t     s8;
@@ -47,7 +42,6 @@ typedef uint32_t   u32;
 typedef int32_t    s32;
 typedef int64_t    s64;
 typedef uint64_t   u64;
-typedef int        bool;
 
 #ifndef __le16
 #define __le16     u16
drivers/net/fm10k/fm10k_ethdev.c +3 -3
index 407baa16c364..581c690b1842 100644
@@ -3210,19 +3210,19 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 
 	/* Make sure Switch Manager is ready before going forward. */
 	if (hw->mac.type == fm10k_mac_pf) {
-		int switch_ready = 0;
+		bool switch_ready = false;
 
 		for (i = 0; i < MAX_QUERY_SWITCH_STATE_TIMES; i++) {
 			fm10k_mbx_lock(hw);
 			hw->mac.ops.get_host_state(hw, &switch_ready);
 			fm10k_mbx_unlock(hw);
-			if (switch_ready)
+			if (switch_ready == true)
 				break;
 			/* Delay some time to acquire async LPORT_MAP info. */
 			rte_delay_us(WAIT_SWITCH_MSG_US);
 		}
 
-		if (switch_ready == 0) {
+		if (switch_ready == false) {
 			PMD_INIT_LOG(ERR, "switch is not ready");
 			return -1;
 		}
Signature · 1 line
2.17.1
Acked-by on v2 6/7
#13 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/fm10k: remove 'typedef int bool'

Hi,

Quoted 81 lines

-----Original Message-----
From: Dharmik Thakkar <[email protected]>
Sent: Friday, January 3, 2020 1:49 AM
To: Zhang, Qi Z <[email protected]>; Wang, Xiao W <[email protected]>
Cc: [email protected]; Dharmik Thakkar <[email protected]>
Subject: [PATCH v2 6/7] net/fm10k: remove 'typedef int bool'

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/fm10k/base/fm10k_osdep.h | 8 +-------
 drivers/net/fm10k/fm10k_ethdev.c     | 6 +++---
 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/net/fm10k/base/fm10k_osdep.h +1 -7
index 3b6298010da5..019fba5e2534 100644
@@ -6,6 +6,7 @@
 #define _FM10K_OSDEP_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <rte_atomic.h>
 #include <rte_byteorder.h>
@@ -32,12 +33,6 @@
 
 #define FALSE      0
 #define TRUE       1
-#ifndef false
-#define false      FALSE
-#endif
-#ifndef true
-#define true       TRUE
-#endif
 
 typedef uint8_t    u8;
 typedef int8_t     s8;
@@ -47,7 +42,6 @@ typedef uint32_t   u32;
 typedef int32_t    s32;
 typedef int64_t    s64;
 typedef uint64_t   u64;
-typedef int        bool;
 
 #ifndef __le16
 #define __le16     u16
drivers/net/fm10k/fm10k_ethdev.c +3 -3
index 407baa16c364..581c690b1842 100644
@@ -3210,19 +3210,19 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 
 	/* Make sure Switch Manager is ready before going forward. */
 	if (hw->mac.type == fm10k_mac_pf) {
-		int switch_ready = 0;
+		bool switch_ready = false;
 
 		for (i = 0; i < MAX_QUERY_SWITCH_STATE_TIMES; i++) {
 			fm10k_mbx_lock(hw);
 			hw->mac.ops.get_host_state(hw, &switch_ready);
 			fm10k_mbx_unlock(hw);
-			if (switch_ready)
+			if (switch_ready == true)
 				break;
 			/* Delay some time to acquire async LPORT_MAP info.
 */
 			rte_delay_us(WAIT_SWITCH_MSG_US);
 		}
 
-		if (switch_ready == 0) {
+		if (switch_ready == false) {
 			PMD_INIT_LOG(ERR, "switch is not ready");
 			return -1;
Quoted 3 lines

}
--
2.17.1

BRs,
Xiao

#14 lore raw

PATCH v2 7/7 net/qede: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

(Not sure if the previous code is checking for true/false condition. Recommend careful review on this patch.)

---
 drivers/net/qede/base/bcm_osal.h | 5 +----
 drivers/net/qede/base/ecore_vf.c | 2 +-
 drivers/net/qede/qede_ethdev.c   | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/qede/base/bcm_osal.h +1 -4
index 0f09557cf06c..513f6a8b429f 100644
@@ -7,6 +7,7 @@
 #ifndef __BCM_OSAL_H
 #define __BCM_OSAL_H
 
+#include <stdbool.h>
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 #include <rte_malloc.h>
@@ -71,10 +72,6 @@ typedef size_t osal_size_t;
 
 typedef intptr_t osal_int_ptr_t;
 
-typedef int bool;
-#define true 1
-#define false 0
-
 #define nothing do {} while (0)
 
 /* Delays */
drivers/net/qede/base/ecore_vf.c +1 -1
index 24846cfb51da..c5c081426281 100644
@@ -446,7 +446,7 @@ static enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn)
 	}
 
 	/* @DPDK */
-	if ((~p_iov->b_pre_fp_hsi &
+	if (((p_iov->b_pre_fp_hsi == true) &
 	    ETH_HSI_VER_MINOR) &&
 	    (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR))
 		DP_INFO(p_hwfn,
drivers/net/qede/qede_ethdev.c +1 -1
index 19d2e961913d..af99ce9c65e6 100644
@@ -450,7 +450,7 @@ int qede_activate_vport(struct rte_eth_dev *eth_dev, bool flg)
 	params.update_vport_active_tx_flg = 1;
 	params.vport_active_rx_flg = flg;
 	params.vport_active_tx_flg = flg;
-	if (~qdev->enable_tx_switching & flg) {
+	if ((qdev->enable_tx_switching == false) && (flg == true)) {
 		params.update_tx_switching_flg = 1;
 		params.tx_switching_flg = !flg;
 	}
Signature · 1 line
2.17.1
#15 lore raw

v3 cover remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' Thus, avoid future compilation problems when 'stdbool.h' gets included in these files.

---
v3:
- Rebase on dpdk-next-net
- Fix build issue in net/ixgbe
---
v2:
- Remove 'typedef int bool' from other drivers
---

Dharmik Thakkar (7):
net/ixgbe: avoid multpile definitions of 'bool'
net/cxgbe: remove 'typedef int bool'
net/vmxnet3: remove 'typedef int bool'
net/bnx2x: remove 'typedef int bool'
net/e1000: remove 'typedef int bool'
net/fm10k: remove 'typedef int bool'
net/qede: remove 'typedef int bool'

 drivers/net/bnx2x/bnx2x_ethdev.h         |  4 +--
 drivers/net/bnx2x/ecore_sp.c             | 46 ++++++++++++------------
 drivers/net/cxgbe/cxgbe_compat.h         |  4 +--
 drivers/net/cxgbe/cxgbe_main.c           | 13 +++----
 drivers/net/e1000/base/e1000_osdep.h     |  5 +--
 drivers/net/fm10k/base/fm10k_osdep.h     |  8 +----
 drivers/net/fm10k/fm10k_ethdev.c         |  6 ++--
 drivers/net/ixgbe/base/ixgbe_osdep.h     |  4 +--
 drivers/net/ixgbe/ixgbe_ethdev.c         | 10 +++---
 drivers/net/qede/base/bcm_osal.h         |  5 +--
 drivers/net/qede/base/ecore_vf.c         |  2 +-
 drivers/net/qede/qede_ethdev.c           |  2 +-
 drivers/net/vmxnet3/base/vmxnet3_defs.h  |  6 ++--
 drivers/net/vmxnet3/base/vmxnet3_osdep.h |  4 +--
 14 files changed, 52 insertions(+), 67 deletions(-)
Signature · 1 line
2.17.1
#16 lore raw

PATCH v3 1/7 net/ixgbe: avoid multpile definitions of 'bool'

Compilation issue arises due to multiple definitions of 'bool' in 'ixgbe_ethdev.h'.

Error:
'/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c: In function ‘ixgbe_dev_setup_link_alarm_handler’:
/dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:4075:43:
error: passing argument 3 of ‘ixgbe_get_link_capabilities’ from incompatible pointer type [-Werror=incompatible-pointer-types]

   ixgbe_get_link_capabilities(hw, &speed, &autoneg);
                                           ^

In file included from /dpdk/drivers/net/ixgbe/ixgbe_ethdev.c:41:0:
/dpdk/drivers/net/ixgbe/base/ixgbe_api.h:63:5: note: expected ‘bool * {aka int *}’ but argument is of type ‘_Bool *’'

---
 drivers/net/ixgbe/base/ixgbe_osdep.h |  4 +---
 drivers/net/ixgbe/ixgbe_ethdev.c     | 10 ++++++----
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/net/ixgbe/base/ixgbe_osdep.h +1 -3
index ea8dc1cbe570..844d1701f595 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_cycles.h>
@@ -82,9 +83,6 @@ typedef int16_t		s16;
 typedef uint32_t	u32;
 typedef int32_t		s32;
 typedef uint64_t	u64;
-#ifndef __cplusplus
-typedef int		bool;
-#endif
 
 #define mb()	rte_mb()
 #define wmb()	rte_wmb()
drivers/net/ixgbe/ixgbe_ethdev.c +6 -4
index b2f723f0b628..e335187bc8f1 100644
@@ -2545,7 +2545,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
 	uint32_t intr_vector = 0;
-	int err, link_up = 0, negotiate = 0;
+	int err;
+	bool link_up = false, negotiate = 0;
 	uint32_t speed = 0;
 	uint32_t allowed_speeds = 0;
 	int mask = 0;
@@ -3992,7 +3993,7 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev,
 
 static int
 ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
-		   int *link_up, int wait_to_complete)
+		   bool *link_up, int wait_to_complete)
 {
 	struct ixgbe_adapter *adapter = container_of(hw,
 						     struct ixgbe_adapter, hw);
@@ -4129,7 +4130,8 @@ ixgbe_wait_for_link_up(struct ixgbe_hw *hw)
 #else
 	const int nb_iter = 0;
 #endif
-	int err, i, link_up = 0;
+	int err, i;
+	bool link_up = false;
 	uint32_t speed = 0;
 
 	for (i = 0; i < nb_iter; i++) {
@@ -4153,7 +4155,7 @@ ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
 	ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
 	struct ixgbe_interrupt *intr =
 		IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
-	int link_up;
+	bool link_up;
 	int diag;
 	int wait = 1;
 	u32 esdp_reg;
Signature · 1 line
2.17.1
#17 lore raw

PATCH v3 2/7 net/cxgbe: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/cxgbe/cxgbe_compat.h |  4 +---
 drivers/net/cxgbe/cxgbe_main.c   | 13 +++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/cxgbe/cxgbe_compat.h +1 -3
index 20e4f8af20ee..83ae1c2e5a83 100644
@@ -10,6 +10,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 
 #include <rte_common.h>
 #include <rte_memcpy.h>
@@ -86,7 +87,6 @@ typedef uint16_t  u16;
 typedef uint32_t  u32;
 typedef int32_t   s32;
 typedef uint64_t  u64;
-typedef int       bool;
 typedef uint64_t  dma_addr_t;
 
 #ifndef __le16
@@ -122,8 +122,6 @@ typedef uint64_t  dma_addr_t;
 
 #define FALSE	0
 #define TRUE	1
-#define false	0
-#define true	1
 
 #ifndef min
 #define min(a, b) RTE_MIN(a, b)
drivers/net/cxgbe/cxgbe_main.c +7 -6
index cc5f4df3acbf..0d0827c0e159 100644
@@ -709,11 +709,12 @@ static int cxgbe_get_devargs(struct rte_devargs *devargs, const char *key,
 	return ret;
 }
 
-static void cxgbe_get_devargs_int(struct adapter *adap, int *dst,
-				  const char *key, int default_value)
+static void cxgbe_get_devargs_int(struct adapter *adap, bool *dst,
+				  const char *key, bool default_value)
 {
 	struct rte_pci_device *pdev = adap->pdev;
-	int ret, devarg_value = default_value;
+	int ret;
+	bool devarg_value = default_value;
 
 	*dst = default_value;
 	if (!pdev)
@@ -729,11 +730,11 @@ static void cxgbe_get_devargs_int(struct adapter *adap, int *dst,
 void cxgbe_process_devargs(struct adapter *adap)
 {
 	cxgbe_get_devargs_int(adap, &adap->devargs.keep_ovlan,
-			      CXGBE_DEVARG_CMN_KEEP_OVLAN, 0);
+			      CXGBE_DEVARG_CMN_KEEP_OVLAN, false);
 	cxgbe_get_devargs_int(adap, &adap->devargs.tx_mode_latency,
-			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY, 0);
+			      CXGBE_DEVARG_CMN_TX_MODE_LATENCY, false);
 	cxgbe_get_devargs_int(adap, &adap->devargs.force_link_up,
-			      CXGBE_DEVARG_VF_FORCE_LINK_UP, 0);
+			      CXGBE_DEVARG_VF_FORCE_LINK_UP, false);
 }
 
 static void configure_vlan_types(struct adapter *adapter)
Signature · 1 line
2.17.1
#18 lore raw

PATCH v3 3/7 net/vmxnet3: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.
Remove 'typedef char Bool' and use 'bool' instead.

---
 drivers/net/vmxnet3/base/vmxnet3_defs.h  | 6 +++---
 drivers/net/vmxnet3/base/vmxnet3_osdep.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/vmxnet3/base/vmxnet3_defs.h +3 -3
index 296d7e54c330..8d62b3e116e6 100644
@@ -577,7 +577,7 @@ enum vmxnet3_intr_type {
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_IntrConf {
-   Bool   autoMask;
+   bool   autoMask;
    uint8  numIntrs;      /* # of interrupts */
    uint8  eventIntrIdx;
    uint8  modLevels[VMXNET3_MAX_INTRS]; /* moderation level for each intr */
@@ -593,7 +593,7 @@ Vmxnet3_IntrConf;
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_QueueStatus {
-   Bool    stopped;
+   bool    stopped;
    uint8   _pad[3];
    __le32  error;
 }
@@ -613,7 +613,7 @@ Vmxnet3_TxQueueCtrl;
 typedef
 #include "vmware_pack_begin.h"
 struct Vmxnet3_RxQueueCtrl {
-   Bool    updateRxProd;
+   bool    updateRxProd;
    uint8   _pad[7];
    __le64  reserved;
 }
drivers/net/vmxnet3/base/vmxnet3_osdep.h +2 -2
index c9b92b049fe7..381a68db6957 100644
@@ -5,12 +5,12 @@
 #ifndef _VMXNET3_OSDEP_H
 #define _VMXNET3_OSDEP_H
 
+#include <stdbool.h>
+
 typedef uint64_t	uint64;
 typedef uint32_t	uint32;
 typedef uint16_t	uint16;
 typedef uint8_t		uint8;
-typedef int		bool;
-typedef char		Bool;
 
 #ifndef UNLIKELY
 #define UNLIKELY(x)  __builtin_expect((x),0)
Signature · 1 line
2.17.1
#19 lore raw

PATCH v3 4/7 net/bnx2x: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/bnx2x/bnx2x_ethdev.h |  4 +--
 drivers/net/bnx2x/ecore_sp.c     | 46 ++++++++++++++++----------------
 2 files changed, 24 insertions(+), 26 deletions(-)
drivers/net/bnx2x/bnx2x_ethdev.h +1 -3
index bd3ef143b63d..f712bb3e84c6 100644
@@ -15,6 +15,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <stdint.h>
 #include <string.h>
@@ -47,9 +48,6 @@
 #define FALSE               0
 #define TRUE                1
 
-typedef int bool;
-#define false               0
-#define true                1
 #define min(a,b)        RTE_MIN(a,b)
 
 #define mb()    rte_mb()
drivers/net/bnx2x/ecore_sp.c +23 -23

172 lines not on this page · raw message

Signature · 1 line
2.17.1
#20 lore raw

PATCH v3 5/7 net/e1000: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/e1000/base/e1000_osdep.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/net/e1000/base/e1000_osdep.h +1 -4
index fd22c7e41fcf..94a49f340446 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <string.h>
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -58,7 +59,6 @@ typedef int64_t		s64;
 typedef int32_t		s32;
 typedef int16_t		s16;
 typedef int8_t		s8;
-typedef int		bool;
 
 #define __le16		u16
 #define __le32		u32
@@ -163,7 +163,4 @@ static inline uint16_t e1000_read_addr16(volatile void *addr)
 #define ETH_ADDR_LEN                  6
 #endif
 
-#define false                         FALSE
-#define true                          TRUE
-
 #endif /* _E1000_OSDEP_H_ */
Signature · 1 line
2.17.1
#21 lore raw

PATCH v3 6/7 net/fm10k: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

---
 drivers/net/fm10k/base/fm10k_osdep.h | 8 +-------
 drivers/net/fm10k/fm10k_ethdev.c     | 6 +++---
 2 files changed, 4 insertions(+), 10 deletions(-)
drivers/net/fm10k/base/fm10k_osdep.h +1 -7
index 3b6298010da5..019fba5e2534 100644
@@ -6,6 +6,7 @@
 #define _FM10K_OSDEP_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include <rte_atomic.h>
 #include <rte_byteorder.h>
@@ -32,12 +33,6 @@
 
 #define FALSE      0
 #define TRUE       1
-#ifndef false
-#define false      FALSE
-#endif
-#ifndef true
-#define true       TRUE
-#endif
 
 typedef uint8_t    u8;
 typedef int8_t     s8;
@@ -47,7 +42,6 @@ typedef uint32_t   u32;
 typedef int32_t    s32;
 typedef int64_t    s64;
 typedef uint64_t   u64;
-typedef int        bool;
 
 #ifndef __le16
 #define __le16     u16
drivers/net/fm10k/fm10k_ethdev.c +3 -3
index 407baa16c364..581c690b1842 100644
@@ -3210,19 +3210,19 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
 
 	/* Make sure Switch Manager is ready before going forward. */
 	if (hw->mac.type == fm10k_mac_pf) {
-		int switch_ready = 0;
+		bool switch_ready = false;
 
 		for (i = 0; i < MAX_QUERY_SWITCH_STATE_TIMES; i++) {
 			fm10k_mbx_lock(hw);
 			hw->mac.ops.get_host_state(hw, &switch_ready);
 			fm10k_mbx_unlock(hw);
-			if (switch_ready)
+			if (switch_ready == true)
 				break;
 			/* Delay some time to acquire async LPORT_MAP info. */
 			rte_delay_us(WAIT_SWITCH_MSG_US);
 		}
 
-		if (switch_ready == 0) {
+		if (switch_ready == false) {
 			PMD_INIT_LOG(ERR, "switch is not ready");
 			return -1;
 		}
Signature · 1 line
2.17.1
#22 lore raw

PATCH v3 7/7 net/qede: remove 'typedef int bool'

In reply to Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' to avoid possible multiple definitions of 'bool'.

(Not sure if the previous code is checking for true/false condition. Recommend careful review on this patch.)

---
 drivers/net/qede/base/bcm_osal.h | 5 +----
 drivers/net/qede/base/ecore_vf.c | 2 +-
 drivers/net/qede/qede_ethdev.c   | 2 +-
 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/qede/base/bcm_osal.h +1 -4
index 0f09557cf06c..513f6a8b429f 100644
@@ -7,6 +7,7 @@
 #ifndef __BCM_OSAL_H
 #define __BCM_OSAL_H
 
+#include <stdbool.h>
 #include <rte_byteorder.h>
 #include <rte_spinlock.h>
 #include <rte_malloc.h>
@@ -71,10 +72,6 @@ typedef size_t osal_size_t;
 
 typedef intptr_t osal_int_ptr_t;
 
-typedef int bool;
-#define true 1
-#define false 0
-
 #define nothing do {} while (0)
 
 /* Delays */
drivers/net/qede/base/ecore_vf.c +1 -1
index 24846cfb51da..c5c081426281 100644
@@ -446,7 +446,7 @@ static enum _ecore_status_t ecore_vf_pf_acquire(struct ecore_hwfn *p_hwfn)
 	}
 
 	/* @DPDK */
-	if ((~p_iov->b_pre_fp_hsi &
+	if (((p_iov->b_pre_fp_hsi == true) &
 	    ETH_HSI_VER_MINOR) &&
 	    (resp->pfdev_info.minor_fp_hsi < ETH_HSI_VER_MINOR))
 		DP_INFO(p_hwfn,
drivers/net/qede/qede_ethdev.c +1 -1
index 19d2e961913d..af99ce9c65e6 100644
@@ -450,7 +450,7 @@ int qede_activate_vport(struct rte_eth_dev *eth_dev, bool flg)
 	params.update_vport_active_tx_flg = 1;
 	params.vport_active_rx_flg = flg;
 	params.vport_active_tx_flg = flg;
-	if (~qdev->enable_tx_switching & flg) {
+	if ((qdev->enable_tx_switching == false) && (flg == true)) {
 		params.update_tx_switching_flg = 1;
 		params.tx_switching_flg = !flg;
 	}
Signature · 1 line
2.17.1
Reviewed-by on the v3 series
#23 lore raw

Re: [dpdk-dev] [PATCH v3 0/7] remove 'typedef int bool'

In reply to Dharmik Thakkar
Quoted 13 lines · Dharmik Thakkar

Replace 'typedef int bool' with 'stdbool.h' Thus, avoid future compilation problems when 'stdbool.h' gets included in these files.

---
v3:
- Rebase on dpdk-next-net
- Fix build issue in net/ixgbe
---
v2:
- Remove 'typedef int bool' from other drivers
---

Quoted 8 lines

Dharmik Thakkar (7):
net/ixgbe: avoid multpile definitions of 'bool'
net/cxgbe: remove 'typedef int bool'
net/vmxnet3: remove 'typedef int bool'
net/bnx2x: remove 'typedef int bool'
net/e1000: remove 'typedef int bool'
net/fm10k: remove 'typedef int bool'
net/qede: remove 'typedef int bool'

For series,

Series applied to dpdk-next-net/master, thanks.