summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCunming Liang <cunming.liang@intel.com>2015-04-01 10:33:34 +0800
committerThomas Monjalon <thomas.monjalon@6wind.com>2015-04-01 21:45:44 +0200
commit263333bbb7a9b3356ac2d996b2a7bfd6941d0022 (patch)
tree29e39066c30708dc8546fc4dfb20d4161d2c1c55
parentb9a8b2f80959ac6c415b202d9cb39fa529b167f5 (diff)
downloaddpdk-263333bbb7a9b3356ac2d996b2a7bfd6941d0022.zip
dpdk-263333bbb7a9b3356ac2d996b2a7bfd6941d0022.tar.gz
dpdk-263333bbb7a9b3356ac2d996b2a7bfd6941d0022.tar.xz
i40e: fix link status timeout
API *rte_eth_link_get* expect to call a wait to complete link_update. That's the difference between *rte_eth_link_get_nowait*. The patch fixes the issue that i40e link_update ignores the wait_to_complete flag. The issue impacts those applications calling rte_eth_link_get to get wrong intermediate link status. Signed-off-by: Cunming Liang <cunming.liang@intel.com> Acked-by: Helin Zhang <helin.zhang@intel.com>
-rw-r--r--lib/librte_pmd_i40e/i40e_ethdev.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/librte_pmd_i40e/i40e_ethdev.c b/lib/librte_pmd_i40e/i40e_ethdev.c
index 00d044f..6b8f96e 100644
--- a/lib/librte_pmd_i40e/i40e_ethdev.c
+++ b/lib/librte_pmd_i40e/i40e_ethdev.c
@@ -1081,28 +1081,37 @@ i40e_dev_set_link_down(__rte_unused struct rte_eth_dev *dev)
int
i40e_dev_link_update(struct rte_eth_dev *dev,
- __rte_unused int wait_to_complete)
+ int wait_to_complete)
{
+#define CHECK_INTERVAL 100 /* 100ms */
+#define MAX_REPEAT_TIME 10 /* 1s (10 * 100ms) in total */
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct i40e_link_status link_status;
struct rte_eth_link link, old;
int status;
+ unsigned rep_cnt = MAX_REPEAT_TIME;
memset(&link, 0, sizeof(link));
memset(&old, 0, sizeof(old));
memset(&link_status, 0, sizeof(link_status));
rte_i40e_dev_atomic_read_link_status(dev, &old);
- /* Get link status information from hardware */
- status = i40e_aq_get_link_info(hw, false, &link_status, NULL);
- if (status != I40E_SUCCESS) {
- link.link_speed = ETH_LINK_SPEED_100;
- link.link_duplex = ETH_LINK_FULL_DUPLEX;
- PMD_DRV_LOG(ERR, "Failed to get link info");
- goto out;
- }
+ do {
+ /* Get link status information from hardware */
+ status = i40e_aq_get_link_info(hw, false, &link_status, NULL);
+ if (status != I40E_SUCCESS) {
+ link.link_speed = ETH_LINK_SPEED_100;
+ link.link_duplex = ETH_LINK_FULL_DUPLEX;
+ PMD_DRV_LOG(ERR, "Failed to get link info");
+ goto out;
+ }
+
+ link.link_status = link_status.link_info & I40E_AQ_LINK_UP;
+ if (!wait_to_complete)
+ break;
- link.link_status = link_status.link_info & I40E_AQ_LINK_UP;
+ rte_delay_ms(CHECK_INTERVAL);
+ } while (!link.link_status && rep_cnt--);
if (!link.link_status)
goto out;