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 0A983A034F for ; Wed, 10 Nov 2021 07:56:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 03F84410FE; Wed, 10 Nov 2021 07:56:34 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) by mails.dpdk.org (Postfix) with ESMTP id 160FC4014D for ; Wed, 10 Nov 2021 07:56:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYGg6SqAqXMM/5Av010QQqQugQ8XO0esryExMZbm/Dxqr9HRwn40DQIKsV3y2G6AW4Wa2NvxZCFrQgNXj1PEeWlzj8XksyK2wzvWyKb8Zbp/Ee5jHZPVFYdDtIIetNy16h1nDD7GWe598f1pVPPw/SyZBOLWiGaBgrxFq6Oap24QLP6ENcPjqBPQUDjq5APL1Ark/Bqwy1biUdOG8yNcxvDmU2pjlB8ibG+fc96KtUJAye3T8v+SotVUL9oc3X4K01StVidu5gfzauPOrJapVl6wQhfa5PjE9bHaccybBFpDSxfGDp83Kc9O/zaguMdbfIN+hKU8rP9KIBLYu1ao3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7dNjPQqDMNjbbRumHkuoOiBs5TEd3FQPkSj6fwWFHt0=; b=FyacQ0niBnX5KKxmbQ/BcPteWYzvwgBy0h8JvVWF3N6JrBcGMjol2xkJp2qSUn48yS2IDKrhpJBetiRxYuuEKvLPybNZEJssa3Yzr1lZ8gEbzGwBpG4SdpIGpN/mjWDORYTsFLrQ7evFQAGe5LmcHobZhcNn/ra3A54P//6iZbNObYfqRBzUmf+izbb+a0mk2+sEr5ybvEGXIjMRFR87s6CBQtpzI7EnfN5+eckicU0LXg0MS2IZdc5cAkKXMpilFsu0goYxTTse9w0YpVhgs2pwWGX6e3x2SBR2+hA0QrvlH10ywIeL2WMnIQ5mdsqGKr4tPeKgmfjkt4nA4xz7uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7dNjPQqDMNjbbRumHkuoOiBs5TEd3FQPkSj6fwWFHt0=; b=ZERzd/9J+VLsDZqHaqJY63RRQzSp1EBjOh1iZWWpUd7R1pyFl8rMaDAAKNxpxqMUDYuqGdQHoLDhxS7dBQhWuwDmGK4fu0qKeoyQdEdYpvwVvCYK3Llkx5wM+CxH/bJJxpASg3SgCEFr2sllGw4Bzoo5HmcsplP0Nf0UcX41PKfsa9X1p58mVqURCJtpzz3bhzz/2NBOEyTej225OafOrRH4qz3CI2idz8pusMcljdI5RGzXBQ5QxcR/CsmQ7JbCD1nfspye7ejXFxLBp7hAU4WMe7HjmWb0FaNYH/pNuaclL12fTX986Qouao+laTO8OZf0zi5xo9LCH2qQZkfhAQ== Received: from DM6PR08CA0030.namprd08.prod.outlook.com (2603:10b6:5:80::43) by SN1PR12MB2480.namprd12.prod.outlook.com (2603:10b6:802:22::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Wed, 10 Nov 2021 06:56:30 +0000 Received: from DM6NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:5:80:cafe::ea) by DM6PR08CA0030.outlook.office365.com (2603:10b6:5:80::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Wed, 10 Nov 2021 06:56:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT032.mail.protection.outlook.com (10.13.173.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Wed, 10 Nov 2021 06:56:29 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 10 Nov 2021 06:56:26 +0000 From: Xueming Li To: Ivan Ilchenko CC: Luca Boccassi , Andrew Rybchenko , Maxime Coquelin , dpdk stable Date: Wed, 10 Nov 2021 14:31:41 +0800 Message-ID: <20211110063216.2744012-218-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211110063216.2744012-1-xuemingl@nvidia.com> References: <20211110063216.2744012-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 25db3371-35e9-41e4-69a1-08d9a41738fa X-MS-TrafficTypeDiagnostic: SN1PR12MB2480: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DnQAoS6gSCW7ImQY/hlOyvFEWA5P6UCHLPzB6OkEav5L/U3hG0GFcm34/6guwm6peaOSMKy1IIzdabLHhZeyeXGibSzLGL/03Qd+pNaez/QU/IuWt0IwSmfwhBMtJm7BWtw3bXvR/9Fg5oaPERrxKQinhMrtmfcEWMJRKjDcnCvquwdJEcTw+Xksik4mMBdMUZ8udGiDs0IbXNmPH9G+dCqojMSa1/5CBRockgJVERkpx4EjofYpRXSbHU0mmc0a559QWi79shnDsJtcqoZ2iUxqFsaO98VKuv4tLFvg92p/jqVNcJLxDveNBahuHgk/jCZOuMC+Tl0m6+4j8gjR5f5gt8vcG25yL77FBiySltFRfXMsKUurGBeffhmvf0d6BfDt8Jo+eDz130OloqpsiEsgtZel7j+83Fka7jdNTNkXznG+icP5oT7+ShAo5774PrVEaCJsm+3EYvGLLV9IapvWpME4PcTBHNerS4ttYUSyekWypHhi6rW7NkJlm/D9dGjU4vvWTT4hTBA+YGdXxLHIsMGpCjEvmZyCR0KMy66imH2iCzOXNpYVtfFDuWFIG5X/+DUqoNoS9+YoD2wKqww5/78WImuuI4PT/9r5ESsbj6m3E5Mqt3y1Ef1XdWiMiyPDiaYxQYYKBn0hDDxa8DAUE/tmW0D4u4prQFrzb6Qk35KyMPuqD5c898zkNr9SrC8DyJNuAsYfy+4sx8pjL5s8yUTr8dxd44IbuiUX0bi1tfnHSC+ouTsnxNX+dGWedOt1xGDhwJ1XR9l0w49kwBFZ2EMt4b+M82FDbwbaka0JtvtY+cdSlLcq6hw9y/dMXYT/l1PaQ1U+eXDrZN0LzQ== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(5660300002)(55016002)(8936002)(26005)(36860700001)(4001150100001)(2906002)(7696005)(36756003)(316002)(53546011)(508600001)(4326008)(6916009)(86362001)(186003)(16526019)(47076005)(54906003)(82310400003)(15650500001)(8676002)(356005)(70586007)(6666004)(6286002)(966005)(7636003)(1076003)(426003)(70206006)(336012)(83380400001)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2021 06:56:29.5674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 25db3371-35e9-41e4-69a1-08d9a41738fa X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB2480 Subject: [dpdk-stable] patch 'net/virtio: fix link update in speed feature' has been queued to stable release 20.11.4 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 Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 11/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/33dcf11cc953ddf9add582cc9f4356474657940f Thanks. Xueming Li --- >From 33dcf11cc953ddf9add582cc9f4356474657940f Mon Sep 17 00:00:00 2001 From: Ivan Ilchenko Date: Fri, 22 Oct 2021 16:17:54 +0300 Subject: [PATCH] net/virtio: fix link update in speed feature Cc: Xueming Li [ upstream commit 3c3c54cfa6b38b48e9b817653fde32631aec024d ] Link update callback reports speed/duplex based on data filled on device initialization. This is wrong in case of VIRTIO_NET_F_SPEED_DUPLEX is negotiated since link could be down at this time. Fix this function to actually update the HW data in this case with respect to the fact that specifying speed via devarg is a highest priority. Fixes: 1357b4b36246 ("net/virtio: support Virtio link speed feature") Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_ethdev.c | 47 +++++++++++++++++++++--------- drivers/net/virtio/virtio_pci.h | 5 ++++ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index afa9fb591f..be6a687d54 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1745,6 +1745,32 @@ virtio_configure_intr(struct rte_eth_dev *dev) return 0; } + +static void +virtio_get_speed_duplex(struct rte_eth_dev *eth_dev, + struct rte_eth_link *link) +{ + struct virtio_hw *hw = eth_dev->data->dev_private; + struct virtio_net_config *config; + struct virtio_net_config local_config; + + config = &local_config; + vtpci_read_dev_config(hw, + offsetof(struct virtio_net_config, speed), + &config->speed, sizeof(config->speed)); + vtpci_read_dev_config(hw, + offsetof(struct virtio_net_config, duplex), + &config->duplex, sizeof(config->duplex)); + hw->speed = config->speed; + hw->duplex = config->duplex; + if (link != NULL) { + link->link_duplex = hw->duplex; + link->link_speed = hw->speed; + } + PMD_INIT_LOG(DEBUG, "link speed = %d, duplex = %d", + hw->speed, hw->duplex); +} + #define DUPLEX_UNKNOWN 0xff /* reset device and renegotiate features if needed */ static int @@ -1803,19 +1829,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); - if (hw->speed == ETH_SPEED_NUM_UNKNOWN) { - if (vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) { - config = &local_config; - vtpci_read_dev_config(hw, - offsetof(struct virtio_net_config, speed), - &config->speed, sizeof(config->speed)); - vtpci_read_dev_config(hw, - offsetof(struct virtio_net_config, duplex), - &config->duplex, sizeof(config->duplex)); - hw->speed = config->speed; - hw->duplex = config->duplex; - } - } + hw->get_speed_via_feat = hw->speed == ETH_SPEED_NUM_UNKNOWN && + vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX); + if (hw->get_speed_via_feat) + virtio_get_speed_duplex(eth_dev, NULL); if (hw->duplex == DUPLEX_UNKNOWN) hw->duplex = ETH_LINK_FULL_DUPLEX; PMD_INIT_LOG(DEBUG, "link speed = %d, duplex = %d", @@ -2688,11 +2705,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet dev->data->port_id); } else { link.link_status = ETH_LINK_UP; + if (hw->get_speed_via_feat) + virtio_get_speed_duplex(dev, &link); PMD_INIT_LOG(DEBUG, "Port %d is up", dev->data->port_id); } } else { link.link_status = ETH_LINK_UP; + if (hw->get_speed_via_feat) + virtio_get_speed_duplex(dev, &link); } return rte_eth_linkstatus_set(dev, &link); diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index f56d3e8bb7..a1696bce1a 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -264,6 +264,11 @@ struct virtio_hw { bool has_rx_offload; uint16_t port_id; uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; + /* + * Speed is specified via 'speed' devarg or + * negotiated via VIRTIO_NET_F_SPEED_DUPLEX + */ + bool get_speed_via_feat; uint32_t notify_off_multiplier; uint32_t speed; /* link speed in MB */ uint8_t duplex; -- 2.33.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-11-10 14:17:11.484346588 +0800 +++ 0217-net-virtio-fix-link-update-in-speed-feature.patch 2021-11-10 14:17:02.030744782 +0800 @@ -1 +1 @@ -From 3c3c54cfa6b38b48e9b817653fde32631aec024d Mon Sep 17 00:00:00 2001 +From 33dcf11cc953ddf9add582cc9f4356474657940f Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 3c3c54cfa6b38b48e9b817653fde32631aec024d ] @@ -14 +16,0 @@ -Cc: stable@dpdk.org @@ -20,3 +22,3 @@ - drivers/net/virtio/virtio.h | 5 ++++ - drivers/net/virtio/virtio_ethdev.c | 46 +++++++++++++++++++++--------- - 2 files changed, 38 insertions(+), 13 deletions(-) + drivers/net/virtio/virtio_ethdev.c | 47 +++++++++++++++++++++--------- + drivers/net/virtio/virtio_pci.h | 5 ++++ + 2 files changed, 39 insertions(+), 13 deletions(-) @@ -24,16 +25,0 @@ -diff --git a/drivers/net/virtio/virtio.h b/drivers/net/virtio/virtio.h -index 9a2ab2caea..5c8f71a44d 100644 ---- a/drivers/net/virtio/virtio.h -+++ b/drivers/net/virtio/virtio.h -@@ -203,6 +203,11 @@ struct virtio_hw { - uint8_t opened; - uint16_t port_id; - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; -+ /* -+ * Speed is specified via 'speed' devarg or -+ * negotiated via VIRTIO_NET_F_SPEED_DUPLEX -+ */ -+ bool get_speed_via_feat; - uint32_t speed; /* link speed in MB */ - uint8_t duplex; - uint8_t intr_lsc; @@ -41 +27 @@ -index 4570bec057..c2588369b2 100644 +index afa9fb591f..be6a687d54 100644 @@ -44 +30,2 @@ -@@ -1843,6 +1843,31 @@ virtio_configure_intr(struct rte_eth_dev *dev) +@@ -1745,6 +1745,32 @@ virtio_configure_intr(struct rte_eth_dev *dev) + @@ -47 +34 @@ - ++ @@ -57 +44 @@ -+ virtio_read_dev_config(hw, ++ vtpci_read_dev_config(hw, @@ -60 +47 @@ -+ virtio_read_dev_config(hw, ++ vtpci_read_dev_config(hw, @@ -73,4 +60,4 @@ - static uint64_t - ethdev_to_virtio_rss_offloads(uint64_t ethdev_hash_types) - { -@@ -2225,19 +2250,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) + #define DUPLEX_UNKNOWN 0xff + /* reset device and renegotiate features if needed */ + static int +@@ -1803,19 +1829,10 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) @@ -80,2 +67,2 @@ -- if (hw->speed == RTE_ETH_SPEED_NUM_UNKNOWN) { -- if (virtio_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) { +- if (hw->speed == ETH_SPEED_NUM_UNKNOWN) { +- if (vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) { @@ -83 +70 @@ -- virtio_read_dev_config(hw, +- vtpci_read_dev_config(hw, @@ -86 +73 @@ -- virtio_read_dev_config(hw, +- vtpci_read_dev_config(hw, @@ -93,2 +80,2 @@ -+ hw->get_speed_via_feat = hw->speed == RTE_ETH_SPEED_NUM_UNKNOWN && -+ virtio_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX); ++ hw->get_speed_via_feat = hw->speed == ETH_SPEED_NUM_UNKNOWN && ++ vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX); @@ -98 +85 @@ - hw->duplex = RTE_ETH_LINK_FULL_DUPLEX; + hw->duplex = ETH_LINK_FULL_DUPLEX; @@ -100 +87 @@ -@@ -2964,11 +2980,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet +@@ -2688,11 +2705,15 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet @@ -103 +90 @@ - link.link_status = RTE_ETH_LINK_UP; + link.link_status = ETH_LINK_UP; @@ -110 +97 @@ - link.link_status = RTE_ETH_LINK_UP; + link.link_status = ETH_LINK_UP; @@ -115,0 +103,16 @@ +diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h +index f56d3e8bb7..a1696bce1a 100644 +--- a/drivers/net/virtio/virtio_pci.h ++++ b/drivers/net/virtio/virtio_pci.h +@@ -264,6 +264,11 @@ struct virtio_hw { + bool has_rx_offload; + uint16_t port_id; + uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; ++ /* ++ * Speed is specified via 'speed' devarg or ++ * negotiated via VIRTIO_NET_F_SPEED_DUPLEX ++ */ ++ bool get_speed_via_feat; + uint32_t notify_off_multiplier; + uint32_t speed; /* link speed in MB */ + uint8_t duplex;