From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id A20C61B321 for ; Thu, 15 Feb 2018 09:46:49 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id m5so2498381wrg.1 for ; Thu, 15 Feb 2018 00:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=3tC0HyRGo+TeCO1Uejm9dy0E4q0AnrDJTBX1ZiDtTvA=; b=S2NrkXflNqtv+B7sTWPLB8hPLiw9BprnlQlqyJIr8ayj7FApnXAgZwY9SPIAoyaflq JpOP1l9yfPQKTqxBh/Uy0xFNHjf6cUTLPaJenka13J5iWDSHvTK//TlcoFFGjG5FAIM8 z4x4llTgD3icZlS4olNY+4ElzTiAQNH+ODwaGrot3+aJNuvqMiLGzr55na0V6ICcnO7F k6k17qpmg28HRPL0rlTKZ59HL4Q3xZ1hOwdnKWhfljPGsvgdxbID+W3tMCB5B0cLubF4 ELxBYVD7rvFmxlIiKeJs86zo/ywz40Sl2ygP/OTvAMv4oy/itvoQPv/Vu2ObF6QsL3Kp 8f1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=3tC0HyRGo+TeCO1Uejm9dy0E4q0AnrDJTBX1ZiDtTvA=; b=W/kb+dmp3ByPDyTbtVBZ+mLhOpYBtzBpNYAUWVNCr8qv4kuuFn5nfzAa7xVy0kKBUl rQkAQjxjFRWKLdo/D2tZXM8TwPL5oFIKWHZ8N5/bQ9L2suAKUvsOImDotUxYHI/bGMsZ 40exG01+sSUBFiqd5W/T/ihwilU3foGZfWXACWR0sfIDOvJ7UEHxaW5vtF4+sEe6gmM6 zKNwbyjDO83XbytOWVJK300sS+9E5m9hMrJaIeC1NoCNhE4NcuVkRveeKrAEUroTK/tO an33S4XHpVL2lFlIHBzsyp3A91zACm+Xt5ZiXaUB4/y4/YGKXDNUDA3dSqHl5EYWimNi yudA== X-Gm-Message-State: APf1xPCdCRT7+yUwxEPPiX/e0/7iy+RRoIuL7wHJJpx+sIC0rF/lhftx 6RBXQFJqUpRGRGlmVoqlUx5HaFIRPQ== X-Google-Smtp-Source: AH8x224cQKN1BTmjizlR8Mci1uPsQiaSz450bBxEQoKK1i8I1F5iHlRVCPoJTkl+WKm5LNGbIY0X2g== X-Received: by 10.223.192.72 with SMTP id c8mr1797196wrf.145.1518684409132; Thu, 15 Feb 2018 00:46:49 -0800 (PST) Received: from laranjeiro-vm.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 42sm3965186wrx.92.2018.02.15.00.46.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Feb 2018 00:46:48 -0800 (PST) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil , Yongseok Koh Date: Thu, 15 Feb 2018 09:47:28 +0100 Message-Id: <16c653c55e2144291ce92c9696ffaa829a70a028.1518684427.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> References: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> In-Reply-To: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> References: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH 2/2] net/mlx5: fix link status to use wait to complete X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Feb 2018 08:46:49 -0000 Wait to complete is present to let the application get a correct status when it requires it, it should not be ignored. Fixes: cb8faed7dde8 ("mlx5: support link status update") Cc: adrien.mazarguil@6wind.com Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_ethdev.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 0ce9f438a..112cc2a40 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -502,11 +502,12 @@ mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev) * * @param dev * Pointer to Ethernet device structure. - * @param wait_to_complete - * Wait for request completion (ignored). + * + * @return + * 0 on success, -1 otherwise. */ static int -mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev, int wait_to_complete) +mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev) { struct priv *priv = dev->data->dev_private; struct ethtool_cmd edata = { @@ -518,7 +519,6 @@ mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev, int wait_to_complete) /* priv_lock() is not taken to allow concurrent calls. */ - (void)wait_to_complete; if (priv_ifreq(priv, SIOCGIFFLAGS, &ifr)) { WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(errno)); return -1; @@ -568,11 +568,9 @@ mlx5_link_update_unlocked_gset(struct rte_eth_dev *dev, int wait_to_complete) * * @param dev * Pointer to Ethernet device structure. - * @param wait_to_complete - * Wait for request completion (ignored). */ static int -mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) +mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev) { struct priv *priv = dev->data->dev_private; struct ethtool_link_settings gcmd = { .cmd = ETHTOOL_GLINKSETTINGS }; @@ -580,7 +578,6 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete) struct rte_eth_link dev_link; uint64_t sc; - (void)wait_to_complete; if (priv_ifreq(priv, SIOCGIFFLAGS, &ifr)) { WARN("ioctl(SIOCGIFFLAGS) failed: %s", strerror(errno)); return -1; @@ -708,6 +705,9 @@ priv_link_stop(struct priv *priv) * Pointer to private structure. * @param wait_to_complete * Wait for request completion (ignored). + * + * @return + * 0 on success, negative value otherwise. */ int priv_link_update(struct priv *priv, int wait_to_complete) @@ -720,10 +720,16 @@ priv_link_update(struct priv *priv, int wait_to_complete) current_version >= KERNEL_VERSION(4, 9, 0) : 0; - if (use_new_api) - ret = mlx5_link_update_unlocked_gset(dev, wait_to_complete); - else - ret = mlx5_link_update_unlocked_gs(dev, wait_to_complete); + do { + if (use_new_api) + ret = mlx5_link_update_unlocked_gset(dev); + else + ret = mlx5_link_update_unlocked_gs(dev); + if (ret == -1) + return -EAGAIN; + } while(wait_to_complete && !ret); + if (ret == -EAGAIN) + return ret; /* If lsc interrupt is disabled, should always be ready for traffic. */ if (!dev->data->dev_conf.intr_conf.lsc) { priv_link_start(priv); @@ -755,10 +761,11 @@ int priv_force_link_status_change(struct priv *priv, int status) { int try = 0; + int ret = 0; while (try < MLX5_MAX_LINK_QUERY_ATTEMPTS) { - priv_link_update(priv, 0); - if (priv->dev->data->dev_link.link_status == status) + ret = priv_link_update(priv, 0); + if (!ret && priv->dev->data->dev_link.link_status == status) return 0; try++; sleep(1); -- 2.11.0