From 12a653eb53e1963f9d3a04cabeead206e2ed1f66 Mon Sep 17 00:00:00 2001 From: Jiawen Wu Date: Thu, 12 Aug 2021 10:00:18 +0800 Subject: [PATCH] net/txgbe: fix link status when device stopped When device is stopped, the port status is not changed and only the Tx laser is turned off by hardware design. Fixes: 0c061eadec59 ("net/txgbe: add link status change") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/txgbe/base/txgbe_type.h | 1 + drivers/net/txgbe/txgbe_ethdev.c | 4 ++++ drivers/net/txgbe/txgbe_ethdev_vf.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 823c6756e7..d95467f9f8 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -781,6 +781,7 @@ struct txgbe_hw { int api_version; bool allow_unsupported_sfp; bool need_crosstalk_fix; + bool dev_start; struct txgbe_devargs devarg; uint64_t isb_dma; diff --git a/drivers/net/txgbe/txgbe_ethdev.c b/drivers/net/txgbe/txgbe_ethdev.c index e62675520a..0063994688 100644 --- a/drivers/net/txgbe/txgbe_ethdev.c +++ b/drivers/net/txgbe/txgbe_ethdev.c @@ -1664,6 +1664,7 @@ txgbe_dev_start(struct rte_eth_dev *dev) return -1; hw->mac.start_hw(hw); hw->mac.get_link_status = true; + hw->dev_start = true; /* configure PF module if SRIOV enabled */ txgbe_pf_host_configure(dev); @@ -1933,6 +1934,7 @@ txgbe_dev_stop(struct rte_eth_dev *dev) hw->adapter_stopped = true; dev->data->dev_started = 0; + hw->dev_start = false; return 0; } @@ -2735,6 +2737,8 @@ txgbe_dev_link_update_share(struct rte_eth_dev *dev, txgbe_dev_setup_link_alarm_handler, dev); } return rte_eth_linkstatus_set(dev, &link); + } else if (!hw->dev_start) { + return rte_eth_linkstatus_set(dev, &link); } intr->flags &= ~TXGBE_FLAG_NEED_LINK_CONFIG; diff --git a/drivers/net/txgbe/txgbe_ethdev_vf.c b/drivers/net/txgbe/txgbe_ethdev_vf.c index 0bae6ffd1f..18ed94bd27 100644 --- a/drivers/net/txgbe/txgbe_ethdev_vf.c +++ b/drivers/net/txgbe/txgbe_ethdev_vf.c @@ -628,6 +628,7 @@ txgbevf_dev_start(struct rte_eth_dev *dev) return err; } hw->mac.get_link_status = true; + hw->dev_start = true; /* negotiate mailbox API version to use with the PF. */ txgbevf_negotiate_api(hw); @@ -749,6 +750,7 @@ txgbevf_dev_stop(struct rte_eth_dev *dev) } adapter->rss_reta_updated = 0; + hw->dev_start = false; return 0; } -- 2.20.1