From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6729A00C3 for ; Tue, 29 Nov 2022 16:25:37 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF78642D2A; Tue, 29 Nov 2022 16:25:34 +0100 (CET) Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) by mails.dpdk.org (Postfix) with ESMTP id 50B1C42C4D; Tue, 29 Nov 2022 16:25:31 +0100 (CET) Received: by mail-qv1-f47.google.com with SMTP id u10so4320350qvp.4; Tue, 29 Nov 2022 07:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LPzMifYhSK+51gHRPynA/rltLQVr8QrHifNEBwjvSxU=; b=TG4fA4vNBmuk99df17qGcPuYp+JH4smPaBxL8uqW3FENCmvtpRmy2aS02nZ4FXj2q6 5jNoCSuyOtr9AXN9nnTQefeGSSBYH+SK0lRRr7M48rIQwoUGdZDBWelWUjUMs0umVxZC XhxluGnYiTMDPDnp+ANcJTJpoiLZH+uNrq20Nf3ZZQXwd83qkezV3Aa4XWnz1yo6dvgg aBNLiUsRUVSR5nqdfJ8dzOtN7q1Nln9DESmjk+GNpWKQtZM2S/hZ9Eb25+HzDriRFElc gELaOx94HCVqWylOA+QlyPa1dWkGpsZyMab3Zii1TfIR773vCSsyv5UQTWAXgS9TOyVr d2Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LPzMifYhSK+51gHRPynA/rltLQVr8QrHifNEBwjvSxU=; b=MXew5P6YaUMfkEfnNsKOpE/+U5sDKYX5YKJMxkXLNlrzrq9AiC8W1X3ZNQFkaaJyeg A9wVHcvBJSQgTW48Mkl8iTcNxlrwEEd3BTFY+Rw7pnHzUYyEmFajKkP5ceyshzgOlHZC C/5Lj16gbh6mxZpWaUgJLdcED79EGulNspH1kPxtuJNiVELwDFg+BXG+F03nGYu2l5XS ZEvajx9ZJBG8So/38ELN+GKP+47SpXz6lrI494Clmfvyqbafwz48QY72g3hPDz5TUVD1 fE+rqgPNbW3EOd/JN9pHZzrogmpMKpZmM6WtoxZ6dyUiiPsIehy8SjcO1AWVhzPbivXz 5AGA== X-Gm-Message-State: ANoB5pmkeIQ6d3iv0JrkEjTxyFi1/kyYk0j4KmraSSsESqhvJfR2EiWQ kbS6UCOOqAXHVsjQpd+3JCE= X-Google-Smtp-Source: AA0mqf5sM8U2ozl/Ka4YpxnCigmA9pnBzevRwizXxtwO/FZ4NHH3Rhce7noXkBWG5yAMjrY3aSjVSw== X-Received: by 2002:a05:6214:5693:b0:4bb:59c1:3ded with SMTP id lm19-20020a056214569300b004bb59c13dedmr37111680qvb.68.1669735530926; Tue, 29 Nov 2022 07:25:30 -0800 (PST) Received: from ubuntu.home (bras-base-hullpq2034w-grc-26-74-12-221-152.dsl.bell.ca. [74.12.221.152]) by smtp.gmail.com with ESMTPSA id r2-20020ae9d602000000b006fb11eee465sm10663412qkk.64.2022.11.29.07.25.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 07:25:30 -0800 (PST) From: Luc Pelletier To: grive@u256.net Cc: dev@dpdk.org, stephen@networkplumber.org, konstantin.ananyev@huawei.com, Luc Pelletier , Matan Azrad , stable@dpdk.org Subject: [PATCH v4 4/5] failsafe: use public APIs in fs_link_update Date: Tue, 29 Nov 2022 10:25:16 -0500 Message-Id: <20221129152516.4513-5-lucp.at.work@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221110163410.12734-1-lucp.at.work@gmail.com> References: <20221110163410.12734-1-lucp.at.work@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org The link_update function pointer is called directly on a sub-device, via its rte_eth_dev structure. In addition, it assumes that if link_update returns a value other than 0 or -1, an error occurred. That's not accurate. For example, the mlx5 PMD returns a positive value to indicate that the link status was updated. This results in fs_link_update failing when it really should have succeeded. The code now uses the public APIs rte_eth_link_get and rte_eth_link_get_nowait to query the link status of each sub-device. It also uses rte_eth_linkstatus_set to set the link status of the failsafe device. Fixes: ae80146c5a1b ("net/failsafe: fix removed device handling") Cc: Matan Azrad Cc: stable@dpdk.org Signed-off-by: Luc Pelletier --- drivers/net/failsafe/failsafe_ops.c | 37 +++++++++++++---------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index d357e1bc83..b66dfa269b 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -820,34 +820,31 @@ fs_link_update(struct rte_eth_dev *dev, { struct sub_device *sdev; uint8_t i; - int ret; + int ret = -1; + int sdev_link_ret; + struct rte_eth_link link_info; fs_lock(dev, 0); FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { - DEBUG("Calling link_update on sub_device %d", i); - ret = (SUBOPS(sdev, link_update))(ETH(sdev), wait_to_complete); - if (ret && ret != -1 && sdev->remove == 0 && - rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) { - ERROR("Link update failed for sub_device %d with error %d", - i, ret); - fs_unlock(dev, 0); - return ret; + DEBUG("Calling rte_eth_link_get on sub_device %d", i); + if (wait_to_complete) { + sdev_link_ret = rte_eth_link_get(PORT_ID(sdev), &link_info); + } else { + sdev_link_ret = rte_eth_link_get_nowait(PORT_ID(sdev), + &link_info); } - } - if (TX_SUBDEV(dev)) { - struct rte_eth_link *l1; - struct rte_eth_link *l2; - l1 = &dev->data->dev_link; - l2 = Ð(TX_SUBDEV(dev))->data->dev_link; - if (memcmp(l1, l2, sizeof(*l1))) { - *l1 = *l2; - fs_unlock(dev, 0); - return 0; + if (likely(sdev_link_ret == 0)) { + if (TX_SUBDEV(dev) == sdev) + ret = rte_eth_linkstatus_set(dev, &link_info); + } else if (sdev->remove == 0 && + rte_eth_dev_is_removed(PORT_ID(sdev)) == 0) { + ERROR("Link get failed for sub_device %d with error %d", + i, sdev_link_ret); } } fs_unlock(dev, 0); - return -1; + return ret; } static int -- 2.38.1