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 6137643BEA; Mon, 26 Feb 2024 13:04:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DC31C40271; Mon, 26 Feb 2024 13:04:17 +0100 (CET) Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2084.outbound.protection.outlook.com [40.107.100.84]) by mails.dpdk.org (Postfix) with ESMTP id F214B40144 for ; Mon, 26 Feb 2024 13:04:16 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jr5Ar2Jziedf8XZjBnUfn3ctiCmSY6R1N5w6WqABmrZo4z47zCt8gmdWiCUCBJtnxkPOfqZGNAo5Xp/5QI80/+RD6fLVeUHdzzEsMcxHplPcsJZyM0fIjVWhP6Q+4RG4MQC1Xtmo+PL778/IQ2UEFOeyuek+IqzfpQSxr8n+5Dlyn4XRxsFEEjM7FlRKnxIJvivsB2gMEgXsGsL14Wqum8o9lNZ/xbtYFKq9a3UIPUZ8/1JjClFxGR9W/VkGNUARyF47SUDhVfsY7lcZwhVe1BlwKAmslV1w4G41W7cHtD37GCmf/qVxsDGsxMgjsETeroueIEeXKjUkuDGosVmDuw== 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=xx1DZXVL1HQaQYz29cbEslkKX93rFxkohLsd8c+vnpk=; b=g1AsH41NWr/GNwW2hC2JSszSz2a+oQ/93m5oSYzj2BYqkz+rJu5vizPNlr9ldV8roGJh6xUkZLdLqf+pRDBxvh05VqODq2IH+U/AxQ1qj4ZpPaxSVzCKFD1WTfeg/Gx43x7xkxRk5X2nMgxw2PWICHDBENF7ALGWHVnesNDkJHqV4amE95t1nDvsgifgmjQ77QcKEAHjWqYtADvQlzdj7tD66yWEJc4oa5oH5IynLRUko9dGhbxykIYvbSgVmm4oudYL8Upn1UVYIoYLX+Ai3Ozkixt85XO8oIhYxfR4wAMXxZ83biSeZqclYzLalotRFTs/PLePfkgsOaZutTlpqA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=xx1DZXVL1HQaQYz29cbEslkKX93rFxkohLsd8c+vnpk=; b=jyf815nJlOQuAcx+dRaSt3U9JGkCChz8iv3CrFaMK+zhDSdD6suB8xf/Gm8sj5cO57yuElhTmPkf09CAj3Ghpp9DNMSMfO541xybf/W2LkFJ4KYbcSN53oVFFQqt8+x1QXPUnCJX98le19r+Q44ND3MLy/EO/ugM7BQqVCF0g/l9DRHwbYzCf+BfQrks4/ooY3uW6OuJx7Pr49K10h5QVQg/LhK+zpPShZPo+Fy2MGEGOG+0JYaZoQYcLcffeMoMx80dBsYwtTTEHKzK7fKeiZEgoZglghUPdvLwh+18x69dBfx10TH429qk1UeQkfd8REZaVQUP4ac0gPf3HjMKqQ== Received: from DM6PR03CA0102.namprd03.prod.outlook.com (2603:10b6:5:333::35) by MN2PR12MB4270.namprd12.prod.outlook.com (2603:10b6:208:1d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Mon, 26 Feb 2024 12:04:13 +0000 Received: from DS2PEPF00003440.namprd02.prod.outlook.com (2603:10b6:5:333:cafe::bf) by DM6PR03CA0102.outlook.office365.com (2603:10b6:5:333::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.49 via Frontend Transport; Mon, 26 Feb 2024 12:04:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS2PEPF00003440.mail.protection.outlook.com (10.167.18.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.25 via Frontend Transport; Mon, 26 Feb 2024 12:04:12 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Mon, 26 Feb 2024 04:03:59 -0800 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Mon, 26 Feb 2024 04:03:54 -0800 From: Haifei Luo To: , , , , Dariusz Sosnowski , Suanming Mou CC: , , , , Subject: [PATCH] net/mlx5: link status change for bonding cases Date: Mon, 26 Feb 2024 14:03:41 +0200 Message-ID: <20240226120341.175710-1-haifeil@nvidia.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003440:EE_|MN2PR12MB4270:EE_ X-MS-Office365-Filtering-Correlation-Id: cbb4ba03-3d82-4381-ada7-08dc36c30c11 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +XlxGL1QJha+wt2U6JsRsnNBbA22CctzIQ5sHgMgPB31geAtIY3i3lHQ7BulYabwWhSiKEOSKoyeP+MqC4LtTFihWBtZ/I0aiIjbtmEIxWReczfW6+zwjk8AAcv61BUqDgQyqBNhY/sEe0ICpKUsDuu51Q408JLtU92+4mhFPnoaB1iDNX2X09WB/axDyfFyhps3hdoLjwjhd/Na7t5eSVH61Nsz+QD18GDTIWWZJbFAmUGYGn6N65nLxAFoLXaRnEaBtYDy2Zg/dYEsMJ4ikF4uTyGQyMRzkBIuGJyNX4ZrQCkwJlv8q1MSfY9ybzRX/+776+RsK7jAMiQ79QjbbD4k+Tu6h36vTrRcUYLQv26/SctRtb1KWwiet/LvbG9vMV9Ai2BrCpDFTrnztKtY3wfKkeFomdZPbLhzcBl2RBBkf5fVJ6KMSNHRTl9EOBtXntsnd6KUPZ53138bdNWAoLDA4NC5GAhQSU0nm3znG/E0EAuP75p/avmQnEEWcnlRPxZyGcGPLg5Pw+VklvHjQkHNXZyyjRaaxjEyM/bNoaMEc1VvR7j1X9xF1C1fmtIdoM8jhvcGRj0DfvWHHAwvhM/hNFVA/Rb6gQv6TjpDp56SHHpTYDlAj5bnSMWo3+BBgWbbsiRUh891v9z0YeZLLXQluy8xJd7QKtcGN3VDpCNWxGRQUMpXuBTebEZ89zuT0qDIHuGVH0VTsbqdSbu9uMKU0kcmJIlchEOh+C0pMjjVyTsi96wnDvJ5nVw5Af5t X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(230273577357003)(36860700004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2024 12:04:12.6275 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbb4ba03-3d82-4381-ada7-08dc36c30c11 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003440.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4270 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 current implementation of mlx5_dev_interrupt_nl_cb routine first compares if event netlink if_index belongs to the same device. This is not fully correct for the bonding device since the bonding master and slave interface netlink events indicate the bonding link status change as well. Add check for if_index is related to the bonding's master/slave. The following step is that it compares the device link status before and after the netlink event handling. There are also the bonding specifics and it should compare the link status of the bonding master to detect the actual status change. Signed-off-by: Haifei Luo --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 55 ++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index dd5a0c5..a9b94f8 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -768,6 +768,47 @@ struct ethtool_link_settings { } } +static bool +mlx5_dev_nl_ifindex_verify(uint32_t if_index, struct mlx5_priv *priv) +{ + struct mlx5_bond_info *bond = &priv->sh->bond; + int i; + + if (bond->n_port == 0) + return (if_index == priv->if_index); + + if (if_index == bond->ifindex) + return true; + for (i = 0; i < bond->n_port; i++) { + if (i >= MLX5_BOND_MAX_PORTS) + return false; + if (if_index == bond->ports[i].ifindex) + return true; + } + + return false; +} + +static void +mlx5_link_update_bond(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_bond_info *bond = &priv->sh->bond; + struct ifreq ifr = (struct ifreq) { + .ifr_flags = 0, + }; + int ret; + + ret = mlx5_ifreq_by_ifname(bond->ifname, SIOCGIFFLAGS, &ifr); + if (ret) { + DRV_LOG(WARNING, "ifname %s ioctl(SIOCGIFFLAGS) failed: %s", + bond->ifname, strerror(rte_errno)); + return; + } + dev->data->dev_link.link_status = + ((ifr.ifr_flags & IFF_UP) && (ifr.ifr_flags & IFF_RUNNING)); +} + static void mlx5_dev_interrupt_nl_cb(struct nlmsghdr *hdr, void *cb_arg) { @@ -790,16 +831,20 @@ struct ethtool_link_settings { !dev->data->dev_conf.intr_conf.lsc) break; priv = dev->data->dev_private; - if (priv->if_index == if_index) { + if (mlx5_dev_nl_ifindex_verify(if_index, priv)) { /* Block logical LSC events. */ uint16_t prev_status = dev->data->dev_link.link_status; - if (mlx5_link_update(dev, 0) < 0) + if (mlx5_link_update(dev, 0) < 0) { DRV_LOG(ERR, "Failed to update link status: %s", rte_strerror(rte_errno)); - else if (prev_status != dev->data->dev_link.link_status) - rte_eth_dev_callback_process - (dev, RTE_ETH_EVENT_INTR_LSC, NULL); + } else { + if (priv->sh->bond.n_port) + mlx5_link_update_bond(dev); + if (prev_status != dev->data->dev_link.link_status) + rte_eth_dev_callback_process + (dev, RTE_ETH_EVENT_INTR_LSC, NULL); + } break; } } -- 1.8.3.1