[dpdk-dev] lib/librte_ether: Prevent link status race condition when LSI enabled

Message ID 1445981935-3559-1-git-send-email-tim.shearer@overturenetworks.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Tim Shearer Oct. 27, 2015, 9:38 p.m. UTC
  Calling the Ethernet driver's link_update function from rte_eth_dev_start can result in a race condition if the NIC raises the link interrupt at the same time. Depending on the interrupt handler implementation, the race can cause the it to think that it received two consecutive link up interrupts, and it exits without calling the user callback. Appears to impact E1000/IGB and virtio drivers only.

Signed-off-by: Tim Shearer <tim.shearer@overturenetworks.com>
---
 lib/librte_ether/rte_ethdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
  

Comments

Thomas Monjalon Nov. 4, 2015, 10:13 p.m. UTC | #1
2015-10-27 17:38, Tim Shearer:
> Calling the Ethernet driver's link_update function from rte_eth_dev_start can result in a race condition if the NIC raises the link interrupt at the same time. Depending on the interrupt handler implementation, the race can cause the it to think that it received two consecutive link up interrupts, and it exits without calling the user callback. Appears to impact E1000/IGB and virtio drivers only.
> 
> Signed-off-by: Tim Shearer <tim.shearer@overturenetworks.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f593f6e..a821a1f 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1300,7 +1300,7 @@  rte_eth_dev_start(uint8_t port_id)
 
 	rte_eth_dev_config_restore(port_id);
 
-	if (dev->data->dev_conf.intr_conf.lsc != 0) {
+	if (dev->data->dev_conf.intr_conf.lsc == 0) {
 		FUNC_PTR_OR_ERR_RET(*dev->dev_ops->link_update, -ENOTSUP);
 		(*dev->dev_ops->link_update)(dev, 0);
 	}