Skip to contentSkip to conversation

net/i40e: fix link_state update for i40e_ethdev_vf drv

PATCH In review Tushar Mulkar 3 participants 4 messages Feb 14, 2018 – Mar 30, 2018 2 messages not in the archive Network drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): B100BEBE3931D74C91B0DFE67C1055F9035BC999

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH v2 1/1 net/i40e: fix link_state update for i40e_ethdev_vf drv

The check for bool was accounting unwanted bits in the calulation of truth value. In dpdk unsingned int is typedefed to bool but all it cares about is Least Significant Bit. But in calculation of condition expression the bits other than LSB was used which doesn't make sense. Some time these bits has values which results in to incorrect expression results. To fix this we just need to account LSB form the bool value . This can be easily done by anding the value with true.

---
 drivers/net/i40e/i40e_ethdev_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +2 -2
index b96d77a0c..d23dff044 100644
@@ -2095,8 +2095,8 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up & true) ? 
+                            ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg =
 		dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED;
 

--
2.11.0

#3 lore raw

Hi,

Quoted 8 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Tushar Mulkar
Sent: Wednesday 14 February 2018 12:00
To: Zhang, Helin <[email protected]>; [email protected]
Cc: Xing, Beilei <[email protected]>; Zhang, Qi Z <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix link_state update for i40e_ethdev_vf drv

Quoted 7 lines

The check for bool was accounting unwanted bits in the calulation of truth value. In dpdk unsingned int is typedefed to bool but all it cares about is Least Significant Bit. But in calculation of condition expression the bits other than LSB was used which doesn't make sense. Some time these bits has values which results in to incorrect expression results. To fix this we just need to account LSB form the bool value . This can be easily done by anding the value with true.

I didn't find any place where link_up is assigned to something other than Boolean. But maybe I'm wrong or I misunderstood what you're saying.
And there is another place in this file with similar evaluation in i40evf_read_pfmsg() function. Format of commit message should be modified as well - it is formatted in one long line without line breaks.

Quoted 25 lines
---
 drivers/net/i40e/i40e_ethdev_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +2 -3
index b96d77a0c..d23dff044 100644
@@ -2095,8 +2095,8 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up & true) ?
+                            ETH_LINK_UP : ETH_LINK_DOWN;
 	new_link.link_autoneg =
 		dev->data->dev_conf.link_speeds &
 ETH_LINK_SPEED_FIXED;
 
--

2.11.0

#4 lore raw
In reply to Tushar Mulkar
Quoted 28 lines

-----Original Message-----
From: Tushar Mulkar [mailto:[email protected]]
Sent: Wednesday, February 14, 2018 8:00 PM
To: Zhang, Helin; [email protected]
Cc: Xing, Beilei; Zhang, Qi Z
Subject: [PATCH v2] net/i40e: fix link_state update for i40e_ethdev_vf drv

The check for bool was accounting unwanted bits in the calulation of truth value. In dpdk unsingned int is typedefed to bool but all it cares about is Least Significant Bit. But in calculation of condition expression the bits other than LSB was used which doesn't make sense. Some time these bits has values which results in to incorrect expression results. To fix this we just need to account LSB form the bool value . This can be easily done by anding the value with true.

---
 drivers/net/i40e/i40e_ethdev_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +0 -0
index b96d77a0c..d23dff044 100644

drivers/net/i40e/i40e_ethdev_vf.c i40evf_dev_link_update(struct rte_eth_dev *dev, · line 2099

Quoted 7 lines
drivers/net/i40e/i40e_ethdev_vf.c +2 -2
@@ -2095,8 +2095,8 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up & true) ?
+                            ETH_LINK_UP : ETH_LINK_DOWN;

It is a bit strange to do bit manipunation on a bool type of value.
Do you see any wrong case with that variable? If yes, I'd suggest correct that one, rather than doing like this.

Thanks,
Helin

Quoted 5 lines
drivers/net/i40e/i40e_ethdev_vf.c +0 -1
 	new_link.link_autoneg =
 		dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED;
 
--

2.11.0

#5 lore raw
Quoted 33 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Zhang, Helin
Sent: Wednesday, March 28, 2018 12:30 AM
To: Tushar Mulkar; [email protected]
Cc: Xing, Beilei; Zhang, Qi Z
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix link_state update for i40e_ethdev_vf drv

Quoted 21 lines

-----Original Message-----
From: Tushar Mulkar [mailto:[email protected]]
Sent: Wednesday, February 14, 2018 8:00 PM
To: Zhang, Helin; [email protected]
Cc: Xing, Beilei; Zhang, Qi Z
Subject: [PATCH v2] net/i40e: fix link_state update for i40e_ethdev_vf drv

The check for bool was accounting unwanted bits in the calulation of truth value. In dpdk unsingned int is typedefed to bool but all it cares about is Least Significant Bit. But in calculation of condition expression the bits other than LSB was used which doesn't make sense. Some time these bits has values which results in to incorrect expression results. To fix this we just need to account LSB form the bool value . This can be easily done by anding the value with true.

---
 drivers/net/i40e/i40e_ethdev_vf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

drivers/net/i40e/i40e_ethdev_vf.c i40evf_dev_link_update(struct rte_eth_dev *dev, · line 2099

Quoted 13 lines
drivers/net/i40e/i40e_ethdev_vf.c +2 -2
index b96d77a0c..d23dff044 100644
@@ -2095,8 +2095,8 @@ i40evf_dev_link_update(struct rte_eth_dev *dev,
 	}
 	/* full duplex only */
 	new_link.link_duplex = ETH_LINK_FULL_DUPLEX;
-	new_link.link_status = vf->link_up ? ETH_LINK_UP :
-					     ETH_LINK_DOWN;
+	new_link.link_status = (vf->link_up & true) ?
+                            ETH_LINK_UP : ETH_LINK_DOWN;

It is a bit strange to do bit manipunation on a bool type of value. Do you see any wrong case with that variable? If yes, I'd suggest correct that one, rather than doing like this.

I'd set it to change requested for now, if there no clarification for the comments, and no ACK. Feel free to set it back if there is anything new. Thanks!

/Helin

Quoted 9 lines

Thanks,
Helin

Quoted 5 lines
drivers/net/i40e/i40e_ethdev_vf.c +0 -1
 	new_link.link_autoneg =
 		dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED;
 
--

2.11.0