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 BD505A00C3; Tue, 29 Nov 2022 15:50:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4216C42D29; Tue, 29 Nov 2022 15:50:38 +0100 (CET) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by mails.dpdk.org (Postfix) with ESMTP id 948B942D1C; Tue, 29 Nov 2022 15:50:33 +0100 (CET) Received: by mail-qk1-f170.google.com with SMTP id x18so9883464qki.4; Tue, 29 Nov 2022 06:50:33 -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=wlKSN034u7j20xmx/5+s+45ybNDOFXAMgBd7/exhE/A=; b=hIxV+bY83sl6FhsezWKLAwUkpntlj9FfEFaMEJR5GFKKdIRDFfZFeKkk8POrWuhNCW yUVQj9Q9Vwzk8YfEMrkaJhhx5eH24eupnslQCFRoT0tLS1AdcZdhE6G8D4RkUKq8o4gp XM7TfUgJ1LiDTDCm4ZD1A3sV5KgRwdr2Euj+JQLcNDwC3m6DN809CabsF2buoWL89yYc 957T/e2GaZulEAyI99p2m6/3WYt/q6gbjnkrbra0klv/vQX0glBEBhvZ4zmd2xrNJ7ZG rQRbXPUxPOtaQdQrdNodb2clvvNTUsSFMO4wBqeYhEcKvjAuv6nXfTytic9Ye48tiNQ2 8lOg== 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=wlKSN034u7j20xmx/5+s+45ybNDOFXAMgBd7/exhE/A=; b=R/30/J8TbXMRt9Yq0zwgWw4YzBAR0Q5DrMBYOI2Je8SBvgJPD5t1nJaES++Cdw4yxW GGQQwBSSdg0OakNMp23B3qEJ0OTwjxK7BNpRt7Tlasm7ReaNhOVDNs8hqWGoow4ahX1l iqbfMug8yoD54JZwHHY1/SvvGbZbk3rerNMxDL1jGafpfqOLQl/MGJVPU6N8GOd2IJ3I Miku76aycUbVghKB6xXokSXWKQdIbjO8oQeheUdy6S3syyTq/i4eiIZpnGKrzauVnm2r UMCpZeY5iAvcFNQKlejCCOGd5wzrelgqGVNJhw8lFpzTldkMhChkievzIT5SjOQHPcad qENw== X-Gm-Message-State: ANoB5plfh9V2VxhOtn3axpBlJmJy5eEkcq5EfQ+nbacepjR5gzQdn0hc YC1bzSkkqhhAPBskgKS7dgkYcY/3hCQ= X-Google-Smtp-Source: AA0mqf4u+uy46/7/O9BFtsKo3iDzaj4Ck9YFTu6lzX2PLiTZ7hSVu3haLIhxONF62Hmyeqq7DN/a6A== X-Received: by 2002:a37:43d4:0:b0:6fb:982e:a685 with SMTP id q203-20020a3743d4000000b006fb982ea685mr50594188qka.347.1669733433003; Tue, 29 Nov 2022 06:50:33 -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 y14-20020a05620a44ce00b006fb7c42e73asm11068836qkp.21.2022.11.29.06.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 06:50:32 -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 v3 4/5] failsafe: use public APIs in fs_link_update Date: Tue, 29 Nov 2022 09:48:32 -0500 Message-Id: <20221129144832.2750-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: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 | 38 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index d357e1bc83..7bd223af37 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -820,34 +820,32 @@ 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