Skip to contentSkip to conversation

Various fixes to compile with gcc6

PATCH Superseded Aaron Conole 7 participants 35 messages Feb 25, 2016 – Mar 22, 2016 Network drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Various fixes to compile with gcc6

This series brings a number of code cleanups to allow building using gcc6, with various legitimate warnings being fixed.

In particular, patch 3 ("drivers/net/e1000: Fix missing brackets") should be checked for correctness (it does not alter any behavior from a functional standpoint, but it may be required to do so for a correct fix).

Aaron Conole (8):
lpm: Fix pointer aliasing issues
app/test/test: Fix missing brackets drivers/net/e1000: Fix missing brackets drivers/net/e1000: Fix missing lsc interrupt check brackets drivers/net/ixgbe: Fix vlan filter missing brackets drivers/net/e1000/igb: Signed left shift operator drivers/net/ixgbe: Signed left shift operator drivers/net/ixgbe: Fix uninitialized warning

 app/test/test.c                    |  3 ++-
 drivers/net/e1000/base/e1000_phy.c | 12 ++++-----
 drivers/net/e1000/em_ethdev.c      |  3 ++-
 drivers/net/e1000/igb_pf.c         |  4 +--
 drivers/net/ixgbe/ixgbe_ethdev.c   |  3 ++-
 drivers/net/ixgbe/ixgbe_pf.c       |  4 +--
 drivers/net/ixgbe/ixgbe_rxtx.c     |  4 +--
 lib/librte_lpm/rte_lpm.h           | 53 +++++++++++++++++++++++++++++---------
 8 files changed, 59 insertions(+), 27 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/8 lpm: Fix pointer aliasing issues

The current implementation attempts to use a uint16_t to alias the lpm table structures. Such aliasing can break optimizer performance. This patch uses union type indirection and adds static inline functions for performing the aliasing.

---
 lib/librte_lpm/rte_lpm.h | 53 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 12 deletions(-)
lib/librte_lpm/rte_lpm.h +41 -12
index c299ce2..eae6ff1 100644
@@ -157,6 +157,33 @@ struct rte_lpm {
 };
 
 /**
+ * Convert from tbl_entry types to integer types
+ */
+static inline uint16_t
+rte_lpm_tbl24_entry_to_uint16(const struct rte_lpm_tbl24_entry *entry)
+{
+	union {
+		uint16_t                   i;
+		struct rte_lpm_tbl24_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+static inline uint16_t
+rte_lpm_tbl8_entry_to_uint16(const struct rte_lpm_tbl8_entry *entry)
+{
+	union {
+		uint16_t                  i;
+		struct rte_lpm_tbl8_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+/**
  * Create an LPM object.
  *
  * @param name
@@ -286,7 +313,7 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop)
 	RTE_LPM_RETURN_IF_TRUE(((lpm == NULL) || (next_hop == NULL)), -EINVAL);
 
 	/* Copy tbl24 entry */
-	tbl_entry = *(const uint16_t *)&lpm->tbl24[tbl24_index];
+	tbl_entry = rte_lpm_tbl24_entry_to_uint16(&lpm->tbl24[tbl24_index]);
 
 	/* Copy tbl8 entry (only if needed) */
 	if (unlikely((tbl_entry & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
@@ -295,7 +322,7 @@ rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint8_t *next_hop)
 		unsigned tbl8_index = (uint8_t)ip +
 				((uint8_t)tbl_entry * RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
 
-		tbl_entry = *(const uint16_t *)&lpm->tbl8[tbl8_index];
+		tbl_entry = rte_lpm_tbl8_entry_to_uint16(&lpm->tbl8[tbl8_index]);
 	}
 
 	*next_hop = (uint8_t)tbl_entry;
@@ -342,7 +369,8 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t * ips,
 
 	for (i = 0; i < n; i++) {
 		/* Simply copy tbl24 entry to output */
-		next_hops[i] = *(const uint16_t *)&lpm->tbl24[tbl24_indexes[i]];
+		next_hops[i] = rte_lpm_tbl24_entry_to_uint16(
+			&lpm->tbl24[tbl24_indexes[i]]);
 
 		/* Overwrite output with tbl8 entry if needed */
 		if (unlikely((next_hops[i] & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
@@ -352,7 +380,8 @@ rte_lpm_lookup_bulk_func(const struct rte_lpm *lpm, const uint32_t * ips,
 					((uint8_t)next_hops[i] *
 					 RTE_LPM_TBL8_GROUP_NUM_ENTRIES);
 
-			next_hops[i] = *(const uint16_t *)&lpm->tbl8[tbl8_index];
+			next_hops[i] = rte_lpm_tbl8_entry_to_uint16(
+					&lpm->tbl8[tbl8_index]);
 		}
 	}
 	return 0;
@@ -419,13 +448,13 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, __m128i ip, uint16_t hop[4],
 	idx = _mm_cvtsi128_si64(i24);
 	i24 = _mm_srli_si128(i24, sizeof(uint64_t));
 
-	tbl[0] = *(const uint16_t *)&lpm->tbl24[(uint32_t)idx];
-	tbl[1] = *(const uint16_t *)&lpm->tbl24[idx >> 32];
+	tbl[0] = rte_lpm_tbl24_entry_to_uint16(&lpm->tbl24[(uint32_t)idx]);
+	tbl[1] = rte_lpm_tbl24_entry_to_uint16(&lpm->tbl24[idx >> 32]);
 
 	idx = _mm_cvtsi128_si64(i24);
 
-	tbl[2] = *(const uint16_t *)&lpm->tbl24[(uint32_t)idx];
-	tbl[3] = *(const uint16_t *)&lpm->tbl24[idx >> 32];
+	tbl[2] = rte_lpm_tbl24_entry_to_uint16(&lpm->tbl24[(uint32_t)idx]);
+	tbl[3] = rte_lpm_tbl24_entry_to_uint16(&lpm->tbl24[idx >> 32]);
 
 	/* get 4 indexes for tbl8[]. */
 	i8.x = _mm_and_si128(ip, mask8);
@@ -446,25 +475,25 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, __m128i ip, uint16_t hop[4],
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[0] = i8.u32[0] +
 			(uint8_t)tbl[0] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl[0] = *(const uint16_t *)&lpm->tbl8[i8.u32[0]];
+		tbl[0] = rte_lpm_tbl8_entry_to_uint16(&lpm->tbl8[i8.u32[0]]);
 	}
 	if (unlikely((pt >> 16 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[1] = i8.u32[1] +
 			(uint8_t)tbl[1] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl[1] = *(const uint16_t *)&lpm->tbl8[i8.u32[1]];
+		tbl[1] = rte_lpm_tbl8_entry_to_uint16(&lpm->tbl8[i8.u32[1]]);
 	}
 	if (unlikely((pt >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[2] = i8.u32[2] +
 			(uint8_t)tbl[2] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl[2] = *(const uint16_t *)&lpm->tbl8[i8.u32[2]];
+		tbl[2] = rte_lpm_tbl8_entry_to_uint16(&lpm->tbl8[i8.u32[2]]);
 	}
 	if (unlikely((pt >> 48 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
 			RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
 		i8.u32[3] = i8.u32[3] +
 			(uint8_t)tbl[3] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
-		tbl[3] = *(const uint16_t *)&lpm->tbl8[i8.u32[3]];
+		tbl[3] = rte_lpm_tbl8_entry_to_uint16(&lpm->tbl8[i8.u32[3]]);
 	}
 
 	hop[0] = (tbl[0] & RTE_LPM_LOOKUP_SUCCESS) ? (uint8_t)tbl[0] : defv;
Signature · 1 line
2.5.0
#2 lore raw

Re: [PATCH 1/8] lpm: Fix pointer aliasing issues

Quoted 34 lines · Aaron Conole

The current implementation attempts to use a uint16_t to alias the lpm table structures. Such aliasing can break optimizer performance. This patch uses union type indirection and adds static inline functions for performing the aliasing.

---
 lib/librte_lpm/rte_lpm.h | 53 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 12 deletions(-)
lib/librte_lpm/rte_lpm.h +16 -0
index c299ce2..eae6ff1 100644
@@ -157,6 +157,33 @@ struct rte_lpm {
 };
 
 /**
+ * Convert from tbl_entry types to integer types
+ */
+static inline uint16_t
+rte_lpm_tbl24_entry_to_uint16(const struct rte_lpm_tbl24_entry *entry)
+{
+	union {
+		uint16_t                   i;
+		struct rte_lpm_tbl24_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+static inline uint16_t
+rte_lpm_tbl8_entry_to_uint16(const struct rte_lpm_tbl8_entry *entry)

lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 185

Quoted 10 lines
lib/librte_lpm/rte_lpm.h +10 -0
+{
+	union {
+		uint16_t                  i;
+		struct rte_lpm_tbl8_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+

These two new functions could be reduced to one with the help of patch:
http://dpdk.org/dev/patchwork/patch/9087/

Anyone care to go back and review or ack that patch for me and simplify all the lpm code just that little bit?

/Bruce

#3 lore raw

Re: [PATCH 1/8] lpm: Fix pointer aliasing issues

Hi Bruce,

Quoted 49 lines · Bruce Richardson
Quoted 34 lines · Aaron Conole

The current implementation attempts to use a uint16_t to alias the lpm table structures. Such aliasing can break optimizer performance. This patch uses union type indirection and adds static inline functions for performing the aliasing.

---
 lib/librte_lpm/rte_lpm.h | 53 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 12 deletions(-)
lib/librte_lpm/rte_lpm.h +16 -0
index c299ce2..eae6ff1 100644
@@ -157,6 +157,33 @@ struct rte_lpm {
 };
 
 /**
+ * Convert from tbl_entry types to integer types
+ */
+static inline uint16_t
+rte_lpm_tbl24_entry_to_uint16(const struct rte_lpm_tbl24_entry *entry)
+{
+	union {
+		uint16_t                   i;
+		struct rte_lpm_tbl24_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+static inline uint16_t
+rte_lpm_tbl8_entry_to_uint16(const struct rte_lpm_tbl8_entry *entry)

lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 185

Quoted 10 lines
lib/librte_lpm/rte_lpm.h +10 -0
+{
+	union {
+		uint16_t                  i;
+		struct rte_lpm_tbl8_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+

These two new functions could be reduced to one with the help of patch:
http://dpdk.org/dev/patchwork/patch/9087/

Quoted 2 lines

Anyone care to go back and review or ack that patch for me and simplify all the lpm code just that little bit?

I definitely ack that patch; I also want to apply it in my local testing setup and test a bit so you can add my Tested-by, but it looks sane on the surface.

Thanks so much for the review!

Quoted 1 line

/Bruce

#4 lore raw

Re: [PATCH 1/8] lpm: Fix pointer aliasing issues

In reply to Bruce Richardson

2016-02-25 21:30, Bruce Richardson:

Quoted 23 lines · Aaron Conole
Quoted 22 lines

/**
+ * Convert from tbl_entry types to integer types
+ */

lib/librte_lpm/rte_lpm.h +19 -0
+static inline uint16_t
+rte_lpm_tbl24_entry_to_uint16(const struct rte_lpm_tbl24_entry *entry)
+{
+	union {
+		uint16_t                   i;
+		struct rte_lpm_tbl24_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+static inline uint16_t
+rte_lpm_tbl8_entry_to_uint16(const struct rte_lpm_tbl8_entry *entry)
+{
+	union {
+		uint16_t                  i;
+		struct rte_lpm_tbl8_entry s;
+	} tbl_entry_u;
Quoted 8 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 173

Quoted 5 lines
lib/librte_lpm/rte_lpm.h +5 -0
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+

These two new functions could be reduced to one with the help of patch:
http://dpdk.org/dev/patchwork/patch/9087/

Aaron, any news about a rework of this patch?

#5 lore raw

Re: [PATCH 1/8] lpm: Fix pointer aliasing issues

Quoted 33 lines · Thomas Monjalon

2016-02-25 21:30, Bruce Richardson:

Quoted 23 lines · Aaron Conole
Quoted 22 lines

/**
+ * Convert from tbl_entry types to integer types
+ */

lib/librte_lpm/rte_lpm.h +19 -0
+static inline uint16_t
+rte_lpm_tbl24_entry_to_uint16(const struct rte_lpm_tbl24_entry *entry)
+{
+	union {
+		uint16_t                   i;
+		struct rte_lpm_tbl24_entry s;
+	} tbl_entry_u;
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+
+static inline uint16_t
+rte_lpm_tbl8_entry_to_uint16(const struct rte_lpm_tbl8_entry *entry)
+{
+	union {
+		uint16_t                  i;
+		struct rte_lpm_tbl8_entry s;
+	} tbl_entry_u;
Quoted 8 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm { · line 173

Quoted 5 lines
lib/librte_lpm/rte_lpm.h +5 -0
+
+	tbl_entry_u.s = *entry;
+	return tbl_entry_u.i;
+}
+

These two new functions could be reduced to one with the help of patch:
http://dpdk.org/dev/patchwork/patch/9087/

Quoted 1 line

Aaron, any news about a rework of this patch?

The rework of this series is in my TODO list with deadline of Thursday. I'll repost the series before then. Sorry for the confusion/delay.

-Aaron

#6 lore raw

PATCH 2/8 app/test/test: Fix missing brackets

In reply to Aaron Conole

The test application calls printf(...) with the suite->suite_name argument. The intent (based on whitespace) in the printf is to check suite->suite_name first and then apply the printf. This doesn't happen due to missing brackets.

---
 app/test/test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test/test.c +2 -1
index f35b304..ccad0e3 100644
@@ -162,9 +162,10 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 	int test_success;
 	unsigned total = 0, executed = 0, skipped = 0, succeeded = 0, failed = 0;
 
-	if (suite->suite_name)
+	if (suite->suite_name) {
 		printf(" + ------------------------------------------------------- +\n");
 		printf(" + Test Suite : %s\n", suite->suite_name);
+	}
 
 	if (suite->setup)
 		if (suite->setup() != 0)
Signature · 1 line
2.5.0
Acked-by on v1 2/8
#7 lore raw

Re: [PATCH 2/8] app/test/test: Fix missing brackets

Quoted 16 lines · Aaron Conole

The test application calls printf(...) with the suite->suite_name argument. The intent (based on whitespace) in the printf is to check suite->suite_name first and then apply the printf. This doesn't happen due to missing brackets.

---
  app/test/test.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
app/test/test.c +0 -0
index f35b304..ccad0e3 100644
@@ -162,9 +162,10 @@ unit_test_suite_runner(struct unit_test_suite *suite)
  	int test_success;

app/test/test.c unit_test_suite_runner(struct unit_test_suite *suite) · line 171

Quoted 10 lines
app/test/test.c +2 -1
  	unsigned total = 0, executed = 0, skipped = 0, succeeded = 0, failed = 0;
 
-	if (suite->suite_name)
+	if (suite->suite_name) {
  		printf(" + ------------------------------------------------------- +\n");
  		printf(" + Test Suite : %s\n", suite->suite_name);
+	}
 
  	if (suite->setup)
  		if (suite->setup() != 0)

This is just about as obvious as they get...

- Panu -

Acked-by on v1 2/8
#8 lore raw

Re: [PATCH 2/8] app/test/test: Fix missing brackets

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 2/8] app/test/test: Fix missing brackets

Quoted 5 lines

The test application calls printf(...) with the suite->suite_name argument. The intent (based on whitespace) in the printf is to check suite->suite_name first and then apply the printf. This doesn't happen due to missing brackets.

Quoted 21 lines
---
 app/test/test.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
app/test/test.c +2 -2
@@ -162,9 +162,10 @@ unit_test_suite_runner(struct unit_test_suite *suite)
 	int test_success;
 	unsigned total = 0, executed = 0, skipped = 0, succeeded = 0, failed = 0;
 
-	if (suite->suite_name)
+	if (suite->suite_name) {
 		printf(" + ------------------------------------------------------- +\n");
 		printf(" + Test Suite : %s\n", suite->suite_name);
+	}
 
 	if (suite->setup)
 		if (suite->setup() != 0)
--

2.5.0

#9 lore raw

PATCH 3/8 drivers/net/e1000: Fix missing brackets

In reply to Aaron Conole

The register read/write mphy functions have misleading whitespace around the locked check. This cleanup merely preserves the existing functionality while improving the ready check.

---
 drivers/net/e1000/base/e1000_phy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/base/e1000_phy.c +6 -6
index d43b7ce..8642d38 100644
@@ -4153,13 +4153,13 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 *data)
 	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;
 }
 
@@ -4218,13 +4218,13 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 data,
 	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;
 }
 
Signature · 1 line
2.5.0
#10 lore raw

Re: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

Hi Aaron,

Quoted 59 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo; Zhang, Helin; Ananyev, Konstantin; Richardson, Bruce
Subject: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

The register read/write mphy functions have misleading whitespace around the locked check. This cleanup merely preserves the existing functionality while improving the ready check.

---
 drivers/net/e1000/base/e1000_phy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/base/e1000_phy.c +3 -3
index d43b7ce..8642d38 100644
@@ -4153,13 +4153,13 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 *data)
 	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;

}

drivers/net/e1000/base/e1000_phy.c +3 -3
@@ -4218,13 +4218,13 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 data,
 	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;

}

Quoted 2 lines

--
2.5.0

Normally we will not maintain the base code. It's just taken from kernel driver.
Agree with you that the whitespace is misleading. But as it's no real impact. I'd like to say not a big deal, better not change it. :)

#11 lore raw

Re: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

Hi Wenzhou,

Quoted 62 lines · Wenzhuo

Hi Aaron,

Quoted 59 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo; Zhang, Helin; Ananyev, Konstantin; Richardson, Bruce
Subject: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

The register read/write mphy functions have misleading whitespace around the locked check. This cleanup merely preserves the existing functionality while improving the ready check.

---
 drivers/net/e1000/base/e1000_phy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/base/e1000_phy.c +3 -3
index d43b7ce..8642d38 100644
@@ -4153,13 +4153,13 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 *data)
 	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;

}

drivers/net/e1000/base/e1000_phy.c +3 -3
@@ -4218,13 +4218,13 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 data,
 	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;

}

Quoted 5 lines
Quoted 2 lines

--
2.5.0

Normally we will not maintain the base code. It's just taken from kernel driver. Agree with you that the whitespace is misleading. But as it's no real impact. I'd like to say not a big deal, better not change it. :)

Thanks for this hint. It turns out my patch is wrong. It should actually be this (and I've confirmed by looking at the drivers):

drivers/net/e1000/base/e1000_phy.c +6 -6
index d43b7ce..ad3fd58 100644
@@ -4153,12 +4153,12 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 *data)
 	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
+	}
 
 	return E1000_SUCCESS;
 }
@@ -4218,12 +4218,12 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 data,
 	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
+	}
 
 	return E1000_SUCCESS;
 }

I will cook up a v2 of this patch if it makes sense. It is a real bug, so should be fixed.

-Aaron

#12 lore raw

Re: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

Quoted 112 lines · Aaron Conole

Hi Wenzhou,

Quoted 62 lines · Wenzhuo

Hi Aaron,

Quoted 59 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo; Zhang, Helin; Ananyev, Konstantin; Richardson, Bruce
Subject: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

The register read/write mphy functions have misleading whitespace around the locked check. This cleanup merely preserves the existing functionality while improving the ready check.

---
  drivers/net/e1000/base/e1000_phy.c | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/base/e1000_phy.c +3 -3
index d43b7ce..8642d38 100644
@@ -4153,13 +4153,13 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 *data)
  	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
  	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
  		ready = e1000_is_mphy_ready(hw);
  		if (!ready)
  			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
  	return E1000_SUCCESS;
  }
drivers/net/e1000/base/e1000_phy.c +3 -3
@@ -4218,13 +4218,13 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 data,
  	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
  	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
  		ready = e1000_is_mphy_ready(hw);
  		if (!ready)
  			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
  	return E1000_SUCCESS;
  }
Quoted 5 lines
Quoted 2 lines

--
2.5.0

Normally we will not maintain the base code. It's just taken from kernel driver. Agree with you that the whitespace is misleading. But as it's no real impact. I'd like to say not a big deal, better not change it. :)

Thanks for this hint. It turns out my patch is wrong. It should actually be this (and I've confirmed by looking at the drivers):

drivers/net/e1000/base/e1000_phy.c +6 -6
index d43b7ce..ad3fd58 100644
@@ -4153,12 +4153,12 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 *data)
  	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
  	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
  		ready = e1000_is_mphy_ready(hw);
  		if (!ready)
  			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
+	}
 
  	return E1000_SUCCESS;
  }
@@ -4218,12 +4218,12 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw *hw, u32 address, u32 data,
  	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
  	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {
  		ready = e1000_is_mphy_ready(hw);
  		if (!ready)
  			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL, E1000_MPHY_DIS_ACCESS);
+	}
 
  	return E1000_SUCCESS;
  }
Quoted 2 lines

I will cook up a v2 of this patch if it makes sense. It is a real bug, so should be fixed.

Yes, it quite clearly is a real bug and there needs to be a documented way of getting these things fixed. The README in the base/ directory is not particularly helpful, since it only says "dont touch it".

This is apparently fixed in FreeBSD codebase so fixing it would be "just" a matter of pulling in a newer version.

The other alternatives are either disabling the whole driver in gcc 6 builds, or paper over the bug with warning disablers, or have everybody patch their packages locally to fix it, all of which just feel so stupid they're not alternatives, really.

OTOH the bug has been there for 2.5 years (since commit 38db3f7f50bde45477f564783a06ac8fbd3348fa) and nobody has noticed...

Thomas, Bruce, thoughts/comments?

- Panu -

#13 lore raw

Re: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

2016-03-01 13:02, Panu Matilainen:

Quoted 8 lines · Aaron Conole
Quoted 7 lines
Quoted 3 lines · Wenzhuo

Normally we will not maintain the base code. It's just taken from kernel driver. Agree with you that the whitespace is misleading. But as it's no real impact. I'd like to say not a big deal, better not change it. :)

Thanks for this hint. It turns out my patch is wrong. It should actually be this (and I've confirmed by looking at the drivers):

[...]

Quoted 2 lines
Quoted 2 lines

I will cook up a v2 of this patch if it makes sense. It is a real bug, so should be fixed.

Yes, waiting for your v2.

Quoted 3 lines

Yes, it quite clearly is a real bug and there needs to be a documented way of getting these things fixed. The README in the base/ directory is not particularly helpful, since it only says "dont touch it".

Yes don't touch it ;)

Quoted 2 lines

This is apparently fixed in FreeBSD codebase so fixing it would be "just" a matter of pulling in a newer version.

Probably.

Quoted 4 lines

The other alternatives are either disabling the whole driver in gcc 6 builds, or paper over the bug with warning disablers, or have everybody patch their packages locally to fix it, all of which just feel so stupid they're not alternatives, really.

No they are not sane alternatives.

Quoted 4 lines

OTOH the bug has been there for 2.5 years (since commit 38db3f7f50bde45477f564783a06ac8fbd3348fa) and nobody has noticed...

Thomas, Bruce, thoughts/comments?

It is in the hands of Wenzhuo, the e1000 maintainer. You just need his ack.

#14 lore raw

Re: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

In reply to Aaron Conole
Quoted 32 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 3/8] drivers/net/e1000: Fix missing brackets

The register read/write mphy functions have misleading whitespace around the locked check. This cleanup merely preserves the existing functionality while improving the ready check.

---
 drivers/net/e1000/base/e1000_phy.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/base/e1000_phy.c +0 -1
index d43b7ce..8642d38 100644
@@ -4153,13 +4153,13 @@ s32 e1000_read_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 *data)
 	*data = E1000_READ_REG(hw, E1000_MPHY_DATA);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)

drivers/net/e1000/base/e1000_phy.c s32 e1000_read_phy_reg_mphy(struct e1000_hw · line 4164

Quoted 10 lines
drivers/net/e1000/base/e1000_phy.c +3 -2
+	if (locked) {
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);

I think the above line should be included in brackets above. Though we should avoid modifying any code in base driver, I'd suggest you to fix the issue here. Thank you!

Quoted 10 lines
drivers/net/e1000/base/e1000_phy.c +0 -0
 	return E1000_SUCCESS;

}

drivers/net/e1000/base/e1000_phy.c +1 -1
@@ -4218,13 +4218,13 @@ s32 e1000_write_phy_reg_mphy(struct e1000_hw
 *hw, u32 address, u32 data,
 	E1000_WRITE_REG(hw, E1000_MPHY_DATA, data);
 
 	/* Disable access to mPHY if it was originally disabled */
-	if (locked)
+	if (locked) {

drivers/net/e1000/base/e1000_phy.c s32 e1000_write_phy_reg_mphy(struct e1000_hw · line 4230

Quoted 10 lines
drivers/net/e1000/base/e1000_phy.c +2 -2
 		ready = e1000_is_mphy_ready(hw);
 		if (!ready)
 			return -E1000_ERR_PHY;
-		E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
-				E1000_MPHY_DIS_ACCESS);
+	}
 
+	E1000_WRITE_REG(hw, E1000_MPHY_ADDR_CTRL,
 E1000_MPHY_DIS_ACCESS);
 	return E1000_SUCCESS;

The same comments as above. Thanks!

Quoted 4 lines

}

--
2.5.0

#15 lore raw

PATCH 4/8 drivers/net/e1000: Fix missing lsc interrupt check brackets

In reply to Aaron Conole

The device lsc interupt check has a misleading whitespace around it which can be improved by adding appropriate braces to the check. Since the ret variable was checked after previous assignment, this introduces no functional change.

---
 drivers/net/e1000/em_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/e1000/em_ethdev.c +2 -1
index 4a843fe..1d86091 100644
@@ -637,13 +637,14 @@ eth_em_start(struct rte_eth_dev *dev)
 
 	if (rte_intr_allow_others(intr_handle)) {
 		/* check if lsc interrupt is enabled */
-		if (dev->data->dev_conf.intr_conf.lsc != 0)
+		if (dev->data->dev_conf.intr_conf.lsc != 0) {
 			ret = eth_em_interrupt_setup(dev);
 			if (ret) {
 				PMD_INIT_LOG(ERR, "Unable to setup interrupts");
 				em_dev_clear_queues(dev);
 				return ret;
 			}
+		}
 	} else {
 		rte_intr_callback_unregister(intr_handle,
 						eth_em_interrupt_handler,
Signature · 1 line
2.5.0
Acked-by on v1 4/8
#16 lore raw

Re: [PATCH 4/8] drivers/net/e1000: Fix missing lsc interrupt check brackets

Quoted 21 lines · Aaron Conole

The device lsc interupt check has a misleading whitespace around it which can be improved by adding appropriate braces to the check. Since the ret variable was checked after previous assignment, this introduces no functional change.

---
  drivers/net/e1000/em_ethdev.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/e1000/em_ethdev.c +1 -1
index 4a843fe..1d86091 100644
@@ -637,13 +637,14 @@ eth_em_start(struct rte_eth_dev *dev)
 
  	if (rte_intr_allow_others(intr_handle)) {
  		/* check if lsc interrupt is enabled */
-		if (dev->data->dev_conf.intr_conf.lsc != 0)
+		if (dev->data->dev_conf.intr_conf.lsc != 0) {

drivers/net/e1000/em_ethdev.c eth_em_start(struct rte_eth_dev *dev) · line 650

Quoted 10 lines
drivers/net/e1000/em_ethdev.c +1 -0
  			ret = eth_em_interrupt_setup(dev);
  			if (ret) {
  				PMD_INIT_LOG(ERR, "Unable to setup interrupts");
  				em_dev_clear_queues(dev);
  				return ret;
  			}
+		}
  	} else {
  		rte_intr_callback_unregister(intr_handle,
  						eth_em_interrupt_handler,

Seems really obvious but cc'd the e1000 maintainer too.

- Panu -

#17 lore raw

Re: [PATCH 4/8] drivers/net/e1000: Fix missing lsc interrupt check brackets

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 4/8] drivers/net/e1000: Fix missing lsc interrupt check brackets

Quoted 3 lines

The device lsc interupt check has a misleading whitespace around it which can be improved by adding appropriate braces to the check. Since the ret variable was checked after previous assignment, this introduces no functional change.

It seems a "Fixes: " line is required.

Quoted 28 lines
---
 drivers/net/e1000/em_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/e1000/em_ethdev.c +2 -2
index 4a843fe..1d86091 100644
@@ -637,13 +637,14 @@ eth_em_start(struct rte_eth_dev *dev)
 
 	if (rte_intr_allow_others(intr_handle)) {
 		/* check if lsc interrupt is enabled */
-		if (dev->data->dev_conf.intr_conf.lsc != 0)
+		if (dev->data->dev_conf.intr_conf.lsc != 0) {
 			ret = eth_em_interrupt_setup(dev);
 			if (ret) {
 				PMD_INIT_LOG(ERR, "Unable to setup interrupts");
 				em_dev_clear_queues(dev);
 				return ret;
 			}
+		}
 	} else {
 		rte_intr_callback_unregister(intr_handle,
 						eth_em_interrupt_handler,
--

2.5.0

#18 lore raw

PATCH 5/8 drivers/net/ixgbe: Fix vlan filter missing brackets

In reply to Aaron Conole

The ixgbe vlan filter code has an if check with an incorrect whitespace.

---
 drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 3e6fe86..2e1c3ad 100644
@@ -4258,10 +4258,11 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
 	if (ixgbe_vmdq_mode_check(hw) < 0)
 		return -ENOTSUP;
 	for (pool_idx = 0; pool_idx < ETH_64_POOLS; pool_idx++) {
-		if (pool_mask & ((uint64_t)(1ULL << pool_idx)))
+		if (pool_mask & ((uint64_t)(1ULL << pool_idx))) {
 			ret = hw->mac.ops.set_vfta(hw,vlan,pool_idx,vlan_on);
 			if (ret < 0)
 				return ret;
+		}
 	}
 
 	return ret;
Signature · 1 line
2.5.0
Acked-by on v1 5/8
#19 lore raw

Re: [PATCH 5/8] drivers/net/ixgbe: Fix vlan filter missing brackets

Quoted 15 lines · Aaron Conole

The ixgbe vlan filter code has an if check with an incorrect whitespace.

---
  drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +0 -0
index 3e6fe86..2e1c3ad 100644
@@ -4258,10 +4258,11 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
  	if (ixgbe_vmdq_mode_check(hw) < 0)
  		return -ENOTSUP;

drivers/net/ixgbe/ixgbe_ethdev.c ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan, · line 4268

Quoted 10 lines
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
  	for (pool_idx = 0; pool_idx < ETH_64_POOLS; pool_idx++) {
-		if (pool_mask & ((uint64_t)(1ULL << pool_idx)))
+		if (pool_mask & ((uint64_t)(1ULL << pool_idx))) {
  			ret = hw->mac.ops.set_vfta(hw,vlan,pool_idx,vlan_on);
  			if (ret < 0)
  				return ret;
+		}
  	}
 
  	return ret;

Seems really obvious but cc'd the ixgbe maintainers too.

- Panu -

Acked-by on v1 5/8
#20 lore raw

Re: [PATCH 5/8] drivers/net/ixgbe: Fix vlan filter missing brackets

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 5/8] drivers/net/ixgbe: Fix vlan filter missing brackets

Quoted 3 lines

The ixgbe vlan filter code has an if check with an incorrect whitespace.

Quoted 25 lines
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ixgbe/ixgbe_ethdev.c +2 -1
index 3e6fe86..2e1c3ad 100644
@@ -4258,10 +4258,11 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev,
 uint16_t vlan,
 	if (ixgbe_vmdq_mode_check(hw) < 0)
 		return -ENOTSUP;
 	for (pool_idx = 0; pool_idx < ETH_64_POOLS; pool_idx++) {
-		if (pool_mask & ((uint64_t)(1ULL << pool_idx)))
+		if (pool_mask & ((uint64_t)(1ULL << pool_idx))) {
 			ret = hw->mac.ops.set_vfta(hw,vlan,pool_idx,vlan_on);
 			if (ret < 0)
 				return ret;
+		}
 	}
 

return ret;
--
2.5.0

#21 lore raw

PATCH 6/8 drivers/net/e1000/igb: Signed left shift operator

In reply to Aaron Conole

Tell the compiler to use an unsigned constant for the config shifts.

---
 drivers/net/e1000/igb_pf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/e1000/igb_pf.c +2 -2
index 1d00dda..afe80f5 100644
@@ -172,8 +172,8 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
 	E1000_WRITE_REG(hw, E1000_VT_CTL, vtctl);
 
 	/* Enable pools reserved to PF only */
-	E1000_WRITE_REG(hw, E1000_VFRE, (~0) << vf_num);
-	E1000_WRITE_REG(hw, E1000_VFTE, (~0) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFRE, (~0U) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFTE, (~0U) << vf_num);
 
 	/* PFDMA Tx General Switch Control Enables VMDQ loopback */
 	if (hw->mac.type == e1000_i350)
Signature · 1 line
2.5.0
Acked-by on v1 6/8
#22 lore raw

Re: [PATCH 6/8] drivers/net/e1000/igb: Signed left shift operator

Quoted 13 lines · Aaron Conole

Tell the compiler to use an unsigned constant for the config shifts.

---
  drivers/net/e1000/igb_pf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/e1000/igb_pf.c +0 -0
index 1d00dda..afe80f5 100644

drivers/net/e1000/igb_pf.c int igb_pf_host_configure(struct rte_eth_dev *eth_dev) · line 179

Quoted 10 lines
drivers/net/e1000/igb_pf.c +2 -2
@@ -172,8 +172,8 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
  	E1000_WRITE_REG(hw, E1000_VT_CTL, vtctl);
 
  	/* Enable pools reserved to PF only */
-	E1000_WRITE_REG(hw, E1000_VFRE, (~0) << vf_num);
-	E1000_WRITE_REG(hw, E1000_VFTE, (~0) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFRE, (~0U) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFTE, (~0U) << vf_num);
 
  	/* PFDMA Tx General Switch Control Enables VMDQ loopback */
  	if (hw->mac.type == e1000_i350)

CC'd the e1000 maintainer too.

- Panu -

Acked-by on v1 6/8
#23 lore raw

Re: [PATCH 6/8] drivers/net/e1000/igb: Signed left shift operator

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 6/8] drivers/net/e1000/igb: Signed left shift operator

Quoted 3 lines

Tell the compiler to use an unsigned constant for the config shifts.

Quoted 21 lines
---
 drivers/net/e1000/igb_pf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/e1000/igb_pf.c index renamed from drivers/net/e1000/igb_pf.c +0 -0

1d00dda..afe80f5 100644

drivers/net/e1000/igb_pf.c +2 -3
@@ -172,8 +172,8 @@ int igb_pf_host_configure(struct rte_eth_dev *eth_dev)
 	E1000_WRITE_REG(hw, E1000_VT_CTL, vtctl);
 
 	/* Enable pools reserved to PF only */
-	E1000_WRITE_REG(hw, E1000_VFRE, (~0) << vf_num);
-	E1000_WRITE_REG(hw, E1000_VFTE, (~0) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFRE, (~0U) << vf_num);
+	E1000_WRITE_REG(hw, E1000_VFTE, (~0U) << vf_num);
 
 	/* PFDMA Tx General Switch Control Enables VMDQ loopback */
 	if (hw->mac.type == e1000_i350)
--

2.5.0

#24 lore raw

PATCH 7/8 drivers/net/ixgbe: Signed left shift operator

In reply to Aaron Conole

Tell the compiler to use an unsigned constant for the config shifts.

---
 drivers/net/ixgbe/ixgbe_pf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +2 -2
index 2ffbd1f..8b5119f 100644
@@ -236,9 +236,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
 	vfre_slot = (vf_num >> VFRE_SHIFT) > 0 ? 1 : 0;
 
 	/* Enable pools reserved to PF only */
-	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0U) << vfre_offset);
 	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot ^ 1), vfre_slot - 1);
-	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0U) << vfre_offset);
 	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot ^ 1), vfre_slot - 1);
 
 	/* PFDMA Tx General Switch Control Enables VMDQ loopback */
Signature · 1 line
2.5.0
Acked-by on v1 7/8
#25 lore raw

Re: [PATCH 7/8] drivers/net/ixgbe: Signed left shift operator

Quoted 14 lines · Aaron Conole

Tell the compiler to use an unsigned constant for the config shifts.

---
  drivers/net/ixgbe/ixgbe_pf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c +0 -0
index 2ffbd1f..8b5119f 100644
@@ -236,9 +236,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev)
  	vfre_slot = (vf_num >> VFRE_SHIFT) > 0 ? 1 : 0;

drivers/net/ixgbe/ixgbe_pf.c int ixgbe_pf_host_configure(struct rte_eth_dev *eth_dev) · line 244

Quoted 10 lines
drivers/net/ixgbe/ixgbe_pf.c +2 -2
 
  	/* Enable pools reserved to PF only */
-	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0U) << vfre_offset);
  	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot ^ 1), vfre_slot - 1);
-	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0U) << vfre_offset);
  	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot ^ 1), vfre_slot - 1);
 
  	/* PFDMA Tx General Switch Control Enables VMDQ loopback */

CC'd the ixgbe maintainers...

- Panu -

Acked-by on v1 7/8
#26 lore raw

Re: [PATCH 7/8] drivers/net/ixgbe: Signed left shift operator

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 7/8] drivers/net/ixgbe: Signed left shift operator

Quoted 3 lines

Tell the compiler to use an unsigned constant for the config shifts.

Quoted 23 lines
---
 drivers/net/ixgbe/ixgbe_pf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_pf.c index renamed from drivers/net/ixgbe/ixgbe_pf.c +0 -0

2ffbd1f..8b5119f 100644

drivers/net/ixgbe/ixgbe_pf.c +2 -2
@@ -236,9 +236,9 @@ int ixgbe_pf_host_configure(struct rte_eth_dev
 *eth_dev)
 	vfre_slot = (vf_num >> VFRE_SHIFT) > 0 ? 1 : 0;
 
 	/* Enable pools reserved to PF only */
-	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot), (~0U) << vfre_offset);
 	IXGBE_WRITE_REG(hw, IXGBE_VFRE(vfre_slot ^ 1), vfre_slot - 1);
-	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0) << vfre_offset);
+	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot), (~0U) << vfre_offset);
 	IXGBE_WRITE_REG(hw, IXGBE_VFTE(vfre_slot ^ 1), vfre_slot - 1);
 

/* PFDMA Tx General Switch Control Enables VMDQ loopback */
--
2.5.0

#27 lore raw

PATCH 8/8 drivers/net/ixgbe: Fix uninitialized warning

In reply to Aaron Conole

Silence a compiler warning that this variable may be used uninitialized.

---
 drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +2 -2
index e95e6b7..775edc7 100644
@@ -1563,7 +1563,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,
 		struct ixgbe_rx_entry *rxe;
 		struct ixgbe_scattered_rx_entry *sc_entry;
 		struct ixgbe_scattered_rx_entry *next_sc_entry;
-		struct ixgbe_rx_entry *next_rxe;
+		struct ixgbe_rx_entry *next_rxe = NULL;
 		struct rte_mbuf *first_seg;
 		struct rte_mbuf *rxm;
 		struct rte_mbuf *nmb;
@@ -1740,7 +1740,7 @@ next_desc:
 		 * the pointer to the first mbuf at the NEXTP entry in the
 		 * sw_sc_ring and continue to parse the RX ring.
 		 */
-		if (!eop) {
+		if (!eop && next_rxe) {
 			rxm->next = next_rxe->mbuf;
 			next_sc_entry->fbuf = first_seg;
 			goto next_desc;
Signature · 1 line
2.5.0
#28 lore raw

Re: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

Quoted 22 lines · Aaron Conole

Silence a compiler warning that this variable may be used uninitialized.

---
  drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +1 -1
index e95e6b7..775edc7 100644
@@ -1563,7 +1563,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,
  		struct ixgbe_rx_entry *rxe;
  		struct ixgbe_scattered_rx_entry *sc_entry;
  		struct ixgbe_scattered_rx_entry *next_sc_entry;
-		struct ixgbe_rx_entry *next_rxe;
+		struct ixgbe_rx_entry *next_rxe = NULL;
  		struct rte_mbuf *first_seg;
  		struct rte_mbuf *rxm;
  		struct rte_mbuf *nmb;

drivers/net/ixgbe/ixgbe_rxtx.c next_desc: · line 1746

Quoted 8 lines
drivers/net/ixgbe/ixgbe_rxtx.c +1 -1
@@ -1740,7 +1740,7 @@ next_desc:
  		 * the pointer to the first mbuf at the NEXTP entry in the
  		 * sw_sc_ring and continue to parse the RX ring.
  		 */
-		if (!eop) {
+		if (!eop && next_rxe) {
  			rxm->next = next_rxe->mbuf;
  			next_sc_entry->fbuf = first_seg;
  			goto next_desc;

The patch looks ok as such, but then again warning looks like a false positive to me: assignment and dereferencing depend on the same value of eop, which cannot change between the two.

CC'ing the maintainers for attention...

- Panu -

#29 lore raw

Re: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

Quoted 4 lines · Panu Matilainen
Quoted 3 lines · Aaron Conole

Silence a compiler warning that this variable may be used uninitialized.

[..]

Quoted 4 lines

The patch looks ok as such, but then again warning looks like a false positive to me: assignment and dereferencing depend on the same value of eop, which cannot change between the two.

In two minds about this. It is a logical impossibility, but these days optimising compilers are getting very aggressive. For instance GCC has a delightfully-named -fdelete-null-pointer-checks option, which caused security holes..

..Remy

#30 lore raw

Re: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

Quoted 8 lines · Remy Horton
Quoted 4 lines · Panu Matilainen
Quoted 3 lines · Aaron Conole

Silence a compiler warning that this variable may be used uninitialized.

[..]

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

The patch looks ok as such, but then again warning looks like a false positive to me: assignment and dereferencing depend on the same value of eop, which cannot change between the two.

In two minds about this. It is a logical impossibility, but these days optimising compilers are getting very aggressive. For instance GCC has a delightfully-named -fdelete-null-pointer-checks option, which caused security holes..

Indeed, that's why silencing a false positive (assuming it actually is one) by throwing some more NULL-checks for the allegedly impossible makes me a bit nervous. Besides compiler optimizations going crazy, I've seen such extra NULL-checks turn into actual bugs when surroundings subtly change.

- Panu -

#31 lore raw

Re: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

Quoted 1 line · Panu Matilainen

On 03/10/2016 04:45 PM, Remy Horton wrote:

[...]

Quoted 10 lines
Quoted 4 lines

In two minds about this. It is a logical impossibility, but these days optimising compilers are getting very aggressive. For instance GCC has a delightfully-named -fdelete-null-pointer-checks option, which caused security holes..

Indeed, that's why silencing a false positive (assuming it actually is one) by throwing some more NULL-checks for the allegedly impossible makes me a bit nervous. Besides compiler optimizations going crazy, I've seen such extra NULL-checks turn into actual bugs when surroundings subtly change.

It cuts both ways. To anyone who is not an active compiler engineer, fixing a warning being /more/ likley to screw things up is quite a big thing. Do we want to turn off warnings or turn off optimisations.. :)

..Remy

Acked-by on v1 8/8
#32 lore raw

Re: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

In reply to Aaron Conole
Quoted 12 lines

-----Original Message-----
From: Aaron Conole [mailto:[email protected]]
Sent: Friday, February 26, 2016 2:49 AM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Zhang, Helin <[email protected]>; Ananyev, Konstantin <[email protected]>; Richardson, Bruce <[email protected]>
Subject: [PATCH 8/8] drivers/net/ixgbe: Fix uninitialized warning

Quoted 3 lines

Silence a compiler warning that this variable may be used uninitialized.

Quoted 29 lines
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ixgbe/ixgbe_rxtx.c +1 -1
index e95e6b7..775edc7 100644
@@ -1563,7 +1563,7 @@ ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf
 **rx_pkts, uint16_t nb_pkts,
 		struct ixgbe_rx_entry *rxe;
 		struct ixgbe_scattered_rx_entry *sc_entry;
 		struct ixgbe_scattered_rx_entry *next_sc_entry;
-		struct ixgbe_rx_entry *next_rxe;
+		struct ixgbe_rx_entry *next_rxe = NULL;
 		struct rte_mbuf *first_seg;
 		struct rte_mbuf *rxm;
drivers/net/ixgbe/ixgbe_rxtx.c +1 -2
 		struct rte_mbuf *nmb;
@@ -1740,7 +1740,7 @@ next_desc:
 		 * the pointer to the first mbuf at the NEXTP entry in the
 		 * sw_sc_ring and continue to parse the RX ring.
 		 */
-		if (!eop) {
+		if (!eop && next_rxe) {
 			rxm->next = next_rxe->mbuf;
 			next_sc_entry->fbuf = first_seg;
 			goto next_desc;
--

2.5.0

#33 lore raw
In reply to Aaron Conole

2016-02-25 13:48, Aaron Conole:

Quoted 6 lines

This series brings a number of code cleanups to allow building using gcc6, with various legitimate warnings being fixed.

In particular, patch 3 ("drivers/net/e1000: Fix missing brackets") should be checked for correctness (it does not alter any behavior from a functional standpoint, but it may be required to do so for a correct fix).

Wenzhuo, Helin, Konstantin, Bruce, we need your opinion for some of these patches.
Thanks

#34 lore raw

RE fixing email addresses...

2016-03-17 16:39, Thomas Monjalon:

Quoted 11 lines

2016-02-25 13:48, Aaron Conole:

Quoted 6 lines

This series brings a number of code cleanups to allow building using gcc6, with various legitimate warnings being fixed.

In particular, patch 3 ("drivers/net/e1000: Fix missing brackets") should be checked for correctness (it does not alter any behavior from a functional standpoint, but it may be required to do so for a correct fix).

Wenzhuo, Helin, Konstantin, Bruce, we need your opinion for some of these patches.
Thanks